AssetManager

Manage the token balances staked by the users, and deposited by admins, and invest tokens to the integrated underlying lending protocols.

Functions:

getPoolBalance(address tokenAddress) → uint256

Returns the balance of asset manager, plus the total amount of tokens deposited to all the underlying lending protocols.

Parameters:

  • tokenAddress: ERC20 token address

Return Values:

  • Lending pool balance

getLoanableAmount(address tokenAddress) → uint256

Returns the amount of the lending pool balance minus the amount of total staked.

Parameters:

  • tokenAddress: ERC20 token address

Return Values:

  • Amount can be borrowed

totalSupply(address tokenAddress) → uint256

Get the total amount of tokens deposited to all the integrated underlying protocols without side effects.

Parameters:

  • tokenAddress: ERC20 token address

Return Values:

  • Total market balance

totalSupplyView(address tokenAddress) → uint256

Get the total amount of tokens deposited to all the integrated underlying protocols, but without side effects. Safe to call anytime, but may not get the most updated number for the current block. Call totalSupply() for that purpose.

Parameters:

  • tokenAddress: ERC20 token address

Return Values:

  • Total market balance

isMarketSupported(address tokenAddress) → bool

Check if there is an underlying protocol available for the given ERC20 token.

Parameters:

  • tokenAddress: ERC20 token address

Return Values:

  • Whether is supported

deposit(address token, uint256 amount) → bool

Deposit tokens to AssetManager, and those tokens will be passed along to adapters to deposit to integrated asset protocols if any is available.

Parameters:

  • token: ERC20 token address

  • amount: Deposit amount, in wei

Return Values:

  • Deposited amount

withdraw(address token, address account, uint256 amount) → bool

Withdraw from AssetManager

Parameters:

  • token: ERC20 token address

  • account: User address

  • amount: Withdraw amount, in wei

Return Values:

  • Withdraw amount

addToken(address tokenAddress)

Add a new ERC20 token to support in AssetManager

Parameters:

  • tokenAddress: ERC20 token address

addAdapter(address adapterAddress)

Add a new adapter for the underlying lending protocol

Parameters:

  • adapterAddress: adapter address

approveAllMarketsMax(address tokenAddress)

For a give token set allowance for all integrated money markets

Parameters:

  • tokenAddress: ERC20 token address

approveAllTokensMax(address adapterAddress)

For a give moeny market set allowance for all underlying tokens

Parameters:

  • adapterAddress: Address of adaptor for money market

changeWithdrawSequence(uint256[] newSeq)

Set withdraw sequence

Parameters:

  • newSeq: priority sequence of money market indices to be used while withdrawing

rebalance(address tokenAddress, uint256[] percentages)

Rebalance the tokens between integrated lending protocols

Parameters:

  • tokenAddress: ERC20 token address

  • percentages: Proportion

claimTokens(address tokenAddress, address recipient)

Claim the tokens left on AssetManager balance, in case there are tokens get stuck here.

Parameters:

  • tokenAddress: ERC20 token address

  • recipient: Recipient address

claimTokensFromAdapter(uint256 index, address tokenAddress, address recipient)

Claim the tokens stuck in the integrated adapters

Parameters:

  • index: MoneyMarkets array index

  • tokenAddress: ERC20 token address

  • recipient: Recipient address

moneyMarketsCount() → uint256

Get the number of supported underlying protocols.

Return Values:

  • MoneyMarkets length

supportedTokensCount() → uint256

Get the count of supported tokens

Return Values:

  • Number of supported tokens

getMoneyMarket(address tokenAddress, uint256 marketId) → uint256, uint256

Get the supported lending protocol

Parameters:

  • tokenAddress: ERC20 token address

  • marketId: MoneyMarkets array index

debtWriteOff(address tokenAddress, uint256 amount)

debt write off

Parameters:

  • tokenAddress: ERC20 token address

  • amount: WriteOff amount

Events:

LogDeposit(address token, address account, uint256 amount)

Emit when making a deposit

Parameters:

  • token: Depositing token address

  • account: Account address

  • amount: Deposit amount, in wei

LogWithdraw(address token, address account, uint256 amount, uint256 remaining)

Emit when withdrawing from AssetManager

Parameters:

  • token: Depositing token address

  • account: Account address

  • amount: Withdraw amount, in wei

  • remaining: The amount cannot be withdrawn

LogRebalance(address tokenAddress, uint256[] percentages)

Emit when rebalancing among the integrated money markets

Parameters:

  • tokenAddress: The address of the token to be rebalanced

  • percentages: Array of the percentages of the tokens to deposit to the money markets

Last updated