crytic / echidna-streaming-series Goto Github PK
View Code? Open in Web Editor NEWA 6-part series on how to use Echidna on real-world codebases
License: MIT License
A 6-part series on how to use Echidna on real-world codebases
License: MIT License
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%
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.