Standard Pool
Steps to Integration
There are three steps in removing liquidity: 1) prepare input, 2) approve tokens, 3) conduct remove liquidity. You need to install PiperX sdk and import it to proceed.
import { v2RemoveLiquidity, v2RouterTokenApproval } from '@piperx/sdk/src/core'
import { WIP_ADDRESS } from '@piperx/sdk/src/constant'
import { v2ComputeAddress } from '@piperx/sdk/src/constant'
Prepare Input
You need the following inputs before you can remove a liquidity
token1_address: address, // if it is $IP native token, use WIP_ADDRESS
token2_address: address, // if it is $IP native token, use WIP_ADDRESS
liquidity: bigint, // amount of lp token you want to remove to the pool
amount1Min: bigint, // minimal amount of token 1 you want to receive
amount2Min: bigint, // minmial amount of token 2 you want to receive
expire_time: bigint// expiration timestamp for a swap
signer: ethers.Signer.
Note that, if you are add liquidity for $IP token, you should pass in the PiperX wrapped $IP token address, because the $IP token is not a ERC-20 token. For example, if you are remove from to $IP to $USDC pool, please use wrapped $IP address WIP_ADDRESS
Approve tokens
You need to approve the router contract to both your tokens to create this pool
let lp_token_address = v2ComputeAddress(token1, token2)
await v2RouterTokenApproval(lp_token_address, amount1, signer)
Remove the liquidity
await v2RemoveLiquidity(
token1: string,
token2: string,
liquidity: bigint,
amount1Min: bigint,
amount2Min: bigint,
expire_time: bigint,
signer
)
Last updated