Jackpot

The main Jackpot contract orchestrates all jackpot operations including ticket purchases, drawings, LP management, and prize distribution.

State Variables

Variable
Type
Description

currentDrawingId

uint256

Current active drawing identifier

ticketPrice

uint256

Cost per ticket in USDC (6 decimals)

normalBallMax

uint8

Maximum value for normal ball numbers

bonusballMin

uint8

Minimum bonusball range

bonusballSoftCap

uint8

Soft cap for bonusball used in pool calculations

bonusballHardCap

uint8

Hard cap for bonusball (cannot be exceeded)

referralFee

uint256

Fraction of ticket price to referrers (1e18 scale)

referralWinShare

uint256

Fraction of winnings shared with referrers

referralFees

mapping(address => uint256)

Accumulated referral fees per address

allowTicketPurchases

bool

Whether ticket purchases are enabled

emergencyMode

bool

Whether emergency mode is active

Structs

Ticket

struct Ticket {
    uint8[] normals;   // 5 unique numbers in [1, ballMax]
    uint8 bonusball;   // 1 number in [1, bonusballMax]
}

DrawingState

ReferralScheme

Events

TicketPurchased

TicketWinningsClaimed

JackpotSettled

NewDrawingInitialized

Functions

buyTickets

Purchase jackpot tickets for the current drawing.

Parameters:

Name
Type
Description

_tickets

Ticket[]

Array of ticket structs with normal numbers and bonusball

_recipient

address

Address to receive the minted ticket NFTs

_referrers

address[]

Referrer addresses for fee sharing (can be empty)

_referralSplit

uint256[]

PRECISE_UNIT-scaled weights (must sum to 1e18 if provided)

_source

bytes32

Identifier for tracking ticket source (telemetry)

Returns:

Type
Description

uint256[]

Array of minted ticket NFT IDs

Example:


claimWinnings

Claim prize winnings for completed drawings.

Parameters:

Name
Type
Description

_userTicketIds

uint256[]

Array of ticket NFT IDs to claim winnings for

Example:


lpDeposit

Deposit USDC into the prize pool as a liquidity provider.

Parameters:

Name
Type
Description

_amountToDeposit

uint256

Amount of USDC to deposit (6 decimals)

Example:


initiateWithdraw

Start LP withdrawal process by converting shares to pending withdrawal.

Parameters:

Name
Type
Description

_amountToWithdrawInShares

uint256

Amount of LP shares to withdraw (1e18 scale)

Example:


finalizeWithdraw

Complete pending LP withdrawals and receive USDC.

Example:


emergencyWithdrawLP

Emergency withdrawal for LPs when system is stuck.

Requirements:

  • Emergency mode must be enabled

Example:


emergencyRefundTickets

Refund tickets from the current drawing during emergency mode.

Parameters:

Name
Type
Description

_userTicketIds

uint256[]

Array of ticket IDs to refund

Requirements:

  • Emergency mode must be active

  • Tickets must be from current drawing only


claimReferralFees

Claim accumulated referral fees.

Example:


runJackpot

Execute the drawing by requesting randomness from entropy provider.

Requirements:

  • Drawing time must have passed

  • Drawing must not be locked

  • Sufficient ETH for entropy fee

Example:


View Functions

getDrawingState

Get complete state for a drawing.

Example:


getReferralScheme

Get referral scheme details.


checkIfTicketsBought

Check if specific tickets have been purchased.


getUnpackedTicket

Unpack a packed ticket into normal numbers and bonusball.


getTicketTierIds

Get prize tier IDs for a list of tickets.


getDrawingTierPayouts

Get payout amounts for all tiers in a drawing.


getEntropyCallbackFee

Get the ETH fee required to run the jackpot.

Last updated