Place a spot order

This guide walks through placing a limit order on one of Pod's spot markets. For background, see Orderbook.

Spot orders use the same submitOrder call as perpetual orders. For spot, pass reduceOnly = false and ioc = false for a resting limit order. Deposit the quote token (USD) before submitting.

The example below trades the NVDAx-USD spot market — see Market Configurations for the full live list.

See the Orderbook precompile reference for the timestamp unit, deadline-alignment, and TTL rules that apply to every call below.

Steps

  1. Deposit the quote token into the orderbook contract.

  2. Submit a limit order with price, size, deadline, and TTL.

import { ethers } from "ethers";

const provider = new ethers.JsonRpcProvider("https://rpc.podtestnet.dev");
const wallet = new ethers.Wallet(PRIVATE_KEY, provider);

const ORDERBOOK = "0x50d0000000000000000000000000000000000002";
const abi = [
  "function deposit(address token, address recipient, uint256 amount, uint128 deadline)",
  "function submitOrder(bytes32 orderbookId, int256 size, uint256 price, uint8 orderType, uint128 deadline, uint128 ttl, bool reduceOnly, bool ioc)",
];
const orderbook = new ethers.Contract(ORDERBOOK, abi, wallet);

// USD is the native token; NVDAx is the synthetic Nvidia base
const USD = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
const orderbookId = "0x0000000000000000000000000000000000000000000000000000000000000001"; // NVDAx-USD spot
const now = BigInt(Date.now()) * 1000n; // microseconds

// 1. Deposit USD (the quote token) into the orderbook
const depositAmount = ethers.parseEther("1000");
await (await orderbook.deposit(USD, wallet.address, depositAmount, now + 60_000_000n)).wait();

// 2. Submit a buy limit order: 1 NVDAx at 200 USD
const size = ethers.parseEther("1");         // buy 1 NVDAx (positive = buy)
const price = ethers.parseEther("200");      // limit price in USD
const orderType = 0;                         // 0 = Limit, 1 = Market
const deadline = now + 10_000_000n;          // include in batches within next 10 seconds
const ttl = 60n * 1_000_000n;               // order lives for 60 seconds

const tx = await orderbook.submitOrder(
  orderbookId, size, price, orderType, deadline, ttl,
  false,    // reduceOnly (perp only)
  false,    // ioc — immediate-or-cancel
);
console.log("Order tx:", tx.hash);

Last updated