Core
@symmio/trading-core is the framework-agnostic SYMMIO SDK. Contract calls, REST clients, GraphQL subgraph reads, WebSocket streams, calculations, and typed errors — no framework assumptions.
Framework layers (@symmio/trading-react, a future Vue layer) sit on top of core and inject the viem-client resolvers it needs.
Install
pnpm add @symmio/trading-core viemviem is the only peer dependency — bring your own copy.
Shape
Every read is getXyz(config, params); every write is xyz(config, params). The config is always the first argument — a single immutable Config object created once with createConfig, shared across every call.
import { createConfig, getUserSubAccounts } from "@symmio/trading-core";
import { createPublicClient, http } from "viem";
import { hyperEvm } from "viem/chains";
const publicClient = createPublicClient({ chain: hyperEvm, transport: http() });
const config = createConfig({
getClient: () => publicClient,
});
const subs = await getUserSubAccounts(config, { user: "0xabc..." });Every read also ships a matching getXyzQueryOptions(config, options) factory returning a fully-formed TanStack Query options bag — feed it into useQuery or queryClient.fetchQuery.
See Config and Query options.
Core Concepts
Cross-cutting mental model referenced by every slice.
- Config —
createConfig, injected client resolvers, chain overrides, WebSocket constructor. - Query Options — the
getXyzQueryOptions/xyzMutationOptionsfactory pattern. - Query Keys — key shape,
filterQueryOptions,predicateMatchinvalidation. - WebSocket Streams —
SocketStatus, reconnect, connection pool. - Errors —
SymmError/SymmApiErrorcatalogue, viem pass-through.
Reference
Every domain slice, one page. Each page follows the same anatomy — purpose → import → per-action signature + params + returns + example → related.
Contracts
- ABI fragments — raw viem
Abiarrays for the escape hatch. - Addresses — per-chain contract address registry.
- AccountLayer — SubAccount / Virtual Account creation, deposits, margin management.
- InstantLayer — delegation reads +
grantDelegation. - SYMMIO Contract — markets, quotes, collateral, allocation, withdraw against the
Symmiocontract.
Trading
- Unified Quotes —
reconcileQuotes,UnifiedQuote,applyNotificationToQuotes,QuoteLifecycle. - Solvers — solver REST reads (markets, locked params). Nested:
- TP/SL — conditional-order handler surface (HTTP + WebSocket).
Data
- Price Service — Enigma mark prices, metadata, health, live stream.
- Notifications — solver notifications stream (
watchNotifications) + REST history (searchNotifications). - Subgraph — balance history, transfers, quote history, quote events, quote funding.
- Muon Oracle — UPNL / price / range signature helpers for on-chain writes that need Muon attestations.
Types
- Shared Types —
ChainIdParameter,ConfigParameter,QueryParameter,SymmioQueryOptions, WebSocket types, TS helpers.
What core doesn’t do
- React hooks. Use
@symmio/trading-react. - Decimal-based math or display formatters. Use
@symmio/utils. - UI primitives. Use
@symmio/ui.