The calculation of NextFundingFeePerUnit involves multiplying block.timestamp - lastUpdatedTimeStamp twice, leading to the exponential growth of fundingFeePerUnit.
If we look at the SettlementBranch:_fillOrder function, and there calculation involved to calculate the fundingFeePerUnit.
Initially the fundingRate is getting calculated, and using that the nextFundingFeePerUnit is getting calculated. If we look and the function perpMarket:getCurrentFundingRate.
If we go through the code, it will get complex, so I will explain the mathematical calculations involved in the calculation of fundingRate and nextFundingFeePerUnit.
The mathematical calculations involved in calculating the fundingRate and nextFundingFeePerUnit are:
fundingRateThe ProportionalElapsedSinceLastFunding is calculated by subtracting current and lastupdated Timestamp, and it is divided by 1 day to convert the seconds to days as the current funding velocity is in days.
Calculated elapsed timestamp is getting multiplied with CurrentFundingVelocity.
Now that fundingRate is being used to calculate fundingFeePerUnit
fundingFeePerUnitNow if we look calculation of PendingFundingFeePerUnit it is getting multiplied by ProportionalElapsedSinceLastFunding and avgFundingRate is already multiplied by ProportionalElapsedSinceLastFunding so double multiplication of ProportionalElapsedSinceLastFunding will grow the funding fee exponentially(Quadratically).
Unbalance of short and long fundingFee as the calculation will be time dependent and non-linear growth will create unbalance.
As funding fees grow exponentially, the cost burden on traders can become unsustainable, leading to a higher risk of liquidation, especially for leveraged positions.
Increased Costs for Traders
Manual Review
Multiply elapsedTime one time.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.