Submitted by Jeiwan, also found by Jeiwan, LokiThe5th, osmanozdemir1, said, and HChang26
Users can lose a portion of their deposited funds if some of their funds havent been deposited to the underlying Uniswap pools. Theres always a chance of such event since Uniswap pools take balanced token amounts when liquidity is added but GeVault doesnt pre-compute balanced amounts. As a result, depositing and withdrawing can result in a partial loss of funds.
The GeVault.deposit() function is used by users to deposits funds into ticks and underlying Uniswap pools. The function takes funds from the caller and calls rebalance() to distribute the funds among the ticks. The GeVault.rebalance() function first removes liquidity from all ticks and then deposits the removed assets plus the user assets back in to the ticks:
The GeVault.deployAssets() function calls the GeVault.depositAndStash() function, which actually deposits tokens into a TokenisableRange contract by calling the TokenisableRange.deposit(). The function deposits tokens into a Uniswap V3 pool and returns unspent tokens to the caller:
However, the GeVault.depositAndStash() function doesnt handle the returned unspent tokens. Since Uniswap V3 pools take balanced token amounts (respective to the current pool price) and since the funds deposited into ticks are not balanced (deployAssets() splits token amounts in halves), theres always a chance that the TokenisableRange.deposit() function wont consume all specified tokens and will return some of them to the GeVault contract. However, GeVault wont return the unused tokens to the depositor.
Moreover, the contract wont include them in the TVL calculation:
Thus, the unused tokens will be locked in the contract until theyre deposited into ticks. However, rebalancing and depositing of tokens can result in new unused tokens that wont be counted in the TVL.
In the GeVault.deposit() function, consider returning unspent tokens to the depositor. Extra testing is needed to guarantee that rebalancing doesnt result in unspent tokens, or, alternatively, such tokens could be counted in a storage variable and excluded from the balance of unspent tokens during depositing.
Alternatively, consider counting GeVaults token balances in the getTVL() function. This wont require returning unspent tokens during depositing and will allow depositors to withdraw their entire funds.
Keref (Good Entry) confirmed and commented:
Good Entry Mitigated:
Status: Mitigation confirmed. Full details in reports from  kutugu, xuwinnie and 3docSec.
