Perpetual futures

A perpetual future ("perp") is a derivative with no expiry date. An ordinary future converges to spot because it settles at maturity; a perp has no maturity to enforce that convergence, so it would be free to drift arbitrarily far from the underlying. The fix is a periodic funding payment exchanged directly between longs and shorts, a synthetic, recurring "dividend" whose sign and size depend on how far the perp trades from its index. That single cash flow is what tethers a contract that never settles to the asset it is supposed to track.

A contract with no expiry, and why it needs funding

In a dated future, the mechanism that pins price to value is settlement: as expiry approaches, the basis (futures minus spot) is squeezed to zero because the two converge to the same cash flow at maturity. Strip out the expiry and that anchor disappears. A perpetual instead manufactures a continual incentive to close the gap. If the perp trades above the index, holding a long is made to cost something; if it trades below, holding a long is made to pay something. Arbitrageurs respond to that carry, and their trades push the perp back toward the index, the same equilibrating role that convergence-to-settlement plays for a dated contract, but applied continuously rather than once at expiry.

The payment is keyed to a position's notional, not to the trader's margin, so it scales with exposure: $\text{funding payment} = \text{notional} \times F$ over each interval (classically every 8 hours). In code, funding_payment(position_notional, rate) returns the amount the long pays, and PerpPosition.apply_funding(mark_price, rate) debits or credits a position's collateral by $-\,\text{side}\times \text{notional}\times F$, so a long (side $+1$) pays and a short (side $-1$) receives when $F\,\textgreater\,0$.

The BitMEX-style funding rate

The modern crypto perpetual swap launched on BitMEX in 2016 (the XBTUSD contract), and its funding convention is now effectively the industry standard. The rate combines a time-weighted premium index $P$, how far the perp has been trading above or below the index, with a small interest-rate term $I$, clamped so the premium can only move funding within a band $\pm c$:

$F=P+\operatorname{clamp}(I-P,\,-c,\,+c)$

Read it from the inside out. When the premium is small, $I-P$ stays inside the band, the clamp is the identity, and the two $P$ terms cancel to leave $F\approx I$: funding is essentially just the interest term. When the premium is large, $I-P$ saturates against $\pm c$ and the surviving $P$ drives funding in the direction that penalises whichever side is pushing the perp off the index. The defaults in funding_rate(premium_index, interest_rate=0.0001, clamp=0.0005) use $I=0.01\%$ and a clamp band $c=0.05\%$ per interval, matching the BitMEX figures.

Who pays whom. A positive rate means the perp is rich relative to the index, so longs pay shorts; a negative rate means the perp is cheap, so shorts pay longs. Persistent funding of one sign invites a cash-and-carry trade, long the spot asset, short the perp in equal notional for a roughly delta-neutral book that collects funding each interval, and it is exactly that arbitrage pressure that keeps the perp tethered to spot.

Mark price and liquidation

Unrealised PnL and liquidation are judged not against the perp's last trade, which is cheap to manipulate with a single wick in a thin book, but against a manipulation-resistant mark price built from the external index plus a decaying funding basis. Using the mark price for margin checks is what prevents momentary, self-inflicted spikes from triggering unfair liquidations. Building that index is upstream of the contract; the position methods below take the mark price as given.

PerpPosition models a leveraged position with fields side ($\pm1$), size, entry_price, collateral, and maintenance_margin_ratio. Its unrealized_pnl(mark) is $\text{side}\times\text{size}\times (\text{mark}-\text{entry})$, account equity(mark) adds that to collateral, and leverage(mark) is notional over equity. A trader posts initial margin (roughly $1/\text{leverage}$ of notional) to open and must keep enough to satisfy the maintenance margin. The position is liquidated when equity drops to that floor:

$\text{equity}(\text{mark}) \le m \cdot \text{notional}(\text{mark}),$

with $m$ the maintenance-margin ratio (default $0.5\%$), exactly the test in is_liquidated(mark). Solving that boundary for the mark price gives the closed form in liquidation_price(): for a long, $p^\* = (\text{size}\cdot\text{entry}-\text{collateral})/(\text{size}\,(1-m))$, and for a short the symmetric $p^\* = (\text{size}\cdot\text{entry}+\text{collateral})/(\text{size}\,(1+m))$. Higher leverage means thinner collateral, which pulls $p^\*$ closer to the entry price and leaves less room before a liquidation.

Margining as a partial mechanism

Funding is a transfer, and a transfer is only incentive-compatible if it can actually be collected. Margining is the layer that makes the promise credible: it has no aggregation step, it turns no beliefs into a price, but it supplies the enforcement leg that every mechanism paying out over time relies on. In mechanism-design terms it restores limited liability and ex-post individual rationality, the constraints pure designs assume away, by demanding skin in the game. Call it a partial mechanism: one half of the aggregation-plus-reward pair, the half that guarantees the reward is real.

Its moving parts are themselves small mechanisms. Initial and maintenance margin set how much capital backs a position; the liquidation rule is a trigger; and the liquidation itself is a forced sale, disposing of inventory into a market that may be thin. That unwind is precisely the illiquid-goods control problem of Cotton & Papanicolaou (2022), where market making is modelled as a sequence of sealed-bid auctions and the optimal quote skew is driven by a super-linear inventory cost. The same collateral and liquidation arithmetic, priced through a pool rather than per position, is the subject of perpetual demand lending pools (collateral_ok, min_collateral, liquidation_price).

Basis, premium dynamics, and Shiller's perpetual claim

The basis, perp minus index, is the state variable the whole mechanism regulates. Funding turns a persistent basis into a recurring carry cost for the rich side, so in equilibrium the premium index $P$ hovers near zero and funding settles near the benign interest term $I$. The basis is not a flaw to be eliminated but the very signal that drives the corrective payments: it aggregates the market's collective view of the spot–perp relationship through carry, just as a continuous double auction aggregates beliefs through trades.

The intellectual origin is Shiller (1993), "Measuring Asset Values for Cash Settlement in Derivative Markets," which introduced the perpetual claim: a never-expiring derivative kept tethered to an index by a stream of dividend- or rent-like cash settlements, so that hedgers of long-lived, illiquid assets (home prices, national income) would never have to roll an expiring contract. Crypto perps inherit that skeleton exactly, no expiry plus a periodic anchoring cash flow, but swap Shiller's exogenous income flow for a market-driven funding rate keyed to the perp's own premium, because their underliers, unlike Shiller's, already have a continuous traded price to anchor against. For the lending side of the same leverage story, how funding-like flows price the cost of leveraged exposure in a pool, see perpetual demand lending pools.

Watch funding tether the perp

The mark price wanders, but each interval the funding rate $F = P + \mathrm{clamp}(I - P)$ pulls it back toward the index: longs pay shorts when the perp trades rich, shorts pay longs when it trades cheap. Watch mark oscillate around the index, with the cumulative funding on a 10k long.

mark    index

Try it: the funding formula

The funding rate $F = P + \mathrm{clamp}(I - P)$ tethers the perp to its index. Set the premium $P$ (perp over index) and a position notional; see the rate, who pays, and the long's cash flow over one interval.

Code: mechanisms/perp.py · Demo: examples/sim_perp.py · Related: demand lending pools · Research: perps-cda-monteprediction.md