Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Errors

The SDK raises two error types. The pure math layer raises PoolMathError, which mirrors the contract’s PoolMathError. Everything above the math layer raises XykError, whose code is a stable string.

PoolMathError

KindCondition
EmptyPoolThe pool is empty on one or both sides
OverflowA value would exceed the numeric bound
ZeroAmountInThe input amount is zero
ZeroAmountOutThe output amount is zero
InsufficientLiquidityThe pool cannot satisfy the operation
InvariantStored reserves and LP supply disagree

The message string matches the contract’s PoolMathError.

XykError

CodeCondition
NOT_A_POOLThe account has no token asset keys, or the keys are zero
POOL_NOT_FOUNDThe account or registry is not in the local store
POOL_NOT_CONFIGUREDA required pool slot is missing
MISSING_SLOTA named storage slot is absent
INVARIANTA vault balance is below the recorded protocol pot
INVALID_ARGUMENTA parameter is out of range or inconsistent
UNSUPPORTED_OPERATIONThe requested operation has no implementation

Failure order

amountOut raises in this order: ZeroAmountIn, EmptyPool, Overflow for any input above MAX_AMOUNT, ZeroAmountOut, InsufficientLiquidity when the output is at least reserve_out, and Overflow when the resulting reserve is at least MAX_AMOUNT.

quoteMint checks addAmount(reserve, amount) against MAX_AMOUNT before the ratio branch, so an over-sized deposit reverts even when part of it would be refunded.

quoteBurn raises InsufficientLiquidity when the burn would leave less than MINIMUM_LIQUIDITY, and when either payout rounds to zero.

The reference error table maps protocol rejections seen in operation to their cause and fix.