Net Funding
How It Works
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
Last updated