Skip to Content
Symmio Trading-SDK — the SDK surface for builders on HyperEVM
CoreSYMMIO ContractOverview

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

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.

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.

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

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

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 calls deallocateAndInitiateWithdraw (deallocate and initiate in one atomic transaction). This path requires amount, 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 calls initiateWithdraw only and ignores amount.

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.

  • Solvers — solver REST catalog: markets, locked params, notional cap, open interest.
  • AccountLayer — SubAccount / Virtual Account creation, balances, allocate / deallocate.
  • InstantLayer — delegated instant flows.
  • Muon oraclegetDeallocateUpnlSig and other uPnL signature helpers for gated writes.
  • Errors — every write can surface a viem revert or an SDK-level SymmError.
Last updated on