I want to share the technical architecture behind RugPot — a provably fair lottery on Solana that uses bonding curves for pricing and Switchboard VRF for verifiable jackpot draws.
This isn't a tutorial (the contracts aren't open source yet), but rather a breakdown of the design and decisions we made. If you're building anything on Solana that involves bonding curves, on-chain randomness or token distribution mechanics - this should be useful.
The Core Loop
RugPot's game loop is deceptively simple:

The complexity lives in making each of these steps atomic, front-running resistant, and gas-efficient on Solana.
Bonding Curve Design
We evaluated several bonding curve models:
The sigmoid curve creates natural game dynamics: early buyers get good prices, mid-round buyers face rapidly increasing prices, and late-round buyers hit a soft ceiling. This prevents unbounded price growth while maintaining the incentive to enter early.
The curve parameters (steepness, midpoint, max price) are set per round and stored on-chain. They cannot be modified after a round begins.
Reflection Mechanics
The reflection system distributes a percentage of every transaction to existing share holders, proportional to their share count. The naive approach — iterating through all holders on every transaction — is O(n) and doesn't scale.
Instead, we use a cumulative reflection-per-share approach:
This makes every transaction O(1) regardless of holder count. Holders can claim accumulated reflections at any time or they're automatically calculated when selling shares.
Switchboard VRF Integration
The jackpot draw is the most critical component.
It must be:
Unpredictable — no one can determine the outcome before the draw.
Unbiased — no one can influence the outcome, including us.
Verifiable — anyone can confirm the outcome was computed correctly.
Switchboard's VRF implementation on Solana provides all three properties. The integration flow:
The callback pattern is important: the winner selection happens inside the VRF callback transaction, meaning the random value and the winner selection are atomic. There's no window between randomness generation and winner selection where manipulation could occur.
Front-Running Protection
Solana's fast block times (~400ms) reduce but don't eliminate front-running risk. We implemented several protections:
Commit-reveal for large buys: Purchases above a threshold use a two-step process to prevent last-second manipulation of share weights before a draw.
Draw lockout period: Purchases are disabled during the brief window between draw trigger and VRF callback execution.
Slippage protection: Bonding curve purchases specify a maximum price to prevent sandwich attacks.
State Management
Each RugPot round is a Program Derived Address (PDA) containing:
Holder state is tracked in separate PDAs keyed by (round_id, wallet_address), keeping the round
account size fixed regardless of participant count.
Lessons Learned
- VRF callbacks are not instant. Switchboard VRF has a latency of 1-3 Solana slots between request and callback. During this window, the round is in a "Drawing" state where no transactions are allowed. This was initially confusing for users — we added real-time status indicators showing "Draw in progress..." to set expectations.
- Reflection precision matters. With potentially thousands of micro-transactions, floating-point errors accumulate. We use u128 fixed-point arithmetic for the reflection-per-share calculation. Even so, there are dust amounts that can't be distributed perfectly — these go into the next round's pot.
- Bonding curve parameters are hard to get right. Too steep and late joiners feel priced out. Too flat and there's no urgency. We ended up running simulations with 1,000+ agents with different strategies to find parameters that created engaging dynamics across different round sizes.
- Solana compute limits are real. The winner selection in the VRF callback needs to iterate through holders weighted by shares. For rounds with many holders, this can exceed Solana's compute budget.
We implemented a sorted holder list (maintained on buy/sell) so the weighted walk is efficient, and tested up to 10,000 holders per round.
What's Next
We're exploring several extensions:
Multiple pot tiers — small, frequent draws alongside a larger jackpot.
Custom rounds — letting communities create their own rounds with custom parameters.
Open-sourcing the VRF integration code — the Switchboard integration patterns could be useful for any Solana project needing verifiable randomness.
If you're building on Solana and have questions about VRF integration or bonding curve design, feel free to reach out. We're active in the Telegram community.
RugPot is live at rugpot.io. The game is real, the rug is the prize, and the math is on-chain.
Disclaimer: RugPot is a game involving financial risk. This post discusses the technical architecture and does not constitute financial advice.




Top comments (0)