DueDEX calculates the Premium Index (P) and Interest Rate (I) every minute and then performs a 8-Hour Time-Weighted-Average-Price (TWAP) over the series of minute rates.
The Funding Rate is next calculated with the 8-Hour Interest Rate Component and the 8-Hour Premium / Discount Component. A +/-0.05% dampener is added.
Funding Rate (F) = Premium Index (P) + clamp (Interest Rate (I) - Premium Index (P), 0.05%, -0.05%)
Formula above is equivalent to below:
When I – P >= 0.05%，F = P + 0.05%
I – P <= -0.05%，F = P – 0.05%
-0.05% < I – P < 0.05%，F = I
The Funding Amount to be paid or received at the Funding Timestamp will be finally calculated by Funding Rate above and position value.