Gravix
πŸš€ Dappβœ‰ Social Media
  • 🏠Welcome
    • About Gravix
    • Full trading guide
    • Top up your wallet (Everscale)
    • FAQ
  • βš–οΈ Trading
    • Full trading guide
    • How to
      • Trade
      • Edit position collateral
      • Share a position
      • Interface
    • Concepts
      • Fees
      • Spread
      • Position liquidation
      • Profit calculation
      • Trade lifecycle
      • Available Assets
      • Work time
  • πŸ”ƒReferral system
    • How to use
    • FAQ
  • πŸ›οΈ Staking
    • Staking overview
    • How to stake
Powered by GitBook
On this page
  • Lifecycle of a long trade
  • Fees while holding a position
  • Closing a position

Was this helpful?

  1. βš–οΈ Trading
  2. Concepts

Trade lifecycle

This page contains a description of the life cycle of transactions, the main stages of trading on the platform and the calculation formulas used to determine the value of transactions, profit and loss, as well as commissions and spreads.

The page also provides examples of PnL (profit and loss) calculations, and an explanation of the terms used on the platform.

Lifecycle of a long trade

Let's start by setting pool and position parameters for traders:

Depth=400  ETHDepth = 400\,\,ETH Depth=400ETH

Open fee=0.03%Open\,fee = 0.03\% Openfee=0.03%

Base spread=0.05%Base\,spread = 0.05\% Basespread=0.05%

Funding base rate=1%Funding\,base\,rate = 1\%Fundingbaserate=1%

Suppose a trader has decided to open a long position for the ETH/USD pair, using 1000 USDT as their collateral and setting the leverage at x2. After the smart contract receives 1000 USDT, it will calculate and charge an open fee, which depends on the size of the open position and the leverage. For this trade, the commission can be calculated using the following formula:

Open fee=Collateralβˆ—Leverageβˆ—Open fee rate=1000βˆ—2βˆ—0.03%=0.6  USDTOpen\,fee = Collateral*Leverage*Open \,fee\,rate = 1000 * 2 * 0.03\% = 0.6\, \,USDTOpenfee=Collateralβˆ—Leverageβˆ—Openfeerate=1000βˆ—2βˆ—0.03%=0.6USDT

Where:

  • Collateral - the amount a trader uses to open a position without taking leverage into account

  • Leverage - a multiplier indicating how much a trader's position is increased relative to their collateral

  • Open fee rate - the percentage rate charged by the exchange for opening a position. It may vary depending on the type of traded asset

Then the calculation of the amount of the trader's position takes place:

Open position=(Collateralβˆ’Open Fee)βˆ—Leverage=(1000βˆ’0.6)βˆ—2=1998.8Open\,position = (Collateral - Open\,Fee)*Leverage = (1000-0.6)*2= 1998.8Openposition=(Collateralβˆ’OpenFee)βˆ—Leverage=(1000βˆ’0.6)βˆ—2=1998.8

The next step is to determine the opening price of the position.

Let's calculate the dynamic spread:

Dynamic spread for long=max(0;(Long+0.5βˆ—Longnewβˆ’Short)Depthβˆ—0.1%)=max(0;(100+0.5βˆ—1.332533βˆ’90)400βˆ—0.1%)=0.002666566625%Dynamic\,spread\,for\,long = max(0; \cfrac{(Long + 0.5*Long_{new} - Short)}{Depth} * 0.1\%) = max(0; \cfrac{(100 + 0.5*1.332533 - 90)}{400} * 0.1\%) = 0.002666566625\%Dynamicspreadforlong=max(0;Depth(Long+0.5βˆ—Longnewβ€‹βˆ’Short)β€‹βˆ—0.1%)=max(0;400(100+0.5βˆ—1.332533βˆ’90)β€‹βˆ—0.1%)=0.002666566625%

Where:

  • Long/Short - the number of short/long positions

  • LongnewLong_{new}Longnew​ - the new long position size

  • Depth - the depth parameter of this asset

The final opening price of the position:

Open long price=Current priceβˆ—(1+Base spread+Dymamic spread)=1500βˆ—(1+0.05%+0.002666566625%)=1500.789998Open\,long\,price = Current\,price*(1+Base\,spread+Dymamic\,spread) = 1500 * (1 + 0.05\% + 0.002666566625\%) = 1500.789998 Openlongprice=Currentpriceβˆ—(1+Basespread+Dymamicspread)=1500βˆ—(1+0.05%+0.002666566625%)=1500.789998

Where:

  • Current price - the current price of the underlying asset in the market

  • Base spread - the fixed base spread

Funding calculations require the value of an open position in ETH:

Long,ETH=Open positionOpen long price=1998.81500.789998=1.331831904 ETHLong, ETH = \cfrac {Open\,position}{Open\,long\,price} = \cfrac {1998.8}{1500.789998} = 1.331831904\,ETHLong,ETH=OpenlongpriceOpenposition​=1500.7899981998.8​=1.331831904ETH

Where:

  • Long, ETH - the amount of Ethereum that was bought when opening a position

  • Open position - the size of a trader's open position

  • Open long price - the purchase price of Ethereum when opening a position

Fees while holding a position

A borrow fee will be continuously debited from the trader’s account: Borrow rate,per hour=Base rateβˆ—Leverage=0.001%βˆ—2=0.002%Borrow\,rate, per\,hour= Base\,rate * Leverage = 0.001\%*2 = 0.002\%Borrowrate,perhour=Baserateβˆ—Leverage=0.001%βˆ—2=0.002%

Where:

  • Borrow rate - the interest rate that the trader pays for using borrowed funds

  • Base rate - the base interest rate for borrowing, which depends on the type of asset used when opening a position

Borrow fee,per hour=Borrow rateβˆ—(Collateralβˆ’Open fee)=0.002%βˆ—(1000βˆ’0.6)=0.19988 USDTBorrow\,fee, per\,hour= Borrow\,rate * (Collateral -Open\,fee) = 0.002\% * (1000-0.6) = 0.19988\,USDTBorrowfee,perhour=Borrowrateβˆ—(Collateralβˆ’Openfee)=0.002%βˆ—(1000βˆ’0.6)=0.19988USDT

Where:

  • Borrow fee - the commission that the trader pays for using borrowed funds

Since there are more long positions open than short positions, the funding rate will be debited from the trader’s account:

Funding rate=Funding base rateβˆ—βˆ£Longβˆ’Short∣Market depth=1%βˆ—βˆ£100+1.331831904βˆ’90∣400=0.02832957976%Funding\,rate = Funding\,base\,rate * \cfrac {|Long - Short|}{Market\,depth} = 1\% * \cfrac {|100+1.331831904-90|}{400} = 0.02832957976\%Fundingrate=Fundingbaserateβˆ—Marketdepth∣Longβˆ’Shortβˆ£β€‹=1%βˆ—400∣100+1.331831904βˆ’90βˆ£β€‹=0.02832957976%

Where:

  • Funding rate - the funding rate that a trader pays or receives depending on the direction of his open position

  • Market Depth - the depth of the market, which determines how large the open amount of assets must be in order to affect the cost of funding

Long funding rate=funding rate=0.02832957976%Long\,funding\,rate = funding\,rate = 0.02832957976\%Longfundingrate=fundingrate=0.02832957976%

The trader will be charged the following hourly amount:

1.331831904 ETHβˆ—ETH  priceβˆ—Long funding rate=1.331831904 ETHβˆ—1500 ETH/USDβˆ—0.0283313325%=0.56598858759 USD1.331831904\,ETH * ETH\,\,price * Long\,funding\,rate = 1.331831904\,ETH * 1500 \,ETH/USD * 0.0283313325\% = 0.56598858759\,USD1.331831904ETHβˆ—ETHpriceβˆ—Longfundingrate=1.331831904ETHβˆ—1500ETH/USDβˆ—0.0283313325%=0.56598858759USD

Let's calculate the trader's liquidation price after one day:

Liquidation Price Distance==Open Priceβˆ—(Collateralβˆ—0.9βˆ’Borrow ratesβˆ’Funding fees)Collateralβˆ—Leverage==1500.789998βˆ—(1000βˆ—0.9βˆ’0.19988βˆ—24βˆ’0.56598858759βˆ—24)1000βˆ—2=661.562604108Liquidation\,Price\,Distance = \\ = \cfrac {Open\,Price * (Collateral * 0.9 - Borrow\,rates - Funding\,fees)} {Collateral * Leverage} = \\ = \cfrac {1500.789998 * (1000 * 0.9 - 0.19988 * 24 - 0.56598858759 * 24)} {1000 * 2} = 661.562604108LiquidationPriceDistance==Collateralβˆ—LeverageOpenPriceβˆ—(Collateralβˆ—0.9βˆ’Borrowratesβˆ’Fundingfees)​==1000βˆ—21500.789998βˆ—(1000βˆ—0.9βˆ’0.19988βˆ—24βˆ’0.56598858759βˆ—24)​=661.562604108

Where:

  • Liquidation Price Distance - the distance between the current price and the liquidation price of the position. It is used to determine when the position will be liquidated

Liquidation price=Open priceβˆ’Liquidation Price Distance1βˆ’Close spread==1500.789998βˆ’661.5626041081βˆ’0.05%=839.6472175 ETH/USDLiquidation\,price = \cfrac {Open\,price - Liquidation\,Price\,Distance}{1-Close\,spread} = \\ = \cfrac {1500.789998 - 661.562604108}{1-0.05\%} = 839.6472175\,ETH/USDLiquidationprice=1βˆ’ClosespreadOpenpriceβˆ’LiquidationPriceDistance​==1βˆ’0.05%1500.789998βˆ’661.562604108​=839.6472175ETH/USD

Where:

  • Liquidation price - the price at which the position will be liquidated

Closing a position

We will assume that ETH has risen to 2,000 USD in 24 hours. Let’s calculate how much profit the trader will receive after closing their position:

Close price=2000βˆ—(1βˆ’Base spread)=2000βˆ—(1βˆ’0.05%)=1999Close\,price = 2000*(1-Base\,spread) = 2000*(1-0.05\%) = 1999Closeprice=2000βˆ—(1βˆ’Basespread)=2000βˆ—(1βˆ’0.05%)=1999

Where:

  • Close price - the price at which the trader closes their position

The trader’s profit excluding fees is then calculated:

PnL Long=(Close priceOpen priceβˆ’1)βˆ—(Collateralβˆ’Open fee)βˆ—Leverage==(19991500.789998βˆ’1)βˆ—(1000βˆ’0.6)βˆ—2=663.531975PnL_{\,Long} = ( \cfrac {Close\,price} {Open\,price} - 1) * (Collateral - Open\,fee) * Leverage = \\ = (\cfrac{1999} {1500.789998} - 1) * (1000 - 0.6) * 2 = 663.531975PnLLong​=(OpenpriceClosepriceβ€‹βˆ’1)βˆ—(Collateralβˆ’Openfee)βˆ—Leverage==(1500.7899981999β€‹βˆ’1)βˆ—(1000βˆ’0.6)βˆ—2=663.531975

Where:

  • PnL LongPnL_{\,Long}PnLLong​ - the profit or loss from an open position

We then calculate the close fee:

Π‘lose fee=((Collateralβˆ’Open fee)βˆ—Leverage+PnLβˆ’Funding feeβˆ’Borrow fee)βˆ—Close fee rate=((1000βˆ’0.6)βˆ—2+663.531975βˆ’0.56598858759βˆ—24βˆ’0.19988βˆ—24)βˆ—0.03%=0.793186Π‘lose\,fee = ((Collateral-Open\,fee) * Leverage + PnL - Funding\,fee - Borrow\,fee) * Close\,fee\,rate = ((1000-0.6) * 2 + 663.531975 - 0.56598858759 * 24 - 0.19988*24) * 0.03\% = 0.793186Π‘losefee=((Collateralβˆ’Openfee)βˆ—Leverage+PnLβˆ’Fundingfeeβˆ’Borrowfee)βˆ—Closefeerate=((1000βˆ’0.6)βˆ—2+663.531975βˆ’0.56598858759βˆ—24βˆ’0.19988βˆ—24)βˆ—0.03%=0.793186

Where:

  • Close fee - the commission charged for closing a position

  • Close fee rate - equals the Open fee rate for this type of asset

Finally, we calculate the trader’s profit after payment of all fees:

PnL Long=(Close priceOpen priceβˆ’1)βˆ—(Collateralβˆ’Open fee)βˆ—Leverageβˆ’Fundingfeeβˆ’Borrowfeeβˆ’Close fee=(19991500.789998βˆ’1)βˆ—(1000βˆ’0.6)βˆ—2βˆ’0.56598858759βˆ—24βˆ’0.19988βˆ—24βˆ’0.793186=644.3579433PnL_{\,Long} = ( \cfrac {Close\,price} {Open\,price} - 1) * (Collateral - Open\,fee) * Leverage - Funding fee - Borrow fee - Close\,fee = (\cfrac{1999} {1500.789998} - 1) * (1000 - 0.6) * 2 - 0.56598858759 * 24 - 0.19988*24 - 0.793186 = 644.3579433PnLLong​=(OpenpriceClosepriceβ€‹βˆ’1)βˆ—(Collateralβˆ’Openfee)βˆ—Leverageβˆ’Fundingfeeβˆ’Borrowfeeβˆ’Closefee=(1500.7899981999β€‹βˆ’1)βˆ—(1000βˆ’0.6)βˆ—2βˆ’0.56598858759βˆ—24βˆ’0.19988βˆ—24βˆ’0.793186=644.3579433

Where:

  • PnL LongPnL_{\,Long}PnLLong​ - profit or loss from an open position

PreviousProfit calculationNextAvailable Assets

Last updated 1 year ago

Was this helpful?

Funding base rate - the base funding rate

set by Gravix
Page cover image