Security Overview
The Multiliquid Program is built with institutional-grade security as a core requirement. Every instruction, account validation, and state transition has been designed with security-first principles, incorporating multiple layers of protection and comprehensive access controls.Program Security
Anchor framework and secure coding practices
Access Control
Multi-tiered permission model
Pause Controls
Multi-level emergency pause capabilities
Admin Transfer
Secure admin handover mechanism
Program Security
Anchor Framework
The program is built exclusively using the Anchor framework, providing: Type Safety:- Automatic account serialization and deserialization
- Compile-time account constraint validation
- Strong typing for all instruction parameters
- Automatic owner checks on all accounts
- PDA derivation verification via seeds constraints
has_oneconstraints for relationship validation
- Built-in discriminator checks to prevent account confusion
- Automatic rent-exemption verification
- Safe arithmetic operations with checked math
Core Security Mechanisms
1. Program-Derived Addresses (PDAs)
All program accounts are derived deterministically using PDAs:- Accounts cannot be spoofed or substituted
- Deterministic derivation enables verification
- No external account addresses stored unnecessarily
2. Signer Validation
All privileged operations require appropriate signatures:3. Integer Overflow Protection
All arithmetic operations use checked math:4. Input Validation
Every instruction validates inputs before execution:- Amounts must be greater than zero
- Basis points must be within valid range (0-10000)
- NAV sources must have valid decimals (0-9)
- Asset types must match expected values
Token Security
SPL Token Integration
The program uses Anchor’s SPL token helpers for safe token operations:- Automatic account ownership validation
- Mint address verification
- Sufficient balance checks
Token-2022 Support
The program supports both SPL Token and Token-2022:- Automatic program detection based on mint owner
- Compatible with Token-2022 extensions
- Safe handling of both token standards
Access Control System
The program implements a sophisticated multi-tier permission model:Admin Role
Holder:GlobalConfig.admin
Permissions:
| Operation | Description |
|---|---|
init_global_config | Initialize program configuration (one-time) |
update_global_config | Update fees, fee wallet, pause state |
set_new_admin | Propose new admin address |
confirm_new_admin | Accept admin role (new admin) |
init_asset_config_account | Register new tokens |
update_asset_config_account | Update token NAV sources |
init_pair | Create trading pairs |
set_paused_for_asset | Pause/unpause assets |
set_paused_for_lp_stable_config | Pause/unpause LP configs |
- Admin should be a multi-signature wallet
- Two-step transfer prevents accidental handover
- Program starts paused by default
Liquidity Provider Role
Holder: Address specified asliquidity_provider in pair creation
Permissions:
| Operation | Description |
|---|---|
update_pair | Configure fees and pause state |
close_pair | Permanently close a pair |
add_liquidity | Deposit tokens to vault |
remove_liquidity | Withdraw tokens from vault |
set_paused_for_lp_stable_config | Pause own LP config |
- Each LP controls only their own pairs
- Cannot affect other LPs’ configurations
- Pairs start paused (LP must explicitly enable)
User Role (Permissionless)
Holder: Any wallet Permissions:| Operation | Description |
|---|---|
swap | Execute token swaps |
claim_fees | Trigger fee distribution to fee wallet |
- Swaps validated against multiple pause states
- Slippage protection via min/max amount parameters
- Fees always sent to configured fee wallet (not caller)
Pause Control System
The program implements a comprehensive four-level pause system:Pause Hierarchy
Level 1: Global Pause
Controlled by: Admin viaupdate_global_config
Effects:
- Blocks ALL swap operations
- Blocks liquidity operations
- Blocks fee claims
- Admin operations still accessible
- Emergency halt during security incident
- Program maintenance or upgrade preparation
- Regulatory requirement
Level 2: Asset Pause
Controlled by: Admin viaset_paused_for_asset
Effects:
- Blocks swaps involving this specific asset
- Other assets remain operational
- Affects all pairs using this asset
- Token-specific security issue
- NAV oracle malfunction
- Compliance requirement for specific asset
Level 3: LP Stable Config Pause
Controlled by: Admin OR LP viaset_paused_for_lp_stable_config
Effects:
- Blocks all pairs for this LP/stablecoin combination
- Other LPs unaffected
- Other stablecoins for same LP unaffected
- LP-specific operational issue
- Stablecoin-specific concern for one LP
- LP maintenance period
Level 4: Pair Pause
Controlled by: LP viaupdate_pair
Effects:
- Blocks only this specific trading pair
- All other pairs remain operational
- Liquidity rebalancing
- Fee adjustment period
- Individual pair maintenance
Swap Validation
Every swap validates ALL four pause levels:Two-Step Admin Transfer
The program implements a secure two-step admin transfer mechanism to prevent accidental or malicious admin handover:Step 1: Propose New Admin
Current admin callsset_new_admin:
- Sets
pending_new_adminto proposed address - Current admin remains in control
- No immediate transfer occurs
Step 2: Confirm New Admin
New admin callsconfirm_new_admin:
- Caller must match
pending_new_admin - Caller must sign the transaction
adminupdated to new addresspending_new_admincleared- Transfer complete
Security Benefits
- No Accidental Transfer: Typo in address won’t transfer control
- Recipient Verification: New admin must actively accept
- Revocable: Current admin can propose different address before confirmation
Error Handling
The program defines comprehensive error codes for security validation:Operational Security Best Practices
For institutions integrating with the program:Key Management
- Use Hardware Wallets: For all signing operations
- Multi-Signature: Admin should be a multi-sig wallet
- Key Rotation: Periodic admin transfer to fresh keys
- Backup Procedures: Secure backup of all signing keys
Transaction Security
- Simulation: Use Solana’s transaction simulation before signing
- Verification: Double-check all account addresses
- Priority Fees: Set appropriate priority fees for time-sensitive operations
- Recent Blockhash: Use recent blockhashes to prevent replay
Monitoring
- Event Tracking: Monitor program events for all state changes
- Balance Monitoring: Track vault and fee vault balances
- Pause State: Alert on any pause state changes
- Admin Changes: Alert on admin transfer initiation
Known Limitations and Assumptions
Token Compatibility
The program assumes:- Tokens follow SPL Token or Token-2022 standards
- Tokens do not have transfer fees that break atomicity
- NAV oracles remain available and accurate
- Token decimals are correctly configured
Price Oracle Assumptions
- NAV sources return valid prices within configured decimals
- Price divergence threshold is appropriately set
- At least one NAV source is always available
- Pyth oracle accounts are correctly configured
Operational Assumptions
- Admin wallet is secure and properly managed
- LPs manage their liquidity appropriately
- Fee vault balances are claimed periodically
- Pairs are closed properly before decommissioning
Security Contacts
For security vulnerabilities or concerns:- Website: https://www.multiliquid.xyz/
- Public Repository: https://github.com/uniformlabs
This security documentation is a living document and will be updated as the program evolves and new security measures are implemented.
Next: Swap Instruction
Explore the main swap instruction managing all trading operations