Claim rewards using merkle proof
User provides:
The leaf is computed as: SHA256(wallet || amount_le_bytes)
fn claim(
env: soroban_sdk::Env,
claimer: soroban_sdk::Address,
epoch: u32,
amount: i128,
merkle_proof: soroban_sdk::Vec>,
proof_directions: soroban_sdk::Vec,
)
Get epoch data
fn get_epoch(env: soroban_sdk::Env, epoch: u32) -> Option
Get owner
fn get_owner(env: soroban_sdk::Env) -> soroban_sdk::Address
Check if a leaf has been claimed for an epoch
fn is_claimed(
env: soroban_sdk::Env,
epoch: u32,
leaf_hash: soroban_sdk::BytesN<32>,
) -> bool
Check contract is deployed
fn is_deployed(env: soroban_sdk::Env) -> bool
Constructor: Initialize with owner, reward asset, and treasury
fn __constructor(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
reward_asset: soroban_sdk::Address,
treasury: soroban_sdk::Address,
)
Register a new epoch's merkle root (admin only) Called weekly by settlement cron job
The merkle tree leaves are: SHA256(wallet_address || amount_le_bytes) This allows users to prove their reward amount
Parameters:
fn register_epoch(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
epoch: u32,
merkle_root: soroban_sdk::BytesN<32>,
total_claimable: i128,
vesting_ledgers: u32,
)
Get total epoch count
fn get_epoch_count(env: soroban_sdk::Env) -> u32
Get reward asset
fn get_reward_asset(env: soroban_sdk::Env) -> soroban_sdk::Address
Compute leaf hash: SHA256(wallet_address_bytes || amount_le_bytes)
fn compute_leaf_hash(
env: soroban_sdk::Env,
wallet: soroban_sdk::Address,
amount: i128,
) -> soroban_sdk::BytesN<32>
Compute merkle root from leaf and proof
fn compute_merkle_root(
env: soroban_sdk::Env,
leaf: soroban_sdk::BytesN<32>,
proof: soroban_sdk::Vec>,
directions: soroban_sdk::Vec,
) -> soroban_sdk::BytesN<32>