# Rebalance

The strategy manager, using their understanding of the markets:

• Predicts the ranges where they expect to see the most trading volume and consequently earn high swap fees.
• Deploy at ranges where they wish to buy or sell.

DefiEdge allows managers to apportion funds on different price ranges. The manager ensures that the contract funds always remain within the active liquidity range by continuously rebalancing them in case of price deviation.

note

The liquidity manager pays the gas fees for all rebalancing actions in the fund. Every time the liquidity manager performs rebalancing, all the liquidity in the pool is removed along with the accrued fees, which are then reinvested.

DefiEdge allows strategy managers to deploy liquidity on five different ranges. They can allocate different proportions of the liquidity to different ranges and the interface calculates how many tokens need to be swapped based on the ratio of tokens required for each range.

When you rebalance your strategy you will need to swap some proportion of your tokens. This is because you can only deposit tokens on UniswapV3 in a certain ratio. This ratio depends upon the current price of the tokens in the pool along with the price range (upper-bound and lower-bound) you want to deploy liquidity in.

If the price in the pool lies within the price range specified by you then the ratio of the two tokens is the following:

$ratio = \sqrt{p} * \frac{\sqrt{p} - \sqrt{p_{min}}}{1-\frac{\sqrt{p}}{\sqrt{p_{max}}}}$

Where ${p}$ : current price,

${p_{min}}$: the lower bound of the price range provided

${p_{max}}$: the upper bound of the price range provided

If the current price of token0 in terms of token1 is greater than the upper bound of your price range then you can only deposit token1 into the pool. On the other hand, if the price of token0 in terms of token1 is lower than the lower bound of your price range then you can only deposit token0 into the pool.

DefiEdge calculates all these ratios for all the price ranges provided by the strategy manager and tells you how many tokens need to be swapped to be able to effectively deploy into the pool.