@gala-chain/launchpad-sdk 3.23.0 → 3.24.1

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.
@@ -0,0 +1,59 @@
1
+ /**
2
+ * GSwapService - Wraps @gala-chain/gswap-sdk for DEX trading integration
3
+ *
4
+ * Provides high-level interface to GalaSwap SDK for:
5
+ * - Token swapping with slippage protection
6
+ * - Quote generation (exact input/output)
7
+ * - User asset queries
8
+ * - Pool information
9
+ * - Real-time transaction monitoring
10
+ */
11
+ import { WebSocketService } from './WebSocketService';
12
+ import type { SwapQuoteParams, SwapQuoteResult, ExecuteSwapParams, ExecuteSwapResult, UserAsset, PoolInfo, GSwapServiceConfig } from '../types/gswap.dto';
13
+ export declare class GSwapService {
14
+ private gswap;
15
+ private tokenConverter;
16
+ private webSocketService;
17
+ private logger;
18
+ constructor(config: GSwapServiceConfig, webSocketService: WebSocketService);
19
+ /**
20
+ * Get swap quote for exact input (spending known amount)
21
+ * @param params Quote request with fromToken, toToken, and input amount
22
+ * @returns Quote with estimated output and fees
23
+ */
24
+ getSwapQuoteExactInput(params: SwapQuoteParams): Promise<SwapQuoteResult>;
25
+ /**
26
+ * Get swap quote for exact output (receive known amount)
27
+ * @param params Quote request with fromToken, toToken, and desired output
28
+ * @returns Quote with required input and fees
29
+ */
30
+ getSwapQuoteExactOutput(params: SwapQuoteParams): Promise<SwapQuoteResult>;
31
+ /**
32
+ * Execute a token swap with slippage protection
33
+ * @param params Swap execution parameters
34
+ * @returns Swap result with transaction details
35
+ */
36
+ executeSwap(params: ExecuteSwapParams): Promise<ExecuteSwapResult>;
37
+ /**
38
+ * Get user's token assets/balances
39
+ * @param walletAddress User's wallet address
40
+ * @returns Array of user assets with balances
41
+ */
42
+ getUserAssets(walletAddress: string): Promise<UserAsset[]>;
43
+ /**
44
+ * Get pool information for token pair
45
+ * @param tokenA First token
46
+ * @param tokenB Second token
47
+ * @returns Pool information
48
+ */
49
+ getPoolInfo(tokenA: string, tokenB: string): Promise<PoolInfo>;
50
+ /**
51
+ * Calculate price impact percentage
52
+ */
53
+ private calculatePriceImpact;
54
+ /**
55
+ * Calculate execution price (output per unit input)
56
+ */
57
+ private calculateExecutionPrice;
58
+ }
59
+ //# sourceMappingURL=GSwapService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GSwapService.d.ts","sourceRoot":"","sources":["../../src/services/GSwapService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAOtD,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EACT,QAAQ,EACR,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB;IA0C1E;;;;OAIG;IACG,sBAAsB,CAC1B,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,eAAe,CAAC;IAkD3B;;;;OAIG;IACG,uBAAuB,CAC3B,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,eAAe,CAAC;IAgD3B;;;;OAIG;IACG,WAAW,CACf,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,iBAAiB,CAAC;IAqF7B;;;;OAIG;IACG,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IA6ChE;;;;;OAKG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAmEpE;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAsB5B;;OAEG;IACH,OAAO,CAAC,uBAAuB;CAehC"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * TokenMetadataService - Proper Token Metadata Resolution
3
+ *
4
+ * This service provides authoritative token metadata by querying the GalaChain network
5
+ * for real token data. It should be used instead of trying to infer metadata from
6
+ * token format strings.
7
+ *
8
+ * Key Responsibilities:
9
+ * - Query GalaChain for real token metadata via GalaChainService
10
+ * - Cache results to minimize network calls
11
+ * - Handle token resolution for both native and wrapped tokens
12
+ * - Provide clean interface for symbol, decimals, and other metadata
13
+ */
14
+ import type { TokenClass } from '../types/gswap.dto';
15
+ export interface TokenMetadata {
16
+ symbol: string;
17
+ name?: string;
18
+ decimals: number;
19
+ collection: string;
20
+ category: string;
21
+ type: string;
22
+ additionalKey: string;
23
+ verified: boolean;
24
+ }
25
+ export interface TokenMetadataCache {
26
+ [key: string]: {
27
+ data: TokenMetadata;
28
+ timestamp: number;
29
+ };
30
+ }
31
+ export declare class TokenMetadataService {
32
+ private cache;
33
+ private cacheExpiry;
34
+ private logger;
35
+ constructor();
36
+ /**
37
+ * Resolve token metadata from a token reference
38
+ *
39
+ * Supports multiple input formats:
40
+ * - Simple symbol: "GALA"
41
+ * - Pipe-delimited: "GALA|Unit|none|none"
42
+ * - TokenClass object: { type: "GALA", ... }
43
+ * - Full format: "Token|Unit|GUSDC|eth:0x..."
44
+ *
45
+ * ⚠️ CRITICAL NOTE: This method should be used when you need REAL token metadata
46
+ * from blockchain. For format conversion only, use TokenFormatConverter.
47
+ *
48
+ * @param token Token reference (symbol, format string, or TokenClass object)
49
+ * @returns Token metadata with verified symbol and decimals from blockchain
50
+ */
51
+ resolveTokenMetadata(token: string | TokenClass): Promise<TokenMetadata>;
52
+ /**
53
+ * Get symbol for a token
54
+ *
55
+ * ✅ This is the CORRECT way to get token symbols
56
+ * ❌ WRONG: Trying to infer from token format string
57
+ * ✅ CORRECT: Query GalaChain via fetchTokenClassFromChain()
58
+ *
59
+ * @param token Token reference
60
+ * @returns Real token symbol from blockchain
61
+ */
62
+ getTokenSymbol(token: string | TokenClass): Promise<string>;
63
+ /**
64
+ * Get decimals for a token
65
+ *
66
+ * @param token Token reference
67
+ * @returns Token decimals from blockchain
68
+ */
69
+ getTokenDecimals(token: string | TokenClass): Promise<number>;
70
+ /**
71
+ * Clear cache to force fresh queries
72
+ */
73
+ clearCache(tokenKey?: string): void;
74
+ /**
75
+ * Get cache statistics
76
+ */
77
+ getCacheStats(): {
78
+ size: number;
79
+ entries: string[];
80
+ };
81
+ /**
82
+ * Generate cache key from token reference
83
+ * @private
84
+ */
85
+ private getCacheKey;
86
+ /**
87
+ * Extract metadata from token reference
88
+ *
89
+ * ⚠️ IMPORTANT: This is a PLACEHOLDER implementation
90
+ * In production, this should query GalaChainService.fetchTokenClassFromChain()
91
+ * to get REAL metadata from the blockchain.
92
+ * @private
93
+ */
94
+ private extractMetadata;
95
+ /**
96
+ * Get known decimals for standard tokens
97
+ *
98
+ * ⚠️ HARDCODED VALUES - In production, query blockchain!
99
+ * @private
100
+ */
101
+ private getDecimalsForToken;
102
+ /**
103
+ * Check if cache entry has expired
104
+ * @private
105
+ */
106
+ private isCacheExpired;
107
+ /**
108
+ * Set cache expiry duration
109
+ * @param ms Milliseconds before cache expires (default: 1 hour)
110
+ */
111
+ setCacheExpiry(ms: number): void;
112
+ }
113
+ //# sourceMappingURL=TokenMetadataService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TokenMetadataService.d.ts","sourceRoot":"","sources":["../../src/services/TokenMetadataService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,IAAI,EAAE,aAAa,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,WAAW,CAAmB;IACtC,OAAO,CAAC,MAAM,CAAS;;IAMvB;;;;;;;;;;;;;;OAcG;IACG,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;IAyB9E;;;;;;;;;OASG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAKjE;;;;;OAKG;IACG,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAKnE;;OAEG;IACH,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAUnC;;OAEG;IACH,aAAa,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE;IAQpD;;;OAGG;IACH,OAAO,CAAC,WAAW;IAWnB;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;IAqDvB;;;;;OAKG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;;OAGG;IACH,OAAO,CAAC,cAAc;IAItB;;;OAGG;IACH,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;CAIjC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Jest setup file for test environment configuration
3
+ *
4
+ * This file is placed in src/ to satisfy TypeScript's rootDir configuration
5
+ * while remaining in the test environment setup pipeline via jest.config.js
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * GSwap SDK Type Definitions and DTOs
3
+ *
4
+ * Interfaces for GalaSwap integration including:
5
+ * - Service configuration
6
+ * - Swap requests and responses
7
+ * - Asset and pool information
8
+ */
9
+ /**
10
+ * Token class representation
11
+ * Used for identifying tokens in GSwap API
12
+ */
13
+ export interface TokenClass {
14
+ collection: string;
15
+ category: string;
16
+ type: string;
17
+ additionalKey: string;
18
+ }
19
+ /**
20
+ * GSwapService configuration
21
+ * @agent Configuration for initializing GSwap trading service with optional wallet support and environment URLs
22
+ */
23
+ export interface GSwapServiceConfig {
24
+ privateKey?: string | undefined;
25
+ walletAddress?: string | undefined;
26
+ gatewayBaseUrl?: string | undefined;
27
+ bundlerBaseUrl?: string | undefined;
28
+ dexBackendBaseUrl?: string | undefined;
29
+ }
30
+ /**
31
+ * Parameters for getting swap quotes
32
+ * @agent Use to request price quotes before executing swaps. Supports both exact-input (known spend) and exact-output (known receive) patterns
33
+ */
34
+ export interface SwapQuoteParams {
35
+ fromToken: string;
36
+ toToken: string;
37
+ amount: string;
38
+ }
39
+ /**
40
+ * Result from swap quote
41
+ * @agent Contains price, impact, and fee information needed for executeSwap. Always get quote before executing swap
42
+ */
43
+ export interface SwapQuoteResult {
44
+ fromToken: string;
45
+ toToken: string;
46
+ inputAmount: string;
47
+ estimatedOutput: string;
48
+ feeTier: number;
49
+ priceImpact: string;
50
+ executionPrice: string;
51
+ }
52
+ /**
53
+ * Parameters for executing a swap
54
+ * @agent Use to execute DEX trade with slippage protection. Must pass estimatedOutput and feeTier from quote result
55
+ */
56
+ export interface ExecuteSwapParams {
57
+ fromToken: string;
58
+ toToken: string;
59
+ inputAmount: string;
60
+ estimatedOutput: string;
61
+ feeTier: number;
62
+ slippageTolerance?: number;
63
+ }
64
+ /**
65
+ * Result from executing a swap
66
+ * @agent Contains transaction details after swap execution. Monitor via transactionId for real-time status updates
67
+ */
68
+ export interface ExecuteSwapResult {
69
+ transactionId: string;
70
+ status: string;
71
+ fromToken: string;
72
+ toToken: string;
73
+ inputAmount: string;
74
+ outputAmount: string;
75
+ feeTier: number;
76
+ slippageTolerance: number;
77
+ timestamp: Date;
78
+ }
79
+ /**
80
+ * User asset (token balance)
81
+ * @agent Represents a single token holding in user's DEX portfolio. Retrieved via getSwapUserAssets()
82
+ */
83
+ export interface UserAsset {
84
+ tokenId: any;
85
+ symbol: string;
86
+ balance: string;
87
+ decimals: number;
88
+ }
89
+ /**
90
+ * Pool information for token pair
91
+ * @agent Provides liquidity and fee tier data for token pairs. Use to assess pool depth and fee structure before trading
92
+ */
93
+ export interface PoolInfo {
94
+ tokenA: string;
95
+ tokenB: string;
96
+ liquidity: string;
97
+ feeTiers: number[];
98
+ swapCount: number;
99
+ }
100
+ /**
101
+ * GSwap API error response
102
+ */
103
+ export interface GSwapError {
104
+ code: string;
105
+ message: string;
106
+ details?: any;
107
+ }
108
+ /**
109
+ * Options for swap execution
110
+ */
111
+ export interface SwapExecutionOptions {
112
+ maxSlippage?: number;
113
+ timeout?: number;
114
+ waitForCompletion?: boolean;
115
+ feeMultiplier?: number;
116
+ }
117
+ /**
118
+ * Detailed quote with breakdown
119
+ */
120
+ export interface DetailedQuote extends SwapQuoteResult {
121
+ fees: {
122
+ protocolFee: string;
123
+ liquidityProviderFee: string;
124
+ totalFee: string;
125
+ effectiveFeePercentage: string;
126
+ };
127
+ execution: {
128
+ minOutputWithSlippage: string;
129
+ maxInputWithSlippage?: string;
130
+ path: string[];
131
+ liquidityProviders: string[];
132
+ };
133
+ risk: {
134
+ highSlippage: boolean;
135
+ untrustedPools: boolean;
136
+ warnings: string[];
137
+ };
138
+ }
139
+ //# sourceMappingURL=gswap.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gswap.dto.d.ts","sourceRoot":"","sources":["../../src/types/gswap.dto.ts"],"names":[],"mappings":"AAAA;;;;;;;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AGf,kBAAkB,EAAE,MAAM,EAAE,CAAC;KAC9B,CAAC;IAGF,IAAI,EAAE;QAEJ,YAAY,EAAE,OAAO,CAAC;QAGtB,cAAc,EAAE,OAAO,CAAC;QAGxB,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH"}
@@ -168,4 +168,181 @@ export declare class TransactionError extends Error {
168
168
  */
169
169
  constructor(message: string, transactionId?: string | undefined, code?: string | undefined);
170
170
  }
171
+ /**
172
+ * Error thrown when GSwap SDK quote operations fail
173
+ *
174
+ * This error is thrown during quote generation (exact input or exact output).
175
+ * It preserves the original GSwap SDK error for detailed diagnostics.
176
+ *
177
+ * @example Quote generation failure
178
+ * ```typescript
179
+ * throw new GSwapQuoteError(
180
+ * 'Failed to get quote for GALA to GUSDC swap',
181
+ * originalGSwapError,
182
+ * 'POOL_NOT_FOUND'
183
+ * );
184
+ * ```
185
+ *
186
+ * @example Catching quote errors
187
+ * ```typescript
188
+ * try {
189
+ * const quote = await service.getSwapQuoteExactInput({ fromToken: 'GALA', toToken: 'GUSDC', amount: '100' });
190
+ * } catch (error) {
191
+ * if (error instanceof GSwapQuoteError) {
192
+ * console.log(`Quote failed: ${error.message}`);
193
+ * console.log(`GSwap error: ${error.code}`);
194
+ * // Implement user notification
195
+ * }
196
+ * }
197
+ * ```
198
+ */
199
+ export declare class GSwapQuoteError extends Error {
200
+ originalError: unknown;
201
+ code?: string | undefined;
202
+ /**
203
+ * Creates a new GSwapQuoteError
204
+ *
205
+ * @param message - Human-readable error message describing what failed
206
+ * @param originalError - The original error from GSwap SDK
207
+ * @param code - Optional error code from GSwap SDK for programmatic handling
208
+ */
209
+ constructor(message: string, originalError: unknown, code?: string | undefined);
210
+ }
211
+ /**
212
+ * Error thrown when GSwap SDK swap execution fails
213
+ *
214
+ * This error is thrown during token swap execution (buy/sell operations).
215
+ * It preserves the original GSwap SDK error and transaction details.
216
+ *
217
+ * @example Swap execution failure
218
+ * ```typescript
219
+ * throw new GSwapSwapError(
220
+ * 'Token swap failed: insufficient balance',
221
+ * originalGSwapError,
222
+ * 'txHash123',
223
+ * 'INSUFFICIENT_BALANCE'
224
+ * );
225
+ * ```
226
+ *
227
+ * @example Catching swap errors
228
+ * ```typescript
229
+ * try {
230
+ * const result = await service.executeSwap(swapParams);
231
+ * } catch (error) {
232
+ * if (error instanceof GSwapSwapError) {
233
+ * console.log(`Swap failed: ${error.message}`);
234
+ * if (error.transactionHash) {
235
+ * console.log(`TX: ${error.transactionHash}`);
236
+ * }
237
+ * }
238
+ * }
239
+ * ```
240
+ */
241
+ export declare class GSwapSwapError extends Error {
242
+ originalError: unknown;
243
+ transactionHash?: string | undefined;
244
+ code?: string | undefined;
245
+ /**
246
+ * Creates a new GSwapSwapError
247
+ *
248
+ * @param message - Human-readable error message describing what failed
249
+ * @param originalError - The original error from GSwap SDK
250
+ * @param transactionHash - Optional transaction hash for transaction tracking
251
+ * @param code - Optional error code from GSwap SDK for programmatic handling
252
+ */
253
+ constructor(message: string, originalError: unknown, transactionHash?: string | undefined, code?: string | undefined);
254
+ }
255
+ /**
256
+ * Error thrown when GSwap SDK pool operations fail
257
+ *
258
+ * This error is thrown when pool-related queries fail, including:
259
+ * - Pool information retrieval
260
+ * - Available token swaps querying
261
+ * - Pool data access errors
262
+ *
263
+ * @example Pool query failure
264
+ * ```typescript
265
+ * throw new GSwapPoolError(
266
+ * 'Pool not found for GALA/GUSDC pair',
267
+ * originalGSwapError,
268
+ * 'GALA',
269
+ * 'GUSDC',
270
+ * 'POOL_NOT_FOUND'
271
+ * );
272
+ * ```
273
+ *
274
+ * @example Catching pool errors
275
+ * ```typescript
276
+ * try {
277
+ * const poolInfo = await service.getPoolInfo('GALA', 'GUSDC');
278
+ * } catch (error) {
279
+ * if (error instanceof GSwapPoolError) {
280
+ * console.log(`Pool error: ${error.message}`);
281
+ * if (error.code === 'POOL_NOT_FOUND') {
282
+ * console.log(`No pool for ${error.tokenA}/${error.tokenB}`);
283
+ * }
284
+ * }
285
+ * }
286
+ * ```
287
+ */
288
+ export declare class GSwapPoolError extends Error {
289
+ originalError: unknown;
290
+ tokenA?: string | undefined;
291
+ tokenB?: string | undefined;
292
+ code?: string | undefined;
293
+ /**
294
+ * Creates a new GSwapPoolError
295
+ *
296
+ * @param message - Human-readable error message describing what failed
297
+ * @param originalError - The original error from GSwap SDK
298
+ * @param tokenA - Optional token A symbol in the pool pair
299
+ * @param tokenB - Optional token B symbol in the pool pair
300
+ * @param code - Optional error code from GSwap SDK for programmatic handling
301
+ */
302
+ constructor(message: string, originalError: unknown, tokenA?: string | undefined, tokenB?: string | undefined, code?: string | undefined);
303
+ }
304
+ /**
305
+ * Error thrown when GSwap SDK asset/balance operations fail
306
+ *
307
+ * This error is thrown when asset-related queries fail, including:
308
+ * - User asset/balance retrieval
309
+ * - Portfolio data access errors
310
+ * - Asset validation failures
311
+ *
312
+ * @example Asset query failure
313
+ * ```typescript
314
+ * throw new GSwapAssetError(
315
+ * 'Failed to fetch user assets',
316
+ * originalGSwapError,
317
+ * 'userAddress123',
318
+ * 'NETWORK_ERROR'
319
+ * );
320
+ * ```
321
+ *
322
+ * @example Catching asset errors
323
+ * ```typescript
324
+ * try {
325
+ * const assets = await service.getUserAssets(walletAddress);
326
+ * } catch (error) {
327
+ * if (error instanceof GSwapAssetError) {
328
+ * console.log(`Asset query failed: ${error.message}`);
329
+ * console.log(`Wallet: ${error.walletAddress}`);
330
+ * }
331
+ * }
332
+ * ```
333
+ */
334
+ export declare class GSwapAssetError extends Error {
335
+ originalError: unknown;
336
+ walletAddress?: string | undefined;
337
+ code?: string | undefined;
338
+ /**
339
+ * Creates a new GSwapAssetError
340
+ *
341
+ * @param message - Human-readable error message describing what failed
342
+ * @param originalError - The original error from GSwap SDK
343
+ * @param walletAddress - Optional wallet address being queried
344
+ * @param code - Optional error code from GSwap SDK for programmatic handling
345
+ */
346
+ constructor(message: string, originalError: unknown, walletAddress?: string | undefined, code?: string | undefined);
347
+ }
171
348
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IAU/B,KAAK,CAAC,EAAE,MAAM;IACd,IAAI,CAAC,EAAE,MAAM;IAVtB;;;;;;OAMG;gBAED,OAAO,EAAE,MAAM,EACR,KAAK,CAAC,EAAE,MAAM,YAAA,EACd,IAAI,CAAC,EAAE,MAAM,YAAA;CAKvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,YAAa,SAAQ,KAAK;IAU5B,UAAU,CAAC,EAAE,MAAM;IACnB,aAAa,CAAC,EAAE,KAAK;IAV9B;;;;;;OAMG;gBAED,OAAO,EAAE,MAAM,EACR,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,aAAa,CAAC,EAAE,KAAK,YAAA;CAK/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IASlC,KAAK,CAAC,EAAE,MAAM;IARvB;;;;;OAKG;gBAED,OAAO,EAAE,MAAM,EACR,KAAK,CAAC,EAAE,MAAM,YAAA;CAKxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IAUhC,aAAa,CAAC,EAAE,MAAM;IACtB,IAAI,CAAC,EAAE,MAAM;IAVtB;;;;;;OAMG;gBAED,OAAO,EAAE,MAAM,EACR,aAAa,CAAC,EAAE,MAAM,YAAA,EACtB,IAAI,CAAC,EAAE,MAAM,YAAA;CAKvB"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBA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;IAW9B,aAAa,EAAE,OAAO;IACtB,eAAe,CAAC,EAAE,MAAM;IACxB,IAAI,CAAC,EAAE,MAAM;IAZtB;;;;;;;OAOG;gBAED,OAAO,EAAE,MAAM,EACR,aAAa,EAAE,OAAO,EACtB,eAAe,CAAC,EAAE,MAAM,YAAA,EACxB,IAAI,CAAC,EAAE,MAAM,YAAA;CAKvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,cAAe,SAAQ,KAAK;IAY9B,aAAa,EAAE,OAAO;IACtB,MAAM,CAAC,EAAE,MAAM;IACf,MAAM,CAAC,EAAE,MAAM;IACf,IAAI,CAAC,EAAE,MAAM;IAdtB;;;;;;;;OAQG;gBAED,OAAO,EAAE,MAAM,EACR,aAAa,EAAE,OAAO,EACtB,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,IAAI,CAAC,EAAE,MAAM,YAAA;CAKvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IAW/B,aAAa,EAAE,OAAO;IACtB,aAAa,CAAC,EAAE,MAAM;IACtB,IAAI,CAAC,EAAE,MAAM;IAZtB;;;;;;;OAOG;gBAED,OAAO,EAAE,MAAM,EACR,aAAa,EAAE,OAAO,EACtB,aAAa,CAAC,EAAE,MAAM,YAAA,EACtB,IAAI,CAAC,EAAE,MAAM,YAAA;CAKvB"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * TokenFormatConverter - Converts between different token ID formats
3
+ *
4
+ * ⚠️ CRITICAL ARCHITECTURAL NOTE:
5
+ * This utility is for FORMAT CONVERSION ONLY (pipe-delimited ↔ object/string).
6
+ * Do NOT use for symbol extraction or metadata inference!
7
+ *
8
+ * For symbol/metadata resolution:
9
+ * - Use GalaChainService.fetchTokenClassFromChain() to query real blockchain data
10
+ * - Use DexService.fetchTokenDetails() for complete token metadata
11
+ * - Use data from GSwap SDK responses directly (already contains correct symbols)
12
+ *
13
+ * Launchpad SDK uses: { collection, category, type, additionalKey }
14
+ * GSwap SDK uses: "symbol|Unit|none|none" (pipe-delimited string)
15
+ *
16
+ * This utility handles bidirectional conversion between formats.
17
+ */
18
+ import type { TokenClass } from '../types/gswap.dto';
19
+ export declare class TokenFormatConverter {
20
+ /**
21
+ * Convert Launchpad token format to GSwap format (pipe-delimited string)
22
+ *
23
+ * ⚠️ WARNING: For API format conversion ONLY
24
+ * This does NOT validate or resolve token symbols - it's structural only.
25
+ *
26
+ * Input: "GALA" or "GALA|Unit|none|none" or { collection: "Token", category: "Unit", type: "GALA", additionalKey: "none" }
27
+ * Output: "GALA|Unit|none|none"
28
+ */
29
+ toLaunchpadFormat(token: string | TokenClass | any): string;
30
+ /**
31
+ * Convert GSwap format (pipe-delimited) to TokenClass object
32
+ *
33
+ * ⚠️ WARNING: For API format conversion ONLY
34
+ * This does NOT provide real symbol/metadata - it's structural only.
35
+ * For actual token data, use GalaChainService.fetchTokenClassFromChain()
36
+ *
37
+ * Input: "GALA|Unit|none|none" or { type: "GALA", ... }
38
+ * Output: { collection: "Token", category: "Unit", type: "GALA", additionalKey: "none" }
39
+ */
40
+ toTokenClass(token: string | TokenClass | any): TokenClass;
41
+ /**
42
+ * Check if token is in pipe-delimited format
43
+ * Input: "GALA|Unit|none|none" → true
44
+ * Input: "GALA" → false
45
+ */
46
+ isGSwapFormat(token: string): boolean;
47
+ /**
48
+ * Normalize any token format to pipe-delimited GSwap format
49
+ *
50
+ * ⚠️ WARNING: For API format conversion ONLY
51
+ * Does not validate or resolve symbols - structural conversion only.
52
+ *
53
+ * Input: "GALA" or "GALA|Unit|none|none" or { type: "GALA" }
54
+ * Output: "GALA|Unit|none|none"
55
+ */
56
+ normalize(token: string | TokenClass): string;
57
+ }
58
+ //# sourceMappingURL=token-format-converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-format-converter.d.ts","sourceRoot":"","sources":["../../src/utils/token-format-converter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,qBAAa,oBAAoB;IAC/B;;;;;;;;OAQG;IACH,iBAAiB,CACf,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,GAAG,GAC/B,MAAM;IAuBT;;;;;;;;;OASG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,GAAG,GAAG,UAAU;IAmC1D;;;;OAIG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIrC;;;;;;;;OAQG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM;CAY9C"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gala-chain/launchpad-sdk",
3
- "version": "3.23.0",
4
- "description": "TypeScript SDK for Gala Launchpad Backend API - 59 methods supporting optional wallet (read-only and full-access modes). Production-ready DeFi token launchpad integration with AgentConfig setup, GalaChain trading, price history, token creation, and comprehensive user operations. Multi-format output (ESM, CJS, UMD).",
3
+ "version": "3.24.1",
4
+ "description": "TypeScript SDK for Gala Launchpad Backend API - 64 methods supporting optional wallet (read-only and full-access modes). Production-ready DeFi token launchpad integration with AgentConfig setup, GalaChain trading, GSwap DEX integration, price history, token creation, and comprehensive user operations. Multi-format output (ESM, CJS, UMD).",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "types": "dist/index.d.ts",
@@ -148,6 +148,7 @@
148
148
  "dependencies": {
149
149
  "@gala-chain/api": "^2.4.3",
150
150
  "@gala-chain/connect": "^2.4.3",
151
+ "@gala-chain/gswap-sdk": "^0.0.9",
151
152
  "@types/uuid": "^10.0.0",
152
153
  "axios": "^1.12.2",
153
154
  "bignumber.js": "^9.1.2",