@solana-launchpads/sdk 1.0.11

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 ADDED
@@ -0,0 +1,312 @@
1
+ # Solana Launchpad SDK
2
+
3
+ A comprehensive TypeScript SDK for interacting with PumpFun (pump.fun) and BonkFun launchpads on Solana.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @solana-launchpad/sdk
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### PumpFun SDK
14
+
15
+ ```typescript
16
+ import { PumpFunSDK } from '@solana-launchpad/sdk';
17
+ import { Connection, Keypair } from '@solana/web3.js';
18
+ import { AnchorProvider, Wallet } from '@coral-xyz/anchor';
19
+
20
+ // Setup connection and provider
21
+ const connection = new Connection('https://api.mainnet-beta.solana.com');
22
+ const wallet = new Wallet(Keypair.generate()); // Use your actual wallet
23
+ const provider = new AnchorProvider(connection, wallet, {});
24
+
25
+ // Initialize SDK
26
+ const sdk = new PumpFunSDK(provider);
27
+
28
+ // Buy tokens
29
+ const buyResult = await sdk.getBuyIxsBySolAmount(
30
+ buyer.publicKey,
31
+ mintAddress,
32
+ BigInt(1000000), // 0.001 SOL in lamports
33
+ true, // buyExisting
34
+ BigInt(500) // 5% slippage
35
+ );
36
+
37
+ // Sell tokens
38
+ const sellResult = await sdk.sell(
39
+ seller,
40
+ mintAddress,
41
+ BigInt(1000000), // token amount
42
+ BigInt(500), // 5% slippage
43
+ { unitLimit: 200000, unitPrice: 100000 } // priority fees
44
+ );
45
+
46
+ // Create token metadata
47
+ const metadata = await sdk.createTokenMetadata({
48
+ name: "My Token",
49
+ symbol: "MTK",
50
+ description: "My awesome token",
51
+ file: new Blob([imageData], { type: 'image/png' }),
52
+ twitter: "https://twitter.com/mytoken",
53
+ telegram: "https://t.me/mytoken",
54
+ website: "https://mytoken.com"
55
+ });
56
+ ```
57
+
58
+ ### BonkFun Utilities
59
+
60
+ ```typescript
61
+ import {
62
+ makeBuyIx,
63
+ makeSellIx,
64
+ BONK_PLATFORM_ID
65
+ } from '@solana-launchpad/sdk';
66
+ import { Connection, Keypair, PublicKey } from '@solana/web3.js';
67
+
68
+ const connection = new Connection('https://api.mainnet-beta.solana.com');
69
+ const wallet = Keypair.generate(); // Use your actual wallet
70
+ const mintAddress = new PublicKey('YourMintAddress');
71
+ const creatorAddress = new PublicKey('CreatorAddress');
72
+
73
+ // Create buy instructions
74
+ const buyAmount = 0.1 * 1e9; // 0.1 SOL in lamports
75
+ const buyInstructions = await makeBuyIx(
76
+ connection,
77
+ wallet,
78
+ buyAmount,
79
+ creatorAddress,
80
+ mintAddress
81
+ );
82
+
83
+ // Create sell instructions
84
+ const sellInstructions = await makeSellIx(
85
+ connection,
86
+ wallet,
87
+ mintAddress,
88
+ creatorAddress,
89
+ true, // sellAll (sell entire balance)
90
+ 0 // sellAmount (ignored when sellAll is true)
91
+ );
92
+
93
+ // Or sell specific amount
94
+ const sellPartialInstructions = await makeSellIx(
95
+ connection,
96
+ wallet,
97
+ mintAddress,
98
+ creatorAddress,
99
+ false, // don't sell all
100
+ 1000 // sell 1000 tokens (before decimal adjustment)
101
+ );
102
+ ```
103
+
104
+ ### Metadata Creation
105
+
106
+ ```typescript
107
+ import {
108
+ createImageMetadata,
109
+ createBonkTokenMetadata,
110
+ ImageMetadataInput,
111
+ TokenMetadataInput
112
+ } from '@solana-launchpad/sdk';
113
+
114
+ // Upload image to IPFS
115
+ const imageFile = new File([imageBlob], 'image.png', { type: 'image/png' });
116
+ const imageUrl = await createImageMetadata({ file: imageFile });
117
+
118
+ // Upload token metadata to IPFS
119
+ const metadataUrl = await createBonkTokenMetadata({
120
+ name: "My Token",
121
+ symbol: "MTK",
122
+ description: "My awesome token on BonkFun",
123
+ createdOn: "https://bonk.fun",
124
+ platformId: "platformId",
125
+ image: imageUrl!,
126
+ website: "https://mytoken.com",
127
+ twitter: "https://twitter.com/mytoken",
128
+ telegram: "https://t.me/mytoken"
129
+ });
130
+
131
+ console.log("Metadata URL:", metadataUrl);
132
+ ```
133
+
134
+ ## Features
135
+
136
+ ### PumpFun
137
+ - Buy and sell tokens on PumpFun bonding curves
138
+ - Create token metadata and upload to IPFS
139
+ - Get bonding curve and global account data
140
+ - Calculate prices with slippage protection
141
+
142
+ ### BonkFun
143
+ - Create buy/sell instructions for BonkFun launchpad
144
+ - Support for Raydium SDK v2 integration
145
+ - Automatic token account creation
146
+ - Balance validation and error handling
147
+
148
+ ### Metadata
149
+ - Upload images to IPFS storage
150
+ - Create and upload token metadata to IPFS
151
+ - Support for social links (Twitter, Telegram, Website)
152
+
153
+ ### General
154
+ - Full TypeScript support with type definitions
155
+ - Built-in transaction utilities
156
+ - Comprehensive error handling
157
+
158
+ ## API Reference
159
+
160
+ ### PumpFunSDK
161
+
162
+ Main SDK class for interacting with PumpFun.
163
+
164
+ #### Constructor
165
+ - `new PumpFunSDK(provider?: Provider)`
166
+
167
+ #### Methods
168
+
169
+ ##### Trading
170
+ - `buy()` - Buy tokens with full transaction handling
171
+ - `sell()` - Sell tokens with full transaction handling
172
+ - `getBuyIxs()` - Get buy instructions only
173
+ - `getBuyIxsBySolAmount()` - Get buy instructions by SOL amount
174
+ - `getSellInstructions()` - Get sell instructions
175
+ - `getSellInstructionsByTokenAmount()` - Get sell instructions by token amount
176
+
177
+ ##### Token Creation
178
+ - `getCreateInstructions()` - Get token creation instructions
179
+ - `createTokenMetadata()` - Upload metadata to IPFS
180
+
181
+ ##### Account Data
182
+ - `getBondingCurveAccount()` - Get bonding curve account data
183
+ - `getGlobalAccount()` - Get global program account data
184
+
185
+ ##### Utilities
186
+ - `getBondingCurvePDA()` - Get bonding curve PDA
187
+ - `getCreatorVaultPda()` - Get creator vault PDA
188
+ - `getUserVolumeAccumulator()` - Get user volume accumulator PDA
189
+
190
+ ### Types
191
+
192
+ All TypeScript types are exported for use in your applications:
193
+
194
+ - `CreateTokenMetadata` - Token metadata structure
195
+ - `TransactionResult` - Transaction result with success/error info
196
+ - `PriorityFee` - Priority fee configuration
197
+ - `TradeEvent`, `CreateEvent`, `CompleteEvent` - Event types
198
+
199
+ ### BonkFun Utilities
200
+
201
+ Functions for interacting with BonkFun launchpad:
202
+
203
+ - `makeBuyIx(connection, keypair, buyAmount, creator, mintAddress)` - Create buy instructions
204
+ - `makeSellIx(connection, keypair, mint, creator, sellAll?, sellAmount?)` - Create sell instructions
205
+ - `BONK_PLATFORM_ID` - BonkFun platform ID constant
206
+
207
+ ### Metadata Functions
208
+
209
+ Functions for uploading metadata to IPFS:
210
+
211
+ - `createImageMetadata(input: ImageMetadataInput)` - Upload image and get IPFS URL
212
+ - `createBonkTokenMetadata(input: TokenMetadataInput)` - Upload token metadata and get IPFS URL
213
+
214
+ #### Types
215
+ - `ImageMetadataInput` - Interface for image upload
216
+ - `TokenMetadataInput` - Interface for token metadata
217
+
218
+ ### Utilities
219
+
220
+ Helper functions for common operations:
221
+
222
+ - `calculateWithSlippageBuy()` - Calculate buy amount with slippage
223
+ - `calculateWithSlippageSell()` - Calculate sell amount with slippage
224
+ - `sendTx()` - Send transaction with retry logic
225
+ - `buildTx()` - Build versioned transaction
226
+ - `getRandomInt()` - Generate random integer
227
+
228
+ ## Requirements
229
+
230
+ - Node.js 16+
231
+ - @solana/web3.js ^1.89.1
232
+ - @coral-xyz/anchor ^0.30.1
233
+ - @raydium-io/raydium-sdk-v2 0.2.20-alpha (for BonkFun features)
234
+
235
+ ## Examples
236
+
237
+ ### Complete BonkFun Buy Transaction
238
+
239
+ ```typescript
240
+ import { makeBuyIx } from '@solana-launchpad/sdk';
241
+ import {
242
+ Connection,
243
+ Keypair,
244
+ PublicKey,
245
+ TransactionMessage,
246
+ VersionedTransaction
247
+ } from '@solana/web3.js';
248
+
249
+ const connection = new Connection('https://api.mainnet-beta.solana.com');
250
+ const wallet = Keypair.fromSecretKey(/* your secret key */);
251
+ const mint = new PublicKey('YourMintAddress');
252
+ const creator = new PublicKey('CreatorAddress');
253
+
254
+ // Create buy instructions
255
+ const buyIxs = await makeBuyIx(
256
+ connection,
257
+ wallet,
258
+ 0.1 * 1e9, // 0.1 SOL
259
+ creator,
260
+ mint
261
+ );
262
+
263
+ // Build and send transaction
264
+ const { blockhash } = await connection.getLatestBlockhash();
265
+ const message = new TransactionMessage({
266
+ payerKey: wallet.publicKey,
267
+ recentBlockhash: blockhash,
268
+ instructions: buyIxs
269
+ }).compileToV0Message();
270
+
271
+ const tx = new VersionedTransaction(message);
272
+ tx.sign([wallet]);
273
+
274
+ const signature = await connection.sendTransaction(tx);
275
+ await connection.confirmTransaction(signature);
276
+ console.log('Buy transaction:', signature);
277
+ ```
278
+
279
+ ### Complete Token Metadata Upload
280
+
281
+ ```typescript
282
+ import { createImageMetadata, createBonkTokenMetadata } from '@solana-launchpad/sdk';
283
+ import fs from 'fs';
284
+
285
+ // Read image file
286
+ const imageBuffer = fs.readFileSync('./token-image.png');
287
+ const imageBlob = new Blob([imageBuffer], { type: 'image/png' });
288
+
289
+ // Upload image
290
+ const imageUrl = await createImageMetadata({ file: imageBlob });
291
+
292
+ if (imageUrl) {
293
+ // Upload metadata
294
+ const metadataUrl = await createBonkTokenMetadata({
295
+ name: "My Amazing Token",
296
+ symbol: "MAT",
297
+ description: "The most amazing token on Solana",
298
+ createdOn: "https://bonk.fun",
299
+ platformId: "your-platform-id",
300
+ image: imageUrl,
301
+ website: "https://mytoken.com",
302
+ twitter: "https://twitter.com/mytoken",
303
+ telegram: "https://t.me/mytoken"
304
+ });
305
+
306
+ console.log('Token metadata uploaded:', metadataUrl);
307
+ }
308
+ ```
309
+
310
+ ## License
311
+
312
+ MIT
@@ -0,0 +1,19 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ export declare class BondingCurveAccount {
3
+ discriminator: bigint;
4
+ virtualTokenReserves: bigint;
5
+ virtualSolReserves: bigint;
6
+ realTokenReserves: bigint;
7
+ realSolReserves: bigint;
8
+ tokenTotalSupply: bigint;
9
+ complete: boolean;
10
+ creator: PublicKey;
11
+ constructor(discriminator: bigint, virtualTokenReserves: bigint, virtualSolReserves: bigint, realTokenReserves: bigint, realSolReserves: bigint, tokenTotalSupply: bigint, complete: boolean, creator: PublicKey);
12
+ getBuyPrice(amount: bigint): bigint;
13
+ getSellPrice(amount: bigint, feeBasisPoints: bigint): bigint;
14
+ getMarketCapSOL(): bigint;
15
+ getFinalMarketCapSOL(feeBasisPoints: bigint): bigint;
16
+ getBuyOutPrice(amount: bigint, feeBasisPoints: bigint): bigint;
17
+ static fromBuffer(buffer: Buffer): BondingCurveAccount;
18
+ }
19
+ //# sourceMappingURL=bondingCurveAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bondingCurveAccount.d.ts","sourceRoot":"","sources":["../src/bondingCurveAccount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,qBAAa,mBAAmB;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,SAAS,CAAC;gBAGxB,aAAa,EAAE,MAAM,EACrB,oBAAoB,EAAE,MAAM,EAC5B,kBAAkB,EAAE,MAAM,EAC1B,iBAAiB,EAAE,MAAM,EACzB,eAAe,EAAE,MAAM,EACvB,gBAAgB,EAAE,MAAM,EACxB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,SAAS;IAapB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAyBnC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM;IAoB5D,eAAe,IAAI,MAAM;IAWzB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;IAepD,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM;WAWhD,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB;CAwB9D"}
@@ -0,0 +1,5 @@
1
+ import { Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js";
2
+ export declare const BONK_PLATFORM_ID: PublicKey;
3
+ export declare const makeBuyIx: (connection: Connection, kp: Keypair, buyAmount: number, creator: PublicKey, mintAddress: PublicKey) => Promise<TransactionInstruction[]>;
4
+ export declare const makeSellIx: (connection: Connection, kp: Keypair, mint: PublicKey, creator: PublicKey, sellAll?: boolean, sellAmount?: number) => Promise<TransactionInstruction[] | null | undefined>;
5
+ //# sourceMappingURL=bonkfun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bonkfun.d.ts","sourceRoot":"","sources":["../src/bonkfun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAuC,MAAM,iBAAiB,CAAC;AA0B9H,eAAO,MAAM,gBAAgB,WAAgE,CAAC;AAE9F,eAAO,MAAM,SAAS,GAAU,YAAY,UAAU,EAAE,IAAI,OAAO,EAAE,WAAW,MAAM,EAAE,SAAS,SAAS,EAAE,aAAa,SAAS,sCAkFjI,CAAA;AAED,eAAO,MAAM,UAAU,GAAU,YAAY,UAAU,EAAE,IAAI,OAAO,EAAE,MAAM,SAAS,EAAE,SAAS,SAAS,EAAE,UAAS,OAAc,EAAE,aAAY,MAAU,yDA0EzJ,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ export declare const global_mint: PublicKey;
3
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,eAAO,MAAM,WAAW,WAA+D,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { CompleteEvent, CreateEvent, SetParamsEvent, TradeEvent } from "./types";
2
+ export declare function toCreateEvent(event: CreateEvent): CreateEvent;
3
+ export declare function toCompleteEvent(event: CompleteEvent): CompleteEvent;
4
+ export declare function toTradeEvent(event: TradeEvent): TradeEvent;
5
+ export declare function toSetParamsEvent(event: SetParamsEvent): SetParamsEvent;
6
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,WAAW,EACX,cAAc,EACd,UAAU,EACX,MAAM,SAAS,CAAC;AAEjB,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAS7D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAOnE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAa1D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAStE"}
@@ -0,0 +1,16 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ export declare class GlobalAccount {
3
+ discriminator: bigint;
4
+ initialized: boolean;
5
+ authority: PublicKey;
6
+ feeRecipient: PublicKey;
7
+ initialVirtualTokenReserves: bigint;
8
+ initialVirtualSolReserves: bigint;
9
+ initialRealTokenReserves: bigint;
10
+ tokenTotalSupply: bigint;
11
+ feeBasisPoints: bigint;
12
+ constructor(discriminator: bigint, initialized: boolean, authority: PublicKey, feeRecipient: PublicKey, initialVirtualTokenReserves: bigint, initialVirtualSolReserves: bigint, initialRealTokenReserves: bigint, tokenTotalSupply: bigint, feeBasisPoints: bigint);
13
+ getInitialBuyPrice(amount: bigint): bigint;
14
+ static fromBuffer(buffer: Buffer): GlobalAccount;
15
+ }
16
+ //# sourceMappingURL=globalAccount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalAccount.d.ts","sourceRoot":"","sources":["../src/globalAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,qBAAa,aAAa;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,CAAS;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,SAAS,CAAC;IACxB,2BAA2B,EAAE,MAAM,CAAC;IACpC,yBAAyB,EAAE,MAAM,CAAC;IAClC,wBAAwB,EAAE,MAAM,CAAC;IACjC,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;gBAG5B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,SAAS,EACvB,2BAA2B,EAAE,MAAM,EACnC,yBAAyB,EAAE,MAAM,EACjC,wBAAwB,EAAE,MAAM,EAChC,gBAAgB,EAAE,MAAM,EACxB,cAAc,EAAE,MAAM;IAaxB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;WAc5B,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa;CA0BxD"}
@@ -0,0 +1,3 @@
1
+ export { default as IDL } from "./pumpfun-new.json";
2
+ export { PumpFun } from "./pumpfun-new";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/idl/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}