Wrong calculation of `tickCumulatives` due to hardcoded pool fees
The contract hardcoded a 500 fee tier when reading tick cumulatives from a Uniswap V3 pool, so for tokens whose liquidity sits in other fee tiers the time-weighted price data was wrong. That produced an incorrect slippage check, raising the risk that a rebalance transaction would execute at a bad price.
Bauchibred Follow with OxZ00mer, ast3ros and 9 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-06-real-wagmi-judging/issues/48
Found by
Bauchibred, OxZ00mer, ast3ros, bitsurfer, crimson-rat-reach, duc, josephdara, mahdiRostami, n1punp, n33k, shogoki, stopthecap
Summary
Wrong calculation of tickCumulatives due to hardcoded pool fees
Vulnerability Detail
Real Wagmi is using a hardcoded 500 fee to calculate the amountOut to check for slippage and revert if it was to high, or got less funds back than expected.
IUniswapV3Pool(underlyingTrustedPools[500].poolAddress)
There are several problems with the hardcoding of the 500 as the fee.
- Not all tokens have
500fee pools - The swapping takes place in pools that don't have a
500fee - The
500pool fee is not the optimal to fetch thetickCumulativesdue to low volume
Specially as they are deploying in so many secondary chains like Kava, this will be a big problem pretty much in every transaction over there.
If any of those scenarios is given, tickCumulatives will be incorrectly calculated and it will set an incorrect slippage return.
Impact
Incorrect slippage calculation will increase the risk of rebalanceAll() rebalance getting rekt.
Code Snippet
https://github.com/sherlock-audit/2023-06-real-wagmi/blob/main/concentrator/contracts/Multipool.sol#L816-L838 https://github.com/sherlock-audit/2023-06-real-wagmi/blob/main/concentrator/contracts/Multipool.sol#L823
Tool used
Manual Review
Recommendation
Consider allowing the fees as an input and consider not even picking low TVL pools with no transations
Discussion
ctf-sec
There are pools that are support not only 500 fee tiers
because the impact result in Incorrect slippage calculation
the severity is still high
fann95
fixed , quotePoolAddress can be changed https://github.com/RealWagmi/concentrator/blob/fbccf1caf28edbb23db8c7e0409d0c40c3a56461/contracts/Multipool.sol#L848C61-L848C77
0xffff11
While the fix allows to change the address of the pool, it is not the best fix possible. The best would either store the pools in a mapping with their fees as a key, or pass directly the address as a parameter.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The pool address used for price and slippage calculations was selected by a hardcoded fee tier rather than the fee tier of the pool actually used for the swap.
Impact
Incorrect slippage calculation will increase the risk of `rebalanceAll()` rebalance getting rekt.
What the attacker needed
Tokens whose liquidity is not in the 500 fee pool; deployment on chains with thin liquidity
The fix
The pool address was made configurable, though a reviewer noted that keying pools by fee tier or passing the address directly would be better.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Uniswap pools for the same pair of tokens exist at several fee levels, such as 0.05% or 0.3%. The code always looked at the 0.05% pool to estimate prices, even when the actual trade happened in a different pool. If that pool is quiet or missing, the price estimate is wrong and the safety check on the trade becomes unreliable.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.