Pool Factory V2
Last updated
Last updated
Contract Code:
initialize()
createPool(uint256 _game, uint256 _gameMode, uint256 _currentPrize, uint256 _entryFee, uint256 _startOn, uint256 _finishOn, uint256 _firstFee, uint256 _secondFee, uint256 _thirdFee, address _tokenAddr)
joinPool(uint256 _poolId)
leavePool(uint256 _poolId)
viewPools(address _addr)
viewPoolPlayers(uint256 _poolId)
viewActivePools()
getTreasury()
finishPool(uint256 _poolId, address payable _winner1, address payable _winner2, address payable _winner3)
cancelPool(uint256 _poolId)
updateFee(uint256 _newFee)
updateTreasury(address payable _newTreasury)
NewPool(uint256 poolId, uint256 _game, uint256 _gameMode, uint256 _currentPrize, uint256 _entryFee, uint256 _startOn, uint256 _finishOn, uint256 _firstFee, uint256 _secondFee, uint256 _thirdFee, address _tokenAddr)
CancelPool(uint256 _poolId)
PoolLeftBy(uint256 _poolId, address _player)
PoolJoinedBy(uint256 _poolId, address _player)
PoolFinished(uint256 _poolId, address _winner)
initialize()
Initializes pool count and bbFee
createPool(uint256 _game, uint256 _gameMode, uint256 _currentPrize, uint256 _entryFee, uint256 _startOn, uint256 _finishOn, uint256 _firstFee, uint256 _secondFee, uint256 _thirdFee, address _tokenAddr) → uint256
Creates a new Pool providing entryFee, CurrentPrize, start and finish times. The transaction value must be equal to initial pool prize. Prizes and fees are in uint256, start and finish times are Unix Epochs in miliseconds. Fees are uint expressed in percentages i.e. a value of 10 means 10% fee, the sum of the 3 fees must equal a 100
_game
: game Id
_gameMode
: game Mode Id
_currentPrize
: initial pool prize
_entryFee
: entry fee to join the pool
_startOn
: unix start epoch in ms
_finishOn
: unix finish epoch in ms
_firstFee
: percentage fee of 1st place
_secondFee
: percentage fee of 2nd place
_thirdFee
: percentage fee of 3d place
_tokenAddr
: token used for pool prize and fees, if tokenAddr is address(0), native coin will be used
PoolId (uint256)
joinPool(uint256 _poolId)
Allows players to join a pool if the pool has an entry fee it should be equal to msg.value
leavePool(uint256 _poolId)
Allows players to leave the pool if they change their mind before it starts Already started pools can't be left
viewPools(address _addr) → uint256[] _userPools
View function to retrieve joined pools for a given player(address)
_addr
: address of player
viewPoolPlayers(uint256 _poolId) → address payable[] _users
View function to retrieve players of a given pool
_poolId
: pool id number
_users an array of players addresses
viewActivePools() → uint256[] _activePools
View function to retrieve current active Pools
_activePools an array of pool Ids
getTreasury() → address _treasury
View function to retrieve current treasury address
finishPool(uint256 _poolId, address payable _winner1, address payable _winner2, address payable _winner3)
Admin function to finish a pool
_poolId
: id of the pool to finish
_winner1
: address of the first place
_winner2
: address of the second place
_winner3
: address of the third place
cancelPool(uint256 _poolId)
Admin function to cancel a pool it returns the entry fee to all the players who joined, and the prize pool to treasury
_poolId
: id of the pool to finish
updateFee(uint256 _newFee)
Admin function to update protocol fee
_newFee
: new fee to set
NewPool(uint256 poolId, uint256 _game, uint256 _gameMode, uint256 _currentPrize, uint256 _entryFee, uint256 _startOn, uint256 _finishOn, uint256 _firstFee, uint256 _secondFee, uint256 _thirdFee, address _tokenAddr)
Event emitted on new pool created
poolId
: pool Id
_game
: game Id
_gameMode
: game Mode Id
_currentPrize
: initial pool prize
_entryFee
: entry fee to join the pool
_startOn
: unix start epoch in ms
_finishOn
: unix finish epoch in ms
_firstFee
: percentage fee of 1st place
_secondFee
: percentage fee of 2nd place
_thirdFee
: percentage fee of 3d place
_tokenAddr
: address of token used for pool
CancelPool(uint256 _poolId)
Event emitted on cancelled pool
_poolId
: pool Id of cancelled pool
PoolLeftBy(uint256 _poolId, address _player)
Event emitted when a player leaves a pool
_player
: player who leaves the pool
_poolId
: pool Id
PoolJoinedBy(uint256 _poolId, address _player)
Event emitted when a player joins a pool
_player
: player who joins the pool
_poolId
: pool Id
PoolFinished(uint256 _poolId, address _winner)
Event emitted on a finished pool
_poolId
: pool Id
_winner
: winner of the pool tournament