VaultShareFormulas
VaultShareFormulas
Addresses
Chain | Address |
---|---|
Arbitrum Sepolia | 0x60435186DA69f146C76145e5cF2223F33dC30686 |
Base Sepolia | 0x59c4528c6c3318ce09116a52F34152095daB4d37 |
Base Mainnet | 0x18Fd5f28B6d6A32687049129D53a9C2a77d053Dd |
Functions
constructor
constructor(struct StorageInstance app_) public
This contract is not designed to be upgradable and is strictly a logic contract. Hance, we are directly initializing the contract from the constructor.
convertInput
Compute the assets/shares received in exchange for the provided assets/shares
function convertInput(
uint256 assets,
Shares shares,
uint256 rateAssets,
Shares rateShares
) public 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
) public 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) public view returns (Shares shares)
convertToShares
Convert assets to shares. See EIP-4626
function convertToShares(
uint256 assets,
enum Math.Rounding rounding,
Shares rateShares,
uint256 rateAssets
) public 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) public view returns (uint256 assets)
convertToAssets
Convert shares to assets. See EIP-4626
function convertToAssets(
Shares shares,
enum Math.Rounding rounding,
Shares rateShares,
uint256 rateAssets
) public 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) public 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) public pure returns (uint256)
Internal conversion function (from shares to assets) to apply when the vault is empty.