Section 17 of 18

Build
+15 Lynx

Periphery: The SwapRouter

Key takeaway: The router is the user-facing shell around the pool's raw swap: checkDeadline rejects stale transactions, exactInputSingle/exactOutputSingle derive zeroForOne from token ordering, default a missing sqrtPriceLimitX96 to MIN_SQRT_RATIO + 1 / MAX_SQRT_RATIO - 1, and enforce amountOutMinimum / amountInMaximum slippage bounds after the pool returns. Payment happens in uniswapV3SwapCallback — and its first real statement is the security boundary of the entire periphery: recompute the legitimate pool for (tokenIn, tokenOut, fee) and require(msg.sender == pool) before trusting one byte of callback data or moving one wei of user funds. Skip that require and anyone can drain every allowance ever granted to your router.

What You Are Building

A single-hop SwapRouter: the checkDeadline modifier, a getPool lookup, exactInputSingle, exactOutputSingle, and the swap callback. Interfaces, TickMath bounds, SafeCast, and TransferHelper are provided.

Your Code

Solution.sol
Solidity
Loading editor...

Requirements

Write your implementation, then click Run Tests. Tests execute on the server.

Sign up free — keep reading + earn 15 Lynx

Zealynx Academy is free. Track your progress, earn Lynx, and climb the leaderboard.

Sign up free to continue

Already have an account? Log in