Deriverse has built a fully onchain perpetual CLOB (central limit orderbook) on Solana, featuring fully onchain liquidations and funding payment calculations, as well as zero administrative role of the founding team. In this blog post, we’ll explore the inner workings of liquidations in our perpetual markets, including how they interact with other protocol components, manage client funds, and ensure capital adequacy. Whether you’re a seasoned perps trader or new to perpetual futures, this guide will help you understand the mechanics behind our system.
Each perpetual market operates as an autonomous system, interacting with other parts of the protocol solely through the input and output of client funds. This design ensures that each market functions independently, providing a robust and modular trading environment. In the current version of the protocol, the oracle price serves as the price source for calculating funding rates and initiating margin call procedures. However, this setup is flexible—future iterations of the protocol can easily replace the oracle price with a spot market price for enhanced accuracy and decentralization.
Client funds are managed with simplicity and transparency. Deposits and withdrawals occur directly from the client’s main account on the platform. In the current version, the settlement currency for all perpetual markets is a stablecoin, e.g. USDC. When trading in perpetual markets, clients have access to the following key data points:
perps: The number of futures in the client’s position.
in_orders_perps: The number of futures in open sell orders.
funds: The client’s available funds in the settlement currency.
in_orders_funds: The client’s funds locked in open buy orders.
The client’s full position is calculated as:
Similarly, the client’s full funds are:
Clients can trade with leverage, which in the current implementation of the protocol ranges from 1x to 10x. To ensure capital adequacy, the protocol evaluates the client’s position using the following formula:
When a new order is submitted, the smart contract checks whether the client’s capital is sufficient using this inequality:
If the inequality holds, the transaction is registered. Otherwise, the system returns an insufficient funds error.
After a client’s position changes, the protocol calculates a critical price—the price at which the client’s evaluation would reach zero. This is determined using the following formulas:
For Long Positions:
For Short Positions:
Here, MAX_PRICE represents a deliberately large, unattainable value.
If the market price for a long position drops below:
or if the market price for a short position rises above:
a margin call is triggered, and the client’s position is forcibly closed.
Clients can withdraw funds from the perpetual market based on the following formula:
If there are unclosed margin calls, the withdrawal process becomes more complex. In such cases, the protocol uses the last spot price before the margin call to calculate the available funds. The client can withdraw the minimum value between the funds calculated using this price and the current market price.
To protect the protocol and its users, we’ve implemented an insurance fund. When a client’s position is forcibly liquidated, they pay a commission of 1%, which (after rebates) is allocated to the insurance fund.
If a loss occurs during liquidation, it is covered by the insurance fund. However, if the insurance fund is insufficient, the loss is distributed proportionally among market participants holding positions opposite to the liquidated position. This ensures that the protocol remains solvent and fair, with all transactions recorded on-chain for transparency.
Our perpetual markets are designed to provide a decentralized, secure, autonomous, and efficient trading experience. By leveraging robust mechanisms for fund management, leverage evaluation, and liquidation, we ensure that both traders and the protocol are protected.
Deriverse isn’t just another decentralized exchange—it’s a trading ecosystem optimized for the most active and demanding users: market makers and professional takers. By leveraging Solana’s latest tech, including compute unit optimization and versioned transactions, Deriverse delivers a fast, reliable, and cost-efficient trading experience for everyone.
Thank you for shaping the future of decentralized derivatives trading with us! Stay tuned for our next article! Please consider giving us a follow on X or join our Discord server.
👉 Follow us on X: https://x.com/deriverse_io
👉 Join our Discord: https://discord.gg/2bWzKRS3SN