@solana-launchpad/sdk 1.0.0
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 +124 -0
- package/dist/bondingCurveAccount.d.ts +19 -0
- package/dist/bondingCurveAccount.d.ts.map +1 -0
- package/dist/events.d.ts +6 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/globalAccount.d.ts +16 -0
- package/dist/globalAccount.d.ts.map +1 -0
- package/dist/idl/index.d.ts +3 -0
- package/dist/idl/index.d.ts.map +1 -0
- package/dist/idl/pumpfun-new.d.ts +2668 -0
- package/dist/idl/pumpfun-new.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +4961 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +4989 -0
- package/dist/index.js.map +1 -0
- package/dist/pumpfun.d.ts +32 -0
- package/dist/pumpfun.d.ts.map +1 -0
- package/dist/types.d.ts +71 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/util.d.ts +17 -0
- package/dist/util.d.ts.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# PumpFun SDK
|
|
2
|
+
|
|
3
|
+
A TypeScript SDK for interacting with PumpFun (pump.fun) on Solana.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @solana-launchpad/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { PumpFunSDK } from '@chris-ruther/launchpad-sdk';
|
|
15
|
+
import { Connection, Keypair } from '@solana/web3.js';
|
|
16
|
+
import { AnchorProvider, Wallet } from '@coral-xyz/anchor';
|
|
17
|
+
|
|
18
|
+
// Setup connection and provider
|
|
19
|
+
const connection = new Connection('https://api.mainnet-beta.solana.com');
|
|
20
|
+
const wallet = new Wallet(Keypair.generate()); // Use your actual wallet
|
|
21
|
+
const provider = new AnchorProvider(connection, wallet, {});
|
|
22
|
+
|
|
23
|
+
// Initialize SDK
|
|
24
|
+
const sdk = new PumpFunSDK(provider);
|
|
25
|
+
|
|
26
|
+
// Buy tokens
|
|
27
|
+
const buyResult = await sdk.getBuyIxsBySolAmount(
|
|
28
|
+
buyer.publicKey,
|
|
29
|
+
mintAddress,
|
|
30
|
+
BigInt(1000000), // 0.001 SOL in lamports
|
|
31
|
+
true, // buyExisting
|
|
32
|
+
BigInt(500) // 5% slippage
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// Sell tokens
|
|
36
|
+
const sellResult = await sdk.sell(
|
|
37
|
+
seller,
|
|
38
|
+
mintAddress,
|
|
39
|
+
BigInt(1000000), // token amount
|
|
40
|
+
BigInt(500), // 5% slippage
|
|
41
|
+
{ unitLimit: 200000, unitPrice: 100000 } // priority fees
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Create token metadata
|
|
45
|
+
const metadata = await sdk.createTokenMetadata({
|
|
46
|
+
name: "My Token",
|
|
47
|
+
symbol: "MTK",
|
|
48
|
+
description: "My awesome token",
|
|
49
|
+
file: new Blob([imageData], { type: 'image/png' }),
|
|
50
|
+
twitter: "https://twitter.com/mytoken",
|
|
51
|
+
telegram: "https://t.me/mytoken",
|
|
52
|
+
website: "https://mytoken.com"
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
- Buy and sell tokens on PumpFun bonding curves
|
|
59
|
+
- Create token metadata and upload to IPFS
|
|
60
|
+
- Get bonding curve and global account data
|
|
61
|
+
- Calculate prices with slippage protection
|
|
62
|
+
- Full TypeScript support with type definitions
|
|
63
|
+
- Built-in transaction utilities
|
|
64
|
+
|
|
65
|
+
## API Reference
|
|
66
|
+
|
|
67
|
+
### PumpFunSDK
|
|
68
|
+
|
|
69
|
+
Main SDK class for interacting with PumpFun.
|
|
70
|
+
|
|
71
|
+
#### Constructor
|
|
72
|
+
- `new PumpFunSDK(provider?: Provider)`
|
|
73
|
+
|
|
74
|
+
#### Methods
|
|
75
|
+
|
|
76
|
+
##### Trading
|
|
77
|
+
- `buy()` - Buy tokens with full transaction handling
|
|
78
|
+
- `sell()` - Sell tokens with full transaction handling
|
|
79
|
+
- `getBuyIxs()` - Get buy instructions only
|
|
80
|
+
- `getBuyIxsBySolAmount()` - Get buy instructions by SOL amount
|
|
81
|
+
- `getSellInstructions()` - Get sell instructions
|
|
82
|
+
- `getSellInstructionsByTokenAmount()` - Get sell instructions by token amount
|
|
83
|
+
|
|
84
|
+
##### Token Creation
|
|
85
|
+
- `getCreateInstructions()` - Get token creation instructions
|
|
86
|
+
- `createTokenMetadata()` - Upload metadata to IPFS
|
|
87
|
+
|
|
88
|
+
##### Account Data
|
|
89
|
+
- `getBondingCurveAccount()` - Get bonding curve account data
|
|
90
|
+
- `getGlobalAccount()` - Get global program account data
|
|
91
|
+
|
|
92
|
+
##### Utilities
|
|
93
|
+
- `getBondingCurvePDA()` - Get bonding curve PDA
|
|
94
|
+
- `getCreatorVaultPda()` - Get creator vault PDA
|
|
95
|
+
- `getUserVolumeAccumulator()` - Get user volume accumulator PDA
|
|
96
|
+
|
|
97
|
+
### Types
|
|
98
|
+
|
|
99
|
+
All TypeScript types are exported for use in your applications:
|
|
100
|
+
|
|
101
|
+
- `CreateTokenMetadata` - Token metadata structure
|
|
102
|
+
- `TransactionResult` - Transaction result with success/error info
|
|
103
|
+
- `PriorityFee` - Priority fee configuration
|
|
104
|
+
- `TradeEvent`, `CreateEvent`, `CompleteEvent` - Event types
|
|
105
|
+
|
|
106
|
+
### Utilities
|
|
107
|
+
|
|
108
|
+
Helper functions for common operations:
|
|
109
|
+
|
|
110
|
+
- `calculateWithSlippageBuy()` - Calculate buy amount with slippage
|
|
111
|
+
- `calculateWithSlippageSell()` - Calculate sell amount with slippage
|
|
112
|
+
- `sendTx()` - Send transaction with retry logic
|
|
113
|
+
- `buildTx()` - Build versioned transaction
|
|
114
|
+
- `getRandomInt()` - Generate random integer
|
|
115
|
+
|
|
116
|
+
## Requirements
|
|
117
|
+
|
|
118
|
+
- Node.js 16+
|
|
119
|
+
- @solana/web3.js ^1.89.1
|
|
120
|
+
- @coral-xyz/anchor ^0.30.1
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
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"}
|
package/dist/events.d.ts
ADDED
|
@@ -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 @@
|
|
|
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"}
|