Reference

Trading SDK

The shared TypeScript 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

Transaction helpers

Transaction-facing helpers live in the Trading UI at ui/trading/ts/protocol/tradeQuote.ts: minimumAfterSlippage and maximumAfterSlippage build conservative bounds, stableSimulation reads the latest canonical block identity (number and hash) and passes it to the simulation callback, whose reads must all use that block hash, retainApprovedMinimum and retainApprovedMaximum keep the approved bounds when the submission-time simulation still satisfies them, and deadlineAtBlock derives router deadlines from the quote block.

Pure math is a responsive preview only. Transaction summaries must simulate the actual router call, use its returned values, and revalidate network, account, balances, approvals, reserves, deadline, and simulation immediately before wallet submission.