Overview
TL;DR: XCCY consists of four core components — VAMMManager for trading, CollateralEngine for margin and positions, OracleHub for prices, and AprOracle for yield rates. Together they enable efficient interest rate swap markets.
System Architecture

Core Components
VAMMManager
Trading engine
Price discovery, swap execution
CollateralEngine
Asset custody
Margin, positions, settlement
OracleHub
Price oracle
Asset prices in USD
AprOracle
Yield oracle
Variable Yield tracking
Component Details
VAMMManager
The trading engine that handles all market operations.
Design Pattern: Follows Uniswap v4's PoolManager singleton approach — all pools managed by one contract for gas efficiency.
CollateralEngine
The "bank" of the protocol — holds all funds and manages positions.
Important: VAMMs do NOT hold funds. All assets are held by CollateralEngine.
OracleHub
Provides USD price feeds for margin calculations.
AprOracle
Tracks Variable Yield rates for settlement calculations.
Data Flow: Opening a Position
Data Flow: Settlement
Pool Structure
Each XCCY pool is defined by a unique key:
Pool Lifecycle
Account System
XCCY supports sub-accounts for isolated positions:
Use Cases
Cross Margin
Share margin across positions (id=0, isolatedMarginToken=0)
Isolated Margin
Separate margin per position (unique id, specific token)
Security Model
Gas Efficiency
XCCY is optimized for low gas costs:
Singleton pattern
No per-pool deployment costs
Storage packing
Reduced storage reads/writes
Custom errors
Cheaper than require strings
Immutable variables
Lower read costs
Next Steps
VAMM Explained — Deep dive into the trading engine
Collateral Engine — Margin and position management
Oracle System — Price and yield feeds
Last updated

