Skip to content

dex.getOrder

Gets an order's details from the Stablecoin DEX orderbook.

Usage

example.ts
import { client } from './viem.config'
 
const order = await client.dex.getOrder({
  orderId: 123n,
})
 
console.log('Order details:', order)
Order details: { amount: 100000000n, maker: '0x...', isBid: true, ... }

Return Type

type ReturnType = {
  /** Original order amount */
  amount: bigint
  /** Orderbook key (identifies the trading pair) */
  bookKey: Hex
  /** Tick to flip to when fully filled (for flip orders). For bid flips: must be > tick. For ask flips: must be < tick */
  flipTick: number
  /** Whether this is a bid (true) or ask (false) order */
  isBid: boolean
  /** Whether this is a flip order */
  isFlip: boolean
  /** Address of the user who placed this order */
  maker: Address
  /** Next order ID in the doubly linked list (0 if tail) */
  next: bigint
  /** The order ID */
  orderId: bigint
  /** Previous order ID in the doubly linked list (0 if head) */
  prev: bigint
  /** Remaining amount to be filled */
  remaining: bigint
  /** Price tick */
  tick: number
}

Returns the complete order details including the maker's address, order amounts, price tick, linked list pointers, and flip order information.

Parameters

orderId

  • Type: bigint

Order ID to query.

account (optional)

  • Type: Account | Address

Account that will be used to send the transaction.

blockNumber (optional)

  • Type: bigint

Block number to read the state from.

blockOverrides (optional)

  • Type: BlockOverrides

Block overrides to apply to the state.

blockTag (optional)

  • Type: BlockTag

Block tag to read the state from.

stateOverride (optional)

  • Type: StateOverride

State override to apply.