# Core

## Overview

In the hub-and-spoke model, Core routes tokens between players and games, enforces membership gating via the Pass NFT, and manages the registry of approved liquidity pools and games.

## Contract Address

The contract is deployed at: [0xBf87898C4e609598a393cCD765482BeF80000000](https://polygonscan.com/address/0xBf87898C4e609598a393cCD765482BeF80000000)

## Contract Structure

The contract is structured into different sections corresponding to the management of tariffs, partners, games, stakings, and betting operations.

### Key Operations

* **Bet Routing:** Automatically calculates and distributes fees (partner, manager, and pool) atomically during the betting process.
* **Liquidity Deposits**: Validates membership and routes provider tokens to the registered Liquidity Pool to mint position NFTs.
* **Membership Gating:** Every transaction is validated against the Pass NFT to ensure only authorized members access the protocol.
* **Transient Storage**: Uses EIP-1153 to securely communicate the original caller's identity between Gateways and game contracts during a transaction.
* **Fee Immutability**: Once a game is registered via `connectGame`, its house edge (RTP) or fee percentage is permanently frozen and cannot be changed.

<br>

### Tariffs

**`addTariff`**: Allows the addition of new tariffs with specified pricing, profit, and stake profit parameters.

**`removeTariff`**: Allows the removal of existing tariffs.

**`getTariffs`**: Retrieves a list of all tariffs.

### Partners

**`addPartner`**  Enables partners to register with the system by linking to existing tariffs and making payments.

`getPartners`  Retrieves a list of all registered partners.

### Games

**`addGame`**: Permits the addition of new games with version validation.

**`getGames`**: Retrieves a list of all registered games.

**`isGame`**: Checks if a given address corresponds to a registered game.

**`removeGame`**: Allows the removal of existing games.

### Stakings

**`addStaking`**: Allows the addition of new stakings with address validation.

**`getStakings`**: Retrieves a list of all registered stakings.

**`isStaking`**: Checks if a given address corresponds to a registered staking.

**`removeStaking`**: Allows the removal of existing stakings.

### Betting Operations

**`placeBet`**: Enables partners to place bets on behalf of players, with fee calculations and bet creation.

**`stake`**: Enables partners to stake tokens on behalf of players, with profit distribution.

### Error Codes

The contract defines various error codes to indicate specific error conditions encountered during contract execution. These error codes are documented within the contract code and serve as a reference for developers integrating with the contract.

### Roles

The contract utilizes AccessControl from OpenZeppelin for role-based access control. The roles defined include `PARTNER` and `TIMELOCK`. These roles control access to critical functions within the contract.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://betfin.gitbook.io/betfin-public/smartcontracts-description/core.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
