UNPKG

pumpdotfun-sdk-sp

Version:

A simple SDK for interacting with pumpdotfun

3,311 lines (3,306 loc) 83.6 kB
import { PublicKey, Transaction, ComputeBudgetProgram, SendTransactionError, TransactionMessage, VersionedTransaction } from '@solana/web3.js'; import { Program } from '@coral-xyz/anchor'; import { struct, u64, bool, publicKey } from '@coral-xyz/borsh'; import { getAssociatedTokenAddress, getAccount, createAssociatedTokenAccountInstruction } from '@solana/spl-token'; import { BN } from 'bn.js'; class GlobalAccount { discriminator; initialized = false; authority; feeRecipient; initialVirtualTokenReserves; initialVirtualSolReserves; initialRealTokenReserves; tokenTotalSupply; feeBasisPoints; constructor(discriminator, initialized, authority, feeRecipient, initialVirtualTokenReserves, initialVirtualSolReserves, initialRealTokenReserves, tokenTotalSupply, feeBasisPoints) { this.discriminator = discriminator; this.initialized = initialized; this.authority = authority; this.feeRecipient = feeRecipient; this.initialVirtualTokenReserves = initialVirtualTokenReserves; this.initialVirtualSolReserves = initialVirtualSolReserves; this.initialRealTokenReserves = initialRealTokenReserves; this.tokenTotalSupply = tokenTotalSupply; this.feeBasisPoints = feeBasisPoints; } getInitialBuyPrice(amount) { if (amount <= 0n) { return 0n; } let n = this.initialVirtualSolReserves * this.initialVirtualTokenReserves; let i = this.initialVirtualSolReserves + amount; let r = n / i + 1n; let s = this.initialVirtualTokenReserves - r; return s < this.initialRealTokenReserves ? s : this.initialRealTokenReserves; } static fromBuffer(buffer) { const structure = struct([ u64("discriminator"), bool("initialized"), publicKey("authority"), publicKey("feeRecipient"), u64("initialVirtualTokenReserves"), u64("initialVirtualSolReserves"), u64("initialRealTokenReserves"), u64("tokenTotalSupply"), u64("feeBasisPoints"), ]); let value = structure.decode(buffer); return new GlobalAccount(BigInt(value.discriminator), value.initialized, value.authority, value.feeRecipient, BigInt(value.initialVirtualTokenReserves), BigInt(value.initialVirtualSolReserves), BigInt(value.initialRealTokenReserves), BigInt(value.tokenTotalSupply), BigInt(value.feeBasisPoints)); } } function toCreateEvent(event) { return { name: event.name, symbol: event.symbol, uri: event.uri, mint: new PublicKey(event.mint), bondingCurve: new PublicKey(event.bondingCurve), user: new PublicKey(event.user), }; } function toCompleteEvent(event) { return { user: new PublicKey(event.user), mint: new PublicKey(event.mint), bondingCurve: new PublicKey(event.bondingCurve), timestamp: Number(event.timestamp), }; } function toTradeEvent(event) { return { mint: new PublicKey(event.mint), solAmount: BigInt(event.solAmount), tokenAmount: BigInt(event.tokenAmount), isBuy: event.isBuy, user: new PublicKey(event.user), timestamp: Number(event.timestamp), virtualSolReserves: BigInt(event.virtualSolReserves), virtualTokenReserves: BigInt(event.virtualTokenReserves), realSolReserves: BigInt(event.realSolReserves), realTokenReserves: BigInt(event.realTokenReserves), }; } function toSetParamsEvent(event) { return { feeRecipient: new PublicKey(event.feeRecipient), initialVirtualTokenReserves: BigInt(event.initialVirtualTokenReserves), initialVirtualSolReserves: BigInt(event.initialVirtualSolReserves), initialRealTokenReserves: BigInt(event.initialRealTokenReserves), tokenTotalSupply: BigInt(event.tokenTotalSupply), feeBasisPoints: BigInt(event.feeBasisPoints), }; } class BondingCurveAccount { discriminator; virtualTokenReserves; virtualSolReserves; realTokenReserves; realSolReserves; tokenTotalSupply; complete; constructor(discriminator, virtualTokenReserves, virtualSolReserves, realTokenReserves, realSolReserves, tokenTotalSupply, complete) { this.discriminator = discriminator; this.virtualTokenReserves = virtualTokenReserves; this.virtualSolReserves = virtualSolReserves; this.realTokenReserves = realTokenReserves; this.realSolReserves = realSolReserves; this.tokenTotalSupply = tokenTotalSupply; this.complete = complete; } getBuyPrice(amount) { if (this.complete) { throw new Error("Curve is complete"); } if (amount <= 0n) { return 0n; } // Calculate the product of virtual reserves let n = this.virtualSolReserves * this.virtualTokenReserves; // Calculate the new virtual sol reserves after the purchase let i = this.virtualSolReserves + amount; // Calculate the new virtual token reserves after the purchase let r = n / i + 1n; // Calculate the amount of tokens to be purchased let s = this.virtualTokenReserves - r; // Return the minimum of the calculated tokens and real token reserves return s < this.realTokenReserves ? s : this.realTokenReserves; } getSellPrice(amount, feeBasisPoints) { if (this.complete) { throw new Error("Curve is complete"); } if (amount <= 0n) { return 0n; } // Calculate the proportional amount of virtual sol reserves to be received let n = (amount * this.virtualSolReserves) / (this.virtualTokenReserves + amount); // Calculate the fee amount in the same units let a = (n * feeBasisPoints) / 10000n; // Return the net amount after deducting the fee return n - a; } getMarketCapSOL() { if (this.virtualTokenReserves === 0n) { return 0n; } return ((this.tokenTotalSupply * this.virtualSolReserves) / this.virtualTokenReserves); } getFinalMarketCapSOL(feeBasisPoints) { let totalSellValue = this.getBuyOutPrice(this.realTokenReserves, feeBasisPoints); let totalVirtualValue = this.virtualSolReserves + totalSellValue; let totalVirtualTokens = this.virtualTokenReserves - this.realTokenReserves; if (totalVirtualTokens === 0n) { return 0n; } return (this.tokenTotalSupply * totalVirtualValue) / totalVirtualTokens; } getBuyOutPrice(amount, feeBasisPoints) { let solTokens = amount < this.virtualTokenReserves ? this.virtualTokenReserves : amount; let totalSellValue = (solTokens * this.virtualSolReserves) / (this.virtualTokenReserves - solTokens) + 1n; let fee = (totalSellValue * feeBasisPoints) / 10000n; return totalSellValue + fee; } static fromBuffer(buffer) { const structure = struct([ u64("discriminator"), u64("virtualTokenReserves"), u64("virtualSolReserves"), u64("realTokenReserves"), u64("realSolReserves"), u64("tokenTotalSupply"), bool("complete"), ]); let value = structure.decode(buffer); return new BondingCurveAccount(BigInt(value.discriminator), BigInt(value.virtualTokenReserves), BigInt(value.virtualSolReserves), BigInt(value.realTokenReserves), BigInt(value.realSolReserves), BigInt(value.tokenTotalSupply), value.complete); } } const DEFAULT_COMMITMENT = "finalized"; const DEFAULT_FINALITY = "finalized"; const calculateWithSlippageBuy = (amount, basisPoints) => { return amount + (amount * basisPoints) / 10000n; }; const calculateWithSlippageSell = (amount, basisPoints) => { return amount - (amount * basisPoints) / 10000n; }; async function sendTx(connection, tx, payer, signers, priorityFees, commitment = DEFAULT_COMMITMENT, finality = DEFAULT_FINALITY) { let newTx = new Transaction(); if (priorityFees) { const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({ units: priorityFees.unitLimit, }); const addPriorityFee = ComputeBudgetProgram.setComputeUnitPrice({ microLamports: priorityFees.unitPrice, }); newTx.add(modifyComputeUnits); newTx.add(addPriorityFee); } newTx.add(tx); let versionedTx = await buildVersionedTx(connection, payer, newTx, commitment); versionedTx.sign(signers); try { const sig = await connection.sendTransaction(versionedTx, { skipPreflight: false, }); console.log("sig:", `https://solscan.io/tx/${sig}`); let txResult = await getTxDetails(connection, sig, commitment, finality); if (!txResult) { return { success: false, error: "Transaction failed", }; } return { success: true, signature: sig, results: txResult, }; } catch (e) { if (e instanceof SendTransactionError) { let ste = e; console.log("SendTransactionError" + await ste.getLogs(connection)); } else { console.error(e); } return { error: e, success: false, }; } } const buildVersionedTx = async (connection, payer, tx, commitment = DEFAULT_COMMITMENT) => { const blockHash = (await connection.getLatestBlockhash(commitment)) .blockhash; let messageV0 = new TransactionMessage({ payerKey: payer, recentBlockhash: blockHash, instructions: tx.instructions, }).compileToV0Message(); return new VersionedTransaction(messageV0); }; const getTxDetails = async (connection, sig, commitment = DEFAULT_COMMITMENT, finality = DEFAULT_FINALITY) => { const latestBlockHash = await connection.getLatestBlockhash(); await connection.confirmTransaction({ blockhash: latestBlockHash.blockhash, lastValidBlockHeight: latestBlockHash.lastValidBlockHeight, signature: sig, }, commitment); return connection.getTransaction(sig, { maxSupportedTransactionVersion: 0, commitment: finality, }); }; var address = "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"; var metadata = { name: "pump", version: "0.1.0", spec: "0.1.0", description: "Created with Anchor" }; var instructions = [ { name: "admin_set_creator", docs: [ "Allows Global::admin_set_creator_authority to override the bonding curve creator" ], discriminator: [ 69, 25, 171, 142, 57, 239, 13, 4 ], accounts: [ { name: "admin_set_creator_authority", signer: true, relations: [ "global" ] }, { name: "global", pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108 ] } ] } }, { name: "mint" }, { name: "bonding_curve", writable: true, pda: { seeds: [ { kind: "const", value: [ 98, 111, 110, 100, 105, 110, 103, 45, 99, 117, 114, 118, 101 ] }, { kind: "account", path: "mint" } ] } }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" } ], args: [ { name: "creator", type: "pubkey" } ] }, { name: "admin_set_idl_authority", discriminator: [ 8, 217, 96, 231, 144, 104, 192, 5 ], accounts: [ { name: "authority", signer: true, relations: [ "global" ] }, { name: "global", pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108 ] } ] } }, { name: "idl_account", writable: true }, { name: "system_program", address: "11111111111111111111111111111111" }, { name: "program_signer", pda: { seeds: [ ] } }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" } ], args: [ { name: "idl_authority", type: "pubkey" } ] }, { name: "admin_update_token_incentives", discriminator: [ 209, 11, 115, 87, 213, 23, 124, 204 ], accounts: [ { name: "authority", writable: true, signer: true, relations: [ "global" ] }, { name: "global", pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108 ] } ] } }, { name: "global_volume_accumulator", writable: true, pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108, 95, 118, 111, 108, 117, 109, 101, 95, 97, 99, 99, 117, 109, 117, 108, 97, 116, 111, 114 ] } ] } }, { name: "mint" }, { name: "global_incentive_token_account", writable: true, pda: { seeds: [ { kind: "account", path: "global_volume_accumulator" }, { kind: "account", path: "token_program" }, { kind: "account", path: "mint" } ], program: { kind: "const", value: [ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89 ] } } }, { name: "associated_token_program", address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" }, { name: "system_program", address: "11111111111111111111111111111111" }, { name: "token_program" }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" } ], args: [ { name: "start_time", type: "i64" }, { name: "end_time", type: "i64" }, { name: "seconds_in_a_day", type: "i64" }, { name: "day_number", type: "u64" }, { name: "pump_token_supply_per_day", type: "u64" } ] }, { name: "buy", docs: [ "Buys tokens from a bonding curve." ], discriminator: [ 102, 6, 61, 18, 1, 218, 235, 234 ], accounts: [ { name: "global", pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108 ] } ] } }, { name: "fee_recipient", writable: true }, { name: "mint" }, { name: "bonding_curve", writable: true, pda: { seeds: [ { kind: "const", value: [ 98, 111, 110, 100, 105, 110, 103, 45, 99, 117, 114, 118, 101 ] }, { kind: "account", path: "mint" } ] } }, { name: "associated_bonding_curve", writable: true, pda: { seeds: [ { kind: "account", path: "bonding_curve" }, { kind: "const", value: [ 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169 ] }, { kind: "account", path: "mint" } ], program: { kind: "const", value: [ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89 ] } } }, { name: "associated_user", writable: true }, { name: "user", writable: true, signer: true }, { name: "system_program", address: "11111111111111111111111111111111" }, { name: "token_program", address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" }, { name: "creator_vault", writable: true, pda: { seeds: [ { kind: "const", value: [ 99, 114, 101, 97, 116, 111, 114, 45, 118, 97, 117, 108, 116 ] }, { kind: "account", path: "bonding_curve.creator", account: "BondingCurve" } ] } }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" }, { name: "global_volume_accumulator", writable: true, pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108, 95, 118, 111, 108, 117, 109, 101, 95, 97, 99, 99, 117, 109, 117, 108, 97, 116, 111, 114 ] } ] } }, { name: "user_volume_accumulator", writable: true, pda: { seeds: [ { kind: "const", value: [ 117, 115, 101, 114, 95, 118, 111, 108, 117, 109, 101, 95, 97, 99, 99, 117, 109, 117, 108, 97, 116, 111, 114 ] }, { kind: "account", path: "user" } ] } } ], args: [ { name: "amount", type: "u64" }, { name: "max_sol_cost", type: "u64" }, { name: "track_volume", type: { defined: { name: "OptionBool" } } } ] }, { name: "claim_token_incentives", discriminator: [ 16, 4, 71, 28, 204, 1, 40, 27 ], accounts: [ { name: "user" }, { name: "user_ata", writable: true, pda: { seeds: [ { kind: "account", path: "user" }, { kind: "account", path: "token_program" }, { kind: "account", path: "mint" } ], program: { kind: "const", value: [ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89 ] } } }, { name: "global_volume_accumulator", pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108, 95, 118, 111, 108, 117, 109, 101, 95, 97, 99, 99, 117, 109, 117, 108, 97, 116, 111, 114 ] } ] } }, { name: "global_incentive_token_account", writable: true, pda: { seeds: [ { kind: "account", path: "global_volume_accumulator" }, { kind: "account", path: "token_program" }, { kind: "account", path: "mint" } ], program: { kind: "const", value: [ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89 ] } } }, { name: "user_volume_accumulator", writable: true, pda: { seeds: [ { kind: "const", value: [ 117, 115, 101, 114, 95, 118, 111, 108, 117, 109, 101, 95, 97, 99, 99, 117, 109, 117, 108, 97, 116, 111, 114 ] }, { kind: "account", path: "user" } ] } }, { name: "mint", relations: [ "global_volume_accumulator" ] }, { name: "token_program" }, { name: "system_program", address: "11111111111111111111111111111111" }, { name: "associated_token_program", address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" }, { name: "payer", writable: true, signer: true } ], args: [ ] }, { name: "close_user_volume_accumulator", discriminator: [ 249, 69, 164, 218, 150, 103, 84, 138 ], accounts: [ { name: "user", writable: true, signer: true }, { name: "user_volume_accumulator", writable: true, pda: { seeds: [ { kind: "const", value: [ 117, 115, 101, 114, 95, 118, 111, 108, 117, 109, 101, 95, 97, 99, 99, 117, 109, 117, 108, 97, 116, 111, 114 ] }, { kind: "account", path: "user" } ] } }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" } ], args: [ ] }, { name: "collect_creator_fee", docs: [ "Collects creator_fee from creator_vault to the coin creator account" ], discriminator: [ 20, 22, 86, 123, 198, 28, 219, 132 ], accounts: [ { name: "creator", writable: true }, { name: "creator_vault", writable: true, pda: { seeds: [ { kind: "const", value: [ 99, 114, 101, 97, 116, 111, 114, 45, 118, 97, 117, 108, 116 ] }, { kind: "account", path: "creator" } ] } }, { name: "system_program", address: "11111111111111111111111111111111" }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" } ], args: [ ] }, { name: "create", docs: [ "Creates a new coin and bonding curve." ], discriminator: [ 24, 30, 200, 40, 5, 28, 7, 119 ], accounts: [ { name: "mint", writable: true, signer: true }, { name: "mint_authority", pda: { seeds: [ { kind: "const", value: [ 109, 105, 110, 116, 45, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "bonding_curve", writable: true, pda: { seeds: [ { kind: "const", value: [ 98, 111, 110, 100, 105, 110, 103, 45, 99, 117, 114, 118, 101 ] }, { kind: "account", path: "mint" } ] } }, { name: "associated_bonding_curve", writable: true, pda: { seeds: [ { kind: "account", path: "bonding_curve" }, { kind: "const", value: [ 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169 ] }, { kind: "account", path: "mint" } ], program: { kind: "const", value: [ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89 ] } } }, { name: "global", pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108 ] } ] } }, { name: "mpl_token_metadata", address: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" }, { name: "metadata", writable: true, pda: { seeds: [ { kind: "const", value: [ 109, 101, 116, 97, 100, 97, 116, 97 ] }, { kind: "const", value: [ 11, 112, 101, 177, 227, 209, 124, 69, 56, 157, 82, 127, 107, 4, 195, 205, 88, 184, 108, 115, 26, 160, 253, 181, 73, 182, 209, 188, 3, 248, 41, 70 ] }, { kind: "account", path: "mint" } ], program: { kind: "account", path: "mpl_token_metadata" } } }, { name: "user", writable: true, signer: true }, { name: "system_program", address: "11111111111111111111111111111111" }, { name: "token_program", address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" }, { name: "associated_token_program", address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" }, { name: "rent", address: "SysvarRent111111111111111111111111111111111" }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" } ], args: [ { name: "name", type: "string" }, { name: "symbol", type: "string" }, { name: "uri", type: "string" }, { name: "creator", type: "pubkey" } ] }, { name: "extend_account", docs: [ "Extends the size of program-owned accounts" ], discriminator: [ 234, 102, 194, 203, 150, 72, 62, 229 ], accounts: [ { name: "account", writable: true }, { name: "user", signer: true }, { name: "system_program", address: "11111111111111111111111111111111" }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" } ], args: [ ] }, { name: "init_user_volume_accumulator", discriminator: [ 94, 6, 202, 115, 255, 96, 232, 183 ], accounts: [ { name: "payer", writable: true, signer: true }, { name: "user" }, { name: "user_volume_accumulator", writable: true, pda: { seeds: [ { kind: "const", value: [ 117, 115, 101, 114, 95, 118, 111, 108, 117, 109, 101, 95, 97, 99, 99, 117, 109, 117, 108, 97, 116, 111, 114 ] }, { kind: "account", path: "user" } ] } }, { name: "system_program", address: "11111111111111111111111111111111" }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" } ], args: [ ] }, { name: "initialize", docs: [ "Creates the global state." ], discriminator: [ 175, 175, 109, 31, 13, 152, 155, 237 ], accounts: [ { name: "global", writable: true, pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108 ] } ] } }, { name: "user", writable: true, signer: true }, { name: "system_program", address: "11111111111111111111111111111111" } ], args: [ ] }, { name: "migrate", docs: [ "Migrates liquidity to pump_amm if the bonding curve is complete" ], discriminator: [ 155, 234, 231, 146, 236, 158, 162, 30 ], accounts: [ { name: "global", pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108 ] } ] } }, { name: "withdraw_authority", writable: true, relations: [ "global" ] }, { name: "mint" }, { name: "bonding_curve", writable: true, pda: { seeds: [ { kind: "const", value: [ 98, 111, 110, 100, 105, 110, 103, 45, 99, 117, 114, 118, 101 ] }, { kind: "account", path: "mint" } ] } }, { name: "associated_bonding_curve", writable: true, pda: { seeds: [ { kind: "account", path: "bonding_curve" }, { kind: "const", value: [ 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169 ] }, { kind: "account", path: "mint" } ], program: { kind: "const", value: [ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89 ] } } }, { name: "user", signer: true }, { name: "system_program", address: "11111111111111111111111111111111" }, { name: "token_program", address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" }, { name: "pump_amm", address: "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA" }, { name: "pool", writable: true, pda: { seeds: [ { kind: "const", value: [ 112, 111, 111, 108 ] }, { kind: "const", value: [ 0, 0 ] }, { kind: "account", path: "pool_authority" }, { kind: "account", path: "mint" }, { kind: "account", path: "wsol_mint" } ], program: { kind: "account", path: "pump_amm" } } }, { name: "pool_authority", writable: true, pda: { seeds: [ { kind: "const", value: [ 112, 111, 111, 108, 45, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] }, { kind: "account", path: "mint" } ] } }, { name: "pool_authority_mint_account", writable: true, pda: { seeds: [ { kind: "account", path: "pool_authority" }, { kind: "account", path: "token_program" }, { kind: "account", path: "mint" } ], program: { kind: "account", path: "associated_token_program" } } }, { name: "pool_authority_wsol_account", writable: true, pda: { seeds: [ { kind: "account", path: "pool_authority" }, { kind: "account", path: "token_program" }, { kind: "account", path: "wsol_mint" } ], program: { kind: "account", path: "associated_token_program" } } }, { name: "amm_global_config", pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108, 95, 99, 111, 110, 102, 105, 103 ] } ], program: { kind: "account", path: "pump_amm" } } }, { name: "wsol_mint", address: "So11111111111111111111111111111111111111112" }, { name: "lp_mint", writable: true, pda: { seeds: [ { kind: "const", value: [ 112, 111, 111, 108, 95, 108, 112, 95, 109, 105, 110, 116 ] }, { kind: "account", path: "pool" } ], program: { kind: "account", path: "pump_amm" } } }, { name: "user_pool_token_account", writable: true, pda: { seeds: [ { kind: "account", path: "pool_authority" }, { kind: "account", path: "token_2022_program" }, { kind: "account", path: "lp_mint" } ], program: { kind: "account", path: "associated_token_program" } } }, { name: "pool_base_token_account", writable: true, pda: { seeds: [ { kind: "account", path: "pool" }, { kind: "account", path: "token_program" }, { kind: "account", path: "mint" } ], program: { kind: "account", path: "associated_token_program" } } }, { name: "pool_quote_token_account", writable: true, pda: { seeds: [ { kind: "account", path: "pool" }, { kind: "account", path: "token_program" }, { kind: "account", path: "wsol_mint" } ], program: { kind: "account", path: "associated_token_program" } } }, { name: "token_2022_program", address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" }, { name: "associated_token_program", address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" }, { name: "pump_amm_event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ], program: { kind: "account", path: "pump_amm" } } }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" } ], args: [ ] }, { name: "sell", docs: [ "Sells tokens into a bonding curve." ], discriminator: [ 51, 230, 133, 164, 1, 127, 131, 173 ], accounts: [ { name: "global", pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108 ] } ] } }, { name: "fee_recipient", writable: true }, { name: "mint" }, { name: "bonding_curve", writable: true, pda: { seeds: [ { kind: "const", value: [ 98, 111, 110, 100, 105, 110, 103, 45, 99, 117, 114, 118, 101 ] }, { kind: "account", path: "mint" } ] } }, { name: "associated_bonding_curve", writable: true, pda: { seeds: [ { kind: "account", path: "bonding_curve" }, { kind: "const", value: [ 6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169 ] }, { kind: "account", path: "mint" } ], program: { kind: "const", value: [ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89 ] } } }, { name: "associated_user", writable: true }, { name: "user", writable: true, signer: true }, { name: "system_program", address: "11111111111111111111111111111111" }, { name: "creator_vault", writable: true, pda: { seeds: [ { kind: "const", value: [ 99, 114, 101, 97, 116, 111, 114, 45, 118, 97, 117, 108, 116 ] }, { kind: "account", path: "bonding_curve.creator", account: "BondingCurve" } ] } }, { name: "token_program", address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" } ], args: [ { name: "amount", type: "u64" }, { name: "min_sol_output", type: "u64" } ] }, { name: "set_creator", docs: [ "Allows Global::set_creator_authority to set the bonding curve creator from Metaplex metadata or input argument" ], discriminator: [ 254, 148, 255, 112, 207, 142, 170, 165 ], accounts: [ { name: "set_creator_authority", signer: true, relations: [ "global" ] }, { name: "global", pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108 ] } ] } }, { name: "mint" }, { name: "metadata", pda: { seeds: [ { kind: "const", value: [ 109, 101, 116, 97, 100, 97, 116, 97 ] }, { kind: "const", value: [ 11, 112, 101, 177, 227, 209, 124, 69, 56, 157, 82, 127, 107, 4, 195, 205, 88, 184, 108, 115, 26, 160, 253, 181, 73, 182, 209, 188, 3, 248, 41, 70 ] }, { kind: "account", path: "mint" } ], program: { kind: "const", value: [ 11, 112, 101, 177, 227, 209, 124, 69, 56, 157, 82, 127, 107, 4, 195, 205, 88, 184, 108, 115, 26, 160, 253, 181, 73, 182, 209, 188, 3, 248, 41, 70 ] } } }, { name: "bonding_curve", writable: true, pda: { seeds: [ { kind: "const", value: [ 98, 111, 110, 100, 105, 110, 103, 45, 99, 117, 114, 118, 101 ] }, { kind: "account", path: "mint" } ] } }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" } ], args: [ { name: "creator", type: "pubkey" } ] }, { name: "set_metaplex_creator", docs: [ "Syncs the bonding curve creator with the Metaplex metadata creator if it exists" ], discriminator: [ 138, 96, 174, 217, 48, 85, 197, 246 ], accounts: [ { name: "mint" }, { name: "metadata", pda: { seeds: [ { kind: "const", value: [ 109, 101, 116, 97, 100, 97, 116, 97 ] }, { kind: "const", value: [ 11, 112, 101, 177, 227, 209, 124, 69, 56, 157, 82, 127, 107, 4, 195, 205, 88, 184, 108, 115, 26, 160, 253, 181, 73, 182, 209, 188, 3, 248, 41, 70 ] }, { kind: "account", path: "mint" } ], program: { kind: "const", value: [ 11, 112, 101, 177, 227, 209, 124, 69, 56, 157, 82, 127, 107, 4, 195, 205, 88, 184, 108, 115, 26, 160, 253, 181, 73, 182, 209, 188, 3, 248, 41, 70 ] } } }, { name: "bonding_curve", writable: true, pda: { seeds: [ { kind: "const", value: [ 98, 111, 110, 100, 105, 110, 103, 45, 99, 117, 114, 118, 101 ] }, { kind: "account", path: "mint" } ] } }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" } ], args: [ ] }, { name: "set_params", docs: [ "Sets the global state parameters." ], discriminator: [ 27, 234, 178, 52, 147, 2, 187, 141 ], accounts: [ { name: "global", writable: true, pda: { seeds: [ { kind: "const", value: [ 103, 108, 111, 98, 97, 108 ] } ] } }, { name: "authority", writable: true, signer: true, relations: [ "global" ] }, { name: "event_authority", pda: { seeds: [ { kind: "const", value: [ 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121 ] } ] } }, { name: "program" } ], args: [ { name: "initial_virtual_token_reserves", type: "u64" }, { name: "initial_virtual_sol_reserves", type: "u64" }, { name: "initial_real_token_reserves", type: "u64" }, { name: "token_total_supply", type: "u64" }, { name: "fee_basis_points", type: "u64" }, { name: "withdraw_authority", type: "pubkey" }, { name: "enable_migrate", type: "bool" }, { name: "pool_migration_fee", type: "u64" }, { name: "creator_fee_basis_points", type: "u64" }, { name: "set_creator_authority", type: "pubkey" }, { name: "admin_set_creator_authority", type: "pubkey" } ] }, { name: "sync_user_volume_accumulator", discriminator: [ 86, 31, 192, 87, 163, 87, 79, 238 ], acco