@gabox-labs/sdk 0.1.1 → 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 +249 -1
- package/README.md +116 -458
- 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 +211 -472
- package/dist/index.js +539 -1093
- 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 -141
- package/skills/gabox-sdk/references/api.md +102 -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
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pump-D0K_0uiC.js","names":["AMM_GLOBAL_VOLUME_ACCUMULATOR_PDA","ammUserVolumeAccumulatorPda","u64"],"sources":["../src/pump/abi.ts","../src/ids.ts","../src/pump/adapter.ts","../src/pump/accounts.ts","../src/pump/venue.ts","../src/pump/create.ts","../src/pump/trade.ts","../src/pump/index.ts"],"sourcesContent":["// GENERATED by scripts/codegen.mjs. Do not edit.\n//\n// The account order and the `writable`/`signer` flags of every Pump and PumpSwap instruction this\n// SDK builds. `market.rs` checks the list `buy_pack` forwards position by position, so this table\n// and the program's own `market_abi.rs` must describe the same thing.\n//\n// Sources:\n// - @pump-fun/pump-sdk@1.36.0 src/idl/pump.json\n// - @pump-fun/pump-swap-sdk@1.19.0 src/idl/pump_amm.json\n//\n// Every trade instruction below was cross-checked against ../../interfaces.json at generation\n// time, index by index. `test/venue-accounts.test.ts` checks the same thing on every test run.\n\nimport type { Address } from '@solana/kit';\n\n/**\n * Program addresses, taken from the two IDLs rather than typed here. `fee_program` and\n * `mayhem_program_id` are `address` constraints on accounts, so the IDL states them exactly.\n */\nexport const PUMP_PROGRAM_ADDRESS = '6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P' as Address;\nexport const PUMP_SWAP_PROGRAM_ADDRESS = 'pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA' as Address;\nexport const PUMP_FEE_PROGRAM_ADDRESS = 'pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ' as Address;\nexport const MAYHEM_PROGRAM_ADDRESS = 'MAyhSmzXzV1pTf7LsNkrNwkWKTo4ougAJ1PPg47MD4e' as Address;\n/** Pump `create_v2` always mints Token-2022. The IDL pins the program on the account. */\nexport const PUMP_CREATE_TOKEN_PROGRAM_ADDRESS = 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb' as Address;\nexport const ASSOCIATED_TOKEN_PROGRAM_ADDRESS = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address;\nexport const SYSTEM_PROGRAM_ADDRESS = '11111111111111111111111111111111' as Address;\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/** `create_v2` on `6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P` — not in interfaces.json (create only, the program reads two slots of it). */\nexport const PUMP_CREATE_V2: VenueInstructionAbi = {\n name: 'create_v2',\n discriminator: new Uint8Array([214, 144, 76, 236, 95, 139, 49, 180]),\n accounts: [\n { name: 'mint', writable: true, signer: true },\n { name: 'mint_authority', writable: false, signer: false },\n { name: 'bonding_curve', writable: true, signer: false },\n { name: 'associated_bonding_curve', writable: true, signer: false },\n { name: 'global', writable: false, signer: false },\n { name: 'user', writable: true, signer: true },\n { name: 'system_program', writable: false, signer: false },\n { name: 'token_program', writable: false, signer: false },\n { name: 'associated_token_program', writable: false, signer: false },\n { name: 'mayhem_program_id', writable: true, signer: false },\n { name: 'global_params', writable: false, signer: false },\n { name: 'sol_vault', writable: true, signer: false },\n { name: 'mayhem_state', writable: true, signer: false },\n { name: 'mayhem_token_vault', writable: true, signer: false },\n { name: 'event_authority', writable: false, signer: false },\n { name: 'program', writable: false, signer: false },\n ],\n};\n\n/** `buy_v2` on `6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P` — cross-checked against interfaces.json. */\nexport const PUMP_BUY: VenueInstructionAbi = {\n name: 'buy_v2',\n discriminator: new Uint8Array([184, 23, 238, 97, 103, 197, 211, 61]),\n accounts: [\n { name: 'global', writable: false, signer: false },\n { name: 'base_mint', writable: false, signer: false },\n { name: 'quote_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: 'associated_token_program', writable: false, signer: false },\n { name: 'fee_recipient', writable: true, signer: false },\n { name: 'associated_quote_fee_recipient', writable: true, signer: false },\n { name: 'buyback_fee_recipient', writable: true, signer: false },\n { name: 'associated_quote_buyback_fee_recipient', writable: true, signer: false },\n { name: 'bonding_curve', writable: true, signer: false },\n { name: 'associated_base_bonding_curve', writable: true, signer: false },\n { name: 'associated_quote_bonding_curve', writable: true, signer: false },\n { name: 'user', writable: true, signer: true },\n { name: 'associated_base_user', writable: true, signer: false },\n { name: 'associated_quote_user', writable: true, signer: false },\n { name: 'creator_vault', writable: true, signer: false },\n { name: 'associated_creator_vault', writable: true, signer: false },\n { name: 'sharing_config', writable: false, signer: false },\n { name: 'global_volume_accumulator', writable: false, signer: false },\n { name: 'user_volume_accumulator', writable: true, signer: false },\n { name: 'associated_user_volume_accumulator', writable: true, signer: false },\n { name: 'fee_config', writable: false, signer: false },\n { name: 'fee_program', writable: false, signer: false },\n { name: 'system_program', writable: false, signer: false },\n { name: 'event_authority', writable: false, signer: false },\n { name: 'program', writable: false, signer: false },\n ],\n};\n\n/** `sell_v2` on `6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P` — cross-checked against interfaces.json. */\nexport const PUMP_SELL: VenueInstructionAbi = {\n name: 'sell_v2',\n discriminator: new Uint8Array([93, 246, 130, 60, 231, 233, 64, 178]),\n accounts: [\n { name: 'global', writable: false, signer: false },\n { name: 'base_mint', writable: false, signer: false },\n { name: 'quote_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: 'associated_token_program', writable: false, signer: false },\n { name: 'fee_recipient', writable: true, signer: false },\n { name: 'associated_quote_fee_recipient', writable: true, signer: false },\n { name: 'buyback_fee_recipient', writable: true, signer: false },\n { name: 'associated_quote_buyback_fee_recipient', writable: true, signer: false },\n { name: 'bonding_curve', writable: true, signer: false },\n { name: 'associated_base_bonding_curve', writable: true, signer: false },\n { name: 'associated_quote_bonding_curve', writable: true, signer: false },\n { name: 'user', writable: true, signer: true },\n { name: 'associated_base_user', writable: true, signer: false },\n { name: 'associated_quote_user', writable: true, signer: false },\n { name: 'creator_vault', writable: true, signer: false },\n { name: 'associated_creator_vault', writable: true, signer: false },\n { name: 'sharing_config', writable: false, signer: false },\n { name: 'user_volume_accumulator', writable: true, signer: false },\n { name: 'associated_user_volume_accumulator', writable: true, signer: false },\n { name: 'fee_config', writable: false, signer: false },\n { name: 'fee_program', writable: false, signer: false },\n { name: 'system_program', writable: false, signer: false },\n { name: 'event_authority', writable: false, signer: false },\n { name: 'program', writable: false, signer: false },\n ],\n};\n\n/** `buy` on `pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA` — cross-checked against interfaces.json. */\nexport const SWAP_BUY: VenueInstructionAbi = {\n name: 'buy',\n discriminator: new Uint8Array([102, 6, 61, 18, 1, 218, 235, 234]),\n accounts: [\n { name: 'pool', writable: true, signer: false },\n { name: 'user', writable: true, signer: true },\n { name: 'global_config', writable: false, signer: false },\n { name: 'base_mint', writable: false, signer: false },\n { name: 'quote_mint', writable: false, signer: false },\n { name: 'user_base_token_account', writable: true, signer: false },\n { name: 'user_quote_token_account', writable: true, signer: false },\n { name: 'pool_base_token_account', writable: true, signer: false },\n { name: 'pool_quote_token_account', writable: true, signer: false },\n { name: 'protocol_fee_recipient', writable: false, signer: false },\n { name: 'protocol_fee_recipient_token_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: 'system_program', writable: false, signer: false },\n { name: 'associated_token_program', writable: false, signer: false },\n { name: 'event_authority', writable: false, signer: false },\n { name: 'program', writable: false, signer: false },\n { name: 'coin_creator_vault_ata', writable: true, signer: false },\n { name: 'coin_creator_vault_authority', writable: false, signer: false },\n { name: 'global_volume_accumulator', writable: false, signer: false },\n { name: 'user_volume_accumulator', writable: true, signer: false },\n { name: 'fee_config', writable: false, signer: false },\n { name: 'fee_program', writable: false, signer: false },\n ],\n};\n\n/** `sell` on `pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA` — cross-checked against interfaces.json. */\nexport const SWAP_SELL: VenueInstructionAbi = {\n name: 'sell',\n discriminator: new Uint8Array([51, 230, 133, 164, 1, 127, 131, 173]),\n accounts: [\n { name: 'pool', writable: true, signer: false },\n { name: 'user', writable: true, signer: true },\n { name: 'global_config', writable: false, signer: false },\n { name: 'base_mint', writable: false, signer: false },\n { name: 'quote_mint', writable: false, signer: false },\n { name: 'user_base_token_account', writable: true, signer: false },\n { name: 'user_quote_token_account', writable: true, signer: false },\n { name: 'pool_base_token_account', writable: true, signer: false },\n { name: 'pool_quote_token_account', writable: true, signer: false },\n { name: 'protocol_fee_recipient', writable: false, signer: false },\n { name: 'protocol_fee_recipient_token_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: 'system_program', writable: false, signer: false },\n { name: 'associated_token_program', writable: false, signer: false },\n { name: 'event_authority', writable: false, signer: false },\n { name: 'program', writable: false, signer: false },\n { name: 'coin_creator_vault_ata', writable: true, signer: false },\n { name: 'coin_creator_vault_authority', writable: false, signer: false },\n { name: 'fee_config', writable: false, signer: false },\n { name: 'fee_program', writable: false, signer: false },\n ],\n};\n","/**\n * Every fixed address this SDK needs, in one place.\n *\n * None of these is typed twice. The gabox program id comes from the generated client, which Codama\n * took from `target/idl/gabox_v2.json`. The venue addresses come from `src/pump/abi.ts`, which\n * `scripts/codegen.mjs` took from the two official Pump IDLs. Retyping a base58 string is a way to\n * be wrong that no test would catch, so the strings live where the IDL put them.\n */\n\nimport type { Address } from '@solana/kit';\n\nimport { GABOX_V2_PROGRAM_ADDRESS } from './generated/programs/gaboxV2';\nimport {\n ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\n MAYHEM_PROGRAM_ADDRESS,\n PUMP_CREATE_TOKEN_PROGRAM_ADDRESS,\n PUMP_FEE_PROGRAM_ADDRESS,\n PUMP_PROGRAM_ADDRESS,\n PUMP_SWAP_PROGRAM_ADDRESS,\n SYSTEM_PROGRAM_ADDRESS,\n} from './pump/abi';\n\n/** `declare_id!` in `programs/gabox-v2/src/lib.rs`. */\nexport const GABOX_PROGRAM_ID = GABOX_V2_PROGRAM_ADDRESS;\n\nexport {\n ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\n MAYHEM_PROGRAM_ADDRESS,\n PUMP_FEE_PROGRAM_ADDRESS,\n PUMP_PROGRAM_ADDRESS,\n PUMP_SWAP_PROGRAM_ADDRESS,\n SYSTEM_PROGRAM_ADDRESS,\n};\n\n/** Classic SPL Token. The quote side of every Pump trade uses it, because the quote is WSOL. */\nexport const TOKEN_PROGRAM_ADDRESS = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address;\n\n/**\n * Token-2022. Pump `create_v2` mints here, so every coin a machine is built on is a Token-2022\n * mint and the pool vault ATA lives under this program.\n */\nexport const TOKEN_2022_PROGRAM_ADDRESS = PUMP_CREATE_TOKEN_PROGRAM_ADDRESS;\n\n/** Wrapped SOL. The quote mint on both venues. */\nexport const WSOL_MINT = 'So11111111111111111111111111111111111111112' as Address;\n\n/** MagicBlock's ephemeral VRF program. `vrf.rs` pins it and refuses any other. */\nexport const VRF_PROGRAM_ADDRESS = 'Vrf1RNUjXmQGjmQrQLvJHs9SNkvDJEsRVFPkfSQUwGz' as Address;\n\n/**\n * MagicBlock's default oracle queue. The program pins this one address, so a pool creator cannot\n * point a draw at an oracle they control.\n */\nexport const VRF_DEFAULT_QUEUE = 'Cuj97ggrhhidhbu39TijNVqE74xvKJ69gDervRUXAxGh' as Address;\n\n/** The seed of both identity PDAs. See `pdas.ts` — there are two, under different programs. */\nexport const IDENTITY_SEED = new Uint8Array([0x69, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79]); // \"identity\"\n\nexport const SLOT_HASHES_SYSVAR = 'SysvarS1otHashes111111111111111111111111111' as Address;\n\nexport const INSTRUCTIONS_SYSVAR = 'Sysvar1nstructions1111111111111111111111111' as Address;\n\n/** `state.rs`. A retry may not run sooner than this after the last attempt. */\nexport const RETRY_SLOTS = 300n;\n\n/** `state.rs`. After this many slots from the purchase, anyone may expire the draw. */\nexport const TIMEOUT_SLOTS = 216_000n;\n\n/** `state.rs`. Three requests in total, counting the one `buy_pack` makes. */\nexport const MAX_ATTEMPTS = 3;\n\n/**\n * `state.rs`. Tokens in one pack, in base units: 1,000,000 tokens at Pump's fixed 6 decimals, or\n * 0.1% of the 1,000,000,000 supply. Every pool sells packs of this size. The venue decides what a\n * pack costs, so the pack price follows the coin. Read `pool.packTokens` rather than this when a\n * pool is at hand: a later program version may change the constant.\n */\nexport const PACK_TOKENS = 1_000_000n * 1_000_000n;\n\n/** `state.rs`. The creator's per-pack fee, in bps of what the venue charged, may not exceed this. */\nexport const MAX_FEE_BPS = 100;\n\n/** Referral reward: 1% of the creator fee, deducted from that fee. */\nexport const REFERRAL_FEE_BPS = 100n;\n\n/** `state.rs`. The protocol's share of every pack's venue cost and of every sale's proceeds, in bps. */\nexport const PROTOCOL_FEE_BPS = 100n;\n\n/**\n * `PROTOCOL_FEE_COLLECTOR` in `state.rs`. Every pack pays 1% of its venue cost here, on top of\n * that cost. Every sale through the program pays 1% of its proceeds here: SOL on Pump, WSOL (into the\n * collector's WSOL ATA) on PumpSwap. The same key holds the program's upgrade authority.\n *\n * The generated instructions pin it as an `address` constraint, and `test/instruction-data.test.ts`\n * checks this copy against the IDL.\n */\nexport const PROTOCOL_FEE_COLLECTOR = '5WcPTEQ59UqpQzjZUPbU8QRGCbj7NeQNLDa7DbsLkLKT' as Address;\n","/**\n * The boundary with Pump's official SDKs.\n *\n * # Why this file exists, and why it is the only one like it\n *\n * `@pump-fun/pump-sdk` and `@pump-fun/pump-swap-sdk` are the maintained clients Pump publishes.\n * They carry two things worth having and expensive to reproduce: the exact seeds of every PDA a\n * trade touches, and the fee-tier and curve math that says how many tokens a given spend buys.\n * Getting either one slightly wrong shows a buyer a price the venue will not honour.\n *\n * Both packages are built on `@solana/web3.js` v1 and `bn.js`. This SDK and the app are on\n * `@solana/kit`. So the conversion happens here and nowhere else: `PublicKey` and `BN` do not\n * appear in any other file, and nothing this module exports carries them. Addresses go out as kit\n * `Address`, amounts as `bigint`.\n *\n * Pinned versions are in `sdk/package.json` and repeated in `sdk/README.md`. They are exact, not\n * ranges: a fee-math change in a patch release changes what a buyer is shown.\n *\n * # What this file does NOT do\n *\n * It does not build instructions. Both packages build their trades around `@solana/web3.js`\n * transactions, and `market.rs` takes the venue's account list as `remaining_accounts` instead.\n * So `accounts.ts` assembles the account lists from the generated `abi.ts` table, using the\n * addresses this file derives.\n */\n\nimport {\n bondingCurvePda,\n creatorVaultPda,\n feeSharingConfigPda,\n getBuySolAmountFromTokenAmount,\n getMayhemStatePda,\n getGlobalParamsPda,\n getSellSolAmountFromTokenAmount,\n getSolVaultPda,\n getTokenVaultPda,\n GLOBAL_PDA,\n GLOBAL_VOLUME_ACCUMULATOR_PDA,\n PUMP_EVENT_AUTHORITY_PDA,\n PUMP_FEE_CONFIG_PDA,\n PUMP_SDK,\n userVolumeAccumulatorPda,\n type BondingCurve,\n type FeeConfig,\n type Global,\n} from '@pump-fun/pump-sdk';\nimport {\n buyBaseInput,\n canonicalPumpPoolPda,\n coinCreatorVaultAtaPda,\n coinCreatorVaultAuthorityPda,\n GLOBAL_CONFIG_PDA,\n GLOBAL_VOLUME_ACCUMULATOR_PDA as AMM_GLOBAL_VOLUME_ACCUMULATOR_PDA,\n PUMP_AMM_EVENT_AUTHORITY_PDA,\n PUMP_AMM_FEE_CONFIG_PDA,\n PUMP_AMM_SDK,\n sellBaseInput,\n userVolumeAccumulatorPda as ammUserVolumeAccumulatorPda,\n type FeeConfig as AmmFeeConfig,\n type GlobalConfig as AmmGlobalConfig,\n} from '@pump-fun/pump-swap-sdk';\nimport { getAssociatedTokenAddressSync, unpackMint } from '@solana/spl-token';\nimport { PublicKey } from '@solana/web3.js';\nimport BN from 'bn.js';\n// Explicitly, not the global. This module is vendored into a Next.js app, where `Buffer` is not\n// defined in the browser — a bundler resolves this import to the `buffer` package instead. Pump's\n// own `pda.ts` does the same thing for the same reason.\nimport { Buffer } from 'buffer';\n\nimport { address, type Address } from '@solana/kit';\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Conversion\n// ─────────────────────────────────────────────────────────────────────────────\n\n// Not exported. A function whose signature names `PublicKey` would put web3.js back into this\n// SDK's public types, which is the one thing this file exists to prevent.\nconst toAddress = (key: PublicKey): Address => address(key.toBase58());\n\nconst toPublicKey = (a: Address): PublicKey => new PublicKey(a);\n\ndeclare const RAW: unique symbol;\n\n/**\n * A decoded value from one of Pump's packages, carried opaquely.\n *\n * The quote functions need the package's own object back — it holds `PublicKey`s and `BN`s the fee\n * math reads. Typing it as the real thing would name web3.js in this SDK's public surface. So it\n * goes out branded and comes back branded, and only this file ever looks inside.\n */\nexport type PumpRaw<K extends string> = { readonly [RAW]: K };\n\nconst brand = <K extends string>(value: unknown): PumpRaw<K> => value as PumpRaw<K>;\nconst unbrand = <T>(value: PumpRaw<string>): T => value as unknown as T;\n\nexport type PumpRawGlobal = PumpRaw<'pumpGlobal'>;\nexport type PumpRawBondingCurve = PumpRaw<'pumpBondingCurve'>;\nexport type PumpRawFeeConfig = PumpRaw<'pumpFeeConfig'>;\nexport type AmmRawPool = PumpRaw<'ammPool'>;\nexport type AmmRawGlobalConfig = PumpRaw<'ammGlobalConfig'>;\nexport type AmmRawFeeConfig = PumpRaw<'ammFeeConfig'>;\n\nconst toBigint = (n: BN): bigint => BigInt(n.toString());\n\nconst toBn = (n: bigint): BN => new BN(n.toString());\n\n/**\n * An `AccountInfo<Buffer>` shaped just enough for the packages' decoders. They read `.data` and\n * nothing else, so the rest is filler rather than a claim about the account.\n */\nfunction accountInfo(data: Uint8Array, owner: PublicKey = PublicKey.default) {\n return { data: Buffer.from(data), executable: false, lamports: 0, owner };\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Pump curve addresses\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** `[\"global\"]` under Pump. Holds the fee recipient lists and the curve's initial reserves. */\nexport const PUMP_GLOBAL = toAddress(GLOBAL_PDA);\nexport const PUMP_EVENT_AUTHORITY = toAddress(PUMP_EVENT_AUTHORITY_PDA);\n/** `[\"fee_config\", pump_program_id]` under the Pump fee program. */\nexport const PUMP_FEE_CONFIG = toAddress(PUMP_FEE_CONFIG_PDA);\nexport const PUMP_GLOBAL_VOLUME_ACCUMULATOR = toAddress(GLOBAL_VOLUME_ACCUMULATOR_PDA);\n/**\n * Mayhem mode is off for every gabox coin, but `create_v2` still takes all four accounts.\n *\n * The four mayhem accounts are derived under the **mayhem** program\n * (`MAyhSmzXzV1pTf7LsNkrNwkWKTo4ougAJ1PPg47MD4e`), not under Pump. Pump's IDL states the seeds but\n * omits the program on `global_params`, `sol_vault` and `mayhem_state`, so read literally it would\n * put all three under Pump and every `create_v2` would fail. `@pump-fun/pump-sdk`'s own\n * `createV2Instruction` derives them under the mayhem program, and that is what these follow.\n * Confirmed by a successful seeded machine creation on devnet on 2026-09-10.\n */\nexport const MAYHEM_GLOBAL_PARAMS = toAddress(getGlobalParamsPda());\nexport const MAYHEM_SOL_VAULT = toAddress(getSolVaultPda());\n\nexport const pumpBondingCurve = (mint: Address): Address =>\n toAddress(bondingCurvePda(toPublicKey(mint)));\n\nexport const pumpCreatorVault = (creator: Address): Address =>\n toAddress(creatorVaultPda(toPublicKey(creator)));\n\nexport const pumpSharingConfig = (mint: Address): Address =>\n toAddress(feeSharingConfigPda(toPublicKey(mint)));\n\nexport const pumpUserVolumeAccumulator = (user: Address): Address =>\n toAddress(userVolumeAccumulatorPda(toPublicKey(user)));\n\nexport const pumpMayhemState = (mint: Address): Address =>\n toAddress(getMayhemStatePda(toPublicKey(mint)));\n\nexport const pumpMayhemTokenVault = (mint: Address): Address =>\n toAddress(getTokenVaultPda(toPublicKey(mint)));\n\n/**\n * `[\"mint-authority\"]` under Pump.\n *\n * The one address here that comes from the IDL rather than the package: `pda.ts` has no helper for\n * it. The seed is in `create_v2`'s own `pda` metadata, so it is not a guess.\n */\nexport const PUMP_MINT_AUTHORITY = toAddress(\n PublicKey.findProgramAddressSync(\n [Buffer.from('mint-authority')],\n new PublicKey('6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P'),\n )[0],\n);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// PumpSwap addresses\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport const AMM_GLOBAL_CONFIG = toAddress(GLOBAL_CONFIG_PDA);\nexport const AMM_EVENT_AUTHORITY = toAddress(PUMP_AMM_EVENT_AUTHORITY_PDA);\nexport const AMM_FEE_CONFIG = toAddress(PUMP_AMM_FEE_CONFIG_PDA);\nexport const AMM_GLOBAL_VOLUME_ACCUMULATOR = toAddress(AMM_GLOBAL_VOLUME_ACCUMULATOR_PDA);\n\n/**\n * The canonical PumpSwap pool for a graduated Pump coin: index 0, owned by the coin's\n * `[\"pool-authority\", mint]` PDA, quoted in WSOL. A coin can have other pools; the program lets the\n * user sign whichever pool they pass, and a client should pick this one.\n */\nexport const ammCanonicalPool = (mint: Address): Address =>\n toAddress(canonicalPumpPoolPda(toPublicKey(mint)));\n\nexport const ammUserVolumeAccumulator = (user: Address): Address =>\n toAddress(ammUserVolumeAccumulatorPda(toPublicKey(user)));\n\nexport const ammCoinCreatorVaultAuthority = (coinCreator: Address): Address =>\n toAddress(coinCreatorVaultAuthorityPda(toPublicKey(coinCreator)));\n\nexport const ammCoinCreatorVaultAta = (\n vaultAuthority: Address,\n quoteMint: Address,\n quoteTokenProgram: Address,\n): Address =>\n toAddress(\n coinCreatorVaultAtaPda(\n toPublicKey(vaultAuthority),\n toPublicKey(quoteMint),\n toPublicKey(quoteTokenProgram),\n ),\n );\n\n/** An ATA, off-curve owners allowed. Pool PDAs and vault authorities are all off-curve. */\nexport const ata = (owner: Address, mint: Address, tokenProgram: Address): Address =>\n toAddress(\n getAssociatedTokenAddressSync(\n toPublicKey(mint),\n toPublicKey(owner),\n true,\n toPublicKey(tokenProgram),\n ),\n );\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Decoders\n// ─────────────────────────────────────────────────────────────────────────────\n\n/** Pump's `Global`, with the two fee-recipient lists a buy needs. Amounts stay `BN` internally. */\nexport type PumpGlobalState = {\n feeRecipient: Address;\n feeRecipients: Address[];\n buybackFeeRecipients: Address[];\n reservedFeeRecipient: Address;\n reservedFeeRecipients: Address[];\n createV2Enabled: boolean;\n mayhemModeEnabled: boolean;\n isCashbackEnabled: boolean;\n feeBasisPoints: bigint;\n creatorFeeBasisPoints: bigint;\n tokenTotalSupply: bigint;\n initialVirtualTokenReserves: bigint;\n initialVirtualSolReserves: bigint;\n initialRealTokenReserves: bigint;\n /** Opaque. Hand it back to the quote functions; there is nothing to read here. */\n raw: PumpRawGlobal;\n};\n\nexport function decodePumpGlobal(data: Uint8Array): PumpGlobalState {\n const g = PUMP_SDK.decodeGlobal(accountInfo(data));\n return {\n feeRecipient: toAddress(g.feeRecipient),\n feeRecipients: g.feeRecipients.map(toAddress),\n buybackFeeRecipients: (g.buybackFeeRecipients ?? []).map(toAddress),\n reservedFeeRecipient: toAddress(g.reservedFeeRecipient),\n reservedFeeRecipients: (g.reservedFeeRecipients ?? []).map(toAddress),\n createV2Enabled: g.createV2Enabled,\n mayhemModeEnabled: g.mayhemModeEnabled,\n isCashbackEnabled: g.isCashbackEnabled,\n feeBasisPoints: toBigint(g.feeBasisPoints),\n creatorFeeBasisPoints: toBigint(g.creatorFeeBasisPoints),\n tokenTotalSupply: toBigint(g.tokenTotalSupply),\n initialVirtualTokenReserves: toBigint(g.initialVirtualTokenReserves),\n initialVirtualSolReserves: toBigint(g.initialVirtualSolReserves),\n initialRealTokenReserves: toBigint(g.initialRealTokenReserves),\n raw: brand<'pumpGlobal'>(g),\n };\n}\n\nexport type PumpBondingCurveState = {\n virtualTokenReserves: bigint;\n virtualQuoteReserves: bigint;\n realTokenReserves: bigint;\n realQuoteReserves: bigint;\n tokenTotalSupply: bigint;\n /** `true` once the coin has graduated. Then trade on PumpSwap, not the curve. */\n complete: boolean;\n creator: Address;\n isMayhemMode: boolean;\n isCashbackCoin: boolean;\n quoteMint: Address;\n /** Opaque. Hand it back to the quote functions. */\n raw: PumpRawBondingCurve;\n};\n\nexport function decodeBondingCurve(data: Uint8Array): PumpBondingCurveState {\n const c = PUMP_SDK.decodeBondingCurve(accountInfo(data));\n return {\n virtualTokenReserves: toBigint(c.virtualTokenReserves),\n virtualQuoteReserves: toBigint(c.virtualQuoteReserves),\n realTokenReserves: toBigint(c.realTokenReserves),\n realQuoteReserves: toBigint(c.realQuoteReserves),\n tokenTotalSupply: toBigint(c.tokenTotalSupply),\n complete: c.complete,\n creator: toAddress(c.creator),\n isMayhemMode: c.isMayhemMode,\n isCashbackCoin: c.isCashbackCoin,\n quoteMint: toAddress(c.quoteMint),\n raw: brand<'pumpBondingCurve'>(c),\n };\n}\n\nexport function decodePumpFeeConfig(data: Uint8Array): PumpRawFeeConfig {\n return brand<'pumpFeeConfig'>(PUMP_SDK.decodeFeeConfig(accountInfo(data)));\n}\n\nexport type AmmPoolState = {\n index: number;\n creator: Address;\n baseMint: Address;\n quoteMint: Address;\n poolBaseTokenAccount: Address;\n poolQuoteTokenAccount: Address;\n coinCreator: Address;\n virtualQuoteReserves: bigint;\n /** Opaque. Hand it back to the quote functions. */\n raw: AmmRawPool;\n};\n\nexport function decodeAmmPool(data: Uint8Array): AmmPoolState {\n const p = PUMP_AMM_SDK.decodePool(accountInfo(data));\n return {\n index: p.index,\n creator: toAddress(p.creator),\n baseMint: toAddress(p.baseMint),\n quoteMint: toAddress(p.quoteMint),\n poolBaseTokenAccount: toAddress(p.poolBaseTokenAccount),\n poolQuoteTokenAccount: toAddress(p.poolQuoteTokenAccount),\n coinCreator: toAddress(p.coinCreator),\n virtualQuoteReserves: toBigint(p.virtualQuoteReserves ?? new BN(0)),\n raw: brand<'ammPool'>(p),\n };\n}\n\nexport type AmmGlobalConfigState = {\n protocolFeeRecipients: Address[];\n /** Opaque. Hand it back to the quote functions. */\n raw: AmmRawGlobalConfig;\n};\n\nexport function decodeAmmGlobalConfig(data: Uint8Array): AmmGlobalConfigState {\n const g = PUMP_AMM_SDK.decodeGlobalConfig(accountInfo(data));\n return {\n protocolFeeRecipients: g.protocolFeeRecipients.map(toAddress),\n raw: brand<'ammGlobalConfig'>(g),\n };\n}\n\nexport function decodeAmmFeeConfig(data: Uint8Array): AmmRawFeeConfig {\n return brand<'ammFeeConfig'>(PUMP_AMM_SDK.decodeFeeConfig(accountInfo(data)));\n}\n\n/** Total supply of an SPL or Token-2022 mint. The AMM fee tiers are a function of it. */\nexport function decodeMintSupply(data: Uint8Array, mint: Address, owner: Address): bigint {\n const program = toPublicKey(owner);\n return unpackMint(toPublicKey(mint), accountInfo(data, program), program).supply;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Quotes\n// ─────────────────────────────────────────────────────────────────────────────\n\n/**\n * Lamports an exact-tokens-out buy of `tokens` costs on the Pump curve, fees included.\n *\n * This is the same function the Pump front end uses. The result is the whole debit — the curve's\n * price plus the venue's protocol and creator fees — which is what `buy_v2`'s `max_sol_cost` has\n * to cover, and what `buy_pack`'s `max_quote_in` caps.\n */\nexport function curveBuyCost({\n global,\n bondingCurve,\n feeConfig,\n mintSupply,\n tokens,\n quoteMint,\n}: {\n global: PumpGlobalState;\n bondingCurve: PumpBondingCurveState | null;\n feeConfig: PumpRawFeeConfig | null;\n mintSupply: bigint | null;\n tokens: bigint;\n quoteMint: Address;\n}): bigint {\n return toBigint(\n getBuySolAmountFromTokenAmount({\n global: unbrand<Global>(global.raw),\n feeConfig: feeConfig === null ? null : unbrand<FeeConfig>(feeConfig),\n mintSupply: mintSupply === null ? null : toBn(mintSupply),\n bondingCurve: bondingCurve ? unbrand<BondingCurve>(bondingCurve.raw) : null,\n amount: toBn(tokens),\n quoteMint: toPublicKey(quoteMint),\n }),\n );\n}\n\n/** Lamports a curve sale of `tokens` returns, net of fees. */\nexport function curveSellQuote({\n global,\n bondingCurve,\n feeConfig,\n mintSupply,\n tokens,\n}: {\n global: PumpGlobalState;\n bondingCurve: PumpBondingCurveState;\n feeConfig: PumpRawFeeConfig | null;\n mintSupply: bigint;\n tokens: bigint;\n}): bigint {\n return toBigint(\n getSellSolAmountFromTokenAmount({\n global: unbrand<Global>(global.raw),\n feeConfig: feeConfig === null ? null : unbrand<FeeConfig>(feeConfig),\n mintSupply: toBn(mintSupply),\n bondingCurve: unbrand<BondingCurve>(bondingCurve.raw),\n amount: toBn(tokens),\n }),\n );\n}\n\n/** WSOL a PumpSwap exact-base-out buy of `tokens` costs, LP and protocol fees included. */\nexport function ammBuyCost({\n pool,\n globalConfig,\n feeConfig,\n baseReserve,\n quoteReserve,\n baseMintSupply,\n tokens,\n}: {\n pool: AmmPoolState;\n globalConfig: AmmGlobalConfigState;\n feeConfig: AmmRawFeeConfig | null;\n baseReserve: bigint;\n quoteReserve: bigint;\n baseMintSupply: bigint;\n tokens: bigint;\n}): bigint {\n const result = buyBaseInput({\n base: toBn(tokens),\n slippage: 0,\n baseReserve: toBn(baseReserve),\n quoteReserve: toBn(quoteReserve),\n virtualQuoteReserves: toBn(pool.virtualQuoteReserves),\n globalConfig: unbrand<AmmGlobalConfig>(globalConfig.raw),\n baseMintAccount: { supply: baseMintSupply } as never,\n baseMint: toPublicKey(pool.baseMint),\n coinCreator: toPublicKey(pool.coinCreator),\n creator: toPublicKey(pool.creator),\n feeConfig: feeConfig === null ? null : unbrand<AmmFeeConfig>(feeConfig),\n });\n return toBigint(result.uiQuote);\n}\n\n/** WSOL a PumpSwap sale of `tokens` returns, net of fees. */\nexport function ammSellQuote({\n pool,\n globalConfig,\n feeConfig,\n baseReserve,\n quoteReserve,\n baseMintSupply,\n tokens,\n}: {\n pool: AmmPoolState;\n globalConfig: AmmGlobalConfigState;\n feeConfig: AmmRawFeeConfig | null;\n baseReserve: bigint;\n quoteReserve: bigint;\n baseMintSupply: bigint;\n tokens: bigint;\n}): bigint {\n const result = sellBaseInput({\n base: toBn(tokens),\n slippage: 0,\n baseReserve: toBn(baseReserve),\n quoteReserve: toBn(quoteReserve),\n virtualQuoteReserves: toBn(pool.virtualQuoteReserves),\n globalConfig: unbrand<AmmGlobalConfig>(globalConfig.raw),\n baseMintAccount: { supply: baseMintSupply } as never,\n baseMint: toPublicKey(pool.baseMint),\n coinCreator: toPublicKey(pool.coinCreator),\n creator: toPublicKey(pool.creator),\n feeConfig: feeConfig === null ? null : unbrand<AmmFeeConfig>(feeConfig),\n });\n return toBigint(result.uiQuote);\n}\n","/**\n * The ordered account list of every Pump and PumpSwap instruction this SDK builds.\n *\n * # Why these are built here and not by the official SDK\n *\n * `market.rs` accepts four trade instructions and no others: Pump's `buy_v2` and `sell_v2`,\n * PumpSwap's `buy` and `sell`. The official packages build these around `@solana/web3.js`\n * transactions, and the program wants a bare account list as `remainingAccounts`. So the lists are\n * assembled here, from `abi.ts`, which `scripts/codegen.mjs` generated from the same IDLs the\n * program's `market_abi.rs` came from.\n *\n * Every address still comes from `adapter.ts`, which means from the official packages. Nothing here\n * invents a derivation.\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 `buy_pack` (or `initialize_pool`, or `sell_prize`) as `remainingAccounts`,\n * unchanged. `market.rs` walks it position by position: a writable slot must be writable in the\n * outer transaction, and the one signer slot must be the purchaser and must sign.\n *\n * # The three addresses that need a chain read\n *\n * `fee_recipient` and `buyback_fee_recipient` on Pump, and `protocol_fee_recipient` on PumpSwap.\n * Each is one of a list held in an on-chain account, and the venue accepts any member. `state.ts`\n * reads those accounts and passes the choice in.\n */\n\nimport { AccountRole, type AccountMeta, type Address } from '@solana/kit';\n\nimport { TOKEN_PROGRAM_ADDRESS, WSOL_MINT } from '../ids';\nimport {\n ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\n MAYHEM_PROGRAM_ADDRESS,\n PUMP_BUY,\n PUMP_CREATE_V2,\n PUMP_FEE_PROGRAM_ADDRESS,\n PUMP_PROGRAM_ADDRESS,\n PUMP_SELL,\n PUMP_SWAP_PROGRAM_ADDRESS,\n SWAP_BUY,\n SWAP_SELL,\n SYSTEM_PROGRAM_ADDRESS,\n type VenueInstructionAbi,\n} from './abi';\nimport {\n AMM_EVENT_AUTHORITY,\n AMM_FEE_CONFIG,\n AMM_GLOBAL_CONFIG,\n AMM_GLOBAL_VOLUME_ACCUMULATOR,\n ammCoinCreatorVaultAta,\n ammCoinCreatorVaultAuthority,\n ammUserVolumeAccumulator,\n ata,\n MAYHEM_GLOBAL_PARAMS,\n MAYHEM_SOL_VAULT,\n PUMP_EVENT_AUTHORITY,\n PUMP_FEE_CONFIG,\n PUMP_GLOBAL,\n PUMP_GLOBAL_VOLUME_ACCUMULATOR,\n PUMP_MINT_AUTHORITY,\n pumpBondingCurve,\n pumpCreatorVault,\n pumpMayhemState,\n pumpMayhemTokenVault,\n pumpSharingConfig,\n pumpUserVolumeAccumulator,\n} from './adapter';\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 —\n * never from the caller — which is what keeps this list in step with `market_abi.rs`.\n */\nfunction 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// Pump curve\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type PumpCreateAccountsInput = {\n mint: Address;\n /** The wallet paying and signing. `initialize_pool` requires this to be the pool creator. */\n user: Address;\n /** Token-2022. `create_v2` pins it in the IDL, so there is nothing else it can be. */\n tokenProgram: Address;\n};\n\n/**\n * `create_v2` on Pump. The mint is a fresh keypair and signs; the user pays.\n *\n * The four mayhem accounts are always present even with mayhem mode off. `create_v2` takes them\n * unconditionally, so a client cannot skip them.\n */\nexport function pumpCreateV2Accounts(input: PumpCreateAccountsInput): AccountMeta[] {\n const { mint, user, tokenProgram } = input;\n return order(PUMP_CREATE_V2, {\n mint,\n mint_authority: PUMP_MINT_AUTHORITY,\n bonding_curve: pumpBondingCurve(mint),\n associated_bonding_curve: ata(pumpBondingCurve(mint), mint, tokenProgram),\n global: PUMP_GLOBAL,\n user,\n system_program: SYSTEM_PROGRAM_ADDRESS,\n token_program: tokenProgram,\n associated_token_program: ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\n mayhem_program_id: MAYHEM_PROGRAM_ADDRESS,\n global_params: MAYHEM_GLOBAL_PARAMS,\n sol_vault: MAYHEM_SOL_VAULT,\n mayhem_state: pumpMayhemState(mint),\n mayhem_token_vault: pumpMayhemTokenVault(mint),\n event_authority: PUMP_EVENT_AUTHORITY,\n program: PUMP_PROGRAM_ADDRESS,\n });\n}\n\nexport type PumpTradeAccountsInput = {\n mint: Address;\n /** The purchaser or seller. The one signing slot in the list. */\n user: Address;\n /** The base mint's own program. Token-2022 for every Pump `create_v2` coin. */\n tokenProgram: Address;\n /** `bondingCurve.creator`. The creator vault is derived from it. */\n creator: Address;\n /** One of `global.feeRecipients`, chosen by the caller. */\n feeRecipient: Address;\n /** One of `global.buybackFeeRecipients`, chosen by the caller. */\n buybackFeeRecipient: Address;\n /** Defaults to WSOL, the only quote `market.rs` accepts. */\n quoteMint?: Address;\n /** Defaults to classic SPL Token, because the quote is WSOL. */\n quoteTokenProgram?: Address;\n};\n\nfunction pumpTradeAccounts(abi: VenueInstructionAbi, input: PumpTradeAccountsInput): AccountMeta[] {\n const {\n mint,\n user,\n tokenProgram,\n creator,\n feeRecipient,\n buybackFeeRecipient,\n quoteMint = WSOL_MINT,\n quoteTokenProgram = TOKEN_PROGRAM_ADDRESS,\n } = input;\n\n const curve = pumpBondingCurve(mint);\n const creatorVault = pumpCreatorVault(creator);\n const volume = pumpUserVolumeAccumulator(user);\n\n return order(abi, {\n global: PUMP_GLOBAL,\n base_mint: mint,\n quote_mint: quoteMint,\n base_token_program: tokenProgram,\n quote_token_program: quoteTokenProgram,\n associated_token_program: ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\n fee_recipient: feeRecipient,\n associated_quote_fee_recipient: ata(feeRecipient, quoteMint, quoteTokenProgram),\n buyback_fee_recipient: buybackFeeRecipient,\n associated_quote_buyback_fee_recipient: ata(buybackFeeRecipient, quoteMint, quoteTokenProgram),\n bonding_curve: curve,\n associated_base_bonding_curve: ata(curve, mint, tokenProgram),\n associated_quote_bonding_curve: ata(curve, quoteMint, quoteTokenProgram),\n user,\n associated_base_user: ata(user, mint, tokenProgram),\n associated_quote_user: ata(user, quoteMint, quoteTokenProgram),\n creator_vault: creatorVault,\n associated_creator_vault: ata(creatorVault, quoteMint, quoteTokenProgram),\n sharing_config: pumpSharingConfig(mint),\n global_volume_accumulator: PUMP_GLOBAL_VOLUME_ACCUMULATOR,\n user_volume_accumulator: volume,\n associated_user_volume_accumulator: ata(volume, quoteMint, quoteTokenProgram),\n fee_config: PUMP_FEE_CONFIG,\n fee_program: PUMP_FEE_PROGRAM_ADDRESS,\n system_program: SYSTEM_PROGRAM_ADDRESS,\n event_authority: PUMP_EVENT_AUTHORITY,\n program: PUMP_PROGRAM_ADDRESS,\n });\n}\n\n/** `buy_v2`. The first argument is tokens to receive; the second is the most SOL to pay. */\nexport const pumpBuyAccounts = (input: PumpTradeAccountsInput): AccountMeta[] =>\n pumpTradeAccounts(PUMP_BUY, input);\n\n/** `sell_v2`. One account shorter than the buy: it has no `global_volume_accumulator`. */\nexport const pumpSellAccounts = (input: PumpTradeAccountsInput): AccountMeta[] =>\n pumpTradeAccounts(PUMP_SELL, input);\n\n// ─────────────────────────────────────────────────────────────────────────────\n// PumpSwap\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport type SwapTradeAccountsInput = {\n /** The AMM pool. Use the canonical one for a graduated Pump coin. */\n pool: Address;\n mint: Address;\n user: Address;\n tokenProgram: Address;\n /** `pool.poolBaseTokenAccount`, read off the pool account. */\n poolBaseTokenAccount: Address;\n /** `pool.poolQuoteTokenAccount`, read off the pool account. */\n poolQuoteTokenAccount: Address;\n /** `pool.coinCreator`. The creator vault authority is derived from it. */\n coinCreator: Address;\n /** One of `globalConfig.protocolFeeRecipients`, chosen by the caller. */\n protocolFeeRecipient: Address;\n quoteMint?: Address;\n quoteTokenProgram?: Address;\n};\n\nfunction swapTradeAccounts(abi: VenueInstructionAbi, input: SwapTradeAccountsInput): AccountMeta[] {\n const {\n pool,\n mint,\n user,\n tokenProgram,\n poolBaseTokenAccount,\n poolQuoteTokenAccount,\n coinCreator,\n protocolFeeRecipient,\n quoteMint = WSOL_MINT,\n quoteTokenProgram = TOKEN_PROGRAM_ADDRESS,\n } = input;\n\n const vaultAuthority = ammCoinCreatorVaultAuthority(coinCreator);\n\n return order(abi, {\n pool,\n user,\n global_config: AMM_GLOBAL_CONFIG,\n base_mint: mint,\n quote_mint: quoteMint,\n user_base_token_account: ata(user, mint, tokenProgram),\n user_quote_token_account: ata(user, quoteMint, quoteTokenProgram),\n pool_base_token_account: poolBaseTokenAccount,\n pool_quote_token_account: poolQuoteTokenAccount,\n protocol_fee_recipient: protocolFeeRecipient,\n protocol_fee_recipient_token_account: ata(\n protocolFeeRecipient,\n quoteMint,\n quoteTokenProgram,\n ),\n base_token_program: tokenProgram,\n quote_token_program: quoteTokenProgram,\n system_program: SYSTEM_PROGRAM_ADDRESS,\n associated_token_program: ASSOCIATED_TOKEN_PROGRAM_ADDRESS,\n event_authority: AMM_EVENT_AUTHORITY,\n program: PUMP_SWAP_PROGRAM_ADDRESS,\n coin_creator_vault_ata: ammCoinCreatorVaultAta(vaultAuthority, quoteMint, quoteTokenProgram),\n coin_creator_vault_authority: vaultAuthority,\n global_volume_accumulator: AMM_GLOBAL_VOLUME_ACCUMULATOR,\n user_volume_accumulator: ammUserVolumeAccumulator(user),\n fee_config: AMM_FEE_CONFIG,\n fee_program: PUMP_FEE_PROGRAM_ADDRESS,\n });\n}\n\n/** `buy` on PumpSwap. The spend is WSOL, so fund the user's WSOL ATA with `max_quote_in` first. */\nexport const swapBuyAccounts = (input: SwapTradeAccountsInput): AccountMeta[] =>\n swapTradeAccounts(SWAP_BUY, input);\n\n/** `sell` on PumpSwap. Proceeds land in the user's WSOL ATA; unwrap separately if wanted. */\nexport const swapSellAccounts = (input: SwapTradeAccountsInput): AccountMeta[] =>\n swapTradeAccounts(SWAP_SELL, input);\n\n/**\n * PumpSwap's optional cashback account, appended after the ABI list.\n *\n * `market.rs` allows exactly one extra account past the end of a PumpSwap list, and checks it is\n * this address and that it is writable. It is the WSOL ATA of the user's own volume accumulator.\n * Append it only when the coin is a cashback coin; otherwise leave the list at its ABI length.\n */\nexport function swapCashbackAccount(user: Address): AccountMeta {\n const volume = ammUserVolumeAccumulator(user);\n return {\n address: ata(volume, WSOL_MINT, TOKEN_PROGRAM_ADDRESS),\n role: AccountRole.WRITABLE,\n };\n}\n","/**\n * Reading the venue: which one a coin trades on right now, what a pack costs there, and the\n * account list for the trade.\n *\n * One round trip does the whole job. `resolveVenue` reads every account the answer depends on,\n * decodes them through `adapter.ts`, and hands back a plain object whose methods are pure. A caller\n * that wants to re-price a different token count calls `quoteBuy` again with no further reads.\n *\n * # Choosing the venue\n *\n * The bonding curve's `complete` flag is the whole rule. `false` means the coin is still on the\n * curve, so trade Pump. `true` means it graduated, so trade the canonical PumpSwap pool. A caller\n * can force either one; forcing PumpSwap for a coin still on the curve simply fails on chain.\n *\n * A coin can graduate between the read and the send. `buy_pack` then fails and no draw is created,\n * which is the intended outcome — refresh and retry.\n */\n\nimport { getBase64Encoder, getU64Decoder, type AccountMeta, type Address } from '@solana/kit';\n\nimport { TOKEN_PROGRAM_ADDRESS, WSOL_MINT } from '../ids';\nimport type { GaboxClient, GaboxRpc } from '../rpc';\nimport { PUMP_PROGRAM_ADDRESS, PUMP_SWAP_PROGRAM_ADDRESS } from './abi';\nimport {\n pumpBuyAccounts,\n pumpSellAccounts,\n swapBuyAccounts,\n swapSellAccounts,\n} from './accounts';\nimport {\n AMM_FEE_CONFIG,\n AMM_GLOBAL_CONFIG,\n ammBuyCost,\n ata,\n ammCanonicalPool,\n ammSellQuote,\n curveBuyCost,\n curveSellQuote,\n decodeAmmFeeConfig,\n decodeAmmGlobalConfig,\n decodeAmmPool,\n decodeBondingCurve,\n decodeMintSupply,\n decodePumpFeeConfig,\n decodePumpGlobal,\n PUMP_FEE_CONFIG,\n PUMP_GLOBAL,\n pumpBondingCurve,\n type AmmGlobalConfigState,\n type AmmRawFeeConfig,\n type AmmPoolState,\n type PumpRawFeeConfig,\n type PumpBondingCurveState,\n type PumpGlobalState,\n} from './adapter';\n\nexport type VenueKind = 'pump' | 'pumpswap';\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 `venue`. */\n program: Address;\n mint: Address;\n /** The base mint's own token program. Token-2022 for a Pump `create_v2` coin. */\n tokenProgram: Address;\n /** `true` once the coin has graduated off the curve. */\n complete: boolean;\n /** The coin's creator, from the bonding curve. The venue pays it a share of each trade. */\n creator: Address;\n /** The ordered account list for an exact-tokens-out buy, in `remainingAccounts` order. */\n buyAccounts: AccountMeta[];\n /** The ordered account list for a sale. */\n sellAccounts: AccountMeta[];\n /** Lamports (or WSOL, on PumpSwap) an exact-tokens-out buy of `tokens` costs right now, fees included. */\n quoteBuy(tokens: bigint): bigint;\n /** Lamports (or WSOL, on PumpSwap) a sale of `tokens` returns right now, net of fees. */\n quoteSell(tokens: bigint): bigint;\n};\n\nexport type ResolveVenueOptions = {\n mint: Address;\n /** The wallet that will sign the trade. Its ATAs appear in the account list. */\n user: Address;\n /** Force a venue instead of reading the `complete` flag. */\n venue?: VenueKind;\n /**\n * Which fee recipient to use, as an index into the on-chain list. Left out, one is picked at\n * random, which is what Pump's own client does to spread load. Pass an index for a reproducible\n * account list.\n */\n feeRecipientIndex?: number;\n /** Same, for Pump's separate buyback recipient list. */\n buybackRecipientIndex?: number;\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();\nconst u64 = getU64Decoder();\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\n/**\n * The `amount` field of an SPL or Token-2022 token account: bytes 64..72, little-endian.\n *\n * Both layouts share their first 165 bytes, so one reader covers both. Token-2022 extensions live\n * past that and do not move this field.\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\nfunction pick<T>(list: readonly T[], index: number | undefined, what: string): T {\n if (list.length === 0) throw new Error(`the chain holds no ${what}`);\n const i = index ?? Math.floor(Math.random() * list.length);\n const chosen = list[i];\n if (chosen === undefined) throw new Error(`${what} index ${i} is out of range (${list.length})`);\n return chosen;\n}\n\n// ─────────────────────────────────────────────────────────────────────────────\n// resolveVenue\n// ─────────────────────────────────────────────────────────────────────────────\n\nexport async function resolveVenue(\n client: GaboxClient,\n options: ResolveVenueOptions,\n): Promise<ResolvedVenue> {\n const { mint, user } = options;\n const curveAddress = pumpBondingCurve(mint);\n const poolAddress = ammCanonicalPool(mint);\n\n const [mintAccount, globalAccount, feeConfigAccount, curveAccount, poolAccount, ammConfigAccount, ammFeeAccount] =\n await readAccounts(client.rpc, [\n mint,\n PUMP_GLOBAL,\n PUMP_FEE_CONFIG,\n curveAddress,\n poolAddress,\n AMM_GLOBAL_CONFIG,\n AMM_FEE_CONFIG,\n ]);\n\n if (!mintAccount) throw new Error(`no mint account at ${mint}`);\n if (!globalAccount) throw new Error(`Pump's Global account is missing at ${PUMP_GLOBAL}`);\n\n const tokenProgram = mintAccount.owner;\n const mintSupply = decodeMintSupply(mintAccount.data, mint, tokenProgram);\n const global: PumpGlobalState = decodePumpGlobal(globalAccount.data);\n const pumpFeeConfig: PumpRawFeeConfig | null = feeConfigAccount\n ? decodePumpFeeConfig(feeConfigAccount.data)\n : null;\n const curve: PumpBondingCurveState | null = curveAccount\n ? decodeBondingCurve(curveAccount.data)\n : null;\n\n const kind: VenueKind = options.venue ?? (curve?.complete === true ? 'pumpswap' : 'pump');\n\n if (kind === 'pump') {\n if (!curve) {\n throw new Error(\n `no bonding curve at ${curveAddress}. The coin does not exist on Pump, or it was not ` +\n 'created with `create_v2`.',\n );\n }\n const feeRecipient = pick(\n [global.feeRecipient, ...global.feeRecipients],\n options.feeRecipientIndex,\n 'Pump fee recipient',\n );\n const buybackFeeRecipient = pick(\n global.buybackFeeRecipients,\n options.buybackRecipientIndex,\n 'Pump buyback fee recipient',\n );\n const shared = {\n mint,\n user,\n tokenProgram,\n creator: curve.creator,\n feeRecipient,\n buybackFeeRecipient,\n };\n return {\n kind,\n program: PUMP_PROGRAM_ADDRESS,\n mint,\n tokenProgram,\n complete: curve.complete,\n creator: curve.creator,\n buyAccounts: pumpBuyAccounts(shared),\n sellAccounts: pumpSellAccounts(shared),\n quoteBuy: (tokens) =>\n curveBuyCost({\n global,\n bondingCurve: curve,\n feeConfig: pumpFeeConfig,\n mintSupply,\n tokens,\n quoteMint: WSOL_MINT,\n }),\n quoteSell: (tokens) =>\n curveSellQuote({ global, bondingCurve: curve, feeConfig: pumpFeeConfig, mintSupply, tokens }),\n };\n }\n\n if (!poolAccount) {\n throw new Error(\n `no canonical PumpSwap pool at ${poolAddress}. The coin has not graduated, or its pool is ` +\n 'not the canonical one.',\n );\n }\n if (!ammConfigAccount) throw new Error(`PumpSwap's GlobalConfig is missing at ${AMM_GLOBAL_CONFIG}`);\n\n const pool: AmmPoolState = decodeAmmPool(poolAccount.data);\n const ammConfig: AmmGlobalConfigState = decodeAmmGlobalConfig(ammConfigAccount.data);\n const ammFeeConfig: AmmRawFeeConfig | null = ammFeeAccount\n ? decodeAmmFeeConfig(ammFeeAccount.data)\n : null;\n\n const [baseVault, quoteVault] = await readAccounts(client.rpc, [\n pool.poolBaseTokenAccount,\n pool.poolQuoteTokenAccount,\n ]);\n if (!baseVault || !quoteVault) throw new Error('the PumpSwap pool has no reserve accounts');\n\n const baseReserve = tokenAccountAmount(baseVault.data);\n const quoteReserve = tokenAccountAmount(quoteVault.data);\n\n const protocolFeeRecipient = pick(\n ammConfig.protocolFeeRecipients,\n options.feeRecipientIndex,\n 'PumpSwap protocol fee recipient',\n );\n\n const shared = {\n pool: poolAddress,\n mint,\n user,\n tokenProgram,\n poolBaseTokenAccount: pool.poolBaseTokenAccount,\n poolQuoteTokenAccount: pool.poolQuoteTokenAccount,\n coinCreator: pool.coinCreator,\n protocolFeeRecipient,\n quoteMint: WSOL_MINT,\n quoteTokenProgram: TOKEN_PROGRAM_ADDRESS,\n };\n\n return {\n kind,\n program: PUMP_SWAP_PROGRAM_ADDRESS,\n mint,\n tokenProgram,\n complete: true,\n creator: curve?.creator ?? pool.coinCreator,\n buyAccounts: swapBuyAccounts(shared),\n sellAccounts: swapSellAccounts(shared),\n quoteBuy: (tokens) =>\n ammBuyCost({\n pool,\n globalConfig: ammConfig,\n feeConfig: ammFeeConfig,\n baseReserve,\n quoteReserve,\n baseMintSupply: mintSupply,\n tokens,\n }),\n quoteSell: (tokens) =>\n ammSellQuote({\n pool,\n globalConfig: ammConfig,\n feeConfig: ammFeeConfig,\n baseReserve,\n quoteReserve,\n baseMintSupply: mintSupply,\n tokens,\n }),\n };\n}\n\n/**\n * Lamports an exact-tokens-out buy of `tokens` costs right now, on whichever venue the coin trades.\n * Pass `pool.packTokens` for the pack price.\n *\n * One read and one number. Use `resolveVenue` when you also need the account list, which every\n * transaction builder does — 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 feeRecipientIndex: 0,\n buybackRecipientIndex: 0,\n });\n return venue.quoteBuy(tokens);\n}\n\n/**\n * Lamports an exact-tokens-out buy of `tokens` would cost on a curve that does not exist yet,\n * fees included. This is what the seed costs: `initialize_pool` buys it in the same transaction\n * that creates the coin, so the curve is Pump's default new curve at that moment.\n */\nexport async function newCurveBuyCost(client: GaboxClient, tokens: bigint): Promise<bigint> {\n const [globalAccount, feeConfigAccount] = await readAccounts(client.rpc, [PUMP_GLOBAL, PUMP_FEE_CONFIG]);\n if (!globalAccount) throw new Error(`Pump's Global account is missing at ${PUMP_GLOBAL}`);\n return curveBuyCost({\n global: decodePumpGlobal(globalAccount.data),\n bondingCurve: null,\n feeConfig: feeConfigAccount ? decodePumpFeeConfig(feeConfigAccount.data) : null,\n mintSupply: null,\n tokens,\n quoteMint: WSOL_MINT,\n });\n}\n\n/** Lamports 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 feeRecipientIndex: 0,\n buybackRecipientIndex: 0,\n });\n return venue.quoteSell(tokens);\n}\n\n/**\n * The user's WSOL associated token account. PumpSwap spends WSOL rather than native SOL, so this\n * account must exist and hold enough before a pack is bought on a graduated coin.\n */\nexport function wsolAccountFor(user: Address): Address {\n return ata(user, WSOL_MINT, TOKEN_PROGRAM_ADDRESS);\n}\n","/**\n * Pump's `create_v2`, built by hand.\n *\n * `@pump-fun/pump-sdk` has a `createV2Instruction`, but it returns a web3.js v1\n * `TransactionInstruction` built through Anchor. Converting that back into a kit instruction means\n * unpacking its account metas and re-deriving each role, which is more moving parts than encoding\n * six arguments. So the arguments are encoded here with kit codecs, and the account list still\n * comes from `accounts.ts`, which comes from the IDL.\n *\n * # The argument layout\n *\n * Borsh, in IDL order: three length-prefixed UTF-8 strings, a pubkey, a bool, and `OptionBool`.\n *\n * `OptionBool` is the one that catches people. It is **not** `Option<bool>`, which would be one or\n * two bytes depending on the tag. The IDL declares it as a struct with a single unnamed `bool`\n * field, so it is exactly one byte, always. `market.rs` hits the same thing on PumpSwap's buy and\n * says so in a comment.\n */\n\nimport {\n addEncoderSizePrefix,\n getAddressEncoder,\n getBooleanEncoder,\n getStructEncoder,\n getU32Encoder,\n getUtf8Encoder,\n type Address,\n type Instruction,\n type TransactionSigner,\n} from '@solana/kit';\n\nimport { PUMP_CREATE_TOKEN_PROGRAM_ADDRESS, PUMP_CREATE_V2, PUMP_PROGRAM_ADDRESS } from './abi';\nimport { pumpCreateV2Accounts } from './accounts';\n\nconst ARGS_ENCODER = getStructEncoder([\n ['name', addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],\n ['symbol', addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],\n ['uri', addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],\n ['creator', getAddressEncoder()],\n ['isMayhemMode', getBooleanEncoder()],\n // A one-field tuple struct, so one byte. Not an `Option<bool>`.\n ['isCashbackEnabled', getBooleanEncoder()],\n]);\n\nexport type PumpCreateV2Input = {\n /** The coin's mint. A brand-new keypair, and it signs. */\n mint: TransactionSigner;\n /** The wallet paying. `initialize_pool` requires this to be the same wallet as its creator. */\n user: TransactionSigner;\n name: string;\n symbol: string;\n /** The metadata URI. Pump stores it on the mint's Token-2022 metadata extension. */\n uri: string;\n /**\n * The address Pump records as the coin's creator and pays creator fees to. Defaults to `user`.\n * It does not have to be the payer, and gabox does not read it.\n */\n creator?: Address;\n /** Mayhem mode. Off for every gabox machine — the coin must behave like an ordinary Pump coin. */\n mayhemMode?: boolean;\n /** Cashback. Off, for the same reason. A cashback coin adds an account PumpSwap buys must carry. */\n cashback?: boolean;\n};\n\n/**\n * `create_v2`. Put it **before** `initialize_pool` in the transaction.\n *\n * `market::require_created_here` reads the Instructions sysvar and looks for this instruction by\n * discriminator, checking that account 0 is the mint and that account 5 — the `user` slot — is the\n * gabox creator and signs. The order matters for a second reason too: the mint account has to exist\n * and deserialize before `initialize_pool`'s own account validation runs.\n */\nexport function getPumpCreateV2Instruction(input: PumpCreateV2Input): Instruction {\n const {\n mint,\n user,\n name,\n symbol,\n uri,\n creator = user.address,\n mayhemMode = false,\n cashback = false,\n } = input;\n\n const metas = pumpCreateV2Accounts({\n mint: mint.address,\n user: user.address,\n tokenProgram: PUMP_CREATE_TOKEN_PROGRAM_ADDRESS,\n });\n\n // Two slots sign: the mint keypair and the payer. `accounts.ts` set the roles from the ABI, so\n // this only attaches the signers the transaction will need to the slots that already say signer.\n const signerFor = new Map<Address, TransactionSigner>([\n [mint.address, mint],\n [user.address, user],\n ]);\n const accounts = metas.map((meta) => {\n const signer = signerFor.get(meta.address);\n const isSigner = meta.role === 2 || meta.role === 3;\n return signer && isSigner ? { ...meta, signer } : meta;\n });\n\n const data = new Uint8Array([\n ...PUMP_CREATE_V2.discriminator,\n ...ARGS_ENCODER.encode({\n name,\n symbol,\n uri,\n creator,\n isMayhemMode: mayhemMode,\n isCashbackEnabled: cashback,\n }),\n ]);\n\n return { programAddress: PUMP_PROGRAM_ADDRESS, accounts, data } as Instruction;\n}\n","/**\n * A venue trade the caller sends on its own, outside a gabox instruction.\n *\n * `buy_pack`, `sell_tokens` and the legacy `sell_prize` take the venue's account list as\n * `remainingAccounts` and the program does the CPI. Standalone trades are used when funding with\n * SOL. A sale of a delivered prize goes through `sell_tokens` (see `tx/redeem.ts`) so that it pays\n * the protocol fee; `venueSellInstruction` stays for coins that have no pool.\n *\n * # The argument layout\n *\n * `market.rs` says it in one sentence: \"Every supported venue instruction starts with the same two\n * u64 args.\" A buy is `(amount_out, max_quote_in)` — the caller fixes the token count and the\n * venue decides the cost. PumpSwap's buy carries one extra byte, `track_volume`, which is an\n * `OptionBool`: a one-field tuple struct, so exactly one byte, never `Option<bool>`'s one-or-two.\n *\n * The account list and the discriminator both come from `abi.ts`, which codegen took from the two\n * official Pump IDLs. Nothing here retypes either.\n */\n\nimport { getU64Encoder, type AccountMeta, type Instruction, type TransactionSigner } from '@solana/kit';\n\nimport { PUMP_BUY, PUMP_SELL, SWAP_BUY, SWAP_SELL, type VenueInstructionAbi } from './abi';\nimport type { ResolvedVenue } from './venue';\n\nconst u64 = getU64Encoder();\n\n/** `track_volume` on PumpSwap's buy. Off: a donation is not a volume-accruing trade for the funder. */\nconst TRACK_VOLUME_OFF = 0;\n\nexport type VenueBuyInput = {\n /** The venue `resolveVenue` returned. Its `buyAccounts` list is used unchanged. */\n venue: ResolvedVenue;\n /** The wallet spending. Must be the `user` slot of `venue.buyAccounts`, and it signs. */\n user: TransactionSigner;\n /** Exact tokens to receive. The venue decides what that costs. */\n tokens: bigint;\n /** The buyer's slippage cap on that cost, in lamports (or WSOL, on PumpSwap). */\n maxQuoteIn: bigint;\n};\n\n/**\n * Buy tokens at the venue, as a standalone instruction.\n *\n * The signer is attached to the one slot the ABI marks as a signer, and only when its address\n * matches — the same rule `create.ts` follows. Passing a `user` that is not in the account list is\n * a mistake this catches here rather than on chain.\n */\nexport function venueBuyInstruction(input: VenueBuyInput): Instruction {\n const { venue, user, tokens, maxQuoteIn } = input;\n if (tokens <= 0n) throw new Error('tokens must be positive');\n if (maxQuoteIn <= 0n) throw new Error('maxQuoteIn must be positive');\n\n const abi: VenueInstructionAbi = venue.kind === 'pump' ? PUMP_BUY : SWAP_BUY;\n const accounts = attachSigner(venue.buyAccounts, user);\n\n const data = new Uint8Array([\n ...abi.discriminator,\n ...u64.encode(tokens),\n ...u64.encode(maxQuoteIn),\n ...(venue.kind === 'pumpswap' ? [TRACK_VOLUME_OFF] : []),\n ]);\n\n return { programAddress: venue.program, accounts, data } as Instruction;\n}\n\nexport type VenueSellInput = {\n /** The venue `resolveVenue` returned. Its `sellAccounts` list is used unchanged. */\n venue: ResolvedVenue;\n /** The wallet whose token ATA is being sold. */\n user: TransactionSigner;\n /** Exact base-token amount to sell. */\n amount: bigint;\n /** Floor on the venue's net SOL or WSOL output. */\n minQuoteOutput: bigint;\n};\n\n/** Sell tokens the wallet already holds, as a standalone venue instruction. */\nexport function venueSellInstruction(input: VenueSellInput): Instruction {\n const { venue, user, amount, minQuoteOutput } = input;\n if (amount <= 0n) throw new Error('amount must be positive');\n if (minQuoteOutput <= 0n) throw new Error('minQuoteOutput must be positive');\n\n const abi: VenueInstructionAbi = venue.kind === 'pump' ? PUMP_SELL : SWAP_SELL;\n return {\n programAddress: venue.program,\n accounts: attachSigner(venue.sellAccounts, user),\n data: new Uint8Array([\n ...abi.discriminator,\n ...u64.encode(amount),\n ...u64.encode(minQuoteOutput),\n ]),\n } as Instruction;\n}\n\n/** Give the signer to the slots 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 venue trade. Resolve the venue 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. `adapter.ts` is the only file in this SDK that imports `@solana/web3.js`\n * or Pump's packages. `accounts.ts` builds the ordered account lists. `venue.ts` reads the chain\n * and decides which venue a coin trades on. `create.ts` builds Pump's `create_v2`. `trade.ts` builds\n * a standalone venue buy, which only the SOL-paid donation flow needs.\n */\n\nexport * from './abi';\nexport * from './accounts';\nexport * from './create';\nexport * from './trade';\nexport * from './venue';\nexport {\n ammBuyCost,\n ammCanonicalPool,\n ammCoinCreatorVaultAta,\n ammCoinCreatorVaultAuthority,\n ammSellQuote,\n ammUserVolumeAccumulator,\n ata,\n curveBuyCost,\n curveSellQuote,\n decodeAmmFeeConfig,\n decodeAmmGlobalConfig,\n decodeAmmPool,\n decodeBondingCurve,\n decodeMintSupply,\n decodePumpFeeConfig,\n decodePumpGlobal,\n pumpBondingCurve,\n pumpCreatorVault,\n pumpMayhemState,\n pumpMayhemTokenVault,\n pumpSharingConfig,\n pumpUserVolumeAccumulator,\n AMM_EVENT_AUTHORITY,\n AMM_FEE_CONFIG,\n AMM_GLOBAL_CONFIG,\n AMM_GLOBAL_VOLUME_ACCUMULATOR,\n MAYHEM_GLOBAL_PARAMS,\n MAYHEM_SOL_VAULT,\n PUMP_EVENT_AUTHORITY,\n PUMP_FEE_CONFIG,\n PUMP_GLOBAL,\n PUMP_GLOBAL_VOLUME_ACCUMULATOR,\n PUMP_MINT_AUTHORITY,\n type AmmGlobalConfigState,\n type AmmPoolState,\n type AmmRawFeeConfig,\n type AmmRawGlobalConfig,\n type AmmRawPool,\n type PumpBondingCurveState,\n type PumpGlobalState,\n type PumpRaw,\n type PumpRawBondingCurve,\n type PumpRawFeeConfig,\n} from './adapter';\n"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAa,uBAAuB;AACpC,MAAa,4BAA4B;AACzC,MAAa,2BAA2B;AACxC,MAAa,yBAAyB;;AAEtC,MAAa,oCAAoC;AACjD,MAAa,mCAAmC;AAChD,MAAa,yBAAyB;;AAgBtC,MAAa,iBAAsC;CACjD,MAAM;CACN,eAAe,IAAI,WAAW;EAAC;EAAK;EAAK;EAAI;EAAK;EAAI;EAAK;EAAI;CAAG,CAAC;CACnE,UAAU;EACR;GAAE,MAAM;GAAQ,UAAU;GAAM,QAAQ;EAAK;EAC7C;GAAE,MAAM;GAAkB,UAAU;GAAO,QAAQ;EAAM;EACzD;GAAE,MAAM;GAAiB,UAAU;GAAM,QAAQ;EAAM;EACvD;GAAE,MAAM;GAA4B,UAAU;GAAM,QAAQ;EAAM;EAClE;GAAE,MAAM;GAAU,UAAU;GAAO,QAAQ;EAAM;EACjD;GAAE,MAAM;GAAQ,UAAU;G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