Lock & Earn Compound Rewards — OLIGHFT SMART COIN Platinum Tier
#![no_std] use soroban_sdk::{ contract, contractimpl, contracttype, Address, Env, token, }; #[contracttype] pub struct StakePosition { pub owner: Address, pub amount: i128, pub start_ledger: u32, pub lock_until: u32, pub reward_debt: i128, pub boost_multiplier: u32, // 100 = 1.0x pub auto_compound: bool, } #[contracttype] pub struct PoolConfig { pub reward_token: Address, pub stake_token: Address, pub reward_per_ledger: i128, pub acc_reward_per_share: i128, pub total_staked: i128, pub last_update_ledger: u32, } #[contract] pub struct PlatinumStake; #[contractimpl] impl PlatinumStake { /// Stake tokens with optional lock period pub fn stake( env: Env, user: Address, amount: i128, lock_days: u32, auto_compound: bool, ) -> StakePosition { user.require_auth(); let boost = match lock_days { 0 => 100, 1..=30 => 150, 31..=90 => 200, _ => 250, }; // Transfer stake_token from user to contract // Update pool accumulators // Create position in persistent storage StakePosition { /* ... */ } } /// Compound accrued rewards back into stake pub fn compound(env: Env, user: Address) -> i128 { user.require_auth(); // pending = (pos.amount * acc_reward_per_share) - pos.reward_debt // pos.amount += pending (compound rewards) // pos.reward_debt = pos.amount * acc_reward_per_share 0 // returns compounded amount } /// Unstake tokens (must respect lock period) pub fn unstake( env: Env, user: Address, amount: i128, ) -> i128 { user.require_auth(); assert!(env.ledger().sequence() >= pos.lock_until, "lock period active"); // Claim pending rewards + withdraw stake 0 } /// Claim rewards without unstaking pub fn claim_rewards(env: Env, user: Address) -> i128 { user.require_auth(); 0 } /// View pending rewards for a position pub fn pending_rewards(env: Env, user: Address) -> i128 { 0 } }
| Function | Description | Auth | Gas (XLM) |
|---|---|---|---|
| stake | Lock tokens with optional time boost | User | ~0.014 |
| unstake | Withdraw after lock period expires | User | ~0.012 |
| compound | Reinvest rewards into position | User | ~0.010 |
| claim_rewards | Withdraw accrued rewards to wallet | User | ~0.010 |
| pending_rewards | Read-only: check unclaimed rewards | None | ~0.001 |
| get_position | Query user's stake details | None | ~0.001 |
| get_pool_info | Query pool TVL, APY, totals | None | ~0.001 |
| set_rewards | Admin: update reward rate per ledger | Admin | ~0.008 |
Up to 2.5x rewards for longer lock periods
BOOSTReinvest rewards automatically each epoch
YIELDRewards accumulate every 5-second ledger close
PRECISIONHarvest rewards without touching principal
FLEXIBLEOn-chain lock prevents early withdrawal
SAFETYPool rewards and positions fully on-chain
AUDITStake $300 to activate your Platinum tier and earn $18 daily rewards. Choose your contract period:
When a user activates with $300, the fee is distributed across the 8-level upline binary tree:
| Generation | Role | Commission | Amount |
|---|---|---|---|
| — | Main Wallet (Platform) | — | $180 |
| Gen 1 | Direct Inviter | 10% | $30 |
| Gen 2 | Inviter’s Inviter | 6% | $18 |
| Gen 3 | Upline Level 3 | 4% | $12 |
| Gen 4 | Upline Level 4 | 4% | $12 |
| Gen 5 | Upline Level 5 | 4% | $12 |
| Gen 6 | Upline Level 6 | 4% | $12 |
| Gen 7 | Upline Level 7 | 4% | $12 |
| Gen 8 | Upline Level 8 | 4% | $12 |
| TOTAL | $300 | ||
#[contracttype] pub struct PlatStake { pub staker: Address, pub stake_amount: i128, // $300 activation pub daily_reward: i128, // $18 per day pub duration_days: u32, // 90 | 180 | 365 days pub service_fee: i128, // $120 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] = [ 30_0000000, // Gen 1: $30 (direct inviter) 18_0000000, // Gen 2: $18 12_0000000, // Gen 3: $12 12_0000000, // Gen 4: $12 12_0000000, // Gen 5: $12 12_0000000, // Gen 6: $12 12_0000000, // Gen 7: $12 12_0000000, // Gen 8: $12 ]; // Total referral: $120 | Main wallet: $180 | Grand total: $300 #[contractimpl] impl PlatinumStake { /// Activate Platinum staking — $300 deposit + $120 service fee /// $300 split: $180 main wallet + $120 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 = 300_0000000; // $300 let fee = 120_0000000; // $120 service fee // Transfer $300 + $120 fee from user to contract tok.transfer(&staker, &env.current_contract_address(), &(activation + fee)); // ── Distribute $300 activation across binary tree ── let main_wallet = get_main_wallet(&env); let mut remaining = activation; // $300 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 ($180 or more) to main wallet tok.transfer( &env.current_contract_address(), &main_wallet, &remaining, ); let stake = PlatStake { staker: staker.clone(), stake_amount: activation, daily_reward: 18_0000000, // $18/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: PlatStake = 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→$1,620 | 180d→$3,240 | 365d→$6,570 } }
| Function | Description | Auth | Cost |
|---|---|---|---|
| activate_stake | Deposit $300 + $120 fee, choose period (90/180/365 days) | User | $420 total |
| claim_rewards | Claim accrued $18/day rewards | User | ~0.01 XLM |
| get_sponsor | Get upline address for a given user | None | ~0.001 XLM |
#[test] fn test_stake_and_compound() { let env = Env::default(); env.mock_all_auths(); let client = PlatinumStakeClient::new(&env, &env.register_contract(None, PlatinumStake)); // Stake 10000 XLM for 90 days (2.0x boost) let pos = client.stake(&user, &10000_0000000, &90, &true); assert_eq!(pos.boost_multiplier, 200); // Advance 1000 ledgers (~83 minutes) env.ledger().set_sequence_number(1000); let pending = client.pending_rewards(&user); assert!(pending > 0); // Compound rewards back into position let compounded = client.compound(&user); assert!(compounded > 0); let new_pos = client.get_position(&user); assert!(new_pos.amount > 10000_0000000); }
OLIGHFT SMART COIN Platinum Staking v1.5.0 • Stellar Testnet • Rust/WASM
Built with soroban-sdk 21.0.0 • April 2026