Submitted by libratus
Note: this issue happened on the deployed version of GoodEntry and was discovered when using https://alpha.goodentry.io
Due to incorrect parameters and validation when working with UniV3 LP the vault may enter a state where rebalancing reverts. This means any deposits and withdrawals from the vault become unavailable.
When rebalancing a vault, the existing positions need to be removed from Uni. This is done in removeFromTick function.
Here, zeros are passed as amount0Min and amount1Min arguments. The execution continues in TokenisableRange.withdraw function. decreaseLiquidity is called to remove liquidity from Uni.
Here there is an edge-case that for really small change in liquidity the returned values removed0 and removed1 can be 0s (will be explained at the end of a section).
Then, collect is called and removed0,removed1 are passed as arguments.
However, collect reverts when both of these values are zeros - https://github.com/Uniswap/v3-periphery/blob/main/contracts/NonfungiblePositionManager.sol#L316
As a result, any deposit/withdraw/rebalancing of the vault will revert when it will be attempting to remove existing liquidity.
This edge-case is possible to achieve as it happened in the currently deployed alpha version of the product. The sponsor confirmed that the code deployed is the same as presented for the audit.
The tick that caused the revert has less than a dollar of liquidity. Additionally, that tick has outstanding debt and so the aBal value was small enough to cause the issue. In the scenario that happened on-chain aBal is only 33446.
The issue can be demonstrated on the contracts deployed on the arbitrum mainnet. This is the foundry test:
The test can be executed by forking the arbitrum mainnet
The result is an error in UniV3 NonfungiblePosition.collect method
It is unclear why this collect call is needed because the fees are already collected a few lines above in claimFees. I suggest removing the second collect call altogether. If its needed then perhaps only collect if one of removed0/removed1 is non-zero.
gzeon (Judge) commented:
Keref (Good Entry) commented:
gzeon (Judge) commented:
libratus (Warden) commented:
Good Entry Mitigated:
Status: Mitigation confirmed. Full details in reports from kutugu, xuwinnie and 3docSec.
