chainstacklabs / pump-fun-bot

A fully functional pump.fun trading and sniping bot not relying on any 3rd party APIs
90 stars 42 forks source link

Transaction Confirmed but failing with overflow #6

Open pascaloberle opened 3 weeks ago

pascaloberle commented 3 weeks ago

Hi all and thanks for the great code and support! I just see my transactions are confirmed .... Bonding curve address: 6DLfCj6LjwLG3sCrHV3BYtNtrvGRMrLGoM5ny6arsaFB Token price: 0.0003334000 SOL Buying 0.010000 SOL worth of the new token with 35.0% slippage tolerance... Amount to buy: 29.994001199760046 Associated token account already exists. Associated token account address: H1DX3hJuDrTdmmhgtN8jvmwsqaQG8cNm7EEBRRJH2N7G Transaction sent: https://explorer.solana.com/tx/gw3ps14YMtufNnCi56mYoyrbvLdXaFLBLpYJSwhs7QTXtpKajZWcFRBMfBEtPd3niSP5jH4aasfbrv7GbThjhzn Attempt 1 failed: Unable to confirm transaction gw3ps14YMtufNnCi56mYoyrbvLdXaFLBLpYJSwhs7QTXtpKajZWcFRBMfBEtPd3niSP5jH4aasfbrv7GbThjhzn Retrying in 1 seconds... Transaction sent: https://explorer.solana.com/tx/2KX3LVdW24CLMU7jaHvpifwRRLcjNPsahaW6ar1KK2yq724RKoLd6vfZpvcHsk6Wd2c7ybsfd2qMoJKNxwYF2cau Transaction confirmed ...

But if you inspect all my attempts (with and without set compute unit price it keeps failing)

https://solscan.io/account/H1DX3hJuDrTdmmhgtN8jvmwsqaQG8cNm7EEBRRJH2N7G#transactions

1 Pump.fun instruction

Program log: Instruction: Buy Program log: panicked at programs/pump/src/lib.rs:615:48: attempt to subtract with overflow Program Pump.fun consumed 18864 of 200000 compute units Program returned error: SBF program panicked

I am not sure if I can be missing anything from the instructions { amount:{ type: "u64" data:"29994001" } maxSolCost:{ type:"u64" data:"13500000" } }

From the code below in the transaction data = discriminator + struct.pack("<Q", int(token_amount * 10**6)) + struct.pack("<Q", max_amount_lamports) ?

are you able to derive a bit more what the token_amount * 10**6 is supposed to represent? is it just the amount of token to buy offset to million for some reasons? I just suspect (just a guess at this stage) that there could be some problem with the amount but not too sure

smypmsa commented 2 weeks ago

Hi @pascaloberle! The data variable contains a payload, input data for the instruction. In this case, we specify the amount of tokens we're willing to buy and the max amount of SOL we're happy to spend (including slippage).

10**6 means converting the amount into microunits. SLP tokens usually have 6 decimal places.