CDS Logics
Here the logics used in CDS contract and CDSLib are explained.
In code, many base PRECISION are used to avoid, arithmetic, division or modulo by zero errors.
USDT depsoited till now - Logic
Check whether the USDT limit in CDS is reached or not by including the current depositing amount also. If its reached, the USDa amount must be 80% of the depositing amount.
Functions which are using the above logic
Options fees to get from each chain
Calculate the each chain CDS amount proportions by dividing them with global CDS amount. Based on the proportions, calculate the options fees to get from each chain.
Let say, if one chain don't have any CDS amount, then take all options fees from other chain. If one chain don't have enough options fees to get, then get available options fees from that chain and get remaining from other chain. If both have enough options fees, then get the amount based on proportions.
Suppose, if there is no liquidation happened between deposit and withdraw of the CDS user, then the ethAmount will be zero.So functionToDo in treasury will be Token transfer only. Likewise, all condtions are applied.
Functions which are using the above logic
USDT to give in redeem - Logic
The amount of USDT to give to the user will be calculated by dividing the USDa price of one token by USDT price of one token. Multiply the ratio with USDa amount, the user is redeeming.
Functions which are using the above logic
Cumulative rate calculation
_fees
uint128
Options fees to give to CDS users.
_totalCdsDepositedAmount
uint256
Total CDS amount in this chain.
_totalCdsDepositedAmountWithOptionFees
uint256
Total CDS amount with options fees in this chain.
_totalGlobalCdsDeposited AmountWithOptionFees
uint256
Total CDS amount with options fees in all chain.
_lastCumulativeRate
uint128
Previously stored cumulative rate.
_noOfBorrowers
uint128
Total number of borrowers in protocol.
Calculate the percentage change by dividing fees by netCDSPoolvalue. If the number of borrowers nil, then the current cumulative rate will be 1 + percentage change. Else,
current cumulative rate will be previous cumulative rate multiple percentage change plus one.
Functions which are using the above logic
Last updated