# Contracts

This launch is on Flap. `MicroTapeTreasury` buys miners and deposits mined `$BEM` into the Flap Dividend. Thesis and identities: [Overview](/). This page is for verification: addresses and interfaces. The 5% tax, after Flap's fee, goes to the treasury. `dividendBps` is 0.

The factory, the treasury, and the Flap token are not deployed to BNB Chain mainnet. Addresses land here after deploy.

The kit-buying script is `contracts/scripts/kit-executor.mjs`. The launch script is `contracts/script/DeployFlap.s.sol`. Sources: `MicroTapeTreasury.sol`, `MicroTapeFactory.sol`.

## This launch

| Contract | Address |
|---|---|
| Flap Portal | `0xe2cE6ab80874Fa9Fa2aAE65D277Dd6B8e65C9De0` |
| MicroTapeFactory | Not deployed |
| MicroTapeTreasury | Not deployed |
| `$MTAPE` | Not deployed |
| Flap Dividend | Created with the token. Not deployed |

## Already on BNB Chain

| Contract | Address |
|---|---|
| PodMining | `0x7E2E0DC66a3bD9103E69b766afA62d9f7b697b46` |
| `$BEM` | `0x5ce033B2bFCa3Af30b3e8C8457DeaF776A8b695a` |
| TapeOut | `0xb1024b89886B9a34Aa4ff5F31C411D708b20a14C` |
| Behemoth | `0x1F5Cb4aeaE1807Bf60c3b9C0D8aDBCC14e91f12C` |
| Firsto V2 | `0x5cebB870dEdC02a709CE7e8416B1b83F3946F572` |
| Gates | `0xCC42ba5De07f01B472a5b14cF45aBcCA79Eb8087` |
| Pancake V2 | `0x10ED43C718714eb63d5aA57B78B54704E256024E` |

## Launch

`DeployFlap` deploys the factory and the treasury, locks a `7777` salt, calls Portal `newTokenV6`, and binds the token. `TOKEN_META` is the IPFS profile URI. It does not set tax or the beneficiary.

| Parameter | Value |
|---|---|
| Tax | 5% buy and sell, 99 years |
| Split | `mktBps = 10000`, dividend / LP / burn = 0 |
| Beneficiary | This treasury |
| Dividend token | `$BEM`. Tracker only until the treasury deposits |
| Floor | 10,000 `$MTAPE` |
| Migration | 800,000,000 tokens sold, Pancake V2 |
| Same-tx buy | `SEED_WEI`. `0` skips it. Tokens go to the signer |

Buys and sells after launch go through Flap `swapExactInput`, not through this treasury.

## MicroTapeTreasury

| Function | Who | Role |
|---|---|---|
| `buyKit` / `buyKits` | kitBuyer | Fill Firsto asks |
| `tapeout` / `tapeoutMany` | Anyone | Burn 1 NAND + 9 LATCH and tape out |
| `arm` / `armNext` | Anyone | Open a 64-block window |
| `startJohnson` / `startJohnsonNext` | Anyone | Start task 220 |
| `start` / `startUnverified` | Nobody | Reverts |
| `stopMining` | Nobody | Reverts |
| `claimMining` / `harvestMany` / `harvestRange` | Anyone | Pull `$BEM`, then deposit it |
| `distributeBem` | Anyone | Deposit `$BEM` still sitting in the treasury |
| `factory.bindToken` | Factory owner, once | Point the treasury at the Flap token |
| `withdrawMachines` | Treasury owner | Claim pending output, then send every circuit NFT still owned here |
| `withdrawQuote` | Treasury owner | Send all native BNB, plus WBNB if any is sitting here |
| `withdrawParts` | Treasury owner | Send unused NAND and LATCH |
| `withdrawBem` | Treasury owner | Send `$BEM` not yet deposited. Deposited `$BEM` stays in the Dividend |
| `setOwner` | Treasury owner | Hand the treasury admin to a new address |
| `snapshot` / `queue` / `machine` / `machines` / `account` | View | Numbers on the page |

Holders claim on the Flap Dividend with `withdrawDividendsFor`. The treasury has no `claimBem`.

## Continuing a machine

Anyone can call in this order.

```mermaid
%%{init: {"theme":"base","themeVariables":{"primaryColor":"#1a120c","primaryTextColor":"#f5ede4","primaryBorderColor":"#953307","lineColor":"#f46622","secondaryColor":"#221710","tertiaryColor":"#120d09","edgeLabelBackground":"#120d09","noteBkgColor":"#221710","noteTextColor":"#f5ede4","noteBorderColor":"#953307","actorBkg":"#1a120c","actorBorder":"#953307","actorTextColor":"#f5ede4","signalColor":"#f46622","signalTextColor":"#f5ede4","fontFamily":"inherit"}}}%%
flowchart TD
  Window{"Window still live?"}
  Window -->|yes| Start["startJohnsonNext"]
  Window -->|no| Arm["armNext"]
  Arm --> Wait["Wait one block"]
  Start --> Parts{"Parts left?"}
  Wait --> Parts
  Parts -->|yes| Tapeout["tapeoutMany"]
  Parts -->|no| BNB{"BNB left?"}
  Tapeout --> BNB
  BNB -->|yes| Buy["Executor buyKits"]
  BNB -->|no| Idle["Idle"]
  classDef hot fill:#f46622,stroke:#f46622,color:#120d09
  classDef dim fill:#120d09,stroke:#3a2416,color:#b9a693
  class Buy hot
  class Idle dim
```

1. If a window is live, call `startJohnsonNext`. It uses the arm-block `blockhash` and dies when the window expires.
2. If there is no window, call `armNext`. An expired window is re-armed.
3. Wait one block. Arm and start cannot share a transaction. In the same block, `startJohnsonNext` returns no startable machine and `startJohnson` returns same block.
4. If parts remain, call `tapeoutMany`.
5. If BNB remains, the executor calls `buyKits`.

`startJohnson` uses about 6.2M gas and cannot batch. Only buying parts and tape-out batch.

Order prices are not chosen on-chain. `TreasuryBestAsk` tests that a non-kitBuyer cannot buy. Which order is selected lives in the script, from the official TapeOut API. Risks: [Risks](/risks).
