# Protocol Math

## Calculating Accrued Interest

Interest rates for each market update on any block in which the ratio of borrowed assets to supplied assets in the market has changed. The amount interest rates are changed depends on the interest rate model smart contract implemented for the market, and the amount of change in the ratio of borrowed assets to supplied assets in the market.

Here is an example of borrow interest accrual:

Alice borrows 1 ETH from Panwfi Lending Market. At the time of borrow, the borrow interest is 0.000000000037893605 ETH per block. No one interacts with the iEther contract for 3 Ethereum blocks. On the subsequent 4th block, Bob borrows some ETH. Alice’s underlying balance is now 1.000000000151574420 ETH (which is 0.000000000037893605 times 4 blocks, plus the original 1 ETH). Alice’s underlying ETH balance in subsequent blocks will have interest accrued based on the new value of 1.000000000151574420 ETH instead of the initial 1 ETH. Note that the borrow rate per block value may change at any time.

That is, the interest will only be compounded whenever there is an interaction with each market. If there is no interaction with the market (let's say USDT), the supply and borrow APY for USDT will be calculated as simple interest.

## Calculating the front-end APY Using Rate Per Block

The Annual Percentage Yield (APY) for supplying or borrowing displaying in each market can be calculated using the value of supply or borrow APY in smart contract with this formula:

Last updated