CanonicCanonic Docs
Documentation

Operators (CLP API)

Overview

The CLP vault is designed to be operated. The operator decides how to deploy pooled liquidity onto MAOB rungs, claim fills, and manage cancellations to maintain liquidity.

In CLP.sol, these actions are gated by OPERATOR_ROLE (and some emergency paths allow DEFAULT_ADMIN_ROLE as well).

Placing orders

placeOrders(withdrawOrders, balanceOrders)

This is the primary operator entrypoint. It places two categories of MAOB liquidity orders:

  • withdrawOrders: orders funded from MAOB withdrawable balances (placed via maob.requoteFromWithdrawable)
  • balanceOrders: orders funded directly from CLP’s wallet balances (placed via maob.addLiquidityBatch)

Operational constraints:

  • CLP maintains an activeOrderIds list with a maximum length MAX_ACTIVE_ORDERS.
  • Before adding new orders, CLP prunes non-active tracked orders.
  • If the placement would exceed MAX_ACTIVE_ORDERS, it reverts with CLP__TooManyOrders().

The call emits TopUp(baseUsed, quoteUsed, orderCount) for accounting/monitoring.

Claiming fills

As fills happen, CLP must claim outputs from MAOB into the vault:

  • claimOrders(orderIds) claims a chosen set of MAOB orders.
  • claimActiveOrders(startIndex, batchSize) claims a slice of the tracked active list.

After claiming, CLP prunes inactive orders from its tracked list.

Cancelling orders

Operators may cancel orders to free liquidity:

  • cancelOrders(orderIds, withdrawAfter)

This function:

  1. claims the given orders (so fills aren’t lost)
  2. cancels any of those orders that remain active
  3. optionally calls maob.withdraw() to pull refunds back to CLP
  4. prunes the tracked order list

Emergency exit

exitAndWithdrawAll()

Callable by either OPERATOR_ROLE or DEFAULT_ADMIN_ROLE.

This is intended as an emergency or shutdown flow:

  1. claim all tracked orders
  2. cancel all active tracked orders
  3. withdraw any MAOB withdrawable balances to CLP
  4. close deposits (depositsOpen = false)

This emits ExitInitiated(caller) and closes deposits to prevent new LP capital entering during an exit.

Operator responsibilities (practical guidance)

  • Maintain a rung strategy (how liquidity is distributed across rungs) based on desired spread and inventory.
  • Monitor MAOB oracle health (staleness and range) because it directly affects fill behavior.
  • Keep enough “free” balances for expected withdrawals; otherwise withdrawals may trigger cancellations and revert under extreme conditions.