swap namespace emits a complete function main() { ... } program with one ISauceRouter.swap(...) statement per spec. Compile with baseDirs: [...swap.SWAP_BASE_DIRS].
sdk/dist/swap/params.d.ts.
Generated from the type declarations shipped in
@eco-incorp/sauce 0.99.4. Each entry shows the package authors’ JSDoc and declaration for this SDK version. For runtime compatibility and deployed addresses, see architecture and deployments.swap.toSwapParams
Function · sdk/dist/swap/params.d.ts
The whole normalization + sign + defaulting + guard decision: lowers a chain-agnostic
SwapSpec into a fully normalized SwapParams - plain bigints (+ the "self"
sentinel for a defaulted payer/recipient), in exact ABI-declaration order, so
Object.keys(toSwapParams(spec)) matches the vendored ISauceRouter.json component order.
Throws (never emits a program that would revert on-chain) for: poolType 9/10 (Infinity - not
dispatchable through swap(), see UndispatchablePoolType); any other out-of-range
poolType; UniV4 missing poolKey; UniV2 poolKey.fee >= 1_000_000; a non-empty callback on a
non-callback-driven pool type; a non-empty callback with an overridden payer/recipient; and
any numeric field given as a number that is not a safe integer (past 2^53-1 pass a bigint or a
string, since the double has already been rounded).
swap.amountSpecifiedFor
Function · sdk/dist/swap/params.d.ts
The single, standalone sign rule (E4.3): given a POSITIVE exact-input amount, returns the
amountSpecified value the given pool type’s handler actually wants.
- UniV3 (
Router.sol:431, passthrough into Uniswap V3’s ownpool.swap): POSITIVE = exact input (fork-verified; contradictsIRouter.sol’s own struct doc comment - seeSwapParams). - UniV4 (
Router.sol’sunlockCallback→V4SwapParams): NEGATIVE = exact input (Uniswap V4’s flipped convention). Encoded as the exact two’s-complementuint256(2**256 - amountIn), not-amountIn- see the module doc for why the compact spelling is deliberately deferred. - Every other pool type (0, 3, 4, 5, 6, 7, 8): the handler takes
abs(amountSpecified), so the canonical positive form is used as-is.
