Vault
The vault is the main contract of the protocol. The vault is responsible for minting/redeeming OUSD tokens, rebalancing funds between the various supported strategies, and liquidating rewards tokens.
All OUSD amounts passed or returned by the Vault methods use 18 decimal places. For example, 1 OUSD is expressed as 1000000000000000000.
For other stablecoins, the number of decimal places varies. DAI uses 18 decimal places while USDC and USDT use only 6.
The protocol was updated in November to increase the resolution of rebasing calculations from 18 decimals to 27 decimals. The OUSD token itself retained 18 decimals of precision and user balances were not affected.
function mint(address _asset, uint256 _amount, uint256 _minimumOusdAmount)
Mints OUSD in exchange for a deposit of a certain
_amount
of stablecoin specified by the _asset
parameter. The caller receives a certain amount of OUSD depending on the exchange rate.Parameter Name | Type | Description |
_asset | address | |
_amount | uint256 | Amount deposited, expressed in decimal units |
_minimumOusdAmount | uint256 | Minimum amount of OUSD the caller is willing to receive. The call to mint() reverts if the minimum is not met. |
function mintMultiple(address[] _assets, uint256[] _amounts, uint256 _minimumOusdAmount)
Mints OUSD in exchange for a deposit of multiple stablecoins in a single call. Stablecoins are specified by the
_assets
array parameter and the amounts by the _amounts
array parameter. The caller receives a certain amount of OUSD depending on the exchange rate.Parameter Name | Type | Description |
_assets | address[] | |
_amounts | uint256[] | Amounts deposited, expressed in decimal units |
_minimumOusdAmount | uint256 | Minimum amount of OUSD the caller is willing to receive. The call to mint() reverts if the minimum is not met. |
On redemptions, it is the protocol and not the user that decides which stablecoin(s) are returned to the user. This decision of which coin(s) to return is based on the internal ratios of the assets that are being held in the vault.
function redeem(uint256 _amount)
OUSD specified by the
_amount
parameter is redeemed in exchange for one or multiple supported stablecoins. Amount of stablecoins received depends on the exchange rate.Parameter Name | Type | Description |
_amount | uint256 | amount of OUSD expressed in decimal units |
function redeemAll()
All OUSD in user's possession is redeemed in exchange for one or multiple supported stablecoins. Amount of stablecoins received depends on the exchange rate.
function rebase()
Updates the balances for all users based on the value of the assets currently stored in the vault. Returns total value of the underlying assets and strategies represented by
uint256
type.function allocate()
Moves the assets under management into their prescribed Stategies to maximize yield and diversify risk.
function totalValue()
Returns total value of underlying assets and strategies.
return name | Type | Description |
value | uint256 | total value of underlying assets and strategies. |
function checkBalance(address _asset)
Returns the balance of an asset specified by the
_asset
parameter held in Vault and all strategies represented by uint256
type.Parameter Name | Type | Description |
_asset | address |
function calculateRedeemOutputs(uint256 _amount)
Calculate the mix of stablecoins that a
redeem
function would return when redeeming certain amount of OUSD specified by the _amount
parameter. Returns an array of stablecoin values.To attribute the stablecoin values to the correct stablecoin currency this call should be used in conjunction with
getAllAssets
function that returns an array of stablecoin addresses.The index of an array that is returned by the
calculateRedeemOutputs
corresponds to the stablecoin address with the same index in an array returned by the getAllAssets
function.Parameter Name | Type | Description |
_amount | uint256 | amount of OUSD expressed in decimal units |
return name | Type | Description |
outputs | uint256[] | array of the amount of the stablecoin assets redeem function would return |
function getAssetCount()
Return the number of supported stablecoin assets represented by
uint256
type.function getAllAssets()
Return all assets addresses of supported stablecoin assets in order represented by
uint256
type.function getStrategyCount()
Return the number of strategies active on the Vault represented by
uint256
type.function getAPR()
Return the total annual percentage yield (APR) of the Vault and all Strategies represented by
uint256
type. Resulting number has 18 decimal places.function isSupportedAsset(address _asset)
Return the boolean that is true if the asset specified by the
_asset
parameter is supported by the Vault.Parameter Name | Type | Description |
_asset | address | Address of the stablecoin |
function priceUSDMint(string symbol)
Returns the exchange rate price of a stable coin specified by the
symbol
parameters used when minting OUSD represented by uint256
type. Resulting number has 18 decimal places.Parameter Name | Type | Description |
symbol | string | Symbol of the stablecoin |
function priceUSDRedeem(string symbol)
Returns the exchange rate price of a stable coin specified by the
symbol
parameters used when redeeming OUSD represented by uint256
type. Resulting number has 18 decimal places.Parameter Name | Type | Description |
symbol | string | Symbol of the stablecoin |
function priceAssetUSDMint(address _asset)
Returns the exchange rate price of a stable coin specified by the
_asset
parameters used when minting OUSD represented by uint256
type. Resulting number has 18 decimal places.Parameter Name | Type | Description |
_asset | address | Address of the stablecoin |
function priceAssetUSDRedeem(address _asset)
Returns the exchange rate price of a stable coin specified by the
_asset
parameters used when redeeming OUSD represented by uint256
type. Resulting number has 18 decimal places.Parameter Name | Type | Description |
_asset | address | Address of the stablecoin |
Last modified 2mo ago