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

getActiveVirtualAccountByKey

Read a subaccount’s active Virtual Account (VA) for an isolation key (isolationType, symbolId): the VA that new quotes on that market, and side, are routed into while the subaccount runs in single-VA mode. It wraps the AccountLayer’s getActiveVAByKey. Predicting the next VA (usePredictedNextVirtualAccount) answers where the next position would go; this answers which VA holds the position now.

import { getActiveVirtualAccountByKey, isolationTypeForSide, PositionType } from "@symmio/trading-core"; const va = await getActiveVirtualAccountByKey(config, { subAccount, isolationType: isolationTypeForSide(PositionType.LONG), symbolId: 42n, });

The active VA changes when a position on the key opens or fully closes, so invalidate the query after those writes rather than caching it forever.

Parameters

subAccountAddressrequired

The parent subaccount.

isolationTypeVirtualAccountIsolationTyperequired

Isolation bucket of the VA. Use isolationTypeForSide(positionType) for a side.

symbolIdbigintrequired

Market id.

chainIdnumberoptional

Optional chain override.

Returns

Address | null

The active VA, or null when none is active for the key. The contract returns the zero address in that case.

Query options

import { getActiveVirtualAccountByKeyQueryOptions } from "@symmio/trading-core"; import { useQuery } from "@tanstack/react-query"; useQuery(getActiveVirtualAccountByKeyQueryOptions(config, { subAccount, isolationType, symbolId }));

Raw ABI

For consumers that want to call viem directly:

import { accountLayerAbi } from "@symmio/trading-core"; await publicClient.readContract({ abi: accountLayerAbi, address: accountLayerAddress, functionName: "getActiveVAByKey", args: [subAccount, isolationType, symbolId], });
Last updated on