TypeScript Code Examples

Memecoin Pools v1 are a subset of Dynamic AMM Pools. A Memecoin Pool v1 is a Dynamic AMM Pool that has a fee scheduler, with liquidity permanently locked at pool creation.

Memecoin Pools v1 can be integrated with platforms such as memecoin launchpads to support liquidity and trading for the token after it has graduated from the launchpad.

To create a new Memecoin Pool v1 or for integration purposes, you can use the Dynamic AMM TypeScript SDK with the code example highlighted below.

Getting Started

1. Install dependencies and initialize AmmImpl instance

1.1 Install dependencies

# NPM
npm i @meteora-ag/dynamic-amm-sdk @coral-xyz/anchor @solana/web3.js @solana/spl-token
# YARN
yarn add @meteora-ag/dynamic-amm-sdk @coral-xyz/anchor @solana/web3.js @solana/spl-token
# Or, use any package manager of your choice.

1.2 Initialize AmmImpl instance

import AmmImpl, { MAINNET_POOL } from '@meteora-ag/dynamic-amm-sdk';
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
import { AnchorProvider, Wallet } from '@coral-xyz/anchor';

// Connection, Wallet, and AnchorProvider to interact with the network
const mainnetConnection = new Connection('https://api.mainnet-beta.solana.com');
const mockWallet = new Wallet(new Keypair());
const provider = new AnchorProvider(mainnetConnection, mockWallet, {
  commitment: 'confirmed',
});
// Alternatively, to use Solana Wallet Adapter

// Create single instance
const constantProductPool = await AmmImpl.create(mainnetConnection, MAINNET_POOL.USDC_SOL);
const stablePool = await AmmImpl.create(mainnetConnection, MAINNET_POOL.USDT_USDC);
// Or with any other pool address, refer to the pool creation section below
const pool = await AmmImpl.create(mainnetConnection, new PublicKey('...'));

// If you need to create multiple, can consider using `createMultiple`
const pools = [MAINNET_POOL.USDC_SOL, MAINNET_POOL.USDT_USDC];
const [constantProductPool, stablePool] = await AmmImpl.createMultiple(mainnetConnection, pools);

2. Fee Schedule Setup: Choose a suitable Pool and Fee Config

Choose a suitable Pool and Fee Config by following the instructions here.

  • What fee parameters to choose depends on your project's needs. You will need to look at the pool config list and choose a suitable pool_config_key with your preferred fee parameters.

  • If you want to create an Alpha Vault along with your new pool, you also need to find a pool_config_key that is mapped to a vault_config_key that meets your requirements.

  • If none of the pool_config_key in the list meet your requirements, please reach out to Meteora for a custom pool config key.

3. Create a Memecoin Pool

After you have selected your preferred pool_config_key , reference this example: https://github.com/MeteoraAg/dynamic-amm-sdk/blob/main/ts-client/src/examples/create_pool_and_lock_liquidity.ts

Using the example, update it with your pool config key selected and other parameters in order to create a Memecoin Pool - which is a Dynamic AMM Pool with a fee scheduler and with liquidity (LP tokens) locked to the user's own lock escrow account.

How to assign which wallets can claim fees from the permanently-locked liquidity

Please refer to the section under let allocations = [

https://github.com/MeteoraAg/dynamic-amm-sdk/blob/main/ts-client/src/examples/create_pool_and_lock_liquidity.ts#L121

In the config file, you can specify different wallet addresses to receive fees from the locked liquidity, and the % to allocate to each wallet. Multiple wallets are possible, but their allocations must add up to 100%.

Last updated