Open Edward-Lo opened 4 years ago
It's just a mathematic problem. Check the formula in "Quote" function, if use amountADesired calculating estimatedB bigger than amountBDesired, in this case, use amountBDesired calculating estimatedA will never greater than amountADesired.
I'll add Assert(estimatedA <= amountADesired, "Insufficient A Amount");
for more comprehensible, thanks for your suggestion.
No math should ever be done when it comes to assets without assertions first. I do not know where to start with the issues as I am independently auditing this repo. The handful of issues in place indicate a complete lack of understanding in the basic framework on which this is built.
I came here to look over the contracts, but there are so many issues I am not quite sure even where to begin. Both contracts are ripe with problems. The math library from C# can be bypassed due to a perceived overload from the NEO libraries that can be called from the browser; timestamps are not implemented, leaving the base libraries open for time-based attacks; and the wrappers do not correctly correlate to prices, leaving the potential for whales to swallow up one half of a pool due to extreme arbitrage opportunities.
This project, with a team of a dozen developers, should not be released for at least 6 more months... I feel sorry that it is being rushed as it could have been a viable DEX; but is in no way prepared to be a "full stack platform".
Description
FlamingoSwapRouter contract provides interfaces for users to add/remove liquidity and swap tokens. The function
AddLiquidity
can add tokens to the pools and mint liquidity tokens for the user.The parameters
amountADesired
andamountBDesired
are the maximum tokens that can be transferred in. The final input token amountsamountA
andamountB
should be less thanamountADesired
andamountBDesired
.However, in the case
estimatedB
is bigger thanamountBDesired
. The contract misses a check thatestimatedA
should also be less thanamountADesired
.Recommendation