On-Chain Voting & Treasury Governance — OLIGHFT SMART COIN Amex Tier
#![no_std] use soroban_sdk::{ contract, contractimpl, contracttype, Address, Env, Vec, Symbol, }; #[contracttype] pub enum ProposalState { Draft, Active, Passed, Failed, Executed, Cancelled, } #[contracttype] pub struct Proposal { pub id: u32, pub creator: Address, pub title: Symbol, pub votes_for: i128, pub votes_against: i128, pub state: ProposalState, pub end_ledger: u32, pub timelock_until: u32, } #[contract] pub struct AmexDAO; #[contractimpl] impl AmexDAO { /// Create a new governance proposal pub fn create_proposal( env: Env, creator: Address, title: Symbol, voting_period: u32, ) -> u32 { creator.require_auth(); let id = Self::next_id(&env); let proposal = Proposal { id, creator, title, votes_for: 0, votes_against: 0, state: ProposalState::Active, end_ledger: env.ledger().sequence() + voting_period, timelock_until: 0, }; id } /// Cast a vote on an active proposal pub fn vote( env: Env, voter: Address, proposal_id: u32, support: bool, amount: i128, ) { voter.require_auth(); // Lock governance tokens as voting weight // Tally votes for or against // Emit VoteCast event } /// Delegate voting power to another address pub fn delegate( env: Env, delegator: Address, delegate_to: Address, ) { delegator.require_auth(); // Transfer voting weight without moving tokens } /// Execute a passed proposal after timelock pub fn execute( env: Env, proposal_id: u32, ) { // Verify: Passed + timelock expired // Check quorum: total_votes >= 10% supply // Execute on-chain action } /// Query current quorum percentage pub fn quorum(env: Env, proposal_id: u32) -> i128 { 0 } }
| Function | Description | Auth | Gas (XLM) |
|---|---|---|---|
| create_proposal | Submit a new governance proposal | Member | ~0.016 |
| vote | Cast for/against vote with token weight | Member | ~0.010 |
| delegate | Delegate voting power to another address | Member | ~0.008 |
| execute | Execute a passed + timelocked proposal | Any | ~0.020 |
| cancel | Cancel a proposal (creator or admin only) | Creator | ~0.006 |
| quorum | Check current quorum percentage | None | ~0.001 |
| get_proposal | Query proposal details and vote tallies | None | ~0.001 |
| withdraw_treasury | Move funds per governance approval | DAO | ~0.014 |
Vote weight proportional to governance tokens locked
COREDelegate power without transferring tokens
SOCIALMandatory delay before execution for safety
SAFETY10% participation threshold to pass proposals
GOVERNANCEOn-chain treasury controlled by DAO votes
FINANCEAll votes and executions emit on-chain events
AUDITStake $200 to activate your Amex tier and earn $12 daily rewards. Choose your contract period:
When a user activates with $200, the fee is distributed across the 8-level upline binary tree:
| Generation | Role | Commission | Amount |
|---|---|---|---|
| — | Main Wallet (Platform) | — | $120 |
| Gen 1 | Direct Inviter | 10% | $20 |
| Gen 2 | Inviter’s Inviter | 6% | $12 |
| Gen 3 | Upline Level 3 | 4% | $8 |
| Gen 4 | Upline Level 4 | 4% | $8 |
| Gen 5 | Upline Level 5 | 4% | $8 |
| Gen 6 | Upline Level 6 | 4% | $8 |
| Gen 7 | Upline Level 7 | 4% | $8 |
| Gen 8 | Upline Level 8 | 4% | $8 |
| TOTAL | $200 | ||
#[contracttype] pub struct AmexStake { pub staker: Address, pub stake_amount: i128, // $200 activation pub daily_reward: i128, // $12 per day pub duration_days: u32, // 90 | 180 | 365 days pub service_fee: i128, // $80 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] = [ 20_0000000, // Gen 1: $20 (direct inviter) 12_0000000, // Gen 2: $12 8_0000000, // Gen 3: $8 8_0000000, // Gen 4: $8 8_0000000, // Gen 5: $8 8_0000000, // Gen 6: $8 8_0000000, // Gen 7: $8 8_0000000, // Gen 8: $8 ]; // Total referral: $80 | Main wallet: $120 | Grand total: $200 #[contractimpl] impl AmexDAO { /// Activate Amex staking — $200 deposit + $80 service fee /// duration: 90 (3 mo) | 180 (6 mo) | 365 (1 yr) /// $200 split: $120 main wallet + $80 across 8-gen binary tree pub fn activate_stake( env: Env, staker: Address, sponsor: Address, duration: u32, ) { staker.require_auth(); assert!(duration == 90 || duration == 180 || duration == 365, "invalid period"); let token = get_payment_token(&env); let tok = token::Client::new(&env, &token); let activation = 200_0000000; // $200 let fee = 80_0000000; // $80 service fee // Transfer $200 + $80 fee from user to contract tok.transfer(&staker, &env.current_contract_address(), &(activation + fee)); // ── Distribute $200 activation across binary tree ── let main_wallet = get_main_wallet(&env); let mut remaining = activation; // $200 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 ($120 or more) to main wallet tok.transfer( &env.current_contract_address(), &main_wallet, &remaining, ); let stake = AmexStake { staker: staker.clone(), stake_amount: activation, daily_reward: 12_0000000, // $12/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: AmexStake = 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,080 | 180d→$2,160 | 365d→$4,380 } }
| Function | Description | Auth | Cost |
|---|---|---|---|
| activate_stake | Deposit $200 + $80 fee, choose period (90/180/365 days) | User | $280 total |
| claim_rewards | Claim accrued $12/day rewards | User | ~0.01 XLM |
| get_sponsor | Get upline address for a given user | None | ~0.001 XLM |
#[test] fn test_proposal_lifecycle() { let env = Env::default(); env.mock_all_auths(); let client = AmexDAOClient::new(&env, &env.register_contract(None, AmexDAO)); // Create proposal let pid = client.create_proposal( &creator, &Symbol::new(&env, "upgrade_v2"), &100); // Vote with 60% of supply FOR client.vote(&voter1, &pid, &true, &600_000); client.vote(&voter2, &pid, &false, &200_000); // Advance past voting period + timelock env.ledger().set_sequence_number(200); client.execute(&pid); let p = client.get_proposal(&pid); assert_eq!(p.state, ProposalState::Executed); }
OLIGHFT SMART COIN Amex DAO Contract v1.3.0 • Stellar Testnet • Rust/WASM
Built with soroban-sdk 21.0.0 • April 2026