> ## Documentation Index
> Fetch the complete documentation index at: https://shield.fi/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Price limits, slippage, and deadlines

> Build the three acceptance controls for current swap entry points.

| Control            | Unit                           | Purpose                         |
| ------------------ | ------------------------------ | ------------------------------- |
| `sqrt_price_limit` | Q128.128 `u256::U256`          | Bounds movement inside one pool |
| `amount_out_min`   | Native output-token base units | Bounds final output             |
| `deadline`         | Aleo block height in `u32`     | Rejects stale execution         |

## Square-root-price limits

The limit must remain inside the Q128.128 domain:

```text theme={"languages":{"custom":["/languages/leo.tmLanguage.json"]}}
minimum = { hi: 0, lo: 702075911466779181339691826087 }
maximum = { hi: 484680305, lo: 8756686347225649145659787327114459760 }
```

A `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 in `SwapOutput.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 when `block.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.
