> For the complete documentation index, see [llms.txt](https://docs.sweep.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sweep.finance/system-architecture/on-chain-architecture.md).

# On-Chain Architecture

Every Sweep game round is **settled on BNB Chain**. Stakes, payouts, fees, rewards, referral commissions and burns are executed as real SWEEP transfers by the **SweepLedger** smart contract and recorded as permanent, sequenced on-chain events. Every balance change is recorded on-chain: each move is validated by the contract, carries a machine-readable memo of the round that produced it, and can be audited by anyone on BscScan.

| Fixed max supply                | Keyless vault contracts | Control                             |
| ------------------------------- | ----------------------- | ----------------------------------- |
| **999,666,333 SWEEP** (no mint) | **5**                   | **48 h timelock · 2-of-3 multisig** |

*Network: BNB Smart Chain (chain ID 56) · Compiler: solc 0.8.38 · Source: verified · Upgrades: none (immutable).*

### Contract addresses

| Contract                 | Address (BscScan)                                                                                                      | Role                                            |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
| **SweepToken (SWEEP)**   | [`0xb8d5d2a067f8d086dddd0e0ae00d0002b8ecbd24`](https://bscscan.com/token/0xb8d5d2a067f8d086dddd0e0ae00d0002b8ecbd24)   | BEP-20 token · fixed supply · burnable · permit |
| **SweepLedger**          | [`0xac7b04edcca4e9cb64118668e5a661dfbbda981f`](https://bscscan.com/address/0xac7b04edcca4e9cb64118668e5a661dfbbda981f) | Game settlement engine · route rules · burn cap |
| ↳ Users vault            | [`0xa5a3FD60847E90777F7C202B251547f5f2b4E1E1`](https://bscscan.com/address/0xa5a3FD60847E90777F7C202B251547f5f2b4E1E1) | Player balances                                 |
| ↳ Game vault             | [`0x2149c2Df97cd8951Ad7ace49d464458fF9112F6d`](https://bscscan.com/address/0x2149c2Df97cd8951Ad7ace49d464458fF9112F6d) | Active stakes and round pools                   |
| ↳ Reward vault           | [`0xE4AFf6D8f992FBe8d66FFb8D0caa63060b77975a`](https://bscscan.com/address/0xE4AFf6D8f992FBe8d66FFb8D0caa63060b77975a) | Holder reward epochs                            |
| ↳ Referral vault         | [`0x470Ac1641c5FeD465590e6fE36f0EE5f4576ee54`](https://bscscan.com/address/0x470Ac1641c5FeD465590e6fE36f0EE5f4576ee54) | Referral commission epochs                      |
| ↳ Burn vault             | [`0x3319c60198F1D968E3c9AED4b0d1DFbDACe32957`](https://bscscan.com/address/0x3319c60198F1D968E3c9AED4b0d1DFbDACe32957) | Burn queue → destroyed on-chain                 |
| **TimelockController**   | [`0xAC44543A4b71D59517598394d6cd5bF92512FE07`](https://bscscan.com/address/0xAC44543A4b71D59517598394d6cd5bF92512FE07) | Owner of both contracts · 48 h delay            |
| **Gnosis Safe (2-of-3)** | [`0x1552F4D50057B666d14F2aad07130FCdF8FdA092`](https://bscscan.com/address/0x1552F4D50057B666d14F2aad07130FCdF8FdA092) | Guardian · proposes to the timelock             |

### Settlement flow

<figure><img src="https://2078048527-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FubReRwyxoDsfk7ZuY2st%2Fuploads%2FTyFH7YT3nbgoOL3r1MOe%2Fsettlement-flow-transparent.png?alt=media&amp;token=e6c439da-7349-4e85-8a6a-30b1e56118fa" alt=""><figcaption></figcaption></figure>

SweepLedger holds five keyless vault contracts. Every balance is real SWEEP held by a vault, and every move between vaults is a real token transfer that anyone can see on BscScan. The contract only accepts these routes:

| From     | Allowed destinations                      |
| -------- | ----------------------------------------- |
| Users    | Game, Reward, Referral, Burn              |
| Game     | Users, Reward, Referral, Burn             |
| Reward   | Users                                     |
| Referral | Users                                     |
| Burn     | Users, Burned (destroyed, total supply ↓) |

### How a round settles

Game outcomes are computed off-chain from committed seeds; every settlement and payout is recorded on-chain.

1. **Commit.** Each round commits a `seed_hash`. The hash is written into every on-chain record of that round, binding the result to its seed for later verification.
2. **Settle.** The relayer submits a strictly sequenced batch to `moveBatch()`. The contract checks route, vault state, balance and reference uniqueness, then moves real SWEEP between vaults.
3. **Distribute.** Fees split by `fee_rate` into Reward, Referral and Burn. Epochs pay out to Users with a **Merkle root** of all recipients committed on-chain.
4. **Burn.** The burn share is destroyed with `ERC20Burnable.burn()`, permanently reducing total supply, within a rolling hourly cap enforced by the contract.

### Verified source: key excerpts

Taken from the verified source code (line breaks condensed for readability; `// ...` marks omitted lines). The full code is public on BscScan and Sourcify.

#### SweepToken.sol: fixed supply

```solidity
contract SweepToken is ERC20, ERC20Burnable, ERC20Pausable,
    ERC20Permit, Ownable2Step {
    uint256 public constant TOTAL_SUPPLY = 999_666_333e18;

    constructor(address treasury, address owner_,
        address guardian_) ERC20("SWEEP", "SWEEP")
        ERC20Permit("SWEEP") Ownable(owner_)
    {
        // ... zero-address checks, set guardian ...
        _mint(treasury, TOTAL_SUPPLY);  // the only mint, ever
    }
```

#### SweepLedger.sol: route whitelist

```solidity
/// Allowed routes as a bitmap, bit index = from * 8 + to.
uint256 internal constant ROUTES =
      (uint256(0x1E) << 0)   // Users:    0b0001_1110
    | (uint256(0x1D) << 8)   // Game:     0b0001_1101
    | (uint256(0x01) << 16)  // Reward:   0b0000_0001
    | (uint256(0x01) << 24)  // Referral: 0b0000_0001
    | (uint256(0x21) << 32); // Burn:     0b0010_0001

function isRouteAllowed(Vault from, Target to) public pure
    returns (bool) {
    return (ROUTES >> (uint256(from) * 8 + uint256(to))) & 1 == 1;
}
```

#### SweepLedger.sol: settlement and replay protection

```solidity
function moveBatch(uint64 firstSeq, Move[] calldata moves)
    external onlyRelayer
{
    uint256 n = moves.length;
    if (n == 0) revert EmptyBatch();
    uint64 seq = nextSeq;
    if (firstSeq != seq) revert WrongSeq(seq, firstSeq);
    nextSeq = seq + uint64(n);

    uint256 burnTotal = 0;
    bytes32 previous = bytes32(0);
    for (uint256 i; i < n; ++i) {
        Move calldata m = moves[i];
        if (m.to == Target.Burned) burnTotal += m.amount;
        if (m.ref == bytes32(0)) revert EmptyRef();
        if (m.ref != previous) {
            if (recorded[m.ref]) revert AlreadyRecorded(m.ref);
            recorded[m.ref] = true;
            previous = m.ref;
        }
    }
    if (burnTotal != 0) _consumeBurnCap(burnTotal);
    // ... per move: route, pause and balance checks, then
    //     emit Moved(seq, from, to, amount, kind, ref, data)
    if (toBurn != 0) _vaults[uint256(Vault.Burn)].burn(toBurn);
}
```

#### SweepLedger.sol: rolling burn cap

```solidity
function _consumeBurnCap(uint256 amount) internal {
    uint256 slot = block.timestamp / BURN_SLOT; // 5-min slots
    // ... drop slots that left the rolling 60-minute window ...
    uint256 cap = burnCapPerHour;
    if (used + amount > cap)
        revert BurnCapExceeded(cap, used, amount);
    _burnedInSlot[slot % BURN_SLOTS] += amount;
    _burnedInWindow = used + amount;
    _lastBurnSlot = slot;
}
```

#### On-chain memos (`Moved` event data, live on BNB Chain)

*Excerpts: selected memo fields are shown. Open the linked transaction for the full record.*

**Round settlement:** `Moved` · seq 3882 · Game → Users · 31.65106077 SWEEP · [view transaction](https://bscscan.com/tx/0x81633535cbd4804709dc57339f9c9facd36bff44aa7f147bf4625ea13e681f3e)

```json
{
  "game": "rugs",
  "fee_rate": 0.051,
  "usdt": "1.58",
  "player": "37096843542e4cbf",
  "seed_hash": "462c66d6f965041d96697013c8983c60723412845f402b2352b052f8c48ed073"
}
```

**Reward epoch settlement:** `Moved` · seq 17066 · Reward → Users · 10.27646636 SWEEP · [view transaction](https://bscscan.com/tx/0xb9065d0ee5b012c3f6ecc264bb19c13b92d205e21a1abba3097cf994307d3f72)

```json
{
  "epoch_end": "2026-11-09T02:00:00",
  "merkle_root": "0x9a0a6f9c8953b1a213eeed02f601f282846cb5b5039cf37ebabb0627e38d1155"
}
```

> **Provably fair, on the record**
>
> Each round commits a **seed hash** that is stamped into the on-chain memo of every move it settles, next to the game, player ID, fee rate and amounts. Players can open **previous rounds directly on the game page**, see the revealed seed and result, and match it against the `seed_hash` recorded on BNB Chain.

### Security by design

| Feature               | What it guarantees                                                                                                                                        |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Fixed supply**      | 999,666,333 SWEEP minted once at deployment. No mint function, no transfer tax.                                                                           |
| **Non-upgradeable**   | No proxy, no swappable code. Vaults are keyless: no owner, no other entry point.                                                                          |
| **48 h timelock**     | Admin actions go through an OpenZeppelin TimelockController with a 48-hour public delay.                                                                  |
| **2-of-3 multisig**   | A Gnosis Safe drives the timelock and acts as guardian. No single key controls Sweep.                                                                     |
| **Route whitelist**   | A compile-time bitmap fixes which vault-to-vault moves exist. Every other route reverts.                                                                  |
| **Rolling burn cap**  | Burns are limited by a rolling hourly burn cap, tracked in 5-minute slots.                                                                                |
| **Replay protection** | Strict sequence numbers and unique operation refs: nothing is recorded or paid twice.                                                                     |
| **Relayer limits**    | The relayer can only move funds along fixed routes, under an hourly burn cap, and each batch can be recorded only once.                                   |
| **Emergency stop**    | Pause exists only for security incidents and requires the 2-of-3 Safe. It halts movement but cannot move or seize funds; unpausing requires the timelock. |

### Verify it yourself

Vault balances change continuously as rounds settle and rewards are distributed.

> 1. **Open the ledger** on BscScan: [bscscan.com/address/0xac7b…981f](https://bscscan.com/address/0xac7b04edcca4e9cb64118668e5a661dfbbda981f#events) → *Events* → `Moved`.
> 2. **Decode the data field** of any event to read the round memo: game, player ID, fee rate, `seed_hash`.
> 3. **Check the rules** under *Read Contract*: `isRouteAllowed`, `burnCapPerHour`, `balances`, `recorded`.
> 4. **Track burns** on the [token](https://bscscan.com/token/0xb8d5d2a067f8d086dddd0e0ae00d0002b8ecbd24): `totalSupply()` vs. `TOTAL_SUPPLY` shows every SWEEP destroyed.
> 5. **Check a round**: open past rounds on the game page and match the seed against its on-chain `seed_hash`.
> 6. **Inspect governance**: `owner()` returns the 48 h timelock; `guardian()` returns the 2-of-3 Safe.
