Secure Treasury Management — OLIGHFT SMART COIN Black Tier
#![no_std] use soroban_sdk::{ contract, contractimpl, contracttype, Address, Env, Vec, token, }; #[contracttype] pub enum TxState { Pending, Approved, Executed, Cancelled, } #[contracttype] pub struct VaultTx { pub id: u32, pub proposer: Address, pub recipient: Address, pub token: Address, pub amount: i128, pub approvals: Vec<Address>, pub state: TxState, pub execute_after: u32, // timelock ledger } #[contracttype] pub struct VaultConfig { pub signers: Vec<Address>, pub threshold: u32, // min approvals needed pub timelock_ledgers: u32, pub daily_limit: i128, } #[contract] pub struct BlackVault; #[contractimpl] impl BlackVault { /// Deposit tokens into the vault pub fn deposit( env: Env, from: Address, token: Address, amount: i128, ) { from.require_auth(); // Transfer token from depositor to vault token::Client::new(&env, &token) .transfer(&from, &env.current_contract_address(), &amount); } /// Propose a withdrawal (requires multi-sig) pub fn propose_withdrawal( env: Env, proposer: Address, recipient: Address, token: Address, amount: i128, ) -> u32 { proposer.require_auth(); // Verify proposer is a signer // Check daily_limit not exceeded // Create VaultTx with Pending state // Auto-count proposer as first approval 0 // returns tx_id } /// Approve a pending withdrawal (signer only) pub fn approve( env: Env, signer: Address, tx_id: u32, ) { signer.require_auth(); // Verify signer is authorized // Prevent duplicate approvals // If threshold reached, set state = Approved // Set execute_after = now + timelock_ledgers } /// Execute an approved withdrawal after timelock pub fn execute(env: Env, tx_id: u32) { // Verify: Approved + timelock expired assert!(env.ledger().sequence() >= tx.execute_after, "timelock active"); // Transfer tokens to recipient // Set state = Executed } /// Cancel a pending/approved withdrawal pub fn cancel( env: Env, signer: Address, tx_id: u32, ) { signer.require_auth(); } /// Query vault balance for a specific token pub fn balance(env: Env, token: Address) -> i128 { 0 } }
| Function | Description | Auth | Gas (XLM) |
|---|---|---|---|
| deposit | Send tokens to vault custody | Any | ~0.008 |
| propose_withdrawal | Create multi-sig withdrawal request | Signer | ~0.016 |
| approve | Sign/approve a pending withdrawal | Signer | ~0.010 |
| execute | Execute after threshold + timelock | Any | ~0.014 |
| cancel | Cancel a pending withdrawal | Signer | ~0.006 |
| balance | Query vault holdings for a token | None | ~0.001 |
| get_tx | Query withdrawal request details | None | ~0.001 |
| update_signers | Add/remove vault signers (multi-sig) | Threshold | ~0.018 |
Configurable M-of-N threshold for all withdrawals
SECURITY24-hour delay after approval before execution
CRITICALConfigurable daily withdrawal caps per token
LIMITAny signer can cancel during timelock period
SAFETYHold XLM, USDC, wETH, wBTC and any SEP-41
FLEXIBLEEvery deposit, approval, and execution on-chain
AUDITStake $500 to activate your Black tier and earn $30 daily rewards. Choose your contract period:
When a user activates with $500, the fee is distributed across the 8-level upline binary tree:
| Generation | Role | Commission | Amount |
|---|---|---|---|
| — | Main Wallet (Platform) | — | $300 |
| Gen 1 | Direct Inviter | 10% | $50 |
| Gen 2 | Inviter’s Inviter | 6% | $30 |
| Gen 3 | Upline Level 3 | 4% | $20 |
| Gen 4 | Upline Level 4 | 4% | $20 |
| Gen 5 | Upline Level 5 | 4% | $20 |
| Gen 6 | Upline Level 6 | 4% | $20 |
| Gen 7 | Upline Level 7 | 4% | $20 |
| Gen 8 | Upline Level 8 | 4% | $20 |
| TOTAL | $500 | ||
#[contracttype] pub struct BlackStake { pub staker: Address, pub stake_amount: i128, // $500 activation pub daily_reward: i128, // $30 per day pub duration_days: u32, // 90 | 180 | 365 days pub service_fee: i128, // $200 platform fee pub sponsor: Address, // direct inviter (Gen 1) pub start_time: u64, pub claimed_days: u32, } // 8-generation binary tree commission rates (in $) const GEN_COMMISSIONS: [i128; 8] = [ 50_0000000, // Gen 1: $50 (direct inviter) 30_0000000, // Gen 2: $30 20_0000000, // Gen 3: $20 20_0000000, // Gen 4: $20 20_0000000, // Gen 5: $20 20_0000000, // Gen 6: $20 20_0000000, // Gen 7: $20 20_0000000, // Gen 8: $20 ]; // Total referral: $200 | Main wallet: $300 | Grand total: $500 #[contractimpl] impl BlackVault { /// Activate Black staking — $500 deposit + $200 service fee /// $500 split: $300 main wallet + $200 across 8-gen binary tree /// duration: 90 (3mo) | 180 (6mo) | 365 (1yr) pub fn activate_stake( env: Env, staker: Address, sponsor: Address, duration: u32, ) { staker.require_auth(); // Valid periods: 90 (3mo), 180 (6mo), 365 (1yr) assert!(duration == 90 || duration == 180 || duration == 365); let token = get_payment_token(&env); let tok = token::Client::new(&env, &token); let activation = 500_0000000; // $500 let fee = 200_0000000; // $200 service fee // Transfer $500 + $200 fee from user to contract tok.transfer(&staker, &env.current_contract_address(), &(activation + fee)); // ── Distribute $500 activation across binary tree ── let main_wallet = get_main_wallet(&env); let mut remaining = activation; // $500 let mut current = sponsor.clone(); for gen in 0..8 { let commission = GEN_COMMISSIONS[gen]; if let Some(upline) = get_sponsor(&env, ¤t) { tok.transfer( &env.current_contract_address(), ¤t, &commission, ); remaining -= commission; current = upline; } else { // No upline — remaining goes to main wallet break; } } // Send remainder ($300 or more) to main wallet tok.transfer( &env.current_contract_address(), &main_wallet, &remaining, ); let stake = BlackStake { staker: staker.clone(), stake_amount: activation, daily_reward: 30_0000000, // $30/day duration_days: duration, service_fee: fee, sponsor: sponsor.clone(), start_time: env.ledger().timestamp(), claimed_days: 0, }; env.storage().persistent().set(&staker, &stake); } /// Claim accrued daily rewards pub fn claim_rewards(env: Env, staker: Address) -> i128 { staker.require_auth(); let mut stake: BlackStake = env.storage().persistent().get(&staker).unwrap(); let elapsed = (env.ledger().timestamp() - stake.start_time) / 86400; let claimable = elapsed.min(stake.duration_days as u64) as u32 - stake.claimed_days; let payout = (claimable as i128) * stake.daily_reward; stake.claimed_days += claimable; env.storage().persistent().set(&staker, &stake); // Transfer rewards to staker token::Client::new(&env, &get_payment_token(&env)) .transfer(&env.current_contract_address(), &staker, &payout); payout // 90d→$2,700 | 180d→$5,400 | 365d→$10,950 } }
| Function | Description | Auth | Cost |
|---|---|---|---|
| activate_stake | Deposit $500 + $200 fee, choose period (90/180/365 days) | User | $700 total |
| claim_rewards | Claim accrued $30/day rewards | User | ~0.01 XLM |
| get_sponsor | Get upline address for a given user | None | ~0.001 XLM |
#[test] fn test_multisig_withdrawal() { let env = Env::default(); env.mock_all_auths(); let client = BlackVaultClient::new(&env, &env.register_contract(None, BlackVault)); // Deposit 50000 XLM into vault client.deposit(&depositor, &xlm, &50000_0000000); assert_eq!(client.balance(&xlm), 50000_0000000); // Propose withdrawal of 10000 XLM let tx_id = client.propose_withdrawal( &signer1, &recipient, &xlm, &10000_0000000); // Approve by signer2 and signer3 (threshold = 3) client.approve(&signer2, &tx_id); client.approve(&signer3, &tx_id); // Wait for timelock (17280 ledgers = ~24h) env.ledger().set_sequence_number(17280); client.execute(&tx_id); assert_eq!(client.balance(&xlm), 40000_0000000); let tx = client.get_tx(&tx_id); assert_eq!(tx.state, TxState::Executed); }
OLIGHFT SMART COIN Black Vault v2.0.0 • Stellar Testnet • Rust/WASM
Built with soroban-sdk 21.0.0 • April 2026