Skip to content

bonding curve not found #1

@nebin110

Description

@nebin110

Hello everyone,
i would like to highlight a little problem about the BUY function. First of all you have done a great work so many thanks for your open source porject with so many functionalities.
I got a specific problem related with new tokens. In particular, when you try to buy a new created token (for example after 1 second) using your buy function. Let me show the code i'm using (very similar to original one). The buy function is the called by buy.js that you already provide.

/**
 * Buys tokens from the bonding curve.
 * @param {string} mintPubKey - The public key of the token mint.
 * @param {number} solPerOrder - The amount of SOL to spend per order.
 * @returns {Promise<void>} - A promise that resolves when the buy operation is complete.
 */
async function buy(mintPubKey, solPerOrder) {
  const provider = new AnchorProvider(connection, wallet, {
    commitment: "finalized",
  });

  const sdk = new PumpFunSDK(provider);

  // Numero massimo di tentativi
  const maxRetries = 20;
  let bondingCurveAccount = null;

  for (let attempt = 1; attempt <= maxRetries; attempt++) {
    bondingCurveAccount = await sdk.getBondingCurveAccount(mintPubKey);

    if (bondingCurveAccount) {
      const bondingCurveAddress = bondingCurveAccount.toBase58
        ? bondingCurveAccount.toBase58()
        : bondingCurveAccount; // Adatta in base al tipo di dati

      console.log("Bonding curve account trovata:", bondingCurveAddress);

      // Procedi con l'acquisto
      let buyResults = await sdk.buy(
        wallet,
        mintPubKey,
        BigInt(solPerOrder * LAMPORTS_PER_SOL),
        SLIPPAGE_BASIS_POINTS,
        {
          unitLimit: 250000,
          unitPrice: 250000,
        }
      );

      if (buyResults.success) {
        await printSPLBalance(connection, mintPubKey, wallet.publicKey);
        console.log("Bonding curve after buy:", bondingCurveAccount);
      } else {
        console.log("Buy failed");
      }
      return; // Esci dalla funzione se l'acquisto è stato completato
    } else {
      console.log("❌ Tentativo ${attempt}: Bonding curve account non trovata, riprovo tra 1 secondo...");
      await new Promise(resolve => setTimeout(resolve, 1000)); // Attendi 1 secondo
    }
  }

  console.log("❌ Raggiunto il numero massimo di tentativi. Impossibile trovare la bonding curve.");
}

So this code works properly but just after 10 seconds of creation. Infact, as you can see, there is a retry so if you start this code immediatly after creation you receive the results in the photo. He has to retry saying "Bonding curve not found". I have also tried to modify the code in order to give the bondingCurveAccount but still does'nt work properly. Do you have any idea??

immagine

Many thanks for your time. If you need more details please let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions