Skip to main content

Batch Order Execution with placeMarketMakingQuotes

The placeMarketMakingQuotes function is the core utility for submitting multiple bid and ask quotes on Clober’s on-chain orderbook. It is typically used in market-making bots to automate quote placement, cancellation, and profit claiming in a single step.


🧾 Function Signature​

export const placeMarketMakingQuotes = async ({
chainId,
userAddress,
bidQuotes,
askQuotes,
baseToken,
quoteToken,
clearOpenOrders,
options,
}: {
chainId: CHAIN_IDS
userAddress: `0x${string}`
bidQuotes: { price: string; amount: string }[]
askQuotes: { price: string; amount: string }[]
baseToken: `0x${string}`
quoteToken: `0x${string}`
clearOpenOrders?: boolean
options?: {
market?: Market
roundingUpMakeBid?: boolean
roundingDownMakeAsk?: boolean
useSubgraph?: boolean
provider?: `0x${string}`
orderIdsToClaim: string[]
orderIdsToCancel: string[]
} & DefaultWriteContractOptions
}): Promise<Transaction>

Description​

This function places multiple bid and ask quotes on the Clober orderbook and can optionally:

  • Clear open orders before placing new ones
  • Claim filled orders
  • Use rounding rules for bid/ask prices
  • Use subgraph or RPC-based market data
  • Customize contract writing options via DefaultWriteContractOptions

You must provide:

  • A valid chain ID (chainId)
  • The address of the user submitting the quotes (userAddress)
  • Arrays of bid and ask quotes with price and amount
  • Token addresses for the market

πŸ“₯ Parameters​

Required​

NameTypeDescription
chainIdnumberChain ID (e.g. 2001 for Monad Testnet)
userAddressstringAddress of the EOA performing the trades
bidQuotes{ price: string, amount: string }[]List of bid orders (sorted low to high recommended)
askQuotes{ price: string, amount: string }[]List of ask orders (sorted high to low recommended)
baseTokenstringBase token address
quoteTokenstringQuote token address

Optional (options object)​

NameTypeDescription
rpcUrlstringRPC endpoint for signing and broadcasting
useSubgraphbooleanWhether to fetch orderbook data from the subgraph (default: true)
orderIdsToClaimstring[]Order IDs to claim before placing new quotes
orderIdsToCancelstring[]Order IDs to cancel before placing new quotes
providerstring?Optional custom provider

πŸš€ Example Usage​

await placeMarketMakingQuotes({
chainId: 2001,
userAddress: walletClient.account.address,
bidQuotes: [
{ price: '0.195', amount: '10' },
{ price: '0.193', amount: '10' },
],
askQuotes: [
{ price: '0.205', amount: '10' },
{ price: '0.207', amount: '10' },
],
baseToken: '0x...WMON',
quoteToken: '0x...USDC',
options: {
rpcUrl: 'https://monad-testnet.node.com',
useSubgraph: false,
orderIdsToClaim: ['order1', 'order2'],
orderIdsToCancel: ['order3'],
},
})

πŸ”„ Execution Flow​

  1. Cancel: Cancel the specified orderIdsToCancel, if any
  2. Claim: Claim filled orders listed in orderIdsToClaim
  3. Quote: Submit new limit orders using the provided bidQuotes and askQuotes

⚠️ Notes & Best Practices​

  • All price and amount values must be strings (can include decimals)
  • amount is always in base token units
  • price should follow the quote/base format
    e.g. if 1 WMON = 0.2 USDC, then price = 0.2
  • It’s recommended to round prices and amounts appropriately before submission
  • If useSubgraph is false, make sure to fetch current prices manually from the on-chain orderbook

πŸ“¬ How to Check Open Orders​

To retrieve all currently open orders for a specific user on a given chain, use the getOpenOrders helper function.

Example​

const openOrders = await getOpenOrders({
chainId: chain.id,
userAddress: walletClient.account.address,
})

This will return a list of open order objects associated with the provided address on the specified chain.

Each order object includes information such as:

  • Order ID (orderId to pass into orderIdsToCancel or orderIdsToClaim)
  • Price
  • Amount remaining
  • Whether the order is bid or ask

You can use this to:

  • Display open orders in your UI
  • Decide which orders to cancel or modify
  • Pass orderIdsToCancel into placeMarketMakingQuotes to manage stale quotes

🧠 Strategy Tips​

  • Wrap this function in a loop with timers to simulate real-time quoting
  • You can build custom quote logic (e.g. skewed spreads, dynamic sizes) and plug them into bidQuotes/askQuotes
  • Use the orderIdsToClaim and orderIdsToCancel arrays to keep your orderbook clean and profitable