The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: medium
Valid

Hardcoding pool fee can result in unnecessary losses for user

Summary

Hardcoding pool fee tier can result in losses for vault users in some situations

Vulnerability Details

Observe the following code

https://github.com/Cyfrin/2023-12-the-standard/blob/91132936cb09ef9bf82f38ab1106346e2ad60f91/contracts/SmartVaultV3.sol#L221

The function swap allows the vault user to swap tokens using uniswap V3. In the swap function, various parameters are set up to initiate the swap. However, the pool fee is hardcoded to 3000 (0.3%) shown here

ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams({
tokenIn: inToken,
tokenOut: getSwapAddressFor(_outToken),
fee: 3000,
recipient: address(this),
deadline: block.timestamp,
amountIn: _amount - swapFee,
amountOutMinimum: minimumAmountOut,
sqrtPriceLimitX96: 0
});

. In uniswap V3, there are 3 pool tiers (0.05%, 0.3%, or 1%). While there is no restriction on which pool tier one can chose to conduct swaps, 0.3% is not the most cost efficient option for each pool.

See the uniswap Docs here

https://docs.uniswap.org/concepts/protocol/fees

Let's say that the vault user is swapping in a pool of very low volatility (e.g. DAI and USDT), instead of using the cost efficient pool tier of .05% which is best for stablecoin pools, the protocol defaults to .3% which is better for pools with medium volatility. If the amount being swapped is very high, the amount of unnecessary losses could be significant.

I am putting this bug as a med as this is a systemic issue where the overall losses will add up for users

Impact

Users can lose funds in some situations

Tools Used

Manual Review

Recommendations

Allow the owner to set the pool fee tier

Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

fixed-uni-fee

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

hardcoded-fee

Support

FAQs

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