Burn Position (remove liquidity)
This is an example of withdrawing all or part of an asset from an existing position in Pangea's pool.
import { ethers } from "ethers";
import {BigNumber} from "@ethersproject/bignumber";
/// concentrated Liquidity Pool Manager address
const poolManagerAddress = "0x000...";
/// web3 Provider (metamask provider / jsonRPC provider / ...)
const provider = ethers.getDefaultProvider();
// burn position
async function burnPosition(
tokenId:number, // tokenId
amount:string, // amount of liquidity to burn
recipient:string // recipient address
) {
const poolManager = await ConcentratedLiquidityPoolManager__factory.connect(positionManagerAddress, provider);
const tx = await poolManager.burn(
tokenId, // position ID to remove liquidity from. will burn if all liquidity is removed
amount, // amount of liquidity to burn. You can get position liquidity size through poolManager.positions(tokenId).
recipient,
0, // token0 slippage limit. if removed token0 is less, revert
0, // token1 slippage limit. if removed token1 is less, revert
false // Unwrap? "true" if you want to get KLAY instead of wKLAY
);
await tx.wait();
}
Last updated