Utils (constants & derives)
Constants
// utils.ts
import { PublicKey } from "@solana/web3.js";
import { NATIVE_MINT, getAssociatedTokenAddressSync } from "@solana/spl-token";
import { BN } from "@coral-xyz/anchor";
/** ===== Program IDs ===== */
export const LAUNCHPAD_PROGRAM_ID = new PublicKey("REPLACE_WITH_PROGRAM_ID"); // Tradersdex Curve (Launchpad)
export const TOKEN_PROGRAM_ID = new PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
export const ATOKEN_PROGRAM_ID = new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
export const SYSTEM_PROGRAM_ID = new PublicKey("11111111111111111111111111111111");
export const MPL_PROGRAM_ID = new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"); // Metaplex Token Metadata
/** ===== Fees / math ===== */
export const TEN_K = 10_000n; // 10000 (basis points denominator)
/** If you want these visible to client code, mirror your on-chain constants here. */
export const PROTOCOL_FEE_BPS = /* e.g. */ 75; // 0.75%
export const CREATOR_FEE_BPS = /* e.g. */ 25; // 0.25%
export const NUM_FEE_ACCOUNTS = /* e.g. */ 10; // how many protocol fee PDAs exist
/** ===== Pool types (curveType) =====
* 0: SOL / no creator fee
* 1: SOL / creator fee
* 2: WSOL / no creator fee
* 3: WSOL / creator fee
*/
export type PoolType = 0 | 1 | 2 | 3;
/** ===== Pool status (for docs/reference) ===== */
export const POOL_STATUS_LIVE = 1;
export const POOL_STATUS_COMPLETED = 2;
/** ===== Misc ===== */
export const ZERO_PUBKEY = new PublicKey(new Uint8Array(32)); // Pubkey::default() in RustDerive functions
Curve type helpers
Validation helpers (mirror on-chain rules)
Example: fee vault selection
Import pattern
Pool parsing (from on-chain account bytes)
Pool-aware math (quotes & slippage)
Quick usage example
Last updated