Don't allow swapping the same token #89
Labels
1 (Low Risk)
Assets are not at risk. State handling, function incorrect as to spec, issues with comments
bug
Something isn't working
sponsor acknowledged
Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Handle
Ruhum
Vulnerability details
Impact
A user might mistakenly swap the same two tokens resulting in them losing funds due to the fees, etc.
I think we can assume that no user would really want to swap the same token. So that might as well be prohibited by checking the passed token indexes in the respective functions.
Uniswap for example doesn't allow creating a pool with the same two tokens, see here
Proof of Concept
Here are the relevant functions IMO:
https://github.com/code-423n4/2021-11-bootfinance/blob/main/customswap/contracts/Swap.sol#L356
https://github.com/code-423n4/2021-11-bootfinance/blob/main/customswap/contracts/Swap.sol#L461
Tools Used
Manual Analysis
Recommended Mitigation Steps
Add a require statement:
`require(tokenIndexFrom != tokenIndexTo, "swapping the same token is not allowed");
The text was updated successfully, but these errors were encountered: