Funding
Variables used
- : mark price at time .
- : index/oracle price at time .
- : per-sample premium.
- : sampling interval (seconds).
- : samples per hour.
- : per-sample clamp magnitude.
- : per-hour clamp magnitude.
- , : market and user funding indexes.
- : signed position size.
Premium sampling and TWAP
- Sample interval: X seconds.
- Per-sample premium is , clamped to ±Z (e.g., set ).
- Over one hour, collect samples and use their average as the hourly premium TWAP.
Funding increment and index
- Funding increment for the hour is the hourly premium TWAP divided by 24 (hourly slice of a daily rate). No price multiplication needed at this level.
- Apply a clamp to the hourly increment: pick a cap (e.g., for 1%) and use . Use the clamped value when updating the funding index.
- Store the funding index as an accumulator per market.
where is captured at funding time.
Margin impact
- Each account tracks its last funding index per market. The unrealized funding owed/receivable is based on the change in index and position size.
- Variables:
- : signed position size (positive = long, negative = short).
- : current market funding index.
- : user's last funding index for this market.
- Positive position with rising index pays; negative position receives.
Settling funding into PnL
- When settling, move UF into realized PnL and advance the user's funding index to the market's.
Attempted funding manipulation
- Flow of play (MM skews quotes to offload inventory):
- Attacker leans on one side to push away from across successive samples. moves toward +Z or -Z.
- The MM accumulates inventory on the pressured side and skews quotes the other way to shed that risk, re-centering toward . Each further push now requires the attacker to absorb more inventory at increasingly unfavorable prices as the MM skews.
- With samples every X seconds, holding near the clamp for an hour forces the attacker to keep trading into the skewed book repeatedly, driving cumulative cost higher.
- Per-sample clamp at ±Z limits how far any single can move; per-hour clamp at ±Y caps the funding drift. Upside is bounded while the inventory cost to maintain the skew keeps rising.
- Net: to achieve a capped funding shift (±Y/hour), the attacker must sustain growing inventory absorption against an MM that continuously skews toward index, making a prolonged attempt increasingly expensive and likely loss-making.
Outage
If an outage accrues for 1 minute or more, funding accrued during the outage is ignored (set to zero). This is calculated per funding period.
RFQ
Funding sampling
To find out funding premiums for RFQ markets, RFQ makers are sent fake requester orders. Fake orders are very short lived (max seconds), they look as usual RFQ orders so that RFQ makers honestly try to fill them. They never execute. A valid maker response is accepted only as a funding-price observation and does not change balances or positions.
Just fake orders created periodically.
Public sampling response
Funding sampling uses the normal protobuf FillRFQResult and TypeScript SDK
RFQ fill result. Because sampling is non-executable, protobuf omits
filled_size and trade_id, and the SDK exposes both filledSize and tradeId
as null. Real RFQ executions use the same result shape with both values set.
Funding formalization
For funding, Nord should run a separate sampler. Every X seconds, the sampler
sends a standardized request-to-fill to subscribed RFQ makers for the configured
impact size. Nord may accept a valid response as a non-executable observation,
but never executes the probe as a trade. The response is used only to observe
the impact price.
The sampler should collect both bid-side and ask-side impact prices and derive
pmid from them:
For funding tick and side , let be the funding-participating RFQ makers that return fresh, valid, non-executable impact proposals:
For each side, aggregate the valid impact proposals into an impact price: the bid impact is the highest valid bid proposal, and the ask impact is the lowest valid ask proposal.
Funding premium is then computed against the index:
If either side has no valid proposal, the tick has no sample:
Funding edge cases:
- if only one side is returned, the sample is missing for ;
- if the index price is unavailable, ignore the sample or use the existing outage policy;