RPS Raffle

RPS Raffle is the core smart contract powering our customizable raffle systems. It handles ticket generation, fund management, and raffle logistics, offering a range of configurable parameters for a tailor-made user experience.

Roles

Operator

This backend account is crucial for managing the raffle mechanics. It is responsible for executing the raffle process once the winning tickets have been randomly selected. Importantly, the Operator is needed for this task because the raffle contract does not maintain information regarding ticket ownership.

Router

Represents the RPSRouter contract.

Owner

Holds ultimate control over raffle parameters, such as pot limits, ticket costs, and prize distributions.


State variables

uint256 public potLimit // raffle fund size threshold
uint256 public currentPotSize // current raffle fund volume
uint256 public raffleTicketCost // ticket cost in ether
uint128 private claimWindow // claim period in seconds
uint16 public numberOfWinners
uint16 public tradeFeeInBps; // raffle fee in bps (100 = 1%, 10000 = 100%)
uint32 public lastRaffleTicketId
uint16 public currentPotId
uint16 public protocolFeeInBps //  integrated protocol fee as a percentage of funds that go to the raffle; controlled by the raffle owner

Mappings

External functions

Generates tickets for the _user based on _amountInWei; can only be called by router.


Generates tickets for multiple trades.


This function represents the final stage of the raffle process and is exclusively invoked by the Operator account. It performs two critical tasks:

  • Winner Assignment: It sets the addresses of the winning participants based on their associated ticket IDs.

  • Fund Release: Upon this assignment, the raffle funds are unlocked, enabling winners to claim their prizes.

The need for Operator intervention arises because the raffle contract does not store ticket ownership information


For raffle winners to claim their funds.

Last updated