Skip to main content

Decrease liquidity

Function name: decreaseLiquidity Recommended gas limit: 300,000

Code overview

The following code demonstrates how to remove all liquidity from an existing position, collect the swap fees, and return the deposit amounts.
When removing liquidity from a pool that involves HBAR, include unwrapWHBAR in your call to convert the Wrapped HBAR (WHBAR) output token back into the native HBAR cryptocurrency.
Call the collect function after removing the liquidity to withdraw the amounts to the recipient address. It will also collect any swap fees earned in the position.
To burn the NFT after completely exiting the position, include burn in the multi-call. See Burning the NFT.
Hedera’s EVM chain ID can be retrieved from https://chainlist.org.
The following code is intended for guidance purposes and does not include checks and safeguards.
Resources:

Burning the NFT

After completely exiting a position, you may burn the NFT position if it is no longer needed. The following code demonstrates how to set a spender allowance for the NFT and include the burn function in the multicall.
An NFT allowance for the NFT Manager contract must be approved by the token holder to enable the contract to retrieve the NFT to burn it.
Resources:

Next steps

Claiming fees (V2)

Collect swap fees without removing liquidity.

Increasing liquidity (V2)

Add liquidity back to the position.

Get user positions (V2)

List positions and fees for an account.