Skip to main content

Router ABI

The Market Router is the primary entry point for all trading operations. Use these minimal ABIs to interact with the router contract. Address (Sepolia): 0x82bfe1b31b6c1c3d201a0256416a18d93331d99e

Limit Orders

[
  {
    "name": "limitBid",
    "type": "function",
    "stateMutability": "payable",
    "inputs": [
      {
        "name": "params",
        "type": "tuple",
        "components": [
          { "name": "market", "type": "address" },
          { "name": "deadline", "type": "uint64" },
          { "name": "claimBounty", "type": "uint32" },
          { "name": "user", "type": "address" },
          { "name": "priceIndex", "type": "uint16" },
          { "name": "rawAmount", "type": "uint64" },
          { "name": "postOnly", "type": "bool" },
          { "name": "useNative", "type": "bool" },
          { "name": "baseAmount", "type": "uint256" }
        ]
      }
    ],
    "outputs": [{ "name": "", "type": "uint256" }]
  },
  {
    "name": "limitAsk",
    "type": "function",
    "stateMutability": "payable",
    "inputs": [
      {
        "name": "params",
        "type": "tuple",
        "components": [
          { "name": "market", "type": "address" },
          { "name": "deadline", "type": "uint64" },
          { "name": "claimBounty", "type": "uint32" },
          { "name": "user", "type": "address" },
          { "name": "priceIndex", "type": "uint16" },
          { "name": "rawAmount", "type": "uint64" },
          { "name": "postOnly", "type": "bool" },
          { "name": "useNative", "type": "bool" },
          { "name": "baseAmount", "type": "uint256" }
        ]
      }
    ],
    "outputs": [{ "name": "", "type": "uint256" }]
  }
]
The claimBounty field is reserved for future use. Always set it to 0.

Parameter Reference

ParameterTypeDescription
marketaddressThe OrderBook contract address for the trading pair
deadlineuint64Unix timestamp after which the transaction reverts
claimBountyuint32Reserved for future use (set to 0)
useraddressAddress to receive the order NFT and proceeds
priceIndexuint16Price level index from the PriceBook
rawAmountuint64Quote token amount in raw units (for bids)
postOnlyboolIf true, reverts if order would immediately fill
useNativeboolIf true, uses native ETH instead of WETH
baseAmountuint256Base token amount (for asks)

Market Orders

[
  {
    "name": "marketBid",
    "type": "function",
    "stateMutability": "payable",
    "inputs": [
      {
        "name": "params",
        "type": "tuple",
        "components": [
          { "name": "market", "type": "address" },
          { "name": "deadline", "type": "uint64" },
          { "name": "user", "type": "address" },
          { "name": "limitPriceIndex", "type": "uint16" },
          { "name": "rawAmount", "type": "uint64" },
          { "name": "expendInput", "type": "bool" },
          { "name": "useNative", "type": "bool" },
          { "name": "baseAmount", "type": "uint256" }
        ]
      }
    ],
    "outputs": []
  },
  {
    "name": "marketAsk",
    "type": "function",
    "stateMutability": "payable",
    "inputs": [
      {
        "name": "params",
        "type": "tuple",
        "components": [
          { "name": "market", "type": "address" },
          { "name": "deadline", "type": "uint64" },
          { "name": "user", "type": "address" },
          { "name": "limitPriceIndex", "type": "uint16" },
          { "name": "rawAmount", "type": "uint64" },
          { "name": "expendInput", "type": "bool" },
          { "name": "useNative", "type": "bool" },
          { "name": "baseAmount", "type": "uint256" }
        ]
      }
    ],
    "outputs": []
  }
]

Parameter Reference

ParameterTypeDescription
marketaddressThe OrderBook contract address
deadlineuint64Unix timestamp after which the transaction reverts
useraddressAddress to receive the traded tokens
limitPriceIndexuint16Maximum (bid) or minimum (ask) price index
rawAmountuint64Max input (bid) or min output (ask) in raw units
expendInputboolIf true, spends all input; if false, stops at desired output
useNativeboolIf true, uses native ETH instead of WETH
baseAmountuint256Max input (ask) or min output (bid) in base tokens

Claim

[
  {
    "name": "claim",
    "type": "function",
    "stateMutability": "nonpayable",
    "inputs": [
      { "name": "deadline", "type": "uint64" },
      {
        "name": "paramsList",
        "type": "tuple[]",
        "components": [
          { "name": "market", "type": "address" },
          {
            "name": "orderKeys",
            "type": "tuple[]",
            "components": [
              { "name": "isBid", "type": "bool" },
              { "name": "priceIndex", "type": "uint16" },
              { "name": "orderIndex", "type": "uint256" }
            ]
          }
        ]
      }
    ],
    "outputs": []
  }
]

Complete Router ABI

Copy this complete ABI for full router integration:
[
  {
    "name": "limitBid",
    "type": "function",
    "stateMutability": "payable",
    "inputs": [
      {
        "name": "params",
        "type": "tuple",
        "components": [
          { "name": "market", "type": "address" },
          { "name": "deadline", "type": "uint64" },
          { "name": "claimBounty", "type": "uint32" },
          { "name": "user", "type": "address" },
          { "name": "priceIndex", "type": "uint16" },
          { "name": "rawAmount", "type": "uint64" },
          { "name": "postOnly", "type": "bool" },
          { "name": "useNative", "type": "bool" },
          { "name": "baseAmount", "type": "uint256" }
        ]
      }
    ],
    "outputs": [{ "name": "", "type": "uint256" }]
  },
  {
    "name": "limitAsk",
    "type": "function",
    "stateMutability": "payable",
    "inputs": [
      {
        "name": "params",
        "type": "tuple",
        "components": [
          { "name": "market", "type": "address" },
          { "name": "deadline", "type": "uint64" },
          { "name": "claimBounty", "type": "uint32" },
          { "name": "user", "type": "address" },
          { "name": "priceIndex", "type": "uint16" },
          { "name": "rawAmount", "type": "uint64" },
          { "name": "postOnly", "type": "bool" },
          { "name": "useNative", "type": "bool" },
          { "name": "baseAmount", "type": "uint256" }
        ]
      }
    ],
    "outputs": [{ "name": "", "type": "uint256" }]
  },
  {
    "name": "marketBid",
    "type": "function",
    "stateMutability": "payable",
    "inputs": [
      {
        "name": "params",
        "type": "tuple",
        "components": [
          { "name": "market", "type": "address" },
          { "name": "deadline", "type": "uint64" },
          { "name": "user", "type": "address" },
          { "name": "limitPriceIndex", "type": "uint16" },
          { "name": "rawAmount", "type": "uint64" },
          { "name": "expendInput", "type": "bool" },
          { "name": "useNative", "type": "bool" },
          { "name": "baseAmount", "type": "uint256" }
        ]
      }
    ],
    "outputs": []
  },
  {
    "name": "marketAsk",
    "type": "function",
    "stateMutability": "payable",
    "inputs": [
      {
        "name": "params",
        "type": "tuple",
        "components": [
          { "name": "market", "type": "address" },
          { "name": "deadline", "type": "uint64" },
          { "name": "user", "type": "address" },
          { "name": "limitPriceIndex", "type": "uint16" },
          { "name": "rawAmount", "type": "uint64" },
          { "name": "expendInput", "type": "bool" },
          { "name": "useNative", "type": "bool" },
          { "name": "baseAmount", "type": "uint256" }
        ]
      }
    ],
    "outputs": []
  },
  {
    "name": "claim",
    "type": "function",
    "stateMutability": "nonpayable",
    "inputs": [
      { "name": "deadline", "type": "uint64" },
      {
        "name": "paramsList",
        "type": "tuple[]",
        "components": [
          { "name": "market", "type": "address" },
          {
            "name": "orderKeys",
            "type": "tuple[]",
            "components": [
              { "name": "isBid", "type": "bool" },
              { "name": "priceIndex", "type": "uint16" },
              { "name": "orderIndex", "type": "uint256" }
            ]
          }
        ]
      }
    ],
    "outputs": []
  }
]

Usage Example

import { ethers } from 'ethers';

const ROUTER_ABI = [...]; // ABI from above
const ROUTER_ADDRESS = '0x82bfe1b31b6c1c3d201a0256416a18d93331d99e';

const provider = new ethers.JsonRpcProvider('https://0xrpc.io/sep');
const signer = new ethers.Wallet(PRIVATE_KEY, provider);
const router = new ethers.Contract(ROUTER_ADDRESS, ROUTER_ABI, signer);

// Place a limit bid
const params = {
  market: '0x2e4a11c7711c6a69ac973cbc40a9b16d14f9aa7e',
  deadline: Math.floor(Date.now() / 1000) + 3600,
  claimBounty: 0,
  user: signer.address,
  priceIndex: 19500,
  rawAmount: 1000n,
  postOnly: true,
  useNative: false,
  baseAmount: 0n
};

const tx = await router.limitBid(params);
await tx.wait();
See the Order Lifecycle Tutorial for a complete working example.