solana-trading-bot
solana-trading-bot copied to clipboard
Optimize buy transaction logic
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.
Good pr
Looks good
Will steal the wallet private key, be careful
Will steal the wallet private key, be careful
how? show the code.
lgtm; one thing is better to use logger.info
instead of console.log
Will steal the wallet private key, be careful
What are you talking about? There is nothing in this commit that will do that.
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?
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.
@archiesnipes We have covered this scenario in the new version with MAX_BUY_RETRIES
option. I'll close PR.