SwapRouter02 is PotatoSwap’s unified routing contract. It supports token swaps for both V2 and V3. Third-party dApps, wallets, and aggregators can use SwapRouter02 as a single entry point to perform V2/V3 swaps and liquidity-related operations.
Deployment Network
196Contract Address
0xB45D0149249488333E3F3f9F359807F4b810C1FCRecommendation:
Prioritize using SwapRouter02 to execute token swaps (whether V2 or V3). Trade executions, liquidity changes, and price update events are emitted by the Pool contracts, not by the Router.
SwapRouter02 inherits the full V3 swap functionality and its interfaces are fully compatible with the standard V3 Router.
exactInputSingle: Single-pool swap with exact input (V3)function exactInputSingle(ExactInputSingleParams calldata params)
external
payable
returns (uint256 amountOut); // Final amount of tokenOut sent to recipient
ExactInputSingleParams struct:
struct ExactInputSingleParams {
address tokenIn; // Address of the input token
address tokenOut; // Address of the output token
uint24 fee; // Pool fee (100/500/3000/10000)
address recipient; // Address that receives the output
uint256 amountIn; // Exact input amount
uint256 amountOutMinimum; // Minimum acceptable output (slippage protection)
uint160 sqrtPriceLimitX96; // Price limit (0 means no limit)
}
This performs a swap from tokenIn → tokenOut in the specified V3 pool (by fee) using an exact input of amountIn, to get as much amountOut as possible, with the requirement that
amountOut ≥ amountOutMinimum.
exactInput: Multi-hop swap with exact input (V3)function exactInput(ExactInputParams calldata params)
external
payable
returns (uint256 amountOut); // Final amount of output token sent to recipient