Skip to content

[Certora] update position missing rules#970

Open
QGarchery wants to merge 6 commits into
certora/offer-splittingfrom
certora-update-position
Open

[Certora] update position missing rules#970
QGarchery wants to merge 6 commits into
certora/offer-splittingfrom
certora-update-position

Conversation

@QGarchery
Copy link
Copy Markdown
Collaborator

Proves the following items in the wish list:

  • similarly use updatePositionView(affectedUser) instead of creditOf(affectedUser) for the credit after the op or prove that both functions return the same.
  • updatePosition and updatePositionView give the same result

@QGarchery QGarchery self-assigned this Jun 2, 2026
@QGarchery QGarchery mentioned this pull request Jun 2, 2026
69 tasks
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6103979082

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread certora/specs/OnlyAuthorizedCanChangeUpdatedCredit.spec Outdated
ghost ghostMulDivDown(uint256, uint256, uint256) returns uint256 {
// Axioms proven in MulDiv.spec.
axiom forall uint256 y. forall uint256 z. ghostMulDivDown(0, y, z) == 0;
axiom forall uint256 x. forall uint256 z. ghostMulDivDown(x, 0, z) == 0;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Axiom 2 is not actually proven in Muldiv.spec no ? we should extend mulDivZero to prove that assert mulDivDown(a, 0, d) == 0; and assert mulDivUp(a, 0, d) == 0; i think.
Axiom 3 is ok as it is derivable

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was added already, but actually it will be the case only after #542


/// An unauthorized caller cannot change a user's updated credit except via liquidate.
/// Assumes no reentrancy: callbacks and token transfers are not modeled as re-entering Midnight, so re-entrant collateral changes are not covered.
rule onlyAuthorizedCanChangeUpdatedCreditExceptLiquidate(env e, method f, calldataarg args, Midnight.Market market, address user) filtered { f -> f.selector != sig:liquidate(Midnight.Market, uint256, uint256, uint256, address, bool, address, address, bytes).selector } {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can also prove onlyAuthorizedCanChangeUpdatedPendingFeeExceptLiquidate as face vzalue of a lender is actually credit - pendingFee maybe it's interesting and a natural companion to this rule , wdyt ?

@QGarchery QGarchery changed the base branch from main to certora/offer-splitting June 3, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants