IVaultShareFormulas
IVaultShareFormulas
Addresses
Chain | Address |
---|
Functions
convertInput
Compute the assets/shares received in exchange for the provided assets/shares
function convertInput(
uint256 assets,
Shares shares,
uint256 rateAssets,
Shares rateShares
) external view returns (
Shares sharesOut,
uint256 assetsOut,
uint256 fee
)
Used for deposit()
and redeem()
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | Assets to be deposited. Must be 0 if shares is set. |
shares | Shares | Shares to be redeemed. Must be 0 if assets is set. |
rateAssets | uint256 | Conversion rate: rateAssets are worth rateShares . |
rateShares | Shares | Conversion rate: rateShares are worth rateAssets . |
Return Values
Name | Type | Description |
---|---|---|
sharesOut | Shares | Shares received in exchange for assets . Fee excluded. |
assetsOut | uint256 | Assets received in exchange for shares . Fee excluded. |
fee | uint256 | Deposit/withdraw fee applied to output, in collateral units. |
convertOutput
Compute the assets/shares required to obtain the requested assets/shares
function convertOutput(
uint256 assets,
Shares shares,
uint256 rateAssets,
Shares rateShares
) external view returns (
Shares sharesIn,
uint256 assetsIn,
uint256 fee
)
Used for withdraw()
and mint()
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | Assets to be withdrawn. Must be 0 if shares is set. |
shares | Shares | Shares to be minted. Must be 0 if assets is set. |
rateAssets | uint256 | Conversion rate: rateAssets are worth rateShares . |
rateShares | Shares | Conversion rate: rateShares are worth rateAssets . |
Return Values
Name | Type | Description |
---|---|---|
sharesIn | Shares | Shares required to withdraw assets . Fee included. |
assetsIn | uint256 | Assets required to mint shares . Fee included. |
fee | uint256 | Deposit/withdraw fee that will be taken out of sharesIn / assetsIn, in collateral units. |
convertToShares
Convert assets to shares. See EIP-4626
function convertToShares(uint256 assets, enum Math.Rounding rounding) external view returns (Shares shares)
convertToShares
Convert assets to shares. See EIP-4626
function convertToShares(
uint256 assets,
enum Math.Rounding rounding,
Shares rateShares,
uint256 rateAssets
) external view returns (
Shares shares
)
ERC4626 reference impl modified to explicitly take a rate
Parameters
Name | Type | Description |
---|---|---|
assets | uint256 | |
rounding | enum Math.Rounding | |
rateShares | Shares | Conversion rate: rateShares are worth rateAssets . |
rateAssets | uint256 | Conversion rate: rateAssets are worth rateShares . |
convertToAssets
Convert shares to assets. See EIP-4626
function convertToAssets(Shares shares, enum Math.Rounding rounding) external view returns (uint256 assets)
convertToAssets
Convert shares to assets. See EIP-4626
function convertToAssets(
Shares shares,
enum Math.Rounding rounding,
Shares rateShares,
uint256 rateAssets
) external view returns (
uint256 assets
)
ERC4626 reference impl modified to explicitly take a rate
Parameters
Name | Type | Description |
---|---|---|
shares | Shares | |
rounding | enum Math.Rounding | |
rateShares | Shares | Conversion rate: rateShares are worth rateAssets . |
rateAssets | uint256 | Conversion rate: rateAssets are worth rateShares . |
initialConvertToShares
function initialConvertToShares(uint256 assets, enum Math.Rounding) external pure returns (Shares shares)
Internal conversion function (from assets to shares) to apply when the vault is empty. Scale by 1e18 to mitigate inflation attacks: github.com/OpenZeppelin/openzeppelin-contracts/issues/3706
initialConvertToAssets
function initialConvertToAssets(Shares shares, enum Math.Rounding) external pure returns (uint256)
Internal conversion function (from shares to assets) to apply when the vault is empty.