# NetNet recipes

Every figure NetNet Intel shows, rebuilt from Robinhood Chain alone. No API key, no NetNet Intel server: point the
recipes at any Robinhood Chain RPC (the public one is the default) and they read the contracts and events themselves.

- `engine.js`: the connection (`makeCtx`), ABI decoding, chunked log scans, `run()` and `compare()`.
- One file per area (`core.js`, `buybacks.js`, `bonds.js`, `advance.js`, `loop.js`, `holders.js`, `predict.js`, ...), each
  exporting `RECIPES`.
- `index.js`: all recipes in one list.

```js
import { makeCtx, run } from "./engine.js";
import { RECIPES } from "./index.js";
const ctx = makeCtx();                                  // or makeCtx({ rpc: "<your node>", block: 84030000 })
const nav = await run(RECIPES.find((r) => r.id === "nav_core"), ctx);
console.log(nav.value, nav.block, ctx.trail);           // the figure, its block, and every request that proved it
```

## A recipe

| field | meaning |
|---|---|
| `id`, `area`, `label`, `unit` | what it is |
| `what` | one plain line |
| `needs` | `eth_call` (current state), `eth_getLogs` (event history), `archive` (old state), or `offchain:<source>` |
| `sources` | every contract call (`address`, `fn`, calldata `data`, `decimals`) and event (`address`, `event`, `topic0`, `fromBlock`) |
| `formula`, `steps` | the arithmetic, in words and in order |
| `params` | optional inputs (`days`, an amount, a price) with defaults |
| `api` | the NetNet Intel endpoint and field serving the same figure, to compare against |
| `caveats` | where the figure is a model, a label or an off-chain input |
| `run(ctx, opts)` | computes it: `{ value, parts?, rows?, inputs? }` |

## Limits of the public RPC

- State (`eth_call`) is kept for the last few thousand blocks only (about 10 minutes; a block every ~0.1 s). A figure at a
  pinned block re-checks there for a few minutes, and on an archive node forever.
- Logs (`eth_getLogs`) answer up to 10,000,000 blocks a request (about 12 days); `ctx.logs` chunks and halves on
  refusals, so event history always re-checks.

MIT licensed. Fan-made and read-only: nothing here signs or sends a transaction.
