Reference

Trading SDK

The private workspace package @zoltar/trading-shared holds the pure Trading math that the UI and the Solidity parity tests share. All chain quantities are bigint.

Pure math

Module @zoltar/trading-shared/trading/math mirrors the quote and price functions of TwoWayConstantProductMath. It has no counterpart of the library's initial-odds and proportional-deposit functions; the UI estimates those in ui/trading/ts/features/live/liquidityEstimate.ts.

Position quotes

Module @zoltar/trading-shared/trading/positions takes { yesReserve, noReserve, feeBps } and a longOutcome of 'YES' or 'NO':

Receive request encoding

Module @zoltar/trading-shared/trading/receiveRequest exports encodeReceiveRequest(request), which ABI-encodes the data argument for a share transfer to the router. The request, typed ReceiveRequest, is a positional tuple in the field order of the router's ReceiveRequest struct, which the router reference lists.

Transaction helpers

Transaction-facing helpers live in the Trading UI at ui/trading/ts/protocol/tradeQuote.ts, not in the shared package:

Pure math is a responsive preview only. A quote does not expire when a new block arrives: immediately before wallet submission the client simulates the actual call again at the latest block, and submits with the bounds and deadline approved in the quote only if that simulation succeeds within them.