Net Funding

Perpetual futures charge or pay a funding rate periodically. In a pair trade, you're paying funding on one side and receiving it on the other. The net funding rate tells you the combined funding cost (or income) of the entire basket.

How It Works

  • Long positions pay funding when the rate is positive (and receive when negative).

  • Short positions receive funding when the rate is positive (and pay when negative).

The net funding rate is the weighted sum across all assets, with signs flipped to reflect the actual cost to the trader:

  • Longs: subtract the funding rate (you're paying it)

  • Shorts: add the funding rate (you're receiving it)

A negative net funding rate means you're paying to hold the position. A positive net funding rate means you're earning by holding it.

Code

type Token = { symbol: string; weight: number };
type TokenPriceMap = Map<string, { markPrice: number; funding: number }>;

function computeNetFundingRate(
  longTokens: Token[],
  shortTokens: Token[],
  prices: TokenPriceMap,
): number {
  let total = 0;
  for (const t of longTokens) {
    const funding = prices.get(t.symbol)?.funding;
    if (funding !== undefined && t.weight > 0) {
      total += -funding * t.weight;
    }
  }
  for (const t of shortTokens) {
    const funding = prices.get(t.symbol)?.funding;
    if (funding !== undefined && t.weight > 0) {
      total += funding * t.weight;
    }
  }
  return total;
}

Example

Given a basket: 50% long HYPE (funding: 0.01%), 25% short ASTER (funding: 0.03%), 25% short XPL (funding: -0.02%):

Slightly negative β€” you're paying a small amount to hold this basket.

Last updated