Position closing

Once a position is open, a trader could choose to close it before expiry. If that's the case, the protocol needs to exit the lending position, which at expiry would have represented an amount LL(principal + interest), and repay the owed debt, which at expiry would have represented an amount DD(principal + interest).

Pricing

The table below presents the price at which a trader could close a long position at a price PC,LP_{C,L} or a short position at a price PC,SP_{C,S}(other notations have been introduced in theoretical pricing).

Side
Price to close a position

Long

Short

Example

Let's consider the close of the long and short positions presented in the numerical example in position opening:

  • A trader wants to immediately close the long position with an open price PO,L=100.59ā€…DAIP_{O,L}= 100.59 \: DAI. Given one could borrow ETH at a yearly fixed rate of rB,b=3.10%r_{B,b}=3.10\%ā€‹ and lend DAI at a yearly fixed rate rQ,l=9.90%r_{Q,l}=9.90\%, and given the total debt to reimburse at expiry is D=50.59ā€…DAID=50.59 \: DAI, the price at which a trader could immediately close the position is:

PC,L=99.90(1+0.0310)0.25+50.59āˆ—(1āˆ’1(1+0.0990)0.25)=100.32ā€…DAIP_{C,L}= \dfrac{99.90}{{(1+0.0310)}^{0.25}} + 50.59 * \bigg( 1 - \dfrac{1}{{(1+0.0990)}^{0.25}} \bigg) = 100.32 \:DAI

  • A trader wants to immediately close the short position with an entry price PO,S=102.70ā€…DAIP_{O,S} =102.70 \: DAI. Given one could lend ETH at a yearly fixed rate of rB,l=2.90%r_{B,l}=2.90\%ā€‹ and borrow DAI at a yearly fixed rate rQ,b=10.10%r_{Q,b}=10.10\%, and given the total money to get back from lending (principal + interest) is L=152.70ā€…DAIL=152.70 \:DAI, the price at which a trader could immediately close the position is:

PC,S=100.10(1+0.0290)0.25+152.70āˆ—(1āˆ’1(1+0.1010)0.25)=103.02ā€…DAIP_{C,S}= \dfrac{100.10}{{(1+0.0290)}^{0.25}} + 152.70 * \bigg( 1 - \dfrac{1}{{(1+0.1010)}^{0.25}} \bigg) = 103.02 \:DAI

Demonstration

Long

Let's consider a trader who wants to immediately close a long position of 1ā€…ETH1 \:ETH (numerical applications rely on the above example):

1. The protocol gets back the base currency which was lent, 1(1+rB,b)T\dfrac{1}{{(1+r_{B,b})}^T}, i.e. 0.9924ā€…ETH0.9924 \:ETH.

2. This base currency is swapped back to the quote currency, SS(1+rB,b)T\dfrac{S_{S}}{{(1+r_{B,b})}^T}, i.e. 99.14ā€…DAI99.14 \:DAI.

3. The protocol buys back the debt DD, today worth D(1+rQ,l)T\dfrac{D}{{(1+r_{Q,l})}^T}, i.e. 49.41ā€…DAI49.41 \: DAI.

4. For closing the position earlier, the trader will get back money on the debt, Dāˆ’D(1+rQ,l)TD - \dfrac{D}{{(1+r_{Q,l})}^T} or D(1āˆ’1(1+rQ,l)T)D \bigg( 1 - \dfrac{1}{{(1+r_{Q,l})}^T} \bigg), i.e. 1.18ā€…DAI1.18 \: DAI.

5. Hence the money the trader gets back for closing the long position is SS(1+rB,b)T+D(1āˆ’1(1+rQ,l)T)\dfrac{S_{S}}{{(1+r_{B,b})}^T} + D \bigg( 1 - \dfrac{1}{{(1+r_{Q,l})}^T} \bigg), i.e 100.32ā€…DAI100.32 \:DAI.

Short

Let's consider a trader who wants to immediately close a short position of 1ā€…ETH1 \:ETH (numerical applications rely on the above example):

1. The protocol needs 1(1+rB,l)Tā€…ETH\dfrac{1}{{(1+r_{B,l})}^T} \: ETHto close the debt, i.e. 0.9929ā€…ETH0.9929 \:ETH.

2. Hence the protocol needs SL(1+rB,l)Tā€…DAI\dfrac{S_{L}}{{(1+r_{B,l})}^T} \: DAIto close the debt, i.e. 99.39ā€…DAI99.39 \: DAI.

3. On the other hand, the protocol gets back L(1+rQ,b)Tā€…DAI\dfrac{L}{{(1+r_{Q,b})}^T} \: DAIfrom lending, i.e. 149.07ā€…DAI149.07 \: DAI.

4. The money lost in lending for closing the position earlier is Lāˆ’L(1+rQ,b)Tā€…DAIL-\dfrac{L}{{(1+r_{Q,b})}^T} \: DAIor L(1āˆ’1(1+rQ,b)T)ā€…DAIL \bigg(1-\dfrac{1}{{(1+r_{Q,b})}^T} \bigg) \: DAI , i.e. 3.63ā€…DAI3.63 \: DAI.

5. Hence the money the trader gets back for closing the short position is SL(1+rB,l)T+L(1āˆ’1(1+rQ,b)T) \dfrac{S_{L}}{{(1+r_{B,l})}^T} + L \bigg( 1 - \dfrac{1}{{(1+r_{Q,b})}^T} \bigg), i.e. 103.02ā€…DAI103.02\:DAI.

Last updated