Program ID: Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB
Install
Install dependencies
npm i @mercurial-finance/dynamic-amm-sdk @project-serum/anchor @solana/web3.js @solana/spl-token @solana/spl-token-registry
Initialize AmmImpl instance
import AmmImpl, { MAINNET_POOL } from'@mercurial-finance/dynamic-amm-sdk';import { PublicKey } from'@solana/web3.js';import { Wallet, AnchorProvider } from'@project-serum/anchor';// Connection, Wallet, and AnchorProvider to interact with the networkconstmainnetConnection=newConnection('https://api.mainnet-beta.solana.com');constmockWallet=newWallet(newKeypair());constprovider=newAnchorProvider(mainnetConnection, mockWallet, { commitment:'confirmed',});// Alternatively, to use Solana Wallet AdapterconstconstantProductPool=awaitAmmImpl.create(connection,MAINNET_POOL.USDC_SOL);conststablePool=awaitAmmImpl.create(connection,MAINNET_POOL.USDT_USDC);// If you need to create multiple, can consider using `createMultiple`constpools= [MAINNET_POOL.USDC_SOL,MAINNET_POOL.USDT_USDC];const [constantProductPool,stablePool] =awaitAmmImpl.createMultiple(connection, pools);
To interact with the AmmImpl
Get Lp Supply
// To refetch the pool's latest supply// Alternatively, use `AmmImpl.poolState.lpSupply`constlpSupply=awaitconstantProductPool.getLpSupply();
Check pool balance
// Get the user's ATA LP balanceconstuserLpBalance=awaitconstantProductPool.getUserBalance(mockWallet.publicKey);
Update pool state (It's recommended to update the deposit before perform any quotation)