@gala-chain/launchpad-mcp-server 1.23.0 → 1.24.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 (102) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/DRY_REFACTORING_GUIDE.md +272 -0
  3. package/README.md +34 -6
  4. package/dist/constants/mcpToolNames.d.ts +6 -2
  5. package/dist/constants/mcpToolNames.d.ts.map +1 -1
  6. package/dist/constants/mcpToolNames.js +4 -2
  7. package/dist/constants/mcpToolNames.js.map +1 -1
  8. package/dist/generated/version.d.ts +1 -1
  9. package/dist/generated/version.js +1 -1
  10. package/dist/prompts/analysis.d.ts.map +1 -1
  11. package/dist/prompts/analysis.js +14 -63
  12. package/dist/prompts/analysis.js.map +1 -1
  13. package/dist/prompts/balances.d.ts.map +1 -1
  14. package/dist/prompts/balances.js +46 -70
  15. package/dist/prompts/balances.js.map +1 -1
  16. package/dist/prompts/creation-utils.d.ts.map +1 -1
  17. package/dist/prompts/creation-utils.js +27 -50
  18. package/dist/prompts/creation-utils.js.map +1 -1
  19. package/dist/prompts/explore-dex-pools.d.ts +20 -0
  20. package/dist/prompts/explore-dex-pools.d.ts.map +1 -0
  21. package/dist/prompts/explore-dex-pools.js +132 -0
  22. package/dist/prompts/explore-dex-pools.js.map +1 -0
  23. package/dist/prompts/index.d.ts +3 -2
  24. package/dist/prompts/index.d.ts.map +1 -1
  25. package/dist/prompts/index.js +6 -3
  26. package/dist/prompts/index.js.map +1 -1
  27. package/dist/prompts/liquidity-positions.d.ts.map +1 -1
  28. package/dist/prompts/liquidity-positions.js +9 -44
  29. package/dist/prompts/liquidity-positions.js.map +1 -1
  30. package/dist/prompts/pools.d.ts.map +1 -1
  31. package/dist/prompts/pools.js +125 -228
  32. package/dist/prompts/pools.js.map +1 -1
  33. package/dist/prompts/portfolio.d.ts.map +1 -1
  34. package/dist/prompts/portfolio.js +13 -48
  35. package/dist/prompts/portfolio.js.map +1 -1
  36. package/dist/prompts/social.d.ts.map +1 -1
  37. package/dist/prompts/social.js +21 -31
  38. package/dist/prompts/social.js.map +1 -1
  39. package/dist/prompts/trading-calculations.d.ts.map +1 -1
  40. package/dist/prompts/trading-calculations.js +37 -126
  41. package/dist/prompts/trading-calculations.js.map +1 -1
  42. package/dist/prompts/trading.d.ts.map +1 -1
  43. package/dist/prompts/trading.js +23 -60
  44. package/dist/prompts/trading.js.map +1 -1
  45. package/dist/prompts/transfers.d.ts.map +1 -1
  46. package/dist/prompts/transfers.js +21 -31
  47. package/dist/prompts/transfers.js.map +1 -1
  48. package/dist/prompts/utility-tools.d.ts.map +1 -1
  49. package/dist/prompts/utility-tools.js +83 -202
  50. package/dist/prompts/utility-tools.js.map +1 -1
  51. package/dist/prompts/utility.d.ts.map +1 -1
  52. package/dist/prompts/utility.js +5 -20
  53. package/dist/prompts/utility.js.map +1 -1
  54. package/dist/prompts/utils/handlerHelpers.d.ts +35 -0
  55. package/dist/prompts/utils/handlerHelpers.d.ts.map +1 -0
  56. package/dist/prompts/utils/handlerHelpers.js +53 -0
  57. package/dist/prompts/utils/handlerHelpers.js.map +1 -0
  58. package/dist/prompts/utils/textTemplates.d.ts +42 -0
  59. package/dist/prompts/utils/textTemplates.d.ts.map +1 -0
  60. package/dist/prompts/utils/textTemplates.js +51 -0
  61. package/dist/prompts/utils/textTemplates.js.map +1 -0
  62. package/dist/tools/dex/fetchAllDexPools.d.ts +9 -0
  63. package/dist/tools/dex/fetchAllDexPools.d.ts.map +1 -0
  64. package/dist/tools/dex/fetchAllDexPools.js +45 -0
  65. package/dist/tools/dex/fetchAllDexPools.js.map +1 -0
  66. package/dist/tools/dex/fetchDexPools.d.ts +9 -0
  67. package/dist/tools/dex/fetchDexPools.d.ts.map +1 -0
  68. package/dist/tools/dex/fetchDexPools.js +58 -0
  69. package/dist/tools/dex/fetchDexPools.js.map +1 -0
  70. package/dist/tools/dex/index.d.ts +4 -3
  71. package/dist/tools/dex/index.d.ts.map +1 -1
  72. package/dist/tools/dex/index.js +9 -4
  73. package/dist/tools/dex/index.js.map +1 -1
  74. package/dist/utils/validation.d.ts +38 -0
  75. package/dist/utils/validation.d.ts.map +1 -1
  76. package/dist/utils/validation.js +52 -0
  77. package/dist/utils/validation.js.map +1 -1
  78. package/package.json +3 -3
  79. package/src/__tests__/server.test.ts +1 -2
  80. package/src/constants/mcpToolNames.ts +4 -2
  81. package/src/prompts/__tests__/promptStructure.test.ts +50 -0
  82. package/src/prompts/__tests__/registry.test.ts +23 -33
  83. package/src/prompts/analysis.ts +15 -64
  84. package/src/prompts/balances.ts +57 -73
  85. package/src/prompts/creation-utils.ts +34 -49
  86. package/src/prompts/explore-dex-pools.ts +138 -0
  87. package/src/prompts/index.ts +5 -2
  88. package/src/prompts/liquidity-positions.ts +11 -44
  89. package/src/prompts/pools.ts +156 -231
  90. package/src/prompts/portfolio.ts +13 -47
  91. package/src/prompts/social.ts +25 -31
  92. package/src/prompts/trading-calculations.ts +42 -127
  93. package/src/prompts/trading.ts +30 -61
  94. package/src/prompts/transfers.ts +25 -31
  95. package/src/prompts/utility-tools.ts +116 -199
  96. package/src/prompts/utility.ts +5 -20
  97. package/src/prompts/utils/handlerHelpers.ts +55 -0
  98. package/src/prompts/utils/textTemplates.ts +73 -0
  99. package/src/tools/dex/fetchAllDexPools.ts +45 -0
  100. package/src/tools/dex/fetchDexPools.ts +58 -0
  101. package/src/tools/dex/index.ts +9 -4
  102. package/src/utils/validation.ts +58 -0
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Fetch DEX Pools Tool
3
+ *
4
+ * Queries the GalaSwap DEX backend for available liquidity pools with pagination,
5
+ * sorting, and search filtering capabilities.
6
+ */
7
+
8
+ import type { MCPTool } from '../../types/mcp.js';
9
+ import { formatSuccess } from '../../utils/response-formatter.js';
10
+ import { withErrorHandling } from '../../utils/error-handler.js';
11
+
12
+ export const fetchDexPoolsTool: MCPTool = {
13
+ name: 'gala_launchpad_fetch_dex_pools',
14
+ description: 'Fetch DEX pools with pagination and filtering - query available liquidity pools on GalaSwap',
15
+ inputSchema: {
16
+ type: 'object',
17
+ properties: {
18
+ search: {
19
+ type: 'string',
20
+ minLength: 1,
21
+ maxLength: 100,
22
+ description: 'Search filter for token symbols in pool pair (e.g., "GALA", "GUSDC", "GALA/GUSDC")',
23
+ },
24
+ sortBy: {
25
+ type: 'string',
26
+ enum: ['tvl', 'volume30d', 'volume1d'],
27
+ description: 'Field to sort results by (default: tvl)',
28
+ },
29
+ sortOrder: {
30
+ type: 'string',
31
+ enum: ['asc', 'desc'],
32
+ description: 'Sort order direction (default: desc)',
33
+ },
34
+ page: {
35
+ type: 'number',
36
+ minimum: 1,
37
+ description: 'Page number (1-based pagination, default: 1)',
38
+ },
39
+ limit: {
40
+ type: 'number',
41
+ minimum: 1,
42
+ maximum: 20,
43
+ description: 'Number of results per page (default: 10, maximum: 20)',
44
+ },
45
+ },
46
+ },
47
+ handler: withErrorHandling(async (sdk, args) => {
48
+ const result = await sdk.fetchDexPools({
49
+ search: args.search,
50
+ sortBy: args.sortBy || 'tvl',
51
+ sortOrder: args.sortOrder || 'desc',
52
+ page: args.page || 1,
53
+ limit: args.limit || 10,
54
+ });
55
+
56
+ return formatSuccess(result);
57
+ }),
58
+ };
@@ -1,12 +1,15 @@
1
1
  /**
2
- * DEX/GalaSwap Trading Operations Tools
2
+ * DEX/GalaSwap Trading Operations Tools & Pool Discovery
3
3
  *
4
- * Tools for trading on GalaSwap DEX after tokens graduate from bonding curves.
5
- * These tools provide quote generation, swap execution, liquidity management, and asset management.
4
+ * Tools for trading on GalaSwap DEX after tokens graduate from bonding curves,
5
+ * discovering liquidity pools, and managing positions.
6
+ * Provides quote generation, swap execution, liquidity management, asset management, and pool exploration.
6
7
  */
7
8
 
8
9
  import type { MCPTool } from '../../types/mcp.js';
9
10
  import { liquidityPositionTools } from './liquidity-positions.js';
11
+ import { fetchDexPoolsTool } from './fetchDexPools.js';
12
+ import { fetchAllDexPoolsTool } from './fetchAllDexPools.js';
10
13
  import { formatSuccess } from '../../utils/response-formatter.js';
11
14
  import { withErrorHandling } from '../../utils/error-handler.js';
12
15
  import {
@@ -215,8 +218,10 @@ export const getSwapPoolInfoTool: MCPTool = {
215
218
  }),
216
219
  };
217
220
 
218
- // Export all DEX tools (5 swap tools + 8 liquidity position tools = 13 tools)
221
+ // Export all DEX tools (2 pool discovery + 5 swap tools + 8 liquidity position tools = 15 tools)
219
222
  export const dexTools: MCPTool[] = [
223
+ fetchDexPoolsTool,
224
+ fetchAllDexPoolsTool,
220
225
  getSwapQuoteExactInputTool,
221
226
  getSwapQuoteExactOutputTool,
222
227
  executeSwapTool,
@@ -369,3 +369,61 @@ export function safeValidate(
369
369
  return { success: false, error: String(error) };
370
370
  }
371
371
  }
372
+
373
+ /**
374
+ * Validate optional field if present
375
+ *
376
+ * Convenience wrapper for validating optional fields. Only runs validation
377
+ * if the value is defined and not null.
378
+ *
379
+ * @param value - Value to validate (can be undefined)
380
+ * @param validator - Validation function to run if value is present
381
+ * @throws {ValidationError} If validation fails
382
+ *
383
+ * @example
384
+ * ```typescript
385
+ * validateOptional(args.slippage, (val) => validateSlippage(val));
386
+ * ```
387
+ */
388
+ export function validateOptional<T>(
389
+ value: T | undefined | null,
390
+ validator: (val: T) => void
391
+ ): void {
392
+ if (value !== undefined && value !== null && value !== '') {
393
+ validator(value as T);
394
+ }
395
+ }
396
+
397
+ /**
398
+ * Validate optional slippage field
399
+ *
400
+ * @param slippage - Slippage value to validate (optional)
401
+ * @throws {ValidationError} If slippage is invalid
402
+ */
403
+ export function validateOptionalSlippage(slippage?: string | number): void {
404
+ validateOptional(slippage, (val) => validateSlippage(val));
405
+ }
406
+
407
+ /**
408
+ * Validate optional pagination limit field
409
+ *
410
+ * @param limit - Limit value to validate (optional)
411
+ * @param max - Maximum allowed limit (default: 100)
412
+ * @throws {ValidationError} If limit is invalid
413
+ */
414
+ export function validateOptionalLimit(
415
+ limit?: string | number,
416
+ max: number = 100
417
+ ): void {
418
+ validateOptional(limit, (val) => validatePaginationLimit(val, max));
419
+ }
420
+
421
+ /**
422
+ * Validate optional address field
423
+ *
424
+ * @param address - Address value to validate (optional)
425
+ * @throws {ValidationError} If address is invalid
426
+ */
427
+ export function validateOptionalAddress(address?: string): void {
428
+ validateOptional(address, (val) => validateAddress(val));
429
+ }