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
sourceAddressoptionalThe deployment’s diamond address (the subgraph’s source).
typesreadonly MarginTransferType[]optionalTransfer 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[]optionalTransactions the transfers happened in — for example a position’s open or close transaction.
virtualAccountsreadonly Address[]optionalVirtual Accounts the margin moved into or out of.
subAccountsreadonly Address[]optionalSubAccounts that own those Virtual Accounts.
startTimenumberoptionalLower bound on the block timestamp (unix seconds, inclusive).
endTimenumberoptionalUpper bound on the block timestamp (unix seconds, inclusive).
firstnumberdefault 1000Page size, 1–1000.
skipnumberdefault 0Rows to skip. The Graph rejects values above 5000.
orderBy"timestamp" | "id"default timestampSort field. Defaults to "id" when idGt is set.
orderDirection"asc" | "desc"default descSort direction. Defaults to "asc" when idGt is set.
idGtstringoptionalCursor: 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.
chainIdnumberoptionalOptional chain override.
Returns
GetMarginTransfersReturnTyperowsMarginTransferRow[]The decoded transfers of this page.
hasMorebooleantrue when the page came back full, so another page may exist.
MarginTransferRow
MarginTransferRowidstringSubgraph entity id — stable; use it as a row key or idGt cursor.
typeMarginTransferType | stringTransfer direction. A type this release does not name passes through as its raw string.
virtualAccountAddressThe Virtual Account the margin moved into or out of.
subAccountAddressThe SubAccount that owns the Virtual Account.
amountbigintAmount moved, 18-decimal wei.
sourceAddressDiamond address the transfer was indexed from.
timestampnumberBlock timestamp, unix seconds.
blockNumberbigintBlock number.
transactionHexTransaction 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.
Related
getBalanceHistory— deposits and withdraws; itsinternalTransfersmode shows the margin-transfer legs among them.getQuoteHistory— each row’ssendQuoteTransactionis the quote’s open transaction, ready to pass astransactions.- React
useMarginTransfers— the hook over this action.