Clearance Bots

Technical Challenges

Implementing the CVEX protocol purely as a smart contract presents several technical challenges:

  • High Operational Costs: Proactively monitoring user margin ratios on-chain, particularly for variation margin, is complex and expensive. This process requires continuous computation and state updates on the blockchain.

  • Reactive Execution Limitations: Smart contracts inherently function on a reactive model and lack the capability for scheduled task execution. This limits the automation of certain time-sensitive protocol functions.

  • Unfair Cost Distribution: When taker orders match with multiple small limit orders in the order book, it can result in a single trader disproportionately bearing the execution costs. This leads to inequitable transaction fee distribution among participants, where one trader inadvertently subsidises the transactions of others.

Clearance Bot Operations

CVEX introduces Clearance Bots, essential actors within its ecosystem, to address these issues, which is crucial for maintaining protocol integrity. They manage various aspects of the protocol's operations:

  • Order Clearing: Clearance Bots manage the clearing of limit orders efficiently. Matched limit orders are moved to a clearance queue before being cleared by these bots, ensuring limited gas expenditure for taker orders and successful executions, irrespective of the number of matched orders.

  • Settlement Responsibilities: After the expiry of futures and options contracts, they oversee the closure of all active positions and the cancellation of open orders.

  • Initiating Portfolio Liquidation: Actively monitoring trader margins, they initiate liquidations when collateral falls below required thresholds.

  • Default Prevention: They play a preventive role in potential default situations, cancelling limit orders of users at high risk of default if executed.

  • Managing Auto Deleverage Queue: Responsible for clearing the ADL queue post-counterparty liquidations adjusting the positions of queued traders that should be deleveraged.

  • Conditional Order Management: Executing or cancelling orders based on predefined conditions like Stop Limit, Stop Loss, and Take Profit.

All Clearance Bot actions are deterministic and defined by the protocol implementation, allowing anyone to operate as Clearance Bot in a permissionless manner, subject only to called actions validity. They are incentivised to perform these services, receiving gas compensation with an extra premium from the Operational Fund for each valid call. This ensures operational continuity and integrity, as bot's activities remain financially viable even during gas price surges.

The CVEX team will publish the Clearance Bot reference implementation as an integral part of the CVEX Protocol, inviting everyone to contribute to the integrity of the ecosystem. The development and use of more advanced versions of Clearance Bots are also unrestricted.

Last updated