when direction=1 the direction on pools could be wrong
Summary
since we are changing direction=1 when we change the value it will only sellBase() not sellQuote.
So if direction=1 then In the first iteration of the loop it's going to sell quote tokens but after that it's going to sell Base tokens which I don't think it intended
Vulnerability Detail
when a user calls mixSwap function and sets directions =1 in the first iteration of the loop directions gets changed to zero and once it's set to zero sellBase function is always called.
Impact
It can cause loss of funds in the most extreme cases but I don't think intended and can make a user swap lost funds because they didn't sell quote tokens.
In the comments, it says this
/// @param directions pool directions aggregation, one bit represents one pool direction, 0 means sellBase, 1 means sellQuote
which is not true because 1 in the loop with bit shifting will be different.
maybe make some sort of offset every iteration of the loop to make sellQuote and sellBase functions switch off or have an extra pram like:
pseudocode:
directions=5 then the sell base is always called
directions=2 then the sell quote is always called
Or just have in the UI the calculation for bigger numbers what would happen in the loop and tell the user instead of letting random input which can cause loss of funds.
simon135
medium
when
direction=1
the direction on pools could be wrongSummary
since we are changing
direction=1
when we change the value it will onlysellBase()
notsellQuote
. So ifdirection=1
then In the first iteration of the loop it's going to sell quote tokens but after that it's going to sell Base tokens which I don't think it intendedVulnerability Detail
when a user calls
mixSwap
function and setsdirections =1
in the first iteration of the loopdirections
gets changed to zero and once it's set to zerosellBase
function is always called.Impact
It can cause loss of funds in the most extreme cases but I don't think intended and can make a user swap lost funds because they didn't sell quote tokens. In the comments, it says this
which is not true because 1 in the loop with bit shifting will be different.
Code Snippet
https://github.com/sherlock-audit/2022-11-dodo/blob/main/contracts/SmartRoute/DODORouteProxy.sol#L292
Tool used
Manual Review
Recommendation
maybe make some sort of offset every iteration of the loop to make
sellQuote
andsellBase
functions switch off or have an extra pram like:Or just have in the UI the calculation for bigger numbers what would happen in the loop and tell the user instead of letting random input which can cause loss of funds.