# Lending

Let

$x$

be the increase in the $X$

pool. This increase is due to the lender depositing $x$

assets in the pool. Let

$y$

be the decrease in the $Y$

pool.Let

$z$

be the decrease in the $Z$

pool.The value of

$x$

**,***y,*and$z$

is calculated from the constant product $K$

$(X+x)\times(Y-y)\times(Z-z)=K$

*As*

$y$

*increases,*

$z$

*has to decrease and when*

$z$

*increases,*

$y$

*has to decrease. So, a user receives lower interest as the insurance increases and vice versa*. Thus,

*at the time of lending assets to the pool.*

**lenders have the flexibility to decide their risk-reward profile**The maximum of

$y$

is when $z=0$

:

$(X+x)\times(Y - y_{max})\times(Z-0)=K$

The maximum of

$z$

is when $y=0$

:

$(X+x)\times(Y-0)\times(Z -z_{max}) = K$

Let

*d*be time duration from the time of user transaction to maturity time of pool in secondsTotal Bond tokens and Insurance tokens received by lenders are as follows:

Bond Principal tokens:

$x$

Bond Interest tokens:

$dy$

Insurance Principal tokens: z_{max}

Insurance Interest tokens= zd/2^25

There is a restriction where,

$y>=\frac{y_{max}}{16}$

, such that there is a minimum interest per second received by lendersAlice would like to lend DAI on DAI-ETH Timeswap pool to earn interest with minimal risk. Suppose a Liquidity Provider(LP) creates the DAI-ETH pool with the following parameters and maturity of 1 year:

$X = 10,000$

$Y=0.0000475$

(Average int rate of 15%)

$Z = 4.16$

$K=1.979$

Now Alice deposits 1000 DAI to the Timeswap DAI — ETH pool 1 month before the pool maturity. So as per the AMM equation for a lending transaction:

****

$(10000+1000)\times(0.0000475-y)\times(4.16-z)=1.979$

Solving for

$y_{max}$

,

$(10000+1000)\times(0.0000475 - y_{max})\times(4.16-0)=1.979$

**

$y_{max}= 0.00000425$

$=>$

The annual interest rate that can be selected by Alice will have a range of $\frac{y_{max}}{16}\times\frac{d_{year}}{x}$

*to*

$y_{max}\times\frac{d_{year}}{x}$

*(where*

$d_{year}$

is no. of sec in a year = 31556926).
In this case, Alice can select APR from 0.84% to 13.41%Solving for

$z_{max}$

,

$(10000+1000) \times(0.0000475-0) \times(4.16-z_{max}) =1.979$

**

$z_{max}=0.37$

Let’s assume Alice chose to receive 10% APR with some insurance while initiating the transaction.

$=>y$

or the interest value per second is $0.1\times\frac{1000}{31556926}=0.00000316$

Let

$d=$

2592000 (duration of 30 days from the time of tx in seconds)Solving for Bond tokens to be received by Alice, we get

Bond Principal tokens=

$x=1000$

Bond lnterest tokens = dy={2592000}\times{0.00000316}=8.19

Solving for z

$(10000+1000)\times (0.0000475-0.00000316)\times(4.16-z)=1.979$

$z=0.1$

Solving for Insurance tokens to be received by Alice, we get

Insurance Principal tokens= z_{max} = 0.37

Insurance Interest tokens = zd/2^25 = 0.1*2592000/33554432 = 0.077

i.e. Alice receives 1000 Bond Principal tokens, 8.19 Bond Interest tokens, 0.37 Insurance Principal tokens and 0.077 Insurance Interest tokens. In total Alice should get 1008.19 DAI after maturity and in case of default coverage of up to 0.371 ETH

**Summarising:**

Alice deposited 1000 DAI to the pool one month before the pool expiry and received toal 1008.19 Bond tokens (BPT+BIT) and 0.371 Insurance tokens (IPT+IIT). At the end of 1 month, she should receive 1008.19 DAI by burning her Bond tokens . However in case her bond tokens are not able to give her exact same amount of DAI, her insurance tokens will kick in to provide her a proportional percentage of coverage on insurance value which is in line with the percentage of unrealised assets from respective bond tokens

Last modified 8mo ago