Skip to main content
Version: V4

DrawCalculatorTimelock

OracleTimelock(s) acts as an intermediary between multiple V4 smart contracts. The OracleTimelock is responsible for pushing Draws to a DrawBuffer and routing claim requests from a PrizeDistributor to a DrawCalculator. The primary objective is to include a "cooldown" period for all new Draws. Allowing the correction of a maliciously set Draw in the unfortunate event an Owner is compromised.

Structs

Timelock

  • uint64 timestamp
  • uint32 drawId

Functions

constructor

  function constructor(
address _owner,
contract IDrawCalculator _calculator
) public

Initialize DrawCalculatorTimelockTrigger smart contract.

Parameters:

NameTypeDescription
_owneraddressAddress of the DrawCalculator owner.
_calculatorcontract IDrawCalculatorDrawCalculator address.

calculate

  function calculate(
address user,
uint32[] drawIds,
bytes data
) external returns (uint256[], bytes)

Routes claim/calculate requests between PrizeDistributor and DrawCalculator.

Will enforce a "cooldown" period between when a Draw is pushed and when users can start to claim prizes.

Parameters:

NameTypeDescription
useraddressUser address
drawIdsuint32[]Draw.drawId
databytesEncoded pick indices

Return Values:

TypeDescription
uint256[]Prizes awardable array

lock

  function lock(
uint32 _drawId,
uint64 _timestamp
) external returns (bool)

Lock passed draw id for timelockDuration seconds.

Restricts new draws by forcing a push timelock.

Parameters:

NameTypeDescription
_drawIduint32Draw id to lock.
_timestampuint64Epoch timestamp to unlock the draw.

Return Values:

TypeDescription
boolTrue if operation was successful.

getDrawCalculator

  function getDrawCalculator(
) external returns (contract IDrawCalculator)

Read internal DrawCalculator variable.

getTimelock

  function getTimelock(
) external returns (struct IDrawCalculatorTimelock.Timelock)

Read internal Timelock struct.

setTimelock

  function setTimelock(
struct IDrawCalculatorTimelock.Timelock _timelock
) external

Set the Timelock struct. Only callable by the contract owner.

Parameters:

NameTypeDescription
_timelockstruct IDrawCalculatorTimelock.TimelockTimelock struct to set.

hasElapsed

  function hasElapsed(
) external returns (bool)

Returns bool for timelockDuration elapsing.

Return Values:

TypeDescription
boolTrue if timelockDuration, since last timelock has elapsed, false otherwise.

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

Deployed

  event Deployed(
contract IDrawCalculator drawCalculator
)

Deployed event when the constructor is called

Parameters:

NameTypeDescription
drawCalculatorcontract IDrawCalculatorDrawCalculator address bound to this timelock

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.

LockedDraw

  event LockedDraw(
uint32 drawId,
uint64 timestamp
)

Emitted when target draw id is locked.

Parameters:

NameTypeDescription
drawIduint32Draw ID
timestampuint64Block timestamp

TimelockSet

  event TimelockSet(
struct IDrawCalculatorTimelock.Timelock timelock
)

Emitted event when the timelock struct is updated

Parameters:

NameTypeDescription
timelockstruct IDrawCalculatorTimelock.TimelockTimelock struct set