Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: high
Invalid

Missing check for assets duplicate

## Summary
Lack of duplicates check for the `assets` array in `FeeDistributionBranch::_performMultiDexSwap`.
## Vulnerability Details
In `FeeDistributionBranch::_performMultiDexSwap` a struct instance to be used for swap operation is created before the swap
operation. However, before the creation of this instance there is not check to enforce that no duplicate asset(that is the
next asset is not the same as the current one) is present in `assets` array.
```javascript
SwapExactInputSinglePayload memory swapCallData = SwapExactInputSinglePayload({
tokenIn: assets[i],
tokenOut: assets[i + 1],
amountIn: amountIn,
recipient: address(this)
});
```
For example: Assuming the `assets` array contain USDT, USDT, USDC, WETH. This means USDT will be swapped to USDT.
## Impact
1. Waste of gas during swap
2. Potential Swap Failures
## Recommendations
Enforce a check that `i` and `i+1` are not the same.
```diff
+ error DuplicateAsset();
.
.
+ if(assets[i] == assets[i + 1]) {
+ revert DuplicateAsset();
+ }
```
Updates

Lead Judging Commences

inallhonesty Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.