Square-root-price limits
The limit must remain inside the Q128.128 domain:zero_for_one limit must be below current price. A one_for_zero limit must be above current price. Equality with current price rejects.
To derive a limit from display price, apply canonical token order and decimal adjustment, take the square root at sufficient precision, multiply by 2^128, and round conservatively. Use integer or decimal arbitrary precision. Never build the signed value with binary floating point.
Tick boundaries
The crossing loop can cross an initialized tick whose price equals the limit. It does not trade past that limit. The bounded partial path cannot perform an uncrossed upward rest exactly on an initialized tick; it stops one Q128.128 unit below when necessary to preserve active-liquidity state.Minimum output
amount_out_min applies to final output after all fees, rounding, crossing bounds, and partial-fill behavior. Multi-hop has one final minimum, not one minimum per hop.
A quote must include:
- current revisioned protocol state;
- current pool slots and initialized ticks;
- all fee tiers and protocol shares;
- five crossing iterations for single-hop or three per active multi-hop leg;
- bounded partial behavior; and
- native base-unit rounding at each step.
Remainder
Execution can leave original input when it reaches a price limit, crossing bound, or zero-effective-input condition. If final output meets the minimum, the swap can succeed and store that amount inSwapOutput.amount_remaining.
For multi-hop, hop 0 can leave original input, but every later hop must consume its full intermediate input or the route rejects. The current mapping stores only remaining original route input. It has no intermediate refund slots.
Deadline
Finalize accepts whenblock.height <= deadline. Read a recent height and add a policy-defined block offset that accounts for proof generation and submission delay.
The transaction-schema endpoint in an older deployment may label this field as a Unix deadline. That label is wrong for the current contract. Encode an Aleo block height.