Skip to main content

Introduction

Multi-hop swaps route through intermediate pools. The contract setup is identical to single swaps — refer to that guide for the base contract, imports, and constructor.

Exact Input Multi Hop Swaps

Input Parameters

  • path: A sequence of (tokenAddress, fee, tokenAddress) encoded via abi.encodePacked. The router resolves each pool from these values.
  • amountOutMinimum: minimum output amount — use an oracle or the SDK in production.

Calling the function

Exact Output Multihop Swap

For exact output, the path is encoded in reverse order because the swap executes backwards to determine the required input.

Input Parameters

  • path: (tokenOut, fee, intermediary, fee, tokenIn) — note the reversed order.
  • amountOut: the desired output amount.
  • amountInMaximum: maximum input willing to spend.

Calling the function