solana-trading-bot icon indicating copy to clipboard operation
solana-trading-bot copied to clipboard

Optimize buy transaction logic

Open archiesnipes opened this issue 10 months ago • 7 comments

Handles refetch of new blockhash in the case where txn fails due to blockhash/height expiry and retries txn again. Try-catch block can also be extended to handle other types of errors i.e. 0x1 insufficent funds etc.

archiesnipes avatar Apr 08 '24 10:04 archiesnipes

Good pr

PushjoeYY avatar Apr 08 '24 14:04 PushjoeYY

Looks good

thealexcons avatar Apr 08 '24 18:04 thealexcons

Will steal the wallet private key, be careful

Yuri-Hong avatar Apr 10 '24 10:04 Yuri-Hong

Will steal the wallet private key, be careful

how? show the code.

archiesnipes avatar Apr 10 '24 10:04 archiesnipes

lgtm; one thing is better to use logger.info instead of console.log

oboshto avatar Apr 10 '24 13:04 oboshto

Will steal the wallet private key, be careful

What are you talking about? There is nothing in this commit that will do that.

zerofill avatar Apr 10 '24 16:04 zerofill

Can we call "solanaConnection.confirmTransaction" right after "solanaConnection.sendRawTransaction"? What would happen if solanaConnection.sendRawTransaction is successful but not yet confirmed? The result of "solanaConnection.confirmTransaction" would be wrong, duplicate buys would execute? Is confirmTransaction a blocking function?

ngtianxun avatar Apr 16 '24 06:04 ngtianxun

Be careful executing client-side retries on buys like this...

You should change the maxRetries of the confirmation request to avoid it taking a long time and retrying the confirmation in the client side too... And also handles how long (in time, not the amount of retries) you want to retry it (or even an option to configure "while the token keeps a specific price, try buying it")...

The current code will, for example:

  • Send a transaction trying to buy a token with the default maxRetries (which will make the RPC retry the confirmation internally)
  • This confirmation may take 30s+ and then return error after this long time (mainly on congestion periods)
  • The blockhash will be expired
  • Another buy transaction will be sent, but now 30 seconds later, and the token may already have been rugged.

lucasoares avatar Apr 25 '24 03:04 lucasoares

@archiesnipes We have covered this scenario in the new version with MAX_BUY_RETRIES option. I'll close PR.

fdundjer avatar Apr 26 '24 07:04 fdundjer