# Detailed Explanation of the Fee System

## Overview

MemeDice adopts **a three-tier fee structure**to ensure the sustainable operation of the platform, game creators, and Oracle services. All fee parameters are determined at contract deployment, the platform fee rate cannot be modified, and the owner fee rate is protected by a hard-coded upper limit.

***

## Fee Structure Overview

```mermaid
graph TD
    A[Player bet amount] --> B{Fee allocation}
    B -->|Platform fee| C[Developer<br/>devWallet]
    B -->|Owner fee| D[Game owner]
    B -->|Oracle fee| E[Oracle service<br/>Oracle mode only]
    B -->|Net bet amount| F[Enters game logic]
    
    style C fill:#4F46E5,color:#fff
    style D fill:#7C3AED,color:#fff
    style E fill:#D97706,color:#fff
    style F fill:#059669,color:#fff
```

### Three-Tier Fees

| Tier       | Name                  | Recipient          | Modifiable           | Upper limit                   |
| ---------- | --------------------- | ------------------ | -------------------- | ----------------------------- |
| **Tier 1** | Platform fee (devFee) | dapp.meme platform | ❌ Immutable          | Determined at deployment (1%) |
| **Tier 2** | Owner fee (ownerFee)  | Game creator       | ✅ Adjustable (0%-9%) | 9% (hard-coded)               |
| **Tier 3** | Oracle fee            | Oracle service     | ❌ Immutable          | Very low                      |

***

## Detailed breakdown of fees by stage

### 1. Bet fee

Each time a player places a bet, fees are deducted from the bet amount:

```
Net bet amount = Bet amount - Platform bet fee - Owner bet fee
```

| Fee              | Calculation                        | Description                         |
| ---------------- | ---------------------------------- | ----------------------------------- |
| Platform bet fee | `betAmount × devBetFeeBps / 10000` | Immutable, determined at deployment |
| Owner bet fee    | `betAmount × ownerFeeBps / 10000`  | Adjustable, capped at 9%            |

**Example**: Assuming platform fee 1%, owner fee 2%, bet 100 USDT

```
Platform fee = 100 × 100 / 10000 = 1 USDT
Owner fee = 100 × 200 / 10000 = 2 USDT
Net bet amount = 100 - 1 - 2 = 97 USDT
```

### 2. Withdrawal fee

When shareholders withdraw their share, fees are deducted from the withdrawal amount:

```
Actual received = Withdrawal amount - Platform withdrawal fee - Owner withdrawal fee
```

| Fee                     | Calculation                                  | Description |
| ----------------------- | -------------------------------------------- | ----------- |
| Platform withdrawal fee | `withdrawAmount × devWithdrawFeeBps / 10000` | Immutable   |
| Owner withdrawal fee    | `withdrawAmount × ownerFeeBps / 10000`       | Adjustable  |

### 3. Oracle fee

When using Oracle mode, each bet requires an additional Oracle service fee (paid in the native token, such as ETH/BNB):

| Fee        | Payment method         | Description                   |
| ---------- | ---------------------- | ----------------------------- |
| Oracle fee | Native token (ETH/BNB) | Paid with `msg.value` payment |

Oracle fees are used to cover:

* Gas fees for Oracle random-number revelation
* Operating costs of the Oracle service
* Fees are extremely low and almost negligible

### 4. Deployment fee

When deploying a game, a deployment fee must be paid (in the native token):

```
Total deployment fee = Base deployment fee + Domain premium
```

| Fee                 | Description                                       |
| ------------------- | ------------------------------------------------- |
| Base deployment fee | Fixed fee charged by the platform                 |
| Domain premium      | Additional fee for short domains (3-4 characters) |

For detailed domain pricing, please refer to [Domain and Pricing](/dapp.meme-en/create-a-game/domains-and-pricing.md).

***

## Bonus calculation

When a player wins a bet, the bonus is calculated as follows:

```
Effective bet amount = Net bet amount (after fees)
Bonus = Effective bet amount × (10000 / winRateParam - 1)
Player receives = Effective bet amount + Bonus
```

### Calculation example

| Parameter         | Value                     |
| ----------------- | ------------------------- |
| Bet amount        | 100 USDT                  |
| Platform fee rate | 1%                        |
| Owner fee rate    | 2%                        |
| Win rate          | 50% (winRateParam = 5000) |

```
Platform fee = 100 × 1% = 1 USDT
Owner fee = 100 × 2% = 2 USDT
Effective bet amount = 100 - 1 - 2 = 97 USDT

Odds = 10000 / 5000 = 2.0x
Bonus = 97 × (2.0 - 1) = 97 USDT
Player receives = 97 + 97 = 194 USDT

Actual odds = 194 / 100 = 1.94x (lower than the theoretical odds of 2.0x; the difference is the fee)
```

***

## Fee flow diagram

```mermaid
graph TD
    subgraph Betting process
        A[Player bets 100] --> B[Platform fee 1]
        A --> C[Owner fee 2]
        A --> D[Net bet amount 97]
    end
    
    subgraph Results
        D --> E{Win/Lose?}
        E -->|Lose| F[97 enters the prize pool]
        E -->|Win| G[97 + bonus paid from the prize pool]
    end
    
    B --> H[Platform wallet]
    C --> I[Owner wallet]
    
    style H fill:#4F46E5,color:#fff
    style I fill:#7C3AED,color:#fff
    style F fill:#059669,color:#fff
```

***

## Fee protection mechanism

### Owner fee rate cap

```
MAX_FEE_BPS = 900 (i.e. 9%)
```

The contract hard-codes the owner fee rate cap at 9%, so even if an administrator acts maliciously, this limit cannot be exceeded.

### Platform fee rate is immutable

Platform fee rate (`devBetFeeBps`,`devDepositFeeBps`,`devWithdrawFeeBps`) is an **immutable variable**in the contract, determined at deployment and never modifiable afterward.

### Transparent fee changes

Every change to the owner fee rate generates an on-chain event and is recorded in [on-chain logs](/dapp.meme-en/leaderboard-and-logs/on-chain-logs-and-game-transparency.md) for anyone to inspect.

***

## Fee comparison table

Using different fee configurations as examples, the fee allocation for a 100 USDT bet is shown below:

| Configuration     | Platform fee | Owner fee | Net bet amount | Odds at 50% win rate |
| ----------------- | ------------ | --------- | -------------- | -------------------- |
| Low fee rate      | 0.5%         | 0%        | 99.5           | 1.99x                |
| Standard fee rate | 1%           | 2%        | 97             | 1.94x                |
| High fee rate     | 1%           | 5%        | 94             | 1.88x                |
| Maximum fee rate  | 1%           | 9%        | 90             | 1.80x                |

> 💡 The lower the fee rate, the closer the player's actual odds are to the theoretical odds, and the more favorable the game is to players.

***

## Related links

* ⬅️ Back [Technical deep overview](/dapp.meme-en/technical-overview/technical-deep-dive-overview.md)
* 🏗️ Learn about [smart contract architecture](/dapp.meme-en/technical-overview/smart-contract-architecture.md)
* ⚙️ Learn about [game management](/dapp.meme-en/manage-games/game-management-overview.md)(fee adjustments)
* 💰 Learn about [investment and shareholding](/dapp.meme-en/provide-liquidity-lp/game-participation-guide.md)(deposit/withdrawal fees)


---

# 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://docs.dapp.meme/dapp.meme-en/technical-overview/detailed-explanation-of-the-fee-system.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.
