1

Does anyone know what can cause a swap transaction to take a while to be accepted by the RPC?

Currently, I made a script that every 1 second tries to do a SOL SWAP transaction for a certain token recently launched on raydium, and I added logs to help check the time. Currently the transaction has a priority fee, so that it can be confirmed faster (and this is working).

According to my logs, the RPC denied the transaction several times in a row, as shown in the log below:

Error: [Transaction simulation failed: Error processing Instruction 4: custom program error: 0x16]...

Until he finally accepted the transaction:

8. Confirm transaction... 2023-12-31 11:20:42.909286

While my transaction was only accepted at 11:20:42, someone else managed to get the swap transaction for the same token accepted at 11:20:21.. 20 seconds before mine..

How is this possible? Since I'm trying to make the transaction every 1 second..

1
  • Hey did you ever figure this out? And do you mine sharing how you were able to get busy even within the first minute? Ive been pulling my hair out for weeks Feb 6 at 20:21

2 Answers 2

1

You probably have a reasonable/tight slippage and it’s a popular market, so by the time your swap transaction lands it is a different price. So you could increase your slippage tolerance. You can also remove client-side simulation, which causes a round-trip request to your RPC before the actual transaction is sent.

2
  • I'm setting the amountOut to 0, so that means I'm accepting slippage of up to 100%, right? Dec 31, 2023 at 14:52
  • It depends how you're calling it (i.e. via Jupiter or a Raydium SDK), you would have to check the docs. You may also be able to look up the specific program error with that hex code.
    – joebuild
    Dec 31, 2023 at 14:56
1

The issue arises from the start time being set when creating the pool. To initiate swapping immediately, you need to adjust it. For example, if you set it like this, swapping will start in 30 seconds.

const poolStartTime = new BN(Math.floor(Math.floor(Date.now() / 1000) + 30)); // Set startTime to current time plus 30 seconds

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.