getVirtualAccountsOfSubAccount
List a subaccount’s Virtual Accounts (VAs) with their details, in one call. Reading the addresses first and then each VA would take one call per VA. Each row carries the VA’s market and isolation type, so a UI can group a subaccount’s isolated positions by market and side without another read.
import { getVirtualAccountsOfSubAccount } from "@symmio/trading-core";
const vas = await getVirtualAccountsOfSubAccount(config, { subAccount });The AccountLayer clamps instead of reverting: an offset past the end returns an empty array, and limit is clamped to what remains. One call with the default limit therefore returns every VA of a subaccount that has at most 200; page past that with getVirtualAccountsCountOfSubAccount.
Parameters
subAccountAddressrequiredThe subaccount whose VAs to list.
offsetbigintdefault 0nPagination offset.
limitbigintdefault 200nMaximum number of entries to return; clamped on-chain to the number remaining.
chainIdnumberoptionalOptional chain override.
Returns
readonly VirtualAccountDetail[]accountAddressAddressThe VA’s own address — the on-chain partyA of the positions it holds.
parentAccountAddressThe subaccount that created the VA.
symbolIdbigintMarket the VA trades.
isExistsbooleantrue once the VA exists on-chain.
metadataHexOpaque per-VA metadata blob, or 0x.
isolationTypeVirtualAccountIsolationTypeVIRTUAL_ACCOUNT_ISOLATION_TYPE: 0 POSITION, 1 MARKET, 2 MARKET_LONG, 3 MARKET_SHORT. MARKET_LONG and
MARKET_SHORT pin the side. Note that 2 means MARKET_DIRECTION on a subaccount’s SubAccountIsolationType.
Query options
import { getVirtualAccountsOfSubAccountQueryOptions } from "@symmio/trading-core";
import { useQuery } from "@tanstack/react-query";
useQuery(getVirtualAccountsOfSubAccountQueryOptions(config, { subAccount }));Raw ABI
For consumers that want to call viem directly:
import { accountLayerAbi } from "@symmio/trading-core";
await publicClient.readContract({
abi: accountLayerAbi,
address: accountLayerAddress,
functionName: "getVirtualAccountsOfSubAccount",
args: [subAccount, 0n, 200n],
});