Blast Documentation
  • 👋We're blast!
  • 🎮Tournaments
    • 🧗Leaderboard
    • 🤼Brackets
    • 👩‍🔬Tournaments Configuration
  • ⚙️Backend Overview
  • 🥸Smart Contracts
    • 👉Official Resources
    • 👉Pool Factory V2
    • 👉Pool Factory V2.2 (Update Apr-23)
Powered by GitBook
On this page
  • Functions:
  • Events:
  • Function initialize()
  • Function createPool(uint256 _game, uint256 _gameMode, uint256 _currentPrize, uint256 _entryFee, uint256 _startOn, uint256 _finishOn, uint256 _firstFee, uint256 _secondFee, uint256 _thirdFee, address _tokenAddr) → uint256
  • Function joinPool(uint256 _poolId)
  • Function leavePool(uint256 _poolId)
  • Function viewPools(address _addr) → uint256[] _userPools
  • Function viewPoolPlayers(uint256 _poolId) → address payable[] _users
  • Function viewActivePools() → uint256[] _activePools
  • Function getTreasury() → address _treasury
  • Function finishPool(uint256 _poolId, address payable _winner1, address payable _winner2, address payable _winner3)
  • Function cancelPool(uint256 _poolId)
  • Function updateFee(uint256 _newFee)
  • Event NewPool(uint256 poolId, uint256 _game, uint256 _gameMode, uint256 _currentPrize, uint256 _entryFee, uint256 _startOn, uint256 _finishOn, uint256 _firstFee, uint256 _secondFee, uint256 _thirdFee, address _tokenAddr)
  • Event CancelPool(uint256 _poolId)
  • Event PoolLeftBy(uint256 _poolId, address _player)
  • Event PoolJoinedBy(uint256 _poolId, address _player)
  • Event PoolFinished(uint256 _poolId, address _winner)
  1. Smart Contracts

Pool Factory V2

Contract Code: https://github.com/0xBets/mvp/blob/upgradable-contracts/packages/hardhat/contracts/PoolFactoryV2.sol

Functions:

  • 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)

Events:

  • 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)

Function initialize()

Initializes pool count and bbFee

Function 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

Parameters:

  • _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

Return Values:

  • PoolId (uint256)

Function joinPool(uint256 _poolId)

Allows players to join a pool if the pool has an entry fee it should be equal to msg.value

Function leavePool(uint256 _poolId)

Allows players to leave the pool if they change their mind before it starts Already started pools can't be left

Function viewPools(address _addr) → uint256[] _userPools

View function to retrieve joined pools for a given player(address)

Parameters:

  • _addr: address of player

Function viewPoolPlayers(uint256 _poolId) → address payable[] _users

View function to retrieve players of a given pool

Parameters:

  • _poolId: pool id number

Return Values:

  • _users an array of players addresses

Function viewActivePools() → uint256[] _activePools

View function to retrieve current active Pools

Return Values:

  • _activePools an array of pool Ids

Function getTreasury() → address _treasury

View function to retrieve current treasury address

Function finishPool(uint256 _poolId, address payable _winner1, address payable _winner2, address payable _winner3)

Admin function to finish a pool

Parameters:

  • _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

Function 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

Parameters:

  • _poolId: id of the pool to finish

Function updateFee(uint256 _newFee)

Admin function to update protocol fee

Parameters:

  • _newFee: new fee to set

Event 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

Parameters:

  • 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

Event CancelPool(uint256 _poolId)

Event emitted on cancelled pool

Parameters:

  • _poolId: pool Id of cancelled pool

Event PoolLeftBy(uint256 _poolId, address _player)

Event emitted when a player leaves a pool

Parameters:

  • _player: player who leaves the pool

  • _poolId: pool Id

Event PoolJoinedBy(uint256 _poolId, address _player)

Event emitted when a player joins a pool

Parameters:

  • _player: player who joins the pool

  • _poolId: pool Id

Event PoolFinished(uint256 _poolId, address _winner)

Event emitted on a finished pool

Parameters:

  • _poolId: pool Id

  • _winner: winner of the pool tournament

PreviousOfficial ResourcesNextPool Factory V2.2 (Update Apr-23)

Last updated 2 years ago

🥸
👉