Trade lifecycle
Last updated
Last updated
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.
Let's start by setting pool and position parameters for traders:
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:
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:
The next step is to determine the opening price of the position.
Let's calculate the dynamic spread:
Where:
Long/Short - the number of short/long positions
Depth - the depth parameter of this asset
The final opening price of the position:
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:
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
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
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:
Where:
Funding rate - the funding rate that a trader pays or receives depending on the direction of his open position
Funding base rate - the base funding rate set by Gravix
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
The trader will be charged the following hourly amount:
Let's calculate the trader's liquidation price after one day:
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
Where:
Liquidation price - the price at which the position will be liquidated
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:
Where:
Close price - the price at which the trader closes their position
The traderโs profit excluding fees is then calculated:
Where:
We then calculate the close fee:
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:
Where:
- the new long position size
A borrow fee will be continuously debited from the traderโs account:
- the profit or loss from an open position
- profit or loss from an open position