Skip to main content
The MarketThree account stores all state for a CLMM (Concentrated Liquidity Market Maker) market, including token mints, escrow accounts, tick-based liquidity configuration, market financials, and LP farm emissions.

Status Flags

MarketThree

ConfigurationOptions

Configuration parameters for market behavior and fees.

MarketFinancials

Financial parameters tracking token balances and expiration.

LiquidityNetBalanceLimits

Rate limiting configuration to prevent rapid liquidity changes.

Tick Node Structure

Ticks are stored in a red-black tree (RedBlackTree<u32, Tick, 1000>) with a maximum of 1000 active nodes. Each node stores:

Fee Growth Tracking

Fee accumulation uses Q64.64 fixed-point arithmetic. Two global counters track accumulated fees per unit of liquidity:
  • fee_growth_index_global_pt (u128) — global PT fee growth per unit L
  • fee_growth_index_global_sy (u128) — global SY fee growth per unit L
Each tick stores fee_growth_outside_pt and fee_growth_outside_sy. When the price crosses a tick boundary, the “outside” values are flipped:
This enables efficient calculation of fees earned within any tick range using the standard Uniswap V3 fee accounting formula.

MarketEmissions

Separate from farm emissions, MarketEmissions tracks yield that flows from the underlying SY program into the market. Market emissions flow through the principal share system — each tick interval’s share of emissions is proportional to its principal_share_supply relative to the total.

Key Concepts

Market Status

The status_flags field is a bitmask controlling which operations are permitted on the market:
  • Deposit Liquidity (0x01) — LPs can deposit into the market
  • Withdraw Liquidity (0x02) — LPs can withdraw from the market
  • Buy PT (0x04) — Users can buy PT tokens
  • Sell PT (0x08) — Users can sell PT tokens
  • Buy YT (0x10) — Users can buy YT tokens
  • Sell YT (0x20) — Users can sell YT tokens

Treasury Fees

The market collects fees on trades, with a portion going to the protocol treasury as defined by treasury_fee_bps. Fee rates dynamically adjust based on the time-weighted fee decay model.

Rate Limiting

The liquidity_net_balance_limits field protects against rapid liquidity changes that could destabilize the market. It tracks net balance changes within time windows and enforces maximum percentage changes.

Market Lifecycle

A market is active when the current timestamp is before financials.expiration_ts. After expiration, PT becomes redeemable 1:1 for the underlying asset, and certain operations may be restricted based on the vault’s maturity state.

Escrow Accounts

The market maintains separate escrow accounts for PT, SY, and YT tokens. The treasury fee accounts (token_fee_treasury_sy and token_fee_treasury_pt) are separate from the escrow accounts and collect the protocol’s share of swap fees.