SwapRouter

The SwapRouter class encodes transaction calldata for executing swaps on the Hydrex router contract.


Import

typescript
import {
  SwapRouter,
  SWAP_ROUTER_ADDRESSES,
  ChainId,
} from '@hydrexfi/hydrex-sdk';

swapCallParameters

Static method that returns encoded calldata and value for a swap transaction. Works with both single-hop and multi-hop trades.

typescript
const { calldata, value } = SwapRouter.swapCallParameters(trade, {
  slippageTolerance: new Percent(50, 10_000), // 0.5%
  recipient: '0xYourWallet',
  deadline: Math.floor(Date.now() / 1000) + 1200,
});

// Contract address for the transaction:
const to = SWAP_ROUTER_ADDRESSES[ChainId.Base];
// 0x6f4bE24d7dC93b6ffcBAb3Fd0747c5817Cea3F9e

Options

ParameterTypeRequiredDescription
slippageTolerancePercentrequiredMaximum acceptable slippage as a Percent. E.g. new Percent(50, 10_000) = 0.5%.
recipientstringrequiredAddress to receive the output tokens.
deadlinenumberrequiredUnix timestamp (seconds) after which the transaction will revert.
inputTokenPermitPermitOptionsoptionalERC-2612 permit data to approve the router without a separate approve tx.
sqrtPriceLimitX96BigintIshoptionalOptional price limit for the swap. Defaults to no limit.
feeFeeOptionsoptionalOptional protocol fee configuration.

Native ETH

When the trade input is native ETH, include the returned value as msg.value in your transaction. The router contract handles wrapping automatically.

Contract Addresses

NetworkAddress
Base Mainnet0x6f4bE24d7dC93b6ffcBAb3Fd0747c5817Cea3F9e
Base Sepoliasee SWAP_ROUTER_ADDRESSES[ChainId.BaseSepolia]
Hydrex

Hydrex is an Omni-Liquidity MetaDEX built on Base for Base, designed to bring new users onchain.

Paragraph

© 2026 Hydrex. All rights reserved.