@gala-chain/launchpad-sdk 0.4.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +628 -0
  3. package/dist/LaunchpadSDK.d.ts +573 -0
  4. package/dist/LaunchpadSDK.d.ts.map +1 -0
  5. package/dist/api/CommentAPI.d.ts +119 -0
  6. package/dist/api/CommentAPI.d.ts.map +1 -0
  7. package/dist/api/LaunchpadAPI.d.ts +440 -0
  8. package/dist/api/LaunchpadAPI.d.ts.map +1 -0
  9. package/dist/api/TradeAPI.d.ts +164 -0
  10. package/dist/api/TradeAPI.d.ts.map +1 -0
  11. package/dist/api/Trading.d.ts +176 -0
  12. package/dist/api/Trading.d.ts.map +1 -0
  13. package/dist/api/UserAPI.d.ts +426 -0
  14. package/dist/api/UserAPI.d.ts.map +1 -0
  15. package/dist/api/WebSocketAPI.d.ts +156 -0
  16. package/dist/api/WebSocketAPI.d.ts.map +1 -0
  17. package/dist/api/dto/BondingCurveDTOs.d.ts +142 -0
  18. package/dist/api/dto/BondingCurveDTOs.d.ts.map +1 -0
  19. package/dist/api/services/BundleService.d.ts +105 -0
  20. package/dist/api/services/BundleService.d.ts.map +1 -0
  21. package/dist/api/services/SignatureService.d.ts +71 -0
  22. package/dist/api/services/SignatureService.d.ts.map +1 -0
  23. package/dist/api/services/TokenClassKeyService.d.ts +116 -0
  24. package/dist/api/services/TokenClassKeyService.d.ts.map +1 -0
  25. package/dist/api/services/WebSocketManager.d.ts +99 -0
  26. package/dist/api/services/WebSocketManager.d.ts.map +1 -0
  27. package/dist/api/services/WebSocketService.d.ts +66 -0
  28. package/dist/api/services/WebSocketService.d.ts.map +1 -0
  29. package/dist/auth/SignatureAuth.d.ts +92 -0
  30. package/dist/auth/SignatureAuth.d.ts.map +1 -0
  31. package/dist/auth/types.d.ts +41 -0
  32. package/dist/auth/types.d.ts.map +1 -0
  33. package/dist/helpers/sdk.d.ts +75 -0
  34. package/dist/helpers/sdk.d.ts.map +1 -0
  35. package/dist/helpers/wallet.d.ts +60 -0
  36. package/dist/helpers/wallet.d.ts.map +1 -0
  37. package/dist/index.cjs.js +1 -0
  38. package/dist/index.d.ts +49 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.esm.js +1 -0
  41. package/dist/index.js +1 -0
  42. package/dist/types/comment.dto.d.ts +160 -0
  43. package/dist/types/comment.dto.d.ts.map +1 -0
  44. package/dist/types/common.d.ts +108 -0
  45. package/dist/types/common.d.ts.map +1 -0
  46. package/dist/types/dto.d.ts +145 -0
  47. package/dist/types/dto.d.ts.map +1 -0
  48. package/dist/types/launchpad.dto.d.ts +517 -0
  49. package/dist/types/launchpad.dto.d.ts.map +1 -0
  50. package/dist/types/launchpad.validation.d.ts +40 -0
  51. package/dist/types/launchpad.validation.d.ts.map +1 -0
  52. package/dist/types/trade.dto.d.ts +446 -0
  53. package/dist/types/trade.dto.d.ts.map +1 -0
  54. package/dist/types/user.dto.d.ts +330 -0
  55. package/dist/types/user.dto.d.ts.map +1 -0
  56. package/dist/utils/VaultCache.d.ts +73 -0
  57. package/dist/utils/VaultCache.d.ts.map +1 -0
  58. package/dist/utils/adapters.d.ts +111 -0
  59. package/dist/utils/adapters.d.ts.map +1 -0
  60. package/dist/utils/agent-config.d.ts +206 -0
  61. package/dist/utils/agent-config.d.ts.map +1 -0
  62. package/dist/utils/http.d.ts +85 -0
  63. package/dist/utils/http.d.ts.map +1 -0
  64. package/dist/utils/multipart.d.ts +60 -0
  65. package/dist/utils/multipart.d.ts.map +1 -0
  66. package/dist/utils/precision-math.d.ts +37 -0
  67. package/dist/utils/precision-math.d.ts.map +1 -0
  68. package/dist/utils/validation.d.ts +131 -0
  69. package/dist/utils/validation.d.ts.map +1 -0
  70. package/dist/utils/wallet.d.ts +174 -0
  71. package/dist/utils/wallet.d.ts.map +1 -0
  72. package/package.json +151 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommentAPI.d.ts","sourceRoot":"","sources":["../../src/api/CommentAPI.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAEL,mBAAmB,EAGnB,qBAAqB,EAItB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,UAAU;IAEnB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;gBADb,IAAI,EAAE,UAAU,EAChB,YAAY,CAAC,EAAE,YAAY,YAAA;IAO9C;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,GAAE,MAAU,EAAE,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA0CnH;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IA8ChG;;;;;;;;;OASG;YACW,uBAAuB;IAIrC;;;;;OAKG;IACH,OAAO,CAAC,2BAA2B;IAenC;;;;OAIG;IACH,UAAU,IAAI,MAAM;IAIpB;;;;OAIG;IACH,kBAAkB,IAAI,MAAM;IAI5B;;;;;OAKG;IACH,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;CAGjD"}
@@ -0,0 +1,440 @@
1
+ /**
2
+ * Launchpad API Controller
3
+ *
4
+ * This class provides access to all launchpad-related endpoints, handling
5
+ * file uploads, pool creation, data fetching, and analysis operations.
6
+ */
7
+ import { HttpClient } from '../utils/http';
8
+ import { ImageUploadOptions, ImageUploadResponse, FetchPoolOptions, FetchPoolResponse, GetAmountResponse, CheckPoolOptions, CheckPoolResponse, GetGraphResponse, GetTokenDistributionResponse, CreateSaleData, CreateSaleResponse, GetTokenBadgesResponse } from '../types/launchpad.dto';
9
+ import { CalculatePreMintData, CalculatePreMintResponse } from '../types/trade.dto';
10
+ /**
11
+ * Launchpad API controller for pool creation and management operations
12
+ *
13
+ * This controller provides access to all launchpad-related functionality including:
14
+ * - Image uploads for token branding
15
+ * - Pool creation and lifecycle management
16
+ * - Pool data fetching with filtering and pagination
17
+ * - Amount calculations for trading operations
18
+ * - Pool existence checking and validation
19
+ * - Historical graph data and analytics
20
+ *
21
+ * All methods include comprehensive input validation, automatic type conversion
22
+ * for backend compatibility, and detailed error handling.
23
+ *
24
+ * @category API Controllers
25
+ * @since 1.0.0
26
+ *
27
+ * @example Basic pool creation workflow
28
+ * ```typescript
29
+ * const sdk = new LaunchpadSDK({ wallet });
30
+ *
31
+ * // 1. Upload token image
32
+ * const uploadResult = await sdk.launchpad.uploadImage({
33
+ * file: imageFile,
34
+ * tokenName: 'mytoken'
35
+ * });
36
+ *
37
+ * // 2. Create the token sale
38
+ * const sale = await sdk.launchpad.createSale({
39
+ * tokenName: 'mytoken',
40
+ * tokenSymbol: 'MTK',
41
+ * tokenDescription: 'My awesome token',
42
+ * tokenImage: uploadResult.data?.imageUrl,
43
+ * preBuyQuantity: '500'
44
+ * });
45
+ *
46
+ * console.log('Sale created:', sale.vaultAddress);
47
+ * ```
48
+ */
49
+ export declare class LaunchpadAPI {
50
+ private readonly http;
51
+ private readonly bundleHttp?;
52
+ constructor(http: HttpClient, bundleHttp?: HttpClient | undefined);
53
+ /**
54
+ * Uploads an image for a token pool
55
+ *
56
+ * Uploads a token image that will be used for branding and display purposes.
57
+ * Supports both browser File objects and Node.js Buffer objects for maximum
58
+ * compatibility across environments.
59
+ *
60
+ * File Requirements:
61
+ * - Format: PNG, JPG, JPEG, WebP
62
+ * - Size: Maximum 5MB
63
+ * - Dimensions: Recommended 512x512px or higher
64
+ * - Aspect ratio: Square (1:1) recommended
65
+ *
66
+ * @category File Operations
67
+ * @param options Upload configuration object
68
+ * @param options.file Image file as File object (browser) or Buffer (Node.js)
69
+ * @param options.tokenName Token name for the image (must be valid token name format)
70
+ * @returns Promise that resolves to upload result containing image URL and metadata
71
+ * @throws {ValidationError} If token name format is invalid
72
+ * @throws {FileValidationError} If file doesn't meet requirements
73
+ * @throws {Error} If upload fails due to network or server issues
74
+ * @since 1.0.0
75
+ *
76
+ * @example Browser file upload
77
+ * ```typescript
78
+ * // From file input element
79
+ * const fileInput = document.querySelector('#image-upload') as HTMLInputElement;
80
+ * const file = fileInput.files?.[0];
81
+ *
82
+ * if (file) {
83
+ * const result = await sdk.launchpad.uploadImage({
84
+ * file,
85
+ * tokenName: 'mytoken'
86
+ * });
87
+ * console.log('Image uploaded:', result.imageUrl);
88
+ * }
89
+ * ```
90
+ *
91
+ * @example Node.js buffer upload
92
+ * ```typescript
93
+ * import * as fs from 'fs';
94
+ *
95
+ * const imageBuffer = fs.readFileSync('./token-image.png');
96
+ * const result = await sdk.launchpad.uploadImage({
97
+ * file: imageBuffer,
98
+ * tokenName: 'mytoken'
99
+ * });
100
+ * console.log('Image URL:', result.imageUrl);
101
+ * ```
102
+ *
103
+ * @example With error handling
104
+ * ```typescript
105
+ * try {
106
+ * const result = await sdk.launchpad.uploadImage({ file, tokenName });
107
+ * return result.imageUrl;
108
+ * } catch (error) {
109
+ * if (error instanceof FileValidationError) {
110
+ * console.error('Invalid file:', error.message);
111
+ * } else if (error instanceof ValidationError) {
112
+ * console.error('Invalid token name:', error.message);
113
+ * } else {
114
+ * console.error('Upload failed:', error.message);
115
+ * }
116
+ * throw error;
117
+ * }
118
+ * ```
119
+ *
120
+ * @see {@link createSale} - Create token sale using uploaded image
121
+ */
122
+ uploadImageByTokenName(tokenName: string, options: ImageUploadOptions): Promise<ImageUploadResponse>;
123
+ /**
124
+ * Fetches pools with filtering and pagination
125
+ *
126
+ * ✅ VERIFIED: Real API payload confirmed - endpoint /launchpad/fetch-pool
127
+ *
128
+ * @param options Fetch options including type, search, and pagination
129
+ * @returns Promise<FetchPoolResponse> Pool data with pagination
130
+ */
131
+ fetchPools(options: FetchPoolOptions): Promise<FetchPoolResponse>;
132
+ /**
133
+ * Calculates amount for trading operations (PRIVATE - Internal use only)
134
+ *
135
+ * @private
136
+ * @param options Amount calculation options
137
+ * @returns Promise<GetAmountResponse> Calculated amount
138
+ */
139
+ private _getAmount;
140
+ /**
141
+ * Checks if a pool exists for given token name or symbol
142
+ *
143
+ * @param options Check options with token name and/or symbol
144
+ * @returns Promise<CheckPoolResponse> Pool existence result
145
+ */
146
+ checkPool(options: CheckPoolOptions): Promise<CheckPoolResponse>;
147
+ /**
148
+ * Fetches graph data for a token
149
+ *
150
+ * ✅ VERIFIED: Real API payload confirmed - endpoint /launchpad/get-graph-data
151
+ *
152
+ * @param options Graph data options
153
+ * @returns Promise<GetGraphResponse> Graph data points
154
+ */
155
+ getGraphDataByTokenName(tokenName: string, options?: {
156
+ from: number;
157
+ to: number;
158
+ resolution: number;
159
+ }): Promise<GetGraphResponse>;
160
+ /**
161
+ * Gets pools with flexible filtering options (unified method)
162
+ *
163
+ * @param options Filtering options including search, tokenName, type, pagination
164
+ * @returns Promise<FetchPoolResponse> Filtered pools
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * // Get recent pools
169
+ * const recent = await sdk.launchpad.getPools({ type: 'recent', page: 1, limit: 10 });
170
+ *
171
+ * // Get popular pools
172
+ * const popular = await sdk.launchpad.getPools({ type: 'popular', page: 1, limit: 10 });
173
+ *
174
+ * // Search pools
175
+ * const searched = await sdk.launchpad.getPools({ search: 'rocket', page: 1, limit: 5 });
176
+ *
177
+ * // Get specific token pools
178
+ * const tokenPools = await sdk.launchpad.getPools({ tokenName: 'ROCKETCH' });
179
+ * ```
180
+ */
181
+ getPools(options?: {
182
+ search?: string;
183
+ tokenName?: string;
184
+ type?: 'recent' | 'popular';
185
+ page?: number;
186
+ limit?: number;
187
+ }): Promise<FetchPoolResponse>;
188
+ /**
189
+ * Checks if a token name is available (convenience method)
190
+ *
191
+ * @param tokenName Token name to check
192
+ * @returns Promise<boolean> True if available (pool doesn't exist)
193
+ */
194
+ isTokenNameAvailable(tokenName: string): Promise<boolean>;
195
+ /**
196
+ * Checks if a token symbol is available (convenience method)
197
+ *
198
+ * @param symbol Token symbol to check
199
+ * @returns Promise<boolean> True if available (pool doesn't exist)
200
+ */
201
+ isTokenSymbolAvailable(symbol: string): Promise<boolean>;
202
+ /**
203
+ * Get buy token amount calculation with unified API (replaces getBuyWithNativeAmountByTokenName/getBuyExactTokenAmountByTokenName)
204
+ *
205
+ * @param tokenName Token name (e.g., "dragnrkti", "rocketri", "unicornri")
206
+ * @param options Calculation options
207
+ * @param options.amount Amount to calculate (GALA for 'native', tokens for 'exact')
208
+ * @param options.type Calculation type: 'native' = GALA input, 'exact' = token output
209
+ * @returns Promise<GetAmountResponse> Calculated amount
210
+ * @throws ValidationError if parameters are invalid or token not found
211
+ *
212
+ * @example
213
+ * ```typescript
214
+ * // Calculate tokens received when spending 1 GALA
215
+ * const result = await sdk.launchpad.getBuyTokenAmount("dragnrkti", {
216
+ * amount: "1000000000000000000", // 1 GALA in wei
217
+ * type: "native"
218
+ * });
219
+ *
220
+ * // Calculate GALA cost for buying 100 tokens
221
+ * const result = await sdk.launchpad.getBuyTokenAmount("dragnrkti", {
222
+ * amount: "100000000000000000000", // 100 tokens in wei
223
+ * type: "exact"
224
+ * });
225
+ * ```
226
+ */
227
+ getBuyTokenAmount(tokenName: string, options: {
228
+ amount: string;
229
+ type: 'native' | 'exact';
230
+ }): Promise<GetAmountResponse>;
231
+ /**
232
+ * Get sell token amount calculation with unified API (replaces getSellExactTokenAmountByTokenName/getSellWithNativeAmountByTokenName)
233
+ *
234
+ * @param tokenName Token name (e.g., "dragnrkti", "rocketri", "unicornri")
235
+ * @param options Calculation options
236
+ * @param options.amount Amount to calculate (tokens for 'exact', GALA for 'native')
237
+ * @param options.type Calculation type: 'exact' = token input, 'native' = GALA output
238
+ * @returns Promise<GetAmountResponse> Calculated amount
239
+ * @throws ValidationError if parameters are invalid or token not found
240
+ *
241
+ * @example
242
+ * ```typescript
243
+ * // Calculate GALA received when selling 50 tokens
244
+ * const result = await sdk.launchpad.getSellTokenAmount("dragnrkti", {
245
+ * amount: "50000000000000000000", // 50 tokens in wei
246
+ * type: "exact"
247
+ * });
248
+ *
249
+ * // Calculate tokens needed to receive 0.5 GALA
250
+ * const result = await sdk.launchpad.getSellTokenAmount("dragnrkti", {
251
+ * amount: "500000000000000000", // 0.5 GALA in wei
252
+ * type: "native"
253
+ * });
254
+ * ```
255
+ */
256
+ getSellTokenAmount(tokenName: string, options: {
257
+ amount: string;
258
+ type: 'exact' | 'native';
259
+ }): Promise<GetAmountResponse>;
260
+ /**
261
+ * Creates a new token sale using the bundle backend
262
+ *
263
+ * ✅ VERIFIED: Real API payload confirmed - endpoint /bundle with CreateSale method
264
+ *
265
+ * This method provides a clean interface for creating token sales by handling:
266
+ * - Optional image upload (if image is File/Buffer)
267
+ * - DTO signing with required fields and defaults
268
+ * - Bundle backend API call with proper request format
269
+ *
270
+ * @category Sale Operations
271
+ * @param data Sale creation configuration
272
+ * @param data.tokenName Unique token name (lowercase, alphanumeric, max 10 chars)
273
+ * @param data.tokenSymbol Token symbol (3-10 characters)
274
+ * @param data.tokenDescription Token description (max 500 characters)
275
+ * @param data.tokenImage Optional image - File, Buffer, or URL string
276
+ * @param data.preBuyQuantity Pre-buy quantity as decimal string
277
+ * @param data.websiteUrl Optional website URL
278
+ * @param data.telegramUrl Optional Telegram channel URL
279
+ * @param data.twitterUrl Optional Twitter profile URL
280
+ * @param data.tokenCategory Optional token category (defaults to 'Unit')
281
+ * @param data.tokenCollection Optional token collection (defaults to 'Token')
282
+ * @param data.reverseBondingCurveConfiguration Optional curve config (uses defaults)
283
+ * @returns Promise that resolves to sale creation result
284
+ * @throws {ValidationError} If any input validation fails
285
+ * @throws {Error} If sale creation fails due to network or signature issues
286
+ * @since 1.0.0
287
+ *
288
+ * @example Create a sale with image upload
289
+ * ```typescript
290
+ * const result = await sdk.launchpad.createTokenAndPool({
291
+ * tokenName: 'mytoken',
292
+ * tokenSymbol: 'MTK',
293
+ * tokenDescription: 'My awesome token for trading',
294
+ * tokenImage: imageFile, // File object from input
295
+ * preBuyQuantity: '100',
296
+ * websiteUrl: 'https://mytoken.com',
297
+ * twitterUrl: 'https://twitter.com/mytoken'
298
+ * });
299
+ *
300
+ * console.log('Sale created successfully!');
301
+ * console.log('Sale ID:', result.data?.saleId);
302
+ * ```
303
+ *
304
+ * @example Create a sale with existing image URL
305
+ * ```typescript
306
+ * const result = await sdk.launchpad.createTokenAndPool({
307
+ * tokenName: 'simpletoken',
308
+ * tokenSymbol: 'SIMPLE',
309
+ * tokenDescription: 'A simple token',
310
+ * tokenImage: 'https://example.com/token-logo.png',
311
+ * preBuyQuantity: '50',
312
+ * websiteUrl: 'https://simple.com'
313
+ * });
314
+ * ```
315
+ *
316
+ * @example Minimal sale creation
317
+ * ```typescript
318
+ * const result = await sdk.launchpad.createTokenAndPool({
319
+ * tokenName: 'minimal',
320
+ * tokenSymbol: 'MIN',
321
+ * tokenDescription: 'Minimal token configuration',
322
+ * preBuyQuantity: '10'
323
+ * // Uses all defaults for optional fields
324
+ * });
325
+ * ```
326
+ */
327
+ createTokenAndPool(data: CreateSaleData): Promise<CreateSaleResponse>;
328
+ /**
329
+ * Get token distribution showing top holders
330
+ *
331
+ * Retrieves the list of top token holders for a specific token,
332
+ * along with their balances and percentage of total supply.
333
+ *
334
+ * @param vaultAddress Token vault address in backend format (eth|40hex)
335
+ * @returns Promise resolving to token distribution data
336
+ *
337
+ * @example
338
+ * ```typescript
339
+ * const distribution = await launchpad.getTokenDistributionByTokenName('mytoken');
340
+ * console.log('Top holders:', distribution.data?.holders);
341
+ * ```
342
+ */
343
+ getTokenDistributionByTokenName(tokenName: string): Promise<GetTokenDistributionResponse>;
344
+ /**
345
+ * Gets badge achievements for a token
346
+ *
347
+ * This endpoint retrieves volume and engagement badges for a specific token.
348
+ * Badges indicate milestones in trading volume and community engagement.
349
+ *
350
+ * **Note**: This endpoint does not require authentication.
351
+ *
352
+ * @param tokenName The name of the token to get badges for
353
+ * @returns Promise<GetTokenBadgesResponse> Badge information
354
+ *
355
+ * @example
356
+ * ```typescript
357
+ * const badges = await launchpad.getTokenBadges('mytoken');
358
+ * console.log('Volume badges:', badges.data?.volumeBadge);
359
+ * console.log('Engagement badges:', badges.data?.engagementBadge);
360
+ * ```
361
+ */
362
+ getTokenBadgesByTokenName(tokenName: string): Promise<GetTokenBadgesResponse>;
363
+ /**
364
+ * Convenience method to check if a token has achieved a specific badge
365
+ *
366
+ * @param tokenName The token name to check
367
+ * @param badgeType Type of badge to check ('volume' or 'engagement')
368
+ * @param badgeName Specific badge name to check for
369
+ * @returns Promise<boolean> Whether the token has achieved this badge
370
+ *
371
+ * @example
372
+ * ```typescript
373
+ * const has10kVolume = await launchpad.hasTokenBadgeByTokenName('mytoken', 'volume', '10k');
374
+ * const hasCrowdEngagement = await launchpad.hasTokenBadgeByTokenName('mytoken', 'engagement', 'CROWD');
375
+ * ```
376
+ */
377
+ hasTokenBadgeByTokenName(tokenName: string, badgeType: 'volume' | 'engagement', badgeName: string): Promise<boolean>;
378
+ /**
379
+ * Calculates pre-mint token amounts using CallMemeTokenOut
380
+ *
381
+ * This method calculates how many tokens a user will receive for a given
382
+ * amount of GALA during the token launch phase. Used when the initial buy
383
+ * amount is greater than 0 in the launch form.
384
+ *
385
+ * **Note**: This endpoint does not require authentication and uses a fixed
386
+ * vault address for pre-mint calculations.
387
+ *
388
+ * @param data Pre-mint calculation data
389
+ * @returns Promise resolving to calculated token amounts and fees
390
+ *
391
+ * @example
392
+ * ```typescript
393
+ * const result = await launchpad.calculatePreMintTokens({
394
+ * nativeTokenQuantity: '100' // 100 GALA
395
+ * });
396
+ * console.log('Tokens to receive:', result.Data.calculatedQuantity);
397
+ * console.log('Fees:', result.Data.extraFees);
398
+ * ```
399
+ */
400
+ getInitialBuyAmount(data: CalculatePreMintData): Promise<CalculatePreMintResponse>;
401
+ /**
402
+ * Gets the authenticated user's address in backend format
403
+ *
404
+ * @returns Address in eth|{40-hex-chars} format
405
+ */
406
+ getAddress(): string;
407
+ /**
408
+ * Converts Ethereum address to backend format
409
+ *
410
+ * @param ethereumAddress Standard Ethereum address (0x...)
411
+ * @returns Address in backend format (eth|...)
412
+ */
413
+ formatAddressForBackend(ethereumAddress: string): string;
414
+ /**
415
+ * Validates a token name (exposed for external validation)
416
+ *
417
+ * @param tokenName Token name to validate
418
+ * @throws ValidationError if validation fails
419
+ */
420
+ validateTokenName(tokenName: string): void;
421
+ /**
422
+ * Validates pagination options (exposed for external validation)
423
+ *
424
+ * @param options Pagination options to validate
425
+ * @throws ValidationError if validation fails
426
+ */
427
+ validatePagination(options: FetchPoolOptions): void;
428
+ /**
429
+ * Resolves a token name to its vault address using cached resolution
430
+ *
431
+ * Uses the shared VaultCache for intelligent caching to eliminate
432
+ * redundant API calls for the same tokenName.
433
+ *
434
+ * @private
435
+ * @param tokenName Token name to resolve (e.g., 'dragnrkti', 'rocketri')
436
+ * @returns Promise<string | null> Vault address if found, null otherwise
437
+ */
438
+ private resolveTokenNameToVault;
439
+ }
440
+ //# sourceMappingURL=LaunchpadAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LaunchpadAPI.d.ts","sourceRoot":"","sources":["../../src/api/LaunchpadAPI.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAc3C,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAEhB,iBAAiB,EAEjB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EAEjB,gBAAgB,EAChB,4BAA4B,EAC5B,cAAc,EACd,kBAAkB,EAGlB,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EAGzB,MAAM,oBAAoB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,GAAG,MAAM;IAIxD;;;;;OAKG;IACH,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI1C;;;;;OAKG;IACH,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAQnD;;;;;;;;;OASG;YACW,uBAAuB;CAGtC"}
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Trade API Controller
3
+ *
4
+ * This controller provides access to trade-related operations including:
5
+ * - Trade creation
6
+ * - Trade listing with filtering
7
+ * - Bundle API trading integration
8
+ *
9
+ * All methods include input validation and handle backend type inconsistencies.
10
+ */
11
+ import { HttpClient } from '../utils/http';
12
+ import type { LaunchpadAPI } from './LaunchpadAPI';
13
+ import { GetTradesResponse, TradeListParams, FetchSaleDetailsResponse } from '../types/trade.dto';
14
+ /**
15
+ * Trade API controller for trade operations
16
+ *
17
+ * Provides methods for:
18
+ * - Fetching trade listings with optional filtering
19
+ * - Fetching sale details from GalaChain
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // Get trades for a token with pagination
24
+ * const trades = await sdk.trade.getTrades({
25
+ * tokenName: "MyToken",
26
+ * page: 1,
27
+ * limit: 10
28
+ * });
29
+ *
30
+ * // Fetch sale details from GalaChain
31
+ * const saleDetails = await sdk.trade.fetchSaleDetails({
32
+ * vaultAddress: "service|Token$Unit$MYSYMBOL$address$launchpad"
33
+ * });
34
+ * ```
35
+ */
36
+ export declare class TradeAPI {
37
+ private readonly http;
38
+ private readonly galaChainHttp;
39
+ private readonly launchpadAPI?;
40
+ constructor(http: HttpClient, galaChainHttp: HttpClient, launchpadAPI?: LaunchpadAPI | undefined);
41
+ /**
42
+ * Gets trades for a token by its tokenName with pagination
43
+ *
44
+ * This method provides a clean, intuitive API for fetching token trades
45
+ * using the token name. Follows the same pattern as CommentAPI.
46
+ *
47
+ * @param tokenName Token name (e.g., "dragnrkti", "rocketri", "unicornri")
48
+ * @param params Optional pagination parameters (page, limit)
49
+ * @returns Promise<GetTradesResponse> Trades with pagination info
50
+ * @throws ValidationError if token name is invalid or not found
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * // Get first page of trades for dragnrkti token
55
+ * const trades = await sdk.trade.getTradesByTokenName("dragnrkti");
56
+ *
57
+ * // Get specific page with custom limit
58
+ * const moreTrades = await sdk.trade.getTradesByTokenName("dragnrkti", { page: 2, limit: 20 });
59
+ * ```
60
+ */
61
+ getTradesByTokenName(tokenName: string, params?: TradeListParams): Promise<GetTradesResponse>;
62
+ /**
63
+ * Validates pagination parameters
64
+ */
65
+ private validatePagination;
66
+ /**
67
+ * Validates TradeListParams for tokenName-based methods
68
+ */
69
+ private validateTradeListParams;
70
+ /**
71
+ * Validates fetch sale details data
72
+ */
73
+ private validateFetchSaleDetailsData;
74
+ /**
75
+ * Builds query parameters for trade listing
76
+ * Note: GET /trade/ expects page/limit as STRINGS (backend quirk)
77
+ *
78
+ * @private
79
+ * @param tokenName Token name to filter by
80
+ * @param page Page number
81
+ * @param limit Items per page
82
+ * @returns Query parameters object
83
+ */
84
+ private buildTradeQueryParams;
85
+ /**
86
+ * Gets current sale details for a token by its tokenName
87
+ *
88
+ * This method provides a clean, intuitive API for fetching current trading pool
89
+ * state using the token name. It automatically resolves the tokenName
90
+ * to the correct vault address internally.
91
+ *
92
+ * @param tokenName Token name (e.g., "dragnrkti", "rocketri", "unicornri")
93
+ * @returns Promise<FetchSaleDetailsResponse> Current trading pool state and bonding curve data
94
+ * @throws ValidationError if token name is invalid or not found
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * // Get current sale details for dragnrkti token
99
+ * const saleDetails = await sdk.trade.getSaleDetailsByTokenName("dragnrkti");
100
+ * console.log('Current GALA in vault:', saleDetails.Data.nativeTokenQuantity);
101
+ * console.log('Bonding curve config:', saleDetails.Data.reverseBondingCurveConfiguration);
102
+ * ```
103
+ */
104
+ getSaleDetailsByTokenName(tokenName: string): Promise<FetchSaleDetailsResponse>;
105
+ /**
106
+ * Internal method for fetching sale details by vault address
107
+ * Used internally by getSaleDetailsByTokenName after vault resolution
108
+ *
109
+ * @private
110
+ * @param data Fetch sale details data with vault address
111
+ * @returns Promise<FetchSaleDetailsResponse> Current trading pool state
112
+ */
113
+ private fetchSaleDetails;
114
+ /**
115
+ * Gets the authenticated user's address in backend format
116
+ *
117
+ * @returns Address in eth|{40-hex-chars} format
118
+ */
119
+ getAddress(): string;
120
+ /**
121
+ * Validates a vault address format (exposed for external validation)
122
+ *
123
+ * @param vaultAddress Vault address to validate
124
+ * @returns True if valid vault address format
125
+ */
126
+ validateVaultAddress(vaultAddress: string): boolean;
127
+ /**
128
+ * Validates a user address format (exposed for external validation)
129
+ *
130
+ * @param userAddress User address to validate
131
+ * @returns True if valid user address format
132
+ */
133
+ validateUserAddress(userAddress: string): boolean;
134
+ /**
135
+ * Validates an amount string format (exposed for external validation)
136
+ *
137
+ * @param amount Amount string to validate
138
+ * @returns True if valid amount format
139
+ */
140
+ validateAmount(amount: string): boolean;
141
+ /**
142
+ * Validates a trade type (exposed for external validation)
143
+ *
144
+ * @param tradeType Trade type to validate
145
+ * @returns True if valid trade type
146
+ */
147
+ validateTradeType(tradeType: string): boolean;
148
+ /**
149
+ * Resolves a token name to its vault address using cached resolution
150
+ *
151
+ * Uses the shared VaultCache for intelligent caching to eliminate
152
+ * redundant API calls for the same tokenName.
153
+ *
154
+ * @private
155
+ * @param tokenName Token name to resolve (e.g., 'dragnrkti', 'rocketri')
156
+ * @returns Promise<string | null> Vault address if found, null otherwise
157
+ */
158
+ private resolveTokenNameToVault;
159
+ /**
160
+ * Validates address format (supports both eth| and 0x formats)
161
+ */
162
+ private isValidAddress;
163
+ }
164
+ //# sourceMappingURL=TradeAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TradeAPI.d.ts","sourceRoot":"","sources":["../../src/api/TradeAPI.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,KAAK,EAAE,Y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