Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions content/protocols/v4/concepts/hook-routing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,23 @@ If you have built a hook that you would like to have allowlisted, fill out the [

You can review current allowlisted hooks in [Allowlisted Hooks](https://support.uniswap.org/hc/en-us/articles/41305283155597-Allowlisted-Hooks).

## Allowlisting and swap compatibility

Allowlisting makes hooked pools eligible for routing. It does not change a hook's validation rules or guarantee that a pool can satisfy every quote request.

A hook can accept or reject swaps based on the swap direction, trade type, pool, caller, hook data, or current state. For each pool and relevant hook state, test all four direction and trade-type combinations:

| Direction | `EXACT_INPUT` | `EXACT_OUTPUT` |
| --- | --- | --- |
| `currency0` to `currency1` | Test | Test |
| `currency1` to `currency0` | Test | Test |

If the pool is intended for multi-hop routing, test the supported combinations in every applicable path position.

If any combination is unsupported, document the constraint for integrators. If an integration submits a pay-side amount as `EXACT_INPUT`, that request may not return a pool whose hook accepts only `EXACT_OUTPUT` in that direction.

<Callout title="Input budgets for exact-output-only directions" type="info">
If the hook guarantees that, for a fixed state, required input is monotonic with requested output over a known range, an integrator can translate an input budget with a bounded search over exact-output quotes. Revalidate the result before execution and use maximum-input protection. Otherwise, require the user to specify the desired output or use hook-specific integration logic.
</Callout>

See [Getting a Quote](/docs/sdks/v4/guides/swapping/quoting) for v4 exact-input and exact-output quote methods and [Swap Routing](/docs/trading/swapping-api/concepts/swap-routing) for API routing behavior.
11 changes: 9 additions & 2 deletions content/trading/swapping-api/concepts/swap-routing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@ description: 'Use Uniswap API routing fields to choose protocol paths and return
icon: 'route'
---
## Routing Principles
In order to get the appropriate swap routing, it is important to closely consider the values submitted through the `/quote` `protocols` and `routingPreference` fields. We recommend specifying the desired swap routing by specifying all `protocols` which you feel comfortable using and leaving the `routingPreference` field blank.
In order to get the appropriate swap routing, it is important to closely consider the values submitted through the `/quote` `type`, `protocols`, and `routingPreference` fields. We recommend specifying the desired swap routing by specifying all `protocols` which you feel comfortable using and leaving the `routingPreference` field blank.

- For a Uniswap Protocol AMM swap, the `type` field determines which side is fixed. `EXACT_INPUT` fixes the amount sent and quotes a variable output. `EXACT_OUTPUT` fixes the amount received and quotes a variable input. See [Chained Actions](/docs/trading/swapping-api/chained-actions) for multi-step routes with additional exact-input behavior.
- The `protocols` field is used to specify the protocols from which pricing will be considered and through which your swap may eventually be executed. The possible values for the field are `V2`, `V3`, `V4`, `UNISWAPX_V2`, and `UNISWAPX_V3`
- The `routingPreference` field is used to specify the preferred matching strategy. The possible values for the field are `BEST_PRICE` and `FASTEST`

For complete information on the available values and combinations for the `protocols` and `routingPreference` fields, see [Swapping Architecture Overview](/docs/trading/swapping-api/getting-started). A summary is provided below:

<Callout title="Trade type is part of the routing request" type="info">
For Uniswap Protocol AMM routing, exact input and exact output are separate quote requests. `BEST_PRICE` optimizes routes for the submitted `type`; it does not reinterpret `EXACT_INPUT` as `EXACT_OUTPUT`.

This distinction is especially important for v4 hooks with custom swap validation. If a hooked pool accepts a direction only as exact output, an exact-input request for that direction may not return the pool even when the pool can satisfy a separately formulated exact-output request. Supporting the input-budget intent requires hook-specific translation logic or an explicitly requested output amount. See [Integrated Routing with UniswapX](/docs/protocols/v4/concepts/hook-routing#allowlisting-and-swap-compatibility).
</Callout>

## Routing Outcomes

- To perform a swap using only Uniswap protocol liquidity pools, specify `protocols` as `V2`, `V3`, and/or `V4`.
Expand All @@ -21,4 +28,4 @@ For complete information on the available values and combinations for the `proto

## Cross-chain and multi-step routing

Some trades cannot settle in a single transaction, either because they cross chains or because they need more than one step on the same chain. For these, `/quote` returns `"routing": "CHAINED"` and the API drives execution as an ordered plan of steps. See [Swapping with Chained Actions](/docs/trading/swapping-api/chained-actions).
Some trades cannot settle in a single transaction, either because they cross chains or because they need more than one step on the same chain. For these, `/quote` returns `"routing": "CHAINED"` and the API drives execution as an ordered plan of steps. See [Swapping with Chained Actions](/docs/trading/swapping-api/chained-actions).
Loading