SYMMIO Contract
Reads and writes against the on-chain SYMMIO diamond contract — quotes, collateral, allocation, withdraw, and the on-chain market list. This slice targets the Symmio contract directly via viem clients.
Solver-side catalog / limit reads (getMarkets, getLockedParams, getNotionalCapBySymbolId, getOpenInterestBySymbolId) hit the solver REST API and live under Solvers — they are not contract reads even when the numbers ultimately reflect on-chain state.
Each method has its own page with the full signature, parameters, return shape, examples, and query options.
On-chain markets
Quote reads
Read one quote struct by id.
getSubAccountQuotesA subaccount’s full quote picture across its Virtual Accounts.
getPartyAOpenPositionsOpen positions for a PartyA (Virtual Account).
getPartyAPendingQuotesPending quote ids for a PartyA.
getPendingQuotesA PartyA’s resting LIMIT orders as full structs — ids hydrated via multicall getQuote.
Cancel a quote
A resting limit order (or any pending quote) is cancelled through the AccountLayer _call proxy so the diamond attributes the call to the subaccount; the connected wallet must be the subaccount’s owner.
Cancel a pending quote. PENDING cancels instantly; LOCKED enters CANCEL_PENDING.
Force-cancel a CANCEL_PENDING quote once the cooldown has elapsed.
The lifecycle: requestToCancelQuote on a LOCKED quote sets it CANCEL_PENDING and stamps statusModifyTimestamp. Once now ≥ statusModifyTimestamp + getCoolDownsOfMA()[1] and partyB still has not acted, forceCancelQuote completes it. A PENDING (unlocked) quote cancels instantly and never needs the force path. The React useLimitOrders + cancel hooks wrap all three.
Cancel a close
The close-side analog: back out of a resting close (e.g. a limit close) while the quote is CLOSE_PENDING. Same _call proxy routing.
Cancel a pending close. If partyB accepts, the quote returns to OPENED; if it stalls, CANCEL_CLOSE_PENDING.
Force-cancel a CANCEL_CLOSE_PENDING close once the cooldown has elapsed — the quote returns to OPENED.
Mirrors the quote-cancel lifecycle, but keyed on the close: requestToCancelCloseRequest on a CLOSE_PENDING quote returns it to OPENED if partyB accepts, else sets CANCEL_CLOSE_PENDING. Once now ≥ statusModifyTimestamp + getCoolDownsOfMA()[2] (forceCancelCloseCooldown), forceCancelCloseRequest completes it. The React useRequestToCancelCloseRequest / useForceCancelCloseRequest hooks wrap both.
Collateral
Collateral-token wallet balance for an owner.
getCollateralAllowanceAllowance the owner has granted the SYMMIO core.
Allocate / deallocate
allocate and deallocate move collateral between an account’s available and allocated balances. They are the same on-chain writes documented under AccountLayer — see allocate and deallocate.
Withdraw
Build a classic (provider-free) withdraw receiver part.
getLastWithdrawRequestIdThe most recent withdraw request id for a subaccount.
getPendingWithdrawRequestsThe active (non-terminal) withdraw requests for a subaccount.
withdrawAuto — high-level entry point
withdrawAuto(config, params) is the high-level entry point: pass just
{ account, amount, receiver } — with amount in the collateral token’s
decimals — and it does all the plumbing. It reads the subaccount’s
SubAccountIsolationType, builds
the classic same-chain withdraw part, scales the deallocate amount, and hands off to
withdraw. Account-layer balances are
1e18-scaled regardless of the collateral token’s decimals, so on the CUSTOM path
it derives the 18-decimal deallocate amount as
amount * 10 ** (18 - collateralDecimals) (assumes collateralDecimals <= 18) and
fetches a fresh Muon uPnL signature for the deallocate leg unless you pass one.
This is the framework-agnostic backing for the React
useWithdraw hook. Reach for
withdraw below (or the underlying actions) when you already know the isolation, or
need custom (multi-part / cross-chain) withdraw parts.
import { withdrawAuto } from "@symmio/trading-core";
// amount in the collateral token's decimals (6-dec USDC → 1 USDC):
const hash = await withdrawAuto(config, { account, amount: 1_000000n, receiver });withdraw — pre-resolved dispatcher
withdraw(config, params) is the lower-level dispatcher: you pass the already-read
isolationType and the ready-made parts, and it routes on the isolation without an
extra read, so callers don’t branch on where the collateral sits:
CUSTOM(cross-margin) — funds are in the allocated balance, so it callsdeallocateAndInitiateWithdraw(deallocate and initiate in one atomic transaction). This path requiresamount, the deallocate amount in 18 decimals (not the collateral token’s decimals), and fetches a fresh Muon uPnL signature for the deallocate leg unless you pass one.MARKET/MARKET_DIRECTION(VA) — funds are already in the available balance, so it callsinitiateWithdrawonly and ignoresamount.
A CUSTOM subaccount called without amount throws a SymmError
(kind: "validation", code: "WITHDRAW_AMOUNT_REQUIRED"). Prefer
withdrawAuto when you want to pass a
collateral-decimals amount and let the SDK read isolation and scale for you; the
underlying deallocateAndInitiateWithdraw / initiateWithdraw actions stay
available for callers that want to drive one path directly. See the
balance model for available-vs-allocated.
import { createClassicWithdrawPart, getSubAccount, SubAccountIsolationType, withdraw } from "@symmio/trading-core";
const { isolationType } = await getSubAccount(config, { account });
const hash = await withdraw(config, {
account,
isolationType,
parts: [createClassicWithdrawPart({ id: 0n, amount, receiver, chainId })],
// required only for CUSTOM — the 18-decimal deallocate amount:
amount: isolationType === SubAccountIsolationType.CUSTOM ? deallocateAmount18 : undefined,
});Query options
Every read ships a matching …QueryOptions factory and …QueryKey builder. See each read’s page for the exact call, and Query options for the shared pattern.
Related
- Solvers — solver REST catalog: markets, locked params, notional cap, open interest.
- AccountLayer — SubAccount / Virtual Account creation, balances,
allocate/deallocate. - InstantLayer — delegated instant flows.
- Muon oracle —
getDeallocateUpnlSigand other uPnL signature helpers for gated writes. - Errors — every write can surface a viem revert or an SDK-level
SymmError.