7: Advanced topics
Token Migration
Error Codes
Code
Name
Description
Events
Monitoring Pools
Last updated
Last updated
{
pool_state: PublicKey;
creator: PublicKey;
config: PublicKey;
base_mint_param: MintParams;
curve_param: CurveParams;
vesting_param: VestingParams;
}{
pool_state: PublicKey;
amount_in: u64;
amount_out: u64;
protocol_fee: u64;
platform_fee: u64;
creator_fee: u64;
trade_direction: 'Buy' | 'Sell';
pool_status: 'Fund' | 'Migrate' | 'Trade';
exact_in: boolean;
}import { Connection } from '@solana/web3.js';
const connection = new Connection('wss://api.mainnet-beta.solana.com');
// Monitor all program account changes
const subscriptionId = connection.onProgramAccountChange(
LAUNCHLAB_PROGRAM_ID,
(accountInfo, context) => {
console.log('Account changed:', accountInfo);
// Decode pool state and react to changes
},
'confirmed'
);// Monitor specific pool state
const subscriptionId = connection.onAccountChange(
poolStateAddress,
(accountInfo, context) => {
// Decode and handle pool state update
const poolState = decodePoolState(accountInfo.data);
console.log('Pool updated:', poolState.status);
},
'confirmed'
);