@somnia-chain/markets-sdk


@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:

kindWhat it recordsEffect on the fund total
BadDebtAuthorisedcoverage asked for and granted, per accountnone — a summary
TierFundeda plain top-upinflow
TierFundedFromSourcea top-up drawn from the configured funding sourceinflow
TierCreditedthe insurance share of a fee, booked by MarginBankinflow
TierDebitedthe liquidation waterfall drew from a tieroutflow
TierWithdrawnan admin withdrawaloutflow
TierWithdrawnToTreasuryan admin withdrawal routed to the treasuryoutflow
TierAllocateda transfer from tier to toTiernone

Gotchas.

  • Never sum amount bare. 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 BY kind using the table above, and remember TierAllocated nets to zero across the fund even though it moves wei between two tiers.
  • covered is not an independent flow. On a BadDebtAuthorised row it is the SUM of the TierDebited rows in the same transaction, so counting both double-counts the same wei. requested > covered is a PARTIAL grant, and covered === "0" is a REFUSAL — the only record the protocol keeps of one.
  • TierCredited is a cross-plane duplicate. It restates wei already recorded as insurancePortion on the fee plane (client.listPerpFees), because MarginBank._chargeFee transfers 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.
  • kind is a raw string, not a decoded union, for the same reason Order.cancelReason is: the vocabulary is the indexer's own — eight distinct events rather than a contract enum arriving as a uint8 — 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.