> For the complete documentation index, see [llms.txt](https://perfectpool.gitbook.io/perfect-pool/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://perfectpool.gitbook.io/perfect-pool/game-contracts/ace-the-brackets8.md).

# Ace the Brackets8

#### Base Sepolia Contract:

<https://sepolia.basescan.org/address/0x9e63ed2acbe3e76e77774f74db51e3c9ff383efa>

#### Base Contract:

<https://basescan.org/address/0x28B527CD5Ea34A7a906D005461D54F5e234B4F3B>

### **Events**

* **UpdatePerformed**: Emitted when upkeep is performed
  * `lastTimeStamp`: `uint256`
* **GameCreated**: Emitted when a new game is created
  * `gameIndex`: `uint256`
* **GameActivated**: Emitted when a game is activated

`gameIndex`: `uint256`

* **GameAdvanced**: Emitted when a game advances to the next round
  * `gameIndex`: `uint256`
  * `round`: `uint8`
* **GameFinished**: Emitted when a game finishes
  * `gameIndex`: `uint256`
  * `result`: `bytes32`
* **DaysToClaimPrizeChanged**: Emitted when days to claim prize is changed
  * `daysToClaimPrize`: `uint8`
* **Paused**: Emitted when pause state is changed
  * `paused`: `bool`
* **PriceFeedAdded**: Emitted when a new token price feed is added to the contract
  * `tokenIndex`: `uint256`

### Constants

* **MIN\_ACTIVE\_TOKENS**: `uint8 public`
  * Minimum number of active tokens

### State Variables

* **gamesHub**: `IGamesHub public`
  * The games hub contract that manages roles and games
* **games**: `mapping(uint256 => Game) public`
  * Mapping from game index to game struct
* **tokens**: `mapping(uint256 => Token) public`
  * Mapping from token index to token struct
* **totalGames**: `uint8 public`
  * Total number of games created
* **daysToClaimPrize**: `uint8 public`
  * Number of days games remain claimable
* **updateActivated**: `bool public`
  * Toggle for enabling/disabling automated updates
* **createNewGames**: `bool public`
  * Toggle for enabling/disabling new game creation
* **lastTimeStamp**: `uint256 public`
  * Timestamp of last update
* **executionAddress**: `address public`
  * Chainlink Automation compatible forwarder address
* **paused**: `bool public`
  * Check if contract is paused
* **minActiveGames**: `uint8 public`
  * Minimum number of active games

### Structs

#### Round

* `tokens`: `uint256[8]`
* `pricesStart`: `uint256[8]`
* `pricesEnd`: `uint256[8]`
* `start`: `uint256`
* `end`: `uint256`

#### Game

* `rounds`: `Round[3]`
* `currentRound`: `uint8`
* `winner`: `uint256`
* `finalPrice`: `uint256`
* `activated`: `bool`
* `start`: `uint256`
* `end`: `uint256`

### Modifiers

* `onlyAdministrator`: Restrict access to admin roles
* `onlyExecutor`: Restrict access to Tenderly executor address
* `gameOutOfIndex(uint256 gameIndex)`: Check if the gameIndex is out of bounds

### Functions

#### Constructor

* Description: Initializes contract parameters
* Arguments:
  * `gamesHubAddress`: `address`
  * `minActiveGames`: `uint8`
  * `forwarderAddress`: `address`

#### performGames

* Description: Tenderly Automation function to perform updates. If contract is paused, it will not run.
* Arguments:
  * `_dataNewGame`: `bytes calldata`
  * `_dataUpdate`: `bytes calldata`
  * `_lastTimestamp`: `uint256`

#### setPaused

* Description: Function to pause / unpause the contract
* Arguments:
  * `paused`: `bool`
* Modifiers:
  * `onlyAdministrator`: Restrict access

#### setExecutionAddress

* Description: Set Tenderly execution address
* Arguments:
  * `_executionAddress`: `address`
* Modifiers:
  * `onlyAdministrator`: Restrict access

#### setCreateNewGames

* Description: Enable/disable new game creation
* Arguments:
  * `_active`: `bool`
* Modifiers:
  * `onlyAdministrator`: Restrict access

#### setMinConcurrentGames

* Description: Function to set the minimum number of concurrent games.
* Arguments:
  * `_minActiveGames`: `uint8` The new minimum number of concurrent games.
* Modifiers:
  * `onlyAdministrator`: Restrict access to admin roles.

#### changeDaysToClaimPrize

* Description: Change number of days games remain claimable
* Arguments:
  * `_daysToClaimPrize`: `uint8`

#### getFinalResult

* Description: Get final bracket result for a game
* Arguments:
  * `gameIndex`: `uint256`
* Returns:
  * `brackets`: `uint256[7] memory`

#### getGameStatus

* Description: Get current status of a game. 0: not started, 1-3: round numbers, 4: finished
* Arguments:
  * `gameIndex`: `uint256`
* Returns:
  * `status`: `uint8`

#### **getRoundFullData**

* Description: Get all data for a round.
* Arguments:
  * `gameIndex`: `uint256`
* Returns:
  * `gameData`: `bytes memory`
    * Encoded as:
      * `symbols1`: `string[8]` Token symbols
      * `pricesStart1`: `uint256[8]` Token pricesStart
      * `pricesEnd1`: `uint256[8]` Token pricesEnd
      * `start`: `uint256` Start timestamp in seconds
      * `end`: `uint256` End timestamp in seconds

#### **getGameFullData**

* Description: Get all data for a game. If currentRound is 0 and start prices are 0, the game is not activated
* Arguments:
  * `gameIndex`: `uint256`
* Returns:
  * `gameData`: `bytes memory`
    * Encoded as:
      * `round1`: `bytes` Round 1 getRoundFullData bytes encoded
      * `round2`: `bytes` Round 2 getRoundFullData bytes encoded
      * `round3`: `bytes` Round 3 getRoundFullData bytes encoded
      * `winner`: `string` Winning token symbol
      * `finalPrice`: `uint256` Final price of winner
      * `currentRound`: `uint8` 0-2: rounds 1-3, 3: finished
      * `start`: `uint256` Start timestamp in seconds
      * `end`: `uint256` End timestamp in seconds
      * `activated`: `bool` True: Active | False: Inactive

#### getRoundData

* Description: Get token IDs and prices for a specific round
* Arguments:
  * `gameIndex`: `uint256`
  * `round`: `uint8`
* Returns:
  * `tokens`: `uint256[8] memory`
  * `prices`: `uint256[8] memory`

#### getActiveGames

* Description: Get array of active game indexes
* Returns:
  * `activeGames`: `uint256[] memory`

#### getTokenSymbol

* Description: Get symbol for a token
* Arguments:
  * `tokenIndex`: `uint256`
* Returns:
  * `symbol`: `string memory`

#### getTokenId

* Description: Get symbol for a token
* Arguments:
  * `symbol`: `string memory`
* Returns:
  * `tokenIndex`: `uint256`

#### getTokensIds

* Description: Get the ids for an array of token symbols
* Arguments:
  * `_symbols`: `bytes memory` Encoded string\[8] array
* Returns:
  * `_tokens`: `uint256[8] memory`

#### getTokensIds

* Description: Get the ids for an array of token symbols
* Arguments:
  * `_tokens`: `bytes memory` Encoded uint256\[8] array
* Returns:
  * `_symbols`: `string[8] memory`

#### **getActiveGamesActualCoins**

* Description: Get symbols and start prices for all active games
* Returns:
  * `_activeGamesActualCoins`: `bytes[4] memory`
    * Each array item encoded as:
      * `gameId`: `uint256`
      * `symbols`: `string[8]`
      * `pricesStart`: `uint256[8]`
