PrizeDistributionFactory

The PrizeDistributionFactory populates a PrizeDistributionBuffer for a prize pool. It uses DrawBuffer and Ticket to bring the information needed for the creation of the prize PrizeDistribution.

Write methods description

initialize()

Allows the deployer to initialize the contract during the deployment.

Parameters:

NameTypeDescription

_owner

address

An account that will become a new owner of a contract.

_drawBuffer

address

Address of the drawBuffer contract.

_prizeDistributionBuffer

address

Address of the prizeDistributionBuffer contract.

_drawBeacon

address

Address of the drawBeacon contract.

_ticket

address

Address of the ticket contract.

_minPickCost

uint256

An account that will become a new owner of a contract.

_endTimestampOffset

uint32

An account that will become a new owner of a contract.

setPrizeDistribution()

Allows the owner or manager to override an existing prize distribution in the buffer. The Draw for the given draw id will be pulled in, and the total network ticket supply will be used to calculate the number of picks. Can only be called by the current owner.

Parameters:

NameTypeDescription

_drawId

uint32

The draw id to compute for, and that will be overwritten.

Return:

NameTypeDescription

_prizeDistribution

PrizeDistribution

The resulting Prize Distribution after the update.

setMinPickCost()

Allows the owner or manager to override the minimum pick cost. The minimum pick cost will affect the number of picks that each user gets.

Parameters:

NameTypeDescription

_minPickCost

uint256

The minimum amount of TWAB balance to get 1 pick.

setEndTimestampOffset()

Allows the owner or manager to override the end timestamps offset.

Parameters:

NameTypeDescription

_endTimestampOffset

uint32

The new timestamps offset to set for future prize distributions.

pushPrizeDistribution()

Allows the owner or manager to push a new prize distribution onto the buffer. The Draw for the given draw id will be pulled in, and the total network ticket supply will be used to calculate the number of picks.

Parameters:

NameTypeDescription

_drawId

uint32

The draw id to compute for, and that will be pushed.

_totalNetworkTicketSupply

uint256

The total supply of tickets across all prize pools for the network that the ticket belongs to.

Return:

NameTypeDescription

_prizeDistribution

PrizeDistribution

The resulting Prize Distribution that was pushed.

claimOwnership()

Allows the pendingOwner address to claim the owner role. This function is only callable by the pendingOwner.

renounceOwnership()

Leaves the contract without owner. It will not be possible to call the owner's functions anymore. Can only be called by the current owner. The method does not take any parameters. Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.

transferOwnership()

Transfers ownership of the contract to a _pendingOwner. Can only be called by the current owner.

Parameters:

NameTypeDescription

newOwner

address

An account that will become the _pendingOwner.

setManager()

Allows the owner to give the manager role to an address. The manager role has access to the functions with the modified onlyManage or onlyManagerOrOwner.

Parameters:

NameTypeDescription

_newManager

address

An account that will become the new manager.

Read methods description

drawBuffer()

The draw buffer to pull the draw from. Can be called by anyone.

prizeDistributionBuffer()

The prize distribution buffer to push and set. This contract must be the manager or owner of the buffer. Can be called by anyone.

drawBeacon()

The draw beacon to pull the draw configuration data. Can be called by anyone.

ticket()

The ticket whose average total supply will be measured to calculate the portion of picks. Can be called by anyone.

minPickCost()

The minimum cost of each pick. Can be called by anyone.

endTimestampOffset()

The offset that is added at the end of the draw. Can be called by anyone.

estimatePartialPicks()

Allows estimating the picks that a user has from the total picks. Can be called by anyone.

Parameters:

NameTypeDescription

_user

address

The user to be used to estimate the partial pick amount.

Return:

NameTypeDescription

_userPicks

uint256

Partial amount of picks that a user has in the active draw.

_totalPicks

uint256

Partial amount of total supply of picks in the active draw.

calculatePrizeDistribution()

ะกalculates what the prize distribution will be, given a draw id and total network ticket supply. Can be called by anyone.

Parameters:

NameTypeDescription

_drawId

uint32

The draw id to pull from the Draw Buffer.

Return:

NameTypeDescription

_prizeDistribution

PrizeDistribution

The result will include startTimestampOffset, endTimestampOffset, and numberOfPicks.

calculatePrizeDistributionWithDrawData()

Calculates what the prize distribution will be, given the draw timestamp and the beacon period. Can be called by anyone.

Parameters:

NameTypeDescription

_beaconPeriodSeconds

uint32

The beacon period in seconds.

_drawTimestamp

uint64

The timestamp at which the draw started.

Return:

NameTypeDescription

_prizeDistribution

PrizeDistribution

The calculated prize distributed based on the given params for the passed draw id.

owner()

Owner role that can be granted exclusive access to specific functions with the modifier onlyOwner.

manager()

Manager role that can be granted exclusive access to specific functions with the modifier onlyManager or onlyManagerOrOwner.

pendingOwner()

The address that can claim the owner role. It is used to transfer the owner.

Last updated