Shift Vault Liquidity Positions

Now that we've let these liquidity positions sit in the market for some time and (hopefully) earn fees we may want to adjust how our liquidity is distributed across prices and the two fee tiers of interest.

To demonstrate this type of operation run this command:

yarn tutorial1-resetPosition --network goerli

Congratulations! You just executed the next leg of your liquidity strategy, recentering your liquidity positions on both fee tiers around the new current prices (and harvesting any fees). You are ready to move on.

What Does This Script Do?

Reset liquidity operation is fundamentally the same as the set liquidity operation (a rebalance call), but now we may be both adding and removing positions in a single operation. Like so:

  const tx = await vault.rebalance(
    {
      burns: [
        {
          liquidity: maxUint128, // remove ALL liquidity = type(uint128).max
          range: ranges[0],
        },
        {
          liquidity: maxUint128, // remove ALL liquidity = type(uint128).max
          range: ranges[1],
        },
      ],
      mints: [
        {
          liquidity: liquidityA, // liquidity amount to add to newRageA
          range: newRangeA,
        },
        {
          liquidity: liquidityB, // liquidity amount to add to newRangeB
          range: newRangeB,
        },
      ],
      swap: nullSwap, // null swap struct (no swapping)
      minBurn0: 0, // optional protection skipped here
      minBurn1: 0,
      minDeposit0: min0, // min deposit slippage protection
      minDeposit1: min1,
    },
  );

Track Position Delta

You can check out how your position has changed by again running:

yarn tutorial1-status --network goerli 

Notice how your liquidity positions have changed their tick bounds for example (provided prices have moved enough).

Last updated