@somnia-chain/markets-sdk / index / PerpFundingPremium
Interface: PerpFundingPremium
Defined in: packages/sdk/src/perp/state.ts:340
A perp pool's funding-premium state — what the next settlement will charge, and the raw accumulator behind it.
Properties
timeWeightedPremium
timeWeightedPremium:
bigint
Defined in: packages/sdk/src/perp/state.ts:349
The premium the NEXT settlement will charge: the time-weighted average of the order-book premium over the interval so far, PRE-clamp, 1e18-scaled and signed. Positive means the perp is rich and longs pay.
This is the value to build a predicted funding rate from. Do not read
lastObservedPremium for that — see its note.
lastObservedPremium
lastObservedPremium:
bigint
Defined in: packages/sdk/src/perp/state.ts:361
The standing INSTANTANEOUS sample, 1e18-scaled and signed.
Exposed beside timeWeightedPremium because the contract's getter for this kept its
signature and changed its meaning: before Wave 28 it WAS the premium the next
settlement would charge. Anything still treating it that way is silently wrong, and
a spot reading is the one number that looks most like the right one.
Useful for "where is the book right now" and for reproducing the open segment. Not for predicting a charge.
accumulator
accumulator:
bigint
Defined in: packages/sdk/src/perp/state.ts:363
Raw premium integral accumulated since intervalStartNs, for exact reproduction.
intervalStartNs
intervalStartNs:
bigint
Defined in: packages/sdk/src/perp/state.ts:365
Start of the interval being averaged, in NANOseconds. Zero when un-armed — see armed.
observedAtNs
observedAtNs:
bigint
Defined in: packages/sdk/src/perp/state.ts:367
When the standing sample was taken, in NANOseconds.
validUntilNs
validUntilNs:
bigint
Defined in: packages/sdk/src/perp/state.ts:377
When the standing sample stops accruing credit, in NANOseconds. Every nanosecond past it is credited at ZERO, which is what makes a quote's weight its resting duration rather than its presence at one instant.
It can legitimately sit BEHIND observedAtNs: a freeze writes the current time here,
and an observation in the same block then advances observedAtNs to match. Do not
subtract them without ordering them first.
armed
armed:
boolean
Defined in: packages/sdk/src/perp/state.ts:387
Whether the time-weighted mechanism is running for this market yet.
Derived from intervalStartNs !== 0n, which is the contract's own migration
sentinel: it is armed by each market's FIRST settlement after the beacon upgrade.
While this is false the pool still charges the point sample, so
timeWeightedPremium equals lastObservedPremium and the accumulator is empty —
correct, not missing, and it resolves on the market's next settlement.