Pangea Swap
English
English
  • Introduction
  • Protocol Overview
  • Disclaimer
    • Risk & Security
    • Terms of Use
  • Updates
  • Audit
  • concentrated liquidity
    • Weakness of V2 DEXs: Low Liquidity utilization rate
    • Solution by V3 DEXs: Concentrated Liquidity
    • Concentrated Liquidity FAQ
  • Connectivity
    • Customizable Pool
  • Governance
    • STONE
      • STONE Distribution Plan
      • Tokenomics (Before)
      • Tokenomics (After)
      • Growth Fund History
    • Contribution Point NFT
  • Guide
    • SWAP
    • Add Liquidity
      • Add liquidity (Preset)
      • Add liquidity (Custom)
    • STONE Staking
    • Revenue Sharing
    • FAQ
  • Growth Partnership
    • Swapscanner
    • ISKRA
  • event
    • Promotion
  • Developers
    • Concept Overview
      • Problem : Lazy Liquidity
      • Liquidity Concentration
      • Position & Risk
      • Price Tick
      • Position NFT
      • Fees
      • Flash Loan
    • Contracts
      • Core Contracts
        • MasterDeployer
        • ConcentratedLiquidityPoolFactory
        • ConcentratedLiquidityPool
        • ConcentratedLiquidityPoolManager
        • PoolRouter
        • PoolLogger
        • AirdropDistributor
      • Contribution Point NFT
      • Price Oracle
    • Interacting with the Protocol
      • Setting up Local Test Environment
        • Test env. commands
      • Getting Pangea Pool Info
      • Creating Pangea Pool
      • Mint Position (add liquidity)
      • Burn Position (remove liquidity)
      • Claim Fee
      • Swap
  • Community
    • Website
    • Discord
    • Telegram
    • Medium
    • Twitter
    • Opensea - Position NFT
    • Opensea - CP NFT
    • GitHub
    • Testnet
    • E-mail
Powered by GitBook
On this page
  1. Developers
  2. Interacting with the Protocol

Mint Position (add liquidity)

This is an example of creating a new position in Pangea's pool or depositing additional liquidity in an existing position.

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();

// Create new position
async function createPosition(
    poolAddress:string,
    lowerTick:number,
    upperTick:number,
    amount0Desired:BigNumber,
    amount1Desired:BigNumber
) {
      const pool = await ConcentratedLiquidityPool__factory.connect(poolAddress, provider);
      const token0 = await ERC20__factory.connect(await pool.token0(), provider);
      const token1 = await ERC20__factory.connect(await pool.token1(), provider);        
            
      const poolManager = await ConcentratedLiquidityPoolManager__factory.connect(positionManagerAddress, provider);
      // first, approve      
      await (await token0.approve(poolManager.address,amount0Desired)).wait();
      await (await token1.approve(poolManager.address, amount1Desired)).wait();
      
      // second, mint postion
      const tx = await poolManager.mint(
            poolAddress, 
            0, // if the lowerOld is not set, will search and input automatically
            lowerTick,
            0, // if the upperOld is not set, will search and input automatically
            uppterTick,
            amount0Desired,
            amount1Desired,
            0,
            0 // if positionId = 0 create new. else, add liquidity to the positionId
      );
      await tx.wait();
}

PreviousCreating Pangea PoolNextBurn Position (remove liquidity)

Last updated 2 years ago