Submitted by Infect3d, also found by EPSec, ka14ar, King_9aimon, KupiaSec, and pontifex
https://github.com/code-423n4/2024-12-lambowin/blob/b8b8b0b1d7c9733a7bd9536e027886adb78ff83a/src/rebalance/LamboRebalanceOnUniwap.sol#L116-L148
The formula implemented assumes that the pool is based on a constant sum AMM formula (x+y = k), and also eludes the fact that reserves in a UniV3 pool do not directly relate to the price because of the 1-sided ticks liquidity.
This make the function imprecise at best, and highly imprecise when liquidity is deposited in distant ticks, with no risk involved for actors depositing in those ticks. 
The previewRebalance function has been developed to output all the necessary input parameters required to call the rebalance function, which goal is to swap tokens in order to keep the peg of the virtual token in comparison to its counterpart (e.g keep vETH/ETH prices = 1):
The implemented formula is incorrect, as it will not rebalance the pool for 2 reasons:
Regarding (2), consider this situation:
WETH balance: 1000
vETH balance: 900
targetBalance = (1000 + 900) / 2 = 950
amountIn = 1000 - 950 = 50 (vETH)
Swapping 50 vETH into the pool will not return 50 WETH because of the inherent slippage of the constant product formula.
Now, add to this bullet (1), and the measured balance will be wrong anyway because of the liquidity deposited in inactive ticks, making the result even more shifted from the optimal result.
The function is not performing as intended, leading to invalid results which complicates the computation of rebalancing amounts necessary to maintain the peg. 
Since this function is important to maintain the health of vETH as it has access to on-chain values, allowing precise rebalancing, failing to devise and implement a reliable solution for rebalancing before launch could result in significant issues. 
Reconsider the computations of rebalancing amounts for a more precise one if keeping a 1:1 peg is important.
You might want to get inspiration from USSDRebalancer::rebalance().
Shaneson (Lambo.win) acknowledged
