Skip to main content

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 the MerkleTreeAccount structure:
Code Reference: lib.rs:896-910

Default Deposit Limits

SOL Tree

The default SOL tree is initialized with:
Amount: 1,000 SOL (1,000,000,000,000 lamports) Code Reference: lib.rs:78

SPL Token Trees

For SPL tokens, the deposit limit is configurable during tree initialization:
The authority can set appropriate limits based on:
  • Token decimals
  • Token value
  • Liquidity considerations
  • Risk management requirements
Code Reference: lib.rs:151-154

Deposit Limit Enforcement

Deposit limits are enforced during transaction processing:

SOL Deposits

Code Reference: lib.rs:266-273

SPL Token Deposits

Code Reference: lib.rs:434-441

Error Handling

If a deposit exceeds the limit, the transaction reverts with:
Error message:
“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

Code Reference: lib.rs:105-112, lib.rs:804-815

Updating SPL Token Deposit Limit

Function Signature

Account Structure

Implementation

Code Reference: 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:
Code Reference: 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
ORE (variable decimals):
  • Check token metadata for decimal count
  • Adjust limits accordingly
General formula:

Practical Examples

Example 1: Setting SOL Deposit Limit

Scenario: Increase SOL deposit limit to 5,000 SOL

Example 2: Setting USDC Deposit Limit

Scenario: Set USDC deposit limit to 100,000 USDC

Example 3: Initializing Token Tree with Custom Limit

Scenario: Initialize USDT tree with 50,000 USDT limit

Security Considerations

Authority Control

Only the tree authority can update deposit limits:
Attempting to update limits without proper authority results in:
“Not authorized to perform this action”

Progressive Limits

Consider implementing progressive limits:
  1. Start with conservative limits during launch
  2. Monitor usage patterns and liquidity
  3. Gradually increase limits as protocol matures
  4. 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?

  1. Liquidity Management: Prevent excessive concentration
  2. Circuit Breaker: Limit potential exploit impact
  3. Gradual Scaling: Allow controlled growth
  4. Market Risk: Manage exposure during volatile periods

Stablecoins (USDC, USDT)

  • Conservative: 10,00010,000 - 50,000 per deposit
  • Moderate: 50,00050,000 - 250,000 per deposit
  • Aggressive: $250,000+ per deposit

Volatile Assets (ORE, ZEC)

  • Conservative: 1,0001,000 - 5,000 per deposit
  • Moderate: 5,0005,000 - 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)