Skip to content

[Certora] Spec for balance and lossIndex#534

Draft
jhoenicke wants to merge 12 commits into
mainfrom
jochen/balanceIndex
Draft

[Certora] Spec for balance and lossIndex#534
jhoenicke wants to merge 12 commits into
mainfrom
jochen/balanceIndex

Conversation

@jhoenicke
Copy link
Copy Markdown
Collaborator

@jhoenicke jhoenicke commented Mar 18, 2026

Work in progress: Verification currently times out.

This adds a specification for the lossIndex. The goal is to prove that the sum of all positive balanceOfAfterSlashing is less equal to totalUnits.

We prove as invariant that (sumof balance/user.lossIndex*PRECISION) * obligation.lossIndex <= totalUnits*PRECISION where the sum only ranges over the positive balances. We keep the values balance/user.lossIndex as a fixed point number in the spec with a very large PRECISION value that avoids rounding. The value is 0 if the balance is negative or the user.lossIndex is 0. Think of PRECISION as being 2^128!, a number that is divisible by any positive uint128. We leave PRECISION unspecified and only require it to be positive and divisible by the accessed user.lossIndex. So the solver can choose any positive value that is divisible by any user lossIndex it sees.

There are currently timeouts related to static analysis; this is why the pull request is not ready yet.

Everything except withdraw, liquidate, and take is already verified, but these missing functions are the most important ones.

@jhoenicke jhoenicke requested a review from QGarchery March 18, 2026 08:58
@jhoenicke jhoenicke marked this pull request as draft March 18, 2026 08:59
@jhoenicke jhoenicke requested a review from lilCertora March 18, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants