Skip to content

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

Open
kiennd wants to merge 4 commits intorckprtr:mainfrom
kiennd:main
Open

Fix Buy/Sell Logic, Update IDL, and Add Missing bn.js Dependency#112
kiennd wants to merge 4 commits intorckprtr:mainfrom
kiennd:main

Conversation

@kiennd
Copy link
Copy Markdown

@kiennd kiennd commented May 21, 2025

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.

@tranchien2002
Copy link
Copy Markdown

LGTM!

@Aries-Spring
Copy link
Copy Markdown

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.

@Storryy
Copy link
Copy Markdown

Storryy commented May 23, 2025

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
Copy link
Copy Markdown

Storryy commented May 23, 2025

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

@kiennd
Copy link
Copy Markdown
Author

kiennd commented May 24, 2025

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

Details % 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 kiennd requested a review from BastienGimbert May 24, 2025 15:02
Copy link
Copy Markdown

@BastienGimbert BastienGimbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buy / sell working.
I did not try the create

@rckprtr
Copy link
Copy Markdown
Owner

rckprtr commented May 25, 2025

I'm going to test and merge thank you!

@vacuumDev
Copy link
Copy Markdown

I'm going to test and merge thank you!

hey? its been a while

venkat22022202 added a commit to venkat22022202/pumpdotfun-sdk that referenced this pull request Apr 1, 2026
…ogram

The on-chain pump program has been updated multiple times since this SDK's
last release, adding creator fees, fee program integration, volume tracking,
cashback, and mayhem mode support. This broke all buy/sell/create operations.

Changes:
- Replace IDL with the official one from pump-fun/pump-public-docs (Mar 2026)
- Update BondingCurveAccount: add creator, isMayhemMode, isCashbackCoin fields
- Update GlobalAccount: add creatorFeeBasisPoints, feeRecipients,
  withdrawAuthority, enableMigrate, poolMigrationFee, setCreatorAuthority
- Update buy instructions to pass all 16 required accounts:
  creator_vault, global_volume_accumulator, user_volume_accumulator,
  fee_config, fee_program
- Update sell instructions to pass all 14 required accounts
- Update sell price calculation to include creator fees
- Add PDA derivation helpers for all new accounts
- Fix browser compatibility (use Uint8Array instead of Buffer at module level)

Fixes rckprtr#108, rckprtr#109, rckprtr#112, rckprtr#120

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants