Skip to Content
Symmio Trading-SDK — the SDK surface for builders on Arbitrum
CoreSubgraphgetMarginTransfers

getMarginTransfers

Margin moved between a SubAccount and its Virtual Accounts, from the analytics subgraph’s marginTransfers collection. Reach for it to see how much margin an open transaction put into its Virtual Account, how much came back on close, or to audit one Virtual Account’s margin over time.

import { getMarginTransfers, MarginTransferType } from "@symmio/trading-core"; // The margin each open transaction put into its Virtual Account. const { rows, hasMore } = await getMarginTransfers(config, { types: [MarginTransferType.Add], transactions: [openTransaction], });

Every filter is optional and applied only when passed; an empty list filter reads nothing. One call returns one page — see Filters and paging for the shared rules and for paging by cursor.

Parameters

sourceAddressoptional

The deployment’s diamond address (the subgraph’s source).

typesreadonly MarginTransferType[]optional

Transfer types to include. The MarginTransfer entity records Add (ADD), Remove (REMOVE), and EmergencyRecover (EMERGENCY_RECOVER); a raw type string this release does not name is accepted too.

transactionsreadonly Hex[]optional

Transactions the transfers happened in — for example a position’s open or close transaction.

virtualAccountsreadonly Address[]optional

Virtual Accounts the margin moved into or out of.

subAccountsreadonly Address[]optional

SubAccounts that own those Virtual Accounts.

startTimenumberoptional

Lower bound on the block timestamp (unix seconds, inclusive).

endTimenumberoptional

Upper bound on the block timestamp (unix seconds, inclusive).

firstnumberdefault 1000

Page size, 1–1000.

skipnumberdefault 0

Rows to skip. The Graph rejects values above 5000.

orderBy"timestamp" | "id"default timestamp

Sort field. Defaults to "id" when idGt is set.

orderDirection"asc" | "desc"default desc

Sort direction. Defaults to "asc" when idGt is set.

idGtstringoptional

Cursor: only transfers whose id sorts after this one. Sorts by id ascending unless a sort is passed; any other sort throws INVALID_SUBGRAPH_CURSOR. See Paging by cursor.

chainIdnumberoptional

Optional chain override.

Returns

GetMarginTransfersReturnType
rowsMarginTransferRow[]

The decoded transfers of this page.

hasMoreboolean

true when the page came back full, so another page may exist.

MarginTransferRow

MarginTransferRow
idstring

Subgraph entity id — stable; use it as a row key or idGt cursor.

typeMarginTransferType | string

Transfer direction. A type this release does not name passes through as its raw string.

virtualAccountAddress

The Virtual Account the margin moved into or out of.

subAccountAddress

The SubAccount that owns the Virtual Account.

amountbigint

Amount moved, 18-decimal wei.

sourceAddress

Diamond address the transfer was indexed from.

timestampnumber

Block timestamp, unix seconds.

blockNumberbigint

Block number.

transactionHex

Transaction hash.

Query options

import { getMarginTransfersQueryOptions, MarginTransferType } from "@symmio/trading-core"; import { useQuery } from "@tanstack/react-query"; useQuery( getMarginTransfersQueryOptions(config, { types: [MarginTransferType.Add], transactions: [openTransaction], }), );

The query is disabled while any list filter (types, transactions, virtualAccounts, subAccounts) is an empty array.

  • getBalanceHistory — deposits and withdraws; its internalTransfers mode shows the margin-transfer legs among them.
  • getQuoteHistory — each row’s sendQuoteTransaction is the quote’s open transaction, ready to pass as transactions.
  • React useMarginTransfers — the hook over this action.
Last updated on