Contango v1
Search
K
Comment on page

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
PC,L=SS(1+rB,b)T+D(11(1+rQ,l)T)P_{C,L}= \dfrac{S_{S}}{{(1+r_{B,b})}^T} + D \bigg( 1 - \dfrac{1}{{(1+r_{Q,l})}^T} \bigg)
Short
PC,S=SL(1+rB,l)T+L(11(1+rQ,b)T)P_{C,S}= \dfrac{S_{L}}{{(1+r_{B,l})}^T} + L \bigg( 1 - \dfrac{1}{{(1+r_{Q,b})}^T} \bigg)

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.59DAIP_{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.59DAID=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(11(1+0.0990)0.25)=100.32DAIP_{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.70DAIP_{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.70DAIL=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(11(1+0.1010)0.25)=103.02DAIP_{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
1ETH1 \: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.9924ETH0.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.14DAI99.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.41DAI49.41 \: DAI
.
4. For closing the position earlier, the trader will get back money on the debt,
DD(1+rQ,l)TD - \dfrac{D}{{(1+r_{Q,l})}^T}
or
D(11(1+rQ,l)T)D \bigg( 1 - \dfrac{1}{{(1+r_{Q,l})}^T} \bigg)
, i.e.
1.18DAI1.18 \: DAI
.
5. Hence the money the trader gets back for closing the long position is
SS(1+rB,b)T+D(11(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.32DAI100.32 \:DAI
.

Short

Let's consider a trader who wants to immediately close a short position of
1ETH1 \:ETH
(numerical applications rely on the above example):
1. The protocol needs
1(1+rB,l)TETH\dfrac{1}{{(1+r_{B,l})}^T} \: ETH
to close the debt, i.e.
0.9929ETH0.9929 \:ETH
.
2. Hence the protocol needs
SL(1+rB,l)TDAI\dfrac{S_{L}}{{(1+r_{B,l})}^T} \: DAI
to close the debt, i.e.
99.39DAI99.39 \: DAI
.
3. On the other hand, the protocol gets back
L(1+rQ,b)TDAI\dfrac{L}{{(1+r_{Q,b})}^T} \: DAI
from lending, i.e.
149.07DAI149.07 \: DAI
.
4. The money lost in lending for closing the position earlier is
LL(1+rQ,b)TDAIL-\dfrac{L}{{(1+r_{Q,b})}^T} \: DAI
or
L(11(1+rQ,b)T)DAIL \bigg(1-\dfrac{1}{{(1+r_{Q,b})}^T} \bigg) \: DAI
, i.e.
3.63DAI3.63 \: DAI
.
5. Hence the money the trader gets back for closing the short position is
SL(1+rB,l)T+L(11(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.02DAI103.02\:DAI
.