STEAMM Developer Integration Guide
Table of Contents
Overview
STEAMM is a next-generation Automated Market Maker (AMM) protocol on Sui that maximizes capital efficiency through:
Modular Quoter System: Support for multiple AMM types (Constant Product, Oracle-based, Stable)
Liquidity Reutilization: Optional integration with Suilend lending markets for yield generation
Shared Liquidity Model: Banks aggregate liquidity across pools for improved efficiency
Yield-bearing LP Tokens: LPs earn both trading fees and lending yields
Key Benefits for Developers
Flexible Integration: Choose between simple AMM pools or advanced yield-bearing pools
Capital Efficiency: Up to 80% of idle liquidity can earn lending yields
Multiple AMM Types: Constant product, oracle-based, and stable coin AMMs
Composable Design: Easy integration with existing DeFi protocols
Architecture
Core Components
Registry: Global tracker of all pools and banks
Pool: Core AMM logic with modular quoter system
Bank: Manages liquidity and optional Suilend integration
Quoter: Pluggable AMM algorithms (CPMM, Oracle, Stable)
Token Flow
Quick Start
Dependencies
Add to your Move.toml:
Basic Pool Creation (No Suilend)
Basic Liquidity Operations
Pool Types
STEAMM supports three main quoter types:
1. Constant Product AMM (CPMM)
Best for: General trading pairs, volatile assets
Features:
Classic x*y=k formula with optional offset
Suitable for most token pairs
Predictable slippage curves
2. Oracle AMM (OMM)
Best for: Stablecoin pairs, reduced impermanent loss
Features:
Uses external price feeds
Dynamic fees based on volatility
Better for correlated assets
Requires Suilend integration (bTokens only)
3. Stable AMM
Best for: Highly correlated assets (USDC/USDT)
Creating Pools
Simple Pool (No Banks)
For basic AMM functionality without yield farming:
Advanced Pool with Suilend Integration
For yield-bearing pools that earn lending yields:
Liquidity Operations
Adding Liquidity
Simple Pool
Yield Pool (with Banks) - Recommended Approach
Removing Liquidity
Simple Pool
Yield Pool - Recommended Approach
Swapping
Understanding STEAMM's Swap Model
STEAMM uses an intent/execute pattern for swaps, especially important for yield pools:
Intent: Declare intention to swap and get a quote
Provision: Banks provision necessary liquidity from Suilend
Execute: Perform the actual swap
Rebalance: Optionally rebalance bank utilization
Simple Pool Swaps
Yield Pool Swaps - Recommended Approach
Always use pool_script_v2 for yield pools - it handles the complex bToken conversions:
Oracle Pool Swaps
Getting Quotes
Always get quotes before executing swaps:
Script Versions: When to Use Which
pool_script: Original version, use for compatibility with older codepool_script_v2: RECOMMENDED - cleaner API, better error handlingDirect pool calls: Only for simple pools without banks
Suilend Integration
Understanding Banks
Banks are the key component that enables Suilend integration:
Purpose: Aggregate liquidity from multiple pools
Yield Generation: Deploy idle liquidity to Suilend for lending yields
bTokens: Yield-bearing representations of underlying tokens (note: singular "btoken")
Utilization Management: Maintain liquidity buffers for instant swaps
Bank Lifecycle
Creation:
bank::create_bank()- Creates bank for a token typeLending Setup:
bank.init_lending()- Enables Suilend integrationOperation: Automatic yield generation and liquidity management
Rebalancing: Periodic adjustment of Suilend exposure
Working with bTokens
Utilization Parameters
Target Utilization: Percentage of bank funds deployed to Suilend Buffer: Allowed deviation before rebalancing occurs
Benefits of Suilend Integration
Additional Yield: LPs earn trading fees + lending yields
Capital Efficiency: Up to 80% of idle liquidity generates yield
Shared Liquidity: Multiple pools share deeper liquidity
Automatic Management: Protocol handles Suilend interactions
When to Use Suilend Integration
Use Suilend Integration When:
You want maximum yield for LPs
Pool expects significant idle periods
Working with established tokens (USDC, SUI, etc.)
You can manage the additional complexity
Use Simple Pools When:
Rapid development needed
Working with new/experimental tokens
Minimizing smart contract dependencies
Token doesn't have Suilend market
Error Handling
Common Error Codes
ESlippageExceeded
0
Output below minimum
Increase slippage tolerance
EInsufficientBankFunds
9
Bank liquidity too low
Wait for rebalancing or provide liquidity
ELendingAlreadyActive
5
Bank already has lending initialized
Check bank state before init
EInvalidBTokenDecimals
1
bToken must have 9 decimals
Fix token metadata
EInvalidLpDecimals
0
LP token must have 9 decimals
Fix LP token metadata
EEmptyBank
1
Bank has no funds
Add liquidity first
EInvariantViolation
0
CPMM invariant broken
Check swap parameters
Error Handling Patterns
Practical Integration
Integrating STEAMM into Your DeFi Protocol
1. Router Pattern
2. Yield Farming Integration
3. Arbitrage Bot Integration
Advanced Usage
Multi-Pool Routing
Fee Management and Revenue
Monitoring Pool Health
Code Examples
Complete Pool Setup
Trading Interface
Reference
Key Functions by Component
Registry
registry::init_for_testing()- Create registry for testingAuto-registration happens when creating pools/banks
Bank
bank::create_bank()- Create new bank (package function)bank.init_lending()- Enable Suilend integrationbank.mint_btoken()- Convert tokens to bTokens (singular!)bank.burn_btoken()- Convert bTokens back to tokens (singular!)bank.rebalance()- Manual rebalancing trigger
Pool
pool.deposit_liquidity()- Add liquiditypool.redeem_liquidity()- Remove liquiditypool.cpmm_swap()- Execute CPMM swappool.cpmm_quote_swap()- Get CPMM quote
Quoters
cpmm::new()- Create constant product poolomm_v2::new()- Create oracle AMM pool (requires full parameters)Various
swap()andquote_swap()functions
Scripts (Recommended)
pool_script_v2::deposit_liquidity()- PREFERRED - Add liquidity with bankspool_script_v2::redeem_liquidity()- PREFERRED - Remove liquidity with bankspool_script_v2::cpmm_swap()- PREFERRED - Swap with bankspool_script_v2::quote_cpmm_swap()- PREFERRED - Quote with banks
Gas Optimization Tips
Use Scripts: Always use
pool_script_v2functions for yield poolsBatch Operations: Combine multiple operations when possible
Pre-calculate: Get quotes off-chain when possible
Rebalance Timing: Banks auto-rebalance, but manual triggers available
Avoid Micro-transactions: Respect minimum token block sizes
Testing
Migration and Versioning
STEAMM uses versioned contracts. When integrating:
Always check current versions in Move.toml files
Use the latest published package addresses
Handle version upgrades gracefully
Test with the exact versions you'll use in production
Best Practices
Start Simple: Begin with basic CPMM pools, add yield later
Use Scripts: Always prefer
pool_script_v2for yield poolsMonitor Health: Regularly check bank utilization and rebalancing needs
Handle Errors: Implement proper error handling for common failure modes
Test Thoroughly: Use the provided test utilities extensively
Gas Awareness: Be mindful of gas costs, especially for bank operations