Calculating borrowing fees
Learn how to calculate trader's borrowing fees
Last updated
Was this helpful?
Learn how to calculate trader's borrowing fees
Last updated
Was this helpful?
Borrowing fees are paid only by one side (either longs or shorts) which is decided by current open interest (higher OI pays the fee)
Each pair is part of a group, meaning that borrowing fee should be calculated for pair and pair's group and the higher of two should be charged (never both)
Borrowing fee is charged on trader's position size (collateral * leverage)
The formula for borrowing fee per block is:
Let's calculate the borrowing fee for ENA/USD pair (pairIndex
is 219
) against USDC collateral (collateralIndex
is 3
)
Access current open interests and fees for given collateral and pair index via endpoint described .
To calculate ENA/USD borrowing fees, we use the following object retrieved from Step 1:
With these values, we can calculate the pair's borrowing fee (per block):
Now we need to do the same for group fee, reading the groupIndex
from the same trading-variables
response (for this example, groupIndex
is 2
). The process is the same as for calculating pair fees, using groups
values of borrowingFees
:
Therefore, the group's borrowing fee (per block) will be:
In this example, groupFeePairBlock
is greater than pairFeePerBlok
(1.9431296324610092e-7 > 1.9219146149012726e-7
) so groupFeePairBlock
is the effective feePerBlock
.
To estimate the hourly paid fee, we need to multiply the number of blocks per hour feePerBlock
.
For this example, on Arbitrum (12000 blocks per hour), the estimated borrowing fee per hour is:
Which corresponds to gTrade's UI: