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 
priceandamount - Token addresses for the market
 
π₯ Parametersβ
Requiredβ
| Name | Type | Description | 
|---|---|---|
chainId | number | Chain ID (e.g. 2001 for Monad Testnet) | 
userAddress | string | Address 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) | 
baseToken | string | Base token address | 
quoteToken | string | Quote token address | 
Optional (options object)β
| Name | Type | Description | 
|---|---|---|
rpcUrl | string | RPC endpoint for signing and broadcasting | 
useSubgraph | boolean | Whether to fetch orderbook data from the subgraph (default: true) | 
orderIdsToClaim | string[] | Order IDs to claim before placing new quotes | 
orderIdsToCancel | string[] | Order IDs to cancel before placing new quotes | 
provider | string? | 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β
- Cancel: Cancel the specified 
orderIdsToCancel, if any - Claim: Claim filled orders listed in 
orderIdsToClaim - Quote: Submit new limit orders using the provided 
bidQuotesandaskQuotes 
β οΈ Notes & Best Practicesβ
- All 
priceandamountvalues must be strings (can include decimals) amountis always in base token unitspriceshould follow the quote/base format
e.g. if 1 WMON = 0.2 USDC, thenprice = 0.2- Itβs recommended to round prices and amounts appropriately before submission
 - If 
useSubgraphisfalse, 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 (
orderIdto pass intoorderIdsToCancelororderIdsToClaim) - 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 
orderIdsToCancelintoplaceMarketMakingQuotesto 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 
orderIdsToClaimandorderIdsToCancelarrays to keep your orderbook clean and profitable