# BlazePhoenix-Dex Whitepaper v2.4.0 — part 7 of 9: Part VI — Staking V4 > One part of the whitepaper in llms.txt form; every part and every section is listed in > https://blazephoenix.xyz/whitepaper/llms.txt. The parts are the full text, unabridged: the bodies of parts > 1-9, joined in order, are https://blazephoenix.xyz/whitepaper.md byte for byte (sha256 a47389f947e4aa6656f693004e43fbe3e0101dccaf133e49c303767811f223cc). > Cite as https://doi.org/10.5281/zenodo.24517342; numbering (§, E, INV-) as in the paper. ----- verbatim text of whitepaper.md follows ----- ## Part VI — Staking V4 ## §25 Staking V4: Design Staking V4 is the current codebase; the address is published at launch. It is not deployed yet, and no address is official until the deployment is published. This chapter describes the staking engine as its source stands: `src/BlazePhoenixStaking.sol` in the `Blaze-Phoenix-Staking` repository, `main` at `9958d5f`, which declares `VERSION = "4.0.0"` (L177). Every line number in this chapter (L*n*) refers to that file at that commit; where this text and the source disagree, the source wins. The chapter carries no addresses, no deployment dates and no yields: every number in it is a constant compiled into the contract, or is derived from one, and the derivation is printed beside it. The repository states that the staking contract is a pre-launch engineering preview and that no external audit has been done: No external audit yet. Inspect it yourself: the code, the tests, the mutants, the bounty. The engine is held to the discipline of the rest of this paper. It holds one token, BZPX, and every claim on that BZPX is a ledger term whose sum the contract re-checks around each state change (E35). A staker locks BZPX for a chosen number of days and earns two streams, a scheduled emission (E27–E29) and the interest borrowers pay (E31–E34), each weighted by a boost that grows with the commitment (E30). A staker may borrow BZPX against the stake (E41). When a loss occurs, it follows one fixed order (E37), and the contract reports, as a public view, whether it holds what it owes (E36). The contract is deployed twice, independently (§25.8), and anyone may trip its circuit breaker on a proven shortfall (§25.11). ### §25.1 Architecture and roles One contract, `BlazePhoenixStaking`, inheriting `AccessControl`, `Pausable` and `ReentrancyGuard` (L175). The token, the treasury and the emission window (`emissionStart`, `emissionEnd`) are immutables (L286–289); the constructor refuses a token address that carries no code (L525). There is no oracle, no upgrade path and no parameter setter: every constant below is compiled in. | Role | Held by | May | Line | |---|---|---|---| | `DEFAULT_ADMIN_ROLE` | the deployer, at construction | grant and revoke roles (no `_setRoleAdmin` call exists, so it administers every role) | L533 | | `ADMIN_ROLE` | the deployer, at construction | `fundEmission` (cumulative funding ≤ `TOTAL_REWARDS`); `withdrawReserve` (to the immutable treasury only, at most `protocolReserve`, closed under a hard breach); `sweepUndistributedEmission` (only after `emissionEnd`); `unpause`; `cancelEmergency` (only on a solvent book) | L534, L564, L582, L619, L642, L684 | | `GUARDIAN_ROLE` | nobody at construction; granted by a role admin | `pause`; `declareEmergency` — neither moves funds | L179, L640, L668 | | anyone | — | `liquidate`; `tripBreaker` (reverts unless the book is in hard breach); `absorbBadDebt`; `syncEquity` (in an emergency only; writes off a position whose stake no longer exceeds its debt); `lockStep` | L1211, L660, L711, L733, L1477 | No role can move a staker's principal, and the only destination any role can send revenue to is the immutable treasury. | Constant | Value | Meaning | Line | |---|---|---|---| | `TOTAL_REWARDS` | 90,000,000e18 | emission budget of this contract, and the cap on cumulative `fundEmission` | L207 | | `BASE_REWARDS`, `HALVING_SERIES` | 60,000,000e18, 32,000,000e18 | the flat base (7,500,000 a year) and the geometric series that carries the 30,000,000 bonus (§25.3) | L208–209 | | `HALVING_PERIOD` | 2 × 365 days | length of one emission period | L210 | | `EMISSION_PERIODS` | 4 | periods before the programme closes (`EMISSION_LENGTH` = 8 years) | L211–212 | | `INITIAL_REWARD_PER_SEC` | `BASE_REWARD_PER_SEC` + `BONUS_REWARD_PER_SEC` | period-0 rate, $R_{b} + R_{0}$: base rate plus period-0 bonus rate (§25.3) | L213–216 | | `MAX_STAKE_PER_WALLET` | 30,000,000e18 | stake ceiling per position | L218 | | `MIN_EMISSION_WEIGHT` | 1,000e18 | below this total weight both streams are throttled pro rata | L228 | | `MAX_LTV` | 50 | borrow ceiling, % of net stake | L230 | | `LIQ_THRESHOLD` | 95 | liquidatable at debt ≥ 95 % of stake | L231 | | `LIQ_BONUS_BPS` | 500 | liquidation surplus to the caller, bps of debt | L232 | | `RESERVE_FACTOR_BPS` | 300 | share of each interest slice kept in `protocolReserve` | L233 | | `MIN_LOCK_DAYS`, `MAX_LOCK_DAYS` | 90, 2,555 | lock bounds in days | L241–242 | | `BOOST_BASE`, `BOOST_LINEAR`, `BOOST_QUAD` | 10,000, 750, 250 | boost polynomial, bps | L244–246 | | `MIN_DEPOSIT_BLOCKS` | 10 | blocks a deposit must age before withdraw, pure-yield claim or lock change | L248 | | `RATE_R0`, `RATE_RK`, `RATE_UK`, `RATE_S1`, `RATE_S2` | 100, 500, 0.8e18, 500, 72,500 | kinked interest curve, annual bps | L251–255 | | `MAX_PROTOCOL_UTIL_WAD` | 0.75e18 | book utilisation ceiling for a new borrow | L262 | | `CONSERVATION_DUST` | 1e10 | tolerance of the conservation guard, in wei | L267 | | `MAINT_BASE`, `MAINT_DENSITY`, `MAINT_GAP_UNIT`, `MAINT_MAX_SCAN`, `MAINT_MAX_LOCK_ACTIONS` | 1, 50, 15 minutes, 10, 4 | autonomous-maintenance budget (E42) | L272–275, L283 | ### §25.2 The flow: stake, unstake, claim, borrow Every user entry point runs one pipeline, in the order `deposit` fixes: snapshot the conservation identity; refuse if the book is in hard breach; advance the interest index and the emission window (`_updateGlobal`, L1620); settle both streams at the weight the position held; attribute the interest the position owes (`_accrueInterestFor`, L1905); clear an elapsed lock; perform the action; recompute the position's weights through the single writer (`_resync` → `_applyBoost` → `_checkpoint`, L2020–2062); run the autonomous maintenance window (E42); and check the conservation identity again (E35). The doors differ only in the gates they add. | Entry point | Paused | Emergency | Hard breach | Further conditions | |---|---|---|---|---| | `deposit(amount, lockDays)` — stake | closed | closed | closed (L898) | $90 \le$ `lockDays` $\le \min(2{,}555,\ \text{days left to } \mathtt{emissionEnd})$; position stake ≤ `MAX_STAKE_PER_WALLET`; before `emissionEnd` (L884–898) | | `lock(lockDays)` | closed | closed | — | `MIN_DEPOSIT_BLOCKS` since the last deposit (L1107–1112) | | `withdraw(amount)` — unstake | open | closed | closed (L1040) | no debt; lock elapsed; `MIN_DEPOSIT_BLOCKS` since the last deposit (L1027–1032) | | `claimRewards()` | open | closed | closed (L1069) | settles emission and pure yield (L1067) | | `claimPureYield()` | open | closed | closed (L1084) | no debt; `MIN_DEPOSIT_BLOCKS` since the last deposit (L1080–1084) | | `borrow(amount)` | closed | closed | closed (L968) | E41 (L960–980) | | `repay(amount)` | open | closed | open | — (L996) | | `liquidate(user)` | closed | closed | open | E39 (L1211) | | `emergencyWithdraw()` — exit | — | only | — | E40 (L772) | | `absorbBadDebt(amount)` | open | open | open | E38 (L711) | **Stake.** `deposit` pulls BZPX into the position and starts or extends its lock; the lock may never run past the end of the emission programme, and the boost it buys (E30) is paid only while the lock is in force. **Unstake.** `withdraw` returns principal once the position owes nothing and its lock has elapsed; it stays open under a guardian pause, so a pause halts new risk without trapping anyone. In an emergency the only exit is `emergencyWithdraw`, which pays net equity, scaled pro rata if the contract holds less than the positions are owed (E40), and forfeits the position's unclaimed streams. **Claim.** The harvest is the two claims: `claimRewards` pays both streams, `claimPureYield` the same for a debt-free position; there is no separate harvest function. **Borrow, repay, liquidate.** A staker may borrow BZPX against its own stake within two ceilings (E41); interest is charged against the stake, not added to the debt (E34); `repay` stays open under a pause and under a hard breach, because closing debt only makes the book safer. A position whose debt reaches 95 % of its stake can be closed by anyone, and the closer receives the surplus of E39. ![FIG-19 — The staking entry points and their one pipeline](https://blazephoenix.xyz/whitepaper/figs/v2.4/fig-19.svg) *FIG-19 — The staking entry points and their one pipeline: the gates each door adds, then the conservation snapshot, the breach gate, the global update, settlement, interest attribution, lock expiry, the action, the single-writer resync, autonomous maintenance and the conservation check; the emergency exit stands apart.* ### §25.3 Reward accounting **Emission.** Each deployment schedules 90,000,000 BZPX over eight years. The schedule has two parts that add up to `TOTAL_REWARDS`: a linear base of 60,000,000 BZPX (`BASE_REWARDS`, L208), paid at a constant rate for the whole eight years, and a bonus series of 30,000,000 BZPX whose rate halves every two years (`HALVING_SERIES` = 32,000,000 BZPX, L209, of which the series contributes 30,000,000 BZPX, because its last step leaves 2,000,000 over: $S - S/16$). Let $T$ = `TOTAL_REWARDS`, $B$ = `BASE_REWARDS`, $S$ = `HALVING_SERIES`, $P$ = `HALVING_PERIOD` (2 × 365 days = 63,072,000 s), $L$ = `EMISSION_LENGTH` = 4$P$ = 252,288,000 s (L212), $R_{b} = \lfloor B / L \rfloor$ (L213), $R_{0} = \lfloor (S/2) / P \rfloor$ (L214), $s$ = `emissionStart`, and for a time $t$ let $\tau = t - s$ and $p = \lfloor \tau / P \rfloor$. The cumulative scheduled emission is a closed form (`_emittedAt`, L1665–1675): $$ E(t) \;=\; \begin{cases} 0 & t \le s \\ R_{b}\,\tau \;+\; \left(S - (S \gg p)\right) \;+\; (R_{0} \gg p)\,(\tau - pP) & s < t < s + 4P \\ B + S - (S \gg 4) & t \ge s + 4P \end{cases} $$ ^e27 *Derivation.* In exact arithmetic the bonus rate in period $q$ is $S/(2^{q+1}P)$, so a full period $q$ emits $S/2^{q+1}$ and the bonus emitted before period $p$ is $\sum_{q 0 \end{cases} $$ ^e30 with $s_{u}$ the position's stake and $d_{u}$ its debt (constants `BOOST_BASE`, `BOOST_LINEAR`, `BOOST_QUAD`, L244–246). Exact values: $b(90) = 10{,}199$, $b(365) = 11{,}000$, $b(730) = 12{,}500$, $b(1{,}825) = 20{,}000$, $b(2{,}555) = 27{,}500$ bps, that is 1.10x at one year, 2.00x at five years and 2.75x at seven years [the 90- and 730-day values carried from 2.3, recomputed from the formula]. Emission weight is on net stake; the pure-yield weight exists only for a debt-free position: a borrower does not earn the interest it pays. *Worked example (illustrative, not a forecast).* Two positions of 1,000 BZPX each, no debt, in a window where they are the only weight. Position X is locked 365 days ($b$ = 11,000, weight 1,100); position Y is locked 1,825 days ($b$ = 20,000, weight 2,000). Total weight 3,100. X takes 1,100/3,100 = 35.5 % of that window's scheduled emission and Y takes 64.5 %. The numbers are chosen for arithmetic only: the rate a real position earns depends on the total weight at the time, which is not known in advance, and this paper states no yield. ![FIG-25.3 — The boost curve b(ℓ) and a two-position example](https://blazephoenix.xyz/whitepaper/figs/v2.4/fig-25.3.svg) *FIG-25.3 — the boost curve b(ℓ) from 90 to 2,555 days, with the marked points above, and the two-position example as a bar of weight shares.* ### §25.4 Interest: the curve and the index **The curve.** Utilisation is $U = \min(\lfloor D \cdot 10^{18} / S \rfloor, 10^{18})$, with $D$ = `totalDebt` and $S$ = `totalStaked` ($U = 10^{18}$ if $S = 0 < D$; the base rate if both are zero), and the annual rate in bps is kinked at 80 % (`simulateRate`, L2623–2627): $$ r(U) \;=\; \begin{cases} 100 + \left\lfloor 500\,U / 10^{18} \right\rfloor & U \le 0.8 \cdot 10^{18} \\ 500 + \left\lfloor 72{,}500\,(U - 0.8\cdot 10^{18}) / 10^{18} \right\rfloor & U > 0.8 \cdot 10^{18} \end{cases} $$ ^e31 The two branches meet at the kink — $100 + 0.8 \times 500 = 500$ — and the curve reaches $500 + 0.2 \times 72{,}500 = 15{,}000$ bps at full utilisation. A borrow may not lift the book above 75 % (E41), so no borrow by itself enters the steep branch. **The index.** Each elapsed slice $\Delta t$ is stamped with the rate in force across it, before any write to $D$ or $S$ (`_interestSlice`, L1860–1890; `_updateInterestIndex`, L1818–1854), with $Y$ = 365 days: $$ \delta \;=\; \left\lfloor \frac{\lfloor 10^{18}\, r(U) / 10^{4} \rfloor \cdot \Delta t}{Y} \right\rfloor, \qquad \sigma \;=\; \left\lfloor \frac{D\,\delta}{10^{18}} \right\rfloor, \qquad I \leftarrow I + \delta, \quad S \leftarrow S - \sigma $$ ^e32 If $\sigma$ would exceed $S$, the index advance is re-derived as $\delta = \lfloor S \cdot 10^{18}/D \rfloor$ and $\sigma$ recomputed from it, so the per-position charges never sum to more than the global debit. The arithmetic saturates to zero instead of reverting, so the entry points that run beneath it cannot freeze, and under an emergency the clock slides without charging (L1826). One function computes the slice for execution and for every quote, so the two cannot round differently. **The split.** The slice leaves the stake and is divided in the same step (L1836–1837; `_dampPure`, L1901–1903), with $W_{\mathrm{p}}$ = `totalBoostedPure` and $A^{\mathrm{p}}$ = `accPureYieldPerShare`: $$ \kappa_{r} = \left\lfloor \frac{300\,\sigma}{10^{4}} \right\rfloor, \quad \pi = \sigma - \kappa_{r}, \quad \eta = \left\lfloor \frac{\pi \cdot \min(W_{\mathrm{p}}, W_{\min})}{W_{\min}} \right\rfloor, \quad A^{\mathrm{p}} \leftarrow A^{\mathrm{p}} + \left\lfloor \frac{\eta \cdot 10^{18}}{W_{\mathrm{p}}} \right\rfloor, \quad \mathtt{protocolReserve} \mathrel{+}= \kappa_{r} + (\pi - \eta) $$ ^e33 so $\sigma = \kappa_{r} + \eta + (\pi - \eta)$ exactly; with no pure weight, all of $\pi$ goes to the reserve. The throttle is the same as emission's (E28), with the same constant. **Attribution.** The global side was settled when the interest accrued; a position's own share is attributed when it is next touched (`_accrueInterestFor`, L1905–1954), with $I_{u}$ its checkpoint of the index: $$ i_{u} \;=\; \left\lfloor \frac{d_{u}\,(I - I_{u})}{10^{18}} \right\rfloor; \qquad i_{u} > s_{u} \;\Rightarrow\; \lambda = i_{u} - s_{u} \ \text{enters E37},\ S \mathrel{+}= \lambda,\ i_{u} \leftarrow s_{u}; \qquad s_{u} \leftarrow s_{u} - i_{u}, \quad I_{u} \leftarrow I $$ ^e34 Interest is paid out of the stake; the debt itself does not grow. A debt-free position only re-checkpoints, so it never inherits index growth from a time it owed nothing. Interest that a position cannot pay was nevertheless distributed by E33; adding it back to $S$ keeps $S = \sum_{u} s_{u}$, and the loss is booked by E37 at the moment it is known. ### §25.5 The reserve, solvency and the loss waterfall **Conservation.** With $B$ the contract's BZPX balance, $D$ = `totalDebt`, $\mathit{BD}$ = `totalBadDebt`, $S$ = `totalStaked`, $\mathit{RR}$ = `rewardReserve`, $\mathit{PR}$ = `protocolReserve` and $\Pi$ = `totalRewardDistributed − totalRewardsPaid` (distributed, not yet paid), every function that wears the `conserves` modifier snapshots both sides before its body and reverts after it unless (L467–486; `_conservationSnapshot`, `_conservationCheck`, L497–505): $$ \left|\, \Delta(B + D + \mathit{BD}) \;-\; \Delta(S + \mathit{RR} + \mathit{PR} + \Pi) \,\right| \;\le\; \varepsilon, \qquad \varepsilon = \mathtt{CONSERVATION\_DUST} = 10^{10}\ \text{wei} $$ ^e35 Every term is a single non-negative state variable, summed without a floor, so the identity is linear in every regime — including terminal distress, where the recovery tools (`repay`, `liquidate`, `absorbBadDebt`) must keep working — and only the change across a call is compared, so history cannot accumulate into a false alarm. **Solvency.** What the contract owes, and the public test of whether it holds it (`_owed`, L2096–2100; `_hardBreach`, L2184–2186; `isSolvent`, L2206): $$ \mathrm{owed} \;=\; (S + \mathit{RR} + \mathit{PR} - D)^{+} \;+\; \Pi, \qquad \mathrm{hardBreach} \iff B + \varepsilon < \mathrm{owed}, \qquad \mathtt{isSolvent}() = \neg\,\mathrm{hardBreach} $$ ^e36 *Derivation of the link to bad debt.* Where $S + \mathit{RR} + \mathit{PR} \ge D$, E35 gives $\Delta(B - \mathrm{owed} + \mathit{BD}) = 0$ (up to $\varepsilon$) across every guarded call, so $B - \mathrm{owed} = c - \mathit{BD}$, with $c$ the balance held beyond the ledger. Recorded bad debt is therefore exactly the term that pushes the book towards a hard breach, and the book reads insolvent once $\mathit{BD} > c + \varepsilon$. Under a hard breach the doors that would pay out at par or add new money to a short pot revert — `deposit`, `borrow`, `withdraw`, `claimRewards`, `claimPureYield` and the pure-yield settlement inside them, `withdrawReserve`, `cancelEmergency` (L898, L968, L1040, L1069, L1084, L1791, L595, L686) — while `repay`, `liquidate` and `absorbBadDebt` stay open, and anyone may call `tripBreaker` to move the contract into emergency (L660). **The waterfall.** A loss $\lambda$ arises at four sites only: a liquidation whose debt exceeds the stake (L1252–1257, L1279), an under-water emergency exit (L844–849), the write-off of an under-water position by `syncEquity` in an emergency (L748–751), and interest a position cannot pay (L1938–1946). All four apply the same order: $$ \kappa \;=\; \min(\lambda,\ \mathit{PR}), \qquad \mathit{PR} \leftarrow \mathit{PR} - \kappa, \qquad \mathit{BD} \leftarrow \mathit{BD} + (\lambda - \kappa) $$ ^e37 The reserve — built from the reserve factor of every interest slice (E33) and from the liquidation bonuses it withholds (a self-liquidation, or any liquidation under a hard breach) — absorbs first; only the uncovered rest becomes recorded bad debt. Recapitalisation is a public door that takes the reserve first, then at most what the caller offers and never more than is still uncovered (`absorbBadDebt`, L711–720), with $a$ the caller's amount: $$ \rho \;=\; \min(\mathit{BD},\ \mathit{PR}), \qquad \gamma \;=\; \min(a,\ \mathit{BD} - \rho), \qquad \mathit{PR} \leftarrow \mathit{PR} - \rho, \qquad \mathit{BD} \leftarrow \mathit{BD} - \rho - \gamma, \qquad B \leftarrow B + \gamma $$ ^e38 It reverts when $\rho + \gamma = 0$, moves nothing out and pays the caller nothing; E35 holds by construction ($\Delta \mathrm{LHS} = \gamma - \rho - \gamma = -\rho = \Delta \mathrm{RHS}$). The loss of an under-water position reaches $\mathit{BD}$ once it is recorded: by its own exit or liquidation or, in an emergency, by a public `syncEquity` call that writes it off through E37 (L733–761). Once $\mathit{BD}$ is back within the dust, `isSolvent()` reads true and the admin may cancel the emergency. **Liquidation.** A position is liquidatable iff $d_{u} > 0$ and ($s_{u} = 0$ or $100\,d_{u} \ge 95\,s_{u}$) (`_isLiquidatable`, L1284–1288). Closing it (`_executeLiquidation`, L1225–1282): $$ \mathrm{seized} \;=\; \min\!\left(d_{u} + \left\lfloor \frac{500\,d_{u}}{10^{4}} \right\rfloor,\ s_{u}\right), \qquad \mathrm{bonus} \;=\; (\mathrm{seized} - d_{u})^{+}, \qquad \lambda \;=\; (d_{u} - s_{u})^{+} \ \text{to E37} $$ ^e39 The bonus goes to the caller, except when a borrower closes its own position or the book is in hard breach, in which case it stays in `protocolReserve`. The position's earned streams are paid before it is closed, and any stake left over remains as a debt-free position that keeps its lock. **Emergency exit.** With $\mathrm{pot} = B$ and $E_{+}$ = `totalPositiveEquity` $= \sum_{u} \max(s_{u} - d_{u}, 0)$ as tracked, the exit pays (`emergencyWithdraw`, L772–869; the scaling, L827–835): $$ x_{0} \;=\; (s_{u} - d_{u})^{+}, \qquad E' \;=\; E_{+} - e_{u} + x_{0}, \qquad x \;=\; \min\!\left( \begin{cases} \lfloor x_{0}\,\mathrm{pot} / E' \rfloor & \mathrm{pot} < E' \\ x_{0} & \text{otherwise} \end{cases},\ \mathrm{pot} \right) $$ ^e40 where $e_{u}$ is the exiter's tracked term, replaced by its exact equity after accrual. On a solvent book the scaling never engages and net equity is paid in full; on a short one each exit takes the same fraction of its claim, and an under-water exit books its shortfall through E37 (L844–849). ![FIG-21 — The loss waterfall](https://blazephoenix.xyz/whitepaper/figs/v2.4/fig-21.svg) *FIG-21 — The loss waterfall E37–E38: protocolReserve absorbs first, the rest is recorded as totalBadDebt and read by isSolvent(), and absorbBadDebt recapitalises from the reserve, then from the caller, never beyond what is uncovered; illustrative proportions, no token amounts.* **Borrowing ceilings.** A borrow of $a$ must satisfy both (`borrow`, L974–980; `_ltvCap`, L2305–2306): $$ d_{u} + a \;\le\; \left\lfloor \frac{50\,(s_{u} - d_{u})^{+}}{100} \right\rfloor, \qquad \left\lfloor \frac{(D + a)\cdot 10^{18}}{S} \right\rfloor \;\le\; 0.75 \cdot 10^{18} $$ ^e41 the first on the position's net stake, the second on the whole book, held below the 80 % kink of E31. **Maintenance.** Each user transaction, unless the contract is paused or in emergency, also scans a window of the borrower registry (liquidating what is under water) and of the lock registry (normalising expired locks), each of size (`_windowBudget`, L1299–1308; `_autoMaintain`, L1332–1360): $$ c(n) \;=\; \min\!\left(1 + \left\lfloor \frac{n}{50} \right\rfloor + \left\lfloor \frac{t - t_{m}}{15\ \mathrm{min}} \right\rfloor,\ 10,\ n\right) $$ ^e42 with $n$ the registry size and $t_{m}$ the last sweep; at most four lock normalisations run per transaction (L283). The schedule is a pure function of on-chain state — no keeper, no governance — and its gas is bounded in every case. **Invariants.** The design adds nine invariants, INV-23 to INV-31 (Appendix B): the conservation identity, the emission ceiling, the loss order, the closed doors under a breach, the recapitalisation bound, the single writer of the weights, the borrowing ceilings, the bounded emergency exit, and the deposit ageing rule. ### §25.6 Hardening in V4 Four merged changes shaped the V4 source after the design that 2.3 described; each is described here at the level of the design it produced. - **#22 (`b44e238`, 2026-10-11).** Interest is stamped per slice by one function shared by execution and every quote (E32), so a preview and a transaction compute the same charge, at the rate in force across the slice. The pure-yield channel is throttled by the same weight floor as emission (E33), so a residual denominator cannot capture the flow. A borrower closing its own position receives no liquidation bonus. Read-only risk views were added (`healthFactor`, `daysToLiquidation`, `maxBorrowOf`). - **#26 (`7fc0c2a`, 2026-10-13).** One loss order for the three loss sites of the time (liquidation, under-water emergency exit, unpaid interest; the fourth, the `syncEquity` write-off of §25.5, came with #42): the reserve first, then recorded bad debt (E37); a public recapitalisation door (E38); the value-moving doors closed under a hard breach (E36); a constructor that refuses a token address with no code; the conservation check emitted once as two internal helpers instead of being inlined at every guarded site, with the identity unchanged; and an assurance test suite. - **#25 (`cc614f9`, 2026-10-14).** Documentation only: short summary lines in the guides and test headers. No contract source changed. - **#42 (`02af63a`, 2026-11-16).** In an emergency, `syncEquity` writes off a position whose stake no longer exceeds its debt, as that position's own exit would: the shortfall goes through the loss order of E37, the reserve first and the rest to recorded bad debt, where `absorbBadDebt` can reach it, so a recapitalised book can read solvent and the emergency can be cancelled. A position above water, or without debt, is only re-checkpointed. ### §25.7 Test evidence The staking repository declares 22 stateful invariants in 6 files at `9958d5f` (checked by listing every `invariant_*` function of the test tree): 7 in `BlazePhoenixStaking.t.sol`, 9 in `InvariantsFullSurface.t.sol`, 2 in `assurance/EmissionScheduleMatrix.t.sol`, 1 in `atq/AtqEmergencySurface.invariant.t.sol`, 2 in `attack/EmissionShareInvariant.t.sol` and 1 in `hunt/ExactAttributionInvariant.t.sol`. Solvency is a named invariant, not a comment: `invariant_solvent` (the contract's own `isSolvent`) and `invariant_backingCoversOwed` (the real BZPX balance covers every ledger term the contract owes), the second stated twice, in the main file and in the full-surface file as `invariant_INV16_backingCoversOwed`. The emission side has its own two: the distributed total never exceeds the schedule and the schedule never exceeds `TOTAL_REWARDS` (`invariant_DistributedNeverExceedsTheScheduleWhichNeverExceedsTotalRewards`), and the reserve plus the distributed total is always what was funded (`invariant_ReservePlusDistributedIsAlwaysWhatWasFunded`). The full list by name is Appendix B. These are counts of what is declared; this paper does not report a pass rate or a mutant count for the staking suite. The number of `test*` functions, of test files and of mutants at `9958d5f` is not reported here; the 2.3 figures (37 files, 256 `test*`, 14 `invariant*` at `cc614f9`) are not carried. ### §25.8 Two deployments, one schedule each The staking contract is deployed twice, and the two deployments are independent. The repository describes them as "two independent deployments of this contract, each capped at 90,000,000 BZPX" (README.md:290, 306–310 @9958d5f): each has its own contract, its own reward reserve, its own protocol reserve and its own emission clock. Nothing crosses from one to the other: a position, a debt, a reserve or a breaker state in one deployment is invisible to the other, and a trip, an emergency or a haircut in one does not touch the other. The deploy script funds one contract per run: it requires the deployer to hold at least 90,000,000 BZPX and funds the emission atomically with the deployment (`script/Deploy.s.sol:5–12, 54, 79, 92–98` @9958d5f), and it does not fix the chain, so the same bytecode can be placed on two networks. The sum of the two caps, 180,000,000 BZPX, is the staking line of the token allocation in §20. It is a sum of two separate budgets, not a single pool: the contract does not know about its twin. A reader who wants the schedule of one deployment reads TAB-25.3; the schedule of the other is the same table, on its own clock. | Property | Deployment 1 | Deployment 2 | |---|---|---| | Emission cap (`TOTAL_REWARDS`) | 90,000,000 BZPX | 90,000,000 BZPX | | Emission length | 8 years from its own `emissionStart` | 8 years from its own `emissionStart` | | Reward reserve, protocol reserve | its own | its own | | Circuit breaker and emergency state | its own | its own | | Shared state | none | none | ^tab-25-8 The two deployments hold 90,000,000 BZPX each; their networks are named at launch, not in this paper. The sum, 180,000,000 BZPX, is the staking line of §20. The staking engine is pre-launch: the site gives its launch as Q2 2027, a schedule and not a deployment, and this paper gives no staking address because there is none yet. ![FIG-25.8 — Two independent staking deployments](https://blazephoenix.xyz/whitepaper/figs/v2.4/fig-25.8.svg) *FIG-25.8 — two side-by-side boxes, each with its own contract, reserves and clock, no arrow between them; underneath, the 90M + 90M = 180M line of §20.* ### §25.9 Clocks: seconds, blocks and chains The contract keeps time in two units, and a reader should know which quantity uses which. **Seconds** (`block.timestamp`): the emission schedule (E27), the interest index (E31), the lock and its expiry, the emergency timestamp (`emergencyTrippedAt`) and the maintenance gap (`MAINT_GAP_UNIT` = 15 minutes, L274). **Blocks** (`block.number`): exactly one guard, the same-transaction and flash-loan guard `MIN_DEPOSIT_BLOCKS` = 10 (L248): a deposit must age more than ten blocks before `withdraw`, `claimPureYield`, `lock` or a debt-free reset can act on it (for example L1031, L1083, L1112). Consequently the *wall-clock* length of that guard depends on the chain's block time, while every economic quantity runs on seconds and is the same on any chain. The wall-clock time of ten blocks differs by chain and is not asserted here. | Quantity | Constant | Unit | Value | |---|---|---|---| | Emission period | `HALVING_PERIOD` (L210) | seconds | 2 × 365 days = 63,072,000 s | | Emission length | `EMISSION_LENGTH` (L212) | seconds | 4 periods = 252,288,000 s (8 years) | | Lock bounds | `MIN_LOCK_DAYS`, `MAX_LOCK_DAYS` (L241–242) | days | 90 and 2,555 | | Deposit age guard | `MIN_DEPOSIT_BLOCKS` (L248) | blocks | 10 | | Emergency grace | `EMERGENCY_GRACE_PERIOD` (L269) | seconds | 30 days (retained for telemetry and UX, per its own comment) | | Maintenance gap | `MAINT_GAP_UNIT` (L274) | seconds | 15 minutes | ^tab-25-9 The period is 2 × 365 days, not two calendar years: leap days are not counted, so "eight years" in this chapter means 8 × 365 days = 2,920 days. The emergency clock behaves as in §25.2 and §25.11: the interest index and the emission clock freeze when emergency mode is entered, and `cancelEmergency` slides both clocks to the current time, so the halt is never charged or emitted retroactively. The reasoning behind treating time as a first-class quantity of an invariant is in `docs/INVARIANTS_AND_TIME.md` (an essay in the repository, not a catalogue; §10 applies it to this emission). ![FIG-25.9 — One deployment on a timeline](https://blazephoenix.xyz/whitepaper/figs/v2.4/fig-25.9.svg) *FIG-25.9 — a timeline of one deployment: emission start, the four two-year periods and the close at 2,920 days, with the lock bounds (90 d and 2,555 d) drawn as bars against it, to show that even the longest lock (2,555 d) is shorter than the programme, and that at deposit a lock is further capped to the whole days left to `emissionEnd` (`maxLockDaysAvailable()`; a longer request reverts), so no lock outlives the programme.* ### §25.10 Reading solvency yourself Solvency is a public view, free to call, and it is built so that a reader does not have to trust a dashboard. Four functions answer, in increasing detail. `owed()` returns every claim on the contract, recorded bad debt included and never netted; `backing()` returns the physical BZPX the contract holds. `isSolvent()` is true exactly when `backing() + dust >= owed()`: it is `!_hardBreach()` (L2206), with `CONSERVATION_DUST` = 1e10 wei (L267). The relationship the other direction is the trip condition: `isSolvent()` is false exactly when `tripBreaker` would succeed outside an emergency. A collateralisation ratio in WAD (`backing × 1e18 / owed`, floored; 1e18 means exactly covered) is published by a single producer, and `solvency()` reports that reading rather than a copy of it. `owed()` is a lower bound until the next sweep: a loss not yet recorded (a borrower whose accrued debt has passed her stake) is read only in part until a sweep, a liquidation, the borrower's own emergency exit or, in an emergency, a public `syncEquity` call records it, which is documented in `docs/KNOWN_ISSUES.md`. A view that reads true therefore means "solvent on what has been recorded", and the paper says so. `auditInvariants()` (L2270) returns a bitmask, one bit per check, 0 meaning all hold: bit 0 hard breach (balance + dust < owed); bit 1 a soft solvency signal (debt above 95 % of stake, or stake zero with debt outstanding); bit 2 `rewardReserve` above `TOTAL_REWARDS`; bit 3 a monotonicity snapshot of the two accumulators (raised by the permissionless `touchAuditSnapshot`, which moves no value); bit 4 boost bounded: the weights must be covered by the stake they were built on. Only bit 0 gates `tripBreaker`; bit 1 is a signal, not a guard, because a position may be transiently unhealthy before a liquidation. The modifier `conserves` (L467) is the mechanism behind all of it. Around every value-moving transaction it compares the change of the two sides of the master identity, each side a plain sum of non-negative state variables with no $\max(x, 0)$ clamp, so it stays linear in every regime, `balance + totalDebt + totalBadDebt + stakedOverdraw == totalStaked + rewardReserve + protocolReserve + pendingDistribution`, within dust, and reverts if a transaction leaks value. `emergencyWithdraw` and `syncEquity` sit outside it so they stay callable in a breach. The identity is checked on the *change* across the call, so historical rounding drift cancels and only a transaction that itself leaks value fails. *Try it (a procedure, not a result).* With any RPC of your choice, call `owed()`, `backing()`, `isSolvent()` and `auditInvariants()` on the staking contract at a block of your choice, and compare `backing() + 1e10` with `owed()` yourself. The four values and the block number are all you need; nothing here depends on our servers. `solvency()` (L2242) returns a `SolvencyReport` struct. | Bit | Name (in the source) | Meaning | Gates `tripBreaker`? | |---|---|---|---| | 0 | Conservation | balance + dust < owed (hard breach) | yes | | 1 | Solvency | debt > 95 % of stake, or stake 0 with debt | no, a signal | | 2 | EmissionCap | `rewardReserve` > `TOTAL_REWARDS` | no | | 3 | Monotonicity | an accumulator fell below its snapshot | no | | 4 | BoostBounded | weights exceed the stake they were built on | no | ^tab-25-10 ![FIG-25.10 — The five bits of auditInvariants](https://blazephoenix.xyz/whitepaper/figs/v2.4/fig-25.10.svg) *FIG-25.10 — the five bits of `auditInvariants` as five lamps, bit 0 highlighted as the only one wired to the breaker.* ### §25.11 The circuit breaker The staking contract has an emergency mode that stops new risk and lets stakers leave. There are two ways to enter it, and one way out. **Circuit breaker.** Anyone can call `tripBreaker()`, but only when the contract's BZPX balance plus dust is below what it owes. The guardian can call `declareEmergency()` at its discretion. Neither call moves funds: both pause deposit, borrow, lock and liquidate, and open `emergencyWithdraw`, which applies a haircut. Only the admin can call `cancelEmergency()`, and only once the invariant holds again. *Exact definition, from the source at `9958d5f` (read line by line).* `tripBreaker()` (L660) can be called by anyone, but reverts with `Staking__NoBreach` unless `_hardBreach()` is true, that is, unless the contract's real BZPX balance plus `CONSERVATION_DUST` (1e10 wei) is below `_owed()` (L2184); it reverts if the contract is already in emergency. `declareEmergency()` (L668) belongs to the guardian role and is discretionary: it does not depend on the breach condition. Neither moves funds. Both run the same body (`_enterEmergency`): the contract brings interest and emission up to the halt, then freezes both; it sets the emergency flag and the trip time; it records `totalRewardDistributed` as the anchor; it pauses the contract if it is not paused; and it emits `EmergencyDeclared` with a flag that says whether the trip was the permissionless breaker. While paused in emergency, `deposit`, `borrow`, `lock` and `liquidate` are closed; `repay` is also closed in emergency, and `emergencyWithdraw` is the only exit (see the table in §25.2). `emergencyWithdraw()` (L772) pays the position's net equity (stake less debt) and forfeits its unclaimed streams. The haircut applies only in a breached emergency: if the contract's balance is below the aggregate positive equity, each exit is scaled pro rata by balance ÷ aggregate equity, and the scaling is arranged so that the sum of payouts never exceeds the balance in any order of exits; if the contract is in emergency but holds enough, the full net equity is paid and the haircut does not engage. `cancelEmergency()` (L684) belongs to the admin role and reverts if the contract is not in emergency or if `_hardBreach()` is still true; it also refuses if the distributed total moved during the halt (a meta-guard), and on success it slides both clocks to now and clears the flag. The contract stays paused after `cancelEmergency`; the admin calls `unpause()` separately (L642), which itself is not available during an emergency. The reason the trigger can be permissionless is stated in the source: nobody can lower the contract's balance except through flows that lower `_owed()` by the same amount, and donations only raise the balance, so the condition can fire only on a genuine shortfall, never on a healthy book, and it is reversible by the admin once the reading clears. The worst a spurious trip can do is a temporary pause that the admin can undo. This is the property that `invariant_INV20_breakerCannotTripWhileSound` (`InvariantsFullSurface.t.sol:421` @9958d5f) tests, and, once the contract is deployed (coming soon), the reader can check the same condition on chain with `isSolvent()` (§25.10). | Call | Who | Condition | Moves funds | Effect | |---|---|---|---|---| | `tripBreaker()` | anyone | balance + dust < owed (`_hardBreach`) | no | enters emergency | | `declareEmergency()` | guardian | at its discretion | no | enters emergency | | `emergencyWithdraw()` | a position holder | emergency active | its own exit only | pays net equity, pro rata if the balance is short | | `cancelEmergency()` | admin | emergency active, `_hardBreach()` false, and no emission distributed since the trip | no | leaves emergency; contract stays paused | | `unpause()` | admin | not in emergency | no | reopens the doors | ^tab-25-11 *Illustration of the haircut (arbitrary numbers, not a forecast).* Suppose a breached emergency in which the contract holds 80 BZPX and the positions' aggregate net equity is 100 BZPX. Every exit is scaled by 80 ÷ 100 = 0.8, so a position of net equity 10 receives 8, whichever order the positions leave in. If the contract held 100 or more, the position would receive 10. This is a statement of what the code does when a shortfall exists. It is not a statement that a shortfall cannot exist, and it is not insurance: the haircut is the contract's rule for dividing a loss, not a promise to avoid one. No external audit has been done, and the repository's pre-launch notice applies (§25 intro). ![FIG-25.11 — Circuit-breaker states](https://blazephoenix.xyz/whitepaper/figs/v2.4/fig-25.11.svg) *FIG-25.11 — a state diagram with three states (running, emergency, paused after cancel), the two entry doors (`tripBreaker` gated by balance + dust < owed; `declareEmergency` gated by role) and the one exit door (`cancelEmergency`, admin, only when the invariant holds), with `emergencyWithdraw` drawn inside the emergency state.*