Skip to Content
Stacks Swap

Error Codes

This page lists the error codes used by the Zest Protocol Stacks Swap contracts. If a swap fails with one of these codes, no funds have moved. The transaction reverted as a whole and the tokens remain in the wallet.

Error Code Ranges

RangeContract GroupDescription
u501-u509AdaptersPer-DEX swap execution errors
u1000-u1016Routers (zr-*)Route validation and settlement errors
u4003-u4005TreasuryOwnership and administration errors

Router Errors (u1000-u1016)

These come from the router contract that executes the route. Most of them indicate a safety check doing its job, and a fresh quote usually resolves the issue.

CodeNameDescription
u1000ERR_DEADLINE_PASSEDThe swap’s deadline passed before the transaction confirmed. Request a fresh quote.
u1001ERR_SKIM_OVER_MAXProtocol fee would exceed the maximum authorized in the signed transaction
u1002ERR_INSUFFICIENT_OUTPUTOutput fell below the minimum received. Price protection triggered; request a fresh quote.
u1004ERR_ZERO_AMOUNTSwap amount cannot be zero
u1005ERR_SKIM_OVER_GROSSProtocol fee would exceed the swap’s gross output
u1006ERR_SAME_TOKENInput and output token are the same
u1007ERR_STX_BOTH_SIDESSTX cannot be both the input and output of a route
u1011ERR_STX_FLOATSafety invariant: the router’s STX balance must be unchanged after the swap
u1012ERR_SPLIT_OUTPUT_MISMATCHSafety invariant: combined output of split route legs did not reconcile
u1013ERR_DELIVERY_MISMATCHSafety invariant: delivered output did not match the measured amount
u1014ERR_ROUTER_OUTFLOWSafety invariant: unexpected token outflow from the router
u1015ERR_INPUT_DELIVERYSafety invariant: swap input was not delivered correctly
u1016ERR_INPUT_OUTFLOWSafety invariant: unexpected input-token outflow detected

Adapter Errors (u501-u509)

These come from the adapter contract for the DEX the route used. All adapters share the first two codes:

CodeNameDescription
u501ERR_ZEROSwap amount or pool output was zero
u502ERR_MIN_OUTPool output fell below the route’s required minimum

Some adapters define additional codes for their platform’s safety checks:

ALEX adapter

CodeNameDescription
u503ERR_BINDINGToken binding check failed
u504ERR_DELIVERYOutput delivery check failed
u505ERR_STX_STRANDSafety invariant: STX left stranded in the adapter
u506ERR_INPUT_STRANDSafety invariant: input tokens left stranded in the adapter

Bitflow DLMM adapter

CodeNameDescription
u504ERR_RESIDUALSafety invariant: the adapter must hold no leftover balance after the swap

Stacking DAO adapter

CodeNameDescription
u502ERR_RECEIPT / ERR_POOLConversion receipt or pool check failed
u503ERR_STX_FLAGInvalid STX flag for this conversion
u504ERR_PAIRUnsupported token pair for this adapter
u505ERR_DIRECTIONUnsupported conversion direction
u506ERR_INPUT_DELTAInput amount check failed
u507ERR_OUTPUT_DELTAOutput amount check failed
u508ERR_MIN_OUTOutput fell below the required minimum
u509ERR_RECEIPT_USEDConversion receipt already used

Treasury Errors (u4003-u4005)

Administrative only. Regular swaps never trigger these.

CodeNameDescription
u4003ERR_NOT_AUTHORIZEDCaller is not the treasury owner
u4004ERR_NO_PENDING_OWNERNo pending ownership transfer to accept
u4005ERR_NOT_PENDING_OWNERCaller is not the proposed new owner

Debugging Tips

  1. u1000 and u1002 are the most common failures. Both mean a protection fired (stale deadline or price movement). Nothing is lost; request a fresh quote and swap again.
  2. Safety invariant errors should never occur in normal use. They indicate the contract refusing to settle a swap that does not reconcile exactly. If one occurs repeatedly, contact support with the transaction ID.
  3. Any of these errors means the whole transaction reverted. Wallet balances remain untouched.
Last updated on