Formula
Let bemark_twap, be oracle_twap, and the current oracle price.
The term (≈ 0.02% per period) is a cost-of-carry offset that nudges
longs to pay shorts even when mark equals oracle. The ±3.03% clamp (via )
caps the worst-case per-period payment.
Breaking it down:
Why a carry offset?
Why a carry offset?
Even when mark == oracle exactly, perpetuals structurally benefit longs (they
get price exposure without owning the asset). The offset charges longs ≈0.02%
per period (≈1.75% annualized) to compensate shorts for providing the
counterparty liquidity.
Why TWAP, not spot?
Why TWAP, not spot?
Using raw prices lets a single fill near the funding crank time swing the
rate. TWAPs smooth that out. Both mark and oracle are tracked as 1-hour
exponential moving averages.
Why the ±3% clamp?
Why the ±3% clamp?
Caps the worst-case per-period payment. A 3.03% clamp per hour is ≈26.5%
annualized, enough to keep the peg alive but not enough for a single
manipulated hour to nuke open interest.
TWAP update
Clamped so that ifelapsed ≥ period, twap_new = price exactly (the memory has
washed out).
- Period: 3600s
- Funding period: 3600s (minimum interval between
update_funding_ratecalls)
Settlement
Funding is accumulated globally (cumulative_funding_rate_long,
_short) and applied lazily per user:
If payment > 0 and the user is long, collateral decreases (they pay). If
the user is short, collateral increases (they earn). Signs flip when
payment < 0.
The divisor 1000 bridges the BASE_PRECISION / QUOTE_PRECISION ratio.
Settlement happens automatically on every user trade, and on-demand via
settle_funding (permissionless; anyone can crank any user account).
Who runs the crank?
update_funding_rate is permissionless. In practice:
- Protocol itself: delta-vault calls
settle_fundingwhen claiming yield. - Keeper bots: Any third party can call
update_funding_rateonce per period to bank the current rate. No reward is hard-coded in the protocol, but integrators can layer MEV or incentive schemes on top.
Read next
kimia-perp reference
Funding instructions and accounts.
Run a keeper
Script to crank funding + liquidations.

