Yield Basis Technical Overview
Each market on YieldBasis provides 2x leverage exposure to Curve LP positions through a sophisticated contract architecture that maintains a compounding leverage at 2x.
System Architecture
┌─────────────────────────────────────────────────────────────────────────────┐
│ FACTORY │
│ (Central Market Registry & Deployer) │
└─────────────────────────────────────────────────────────────────────────────┘
│ │
▼ ▼
┌──────────────────────────────────────┐ ┌──────────────────────────────────────┐
│ MARKET 0 (WBTC) │ │ MARKET 1 (cbBTC) │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ LT │ │ LEVAMM │ │ Oracle │ │ │ │ LT │ │ LEVAMM │ │ Oracle │ │
│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │
│ └─────────┘ └─────────┘ └─────────┘ │ │ └─────────┘ └─────────┘ └─────────┘ │
│ ┌─────────┐ ┌─────────┐ │ │ ┌─────────┐ ┌─────────┐ │
│ │ Virtual │ │ Staker │ │ │ │ Virtual │ │ Staker │ │
│ │ Pool │ │ │ │ │ │ Pool │ │ │ │
│ └─────────┘ └─────────┘ │ │ └─────────┘ └─────────┘ │
└──────────────────────────────────────┘ └──────────────────────────────────────┘
The system supports multiple independent BTC markets like cbBTC, WBTC, tBTC (and ETH markets coming in the future), each with its own set of contract instances. Markets are completely isolated from each other.
Core Technical Concepts
2x Leverage Mechanism
Each market maintains a constant 2x compounding leverage ratio through mathematical bonding curves. The AMM
automatically rebalances positions to maintain this ratio, ensuring users always have 2x exposure to their underlying Curve LP positions.
Market Isolation
- Independent State: Each market maintains separate collateral, debt, and fee balances
- Risk Separation: Issues in one market don't affect others
- Custom Parameters: Each market can have tailored fee structures and risk parameters
- Independent Upgrades: Contract implementations can be updated globally, affecting future markets
Fee Collection and Distribution
Interest fees are automatically collected by the AMM
and distributed to the LT
contract. These fees are then donated back to the underlying Curve pool (no LP tokens minted), deepening pool liquidity and benefiting all LP token holders.
Contract Architecture
Factory.vy
: Market Registry and Deployment
The Factory contract serves as the central orchestrator that:
- Deploys new markets using blueprint contract patterns
- Manages contract implementations and upgrades
- Controls stablecoin allocations and debt ceilings per market
- Acts as a registry of all markets where info can be read from
The full documentation can be found here: Factory.
LT.vy
: Market-Specific Vaults
Each market has its own LT instance (e.g., yb-WBTC
, yb-cbBTC
) that:
- Implements ERC-20 standard with some additional logic ontop
- Manages market-specific fee collection and interest rates
- Handles automatic rebalancing and fee distribution
- Integrates with staking contract for YB emissions
The full documentation can be found here: LT.
AMM.vy
: Constant Leverage Maintenance
The AMM contract maintains 2x leverage through:
- Mathematical bonding curves with constant leverage ratios
- Automatic rebalancing when users trade
- Dynamic price discovery based on collateral/debt ratios
- Interest rate accumulation over time
The full documentation can be found here: AMM.
VirtualPool.vy
: Flash Loan Arbitrage
The Virtual Pool enables:
- Trading between stablecoins and crypto without need of touching LP tokens
- Flash loan integration
- Arbitrage between Curve pool and AMM prices
- Maintenance of 2x leverage through market forces
The full documentation can be found here: VirtualPool.
CryptopoolLPOracle.vy
: Price Feed
Each market has its own price oracle that:
- Combines Curve LP token prices with USD aggregator data
- Provides real-time pricing for leverage calculations
- Validates price feeds to prevent manipulation
- Enables accurate collateral and debt valuations
The full documentation can be found here: Price Oracle.
Mathematical Foundation
The AMM uses sophisticated mathematics based on the equation:
x₀ = (collateral_value + √(collateral_value² - 4 × collateral_value × LEV_RATIO × debt)) / (2 × LEV_RATIO)
Where:
LEV_RATIO = leverage²
- For 2x leverage:
LEV_RATIO = 4 / 9
- This ensures the system always maintains the target leverage ratio
For detailed mathematical explanations and user-facing documentation, see the Mathematical Foundation page.
Glossary
Asset: The underlying asset (e.g., wBTC, cbBTC) that users deposit into YieldBasis.
Collateral: LP tokens from Curve Cryptoswap pools. The AMM holds these LP tokens as collateral against the debt.
Debt: Stablecoin debt (crvUSD) which is borrowed from a dedicated crvUSD CDP credit line and the AMM owes. This debt accrues interest over time and must be maintained at approximately 50% of the collateral value for 2x leverage.
Debt-to-Value (DTV) Ratio: The ratio of debt to collateral value, expressed as a percentage. Target DTV is 50% for 2x leverage.
Safety Band: The acceptable range of DTV ratios (6.25%–53.125% for 2x leverage) that the AMM enforces to prevent extreme leverage positions.
LP Token: Liquidity Provider token from Curve pools representing a share of the pool's liquidity. These tokens are used as collateral in the AMM.
Virtual Pool: A flash loan-powered interface that enables trading between assets and stablecoins without requiring users to handle LP tokens directly.
LEVAMM: The constant leverage AMM that maintains 2x leverage through mathematical bonding curves and automatic rebalancing.
Flash Loan: A mechanism that allows borrowing tokens without collateral, as long as the loan is repaid within the same transaction. Used by the VirtualPool
for arbitrage operations.
Bonding Curve: A mathematical curve that determines token prices based on supply and demand. The AMM uses bonding curves to maintain constant leverage ratios.
Slippage: The difference between expected and actual trade execution prices, often caused by market depth or large trade sizes. Protected against with minimum output parameters.
Checkpoint: A snapshot of system state at a specific point in time, used for tracking changes in voting power, rewards, and other time-dependent calculations.
Gauge: A smart contract that measures liquidity and distributes rewards to users based on their stake and voting weight. Used in the governance system for reward distribution.
veYB: Vote-escrowed YB tokens that provide time-weighted voting power. Users lock YB tokens for up to 4 years to receive voting rights that decay over time.
CDP (Collateralized Debt Position): A credit line system where users can borrow stablecoins against collateral. The AMM uses a crvUSD CDP for debt management.
Rebalancing: The process of refueling (donating) liquidity to the Curve Cryptoswap pool to maintain optimal pool depth and pricing. See Curve's Refuel documentation for more details.
Oracle: A price feed system that provides real-time asset prices.
Factory: The smart contract that deploys and manages all market instances. Acts as a registry and upgrade mechanism (controlled via veYB) for the protocol.
Market: A complete set of contracts (LT, AMM, Oracle, VirtualPool, Staker) for a specific asset (e.g., wBTC, cbBTC).
Admin Fee: Dynamic fee percentage collected by the protocol and distributed to veYB. Calculated based on staked token ratios and position performance.
Interest Rate: The rate at which debt accrues interest over time. Set by the LT contract and affects the cost of maintaining leveraged positions.
Allocation: The amount of stablecoins allocated to a specific market for borrowing. Controlled by the Factory and limited by debt ceilings.