跳转至

Router ABI

Contract name on-chain: MarketRouter (implements the SeraRouter interface). 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

Full ABI Artifact

  • Interface: sera-protocol/src/interfaces/SeraRouter.sol
  • Full ABI JSON can be generated from the interface; the minimal ABIs below cover common entry points.

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" }]
  }
]

Note

The claimBounty field is reserved for future use. Always set it to 0.

Parameter Reference

Parameter Type Description
market address The OrderBook contract address for the trading pair
deadline uint64 Unix timestamp after which the transaction reverts
claimBounty uint32 Reserved for future use (set to 0)
user address Address to receive the order NFT and proceeds
priceIndex uint16 Price level index from the PriceBook
rawAmount uint64 Quote token amount in raw units (for bids)
postOnly bool If true, reverts if order would immediately fill
useNative bool If true, uses native ETH instead of WETH
baseAmount uint256 Base 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

Parameter Type Description
market address The OrderBook contract address
deadline uint64 Unix timestamp after which the transaction reverts
user address Address to receive the traded tokens
limitPriceIndex uint16 Maximum (bid) or minimum (ask) price index
rawAmount uint64 Max input (bid) or min output (ask) in raw units
expendInput bool If true, spends all input; if false, stops at desired output
useNative bool If true, uses native ETH instead of WETH
baseAmount uint256 Max 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:

View Complete Router ABI
[
  {
    "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();

Tip

See the Order Lifecycle Tutorial for a complete working example.