@pump-fun/pump-sdk 1.17.3 → 1.17.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1 +1,103 @@
1
1
  # Pump SDK
2
+
3
+ Official Pump program SDK
4
+
5
+ ```Typescript
6
+ const connection = new Connection(
7
+ "https://api.devnet.solana.com",
8
+ "confirmed",
9
+ );
10
+ const sdk = new PumpSdk(connection);
11
+ ```
12
+
13
+ ## Coin creation
14
+
15
+ ```Typescript
16
+ const mint = PublicKey.unique();
17
+ const creator = PublicKey.unique();
18
+ const user = PublicKey.unique();
19
+
20
+ const instruction = await sdk.createInstruction({
21
+ mint,
22
+ name: "name",
23
+ symbol: "symbol",
24
+ uri: "uri",
25
+ creator,
26
+ user,
27
+ });
28
+
29
+ // or creating and buying instructions in the same tx
30
+
31
+ const global = await sdk.fetchGlobal();
32
+ const solAmount = new BN(0.1 * 10 ** 9); // 0.1 SOL
33
+
34
+ const instructions = await sdk.createAndBuyInstructions({
35
+ global,
36
+ mint,
37
+ name: "name",
38
+ symbol: "symbol",
39
+ uri: "uri",
40
+ creator,
41
+ user,
42
+ solAmount,
43
+ amount: getBuyTokenAmountFromSolAmount(global, null, solAmount),
44
+ });
45
+ ```
46
+
47
+ ## Buying coins
48
+
49
+ ```Typescript
50
+ const mint = PublicKey.unique();
51
+ const user = PublicKey.unique();
52
+
53
+ const global = await sdk.fetchGlobal();
54
+ const { bondingCurveAccountInfo, bondingCurve, associatedUserAccountInfo } =
55
+ await sdk.fetchBuyState(mint, user);
56
+ const solAmount = new BN(0.1 * 10 ** 9); // 0.1 SOL
57
+
58
+ const instructions = await sdk.buyInstructions({
59
+ global,
60
+ bondingCurveAccountInfo,
61
+ bondingCurve,
62
+ associatedUserAccountInfo,
63
+ mint,
64
+ user,
65
+ solAmount,
66
+ amount: getBuyTokenAmountFromSolAmount(global, bondingCurve, solAmount),
67
+ slippage: 1,
68
+ });
69
+ ```
70
+
71
+ ## Selling coins
72
+
73
+ ```Typescript
74
+ const mint = PublicKey.unique();
75
+ const user = PublicKey.unique();
76
+
77
+ const global = await sdk.fetchGlobal();
78
+ const { bondingCurveAccountInfo, bondingCurve } = await sdk.fetchSellState(mint, user);
79
+ const amount = new BN(15_828);
80
+
81
+ const instructions = await sdk.sellInstructions({
82
+ global,
83
+ bondingCurveAccountInfo,
84
+ bondingCurve,
85
+ mint,
86
+ user,
87
+ amount,
88
+ solAmount: getSellSolAmountFromTokenAmount(global, bondingCurve, amount),
89
+ slippage: 1,
90
+ });
91
+ ```
92
+
93
+ ## Creator fees
94
+
95
+ ```Typescript
96
+ const user = PublicKey.unique();
97
+
98
+ // Getting total accumulated creator fees for both Pump and PumpSwap programs
99
+ console.log((await sdk.getCreatorVaultBalanceBothPrograms(user)).toString());
100
+
101
+ // Collecting creator fees instructions
102
+ const instructions = await sdk.collectCoinCreatorFeeInstructions(user);
103
+ ```
package/dist/esm/index.js CHANGED
@@ -4538,7 +4538,7 @@ function getBuyTokenAmountFromSolAmountQuote({
4538
4538
  }) {
4539
4539
  return inputAmount.mul(virtualTokenReserves).div(virtualSolReserves.add(inputAmount));
4540
4540
  }
4541
- function getSellTokenAmountFromSolAmountQuote({
4541
+ function getSellSolAmountFromTokenAmountQuote({
4542
4542
  inputAmount,
4543
4543
  virtualTokenReserves,
4544
4544
  virtualSolReserves
@@ -4595,7 +4595,7 @@ function getSellSolAmountFromTokenAmount(global, bondingCurve, amount) {
4595
4595
  if (bondingCurve.virtualTokenReserves.eq(new BN(0))) {
4596
4596
  return new BN(0);
4597
4597
  }
4598
- const solCost = getSellTokenAmountFromSolAmountQuote({
4598
+ const solCost = getSellSolAmountFromTokenAmountQuote({
4599
4599
  inputAmount: amount,
4600
4600
  virtualTokenReserves: bondingCurve.virtualTokenReserves,
4601
4601
  virtualSolReserves: bondingCurve.virtualSolReserves
@@ -5054,6 +5054,11 @@ var PumpSdk = class {
5054
5054
  }
5055
5055
  return new BN3(accountInfo.lamports - rentExemptionLamports);
5056
5056
  }
5057
+ async getCreatorVaultBalanceBothPrograms(creator) {
5058
+ const balance = await this.getCreatorVaultBalance(creator);
5059
+ const ammBalance = await this.pumpAmmSdk.getCoinCreatorVaultBalance(creator);
5060
+ return balance.add(ammBalance);
5061
+ }
5057
5062
  async adminUpdateTokenIncentives(startTime, endTime, dayNumber, tokenSupplyPerDay, secondsInADay = new BN3(86400), mint = PUMP_TOKEN_MINT, tokenProgram = TOKEN_2022_PROGRAM_ID) {
5058
5063
  const { authority } = await this.fetchGlobal();
5059
5064
  return await this.offlinePumpProgram.methods.adminUpdateTokenIncentives(
@@ -5337,7 +5342,7 @@ export {
5337
5342
  getBuyTokenAmountFromSolAmountQuote,
5338
5343
  getPumpProgram,
5339
5344
  getSellSolAmountFromTokenAmount,
5340
- getSellTokenAmountFromSolAmountQuote,
5345
+ getSellSolAmountFromTokenAmountQuote,
5341
5346
  globalPda,
5342
5347
  globalVolumeAccumulatorPda,
5343
5348
  newBondingCurve,
package/dist/index.d.mts CHANGED
@@ -9085,7 +9085,7 @@ declare function getBuyTokenAmountFromSolAmountQuote({ inputAmount, virtualToken
9085
9085
  virtualTokenReserves: BN;
9086
9086
  virtualSolReserves: BN;
9087
9087
  }): BN;
9088
- declare function getSellTokenAmountFromSolAmountQuote({ inputAmount, virtualTokenReserves, virtualSolReserves, }: {
9088
+ declare function getSellSolAmountFromTokenAmountQuote({ inputAmount, virtualTokenReserves, virtualSolReserves, }: {
9089
9089
  inputAmount: BN;
9090
9090
  virtualTokenReserves: BN;
9091
9091
  virtualSolReserves: BN;
@@ -9186,6 +9186,7 @@ declare class PumpSdk {
9186
9186
  collectCoinCreatorFeeInstructions(coinCreator: PublicKey): Promise<TransactionInstruction[]>;
9187
9187
  adminSetCoinCreatorInstructions(newCoinCreator: PublicKey, mint: PublicKey): Promise<TransactionInstruction[]>;
9188
9188
  getCreatorVaultBalance(creator: PublicKey): Promise<BN>;
9189
+ getCreatorVaultBalanceBothPrograms(creator: PublicKey): Promise<BN>;
9189
9190
  adminUpdateTokenIncentives(startTime: BN, endTime: BN, dayNumber: BN, tokenSupplyPerDay: BN, secondsInADay?: BN, mint?: PublicKey, tokenProgram?: PublicKey): Promise<TransactionInstruction>;
9190
9191
  adminUpdateTokenIncentivesBothPrograms(startTime: BN, endTime: BN, dayNumber: BN, tokenSupplyPerDay: BN, secondsInADay?: BN, mint?: PublicKey, tokenProgram?: PublicKey): Promise<TransactionInstruction[]>;
9191
9192
  claimTokenIncentives(user: PublicKey, payer: PublicKey): Promise<TransactionInstruction[]>;
@@ -9229,4 +9230,4 @@ declare class PumpSdk {
9229
9230
  declare function totalUnclaimedTokens(globalVolumeAccumulator: GlobalVolumeAccumulator, userVolumeAccumulator: UserVolumeAccumulator, currentTimestamp?: number): BN;
9230
9231
  declare function currentDayTokens(globalVolumeAccumulator: GlobalVolumeAccumulator, userVolumeAccumulator: UserVolumeAccumulator, currentTimestamp?: number): BN;
9231
9232
 
9232
- export { BONDING_CURVE_NEW_SIZE, type BondingCurve, CANONICAL_POOL_INDEX, type Global, type GlobalVolumeAccumulator, PUMP_AMM_PROGRAM_ID, PUMP_PROGRAM_ID, type Pump, PumpSdk, type UserVolumeAccumulator, type UserVolumeAccumulatorTotalStats, bondingCurvePda, canonicalPumpPoolPda, creatorVaultPda, currentDayTokens, getBuySolAmountFromTokenAmount, getBuySolAmountFromTokenAmountQuote, getBuyTokenAmountFromSolAmount, getBuyTokenAmountFromSolAmountQuote, getPumpProgram, getSellSolAmountFromTokenAmount, getSellTokenAmountFromSolAmountQuote, globalPda, globalVolumeAccumulatorPda, newBondingCurve, pump as pumpIdl, pumpPoolAuthorityPda, totalUnclaimedTokens, userVolumeAccumulatorPda };
9233
+ export { BONDING_CURVE_NEW_SIZE, type BondingCurve, CANONICAL_POOL_INDEX, type Global, type GlobalVolumeAccumulator, PUMP_AMM_PROGRAM_ID, PUMP_PROGRAM_ID, type Pump, PumpSdk, type UserVolumeAccumulator, type UserVolumeAccumulatorTotalStats, bondingCurvePda, canonicalPumpPoolPda, creatorVaultPda, currentDayTokens, getBuySolAmountFromTokenAmount, getBuySolAmountFromTokenAmountQuote, getBuyTokenAmountFromSolAmount, getBuyTokenAmountFromSolAmountQuote, getPumpProgram, getSellSolAmountFromTokenAmount, getSellSolAmountFromTokenAmountQuote, globalPda, globalVolumeAccumulatorPda, newBondingCurve, pump as pumpIdl, pumpPoolAuthorityPda, totalUnclaimedTokens, userVolumeAccumulatorPda };
package/dist/index.d.ts CHANGED
@@ -9085,7 +9085,7 @@ declare function getBuyTokenAmountFromSolAmountQuote({ inputAmount, virtualToken
9085
9085
  virtualTokenReserves: BN;
9086
9086
  virtualSolReserves: BN;
9087
9087
  }): BN;
9088
- declare function getSellTokenAmountFromSolAmountQuote({ inputAmount, virtualTokenReserves, virtualSolReserves, }: {
9088
+ declare function getSellSolAmountFromTokenAmountQuote({ inputAmount, virtualTokenReserves, virtualSolReserves, }: {
9089
9089
  inputAmount: BN;
9090
9090
  virtualTokenReserves: BN;
9091
9091
  virtualSolReserves: BN;
@@ -9186,6 +9186,7 @@ declare class PumpSdk {
9186
9186
  collectCoinCreatorFeeInstructions(coinCreator: PublicKey): Promise<TransactionInstruction[]>;
9187
9187
  adminSetCoinCreatorInstructions(newCoinCreator: PublicKey, mint: PublicKey): Promise<TransactionInstruction[]>;
9188
9188
  getCreatorVaultBalance(creator: PublicKey): Promise<BN>;
9189
+ getCreatorVaultBalanceBothPrograms(creator: PublicKey): Promise<BN>;
9189
9190
  adminUpdateTokenIncentives(startTime: BN, endTime: BN, dayNumber: BN, tokenSupplyPerDay: BN, secondsInADay?: BN, mint?: PublicKey, tokenProgram?: PublicKey): Promise<TransactionInstruction>;
9190
9191
  adminUpdateTokenIncentivesBothPrograms(startTime: BN, endTime: BN, dayNumber: BN, tokenSupplyPerDay: BN, secondsInADay?: BN, mint?: PublicKey, tokenProgram?: PublicKey): Promise<TransactionInstruction[]>;
9191
9192
  claimTokenIncentives(user: PublicKey, payer: PublicKey): Promise<TransactionInstruction[]>;
@@ -9229,4 +9230,4 @@ declare class PumpSdk {
9229
9230
  declare function totalUnclaimedTokens(globalVolumeAccumulator: GlobalVolumeAccumulator, userVolumeAccumulator: UserVolumeAccumulator, currentTimestamp?: number): BN;
9230
9231
  declare function currentDayTokens(globalVolumeAccumulator: GlobalVolumeAccumulator, userVolumeAccumulator: UserVolumeAccumulator, currentTimestamp?: number): BN;
9231
9232
 
9232
- export { BONDING_CURVE_NEW_SIZE, type BondingCurve, CANONICAL_POOL_INDEX, type Global, type GlobalVolumeAccumulator, PUMP_AMM_PROGRAM_ID, PUMP_PROGRAM_ID, type Pump, PumpSdk, type UserVolumeAccumulator, type UserVolumeAccumulatorTotalStats, bondingCurvePda, canonicalPumpPoolPda, creatorVaultPda, currentDayTokens, getBuySolAmountFromTokenAmount, getBuySolAmountFromTokenAmountQuote, getBuyTokenAmountFromSolAmount, getBuyTokenAmountFromSolAmountQuote, getPumpProgram, getSellSolAmountFromTokenAmount, getSellTokenAmountFromSolAmountQuote, globalPda, globalVolumeAccumulatorPda, newBondingCurve, pump as pumpIdl, pumpPoolAuthorityPda, totalUnclaimedTokens, userVolumeAccumulatorPda };
9233
+ export { BONDING_CURVE_NEW_SIZE, type BondingCurve, CANONICAL_POOL_INDEX, type Global, type GlobalVolumeAccumulator, PUMP_AMM_PROGRAM_ID, PUMP_PROGRAM_ID, type Pump, PumpSdk, type UserVolumeAccumulator, type UserVolumeAccumulatorTotalStats, bondingCurvePda, canonicalPumpPoolPda, creatorVaultPda, currentDayTokens, getBuySolAmountFromTokenAmount, getBuySolAmountFromTokenAmountQuote, getBuyTokenAmountFromSolAmount, getBuyTokenAmountFromSolAmountQuote, getPumpProgram, getSellSolAmountFromTokenAmount, getSellSolAmountFromTokenAmountQuote, globalPda, globalVolumeAccumulatorPda, newBondingCurve, pump as pumpIdl, pumpPoolAuthorityPda, totalUnclaimedTokens, userVolumeAccumulatorPda };
package/dist/index.js CHANGED
@@ -45,7 +45,7 @@ __export(index_exports, {
45
45
  getBuyTokenAmountFromSolAmountQuote: () => getBuyTokenAmountFromSolAmountQuote,
46
46
  getPumpProgram: () => getPumpProgram,
47
47
  getSellSolAmountFromTokenAmount: () => getSellSolAmountFromTokenAmount,
48
- getSellTokenAmountFromSolAmountQuote: () => getSellTokenAmountFromSolAmountQuote,
48
+ getSellSolAmountFromTokenAmountQuote: () => getSellSolAmountFromTokenAmountQuote,
49
49
  globalPda: () => globalPda,
50
50
  globalVolumeAccumulatorPda: () => globalVolumeAccumulatorPda,
51
51
  newBondingCurve: () => newBondingCurve,
@@ -4596,7 +4596,7 @@ function getBuyTokenAmountFromSolAmountQuote({
4596
4596
  }) {
4597
4597
  return inputAmount.mul(virtualTokenReserves).div(virtualSolReserves.add(inputAmount));
4598
4598
  }
4599
- function getSellTokenAmountFromSolAmountQuote({
4599
+ function getSellSolAmountFromTokenAmountQuote({
4600
4600
  inputAmount,
4601
4601
  virtualTokenReserves,
4602
4602
  virtualSolReserves
@@ -4653,7 +4653,7 @@ function getSellSolAmountFromTokenAmount(global, bondingCurve, amount) {
4653
4653
  if (bondingCurve.virtualTokenReserves.eq(new import_bn.default(0))) {
4654
4654
  return new import_bn.default(0);
4655
4655
  }
4656
- const solCost = getSellTokenAmountFromSolAmountQuote({
4656
+ const solCost = getSellSolAmountFromTokenAmountQuote({
4657
4657
  inputAmount: amount,
4658
4658
  virtualTokenReserves: bondingCurve.virtualTokenReserves,
4659
4659
  virtualSolReserves: bondingCurve.virtualSolReserves
@@ -5104,6 +5104,11 @@ var PumpSdk = class {
5104
5104
  }
5105
5105
  return new import_bn3.default(accountInfo.lamports - rentExemptionLamports);
5106
5106
  }
5107
+ async getCreatorVaultBalanceBothPrograms(creator) {
5108
+ const balance = await this.getCreatorVaultBalance(creator);
5109
+ const ammBalance = await this.pumpAmmSdk.getCoinCreatorVaultBalance(creator);
5110
+ return balance.add(ammBalance);
5111
+ }
5107
5112
  async adminUpdateTokenIncentives(startTime, endTime, dayNumber, tokenSupplyPerDay, secondsInADay = new import_bn3.default(86400), mint = PUMP_TOKEN_MINT, tokenProgram = import_spl_token.TOKEN_2022_PROGRAM_ID) {
5108
5113
  const { authority } = await this.fetchGlobal();
5109
5114
  return await this.offlinePumpProgram.methods.adminUpdateTokenIncentives(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pump-fun/pump-sdk",
3
- "version": "1.17.3",
3
+ "version": "1.17.5",
4
4
  "description": "Pump Bonding Curve SDK",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/pump-fun/pump-sdk#readme",
@@ -64,7 +64,7 @@ export function getBuyTokenAmountFromSolAmountQuote({
64
64
  .div(virtualSolReserves.add(inputAmount));
65
65
  }
66
66
 
67
- export function getSellTokenAmountFromSolAmountQuote({
67
+ export function getSellSolAmountFromTokenAmountQuote({
68
68
  inputAmount,
69
69
  virtualTokenReserves,
70
70
  virtualSolReserves,
@@ -162,7 +162,7 @@ export function getSellSolAmountFromTokenAmount(
162
162
  return new BN(0);
163
163
  }
164
164
 
165
- const solCost = getSellTokenAmountFromSolAmountQuote({
165
+ const solCost = getSellSolAmountFromTokenAmountQuote({
166
166
  inputAmount: amount,
167
167
  virtualTokenReserves: bondingCurve.virtualTokenReserves,
168
168
  virtualSolReserves: bondingCurve.virtualSolReserves,
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@ export {
4
4
  getBuyTokenAmountFromSolAmount,
5
5
  getBuySolAmountFromTokenAmountQuote,
6
6
  getBuyTokenAmountFromSolAmountQuote,
7
- getSellTokenAmountFromSolAmountQuote,
7
+ getSellSolAmountFromTokenAmountQuote,
8
8
  getBuySolAmountFromTokenAmount,
9
9
  getSellSolAmountFromTokenAmount,
10
10
  newBondingCurve,
package/src/sdk.ts CHANGED
@@ -532,6 +532,13 @@ export class PumpSdk {
532
532
  return new BN(accountInfo.lamports - rentExemptionLamports);
533
533
  }
534
534
 
535
+ async getCreatorVaultBalanceBothPrograms(creator: PublicKey): Promise<BN> {
536
+ const balance = await this.getCreatorVaultBalance(creator);
537
+ const ammBalance =
538
+ await this.pumpAmmSdk.getCoinCreatorVaultBalance(creator);
539
+ return balance.add(ammBalance);
540
+ }
541
+
535
542
  async adminUpdateTokenIncentives(
536
543
  startTime: BN,
537
544
  endTime: BN,