# Mining and payment totals

`GET /stats/mining/totals` · Lithos client API · Statistics

Source: https://lithosprotocol.org/docs/api/get-mining-totals

Running totals over the retained history: Lithos blocks, payout rewards, bond refunds,
transaction fees, batching revenue, participation and confirmed fraud proofs. Keys under
`local.` belong to this client's primary mining address; `network.` keys cover the whole
configured protocol.

Label the period with the height and timestamp fields. Retention holds a rollback buffer
and can run behind on pruning, so the period is often longer than the configured number
of days. Only `ready` means collection reached the last checked chain tip — a loading or
disabled response can return an empty `totals` map, which is not evidence that nothing
happened. Reorgs and pruning can lower a total between two requests.

## Responses

### 200: The last published totals, with collection status and coverage.

`MiningTotalsResponse`

- `status` (string, required, one of disabled, loading, ready, stale, unavailable, catching-up, recovering): How far collection has got. `ready` means it reached the last checked chain tip. `catching-up` and `recovering` mean replay or reorg work is still running, `stale` means the last successful check is too old, and `unavailable` means collection failed. On `disabled` or `loading` the numbers are not evidence that the period was quiet.
- `persistent` (boolean, required): Whether history survives a client restart.
- `observedAt` (integer · int64): When the last replay cycle started, in Unix milliseconds. Absent until the first check after a restart.
- `sourceHeight` (integer): Last processed height, or the starting anchor if nothing has been collected yet.
- `sourceBlockId` (string): The block id at `sourceHeight`.
- `targetHeight` (integer): Last checked chain height. Collection can lag behind it.
- `fromHeight` (integer): First retained height. Higher than `sourceHeight` means the history is empty.
- `fromTimestamp` (integer · int64): Timestamp of the first retained block, in Unix milliseconds. Absent when there are no block records.
- `totals` (MiningAccountingMetrics, required): Exact sums and counts for the period, as decimal strings. A missing key means nothing was collected for it, which is not evidence that nothing happened outside the coverage. Amounts ending in `NanoErg` are nanoERG and LIT amounts are base units. New keys get added over time, so ignore ones you do not recognise. \| Key \| Meaning \| \| --- \| --- \| \| `chain.blocks`, `chain.difficultySum` \| Ergo blocks processed, and the sum of their network difficulty. \| \| `chain.transactionFeeNanoErg` \| Miner-fee outputs from every transaction in those blocks. \| \| `lithos.blocks`, `lithos.difficultySum` \| Blocks carrying a configured Lithos genesis — counted once each — and their difficulty. \| \| `lithos.transactionFeeNanoErg` \| Miner-fee outputs from the transactions inside those Lithos blocks. \| \| `local.payout.*` \| Confirmed payouts to this client's primary mining address. \| \| `local.slashed.count`, `.bondNanoErg` \| Fraud proofs that removed this client's own entry, and the bonds it lost. \| \| `network.payout.*` \| Every payout seen for the configured protocol, local ones included. \| \| `collateral.consumedNanoErg` \| Collateral spent by genesis transactions. Not income. \| \| `holding.genesisNanoErg` \| Value placed in holding boxes at genesis. Contains the pool's share of any priority bid. \| \| `lithos.priorityFeeNanoErg` \| Priority fees carried by the collateral boxes those blocks spent. \| \| `lithos.blocksWithPriorityFee` \| How many of those blocks carried a fee at all. \| \| `collateral.<path>.*` \| Lender cost and return by how the spent box was taken, `bid` or `clearance`: `boxes`, `priorityFeeNanoErg`, `costNanoErg`, `receivedNanoErg`, `waitBlocks`, and `capitalNanoErgBlocks`, the queue box's value times the blocks it stayed locked. `/stats/collateral` turns these into rates. \| \| `batching.<protocol>.*` \| Executor fees earned filling `ergodex` or `lithosdex` orders, builder takings from `forwards` recordings and settlements, and `arb` cycle profit. \| \| `batching.<protocol>.tokens.<tokenId>`, `.otherTokens` \| Tokens executors kept, by verified token id; `otherTokens` counts the times an unlisted token was kept, never its amount. \| \| `lithos.batching.<protocol>.*` \| The same, counting only blocks that carried a Lithos genesis. \| \| `pool.batching.<protocol>.orders`, `.grossNanoErg` \| Fee-less executions inside Lithos blocks. Their takings top up the rollup, so they reach miners through payouts. \| \| `local.batching.<protocol>.*` \| Executions whose takings went to this client, outside the pool. Paid straight to its wallet, less the transaction fee. \| \| `local.received.<protocol>.tokens.<tokenId>`, `.otherTokens` \| Tokens that reached this client's own address, in its own Lithos blocks too: a holding box never takes tokens, so they go to the block's finder. \| \| `rollup.<kind>.*` \| Confirmed rollup transitions: `topUp`, `submission`, `evaluation`, `fraudProof`, `payoutReady`. \| \| `transaction.<kind>.count`, `.feeNanoErg` \| Recognised transactions and the fees they paid. \| \| `registration.<kind>.count`, `.localCount` \| Miner Dictionary `add`, `remove` and `evict` events. \| **Payout families** hold `outputs`, `grossNanoErg`, `rewardNanoErg`, `bondNanoErg`, `surplusNanoErg`, `rewardLit` and `receivedLit`. Gross ERG is reward plus refunded bond plus any surplus. `rewardLit` is what the protocol owes; `receivedLit` is what the outputs actually carried. Network totals already contain the local ones — never add the two together. **Batching families** hold `orders`, `grossNanoErg`, `transactionFeeNanoErg` and `afterTransactionFeesNanoErg`, counting recognised execution layouts only, not all pool activity. Gross is newly earned executor fees and excludes takings carried in from earlier. Liquidity-provider fees are a different thing and live on the DEX API. `pool.batching` pays no transaction fee, so it holds only `orders` and `grossNanoErg`. It and `local.batching` never count the same execution. A `forwards` recording broadcast alone pays its fee from the wallet for LIT, so its fee is above its gross: that part is `feeAboveGrossNanoErg`, and the net is `afterTransactionFeesNanoErg - feeAboveGrossNanoErg`. Token keys are named only for tokens on the verified list when the execution was recorded; `tokens` in the response names each one. For `arb`, `orders` counts cycles and gross is the ERG a cycle returned above its stake. A cycle runs only in its own miner's block with no fee, so in a Lithos block it is counted in `pool.batching.arb`. **Rollup families** hold `count`, `miners`, `claimedScore`, `bondNanoErg` and `valueNanoErg`, plus `localCount`, `localValueNanoErg`, `localBondNanoErg` and `localClaimedScore` where the local miner is identifiable — the submitting miner for submissions, the prover input for fraud proofs. So `rollup.submission.localBondNanoErg` is the bond this client posted, and `rollup.fraudProof.localValueNanoErg` is the slashed bonds it was paid for proving fraud. `miners` counts entries at that transition, not unique people. `valueNanoErg` means a different thing per kind: added holding value for a top-up, zero for a submission, the full box value at evaluation, the slashed bond for a fraud proof, and distributable ERG excluding bonds at payout readiness. These are stages of the same funds, so summing them is not income. `transaction.<kind>` covers `genesis`, the rollup kinds above, `payout`, `registration`, `ergodex`, `lithosdex`, `forwards`, `arb` (each leg of a cycle), `ergodexOtherPoolSpend` and `lithosdexOtherPoolSpend`. Those fees overlap the block fee totals. **Priority fees.** `lithos.priorityFeeNanoErg / lithos.blocks` is the mean fee across every Lithos block; divide by `lithos.blocksWithPriorityFee` instead for the mean across the blocks that carried one. The amount is the WHOLE fee the lender posted, not the share the block's finder keeps out of it. The pool's share went into the holding box and is already inside `holding.genesisNanoErg`, so there is deliberately no separate key for it. Divide a sum by its matching count for an average. `claimedScore` is protocol accounting, not measured hashrate. A transaction fee is a transaction's cost and not automatically this client's expense, holding top-ups and executor fees can describe the same proceeds, and no key here is a net-income figure. 
- `tokens` (map<string, VerifiedToken>): Every verified token a `.tokens.<tokenId>` key above names, by id, so each amount can be shown in whole units.

## Example request

```bash
curl -X GET "http://localhost:9000/stats/mining/totals"
```

## Example response

```json
{
  "status": "disabled",
  "persistent": true,
  "observedAt": 0,
  "sourceHeight": 0,
  "sourceBlockId": "string",
  "targetHeight": 0,
  "fromHeight": 0,
  "fromTimestamp": 0,
  "totals": {
    "chain.blocks": "720",
    "lithos.blocks": "12",
    "local.payout.outputs": "3",
    "local.payout.rewardNanoErg": "1500000000",
    "local.payout.bondNanoErg": "3000000",
    "batching.lithosdex.orders": "20",
    "batching.lithosdex.grossNanoErg": "40000000"
  },
  "tokens": {
    "key": {
      "tokenId": "c1980d829988229516430a47a5eca376060b6ce859616db0936e78ab25cb6de7",
      "name": "LIT",
      "ticker": "LIT",
      "decimals": 9
    }
  }
}
```
