Unified quotes
@symmio/trading-core folds every source of quote-ish data — on-chain positions and pending quotes, pending instant-opens, pending instant-closes, and solver notifications — into one stable, de-duplicated, lifecycle-tagged shape: the UnifiedQuote. It is the primary abstraction consumers build quote and position UIs against.
The rest of the SDK returns raw records from each source. This module is the reconciliation engine that merges them. reconcileQuotes performs a pure, deterministic merge of one snapshot of every source into a de-duplicated row list; applyNotificationToQuotes advances a row’s lifecycle as solver notifications arrive; resolveQuoteAccounts works out which on-chain accounts (a sub-account plus its Virtual Accounts) hold the picture; and the shouldAccelerate* predicates tell a poll scheduler when to tighten its interval.
Every function here is a pure transform — no config, no clock, no network — except resolveQuoteAccounts, which reads Virtual Account addresses on-chain. The merge is stable across ticks: a temp (off-chain) row keeps its identity as it anchors on-chain, so React lists never flicker. The React layer’s useManagedQuotes composes all of it into a live quote list; framework-agnostic consumers call these functions directly.
Each type and function has its own page with the full signature, fields or parameters, return shape, and examples.
Types
One quote/position row merged from every source into a stable, de-duplicated shape. The primary abstraction.
QuoteOriginWhere a row was sourced from before reconciliation — "onchain" or "offchain".
The merged lifecycle stage of a row across the on-chain and off-chain sources.
QuoteNotificationActionKindWhich quote flow a notification’s action belongs to — "open", "close", or "other".
Reconciliation
Merge one snapshot of every quote source into a de-duplicated, lifecycle-tagged UnifiedQuote[]. Pure and
stateless.
Apply one solver notification to the row list — links temp ↔ on-chain ids, fills prices, advances lifecycle.
resolveQuoteAccountsResolve the full set of on-chain accounts (sub-account + Virtual Accounts + predicted VAs) that hold a sub-account’s quotes.
classifyQuoteNotificationActionClassify a notification’s lastSeenAction into the quote flow it belongs to.
Polling
Whether the on-chain reads specifically should poll faster — true while a row awaits on-chain confirmation.
Whether quote polling should run at the accelerated interval — true while any row is mid-transition.
Adapters
Fold a pending instant-open record into an optimistic UnifiedQuote without merging.
Fold a pending instant-close record into a CLOSING UnifiedQuote without merging.
Fold an on-chain quote/position struct into a UnifiedQuote without merging.
Related
- Notifications stream — the source
applyNotificationToQuotesandclassifyQuoteNotificationActionfold in. getSubAccountQuotes— the convenience read that runsresolveQuoteAccounts+ the source reads +reconcileQuotesin one call.- Solvers —
PendingInstantOpen/PendingInstantClosefromgetInstantOpens/getInstantClosesfeed the reconciler. - React
useManagedQuotes— the hook composed on top of everything here.