@somnia-chain/markets-sdk / index / ClientConfig
Interface: ClientConfig
Defined in: packages/sdk/src/config.ts:303
Configuration for a SomniaMarketsClient. Each transport is required
only by the features that use it: indexerUrl powers the indexer reads and
the live watches' snapshot hydration (omit it for a chain-only client —
smart accounts, executors, on-chain reads — and those reads throw
NotConfiguredError); chain + wsRpcUrl power the live tail,
on-chain reads, and writes, but the WebSocket socket is opened lazily, so an
indexer-only client (e.g. server-side GraphQL reads) that never touches the
chain never opens one.
Properties
reconciliation?
optionalreconciliation?:TailReconciliationConfig
Defined in: packages/sdk/src/config.ts:311
Optional diagnostic, off by default. At most once per interval, recover logs through one target and compare both top-N sides at that block and timestamp. Costs chunked getLogs plus one header and two book reads per watched pool. Failures and retained divergence evidence appear in getLiveStatus(). It never replaces seed orders or the event-derived store.
indexerUrl?
optionalindexerUrl?:string
Defined in: packages/sdk/src/config.ts:319
Envio/Hasura GraphQL endpoint (HTTP). Same-origin relative paths are fine. Optional: a chain-only client (smart accounts, executors, on-chain reads) needs none; every indexer read and live watch then throws NotConfiguredError naming this field. An empty string counts as absent.
indexerHeaders?
optionalindexerHeaders?:Record<string,string>
Defined in: packages/sdk/src/config.ts:327
Extra headers sent with every indexer request — e.g. a Hasura role /
admin-secret for SERVER-side reads that need privileges the public role
lacks (notably _aggregate fields, which envio hides from the public
role). MUST stay server-only; never construct a browser client with a
secret here.
signal?
optionalsignal?:AbortSignal
Defined in: packages/sdk/src/config.ts:345
Cancels this client's in-flight INDEXER reads when aborted — pass one per request on a server, or a component's controller signal in a UI, so a navigation away stops work already on the wire.
Details
Client-wide, not per-read: it is combined with the SDK's own request timeout
(whichever fires first wins). An abort re-throws YOUR abort reason
unwrapped rather than an IndexerError, so name === "AbortError"
checks keep working — a cancellation is not an indexer failure.
Gotchas
Covers indexer reads only. Chain reads go over the WebSocket transport, which is bounded by its own request timeout instead.
chain
chain:
Chain
Defined in: packages/sdk/src/config.ts:347
viem chain the markets live on.
wsRpcUrl?
optionalwsRpcUrl?:string
Defined in: packages/sdk/src/config.ts:359
Chain WebSocket RPC — the single chain transport. The live tail subscribes to logs + new heads over it, and all on-chain reads/writes use it too. There is no HTTP fallback: the SDK assumes a healthy WebSocket.
Optional when chain carries a WebSocket endpoint — every definition in
@somnia-chain/markets-sdk/chains does (rpcUrls.default.webSocket), so
with those this is only an override. viem's own somniaTestnet lacks one,
so with that chain (or any ws-less definition) it stays required and the
first chain touch throws NotConfiguredError without it.
fees?
optionalfees?:FixedFees
Defined in: packages/sdk/src/config.ts:364
Fixed fees for SDK-signed writes (default DEFAULT_FEES). Override for a chain whose base fee can exceed the default ceiling.
addresses?
optionaladdresses?:SomniaMarketsAddresses
Defined in: packages/sdk/src/config.ts:369
Protocol contract addresses — used by the write client, the live tail's factory watch, and /system reads.
priceFeed?
optionalpriceFeed?:PriceFeedConfig
Defined in: packages/sdk/src/config.ts:376
The realtime price-feed endpoint (see PriceFeedConfig). One endpoint
serves every asset; callers filter by asset. Required only for the price-feed
methods (watchPrice, getLivePrice, fetchPrices, …); a client that never
touches prices needs none.
debug?
optionaldebug?: (e) =>void
Defined in: packages/sdk/src/config.ts:409
Opt-in debug/tracing sink. Unset (the default) means the SDK emits nothing
and does no debug-only work. When set, the client sends every
DebugEvent it produces — structured log lines plus span
start/annotate/end events around trader calls and live-tail hydration —
and the sink decides everything else: filtering, formatting, toggling, or
forwarding to a real tracer (the shape maps 1:1 onto OpenTelemetry). Two
sinks ship with the package: consoleDebugSink (indented span tree) and
debugCollector (test capture). The toggle mechanism belongs to the app,
not the SDK:
Example (Enabling debug output)
Explorer (dev) — flip on from devtools via localStorage; a Node bot gates a JSON-lines sink on an env var instead:
const devExchange = new SomniaMarkets({
...config,
debug: localStorage.getItem("sdk-debug")
? consoleDebugSink()
: undefined,
});
const botExchange = new SomniaMarkets({
...config,
debug: process.env.SDK_DEBUG
? (e) => console.log(JSON.stringify(e, (_, v) => (typeof v === "bigint" ? v.toString() : v)))
: undefined,
});
Parameters
e
Returns
void