Submitted by ktg
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/automators/Automator.sol#L151-L153
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/automators/AutoExit.sol#L162-L169
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/transformers/AutoRange.sol#L157-L164
Contract AutoRange and AutoExit both inherits contract Automator and uses its function _validateSwap:
The function will revert if the difference between current tick and twap tick > maxTickDifference. Currently, maxTickDifference must <= 200 as you can see in function setTWAPConfig:
MAX_TWAP_TICK_DIFFERENCE = 200.
If for example, maxTWAPTickDifference = 100, then the function will revert if price difference = 1.0001 * 100 = 1%. This will prevent users of AutoExit and AutoRange from stopping their loss in case the market drops > 1%.
Lets take an example:
The same thing happens in AutoExit, users cannot withdraw their tokens in case the prices change > 1%.
Below is a POC for the above example, save this test case to file test/integration/automators/AutoRange.t.sol and run it using command:
forge test --match-path test/integration/automators/AutoRange.t.sol --match-test testNoSwapRevert -vvvv.
In the test case, I creates a mockCall to uniswap v3 observe function to simulate a market drop.
I recommend skipping the swap operation if _hasMaxTWAPTickDifference returns false instead of reverting.
Invalid Validation
EV_om (lookout) commented:
ktg (warden) commented:
EV_om (lookout) commented:
ktg (warden) commented:
ronnyx2017 (judge) decreased severity to Medium and commented:
kalinbas (Revert) confirmed and commented:
Revert mitigated:
Status: Mitigation Confirmed. Full details in reports from b0g0, thank_you and ktg.
