Overview
Privacy Cash implements configurable deposit limits to manage risk and ensure protocol stability. Each Merkle tree (SOL and individual SPL tokens) can have its own maximum deposit amount that users cannot exceed in a single transaction.Deposit Limit Structure
Deposit limits are stored in theMerkleTreeAccount structure:
lib.rs:896-910
Default Deposit Limits
SOL Tree
The default SOL tree is initialized with:lib.rs:78
SPL Token Trees
For SPL tokens, the deposit limit is configurable during tree initialization:- Token decimals
- Token value
- Liquidity considerations
- Risk management requirements
lib.rs:151-154
Deposit Limit Enforcement
Deposit limits are enforced during transaction processing:SOL Deposits
lib.rs:266-273
SPL Token Deposits
lib.rs:434-441
Error Handling
If a deposit exceeds the limit, the transaction reverts with:“Deposit limit exceeded”Code Reference:
lib.rs:936-937
Updating Deposit Limits
Only the protocol authority can update deposit limits.Updating SOL Deposit Limit
Function Signature
Account Structure
Implementation
lib.rs:105-112, lib.rs:804-815
Updating SPL Token Deposit Limit
Function Signature
Account Structure
Implementation
lib.rs:191-206, lib.rs:858-872
Withdrawal Limits
Importantly, there are no limits on withdrawals. Users can withdraw any amount up to the available balance in the tree’s token account:lib.rs:285-316 (SOL), lib.rs:453-476 (SPL)
Units and Decimals
SOL Deposits
Limits are specified in lamports:- 1 SOL = 1,000,000,000 lamports
- Default limit: 1,000,000,000,000 lamports = 1,000 SOL
SPL Token Deposits
Limits are specified in the token’s smallest unit based on its decimals:Examples
USDC (6 decimals):- 1 USDC = 1,000,000 units
- Limit of 1,000,000 units = 1 USDC
- Limit of 10,000,000,000 units = 10,000 USDC
- Check token metadata for decimal count
- Adjust limits accordingly
Practical Examples
Example 1: Setting SOL Deposit Limit
Scenario: Increase SOL deposit limit to 5,000 SOLExample 2: Setting USDC Deposit Limit
Scenario: Set USDC deposit limit to 100,000 USDCExample 3: Initializing Token Tree with Custom Limit
Scenario: Initialize USDT tree with 50,000 USDT limitSecurity Considerations
Authority Control
Only the tree authority can update deposit limits:“Not authorized to perform this action”
Progressive Limits
Consider implementing progressive limits:- Start with conservative limits during launch
- Monitor usage patterns and liquidity
- Gradually increase limits as protocol matures
- Adjust based on market conditions
Per-Transaction vs Cumulative
The current implementation enforces per-transaction limits:- Each individual deposit must be ≤
max_deposit_amount - No cumulative limit across multiple deposits
- Users can make multiple deposits below the limit
Risk Management
Why Deposit Limits?
- Liquidity Management: Prevent excessive concentration
- Circuit Breaker: Limit potential exploit impact
- Gradual Scaling: Allow controlled growth
- Market Risk: Manage exposure during volatile periods
Recommended Limits by Asset Type
Stablecoins (USDC, USDT)
- Conservative: 50,000 per deposit
- Moderate: 250,000 per deposit
- Aggressive: $250,000+ per deposit
Volatile Assets (ORE, ZEC)
- Conservative: 5,000 per deposit
- Moderate: 25,000 per deposit
- Aggressive: $25,000+ per deposit
Native SOL
- Conservative: 100 - 500 SOL per deposit
- Moderate: 500 - 2,500 SOL per deposit
- Aggressive: 2,500+ SOL per deposit
Monitoring and Adjustment
Regularly review and adjust limits based on:- Total Value Locked (TVL)
- Transaction volume
- Market volatility
- Liquidity depth
- Security incidents
Client-Side Implementation
Checking Deposit Limits
Before submitting a deposit, check the current limit:Handling Limit Exceeded Errors
Splitting Large Deposits
For amounts exceeding the limit, split into multiple transactions:Code References
- MerkleTreeAccount structure:
lib.rs:896-910 - Default SOL limit:
lib.rs:78 - SOL deposit validation:
lib.rs:266-273 - SPL deposit validation:
lib.rs:434-441 - Update SOL limit function:
lib.rs:105-112 - Update SPL limit function:
lib.rs:191-206 - Update limit accounts (SOL):
lib.rs:804-815 - Update limit accounts (SPL):
lib.rs:858-872 - No withdrawal limits:
lib.rs:285-316(SOL),lib.rs:453-476(SPL)