@gala-chain/launchpad-sdk 3.31.0 → 4.0.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 (115) hide show
  1. package/API.md +524 -4
  2. package/CHANGELOG.md +92 -0
  3. package/EXAMPLES.md +845 -0
  4. package/README.md +421 -14
  5. package/dist/LaunchpadSDK.d.ts +435 -18
  6. package/dist/LaunchpadSDK.d.ts.map +1 -1
  7. package/dist/api/LaunchpadAPI.d.ts.map +1 -1
  8. package/dist/api/dto/TransferTokenDto.d.ts.map +1 -1
  9. package/dist/constants/version.generated.d.ts +1 -1
  10. package/dist/constants/version.generated.d.ts.map +1 -1
  11. package/dist/helpers/sdk.d.ts +1 -0
  12. package/dist/helpers/sdk.d.ts.map +1 -1
  13. package/dist/index.cjs.js +1 -1
  14. package/dist/index.d.ts +10 -3
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.esm.js +1 -1
  17. package/dist/index.js +1 -1
  18. package/dist/services/BaseService.d.ts +32 -3
  19. package/dist/services/BaseService.d.ts.map +1 -1
  20. package/dist/services/BundleService.d.ts.map +1 -1
  21. package/dist/services/CommentService.d.ts.map +1 -1
  22. package/dist/services/DexBackendClient.d.ts +46 -0
  23. package/dist/services/DexBackendClient.d.ts.map +1 -0
  24. package/dist/services/DexPoolService.d.ts +54 -12
  25. package/dist/services/DexPoolService.d.ts.map +1 -1
  26. package/dist/services/DexQuoteService.d.ts +288 -0
  27. package/dist/services/DexQuoteService.d.ts.map +1 -0
  28. package/dist/services/DexService.d.ts.map +1 -1
  29. package/dist/services/FaucetService.d.ts.map +1 -1
  30. package/dist/services/GSwapService.d.ts +519 -44
  31. package/dist/services/GSwapService.d.ts.map +1 -1
  32. package/dist/services/GalaChainGatewayClient.d.ts +89 -0
  33. package/dist/services/GalaChainGatewayClient.d.ts.map +1 -0
  34. package/dist/services/GalaChainService.d.ts +26 -0
  35. package/dist/services/GalaChainService.d.ts.map +1 -1
  36. package/dist/services/ImageService.d.ts.map +1 -1
  37. package/dist/services/PoolService.d.ts.map +1 -1
  38. package/dist/services/PoolStateManager.d.ts +176 -0
  39. package/dist/services/PoolStateManager.d.ts.map +1 -0
  40. package/dist/services/PriceHistoryService.d.ts +4 -5
  41. package/dist/services/PriceHistoryService.d.ts.map +1 -1
  42. package/dist/services/SignatureService.d.ts +15 -38
  43. package/dist/services/SignatureService.d.ts.map +1 -1
  44. package/dist/services/TokenClassKeyService.d.ts +3 -4
  45. package/dist/services/TokenClassKeyService.d.ts.map +1 -1
  46. package/dist/services/TokenMetadataCache.d.ts +2 -2
  47. package/dist/services/TokenMetadataCache.d.ts.map +1 -1
  48. package/dist/services/TokenMetadataService.d.ts +3 -3
  49. package/dist/services/TokenMetadataService.d.ts.map +1 -1
  50. package/dist/services/TokenResolverService.d.ts +2 -2
  51. package/dist/services/TokenResolverService.d.ts.map +1 -1
  52. package/dist/services/TradeService.d.ts.map +1 -1
  53. package/dist/services/UserService.d.ts.map +1 -1
  54. package/dist/services/WebSocketService.d.ts +100 -2
  55. package/dist/services/WebSocketService.d.ts.map +1 -1
  56. package/dist/services/__mocks__/logger.mock.d.ts +17 -0
  57. package/dist/services/__mocks__/logger.mock.d.ts.map +1 -0
  58. package/dist/types/common.d.ts +2 -0
  59. package/dist/types/common.d.ts.map +1 -1
  60. package/dist/types/composite-pool.dto.d.ts +103 -0
  61. package/dist/types/composite-pool.dto.d.ts.map +1 -0
  62. package/dist/types/dex-pool.dto.d.ts +56 -5
  63. package/dist/types/dex-pool.dto.d.ts.map +1 -1
  64. package/dist/types/dto.d.ts +6 -6
  65. package/dist/types/dto.d.ts.map +1 -1
  66. package/dist/types/eip712-types.d.ts +140 -0
  67. package/dist/types/eip712-types.d.ts.map +1 -0
  68. package/dist/types/galachain-api.types.d.ts +206 -0
  69. package/dist/types/galachain-api.types.d.ts.map +1 -0
  70. package/dist/types/gswap-responses.types.d.ts +366 -0
  71. package/dist/types/gswap-responses.types.d.ts.map +1 -0
  72. package/dist/types/gswap.dto.d.ts +58 -3
  73. package/dist/types/gswap.dto.d.ts.map +1 -1
  74. package/dist/types/launchpad.dto.d.ts +57 -0
  75. package/dist/types/launchpad.dto.d.ts.map +1 -1
  76. package/dist/types/pool-state-delta.dto.d.ts +246 -0
  77. package/dist/types/pool-state-delta.dto.d.ts.map +1 -0
  78. package/dist/types/pool-state-manager-config.dto.d.ts +103 -0
  79. package/dist/types/pool-state-manager-config.dto.d.ts.map +1 -0
  80. package/dist/utils/SignatureHelper.d.ts.map +1 -1
  81. package/dist/utils/auto-pagination.d.ts +206 -0
  82. package/dist/utils/auto-pagination.d.ts.map +1 -0
  83. package/dist/utils/bignumber-helpers.d.ts +336 -0
  84. package/dist/utils/bignumber-helpers.d.ts.map +1 -0
  85. package/dist/utils/bignumber-pool-cache.d.ts +169 -0
  86. package/dist/utils/bignumber-pool-cache.d.ts.map +1 -0
  87. package/dist/utils/composite-pool-converter.d.ts +121 -0
  88. package/dist/utils/composite-pool-converter.d.ts.map +1 -0
  89. package/dist/utils/errors.d.ts +86 -0
  90. package/dist/utils/errors.d.ts.map +1 -1
  91. package/dist/utils/http.d.ts.map +1 -1
  92. package/dist/utils/load-env.d.ts +31 -0
  93. package/dist/utils/load-env.d.ts.map +1 -0
  94. package/dist/utils/pool-pair-parser.d.ts +55 -0
  95. package/dist/utils/pool-pair-parser.d.ts.map +1 -0
  96. package/dist/utils/pool-state-validator.d.ts +207 -0
  97. package/dist/utils/pool-state-validator.d.ts.map +1 -0
  98. package/dist/utils/position-filters.d.ts +253 -0
  99. package/dist/utils/position-filters.d.ts.map +1 -0
  100. package/dist/utils/swap-delta-calculator.d.ts +231 -0
  101. package/dist/utils/swap-delta-calculator.d.ts.map +1 -0
  102. package/dist/utils/tick-crossing-handler.d.ts +250 -0
  103. package/dist/utils/tick-crossing-handler.d.ts.map +1 -0
  104. package/dist/utils/token-format-converter.d.ts +85 -6
  105. package/dist/utils/token-format-converter.d.ts.map +1 -1
  106. package/dist/utils/token-parser.d.ts +235 -0
  107. package/dist/utils/token-parser.d.ts.map +1 -0
  108. package/dist/utils/tokenNormalizer.d.ts +66 -0
  109. package/dist/utils/tokenNormalizer.d.ts.map +1 -1
  110. package/dist/utils/transfer-validation.d.ts.map +1 -1
  111. package/dist/utils/validation-helpers.d.ts +75 -0
  112. package/dist/utils/validation-helpers.d.ts.map +1 -1
  113. package/package.json +36 -15
  114. package/dist/utils/tokenFormatConverter.d.ts +0 -53
  115. package/dist/utils/tokenFormatConverter.d.ts.map +0 -1
package/API.md CHANGED
@@ -2,17 +2,21 @@
2
2
 
3
3
  Complete API documentation for the Gala Launchpad SDK (v3.23.0+).
4
4
 
5
+ > **⚠️ BREAKING CHANGE (v3.33.0+)**: Token format parsing now **ONLY accepts delimited formats**. Plain token strings (`'GALA'`, `'GUSDC'`) are **permanently rejected** for security. Use delimited format: `'GALA|Unit|none|none'` or `'GALA$Unit$none$none'`. See README.md for [migration guide](./README.md#token-format-migration-v330).
6
+
5
7
  ## Table of Contents
6
8
 
7
9
  - [SDK Initialization](#sdk-initialization)
8
10
  - [Bonding Curve Trading (Launchpad Tokens)](#bonding-curve-trading)
9
11
  - [DEX Trading (Graduated Tokens)](#dex-trading-galaswap)
12
+ - [GalaSwap Liquidity Position Management](#galaswap-liquidity-position-management)
10
13
  - [Pool Information](#pool-information)
11
14
  - [Token Management](#token-management)
12
15
  - [Portfolio & Balances](#portfolio--balances)
13
16
  - [Price History & Analytics](#price-history--analytics)
14
17
  - [Real-Time Features](#real-time-features)
15
18
  - [Type Definitions](#type-definitions)
19
+ - [Error Handling](#error-handling)
16
20
 
17
21
  ---
18
22
 
@@ -244,8 +248,8 @@ Get a quote for swapping a known input amount on GalaSwap DEX.
244
248
 
245
249
  **Parameters:**
246
250
  ```typescript
247
- fromToken: string; // Source token ("GALA", "GUSDC", or pipe-delimited format)
248
- toToken: string; // Destination token ("GALA", "GUSDC", or pipe-delimited format)
251
+ fromToken: string; // Source token in delimited format (e.g., "GALA|Unit|none|none" or "GALA$Unit$none$none") - v3.33.0+ REQUIRED
252
+ toToken: string; // Destination token in delimited format (e.g., "GUSDC|Unit|none|none" or "GUSDC$Unit$none$none") - v3.33.0+ REQUIRED
249
253
  amount: string; // Input amount (how much fromToken to spend)
250
254
  ```
251
255
 
@@ -262,8 +266,8 @@ amount: string; // Input amount (how much fromToken to spend)
262
266
 
263
267
  **Example:**
264
268
  ```typescript
265
- // How many GUSDC for 100 GALA?
266
- const quote = await sdk.getSwapQuoteExactInput('GALA', 'GUSDC', '100');
269
+ // How many GUSDC for 100 GALA? (v3.33.0+ requires delimited token format)
270
+ const quote = await sdk.getSwapQuoteExactInput('GALA|Unit|none|none', 'GUSDC|Unit|none|none', '100');
267
271
  console.log(`Spend: 100 GALA`);
268
272
  console.log(`Receive: ~${quote.estimatedOutput} GUSDC`);
269
273
  console.log(`Price impact: ${(quote.priceImpact * 100).toFixed(2)}%`);
@@ -406,6 +410,418 @@ console.log(`Fee tiers: ${pool.feeTiers.map(t => t / 100 + '%').join(', ')}`);
406
410
 
407
411
  ---
408
412
 
413
+ ## GalaSwap Liquidity Position Management
414
+
415
+ Provide liquidity to DEX pools and earn trading fees. Liquidity positions enable passive income through fee accumulation while helping maintain DEX liquidity.
416
+
417
+ ### `getAllSwapUserLiquidityPositions(ownerAddress)`
418
+
419
+ Get **all** open liquidity positions for a wallet with automatic pagination (recommended).
420
+
421
+ **Parameters:**
422
+ ```typescript
423
+ ownerAddress: string; // Wallet address (e.g., "0x1234..." or "eth|1234...")
424
+ ```
425
+
426
+ **Returns:**
427
+ ```typescript
428
+ Array<{
429
+ positionId: string; // Unique position identifier
430
+ token0: string; // First token symbol
431
+ token1: string; // Second token symbol
432
+ feeTier: number; // Fee tier in basis points
433
+ liquidity: string; // Liquidity amount
434
+ amount0: string; // Token0 amount in position
435
+ amount1: string; // Token1 amount in position
436
+ feeAmount0: string; // Accumulated fees (Token0)
437
+ feeAmount1: string; // Accumulated fees (Token1)
438
+ tickLower: number; // Lower tick boundary
439
+ tickUpper: number; // Upper tick boundary
440
+ }>
441
+ ```
442
+
443
+ **Example:**
444
+ ```typescript
445
+ // Fetch all positions with automatic pagination
446
+ const allPositions = await sdk.getAllSwapUserLiquidityPositions('eth|0x...');
447
+
448
+ console.log(`Total positions: ${allPositions.length}`);
449
+
450
+ // Analyze positions
451
+ allPositions.forEach(pos => {
452
+ console.log(`${pos.token0}/${pos.token1}: ${pos.liquidity} liquidity`);
453
+ console.log(`Fees earned: ${pos.feeAmount0} ${pos.token0}, ${pos.feeAmount1} ${pos.token1}`);
454
+ });
455
+
456
+ // Find best-performing position (highest accumulated fees)
457
+ const bestPosition = allPositions.reduce((best, current) => {
458
+ const currentFees = parseFloat(current.feeAmount0) + parseFloat(current.feeAmount1);
459
+ const bestFees = parseFloat(best.feeAmount0) + parseFloat(best.feeAmount1);
460
+ return currentFees > bestFees ? current : best;
461
+ });
462
+ console.log(`Best position: ${bestPosition.token0}/${bestPosition.token1}`);
463
+ ```
464
+
465
+ ### `getSwapUserLiquidityPositions(ownerAddress, limit?, bookmark?)`
466
+
467
+ Get open liquidity positions with manual pagination control (paginated version).
468
+
469
+ **Parameters:**
470
+ ```typescript
471
+ ownerAddress: string; // Wallet address
472
+ limit?: number; // Results per page (default: 10, max: 20)
473
+ bookmark?: string; // Pagination bookmark from previous response
474
+ ```
475
+
476
+ **Returns:** Same array structure as getAllSwapUserLiquidityPositions, plus pagination metadata:
477
+ ```typescript
478
+ {
479
+ positions: Array<...>; // Array of position objects
480
+ bookmark?: string; // Bookmark for next page (if more results exist)
481
+ hasMore: boolean; // True if more pages available
482
+ total: number; // Total positions
483
+ }
484
+ ```
485
+
486
+ **Example:**
487
+ ```typescript
488
+ // Paginated retrieval for streaming/processing
489
+ let allPositions = [];
490
+ let bookmark;
491
+ let hasMore = true;
492
+
493
+ while (hasMore) {
494
+ const page = await sdk.getSwapUserLiquidityPositions('eth|0x...', 10, bookmark);
495
+ allPositions = allPositions.concat(page.positions);
496
+ hasMore = !!page.bookmark;
497
+ bookmark = page.bookmark;
498
+ console.log(`Fetched page: ${page.positions.length} positions`);
499
+ }
500
+
501
+ console.log(`Total fetched: ${allPositions.length}`);
502
+ ```
503
+
504
+ ### `getSwapLiquidityPositionById(ownerAddress, positionId)`
505
+
506
+ Get a specific liquidity position by its ID.
507
+
508
+ **Parameters:**
509
+ ```typescript
510
+ ownerAddress: string; // Wallet address
511
+ positionId: string; // Position UUID
512
+ ```
513
+
514
+ **Returns:** Single position object (same structure as above)
515
+
516
+ **Example:**
517
+ ```typescript
518
+ const position = await sdk.getSwapLiquidityPositionById('eth|0x...', 'position-uuid');
519
+
520
+ console.log(`Position: ${position.token0}/${position.token1}`);
521
+ console.log(`Liquidity: ${position.liquidity}`);
522
+ console.log(`Accumulated fees: ${position.feeAmount0} + ${position.feeAmount1}`);
523
+ ```
524
+
525
+ ### `getSwapLiquidityPosition(ownerAddress, token0, token1, fee, tickLower, tickUpper)`
526
+
527
+ Get a liquidity position by token pair and price range.
528
+
529
+ **Parameters:**
530
+ ```typescript
531
+ ownerAddress: string; // Wallet address
532
+ token0: string; // First token
533
+ token1: string; // Second token
534
+ fee: number; // Fee tier (500, 3000, or 10000)
535
+ tickLower: number; // Lower tick boundary
536
+ tickUpper: number; // Upper tick boundary
537
+ ```
538
+
539
+ **Returns:** Single position object
540
+
541
+ **Example:**
542
+ ```typescript
543
+ const position = await sdk.getSwapLiquidityPosition(
544
+ 'eth|0x...',
545
+ 'GALA',
546
+ 'GUSDC',
547
+ 3000,
548
+ -1000,
549
+ 1000
550
+ );
551
+
552
+ console.log(`Active: ${position.liquidity > 0}`);
553
+ ```
554
+
555
+ ### `getSwapEstimateRemoveLiquidity(token0, token1, fee, liquidity, tickLower, tickUpper)`
556
+
557
+ Estimate tokens and fees you'll receive when removing liquidity.
558
+
559
+ **Parameters:**
560
+ ```typescript
561
+ token0: string; // First token
562
+ token1: string; // Second token
563
+ fee: number; // Fee tier
564
+ liquidity: string; // Liquidity amount to remove
565
+ tickLower: number; // Lower tick
566
+ tickUpper: number; // Upper tick
567
+ ```
568
+
569
+ **Returns:**
570
+ ```typescript
571
+ {
572
+ amount0: string; // Token0 amount to receive
573
+ amount1: string; // Token1 amount to receive
574
+ fee0: string; // Collected fees (Token0)
575
+ fee1: string; // Collected fees (Token1)
576
+ feeAmount0: string; // Same as fee0
577
+ feeAmount1: string; // Same as fee1
578
+ token0Symbol: string; // Token0 symbol
579
+ token1Symbol: string; // Token1 symbol
580
+ }
581
+ ```
582
+
583
+ **Example:**
584
+ ```typescript
585
+ // Preview removal before executing
586
+ const estimate = await sdk.getSwapEstimateRemoveLiquidity(
587
+ 'GALA',
588
+ 'GUSDC',
589
+ 3000,
590
+ position.liquidity,
591
+ position.tickLower,
592
+ position.tickUpper
593
+ );
594
+
595
+ console.log(`Will receive: ${estimate.amount0} GALA, ${estimate.amount1} GUSDC`);
596
+ console.log(`Collected fees: ${estimate.feeAmount0} GALA, ${estimate.feeAmount1} GUSDC`);
597
+ ```
598
+
599
+ ### `addSwapLiquidityByPrice(token0, token1, fee, minPrice, maxPrice, amount0Desired, amount1Desired, amount0Min?, amount1Min?)`
600
+
601
+ Add liquidity by specifying a price range (user-friendly approach).
602
+
603
+ **Parameters:**
604
+ ```typescript
605
+ token0: string; // First token
606
+ token1: string; // Second token
607
+ fee: number; // Fee tier (500, 3000, or 10000)
608
+ minPrice: string; // Minimum price (e.g., "0.95")
609
+ maxPrice: string; // Maximum price (e.g., "1.05")
610
+ amount0Desired: string; // Desired Token0 amount to provide
611
+ amount1Desired: string; // Desired Token1 amount to provide
612
+ amount0Min?: string; // Minimum Token0 (slippage protection, default: "0")
613
+ amount1Min?: string; // Minimum Token1 (slippage protection, default: "0")
614
+ ```
615
+
616
+ **Returns:**
617
+ ```typescript
618
+ {
619
+ transactionId: string;
620
+ status: 'PENDING' | 'COMPLETED' | 'FAILED';
621
+ positionId: string; // New position ID
622
+ liquidity: string; // Liquidity amount provided
623
+ amount0Used: string; // Actual Token0 used
624
+ amount1Used: string; // Actual Token1 used
625
+ wait(): Promise<TransactionResult>;
626
+ }
627
+ ```
628
+
629
+ **Example:**
630
+ ```typescript
631
+ // Create position with 0.95-1.05 price range
632
+ const result = await sdk.addSwapLiquidityByPrice({
633
+ token0: 'GALA',
634
+ token1: 'GUSDC',
635
+ fee: 3000, // 0.30% fee tier
636
+ minPrice: '0.95', // Active when price between 0.95-1.05
637
+ maxPrice: '1.05',
638
+ amount0Desired: '100', // Provide 100 GALA
639
+ amount1Desired: '100', // Provide 100 GUSDC
640
+ amount0Min: '95', // Accept at least 95 GALA
641
+ amount1Min: '95' // Accept at least 95 GUSDC
642
+ });
643
+
644
+ console.log(`Position created: ${result.positionId}`);
645
+ console.log(`Liquidity provided: ${result.liquidity}`);
646
+
647
+ // Wait for confirmation
648
+ await result.wait();
649
+ ```
650
+
651
+ ### `addSwapLiquidityByTicks(token0, token1, feeTier, tickLower, tickUpper, amount0Desired, amount1Desired, amount0Min?, amount1Min?)`
652
+
653
+ Add liquidity by specifying exact tick boundaries (advanced users).
654
+
655
+ **Parameters:**
656
+ ```typescript
657
+ token0: string; // First token
658
+ token1: string; // Second token
659
+ feeTier: number; // Fee tier (500, 3000, or 10000)
660
+ tickLower: number; // Lower tick (must align with tickSpacing)
661
+ tickUpper: number; // Upper tick (must align with tickSpacing)
662
+ amount0Desired: string; // Desired Token0 amount
663
+ amount1Desired: string; // Desired Token1 amount
664
+ amount0Min?: string; // Minimum Token0 (default: "0")
665
+ amount1Min?: string; // Minimum Token1 (default: "0")
666
+ ```
667
+
668
+ **Returns:** Same as addSwapLiquidityByPrice
669
+
670
+ **Example:**
671
+ ```typescript
672
+ // Create position with exact tick boundaries (advanced)
673
+ // Note: ticks must be multiples of tickSpacing (varies by fee tier)
674
+ const result = await sdk.addSwapLiquidityByTicks({
675
+ token0: 'GALA',
676
+ token1: 'GUSDC',
677
+ feeTier: 3000,
678
+ tickLower: -1000, // Exact tick
679
+ tickUpper: 1000, // Exact tick
680
+ amount0Desired: '100',
681
+ amount1Desired: '100'
682
+ });
683
+
684
+ console.log(`Position ID: ${result.positionId}`);
685
+ ```
686
+
687
+ ### `removeSwapLiquidity(ownerAddress, positionId, liquidity, amount0Min, amount1Min, deadline?)`
688
+
689
+ Remove liquidity from a position and withdraw underlying tokens.
690
+
691
+ **Parameters:**
692
+ ```typescript
693
+ ownerAddress: string; // Wallet address
694
+ positionId: string; // Position ID to remove from
695
+ liquidity: string; // Liquidity amount to remove (use full amount to close)
696
+ amount0Min: string; // Minimum Token0 to receive (slippage protection)
697
+ amount1Min: string; // Minimum Token1 to receive (slippage protection)
698
+ deadline?: number; // Deadline timestamp (unix seconds, optional)
699
+ ```
700
+
701
+ **Returns:**
702
+ ```typescript
703
+ {
704
+ transactionId: string;
705
+ status: 'PENDING' | 'COMPLETED' | 'FAILED';
706
+ amount0Withdrawn: string; // Token0 received
707
+ amount1Withdrawn: string; // Token1 received
708
+ fee0Collected: string; // Fees collected (Token0)
709
+ fee1Collected: string; // Fees collected (Token1)
710
+ wait(): Promise<TransactionResult>;
711
+ }
712
+ ```
713
+
714
+ **Example:**
715
+ ```typescript
716
+ // Preview removal before executing
717
+ const estimate = await sdk.getSwapEstimateRemoveLiquidity(
718
+ position.token0,
719
+ position.token1,
720
+ position.feeTier,
721
+ position.liquidity,
722
+ position.tickLower,
723
+ position.tickUpper
724
+ );
725
+
726
+ // Remove full liquidity and close position
727
+ const result = await sdk.removeSwapLiquidity({
728
+ ownerAddress: 'eth|0x...',
729
+ positionId: position.positionId,
730
+ liquidity: position.liquidity,
731
+ amount0Min: estimate.amount0, // Use estimate values
732
+ amount1Min: estimate.amount1,
733
+ deadline: Math.floor(Date.now() / 1000) + 3600 // 1 hour from now
734
+ });
735
+
736
+ console.log(`Withdrawn: ${result.amount0Withdrawn} + ${result.amount1Withdrawn}`);
737
+ console.log(`Fees collected: ${result.fee0Collected} + ${result.fee1Collected}`);
738
+ ```
739
+
740
+ ### `collectSwapPositionFees(ownerAddress, positionId, amount0Max?, amount1Max?)`
741
+
742
+ Collect accumulated trading fees without closing the position.
743
+
744
+ **Parameters:**
745
+ ```typescript
746
+ ownerAddress: string; // Wallet address
747
+ positionId: string; // Position ID
748
+ amount0Max?: string; // Maximum Token0 fees (optional)
749
+ amount1Max?: string; // Maximum Token1 fees (optional)
750
+ ```
751
+
752
+ **Returns:**
753
+ ```typescript
754
+ {
755
+ transactionId: string;
756
+ status: 'PENDING' | 'COMPLETED' | 'FAILED';
757
+ amount0Collected: string; // Token0 fees collected
758
+ amount1Collected: string; // Token1 fees collected
759
+ wait(): Promise<TransactionResult>;
760
+ }
761
+ ```
762
+
763
+ **Example:**
764
+ ```typescript
765
+ // Collect fees periodically without removing liquidity
766
+ const result = await sdk.collectSwapPositionFees({
767
+ ownerAddress: 'eth|0x...',
768
+ positionId: position.positionId
769
+ });
770
+
771
+ console.log(`Collected: ${result.amount0Collected} + ${result.amount1Collected}`);
772
+
773
+ // Position remains active and continues earning fees
774
+ ```
775
+
776
+ ### Complete Liquidity Management Workflow
777
+
778
+ ```typescript
779
+ // 1. View all positions
780
+ const positions = await sdk.getAllSwapUserLiquidityPositions('eth|0x...');
781
+ console.log(`You have ${positions.length} active positions`);
782
+
783
+ // 2. Create new position
784
+ const newPos = await sdk.addSwapLiquidityByPrice({
785
+ token0: 'GALA',
786
+ token1: 'GUSDC',
787
+ fee: 3000,
788
+ minPrice: '0.95',
789
+ maxPrice: '1.05',
790
+ amount0Desired: '1000',
791
+ amount1Desired: '1000'
792
+ });
793
+
794
+ await newPos.wait();
795
+ console.log(`Position created: ${newPos.positionId}`);
796
+
797
+ // 3. Monitor fees (periodically)
798
+ setTimeout(async () => {
799
+ const position = await sdk.getSwapLiquidityPositionById('eth|0x...', newPos.positionId);
800
+ console.log(`Fees earned: ${position.feeAmount0} + ${position.feeAmount1}`);
801
+ }, 3600000); // Every hour
802
+
803
+ // 4. Collect fees when ready
804
+ const fees = await sdk.collectSwapPositionFees({
805
+ ownerAddress: 'eth|0x...',
806
+ positionId: newPos.positionId
807
+ });
808
+
809
+ console.log(`Harvested: ${fees.amount0Collected} + ${fees.amount1Collected}`);
810
+
811
+ // 5. Close position when desired
812
+ const removed = await sdk.removeSwapLiquidity({
813
+ ownerAddress: 'eth|0x...',
814
+ positionId: newPos.positionId,
815
+ liquidity: newPos.liquidity,
816
+ amount0Min: '0',
817
+ amount1Min: '0'
818
+ });
819
+
820
+ console.log(`Closed position, received: ${removed.amount0Withdrawn} + ${removed.amount1Withdrawn}`);
821
+ ```
822
+
823
+ ---
824
+
409
825
  ## Pool Information
410
826
 
411
827
  ### `fetchPoolDetails(tokenName)`
@@ -548,6 +964,81 @@ symbol: string; // 1-8 uppercase characters
548
964
  }
549
965
  ```
550
966
 
967
+ ### `fetchTokenClassesWithSupply(tokenClasses)`
968
+
969
+ Fetch authoritative supply information for one or more token classes from GalaChain.
970
+
971
+ Queries the GalaChain network for definitive token supply data including total supply, maximum supply, burned amounts, and mint-related metrics. This method provides blockchain-verified token information.
972
+
973
+ **Parameters:**
974
+ ```typescript
975
+ tokenClasses: TokenClassKey[]; // Array of token class identifiers
976
+ ```
977
+
978
+ **Returns:**
979
+ ```typescript
980
+ Promise<Array<{
981
+ // Token Identification
982
+ collection: string; // Token collection (e.g., 'Token')
983
+ category: string; // Token category (e.g., 'Unit')
984
+ type: string; // Token type (e.g., 'GALA', 'GUSDC')
985
+ additionalKey: string; // Additional key/network (e.g., 'eth:0x...', 'none')
986
+
987
+ // Token Metadata
988
+ symbol: string; // Token symbol
989
+ name: string; // Token display name
990
+ decimals: number; // Decimal precision
991
+
992
+ // Supply Information
993
+ totalSupply: string; // Current total supply in circulation
994
+ maxSupply: string; // Maximum possible supply
995
+ totalBurned: string; // Total amount burned
996
+ knownMintSupply: string; // Known mint supply
997
+ knownMintAllowanceSupply: string; // Known mint allowance
998
+ }>>
999
+ ```
1000
+
1001
+ **Example:**
1002
+ ```typescript
1003
+ // Query single token
1004
+ const supplies = await sdk.fetchTokenClassesWithSupply([
1005
+ {
1006
+ collection: 'Token',
1007
+ category: 'Unit',
1008
+ type: 'GALA',
1009
+ additionalKey: 'none'
1010
+ }
1011
+ ]);
1012
+
1013
+ console.log(`GALA Total Supply: ${supplies[0].totalSupply}`);
1014
+ console.log(`GALA Max Supply: ${supplies[0].maxSupply}`);
1015
+ console.log(`GALA Burned: ${supplies[0].totalBurned}`);
1016
+
1017
+ // Query multiple tokens in one call
1018
+ const multiSupplies = await sdk.fetchTokenClassesWithSupply([
1019
+ { collection: 'Token', category: 'Unit', type: 'GALA', additionalKey: 'none' },
1020
+ { collection: 'Token', category: 'Unit', type: 'GUSDC', additionalKey: 'eth:0x...' }
1021
+ ]);
1022
+
1023
+ // Analyze supply metrics
1024
+ for (const token of multiSupplies) {
1025
+ const circulationPercent = (parseFloat(token.totalSupply) / parseFloat(token.maxSupply)) * 100;
1026
+ const burnPercent = (parseFloat(token.totalBurned) / parseFloat(token.totalSupply)) * 100;
1027
+
1028
+ console.log(`${token.symbol}:`);
1029
+ console.log(` Circulation: ${circulationPercent.toFixed(2)}% of max`);
1030
+ console.log(` Burned: ${burnPercent.toFixed(2)}% of total`);
1031
+ }
1032
+ ```
1033
+
1034
+ **Use Cases:**
1035
+ - Token supply tracking and dashboards
1036
+ - Burn rate analysis and monitoring
1037
+ - Mint allowance verification
1038
+ - Token health metrics and reporting
1039
+ - Supply distribution analysis
1040
+ - Compliance and audit reporting
1041
+
551
1042
  ---
552
1043
 
553
1044
  ## Portfolio & Balances
@@ -877,6 +1368,35 @@ interface TokenClassKey {
877
1368
  }
878
1369
  ```
879
1370
 
1371
+ ### TokenClassWithSupply
1372
+ ```typescript
1373
+ interface TokenClassWithSupply {
1374
+ // Token Identification
1375
+ collection: string; // Token collection (e.g., "Token")
1376
+ category: string; // Token category (e.g., "Unit")
1377
+ type: string; // Token type (e.g., "GALA", "GUSDC")
1378
+ additionalKey: string; // Network/chain info (e.g., "eth:0x...", "none")
1379
+
1380
+ // Token Metadata
1381
+ symbol: string; // Token symbol
1382
+ name: string; // Token display name
1383
+ decimals: number; // Decimal precision
1384
+
1385
+ // Supply Information
1386
+ totalSupply: string; // Current total supply in circulation
1387
+ maxSupply: string; // Maximum possible supply
1388
+ totalBurned: string; // Total amount burned
1389
+ knownMintSupply: string; // Known mint supply
1390
+ knownMintAllowanceSupply: string; // Known mint allowance supply
1391
+
1392
+ // Optional Fields
1393
+ authorities?: Array<{ // Optional token authorities
1394
+ address?: string; // Authority address
1395
+ role?: string; // Authority role/type
1396
+ }>;
1397
+ }
1398
+ ```
1399
+
880
1400
  ### TransactionResult
881
1401
  ```typescript
882
1402
  interface TransactionResult {
package/CHANGELOG.md CHANGED
@@ -1,5 +1,97 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.0
4
+
5
+ ### BREAKING CHANGES
6
+
7
+ - **`fetchLaunchpadTokenSpotPrice()` method REMOVED**
8
+ - **Deprecated**: v3.22.7
9
+ - **Removed**: v4.0.0
10
+ - **Replacement**: `fetchTokenPrice()` with smart routing (v3.22.7+)
11
+ - **Why**: Unified pricing interface for both launchpad and DEX tokens. Single method handles all price queries with automatic routing.
12
+ - **Impact**: Direct replacement required in all code using this method
13
+
14
+ **Migration Path:**
15
+ ```typescript
16
+ // ❌ REMOVED in v4.0.0 - NO LONGER WORKS
17
+ const price = await sdk.fetchLaunchpadTokenSpotPrice('anime');
18
+
19
+ // ✅ USE INSTEAD (v4.0.0+)
20
+ const price = await sdk.fetchTokenPrice({ tokenName: 'anime' });
21
+
22
+ // Also supports tokenId format for DEX tokens
23
+ const priceById = await sdk.fetchTokenPrice({
24
+ tokenId: 'Token|Unit|GALA|none'
25
+ });
26
+ ```
27
+
28
+ ### New Features
29
+
30
+ - **New Service Clients** - Low-level HTTP clients for direct blockchain interactions:
31
+ - `DexBackendClient` - Direct access to DEX Backend API for advanced swap operations and pool queries
32
+ - `GalaChainGatewayClient` - Direct access to GalaChain Gateway for token operations and DEX contract calls
33
+ - **Note**: These are internal clients used by higher-level SDK methods. Standard SDK methods continue to work without changes.
34
+
35
+ ### Deprecation Status
36
+
37
+ - ✅ **Token format parsing** (v3.33.0 enforced) - Continues to enforce delimited formats only (`'GALA|Unit|none|none'`)
38
+ - ✅ **`parseToken()` signature** (v3.33.0 enforced) - Continues strict validation
39
+
40
+ ### Migration Checklist
41
+
42
+ - [ ] Replace `fetchLaunchpadTokenSpotPrice()` calls with `fetchTokenPrice()`
43
+ - [ ] Test price queries for both launchpad and DEX tokens
44
+ - [ ] Verify all trading operations use delimited token format
45
+ - [ ] Run full test suite against v4.0.0
46
+
47
+ ### Expected Impact
48
+
49
+ - **For launchpad tokens**: No functional change, just method name
50
+ - **For DEX tokens**: New method works with all token types (previously would fail)
51
+ - **Bundle size**: No change (both methods were similar complexity)
52
+ - **Migration time**: Low (single method replacement across codebase)
53
+
54
+ ---
55
+
56
+ ## 3.33.0
57
+
58
+ ### BREAKING CHANGES
59
+
60
+ - **Token format parsing now ONLY accepts delimited formats (pipe or dollar-delimited)**
61
+ - **Before (v3.32.x)**: Plain token strings like `'GALA'` and `'GUSDC'` were accepted and converted to delimited format
62
+ - **After (v3.33.0)**: All tokens MUST be in delimited format: `'GALA|Unit|none|none'` or `'GALA$Unit$none$none'`
63
+ - **Why**: Removed dangerous "escape hatch" that allowed ambiguous token identifiers. Enforces strict security-by-design.
64
+ - **Affected Methods**: `getSwapQuoteExactInput()`, `getSwapQuoteExactOutput()`, `executeSwap()`, `addSwapLiquidityByPrice()`, `addSwapLiquidityByTicks()`, `removeSwapLiquidity()`, `getSwapPoolInfo()`
65
+
66
+ **Migration Path:**
67
+ ```typescript
68
+ // ❌ NO LONGER WORKS (v3.33.0+)
69
+ await sdk.executeSwap('GALA', 'GUSDC', '100', ...);
70
+
71
+ // ✅ REQUIRED FORMAT (v3.33.0+)
72
+ await sdk.executeSwap('GALA|Unit|none|none', 'GUSDC|Unit|none|none', '100', ...);
73
+ ```
74
+
75
+ - **`parseToken()` function signature changed**
76
+ - **Before**: `parseToken(token: string | TokenClassKey, allowPlainStrings: boolean = false)`
77
+ - **After**: `parseToken(token: string | TokenClassKey)`
78
+ - **Why**: The `allowPlainStrings` parameter created a security escape hatch. Removed entirely.
79
+ - **Migration**: Always provide delimited token format
80
+
81
+ ### Security Enhancements
82
+
83
+ - ✅ **Strict token format enforcement** prevents injection attacks via token string manipulation
84
+ - ✅ **Eliminated ambiguous parsing** - no more fallback to plain string conversion
85
+ - ✅ **Deterministic security** - no escapehatches or opt-in flags that weaken validation
86
+ - ✅ **Explicit token specification** - users must provide full TokenClassKey structure via delimiters
87
+
88
+ ### Documentation Updates
89
+
90
+ - Added comprehensive [Token Format Migration guide](./README.md#token-format-migration-v330) to README
91
+ - Updated all DEX trading examples to use delimited token format
92
+ - Added breaking change notices to API.md and EXAMPLES.md
93
+ - Updated JSDoc comments in token-parser.ts with v3.33.0 enforcement notes
94
+
3
95
  ## 3.29.0
4
96
 
5
97
  ### BREAKING CHANGES