@somnia-chain/markets-sdk / index / ClientConfig
Interface: ClientConfig
Defined in: packages/sdk/src/config.ts:209
Configuration for a SomniaMarketsClient. indexerUrl is always required.
chain + wsRpcUrl power the live tail, on-chain reads, and writes — they're
required by those features, 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
indexerUrl
indexerUrl:
string
Defined in: packages/sdk/src/config.ts:211
Envio/Hasura GraphQL endpoint (HTTP). Same-origin relative paths are fine.
indexerHeaders?
optionalindexerHeaders?:Record<string,string>
Defined in: packages/sdk/src/config.ts:219
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:237
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:239
viem chain the markets live on.
wsRpcUrl?
optionalwsRpcUrl?:string
Defined in: packages/sdk/src/config.ts:251
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:256
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:261
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:268
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:299
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:
Parameters
e
Returns
void
Example
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,
});