Increasing Liquidity
Adding more liquidity to an existing liquidity position
Contract ID: SaucerSwapV2NonfungiblePositionManager
See Liquidity position fee for an example of how to obtain the current fee, payable in HBAR, for minting a new liquidity position or adding more liquidity to an existing one.
See New liquidity position for creating a new liquidity position.
When working with HBAR, use the Wrapped HBAR token ID and include the HBAR amount in the setPayableAmount() method for the ContractExecuteTransaction call.
Function name: increaseLiquidity
โฝ Recommended gas: 330,000 gwei (~ $0.028 USD)
Struct Parameter Name | Description |
---|---|
uint256 tokenSN | The serial number of the token for which liquidity is being increased |
uint256 amount0Desired | The maximum amount for the first token in its smallest unit |
uint256 amount1Desired | The maximum amount for the second token in its smallest unit |
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 |
uint deadline | Deadline in Unix seconds |
Code Overview
The following code demonstrates how to add more liquidity to an existing position.
See Fetch pool token ratio for an example how to retrieve the latest data construct the Pool object using the Uniswap SDK library.
See Fetch all pools to retrieve the pool address, token pairs, fee tier, token IDs and decimal places for the target pool of interest.
The refundETH function uses HBAR, but its name is derived from Uniswap on Ethereum. The name was retained to simplify integration for developers familiar with Uniswap tools. It is used to refund any excess HBAR when setting up a new liquidity position.
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.