VaultRouter
This is the router contract for minting and redeeming Honey.
State Variables
ONE_HUNDRED_PERCENT_RATE
The constant representing 100% of mint/redeem rate.
uint256 private constant ONE_HUNDRED_PERCENT_RATE = 1e18;
honey
The Honey token contract.
Honey public honey;
mintRates
Mint rate of Honey for each asset, 60.18-decimal fixed-point number representation
mapping(ERC20 asset => uint256 rate) internal mintRates;
redeemRates
Redemption rate of Honey for each asset, 60.18-decimal fixed-point number representation
mapping(ERC20 asset => uint256 rate) internal redeemRates;
Functions
constructor
constructor();
initialize
function initialize(address _governance, Honey _honey) external initializer;
setMintRate
Set the mint rate of Honey for an asset.
function setMintRate(ERC20 asset, uint256 mintRate) external onlyOwner;
setRedeemRate
Set the redemption rate of Honey for an asset.
function setRedeemRate(ERC20 asset, uint256 redeemRate) external onlyOwner;
checkInvariants
Check the invariant of the vault to ensure
that assets are always sufficient to redeem.
modifier checkInvariants(ERC20 asset);
mint
Mint Honey by sending ERC20 to this contract.
function mint(
address asset,
uint256 amount,
address receiver
)
external
onlyRegisteredAsset(ERC20(asset))
whenNotPaused
checkInvariants(ERC20(asset))
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
asset | address | |
amount | uint256 | The amount of ERC20 to mint with. |
receiver | address | The address that will receive Honey. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of Honey minted. |
redeem
Redeem assets by sending Honey in to burn.
function redeem(
address asset,
uint256 honeyAmount,
address receiver
)
external
onlyRegisteredAsset(ERC20(asset))
whenNotPaused
checkInvariants(ERC20(asset))
returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
asset | address | |
honeyAmount | uint256 | The amount of Honey to redeem. |
receiver | address | The address that will receive assets. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of assets redeemed. |
previewMint
Get the amount of Honey that can be minted with the given ERC20.
function previewMint(address asset, uint256 amount) external view returns (uint256 honeyAmount);
Parameters
Name | Type | Description |
---|---|---|
asset | address | The ERC20 to mint with. |
amount | uint256 | The amount of ERC20 to mint with. |
Returns
Name | Type | Description |
---|---|---|
honeyAmount | uint256 | The amount of Honey that can be minted. |
previewRedeem
Get the amount of ERC20 that can be redeemed with the given Honey.
function previewRedeem(address asset, uint256 honeyAmount) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
asset | address | The ERC20 to redeem. |
honeyAmount | uint256 | The amount of Honey to redeem. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of ERC20 that can be redeemed. |
previewRequiredCollateral
Previews the amount of ERC20 required to mint an exact amount of honey.
function previewRequiredCollateral(address asset, uint256 exactHoneyAmount) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
asset | address | The ERC20 asset to use. |
exactHoneyAmount | uint256 | The exact amount of honey to mint. |
previewHoneyToRedeem
Previews the amount of honey required to redeem an exact amount of target ERC20 asset.
function previewHoneyToRedeem(address asset, uint256 exactAmount) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
asset | address | The ERC20 asset to receive. |
exactAmount | uint256 | The exact amount of assets to receive. |
getMintRate
Get the mint rate of the asset.
function getMintRate(address asset) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
asset | address | The ERC20 asset to get the mint rate. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The mint rate of the asset. |
getRedeemRate
Get the redeem rate of the asset.
function getRedeemRate(address asset) external view returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
asset | address | The ERC20 asset to get the redeem rate. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The redeem rate of the asset. |
_getHoneyMintedFromShares
function _getHoneyMintedFromShares(
ERC20 asset,
uint256 shares
)
internal
view
returns (uint256 honeyAmount, uint256 feeShares);
_getSharesRedeemedFromHoney
function _getSharesRedeemedFromHoney(
ERC20 asset,
uint256 honeyAmount
)
internal
view
returns (uint256 shares, uint256 feeShares);
_getMintRate
function _getMintRate(ERC20 asset) internal view returns (uint256);
_getRedeemRate
function _getRedeemRate(ERC20 asset) internal view returns (uint256);