Periphery

WarpRouter02 (Router)

Source: packages/periphery/contracts/WarpRouter.sol implementing IWarpRouter02.

State: immutable factory() and WETH() addresses; reverts if deadline < block.timestamp on any user-facing method.

Liquidity Management

  • addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin, to, deadline)

    • Approvals required for both tokens to the router.

    • If the pair does not exist, the router creates it on the fly via the factory.

    • Internally balances desired inputs using WarpLibrary.quote so slippage bounds (amountA/BMin) must be set around expected ratios.

  • addLiquidityETH(token, amountTokenDesired, amountTokenMin, amountETHMin, to, deadline) (payable)

    • Wraps native ETH into WETH before forwarding into the pair.

    • Refunds surplus ETH to the sender.

  • removeLiquidity(...) and removeLiquidityETH(...)

    • Transfer LP tokens from the caller to the pair, burn them, and distribute assets to to.

    • ETH variant unwraps WETH before final transfer.

  • Permit variants: removeLiquidityWithPermit + removeLiquidityETHWithPermit accept EIP-2612 signatures so integrators can batch approve-and-remove in one call.

Liquidity for Fee-On-Transfer Tokens

removeLiquidityETHSupportingFeeOnTransferTokens and removeLiquidityETHWithPermitSupportingFeeOnTransferTokens handle tokens that tax transfers by re-checking router balances instead of the raw burn return values.

Swap Entry Points

All swap functions expect an ordered path of at least two addresses. The router handles wiring funds between intermediate pairs and enforces min/max slippage via amountOutMin/amountInMax. Available combinations:

  • swapExactTokensForTokens

  • swapTokensForExactTokens

  • swapExactETHForTokens (payable)

  • swapTokensForExactETH

  • swapExactTokensForETH

  • swapETHForExactTokens (payable)

Fee-on-transfer safe variants (swapExactTokensForTokensSupportingFeeOnTransferTokens, swapExactETHForTokensSupportingFeeOnTransferTokens, swapExactTokensForETHSupportingFeeOnTransferTokens) read the received balance instead of trusting pair outputs.

Pricing Helpers

Integrators can quote trades or rebalance liquidity without touching the chain via:

  • quote(amountA, reserveA, reserveB) – deterministic price quote.

  • getAmountOut(amountIn, reserveIn, reserveOut) and getAmountIn(amountOut, reserveIn, reserveOut) – expose the 0.30% fee curve.

  • getAmountsOut(amountIn, path) and getAmountsIn(amountOut, path) – chain-aware quoting across multiple hops.

These mirror functions in WarpLibrary so any SDK code can reuse the same math off-chain.

WarpRouter01

packages/periphery/contracts/WarpRouter01.sol is a slimmer router that omits fee-on-transfer helpers. Use it only if you require a byte-identical clone of the Uniswap v2 router v1 interface; otherwise WarpRouter02 (above) is the canonical deployment.

WarpMigrator

Source: packages/periphery/contracts/WarpMigrator.sol

Single migrate(token, amountTokenMin, amountETHMin, to, deadline) entrypoint:

  1. Pulls the caller’s entire V1 LP position from the V1 exchange (requires prior approval to the migrator).

  2. Removes V1 liquidity and captures the token/ETH amounts.

  3. Approves the v2 router for those tokens and adds v2 liquidity via addLiquidityETH, respecting the caller’s min amounts.

  4. Refunds any excess tokens or ETH back to the caller.

Route bonding-curve graduates or legacy LPs through this migrator to seed v2 pools atomically.

Last updated