Charm

Searchâ€¦

How the strategy works

Detailed explanation of the LP strategy

Overview

A strategy is deployed for a certain pool on Uniswap, such as ETH/USDC. It has two main parameters:

- B (base threshold)
- L (limit threshold)

The strategy always maintains two range orders:

**Base order symmetric around current price X**, in the tick range [X-B, X+B].**Limit order just above or below the current price.**It will be a single-token order in the tick range [X-R, X], or [X, X+R], depending on which token it holds more of after the base order was placed. This order helps the strategy rebalance and get closer to 50:50 to reduce inventory risk.

Every 48 hours, the *rebalance()* method is called by a keeper. This shifts the two orders according to the updated price and token balances. If the strategy performs well, this time period can be decreased.

Note that the rebalance order doesnâ€™t guarantee the ratio returns to 50:50 - it just makes it more likely. If it holds more ETH than USDC, it makes it more likely itâ€™ll sell more ETH than buying more ETH. However, if the price keeps increasing, the strategy will get more and more unbalanced, but on average itâ€™s more likely to return to 50:50 since itâ€™s offering to sell more tokens than itâ€™s offering to buy.

â€‹

Code

The logic for rebalancing the strategy can be found in the

`rebalance()`

method in PassiveStrategy.sol.â€‹

Example

For example, letâ€™s say the current price is 150 ticks, B = 50 and R = 20, and the strategy holds 1 ETH and 160 USDC. It would then place a base order between [100, 200] ticks using 1 ETH and 150 USDC. The base order is symmetric around the current price so it deposits equal values of ETH and USDC.

It then has 10 USDC left over, which is used for a rebalancing order between [130, 150] ticks in order to try to buy more ETH with its USDC to get closer to a 50/50 ratio.

If the price goes up to 180, after rebalancing, the base order will be shifted up to [130, 230]. Letâ€™s say the strategy now holds 1.2 ETH and 90 USDC. The strategy would then use 0.5 ETH and 90 USDC for its base order. It has 0.7 ETH left over, so it uses it for a rebalancing order between [180, 200].

Last modified 7mo ago

Copy link

On this page

Overview

Code

Example