Comment on page
as of 01/04/2023
Most numbers are represented as a mantissa, an unsigned integer scaled by 1 * 10 ^ 18, to perform basic math at a high level of precision.
Which can be translated to the following difference equation if we apply the explicit Euler discretization scheme:
With initial condition
Notice that this index is just the dynamics of a borrow of one unit. This is what is usually called the Money Market equation. This index can be use to update any borrowed amount at time
to any point in time
In other words, the quotient among indexes define the well known discount factor:
Finally, notice that the borrows increase or decrease at specific time points depending on loans being taken or repaid. These two scenarios imply that the total borrows present discontinuities at such time points.
Finally, a portion of the liquidation incentive being paid to liquidators will probably be redirected to the Protocol Reserves. This means that
might increase and present a discontinuity at liquidation time points.
The borrow and supply rates are defined through a mathematical model that relies on fixed parameters and the utilization factor. At any point in time, the Money aMrket utilization factor
is defined as:
At this point, it is important to discuss some edge cases. When there are no borrows, i.e.
, the utilization is zero. On the other hand, when liquidity is zero, we cap the utilization as the first utilization that yields the maximum borrow rate, such that:
Finally, the supply rate is given by:
represents the token total supply and with an initial condition
. Lenders will receive these tokens when they deposit underlying into the pool. On the contrary, they will have to redeem back those tokens in exchange for more underlying than what they have previously deposited. The conversion is performed as follows:
We might need to distribute rewards either to incentivize the use of our Money Markets or for yield in our safety modules. For that purpose, we propose a rewards mechanism based on a speed of rewards (an amount of tokens being distributed per second for all beneficiaries) and the fraction of ownership for each individual account. Namely, the total amount of tokens being distributed as rewards
is the speed of rewards. An account gets rewards based on its supplied, borrowed or staked amount and the total amount being supplied, borrowed or staked:
is the account’s rewards,
is the account supplied, borrowed or staked amount and
is the total supplied, borrowed or staked amount. This previous equation can be written as:
can be considered as the price of an index, stock or share. This allows the account’s rewards computation to be performed as the amount of shares times the share price. This trick decouples the problem and requires re-computing only the index price at each protocol interaction but does not require updating rewards for all accounts at all interactions (these kinds of loops are computationally prohibited in smart contracts development). Now, we can implement the same discretization scheme as before, such that:
Notice that the times
are a subset of times
. In other words, a particular account needs to be updated at a given date
while the index price is updated at all protocol interactions