pump-kit 0.0.5 → 0.0.7
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 +78 -69
- package/dist/index.js +0 -2
- package/package.json +2 -2
- package/dist/index.js.map +0 -173
package/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
1
|
# Pump Kit
|
|
4
2
|
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="@pump-kit.png" alt="Pump Kit" width="600" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
5
7
|
<p align="center">
|
|
6
8
|
<a href="https://www.npmjs.com/package/pump-kit">
|
|
7
|
-
<img src="https://img.shields.io/
|
|
8
|
-
</a>
|
|
9
|
-
<a href="https://www.npmjs.com/package/pump-kit">
|
|
10
|
-
<img src="https://img.shields.io/npm/dm/pump-kit.svg?logo=npm&label=downloads" alt="npm downloads" />
|
|
9
|
+
<img src="https://img.shields.io/npm/v/pump-kit.svg?logo=npm&label=npm" alt="npm version" />
|
|
11
10
|
</a>
|
|
12
11
|
<a href="https://bun.sh">
|
|
13
12
|
<img src="https://img.shields.io/badge/bun-%3E%3D1.3.0-000000?logo=bun&logoColor=fff" alt="Bun >= 1.3.0" />
|
|
@@ -17,99 +16,75 @@
|
|
|
17
16
|
</a>
|
|
18
17
|
</p>
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
A lightweight TypeScript SDK for Pump.fun that handles all the lamport math for you. Work with human-readable SOL amounts, token counts, and wallet percentages.
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
## Features
|
|
23
22
|
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
23
|
+
- **Human-readable inputs** – Use SOL amounts and percentages instead of lamports
|
|
24
|
+
- **Automatic slippage protection** – Built-in guards for buy/sell operations
|
|
25
|
+
- **Token launches** – Create and buy tokens in one transaction
|
|
26
|
+
- **Liquidity management** – Add/remove liquidity with simple helpers
|
|
27
|
+
- **Full TypeScript support** – Strong types throughout
|
|
28
|
+
- **Bun-optimized** – Built and tested with Bun
|
|
28
29
|
|
|
29
30
|
---
|
|
30
31
|
|
|
31
32
|
## Installation
|
|
32
33
|
|
|
33
|
-
Install via npm:
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
npm install pump-kit
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
Or with Bun:
|
|
40
|
-
|
|
41
34
|
```bash
|
|
42
35
|
bun add pump-kit
|
|
43
36
|
```
|
|
44
37
|
|
|
45
|
-
Or with Yarn:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
yarn add pump-kit
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Or with pnpm:
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
pnpm add pump-kit
|
|
55
|
-
```
|
|
56
|
-
|
|
57
38
|
---
|
|
58
39
|
|
|
59
40
|
## Quick Start
|
|
60
41
|
|
|
61
|
-
###
|
|
42
|
+
### Setup
|
|
62
43
|
|
|
63
44
|
```ts
|
|
64
|
-
import { buy } from "pump-kit";
|
|
65
45
|
import { createSolanaRpc } from "@solana/kit";
|
|
66
46
|
|
|
67
|
-
const rpc = createSolanaRpc("https://
|
|
47
|
+
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Buy Tokens
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { buy } from "pump-kit";
|
|
68
54
|
|
|
69
55
|
await buy({
|
|
70
56
|
user: myWallet,
|
|
71
57
|
mint: "TokenMintAddress",
|
|
72
|
-
solAmount: 0.5,
|
|
73
|
-
slippageBps:
|
|
58
|
+
solAmount: 0.5, // 0.5 SOL
|
|
59
|
+
slippageBps: 50, // 0.5% slippage (optional)
|
|
74
60
|
rpc,
|
|
75
61
|
});
|
|
76
62
|
```
|
|
77
63
|
|
|
78
|
-
### Sell Tokens
|
|
64
|
+
### Sell Tokens
|
|
79
65
|
|
|
80
66
|
```ts
|
|
81
67
|
import { sell } from "pump-kit";
|
|
82
68
|
|
|
83
|
-
// Sell
|
|
69
|
+
// Sell specific amount
|
|
84
70
|
await sell({
|
|
85
71
|
user: myWallet,
|
|
86
72
|
mint: "TokenMintAddress",
|
|
87
|
-
tokenAmount: 125_000,
|
|
73
|
+
tokenAmount: 125_000,
|
|
88
74
|
rpc,
|
|
89
75
|
});
|
|
90
76
|
|
|
91
|
-
// Sell
|
|
77
|
+
// Sell percentage of wallet
|
|
92
78
|
await sell({
|
|
93
79
|
user: myWallet,
|
|
94
80
|
mint: "TokenMintAddress",
|
|
95
81
|
useWalletPercentage: true,
|
|
96
|
-
walletPercentage: 40,
|
|
82
|
+
walletPercentage: 40, // Sell 40% of holdings
|
|
97
83
|
rpc,
|
|
98
84
|
});
|
|
99
85
|
```
|
|
100
86
|
|
|
101
|
-
###
|
|
102
|
-
|
|
103
|
-
```ts
|
|
104
|
-
import { quickBuy, quickSell } from "pump-kit";
|
|
105
|
-
|
|
106
|
-
const buyInstruction = await quickBuy(myWallet, "TokenMint", 0.25, { rpc });
|
|
107
|
-
const sellInstruction = await quickSell(myWallet, "TokenMint", 100_000, { rpc });
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
> **Note:** The quick helpers require an RPC client. Always pass `{ rpc }` (and any optional overrides) as the final argument.
|
|
111
|
-
|
|
112
|
-
### Mint New Token
|
|
87
|
+
### Create and Buy Token
|
|
113
88
|
|
|
114
89
|
```ts
|
|
115
90
|
import { mintWithFirstBuy } from "pump-kit";
|
|
@@ -124,36 +99,70 @@ const { createInstruction, buyInstruction } = await mintWithFirstBuy({
|
|
|
124
99
|
name: "My Token",
|
|
125
100
|
symbol: "MTK",
|
|
126
101
|
uri: "https://arweave.net/metadata.json",
|
|
127
|
-
firstBuyTokenAmount: 1_000_000,
|
|
128
|
-
firstBuySolBudget: 1.
|
|
102
|
+
firstBuyTokenAmount: 1_000_000,
|
|
103
|
+
firstBuySolBudget: 1.0,
|
|
129
104
|
rpc,
|
|
130
105
|
});
|
|
131
106
|
```
|
|
132
107
|
|
|
133
|
-
|
|
108
|
+
### Quick Helpers
|
|
134
109
|
|
|
135
|
-
|
|
110
|
+
```ts
|
|
111
|
+
import { quickBuy, quickSell } from "pump-kit";
|
|
112
|
+
|
|
113
|
+
// Get buy instruction
|
|
114
|
+
const buyIx = await quickBuy(myWallet, "TokenMint", 0.25, { rpc });
|
|
136
115
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
- **Composable** – Works alongside your existing transaction flow; no global configuration
|
|
116
|
+
// Get sell instruction
|
|
117
|
+
const sellIx = await quickSell(myWallet, "TokenMint", 100_000, { rpc });
|
|
118
|
+
```
|
|
141
119
|
|
|
142
|
-
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## API Reference
|
|
123
|
+
|
|
124
|
+
### Core Functions
|
|
143
125
|
|
|
144
126
|
```ts
|
|
127
|
+
// Buy tokens
|
|
128
|
+
buy({ user, mint, solAmount, slippageBps?, rpc, ... })
|
|
129
|
+
|
|
130
|
+
// Sell tokens
|
|
131
|
+
sell({ user, mint, tokenAmount?, useWalletPercentage?, walletPercentage?, rpc, ... })
|
|
132
|
+
|
|
133
|
+
// Quick helpers (return instructions only)
|
|
145
134
|
quickBuy(wallet, mint, solAmount, { rpc, ...options })
|
|
146
135
|
quickSell(wallet, mint, tokenAmount, { rpc, ...options })
|
|
147
136
|
|
|
148
|
-
|
|
149
|
-
|
|
137
|
+
// Create token with initial buy
|
|
138
|
+
mintWithFirstBuy({ user, mint, name, symbol, uri, firstBuyTokenAmount, firstBuySolBudget, rpc, ... })
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Liquidity Management
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
// Add liquidity to pool
|
|
145
|
+
addLiquidity({ user, baseMint, quoteMint?, maxBaseAmountIn, maxQuoteAmountIn, rpc, ... })
|
|
146
|
+
|
|
147
|
+
// Remove liquidity from pool
|
|
148
|
+
removeLiquidity({ user, baseMint, quoteMint?, lpAmountIn, rpc, ... })
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Transaction Utilities
|
|
150
152
|
|
|
153
|
+
```ts
|
|
154
|
+
// Build transaction
|
|
151
155
|
buildTransaction({ instructions, payer, prependInstructions?, appendInstructions?, rpc })
|
|
156
|
+
|
|
157
|
+
// Send and confirm
|
|
152
158
|
sendAndConfirmTransaction({ instructions, payer, rpc, rpcSubscriptions, ... })
|
|
159
|
+
|
|
160
|
+
// Simulate transaction
|
|
153
161
|
simulateTransaction({ instructions, payer, rpc, options? })
|
|
162
|
+
```
|
|
154
163
|
|
|
155
|
-
|
|
156
|
-
removeLiquidity({ user, baseMint, quoteMint?, lpAmountIn, ... })
|
|
164
|
+
---
|
|
157
165
|
|
|
158
|
-
|
|
159
|
-
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -21,5 +21,3 @@ Message: ${P}.
|
|
|
21
21
|
Program logs:
|
|
22
22
|
${f.slice(0,10).join(`
|
|
23
23
|
`)}`}throw Error(o)}catch(p){let c=g.err&&typeof g.err==="object"?JSON.stringify(g.err,(o,f)=>typeof f==="bigint"?f.toString():f):String(g.err);throw Error(`Transaction failed: ${c}`)}return{signature:E,slot:g?.slot??null}}async function sI({instructions:T,payer:A,additionalSigners:P=[],latestBlockhash:Q,lastValidBlockHeight:C,version:W,prependInstructions:G,appendInstructions:J,priorityFees:$,rpc:X,commitment:Z=JT(),options:R={}}){let D=await LW({instructions:T,payer:A,additionalSigners:P,latestBlockhash:Q,lastValidBlockHeight:C,version:W,prependInstructions:G,appendInstructions:J,priorityFees:$,rpc:X,commitment:Z}),z=await XQ(D.transactionMessage),S=D6(z),E={commitment:R.commitment??Z};if(R.minContextSlot!==void 0)E.minContextSlot=BigInt(R.minContextSlot);if(R.sigVerify!==void 0)E.sigVerify=R.sigVerify;if(R.replaceRecentBlockhash!==void 0){if(R.sigVerify)throw Error("replaceRecentBlockhash cannot be true when sigVerify is enabled.");E.replaceRecentBlockhash=R.replaceRecentBlockhash}if(R.accounts)E.accounts=R.accounts;let w=await X.simulateTransaction(S,E).send();return{context:{slot:Number(w.context.slot)},value:{err:w.value.err,logs:w.value.logs,unitsConsumed:w.value.unitsConsumed!==void 0?Number(w.value.unitsConsumed):void 0,accounts:w.value.accounts,returnData:w.value.returnData??void 0}}}function tI(T){return typeof T!=="string"&&S0(T)}function Nq(T){if(!T)return[];let A=[];if(T.computeUnitLimit!==void 0&&T.computeUnitLimit>0)A.push(eI(T.computeUnitLimit));if(T.computeUnitPriceMicroLamports!==void 0&&BigInt(T.computeUnitPriceMicroLamports)>0n)A.push(TS(BigInt(T.computeUnitPriceMicroLamports)));return A}function eI(T){let A=new Uint8Array(5);return A[0]=0,new DataView(A.buffer).setUint32(1,T,!0),{programAddress:Sq,accounts:[],data:A}}function TS(T){let A=new Uint8Array(9);return A[0]=3,new DataView(A.buffer).setBigUint64(1,T,!0),{programAddress:Sq,accounts:[],data:A}}async function AS(T){let{creator:A,metadata:P,firstBuyTokenAmount:Q,estimatedFirstBuyCost:C,slippageBps:W,feeRecipient:G,bondingCurveCreator:J,mintAuthority:$,mint:X,priorityFees:Z,prependInstructions:R,appendInstructions:D,additionalSigners:z,sendOptions:S,commitment:E=JT(),rpc:w,rpcSubscriptions:O}=T,m=X??await BJ(),g={user:A,mint:m,mintAuthority:$??A.address,name:P.name,symbol:P.symbol,uri:P.uri,firstBuyTokenAmount:Q,estimatedFirstBuyCost:C,slippageBps:W,feeRecipient:G,bondingCurveCreator:J??A.address,rpc:w,commitment:E},{createInstruction:p,buyInstruction:c}=await wW(g);return{...await EW({instructions:[p,c],payer:A,commitment:E,priorityFees:Z,prependInstructions:R,appendInstructions:D,additionalSigners:PS([m,...z??[]]),sendOptions:S,rpc:w,rpcSubscriptions:O}),mint:m,createInstruction:p,buyInstruction:c}}function PS(T){let A=new Set,P=[];for(let Q of T){let C=Q.address;if(!A.has(C))A.add(C),P.push(Q)}return P}var O4=new TextEncoder,B4=HT();async function BW(T,A,P,Q){let C=new Uint8Array(2);C[0]=T&255,C[1]=T>>8&255;let[W]=await j1({programAddress:b(N0),seeds:[O4.encode("pool"),C,B4.encode(b(A)),B4.encode(b(P)),B4.encode(b(Q))]});return W}async function OW(T){let[A]=await j1({programAddress:b(N0),seeds:[O4.encode("pool_lp_mint"),B4.encode(b(T))]});return A}async function xW(T,A){let[P]=await gJ({owner:T,mint:A});return P}async function h2(T,A,P){let[Q]=await MT({owner:T,mint:A,tokenProgram:P});return Q}async function _W(){let[T]=await j1({programAddress:b(N0),seeds:[O4.encode("global_config")]});return T}async function hW(){let[T]=await j1({programAddress:b(N0),seeds:[O4.encode("__event_authority")]});return T}var I1="pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA";function K0(T){if(!T)throw Error("Expected a Address.");if(typeof T==="object"&&"address"in T)return T.address;if(Array.isArray(T))return T[0];return T}function S1(T,A){return(P)=>{if(!P.value){if(A==="omitted")return;return Object.freeze({address:T,role:X1.READONLY})}let Q=P.isWritable?X1.WRITABLE:X1.READONLY;return Object.freeze({address:K0(P.value),role:wq(P.value)?X6(Q):Q,...wq(P.value)?{signer:P.value}:{}})}}function wq(T){return!!T&&typeof T==="object"&&"address"in T&&S0(T)}var Tg=new Uint8Array([242,40,117,145,73,96,105,104]);var Cg=new Uint8Array([209,11,115,87,213,23,124,204]);var Qv=new Uint8Array([102,6,61,18,1,218,235,234]);var Jv=new Uint8Array([198,46,21,82,180,217,232,112]);var Yv=new Uint8Array([16,4,71,28,204,1,40,27]);var Kv=new Uint8Array([249,69,164,218,150,103,84,138]);var Dv=new Uint8Array([160,57,89,42,181,139,43,66]);var Iv=new Uint8Array([201,207,243,114,75,111,47,189]);var Ev=new Uint8Array([233,146,209,142,207,104,64,188]);var WS=new Uint8Array([242,35,198,137,82,225,242,182]);function GS(){return lT(uT([["discriminator",iT(W0(),8)],["lpTokenAmountOut",DT()],["maxBaseAmountIn",DT()],["maxQuoteAmountIn",DT()]]),(T)=>({...T,discriminator:WS}))}function Lq(T,A){let P=A?.programAddress??I1,C={pool:{value:T.pool??null,isWritable:!0},globalConfig:{value:T.globalConfig??null,isWritable:!1},user:{value:T.user??null,isWritable:!1},baseMint:{value:T.baseMint??null,isWritable:!1},quoteMint:{value:T.quoteMint??null,isWritable:!1},lpMint:{value:T.lpMint??null,isWritable:!0},userBaseTokenAccount:{value:T.userBaseTokenAccount??null,isWritable:!0},userQuoteTokenAccount:{value:T.userQuoteTokenAccount??null,isWritable:!0},userPoolTokenAccount:{value:T.userPoolTokenAccount??null,isWritable:!0},poolBaseTokenAccount:{value:T.poolBaseTokenAccount??null,isWritable:!0},poolQuoteTokenAccount:{value:T.poolQuoteTokenAccount??null,isWritable:!0},tokenProgram:{value:T.tokenProgram??null,isWritable:!1},token2022Program:{value:T.token2022Program??null,isWritable:!1},eventAuthority:{value:T.eventAuthority??null,isWritable:!1},program:{value:T.program??null,isWritable:!1}},W={...T};if(!C.tokenProgram.value)C.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!C.token2022Program.value)C.token2022Program.value="TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";let G=S1(P,"programId");return Object.freeze({accounts:[G(C.pool),G(C.globalConfig),G(C.user),G(C.baseMint),G(C.quoteMint),G(C.lpMint),G(C.userBaseTokenAccount),G(C.userQuoteTokenAccount),G(C.userPoolTokenAccount),G(C.poolBaseTokenAccount),G(C.poolQuoteTokenAccount),G(C.tokenProgram),G(C.token2022Program),G(C.eventAuthority),G(C.program)],data:GS().encode(W),programAddress:P})}var vv=new Uint8Array([185,173,187,90,216,15,238,233]);var pv=new Uint8Array([234,102,194,203,150,72,62,229]);var cv=new Uint8Array([94,6,202,115,255,96,232,183]);var iv=new Uint8Array([51,230,133,164,1,127,131,173]);var ev=new Uint8Array([210,149,128,45,188,58,78,175]);var Qy=new Uint8Array([86,31,192,87,163,87,79,238]);var Uy=new Uint8Array([161,176,40,213,60,184,179,228]);var qy=new Uint8Array([104,184,103,242,88,151,107,20]);var US=new Uint8Array([183,18,70,156,148,109,161,34]);function JS(){return lT(uT([["discriminator",iT(W0(),8)],["lpTokenAmountIn",DT()],["minBaseAmountOut",DT()],["minQuoteAmountOut",DT()]]),(T)=>({...T,discriminator:US}))}function Eq(T,A){let P=A?.programAddress??I1,C={pool:{value:T.pool??null,isWritable:!0},globalConfig:{value:T.globalConfig??null,isWritable:!1},user:{value:T.user??null,isWritable:!1},baseMint:{value:T.baseMint??null,isWritable:!1},quoteMint:{value:T.quoteMint??null,isWritable:!1},lpMint:{value:T.lpMint??null,isWritable:!0},userBaseTokenAccount:{value:T.userBaseTokenAccount??null,isWritable:!0},userQuoteTokenAccount:{value:T.userQuoteTokenAccount??null,isWritable:!0},userPoolTokenAccount:{value:T.userPoolTokenAccount??null,isWritable:!0},poolBaseTokenAccount:{value:T.poolBaseTokenAccount??null,isWritable:!0},poolQuoteTokenAccount:{value:T.poolQuoteTokenAccount??null,isWritable:!0},tokenProgram:{value:T.tokenProgram??null,isWritable:!1},token2022Program:{value:T.token2022Program??null,isWritable:!1},eventAuthority:{value:T.eventAuthority??null,isWritable:!1},program:{value:T.program??null,isWritable:!1}},W={...T};if(!C.tokenProgram.value)C.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";if(!C.token2022Program.value)C.token2022Program.value="TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";let G=S1(P,"programId");return Object.freeze({accounts:[G(C.pool),G(C.globalConfig),G(C.user),G(C.baseMint),G(C.quoteMint),G(C.lpMint),G(C.userBaseTokenAccount),G(C.userQuoteTokenAccount),G(C.userPoolTokenAccount),G(C.poolBaseTokenAccount),G(C.poolQuoteTokenAccount),G(C.tokenProgram),G(C.token2022Program),G(C.eventAuthority),G(C.program)],data:JS().encode(W),programAddress:P})}var vy=new Uint8Array([241,154,109,4,17,177,109,188]);var by=new Uint8Array([149,8,156,202,160,252,176,217]);var Bq=0;async function Oq(T){let{user:A,baseMint:P,quoteMint:Q,index:C=Bq,poolAddress:W,poolCreator:G,maxBaseIn:J,maxQuoteIn:$,minLpOut:X=0n,tokenProgram:Z=FT,token2022Program:R=i8}=T;if(J<=0n)throw Error("maxBaseIn must be positive");if($<=0n)throw Error("maxQuoteIn must be positive");if(X<0n)throw Error("minLpOut cannot be negative");let D=b(A.address),z=b(P),S=b(Q),E=b(Z),w=b(R),O=W?b(W):await BW(C,b(G??D),z,S),m=await _W(),g=await OW(O),p=await xW(D,g),[c]=await MT({owner:D,tokenProgram:E,mint:z}),[o]=await MT({owner:D,tokenProgram:E,mint:S}),f=await h2(O,z,E),d=await h2(O,S,E),_=await hW();return Lq({pool:O,globalConfig:m,user:A,baseMint:z,quoteMint:S,lpMint:g,userBaseTokenAccount:c,userQuoteTokenAccount:o,userPoolTokenAccount:p,poolBaseTokenAccount:f,poolQuoteTokenAccount:d,tokenProgram:E,token2022Program:w,eventAuthority:_,program:b(N0),lpTokenAmountOut:X,maxBaseAmountIn:J,maxQuoteAmountIn:$},{programAddress:b(N0)})}async function xq(T){let{user:A,baseMint:P,quoteMint:Q,index:C=Bq,poolAddress:W,poolCreator:G,lpAmountIn:J,minBaseOut:$=0n,minQuoteOut:X=0n,tokenProgram:Z=FT,token2022Program:R=i8}=T;if(J<=0n)throw Error("lpAmountIn must be positive");if($<0n)throw Error("minBaseOut cannot be negative");if(X<0n)throw Error("minQuoteOut cannot be negative");let D=b(A.address),z=b(P),S=b(Q),E=b(Z),w=b(R),O=W?b(W):await BW(C,b(G??D),z,S),m=await _W(),g=await OW(O),p=await xW(D,g),[c]=await MT({owner:D,tokenProgram:E,mint:z}),[o]=await MT({owner:D,tokenProgram:E,mint:S}),f=await h2(O,z,E),d=await h2(O,S,E),_=await hW();return Eq({pool:O,globalConfig:m,user:A,baseMint:z,quoteMint:S,lpMint:g,userBaseTokenAccount:c,userQuoteTokenAccount:o,userPoolTokenAccount:p,poolBaseTokenAccount:f,poolQuoteTokenAccount:d,tokenProgram:E,token2022Program:w,eventAuthority:_,program:b(N0),lpTokenAmountIn:J,minBaseAmountOut:$,minQuoteAmountOut:X},{programAddress:b(N0)})}function $S(T){let{owner:A,amount:P,payer:Q=A,associatedTokenAddress:C,createAta:W=!0,autoClose:G=!1}=T;if(P<=0n)throw Error("Amount must be positive when wrapping SOL");let J=mW(A),$=mW(Q),X=C?new n(C):_2(new n(xA),J,!1,fT,v0),Z=[],R=[];if(W)Z.push(m2(N4($,X,J,new n(xA))));if(Z.push(m2(UT.transfer({fromPubkey:$,toPubkey:X,lamports:Number(P)}))),Z.push(m2(jq(X))),G)R.push(m2(SW(X,$,J)));return{prepend:Z,append:R,associatedTokenAddress:b(X.toBase58())}}function VS(T,A){let P=mW(T),Q=A?new n(A):_2(new n(xA),P,!1,fT,v0);return[m2(SW(Q,P,P))]}function mW(T){if(typeof T==="string")return new n(T);if(typeof T==="object"&&"address"in T)return new n(T.address);return new n(T)}function m2(T){return{programAddress:b(T.programId.toBase58()),accounts:T.keys.map((A)=>({address:b(A.pubkey.toBase58()),role:A.isSigner?A.isWritable?X1.WRITABLE_SIGNER:X1.READONLY_SIGNER:A.isWritable?X1.WRITABLE:X1.READONLY})),data:T.data}}var xA="So11111111111111111111111111111111111111112";var qS=xA;async function _q(T){let{user:A,baseMint:P,quoteMint:Q=xA,poolIndex:C,poolAddress:W,poolCreator:G,maxBaseAmountIn:J,maxQuoteAmountIn:$,minLpTokensOut:X,tokenProgram:Z,token2022Program:R}=T;if(J<=0n)throw Error("maxBaseAmountIn must be positive");if($<=0n)throw Error("maxQuoteAmountIn must be positive");return await Oq({user:A,baseMint:P,quoteMint:Q,index:C,poolAddress:W,poolCreator:G,maxBaseIn:J,maxQuoteIn:$,minLpOut:X??0n,tokenProgram:Z,token2022Program:R})}async function hq(T){let{user:A,baseMint:P,quoteMint:Q=xA,poolIndex:C,poolAddress:W,poolCreator:G,lpAmountIn:J,minBaseAmountOut:$,minQuoteAmountOut:X,tokenProgram:Z,token2022Program:R}=T;if(J<=0n)throw Error("lpAmountIn must be positive");return await xq({user:A,baseMint:P,quoteMint:Q,index:C,poolAddress:W,poolCreator:G,lpAmountIn:J,minBaseOut:$??0n,minQuoteOut:X??0n,tokenProgram:Z,token2022Program:R})}async function YS(T,A,P,Q,C={}){return _q({user:T,baseMint:A,maxBaseAmountIn:P,maxQuoteAmountIn:Q,...C})}async function ZS(T,A,P,Q={}){return hq({user:T,baseMint:A,lpAmountIn:P,...Q})}class gW{connection;programId;commitment;listeners=new Map;nextListenerId=1;subscriptionId=null;constructor(T,A={}){this.connection=T,this.programId=new n(A.programId??dT),this.commitment=A.commitment??"confirmed"}addEventListener(T,A){let P=this.nextListenerId++;return this.listeners.set(P,{id:P,type:T,callback:A}),this.ensureSubscription(),P}removeEventListener(T){if(this.listeners.delete(T),this.listeners.size===0)this.teardownSubscription()}ensureSubscription(){if(this.subscriptionId!==null)return;let T=(A,P)=>{this.dispatch(A,P.slot)};try{let A=this.connection.onLogs(this.programId,T,this.commitment);this.subscriptionId=A}catch(A){console.error("Failed to subscribe to Pump.fun logs",A)}}async teardownSubscription(){if(this.subscriptionId!==null){try{await this.connection.removeOnLogsListener(this.subscriptionId)}catch(T){console.warn("Failed to remove Pump.fun log listener",T)}this.subscriptionId=null}}dispatch(T,A){let P=T.signature??"";for(let Q of T.logs){let C=HS(Q,A,P);for(let W of this.listeners.values())if(W.type==="raw"||W.type===C.type)W.callback(C)}}}var XS={create:["createEvent","create_event"],trade:["tradeEvent","trade_event"],complete:["completeEvent","complete_event"],raw:[]};function HS(T,A,P){let Q="raw";for(let[G,J]of Object.entries(XS)){if(G==="raw")continue;if(J.some(($)=>T.includes($))){Q=G;break}}let C,W=T.indexOf("{");if(W!==-1){let G=T.slice(W);try{C=JSON.parse(G)}catch{C=void 0}}return{type:Q,slot:A,signature:P,rawLog:T,parsed:C}}function KS(T,A={}){return new gW(T,A)}export{E0 as validateSlippage,aI as validateMintParams,t8 as subSlippage,sI as simulateTransaction,jR as setDefaultCommitment,EW as sendAndConfirmTransaction,IR as sellWithSlippage,MQ as sellSimple,Iq as sell,hq as removeLiquidity,iI as quickSell,ZS as quickRemoveLiquidity,fI as quickBuy,YS as quickAddLiquidity,DR as percentToBps,wW as mintWithFirstBuy,JT as getDefaultCommitment,KS as createPumpEventManager,AS as createAndBuy,zR as buyWithSlippage,FQ as buySimple,zq as buy,$S as buildWrapSolInstructions,VS as buildUnwrapSolInstructions,LW as buildTransaction,Nq as buildPriorityFeeInstructions,FR as bpsToPercent,s8 as addSlippage,_q as addLiquidity,xA as WSOL_ADDRESS,qS as WSOL,gW as PumpEventManager,L0 as DEFAULT_SLIPPAGE_BPS};
|
|
24
|
-
|
|
25
|
-
//# debugId=DCD7DDBE1978EC3A64756E2164756E21
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pump-kit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"dev:typecheck": "tsc -p tsconfig.json --noEmit",
|
|
28
|
-
"build:js": "bun build ./src/index.ts --outdir dist --format esm --minify
|
|
28
|
+
"build:js": "bun build ./src/index.ts --outdir dist --format esm --minify",
|
|
29
29
|
"build:types": "tsc -p tsconfig.build.json",
|
|
30
30
|
"build": "rm -rf dist && bun run build:js && bun run build:types",
|
|
31
31
|
"release:prepare": "bun run build && bun run test",
|