# Computing CKB Treasury Share
## Metadata
**Status**:: #x
**Zettel**:: #zettel/fleeting
**Created**:: [[2026-03-12]]
## Motivation
Before activating CKB treasury, we must be able to compute the share of secondary issuance for the treasury. This post is a survey on possible solutions to invoke further discussions.
## Background
See [Understanding the Nervos CKB Issuance Model](https://www.nervos.org/knowledge-base/understanding_nervos_ckb_issuance_model).
## Problem
The DAO field is a 32-byte value embedded in every block header. The layout, stored in **little-endian**, is:
| Byte Range | Field | Type | Meaning |
| ---------- | ------ | ----------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `[0..8]` | **C** | `Capacity` (u64, in shannons) | Total issuance up to and including this block (primary + secondary) |
| `[8..16]` | **AR** | `u64` (raw, scaled by 10^16) | Accumulated rate — reflects cumulative secondary issuance relative to total supply |
| `[16..24]` | **S** | `Capacity` (u64, in shannons) | Accumulated "unclaimed" NervosDAO compensation (secondary issuance to Treasury and DAO minus withdrawn interest) |
| `[24..32]` | **U** | `Capacity` (u64, in shannons) | Total occupied capacity (bytes actually used to store state on-chain) |
The miner's share of secondary issuance is calculated using the ratio `U/C`. The remaining secondary issuance is added to `S`. When users withdraw cells from NervosDAO, the reward is computed based on `AR` at both the starting and ending blocks and is subtracted from `S`.
**The treasury share is never explicitly computed or stored.** We know it is less than `S`, but there is no straightforward way to determine either the exact upper bound of the total burned treasury amount or the secondary issuance share allocated to the treasury in each block.
We need total CKB amount deposited in NervosDAO (marked as `D` below) at every block to compute the share for the treasury, but `D` is not stored anywhere in the block header.
## Practical Options
There are really three approaches:
1. **Track `D` in a new consensus field (soft or hard fork).** Add the total deposited amount to the block extension ([RFC0013](https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0031-variable-length-header-field/0031-variable-length-header-field.md)). This is the clean solution -- at each block you already process deposit/withdraw transactions, so maintaining a running `D` total is cheap. Then treasury share per block is directly `g2 * (C - U - D) / C`.
2. **Compute `D` from the UTXO set via an indexer.** Scan all live NervosDAO deposit cells at the activation block to get the initial `D`, then track it going forward. This only needs to happen once for the historical accumulation, and from the activation block onward you can maintain `D` incrementally. However, this approach could render on-chain treasury governance difficult—or even impossible—to implement.
3. **Subtracting DAO Interests**. We can compute the total unclaimed DAO interest by assuming all deposits were withdrawn in the current block. Subtracting it from `S` gives us the total amount of the treasury until the current block. To determine the secondary issuance for a single block, calculate the difference between consecutive treasury totals.