Piku Redemption Fund Conservation

Every unit of modeled backing is either distributed, queued, retained, or assigned to treasury fees.

Piku uses an Inverter oracle-priced funding manager for USP redemption. A user sells issuance tokens, the funding manager computes a collateral redemption amount, fees are split, and a manual payment queue later settles the order.

The property tracks one unit of value: redemption backing. After each modeled accounting transition, backing must be accounted for as user distributions, queued redemptions, retained backing, or treasury fees.

Why It Matters

A redemption system can look solvent while silently losing value between buckets. If an order creation or queue settlement step changed one bucket without the matching opposite update, users could be underpaid, fees could be overcounted, or retained backing could be overstated.

The invariant turns that accounting question into a checkable statement. The sum of all backing already distributed, still queued, still retained, and assigned to fees must equal the initial backing committed to the redemption pool.

How This Was Modeled and Proven

The benchmark pins the docs-matching Inverter implementation at commit 8b7bc438344d646bab05b751c8eb4a7f0c8ca588. The modeled Solidity source is FM_PC_Oracle_Redeeming_v1.sol.

The Verity model keeps the Solidity names for the functions and storage it models, including _sellOrder, amountPaid, and _openRedemptionAmount. Each non-trivial block in Contract.lean is annotated with the Solidity lines it models.

The proof first establishes exact slot-write facts for order creation and settlement. It then rewrites the readable spec in Specs.lean using those facts to discharge the fee split and bucket moves. The reference solution is in Proofs.lean.

Scope

Included: the source functions in scope are _sellOrder and amountPaid. The payment processor functions processPayments and executePaymentQueue provide context for successful settlement, but the model focuses on the accounting updates after a valid order exists.

The Solidity contract stores _openRedemptionAmount. The benchmark adds ghost accounting slots for initial backing, distributed backing, remaining backing, protocol fees, and project fees. Those slots make Piku's fund-conservation requirement explicit in the model.

Oracle pricing, ERC20 transfer return behavior, access control, payment-order array shape, blacklist fallback, and failed payment accounting are outside this case. The proof covers the successful redemption order creation and successful queue settlement accounting transitions.

Proof artifacts
  • Contract.lean contains the model, with each non-trivial block annotated with the Solidity lines it models.
  • Specs.lean contains the readable spec.
  • Proofs.lean contains the reference solution.

Conditional on the modeled transition preconditions below, all four public theorem targets compile. The fund-conservation proofs discharge the fee-split and bucket arithmetic in Lean. The proof in Proofs.lean uses no sorry and no axiom.

FunctionTheoremStatus
_sellOrder_sellOrder_records_redemption_bucketsproven
_sellOrder_sellOrder_preserves_fund_conservationproven
amountPaidamountPaid_records_distributionproven
amountPaidamountPaid_preserves_fund_conservationproven
Verify it yourself
git clone https://github.com/lfglabs-dev/verity-benchmark
cd verity-benchmark
git checkout piku-fund-conservation
lake build Benchmark.Cases.Piku.FundConservation.Compile

If the build succeeds, the theorem targets compile under the stated preconditions. Source repository

Hypotheses

These theorem preconditions restrict the modeled transition.

  • redemption amount is non-zero

    _sellOrder theorem hypothesis

    The redemption amount must be non-zero: total != 0. This mirrors the scoped Solidity guard on the sell path.

  • total fees stay below 100%

    _sellOrder theorem hypothesis

    The combined protocol and project fee rate must stay below 100 percent: protocolFeeBps + sellFee < 10000. Without this, the fee split can stop representing a valid redemption amount.

  • enough backing exists before a sell order

    _sellOrder theorem hypothesis

    The ghost solvency ledger must hold enough backing before an order is created: total <= remainingBacking. This is a benchmark precondition for the explicit fund-conservation ledger.

  • settlement stays within open redemptions

    amountPaid theorem hypothesis

    Settlement cannot deduct more queued backing than the funding manager currently records as open redemption amount: amount <= _openRedemptionAmount.

  • protocol fee fits inside the order

    amountPaid theorem hypothesis

    The protocol fee paid during settlement must fit inside the settled order amount: protocolFeeAmount <= amount. This keeps the user distribution non-negative.

  • funds add up before each step

    Invariant induction hypothesis

    The pre-state buckets must sum to initialBacking. Preservation theorems are local transitions. They assume this invariant held before the transition and prove it still holds afterward.

Learn More

Piku documentation, including the public contract/module references used for scoping.

What is a formal proof? A short explanation for non-specialists.