@somnia-chain/markets-sdk


@somnia-chain/markets-sdk / index / FundingPayment

Type Alias: FundingPayment

FundingPayment = object

Defined in: packages/sdk/src/perp/history.ts:48

A signed funding payment (mirror of the indexer FundingPayment entity). amount is signed raw collateral: positive is what the account pays, negative is what it receives.

Details. The sign is the on-chain one, passed straight through from MarginBank.FundingSettled's int256 payment — the indexer does not negate it, and neither does this type. MarginBank debits the account when payment > 0 and credits it when payment < 0, and IMarginBank documents the event parameter as "positive = paid by account, negative = received by account". Keeping the pass-through is what lets a caller reconcile the value against the chain and against the cumulative funding index. It is the same direction as PerpPositionMetrics.accruedFunding, which is a cost subtracted from equity, and as docs/PERPS.md's fundingSettled.

Gotchas. To display "paid" or "received" to a user, branch on amount > 0n meaning paid. A row read as though positive meant received labels every funding transfer the wrong way round.

Example

Label a settled funding row for a user

ts
// Positive `amount` = the account PAID this much funding.
const paid: Pick<FundingPayment, "amount"> = { amount: "2226" };
const label = BigInt(paid.amount) > 0n ? "paid" : "received";
// label === "paid"

Properties

id

id: string

Defined in: packages/sdk/src/perp/history.ts:50

Payment id (${txHash}_${logIndex}).


account

account: string

Defined in: packages/sdk/src/perp/history.ts:52

Account (lowercased).


pool

pool: string | null

Defined in: packages/sdk/src/perp/history.ts:54

Perp pool (lowercased); null when unlinked.


amount

amount: string

Defined in: packages/sdk/src/perp/history.ts:56

Signed funding payment (raw collateral; positive = paid by the account, negative = received).


timestamp

timestamp: string

Defined in: packages/sdk/src/perp/history.ts:58

Timestamp (unix seconds) the funding settled.


txHash

txHash: string

Defined in: packages/sdk/src/perp/history.ts:60

Tx hash the settlement landed in.