πŸ€‘Single Random Winner

The Single Random Winner prize strategy periodically selects a random winner and awards to them all the prizes available in the Prize Pool.

A Single Random Winner prize strategy is initialized with:

Prize Period Start: the timestamp at which the prize period should start

Prize Period Seconds: the duration of time between prizes

Ticket: The interface to use to select winners

Sponsorship: The token that represents sponsorship

Random Number Generator: used to generate random numbers for winner selection

Awarding

Anyone may start the award process.

function startAward() external

startAward():

  • Requires that either:

    • the current time is greater than or equal to start time + prize period

    • there is an active random number request and it has timed out

  • Locks the pool. Tickets cannot be minted or redeemed

  • Requests a random number from the RNG service

Once the random number is available, a user can call:

completeAward():

  • Requires that startAward() has been called

  • Unlocks the pool

  • Disburses the prize

  • Moves the prize start time forward

  • Clears the random number request

You can check the above required conditions using canStartAward() and canCompleteAward():

and

Prizes

Current Yield Prize

To retrieve amount of accrued prize interest so far you may call:

Estimating Prize

To estimate what the prize will be you can call:

External Prizes

The owner can add "external" ERC20 tokens as prizes. The strategy will award the entire balance held by the Prize Pool to the winner.

The owner can add "external" ERC721 tokens as prizes. These tokens will be transferred to the winner.

Time

To retrieve when the current prize started:

To retrieve when the prize will end:

Miscellaneous

Function

Description

function sponsorship() returns (ERC20)

Returns the address of the sponsorship token.

function ticket() returns (Ticket)

Returns the address of the ticket token.

Last updated

Was this helpful?