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. ERC20 --> ERC20
  • 2. ERC20 --> KLAY
  • 3. KLAY --> ERC20
  1. Developers
  2. Interacting with the Protocol

Swap

Here are 3 cases of swapping in Pangea's pool via router :

1. ERC20 --> ERC20

  • Before the swap request, you need to make an approve request to the router for the input token.

poolRouter.exactInputSingle({
          tokenIn: tokenInAddress, // input token address
          amountIn: BigNumber.from(amountIn), // amount of input token to swap
          amountOutMinimum: BigNumber.from(amountOutMinimum), // slippage
          pool: PoolAddress, // pool address
          to: recipient,     // recipient address
          unwrap: false      // always "false" for erc20 tokens
        });

2. ERC20 --> KLAY

  • Before the swap request, you need to make an approve request to the router for the input token.

poolRouter.exactInputSingle({
          tokenIn: tokenInAddress, // input token address
          amountIn: BigNumber.from(amountIn), // amount of input token to swap
          amountOutMinimum: BigNumber.from(amountOutMinimum), // slippage
          pool: PoolAddress, // pool address
          to: recipient,     // recipient address
          unwrap: true      // always "false" for erc20 tokens
        });

3. KLAY --> ERC20

poolRouter.exactInputSingle({
          // if input token is KLAY, set token address to 0 address
          tokenIn: "0x0000000000000000000000000000000000000000", 
          amountIn: BigNumber.from(amountIn),
          amountOutMinimum: BigNumber.from(amountOutMinimum),
          pool: PoolAddress,
          to: recipient,
          unwrap: false
        }, {
           // amount of KLAY to sent should be input like below
           value: BigNumber.from(amountIn)
        });

PreviousClaim Fee

Last updated 2 years ago