Decrease liquidity or completely exit an existing liquidity position
Contract ID: SaucerSwapV2NonfungiblePositionManager
Function name: decreaseLiquidity
⛽ Recommended gas: 300,000 gwei (~ $0.026 USD)
Struct Parameter Name | Description |
---|---|
uint256 tokenSN | The serial number of the token for which liquidity is being increased |
uint128 liquidity | Liquidity amount to remove |
uint256 amount0Min | The minimum amount for the first token in its smallest unit |
uint256 amount1Min | The minimum amount for the second token in its smallest unit |
uint256 deadline | Deadline in Unix seconds |
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.
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.
A Note allowance for the NFT Manager contract must be approved by the token holder to enable the contract to retrieve the NFT to burn it.
Decrease liquidity or completely exit an existing liquidity position
Contract ID: SaucerSwapV2NonfungiblePositionManager
Function name: decreaseLiquidity
⛽ Recommended gas: 300,000 gwei (~ $0.026 USD)
Struct Parameter Name | Description |
---|---|
uint256 tokenSN | The serial number of the token for which liquidity is being increased |
uint128 liquidity | Liquidity amount to remove |
uint256 amount0Min | The minimum amount for the first token in its smallest unit |
uint256 amount1Min | The minimum amount for the second token in its smallest unit |
uint256 deadline | Deadline in Unix seconds |
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.
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.
A Note allowance for the NFT Manager contract must be approved by the token holder to enable the contract to retrieve the NFT to burn it.