Skip to content

About

Fixed-term zero-coupon bond: buy at a discount, redeem par at maturity, fully reserve-backed (redemption always honored), multi-series, full-backing solvency invariant

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Fixed-Term Zero-Coupon Bond (BondManager)

A fully-collateralized zero-coupon discount bond issuer. One contract manages many independent bond series. In a series, an issuer sells bonds at a discount: a bond costs price today and redeems for a larger fixed faceValue at maturity. Every series is kept fully backed at all times, so redemption is unconditionally guaranteed.

reserve(series)  >=  bondsOutstanding(series) * faceValue      (always)

Why redemption is always honored

An ordinary bond is a promise: the issuer intends to pay face value at maturity, but a defaulting issuer can leave holders unpaid. This contract removes the promise and replaces it with collateral. A bond can only be sold if the series' reserve already covers its full face value after the sale — the sale is gated on solvency. Because backing can never lag issuance, the reserve can never be short at maturity, and there is no default path to handle. That impossibility is the whole point of the design versus an under-collateralized bond.

Solvency model — single reserve, surplus withdrawal

Every token unit belonging to a series lives in one number, reserve.

  • Buyers pay count * price INTO the reserve. Those proceeds count toward backing, so the issuer only has to pre-fund the discount shortfall (faceValue - price per bond) through fund(). Full face backing is thus financed jointly by buyer proceeds and issuer top-up.
  • buy reverts Underfunded if, after the sale, reserve would be below bondsOutstanding * faceValue. Solvency is enforced at sale time.
  • redeem removes exactly count * faceValue from both reserve and bondsOutstanding, so the backing inequality is preserved by construction.
  • issuerWithdrawSurplus pays out only reserve - bondsOutstanding * faceValue — strictly the un-owed buffer (accumulated proceeds plus any over-funding). It can never touch the funds backing live bonds. Once every bond has matured and redeemed, bondsOutstanding == 0, so the entire remainder becomes withdrawable surplus.

This is the cleaner of the two candidate models: with a single reserve number, per-series conservation is simply reserve == tokensIn - tokensOut, and there is no separate "proceeds pot" to reconcile.

Issuer surplus rule

The issuer can pull reserve − bondsOutstanding·faceValue at any time, and never one wei more. No sequence of buys, redemptions, transfers, withdrawals, or time warps lets the issuer reach the funds owed to outstanding bondholders.

Rounding

No division occurs anywhere — faceValue and price are absolute per-bond token amounts and count is an integer, so count * price and count * faceValue are exact. There is no rounding, hence nothing can ever round against the reserve.

Lifecycle

  1. createSeries(token, faceValue, price, maturity, maxBonds) — issuer defines a series (requires faceValue > price > 0, maturity > now, maxBonds > 0) and becomes its owner. Returns seriesId.
  2. fund(seriesId, amount) — issuer deposits backing (at least the discount shortfall for the bonds it expects to sell).
  3. buy(seriesId, count) — buyer pays count * price, receives count bonds. Reverts on SaleClosed (at/after maturity), MaxBondsExceeded, or Underfunded.
  4. transferBonds(seriesId, to, count) — bonds are transferable; a pure ledger move that leaves backing untouched. The recipient inherits redemption rights.
  5. redeem(seriesId, count) — at/after maturity, holder burns count bonds and receives count * faceValue.
  6. issuerWithdrawSurplus(seriesId) — issuer withdraws the un-owed surplus.

Views

series(id), bondsOf(id, holder), reserve(id), backingRequired(id), surplus(id), redeemableAt(id) (maturity timestamp), isMatured(id), seriesCount().

Fee-on-transfer / rebasing tokens: unsupported

BondManager tracks reserves by explicit bookkeeping, so a token that delivers fewer units than requested would desync the reserve from the real balance. Every inbound pull measures the actual balance delta and reverts FeeOnTransferUnsupported if it differs from the requested amount — the contract rejects such tokens loudly rather than mis-accounting silently. Use standard, non-rebasing, non-fee ERC-20s. (test/mocks/FeeOnTransferERC20.sol exists purely to assert this rejection.)

Security properties (enforced by tests)

  • Full-backing solvency — reserve >= bondsOutstanding * faceValue for every series, under every buy / redeem / withdraw / transfer / time sequence.
  • Conservation — per series, reserve == tokensIn − tokensOut; the sum of series reserves equals the contract's token balance; no cross-series mixing.
  • Can't redeem before maturity; can't buy past maxBonds; can't buy when it would underfund; issuer can't withdraw backing owed; double-redeem is impossible (bonds are burned before payout); transfers conserve total bonds.
  • nonReentrant on every state-changing external entry point that moves tokens; effects-before-interaction ordering; SafeERC20 throughout.

Tests

55 tests, all green — 51 unit/fuzz + 4 stateful invariants.

Three invariants (invariant_FullBacking, invariant_Conservation, invariant_SurplusDecomposition) each run 64 × 200 = 12,800 calls with 0 reverts under fail-on-revert = true (pinned inline), driving two series over a shared token through a bounded, revert-free handler — proving the suite is non-hollow.

Deep dive (v2)

A second adversarial pass hammered the full-backing solvency model across every buy / fund / redeem / withdraw-surplus / transfer / time interleaving, including cross-series interference over a shared token, boundary surplus math, reentrancy on redeem/buy/withdraw, per-series authorization, and the checked-arithmetic overflow behaviour of the outstanding * face backing gate.

Finding: no solvency bug. The invariant reserve ≥ outstanding·faceValue is preserved by construction on every path — the sale gate enforces it at issuance, redeem removes exactly count·face from both sides, surplus withdrawal floors the reserve at backing, and transfers touch neither term. Overflow of the backing product is self-limiting: the buy that would create it reverts under 0.8 checked math, so an under-backed bond can never be minted.

Hardening added this pass:

  • A fourth invariant, invariant_BackingHoldsUnderArbitraryCalls, driven by an un-clamped handler that fires arbitrary (revert-tolerated) buys/redeems. Unlike a gate-clamped handler, it actually probes the solvency gate: deleting the Underfunded check makes it fail (verified by mutation).
  • Cross-function reentrancy tests re-entering buy and issuerWithdrawSurplus mid-payout (both stopped by the shared guard); a non-holder-redeem test; a per-series issuer-authorization test; an overflow self-limit test; and a full-lifecycle interleave fuzz asserting exact face payout and intact backing.
  • Mutation sanity: disabling the buy solvency gate fails 2 unit tests and the new adversarial invariant; reverted after confirming.
forge test           # unit + invariant
forge test --match-contract Invariant
forge build --sizes  # BondManager runtime: 3,645 B (well under EIP-170's 24,576)
forge fmt --check

Deploy

forge script script/Deploy.s.sol:Deploy --rpc-url <RPC> --broadcast

BondManager takes no constructor arguments; issuers create series after deployment.

About

Fixed-term zero-coupon bond: buy at a discount, redeem par at maturity, fully reserve-backed (redemption always honored), multi-series, full-backing solvency invariant

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages