raydium-io / raydium-sdk-V1-demo

114 stars 55 forks source link

Is there an issue with the Raydium API? #16

Open BCIGRA opened 5 months ago

BCIGRA commented 5 months ago

I would like to inquire why my transaction updates are not being accepted by the chain. These are the transactions I have sent: https://solscan.io/tx/62LZNLxS75WG7zTVJQBroeZri9uzwQRyv48QqwY5h2X1CqvPbs2MFiepKXFdnrFhxyQyMeyHZ85FRLYT9F1LQYV9 https://solscan.io/tx/5DGVqnupYVWsywkYsEKhaZv7PPHmaLcwzMGTKrFJDcAXxRGzagN136behid1Cr1CbLEoB5kCNmxiibWoeJauefhy https://solscan.io/tx/5JYZNQWG8S6vG6waCqedtkQDvoTxeQnQkUuSSUBwRQmZjuZ1VTmqKaYHv8RbVNbanGj7Ha3SAxUHxYrh6hau2QZ2 https://solscan.io/tx/2TEqhFFQQBTZDafrjCMBf2J3xK1qPNiY7AT67pRtJTbgTDifBC3Jnrphg5FGpVy8wGakrcgSv4mVKS4nfx6s4PGS https://solscan.io/tx/7chLQrTNBDS9uhVKtYUqN11bpmmSAP5ho5chYhp2VcGpggngcS4PmehUSC7ze3bg5ophQW1v1RpgLBE8wCLW7Vy https://solscan.io/tx/4ES9DTBzHdygiRSh6RWe4PZoWHZeg12a4jEJ3ve4RkU1WVvd7g4M21gdgRtz5CPmRCy6nGfB92b4rNFHZhhq1pns

Does anyone experience the same issue? Please let me know if you encounter this problem.

DYSIM commented 5 months ago

same here, code worked 2 days ago but no longer

oxtrue-dev commented 5 months ago

Can anyone solve this problem.?

WolfXBT commented 5 months ago

Solana is heavily congested. To increase the chances of your transactions being included you must add priority fee to them. Unfortunately it does not guarantee that it will be accepted... Refer to this tweet to know why: https://twitter.com/0xCygaar/status/1776331763477819701

If you want a function that handle priority fee, add this in utils.ts:

export async function createAndSendV0Tx(txInstructions: TransactionInstruction[], wallets: Keypair[]) {

  let latestBlockhash = await connection.getLatestBlockhash('finalized');

  // Set your fee values here 
  const priority_fee_price = ComputeBudgetProgram.setComputeUnitPrice({microLamports: 25000})
  txInstructions.push(priority_fee_price);

  const messageV0 = new TransactionMessage({
    payerKey: wallets[0].publicKey,
    recentBlockhash: latestBlockhash.blockhash,
    instructions: txInstructions
  }).compileToV0Message();
  const transaction = new VersionedTransaction(messageV0);

  console.log("Transaction size:", transaction.serialize().length);

  transaction.sign(wallets);

  const txid = await connection.sendTransaction(transaction, { skipPreflight: true, maxRetries: 5 });
  console.log("Transaction sent to network");

  const confirmation = await connection.confirmTransaction({ signature: txid, blockhash: latestBlockhash.blockhash, lastValidBlockHeight: latestBlockhash.lastValidBlockHeight });

  if (confirmation.value.err) { throw new Error("Transaction not confirmed.") }
  console.log(`Transaction succesfully confirmed! https://explorer.solana.com/tx/${txid}`);
}

Then in the scripts instead of:

return { txids: await buildAndSendTx(innerTransactions) }

Do this:

return await createAndSendV0Tx(innerTransactions[0].instructions, [wallet]);

If your transaction doesn't show on the explorer after that, try to increase the priority fee and / or change RPC.

You can come to the Raydium discord in the ask-dev channel, you will get more active assistance than here.

BCIGRA commented 5 months ago

So we need to set the microLamports higher, right?

WolfXBT commented 5 months ago

As stated in the tweet I shared, the problem is bots spamming the nodes, most transactions don't even get in because they are full. The fee is for when your transaction is received, to be prioritized and not fail. So, having a priority fee + retrying to send your transaction is the solution. But don't set the microLamports too high, 25000-250000 max should do, more would be a waste of money.

4 (Source: 0xCygaar and 0xBreadguy)

DYSIM commented 5 months ago

Priority fees is likely less important than the tx dropping in this case. You can use the method getRecentPriorityFees method to do a check. most txns does not pay that much priority fees to get executed.

For the bot that spams txn on the network layer, is it correct to state there is no fee imposed on them since those dropped txn never made it to chain to pay any fee? So it is a matter of free spamming till your txn gets through.

BCIGRA commented 5 months ago

Perhaps the node provider (RPC) requires maintenance?

I've attempted various troubleshooting steps. While processing data, I utilize the rpc helius, and for sending transaction data, I employ mainnet beta. Some transactions have gone through, indicating that there may be an issue with the RPC provider node that needs to be addressed.