# Contracts

This launch is two contracts. `MicroTapeFund` is the curve and the fees. `MicroTapeTreasury` is the miners and `$BEM`. Thesis and identities: [Overview](/). This page is for verification: addresses and interfaces.

Neither contract is deployed to BNB Chain mainnet. Addresses land here after deploy.

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

## This launch

| Contract | Address |
|---|---|
| MicroTapeFund | Not deployed |
| MicroTapeTreasury | Not deployed |

## Already on BNB Chain

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

## MicroTapeFund

| Function | Role |
|---|---|
| `buy` / `buyTo` | Inner buy. Dead after graduation |
| `sell` | Inner sell. No launch surcharge |
| `quoteBuy` / `quoteSell` / `room` | Quotes, and how much BNB remains to 18 |
| `snipeTaxBps` | Launch surcharge for the current second |
| `graduate` | Graduate once real quote is 18 BNB |
| `swapTax` | After graduation, sell accrued tax tokens for BNB |

## 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 into the treasury |
| `claimBem` / `claimBemMany` | Anyone | Pay BEM to an address that clears the floor |
| `snapshot` / `queue` / `machine` / `machines` / `account` | View | Numbers on the page |

## 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).
