Liquidity Lu saysPerpetual futures use a funding rate to drive the mark price toward the index: when mark > index, longs pay shorts; when mark < index, shorts pay longs — every funding period.
Perpetuals have no expiry, so they need a mechanism to anchor them to the spot index. The funding rate does it: it is computed every funding period (8h typical) as roughly (mark − index) / index / periodsPerDay. Longs pay shorts that amount per unit position when mark exceeds index; shorts pay longs when mark falls below.
This aligns incentives without expiry: traders pay (or receive) to stay open, pushing mark back toward index. GMX, Synthetix, dYdX, and Hyperliquid all use variants. The demo shows funding across three mark/index scenarios.
Power-ups you unlock
Funding rate = (mark − index) / index / periodsPerDay
Longs pay shorts when mark > index
Shorts pay longs when mark < index
Anchors mark to index without expiry
GMX, Synthetix, dYdX, Hyperliquid all use variants
The Sandwich Bot attacks — common mistakes
Holding leveraged positions across funding without accounting
Forgetting funding rates can become extreme during sharp moves
Confusing funding rate with interest rate
Ignoring funding-rate arbitrage opportunities
Boss battleCompute the 8-hour funding rate for mark/index pairs (2050/2000), (1980/2000), and (2000/2000).
Example code
<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>
function funding(mark, index, periodH){
const premium = (mark - index) / index;
return premium / (24 / periodH);
}
const cases = [[2050, 2000], [1980, 2000], [2000, 2000]];
const rows = cases.map(([m, i]) => {
const f = funding(m, i, 8);
const dir = f > 0 ? 'longs pay shorts' : f < 0 ? 'shorts pay longs' : 'no funding (anchored)';
return ' mark=' + m + ' index=' + i + ' → funding ' + (f*100).toFixed(4) + '% / 8h (' + dir + ')';
});
document.getElementById('o').textContent = [
'perp funding rate per 8h period:',
'',
...rows,
'',
'positive funding pulls mark down toward index; negative pulls it up'
].join('\n');
</script></body></html>