@gala-chain/launchpad-sdk 4.0.4-beta.0 → 4.0.5

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 (37) hide show
  1. package/EXAMPLES.md +96 -35
  2. package/README.md +2 -0
  3. package/dist/index.cjs.js +1 -1
  4. package/dist/index.esm.js +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/src/LaunchpadSDK.d.ts +750 -72
  7. package/dist/src/LaunchpadSDK.d.ts.map +1 -1
  8. package/dist/src/constants/version.generated.d.ts +1 -1
  9. package/dist/src/constants/version.generated.d.ts.map +1 -1
  10. package/dist/src/services/DexBackendClient.d.ts +139 -10
  11. package/dist/src/services/DexBackendClient.d.ts.map +1 -1
  12. package/dist/src/services/DexQuoteService.d.ts +181 -22
  13. package/dist/src/services/DexQuoteService.d.ts.map +1 -1
  14. package/dist/src/services/DexService.d.ts +274 -38
  15. package/dist/src/services/DexService.d.ts.map +1 -1
  16. package/dist/src/services/GSwapService.d.ts +555 -246
  17. package/dist/src/services/GSwapService.d.ts.map +1 -1
  18. package/dist/src/services/GalaChainGatewayClient.d.ts +139 -41
  19. package/dist/src/services/GalaChainGatewayClient.d.ts.map +1 -1
  20. package/dist/src/services/ImageService.d.ts +101 -12
  21. package/dist/src/services/ImageService.d.ts.map +1 -1
  22. package/dist/src/services/PoolCacheManager.d.ts +125 -31
  23. package/dist/src/services/PoolCacheManager.d.ts.map +1 -1
  24. package/dist/src/services/SignatureService.d.ts +35 -5
  25. package/dist/src/services/SignatureService.d.ts.map +1 -1
  26. package/dist/src/services/SwapEventQueue.d.ts +79 -10
  27. package/dist/src/services/SwapEventQueue.d.ts.map +1 -1
  28. package/dist/src/services/TokenClassKeyService.d.ts +56 -10
  29. package/dist/src/services/TokenClassKeyService.d.ts.map +1 -1
  30. package/dist/src/services/TokenMetadataService.d.ts +407 -31
  31. package/dist/src/services/TokenMetadataService.d.ts.map +1 -1
  32. package/dist/src/services/TradeService.d.ts +168 -6
  33. package/dist/src/services/TradeService.d.ts.map +1 -1
  34. package/dist/src/services/UserService.d.ts +117 -15
  35. package/dist/src/services/UserService.d.ts.map +1 -1
  36. package/package.json +12 -2
  37. package/API.md +0 -1475
@@ -24,35 +24,111 @@ export declare class GSwapService extends LoggerBase {
24
24
  */
25
25
  setPricingConcurrency(concurrency: number): void;
26
26
  /**
27
- * Get swap quote for exact input (spending known amount)
28
- *
29
- * Uses DexQuoteService with dynamic fee tier discovery ([3000, 500, 10000]).
30
- * NEVER falls back - if all fee tiers fail, throws loudly to expose the real problem.
31
- *
32
- * Guarantees: All quotes are ALWAYS fresh (never cached) to prevent MEV in volatile markets.
27
+ * Get swap quote for spending a known input amount (exact input swap quote)
28
+ *
29
+ * Calculates how much of the destination token you will receive when spending a specific amount
30
+ * of the source token. Uses dynamic fee tier discovery to find the best available liquidity pool,
31
+ * trying fee tiers in order of typical liquidity: 3000 (0.30%), 500 (0.05%), then 10000 (1.00%).
32
+ * All quotes are always fresh (never cached) to prevent MEV vulnerabilities in volatile markets.
33
+ *
34
+ * @param params - Quote request parameters
35
+ * @param params.fromToken - Source token identifier (pipe-delimited format: 'GALA|Unit|none|none')
36
+ * @param params.toToken - Destination token identifier (pipe-delimited format)
37
+ * @param params.amount - Input amount to spend (must be positive number string)
38
+ * @returns Promise<SwapQuoteResult> Quote with estimated output amount, fee tier, price impact, and execution price
39
+ * @throws {GSwapQuoteError} If DexQuoteService not configured or all fee tiers fail to provide a quote
40
+ * @since 4.0.4-beta.0
41
+ * @category Services
42
+ *
43
+ * @example Get quote for buying tokens with 100 GALA
44
+ * ```typescript
45
+ * const quote = await gswapService.getSwapQuoteExactInput({
46
+ * fromToken: 'GALA|Unit|none|none',
47
+ * toToken: 'Token|Unit|BENE|client:123',
48
+ * amount: '100'
49
+ * });
33
50
  *
34
- * @param params Quote request with fromToken, toToken, and input amount
35
- * @returns Quote with estimated output, actual price impact, and fees
36
- * @throws GSwapQuoteError if DexQuoteService not configured or all fee tiers fail
51
+ * console.log(`Spending ${quote.inputAmount} GALA`);
52
+ * console.log(`Receiving ~${quote.estimatedOutput} BENE tokens`);
53
+ * console.log(`Fee tier: ${quote.feeTier / 100}%`);
54
+ * console.log(`Price impact: ${(parseFloat(quote.priceImpact) * 100).toFixed(4)}%`);
55
+ * ```
37
56
  */
38
57
  getSwapQuoteExactInput(params: SwapQuoteParams): Promise<SwapQuoteResult>;
39
58
  /**
40
- * Get swap quote for exact output (receive known amount)
41
- *
42
- * Uses DexQuoteService with dynamic fee tier discovery ([3000, 500, 10000]).
43
- * NEVER falls back - if all fee tiers fail, throws loudly to expose the real problem.
44
- *
45
- * Guarantees: All quotes are ALWAYS fresh (never cached) to prevent MEV in volatile markets.
59
+ * Get swap quote for receiving a known output amount (exact output swap quote)
60
+ *
61
+ * Calculates how much of the source token you need to spend to receive a specific amount
62
+ * of the destination token. Uses dynamic fee tier discovery to find the best available liquidity pool,
63
+ * trying fee tiers in order of typical liquidity: 3000 (0.30%), 500 (0.05%), then 10000 (1.00%).
64
+ * All quotes are always fresh (never cached) to prevent MEV vulnerabilities in volatile markets.
65
+ *
66
+ * @param params - Quote request parameters
67
+ * @param params.fromToken - Source token identifier (pipe-delimited format: 'GALA|Unit|none|none')
68
+ * @param params.toToken - Destination token identifier (pipe-delimited format)
69
+ * @param params.amount - Desired output amount to receive (must be positive number string)
70
+ * @returns Promise<SwapQuoteResult> Quote with required input amount, fee tier, price impact, and execution price
71
+ * @throws {GSwapQuoteError} If DexQuoteService not configured or all fee tiers fail to provide a quote
72
+ * @since 4.0.4-beta.0
73
+ * @category Services
74
+ *
75
+ * @example Get quote for receiving exactly 50 tokens
76
+ * ```typescript
77
+ * const quote = await gswapService.getSwapQuoteExactOutput({
78
+ * fromToken: 'GALA|Unit|none|none',
79
+ * toToken: 'GUSDC|Unit|none|none',
80
+ * amount: '50'
81
+ * });
46
82
  *
47
- * @param params Quote request with fromToken, toToken, and desired output
48
- * @returns Quote with required input, actual price impact, and fees
49
- * @throws GSwapQuoteError if DexQuoteService not configured or all fee tiers fail
83
+ * console.log(`Need to spend ${quote.inputAmount} GALA`);
84
+ * console.log(`To receive exactly ${quote.estimatedOutput} GUSDC`);
85
+ * console.log(`Fee tier: ${quote.feeTier / 100}%`);
86
+ * console.log(`Price impact: ${(parseFloat(quote.priceImpact) * 100).toFixed(4)}%`);
87
+ * ```
50
88
  */
51
89
  getSwapQuoteExactOutput(params: SwapQuoteParams): Promise<SwapQuoteResult>;
52
90
  /**
53
- * Execute a token swap with slippage protection
54
- * @param params Swap execution parameters
55
- * @returns Swap result with transaction details
91
+ * Execute a token swap with slippage protection on GalaSwap DEX
92
+ *
93
+ * Performs a direct swap transaction between two tokens using the specified fee tier pool.
94
+ * Automatically calculates slippage-adjusted minimum output to protect against price movement,
95
+ * submits the transaction via the bundler, and monitors confirmation via WebSocket. Always get
96
+ * a fresh quote before executing to ensure accurate pricing and appropriate fee tier selection.
97
+ *
98
+ * @param params - Swap execution parameters
99
+ * @param params.fromToken - Source token to swap from (pipe-delimited format: 'GALA|Unit|none|none')
100
+ * @param params.toToken - Destination token to swap to (pipe-delimited format)
101
+ * @param params.inputAmount - Amount of source token to spend (string number)
102
+ * @param params.estimatedOutput - Expected output amount from quote (used for slippage calculation)
103
+ * @param params.feeTier - Pool fee tier in basis points (500 = 0.05%, 3000 = 0.30%, 10000 = 1.00%)
104
+ * @param params.slippageTolerance - Maximum acceptable slippage (default: 0.01 = 1%)
105
+ * @returns Promise<ExecuteSwapResult> Transaction result with status, amounts, and monitoring details
106
+ * @throws {Error} If private key not available, wallet address missing, or transaction fails
107
+ * @since 4.0.4-beta.0
108
+ * @category Services
109
+ *
110
+ * @example Complete swap workflow with quote and execution
111
+ * ```typescript
112
+ * // Step 1: Get fresh quote
113
+ * const quote = await gswapService.getSwapQuoteExactInput({
114
+ * fromToken: 'GALA|Unit|none|none',
115
+ * toToken: 'GUSDC|Unit|none|none',
116
+ * amount: '100'
117
+ * });
118
+ *
119
+ * // Step 2: Execute swap with 1% slippage tolerance
120
+ * const result = await gswapService.executeSwap({
121
+ * fromToken: 'GALA|Unit|none|none',
122
+ * toToken: 'GUSDC|Unit|none|none',
123
+ * inputAmount: '100',
124
+ * estimatedOutput: quote.estimatedOutput,
125
+ * feeTier: quote.feeTier, // Use fee tier from quote
126
+ * slippageTolerance: 0.01 // 1% max slippage
127
+ * });
128
+ *
129
+ * console.log(`Swap ${result.status}: ${result.transactionId}`);
130
+ * console.log(`Spent ${result.inputAmount} → Received ${result.outputAmount}`);
131
+ * ```
56
132
  */
57
133
  executeSwap(params: ExecuteSwapParams): Promise<ExecuteSwapResult>;
58
134
  /**
@@ -109,21 +185,152 @@ export declare class GSwapService extends LoggerBase {
109
185
  * @returns TokenClassKey object
110
186
  */
111
187
  private parseTokenFlexible;
188
+ /**
189
+ * Fetch user's liquidity positions with pagination and optional price enrichment
190
+ *
191
+ * Retrieves concentrated liquidity positions for a specific wallet address using bookmark-based
192
+ * cursor pagination. Supports optional real-time price enrichment to include current token prices
193
+ * and position value calculations. Use this method when you need manual pagination control or
194
+ * want to fetch positions incrementally.
195
+ *
196
+ * @param ownerAddress - Wallet address to query positions for (format: 'eth|0x...' or 'client|...')
197
+ * @param limit - Maximum positions per page (default: GSWAP_LIQUIDITY_POSITIONS_PAGE_SIZE)
198
+ * @param bookmark - Optional pagination cursor from previous result's nextBookmark field
199
+ * @param options - Optional configuration for price enrichment and additional data
200
+ * @param options.withPrices - If true, enriches positions with current token prices and USD values
201
+ * @returns Promise<GetLiquidityPositionsResult> Paginated positions with optional nextBookmark and prices
202
+ * @throws {GSwapPositionError} If API request fails or position normalization errors occur
203
+ * @since 4.0.4-beta.0
204
+ * @category Services
205
+ *
206
+ * @example Manual pagination without price enrichment
207
+ * ```typescript
208
+ * // Fetch first page
209
+ * const page1 = await gswapService.getUserLiquidityPositions(
210
+ * 'eth|0x1234...',
211
+ * 10
212
+ * );
213
+ *
214
+ * console.log(`Found ${page1.items.length} positions`);
215
+ *
216
+ * // Fetch next page if available
217
+ * if (page1.nextBookmark) {
218
+ * const page2 = await gswapService.getUserLiquidityPositions(
219
+ * 'eth|0x1234...',
220
+ * 10,
221
+ * page1.nextBookmark
222
+ * );
223
+ * }
224
+ * ```
225
+ *
226
+ * @example Fetch positions with real-time price enrichment
227
+ * ```typescript
228
+ * const positions = await gswapService.getUserLiquidityPositions(
229
+ * 'eth|0x1234...',
230
+ * 20,
231
+ * undefined,
232
+ * { withPrices: true }
233
+ * );
234
+ *
235
+ * // Prices map available at result.prices
236
+ * positions.items.forEach(pos => {
237
+ * const poolKey = `${pos.token0}/${pos.token1}`;
238
+ * const prices = positions.prices?.get(poolKey);
239
+ * if (prices) {
240
+ * console.log(`${poolKey}: Token0=$${prices.token0PriceUsd}, Token1=$${prices.token1PriceUsd}`);
241
+ * }
242
+ * });
243
+ * ```
244
+ */
112
245
  getUserLiquidityPositions(ownerAddress: string, limit?: number, bookmark?: string, options?: GetLiquidityPositionsOptions): Promise<GetLiquidityPositionsResult>;
113
246
  /**
114
- * Get ALL user liquidity positions with automatic pagination
115
- * Automatically fetches all pages of liquidity positions for a wallet
116
- * Uses bookmark-based cursor pagination internally
117
- * @param ownerAddress User's wallet address
118
- * @param options Optional configuration for pricing enrichment
119
- * @returns All liquidity positions combined from all pages, optionally with pricing data
247
+ * Fetch ALL user liquidity positions with automatic pagination and optional price enrichment
248
+ *
249
+ * Convenience method that automatically handles bookmark-based pagination to retrieve all
250
+ * concentrated liquidity positions for a wallet in a single call. Uses maximum page size
251
+ * internally for efficiency and combines results from all pages. Optionally enriches positions
252
+ * with real-time token prices and USD value calculations.
253
+ *
254
+ * @param ownerAddress - Wallet address to query positions for (format: 'eth|0x...' or 'client|...')
255
+ * @param options - Optional configuration for price enrichment and additional data
256
+ * @param options.withPrices - If true, enriches all positions with current token prices and USD values
257
+ * @returns Promise<GSwapPosition[] | GetLiquidityPositionsResult> All positions (array if no prices, result with prices if requested)
258
+ * @throws {GSwapPositionError} If API request fails or position normalization errors occur
259
+ * @since 4.0.4-beta.0
260
+ * @category Services
261
+ *
262
+ * @example Fetch all positions without prices (simple array)
263
+ * ```typescript
264
+ * const allPositions = await gswapService.getAllSwapUserLiquidityPositions(
265
+ * 'eth|0x1234...'
266
+ * );
267
+ *
268
+ * console.log(`Total positions: ${allPositions.length}`);
269
+ * allPositions.forEach(pos => {
270
+ * console.log(`Position ${pos.positionId}: ${pos.token0}/${pos.token1}`);
271
+ * console.log(` Liquidity: ${pos.liquidity}, Range: ${pos.tickLower}-${pos.tickUpper}`);
272
+ * });
273
+ * ```
274
+ *
275
+ * @example Fetch all positions with price enrichment (full result object)
276
+ * ```typescript
277
+ * const result = await gswapService.getAllSwapUserLiquidityPositions(
278
+ * 'eth|0x1234...',
279
+ * { withPrices: true }
280
+ * );
281
+ *
282
+ * // When withPrices=true, returns GetLiquidityPositionsResult with prices Map
283
+ * if ('prices' in result) {
284
+ * result.items.forEach(pos => {
285
+ * const poolKey = `${pos.token0}/${pos.token1}`;
286
+ * const prices = result.prices?.get(poolKey);
287
+ * if (prices) {
288
+ * console.log(`${poolKey}: $${prices.token0PriceUsd} / $${prices.token1PriceUsd}`);
289
+ * }
290
+ * });
291
+ * }
292
+ * ```
120
293
  */
121
294
  getAllSwapUserLiquidityPositions(ownerAddress: string, options?: GetLiquidityPositionsOptions): Promise<GSwapPosition[] | GetLiquidityPositionsResult>;
122
295
  /**
123
- * Get a specific liquidity position
124
- * @param ownerAddress User's wallet address
125
- * @param position Position details (token0, token1, fee, tickLower, tickUpper)
126
- * @returns Detailed position information with full type safety
296
+ * Fetch a specific liquidity position by its compound key (token pair, fee tier, and tick range)
297
+ *
298
+ * Retrieves detailed information about a single concentrated liquidity position using its
299
+ * compound key consisting of the token pair, fee tier, and tick boundaries. This method
300
+ * validates tick spacing for the given fee tier before making the API call to ensure the
301
+ * position parameters are valid for the specified pool.
302
+ *
303
+ * @param ownerAddress - Wallet address that owns the position (format: 'eth|0x...' or 'client|...')
304
+ * @param position - Compound key identifying the specific position
305
+ * @param position.token0 - First token identifier (pipe-delimited format: 'GALA|Unit|none|none')
306
+ * @param position.token1 - Second token identifier (pipe-delimited format)
307
+ * @param position.fee - Pool fee tier in basis points (500, 3000, or 10000)
308
+ * @param position.tickLower - Lower tick boundary of the position's price range
309
+ * @param position.tickUpper - Upper tick boundary of the position's price range
310
+ * @returns Promise<GSwapPosition> Complete position details with liquidity, amounts, and fees
311
+ * @throws {GSwapPositionError} If position not found, tick spacing invalid, or API request fails
312
+ * @since 4.0.4-beta.0
313
+ * @category Services
314
+ *
315
+ * @example Fetch position by compound key
316
+ * ```typescript
317
+ * const position = await gswapService.getLiquidityPosition(
318
+ * 'eth|0x1234...',
319
+ * {
320
+ * token0: 'GALA|Unit|none|none',
321
+ * token1: 'GUSDC|Unit|none|none',
322
+ * fee: 3000, // 0.30% fee tier
323
+ * tickLower: -276330,
324
+ * tickUpper: -276270
325
+ * }
326
+ * );
327
+ *
328
+ * console.log(`Position ID: ${position.positionId}`);
329
+ * console.log(`Liquidity: ${position.liquidity}`);
330
+ * console.log(`Token0 amount: ${position.amount0}`);
331
+ * console.log(`Token1 amount: ${position.amount1}`);
332
+ * console.log(`Uncollected fees: ${position.feeAmount0} / ${position.feeAmount1}`);
333
+ * ```
127
334
  */
128
335
  getLiquidityPosition(ownerAddress: string, position: {
129
336
  token0: string;
@@ -133,15 +340,51 @@ export declare class GSwapService extends LoggerBase {
133
340
  tickUpper: number;
134
341
  }): Promise<GSwapPosition>;
135
342
  /**
136
- * Get a liquidity position by its ID
137
- * @param ownerAddress User's wallet address
138
- * @param positionId Position UUID
139
- * @param token0 Optional first token for compound key lookup (token0)
140
- * @param token1 Optional second token for compound key lookup (token1)
141
- * @param feeTier Optional fee tier for compound key lookup (500, 3000, or 10000)
142
- * @param tickLower Optional lower tick boundary for compound key lookup
143
- * @param tickUpper Optional upper tick boundary for compound key lookup
144
- * @returns Detailed position information with full type safety
343
+ * Fetch a liquidity position by its unique position ID with automatic retry logic
344
+ *
345
+ * Retrieves detailed information about a concentrated liquidity position using its unique position ID.
346
+ * Includes automatic retry logic (5 attempts with 2-second delays) for newly created positions that
347
+ * may not be immediately indexed. Optionally accepts compound key parameters (token pair, fee tier,
348
+ * tick range) for faster compound key lookup instead of iterating through all positions.
349
+ *
350
+ * @param ownerAddress - Wallet address that owns the position (format: 'eth|0x...' or 'client|...')
351
+ * @param positionId - Unique position UUID returned when position was created
352
+ * @param token0 - Optional first token for compound key lookup (faster than ID scan)
353
+ * @param token1 - Optional second token for compound key lookup (faster than ID scan)
354
+ * @param feeTier - Optional fee tier in basis points for compound key lookup (500, 3000, or 10000)
355
+ * @param tickLower - Optional lower tick boundary for compound key lookup
356
+ * @param tickUpper - Optional upper tick boundary for compound key lookup
357
+ * @returns Promise<GSwapPosition> Complete position details with liquidity, amounts, fees, and metadata
358
+ * @throws {GSwapPositionError} If position not found after retries or API request fails
359
+ * @since 4.0.4-beta.0
360
+ * @category Services
361
+ *
362
+ * @example Fetch position by ID only (with automatic retry)
363
+ * ```typescript
364
+ * const position = await gswapService.getLiquidityPositionById(
365
+ * 'eth|0x1234...',
366
+ * 'abc123-position-uuid'
367
+ * );
368
+ *
369
+ * console.log(`Found position: ${position.token0}/${position.token1}`);
370
+ * console.log(`Liquidity: ${position.liquidity}`);
371
+ * ```
372
+ *
373
+ * @example Fetch position by ID with compound key for faster lookup
374
+ * ```typescript
375
+ * // Providing compound key parameters enables direct lookup (much faster)
376
+ * const position = await gswapService.getLiquidityPositionById(
377
+ * 'eth|0x1234...',
378
+ * 'abc123-position-uuid',
379
+ * 'GALA|Unit|none|none',
380
+ * 'GUSDC|Unit|none|none',
381
+ * 3000, // 0.30% fee tier
382
+ * -276330, // tickLower
383
+ * -276270 // tickUpper
384
+ * );
385
+ *
386
+ * console.log(`Position ${position.positionId} found via compound key`);
387
+ * ```
145
388
  */
146
389
  getLiquidityPositionById(ownerAddress: string, positionId: string, token0?: string | Record<string, unknown>, token1?: string | Record<string, unknown>, feeTier?: number, tickLower?: number, tickUpper?: number): Promise<GSwapPosition>;
147
390
  /**
@@ -164,9 +407,59 @@ export declare class GSwapService extends LoggerBase {
164
407
  owner: string;
165
408
  }): Promise<GSwapPosition>;
166
409
  /**
167
- * Estimate tokens received from removing liquidity
168
- * @param args Removal estimation parameters including owner address
169
- * @returns Estimated token amounts
410
+ * Estimate token amounts that will be received when removing liquidity from a position
411
+ *
412
+ * Calculates the expected token0 and token1 amounts that will be returned when removing a
413
+ * specific amount of liquidity from a concentrated liquidity position. This is useful for
414
+ * previewing the outcome before executing the actual removal transaction. Validates tick
415
+ * spacing for the given fee tier before making the API call to ensure valid parameters.
416
+ *
417
+ * @param args - Liquidity removal estimation parameters
418
+ * @param args.token0 - First token identifier (pipe-delimited format: 'GALA|Unit|none|none')
419
+ * @param args.token1 - Second token identifier (pipe-delimited format)
420
+ * @param args.fee - Pool fee tier in basis points (500, 3000, or 10000)
421
+ * @param args.liquidity - Amount of liquidity to remove (string number from position.liquidity)
422
+ * @param args.tickLower - Lower tick boundary of the position
423
+ * @param args.tickUpper - Upper tick boundary of the position
424
+ * @param args.owner - Wallet address that owns the position (format: 'eth|0x...' or 'client|...')
425
+ * @returns Promise<GSwapEstimateRemoveLiquidityResult> Estimated token0 and token1 amounts to be received
426
+ * @throws {GSwapPositionError} If tick spacing invalid, parameters incorrect, or API request fails
427
+ * @since 4.0.4-beta.0
428
+ * @category Services
429
+ *
430
+ * @example Estimate removal before executing
431
+ * ```typescript
432
+ * // First, get the position details
433
+ * const position = await gswapService.getLiquidityPositionById(
434
+ * 'eth|0x1234...',
435
+ * 'position-uuid'
436
+ * );
437
+ *
438
+ * // Estimate what you'll receive from removing all liquidity
439
+ * const estimate = await gswapService.estimateRemoveLiquidity({
440
+ * token0: position.token0,
441
+ * token1: position.token1,
442
+ * fee: position.feeTier,
443
+ * liquidity: position.liquidity, // Remove all liquidity
444
+ * tickLower: position.tickLower,
445
+ * tickUpper: position.tickUpper,
446
+ * owner: 'eth|0x1234...'
447
+ * });
448
+ *
449
+ * console.log(`Removing liquidity will return:`);
450
+ * console.log(` Token0: ${estimate.amount0}`);
451
+ * console.log(` Token1: ${estimate.amount1}`);
452
+ *
453
+ * // Then execute actual removal if amounts look good
454
+ * const result = await gswapService.removeLiquidity({
455
+ * token0: position.token0,
456
+ * token1: position.token1,
457
+ * fee: position.feeTier,
458
+ * liquidity: position.liquidity,
459
+ * tickLower: position.tickLower,
460
+ * tickUpper: position.tickUpper
461
+ * });
462
+ * ```
170
463
  */
171
464
  estimateRemoveLiquidity(args: {
172
465
  token0: string;
@@ -178,9 +471,51 @@ export declare class GSwapService extends LoggerBase {
178
471
  owner: string;
179
472
  }): Promise<GSwapEstimateRemoveLiquidityResult>;
180
473
  /**
181
- * Add liquidity using price ranges (user-friendly)
182
- * @param args Liquidity addition parameters with price ranges
183
- * @returns Transaction result with position ID
474
+ * Add concentrated liquidity to a DEX pool using user-friendly price ranges
475
+ *
476
+ * Creates a new liquidity position in a GalaSwap concentrated liquidity pool by specifying minimum
477
+ * and maximum prices instead of raw tick values. Automatically converts price ranges to tick boundaries
478
+ * using the pool's tick spacing, submits the transaction via bundler, and monitors confirmation via
479
+ * WebSocket. Returns a result object with transaction details and an optional wait() method for
480
+ * tracking on-chain confirmation.
481
+ *
482
+ * @param args - Liquidity addition parameters with price range
483
+ * @param args.token0 - First token identifier (pipe-delimited format: 'GALA|Unit|none|none')
484
+ * @param args.token1 - Second token identifier (pipe-delimited format)
485
+ * @param args.fee - Pool fee tier in basis points (500 = 0.05%, 3000 = 0.30%, 10000 = 1.00%)
486
+ * @param args.minPrice - Minimum price for the liquidity range (string number, token1 per token0)
487
+ * @param args.maxPrice - Maximum price for the liquidity range (string number, token1 per token0)
488
+ * @param args.amount0Desired - Desired amount of token0 to deposit (string number)
489
+ * @param args.amount1Desired - Desired amount of token1 to deposit (string number)
490
+ * @param args.amount0Min - Optional minimum amount0 to accept (default: '0')
491
+ * @param args.amount1Min - Optional minimum amount1 to accept (default: '0')
492
+ * @returns Promise<GSwapAddLiquidityResult> Transaction result with positionId, liquidity amounts, status, and wait() helper
493
+ * @throws {Error} If private key not available, wallet address missing, or transaction fails
494
+ * @since 4.0.4-beta.0
495
+ * @category Services
496
+ *
497
+ * @example Add liquidity with price range (user-friendly approach)
498
+ * ```typescript
499
+ * // Add liquidity to GALA/GUSDC pool with price range $0.025 to $0.035
500
+ * const result = await gswapService.addLiquidityByPrice({
501
+ * token0: 'GALA|Unit|none|none',
502
+ * token1: 'GUSDC|Unit|none|none',
503
+ * fee: 3000, // 0.30% fee tier
504
+ * minPrice: '0.025', // Minimum price: $0.025 per GALA
505
+ * maxPrice: '0.035', // Maximum price: $0.035 per GALA
506
+ * amount0Desired: '1000', // Deposit up to 1000 GALA
507
+ * amount1Desired: '30', // Deposit up to 30 GUSDC
508
+ * amount0Min: '900', // Accept minimum 900 GALA
509
+ * amount1Min: '25' // Accept minimum 25 GUSDC
510
+ * });
511
+ *
512
+ * console.log(`Position created: ${result.positionId}`);
513
+ * console.log(`Transaction: ${result.transactionId}`);
514
+ *
515
+ * // Wait for on-chain confirmation
516
+ * await result.wait?.();
517
+ * console.log(`Position confirmed with liquidity: ${result.liquidity}`);
518
+ * ```
184
519
  */
185
520
  addLiquidityByPrice(args: {
186
521
  token0: string;
@@ -197,71 +532,63 @@ export declare class GSwapService extends LoggerBase {
197
532
  wait?: (timeoutMs?: number) => Promise<void>;
198
533
  }>;
199
534
  /**
200
- * Add liquidity to GSwap pool using precise tick ranges (concentrated liquidity)
201
- *
202
- * **CRITICAL: WebSocket-First Pattern**
203
- * This method ensures WebSocket connection is established BEFORE submitting the
204
- * transaction to prevent race conditions where the transaction confirms before
205
- * the listener becomes active. This is essential because:
206
- *
207
- * 1. WebSocket listener created IMMEDIATELY after transactionId received
208
- * 2. Socket.IO buffers events for registered listeners
209
- * 3. If listener not active when transaction confirms, confirmation is missed
210
- * 4. Position discovery retry logic handles indexing delays (up to 11 seconds)
211
- *
212
- * **Position Discovery Flow**
213
- * After bundler submits transaction:
214
- * 1. WebSocket listener monitors for on-chain confirmation (~2-3 seconds)
215
- * 2. Once confirmed, waits for backend position indexing (5-11 seconds)
216
- * 3. Queries positions API up to 3 times with exponential backoff
217
- * 4. Matches position by token pair + fee tier (handles multiple positions)
218
- * 5. Fetches full position details for complete data
219
- *
220
- * **Token Format Support**
221
- * - String tokens: 'GALA', 'GUSDC' → auto-converted to TokenClassKey
222
- * - TokenClassKey: { collection, category, type, additionalKey }
223
- * - Both formats normalized to TokenClassKey for bundler submission
224
- *
225
- * **Tick Range Details**
226
- * - Supports negative ticks for full concentrated liquidity ranges
227
- * - Example: tickLower: -1080, tickUpper: 900
228
- * - Must be multiples of tickSpacing (determined by fee tier)
229
- * - Fee 500bps: tickSpacing=10, Fee 3000bps: tickSpacing=60, Fee 10000bps: tickSpacing=200
230
- *
231
- * @param args Liquidity addition parameters
232
- * @param args.token0 First token (string or TokenClassKey)
233
- * @param args.token1 Second token (string or TokenClassKey)
234
- * @param args.fee Fee tier in basis points (500, 3000, or 10000)
235
- * @param args.tickLower Lower tick boundary (supports negative values)
236
- * @param args.tickUpper Upper tick boundary
237
- * @param args.amount0Desired Desired amount of token0
238
- * @param args.amount1Desired Desired amount of token1
239
- * @param args.amount0Min Optional minimum token0 (default: '0')
240
- * @param args.amount1Min Optional minimum token1 (default: '0')
241
- *
242
- * @returns Promise<GSwapAddLiquidityResult> Transaction result with:
243
- * - transactionId: Bundler transaction ID
244
- * - positionId: GSwap position ID (discovered from on-chain data)
245
- * - status: Transaction status from WebSocket
246
- * - liquidity: Position liquidity amount
247
- * - amount0/amount1: Actual amounts added
248
- * - wait(): Async method to wait for confirmation
249
- *
250
- * @throws GSwapPositionError if private key unavailable or bundler submission fails
251
- *
252
- * @example
253
- * // Add liquidity with explicit tick range
254
- * const result = await sdk.addSwapLiquidityByTicks({
255
- * token0: 'GALA',
256
- * token1: 'GUSDC',
257
- * fee: 3000,
258
- * tickLower: -1080, // Supports negative ticks
259
- * tickUpper: 900,
260
- * amount0Desired: '100',
261
- * amount1Desired: '100',
535
+ * Add concentrated liquidity to a DEX pool using precise tick boundaries (advanced)
536
+ *
537
+ * Creates a new liquidity position in a GalaSwap concentrated liquidity pool using raw tick
538
+ * boundaries instead of price ranges. This advanced method gives precise control over position
539
+ * range but requires understanding of Uniswap V3 tick mechanics and tick spacing constraints.
540
+ * Automatically connects WebSocket before transaction submission to prevent missed confirmations,
541
+ * then monitors position discovery with retry logic to handle indexing delays.
542
+ *
543
+ * @param args - Liquidity addition parameters with tick boundaries
544
+ * @param args.token0 - First token (pipe-delimited string or TokenClassKey object)
545
+ * @param args.token1 - Second token (pipe-delimited string or TokenClassKey object)
546
+ * @param args.fee - Pool fee tier in basis points (500 = 0.05%, 3000 = 0.30%, 10000 = 1.00%)
547
+ * @param args.tickLower - Lower tick boundary (must be multiple of tickSpacing, supports negative values)
548
+ * @param args.tickUpper - Upper tick boundary (must be multiple of tickSpacing)
549
+ * @param args.amount0Desired - Desired amount of token0 to deposit (string number)
550
+ * @param args.amount1Desired - Desired amount of token1 to deposit (string number)
551
+ * @param args.amount0Min - Optional minimum amount0 to accept (default: '0')
552
+ * @param args.amount1Min - Optional minimum amount1 to accept (default: '0')
553
+ * @returns Promise<GSwapAddLiquidityResult> Transaction result with positionId, liquidity amounts, status, and wait() helper
554
+ * @throws {Error} If private key not available, wallet address missing, tick spacing invalid, or transaction fails
555
+ * @since 4.0.4-beta.0
556
+ * @category Services
557
+ *
558
+ * @example Add liquidity with precise tick range (advanced users)
559
+ * ```typescript
560
+ * // Add liquidity to GALA/GUSDC pool with exact tick boundaries
561
+ * // Tick spacing for fee=3000 (0.30%) is 60, so ticks must be multiples of 60
562
+ * const result = await gswapService.addSwapLiquidityByTicks({
563
+ * token0: 'GALA|Unit|none|none',
564
+ * token1: 'GUSDC|Unit|none|none',
565
+ * fee: 3000, // 0.30% fee tier → tickSpacing=60
566
+ * tickLower: -276360, // Must be multiple of 60
567
+ * tickUpper: -276240, // Must be multiple of 60
568
+ * amount0Desired: '1000',
569
+ * amount1Desired: '30',
570
+ * amount0Min: '900',
571
+ * amount1Min: '25'
262
572
  * });
263
- * console.log('Position ID:', result.positionId);
264
- * await result.wait(); // Wait for on-chain confirmation
573
+ *
574
+ * console.log(`Position ${result.positionId} created`);
575
+ * console.log(`Liquidity: ${result.liquidity}`);
576
+ *
577
+ * // Wait for on-chain confirmation
578
+ * await result.wait?.();
579
+ * console.log(`Position confirmed: ${result.status}`);
580
+ * ```
581
+ *
582
+ * @example Tick spacing constraints by fee tier
583
+ * ```typescript
584
+ * // Fee tier determines required tick spacing:
585
+ * // - Fee 500 (0.05%): tickSpacing = 10
586
+ * // - Fee 3000 (0.30%): tickSpacing = 60
587
+ * // - Fee 10000 (1.00%): tickSpacing = 200
588
+ *
589
+ * // Valid ticks for fee=3000: -276360, -276300, -276240, etc.
590
+ * // Invalid: -276350 (not multiple of 60)
591
+ * ```
265
592
  */
266
593
  addSwapLiquidityByTicks(args: {
267
594
  token0: string | TokenClassKey;
@@ -304,76 +631,70 @@ export declare class GSwapService extends LoggerBase {
304
631
  */
305
632
  private monitorBundlerTransaction;
306
633
  /**
307
- * Remove liquidity from an existing concentrated liquidity position
308
- *
309
- * **CRITICAL: WebSocket-First Pattern**
310
- * This method ensures WebSocket connection is established BEFORE submitting the
311
- * transaction to prevent race conditions where the transaction confirms before
312
- * the listener becomes active. This is essential because:
313
- *
314
- * 1. WebSocket listener created IMMEDIATELY after transactionId received
315
- * 2. Socket.IO buffers events for registered listeners
316
- * 3. If listener not active when transaction confirms, confirmation is missed
317
- * 4. Graceful fallback returns partial result with transaction ID on timeout
318
- *
319
- * **Error Handling & Recovery**
320
- * If WebSocket monitoring times out (after 60 seconds):
321
- * - Returns `{ transactionId, status: 'SUBMITTED' }` indicating transaction was accepted
322
- * - Transaction may still succeed on-chain even if monitoring fails
323
- * - Users can call `.wait()` again to retry monitoring
324
- * - Recommended: retry monitoring after waiting or check on-chain later
325
- *
326
- * **Partial vs Complete Removal**
327
- * - Partial: Set liquidity to a fraction (e.g., 50% of current amount)
328
- * - Complete: Set liquidity to the full amount to close the position
329
- * - Retrieved from position details via `getSwapUserLiquidityPositions()`
330
- *
331
- * **Token Format Support**
332
- * - String tokens: 'GALA', 'GUSDC' → auto-converted to TokenClassKey
333
- * - TokenClassKey: { collection, category, type, additionalKey }
334
- * - Both formats normalized to TokenClassKey for bundler submission
335
- *
336
- * @param args Liquidity removal parameters
337
- * @param args.token0 First token (string or TokenClassKey)
338
- * @param args.token1 Second token (string or TokenClassKey)
339
- * @param args.fee Fee tier in basis points (500, 3000, or 10000)
340
- * @param args.tickLower Lower tick boundary of the position
341
- * @param args.tickUpper Upper tick boundary of the position
342
- * @param args.liquidity Amount of liquidity to remove (partial or complete)
343
- * @param args.amount0Min Optional minimum token0 to accept (default: '0')
344
- * @param args.amount1Min Optional minimum token1 to accept (default: '0')
345
- * @param args.positionId Optional position ID for tracking/verification
346
- *
347
- * @returns Promise<GSwapRemoveLiquidityResult> Transaction result with:
348
- * - transactionId: Bundler transaction ID
349
- * - status: Transaction status from WebSocket (or 'SUBMITTED' if timeout)
350
- * - timestamp: When transaction was submitted
351
- * - wait(): Async method to monitor or retry confirmation
352
- *
353
- * @throws GSwapPositionError if private key unavailable or bundler submission fails
354
- *
355
- * @example
356
- * // Get position first
357
- * const positions = await sdk.getSwapUserLiquidityPositions(walletAddress);
358
- * const position = positions[0];
359
- *
360
- * // Remove 50% of liquidity
361
- * const liquidityToRemove = (parseFloat(position.liquidity) * 50) / 100;
362
- * const result = await sdk.removeSwapLiquidity({
363
- * token0: 'GALA',
364
- * token1: 'GUSDC',
365
- * fee: 3000,
634
+ * Remove liquidity from an existing concentrated liquidity position (partial or complete)
635
+ *
636
+ * Withdraws liquidity from a GalaSwap concentrated liquidity position, returning the underlying
637
+ * token0 and token1 amounts to your wallet. Supports both partial removal (reduce position size)
638
+ * and complete removal (close position). Validates liquidity amount to prevent zero-value removals
639
+ * that would waste gas fees. Automatically connects WebSocket before transaction submission to
640
+ * monitor confirmation, with graceful timeout handling if monitoring fails.
641
+ *
642
+ * @param args - Liquidity removal parameters
643
+ * @param args.token0 - First token (pipe-delimited string or TokenClassKey object)
644
+ * @param args.token1 - Second token (pipe-delimited string or TokenClassKey object)
645
+ * @param args.fee - Pool fee tier in basis points (500 = 0.05%, 3000 = 0.30%, 10000 = 1.00%)
646
+ * @param args.tickLower - Lower tick boundary of the position
647
+ * @param args.tickUpper - Upper tick boundary of the position
648
+ * @param args.liquidity - Amount of liquidity to remove (must be > 0, use position.liquidity for full removal)
649
+ * @param args.amount0Min - Optional minimum token0 to accept for slippage protection (default: '0')
650
+ * @param args.amount1Min - Optional minimum token1 to accept for slippage protection (default: '0')
651
+ * @param args.positionId - Optional position ID for tracking and error messaging
652
+ * @returns Promise<GSwapAddLiquidityResult> Transaction result with transactionId, status, timestamp, and wait() helper
653
+ * @throws {Error} If private key not available, liquidity is zero, or transaction fails
654
+ * @since 4.0.4-beta.0
655
+ * @category Services
656
+ *
657
+ * @example Remove 50% of liquidity from a position (partial removal)
658
+ * ```typescript
659
+ * // Step 1: Get position details
660
+ * const positions = await gswapService.getUserLiquidityPositions('eth|0x1234...');
661
+ * const position = positions.items[0];
662
+ *
663
+ * // Step 2: Calculate 50% of liquidity to remove
664
+ * const halfLiquidity = (parseFloat(position.liquidity) * 0.5).toString();
665
+ *
666
+ * // Step 3: Remove partial liquidity
667
+ * const result = await gswapService.removeLiquidity({
668
+ * token0: position.token0,
669
+ * token1: position.token1,
670
+ * fee: position.feeTier,
366
671
  * tickLower: position.tickLower,
367
672
  * tickUpper: position.tickUpper,
368
- * liquidity: liquidityToRemove.toString(),
369
- * amount0Min: '0',
673
+ * liquidity: halfLiquidity,
674
+ * amount0Min: '0', // Accept any amount (consider slippage for production)
370
675
  * amount1Min: '0',
371
- * positionId: position.positionId,
676
+ * positionId: position.positionId
372
677
  * });
373
678
  *
374
- * console.log('Removal submitted:', result.transactionId);
375
- * await result.wait(); // Wait for on-chain confirmation
376
- * console.log('Final status:', result.status);
679
+ * console.log(`Removed half liquidity: ${result.transactionId}`);
680
+ * await result.wait?.();
681
+ * ```
682
+ *
683
+ * @example Remove all liquidity to close position (complete removal)
684
+ * ```typescript
685
+ * // Close position completely by removing all liquidity
686
+ * const result = await gswapService.removeLiquidity({
687
+ * token0: 'GALA|Unit|none|none',
688
+ * token1: 'GUSDC|Unit|none|none',
689
+ * fee: 3000,
690
+ * tickLower: -276360,
691
+ * tickUpper: -276240,
692
+ * liquidity: position.liquidity, // Remove ALL liquidity
693
+ * positionId: position.positionId
694
+ * });
695
+ *
696
+ * console.log(`Position closed: ${result.status}`);
697
+ * ```
377
698
  */
378
699
  removeLiquidity(args: {
379
700
  token0: string | TokenClassKey;
@@ -387,83 +708,71 @@ export declare class GSwapService extends LoggerBase {
387
708
  positionId?: string;
388
709
  }): Promise<GSwapAddLiquidityResult>;
389
710
  /**
390
- * Collect accumulated trading fees from a concentrated liquidity position
391
- *
392
- * **CRITICAL: WebSocket-First Pattern**
393
- * This method ensures WebSocket connection is established BEFORE submitting the
394
- * transaction to prevent race conditions where the transaction confirms before
395
- * the listener becomes active. This is essential because:
396
- *
397
- * 1. WebSocket listener created IMMEDIATELY after transactionId received
398
- * 2. Socket.IO buffers events for registered listeners
399
- * 3. If listener not active when transaction confirms, confirmation is missed
400
- * 4. Graceful fallback returns partial result with transaction ID on timeout
401
- *
402
- * **Error Handling & Recovery**
403
- * If WebSocket monitoring times out (after 60 seconds):
404
- * - Returns `{ transactionId, status: 'SUBMITTED' }` indicating transaction was accepted
405
- * - Transaction may still succeed on-chain even if monitoring fails
406
- * - Users can call `.wait()` again to retry monitoring
407
- * - Recommended: retry monitoring after waiting or check position fees on-chain later
408
- *
409
- * **Fee Accumulation**
410
- * Fees accumulate when your position is in-range and trades execute within your price range.
411
- * - In-range fees: Actively accumulating (trading happens in your range)
412
- * - Out-of-range fees: Not accumulating (current price outside your range)
413
- * - Collect periodically for optimal capital efficiency (fees don't compound)
414
- * - Fees are denominated in the two tokens of the pair (token0 and token1)
415
- *
416
- * **Partial vs Complete Collection**
417
- * - Collect all: Set amount0Requested='0' and amount1Requested='0' (default)
418
- * - Collect specific amount: Set amount0Requested/amount1Requested to desired amounts
419
- * - Partial collection doesn't affect the position's liquidity
420
- * - Current fees visible in position details via `getSwapUserLiquidityPositions()`
421
- *
422
- * **Token Format Support**
423
- * - String tokens: 'GALA', 'GUSDC' → auto-converted to TokenClassKey
424
- * - TokenClassKey: { collection, category, type, additionalKey }
425
- * - Both formats normalized to TokenClassKey for bundler submission
426
- *
427
- * @param args Fee collection parameters
428
- * @param args.token0 First token (string or TokenClassKey)
429
- * @param args.token1 Second token (string or TokenClassKey)
430
- * @param args.fee Fee tier in basis points (500, 3000, or 10000)
431
- * @param args.tickLower Lower tick boundary of the position
432
- * @param args.tickUpper Upper tick boundary of the position
433
- * @param args.amount0Requested Optional amount of token0 fees to collect (default: '0' = all)
434
- * @param args.amount1Requested Optional amount of token1 fees to collect (default: '0' = all)
435
- * @param args.positionId Optional position ID for tracking/verification
436
- *
437
- * @returns Promise<GSwapCollectFeesResult> Transaction result with:
438
- * - transactionId: Bundler transaction ID
439
- * - status: Transaction status from WebSocket (or 'SUBMITTED' if timeout)
440
- * - timestamp: When transaction was submitted
441
- * - wait(): Async method to monitor or retry confirmation
442
- *
443
- * @throws GSwapPositionError if private key unavailable or bundler submission fails
444
- *
445
- * @example
446
- * // Get position with accumulated fees
447
- * const positions = await sdk.getSwapUserLiquidityPositions(walletAddress);
448
- * const position = positions[0];
449
- *
711
+ * Collect accumulated trading fees from a concentrated liquidity position (partial or complete)
712
+ *
713
+ * Claims trading fees that have accumulated in your liquidity position without affecting the
714
+ * position's liquidity. Fees only accumulate when your position is in-range (current price within
715
+ * your tick boundaries) and trades execute in that range. Supports collecting all fees at once
716
+ * (default with '0' amounts) or specific amounts for capital management strategies. Automatically
717
+ * connects WebSocket before transaction submission to monitor confirmation.
718
+ *
719
+ * @param args - Fee collection parameters (supports two patterns: direct parameters or position lookup)
720
+ * @param args.token0 - First token (pipe-delimited string or TokenClassKey, required unless using ownerAddress pattern)
721
+ * @param args.token1 - Second token (pipe-delimited string or TokenClassKey, required unless using ownerAddress pattern)
722
+ * @param args.fee - Pool fee tier in basis points (500, 3000, or 10000, required unless using ownerAddress pattern)
723
+ * @param args.tickLower - Lower tick boundary of the position (required unless using ownerAddress pattern)
724
+ * @param args.tickUpper - Upper tick boundary of the position (required unless using ownerAddress pattern)
725
+ * @param args.amount0Requested - Optional token0 fee amount to collect (default: '0' = collect all)
726
+ * @param args.amount1Requested - Optional token1 fee amount to collect (default: '0' = collect all)
727
+ * @param args.positionId - Optional position ID for tracking and verification
728
+ * @param args.ownerAddress - Alternative pattern: fetch position details first using this address and positionId
729
+ * @param args.amount0Max - Alternative naming for amount0Requested (MCP tool compatibility)
730
+ * @param args.amount1Max - Alternative naming for amount1Requested (MCP tool compatibility)
731
+ * @returns Promise<GSwapAddLiquidityResult> Transaction result with transactionId, status, timestamp, and wait() helper
732
+ * @throws {Error} If private key not available, position not found, or transaction fails
733
+ * @since 4.0.4-beta.0
734
+ * @category Services
735
+ *
736
+ * @example Collect all accumulated fees from a position
737
+ * ```typescript
738
+ * // Step 1: Get position details to check accumulated fees
739
+ * const positions = await gswapService.getUserLiquidityPositions('eth|0x1234...');
740
+ * const position = positions.items[0];
741
+ *
742
+ * console.log(`Token0 fees: ${position.feeAmount0}`);
743
+ * console.log(`Token1 fees: ${position.feeAmount1}`);
744
+ *
745
+ * // Step 2: Collect all fees if there are any
450
746
  * if (parseFloat(position.feeAmount0) > 0 || parseFloat(position.feeAmount1) > 0) {
451
- * // Collect all accumulated fees
452
- * const result = await sdk.collectSwapPositionFees({
453
- * token0: 'GALA',
454
- * token1: 'GUSDC',
455
- * fee: 3000,
747
+ * const result = await gswapService.collectPositionFees({
748
+ * token0: position.token0,
749
+ * token1: position.token1,
750
+ * fee: position.feeTier,
456
751
  * tickLower: position.tickLower,
457
752
  * tickUpper: position.tickUpper,
458
- * amount0Requested: '0', // Collect all token0 fees
459
- * amount1Requested: '0', // Collect all token1 fees
460
- * positionId: position.positionId,
753
+ * amount0Requested: '0', // '0' means collect ALL token0 fees
754
+ * amount1Requested: '0', // '0' means collect ALL token1 fees
755
+ * positionId: position.positionId
461
756
  * });
462
757
  *
463
- * console.log('Fee collection submitted:', result.transactionId);
464
- * await result.wait(); // Wait for on-chain confirmation
465
- * console.log('Fees collected successfully');
758
+ * console.log(`Fee collection submitted: ${result.transactionId}`);
759
+ * await result.wait?.();
760
+ * console.log('All fees collected successfully');
466
761
  * }
762
+ * ```
763
+ *
764
+ * @example Collect fees using position lookup pattern (MCP tool compatible)
765
+ * ```typescript
766
+ * // Alternative pattern that fetches position details automatically
767
+ * const result = await gswapService.collectPositionFees({
768
+ * ownerAddress: 'eth|0x1234...',
769
+ * positionId: 'position-uuid',
770
+ * amount0Max: '0', // Collect all token0 fees (MCP naming)
771
+ * amount1Max: '0' // Collect all token1 fees (MCP naming)
772
+ * });
773
+ *
774
+ * console.log(`Fees collected: ${result.status}`);
775
+ * ```
467
776
  */
468
777
  collectPositionFees(args: {
469
778
  token0?: string | TokenClassKey;