@somnia-chain/markets-sdk / index / PerpInsuranceFundEvent
Type Alias: PerpInsuranceFundEvent
PerpInsuranceFundEvent =
object
Defined in: packages/sdk/src/perp/system.ts:327
One movement in the InsuranceFund's tier ledger (mirror of the indexer
PerpInsuranceFundEvent entity).
Eight kinds share this row, and they are NOT interchangeable — most fields are populated for some kinds and null for the rest, so PerpInsuranceFundEvent.kind is the field to branch on first:
kind | What it records | Effect on the fund total |
|---|---|---|
BadDebtAuthorised | coverage asked for and granted, per account | none — a summary |
TierFunded | a plain top-up | inflow |
TierFundedFromSource | a top-up drawn from the configured funding source | inflow |
TierCredited | the insurance share of a fee, booked by MarginBank | inflow |
TierDebited | the liquidation waterfall drew from a tier | outflow |
TierWithdrawn | an admin withdrawal | outflow |
TierWithdrawnToTreasury | an admin withdrawal routed to the treasury | outflow |
TierAllocated | a transfer from tier to toTier | none |
Gotchas.
- Never sum
amountbare. It is populated on inflows, outflows and the internal move alike, so a plain total is gross turnover rather than a net position. Fold it BYkindusing the table above, and rememberTierAllocatednets to zero across the fund even though it moves wei between two tiers. coveredis not an independent flow. On aBadDebtAuthorisedrow it is the SUM of theTierDebitedrows in the same transaction, so counting both double-counts the same wei.requested > coveredis a PARTIAL grant, andcovered === "0"is a REFUSAL — the only record the protocol keeps of one.TierCreditedis a cross-plane duplicate. It restates wei already recorded asinsurancePortionon the fee plane (client.listPerpFees), becauseMarginBank._chargeFeetransfers the insurance share and then books the tier credit for the same amount. What this row adds is WHICH TIER received it, which the fee plane does not carry. Do not add the two together.kindis a raw string, not a decoded union, for the same reasonOrder.cancelReasonis: the vocabulary is the indexer's own — eight distinct events rather than a contract enum arriving as auint8— so there is nothing to decode, and a kind a newer indexer emits reaches a consumer intact rather than becoming null.
Properties
id
id:
string
Defined in: packages/sdk/src/perp/system.ts:329
Row id (${txHash}_${logIndex}).
kind
kind:
string
Defined in: packages/sdk/src/perp/system.ts:331
Which of the eight movements this row is — branch on this before reading any other field.
tier
tier:
string|null
Defined in: packages/sdk/src/perp/system.ts:336
The tier this row moves, or the SOURCE tier on TierAllocated. Null on
BadDebtAuthorised, which is account-scoped rather than tier-scoped.
toTier
toTier:
string|null
Defined in: packages/sdk/src/perp/system.ts:338
The DESTINATION tier (TierAllocated only).
amount
amount:
string|null
Defined in: packages/sdk/src/perp/system.ts:343
Wei that actually MOVED, raw collateral units. Null on BadDebtAuthorised. Fold by
kind — see the type note; a bare sum is turnover, not a balance.
requested
requested:
string|null
Defined in: packages/sdk/src/perp/system.ts:345
Coverage ASKED FOR (BadDebtAuthorised only).
covered
covered:
string|null
Defined in: packages/sdk/src/perp/system.ts:350
Coverage GRANTED (BadDebtAuthorised only) — the sum of the same-transaction
TierDebited rows rather than an independent flow. "0" is a refusal.
account
account:
string|null
Defined in: packages/sdk/src/perp/system.ts:352
The account whose bad debt was authorised (BadDebtAuthorised only), lowercased.
counterparty
counterparty:
string|null
Defined in: packages/sdk/src/perp/system.ts:354
The funding source or the treasury, where the event names one (lowercased).
caller
caller:
string|null
Defined in: packages/sdk/src/perp/system.ts:356
Who triggered it, where the event names a caller distinct from the counterparty.
timestamp
timestamp:
string
Defined in: packages/sdk/src/perp/system.ts:358
Timestamp (unix seconds) of the movement.
blockNumber
blockNumber:
string
Defined in: packages/sdk/src/perp/system.ts:360
Block the movement landed in.
logIndex
logIndex:
number
Defined in: packages/sdk/src/perp/system.ts:366
Position within the block. Load-bearing for ordering, not decoration: one
authorisation debits SEVERAL tiers in the same block and transaction, and id leads
with an unordered transaction hash, so nothing else can rank them.
txHash
txHash:
string
Defined in: packages/sdk/src/perp/system.ts:368
Tx hash the movement landed in.