Overview
Theinitialize_tree_account_for_spl_token instruction creates a separate merkle tree for a specific SPL token. Each token type gets its own isolated tree to track deposits and withdrawals.
This instruction can only be called by the program authority and only for tokens in the allowed list.
Function Signature
Parameters
Maximum deposit amount allowed for this token in base units. For example, for a token with 6 decimals:
- 1,000,000 = 1 token
- 50,000,000,000,000 = 50 million tokens
Accounts
Token-specific merkle tree account. PDA derived from
["merkle_tree", mint.key()].- Mutable: Yes
- Initialized: Yes (created by this instruction)
SPL token mint account. Must be in the allowed tokens list.
Global configuration account. PDA:
["global_config"].Program authority that can initialize trees. Must match admin pubkey on mainnet.
- Mutable: Yes (pays for account creation)
- Signer: Yes
Solana system program.
Tree Configuration
The instruction initializes the tree with:- Height: 26 levels (same as SOL tree)
- Root History Size: 100 historical roots
- Max Deposit Amount: Specified by caller
- Authority: Set to the signer
- Next Index: 0 (empty tree)
- Root Index: 0
Code Example
Example Deposit Limits
USDC (6 decimals)
- 1,000 tokens:
1_000_000_000 - 1 million tokens:
1_000_000_000_000 - 50 million tokens:
50_000_000_000_000
Custom Token (9 decimals)
- 1,000 tokens:
1_000_000_000_000 - 1 million tokens:
1_000_000_000_000_000 - 50 million tokens:
50_000_000_000_000_000
State Changes
MerkleTreeAccount
authority: Set to the signer’s public keynext_index: Initialized to 0root_index: Initialized to 0max_deposit_amount: Set to the provided parameterheight: Set to 26root_history_size: Set to 100bump: PDA bump seedroot: Initialized to the empty tree rootsubtrees: Initialized for Poseidon merkle tree
Authorization
- Localnet
- Devnet
- Mainnet
No authorization required. Any account can initialize.
Token Allowlist
The mint must be in the program’s allowed tokens list. See the transact_spl documentation for the complete list of supported tokens. On localnet, all tokens are automatically allowed for testing purposes.Errors
Thrown when the signer is not the authorized admin (mainnet/devnet only).
Thrown when the mint address is not in the allowed tokens list.
Usage Pattern
See Also
- initialize - Initialize the main SOL tree
- transact_spl - Transact with SPL tokens
- update_deposit_limit - Update SPL token deposit limits