Treasury Logics
Here the logics used in Treasury contract are explained.
Cumulative rate calculation
Treasury.sol
Param Name
Type
Description
balanceBeforeEvent
uint256
Balance of external protocol tokens before deposit or withdraw.
_protocol
enum Protocol
Which external protocol cumulative rate needs to be calculated.
For the first time deposit, the cumulative rate will be 1.
For further events, calculate the percentage change by dividing the tokens credited between last event and balance before event by total credited tokens till last event.
Then current cumulative rate will be previous cumulative rate multiplied with percentage change plus one.
Reason for adding 1 to percentage change is, converting that into rate.
Functions which are using the above logic
Last updated