@gabox-labs/sdk 0.2.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +226 -0
- package/README.md +116 -460
- package/dist/generated/index.d.ts +334 -755
- package/dist/generated/index.js +2403 -338
- package/dist/generated/index.js.map +1 -1
- package/dist/index-BDfGvmgF.d.ts +934 -0
- package/dist/index.d.ts +191 -448
- package/dist/index.js +468 -1034
- package/dist/index.js.map +1 -1
- package/dist/raydium/index.d.ts +2 -0
- package/dist/raydium/index.js +2 -0
- package/dist/raydium-B-l9V3O-.js +2604 -0
- package/dist/raydium-B-l9V3O-.js.map +1 -0
- package/llms.txt +4 -2
- package/package.json +11 -16
- package/skills/gabox-sdk/SKILL.md +40 -142
- package/skills/gabox-sdk/references/api.md +103 -145
- package/dist/gaboxV2-CV2XltqC.js +0 -3347
- package/dist/gaboxV2-CV2XltqC.js.map +0 -1
- package/dist/index-BxvSkzCO.d.ts +0 -471
- package/dist/pump/index.d.ts +0 -2
- package/dist/pump/index.js +0 -2
- package/dist/pump-D0K_0uiC.js +0 -1531
- package/dist/pump-D0K_0uiC.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raydium-B-l9V3O-.js","names":["address","u8","u64","base64"],"sources":["../src/raydium/abi.ts","../src/raydium/ids.ts","../src/raydium/pdas.ts","../src/raydium/adapter.ts","../src/compute.ts","../src/raydium/accounts.ts","../src/raydium/curve.ts","../src/raydium/venue.ts","../src/tx/message.ts","../src/raydium/launch.ts","../src/raydium/claim.ts","../src/raydium/trade.ts","../src/raydium/index.ts"],"sourcesContent":["// GENERATED by scripts/codegen.mjs. Do not edit.\n//\n// The Raydium addresses Gabox pins, and the account order and `writable`/`signer` flags of every\n// Raydium instruction this SDK builds. `venue/trade.rs` checks the list `buy_pack` forwards\n// position by position, so this table and the program's own `venue/abi.rs` must describe the same\n// thing.\n//\n// Sources:\n// - the Rust program's programs/gabox/src/venue/ids.rs and constants.rs (the addresses)\n// - ../../idl/raydium_launchpad.json (LaunchLab)\n// - ../../idl/raydium_cp_swap.json (CPMM)\n//\n// Both IDL snapshots were checked against the SHA-256 that ../../idl/interfaces.json records, and\n// every trade instruction below was cross-checked against that file, index by index.\n// `test/venue-accounts.test.ts` checks the same thing on every test run.\n\nimport type { Address } from '@solana/kit';\n\n/** One account slot: its IDL name and the privileges the venue's own ABI gives it. */\nexport type VenueAccountSpec = {\n readonly name: string;\n readonly writable: boolean;\n readonly signer: boolean;\n};\n\nexport type VenueInstructionAbi = {\n readonly name: string;\n readonly discriminator: Uint8Array;\n readonly accounts: readonly VenueAccountSpec[];\n};\n\n/**\n * The Raydium deployment of one cluster. Mainnet and devnet run different programs, so every\n * address here differs between the two, and so does the quote the curve must raise.\n */\nexport type RaydiumClusterIds = {\n /** Raydium LaunchLab, the bonding curve a Gabox coin launches and trades on first. */\n readonly launchlab: Address;\n /** PDA([\"vault_auth_seed\"], launchlab). Signs LaunchLab's own vault transfers. */\n readonly launchlabAuthority: Address;\n /** PDA([\"__event_authority\"], launchlab). */\n readonly launchlabEventAuthority: Address;\n /** PDA([\"global_config\", WSOL, u8 0, u16 big-endian 0], launchlab). Holds the curve settings. */\n readonly solGlobalConfig: Address;\n /** PDA([\"platform_config\", PLATFORM_ADMIN], launchlab). The Gabox platform on LaunchLab. */\n readonly gaboxPlatform: Address;\n /** Raydium CPMM, the pool a Gabox coin graduates into. */\n readonly cpmm: Address;\n /** PDA([\"vault_and_lp_mint_auth_seed\"], cpmm). */\n readonly cpmmAuthority: Address;\n /**\n * The quote the curve must raise before the coin graduates, in lamports.\n *\n * There is no fee tier here on purpose. The Gabox platform config names the CPMM fee tier a coin\n * graduates into, and a migrated pool records it again in its own data. Both are read from the\n * chain, never compiled in.\n */\n readonly launchQuoteRaise: bigint;\n};\n\nexport const RAYDIUM_MAINNET_IDS: RaydiumClusterIds = {\n launchlab: 'LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj' as Address,\n launchlabAuthority: 'WLHv2UAZm6z4KyaaELi5pjdbJh6RESMva1Rnn8pJVVh' as Address,\n launchlabEventAuthority: '2DPAtwB8L12vrMRExbLuyGnC7n2J5LNoZQSejeQGpwkr' as Address,\n solGlobalConfig: '6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX' as Address,\n gaboxPlatform: '8tXUG97CEpSKTNXdGtanYyC33RWmTTuSin4VdaWwNj8q' as Address,\n cpmm: 'CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C' as Address,\n cpmmAuthority: 'GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL' as Address,\n launchQuoteRaise: 85000000000n,\n};\n\nexport const RAYDIUM_DEVNET_IDS: RaydiumClusterIds = {\n launchlab: 'DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6' as Address,\n launchlabAuthority: '5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq' as Address,\n launchlabEventAuthority: '4uAB7seenFJKPUXqYewAdfra2u6baBgjiXU8x1SC7Ycz' as Address,\n solGlobalConfig: '7ZR4zD7PYfY2XxoG1Gxcy2EgEeGYrpxrwzPuwdUBssEt' as Address,\n gaboxPlatform: 'DdEeCPXbCAzHE2PZSoR3RZng4WA4bSztrezQznrJ4ooB' as Address,\n cpmm: 'DRaycpLY18LhpbydsBWbVJtxpNv9oXPgjRSfpF2bWpYb' as Address,\n cpmmAuthority: 'CXniRufdq5xL8t8jZAPxsPZDpuudwuJSPWnbcD5Y5Nxq' as Address,\n launchQuoteRaise: 3000000000n,\n};\n\n/** Wrapped SOL. The only quote Gabox accepts today, on both venues. */\nexport const WSOL_MINT = 'So11111111111111111111111111111111111111112' as Address;\n/** Metaplex Token Metadata, which LaunchLab's create instruction writes to. */\nexport const METAPLEX_PROGRAM_ADDRESS = 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s' as Address;\n/**\n * `PLATFORM_ADMIN` in the program's constants.rs. The Gabox platform config PDA derives from this\n * wallet, and LaunchLab pays the platform share of every curve trade to it.\n */\nexport const PLATFORM_ADMIN = '5WcPTEQ59UqpQzjZUPbU8QRGCbj7NeQNLDa7DbsLkLKT' as Address;\n\n/** The coin supply every Gabox launch mints: 1,000,000,000 coins at 6 decimals. */\nexport const LAUNCH_SUPPLY = 1000000000000000n;\n/** The part of the supply the LaunchLab curve sells: 793,100,000 coins. */\nexport const LAUNCH_TOTAL_BASE_SELL = 793100000000000n;\n\n/** Classic SPL Token. LaunchLab pins it on both sides of every Gabox launch and trade. */\nexport const TOKEN_PROGRAM_ADDRESS = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address;\nexport const ASSOCIATED_TOKEN_PROGRAM_ADDRESS = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address;\nexport const SYSTEM_PROGRAM_ADDRESS = '11111111111111111111111111111111' as Address;\n/** The rent sysvar. LaunchLab's create instruction still takes it. */\nexport const RENT_SYSVAR_ADDRESS = 'SysvarRent111111111111111111111111111111111' as Address;\n\n/**\n * The first eight bytes of each Raydium account this SDK decodes. `adapter.ts` checks them before\n * it reads a field, so an account of the wrong type fails loudly instead of decoding as rubbish.\n *\n * LaunchLab and CPMM give their pool account the same eight bytes, because Anchor derives a\n * discriminator from the struct name alone and both are called `PoolState`. The two programs own\n * different accounts, so the pair never collides in practice.\n */\nexport const LAUNCHLAB_POOL_STATE_DISCRIMINATOR = new Uint8Array([247, 237, 227, 245, 215, 195, 222, 70]);\nexport const LAUNCHLAB_GLOBAL_CONFIG_DISCRIMINATOR = new Uint8Array([149, 8, 156, 202, 160, 252, 176, 217]);\nexport const LAUNCHLAB_PLATFORM_CONFIG_DISCRIMINATOR = new Uint8Array([160, 78, 128, 0, 248, 83, 230, 160]);\nexport const CPMM_POOL_STATE_DISCRIMINATOR = new Uint8Array([247, 237, 227, 245, 215, 195, 222, 70]);\nexport const CPMM_AMM_CONFIG_DISCRIMINATOR = new Uint8Array([218, 244, 33, 104, 203, 203, 43, 111]);\n/**\n * `initialize_v2` on `LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj` — cross-checked against interfaces.json.\n */\nexport const LAUNCHLAB_INITIALIZE: VenueInstructionAbi = {\n name: 'initialize_v2',\n discriminator: new Uint8Array([67, 153, 175, 39, 218, 16, 38, 32]),\n accounts: [\n { name: 'payer', writable: true, signer: true },\n { name: 'creator', writable: false, signer: false },\n { name: 'global_config', writable: false, signer: false },\n { name: 'platform_config', writable: false, signer: false },\n { name: 'authority', writable: false, signer: false },\n { name: 'pool_state', writable: true, signer: false },\n { name: 'base_mint', writable: true, signer: true },\n { name: 'quote_mint', writable: false, signer: false },\n { name: 'base_vault', writable: true, signer: false },\n { name: 'quote_vault', writable: true, signer: false },\n { name: 'metadata_account', writable: true, signer: false },\n { name: 'base_token_program', writable: false, signer: false },\n { name: 'quote_token_program', writable: false, signer: false },\n { name: 'metadata_program', writable: false, signer: false },\n { name: 'system_program', writable: false, signer: false },\n { name: 'rent_program', writable: false, signer: false },\n { name: 'event_authority', writable: false, signer: false },\n { name: 'program', writable: false, signer: false },\n ],\n};\n\n/**\n * `buy_exact_in` on `LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj` — not in interfaces.json (the program never builds it).\n * The last three accounts are not in the IDL. LaunchLab reads them from the remaining\n * accounts, in this order.\n */\nexport const LAUNCHLAB_BUY_EXACT_IN: VenueInstructionAbi = {\n name: 'buy_exact_in',\n discriminator: new Uint8Array([250, 234, 13, 123, 213, 156, 19, 236]),\n accounts: [\n { name: 'payer', writable: true, signer: true },\n { name: 'authority', writable: false, signer: false },\n { name: 'global_config', writable: false, signer: false },\n { name: 'platform_config', writable: false, signer: false },\n { name: 'pool_state', writable: true, signer: false },\n { name: 'user_base_token', writable: true, signer: false },\n { name: 'user_quote_token', writable: true, signer: false },\n { name: 'base_vault', writable: true, signer: false },\n { name: 'quote_vault', writable: true, signer: false },\n { name: 'base_token_mint', writable: false, signer: false },\n { name: 'quote_token_mint', writable: false, signer: false },\n { name: 'base_token_program', writable: false, signer: false },\n { name: 'quote_token_program', writable: false, signer: false },\n { name: 'event_authority', writable: false, signer: false },\n { name: 'program', writable: false, signer: false },\n { name: 'system_program', writable: false, signer: false },\n { name: 'platform_fee_vault', writable: true, signer: false },\n { name: 'creator_fee_vault', writable: true, signer: false },\n ],\n};\n\n/**\n * `buy_exact_out` on `LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj` — cross-checked against interfaces.json.\n * The last three accounts are not in the IDL. LaunchLab reads them from the remaining\n * accounts, in this order.\n */\nexport const LAUNCHLAB_BUY_EXACT_OUT: VenueInstructionAbi = {\n name: 'buy_exact_out',\n discriminator: new Uint8Array([24, 211, 116, 40, 105, 3, 153, 56]),\n accounts: [\n { name: 'payer', writable: true, signer: true },\n { name: 'authority', writable: false, signer: false },\n { name: 'global_config', writable: false, signer: false },\n { name: 'platform_config', writable: false, signer: false },\n { name: 'pool_state', writable: true, signer: false },\n { name: 'user_base_token', writable: true, signer: false },\n { name: 'user_quote_token', writable: true, signer: false },\n { name: 'base_vault', writable: true, signer: false },\n { name: 'quote_vault', writable: true, signer: false },\n { name: 'base_token_mint', writable: false, signer: false },\n { name: 'quote_token_mint', writable: false, signer: false },\n { name: 'base_token_program', writable: false, signer: false },\n { name: 'quote_token_program', writable: false, signer: false },\n { name: 'event_authority', writable: false, signer: false },\n { name: 'program', writable: false, signer: false },\n { name: 'system_program', writable: false, signer: false },\n { name: 'platform_fee_vault', writable: true, signer: false },\n { name: 'creator_fee_vault', writable: true, signer: false },\n ],\n};\n\n/**\n * `sell_exact_in` on `LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj` — cross-checked against interfaces.json.\n * The last three accounts are not in the IDL. LaunchLab reads them from the remaining\n * accounts, in this order.\n */\nexport const LAUNCHLAB_SELL_EXACT_IN: VenueInstructionAbi = {\n name: 'sell_exact_in',\n discriminator: new Uint8Array([149, 39, 222, 155, 211, 124, 152, 26]),\n accounts: [\n { name: 'payer', writable: true, signer: true },\n { name: 'authority', writable: false, signer: false },\n { name: 'global_config', writable: false, signer: false },\n { name: 'platform_config', writable: false, signer: false },\n { name: 'pool_state', writable: true, signer: false },\n { name: 'user_base_token', writable: true, signer: false },\n { name: 'user_quote_token', writable: true, signer: false },\n { name: 'base_vault', writable: true, signer: false },\n { name: 'quote_vault', writable: true, signer: false },\n { name: 'base_token_mint', writable: false, signer: false },\n { name: 'quote_token_mint', writable: false, signer: false },\n { name: 'base_token_program', writable: false, signer: false },\n { name: 'quote_token_program', writable: false, signer: false },\n { name: 'event_authority', writable: false, signer: false },\n { name: 'program', writable: false, signer: false },\n { name: 'system_program', writable: false, signer: false },\n { name: 'platform_fee_vault', writable: true, signer: false },\n { name: 'creator_fee_vault', writable: true, signer: false },\n ],\n};\n\n/**\n * `claim_creator_fee` on `LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj` — not in interfaces.json (the program never builds it).\n */\nexport const LAUNCHLAB_CLAIM_CREATOR_FEE: VenueInstructionAbi = {\n name: 'claim_creator_fee',\n discriminator: new Uint8Array([26, 97, 138, 203, 132, 171, 141, 252]),\n accounts: [\n { name: 'creator', writable: true, signer: true },\n { name: 'fee_vault_authority', writable: false, signer: false },\n { name: 'creator_fee_vault', writable: true, signer: false },\n { name: 'recipient_token_account', writable: true, signer: false },\n { name: 'quote_mint', writable: false, signer: false },\n { name: 'token_program', writable: false, signer: false },\n { name: 'system_program', writable: false, signer: false },\n { name: 'associated_token_program', writable: false, signer: false },\n ],\n};\n\n/**\n * `swap_base_output` on `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C` — cross-checked against interfaces.json.\n */\nexport const CPMM_SWAP_BASE_OUTPUT: VenueInstructionAbi = {\n name: 'swap_base_output',\n discriminator: new Uint8Array([55, 217, 98, 86, 163, 74, 180, 173]),\n accounts: [\n { name: 'payer', writable: false, signer: true },\n { name: 'authority', writable: false, signer: false },\n { name: 'amm_config', writable: false, signer: false },\n { name: 'pool_state', writable: true, signer: false },\n { name: 'input_token_account', writable: true, signer: false },\n { name: 'output_token_account', writable: true, signer: false },\n { name: 'input_vault', writable: true, signer: false },\n { name: 'output_vault', writable: true, signer: false },\n { name: 'input_token_program', writable: false, signer: false },\n { name: 'output_token_program', writable: false, signer: false },\n { name: 'input_token_mint', writable: false, signer: false },\n { name: 'output_token_mint', writable: false, signer: false },\n { name: 'observation_state', writable: true, signer: false },\n ],\n};\n\n/**\n * `swap_base_input` on `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C` — cross-checked against interfaces.json.\n */\nexport const CPMM_SWAP_BASE_INPUT: VenueInstructionAbi = {\n name: 'swap_base_input',\n discriminator: new Uint8Array([143, 190, 90, 218, 196, 30, 51, 222]),\n accounts: [\n { name: 'payer', writable: false, signer: true },\n { name: 'authority', writable: false, signer: false },\n { name: 'amm_config', writable: false, signer: false },\n { name: 'pool_state', writable: true, signer: false },\n { name: 'input_token_account', writable: true, signer: false },\n { name: 'output_token_account', writable: true, signer: false },\n { name: 'input_vault', writable: true, signer: false },\n { name: 'output_vault', writable: true, signer: false },\n { name: 'input_token_program', writable: false, signer: false },\n { name: 'output_token_program', writable: false, signer: false },\n { name: 'input_token_mint', writable: false, signer: false },\n { name: 'output_token_mint', writable: false, signer: false },\n { name: 'observation_state', writable: true, signer: false },\n ],\n};\n\n/**\n * `collect_creator_fee` on `CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C` — not in interfaces.json (the program never builds it).\n * The last account is not in the IDL snapshot; see `CPMM_CREATOR_FEE_SHARE_ACCOUNT` in\n * scripts/codegen.mjs. Derive it as PDA([\"creator_fee_share\", creator, amm_config]).\n */\nexport const CPMM_COLLECT_CREATOR_FEE: VenueInstructionAbi = {\n name: 'collect_creator_fee',\n discriminator: new Uint8Array([20, 22, 86, 123, 198, 28, 219, 132]),\n accounts: [\n { name: 'creator', writable: true, signer: true },\n { name: 'authority', writable: false, signer: false },\n { name: 'pool_state', writable: true, signer: false },\n { name: 'amm_config', writable: false, signer: false },\n { name: 'token_0_vault', writable: true, signer: false },\n { name: 'token_1_vault', writable: true, signer: false },\n { name: 'vault_0_mint', writable: false, signer: false },\n { name: 'vault_1_mint', writable: false, signer: false },\n { name: 'creator_token_0', writable: true, signer: false },\n { name: 'creator_token_1', writable: true, signer: false },\n { name: 'token_0_program', writable: false, signer: false },\n { name: 'token_1_program', writable: false, signer: false },\n { name: 'associated_token_program', writable: false, signer: false },\n { name: 'system_program', writable: false, signer: false },\n { name: 'creator_fee_share', writable: false, signer: false },\n ],\n};\n","/**\n * The Raydium addresses and launch numbers Gabox pins, per cluster.\n *\n * Mainnet and devnet run different Raydium deployments. Every program id and every PDA differs, and\n * so does the quote the curve must raise before a coin graduates. So nothing here is a global: a\n * caller passes the cluster, which comes from `createClient({ cluster })`.\n *\n * None of these strings is typed in this file. `scripts/codegen.mjs` reads them out of the Rust\n * program's `programs/gabox/src/venue/ids.rs` and writes `abi.ts`. The Rust file is the source of\n * truth, because the program checks every one of these addresses on chain.\n * `test/raydium-pdas.test.ts` derives each PDA again and compares.\n */\n\nimport { getAddressEncoder, type Address } from '@solana/kit';\n\nimport type { Cluster } from '../rpc';\nimport {\n LAUNCH_SUPPLY,\n LAUNCH_TOTAL_BASE_SELL,\n METAPLEX_PROGRAM_ADDRESS,\n PLATFORM_ADMIN,\n RAYDIUM_DEVNET_IDS,\n RAYDIUM_MAINNET_IDS,\n WSOL_MINT,\n type RaydiumClusterIds,\n} from './abi';\n\nconst ADDRESS_ENCODER = getAddressEncoder();\n\nexport {\n LAUNCH_SUPPLY,\n LAUNCH_TOTAL_BASE_SELL,\n METAPLEX_PROGRAM_ADDRESS,\n PLATFORM_ADMIN,\n RAYDIUM_DEVNET_IDS,\n RAYDIUM_MAINNET_IDS,\n WSOL_MINT,\n};\nexport type { RaydiumClusterIds };\n\n/** The name the rest of the SDK uses for one cluster's Raydium deployment. */\nexport type RaydiumIds = RaydiumClusterIds;\n\n/**\n * The decimals every Gabox coin is launched with. `venue/launch.rs` refuses any other value, and\n * `tokens.rs` refuses a pool mint that does not have exactly this many.\n */\nexport const LAUNCH_DECIMALS = 6;\n\n/**\n * The Raydium deployment of each cluster.\n *\n * `localnet` uses the mainnet set. A local validator normally clones the mainnet Raydium programs,\n * and the program's own default `anchor build` pins the mainnet addresses too; the `devnet` cargo\n * feature is what swaps them. Pass your own ids to a builder if your validator clones devnet.\n */\nexport const RAYDIUM_IDS: Readonly<Record<Cluster, RaydiumIds>> = {\n 'mainnet-beta': RAYDIUM_MAINNET_IDS,\n devnet: RAYDIUM_DEVNET_IDS,\n localnet: RAYDIUM_MAINNET_IDS,\n};\n\n/** The Raydium deployment one cluster trades on. Throws for a cluster this SDK does not know. */\nexport function raydiumIds(cluster: Cluster): RaydiumIds {\n const ids = RAYDIUM_IDS[cluster];\n if (!ids) {\n throw new Error(\n `unknown cluster ${JSON.stringify(cluster)}; expected 'devnet', 'mainnet-beta' or 'localnet'`,\n );\n }\n return ids;\n}\n\n/** LaunchLab's PDA seeds, and the two Gabox coins are always sorted against. */\nexport const LAUNCHLAB_SEEDS = {\n /** `[\"vault_auth_seed\"]`. */\n authority: 'vault_auth_seed',\n /** `[\"__event_authority\"]`. */\n eventAuthority: '__event_authority',\n /** `[\"global_config\", quote_mint, u8 curve_type, u16 big-endian index]`. */\n globalConfig: 'global_config',\n /** `[\"platform_config\", platform_admin]`. */\n platformConfig: 'platform_config',\n /** `[\"pool\", base_mint, quote_mint]`. */\n pool: 'pool',\n /** `[\"pool_vault\", pool_state, mint]`. */\n vault: 'pool_vault',\n /** `[\"creator_fee_vault_auth_seed\"]`, the authority over every creator fee vault. */\n creatorFeeVaultAuthority: 'creator_fee_vault_auth_seed',\n} as const;\n\n/** CPMM's PDA seeds. */\nexport const CPMM_SEEDS = {\n /** `[\"vault_and_lp_mint_auth_seed\"]`. */\n authority: 'vault_and_lp_mint_auth_seed',\n /** `[\"pool\", amm_config, token_0_mint, token_1_mint]`, the mints sorted by byte order. */\n pool: 'pool',\n /** `[\"pool_vault\", pool_state, mint]`. */\n vault: 'pool_vault',\n /** `[\"observation\", pool_state]`. */\n observation: 'observation',\n /** `[\"creator_fee_share\", creator, amm_config]`. */\n creatorFeeShare: 'creator_fee_share',\n} as const;\n\n/** Metaplex's metadata PDA seed: `[\"metadata\", metaplex, mint]`. */\nexport const METADATA_SEED = 'metadata';\n\n/**\n * Every rate LaunchLab and CPMM state is out of 1,000,000, not out of 10,000. A `trade_fee_rate`\n * of 5,000 is 0.5%.\n */\nexport const RATE_DENOMINATOR = 1_000_000n;\n\n/** The share-fee receiver Gabox never passes, so its rate is always zero on every trade. */\nexport const SHARE_FEE_RATE = 0n;\n\n/** `CurveParams::Constant`, the only curve shape Gabox launches. */\nexport const CONSTANT_CURVE_TAG = 0;\n\n/** `migrate_type` 1: the coin graduates into a CPMM pool, not into an AMM pool. */\nexport const MIGRATE_TO_CPMM = 1;\n\n/** `AmmCreatorFeeOn::QuoteToken`, so the CPMM creator fee is paid in WSOL. */\nexport const CREATOR_FEE_ON_QUOTE = 0;\n\n/** LaunchLab pool `status`: still selling on the curve. */\nexport const LAUNCHLAB_STATUS_FUND = 0;\n/** LaunchLab pool `status`: the raise is complete and Raydium's bot is migrating the coin. */\nexport const LAUNCHLAB_STATUS_MIGRATE = 1;\n/** LaunchLab pool `status`: the coin has graduated and trades on its CPMM pool. */\nexport const LAUNCHLAB_STATUS_TRADE = 2;\n\n/** Metaplex's own limits on the three strings a creator picks, in UTF-8 bytes. */\nexport const METADATA_LIMITS = { name: 32, symbol: 10, uri: 200 } as const;\n\n/** Raydium sorts a CPMM pair by raw address byte order. */\nexport function sortedMints(a: Address, b: Address): [Address, Address] {\n return compareAddresses(a, b) <= 0 ? [a, b] : [b, a];\n}\n\n/** Compare two addresses the way the runtime does: by their 32 raw bytes, not by base58 text. */\nexport function compareAddresses(a: Address, b: Address): number {\n const left = ADDRESS_ENCODER.encode(a);\n const right = ADDRESS_ENCODER.encode(b);\n for (let i = 0; i < 32; i++) {\n const difference = (left[i] ?? 0) - (right[i] ?? 0);\n if (difference !== 0) return difference;\n }\n return 0;\n}\n","/**\n * Every Raydium address a Gabox transaction derives.\n *\n * All of them are program-derived, so each one takes the program it lives under. Mainnet and devnet\n * run different Raydium programs, so the same seeds give different addresses on the two clusters.\n * Pass `raydiumIds(client.cluster)` and read the program out of it.\n *\n * `venue/trade.rs` and `venue/launch.rs` derive the same addresses on chain and refuse any account\n * that does not match. `test/raydium-pdas.test.ts` checks every one of these against the pinned\n * table in `abi.ts`, for both clusters.\n */\n\nimport {\n Endian,\n getAddressEncoder,\n getProgramDerivedAddress,\n getU16Encoder,\n getU8Encoder,\n getUtf8Encoder,\n type Address,\n} from '@solana/kit';\n\nimport {\n ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\n METAPLEX_PROGRAM_ADDRESS,\n TOKEN_PROGRAM_ADDRESS,\n} from './abi';\nimport { CPMM_SEEDS, LAUNCHLAB_SEEDS, METADATA_SEED, sortedMints } from './ids';\n\nconst address = getAddressEncoder();\nconst utf8 = getUtf8Encoder();\nconst u8 = getU8Encoder();\nconst u16be = getU16Encoder({ endian: Endian.Big });\n\nconst derive = async (programAddress: Address, seeds: Uint8Array[]): Promise<Address> =>\n (await getProgramDerivedAddress({ programAddress, seeds }))[0];\n\n// ─────────────────────────────────────────────────────────────────────────────\n// LaunchLab\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** `[\"vault_auth_seed\"]`. LaunchLab signs its own vault transfers with this PDA. */\nexport const launchlabAuthority = async (launchlab: Address): Promise<Address> =>\n await derive(launchlab, [utf8.encode(LAUNCHLAB_SEEDS.authority) as Uint8Array]);\n\n/** `[\"__event_authority\"]`. */\nexport const launchlabEventAuthority = async (launchlab: Address): Promise<Address> =>\n await derive(launchlab, [utf8.encode(LAUNCHLAB_SEEDS.eventAuthority) as Uint8Array]);\n\n/**\n * `[\"global_config\", quote_mint, u8 curve_type, u16 big-endian index]`. The curve settings for one\n * quote asset. Gabox uses curve type 0 (constant product) and index 0.\n */\nexport const launchlabGlobalConfig = async (\n launchlab: Address,\n quoteMint: Address,\n curveType = 0,\n index = 0,\n): Promise<Address> =>\n await derive(launchlab, [\n utf8.encode(LAUNCHLAB_SEEDS.globalConfig) as Uint8Array,\n address.encode(quoteMint) as Uint8Array,\n u8.encode(curveType) as Uint8Array,\n u16be.encode(index) as Uint8Array,\n ]);\n\n/** `[\"platform_config\", platform_admin]`. The Gabox platform on LaunchLab. */\nexport const launchlabPlatformConfig = async (\n launchlab: Address,\n platformAdmin: Address,\n): Promise<Address> =>\n await derive(launchlab, [\n utf8.encode(LAUNCHLAB_SEEDS.platformConfig) as Uint8Array,\n address.encode(platformAdmin) as Uint8Array,\n ]);\n\n/** `[\"pool\", base_mint, quote_mint]`. The curve pool of one coin. */\nexport const launchlabPoolAddress = async (\n launchlab: Address,\n baseMint: Address,\n quoteMint: Address,\n): Promise<Address> =>\n await derive(launchlab, [\n utf8.encode(LAUNCHLAB_SEEDS.pool) as Uint8Array,\n address.encode(baseMint) as Uint8Array,\n address.encode(quoteMint) as Uint8Array,\n ]);\n\n/** `[\"pool_vault\", pool_state, mint]`. One side of a curve pool's reserves. */\nexport const launchlabVaultAddress = async (\n launchlab: Address,\n poolState: Address,\n mint: Address,\n): Promise<Address> =>\n await derive(launchlab, [\n utf8.encode(LAUNCHLAB_SEEDS.vault) as Uint8Array,\n address.encode(poolState) as Uint8Array,\n address.encode(mint) as Uint8Array,\n ]);\n\n/**\n * `[platform_config, quote_mint]`. LaunchLab pays the platform share of every curve trade here.\n *\n * The seeds carry no text prefix. That is Raydium's own derivation, not a mistake.\n */\nexport const platformFeeVaultAddress = async (\n launchlab: Address,\n platformConfig: Address,\n quoteMint: Address,\n): Promise<Address> =>\n await derive(launchlab, [\n address.encode(platformConfig) as Uint8Array,\n address.encode(quoteMint) as Uint8Array,\n ]);\n\n/**\n * `[creator, quote_mint]`. LaunchLab pays the creator share of every curve trade here.\n *\n * One vault per wallet per quote asset, not one per coin. A creator with several coins collects\n * all of them with a single `claim_creator_fee`.\n */\nexport const creatorFeeVaultAddress = async (\n launchlab: Address,\n creator: Address,\n quoteMint: Address,\n): Promise<Address> =>\n await derive(launchlab, [\n address.encode(creator) as Uint8Array,\n address.encode(quoteMint) as Uint8Array,\n ]);\n\n/** `[\"creator_fee_vault_auth_seed\"]`. The authority `claim_creator_fee` signs the payout with. */\nexport const creatorFeeVaultAuthority = async (launchlab: Address): Promise<Address> =>\n await derive(launchlab, [utf8.encode(LAUNCHLAB_SEEDS.creatorFeeVaultAuthority) as Uint8Array]);\n\n/** `[\"metadata\", metaplex, mint]` under Metaplex. LaunchLab's create instruction writes it. */\nexport const metadataAddress = async (mint: Address): Promise<Address> =>\n await derive(METAPLEX_PROGRAM_ADDRESS, [\n utf8.encode(METADATA_SEED) as Uint8Array,\n address.encode(METAPLEX_PROGRAM_ADDRESS) as Uint8Array,\n address.encode(mint) as Uint8Array,\n ]);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// CPMM\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** `[\"vault_and_lp_mint_auth_seed\"]`. */\nexport const cpmmAuthority = async (cpmm: Address): Promise<Address> =>\n await derive(cpmm, [utf8.encode(CPMM_SEEDS.authority) as Uint8Array]);\n\n/**\n * `[\"pool\", amm_config, token_0, token_1]`, with the two mints sorted by raw byte order.\n *\n * This is where Raydium migrates a coin when the address is free. It is only a first guess: when the\n * account is taken, the migration lands somewhere else entirely. And the address alone proves\n * nothing, because anyone can open a CPMM pool for any pair under any config. `findCpmmPool` tries\n * this address, checks the account data, and scans for the real pool when it does not match.\n *\n * There are no vault or observation derivations here on purpose. `venue/trade.rs` reads those three\n * addresses out of the pool account, and so does this SDK: a migrated pool names its own vaults and\n * its own oracle, wherever it sits.\n */\nexport const cpmmPoolAddress = async (\n cpmm: Address,\n ammConfig: Address,\n mintA: Address,\n mintB: Address,\n): Promise<Address> => {\n const [token0, token1] = sortedMints(mintA, mintB);\n return await derive(cpmm, [\n utf8.encode(CPMM_SEEDS.pool) as Uint8Array,\n address.encode(ammConfig) as Uint8Array,\n address.encode(token0) as Uint8Array,\n address.encode(token1) as Uint8Array,\n ]);\n};\n\n/**\n * `[\"creator_fee_share\", creator, amm_config]`. Where CPMM tracks what one creator is owed under\n * one fee tier.\n *\n * `collect_creator_fee` takes this account after the fourteen the mainnet IDL lists. That snapshot\n * predates the account; Raydium's devnet build declares it and stops with `AccountNotEnoughKeys`\n * (3005) when it is missing. One account per creator per fee tier, not one per pool.\n */\nexport const cpmmCreatorFeeShare = async (\n cpmm: Address,\n creator: Address,\n ammConfig: Address,\n): Promise<Address> =>\n await derive(cpmm, [\n utf8.encode(CPMM_SEEDS.creatorFeeShare) as Uint8Array,\n address.encode(creator) as Uint8Array,\n address.encode(ammConfig) as Uint8Array,\n ]);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Token accounts\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** An associated token account. Off-curve owners are allowed: pool PDAs are all off-curve. */\nexport const ata = async (\n owner: Address,\n mint: Address,\n tokenProgram: Address = TOKEN_PROGRAM_ADDRESS,\n): Promise<Address> =>\n await derive(ASSOCIATED_TOKEN_PROGRAM_ADDRESS, [\n address.encode(owner) as Uint8Array,\n address.encode(tokenProgram) as Uint8Array,\n address.encode(mint) as Uint8Array,\n ]);\n","/**\n * Reading Raydium's accounts.\n *\n * Every decoder here is written from the field list in the two IDL snapshots under `idl/`. Nothing\n * is guessed: each struct is laid out in Borsh order with no padding between fields, so the offsets\n * follow from the field sizes alone. Each decoder checks the account's eight-byte discriminator\n * first, so a wrong account fails loudly instead of decoding as plausible rubbish.\n *\n * `test/raydium-decode.test.ts` builds one byte array per decoder by hand and reads it back.\n *\n * Only the fields Gabox needs are decoded. The trailing padding of each account is skipped, which\n * is also why a longer account than the one recorded here still decodes: Raydium only ever appends\n * into its own padding.\n *\n * Kit's codecs, never `Buffer`. This module is vendored into a Next.js app, and `Buffer` does not\n * exist in a browser.\n */\n\nimport {\n fixDecoderSize,\n getAddressDecoder,\n getBooleanDecoder,\n getBytesDecoder,\n getStructDecoder,\n getU8Decoder,\n getU16Decoder,\n getU64Decoder,\n type Address,\n type ReadonlyUint8Array,\n} from '@solana/kit';\n\nimport {\n CPMM_AMM_CONFIG_DISCRIMINATOR,\n CPMM_POOL_STATE_DISCRIMINATOR,\n LAUNCHLAB_GLOBAL_CONFIG_DISCRIMINATOR,\n LAUNCHLAB_PLATFORM_CONFIG_DISCRIMINATOR,\n LAUNCHLAB_POOL_STATE_DISCRIMINATOR,\n} from './abi';\n\nconst DISCRIMINATOR = 8;\n\nconst u8 = getU8Decoder();\nconst u16 = getU16Decoder();\nconst u64 = getU64Decoder();\nconst addressAt = getAddressDecoder();\nconst bool = getBooleanDecoder();\n\n/** Refuse an account that is too short or carries another type's discriminator. */\nfunction checked(data: Uint8Array, discriminator: ReadonlyUint8Array, what: string): Uint8Array {\n if (data.length < discriminator.length) {\n throw new Error(`not a ${what}: ${data.length} bytes is shorter than a discriminator`);\n }\n for (const [i, byte] of discriminator.entries()) {\n if (data[i] !== byte) throw new Error(`not a ${what}: the discriminator does not match`);\n }\n return data;\n}\n\n/** Refuse a truncated account before a decoder reads past its end. */\nfunction atLeast(data: Uint8Array, size: number, what: string): Uint8Array {\n if (data.length < size) {\n throw new Error(`not a ${what}: ${data.length} bytes, expected at least ${size}`);\n }\n return data;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Token accounts\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * The `amount` field of an SPL token account: bytes 64 to 72, little-endian.\n *\n * Both venues and every Gabox account use classic SPL Token, whose account is 165 bytes. The\n * Token-2022 layout shares those first 165 bytes, so this reader covers a Token-2022 account too.\n */\nexport function tokenAccountAmount(data: Uint8Array): bigint {\n if (data.length < 72) throw new Error('not a token account: fewer than 72 bytes');\n return u64.decode(data, 64);\n}\n\n/** The `mint` and `owner` of an SPL token account: bytes 0 to 32 and 32 to 64. */\nexport function tokenAccountOwnerAndMint(data: Uint8Array): { mint: Address; owner: Address } {\n if (data.length < 64) throw new Error('not a token account: fewer than 64 bytes');\n return { mint: addressAt.decode(data, 0), owner: addressAt.decode(data, 32) };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// LaunchLab\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** The curve pool of one coin, as far as pricing and routing need it. */\nexport type LaunchlabPoolState = {\n /** 0 while the curve still sells, 1 while Raydium migrates the coin, 2 once it has graduated. */\n status: number;\n baseDecimals: number;\n quoteDecimals: number;\n /** 1 means the coin graduates into a CPMM pool. Every Gabox launch pins this. */\n migrateType: number;\n supply: bigint;\n /** The part of the supply the curve sells. The curve cannot sell more than this. */\n totalBaseSell: bigint;\n /** The curve's virtual reserves. `virtualQuote / virtualBase` is the starting price. */\n virtualBase: bigint;\n virtualQuote: bigint;\n /** Coins the curve has already sold, and quote it has already raised. */\n realBase: bigint;\n realQuote: bigint;\n totalQuoteFundRaising: bigint;\n migrateFee: bigint;\n globalConfig: Address;\n platformConfig: Address;\n baseMint: Address;\n quoteMint: Address;\n baseVault: Address;\n quoteVault: Address;\n /** The coin creator. LaunchLab pays the creator share of every trade to this wallet's vault. */\n creator: Address;\n /** 0 means the CPMM creator fee is paid in the quote token only. Every Gabox launch pins it. */\n ammCreatorFeeOn: number;\n};\n\n/** Offsets follow the `PoolState` field list in `idl/raydium_launchpad.json`. */\nconst LAUNCHLAB_POOL_HEAD = getStructDecoder([\n ['epoch', u64],\n ['authBump', u8],\n ['status', u8],\n ['baseDecimals', u8],\n ['quoteDecimals', u8],\n ['migrateType', u8],\n ['supply', u64],\n ['totalBaseSell', u64],\n ['virtualBase', u64],\n ['virtualQuote', u64],\n ['realBase', u64],\n ['realQuote', u64],\n ['totalQuoteFundRaising', u64],\n ['quoteProtocolFee', u64],\n ['platformFee', u64],\n ['migrateFee', u64],\n // VestingSchedule: five u64s Gabox always launches as zero.\n ['vestingTotalLockedAmount', u64],\n ['vestingCliffPeriod', u64],\n ['vestingUnlockPeriod', u64],\n ['vestingStartTime', u64],\n ['vestingAllocatedShareAmount', u64],\n ['globalConfig', addressAt],\n ['platformConfig', addressAt],\n ['baseMint', addressAt],\n ['quoteMint', addressAt],\n ['baseVault', addressAt],\n ['quoteVault', addressAt],\n ['creator', addressAt],\n ['tokenProgramFlag', u8],\n ['ammCreatorFeeOn', u8],\n]);\n\n/** The bytes the decoder above reads, discriminator included. The account itself is longer. */\nexport const LAUNCHLAB_POOL_STATE_HEAD_SIZE = 367;\n\nexport function decodeLaunchlabPool(data: Uint8Array): LaunchlabPoolState {\n checked(data, LAUNCHLAB_POOL_STATE_DISCRIMINATOR, 'LaunchLab pool');\n atLeast(data, LAUNCHLAB_POOL_STATE_HEAD_SIZE, 'LaunchLab pool');\n const head = LAUNCHLAB_POOL_HEAD.decode(data, DISCRIMINATOR);\n return {\n status: head.status,\n baseDecimals: head.baseDecimals,\n quoteDecimals: head.quoteDecimals,\n migrateType: head.migrateType,\n supply: head.supply,\n totalBaseSell: head.totalBaseSell,\n virtualBase: head.virtualBase,\n virtualQuote: head.virtualQuote,\n realBase: head.realBase,\n realQuote: head.realQuote,\n totalQuoteFundRaising: head.totalQuoteFundRaising,\n migrateFee: head.migrateFee,\n globalConfig: head.globalConfig,\n platformConfig: head.platformConfig,\n baseMint: head.baseMint,\n quoteMint: head.quoteMint,\n baseVault: head.baseVault,\n quoteVault: head.quoteVault,\n creator: head.creator,\n ammCreatorFeeOn: head.ammCreatorFeeOn,\n };\n}\n\n/** LaunchLab's settings for one quote asset. Gabox reads the trade fee and the migrate fee. */\nexport type LaunchlabGlobalConfig = {\n /** 0 is the constant product curve, the only shape Gabox launches. */\n curveType: number;\n index: number;\n /** The quote LaunchLab keeps at graduation. It lowers the curve's own starting reserves. */\n migrateFee: bigint;\n /** Raydium's own share of every curve trade, out of 1,000,000. */\n tradeFeeRate: bigint;\n quoteMint: Address;\n};\n\nconst LAUNCHLAB_GLOBAL_CONFIG_HEAD = getStructDecoder([\n ['epoch', u64],\n ['curveType', u8],\n ['index', u16],\n ['migrateFee', u64],\n ['tradeFeeRate', u64],\n ['maxShareFeeRate', u64],\n ['minBaseSupply', u64],\n ['maxLockRate', u64],\n ['minBaseSellRate', u64],\n ['minBaseMigrateRate', u64],\n ['minQuoteFundRaising', u64],\n ['quoteMint', addressAt],\n]);\n\nexport const LAUNCHLAB_GLOBAL_CONFIG_HEAD_SIZE = 115;\n\nexport function decodeLaunchlabGlobalConfig(data: Uint8Array): LaunchlabGlobalConfig {\n checked(data, LAUNCHLAB_GLOBAL_CONFIG_DISCRIMINATOR, 'LaunchLab global config');\n atLeast(data, LAUNCHLAB_GLOBAL_CONFIG_HEAD_SIZE, 'LaunchLab global config');\n const head = LAUNCHLAB_GLOBAL_CONFIG_HEAD.decode(data, DISCRIMINATOR);\n return {\n curveType: head.curveType,\n index: head.index,\n migrateFee: head.migrateFee,\n tradeFeeRate: head.tradeFeeRate,\n quoteMint: head.quoteMint,\n };\n}\n\n/** The Gabox platform on LaunchLab. Its two rates are the platform and creator shares. */\nexport type LaunchlabPlatformConfig = {\n /** Receives the platform share of every curve trade. */\n platformFeeWallet: Address;\n /** The platform share of every curve trade, out of 1,000,000. 5,000 is 0.5%. */\n feeRate: bigint;\n /** The coin creator's share of every curve trade, out of 1,000,000. 5,000 is 0.5%. */\n creatorFeeRate: bigint;\n /** The CPMM fee tier a coin of this platform graduates into. */\n cpswapConfig: Address;\n /**\n * When this is a real wallet, it becomes the CPMM pool creator at graduation instead of the coin\n * creator. Gabox leaves it empty, so its coin creators keep the CPMM creator fee.\n */\n platformCpCreator: Address;\n};\n\n/**\n * The fixed-size head of `PlatformConfig`, before its `curve_params` vector. The three text fields\n * are fixed byte arrays, so this is the same length for every platform.\n */\nconst LAUNCHLAB_PLATFORM_CONFIG_HEAD = getStructDecoder([\n ['epoch', u64],\n ['platformFeeWallet', addressAt],\n ['platformNftWallet', addressAt],\n ['platformScale', u64],\n ['creatorScale', u64],\n ['burnScale', u64],\n ['feeRate', u64],\n]);\n\n/** `name` is 64 bytes, `web` and `img` are 256 each. They sit between the two rates. */\nconst PLATFORM_TEXT_BYTES = 64 + 256 + 256;\nconst PLATFORM_CPSWAP_CONFIG_OFFSET = DISCRIMINATOR + 8 + 32 + 32 + 8 + 8 + 8 + 8 + PLATFORM_TEXT_BYTES;\nconst PLATFORM_CREATOR_FEE_RATE_OFFSET = PLATFORM_CPSWAP_CONFIG_OFFSET + 32;\nconst PLATFORM_CP_CREATOR_OFFSET = PLATFORM_CREATOR_FEE_RATE_OFFSET + 8 + 32 + 32 + 8;\n\n/** Everything before `curve_params`, discriminator included. */\nexport const LAUNCHLAB_PLATFORM_CONFIG_HEAD_SIZE = PLATFORM_CP_CREATOR_OFFSET + 32 + 108;\n\nexport function decodeLaunchlabPlatformConfig(data: Uint8Array): LaunchlabPlatformConfig {\n checked(data, LAUNCHLAB_PLATFORM_CONFIG_DISCRIMINATOR, 'LaunchLab platform config');\n atLeast(data, LAUNCHLAB_PLATFORM_CONFIG_HEAD_SIZE, 'LaunchLab platform config');\n const head = LAUNCHLAB_PLATFORM_CONFIG_HEAD.decode(data, DISCRIMINATOR);\n return {\n platformFeeWallet: head.platformFeeWallet,\n feeRate: head.feeRate,\n creatorFeeRate: u64.decode(data, PLATFORM_CREATOR_FEE_RATE_OFFSET),\n cpswapConfig: addressAt.decode(data, PLATFORM_CPSWAP_CONFIG_OFFSET),\n platformCpCreator: addressAt.decode(data, PLATFORM_CP_CREATOR_OFFSET),\n };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// CPMM\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** The pool a graduated Gabox coin trades in. */\nexport type CpmmPoolState = {\n ammConfig: Address;\n /** LaunchLab sets this to the coin creator at migration. It earns the CPMM creator fee. */\n poolCreator: Address;\n token0Vault: Address;\n token1Vault: Address;\n token0Mint: Address;\n token1Mint: Address;\n token0Program: Address;\n token1Program: Address;\n observationKey: Address;\n /** Bit flags. Bit 2 set (value 4) means swaps are switched off. */\n status: number;\n mint0Decimals: number;\n mint1Decimals: number;\n /** Fees the pool owes and a swap must not spend. Subtract them from the vault balances. */\n protocolFeesToken0: bigint;\n protocolFeesToken1: bigint;\n fundFeesToken0: bigint;\n fundFeesToken1: bigint;\n creatorFeesToken0: bigint;\n creatorFeesToken1: bigint;\n /** Unix seconds. Swaps fail before it. */\n openTime: bigint;\n /** 0 charges the creator fee on whichever token comes in, 1 only token 0, 2 only token 1. */\n creatorFeeOn: number;\n /** `false` switches the creator fee off entirely. */\n enableCreatorFee: boolean;\n};\n\nconst CPMM_POOL_HEAD = getStructDecoder([\n ['ammConfig', addressAt],\n ['poolCreator', addressAt],\n ['token0Vault', addressAt],\n ['token1Vault', addressAt],\n ['lpMint', addressAt],\n ['token0Mint', addressAt],\n ['token1Mint', addressAt],\n ['token0Program', addressAt],\n ['token1Program', addressAt],\n ['observationKey', addressAt],\n ['authBump', u8],\n ['status', u8],\n ['lpMintDecimals', u8],\n ['mint0Decimals', u8],\n ['mint1Decimals', u8],\n ['lpSupply', u64],\n ['protocolFeesToken0', u64],\n ['protocolFeesToken1', u64],\n ['fundFeesToken0', u64],\n ['fundFeesToken1', u64],\n ['openTime', u64],\n ['recentEpoch', u64],\n ['creatorFeeOn', u8],\n ['enableCreatorFee', bool],\n ['padding1', fixDecoderSize(getBytesDecoder(), 6)],\n ['creatorFeesToken0', u64],\n ['creatorFeesToken1', u64],\n]);\n\nexport const CPMM_POOL_STATE_HEAD_SIZE = 413;\n\n/**\n * The full byte length of a CPMM `PoolState`, trailing padding included. A `getProgramAccounts`\n * scan filters on it, so it has to be the whole account and not only the part decoded above.\n */\nexport const CPMM_POOL_STATE_SIZE = 637;\n\n/**\n * Byte offsets a `getProgramAccounts` scan matches on. They are the same offsets `venue/trade.rs`\n * reads the fields at, so a pool that passes the scan passes the program's own check.\n */\nexport const CPMM_POOL_OFFSETS = {\n ammConfig: 8,\n poolCreator: 40,\n token0Mint: 168,\n token1Mint: 200,\n enableCreatorFee: 390,\n} as const;\n\nexport function decodeCpmmPool(data: Uint8Array): CpmmPoolState {\n checked(data, CPMM_POOL_STATE_DISCRIMINATOR, 'CPMM pool');\n atLeast(data, CPMM_POOL_STATE_HEAD_SIZE, 'CPMM pool');\n const head = CPMM_POOL_HEAD.decode(data, DISCRIMINATOR);\n return {\n ammConfig: head.ammConfig,\n poolCreator: head.poolCreator,\n token0Vault: head.token0Vault,\n token1Vault: head.token1Vault,\n token0Mint: head.token0Mint,\n token1Mint: head.token1Mint,\n token0Program: head.token0Program,\n token1Program: head.token1Program,\n observationKey: head.observationKey,\n status: head.status,\n mint0Decimals: head.mint0Decimals,\n mint1Decimals: head.mint1Decimals,\n protocolFeesToken0: head.protocolFeesToken0,\n protocolFeesToken1: head.protocolFeesToken1,\n fundFeesToken0: head.fundFeesToken0,\n fundFeesToken1: head.fundFeesToken1,\n creatorFeesToken0: head.creatorFeesToken0,\n creatorFeesToken1: head.creatorFeesToken1,\n openTime: head.openTime,\n creatorFeeOn: head.creatorFeeOn,\n enableCreatorFee: head.enableCreatorFee,\n };\n}\n\n/** One CPMM fee tier. Every rate is out of 1,000,000. */\nexport type CpmmAmmConfig = {\n index: number;\n disableCreatePool: boolean;\n /** The pool's own fee on every swap. Devnet tier 5 is 5,000, which is 0.50%. */\n tradeFeeRate: bigint;\n /** Raydium's share of the trade fee, not an extra charge on the swap. */\n protocolFeeRate: bigint;\n fundFeeRate: bigint;\n /** The pool creator's fee on every swap. Devnet tier 5 is 4,000, which is 0.40%. */\n creatorFeeRate: bigint;\n};\n\nconst CPMM_AMM_CONFIG_HEAD = getStructDecoder([\n ['bump', u8],\n ['disableCreatePool', bool],\n ['index', u16],\n ['tradeFeeRate', u64],\n ['protocolFeeRate', u64],\n ['fundFeeRate', u64],\n ['createPoolFee', u64],\n ['protocolOwner', addressAt],\n ['fundOwner', addressAt],\n ['creatorFeeRate', u64],\n]);\n\nexport const CPMM_AMM_CONFIG_HEAD_SIZE = 116;\n\nexport function decodeCpmmAmmConfig(data: Uint8Array): CpmmAmmConfig {\n checked(data, CPMM_AMM_CONFIG_DISCRIMINATOR, 'CPMM amm config');\n atLeast(data, CPMM_AMM_CONFIG_HEAD_SIZE, 'CPMM amm config');\n const head = CPMM_AMM_CONFIG_HEAD.decode(data, DISCRIMINATOR);\n return {\n index: head.index,\n disableCreatePool: head.disableCreatePool,\n tradeFeeRate: head.tradeFeeRate,\n protocolFeeRate: head.protocolFeeRate,\n fundFeeRate: head.fundFeeRate,\n creatorFeeRate: head.creatorFeeRate,\n };\n}\n","/**\n * The two `ComputeBudget` instructions the transaction builders prepend.\n *\n * # Why every gabox transaction needs one\n *\n * The default budget is 200,000 compute units for the whole transaction. `buy_pack` alone does a\n * CPI into Raydium (which does its own CPIs into the token program and may create two fee vaults),\n * a `transfer_checked`, an account init, and a CPI into MagicBlock's VRF program that allocates a\n * request account. `createMachine` adds LaunchLab's `initialize_v2` to that, which mints the coin\n * and writes its Metaplex metadata. Neither fits in the default, and nothing on chain can raise its\n * own budget.\n *\n * # The numbers are measured\n *\n * Each figure below is about 1.3x the largest `computeUnitsConsumed` the devnet end-to-end test saw\n * over three runs on 2026-09-18, across both venues. That matters because the prioritisation fee is\n * `price x requested limit`: a request three times too large costs three times too much on every\n * pack. A caller may still override any of them.\n *\n * The three runs did not agree. A curve pack cost 164,717, then 167,723, then 181,225 units for the\n * same work, so the venue's own cost moves with state this SDK does not control. The 1.3x margin is\n * there to absorb that, and the largest of the three is always the basis.\n *\n * Re-measure after a change to a builder or to a Raydium program. `test/devnet.e2e.test.ts` prints\n * `CU <label>: <units> | <signature>` for every transaction it sends, which is where these came\n * from.\n */\n\nimport {\n getStructEncoder,\n getU32Encoder,\n getU64Encoder,\n getU8Encoder,\n type Address,\n type Instruction,\n type InstructionWithData,\n type ReadonlyUint8Array,\n} from '@solana/kit';\n\nexport const COMPUTE_BUDGET_PROGRAM_ADDRESS =\n 'ComputeBudget111111111111111111111111111111' as Address;\n\n/** The runtime's per-transaction ceiling. A larger request is rejected outright. */\nexport const MAX_COMPUTE_UNIT_LIMIT = 1_400_000;\n\n/** What an instruction gets when no `SetComputeUnitLimit` is present. */\nexport const DEFAULT_COMPUTE_UNIT_LIMIT = 200_000;\n\n/**\n * LaunchLab `initialize_v2`, the WSOL wrap, pool initialization with a seed buy, and the WSOL\n * close, in one transaction. Measured at `293,004`, `264,249` and `268,749`. The first run is the\n * worst case: that creator had no LaunchLab fee vault yet, so the transaction created one.\n */\nexport const CREATE_MACHINE_COMPUTE_UNITS = 385_000;\n\n/**\n * A WSOL wrap, a venue buy, an escrow transfer, a draw init, a VRF request and the WSOL close.\n * Measured at `164,717`, `167,723` and `181,225` on the curve, and `116,332`, `113,342` and\n * `119,334` on CPMM. The curve buy is dearer because a coin's first trade also creates the platform\n * and creator fee vaults.\n */\nexport const BUY_PACK_COMPUTE_UNITS = 240_000;\n\n/**\n * A WSOL wrap, a venue sale, and the WSOL close. Measured at `93,827`, `93,827` and `101,327` on\n * the curve, and `61,041`, `64,041` and `67,041` on CPMM.\n */\nexport const REDEEM_COMPUTE_UNITS = 135_000;\n\n/**\n * A creator fee claim: create the WSOL account, claim or collect, close it again. Measured at\n * `31,319` every run for the LaunchLab claim, and `40,959` every run for the CPMM collect.\n */\nexport const CLAIM_COMPUTE_UNITS = 55_000;\n\n/** `ComputeBudgetInstruction`'s discriminants. Positional and append-only upstream. */\nconst SET_COMPUTE_UNIT_LIMIT = 2;\nconst SET_COMPUTE_UNIT_PRICE = 3;\n\n/** `[u8 discriminant, u32 units]` — five bytes. */\nconst LIMIT_ENCODER = getStructEncoder([\n ['discriminant', getU8Encoder()],\n ['units', getU32Encoder()],\n]);\n\n/** `[u8 discriminant, u64 microLamports]` — nine bytes. */\nconst PRICE_ENCODER = getStructEncoder([\n ['discriminant', getU8Encoder()],\n ['microLamports', getU64Encoder()],\n]);\n\n/** An instruction for the compute budget program: no accounts, all of it in the data. */\nexport type ComputeBudgetInstruction = Instruction<string, readonly []> &\n InstructionWithData<ReadonlyUint8Array>;\n\nexport function getSetComputeUnitLimitInstruction(units: number): ComputeBudgetInstruction {\n if (!Number.isInteger(units) || units < 0 || units > MAX_COMPUTE_UNIT_LIMIT) {\n throw new Error(\n `compute unit limit must be an integer in 0..=${MAX_COMPUTE_UNIT_LIMIT}, got ${units}`,\n );\n }\n return {\n programAddress: COMPUTE_BUDGET_PROGRAM_ADDRESS,\n accounts: [],\n data: LIMIT_ENCODER.encode({ discriminant: SET_COMPUTE_UNIT_LIMIT, units }),\n };\n}\n\n/**\n * `SetComputeUnitPrice(microLamports)` — the priority fee, per compute unit.\n *\n * No default, deliberately. The fee that lands a transaction is a property of the network at the\n * moment you send it. A hardcoded price is either money burnt on an idle chain or a transaction\n * that quietly stops landing under load. Sample `getRecentPrioritizationFees`, or take it from\n * config.\n */\nexport function getSetComputeUnitPriceInstruction(\n microLamports: number | bigint,\n): ComputeBudgetInstruction {\n const price = BigInt(microLamports);\n if (price < 0n) throw new Error(`compute unit price must not be negative, got ${price}`);\n return {\n programAddress: COMPUTE_BUDGET_PROGRAM_ADDRESS,\n accounts: [],\n data: PRICE_ENCODER.encode({ discriminant: SET_COMPUTE_UNIT_PRICE, microLamports: price }),\n };\n}\n\n/** The compute budget prefix a builder prepends: a limit, and a price only when one is asked for. */\nexport function computeBudgetInstructions(\n units: number,\n microLamports?: number | bigint,\n): ComputeBudgetInstruction[] {\n const instructions = [getSetComputeUnitLimitInstruction(units)];\n if (microLamports !== undefined) {\n instructions.push(getSetComputeUnitPriceInstruction(microLamports));\n }\n return instructions;\n}\n","/**\n * The ordered account list of every Raydium trade Gabox forwards.\n *\n * # Why these are built here\n *\n * `venue/trade.rs` accepts four trade instructions and no others: LaunchLab's `buy_exact_out` and\n * `sell_exact_in`, CPMM's `swap_base_output` and `swap_base_input`. It takes the venue's own\n * account list as `remaining_accounts` and walks it position by position. So the lists are\n * assembled here, from `abi.ts`, which codegen generated from the same Raydium IDLs the program's\n * `venue/abi.rs` came from.\n *\n * # How to read the output\n *\n * Each function returns `AccountMeta[]` in ABI order, with the role each slot's own ABI gives it.\n * That list goes into `initialize_pool`, `buy_pack` or `sell_tokens` as `remainingAccounts`,\n * unchanged. The program then requires every writable slot to be writable in the outer transaction,\n * requires the one signer slot to be the purchaser, and checks every address by name.\n *\n * # CPMM names its accounts by direction\n *\n * CPMM calls its four pairs `input_*` and `output_*`. A buy sends quote and receives the coin; a\n * sell is the other way round. So the two builders below fill the same four names with opposite\n * addresses. LaunchLab names its accounts by role instead, and uses one list for both sides.\n */\n\nimport { AccountRole, type AccountMeta, type Address } from '@solana/kit';\n\nimport {\n CPMM_SWAP_BASE_INPUT,\n CPMM_SWAP_BASE_OUTPUT,\n LAUNCHLAB_BUY_EXACT_IN,\n LAUNCHLAB_BUY_EXACT_OUT,\n LAUNCHLAB_SELL_EXACT_IN,\n SYSTEM_PROGRAM_ADDRESS,\n TOKEN_PROGRAM_ADDRESS,\n type VenueInstructionAbi,\n} from './abi';\n\n/**\n * Turn `{name -> address}` into the ABI's ordered `AccountMeta[]`.\n *\n * The map is keyed by the IDL's own account names, so a missing entry names the slot it belongs to\n * rather than failing as an off-by-one further down. The role comes from the ABI table alone, never\n * from the caller, which is what keeps this list in step with `venue/abi.rs`.\n */\nexport function order(abi: VenueInstructionAbi, byName: Record<string, Address>): AccountMeta[] {\n return abi.accounts.map((spec) => {\n const address = byName[spec.name];\n if (address === undefined) {\n throw new Error(`${abi.name}: no address given for the \"${spec.name}\" account`);\n }\n const role = spec.signer\n ? spec.writable\n ? AccountRole.WRITABLE_SIGNER\n : AccountRole.READONLY_SIGNER\n : spec.writable\n ? AccountRole.WRITABLE\n : AccountRole.READONLY;\n return { address, role };\n });\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// LaunchLab\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** Everything a LaunchLab trade list needs. Every address is derived, never read off the chain. */\nexport type LaunchlabTradeAccountsInput = {\n /** Raydium LaunchLab on this cluster. */\n launchlab: Address;\n /** `[\"vault_auth_seed\"]` under LaunchLab. */\n launchlabAuthority: Address;\n /** `[\"__event_authority\"]` under LaunchLab. */\n launchlabEventAuthority: Address;\n /** The global config of the quote asset. */\n globalConfig: Address;\n /** The Gabox platform config. */\n platformConfig: Address;\n /** `[\"pool\", mint, quote_mint]` under LaunchLab. */\n poolState: Address;\n mint: Address;\n quoteMint: Address;\n /** `[\"pool_vault\", pool_state, mint]` under LaunchLab. */\n baseVault: Address;\n /** `[\"pool_vault\", pool_state, quote_mint]` under LaunchLab. */\n quoteVault: Address;\n /** The trader. The one signing slot in the list. */\n user: Address;\n /** The trader's coin ATA. `buy_pack` passes the same address as its own `user_tokens`. */\n userBaseToken: Address;\n /** The trader's WSOL ATA. Both venues settle here. */\n userQuoteToken: Address;\n /** `[platform_config, quote_mint]` under LaunchLab. */\n platformFeeVault: Address;\n /** `[creator, quote_mint]` under LaunchLab, where `creator` is the coin creator. */\n creatorFeeVault: Address;\n};\n\nfunction launchlabTradeAccounts(\n abi: VenueInstructionAbi,\n input: LaunchlabTradeAccountsInput,\n): AccountMeta[] {\n return order(abi, {\n payer: input.user,\n authority: input.launchlabAuthority,\n global_config: input.globalConfig,\n platform_config: input.platformConfig,\n pool_state: input.poolState,\n user_base_token: input.userBaseToken,\n user_quote_token: input.userQuoteToken,\n base_vault: input.baseVault,\n quote_vault: input.quoteVault,\n base_token_mint: input.mint,\n quote_token_mint: input.quoteMint,\n base_token_program: TOKEN_PROGRAM_ADDRESS,\n quote_token_program: TOKEN_PROGRAM_ADDRESS,\n event_authority: input.launchlabEventAuthority,\n program: input.launchlab,\n // The three LaunchLab reads from the remaining accounts. Without them it fails with error\n // 6018, `NotEnoughRemainingAccounts`.\n system_program: SYSTEM_PROGRAM_ADDRESS,\n platform_fee_vault: input.platformFeeVault,\n creator_fee_vault: input.creatorFeeVault,\n });\n}\n\n/** `buy_exact_out`: 18 accounts. The first argument is the coins wanted, the second the cost cap. */\nexport const launchlabBuyAccounts = (input: LaunchlabTradeAccountsInput): AccountMeta[] =>\n launchlabTradeAccounts(LAUNCHLAB_BUY_EXACT_OUT, input);\n\n/** `sell_exact_in`: the same 18 accounts. `venue/trade.rs` uses one table for both sides. */\nexport const launchlabSellAccounts = (input: LaunchlabTradeAccountsInput): AccountMeta[] =>\n launchlabTradeAccounts(LAUNCHLAB_SELL_EXACT_IN, input);\n\n/**\n * `buy_exact_in`: the same 18 accounts again. Gabox never forwards this instruction; a wallet sends\n * it on its own, to buy the curve out with a fixed spend.\n */\nexport const launchlabBuyExactInAccounts = (input: LaunchlabTradeAccountsInput): AccountMeta[] =>\n launchlabTradeAccounts(LAUNCHLAB_BUY_EXACT_IN, input);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// CPMM\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** Everything a CPMM trade list needs. */\nexport type CpmmTradeAccountsInput = {\n /** `[\"vault_and_lp_mint_auth_seed\"]` under CPMM. */\n cpmmAuthority: Address;\n /** The fee tier the pool belongs to. Gabox pins the one LaunchLab migrates into. */\n ammConfig: Address;\n /** The migrated pool. */\n poolState: Address;\n mint: Address;\n quoteMint: Address;\n /** `[\"pool_vault\", pool_state, mint]` under CPMM. */\n baseVault: Address;\n /** `[\"pool_vault\", pool_state, quote_mint]` under CPMM. */\n quoteVault: Address;\n /** `[\"observation\", pool_state]` under CPMM. */\n observationState: Address;\n /** The trader. The one signing slot, and read-only here: CPMM does not take its lamports. */\n user: Address;\n userBaseToken: Address;\n userQuoteToken: Address;\n};\n\n/** A buy sends the quote and receives the coin. A sell is the other way round. */\nfunction cpmmTradeAccounts(\n abi: VenueInstructionAbi,\n input: CpmmTradeAccountsInput,\n side: 'buy' | 'sell',\n): AccountMeta[] {\n const buying = side === 'buy';\n return order(abi, {\n payer: input.user,\n authority: input.cpmmAuthority,\n amm_config: input.ammConfig,\n pool_state: input.poolState,\n input_token_account: buying ? input.userQuoteToken : input.userBaseToken,\n output_token_account: buying ? input.userBaseToken : input.userQuoteToken,\n input_vault: buying ? input.quoteVault : input.baseVault,\n output_vault: buying ? input.baseVault : input.quoteVault,\n input_token_program: TOKEN_PROGRAM_ADDRESS,\n output_token_program: TOKEN_PROGRAM_ADDRESS,\n input_token_mint: buying ? input.quoteMint : input.mint,\n output_token_mint: buying ? input.mint : input.quoteMint,\n observation_state: input.observationState,\n });\n}\n\n/** `swap_base_output`: 13 accounts. Note the argument order is `(max_amount_in, amount_out)`. */\nexport const cpmmBuyAccounts = (input: CpmmTradeAccountsInput): AccountMeta[] =>\n cpmmTradeAccounts(CPMM_SWAP_BASE_OUTPUT, input, 'buy');\n\n/** `swap_base_input`: 13 accounts, with the four pairs swapped. */\nexport const cpmmSellAccounts = (input: CpmmTradeAccountsInput): AccountMeta[] =>\n cpmmTradeAccounts(CPMM_SWAP_BASE_INPUT, input, 'sell');\n","/**\n * Raydium's own price math, ported to bigint.\n *\n * Every function here is a line-by-line port of Raydium's TypeScript, which is itself the same math\n * their on-chain programs run. The point is that a buyer sees the exact number the venue will\n * charge, not an estimate: `buy_pack` passes the pack size as an exact-tokens-out amount, and the\n * program then requires the token delta to equal one pack.\n *\n * Sources, read on 2026-09-18:\n *\n * - `raydium/launchpad/curve/constantProductCurve.ts` and `curve.ts` (LaunchLab)\n * - `raydium/cpmm/curve/calculator.ts`, `constantProduct.ts` and `fee.ts` (CPMM)\n *\n * Raydium uses `BN`, which truncates toward zero on division. Every value here is a non-negative\n * bigint, where `/` truncates the same way, so a plain `/` is the faithful port of their `.div()`.\n * Where they round up they call a ceiling helper, and so does this file. Nothing is approximated\n * and no step is reordered: a division that happens before a subtraction there happens before it\n * here, because the two orders give different answers.\n *\n * Every rate is out of 1,000,000, not out of 10,000.\n */\n\nimport { RATE_DENOMINATOR } from './ids';\n\n/** `ceilDiv(a, b, denominator)` in Raydium's code: `ceil(a * b / denominator)`. */\nexport function ceilDivRate(amount: bigint, rate: bigint, denominator = RATE_DENOMINATOR): bigint {\n if (rate === 0n) return 0n;\n return ceilDiv(amount * rate, denominator);\n}\n\n/** `ceil(numerator / denominator)` for non-negative values. */\nexport function ceilDiv(numerator: bigint, denominator: bigint): bigint {\n if (denominator === 0n) throw new Error('divide by zero');\n return (numerator + denominator - 1n) / denominator;\n}\n\n/**\n * The amount before a fee was taken, given the amount after it: `ceil(post * 1e6 / (1e6 - rate))`.\n *\n * Raydium calls this `calculatePreFee` on the curve and `calculatePreFeeAmount` on CPMM. Both are\n * the same expression.\n */\nexport function preFeeAmount(postFeeAmount: bigint, rate: bigint): bigint {\n if (rate === 0n) return postFeeAmount;\n if (rate >= RATE_DENOMINATOR) throw new Error('a fee rate of 100% or more has no pre-fee amount');\n return ceilDiv(postFeeAmount * RATE_DENOMINATOR, RATE_DENOMINATOR - rate);\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// LaunchLab: the constant product curve\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** The four reserve numbers a curve price depends on. Read them off the pool account. */\nexport type CurveReserves = {\n virtualBase: bigint;\n virtualQuote: bigint;\n realBase: bigint;\n realQuote: bigint;\n /** The most the curve will ever sell. A buy larger than what is left is capped at it. */\n totalBaseSell: bigint;\n};\n\n/** The three fee rates a curve trade pays, each out of 1,000,000. */\nexport type CurveFeeRates = {\n /** `trade_fee_rate` on LaunchLab's global config: Raydium's own share. */\n tradeFeeRate: bigint;\n /** `fee_rate` on the platform config: the Gabox platform's share. */\n platformFeeRate: bigint;\n /** `creator_fee_rate` on the platform config: the coin creator's share. */\n creatorFeeRate: bigint;\n};\n\n/**\n * The whole fee a curve trade pays. Gabox never passes a share-fee receiver, so the fourth rate\n * Raydium supports is always zero and is left out here.\n */\nexport function totalCurveFeeRate(rates: CurveFeeRates): bigint {\n const total = rates.tradeFeeRate + rates.platformFeeRate + rates.creatorFeeRate;\n if (total > RATE_DENOMINATOR) throw new Error('the total curve fee rate exceeds 1,000,000');\n return total;\n}\n\n/** Coins the curve still has to sell. A buy cannot take more than this. */\nexport function remainingBase(pool: CurveReserves): bigint {\n return pool.totalBaseSell > pool.realBase ? pool.totalBaseSell - pool.realBase : 0n;\n}\n\n/** The two sides of the constant product, as the curve sees them right now. */\nconst quoteSide = (pool: CurveReserves): bigint => pool.virtualQuote + pool.realQuote;\nconst baseSide = (pool: CurveReserves): bigint => pool.virtualBase - pool.realBase;\n\n/**\n * Quote needed to buy exactly `tokens` coins on the curve, fees included.\n *\n * This is `Curve.buyExactOut` with no token transfer fee, which is always the case for Gabox: both\n * mints are classic SPL Token and carry no transfer-fee extension.\n *\n * Raydium caps the amount at what the curve has left to sell and still returns a price, so this\n * does the same. A caller that needs the whole `tokens` must check `remainingBase` first;\n * `resolveVenue` does.\n */\nexport function curveBuyExactOut(\n pool: CurveReserves,\n rates: CurveFeeRates,\n tokens: bigint,\n): bigint {\n if (tokens <= 0n) throw new Error('tokens must be positive');\n const remaining = remainingBase(pool);\n const amount = tokens > remaining ? remaining : tokens;\n if (amount === 0n) throw new Error('the curve has no coins left to sell');\n const quoteBeforeFees = curveQuoteInForBaseOut(pool, amount);\n return preFeeAmount(quoteBeforeFees, totalCurveFeeRate(rates));\n}\n\n/**\n * Coins `quote` buys on the curve right now, fees already taken off the spend.\n *\n * This is `Curve.buyExactIn`. It is what a raw `buy_exact_in` pays out, which the devnet end-to-end\n * test uses to push a curve to graduation.\n */\nexport function curveBuyExactIn(pool: CurveReserves, rates: CurveFeeRates, quote: bigint): bigint {\n if (quote <= 0n) throw new Error('quote must be positive');\n const fee = ceilDivRate(quote, totalCurveFeeRate(rates));\n const spend = quote - fee;\n if (spend <= 0n) throw new Error('the whole spend would go to fees');\n const tokens = curveBaseOutForQuoteIn(pool, spend);\n const remaining = remainingBase(pool);\n return tokens > remaining ? remaining : tokens;\n}\n\n/**\n * Quote a sale of exactly `tokens` coins returns, net of fees. This is `Curve.sellExactIn`.\n */\nexport function curveSellExactIn(pool: CurveReserves, rates: CurveFeeRates, tokens: bigint): bigint {\n if (tokens <= 0n) throw new Error('tokens must be positive');\n const gross = curveQuoteOutForBaseIn(pool, tokens);\n const fee = ceilDivRate(gross, totalCurveFeeRate(rates));\n return gross > fee ? gross - fee : 0n;\n}\n\n/** `getAmountIn` on the buy side: `ceil(quoteSide * out / (baseSide - out))`. */\nfunction curveQuoteInForBaseOut(pool: CurveReserves, tokens: bigint): bigint {\n const output = baseSide(pool);\n if (tokens >= output) throw new Error('the curve does not hold that many coins');\n return ceilDiv(quoteSide(pool) * tokens, output - tokens);\n}\n\n/** `getAmountOut` on the buy side: `floor(in * baseSide / (quoteSide + in))`. */\nfunction curveBaseOutForQuoteIn(pool: CurveReserves, quote: bigint): bigint {\n return (quote * baseSide(pool)) / (quoteSide(pool) + quote);\n}\n\n/** `getAmountOut` on the sell side: `floor(in * quoteSide / (baseSide + in))`. */\nfunction curveQuoteOutForBaseIn(pool: CurveReserves, tokens: bigint): bigint {\n return (tokens * quoteSide(pool)) / (baseSide(pool) + tokens);\n}\n\n/** What a launch pins, and what the starting reserves follow from. */\nexport type LaunchParams = {\n /** The whole supply the coin is minted with. */\n supply: bigint;\n /** The part of it the curve sells. */\n totalBaseSell: bigint;\n /** The quote the curve must raise before the coin graduates. */\n quoteRaise: bigint;\n /** Coins locked in a vesting schedule. Always zero for a Gabox launch. */\n totalLockedAmount?: bigint;\n /** The quote LaunchLab keeps at graduation, from its global config. */\n migrateFee?: bigint;\n};\n\n/**\n * The virtual reserves LaunchLab gives a coin that does not exist yet.\n *\n * This is `LaunchConstantProductCurve.getInitParam`. `createMachine` needs it because the seed buy\n * runs in the same transaction that creates the coin: there is no pool account to read yet, and the\n * reserves follow from the pinned launch shape alone.\n *\n * Checked against Raydium's own published numbers for the mainnet Gabox launch shape (supply\n * 1,000,000,000 coins, 793,100,000 sold on the curve, 85 SOL raised, no migrate fee):\n * `virtualBase` 1,073,025,605,596,382 and `virtualQuote` 30,000,852,951.\n */\nexport function initialCurve(params: LaunchParams): CurveReserves {\n const { supply, totalBaseSell, quoteRaise } = params;\n const locked = params.totalLockedAmount ?? 0n;\n const migrateFee = params.migrateFee ?? 0n;\n\n if (supply <= totalBaseSell) throw new Error('the supply must be larger than the curve sells');\n const migrateBase = supply - totalBaseSell - locked;\n if (migrateBase <= 0n) throw new Error('nothing would be left to seed the pool at graduation');\n const raiseLessMigrateFee = quoteRaise - migrateFee;\n if (raiseLessMigrateFee <= 0n) throw new Error('the migrate fee eats the whole raise');\n\n // Raydium divides where it divides. Moving either division changes the answer.\n const numerator = (raiseLessMigrateFee * totalBaseSell * totalBaseSell) / migrateBase;\n const denominator = (raiseLessMigrateFee * totalBaseSell) / migrateBase - quoteRaise;\n if (denominator <= 0n) throw new Error('these launch parameters have no valid starting price');\n\n return {\n virtualBase: numerator / denominator,\n virtualQuote: (quoteRaise * quoteRaise) / denominator,\n realBase: 0n,\n realQuote: 0n,\n totalBaseSell,\n };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// CPMM: the graduated pool\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** One side of a CPMM swap, after the pool's own unspendable fee balances are taken off. */\nexport type CpmmSwapSides = {\n /** Token going in: the quote on a buy, the coin on a sell. */\n inputReserve: bigint;\n /** Token coming out: the coin on a buy, the quote on a sell. */\n outputReserve: bigint;\n};\n\n/** The two CPMM rates, each out of 1,000,000, plus where the creator fee is charged. */\nexport type CpmmFeeRates = {\n /** `trade_fee_rate` on the `amm_config`. */\n tradeFeeRate: bigint;\n /** `creator_fee_rate` on the `amm_config`, or zero when the pool switched the fee off. */\n creatorFeeRate: bigint;\n /**\n * `true` when this side's creator fee comes off the input token, `false` when it comes off the\n * output. It follows from the pool's `creator_fee_on` and which token is going in.\n */\n creatorFeeOnInput: boolean;\n};\n\n/**\n * Quote a CPMM buy of exactly `tokens` coins costs, both fees included.\n *\n * This is `CurveCalculator.swapBaseOutput`, which is what `swap_base_output` charges.\n */\nexport function cpmmSwapBaseOutput(\n sides: CpmmSwapSides,\n rates: CpmmFeeRates,\n amountOut: bigint,\n): bigint {\n if (amountOut <= 0n) throw new Error('amountOut must be positive');\n const actualOut = rates.creatorFeeOnInput\n ? amountOut\n : preFeeAmount(amountOut, rates.creatorFeeRate);\n if (actualOut >= sides.outputReserve) {\n throw new Error('the pool does not hold that much of the output token');\n }\n const swapped = ceilDiv(sides.inputReserve * actualOut, sides.outputReserve - actualOut);\n const rate = rates.creatorFeeOnInput\n ? rates.tradeFeeRate + rates.creatorFeeRate\n : rates.tradeFeeRate;\n return preFeeAmount(swapped, rate);\n}\n\n/**\n * What a CPMM swap of exactly `amountIn` returns, net of both fees.\n *\n * This is `CurveCalculator.swapBaseInput`, which is what `swap_base_input` pays out.\n */\nexport function cpmmSwapBaseInput(\n sides: CpmmSwapSides,\n rates: CpmmFeeRates,\n amountIn: bigint,\n): bigint {\n if (amountIn <= 0n) throw new Error('amountIn must be positive');\n const tradeFee = ceilDivRate(amountIn, rates.tradeFeeRate);\n const creatorFeeIn = rates.creatorFeeOnInput ? ceilDivRate(amountIn, rates.creatorFeeRate) : 0n;\n const lessFees = amountIn - tradeFee - creatorFeeIn;\n if (lessFees <= 0n) throw new Error('the whole input would go to fees');\n const swapped = (lessFees * sides.outputReserve) / (sides.inputReserve + lessFees);\n if (rates.creatorFeeOnInput) return swapped;\n const creatorFeeOut = ceilDivRate(swapped, rates.creatorFeeRate);\n return swapped > creatorFeeOut ? swapped - creatorFeeOut : 0n;\n}\n","/**\n * Reading the venue: which one a coin trades on right now, what a pack costs there, and the account\n * list for the trade.\n *\n * `resolveVenue` reads every account the answer depends on, decodes them, and hands back a plain\n * object whose methods are pure. A caller that wants to re-price a different token count calls\n * `quoteBuy` again with no further reads.\n *\n * # Choosing the venue\n *\n * The LaunchLab pool's `status` is the whole rule:\n *\n * - `0`: the curve is still selling, so trade LaunchLab.\n * - `1`: the raise is finished and Raydium's own bot is moving the coin into a CPMM pool. Nothing\n * trades. This throws, and the message says to retry in a moment. On devnet the move usually\n * finishes within a minute.\n * - `2`: the coin graduated, so trade its CPMM pool.\n *\n * A coin can graduate between the read and the send. A pack buy then fails and no draw is created,\n * which is the intended outcome: refresh and retry.\n *\n * # Finding the migrated CPMM pool\n *\n * The pool is normally at `[\"pool\", cpswap_config, token_0, token_1]` under CPMM, where\n * `cpswap_config` is the fee tier the Gabox platform config names. It is not always: when that\n * address is already taken, Raydium migrates into a random account instead. So this module tries\n * the derived address first and falls back to a filtered `getProgramAccounts` scan.\n *\n * Either way the pool has to prove itself from its own data, which is what `venue/trade.rs` checks\n * on chain as well: CPMM owns it, it carries the `PoolState` discriminator, its `pool_creator` is\n * the coin creator, its two mints are the sorted pair, and `enable_creator_fee` is true. That last\n * flag is the one that cannot be forged. A plain CPMM `initialize` always leaves it false; only a\n * creator Raydium has permissioned, such as LaunchLab's migration, can set it.\n */\n\nimport {\n getBase64Encoder,\n type AccountMeta,\n type Address,\n type Base58EncodedBytes,\n} from '@solana/kit';\n\nimport type { GaboxClient, GaboxRpc } from '../rpc';\nimport {\n CPMM_POOL_OFFSETS,\n CPMM_POOL_STATE_SIZE,\n decodeCpmmAmmConfig,\n decodeCpmmPool,\n decodeLaunchlabGlobalConfig,\n decodeLaunchlabPlatformConfig,\n decodeLaunchlabPool,\n tokenAccountAmount,\n type CpmmAmmConfig,\n type CpmmPoolState,\n type LaunchlabPoolState,\n} from './adapter';\nimport {\n cpmmBuyAccounts,\n cpmmSellAccounts,\n launchlabBuyAccounts,\n launchlabSellAccounts,\n type CpmmTradeAccountsInput,\n type LaunchlabTradeAccountsInput,\n} from './accounts';\nimport {\n cpmmSwapBaseInput,\n cpmmSwapBaseOutput,\n curveBuyExactOut,\n curveSellExactIn,\n initialCurve,\n remainingBase,\n type CpmmFeeRates,\n type CpmmSwapSides,\n type CurveFeeRates,\n type CurveReserves,\n} from './curve';\nimport {\n LAUNCHLAB_STATUS_FUND,\n LAUNCHLAB_STATUS_MIGRATE,\n LAUNCHLAB_STATUS_TRADE,\n LAUNCH_SUPPLY,\n LAUNCH_TOTAL_BASE_SELL,\n WSOL_MINT,\n raydiumIds,\n sortedMints,\n type RaydiumIds,\n} from './ids';\nimport {\n ata,\n cpmmPoolAddress,\n creatorFeeVaultAddress,\n launchlabPoolAddress,\n launchlabVaultAddress,\n platformFeeVaultAddress,\n} from './pdas';\n\nexport type VenueKind = 'launchlab' | 'cpmm';\n\n/** Everything `resolveVenue` learned, plus the pure functions that follow from it. */\nexport type ResolvedVenue = {\n kind: VenueKind;\n /** The program to pass as the `venue` account. */\n program: Address;\n mint: Address;\n quoteMint: Address;\n /** The venue's own pool: the LaunchLab curve pool, or the migrated CPMM pool. */\n poolState: Address;\n /** The LaunchLab pool's `status`: 0 funding, 1 migrating, 2 graduated. */\n status: number;\n /** The coin creator. LaunchLab and CPMM both pay their creator fee to this wallet. */\n creator: Address;\n /** The CPMM fee tier the pool names. Equal to the LaunchLab program on the curve venue. */\n ammConfig: Address | null;\n /** Coins the curve still has to sell. `0n` once the coin has graduated. */\n remainingCurveBase: bigint;\n /** The ordered account list for an exact-coins-out buy, in `remainingAccounts` order. */\n buyAccounts: AccountMeta[];\n /** The ordered account list for a sale. */\n sellAccounts: AccountMeta[];\n /** WSOL an exact-coins-out buy of `tokens` costs right now, the venue's fees included. */\n quoteBuy(tokens: bigint): bigint;\n /** WSOL a sale of `tokens` returns right now, net of the venue's fees. */\n quoteSell(tokens: bigint): bigint;\n};\n\nexport type ResolveVenueOptions = {\n mint: Address;\n /** The wallet that will sign the trade. Its token accounts appear in the account list. */\n user: Address;\n /** Force a venue instead of reading the pool's `status`. A wrong choice fails on chain. */\n venue?: VenueKind;\n};\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Small readers\n// ─────────────────────────────────────────────────────────────────────────────\n\ntype MaybeAccount = { data: Uint8Array; owner: Address } | null;\n\n// Kit's codecs, not `Buffer`. This module is vendored into a Next.js app and `Buffer` is not\n// defined in the browser.\nconst base64 = getBase64Encoder();\n\nasync function readAccounts(rpc: GaboxRpc, addresses: Address[]): Promise<MaybeAccount[]> {\n const { value } = await rpc\n .getMultipleAccounts(addresses, { encoding: 'base64', commitment: 'confirmed' })\n .send();\n return value.map((account) => {\n if (!account) return null;\n const [encoded] = account.data;\n return { data: new Uint8Array(base64.encode(encoded)), owner: account.owner };\n });\n}\n\nexport { tokenAccountAmount };\n\n/**\n * The user's WSOL associated token account.\n *\n * Both venues settle in WSOL, never in native SOL. This account must exist and hold enough before a\n * pack is bought, and sale proceeds land in it. Every builder in `tx/` wraps the SOL it needs into\n * this account and closes it again in the same transaction.\n */\nexport async function wsolAccountFor(user: Address): Promise<Address> {\n return await ata(user, WSOL_MINT);\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// resolveVenue\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** What LaunchLab's global config and the Gabox platform config say about a curve trade. */\nexport type CurveSettings = {\n rates: CurveFeeRates;\n /** `migrate_fee` on the global config. The starting reserves depend on it. */\n migrateFee: bigint;\n /** `cpswap_config` on the platform config: the CPMM fee tier a Gabox coin graduates into. */\n cpswapConfig: Address;\n};\n\n/** Read the two pinned config accounts and take the four numbers a quote needs out of them. */\nexport async function fetchCurveSettings(\n client: GaboxClient,\n ids: RaydiumIds = raydiumIds(client.cluster),\n): Promise<CurveSettings> {\n const [globalAccount, platformAccount] = await readAccounts(client.rpc, [\n ids.solGlobalConfig,\n ids.gaboxPlatform,\n ]);\n if (!globalAccount) {\n throw new Error(`LaunchLab's WSOL global config is missing at ${ids.solGlobalConfig}`);\n }\n if (!platformAccount) {\n throw new Error(`the Gabox platform config is missing at ${ids.gaboxPlatform}`);\n }\n return settingsFrom(globalAccount.data, platformAccount.data);\n}\n\nfunction settingsFrom(globalData: Uint8Array, platformData: Uint8Array): CurveSettings {\n const global = decodeLaunchlabGlobalConfig(globalData);\n const platform = decodeLaunchlabPlatformConfig(platformData);\n return {\n rates: {\n tradeFeeRate: global.tradeFeeRate,\n platformFeeRate: platform.feeRate,\n creatorFeeRate: platform.creatorFeeRate,\n },\n migrateFee: global.migrateFee,\n cpswapConfig: platform.cpswapConfig,\n };\n}\n\nexport async function resolveVenue(\n client: GaboxClient,\n options: ResolveVenueOptions,\n): Promise<ResolvedVenue> {\n const ids = raydiumIds(client.cluster);\n const { mint, user } = options;\n const quoteMint = WSOL_MINT;\n\n const curvePool = await launchlabPoolAddress(ids.launchlab, mint, quoteMint);\n const [poolAccount, globalAccount, platformAccount] = await readAccounts(client.rpc, [\n curvePool,\n ids.solGlobalConfig,\n ids.gaboxPlatform,\n ]);\n\n if (!poolAccount) {\n throw new Error(\n `no LaunchLab pool at ${curvePool}. The coin was not launched on LaunchLab with WSOL as its ` +\n 'quote, so it has no Gabox venue.',\n );\n }\n if (!globalAccount) {\n throw new Error(`LaunchLab's WSOL global config is missing at ${ids.solGlobalConfig}`);\n }\n if (!platformAccount) {\n throw new Error(`the Gabox platform config is missing at ${ids.gaboxPlatform}`);\n }\n\n const pool: LaunchlabPoolState = decodeLaunchlabPool(poolAccount.data);\n if (pool.baseMint !== mint || pool.quoteMint !== quoteMint) {\n throw new Error(`the LaunchLab pool at ${curvePool} is not the pool of ${mint}`);\n }\n const settings = settingsFrom(globalAccount.data, platformAccount.data);\n\n const kind: VenueKind =\n options.venue ?? (pool.status === LAUNCHLAB_STATUS_TRADE ? 'cpmm' : 'launchlab');\n\n if (options.venue === undefined && pool.status === LAUNCHLAB_STATUS_MIGRATE) {\n throw new Error(\n `${mint} is graduating: its LaunchLab curve is sold out and Raydium is moving it into a ` +\n 'CPMM pool. Retry in a moment; the move usually finishes within a minute.',\n );\n }\n\n if (kind === 'launchlab') {\n if (pool.status !== LAUNCHLAB_STATUS_FUND) {\n throw new Error(\n `${mint} no longer trades on its LaunchLab curve (status ${pool.status}). Use the CPMM ` +\n 'venue.',\n );\n }\n return await launchlabVenue(ids, pool, settings.rates, {\n mint,\n quoteMint,\n user,\n poolState: curvePool,\n });\n }\n\n return await cpmmVenue(client, ids, pool, settings.cpswapConfig, { mint, quoteMint, user });\n}\n\nasync function launchlabVenue(\n ids: RaydiumIds,\n pool: LaunchlabPoolState,\n rates: CurveFeeRates,\n where: { mint: Address; quoteMint: Address; user: Address; poolState: Address },\n): Promise<ResolvedVenue> {\n const { mint, quoteMint, user, poolState } = where;\n const shared: LaunchlabTradeAccountsInput = {\n launchlab: ids.launchlab,\n launchlabAuthority: ids.launchlabAuthority,\n launchlabEventAuthority: ids.launchlabEventAuthority,\n globalConfig: ids.solGlobalConfig,\n platformConfig: ids.gaboxPlatform,\n poolState,\n mint,\n quoteMint,\n baseVault: await launchlabVaultAddress(ids.launchlab, poolState, mint),\n quoteVault: await launchlabVaultAddress(ids.launchlab, poolState, quoteMint),\n user,\n userBaseToken: await ata(user, mint),\n userQuoteToken: await ata(user, quoteMint),\n platformFeeVault: await platformFeeVaultAddress(ids.launchlab, ids.gaboxPlatform, quoteMint),\n creatorFeeVault: await creatorFeeVaultAddress(ids.launchlab, pool.creator, quoteMint),\n };\n const reserves: CurveReserves = {\n virtualBase: pool.virtualBase,\n virtualQuote: pool.virtualQuote,\n realBase: pool.realBase,\n realQuote: pool.realQuote,\n totalBaseSell: pool.totalBaseSell,\n };\n const remaining = remainingBase(reserves);\n\n return {\n kind: 'launchlab',\n program: ids.launchlab,\n mint,\n quoteMint,\n poolState,\n status: pool.status,\n creator: pool.creator,\n ammConfig: null,\n remainingCurveBase: remaining,\n buyAccounts: launchlabBuyAccounts(shared),\n sellAccounts: launchlabSellAccounts(shared),\n quoteBuy: (tokens) => {\n if (tokens > remaining) {\n throw new Error(\n `the curve has ${remaining} base units left and cannot sell ${tokens}. Wait for the ` +\n 'coin to graduate, then buy on its CPMM pool.',\n );\n }\n return curveBuyExactOut(reserves, rates, tokens);\n },\n quoteSell: (tokens) => curveSellExactIn(reserves, rates, tokens),\n };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// The migrated CPMM pool\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** A CPMM pool that has proved, from its own data, that it is a coin's migrated pool. */\nexport type MigratedCpmmPool = { address: Address; pool: CpmmPoolState };\n\nexport type FindCpmmPoolOptions = {\n mint: Address;\n /** The coin creator, from the Gabox pool or the LaunchLab pool. */\n creator: Address;\n /** The fee tier the Gabox platform config names. Read it with `fetchCurveSettings`. */\n cpswapConfig: Address;\n quoteMint?: Address;\n};\n\n/**\n * Every check the program makes on a CPMM pool account, in one place.\n *\n * `enable_creator_fee` is the one that identifies the migrated pool. Anyone can call CPMM's own\n * `initialize` and open a pool for the same pair with the same creator, but that pool always has\n * the flag false. Only a creator Raydium has permissioned can set it, and LaunchLab's migration is\n * one of those.\n */\nexport function cpmmPoolMatches(\n pool: CpmmPoolState,\n expect: { creator: Address; token0: Address; token1: Address },\n): boolean {\n return (\n pool.enableCreatorFee &&\n pool.poolCreator === expect.creator &&\n pool.token0Mint === expect.token0 &&\n pool.token1Mint === expect.token1\n );\n}\n\n/**\n * The CPMM pool LaunchLab migrated a coin into.\n *\n * Two steps, because the pool is not always at a derived address. Raydium migrates into\n * `[\"pool\", cpswap_config, token_0, token_1]` when that account is free, and into a random account\n * when it is not. So: try the derived address, and scan for the pool when it does not hold one.\n *\n * The scan filters on the account length and on the three fields at their fixed offsets, so the\n * RPC does the work and returns at most a handful of accounts. Every candidate still has to pass\n * `cpmmPoolMatches`, and more than one match is an error rather than a guess.\n */\nexport async function findCpmmPool(\n client: GaboxClient,\n options: FindCpmmPoolOptions,\n): Promise<MigratedCpmmPool> {\n const ids = raydiumIds(client.cluster);\n const { mint, creator, cpswapConfig } = options;\n const quoteMint = options.quoteMint ?? WSOL_MINT;\n const [token0, token1] = sortedMints(mint, quoteMint);\n const expect = { creator, token0, token1 };\n\n const derived = await cpmmPoolAddress(ids.cpmm, cpswapConfig, mint, quoteMint);\n const [account] = await readAccounts(client.rpc, [derived]);\n if (account && account.owner === ids.cpmm) {\n const pool = decodeCpmmPoolOrNull(account.data);\n if (pool && cpmmPoolMatches(pool, expect)) return { address: derived, pool };\n }\n\n const rows = await client.rpc\n .getProgramAccounts(ids.cpmm, {\n encoding: 'base64',\n commitment: 'confirmed',\n filters: [\n { dataSize: BigInt(CPMM_POOL_STATE_SIZE) },\n memcmp(CPMM_POOL_OFFSETS.poolCreator, creator),\n memcmp(CPMM_POOL_OFFSETS.token0Mint, token0),\n memcmp(CPMM_POOL_OFFSETS.token1Mint, token1),\n ],\n })\n .send();\n\n const matches: MigratedCpmmPool[] = [];\n for (const { pubkey, account: row } of rows) {\n const pool = decodeCpmmPoolOrNull(new Uint8Array(base64.encode(row.data[0])));\n if (pool && cpmmPoolMatches(pool, expect)) matches.push({ address: pubkey, pool });\n }\n\n const [only] = matches;\n if (!only) {\n throw new Error(\n `no migrated CPMM pool for ${mint}. The derived address ${derived} holds no matching pool, ` +\n 'and no other CPMM pool has this coin, this creator and a creator fee enabled.',\n );\n }\n if (matches.length > 1) {\n throw new Error(\n `${matches.length} CPMM pools match ${mint}: ${matches.map((m) => m.address).join(', ')}. ` +\n 'Pass the one you mean rather than letting this choose.',\n );\n }\n return only;\n}\n\n/** A `getProgramAccounts` byte filter. The bytes of an address are its own base58 text. */\nfunction memcmp(offset: number, value: Address) {\n return {\n memcmp: {\n offset: BigInt(offset),\n bytes: value as unknown as Base58EncodedBytes,\n encoding: 'base58' as const,\n },\n };\n}\n\n/** Decode a candidate account, or give up quietly. A scan row that is not a pool is not an error. */\nfunction decodeCpmmPoolOrNull(data: Uint8Array): CpmmPoolState | null {\n try {\n return decodeCpmmPool(data);\n } catch {\n return null;\n }\n}\n\nasync function cpmmVenue(\n client: GaboxClient,\n ids: RaydiumIds,\n curve: LaunchlabPoolState,\n cpswapConfig: Address,\n where: { mint: Address; quoteMint: Address; user: Address },\n): Promise<ResolvedVenue> {\n const { mint, quoteMint, user } = where;\n const { address: poolState, pool } = await findCpmmPool(client, {\n mint,\n quoteMint,\n creator: curve.creator,\n cpswapConfig,\n });\n\n // Every address below comes out of the pool account, exactly as `venue/trade.rs` reads them.\n // Nothing about a CPMM pool is derived: Raydium migrates into whatever address is free, and the\n // pool names its own fee tier, its own vaults and its own oracle.\n const baseIsToken0 = pool.token0Mint === mint;\n const baseVault = baseIsToken0 ? pool.token0Vault : pool.token1Vault;\n const quoteVault = baseIsToken0 ? pool.token1Vault : pool.token0Vault;\n\n const [configAccount, baseVaultAccount, quoteVaultAccount] = await readAccounts(client.rpc, [\n pool.ammConfig,\n baseVault,\n quoteVault,\n ]);\n if (!configAccount) {\n throw new Error(`the CPMM pool at ${poolState} names a fee tier that is not on chain`);\n }\n if (!baseVaultAccount || !quoteVaultAccount) {\n throw new Error(`the CPMM pool at ${poolState} has no reserve accounts`);\n }\n\n const config: CpmmAmmConfig = decodeCpmmAmmConfig(configAccount.data);\n // A swap may not spend what the pool already owes. Raydium subtracts the same three balances.\n const owedBase = baseIsToken0\n ? pool.protocolFeesToken0 + pool.fundFeesToken0 + pool.creatorFeesToken0\n : pool.protocolFeesToken1 + pool.fundFeesToken1 + pool.creatorFeesToken1;\n const owedQuote = baseIsToken0\n ? pool.protocolFeesToken1 + pool.fundFeesToken1 + pool.creatorFeesToken1\n : pool.protocolFeesToken0 + pool.fundFeesToken0 + pool.creatorFeesToken0;\n const baseReserve = tokenAccountAmount(baseVaultAccount.data) - owedBase;\n const quoteReserve = tokenAccountAmount(quoteVaultAccount.data) - owedQuote;\n if (baseReserve <= 0n || quoteReserve <= 0n) {\n throw new Error(`the CPMM pool at ${poolState} has no tradable reserves`);\n }\n\n const shared: CpmmTradeAccountsInput = {\n cpmmAuthority: ids.cpmmAuthority,\n ammConfig: pool.ammConfig,\n poolState,\n mint,\n quoteMint,\n baseVault,\n quoteVault,\n observationState: pool.observationKey,\n user,\n userBaseToken: await ata(user, mint),\n userQuoteToken: await ata(user, quoteMint),\n };\n\n const creatorFeeRate = pool.enableCreatorFee ? config.creatorFeeRate : 0n;\n const buySides: CpmmSwapSides = { inputReserve: quoteReserve, outputReserve: baseReserve };\n const sellSides: CpmmSwapSides = { inputReserve: baseReserve, outputReserve: quoteReserve };\n const buyRates: CpmmFeeRates = {\n tradeFeeRate: config.tradeFeeRate,\n creatorFeeRate,\n creatorFeeOnInput: creatorFeeOnInput(pool, quoteMint),\n };\n const sellRates: CpmmFeeRates = {\n tradeFeeRate: config.tradeFeeRate,\n creatorFeeRate,\n creatorFeeOnInput: creatorFeeOnInput(pool, mint),\n };\n\n return {\n kind: 'cpmm',\n program: ids.cpmm,\n mint,\n quoteMint,\n poolState,\n status: curve.status,\n creator: pool.poolCreator,\n ammConfig: pool.ammConfig,\n remainingCurveBase: 0n,\n buyAccounts: cpmmBuyAccounts(shared),\n sellAccounts: cpmmSellAccounts(shared),\n quoteBuy: (tokens) => cpmmSwapBaseOutput(buySides, buyRates, tokens),\n quoteSell: (tokens) => cpmmSwapBaseInput(sellSides, sellRates, tokens),\n };\n}\n\n/**\n * Does this side's creator fee come off the token going in?\n *\n * `creator_fee_on` is 0 when the fee follows the input token, 1 when it is always token 0, and 2\n * when it is always token 1. LaunchLab migrates a Gabox coin with `AmmCreatorFeeOn::QuoteToken`, so\n * the pool charges the creator fee in WSOL only: on the input of a buy, on the output of a sale.\n */\nexport function creatorFeeOnInput(pool: CpmmPoolState, inputMint: Address): boolean {\n if (pool.creatorFeeOn === 0) return true;\n const inputIsToken0 = pool.token0Mint === inputMint;\n return pool.creatorFeeOn === 1 ? inputIsToken0 : !inputIsToken0;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Price-only reads\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * WSOL an exact-coins-out buy of `tokens` costs right now, on whichever venue the coin trades.\n * Pass `pool.packTokens` for the pack price.\n *\n * Use `resolveVenue` when you also need the account list, which every transaction builder does.\n * This is for a price display.\n */\nexport async function curveQuote(\n client: GaboxClient,\n mint: Address,\n tokens: bigint,\n options: { user?: Address; venue?: VenueKind } = {},\n): Promise<bigint> {\n const venue = await resolveVenue(client, {\n mint,\n // No trade is built, so the account list is never used. Any address gives a valid one.\n user: options.user ?? mint,\n ...(options.venue ? { venue: options.venue } : {}),\n });\n return venue.quoteBuy(tokens);\n}\n\n/** WSOL a sale of `tokens` returns right now, net of the venue's fees. */\nexport async function sellQuote(\n client: GaboxClient,\n mint: Address,\n tokens: bigint,\n options: { user?: Address; venue?: VenueKind } = {},\n): Promise<bigint> {\n const venue = await resolveVenue(client, {\n mint,\n user: options.user ?? mint,\n ...(options.venue ? { venue: options.venue } : {}),\n });\n return venue.quoteSell(tokens);\n}\n\n/**\n * WSOL an exact-coins-out buy of `tokens` would cost on a curve that does not exist yet, fees\n * included.\n *\n * This is what the seed costs. `initialize_pool` buys it in the same transaction that creates the\n * coin, so the curve is a brand-new LaunchLab curve with the pinned Gabox launch shape at that\n * moment. Exact, unless Raydium changes a fee rate between this read and the send.\n */\nexport async function newCurveBuyCost(client: GaboxClient, tokens: bigint): Promise<bigint> {\n if (tokens <= 0n) return 0n;\n const ids = raydiumIds(client.cluster);\n const settings = await fetchCurveSettings(client, ids);\n return curveBuyExactOut(newCurveReserves(ids, settings.migrateFee), settings.rates, tokens);\n}\n\n/** The starting reserves of a brand-new Gabox curve on this cluster. */\nexport function newCurveReserves(ids: RaydiumIds, migrateFee: bigint): CurveReserves {\n return initialCurve({\n supply: LAUNCH_SUPPLY,\n totalBaseSell: LAUNCH_TOTAL_BASE_SELL,\n quoteRaise: ids.launchQuoteRaise,\n migrateFee,\n });\n}\n","/**\n * Assembling a transaction message.\n *\n * Every builder in this directory ends here: compute budget first, then the program instructions,\n * with a fee payer and a blockhash lifetime. The result is a message a wallet can sign and send —\n * nothing in this SDK signs or sends anything itself.\n */\n\nimport {\n appendTransactionMessageInstructions,\n compileTransaction,\n compressTransactionMessageUsingAddressLookupTables,\n createTransactionMessage,\n getTransactionEncoder,\n pipe,\n setTransactionMessageFeePayerSigner,\n setTransactionMessageLifetimeUsingBlockhash,\n type AddressesByLookupTableAddress,\n type Instruction,\n type TransactionMessage,\n type TransactionMessageWithBlockhashLifetime,\n type TransactionMessageWithFeePayerSigner,\n type TransactionSigner,\n} from '@solana/kit';\n\nimport { computeBudgetInstructions } from '../compute';\nimport type { GaboxClient } from '../rpc';\n\n/**\n * What every builder returns: a version 0 message with a fee-payer signer and a blockhash\n * lifetime, ready for `signTransactionMessageWithSigners`.\n *\n * Named, and built only from types `@solana/kit` exports, so the published declaration file\n * refers to kit's types instead of copying them. `pipe`'s inferred type is a long intersection\n * of kit-internal brands, and a copy of a branded type is not assignable to the original.\n */\nexport type GaboxTransactionMessage = Extract<TransactionMessage, { version: 0 }> &\n TransactionMessageWithFeePayerSigner &\n TransactionMessageWithBlockhashLifetime;\n\nexport type BuildOptions = {\n /** Compute units to request. Each builder passes its own default. */\n computeUnitLimit: number;\n /** Priority fee in micro-lamports per compute unit. Left out, no price instruction is added. */\n computeUnitPrice?: number | bigint;\n /** Defaults to the client's tables, which the cluster chose. Pass `{}` to disable compression. */\n addressLookupTables?: AddressesByLookupTableAddress;\n};\n\n/**\n * Build the message. One RPC read, for the blockhash.\n *\n * The blockhash expires in about a minute, so build the message when the user is ready to sign\n * rather than when the page loads.\n */\nexport async function buildMessage(\n client: GaboxClient,\n feePayer: TransactionSigner,\n instructions: Instruction[],\n options: BuildOptions,\n): Promise<GaboxTransactionMessage> {\n const { value: latestBlockhash } = await client.rpc\n .getLatestBlockhash({ commitment: 'confirmed' })\n .send();\n\n const budget = computeBudgetInstructions(\n options.computeUnitLimit,\n options.computeUnitPrice,\n ) as unknown as Instruction[];\n\n const message = pipe(\n createTransactionMessage({ version: 0 }),\n (m) => setTransactionMessageFeePayerSigner(feePayer, m),\n (m) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, m),\n (m) => appendTransactionMessageInstructions([...budget, ...instructions], m),\n (m) => compressTransactionMessageUsingAddressLookupTables(\n m,\n options.addressLookupTables ?? client.addressLookupTables,\n ),\n );\n const size = getTransactionEncoder().encode(compileTransaction(message)).length;\n if (size > 1232) {\n throw new Error(`Transaction is ${size} bytes; Solana allows 1232. Shorten metadata or supply additional address lookup tables.`);\n }\n return message;\n}\n\n/** Append `remainingAccounts` to a generated instruction, which is how a venue's list is passed. */\nexport function withRemainingAccounts<T extends Instruction>(\n instruction: T,\n remaining: readonly NonNullable<T['accounts']>[number][],\n): T {\n return {\n ...instruction,\n accounts: [...(instruction.accounts ?? []), ...remaining],\n };\n}\n","/**\n * LaunchLab's `initialize_v2`, built by hand.\n *\n * Put it **before** `initialize_pool` in the transaction. `venue/launch.rs` reads the Instructions\n * sysvar and looks for this instruction by discriminator, then checks all 18 of its accounts and\n * every one of its arguments. The order matters for a second reason too: the mint account has to\n * exist and deserialize before Anchor validates the Gabox accounts.\n *\n * # The launch shape is pinned\n *\n * A creator picks the name, the symbol and the metadata URI. Nothing else. Every other argument is\n * fixed, and the program refuses any other value:\n *\n * | Argument | Value |\n * | --- | --- |\n * | `decimals` | 6 |\n * | curve | `Constant` |\n * | `supply` | 1,000,000,000 coins |\n * | `total_base_sell` | 793,100,000 coins |\n * | `total_quote_fund_raising` | 85 SOL on mainnet, 3 SOL on devnet |\n * | `migrate_type` | 1, which means graduate into a CPMM pool |\n * | `VestingParams` | all three fields 0 |\n * | `AmmCreatorFeeOn` | `QuoteToken` |\n *\n * The instruction data must end exactly after the last argument. Trailing bytes are refused.\n *\n * # The argument layout\n *\n * Borsh, in IDL order: `MintParams { decimals, name, symbol, uri }`, then the `CurveParams` enum\n * tag and its `ConstantCurve` fields, then `VestingParams`, then the `AmmCreatorFeeOn` enum tag.\n * An Anchor enum tag is one byte.\n */\n\nimport {\n addEncoderSizePrefix,\n getStructEncoder,\n getU8Encoder,\n getU32Encoder,\n getU64Encoder,\n getUtf8Encoder,\n type Address,\n type Instruction,\n type TransactionSigner,\n} from '@solana/kit';\n\nimport {\n LAUNCHLAB_INITIALIZE,\n LAUNCH_SUPPLY,\n LAUNCH_TOTAL_BASE_SELL,\n METAPLEX_PROGRAM_ADDRESS,\n RENT_SYSVAR_ADDRESS,\n SYSTEM_PROGRAM_ADDRESS,\n TOKEN_PROGRAM_ADDRESS,\n} from './abi';\nimport { order } from './accounts';\nimport {\n CONSTANT_CURVE_TAG,\n CREATOR_FEE_ON_QUOTE,\n LAUNCH_DECIMALS,\n METADATA_LIMITS,\n MIGRATE_TO_CPMM,\n WSOL_MINT,\n type RaydiumIds,\n} from './ids';\nimport { launchlabPoolAddress, launchlabVaultAddress, metadataAddress } from './pdas';\n\nconst borshString = () => addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder());\n\nconst ARGS_ENCODER = getStructEncoder([\n // MintParams\n ['decimals', getU8Encoder()],\n ['name', borshString()],\n ['symbol', borshString()],\n ['uri', borshString()],\n // CurveParams::Constant(ConstantCurve { … })\n ['curveTag', getU8Encoder()],\n ['supply', getU64Encoder()],\n ['totalBaseSell', getU64Encoder()],\n ['totalQuoteFundRaising', getU64Encoder()],\n ['migrateType', getU8Encoder()],\n // VestingParams. Gabox coins have no vesting, so all three are zero.\n ['totalLockedAmount', getU64Encoder()],\n ['cliffPeriod', getU64Encoder()],\n ['unlockPeriod', getU64Encoder()],\n // AmmCreatorFeeOn\n ['ammFeeOn', getU8Encoder()],\n]);\n\nexport type LaunchInput = {\n /** The coin's mint. A fresh keypair, and it signs. */\n mint: TransactionSigner;\n /**\n * The wallet paying. LaunchLab takes it as both `payer` and `creator`, so this wallet receives\n * LaunchLab's creator fee and owns the CPMM creator fee after graduation. It must be the same\n * wallet that signs `initialize_pool`.\n */\n creator: TransactionSigner;\n name: string;\n symbol: string;\n /** The metadata URI. Metaplex stores it on the mint's metadata account. */\n uri: string;\n};\n\n/** Metaplex refuses a longer string, so refuse it here rather than on chain. */\nfunction bounded(value: string, limit: number, what: string): string {\n const bytes = new TextEncoder().encode(value).length;\n if (bytes === 0) throw new Error(`${what} must not be empty`);\n if (bytes > limit) {\n throw new Error(`${what} is ${bytes} UTF-8 bytes; Metaplex allows at most ${limit}`);\n }\n return value;\n}\n\n/**\n * Build `initialize_v2` for one cluster's LaunchLab. `ids` is `raydiumIds(client.cluster)`.\n *\n * Two slots sign: the mint keypair, which LaunchLab takes as a signer rather than deriving, and the\n * creator, who pays for everything.\n */\nexport async function getLaunchInstruction(\n input: LaunchInput,\n ids: RaydiumIds,\n): Promise<Instruction> {\n const { mint, creator } = input;\n const name = bounded(input.name, METADATA_LIMITS.name, 'name');\n const symbol = bounded(input.symbol, METADATA_LIMITS.symbol, 'symbol');\n const uri = bounded(input.uri, METADATA_LIMITS.uri, 'uri');\n\n const quoteMint = WSOL_MINT;\n const poolState = await launchlabPoolAddress(ids.launchlab, mint.address, quoteMint);\n\n const metas = order(LAUNCHLAB_INITIALIZE, {\n payer: creator.address,\n creator: creator.address,\n global_config: ids.solGlobalConfig,\n platform_config: ids.gaboxPlatform,\n authority: ids.launchlabAuthority,\n pool_state: poolState,\n base_mint: mint.address,\n quote_mint: quoteMint,\n base_vault: await launchlabVaultAddress(ids.launchlab, poolState, mint.address),\n quote_vault: await launchlabVaultAddress(ids.launchlab, poolState, quoteMint),\n metadata_account: await metadataAddress(mint.address),\n base_token_program: TOKEN_PROGRAM_ADDRESS,\n quote_token_program: TOKEN_PROGRAM_ADDRESS,\n metadata_program: METAPLEX_PROGRAM_ADDRESS,\n system_program: SYSTEM_PROGRAM_ADDRESS,\n rent_program: RENT_SYSVAR_ADDRESS,\n event_authority: ids.launchlabEventAuthority,\n program: ids.launchlab,\n });\n\n // `accounts.ts` set the roles from the ABI. This only attaches each signer to the slot that\n // already says signer, so a signer can never widen a slot's privileges.\n const signerFor = new Map<Address, TransactionSigner>([\n [mint.address, mint],\n [creator.address, creator],\n ]);\n const accounts = metas.map((meta) => {\n // Roles 2 and 3 are READONLY_SIGNER and WRITABLE_SIGNER.\n const signs = meta.role === 2 || meta.role === 3;\n const signer = signerFor.get(meta.address);\n return signs && signer ? { ...meta, signer } : meta;\n });\n\n const data = new Uint8Array([\n ...LAUNCHLAB_INITIALIZE.discriminator,\n ...ARGS_ENCODER.encode({\n decimals: LAUNCH_DECIMALS,\n name,\n symbol,\n uri,\n curveTag: CONSTANT_CURVE_TAG,\n supply: LAUNCH_SUPPLY,\n totalBaseSell: LAUNCH_TOTAL_BASE_SELL,\n totalQuoteFundRaising: ids.launchQuoteRaise,\n migrateType: MIGRATE_TO_CPMM,\n totalLockedAmount: 0n,\n cliffPeriod: 0n,\n unlockPeriod: 0n,\n ammFeeOn: CREATOR_FEE_ON_QUOTE,\n }),\n ]);\n\n return { programAddress: ids.launchlab, accounts, data } as Instruction;\n}\n","/**\n * Collecting the creator's share of trading.\n *\n * Gabox charges no fee at all. The creator's income is the share Raydium pays out of its own\n * revenue, and it sits in two different places depending on where the coin trades:\n *\n * - **On the curve.** LaunchLab pays 0.5% of every trade into `[creator, WSOL]` under LaunchLab.\n * One vault per wallet, not one per coin, so a single `claim_creator_fee` sweeps every coin\n * that creator launched.\n * - **After graduation.** The CPMM pool keeps the creator's fee inside the pool account, and\n * `collect_creator_fee` pays it out. That is per pool, so it takes one call per coin.\n *\n * Both instructions pay into the creator's WSOL associated token account. Every builder here closes\n * that account afterwards, so the creator ends up with plain SOL in their wallet.\n *\n * **Closing unwraps everything.** If the creator already held WSOL in that account before the\n * claim, closing turns that into SOL too. Nothing is lost, but the balance moves.\n */\n\nimport {\n getCloseAccountInstruction,\n getCreateAssociatedTokenIdempotentInstruction,\n} from '@solana-program/token';\nimport {\n AccountRole,\n getBase64Encoder,\n type AccountMeta,\n type Address,\n type Instruction,\n type TransactionSigner,\n} from '@solana/kit';\n\nimport { CLAIM_COMPUTE_UNITS } from '../compute';\nimport type { GaboxClient } from '../rpc';\nimport { buildMessage, type BuildOptions, type GaboxTransactionMessage } from '../tx/message';\nimport {\n ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\n CPMM_COLLECT_CREATOR_FEE,\n LAUNCHLAB_CLAIM_CREATOR_FEE,\n SYSTEM_PROGRAM_ADDRESS,\n TOKEN_PROGRAM_ADDRESS,\n} from './abi';\nimport { order } from './accounts';\nimport { tokenAccountAmount } from './adapter';\nimport { WSOL_MINT, raydiumIds, sortedMints, type RaydiumIds } from './ids';\nimport {\n ata,\n cpmmCreatorFeeShare,\n creatorFeeVaultAddress,\n creatorFeeVaultAuthority,\n} from './pdas';\nimport { fetchCurveSettings, findCpmmPool } from './venue';\n\nconst base64 = getBase64Encoder();\n\n/**\n * Create the creator's WSOL account, if it is missing, and close it again at the end.\n *\n * Raydium's own instructions create the account when they need to, but an idempotent create here\n * costs nothing and makes the flow the same whichever instruction runs. The close is what turns the\n * WSOL into SOL.\n */\nasync function wrapAround(\n creator: TransactionSigner,\n middle: Instruction[],\n): Promise<Instruction[]> {\n const account = await ata(creator.address, WSOL_MINT);\n return [\n getCreateAssociatedTokenIdempotentInstruction({\n payer: creator,\n ata: account,\n owner: creator.address,\n mint: WSOL_MINT,\n tokenProgram: TOKEN_PROGRAM_ADDRESS,\n }) as Instruction,\n ...middle,\n getCloseAccountInstruction({\n account,\n destination: creator.address,\n owner: creator,\n }) as Instruction,\n ];\n}\n\n/** Attach a signer to the one slot the ABI marks as signing. Roles never change here. */\nfunction withSigner(accounts: AccountMeta[], signer: TransactionSigner): AccountMeta[] {\n return accounts.map((meta) =>\n (meta.role === AccountRole.READONLY_SIGNER || meta.role === AccountRole.WRITABLE_SIGNER) &&\n meta.address === signer.address\n ? { ...meta, signer }\n : meta,\n );\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// LaunchLab\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * The instructions of a curve fee claim: create the WSOL account, claim, close it.\n *\n * This sweeps **every** coin this wallet launched, because LaunchLab keeps one vault per wallet per\n * quote asset. There is no per-coin version.\n */\nexport async function getClaimCreatorFeeInstructions(\n creator: TransactionSigner,\n ids: RaydiumIds,\n): Promise<Instruction[]> {\n const quoteMint = WSOL_MINT;\n const claim = {\n programAddress: ids.launchlab,\n accounts: withSigner(\n order(LAUNCHLAB_CLAIM_CREATOR_FEE, {\n creator: creator.address,\n fee_vault_authority: await creatorFeeVaultAuthority(ids.launchlab),\n creator_fee_vault: await creatorFeeVaultAddress(ids.launchlab, creator.address, quoteMint),\n recipient_token_account: await ata(creator.address, quoteMint),\n quote_mint: quoteMint,\n token_program: TOKEN_PROGRAM_ADDRESS,\n system_program: SYSTEM_PROGRAM_ADDRESS,\n associated_token_program: ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\n }),\n creator,\n ),\n // `claim_creator_fee` takes no arguments.\n data: new Uint8Array(LAUNCHLAB_CLAIM_CREATOR_FEE.discriminator),\n } as Instruction;\n return await wrapAround(creator, [claim]);\n}\n\nexport type ClaimCreatorFeeInput = { creator: TransactionSigner } & Partial<BuildOptions>;\n\n/**\n * Claim the curve creator fee and receive it as SOL.\n *\n * One transaction, three instructions. It sweeps every coin this wallet launched on LaunchLab.\n */\nexport async function claimCreatorFee(\n client: GaboxClient,\n input: ClaimCreatorFeeInput,\n): Promise<GaboxTransactionMessage> {\n const ids = raydiumIds(client.cluster);\n const instructions = await getClaimCreatorFeeInstructions(input.creator, ids);\n return await buildMessage(client, input.creator, instructions, {\n addressLookupTables: input.addressLookupTables,\n computeUnitLimit: input.computeUnitLimit ?? CLAIM_COMPUTE_UNITS,\n ...(input.computeUnitPrice === undefined ? {} : { computeUnitPrice: input.computeUnitPrice }),\n });\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// CPMM\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * The instructions of a graduated coin's fee collection: create the WSOL account, collect, close.\n *\n * This is per coin. `collect_creator_fee` pays out both sides of the pair, so anything owed in the\n * coin itself lands in the creator's coin account and stays there.\n */\nexport async function getCollectCreatorFeeInstructions(\n client: GaboxClient,\n input: { mint: Address; creator: TransactionSigner },\n ids: RaydiumIds = raydiumIds(client.cluster),\n): Promise<Instruction[]> {\n const { mint, creator } = input;\n const quoteMint = WSOL_MINT;\n const settings = await fetchCurveSettings(client, ids);\n const { address: poolState, pool } = await findCpmmPool(client, {\n mint,\n quoteMint,\n creator: creator.address,\n cpswapConfig: settings.cpswapConfig,\n });\n\n const collect = {\n programAddress: ids.cpmm,\n accounts: withSigner(\n order(CPMM_COLLECT_CREATOR_FEE, {\n creator: creator.address,\n authority: ids.cpmmAuthority,\n pool_state: poolState,\n // The fee tier the pool itself names, never a compiled-in address.\n amm_config: pool.ammConfig,\n // The pool names its own vaults; nothing here is derived.\n token_0_vault: pool.token0Vault,\n token_1_vault: pool.token1Vault,\n vault_0_mint: pool.token0Mint,\n vault_1_mint: pool.token1Mint,\n creator_token_0: await ata(creator.address, pool.token0Mint, pool.token0Program),\n creator_token_1: await ata(creator.address, pool.token1Mint, pool.token1Program),\n token_0_program: pool.token0Program,\n token_1_program: pool.token1Program,\n associated_token_program: ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\n system_program: SYSTEM_PROGRAM_ADDRESS,\n // Keyed by the fee tier the pool names, so it follows the pool, not a compiled-in config.\n creator_fee_share: await cpmmCreatorFeeShare(ids.cpmm, creator.address, pool.ammConfig),\n }),\n creator,\n ),\n // `collect_creator_fee` takes no arguments.\n data: new Uint8Array(CPMM_COLLECT_CREATOR_FEE.discriminator),\n } as Instruction;\n return await wrapAround(creator, [collect]);\n}\n\nexport type CollectCreatorFeeInput = {\n mint: Address;\n creator: TransactionSigner;\n} & Partial<BuildOptions>;\n\n/** Collect one graduated coin's CPMM creator fee and receive the WSOL side as SOL. */\nexport async function collectCreatorFee(\n client: GaboxClient,\n input: CollectCreatorFeeInput,\n): Promise<GaboxTransactionMessage> {\n const instructions = await getCollectCreatorFeeInstructions(client, {\n mint: input.mint,\n creator: input.creator,\n });\n return await buildMessage(client, input.creator, instructions, {\n addressLookupTables: input.addressLookupTables,\n computeUnitLimit: input.computeUnitLimit ?? CLAIM_COMPUTE_UNITS,\n ...(input.computeUnitPrice === undefined ? {} : { computeUnitPrice: input.computeUnitPrice }),\n });\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Reads\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** What a creator can collect right now. Every amount is in base units. */\nexport type CreatorFees = {\n /** WSOL waiting in the LaunchLab creator fee vault, across every coin this wallet launched. */\n curveLamports: bigint;\n /**\n * WSOL the migrated CPMM pool of `mint` owes this creator. `0n` when the coin has not graduated,\n * and `0n` when no `mint` was passed.\n */\n cpmmLamports: bigint;\n /** Coins the same pool owes this creator. CPMM can charge the fee on either side. */\n cpmmTokens: bigint;\n};\n\n/**\n * Read both places a creator's fees can sit.\n *\n * `mint` is optional. Without it only the curve vault is read, which is the one number that covers\n * every coin at once. With it the coin's CPMM pool is read too, and a coin that has not graduated\n * reports zeros rather than failing.\n */\nexport async function fetchCreatorFees(\n client: GaboxClient,\n input: { creator: Address; mint?: Address },\n): Promise<CreatorFees> {\n const ids = raydiumIds(client.cluster);\n const quoteMint = WSOL_MINT;\n const vault = await creatorFeeVaultAddress(ids.launchlab, input.creator, quoteMint);\n const { value } = await client.rpc\n .getAccountInfo(vault, { encoding: 'base64', commitment: 'confirmed' })\n .send();\n const curveLamports = value ? tokenAccountAmount(new Uint8Array(base64.encode(value.data[0]))) : 0n;\n\n if (!input.mint) return { curveLamports, cpmmLamports: 0n, cpmmTokens: 0n };\n\n const settings = await fetchCurveSettings(client, ids);\n try {\n const { pool } = await findCpmmPool(client, {\n mint: input.mint,\n quoteMint,\n creator: input.creator,\n cpswapConfig: settings.cpswapConfig,\n });\n const [token0] = sortedMints(input.mint, quoteMint);\n const baseIsToken0 = token0 === input.mint;\n return {\n curveLamports,\n cpmmLamports: baseIsToken0 ? pool.creatorFeesToken1 : pool.creatorFeesToken0,\n cpmmTokens: baseIsToken0 ? pool.creatorFeesToken0 : pool.creatorFeesToken1,\n };\n } catch {\n // The coin has not graduated, so no CPMM pool owes anything yet.\n return { curveLamports, cpmmLamports: 0n, cpmmTokens: 0n };\n }\n}\n","/**\n * A venue trade a wallet sends on its own, outside any Gabox instruction.\n *\n * Pack buys and token sales go through `buy_pack` and `sell_tokens`: they take the venue's account\n * list as `remainingAccounts` and the Gabox program does the call. This file is for the one trade\n * Gabox never makes, a plain `buy_exact_in` on the curve. Anyone may trade a Gabox coin directly,\n * and the devnet end-to-end test uses this to buy the rest of the curve and force graduation.\n *\n * The account list and the discriminator both come from `abi.ts`, which codegen took from\n * Raydium's IDL. Nothing here retypes either.\n */\n\nimport {\n getU64Encoder,\n type AccountMeta,\n type Address,\n type Instruction,\n type TransactionSigner,\n} from '@solana/kit';\n\nimport { LAUNCHLAB_BUY_EXACT_IN } from './abi';\nimport { launchlabBuyExactInAccounts } from './accounts';\nimport { SHARE_FEE_RATE, WSOL_MINT, raydiumIds, type RaydiumIds } from './ids';\nimport {\n ata,\n creatorFeeVaultAddress,\n launchlabPoolAddress,\n launchlabVaultAddress,\n platformFeeVaultAddress,\n} from './pdas';\nimport type { GaboxClient } from '../rpc';\n\nconst u64 = getU64Encoder();\n\nexport type CurveBuyExactInInput = {\n mint: Address;\n /** The coin creator, so the creator fee vault can be derived. Read it off the pool. */\n creator: Address;\n /** The wallet spending. It signs, and its WSOL ATA must already hold `quoteIn`. */\n user: TransactionSigner;\n /** WSOL to spend, fees included. */\n quoteIn: bigint;\n /** The floor on the coins received. Use `curveBuyExactIn` from `curve.ts` to compute it. */\n minTokensOut: bigint;\n};\n\n/**\n * `buy_exact_in` on the curve: spend exactly `quoteIn` WSOL and take whatever coins it buys.\n *\n * LaunchLab caps the trade at what the curve has left to sell, so a spend larger than the rest of\n * the raise still succeeds and graduates the coin. Wrap the SOL into the user's WSOL ATA first and\n * close it afterwards, the same way the Gabox builders do.\n */\nexport async function getCurveBuyExactInInstruction(\n client: GaboxClient,\n input: CurveBuyExactInInput,\n ids: RaydiumIds = raydiumIds(client.cluster),\n): Promise<Instruction> {\n if (input.quoteIn <= 0n) throw new Error('quoteIn must be positive');\n if (input.minTokensOut < 0n) throw new Error('minTokensOut must not be negative');\n\n const quoteMint = WSOL_MINT;\n const poolState = await launchlabPoolAddress(ids.launchlab, input.mint, quoteMint);\n const accounts = launchlabBuyExactInAccounts({\n launchlab: ids.launchlab,\n launchlabAuthority: ids.launchlabAuthority,\n launchlabEventAuthority: ids.launchlabEventAuthority,\n globalConfig: ids.solGlobalConfig,\n platformConfig: ids.gaboxPlatform,\n poolState,\n mint: input.mint,\n quoteMint,\n baseVault: await launchlabVaultAddress(ids.launchlab, poolState, input.mint),\n quoteVault: await launchlabVaultAddress(ids.launchlab, poolState, quoteMint),\n user: input.user.address,\n userBaseToken: await ata(input.user.address, input.mint),\n userQuoteToken: await ata(input.user.address, quoteMint),\n platformFeeVault: await platformFeeVaultAddress(ids.launchlab, ids.gaboxPlatform, quoteMint),\n creatorFeeVault: await creatorFeeVaultAddress(ids.launchlab, input.creator, quoteMint),\n });\n\n return {\n programAddress: ids.launchlab,\n accounts: attachSigner(accounts, input.user),\n data: new Uint8Array([\n ...LAUNCHLAB_BUY_EXACT_IN.discriminator,\n ...u64.encode(input.quoteIn),\n ...u64.encode(input.minTokensOut),\n // Gabox never passes a share-fee receiver, so this rate is always zero.\n ...u64.encode(SHARE_FEE_RATE),\n ]),\n } as Instruction;\n}\n\n/** Give the signer to the slot the ABI already marks as signing. Roles never change here. */\nfunction attachSigner(accounts: readonly AccountMeta[], signer: TransactionSigner): AccountMeta[] {\n let matched = false;\n const withSigner = accounts.map((meta) => {\n // Roles 2 and 3 are READONLY_SIGNER and WRITABLE_SIGNER.\n const signs = meta.role === 2 || meta.role === 3;\n if (!signs || meta.address !== signer.address) return meta;\n matched = true;\n return { ...meta, signer };\n });\n if (!matched) {\n throw new Error(\n `${signer.address} is not the signing account of this trade. Build the account list with ` +\n 'the same wallet you are going to sign with.',\n );\n }\n return withSigner as AccountMeta[];\n}\n","/**\n * Everything about the two venues.\n *\n * `abi.ts` is generated: it carries the Raydium addresses of both clusters and the account table of\n * every Raydium instruction this SDK builds. `ids.ts` names those tables per cluster and holds the\n * pinned launch shape. `pdas.ts` derives every Raydium address. `adapter.ts` decodes Raydium's\n * accounts. `curve.ts` is the price math, ported from Raydium's own code. `accounts.ts` builds the\n * ordered trade account lists. `venue.ts` reads the chain and decides which venue a coin trades on.\n * `launch.ts` builds LaunchLab's `initialize_v2`. `claim.ts` collects the creator's fees.\n * `trade.ts` builds the one venue trade Gabox never makes itself.\n */\n\nexport * from './abi';\nexport * from './accounts';\nexport * from './adapter';\nexport * from './claim';\nexport * from './curve';\nexport * from './ids';\nexport * from './launch';\nexport * from './pdas';\nexport * from './trade';\nexport * from './venue';\n"],"mappings":";;;;AA4DA,MAAa,sBAAyC;CACpD,WAAW;CACX,oBAAoB;CACpB,yBAAyB;CACzB,iBAAiB;CACjB,eAAe;CACf,MAAM;CACN,eAAe;CACf,kBAAkB;AACpB;AAEA,MAAa,qBAAwC;CACnD,WAAW;CACX,oBAAoB;CACpB,yBAAyB;CACzB,iBAAiB;CACjB,eAAe;CACf,MAAM;CACN,eAAe;CACf,kBAAkB;AACpB;;AAGA,MAAa,YAAY;;AAEzB,MAAa,2BAA2B;;;;;AAKxC,MAAa,iBAAiB;;AAG9B,MAAa,gBAAgB;;AAE7B,MAAa,yBAAyB;;AAGtC,MAAa,wBAAwB;AACrC,MAAa,mCAAmC;AAChD,MAAa,yBAAyB;;AAEtC,MAAa,sBAAsB;;;;;;;;;AAUnC,MAAa,qCAAqC,IAAI,WAAW;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;AAAE,CAAC;AACxG,MAAa,wCAAwC,IAAI,WAAW;CAAC;CAAK;CAAG;CAAK;CAAK;CAAK;CAAK;CAAK;AAAG,CAAC;AAC1G,MAAa,0CAA0C,IAAI,WAAW;CAAC;CAAK;CAAI;CAAK;CAAG;CAAK;CAAI;CAAK;AAAG,CAAC;AAC1G,MAAa,gCAAgC,IAAI,WAAW;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;AAAE,CAAC;AACnG,MAAa,gCAAgC,IAAI,WAAW;CAAC;CAAK;CAAK;CAAI;CAAK;CAAK;CAAK;CAAI;AAAG,CAAC;;;;AAIlG,MAAa,uBAA4C;CACvD,MAAM;CACN,eAAe,IAAI,W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AC3F,iBAAiB,MAAM,uBAAuB,IAAI,WAAW,MAAM,SAAS,SAAS;CACvF,CAAC;CAED,OAAO;EACL,gBAAgB,IAAI;EACpB,UAAU,aAAa,UAAU,MAAM,IAAI;EAC3C,MAAM,IAAI,WAAW;GACnB,GAAG,uBAAuB;GAC1B,GAAG,IAAI,OAAO,MAAM,OAAO;GAC3B,GAAG,IAAI,OAAO,MAAM,YAAY;GAEhC,GAAG,IAAI,OAAO,cAAc;EAC9B,CAAC;CACH;AACF;;AAGA,SAAS,aAAa,UAAkC,QAA0C;CAChG,IAAI,UAAU;CACd,MAAM,aAAa,SAAS,KAAK,SAAS;EAGxC,IAAI,EADU,KAAK,SAAS,KAAK,KAAK,SAAS,MACjC,KAAK,YAAY,OAAO,SAAS,OAAO;EACtD,UAAU;EACV,OAAO;GAAE,GAAG;GAAM;EAAO;CAC3B,CAAC;CACD,IAAI,CAAC,SACH,MAAM,IAAI,MACR,GAAG,OAAO,QAAQ,mHAEpB;CAEF,OAAO;AACT"}
|
package/llms.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @gabox-labs/sdk
|
|
2
2
|
|
|
3
|
-
> The TypeScript SDK for gabox machines on Solana: prize pools tied to new
|
|
4
|
-
> Built on @solana/kit 7. ESM only, Node 24+. Devnet
|
|
3
|
+
> The TypeScript SDK for gabox machines on Solana: prize pools tied to new Raydium LaunchLab coins,
|
|
4
|
+
> which graduate into Raydium CPMM pools. Built on @solana/kit 7. ESM only, Node 24+. Devnet today.
|
|
5
5
|
|
|
6
6
|
## Start here
|
|
7
7
|
|
|
@@ -20,3 +20,5 @@
|
|
|
20
20
|
- `createClient({ cluster: 'devnet' })` once; pass it to every function.
|
|
21
21
|
- Builders return a kit transaction message. You sign and send.
|
|
22
22
|
- All amounts are bigint. Tokens have 6 decimals. A pack is 1,000,000 tokens.
|
|
23
|
+
- Gabox charges no fee. Every price already includes Raydium's own fees.
|
|
24
|
+
- Both venues settle in wrapped SOL; every builder wraps and unwraps it for you.
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gabox-labs/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "The Solana Kit SDK for gabox
|
|
5
|
+
"description": "The Solana Kit SDK for gabox: generated instruction builders, PDAs, Raydium LaunchLab and CPMM venue accounts, and the pack flow.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
"solana",
|
|
17
17
|
"solana-kit",
|
|
18
18
|
"gabox",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"raydium",
|
|
20
|
+
"launchlab",
|
|
21
|
+
"cpmm",
|
|
21
22
|
"anchor"
|
|
22
23
|
],
|
|
23
24
|
"engines": {
|
|
@@ -40,10 +41,10 @@
|
|
|
40
41
|
"import": "./dist/generated/index.js",
|
|
41
42
|
"default": "./dist/generated/index.js"
|
|
42
43
|
},
|
|
43
|
-
"./
|
|
44
|
-
"types": "./dist/
|
|
45
|
-
"import": "./dist/
|
|
46
|
-
"default": "./dist/
|
|
44
|
+
"./raydium": {
|
|
45
|
+
"types": "./dist/raydium/index.d.ts",
|
|
46
|
+
"import": "./dist/raydium/index.js",
|
|
47
|
+
"default": "./dist/raydium/index.js"
|
|
47
48
|
},
|
|
48
49
|
"./package.json": "./package.json"
|
|
49
50
|
},
|
|
@@ -68,15 +69,9 @@
|
|
|
68
69
|
"prepublishOnly": "npm run typecheck && npm test && npm run check:surface && npm run build && npm run check:package"
|
|
69
70
|
},
|
|
70
71
|
"dependencies": {
|
|
71
|
-
"@pump-fun/pump-sdk": "1.36.0",
|
|
72
|
-
"@pump-fun/pump-swap-sdk": "1.19.0",
|
|
73
72
|
"@solana-program/system": "^0.13.0",
|
|
74
73
|
"@solana-program/token": "^0.15.0",
|
|
75
|
-
"@solana/program-client-core": "^7.0.0"
|
|
76
|
-
"@solana/spl-token": "^0.4.15",
|
|
77
|
-
"@solana/web3.js": "^1.99.0",
|
|
78
|
-
"bn.js": "^5.2.5",
|
|
79
|
-
"buffer": "^6.0.3"
|
|
74
|
+
"@solana/program-client-core": "^7.0.0"
|
|
80
75
|
},
|
|
81
76
|
"peerDependencies": {
|
|
82
77
|
"@solana/kit": "^7.0.0"
|
|
@@ -86,7 +81,7 @@
|
|
|
86
81
|
"@codama/nodes-from-anchor": "^1.5.3",
|
|
87
82
|
"@codama/renderers-js": "^2.3.1",
|
|
88
83
|
"@solana/kit": "^7.0.0",
|
|
89
|
-
"@
|
|
84
|
+
"@solana/web3.js": "^1.99.0",
|
|
90
85
|
"@types/node": "^24.3.0",
|
|
91
86
|
"codama": "^1.10.0",
|
|
92
87
|
"publint": "0.3.24",
|