Contango v1
  • Basics
    • 💃What is Contango?
    • 🤔What are expirables?
    • 📅Why expirables?
    • 💰Use cases
  • PROTOCOL
    • 🤯Theoretical pricing
    • ⚙️How it works
    • 🤓Protocol pricing
      • Position opening
      • Position closing
      • Price improvement
    • 🔁Borrowing and lending
      • Yield protocol
      • Notional
    • 🎛️Equity management
    • 📋Types of contracts
    • 🤝Delivery
    • 🪙Tokenomics
    • ⚠️Risks
    • 📖Tutorials
  • Resources
    • 👌Official links
    • 📑Contracts
    • 👨‍🏫Educational links
    • 📖Glossary
Powered by GitBook
On this page
  • Pricing
  • Example
  • Demonstration
  • Long
  • Short
  1. PROTOCOL
  2. Protocol pricing

Position closing

PreviousPosition openingNextPrice improvement

Last updated 2 years ago

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 LLL(principal + interest), and repay the owed debt, which at expiry would have represented an amount DDD(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}PC,L​ or a short position at a price PC,SP_{C,S}PC,S​(other notations have been introduced in ).

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 :

  • A trader wants to immediately close the long position with an open price PO,L=100.59 DAIP_{O,L}= 100.59 \: DAIPO,L​=100.59DAI. Given one could borrow ETH at a yearly fixed rate of rB,b=3.10%r_{B,b}=3.10\%rB,b​=3.10%​ and lend DAI at a yearly fixed rate rQ,l=9.90%r_{Q,l}=9.90\%rQ,l​=9.90%, and given the total debt to reimburse at expiry is D=50.59 DAID=50.59 \: DAID=50.59DAI, 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 \:DAIPC,L​=(1+0.0310)0.2599.90​+50.59∗(1−(1+0.0990)0.251​)=100.32DAI

  • A trader wants to immediately close the short position with an entry price PO,S=102.70 DAIP_{O,S} =102.70 \: DAIPO,S​=102.70DAI. Given one could lend ETH at a yearly fixed rate of rB,l=2.90%r_{B,l}=2.90\%rB,l​=2.90%​ and borrow DAI at a yearly fixed rate rQ,b=10.10%r_{Q,b}=10.10\%rQ,b​=10.10%, and given the total money to get back from lending (principal + interest) is L=152.70 DAIL=152.70 \:DAIL=152.70DAI, 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 \:DAIPC,S​=(1+0.0290)0.25100.10​+152.70∗(1−(1+0.1010)0.251​)=103.02DAI

Demonstration

Long

Let's consider a trader who wants to immediately close a long position of 1 ETH1 \:ETH1ETH (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}(1+rB,b​)T1​, i.e. 0.9924 ETH0.9924 \:ETH0.9924ETH.

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

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

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}D−(1+rQ,l​)TD​ or D(1−1(1+rQ,l)T)D \bigg( 1 - \dfrac{1}{{(1+r_{Q,l})}^T} \bigg)D(1−(1+rQ,l​)T1​), i.e. 1.18 DAI1.18 \: DAI1.18DAI.

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)(1+rB,b​)TSS​​+D(1−(1+rQ,l​)T1​), i.e 100.32 DAI100.32 \:DAI100.32DAI.

Short

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

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

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

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

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} \: DAIL−(1+rQ,b​)TL​DAIor L(1−1(1+rQ,b)T) DAIL \bigg(1-\dfrac{1}{{(1+r_{Q,b})}^T} \bigg) \: DAI L(1−(1+rQ,b​)T1​)DAI, i.e. 3.63 DAI3.63 \: DAI3.63DAI.

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)(1+rB,l​)TSL​​+L(1−(1+rQ,b​)T1​), i.e. 103.02 DAI103.02\:DAI103.02DAI.

🤓
PC,L=SS(1+rB,b)T+D(1−1(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)PC,L​=(1+rB,b​)TSS​​+D(1−(1+rQ,l​)T1​)
PC,S=SL(1+rB,l)T+L(1−1(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)PC,S​=(1+rB,l​)TSL​​+L(1−(1+rQ,b​)T1​)
theoretical pricing
position opening