Git Product home page Git Product logo

echidna-streaming-series's Issues

Potential issue with `testPathIndependenceForSwaps` test from part 3/4

Hello,

I am fuzzing Uniswap v2 and I believe I have found a potential issue with the testPathIndependenceForSwaps test from part 3/4.

When running echidna with testLimit equals to 100k and 4 workers, the test breaks:

swapExactTokensForTokensPathIndependence(uint256): failed!๐Ÿ’ฅ
  Call sequence:
    testProvideLiquidityInvariants(7222,148)
    testRemoveLiquidityInvariants(1412263)
    testSwapTokens(878955802143800039497958245)
    testPathIndependenceForSwaps(0)

I believe this is caused by a wrong assumption that swapping back and forth only costs 3% in fees.

    /*
    Swapping x of testToken1 for y token of testToken2 and back should (roughly) give user x of testToken1.
    The following function checks this condition by assessing that the resulting x is no more than 3% from the original x.
    ...
    */
    ...

        assert((x - xOut) * 100 <= 3 * x); // (x - xOut) / x <= 0.03; no more than 3% loss of funds

Instead, each swap takes 3%, so the back-and-forth maximum loss should be 100% - (100%-3%)*(100%-3%) = 5.91%

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.