OnchainMadness Entry
Factory contract for creating and managing OnchainMadnessEntry pools. Uses the Clones pattern to deploy minimal proxy contracts for each pool, providing efficient pool management and ticket operations.
Base Testnet: https://sepolia.basescan.org/address/0x464D768D972758f8F616d2f6c8E17691245a5C41
Events
EntryPoolCreated: Emitted when a new entry pool is created
poolId
:uint256
- ID of the created poolpoolAddress
:address
- Address of the created poolpoolName
:string
- Name of the created pool
ContinueIteration: Emitted when the iteration needs to be continued
year
:uint256
- Tournament year being iterated
IterationFinished: Emitted when an iteration is completed for a year
year
:uint256
- Tournament year that finished iteration
ContinueBurnIteration: Emitted when a burn iteration needs to be continued
year
:uint256
- Tournament year being iterated
BurnFinished: Emitted when a burn iteration is completed for a year
year
:uint256
- Tournament year that finished burn iteration
ContinueDismissIteration: Emitted when a dismiss iteration needs to be continued
year
:uint256
- Tournament year being iterated
DismissIterationFinished: Emitted when a dismiss iteration is completed for a year
year
:uint256
- Tournament year that finished dismiss iteration
PrizeClaimed: Emitted when a prize is claimed for a token
_tokenId
:uint256
- ID of the token claiming prize_poolId
:uint256
- ID of the pool
BetPlaced: Emitted when a bet is placed
gameYear
:uint256
- Year of the tournamentpoolId
:uint256
- ID of the pooltokenId
:uint256
- ID of the minted tokenplayer
:address
- Address of the player placing the bet
GamePotIncreased: Emitted when the game pot is increased
_gameYear
:uint256
- Year of the tournament_amount
:uint256
- Amount added to the pot
GameDeployerChanged: Emitted when the game deployer is changed
_gameDeployer
:address
- New game deployer address
Constants
PPS_BURN_DELAY:
uint256 public
- Time after tournament to start burning PPS tokens (30 days)
State Variables
pools:
mapping(uint256 => address) public
- Mapping of pool IDs to pool addressesyearToPoolIdIteration:
mapping(uint256 => uint256) public
- Mapping of years to their corresponding pool ID iterationsyearToPoolIdBurnIteration:
mapping(uint256 => uint256) public
- Mapping of years to their corresponding pool ID burn iterationsyearToPoolIdDismissIteration:
mapping(uint256 => uint256) public
- Mapping of years to their corresponding pool ID dismiss iterationsonchainMadnessContracts:
mapping(address => bool) public
- Mapping to track valid OnchainMadness contract addressespoolNames:
mapping(bytes32 => bool) public
- Mapping to block duplication of pool namesyearToPPSBurned:
mapping(uint256 => bool) public
- Mapping to check if the PPS tokens have already been burned for a yearyearToPPSBurnDate:
mapping(uint256 => uint256) public
- Mapping to check the date to burn PPS tokensyearToPrizeDismissed:
mapping(uint256 => bool) public
- Mapping to check if the prizes have already been dismissed for a yearimplementation:
address public immutable
- Address of the implementation contract for cloninggameDeployer:
IOnchainMadnessFactory public
- Reference to the game factory contractUSDC:
IERC20 public
- Reference to the USDC token contract
Modifiers
onlyAdmin()
: Checks if the caller is the contract owner
Functions
Constructor
Description: Initializes the factory with the implementation contract address
Arguments:
_implementation
:address
- Address of the implementation contract_gameDeployer
:address
- Address of the game deployer contract_token
:address
- Address of the USDC token contract
setGameDeployer
Description: Sets the game deployer contract
Arguments:
_gameDeployer
:address
- Address of the game deployer contract
Modifiers:
onlyAdmin
: Only admin can call this function
createPool
Description: Creates a new OnchainMadnessEntry pool using the clone pattern
Arguments:
_isProtocolPool
:bool
- Whether this is a protocol pool_isPrivatePool
:bool
- Whether this is a private pool_pin
:string
- Pin for private pools_poolName
:string
- The name of the pool (15 chars maximum)
Returns:
uint256
- The ID of the newly created poolModifiers:
whenNotPaused
: Only when contract is not pausednonReentrant
: Prevents reentrancy
claimPPShare
Description: Claims PerfectPool tokens earned from shares
Arguments:
_player
:address
- Address to receive the tokens_gameYear
:uint256
- Tournament year to check
verifyShares
Description: Verifies the shares for a player
Arguments:
_player
:address
- Address to check_gameYear
:uint256
- Tournament year to check
Returns:
uint256
- Amount of PP tokens available for the player
safeMint
Description: Mints a new NFT representing a bracket prediction
Arguments:
_poolId
:uint256
- ID of the pool_gameYear
:uint256
- Tournament yearbets
:uint8[63]
- Array of 63 predictions for the tournament_pin
:string
- PIN for private pools
Modifiers:
whenNotPaused
: Only when contract is not pausednonReentrant
: Prevents reentrancy
iterateYearTokens
Description: Iterates through NFTs across all pools for a given year
Arguments:
_gameYear
:uint256
- The year to iterate
Modifiers:
whenNotPaused
: Only when contract is not pausednonReentrant
: Prevents reentrancy
needsToBeBurned
Description: Checks if the tokens need to be burned
Arguments:
_gameYear
:uint256
- The year to check
Returns:
bool
- True if the tokens need to be burned, false otherwise
burnYearTokens
Description: Iterates through the pools to burn PPS tokens for a given year
Arguments:
_gameYear
:uint256
- The year to iterate
Modifiers:
whenNotPaused
: Only when contract is not pausednonReentrant
: Prevents reentrancy
needsToBeDismissed
Description: Checks if the prize can be dismissed
Arguments:
_gameYear
:uint256
- The year to check
Returns:
bool
- True if the prize can be dismissed, false otherwise
iterateDismissYear
Description: Iterates through the pools to dismiss prizes for a given year
Arguments:
_gameYear
:uint256
- The year to iterate
Modifiers:
whenNotPaused
: Only when contract is not pausednonReentrant
: Prevents reentrancy
claimPrize
Description: Claims prize for a winning bracket
Arguments:
_poolId
:uint256
- ID of the pool_tokenId
:uint256
- Token ID representing the bracket
Modifiers:
whenNotPaused
: Only when contract is not pausednonReentrant
: Prevents reentrancy
claimAll
Description: Claims prize for multiple tokenIds at the same pool
Arguments:
_poolId
:uint256
- ID of the pool_tokenIds
:uint256[]
- Token IDs representing the brackets
Modifiers:
whenNotPaused
: Only when contract is not pausednonReentrant
: Prevents reentrancy
increaseGamePot
Description: Increases the prize pool for a specific game
Arguments:
_poolId
:uint256
- ID of the pool_gameYear
:uint256
- Tournament year to increase pot for_amount
:uint256
- Amount of USDC to add to the pot
Modifiers:
whenNotPaused
: Only when contract is not pausednonReentrant
: Prevents reentrancy
tokenURI
Description: Returns the token URI for a given NFT
Arguments:
_poolId
:uint256
- ID of the pool_tokenId
:uint256
- ID of the NFT
Returns:
string
- The token URI
getPoolAddress
Description: Returns the pool address for a given pool ID
Arguments:
_poolId
:uint256
- ID of the pool
Returns:
address
- The pool address
getTotalPools
Description: Returns the total number of pools created
Returns:
uint256
- The total number of pools
getBetData
Description: Returns the bet data for a given NFT
Arguments:
_poolId
:uint256
- ID of the pool_tokenId
:uint256
- ID of the NFT
Returns:
uint8[63]
- Array of bet predictions
getGameYear
Description: Returns the game year for a given NFT
Arguments:
_poolId
:uint256
- ID of the pool_tokenId
:uint256
- ID of the NFT
Returns:
uint256
- The game year
betValidator
Description: Validates a bracket prediction and returns its score
Arguments:
_poolId
:uint256
- ID of the pool_tokenId
:uint256
- Token ID of the bracket to validate
Returns:
validator
:uint8[63]
- Array indicating correct/incorrect predictionspoints
:uint8
- Total score achieved
getTeamSymbols
Description: Returns the team symbols for a given NFT
Arguments:
_poolId
:uint256
- ID of the pool_tokenId
:uint256
- ID of the NFT
Returns:
string[63]
- Array of team symbols
amountPrizeClaimed
Description: Returns the amount of prize claimed for a bracket
Arguments:
_poolId
:uint256
- ID of the pool_tokenId
:uint256
- Token ID of the bracket
Returns:
amountToClaim
:uint256
- Amount of USDC that can be claimedamountClaimed
:uint256
- Amount of USDC already claimed
potentialPayout
Description: Returns the potential payout for a game year
Arguments:
_poolId
:uint256
- ID of the poolgameYear
:uint256
- Tournament year to check
Returns:
uint256
- Maximum potential payout in USDC
playerQuantity
Description: Returns the number of players for a game year
Arguments:
_poolId
:uint256
- ID of the poolgameYear
:uint256
- Tournament year to check
Returns:
uint256
- Number of players participating
getPoolId
Description: Returns the pool ID for a given pool address
Arguments:
_poolAddress
:address
- The pool address
Returns:
uint256
- The pool ID
getPoolData
Description: Returns the created pool data
Arguments:
poolId
:uint256
- The ID of the pool
Returns:
name
:string
- The name of the poolpoolAddress
:address
- The pool contract addressisPrivate
:bool
- Whether the pool is privateisProtocol
:bool
- Whether the pool is created by the protocolpin
:bytes
- The PIN required to join the poolcreator
:address
- The address of the creator of the pool
getGameDeployer
Description: Returns the address of the game deployer contract
Returns:
address
- The game deployer address
poolNameExists
Description: Returns if the pool name exists
Arguments:
_poolName
:string
- The name of the pool
Returns:
bool
- Whether the pool name exists
pause
Description: Pauses the contract
Modifiers:
onlyAdmin
: Only admin can call this function
unpause
Description: Unpauses the contract
Modifiers:
onlyAdmin
: Only admin can call this function
Last updated
Was this helpful?