RabbitX Real-Time Risk Engine: Building The Safest Exchange In DeFi

RabbitX
4 min readJun 12, 2023

--

Risk management is, and always will be, one of the key pillars of RabbitX. Our precise risk management ensures the safety of all our traders and reliability of our exchange.

In this post, we break down what’s happening under the hood of the exchange matching engine and reveal why RabbitX is the safest and most reliable exchange you can trust.

Have you ever wondered what happens to your money when you deposit to a CEX (Centralised Exchange)? On a CEX, your deposit to a wallet address gets swept to another master wallet under the control of the exchange. The exchange can then lend it to themselves and buy nice penthouses with your money (case in point FTX). You often hear news of large CEXs mishandling assets or comingling funds. That’s not how RabbitX operates. Customer funds are always kept safely segregated in a smart contract. We set out to build the most trusted and resilient decentralised derivatives exchange in DeFi (Decentralised Finance). You are in control.

On RabbitX, your assets are always onchain, viewable in our smart contract. 24/7 proof of reserves, no “swapping” of funds or comingling of customer and treasury funds. Traders and LP assets are backed 1:1. Always. That’s why you never hear questions asked about the solvency of RabbitX. Next, we will show you why we’re also the most resilient derivatives exchange in DeFi thanks to our high performance real-time risk engine.

Let’s first look at spot exchanges. Verifying the solvency of a spot exchange is pretty easy (assuming there’s no rehypothecation happening, something we never do). On a decentralised spot exchange, all trades are backed 1:1 with real assets, and there is no margin risk.

Things aren’t so simple when you’re building a derivatives exchange. Derivatives allow traders to go long and short… with leverage. With only $1,000 a trader can buy $20,000 worth of BTC on RabbitX, this added opportunity comes with added risk. RabbitX is building to become the preeminent exchange not just in DeFi, but globally (seriously); so we absolutely have to get the risk management right.

Derivatives and leverage introduce new layers of complexity, as RabbitX now needs to monitor all traders’ positions and order margin, while simultaneously ensuring the exchange’s assets are always sufficient to cover all trader’s equity plus profit and loss (PnL). This is why we built a high-performance matching engine.

Our high-performance matching engine is built using Tarantool, an in-memory database with an expressive programming language called Lua. Tarantool is what we used to create a blazing-fast, ultra-precise exchange that’s robust enough to handle leveraged positions with billions of volume. Written in C and faster than Java (or any programming language), we recognized early that Tarantool was the right database to build the system architecture of RabbitX.

Our risk engine is the fortress that protects our exchange. It’s a state-of-the-art system that constantly ensures the safety and security of all funds and RabbitX solvency. It audits every order in real-time, allowing thousands of transactions to seamlessly and coherently process with no errors and ultra-low latency.

Transactions don’t get lost in our matching engine. The exchange balance never goes negative. This removes a whole class of bugs that exist on other exchanges that aren’t present on RabbitX. It’s this precise attention to detail and innovation that differentiates us from others.

Our real-time auditing risk engine adheres to the ACID framework (atomicity, consistency, isolation, durability). For each order on RabbitX is simulated before being confirmed; this is the backbone of our atomic, rapid matching engine. This way, every transaction can be checked one at a time into the future, and rejected in a single atomic operation if it violates account margin or global risk requirements. If an order does not pass the risk checks in our post-match engine simulation, they will receive a “POST_MATCH” error.

All data is maintained in-memory, facilitating ultra-fast matching and response. Data persistence and consistency is ensured by a write-ahead log and snapshotting, so orders are never lost. Even in a crash, data is persisted, and RabbitX’s orderbook is always maintained.

With this model, we are able to total all traders equity, position margin, and order margin at once atomically. This is how we ensure that the exchange’s assets are always greater than or equal to the trader’s equity in real-time. We do all these checks in less than 0.001 seconds. This means that RabbitX can guarantee the integrity and solvency of the exchange on every. single. order.

This level of certainty is essential for derivatives trading. Crypto exchanges lag behind their TradFi counterparts in sophistication of their risk management. RabbitX is built different. We are a team of former actuaries, risk analysts, market makers, and hedge fund portfolio managers. We understand how critical risk infrastructure is when building for the long term. This knowledge advantage and our technological edge gives RabbitX a substantial competitive advantage.

Our state-of-the-art risk and matching engines are the unsung heroes of RabbitX, tirelessly working behind the scenes to guarantee a secure, superior trading experience. We’ve built a fortress of security and reliability. So if you get that margin rejection message, just know it’s working to keep everything safe, always.

Welcome to RabbitX, where safety meets speed. Trade. Earn. Win.

--

--

RabbitX

To build the largest fixed income trading platform for DeFi