Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Funding

Fundings are periodic payments between longs and shorts that anchor the perpetual contract price to the oracle. When the market trades above the oracle, longs pay shorts; when below, shorts pay longs. This mechanism discourages persistent deviations from the spot price without requiring contract expiry.

1. Premium

Each funding cycle begins with measuring how far the order book deviates from the oracle. The contract computes two impact prices by walking the book:

  • Impact bid — the volume-weighted average price (VWAP) obtained by selling worth of base asset into the bid side.
  • Impact ask — the VWAP obtained by buying worth from the ask side.

The premium is then:

If either side has insufficient depth to fill , its term contributes zero. When both sides lack depth, the premium is zero.

2. Sampling

A cron job runs frequently (e.g. every minute). Each invocation samples the premium for every active pair and accumulates it into the pair’s state:

Sampling more frequently than collecting gives the average premium resilience against momentary spikes — a single large order cannot dominate the rate.

3. Collection

When has elapsed since the last collection, the same cron invocation finalises the funding rate:

  1. Average premium:

  2. Clamp to the configured bounds:

  3. Funding delta — scale by the actual elapsed interval and oracle price:

  4. Accumulate into the pair-level running total:

  5. Reset accumulators: , , .

4. Position-level settlement

Accrued funding is settled on a position whenever it is touched — during a fill, liquidation, or ADL event:

After settlement the entry point is reset:

Sign convention: positive accrued funding is a cost to the holder (longs pay when the rate is positive, shorts pay when it is negative). The negated accrued funding is added to the user’s realised PnL. See Order matching §7a and Vault §4 for how this integrates with fill execution and vault accounting.

5. Parameters

FieldTypeDescription
funding_periodDurationMinimum time between funding collections.
impact_sizeUsdValueNotional depth walked on each side of the book to compute impact prices.
max_abs_funding_rateFundingRateSymmetric clamp applied to the average premium before scaling to a delta. Prevents runaway rates during prolonged skew.