Trading Basics
Learn the fundamental concepts of trading interest rate swaps on the Rate Swap Protocol.
Interest Rate Swap Fundamentals
An Interest Rate Swap (IRS) is a derivative contract where two parties exchange interest rate cash flows. In the Rate Swap Protocol:
- One side pays a fixed rate
- The other side pays a floating rate (based on an oracle index)
- Notional amount determines the size of payments
- Positions are margined and mark-to-market
Position Types
Pay Fixed / Receive Floating (Long Rates)
- Notional: Positive (
notional > 0) - Profit: When rates rise above your entry rate
- Loss: When rates fall below your entry rate
- Use Case: You expect rates to increase
Receive Fixed / Pay Floating (Short Rates)
- Notional: Negative (
notional < 0) - Profit: When rates fall below your entry rate
- Loss: When rates rise above your entry rate
- Use Case: You expect rates to decrease
Market Structure
Each market is defined by three parameters:
- Rate Index: The underlying rate (e.g., perp funding rate, borrow APR)
- Quote Token: The collateral and settlement currency (e.g., USDC)
- Maturity: When the swap expires
Multi-Market Pools
A single pool can support up to 16 markets, all using the same quote token. This enables:
- Multiple maturities for the same rate index
- Different rate indices sharing liquidity
- Efficient capital utilization for LPs
Pricing & AMM
The protocol uses an Automated Market Maker (AMM) to price swaps:
- Rates adjust based on net pool exposure
- Larger trades have greater price impact
- Liquidity depth determines available notional
DV01-Based Liquidity
For risk-increasing trades (trades that increase the market's DV01):
- Available liquidity is reduced by a DV01 reserve
- The reserve protects the pool from rate movements
- A utilization-based scalar may further reduce depth at high utilization
For risk-reducing trades:
- Full allocated liquidity is available
- No DV01 gating applies
Cash Flow Settlement
The protocol uses accounting-only settlement:
Rate_Settlement = notional × (Current_Index - Last_Index)- No token transfers during settlement
- Settlement updates
position.realized_pnl - Pool counterparty updates
market.pool_rate_accumulator - Tokens only move on explicit deposit/withdraw
This is different from traditional systems where funding flows directly to/from collateral balances.
Mark-to-Market (MTM)
Your unrealized P&L is calculated as:
MTM = (Current_Rate - Entry_Rate) × Notional × Time_to_Maturity / Seconds_Per_YearThis MTM is used for:
- Position health calculation
- Liquidation risk assessment
- Real-time P&L tracking
Execution Flow
- Select Market: Choose rate index, maturity
- Deposit Collateral: Add quote tokens (e.g., USDC) to your margin account
- Specify Trade: Direction and notional size
- Check Margin: Ensure sufficient initial margin
- Execute: AMM quotes rate and executes swap
- Monitor: Track funding settlements in
realized_pnland MTM
Circuit Breaker Awareness
Before trading, check market status:
- Normal: All trades allowed
- Closing-Only: Can only reduce positions
- Halted: No trading (only liquidations)
Fees & Costs
Swap Fees
Swap_Fee = |notional_delta| × swap_fee_bps / 10000- Fee is deducted from your
position.realized_pnl(accounting-only) - Fee is split between LPs and protocol based on
protocol_fee_share_bps
Funding Payments
- Based on rate oracle index changes
- Accumulated in
position.realized_pnl - Can be positive or negative depending on direction
Transaction Costs
- Solana transaction fees (minimal)
- No gas fees for settlement (accounting-only)
Position Management
Opening a Position
- Ensure margin account exists (or create one)
- Deposit sufficient quote tokens
- Call swap with positive
notional_deltafor pay-fixed - Call swap with negative
notional_deltafor receive-fixed
Increasing Position
- Same direction as existing: increases notional
- Entry rate becomes weighted average
- Must meet initial margin requirement
Reducing Position
- Opposite direction from existing: reduces notional
- Realized PnL includes closed portion
- Risk-reducing trades have full liquidity access
Closing Position
- Swap with opposite notional to net to zero
realized_pnlincludes final settlement- Position slot freed for reuse
Realized vs Unrealized PnL
Realized PnL
Stored in position.realized_pnl_wad:
- Funding settlements accumulate here
- Closed position gains/losses added here
- Swap fees deducted here
- Can be withdrawn when position is closed
Unrealized PnL (MTM)
Computed on-the-fly:
- Based on current rate vs entry rate
- Changes with market movements
- Contributes to equity for health calculation
- Becomes realized when position is closed
Best Practices
- Start with small positions to learn mechanics
- Monitor health factor regularly
- Understand margin requirements before trading
- Keep extra collateral for market volatility
- Watch market status for circuit breaker changes
- Track realized_pnl for funding accumulation
- Close positions before maturity to avoid settlement complexity
Example Trade
Opening a 100,000 USDC notional pay-fixed position:
- Deposit Margin: 10,000 USDC (10% for 5% initial margin + buffer)
- Execute Swap:
swap(notional_delta = +100,000 × WAD) - Position State:
notional_wad: +100,000 × WADentry_fixed_rate_wad: AMM execution raterealized_pnl_wad: -swap_fee (accounting-only)
- Monitor: Watch health, MTM, and funding accumulation
- Close:
swap(notional_delta = -100,000 × WAD)to exit
Next Steps
- Understanding Swaps - Detailed swap mechanics
- Risk Management - Protect your capital
- Engineering API - Programmatic trading