modifier onlyWhitelisted()
Restrict msg.sender to be externally owned accounts only.
uint8 UNIFORM_DECIMALS
We adjust tokens amounts to have uniform number of decimals where needed for calculations.
uint256 cycleDuration
Minimum time needed before depositing batch balance into strategies.
uint256 minUsdPerCycle
Minimum batch balance to be deposited into strategies.
uint256 minDeposit
Minimum amount to be deposited into batch by the user.
mapping(uint256 => struct StrategyRouter.Cycle) cycles
Contains info such as how much were deposited into strategies or price per share in each cycle.
function allocateToStrategies() external
Deposit money collected in the batch into strategies. Can be called when `cycleDuration` seconds has been passed or batch has reached `minUsdPerCycle` amount of coins.
Only callable by user wallets.
function compoundAll() external
Compound all strategies.
Only callable by user wallets.
function getSupportedTokens() public view returns (address[])
Returns list of supported tokens.
function getStrategyPercentWeight(uint256 _strategyId) public view returns (uint256 strategyPercentAllocation)
Returns strategy weight as percent of total weight.
function getStrategiesCount() public view returns (uint256 count)
Returns count of strategies.
function getStrategies() public view returns (struct StrategyRouter.StrategyInfo[])
Returns array of strategies.
function getStrategiesBalance() public view returns (uint256 totalBalance, uint256[] balances)
Returns amount of tokens in strategies. All returned numbers have `UNIFORM_DECIMALS` decimals.
Name | Type | Description |
---|---|---|
totalBalance | uint256 | Total amount of tokens in strategies. |
balances | uint256[] | Array of token amount in each strategy. |
function getBatchBalance() public view returns (uint256 totalBalance, uint256[] balances)
Returns token balances and their sum in the batch. Shows total batch balance, possibly not total to be deposited into strategies. because strategies might not take all token supported by router. All returned amounts have `UNIFORM_DECIMALS` decimals.
Name | Type | Description |
---|---|---|
totalBalance | uint256 | Total tokens in the batch. |
balances | uint256[] | Array of token balances in the batch. |
function receiptToShares(uint256 receiptId) public view returns (uint256 shares)
Returns amount of shares retrievable by receipt. Cycle noted in receipt should be closed.
function sharesToUsd(uint256 shares) public view returns (uint256 amount)
Calculate how much usd shares representing using current price per share.
Returns amount with uniform decimals
function redeemReceiptsToShares(uint256 receiptId) public returns (uint256 shares)
Convert receipt NFT into share tokens, withdraw functions do it internally. Cycle noted in receipt should be closed.
function withdrawFromStrategies(uint256 receiptId, address withdrawToken, uint256 shares, uint256 amount) external
User withdraw usd from strategies via receipt NFT. On partial withdraw leftover shares transfered to user. Receipt is burned. Internally all receipt's shares unlocked from that NFT.
Only callable by user wallets.
Name | Type | Description |
---|---|---|
receiptId | uint256 | Receipt NFT id. |
withdrawToken | address | Supported token that user wish to receive. |
shares | uint256 | Amount of shares to withdraw. |
amount | uint256 | Uniform amount from receipt to withdraw, only for current cycle. |
function withdrawShares(uint256 shares, address withdrawToken) external
User withdraw tokens from strategies via shares. Receipts should be converted to shares prior to call this.
Name | Type | Description |
---|---|---|
shares | uint256 | Amount of shares to withdraw. |
withdrawToken | address | Supported token that user wish to receive. |
function withdrawFromBatch(uint256 receiptId, address withdrawToken, uint256 shares, uint256 amount) external
User withdraw tokens from batch. On partial withdraw amount noted in receipt is updated. Receipt is burned when withdrawing whole amount.
Only callable by user wallets.
Name | Type | Description |
---|---|---|
receiptId | uint256 | Receipt NFT id. |
withdrawToken | address | Supported token that user wish to receive. |
shares | uint256 | Amount of shares to withdraw, specify this if money of receipt were deposited into strategies. |
amount | uint256 | Amount to withdraw, specify this if money of receipt isn't deposited into strategies yet. |
function depositToBatch(address depositToken, uint256 _amount) external
Deposit token into batch. Tokens not deposited into strategies immediately.
_User should approve `amount` of `depositToken` to this contract. Only callable by user wallets.
Name | Type | Description |
---|---|---|
depositToken | address | Supported token to deposit. |
_amount | uint256 | Amount to deposit. |
function setExchange(contract Exchange newExchange) external
Set address of exchange contract.
Admin function.
function setMinUsdPerCycle(uint256 amount) external
Minimum usd needed to be able to close the cycle.
Admin function.
Name | Type | Description |
---|---|---|
amount | uint256 | Amount of usd, must be `UNIFORM_DECIMALS` decimals. |
function setMinDepositUsd(uint256 amount) external
Minimum to be deposited in the batch.
Admin function.
Name | Type | Description |
---|---|---|
amount | uint256 | Amount of usd, must be `UNIFORM_DECIMALS` decimals. |
function setCycleDuration(uint256 duration) external
Minimum time needed to be able to close the cycle.
Admin function.
Name | Type | Description |
---|---|---|
duration | uint256 | Duration of cycle in seconds. |
function addStrategy(address _strategyAddress, address _depositTokenAddress, uint256 _weight) external
Add strategy.
Admin function. Deposit asset must be supported by the router.
Name | Type | Description |
---|---|---|
_strategyAddress | address | Address of the strategy. |
_depositTokenAddress | address | Asset to be deposited into strategy. |
_weight | uint256 | Weight of the strategy. Used to split user deposit between strategies. |
function updateStrategy(uint256 _strategyId, uint256 _weight) external
Update strategy weight.
Admin function.
Name | Type | Description |
---|---|---|
_strategyId | uint256 | Id of the strategy. |
_weight | uint256 | Weight of the strategy. |
function removeStrategy(uint256 _strategyId) external
Remove strategy, deposit its balance in other strategies.
Admin function.
Name | Type | Description |
---|---|---|
_strategyId | uint256 | Id of the strategy. |
function rebalanceStrategies() external returns (uint256 totalInStrategies, uint256[] balances)
Rebalance strategies, so that their balances will match their weights.
Admin function.
function setSupportedToken(address tokenAddress, bool supported) external
Set token as supported for user deposit and withdraw.
Admin function.