{"version":3,"file":"TradeModule.cjs","sources":["../../../../src/modules/TradeModule.ts"],"sourcesContent":["import BN from \"bn.js\";\r\nimport { getAssociatedTokenAddress } from \"@solana/spl-token\";\r\nimport {\r\n  Keypair,\r\n  Commitment,\r\n  Finality,\r\n  Transaction,\r\n  PublicKey,\r\n} from \"@solana/web3.js\";\r\nimport { GlobalAccount } from \"../globalAccount.js\";\r\n\r\nimport { DEFAULT_COMMITMENT, DEFAULT_FINALITY } from \"../pumpFun.consts.js\";\r\nimport {\r\n  CreateTokenMetadata,\r\n  PriorityFee,\r\n  TransactionResult,\r\n} from \"../pumpFun.types.js\";\r\nimport { PumpFunSDK } from \"../PumpFunSDK.js\";\r\nimport {\r\n  calculateWithSlippageBuy,\r\n  calculateWithSlippageSell,\r\n} from \"../slippage.js\";\r\nimport { sendTx } from \"../tx.js\";\r\n\r\nexport class TradeModule {\r\n  constructor(private sdk: PumpFunSDK) {}\r\n\r\n  async createAndBuy(\r\n    creator: Keypair,\r\n    mint: Keypair,\r\n    metadata: CreateTokenMetadata,\r\n    buyAmountSol: bigint,\r\n    slippageBasisPoints: bigint = 500n,\r\n    priorityFees?: PriorityFee,\r\n    commitment: Commitment = DEFAULT_COMMITMENT,\r\n    finality: Finality = DEFAULT_FINALITY\r\n  ): Promise<TransactionResult> {\r\n    const tokenMetadata = await this.sdk.token.createTokenMetadata(metadata);\r\n\r\n    const createIx = await this.getCreateInstructions(\r\n      creator.publicKey,\r\n      metadata.name,\r\n      metadata.symbol,\r\n      tokenMetadata.metadataUri,\r\n      mint\r\n    );\r\n\r\n    const transaction = new Transaction().add(createIx);\r\n\r\n    if (buyAmountSol > 0n) {\r\n      const globalAccount = await this.sdk.token.getGlobalAccount(commitment);\r\n      const buyAmount = globalAccount.getInitialBuyPrice(buyAmountSol);\r\n      const buyAmountWithSlippage = calculateWithSlippageBuy(\r\n        buyAmountSol,\r\n        slippageBasisPoints\r\n      );\r\n\r\n      await this.buildBuyIx(\r\n        creator.publicKey,\r\n        mint.publicKey,\r\n        buyAmount,\r\n        buyAmountWithSlippage,\r\n        transaction,\r\n        commitment,\r\n        true\r\n      );\r\n    }\r\n\r\n    return await sendTx(\r\n      this.sdk.connection,\r\n      transaction,\r\n      creator.publicKey,\r\n      [creator, mint],\r\n      priorityFees,\r\n      commitment,\r\n      finality\r\n    );\r\n  }\r\n\r\n  async buy(\r\n    buyer: Keypair,\r\n    mint: PublicKey,\r\n    buyAmountSol: bigint,\r\n    slippageBasisPoints: bigint = 500n,\r\n    priorityFees?: PriorityFee,\r\n    commitment: Commitment = DEFAULT_COMMITMENT,\r\n    finality: Finality = DEFAULT_FINALITY\r\n  ): Promise<TransactionResult> {\r\n    const bondingAccount = await this.sdk.token.getBondingCurveAccount(\r\n      mint,\r\n      commitment\r\n    );\r\n    if (!bondingAccount) {\r\n      throw new Error(`Bonding curve account not found: ${mint.toBase58()}`);\r\n    }\r\n\r\n    const buyAmount = bondingAccount.getBuyPrice(buyAmountSol);\r\n    const buyAmountWithSlippage = calculateWithSlippageBuy(\r\n      buyAmountSol,\r\n      slippageBasisPoints\r\n    );\r\n\r\n    const transaction = new Transaction();\r\n    await this.buildBuyIx(\r\n      buyer.publicKey,\r\n      mint,\r\n      buyAmount,\r\n      buyAmountWithSlippage,\r\n      transaction,\r\n      commitment,\r\n      false\r\n    );\r\n\r\n    return await sendTx(\r\n      this.sdk.connection,\r\n      transaction,\r\n      buyer.publicKey,\r\n      [buyer],\r\n      priorityFees,\r\n      commitment,\r\n      finality\r\n    );\r\n  }\r\n\r\n  async getBuyInstructionsBySolAmount(\r\n    buyer: PublicKey,\r\n    mint: PublicKey,\r\n    buyAmountSol: bigint,\r\n    slippageBasisPoints: bigint = 500n,\r\n    commitment: Commitment = DEFAULT_COMMITMENT\r\n  ): Promise<Transaction> {\r\n    const bondingCurveAccount = await this.sdk.token.getBondingCurveAccount(\r\n      mint,\r\n      commitment\r\n    );\r\n    if (!bondingCurveAccount) {\r\n      throw new Error(`Bonding curve account not found: ${mint.toBase58()}`);\r\n    }\r\n\r\n    const buyAmount = bondingCurveAccount.getBuyPrice(buyAmountSol);\r\n    const buyAmountWithSlippage = calculateWithSlippageBuy(\r\n      buyAmountSol,\r\n      slippageBasisPoints\r\n    );\r\n\r\n    const transaction = new Transaction();\r\n    await this.buildBuyIx(\r\n      buyer,\r\n      mint,\r\n      buyAmount,\r\n      buyAmountWithSlippage,\r\n      transaction,\r\n      commitment,\r\n      false\r\n    );\r\n\r\n    return transaction;\r\n  }\r\n\r\n  async buildBuyIx(\r\n    buyer: PublicKey,\r\n    mint: PublicKey,\r\n    amount: bigint,\r\n    maxSolCost: bigint,\r\n    tx: Transaction,\r\n    commitment: Commitment,\r\n    shouldUseBuyerAsBonding: boolean\r\n  ): Promise<void> {\r\n    const bondingCurve = this.sdk.pda.getBondingCurvePDA(mint);\r\n    const associatedBonding = await getAssociatedTokenAddress(\r\n      mint,\r\n      bondingCurve,\r\n      true\r\n    );\r\n\r\n    const associatedUser =\r\n      await this.sdk.token.createAssociatedTokenAccountIfNeeded(\r\n        buyer,\r\n        buyer,\r\n        mint,\r\n        tx,\r\n        commitment\r\n      );\r\n\r\n    const globalPda = this.sdk.pda.getGlobalAccountPda();\r\n    const globalAccBuf = await this.sdk.connection.getAccountInfo(\r\n      globalPda,\r\n      commitment\r\n    );\r\n    const feeRecipient = GlobalAccount.fromBuffer(\r\n      globalAccBuf!.data\r\n    ).feeRecipient;\r\n\r\n    const bondingCreator = shouldUseBuyerAsBonding\r\n      ? this.sdk.pda.getCreatorVaultPda(buyer)\r\n      : await this.sdk.token.getBondingCurveCreator(bondingCurve, commitment);\r\n    const creatorVault = shouldUseBuyerAsBonding\r\n      ? bondingCreator\r\n      : this.sdk.pda.getCreatorVaultPda(bondingCreator);\r\n\r\n    const eventAuthority = this.sdk.pda.getEventAuthorityPda();\r\n\r\n    const ix = await this.sdk.program.methods\r\n      .buy(new BN(amount.toString()), new BN(maxSolCost.toString()))\r\n      .accounts({\r\n        global: globalPda,\r\n        feeRecipient,\r\n        mint,\r\n        bondingCurve,\r\n        associatedBondingCurve: associatedBonding,\r\n        associatedUser,\r\n        user: buyer,\r\n        creatorVault,\r\n        eventAuthority,\r\n        globalVolumeAccumulator: this.sdk.pda.getGlobalVolumeAccumulatorPda(),\r\n        userVolumeAccumulator: this.sdk.pda.getUserVolumeAccumulatorPda(buyer),\r\n      })\r\n      .instruction();\r\n\r\n    tx.add(ix);\r\n  }\r\n\r\n  //create token instructions\r\n  async getCreateInstructions(\r\n    creator: PublicKey,\r\n    name: string,\r\n    symbol: string,\r\n    uri: string,\r\n    mint: Keypair\r\n  ): Promise<Transaction> {\r\n    const mintAuthority = this.sdk.pda.getMintAuthorityPDA();\r\n    const bondingCurve = this.sdk.pda.getBondingCurvePDA(mint.publicKey);\r\n    const associatedBonding = await getAssociatedTokenAddress(\r\n      mint.publicKey,\r\n      bondingCurve,\r\n      true\r\n    );\r\n    const global = this.sdk.pda.getGlobalAccountPda();\r\n    const metadata = this.sdk.pda.getMetadataPDA(mint.publicKey);\r\n    const eventAuthority = this.sdk.pda.getEventAuthorityPda();\r\n\r\n    const ix = await this.sdk.program.methods\r\n      .create(name, symbol, uri, creator)\r\n      .accounts({\r\n        mint: mint.publicKey,\r\n        mintAuthority,\r\n        bondingCurve,\r\n        associatedBondingCurve: associatedBonding,\r\n        global,\r\n        metadata,\r\n        user: creator,\r\n        eventAuthority,\r\n      })\r\n      .instruction();\r\n\r\n    return new Transaction().add(ix);\r\n  }\r\n\r\n  async buildSellIx(\r\n    seller: PublicKey,\r\n    mint: PublicKey,\r\n    tokenAmount: bigint,\r\n    minSolOutput: bigint,\r\n    tx: Transaction,\r\n    commitment: Commitment\r\n  ): Promise<void> {\r\n    const bondingCurve = this.sdk.pda.getBondingCurvePDA(mint);\r\n    const associatedBonding = await getAssociatedTokenAddress(\r\n      mint,\r\n      bondingCurve,\r\n      true\r\n    );\r\n\r\n    const associatedUser =\r\n      await this.sdk.token.createAssociatedTokenAccountIfNeeded(\r\n        seller,\r\n        seller,\r\n        mint,\r\n        tx,\r\n        commitment\r\n      );\r\n\r\n    const globalPda = this.sdk.pda.getGlobalAccountPda();\r\n    const globalBuf = await this.sdk.connection.getAccountInfo(\r\n      globalPda,\r\n      commitment\r\n    );\r\n    const feeRecipient = GlobalAccount.fromBuffer(globalBuf!.data).feeRecipient;\r\n\r\n    const bondingCreator = await this.sdk.token.getBondingCurveCreator(\r\n      bondingCurve,\r\n      commitment\r\n    );\r\n    const creatorVault = this.sdk.pda.getCreatorVaultPda(bondingCreator);\r\n\r\n    const eventAuthority = this.sdk.pda.getEventAuthorityPda();\r\n\r\n    const ix = await this.sdk.program.methods\r\n      .sell(new BN(tokenAmount.toString()), new BN(minSolOutput.toString()))\r\n      .accounts({\r\n        global: globalPda,\r\n        feeRecipient,\r\n        mint,\r\n        bondingCurve,\r\n        associatedBondingCurve: associatedBonding,\r\n        associatedUser,\r\n        user: seller,\r\n        creatorVault,\r\n        eventAuthority,\r\n      })\r\n      .instruction();\r\n\r\n    tx.add(ix);\r\n  }\r\n\r\n  async sell(\r\n    seller: Keypair,\r\n    mint: PublicKey,\r\n    sellTokenAmount: bigint,\r\n    slippageBasisPoints: bigint = 500n,\r\n    priorityFees?: PriorityFee,\r\n    commitment: Commitment = DEFAULT_COMMITMENT,\r\n    finality: Finality = DEFAULT_FINALITY\r\n  ): Promise<TransactionResult> {\r\n    const bondingAccount = await this.sdk.token.getBondingCurveAccount(\r\n      mint,\r\n      commitment\r\n    );\r\n    if (!bondingAccount)\r\n      throw new Error(`Bonding curve account not found: ${mint.toBase58()}`);\r\n\r\n    const globalAccount = await this.sdk.token.getGlobalAccount(commitment);\r\n\r\n    const minSolOutput = bondingAccount.getSellPrice(\r\n      sellTokenAmount,\r\n      globalAccount.feeBasisPoints\r\n    );\r\n    let sellAmountWithSlippage = calculateWithSlippageSell(\r\n      minSolOutput,\r\n      slippageBasisPoints\r\n    );\r\n    if (sellAmountWithSlippage < 1n) sellAmountWithSlippage = 1n;\r\n\r\n    const transaction = new Transaction();\r\n    await this.buildSellIx(\r\n      seller.publicKey,\r\n      mint,\r\n      sellTokenAmount,\r\n      sellAmountWithSlippage,\r\n      transaction,\r\n      commitment\r\n    );\r\n\r\n    return await sendTx(\r\n      this.sdk.connection,\r\n      transaction,\r\n      seller.publicKey,\r\n      [seller],\r\n      priorityFees,\r\n      commitment,\r\n      finality\r\n    );\r\n  }\r\n\r\n  async getSellInstructionsByTokenAmount(\r\n    seller: PublicKey,\r\n    mint: PublicKey,\r\n    sellTokenAmount: bigint,\r\n    slippageBasisPoints: bigint = 500n,\r\n    commitment: Commitment = DEFAULT_COMMITMENT\r\n  ): Promise<Transaction> {\r\n    const bondingAccount = await this.sdk.token.getBondingCurveAccount(\r\n      mint,\r\n      commitment\r\n    );\r\n    if (!bondingAccount)\r\n      throw new Error(`Bonding curve account not found: ${mint.toBase58()}`);\r\n\r\n    const globalAccount = await this.sdk.token.getGlobalAccount(commitment);\r\n    const minSolOutput = bondingAccount.getSellPrice(\r\n      sellTokenAmount,\r\n      globalAccount.feeBasisPoints\r\n    );\r\n    let sellAmountWithSlippage = calculateWithSlippageSell(\r\n      minSolOutput,\r\n      slippageBasisPoints\r\n    );\r\n    if (sellAmountWithSlippage < 1n) sellAmountWithSlippage = 1n;\r\n\r\n    const transaction = new Transaction();\r\n    await this.buildSellIx(\r\n      seller,\r\n      mint,\r\n      sellTokenAmount,\r\n      sellAmountWithSlippage,\r\n      transaction,\r\n      commitment\r\n    );\r\n    return transaction;\r\n  }\r\n}\r\n"],"names":["DEFAULT_COMMITMENT","DEFAULT_FINALITY","Transaction","calculateWithSlippageBuy","sendTx","getAssociatedTokenAddress","GlobalAccount","BN","calculateWithSlippageSell"],"mappings":";;;;;;;;;;MAwBa,WAAW,CAAA;AACF,IAAA,GAAA;AAApB,IAAA,WAAA,CAAoB,GAAe,EAAA;QAAf,IAAA,CAAA,GAAG,GAAH,GAAG;;IAEvB,MAAM,YAAY,CAChB,OAAgB,EAChB,IAA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