Turbin3 Q1 2026 - Capstone Project - A protocol for opening leveraged liquidity provider positions on Meteora DLMM pools with automated risk management.
This protocol enables experienced Solana LPs to open leveraged DLMM liquidity positions on Meteora where trading fees are the primary source of return. Users deposit SOL or USDC as collateral, and the protocol borrows additional capital to create larger liquidity positions, amplifying fee generation while managing liquidation risk.
- Fee-First Leverage - Amplify DLMM trading fee yield through conservative leverage
- Automated Position Management - Protocol handles bin setup, position creation, and risk monitoring
- Explicit Risk Controls - Clear LTV thresholds, oracle-based health checks, and automated liquidations
- Capital Efficiency - Earn more fees with the same collateral through leverage
- Deposit Collateral - User deposits SOL or USDC into protocol vaults
- Open Leveraged Position - Protocol borrows additional funds and creates DLMM LP position on Meteora
- Earn Fees - Position generates trading fees from Meteora pool activity
- Monitor Health - Oracle-based health checks ensure position stays solvent
- Close or Liquidate - User can voluntarily close, or liquidators force-close if unhealthy
- Experienced Meteora LPs - Already familiar with DLMM mechanics and bin strategies
- Leverage-Comfortable DeFi Users - Understand leverage protocols (Kamino, Loopscale)
- Risk-Aware Yield Optimizers - Comfortable with liquidation risk for higher fee APR
This protocol uses a per-collateral configuration pattern (similar to Aave, Kamino, Solend) where:
- Each collateral type (SOL, USDC, etc.) has its own
CollateralConfigaccount - Risk parameters (LTV, liquidation thresholds, interest rates) are tailored per asset
- New collateral types can be added dynamically without program upgrades
- Users can hold multiple positions with different collateral types simultaneously
Benefits:
- β Risk-appropriate parameters - Volatile assets (SOL) have lower LTV than stablecoins (USDC)
- β Scalability - Add new collaterals without code changes
- β Flexibility - Adjust parameters per asset based on market conditions
- β Capital efficiency - Users can optimize based on their preferred collateral
programs/
βββ metlev-engine/
βββ src/
βββ lib.rs # Program entry point
βββ state/
β βββ mod.rs # State module exports
β βββ config.rs # Global protocol configuration
β βββ position.rs # User leveraged position state
β βββ lending_vault.rs # Lending vault state and accounting
β βββ lp_position.rs # LP supplier position and interest
βββ instructions/
β βββ mod.rs # Instruction exports
β βββ initialize.rs # Initialize protocol config
β βββ register_collateral.rs # Register new collateral type
β βββ deposit_sol_collateral.rs # Deposit SOL as collateral
β βββ deposit_token_collateral.rs # Deposit SPL tokens as collateral
β βββ initialize_lending_vault.rs # Create and seed the lending vault
β βββ supply.rs # LP supplies SOL to the vault
β βββ withdraw.rs # LP withdraws SOL + interest
β βββ open_position.rs # Create leveraged DLMM position
β βββ close_position.rs # Close position and repay debt
β βββ liquidate.rs # Force-close unhealthy positions
β βββ update_config.rs # Update protocol/collateral parameters
βββ utils/
β βββ mod.rs # Utility exports
β βββ health.rs # Health factor calculations
β βββ oracle.rs # Price oracle helpers
βββ errors.rs # Custom error definitions
Config (Global Protocol Settings)
pub struct Config {
pub authority: Pubkey, // Protocol admin
pub paused: bool, // Emergency pause state
pub bump: u8,
}- PDA:
["config"] - Manages protocol-level settings and pause state
- Does NOT store collateral-specific parameters
CollateralConfig (Per-Collateral Risk Parameters)
pub struct CollateralConfig {
pub mint: Pubkey, // Collateral token mint
pub oracle: Pubkey, // Price oracle (Pyth/Switchboard)
pub max_ltv: u16, // Max loan-to-value (basis points)
pub liquidation_threshold: u16, // Liquidation trigger (basis points)
pub liquidation_penalty: u16, // Penalty for liquidation (basis points)
pub min_deposit: u64, // Minimum deposit amount
pub interest_rate_bps: u16, // Interest rate (basis points)
pub oracle_max_age: u64, // Max oracle staleness (seconds)
pub enabled: bool, // Whether collateral is active
pub bump: u8,
}- PDA:
["collateral_config", mint] - Each collateral (SOL, USDC, etc.) has independent risk parameters
- Allows different LTV ratios for volatile vs stable assets
- Example: SOL at 75% LTV, USDC at 90% LTV
Position (Per-User Leveraged Position)
pub struct Position {
pub owner: Pubkey, // User wallet
pub collateral_mint: Pubkey, // Which token is used as collateral
pub collateral_amount: u64, // Amount deposited
pub debt_amount: u64, // Amount borrowed
pub meteora_position: Pubkey, // Reference to DLMM position
pub created_at: i64, // Unix timestamp
pub status: PositionStatus, // Active/Closed/Liquidated
pub bump: u8,
}- PDA:
["position", owner, collateral_mint] - Users can have multiple positions with different collateral types
- Each position is isolated per collateral mint
LendingVault (On-Chain SOL Vault)
pub struct LendingVault {
pub total_supplied: u64, // Total SOL supplied by LPs
pub total_borrowed: u64, // Total SOL currently borrowed
pub interest_rate_bps: u16, // Annual interest rate in basis points
pub bump: u8, // LendingVault PDA bump
pub vault_bump: u8, // sol_vault PDA bump (for CPI signing)
}- PDA:
["lending_vault"] - Paired with a
sol_vaultSystemAccount PDA that holds the actual lamports sol_vaultPDA:["sol_vault", lending_vault]- Seeded with rent-exempt minimum on initialization
- Tracks total supplied and borrowed for utilization calculations
LpPosition (Per-LP Supplier State)
pub struct LpPosition {
pub lp: Pubkey, // Supplier wallet
pub supplied_amount: u64, // Principal supplied
pub interest_earned: u64, // Accrued interest
pub last_update: i64, // Unix timestamp of last interest accrual
pub bump: u8,
}- PDA:
["lp_position", lp, lending_vault] - Created via
init_if_neededto support top-up deposits - Interest accrues using simple interest:
principal * rate_bps * elapsed / (365 * 24 * 3600 * 10000) - Closed (rent returned) on full withdrawal
-
Project Setup
- Initialize Anchor project structure
- Define state accounts (Config, CollateralConfig, Position, LendingVault)
- Create custom error types
- Set up test environment
-
Basic Instructions
initialize- Set up global protocol config (authority, pause state)register_collateral- Register new collateral types with risk parametersdeposit_collateral- Accept deposits for any enabled collateral- Base account validation and PDA derivation
-
Open Position Logic
open_position- Create leveraged DLMM position- Integrate mock lending vault for borrowing
- CPI to Meteora DLMM to create LP position
- Store position reference and debt tracking
-
Close Position Logic
close_position- Unwind position voluntarily- CPI to Meteora to remove liquidity
- Repay debt to lending vault
- Return remaining collateral to user
-
Health Monitoring
- Integrate price oracle (Pyth/Switchboard/magicblock)
- Implement health factor calculation
- LTV calculation based on collateral value vs debt
-
Liquidation System
liquidate- Force-close unhealthy positions- Health check validation
- Liquidator incentive distribution
- Bad debt handling
-
Comprehensive Testing
- Unit tests for all instructions
- Integration tests with Meteora devnet
- Liquidation scenario testing
- Oracle edge case handling
-
Security Hardening
- Reentrancy protection
- Oracle staleness checks
- Overflow/underflow validation
- Access control verification
- Challenge: CPI to Meteora to create/close DLMM positions
- Solution: Study Meteora SDK and program interface, implement proper account passing
- Challenge: Accurately value DLMM position + account for impermanent loss
- Solution: Oracle-based collateral pricing, conservative LTV ratios
- Challenge: Track borrowed amounts and interest accrual
- Solution: Simple interest model in POC, store principal + timestamp
- Challenge: Ensure liquidations are profitable and timely
- Solution: Clear threshold + liquidator incentives, anyone can liquidate
- Challenge: Reliable price feeds for SOL/USDC
- Solution: Pyth oracle integration with staleness checks
- Deposit collateral - Deposit SOL or USDC to open positions
- Open leveraged position - Create DLMM LP with borrowed funds
- View position status - Check health factor and liquidation risk
- Close position - Exit position, repay debt, withdraw collateral
- Check position health - Monitor positions for liquidation
- Force-close unsafe positions - Liquidate unhealthy positions for reward
Risk parameters are per-collateral, allowing different configurations for volatile vs stable assets.
| Parameter | Value | Description |
|---|---|---|
| Max LTV | 75% | Maximum loan-to-value ratio |
| Liquidation Threshold | 80% | Health factor triggers liquidation |
| Liquidation Penalty | 5% | Penalty paid to liquidator |
| Min Deposit | 0.1 SOL | Minimum deposit amount |
| Interest Rate | 5% APR | Borrow rate for SOL positions |
| Oracle Max Age | 60 seconds | Max staleness for price feeds |
| Parameter | Value | Description |
|---|---|---|
| Max LTV | 90% | Higher LTV due to stability |
| Liquidation Threshold | 95% | Closer threshold (less volatility) |
| Liquidation Penalty | 3% | Lower penalty (less risk) |
| Min Deposit | 10 USDC | Minimum deposit amount |
| Interest Rate | 3% APR | Lower rate for stable collateral |
| Oracle Max Age | 60 seconds | Max staleness for price feeds |
Note: Each collateral type can be added via
register_collateralinstruction with custom parameters.
[dependencies]
anchor-lang = "0.32.1"
anchor-spl = { version = "0.32.1", features = ["token"] }
pyth-solana-receiver-sdk = "0.2.0" # Oracle integration- Rust 1.89.0
- Solana CLI 3.1.6
- Anchor 0.32.1
- Node.js 20+
- Yarn
# Install dependencies (also sets up git hooks)
yarn install
# Build the program
anchor build
# Run tests
anchor testThis repo enforces branch naming via a git pre-push hook and CI check. Branches must follow:
feat/<name> # New feature
fix/<name> # Bug fix
chore/<name> # Maintenance
docs/<name> # Documentation
refactor/<name> # Code refactoring
The hook is automatically configured when you run yarn install.
- Config initialization
- Collateral deposit/withdrawal
- Debt accounting
- Health factor calculation
- Liquidation threshold logic
- Full position lifecycle (deposit β open β close)
- Liquidation scenarios (healthy β unhealthy β liquidated)
- Oracle price updates
- Multi-user interactions
- Deploy to Solana devnet
- Test with real Meteora DLMM pools
- Monitor liquidation bot behavior
- Validate oracle integration
- Oracle Manipulation - Use staleness checks, multiple oracle sources
- Flash Loan Attacks - Position changes require minimum time delays
- Bad Debt Accumulation - Conservative LTV ratios, liquidation buffers
- CPI Reentrancy - Proper account validation and state checks
- Multiple leverage presets (2x, 3x, 5x)
- Auto-rebalancing based on volatility
- Fee compounding / auto-reinvestment
- Partial position closes
- Integration with real lending protocols (Kamino, Solana)
- Support for additional DLMM pairs
Tests run automatically via GitHub Actions on push to main, feat/**, fix/** and on pull requests to main.
The pipeline:
- Validates branch naming convention
- Builds with Rust 1.89.0 (Rust deps cached)
- Installs Solana CLI 3.1.6 (cached after first run)
- Installs Anchor CLI 0.32.1 (cached after first run)
- Installs Node dependencies (yarn cache)
- Runs
anchor build+anchor test
π§ In Development - POC Phase
- Project planning and requirements
- Project skeleton and base structure
- Core state accounts (Config, Position, LendingVault, LpPosition)
- Base instructions (initialize, register_collateral, deposit_collateral)
- Lending vault (initialize_lending_vault, supply, withdraw with interest accrual)
- Lending vault test suite with constraint validation
- CI/CD pipeline (GitHub Actions) with Solana/Anchor/Rust caching
- Branch naming enforcement (git hook + CI check)
- Position opening (Meteora DLMM integration via CPI)
- Health monitoring (oracle integration)
- Liquidation system
- Dynamic APY based on vault utilization (kink rate model)
- Full integration testing and deployment