getPartyAOpenPositionsBatch
Read the open positions of many partyAs at once — typically every Virtual Account of a sub-account. The accounts are bundled into multicalls of batchSize (default 10), so ten accounts cost one eth_call instead of ten. Reach for it whenever you would otherwise call getPartyAOpenPositions in a loop.
import { getPartyAOpenPositionsBatch } from "@symmio/trading-core";
const results = await getPartyAOpenPositionsBatch(config, {
partyAs: virtualAccounts,
includeLiquidationStatus: true,
});
const quotes = results.flatMap((result) => (result.status === "success" && !result.isLiquidated ? result.quotes : []));One result per account
Every input account gets exactly one entry back, in input order:
success— the account’squotes(the same structsgetPartyAOpenPositionsreturns),hasMore, and — withincludeLiquidationStatus—isLiquidated.failure— that account’s read reverted. Theerroris kept; the other accounts are unaffected.
A transport or RPC failure (the multicall itself never reaches the chain) rejects the whole call.
partyA is echoed exactly as you passed it — no checksum rewrite — so results can be matched back to your own
keys. The same address (in any casing) with the same start is read once.
Paging one account
Each account pages on its own. A success with hasMore: true filled the whole page (quotes.length === size); read the next page for just that account by passing it with a start:
const [first] = await getPartyAOpenPositionsBatch(config, { partyAs: [va] });
if (first.status === "success" && first.hasMore) {
await getPartyAOpenPositionsBatch(config, {
partyAs: [{ partyA: va, start: first.start + BigInt(first.quotes.length) }],
});
}A start greater than the account’s position count reverts on-chain, so that entry comes back as a failure. A
start equal to the count returns an empty page.
Liquidation status
includeLiquidationStatus: true adds an isPartyALiquidated read per account inside the same multicall. While it is true the account is frozen mid-liquidation and every action on its positions reverts — most UIs hide those positions. If only the flag’s read fails, the account still succeeds with isLiquidated: undefined (unknown — never reported as false).
Parameters
partyAsreadonly (Address | { partyA: Address; start?: bigint })[]requiredThe accounts to read. A bare address reads from 0n; an object carries that account’s own pagination offset.
sizebigintdefault 200nMaximum number of positions per account. Clamped on-chain to the number remaining after that account’s start.
includeLiquidationStatusbooleandefault falseAlso read each account’s liquidation-in-progress flag, reported as isLiquidated.
batchSizenumberdefault 10Accounts per multicall; chunks run in parallel. A full 200-position read costs a lot of gas and one eth_call has a
gas cap, so keep it modest when accounts may hold many positions. Must be a positive integer — anything else throws
SymmError INVALID_BATCH_SIZE.
chainIdnumberoptionalOptional chain override.
Returns
readonly PartyAOpenPositionsBatchResult[]One entry per input account, in input order. PartyAOpenPositionsBatchSuccess carries partyA, start, quotes,
hasMore and (when requested) isLiquidated; PartyAOpenPositionsBatchFailure carries partyA, start and
error. Narrow on status.
The read uses the client’s multicall, so the viem client’s chain must define a Multicall3 address (every chain viem
ships does).
Query options
The query stays idle while partyAs is empty.
import { getPartyAOpenPositionsBatchQueryOptions } from "@symmio/trading-core";
import { useQuery } from "@tanstack/react-query";
useQuery(getPartyAOpenPositionsBatchQueryOptions(config, { partyAs: virtualAccounts }));Related
- getPartyAOpenPositions — the single-account read.
- isPartyALiquidated — the liquidation flag on its own.
- React
usePartyAOpenPositionsBatch— the hook form.