Skip to main content
Version: V4

PrizeDistributionFactory

The Prize Distribution Factory populates a Prize Distribution Buffer for a prize pool. It uses a Prize Tier History, Draw Buffer and Ticket to compute the correct prize distribution. It automatically sets the cardinality based on the minPickCost and the total network ticket supply.

Functions

constructor

  function constructor(
) public

pushPrizeDistribution

  function pushPrizeDistribution(
uint32 _drawId,
uint256 _totalNetworkTicketSupply
) external returns (struct IPrizeDistributionBuffer.PrizeDistribution)

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

Parameters:

NameTypeDescription
_drawIduint32The draw id to compute for
_totalNetworkTicketSupplyuint256The total supply of tickets across all prize pools for the network that the ticket belongs to.

Return Values:

TypeDescription
struct IPrizeDistributionBuffer.PrizeDistributionThe resulting Prize Distribution

setPrizeDistribution

  function setPrizeDistribution(
uint32 _drawId,
uint256 _totalNetworkTicketSupply
) external returns (struct IPrizeDistributionBuffer.PrizeDistribution)

Allows the owner or manager to override an existing prize distribution in the buffer. The PrizeTier and Draw for the given draw id will be pulled in, and the total network ticket supply will be used to calculate cardinality.

Parameters:

NameTypeDescription
_drawIduint32The draw id to compute for
_totalNetworkTicketSupplyuint256The total supply of tickets across all prize pools for the network that the ticket belongs to.

Return Values:

TypeDescription
struct IPrizeDistributionBuffer.PrizeDistributionThe resulting Prize Distribution

calculatePrizeDistribution

  function calculatePrizeDistribution(
uint32 _drawId,
uint256 _totalNetworkTicketSupply
) public returns (struct IPrizeDistributionBuffer.PrizeDistribution)

Calculates what the prize distribution will be, given a draw id and total network ticket supply.

Parameters:

NameTypeDescription
_drawIduint32The draw id to pull from the Draw Buffer and Prize Tier History
_totalNetworkTicketSupplyuint256The total of all ticket supplies across all prize pools in this network

Return Values:

TypeDescription
struct IPrizeDistributionBuffer.PrizeDistributionPrizeDistribution using info from the Draw for the given draw id, total network ticket supply, and PrizeTier for the draw.

calculatePrizeDistributionWithDrawData

  function calculatePrizeDistributionWithDrawData(
uint32 _drawId,
uint256 _totalNetworkTicketSupply,
uint32 _beaconPeriodSeconds,
uint64 _drawTimestamp
) public returns (struct IPrizeDistributionBuffer.PrizeDistribution)

Calculates what the prize distribution will be, given a draw id and total network ticket supply.

Parameters:

NameTypeDescription
_drawIduint32The draw from which to use the Draw and
_totalNetworkTicketSupplyuint256The sum of all ticket supplies across all prize pools on the network
_beaconPeriodSecondsuint32The beacon period in seconds
_drawTimestampuint64The timestamp at which the draw RNG request started.

Return Values:

TypeDescription
struct IPrizeDistributionBuffer.PrizeDistributionA PrizeDistribution based on the given params and PrizeTier for the passed draw id

manager

  function manager(
) public returns (address)

Gets current _manager.

Return Values:

TypeDescription
addressCurrent _manager address.

setManager

  function setManager(
address _newManager
) external returns (bool)

Set or change of manager.

Throws if called by any account other than the owner.

Parameters:

NameTypeDescription
_newManageraddressNew _manager address.

Return Values:

TypeDescription
boolBoolean to indicate if the operation was successful or not.

owner

  function owner(
) public returns (address)

Returns the address of the current owner.

pendingOwner

  function pendingOwner(
) external returns (address)

Gets current _pendingOwner.

Return Values:

TypeDescription
addressCurrent _pendingOwner address.

renounceOwnership

  function renounceOwnership(
) external

Renounce ownership of the contract.

Leaves the contract without owner. It will not be possible to call onlyOwner functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.

transferOwnership

  function transferOwnership(
address _newOwner
) external

Allows current owner to set the _pendingOwner address.

Parameters:

NameTypeDescription
_newOwneraddressAddress to transfer ownership to.

claimOwnership

  function claimOwnership(
) external

Allows the _pendingOwner address to finalize the transfer.

This function is only callable by the _pendingOwner.

Events

PrizeDistributionPushed

  event PrizeDistributionPushed(
uint32 drawId,
uint256 totalNetworkTicketSupply
)

Emitted when a new Prize Distribution is pushed.

Parameters:

NameTypeDescription
drawIduint32The draw id for which the prize dist was pushed
totalNetworkTicketSupplyuint256The total network ticket supply that was used to compute the cardinality and portion of picks

PrizeDistributionSet

  event PrizeDistributionSet(
uint32 drawId,
uint256 totalNetworkTicketSupply
)

Emitted when a Prize Distribution is set (overrides another)

Parameters:

NameTypeDescription
drawIduint32The draw id for which the prize dist was set
totalNetworkTicketSupplyuint256The total network ticket supply that was used to compute the cardinality and portion of picks

ManagerTransferred

  event ManagerTransferred(
address previousManager,
address newManager
)

Emitted when _manager has been changed.

Parameters:

NameTypeDescription
previousManageraddressprevious _manager address.
newManageraddressnew _manager address.

OwnershipOffered

  event OwnershipOffered(
address pendingOwner
)

Emitted when _pendingOwner has been changed.

Parameters:

NameTypeDescription
pendingOwneraddressnew _pendingOwner address.

OwnershipTransferred

  event OwnershipTransferred(
address previousOwner,
address newOwner
)

Emitted when _owner has been changed.

Parameters:

NameTypeDescription
previousOwneraddressprevious _owner address.
newOwneraddressnew _owner address.