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=400ETH
Openfee=0.03%
Basespread=0.05%
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:
Openfee=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:
Openposition=(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:
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
Longnewβ - the new long position size
Depth - the depth parameter of this asset
The final opening price of the position:
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=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:
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
Borrowfee,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:
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
Longfundingrate=fundingrate=0.02832957976%
The trader will be charged the following hourly amount:
1.331831904ETHβETHpriceβLongfundingrate=1.331831904ETHβ1500ETH/USDβ0.0283313325%=0.56598858759USD
Let's calculate the trader's liquidation price after one day:
LiquidationPriceDistance==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
Liquidationprice=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:
Closeprice=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:
PnLLongβ=(OpenpriceClosepriceββ1)β(CollateralβOpenfee)βLeverage==(1500.7899981999ββ1)β(1000β0.6)β2=663.531975
Where:
PnLLongβ - the profit or loss from an open position
We then calculate the close fee:
Π‘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:
PnLLongβ=(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:
PnLLongβ - profit or loss from an open position