Create Pool

This page illustrate how to integrate PiperX create pool functionality to your Dapps and website.

Integrating Create pool to website

Integrating the PiperX swap functionality to your website makes it easy for you to leverge the liquidity from PiperX without the needs of maintain your own pools. Some example applications includes memecoin launchpad want to automatically creating pools on PiperX. Note that this is only creating the pool on blockchain. To make your pool visible in the PiperX frontend website, please contact the team to get it listed.

Steps to Integration

There are three steps in conducting a create pool: 1) prepare input, 2) approve tokens, 3) conduct create pool. You need to install PiperX sdk and import it to proceed.

import { v2AddLiquidity, v2RouterTokenApproval } from '@piperx/sdk/src/v2core'
import { WIP_ADDRESS } from '@piperx/sdk/src/constant'

Prepare Input

You need the following inputs before you can conduct a swap

token1_address: address, // if it is $IP native token, use WIP_ADDRESS
token2_address: address, // if it is $IP native token, use WIP_ADDRESS
amount1: bigint, // amount of token 1 you want to deposit to the pool
amount2: bigint, // amount of token 2 you want to deposit to the pool
amount1Min: bigint, // minimal amount of token 1 you want to deposit to the pool
amount2Min: bigint, // minmial amount of token 2 you want to deposit to the pool
current_address: string, // your account address
expire_time: bigint// expiration timestamp for a swap

Note that, if you are swapping $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 swapping from staked $IP token to $IP token, please use wrapped $IP address WIP_ADDRESS

Approve tokens

You need to approve the router contract to both your tokens to create this pool

await v2RouterTokenApproval(token1_address, amount1)
await v2RouterTokenApproval(token2_address, amount2)

Creating the pool

await v2AddLiquidity(
    token1: string,
    token2: string,
    amount1: bigint,
    amount2: bigint,
    amount1Min: bigint,
    amount2Min: bigint,
    current_address: string,
    expire_time: bigint
)

Last updated