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 with margin
  • Formulas
  • Example
  • Demonstration
  • Pricing with margin ratio
  • Formulas
  • Example
  1. PROTOCOL
  2. Protocol pricing

Position opening

PreviousProtocol pricingNextPosition closing

Last updated 2 years ago

Pricing with margin

Formulas

The formulas below present the price at which a trader could open a long position at a price PO,LP_{O,L}PO,L​ or a short position at a price PO,SP_{O,S}PO,S​ with an initial margin MMM (other notations have been introduced in ).

Side
Price to open a position

Long

Short

Contango protocol provides a price improvement compared to the theoretical formulas presented in :

  • Since M∗[(1+rQ,b)T−1]>0M *[{(1+r_{Q ,b })}^T -1] > 0M∗[(1+rQ,b​)T−1]>0, the price to open a long position is at a lower price, i.e. more favourable to the trader.

  • Since M∗[(1+rQ,l)T−1]>0M *[{(1+r_{Q , l})}^T -1] > 0M∗[(1+rQ,l​)T−1]>0, the price to open a short position is at a higher price, i.e. more favourable to the trader.

Example

Let's consider a contract on ETHDAI expiring in 3 months (T=1T=1T=1) and where the traders posts 50 DAI50 \:DAI50DAI as margin:

  • Given one could borrow DAI at a yearly fixed rate of rQ,b=10.10%r_{Q,b}=10.10\%rQ,b​=10.10%​, lend ETH at a yearly fixed rate rB,l=2.90%r_{B,l}=2.90\%rB,l​=2.90%and buy ETH on the spot market at SL=100.10 DAIS_{L}=100.10\:DAISL​=100.10DAI then the price at which a trader could open a long a position is:

PO,L=100.10∗(1+0.10101+0.0290)0.25−50∗[(1+0.1010)0.25−1]=100.59 DAIP_{O,L}=100.10*{ \bigg( \dfrac{1+0.1010}{1+0.0290} \bigg) }^{0.25} - 50 *[{(1+{0.1010})}^{0.25} -1] = 100.59 \: DAIPO,L​=100.10∗(1+0.02901+0.1010​)0.25−50∗[(1+0.1010)0.25−1]=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%​, lend DAI at a yearly fixed rate of rQ,l=9.90%r_{Q,l}=9.90\%rQ,l​=9.90%and sell ETH on the spot market at SS=99.90 DAIS_{S}=99.90\:DAISS​=99.90DAI then the price at which a trader could open a short position is:

PO,S=99.90∗(1+0.09901+0.0310)0.25+50∗[(1+0.0990)0.25−1]=102.70 DAIP_{O,S}=99.90*{ \bigg( \dfrac{1+0.0990}{1+0.0310} \bigg) }^{0.25} + 50 *[{(1+{0.0990})}^{0.25} -1] = 102.70\: DAIPO,S​=99.90∗(1+0.03101+0.0990​)0.25+50∗[(1+0.0990)0.25−1]=102.70DAI​

Demonstration

Long

Let's consider that a trader wants to buy 1 expirable (the numerical values are taken from the above example). In this demonstration, we will present the steps to replicate the cash flows of a expirable position. Let's figure out the price of the expirable, i.e. the DAI money needed, to get 1 ETH at expiry:

Short

Let's consider a trader who wants to sell 1 expirable (the numerical values are taken from the example above). This means she would give 1 ETH at expiry, let's figure out the steps and how much money she would need to receive at expiry:

Pricing with margin ratio

Formulas

Side
Price to open a position

Long

Short

Example

1. To receive 1 ETH at expiry, the trader needs to lend 1(1+rB,l)T ETH\dfrac{1}{(1+r_{B,l})^T} \: ETH(1+rB,l​)T1​ETH, i.e. 0.9929 ETH0.9929 \: ETH0.9929ETH

2. To get that ETH, the trader first swaps SL(1+rB,l)T DAI\dfrac{S_{L}}{(1+r_{B,l})^T} \: DAI(1+rB,l​)TSL​​DAI, i.e. 99.39 DAI99.39 \: DAI99.39DAI.

3. Since the trader has already some margin, she only needs to borrow SL(1+rB,l)T−M DAI\dfrac{S_{L}}{(1+r_{B,l})^T} - M \: DAI(1+rB,l​)TSL​​−MDAI, i.e. 49.39 DAI49.39 \: DAI49.39DAI.

4. The debt DDD the trader owes at expiry (principal + interest) is: D=[SL(1+rB,l)T−M]∗(1+rQ,b)T DAID = [\dfrac{S_{L}}{(1+r_{B,l})^T} - M] * {(1+r_{Q , b})}^T \: DAID=[(1+rB,l​)TSL​​−M]∗(1+rQ,b​)TDAI, i.e. D=50.59 DAID=50.59 \: DAID=50.59DAI.

5. Hence, the money needed to receive 1 ETH at expiry is the sum of the debt and the margin provided: [SL(1+rB,l)T−M]∗(1+rQ,b)T+M DAI[\dfrac{S_{L}}{(1+r_{B,l})^T} - M] * {(1+r_{Q , b})}^T + M \: DAI[(1+rB,l​)TSL​​−M]∗(1+rQ,b​)T+MDAI or SL∗(1+rQ,b1+rB,l)T−M∗[(1+rQ,b)T−1] DAIS_{L}*{ \bigg( \dfrac{1+r_{Q,b}}{1+r_{B,l}} \bigg) }^T - M *[{(1+r_{Q ,b })}^T -1] \: DAISL​∗(1+rB,l​1+rQ,b​​)T−M∗[(1+rQ,b​)T−1]DAI, i.e. 100.59 DAI100.59 \: DAI100.59DAI.

1. The trader will give 1 ETH at expiry to reimburse a debt. Hence the trader borrows 1(1+rB,b)T ETH\dfrac{1}{(1+r_{B,b})^T} \: ETH(1+rB,b​)T1​ETH, i.e. 0.9924 ETH0.9924 \: ETH0.9924ETH.

2. The trader swaps the ETH to get SS(1+rB,b)T DAI\dfrac{S_{S}}{(1+r_{B,b})^T} \: DAI(1+rB,b​)TSS​​DAI, i.e. 99.14 DAI99.14 \: DAI99.14DAI.

3. The trader lends the DAI from the swap and her margin. At expiry the trader receives an amount L=[SS(1+rB,b)T+M]∗(1+rQ,l)T DAIL=[\dfrac{S_{S}}{(1+r_{B,b})^T} + M] *{(1+r_{Q , l})}^T \: DAIL=[(1+rB,b​)TSS​​+M]∗(1+rQ,l​)TDAI, i.e. L=152.70 DAIL=152.70 \: DAIL=152.70DAI.

4. The amount of money the trader will receive at expiry, which is also the price of the expirable, is the difference between the amount L and the margin: [SS(1+rB,b)T+M]∗(1+rQ,l)T−M DAI[\dfrac{S_{S}}{(1+r_{B,b})^T} + M] *{(1+r_{Q , l})}^T - M \: DAI[(1+rB,b​)TSS​​+M]∗(1+rQ,l​)T−MDAI or SS∗(1+rQ,l1+rB,b)T+M∗[(1+rQ,l)T−1] DAIS_{S}*{ \bigg( \dfrac{1+r_{Q,l}}{1+r_{B,b}} \bigg) }^T + M *[{(1+r_{Q , l})}^T -1] \: DAISS​∗(1+rB,b​1+rQ,l​​)T+M∗[(1+rQ,l​)T−1]DAI, i.e. 102.70 DAI102.70 \: DAI102.70DAI.

Given the MRMRMR:

the margin for a long position could be expressed as M=MR∗PO,LM = MR*P_{O,L}M=MR∗PO,L​, e.g. if the price to open a long position is PO,L=100 DAIP_{O,L}=100 \:DAIPO,L​=100DAI and if the trader wants a margin ratio of 50%, then the required margin is M=50 DAIM=50 \:DAIM=50DAI

the margin for a short position could be expressed as M=MR∗PO,SM = MR*P_{O,S}M=MR∗PO,S​, e.g. if the price to open a short position is PO,S=100 DAIP_{O,S}=100 \:DAIPO,S​=100DAI and if the trader wants a margin ratio of 50%, then the required margin is M=50 DAIM=50 \:DAIM=50DAI

Replacing the margin MMM in the main to open a position, we find new expressions depending on the collaterisation ratio MRMRMR :

Let's consider a contract on ETHDAI expiring in 3 months (T=1T=1T=1) where the trader puts a 50%50\%50%MR:

Given one could borrow DAI at a yearly fixed rate of rQ,b=10.10%r_{Q,b}=10.10\%rQ,b​=10.10%, lend ETH at a yearly fixed rate rB,l=2.90%r_{B,l}=2.90\%rB,l​=2.90% and buy ETH on the spot market at SL=100.10 DAIS_{L}=100.10\:DAISL​=100.10DAIthen the price at which a trader could open a long a position is:

PO,L=100.10∗(1.10101.0290)0.25∗11+0.5∗[(1.1010)0.25−1]=100.68 DAIP_{O,L}=100.10*{ \bigg( \dfrac{1.1010}{1.0290} \bigg) }^{0.25} * \dfrac{1}{1+0.5*[{(1.1010)}^{0.25} -1]}=100.68\:DAIPO,L​=100.10∗(1.02901.1010​)0.25∗1+0.5∗[(1.1010)0.25−1]1​=100.68DAI

Given one could borrow ETH at a yearly fixed rate of rB,b=3.10%r_{B,b}=3.10\%rB,b​=3.10%, lend DAI at a yearly fixed rate of rQ,l=9.90%r_{Q,l}=9.90\%rQ,l​=9.90%, and sell ETH on the spot market at SS=99.90 DAIS_{S}=99.90\:DAISS​=99.90DAI then the price at which a trader could open a short position is:

PO,S=99.90∗(1.09901.0310)0.25∗11−0.5∗[(1.0990)0.25−1]=100.31 DAIP_{O,S}=99.90*{ \bigg( \dfrac{1.0990}{1.0310} \bigg) }^{0.25} * \dfrac{1}{1-0.5*[{(1.0990)}^{0.25} -1]}=100.31\:DAIPO,S​=99.90∗(1.03101.0990​)0.25∗1−0.5∗[(1.0990)0.25−1]1​=100.31DAI

🤓
PO,L=SL∗(1+rQ,b1+rB,l)T−M∗[(1+rQ,b)T−1]P_{O,L}=S_{L}*{ \bigg( \dfrac{1+r_{Q,b}}{1+r_{B,l}} \bigg) }^T - M *[{(1+r_{Q ,b })}^T -1]PO,L​=SL​∗(1+rB,l​1+rQ,b​​)T−M∗[(1+rQ,b​)T−1]
PO,S=SS∗(1+rQ,l1+rB,b)T+M∗[(1+rQ,l)T−1]P_{O,S}=S_{S}*{ \bigg( \dfrac{1+r_{Q,l}}{1+r_{B,b}} \bigg) }^T + M *[{(1+r_{Q , l})}^T -1]PO,S​=SS​∗(1+rB,b​1+rQ,l​​)T+M∗[(1+rQ,l​)T−1]
PO,L=SL∗(1+rQ,b1+rB,l)T∗11+MR∗[(1+rQ,b)T−1]P_{O,L}=S_{L}*{ \bigg( \dfrac{1+r_{Q,b}}{1+r_{B,l}} \bigg) }^T * \dfrac{1}{1+MR*[{(1+r_{Q ,b })}^T -1]}PO,L​=SL​∗(1+rB,l​1+rQ,b​​)T∗1+MR∗[(1+rQ,b​)T−1]1​
PO,S=SS∗(1+rQ,l1+rB,b)T∗11−MR∗[(1+rQ,l)T−1]P_{O,S}=S_{S}*{ \bigg( \dfrac{1+r_{Q,l}}{1+r_{B,b}} \bigg) }^T * \dfrac{1}{1-MR*[{(1+r_{Q ,l })}^T -1]}PO,S​=SS​∗(1+rB,b​1+rQ,l​​)T∗1−MR∗[(1+rQ,l​)T−1]1​
theoretical pricing
theoretical pricing
pricing formula
margin ratio