triple orange
No-loss. Play daily, win up to 3x per week. Yield funds prizes. Your principal stays safe
Problem Statement
ripleOrange: No-Loss Lottery on Citrea Testnet TripleOrange is a no-loss lottery protocol on Citrea testnet. Users deposit cBTC tokens and can play a daily luck game during 7-day epochs. How It Works: Users deposit cBTC tokens (principal is always safe and withdrawable) Each epoch lasts 7 days Users can play the luck game once every 24 hours (up to 7 plays per epoch) Win probability is weighted by deposit size (larger deposits = higher chance) Maximum 3 wins per epoch per user Prize pool comes from yield generated during the epoch At epoch end, winners share the prize pool proportionally based on their win count Why TripleOrange Wins: Instead of earning only your own yield (e.g., 5% APY on 1 cBTC = 0.05 cBTC/year), winners share the entire epoch prize pool. If 100 users deposit 100 cBTC total and generate 10 cBTC in yield, winners split that 10 cBTC. With 3 wins, you could receive a large share—potentially 10x, 50x, or 100x more than your individual yield. You keep your principal and can win a share of the total yield pool. Key Features: No-loss: users can withdraw their principal at any time Daily gameplay: play once every 24 hours during the epoch Weighted probability: larger depositors have higher win chances (PoolTogether-style) Proportional prizes: winners share based on number of wins (not deposit size) Yield-powered: prizes come from yield generated, not user deposits Transparent: all game mechanics are on-chain and verifiable Example: If User A has 1 cBTC, User B has 2 cBTC, and User C has 10 cBTC deposited, User C has approximately 77% win probability per play, User B has 15%, and User A has 8%. If the prize pool is 70 cBTC and User C wins 2 times while others win 1 time each, User C receives 50% of the prize (2/4 wins), while others receive 25% each. Instead of earning ~0.01 cBTC from normal yield, winners can receive 17.5+ cBTC—over 1,000x more. Built for the Citrea hackathon, TripleOrange combines the excitement of lottery games with the security of no-loss savings, making DeFi more accessible and fun.
Solution
How It's Made: TripleOrange is built on Solidity 0.8.13 using Foundry for development, testing, and deployment. Smart Contract Architecture: Core contract: TripleOrange.sol with epoch-based state management Epoch system: 7-day cycles with automatic transitions Probability engine: PoolTogether-style weighted selection using 18-decimal precision (1e18) for accuracy Randomness: multi-source entropy combining block.prevrandao, block.timestamp, blockhashes, player address, epoch, and play history Stack optimization: internal helper functions (_generateRandomSeed, _calculatePlayerShare) to avoid "stack too deep" errors Key Technical Features: Yield tracking: per-epoch yield snapshots to calculate prize pools accurately Cooldown system: per-epoch play timestamps enabling immediate first play Win tracking: maximum 3 wins per epoch with proportional prize distribution Admin functions: resetUserCooldown() for testing/hackathon demos Safe blockhash handling: guards for low block numbers in test environments Testing & Deployment: Test suite: 19 tests covering game mechanics, probability, prize distribution, and edge cases Mock ERC20: MockERC20.sol for cBTC token simulation Deployment script: automated deployment to Citrea testnet (Chain ID 5115) with RPC integration Foundry configuration: custom RPC endpoints and explorer settings for Citrea Notable Implementation Details: Probability calculation uses fixed-point math (1e18 precision) instead of basis points for better accuracy Epoch transitions are automatic on any user interaction (deposit/withdraw/play), ensuring no manual intervention needed Prize pool calculation happens atomically during epoch end, preventing race conditions All state changes emit events for frontend integration and transparency The contract is gas-optimized, uses internal functions to reduce stack depth, and includes comprehensive error handling for production readiness.
Hackathon
ETHGlobal Buenos Aires
2025
Prizes
- 🏆
Best Degen Bapps (Bitcoin Applications)2nd place
Citrea
Contributors
- MiguelBits
4 contributions