@pump-fun/pump-sdk 1.17.2 → 1.17.4

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
@@ -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(
package/dist/index.d.mts CHANGED
@@ -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[]>;
package/dist/index.d.ts CHANGED
@@ -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[]>;
package/dist/index.js CHANGED
@@ -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.2",
3
+ "version": "1.17.4",
4
4
  "description": "Pump Bonding Curve SDK",
5
5
  "keywords": [],
6
6
  "homepage": "https://github.com/pump-fun/pump-sdk#readme",
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,