Funding
Funding on a company perpetual is dYdX's: an 8-hour rate, paid every hour (the
funding-tick epoch, 3,600 s), from longs to shorts when positive and from shorts to longs
when negative, applied to the perpetual's funding index at the index I. Binaries, calls and
puts never pay funding.
What differs is who votes the premium. On dYdX each block's proposer votes each market's premium from its own view of the book and the oracle, and nothing checks those votes against the book. For a company perpetual the chain votes itself, from state every validator sees:
- a proposer's premium vote for any chain market is refused, in ProcessProposal and in
DeliverTx (
ErrPremiumVoteForChainMarket, perpetuals error 20010); - the chain adds one vote a block for each active company whose book is active and whose index is BLENDED and fresh, from the premium it computed in the previous block's EndBlock.
The premium
Each block's premium sample is
premium = (max(0, bid − I) − max(0, I − ask)) / I
with bid and ask the impact bid and ask: the average price of selling, and of buying, the
tier's impact notional, $1,000 (CompanyPerp's impact_notional), into the covered
long-term orders of that block's book sample, best first (the bid rounded down, the ask up).
It is truncated toward zero to a ppm and held within ±2% (max_abs_premium_ppm, and the
tier's vote clamp).
A sample counts only from a valid book sample whose two sides each hold the impact notional, in a block the index is blended and fresh. The vote is the average of the samples over the book ring (60 blocks, valid once 40 are), truncated toward zero: a quote has to be there, with $1,000 behind it, for most of a minute to move funding. A book above the index gives a positive premium, and longs pay. A zero premium casts no vote.
From votes to the rate
- Every minute (the
funding-sampleepoch, 60 s) a funding sample is taken: the median of the block votes, padded with zeros up to the minimum vote count (min_num_votes_per_sample, 15 on the testnet). - Every hour the 8-hour rate is the average of the samples, held within the tier's clamp
(
funding_rate_clamp_factor_ppm600% × (initial − maintenance) = 600% × 20% = 120%), then within the company's bound, ±1% per 8 hours by default (max_abs_funding_rate_ppm, at most 10%). - The rate is 0 while the perpetual's book isn't active.
Each hour a holder of n contracts pays n × I × rate / 8 (positive n is long), settled into its USDC the next time its subaccount is updated.
Example
I = $50.00, blended and fresh. All hour the covered book holds at least $1,000 at a bid of $50.60 and at an ask of $50.70. The impact prices are $50.60 and $50.70, the premium 0.60 / 50 = 1.2%, so the 8-hour rate is 1.2%, clamped to 1%. Each hour a long pays 1% / 8 × $50 = $0.0625 a contract, and a short receives it.
A book 1% wide around I ($49.75 / $50.25) votes nothing, whoever quotes a few contracts inside it: their quotes don't hold the notional, so the impact prices stay either side of I.
When there is no funding
No funding is voted while the index is held, in fallback, or blended but stale on fading expiries, nor while the company is halted. The trading app shows "none" with the reason.
Reading it
- The chain's premium for the next vote:
premium_ppmandpremium_validin/dydxprotocol/binary/company_index/{company_id}, with the block'simpact_bidandimpact_ask. - Premium votes and samples:
/dydxprotocol/perpetuals/premium_votes,/dydxprotocol/perpetuals/premium_samples. - The funding index:
funding_indexin/dydxprotocol/perpetuals/perpetual/{id}. - Epochs:
/dydxprotocol/v4/epochs/epoch_info. - Historical funding by market: the indexer's
/v4/historicalFunding/{ticker}(indexer HTTP API).
One subaccount's bid of $1,000, one tick under an honest ask, can be the whole impact bid and make longs pay; anyone selling into it receives the funding. See rules and risks.