Skip to Content

Accounting & Settlement

Within Velocity, all token deposits are held in a global collateral vault. This is required for seamless cross-margin and borrow-lend. The only exception to this is the insurance fund vault residing outside. Isolated positions are still backed by the same vault — their collateral is just accounted for separately from the account’s cross-margin balance.

Ensuring proper accounting across users requires a robust settlement mechanism. The protocol uses intermediate Pool Balances to facilitate transfers and ensure that claimed gains are required to come from settled offsetting losses.

High Level Architecture

Perpetual Market

An individual perpetual market has two pools:

A. P&L Pool: accumulates funds from users with losses for settlement to users with profits. Trade-fee value also lands here first as fills settle, before the fee sweep routes it onward.

B. AMM Fee Pool (amm.feePool): holds only the AMM’s own money — its cut of the per-fill fee split plus any spread surplus, tokenized out of the P&L Pool by the fee sweep.

The P&L Pool receives the highest priority on claimed funds, in order to give users the best possible experience. Every fill also carves out protocol and insurance-fund cuts of the fee remainder (FeeStructure.ammFeeNumerator / ifFeeNumerator, protocol = residual) — see Trading Fees for the full split. Those two cuts accrue as pending counters in the market’s feeLedger and are swept out of the P&L Pool’s surplus (above live user claims) into the withdrawable protocol_fee_pool and the quote spot market’s revenue_pool, respectively — they never pass through the AMM Fee Pool.

The streaming sweep reserves max(net_user_pnl, 0) in the P&L Pool on every drain so live user claims stay fully backed. The protocol’s cut sweeps first and is exempt from the per-market retention buffer (fee_pool_buffer_target); the insurance-fund cut and AMM-provision tokenization sweep next, above that buffer.

Spot Market

An individual spot market has a Revenue Pool, which stages the insurance fund’s cut of protocol revenue (perp trading fees route to spot market 0 / USDC; spot lending and liquidation revenue stay in their own market) before it settles to the Insurance Fund vault.

The Revenue Pool can collect fees from:

  • Borrow interest (InsuranceFund.ifFeeFactor)

  • Liquidations (the insurance-fund cut of if_liquidation_fee)

  • Perpetual Markets (the insurance-fund cut of the per-fill fee split)

and pays out to:

  • Insurance Fund Stakers (100% of every settle — there are no protocol-owned IF shares)

(see details of these rules in Revenue Pool)

The protocol’s own cut of these same fee sources goes directly to each market’s withdrawable protocol_fee_pool instead — it never routes through the Revenue Pool or the Insurance Fund.

Future Work

Currently, a Perpetuals Market can only pull from the Spot Market Revenue Pool and Insurance Fund for its quote currency.

  • In the future, it may be possible for a distressed associative perp market (BTC-PERP) to be able to pull funds from the associated spot market (BTC) revenue/insurance pool and immediately swap for USDC to top off its fee/P&L pool.
Last updated on