Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Vault

1. Overview

The vault is the passive market maker for the perpetual futures exchange. It continuously quotes bid/ask orders around the oracle price on every pair, earning the spread.

Liquidity providers (LPs) deposit settlement currency into the vault and receive vault shares credited to their account.

2. Liquidity provision

Adding liquidity follows an ERC-4626 virtual shares pattern to prevent the first depositor inflation attack.

Constants

NameValue
Virtual shares1,000,000
Virtual assets$1

Share minting

The LP specifies a USD margin amount to transfer from their trading margin to the vault.

Floor rounding protects the vault from rounding exploitation. A minimum-shares parameter lets depositors revert if slippage is too high.

First depositor protection

The virtual terms dominate when real supply and equity are small. An attacker cannot inflate the share price to steal from subsequent depositors because the initial share price is effectively per share.

3. Liquidity withdrawal

The LP specifies how many vault shares to burn. The USD value to release is computed:

The fund is not released immediately. A cooldown is initiated, with the ending time computed as:

Once is reached, the contract credits the released USD value back to the LP’s trading margin.

4. Vault equity

The vault has its own user state (positions acquired from market-making fills). Its equity follows the same formula as any user:

where is the vault’s internal USD margin (updated in-place during settlement), and the sums run over all of the vault’s open positions.

If is non-positive the vault is in catastrophic loss and both deposits and withdrawals are disabled.

5. Market making policy

The vault uses its margin to market make in the order book. For now, it does so following a naïve policy. We expect to optimize this in the future.

Each block, after the oracle update, the vault cancels all existing quotes and recomputes bid/ask orders for every pair.

Margin allocation

Total vault margin is split across pairs by weight:

Quote size

Each side receives half the allocated margin, capped by a per-pair maximum:

where is the initial margin ratio.

Bid price

Snap down to the nearest tick:

Book-crossing prevention: if , clamp to .

Skip if or notional is below the minimum order size.

Ask price

Snap up to the nearest tick (ceiling):

Book-crossing prevention: if , clamp to .

Skip if notional is below the minimum order size.

Per-pair parameters

ParameterRole
vault_half_spreadHalf the bid-ask spread around oracle price
vault_max_quote_sizeMaximum size per side
vault_liquidity_weightWeight for margin allocation across pairs
tick_sizePrice granularity for snapping
initial_margin_ratioUsed to compute margin-constrained size
min_order_sizeMinimum notional to place an order

If any of vault_half_spread, vault_max_quote_size, vault_liquidity_weight, tick_size, or the allocated margin is zero, the vault skips quoting for that pair.