added coinflip game to Qusino sc - #998
Open
TakaYuPP wants to merge 9 commits into
Open
Conversation
Franziska-Mueller
self-requested a review
September 3, 2026 11:24
fnordspace
requested changes
Sep 3, 2026
fnordspace
left a comment
Contributor
There was a problem hiding this comment.
Please let us know when the PR is ready for the review.
Franziska-Mueller
removed their request for review
September 3, 2026 14:13
fnordspace
approved these changes
Sep 3, 2026
fnordspace
left a comment
Contributor
There was a problem hiding this comment.
Looks ok to me. Please not we do not review the logic of the contract it self. Please make sure it works as intended and test your contract thoroughly.
Also this PR changes the logic of the contract and needs a Proposal to be merged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Coin Flip game with RANDOM-backed RNG "Result Bank"
Summary
Integrates the
RANDOMsmart contract intoQusinoto power a new Coin Flip game, using a "Result Bank" architecture (per-game pool + shared overflow reserve) so individual bets resolve instantly instead of waiting on a liveRANDOMcall.What's new
RNG Result Bank
refillRandomBank()— permissionless maintenance call that buys entropy fromRANDOMin bulk (256 bits/call), expands it via K12 re-hashing into a 1024-entry shared reserve, and bootstraps any not-yet-seeded game's 256-entry pool from that reserve.QUSINO_RNG_MAX_GAMES(32, headroom for future games) vs.QUSINO_RNG_ACTIVE_GAMES(1, bumped as new games launch) so this plumbing is reusable for Blackjack/Baccarat later without another state layout change.getRandomBankStatus()— read-only view of pool/reserve health for frontends to poll.Coin Flip
coinFlip(guess, assetType, amount)— bets QSC or STAR (never raw Qu) on heads/tails. Outcome is drawn instantly from the pool (context-mixed, then re-hashed against the drawn value so it can't be predicted or replayed), and the consumed slot is topped up from the reserve.QSC_PRICE); a win credits new QSC back to the caller (they redeem it for real Qu themselves via the existingredemptionQSCToQubic), a loss keeps the Qu value in the bankroll. STAR bets never touch Qu — a win mints STAR, a loss burns it, mirroring the existing vote-fee burn.Qu game bankroll
bonusAmount(previously only backing the daily-claim-bonus feature) now doubles as the Qu bankroll funding bothrefillRandomBank's RANDOM fees and Coin Flip's QSC payouts. Funded by the game owner via the existingdepositBonus.QUSINO_GAME_BANKROLL_CAP) — any deposit or loss top-up that would push it past the cap routes the excess intoepochRevenueinstead.New return codes:
QUSINO_INVALID_INPUT,QUSINO_RNG_NOT_READY,QUSINO_RNG_REFILL_TOO_SOON,QUSINO_RNG_REFILL_FAILED(reusesQUSINO_INSUFFICIENT_BONUS_AMOUNT/QUSINO_WRONG_ASSET_TYPE/QUSINO_INSUFFICIENT_QSC/QUSINO_INSUFFICIENT_STARfor the rest).Testing
40 GoogleTest cases in
contract_qusino.cpp(up from 32), covering: bank refill success/failure/rate-limiting/insufficient-bankroll paths, Coin Flip validation (bad guess/asset type/bet size/balance), QSC settlement (win credit, loss top-up, bankroll gating), STAR settlement (mint/burn, no bankroll interaction), and the bankroll cap/overflow-to-revenue behavior. All passing.Notes for reviewers
bonusAmountis now shared between daily-claim-bonus and the game bankroll — a design choice, not an oversight (dailyClaimBonus payouts and Coin Flip traffic draw from the same treasury).QUSINO_COINFLIP_MIN_BETandQUSINO_COINFLIP_PAYOUT_PERCENT(1.96x, ~2% house edge)