Help center
  • General Info
    • FlashFlow Overview
    • Price aggregation
    • Liquidity
  • Trading guides
    • How to connect a Wallet
    • How to choose a network
    • How to open and close a trade
    • How to swap coins
    • Order Types
  • Trading Conditions
    • Fees and funding
    • What coins can be collaterals
    • Liquidation
    • PnL calculations
    • Trading assets
  • For developers
    • Smart contracts
  • Referral program
    • Referral program
  • FAQ
    • Can I trust FlashFlow?
    • What makes FlashFlow stand out among other trading protocols?
    • How much is the maximum leverage?
    • Why do I have to confirm my order twice?
    • Do I have to make a deposit to start trading?
    • How does FlashFlow get profit?
    • Is it safe to connect your wallet to FlashFlow?
    • How much do I lose in case of liquidation?
    • Why are there two liquidation prices?
    • What is the 'Claim' feature in the Wallet settings?
  • Terms and policies
    • Terms of use
    • Cookie policy
    • Privacy policy
Powered by GitBook
On this page
  1. Trading Conditions

PnL calculations

To calculate the current PnL of a deal you may use the following example for ETH/DAI position:

Assume, we open an ETH/DAI in long using $1000 of DAI as collatral, with x5 leverage and slippage tolerance set to 0.5%, when DAI market price was at $0.99 and ETH market price at $2000 and ETH price rose to $2100

The amount of fees paid for opening a position on the market would be:

protocolFeeRate = 0.16%
flashLoanFeeRate = 0.09%

The amount of margin reserved for the loan would be:

margin = 1000 DAI
marginBaseOpenPrice = $0.99

Using the set order parameters we can calculate the Position Size in USD and ETH excluding the fees incurred, and the minimum size filled considering the current slippage tolerance applied:

collateralBaseOpenPrice = 2000
PositionSize = (margin × (leverage - 1) + margin) = 5000
totalSizeWithProtocolFee = positionSize - (positionSize × protocolFeeRate) = 4992
totalSizeWithSlippage = totalSizeWithProtocolFee - (totalSizeWithProtocolFee × slippage) = 4987.008
collateral = (totalSizeWithSlippage × marginBaseOpenPrice) / collateralBaseOpenPrice = 2.4685896 (ETH)

Now, we can calculate the amount of fees incurred to our position upon opening:

flashloanAmount = margin × (leverage - 1) = 4000
flashloanFee = (flashloanAmount × flashLoanFee) = 3.6

Next, we would have to calculate the funding rate and funding amounts. General formula to calculate the funding amount is the following:

fundingFee = (totalSizeWithSlippage - margin) × ratePerTime = 0.00648643

Where,

ratePerTime = (rateAPY / 100) × timePassed / 31536000 (seconds in 1 year) = 0.00000163, where

rateAPY = 1.43%
timePassed = 3600 (seconds in 1 hour)

For the simplicity of calculations, however, let's assume that the position hasn't been open for an hour yet, thus the funding fee has not yet been charged.

In order to find the PnL value, we would first need to calculate the current market prices for the position in DAI and ETH.

ethInUsdOpen = collateral × collateralBaseOpenPrice = 4937.13792
ethInUsdCurrent = collateral × collateralBaseCurrentPrice = 5183.994816
daiInUsd = (totalSizeWithSlippage - (flashloanFee - (fundingFee × hourPassed))) × marginBasePrice = 4983.74616

Now, in order to calculate the PnL of our position we have to find the difference between the current collateral market price and the open collateral market price:

TotalPnL = (ethInUsdCurrent / daiInUsd) × ethInUsdCurrent - ethInUsdOpen = $246.856896

PreviousLiquidationNextTrading assets

Last updated 2 years ago