IPriceAndFeeCalculator

Interface for the unit price provider

Functions

setInitialPrice

Set the initial price state for the vault

function setInitialPrice(address vault, uint128 price, uint32 timestamp) external;

Parameters

Name
Type
Description

vault

address

Address of the vault

price

uint128

New unit price

timestamp

uint32

Timestamp when the price was measured

setThresholds

Set vault thresholds

function setThresholds(
    address vault,
    uint16 minPriceToleranceRatio,
    uint16 maxPriceToleranceRatio,
    uint16 minUpdateIntervalMinutes,
    uint8 maxPriceAge,
    uint8 maxUpdateDelayDays
) external;

Parameters

Name
Type
Description

vault

address

Address of the vault

minPriceToleranceRatio

uint16

Minimum ratio (of a price decrease) in basis points

maxPriceToleranceRatio

uint16

Maximum ratio (of a price increase) in basis points

minUpdateIntervalMinutes

uint16

The minimum interval between updates in minutes

maxPriceAge

uint8

Max delay between when a vault was priced and when the price is acceptable

maxUpdateDelayDays

uint8

Max delay between two price updates

setUnitPrice

Set the unit price for the vault in numeraire terms

function setUnitPrice(address vault, uint128 price, uint32 timestamp) external;

Parameters

Name
Type
Description

vault

address

Address of the vault

price

uint128

New unit price

timestamp

uint32

Timestamp when the price was measured

pauseVault

Pause the vault

function pauseVault(address vault) external;

Parameters

Name
Type
Description

vault

address

Address of the vault

unpauseVault

Unpause the vault

MUST revert if price or timestamp don't exactly match last update

function unpauseVault(address vault, uint128 price, uint32 timestamp) external;

Parameters

Name
Type
Description

vault

address

Address of the vault

price

uint128

Expected price of the last update

timestamp

uint32

Expected timestamp of the last update

resetHighestPrice

Resets the highest price for a vault to the current price

function resetHighestPrice(address vault) external;

Parameters

Name
Type
Description

vault

address

Address of the vault

convertUnitsToToken

Convert units to token amount

function convertUnitsToToken(address vault, IERC20 token, uint256 unitsAmount)
    external
    view
    returns (uint256 tokenAmount);

Parameters

Name
Type
Description

vault

address

Address of the vault

token

IERC20

Address of the token

unitsAmount

uint256

Amount of units

Returns

Name
Type
Description

tokenAmount

uint256

Amount of tokens

convertUnitsToTokenIfActive

Convert units to token amount if vault is not paused

MUST revert if vault is paused

function convertUnitsToTokenIfActive(address vault, IERC20 token, uint256 unitsAmount, Math.Rounding rounding)
    external
    view
    returns (uint256 tokenAmount);

Parameters

Name
Type
Description

vault

address

Address of the vault

token

IERC20

Address of the token

unitsAmount

uint256

Amount of units

rounding

Math.Rounding

The rounding mode

Returns

Name
Type
Description

tokenAmount

uint256

Amount of tokens

convertTokenToUnits

Convert token amount to units

function convertTokenToUnits(address vault, IERC20 token, uint256 tokenAmount)
    external
    view
    returns (uint256 unitsAmount);

Parameters

Name
Type
Description

vault

address

Address of the vault

token

IERC20

Address of the token

tokenAmount

uint256

Amount of tokens

Returns

Name
Type
Description

unitsAmount

uint256

Amount of units

convertTokenToUnitsIfActive

Convert token amount to units if vault is not paused

MUST revert if vault is paused

function convertTokenToUnitsIfActive(address vault, IERC20 token, uint256 tokenAmount, Math.Rounding rounding)
    external
    view
    returns (uint256 unitsAmount);

Parameters

Name
Type
Description

vault

address

Address of the vault

token

IERC20

Address of the token

tokenAmount

uint256

Amount of tokens

rounding

Math.Rounding

The rounding mode

Returns

Name
Type
Description

unitsAmount

uint256

Amount of units

convertUnitsToNumeraire

Convert units to numeraire token amount

function convertUnitsToNumeraire(address vault, uint256 unitsAmount) external view returns (uint256 numeraireAmount);

Parameters

Name
Type
Description

vault

address

Address of the vault

unitsAmount

uint256

Amount of units

Returns

Name
Type
Description

numeraireAmount

uint256

Amount of numeraire

getVaultState

Return the state of the vault

function getVaultState(address vault) external view returns (VaultPriceState memory, VaultAccruals memory);

Parameters

Name
Type
Description

vault

address

Address of the vault

Returns

Name
Type
Description

<none>

VaultPriceState

vaultPriceState The price state of the vault

<none>

VaultAccruals

vaultAccruals The accruals state of the vault

getVaultsPriceAge

Returns the age of the last submitted price for a vault

function getVaultsPriceAge(address vault) external view returns (uint256);

Parameters

Name
Type
Description

vault

address

Address of the vault

Returns

Name
Type
Description

<none>

uint256

priceAge The difference between block.timestamp and vault's unit price timestamp

isVaultPaused

Check if a vault is paused

function isVaultPaused(address vault) external view returns (bool);

Parameters

Name
Type
Description

vault

address

The address of the vault

Returns

Name
Type
Description

<none>

bool

True if the vault is paused, false otherwise

Events

ThresholdsSet

Emitted when thresholds are set for a vault

event ThresholdsSet(
    address indexed vault,
    uint16 minPriceToleranceRatio,
    uint16 maxPriceToleranceRatio,
    uint16 minUpdateIntervalMinutes,
    uint8 maxPriceAge
);

Parameters

Name
Type
Description

vault

address

The address of the vault

minPriceToleranceRatio

uint16

Minimum ratio (of a price decrease) in basis points

maxPriceToleranceRatio

uint16

Maximum ratio (of a price increase) in basis points

minUpdateIntervalMinutes

uint16

The minimum interval between updates in minutes

maxPriceAge

uint8

Max delay between when a vault was priced and when the price is acceptable

UnitPriceUpdated

Emitted when a vault's unit price is updated

event UnitPriceUpdated(address indexed vault, uint128 price, uint32 timestamp);

Parameters

Name
Type
Description

vault

address

The address of the vault

price

uint128

The new unit price

timestamp

uint32

The timestamp when the price was updated

VaultPausedChanged

Emitted when a vault's paused state is changed

event VaultPausedChanged(address indexed vault, bool paused);

Parameters

Name
Type
Description

vault

address

The address of the vault

paused

bool

Whether the vault is paused

HighestPriceReset

Emitted when a vault's highest price is reset

event HighestPriceReset(address indexed vault, uint128 newHighestPrice);

Parameters

Name
Type
Description

vault

address

The address of the vault

newHighestPrice

uint128

The new highest price

Errors

Aera__StalePrice

error Aera__StalePrice();

Aera__TimestampMustBeAfterLastUpdate

error Aera__TimestampMustBeAfterLastUpdate();

Aera__TimestampCantBeInFuture

error Aera__TimestampCantBeInFuture();

Aera__ZeroAddressOracleRegistry

error Aera__ZeroAddressOracleRegistry();

Aera__InvalidMaxPriceToleranceRatio

error Aera__InvalidMaxPriceToleranceRatio();

Aera__InvalidMinPriceToleranceRatio

error Aera__InvalidMinPriceToleranceRatio();

Aera__InvalidMaxPriceAge

error Aera__InvalidMaxPriceAge();

Aera__InvalidMaxUpdateDelayDays

error Aera__InvalidMaxUpdateDelayDays();

Aera__ThresholdNotSet

error Aera__ThresholdNotSet();

Aera__VaultPaused

error Aera__VaultPaused();

Aera__VaultNotPaused

error Aera__VaultNotPaused();

Aera__UnitPriceMismatch

error Aera__UnitPriceMismatch();

Aera__TimestampMismatch

error Aera__TimestampMismatch();

Aera__VaultAlreadyInitialized

error Aera__VaultAlreadyInitialized();

Aera__VaultNotInitialized

error Aera__VaultNotInitialized();

Aera__InvalidPrice

error Aera__InvalidPrice();

Aera__CurrentPriceAboveHighestPrice

error Aera__CurrentPriceAboveHighestPrice();

Last updated