Sujiko uses a liquidity mechanism composed of a) a core hybrid virtual AMM (vAMM), b) auction mechanism and c) limit orderbook.
A normal AMM has the same price for asks and bids with flat fee.
Our hybrid vAMM has configurable parameters such as initial/maintenance margin ratio, minimum/maximum spread, initial reserves (referred to as terminal reserves), liquidity depth, max fill reserve fraction, etc.
The base price, also known as reservation price, adjusts based on the current oracle price. The bid/ask price quoted by the hybrid vAMM is equal to the reservation price ± base_spread + f(inventory skew).
Each perpetual futures market on Sujiko includes tracking for:
- Last 10 oracle values (lookback window for volatility dampening)
- Mark TWAP - 1HR + Oracle TWAP - 1HR (used for funding)
- Mark TWAP - 5min + Oracle TWAP - 5min (used to determine market health i.e. if mark price > 20% from TWAP)
Each hybrid vAMM of each perpetual futures market has an associated isolated adjustments pool, funding rate pool, and insurance fund pool. The adjustments pool is used to adjust the base price by rebalancing the pool through a repeg. The funding rate pool is used to pay out/receive funding payments to/from traders with positions.
The insurance fund pool is used to cover losses from liquidations. When a position is liquidated, a liquidation penalty is incurred. This liquidation penalty is added to the insurance fund pool.
A perpetuals futures market can enter a restricted mode if it is deemed unhealthy. This can occur when a strong imbalance of longs and shorts exists or the divergence between oracle and mark price exceeds a pre-defined limit of 20%. When a market enters restricted mode, there will be restrictions to order fills, liquidations, and funding rate updates if they increase protocol risk.
A repeg event effectively keeps the funding rate within a range. The cost/benefit of the repeg is the change in total liquidating cost of the net position of the protocol. This is implemented using a scaling factor we call m_mul:
The new hybrid vAMM mark price can be calculated using:
- y = quote reserves
- x = base reserves in the hybrid vAMM
The protocol will check if a repeg is required on any trade or after a funding payment is made. If the divergence between oracle and mark price is greater than 5% for more than 3 hours, a repeg event is triggered and the hybrid vAMM’s mark price is reset to the oracle price. Each market’s dedicated adjustments pool will cover any costs that arise from repeg events.
Repeg cost (difference between actual and terminal reserves).
Use optimal peg
budget > cost
We can calculate a repeg cost using:
If there are enough funds in the pool, we will repeg when profitable or cost-free.
To prevent toxic orderflow, we’ve implemented an auction mechanism for taker orders which applies to liquidation orders. The auction process mimics a small settlement delay for taker orders (where the delay is t = 5s).
Each market order enters an individual auction that has three default parameters:
vAMM ask price
vAMM bid price
The auction is a Dutch-style regular auction where the price goes from best to worst for the taker.
The auction ends up creating a price band per auction where the top of price band = hybrid vAMM price and bottom of price band = oracle price (if market order is buy direction and conversely if sell direction).
- A trader submits a market order. On submission, the order is validated and broadcast to off-chain keepers.
- The market order is first attempted to be matched with any orders on Sujiko’s limit orderbook. If there are no matching orders or there is size remaining after matching against limit orders, the remaining size will be placed in a Dutch auction.
- The market order enters the Dutch auction with a start time, specific start price (oracle price), end price (hybrid vAMM quote price), and duration (fixed at 5s).
- Market makers can compete to fill the trader’s order at a price better than or equal to the current auction price.
- If no market maker fills the order within the duration or there is only a partial fill, the remaining order size will be filled by the hybrid vAMM. The hybrid vAMM may repeg and adjust its bid/ask quotes before settling the remaining size.
- There can only be up to 32 auctions at one given time for a given market. Makers can enter any and as many auctions as they wish to.
- Market orders can be partially filled based on slippage tolerance and available liquidity.
- An auction can be cancelled midway by the initiating trader. This does not apply to any partially filled size.
- The auction mechanism is isolated from the limit orderbook (i.e. orders posted for a specific auction will not appear on the limit orderbook during or after the auction).
Each perpetual futures market on Sujiko has an individual limit orderbook.
Sujiko’s limit orderbooks mimic central limit order books (CLOBs) through an off-chain network of keepers.
Orders are kept in trader accounts on-chain. When a keeper starts up, it will fetch on-chain orders and construct an in-memory orderbook where orders include price, size, time/age. Keepers will sort orders by price, then age, then size if two orders have matching age.
- Traders submit limit order as post-only. On submission, order is validated.
- Keepers listen to trader account changes and see new order. Order is added into in-memory orderbook.
- Next, 3 scenarios are possible:
- Hybrid vAMM price hits limit order price. Keeper network observes this and submits a settlement instruction (settling the limit order against the hybrid vAMM’s quoted price).
- A market order is submitted that matches the limit order. In this event, the limit order is filled up to the size of the market order. If the limit order is only partially filled, it remains on the limit orderbook with the remaining size.
- A limit order (taker, fill-or-kill) is submitted at the same price as the post-only limit order.
- Each trader can only have 64 total open orders across all markets.
- Two post-only orders cannot be matched with each other.
- Orders filled by the hybrid vAMM are not eligible for fee rebate.
- There can be scenarios where an order is not filled due to degraded network conditions. The keeper network depends on transactions being processed successfully and if the network is degraded (e.g. network halt or low TPS) transactions may not confirm as expected.
Keepers will earn a portion of the fees generated through matched orders.
Traders can increase the likelihood of an order being filled by paying a additional fee capped at 0.1 SOL. This fee is directly paid to the keeper for matching the order.