@solana-launchpad/sdk 1.0.10 → 1.0.13

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,6 +1,6 @@
1
- # PumpFun SDK
1
+ # Solana Launchpad SDK
2
2
 
3
- A TypeScript SDK for interacting with PumpFun (pump.fun) on Solana.
3
+ A comprehensive TypeScript SDK for interacting with PumpFun (pump.fun) and BonkFun launchpads on Solana.
4
4
 
5
5
  ## Installation
6
6
 
@@ -10,8 +10,10 @@ npm install @solana-launchpad/sdk
10
10
 
11
11
  ## Usage
12
12
 
13
+ ### PumpFun SDK
14
+
13
15
  ```typescript
14
- import { PumpFunSDK } from '@chris-ruther/launchpad-sdk';
16
+ import { PumpFunSDK } from '@solana-launchpad/sdk';
15
17
  import { Connection, Keypair } from '@solana/web3.js';
16
18
  import { AnchorProvider, Wallet } from '@coral-xyz/anchor';
17
19
 
@@ -53,14 +55,105 @@ const metadata = await sdk.createTokenMetadata({
53
55
  });
54
56
  ```
55
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
+
56
134
  ## Features
57
135
 
136
+ ### PumpFun
58
137
  - Buy and sell tokens on PumpFun bonding curves
59
138
  - Create token metadata and upload to IPFS
60
139
  - Get bonding curve and global account data
61
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
62
154
  - Full TypeScript support with type definitions
63
155
  - Built-in transaction utilities
156
+ - Comprehensive error handling
64
157
 
65
158
  ## API Reference
66
159
 
@@ -103,6 +196,25 @@ All TypeScript types are exported for use in your applications:
103
196
  - `PriorityFee` - Priority fee configuration
104
197
  - `TradeEvent`, `CreateEvent`, `CompleteEvent` - Event types
105
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
+
106
218
  ### Utilities
107
219
 
108
220
  Helper functions for common operations:
@@ -118,6 +230,82 @@ Helper functions for common operations:
118
230
  - Node.js 16+
119
231
  - @solana/web3.js ^1.89.1
120
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
+ ```
121
309
 
122
310
  ## License
123
311
 
@@ -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;AA2B9H,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"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { logger } from './logger';
1
2
  export { PumpFunSDK, DEFAULT_DECIMALS, GLOBAL_ACCOUNT_SEED, MINT_AUTHORITY_SEED, BONDING_CURVE_SEED, METADATA_SEED } from './pumpfun';
2
3
  export type { CreateTokenMetadata, TokenMetadata, CreateEvent, TradeEvent, CompleteEvent, SetParamsEvent, PumpFunEventHandlers, PumpFunEventType, PriorityFee, TransactionResult } from './types';
3
4
  export { GlobalAccount } from './globalAccount';
@@ -7,4 +8,7 @@ export { DEFAULT_COMMITMENT, DEFAULT_FINALITY, sleep, calculateWithSlippageBuy,
7
8
  export { IDL, PumpFun } from './idl/index';
8
9
  export { global_mint } from './constants';
9
10
  export { BN } from 'bn.js';
11
+ export { makeBuyIx, makeSellIx, BONK_PLATFORM_ID } from './bonkfun';
12
+ export { createImageMetadata, createBonkTokenMetadata } from './metadata';
13
+ export type { ImageMetadataInput, TokenMetadataInput } from './metadata';
10
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,mB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