Midas Growth-Aware Feed Safety Guarantees
If a submitted round satisfies the safe path's guardrails, setRoundDataSafe succeeds and writes that round exactly as submitted.
If it does not satisfy those guardrails, the safe path rejects it before it can update the feed.
Names are simplified on purpose: answer, start, apr, and now are the call inputs.oldFeed is the feed state before the call.safeInputsOk(...) means the submission satisfies the safe path's guardrails.safeAccepted(...) means setRoundDataSafe succeeds.writesSubmittedRound(...) means the newly written round stores the submitted answer, timestamp, block time, and APR exactly.
Midas's CustomAggregatorV3CompatibleFeedGrowth is an onchain price feed that stores a raw answer, a start timestamp, and a growth APR for each round. In other words, the contract does not treat the stored answer as the final price forever. Starting from the round's startedAt, it updates that answer over time using the configured APR. This lets the feed track assets whose price is expected to increase between submissions, instead of staying flat until the next manual update.
That makes the safe submission path economically important. When a new round is submitted, the contract compares the new growth-adjusted price at the current block time against the previous growth-adjusted price at the current block time. It does not just compare the two stored round values as if no time had passed.
In the shape of this contract, most of the risk is operator risk: an authorized updater submits the next round by hand. Formal verification helps here by showing exactly what the safe wrapper setRoundDataSafe does on both sides of the guard. In particular, the benchmark now exposes human-readable theorems saying that guardrail-safe submissions are accepted and written exactly as submitted, while submissions outside those guardrails are rejected.
Why It Matters
This is a manually updated price feed. That means the main operational risk is not an adversary exploiting arithmetic from nowhere, but an authorized operator submitting a round that should have been rejected by the feed's own configured rules.
If the safe path accepted a submission outside those rules, every downstream integration reading the feed would inherit a price the contract itself was supposed to screen out. The point of this case study is to make those guardrails explicit and machine-check that they hold on the guarded entrypoint.
How This Was Modeled and Proven
The benchmark isolates the contract slice that determines whether a safe submission is accepted and what gets written if it is. That includes the current configuration fields, the storage for the latest round, and the next-round write path that records the new answer, timestamps, APR, and round id.
The updated spec layer also introduces human-readable helpers such as safeAccepted, safeRejected, safeInputsOk, and writesSubmittedRound. Those names let the top-level theorem talk about the user-facing behavior of the safe setter instead of only exposing lower-level arithmetic lemmas.
The model also captures the growth arithmetic used to reconstruct the previous live price and the candidate live price of the new submission. This matters because the safety check is about the economically meaningful price at the current moment, not just the raw number stored in storage.
Deviation is modeled with the contract's special zero-price branch, where a candidate live price of zero is treated as a full 100% move. The negative-deviation branch used by onlyUp is included as well, along with the underlying band checks from setRoundData.
Scope
This case study is about setRoundDataSafe, the guarded submission path. It also models the underlying write behavior of setRoundData, because a successful safe call ends by writing a new round through that path.
- Positive-path guarantee: if a submitted round satisfies the safe path's own guardrails, then
setRoundDataSafesucceeds and the next round stores exactly the submitted answer,startedAt, current block timestamp, and growth APR. - Rejection guarantee: if the submitted round does not satisfy those guardrails, then
setRoundDataSaferejects before the feed can be updated.
The comparison is growth-aware on both sides. The previous round is first turned into a live price at the current block time, and the incoming submission is also projected forward to the current block time before deviation is measured.
In the new spec layer, those guardrails are bundled into a readable helper safeInputsOk. It packages the deviation check, time ordering, one-hour gap, onlyUp behavior, and the answer/APR range checks that the safe path relies on.
Out of scope: direct calls that bypass setRoundDataSafe and invoke setRoundData directly, access control plumbing, events, unrelated read-only interface methods, downstream protocol integrations outside this contract.
Proof artifacts
This case is now organized around two human-readable headline specs in Lean 4: one theorem for accepted submissions and one theorem for rejected submissions. The corresponding proof file in the Verity benchmark repository is sorry-free, so the proved claims in the table are accepted by Lean's kernel rather than by informal review.
The rejection theorem is proved by contrapositive: any successful safe call is shown to satisfy safeInputsOk, so a call that does not satisfy safeInputsOk must reject. The helper packages the lower-level deviation, timing, monotonicity, onlyUp, and band checks into a single readable condition.
| Function | Theorem | Status |
|---|---|---|
| setRoundDataSafe | setRoundDataSafe_accepts_and_writes_submitted_roundsafeInputsOk -> accepts and writes submitted round | Proven |
| setRoundDataSafe | setRoundDataSafe_rejects_outside_guardrailsnot safeInputsOk -> rejected | Proven |
| setRoundDataSafe | setRoundDataSafe_zero_rejected_under_strict_deviationZero price rejected below 100% cap | Proven |
Verify it yourself
git clone https://github.com/lfglabs-dev/verity-benchmark cd verity-benchmark git checkout 07564a24d6a85eefc0479af3a547381bb7a40a68 lake build Benchmark.Cases.Midas.CustomFeedGrowthSafe.Proofs
If the build succeeds, the proofs are correct. Source repository
Hypotheses
The proofs use zero axioms. The accept/reject theorems are phrased through the helper safeInputsOk. The two assumptions below matter specifically for the separate zero-price rejection corollary.
the feed already has a previous roundsetRoundDataSafe compares against lastAnswer() only when history exists
The feed already has a previous round, so
setRoundDataSafecompares the new submission againstlastAnswer(). With no prior round, it skips the deviation check entirely. The zero-price rejection corollary only covers states where this comparison runs.max price deviation is set below 100%Fixed-point threshold in the contract's percentage units
The configured deviation cap is strictly below 100%:
maxAnswerDeviation < 100 * 1e8in the contract's fixed-point percentage units. The contract allows a cap up to and including 100%. At exactly 100%, the zero-price rejection corollary no longer follows from the deviation check alone.
Learn More
Upstream Solidity contract, the production source modeled in this case.
Verity benchmark repository, which contains the formal specification, machine-checked proofs, and the broader benchmark suite this case belongs to.
What is a formal proof? A short explanation for non-specialists.
More research
Kuru V2 Shared Withdrawal Budget
A successful batch of ordinary withdrawals in the model reduces the shared budget by exactly its recorded payout value, across all accounts and tokens.
Dromos MetaDEX Allocation Conservation
In the root-ledger model, chain allocations sum to committed voting power.

KPK Shares Settlement Accounting
A successful kpkShares settlement batch processes each eligible request at most once and accounts exactly for its fees, shares and asset transfers.