Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Stretch Goal: prove x*y=k #43

@d-xo

Description

@d-xo

Adding this just as a note really, and the idea is stolen from this issue in k-dss.

We could introduce a new kind of block into act: invariant that would look something like this:

invariant K of UniswapV2Exchange

storage

    reserve0_reserve1_blockTimestampLast |-> #WordPackUInt112UInt112UInt32(Reserve0, Reserve1, _) => _
    totalSupply |-> TotalSupply => _
    kLast       |-> KLast => _

such that

    (Reserve0 * Reserve1) / (TotalSupply ^ 2) == KLast

This would generate a K spec with symbolic calldata that proves that the generalized invariant holds at the end of every possible call to the contract. This proof could be made fast by implicitly reusing all the other specs (i.e. implicitly including every other spec for UniswapV2Exchange in a calls block for each invariant block).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions