Skip to content

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.

solidity
uint256 private constant ONE_HUNDRED_PERCENT_RATE = 1e18;

honey

The Honey token contract.

solidity
Honey public honey;

mintRates

Mint rate of Honey for each asset, 60.18-decimal fixed-point number representation

solidity
mapping(ERC20 asset => uint256 rate) internal mintRates;

redeemRates

Redemption rate of Honey for each asset, 60.18-decimal fixed-point number representation

solidity
mapping(ERC20 asset => uint256 rate) internal redeemRates;

Functions

constructor

solidity
constructor();

initialize

solidity
function initialize(address _governance, Honey _honey) external initializer;

setMintRate

Set the mint rate of Honey for an asset.

solidity
function setMintRate(ERC20 asset, uint256 mintRate) external onlyOwner;

setRedeemRate

Set the redemption rate of Honey for an asset.

solidity
function setRedeemRate(ERC20 asset, uint256 redeemRate) external onlyOwner;

checkInvariants

Check the invariant of the vault to ensure

that assets are always sufficient to redeem.

solidity
modifier checkInvariants(ERC20 asset);

mint

Mint Honey by sending ERC20 to this contract.

solidity
function mint(
    address asset,
    uint256 amount,
    address receiver
)
    external
    onlyRegisteredAsset(ERC20(asset))
    whenNotPaused
    checkInvariants(ERC20(asset))
    returns (uint256);

Parameters

NameTypeDescription
assetaddress
amountuint256The amount of ERC20 to mint with.
receiveraddressThe address that will receive Honey.

Returns

NameTypeDescription
<none>uint256The amount of Honey minted.

redeem

Redeem assets by sending Honey in to burn.

solidity
function redeem(
    address asset,
    uint256 honeyAmount,
    address receiver
)
    external
    onlyRegisteredAsset(ERC20(asset))
    whenNotPaused
    checkInvariants(ERC20(asset))
    returns (uint256);

Parameters

NameTypeDescription
assetaddress
honeyAmountuint256The amount of Honey to redeem.
receiveraddressThe address that will receive assets.

Returns

NameTypeDescription
<none>uint256The amount of assets redeemed.

previewMint

Get the amount of Honey that can be minted with the given ERC20.

solidity
function previewMint(address asset, uint256 amount) external view returns (uint256 honeyAmount);

Parameters

NameTypeDescription
assetaddressThe ERC20 to mint with.
amountuint256The amount of ERC20 to mint with.

Returns

NameTypeDescription
honeyAmountuint256The amount of Honey that can be minted.

previewRedeem

Get the amount of ERC20 that can be redeemed with the given Honey.

solidity
function previewRedeem(address asset, uint256 honeyAmount) external view returns (uint256);

Parameters

NameTypeDescription
assetaddressThe ERC20 to redeem.
honeyAmountuint256The amount of Honey to redeem.

Returns

NameTypeDescription
<none>uint256The amount of ERC20 that can be redeemed.

previewRequiredCollateral

Previews the amount of ERC20 required to mint an exact amount of honey.

solidity
function previewRequiredCollateral(address asset, uint256 exactHoneyAmount) external view returns (uint256);

Parameters

NameTypeDescription
assetaddressThe ERC20 asset to use.
exactHoneyAmountuint256The exact amount of honey to mint.

previewHoneyToRedeem

Previews the amount of honey required to redeem an exact amount of target ERC20 asset.

solidity
function previewHoneyToRedeem(address asset, uint256 exactAmount) external view returns (uint256);

Parameters

NameTypeDescription
assetaddressThe ERC20 asset to receive.
exactAmountuint256The exact amount of assets to receive.

getMintRate

Get the mint rate of the asset.

solidity
function getMintRate(address asset) external view returns (uint256);

Parameters

NameTypeDescription
assetaddressThe ERC20 asset to get the mint rate.

Returns

NameTypeDescription
<none>uint256The mint rate of the asset.

getRedeemRate

Get the redeem rate of the asset.

solidity
function getRedeemRate(address asset) external view returns (uint256);

Parameters

NameTypeDescription
assetaddressThe ERC20 asset to get the redeem rate.

Returns

NameTypeDescription
<none>uint256The redeem rate of the asset.

_getHoneyMintedFromShares

solidity
function _getHoneyMintedFromShares(
    ERC20 asset,
    uint256 shares
)
    internal
    view
    returns (uint256 honeyAmount, uint256 feeShares);

_getSharesRedeemedFromHoney

solidity
function _getSharesRedeemedFromHoney(
    ERC20 asset,
    uint256 honeyAmount
)
    internal
    view
    returns (uint256 shares, uint256 feeShares);

_getMintRate

solidity
function _getMintRate(ERC20 asset) internal view returns (uint256);

_getRedeemRate

solidity
function _getRedeemRate(ERC20 asset) internal view returns (uint256);