@bropump/sdk 0.2.1 → 0.2.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BroPump
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,56 +1,210 @@
1
1
  # @bropump/sdk
2
2
 
3
- TypeScript SDK for the BroPump API.
3
+ TypeScript SDK for BroPump launches, fee previews, and realtime launch sessions.
4
4
 
5
5
  ## Install
6
6
 
7
- Install from public npmjs:
8
-
9
7
  ```bash
10
8
  npm install @bropump/sdk
11
9
  ```
12
10
 
13
- ## Example
11
+ ## Create a Client
12
+
13
+ Use the built-in network presets for the normal app environments:
14
14
 
15
15
  ```ts
16
16
  import { BroPumpClient } from '@bropump/sdk'
17
17
 
18
+ const mainnet = new BroPumpClient({ network: 'mainnet' })
19
+ const devnet = new BroPumpClient({ network: 'devnet' })
20
+ ```
21
+
22
+ The SDK resolves hosts automatically:
23
+
24
+ - `mainnet` -> `https://api.bropump.run`
25
+ - `devnet` -> `https://dev.bropump.run`
26
+
27
+ If you need local or preview infrastructure, keep using `baseUrl` as an override:
28
+
29
+ ```ts
18
30
  const client = new BroPumpClient({
19
- network: 'mainnet',
31
+ network: 'devnet',
32
+ baseUrl: 'http://localhost:3001',
20
33
  })
34
+ ```
35
+
36
+ ## Launch Modes
37
+
38
+ Launch modes are the current available token fee, liquidity, and bonding setups.
39
+
40
+ Fetch the currently available launch modes from the API:
41
+
42
+ ```ts
43
+ const launchConfig = await client.launchConfig.get()
44
+
45
+ console.log(launchConfig.defaultLaunchMode)
46
+ console.log(launchConfig.availableLaunchModes)
47
+ console.log(launchConfig.launchModeOptions)
48
+ ```
49
+
50
+ Each option includes:
51
+
52
+ - `launchMode`, for example `MAINNET_CONFIG_25`
53
+ - `migrationThreshold`, the resolved quote target behind that mode
54
+ - `configAddress`
55
+ - `deploymentMode`
56
+
57
+ ## Launch a Token
58
+
59
+ ```ts
60
+ import { BroPumpClient, BroPumpTokenFailedError } from '@bropump/sdk'
61
+
62
+ const client = new BroPumpClient({ network: 'devnet' })
21
63
 
22
64
  const token = await client.tokens.create({
65
+ mode: 'live',
23
66
  name: 'Bro Pump',
24
67
  symbol: 'BRO',
25
68
  description: 'Simple token flow',
26
69
  deployer: 'YOUR_WALLET',
27
- migrationThreshold: 35,
70
+ launchMode: 'DEVNET_CONFIG_1',
71
+ firstBuyAmount: 0.25,
28
72
  image: new Blob(['demo'], { type: 'image/png' }),
29
73
  })
30
74
 
31
- const ready = await client.tokens.waitForReadyToSign(token.id)
75
+ try {
76
+ const ready = await client.tokens.waitForReadyToSign(token.id)
77
+
78
+ await client.tokens.submitSigned(token.id, {
79
+ submitId: ready.submit.id,
80
+ signedTransactions: [
81
+ /* signed base64 transactions */
82
+ ],
83
+ })
84
+
85
+ const live = await client.tokens.waitForLive(token.id)
86
+ console.log(live.pool, live.mint)
87
+ } catch (error) {
88
+ if (error instanceof BroPumpTokenFailedError) {
89
+ console.error(error.token.error)
90
+ }
91
+ throw error
92
+ }
93
+ ```
32
94
 
33
- await client.tokens.submitSigned(token.id, {
34
- submitId: ready.submit.id,
35
- signedTransactions: ready.submit.transactions.map((tx) => tx),
95
+ ## Preview Fees and Curve Data
96
+
97
+ ```ts
98
+ const preview = await client.fees.preview({
99
+ launchMode: 'MAINNET_CONFIG_25',
100
+ firstBuyAmount: 0.5,
101
+ deployerWallet: 'YOUR_WALLET',
36
102
  })
103
+
104
+ console.log(preview.selectedLaunchMode)
105
+ console.log(preview.curve.migrationThreshold)
106
+ console.log(preview.costQuote.recommendedMinBalanceSol)
107
+ ```
108
+
109
+ ## Polling Helpers
110
+
111
+ The SDK includes built-in polling helpers for the common launch lifecycle checkpoints:
112
+
113
+ - `client.tokens.waitForReadyToSign(id, options)`
114
+ - `client.tokens.waitForLive(id, options)`
115
+ - `client.tokens.waitFor(id, predicate, options)`
116
+
117
+ All wait helpers accept:
118
+
119
+ - `timeoutMs`
120
+ - `pollIntervalMs`
121
+ - `signal`
122
+ - `stopOnFailed`
123
+
124
+ ## Realtime / WSS
125
+
126
+ You do not need to manage a separate websocket host manually. The SDK derives `ws://` or `wss://`
127
+ from the API base URL automatically for both `mainnet` and `devnet`.
128
+
129
+ ### Watch a Token Session
130
+
131
+ ```ts
132
+ const stream = await client.tokens.watch(token.id)
133
+
134
+ for await (const message of stream) {
135
+ console.log(message.type, message.data)
136
+
137
+ if (message.type === 'token_update' && message.data?.status === 'live') {
138
+ break
139
+ }
140
+ }
141
+
142
+ stream.close()
37
143
  ```
38
144
 
39
- Use `network: 'devnet'` for the dev environment:
145
+ ### Wait for a Specific Realtime Event
40
146
 
41
147
  ```ts
42
- const client = new BroPumpClient({
43
- network: 'devnet',
44
- })
148
+ const stream = await client.tokens.watch(token.id)
149
+
150
+ const readyMessage = await stream.waitFor(
151
+ (message) =>
152
+ message.type === 'token_update' &&
153
+ Boolean(message.data?.submit?.id),
154
+ 30_000
155
+ )
156
+
157
+ console.log(readyMessage.data?.submit?.id)
158
+ stream.close()
45
159
  ```
46
160
 
47
- `baseUrl` remains available as an override for local or preview environments.
161
+ ### Watch a Pool Directly
48
162
 
49
- ## Publish
163
+ ```ts
164
+ const poolStream = await client.tokens.watchPool('POOL_ADDRESS')
50
165
 
51
- This package is set up to publish publicly to npmjs under `@bropump/sdk`.
166
+ for await (const message of poolStream) {
167
+ console.log(message.type, message.data?.runtime?.phase)
168
+ }
169
+ ```
52
170
 
53
- ```bash
54
- cd packages/sdk
55
- npm publish --access public --registry=https://registry.npmjs.org
171
+ Common message types:
172
+
173
+ - `token_snapshot`
174
+ - `token_update`
175
+ - `launch_snapshot`
176
+ - `launch_update`
177
+ - `runtime_snapshot`
178
+ - `runtime_update`
179
+
180
+ Use `client.tokens.watch(tokenId)` for a launch session and `client.tokens.watchPool(poolAddress)`
181
+ for a live pool stream.
182
+
183
+ ## Manual WSS URL Access
184
+
185
+ If you need the derived websocket URL for your own socket layer, use `buildWebSocketUrl`:
186
+
187
+ ```ts
188
+ import { buildWebSocketUrl } from '@bropump/sdk'
189
+
190
+ const wsUrl = buildWebSocketUrl('https://dev.bropump.run', '/tokens/123/ws')
56
191
  ```
192
+
193
+ ## Errors
194
+
195
+ Request failures throw `BroPumpApiError`:
196
+
197
+ ```ts
198
+ import { BroPumpApiError } from '@bropump/sdk'
199
+
200
+ try {
201
+ await client.health()
202
+ } catch (error) {
203
+ if (error instanceof BroPumpApiError) {
204
+ console.error(error.status, error.code, error.body)
205
+ }
206
+ }
207
+ ```
208
+
209
+ Lifecycle polling helpers throw `BroPumpTokenFailedError` when a token reaches `failed` while
210
+ you are waiting on it.
package/dist/client.js CHANGED
@@ -123,19 +123,21 @@ export class BroPumpClient {
123
123
  });
124
124
  }
125
125
  async previewFees(input, options) {
126
- return this.request({
126
+ const preview = await this.request({
127
127
  path: '/fees/preview',
128
128
  method: 'POST',
129
- body: input ?? {},
129
+ body: buildFeePreviewPayload(input),
130
130
  options,
131
131
  });
132
+ return normalizeCurvePreview(preview);
132
133
  }
133
134
  async getLaunchConfig(options) {
134
- return this.request({
135
+ const launchConfig = await this.request({
135
136
  path: '/launch-config',
136
137
  method: 'GET',
137
138
  options,
138
139
  });
140
+ return normalizeLaunchConfigView(launchConfig);
139
141
  }
140
142
  async getWalletBalance(address, options) {
141
143
  return this.request({
@@ -198,7 +200,8 @@ function buildCreateTokenFormData(input) {
198
200
  appendFormValue(form, 'symbol', input.symbol);
199
201
  appendFormValue(form, 'description', input.description);
200
202
  appendFormValue(form, 'deployer', input.deployer);
201
- appendFormValue(form, 'migrationThreshold', input.migrationThreshold);
203
+ appendFormValue(form, 'launchMode', input.launchMode);
204
+ appendFormValue(form, 'configMode', input.launchMode);
202
205
  appendFormValue(form, 'firstBuyAmount', input.firstBuyAmount);
203
206
  appendFormValue(form, 'x', input.x);
204
207
  appendFormValue(form, 'website', input.website);
@@ -212,6 +215,72 @@ function appendFormValue(form, key, value) {
212
215
  return;
213
216
  form.set(key, String(value));
214
217
  }
218
+ function buildFeePreviewPayload(input) {
219
+ if (!input)
220
+ return {};
221
+ return {
222
+ ...input,
223
+ ...(input.launchMode ? { configMode: input.launchMode } : {}),
224
+ };
225
+ }
226
+ function normalizeLaunchModeOption(input) {
227
+ const launchMode = typeof input.launchMode === 'string'
228
+ ? input.launchMode
229
+ : typeof input.configMode === 'string'
230
+ ? input.configMode
231
+ : '';
232
+ return {
233
+ launchMode,
234
+ migrationThreshold: Number(input.migrationThreshold ?? 0),
235
+ configAddress: typeof input.configAddress === 'string' || input.configAddress === null
236
+ ? input.configAddress
237
+ : null,
238
+ deploymentMode: input.deploymentMode === 'per-launch-config' ? 'per-launch-config' : 'predeployed-config',
239
+ };
240
+ }
241
+ function normalizeLaunchConfigView(input) {
242
+ const optionRows = Array.isArray(input.launchModeOptions)
243
+ ? input.launchModeOptions
244
+ : Array.isArray(input.configModeOptions)
245
+ ? input.configModeOptions
246
+ : [];
247
+ const launchModeOptions = optionRows
248
+ .filter((value) => Boolean(value) && typeof value === 'object')
249
+ .map(normalizeLaunchModeOption);
250
+ return {
251
+ network: input.network === 'devnet' ? 'devnet' : 'mainnet',
252
+ defaultLaunchMode: typeof input.defaultLaunchMode === 'string'
253
+ ? input.defaultLaunchMode
254
+ : typeof input.defaultConfigMode === 'string'
255
+ ? input.defaultConfigMode
256
+ : launchModeOptions[0]?.launchMode || '',
257
+ availableLaunchModes: Array.isArray(input.availableLaunchModes)
258
+ ? input.availableLaunchModes.filter((value) => typeof value === 'string')
259
+ : Array.isArray(input.availableConfigModes)
260
+ ? input.availableConfigModes.filter((value) => typeof value === 'string')
261
+ : launchModeOptions.map((option) => option.launchMode),
262
+ launchModeOptions,
263
+ };
264
+ }
265
+ function normalizeCurvePreview(input) {
266
+ const optionRows = Array.isArray(input.launchModeOptions)
267
+ ? input.launchModeOptions
268
+ : Array.isArray(input.configModeOptions)
269
+ ? input.configModeOptions
270
+ : [];
271
+ const launchModeOptions = optionRows
272
+ .filter((value) => Boolean(value) && typeof value === 'object')
273
+ .map(normalizeLaunchModeOption);
274
+ return {
275
+ ...input,
276
+ launchModeOptions,
277
+ selectedLaunchMode: typeof input.selectedLaunchMode === 'string'
278
+ ? input.selectedLaunchMode
279
+ : typeof input.selectedConfigMode === 'string'
280
+ ? input.selectedConfigMode
281
+ : launchModeOptions[0]?.launchMode || '',
282
+ };
283
+ }
215
284
  function toImagePart(image) {
216
285
  if (isBlob(image)) {
217
286
  return {
package/dist/types.d.ts CHANGED
@@ -38,7 +38,7 @@ export type CreateTokenInput = {
38
38
  symbol: string;
39
39
  description: string;
40
40
  deployer: string;
41
- migrationThreshold?: number;
41
+ launchMode?: string;
42
42
  firstBuyAmount?: number;
43
43
  x?: string;
44
44
  website?: string;
@@ -90,19 +90,17 @@ export type LaunchCostQuote = {
90
90
  };
91
91
  breakdown: LaunchCostBreakdown;
92
92
  };
93
- export type MigrationThresholdOption = {
93
+ export type LaunchModeOption = {
94
+ launchMode: string;
94
95
  migrationThreshold: number;
95
- presetBinding: string;
96
96
  configAddress: string | null;
97
97
  deploymentMode: 'predeployed-config' | 'per-launch-config';
98
98
  };
99
99
  export type LaunchConfigView = {
100
100
  network: 'devnet' | 'mainnet';
101
- defaultMigrationThreshold: number;
102
- allowedMigrationThresholds: number[];
103
- availableMigrationThresholds: number[];
104
- migrationThresholdOptions: MigrationThresholdOption[];
105
- availableMigrationThresholdOptions: MigrationThresholdOption[];
101
+ defaultLaunchMode: string;
102
+ availableLaunchModes: string[];
103
+ launchModeOptions: LaunchModeOption[];
106
104
  };
107
105
  export type SubmitAction = {
108
106
  id: string;
@@ -159,9 +157,8 @@ export type RealtimeMessage<T> = {
159
157
  data: T | null;
160
158
  };
161
159
  export type CurvePreview = {
162
- allowedMigrationThresholds: number[];
163
- migrationThresholdOptions: MigrationThresholdOption[];
164
- selectedMigrationThreshold: number;
160
+ launchModeOptions: LaunchModeOption[];
161
+ selectedLaunchMode: string;
165
162
  curve: {
166
163
  startingMC: number;
167
164
  endingMC: number;
@@ -202,7 +199,7 @@ export type CurvePreview = {
202
199
  };
203
200
  export type FeePreviewRequest = {
204
201
  totalSupply?: string;
205
- migrationThreshold?: number;
202
+ launchMode?: string;
206
203
  firstBuyAmount?: number;
207
204
  deployerWallet?: string;
208
205
  };
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@bropump/sdk",
3
- "version": "0.2.1",
4
- "description": "TypeScript SDK for the BroPump API",
5
- "license": "UNLICENSED",
3
+ "version": "0.2.3",
4
+ "description": "TypeScript SDK for BroPump launches, fee previews, and realtime sessions",
5
+ "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": false,
8
8
  "main": "./dist/index.js",
9
9
  "types": "./dist/index.d.ts",
10
10
  "files": [
11
11
  "dist",
12
- "README.md"
12
+ "README.md",
13
+ "LICENSE"
13
14
  ],
14
15
  "repository": {
15
16
  "type": "git",
@@ -21,7 +22,8 @@
21
22
  "sdk",
22
23
  "typescript",
23
24
  "api",
24
- "cloudflare"
25
+ "launches",
26
+ "solana"
25
27
  ],
26
28
  "engines": {
27
29
  "node": ">=18"