Bank
contract, as its name implied, mainly deals with the methods and variables related to the saving pool. It uses three variables to track the total amount of tokens in the pool and their allocations. For each token
,totalLoans[token]
tracks total amount of token
lend.totalReserve[token]
tracks total amount of token
reserved.totalCompound[token]
tracks total amount of token
in compoundtoken
in the pool is the summation of these three variables. The token utilization ratio U
, token reservation ratio R
and compound ratio C
are defined accordingly. function getTotalDepositStore(address _token) public view returns(uint)
totalLoans[token]
,totalReserve[token]
and totalCompound[token]
.function getPoolAmount(address _token) public view returns(uint)
totalCompound[token]
and totalReserve[token]
.function getTokenState(address _token) public view returns (uint256 deposits, uint256 loans, uint256 reserveBalance, uint256 remainingAssets)
function getCapitalUtilizationRatio(address _token) public view returns(uint)
U
of a token, which is the ratio of the total loan to the total deposit.function getCapitalCompoundRatio(address _token) public view returns(uint)
C
of a token, which is the ratio of the total amount in Compound to the total deposit. function newRateIndexCheckpoint(address _token) public onlyAuthorized
function getDepositRatePerBlock(address _token) public view returns(uint)
function getBorrowRatePerBlock(address _token) public view returns(uint)
GlobalConfig
contract.function depositRateIndexNow(address _token) public view returns(uint)
function borrowRateIndexNow(address _token) public view returns(uint)
function getDepositAccruedRate(address _token, uint _depositRateRecordStart) external view returns (uint256)
_depositRateRecordStart
you specified in the parameter and n
tokens at block function getBorrowAccruedRate(address _token, uint _borrowRateRecordStart) external view returns (uint256)
function deposit(address _to, address _token, uint256 _amount) external onlyAuthorized
msg.sender
in Accounts
contract. Then, it will update the pool balance, i.e. the value of totalReserve[token]
and totalCompound[token]
, accordingly.R
exceeds 20%
, the contract will deposit the token to Compound to reset R
to be 15%
.function withdraw(address _from, address _token, uint256 _amount) external onlyAuthorized returns(uint)
msg.sender
in Accounts
contract. The withdraw is allowed only if the account has enough balance and its loan value is still below the reduced borrow power after withdrawn. Then, the contract will update the pool balance by calling update
method.function borrow(address _from, address _token, uint256 _amount) external onlyAuthorized
msg.sender
in Accounts
contract. The borrow is allowed only if the added loan value is below the borrow power. Then, the contract will update the pool balance by calling update
method.function repay(address _to, address _token, uint256 _amount) external onlyAuthorized returns(uint)
msg.sender
in Accounts
contract. The borrow is allowed only if the added loan value is below the borrow power. Then, the contract will update the pool balance by calling update
method.function update(address _token, uint _amount, ActionType _action) public onlyAuthorized returns(uint256 compoundAmount)
20%
, the contract will deposit an extra amount of token to Compound and reset R
to be 15%. On the other hand, if an account withdraw or borrow such that the reservation ratio falls behind 10%
, the contract will withdraw the token from Compound and try to reset R
to be 15%
. However, in this case, there might not be enough tokens in Compound so that the final R
could be below 15%
.