> For the complete documentation index, see [llms.txt](https://betfin.gitbook.io/betfin-public/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://betfin.gitbook.io/betfin-public/smartcontracts-description/contracts-overview.md).

# Contracts Overview

The protocol utilizes a modular hub-and-spoke architecture. The Core contract serves as the central hub, providing fundamental safety and routing guarantees for all parties interacting with the liquidity pool, members, affiliates, or games.

### Module Architecture and Roles

<table><thead><tr><th width="130.8125">Module</th><th width="334.14453125">V2 Purpose</th><th>Role in Hub-and-Spoke</th></tr></thead><tbody><tr><td>Core</td><td>Central router for all bets, deposits, and fee distributions.</td><td><br>The Hub</td></tr><tr><td>Gateway</td><td>Swaps any ERC20 (USDT, WBTC) to native tokens via Uniswap in one transaction.</td><td>Spoke</td></tr><tr><td>Liquidity Pool</td><td>O(1) gas-efficient pool with cumulative per-share accounting.</td><td>Spoke</td></tr><tr><td>Pass</td><td>Soulbound NFT membership card required for all protocol access.</td><td>Spoke</td></tr><tr><td>Affiliate</td><td>Manages bonus distribution, referral trees, and daily claim limits.</td><td>Spoke</td></tr><tr><td>DAO</td><td>Sole authoritative venue for on-chain governance and voting power.</td><td>Spoke</td></tr><tr><td>Game Templates</td><td>Standardized logic for House, PvP, Lottery, and Mirror games.</td><td>Spoke</td></tr></tbody></table>

| **Contract Name**           | **Purpose**                                                        | **Dependencies**                                                                 |
| --------------------------- | ------------------------------------------------------------------ | -------------------------------------------------------------------------------- |
| **Token**                   | Implements the ERC20 token.                                        | -                                                                                |
| **Timelock**                | Implements time-based access control for contract functions.       | -                                                                                |
| **Tariff**                  | Manages tariff plans and fee structures.                           | Core                                                                             |
| **Pass**                    | Implements ERC721 token with affiliate system and minting logic.   | ERC721, AffiliateMember                                                          |
| **Partner**                 | Allows partners to place bets and stake funds.                     | ERC20                                                                            |
| **Multisend**               | Allows bulk sending of ERC20 tokens.                               | ERC20                                                                            |
| **Multimint**               | Allows bulk minting of Pass tokens.                                | Pass                                                                             |
| **Metadata**                | Allows members to set metadata.                                    | Pass                                                                             |
| **Helper**                  | Contains helper functions for profit calculation and distribution. | -                                                                                |
| **GameInterface**           | Defines the interface for game contracts.                          | -                                                                                |
| **CoreInterface**           | Defines the interface for the core contract.                       | -                                                                                |
| **Core**                    | Implements core logic for game management, staking, and tariffs.   | ERC20, StakingInterface, GameInterface, Tariff, Timelock, AffiliateInterface     |
| **Common**                  | Contains common data structures.                                   | -                                                                                |
| **BetsMemory**              | Manages bets and statistics.                                       | Core                                                                             |
| **AffiliateFund**           | Manages the affiliate fund.                                        | ERC20                                                                            |
| **Affiliate**               | Implements affiliate logic.                                        | AccessControl, AffiliateInterface                                                |
| **ConservativeStaking**     | Conservative staking with pools.                                   | StakingInterface, AccessControl, ReentrancyGuard, Pass, ConservativeStakingPool  |
| **DynamicStaking**          | Dynamic staking with pools.                                        | StakingInterface, AccessControl, ReentrancyGuard, Pass, Core                     |
| **ConservativeStakingPool** | Pool for conservative staking.                                     | AccessControl, ReentrancyGuard                                                   |
| **DynamicStakingPool**      | Pool for dynamic staking.                                          | AccessControl, ReentrancyGuard                                                   |
| **StakingInterface**        | Interface for staking contracts.                                   | -                                                                                |
| **Vesting**                 | Manages token vesting.                                             | ERC20, Ownable                                                                   |
| **Roulette**                | Game contract for roulette.                                        | VRFCoordinatorV2Interface, AccessControl, VRFConsumerBaseV2, GameInterface, Core |
| **RouletteBet**             | Manages individual roulette bets.                                  | Ownable, BetInterface                                                            |
| **Predict**                 | Manages prediction games.                                          | AccessControl, GameInterface, CoreInterface, PredictGame                         |
| **PredictGame**             | Game contract for prediction games.                                | Ownable, Predict, ERC20, AggregatorV3Interface                                   |
| **PredictBet**              | Manages individual prediction bets.                                | Ownable, BetInterface, Common                                                    |
| **DataFeed**                | Manages and updates data from Chainlink.                           | AggregatorV3Interface                                                            |
| **DataFeedTest**            | Test version of DataFeed                                           | DataFeed                                                                         |
| **AffiliateMember**         | Manages affiliate members.                                         | AccessControl                                                                    |
| **Lottery**                 | Game contract for lottery LUCKY ROUND.                             | VRFCoordinatorV2Interface, AccessControl, VRFConsumerBaseV2, GameInterface, Core |
| **LotteryBet**              | Manages individual lottery bets.                                   | Ownable, BetInterface                                                            |
| **AffiliateInterface**      | Interface for affiliate logic.                                     | -                                                                                |

This table summarizes each contract's purpose and its dependencies, providing an overview of the project structure and functionality.
