pumpdotfun-sdk icon indicating copy to clipboard operation
pumpdotfun-sdk copied to clipboard

Fix Buy/Sell Logic, Update IDL, and Add Missing bn.js Dependency

Open kiennd opened this issue 7 months ago • 7 comments

This pull request addresses compatibility and functionality issues introduced by the recent Pump.fun IDL update. The following changes have been made:

  • Updated buy, sell, and createAndBuy functions to align with the updated IDL structure.

  • Synchronized project interfaces with the latest Pump.fun IDL to ensure seamless program interaction.

  • Added the missing bn.js dependency required for BigNumber operations.

kiennd avatar May 21 '25 19:05 kiennd

LGTM!

tranchien2002 avatar May 22 '25 02:05 tranchien2002

Getting this error when attempting to create a token using this MR:

34 |         if ((0, idl_js_1.isCompositeAccounts)(acc)) {
35 |             validateAccounts(acc.accounts, accounts[acc.name]);
36 |         }
37 |         else {
38 |             if (!accounts[acc.name]) {
39 |                 throw new Error(`Account \`${acc.name}\` not provided.`);
                           ^
error: Account `feeRecipient` not provided.

LightYagami200 avatar May 22 '25 23:05 LightYagami200

Getting this error when attempting to create a token using this MR:

34 |         if ((0, idl_js_1.isCompositeAccounts)(acc)) {
35 |             validateAccounts(acc.accounts, accounts[acc.name]);
36 |         }
37 |         else {
38 |             if (!accounts[acc.name]) {
39 |                 throw new Error(`Account \`${acc.name}\` not provided.`);
                           ^
error: Account `feeRecipient` not provided.

same here. Any fix for this?

Storryy avatar May 23 '25 13:05 Storryy

I changed the files that were changed in this commit, but I seem to run into this issue

Storryy avatar May 23 '25 17:05 Storryy

@LightYagami200 @Storryy i've updated new code, bellow is working log:

% npm run example

Initial test account balance: 2KGqqvJeURrkLuV9W8LXwErmvPuEcjekiMCt9gAzF1w1: 0.053529375 SOL

🔧 GlobalAccount: { initialized: true, authority: FFWtrEQ4B4PKQoVuHYzZq8FabGkVatYzDpEVHsK5rrhF, feeRecipient: 62qc2CNXwrYqQScmEdiZFFAnJR262PxWEuNQtxfafNgV, initialVirtualTokenReserves: 1073000000000000n, initialVirtualSolReserves: 30000000000n, initialRealTokenReserves: 793100000000000n, tokenTotalSupply: 1000000000000000n, feeBasisPoints: 95n }

📤 Create & Buy TX:
🔗 https://solscan.io/tx/5gNv8LzdSB6kAMYJ19JMKEub48oNkHpVzSNYAEUFePmYUu1iQNwThYaPT9374Dy76kEAatJLkFitsKZyERhrUH5Y
✅ Success: https://pump.fun/EgYErvxQUiuo87BcY3RPZZGj2JnfLmGHorFAZmDC7jsQ

📈 Bonding curve after create & buy: { virtualTokenReserves: 1072996423345256n, virtualSolReserves: 30000100000n, realTokenReserves: 793096423345256n, realSolReserves: 100000n, complete: false }

💰 SPL Balance after buy: 3576.654744

📤 Buy TX:
🔗 https://solscan.io/tx/9KUVMbaQYnAPYGRoSFuxA5jKJS7Bge1NNSaxfGrdDTWc4zyhakZ28iuQKpcxMbDEwWq7tZLTKgSg13z4pbXifNf

📈 Bonding curve after buy: { virtualTokenReserves: 1072727817469418n, virtualSolReserves: 30007611881n, realTokenReserves: 792827817469418n, realSolReserves: 7611881n, complete: false }

💸 Sell:

  • amount: 3576654744
  • exactSolOutput: 99100
  • withSlippage: 98109
  • vault PDA: 9FP2NECUSpPdgPZwd3ummxhEFXbkyUC1mRvjYwLcwYtF

📤 Sell TX:
🔗 https://solscan.io/tx/43Tjd6FMoMCdLFiDZpAeBqTZY7kBW11FtYNcnm4mXPRpoRGMu8mLZSz2JyfuUhCV1GcLRnEHh62ZjVapBUG8q19j

Final test account balance: 0.031397181 SOL
After full SPL sell: 0 SOL

📉 Bonding curve after sell: { virtualTokenReserves: 1072423395124162n, virtualSolReserves: 30016129961n, realTokenReserves: 792523395124162n, realSolReserves: 16129961n, complete: false }

kiennd avatar May 24 '25 14:05 kiennd

I'm going to test and merge thank you!

rckprtr avatar May 25 '25 04:05 rckprtr

I'm going to test and merge thank you!

hey? its been a while

vacuumDev avatar Jun 05 '25 03:06 vacuumDev