Funding Rate = Average Premium + clamp(Interest Rate - Average Premium, ±0.05%)
Components:
ClearingHouse
periodically samples this premium and feeds it to the FundingRateCalculator
. The calculator then computes the simple average of these samples over the hour-long funding period to determine the Average Premium
.clamp
function is applied. The difference between the Interest Rate and the Average Premium is clamped, with a bound set to 0.05%. This limits the influence of this part of the formula on the final funding rate.FundingRateCalculator
is central to this process and manages the state throughout each funding period.
premium_samples
is maintained during the funding interval.calculate_funding_rate
function is triggered. This function computes the new funding rate based on the collected samples.last_funding_ts
(timestamp) and next_funding_ts
are also updated.