@gala-chain/launchpad-mcp-server 1.21.6 → 1.22.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 (73) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/dist/generated/version.d.ts +1 -1
  3. package/dist/generated/version.js +1 -1
  4. package/docs/AI-AGENT-PATTERNS.md +555 -0
  5. package/docs/CONSTRAINTS-REFERENCE.md +454 -0
  6. package/docs/PROMPT-TOOL-MAPPING.md +352 -0
  7. package/docs/examples/default-values-pattern.md +240 -0
  8. package/docs/examples/tool-factory-pattern.md +217 -0
  9. package/jest.config.js +94 -0
  10. package/package.json +2 -2
  11. package/src/__tests__/integration/fetchTokenDetails.integration.test.ts +258 -0
  12. package/src/__tests__/integration/poolTools.integration.test.ts +185 -0
  13. package/src/constants/mcpToolNames.ts +141 -0
  14. package/src/index.ts +19 -0
  15. package/src/prompts/__tests__/promptStructure.test.ts +137 -0
  16. package/src/prompts/__tests__/registry.test.ts +191 -0
  17. package/src/prompts/analysis.ts +429 -0
  18. package/src/prompts/create-token.ts +123 -0
  19. package/src/prompts/dex-trading.ts +86 -0
  20. package/src/prompts/discover-tokens.ts +86 -0
  21. package/src/prompts/index.ts +154 -0
  22. package/src/prompts/liquidity-positions.ts +270 -0
  23. package/src/prompts/portfolio.ts +242 -0
  24. package/src/prompts/trading.ts +191 -0
  25. package/src/prompts/utility.ts +43 -0
  26. package/src/prompts/utils/workflowTemplates.ts +511 -0
  27. package/src/schemas/common-schemas.ts +393 -0
  28. package/src/scripts/test-all-prompts.ts +184 -0
  29. package/src/server.ts +277 -0
  30. package/src/tools/__tests__/dex-tools.test.ts +562 -0
  31. package/src/tools/__tests__/liquidity-positions.test.ts +673 -0
  32. package/src/tools/balance/index.ts +174 -0
  33. package/src/tools/creation/index.ts +182 -0
  34. package/src/tools/dex/index.ts +226 -0
  35. package/src/tools/dex/liquidity-positions.ts +547 -0
  36. package/src/tools/index.ts +86 -0
  37. package/src/tools/pools/fetchAllPools.ts +47 -0
  38. package/src/tools/pools/fetchAllPriceHistory.ts +119 -0
  39. package/src/tools/pools/fetchPoolDetails.ts +27 -0
  40. package/src/tools/pools/fetchPoolDetailsForCalculation.ts +22 -0
  41. package/src/tools/pools/fetchPools.ts +47 -0
  42. package/src/tools/pools/fetchPriceHistory.ts +124 -0
  43. package/src/tools/pools/fetchTokenDetails.ts +77 -0
  44. package/src/tools/pools/index.ts +284 -0
  45. package/src/tools/social/index.ts +64 -0
  46. package/src/tools/trading/index.ts +605 -0
  47. package/src/tools/transfers/index.ts +75 -0
  48. package/src/tools/utils/clearCache.ts +36 -0
  49. package/src/tools/utils/createWallet.ts +19 -0
  50. package/src/tools/utils/explainSdkUsage.ts +1446 -0
  51. package/src/tools/utils/getAddress.ts +12 -0
  52. package/src/tools/utils/getCacheInfo.ts +14 -0
  53. package/src/tools/utils/getConfig.ts +11 -0
  54. package/src/tools/utils/getEthereumAddress.ts +12 -0
  55. package/src/tools/utils/getUrlByTokenName.ts +12 -0
  56. package/src/tools/utils/getVersion.ts +25 -0
  57. package/src/tools/utils/getWallet.ts +25 -0
  58. package/src/tools/utils/hasWallet.ts +15 -0
  59. package/src/tools/utils/index.ts +33 -0
  60. package/src/tools/utils/isTokenGraduated.ts +16 -0
  61. package/src/tools/utils/setWallet.ts +41 -0
  62. package/src/types/mcp.ts +72 -0
  63. package/src/utils/__tests__/validation.test.ts +147 -0
  64. package/src/utils/constraints.ts +155 -0
  65. package/src/utils/default-values.ts +208 -0
  66. package/src/utils/error-handler.ts +69 -0
  67. package/src/utils/error-templates.ts +273 -0
  68. package/src/utils/response-formatter.ts +51 -0
  69. package/src/utils/tool-factory.ts +257 -0
  70. package/src/utils/tool-registry.ts +296 -0
  71. package/src/utils/validation.ts +371 -0
  72. package/tests/wallet-management-integration.test.ts +284 -0
  73. package/tsconfig.json +23 -0
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Token Discovery Prompts
3
+ *
4
+ * Slash commands for discovering and researching tokens on Gala Launchpad
5
+ */
6
+
7
+ import type { MCPPrompt } from '../types/mcp.js';
8
+ import { createDiscoverTokensWorkflow } from './utils/workflowTemplates.js';
9
+ import { validateNumericAmount } from '../utils/validation.js';
10
+
11
+ /**
12
+ * Discover Tokens - Token discovery and exploration workflow
13
+ */
14
+ export const discoverTokensPrompt: MCPPrompt = {
15
+ name: 'galachain-launchpad:discover-tokens',
16
+ description:
17
+ 'Discover new opportunities on Gala Launchpad - find recently launched tokens, popular tokens, or tokens near graduation',
18
+ arguments: [
19
+ {
20
+ name: 'type',
21
+ description:
22
+ 'Type of discovery - "recent" for newly launched tokens (default), "popular" for most traded tokens, or "near-graduation" for tokens close to completing their bonding curve',
23
+ required: false,
24
+ },
25
+ {
26
+ name: 'limit',
27
+ description: 'Number of tokens to show (default: 10, max: 50)',
28
+ required: false,
29
+ },
30
+ {
31
+ name: 'minProgress',
32
+ description:
33
+ 'Minimum graduation progress percentage - only for "near-graduation" type (e.g., "85" for 85%+ progress)',
34
+ required: false,
35
+ },
36
+ {
37
+ name: 'maxPrice',
38
+ description:
39
+ 'Maximum USD price for tokens (e.g., "1.50" to find tokens under $1.50) - useful for finding low-cost tokens to accumulate',
40
+ required: false,
41
+ },
42
+ ],
43
+ handler: (args) => {
44
+ // Parse and validate inputs
45
+ const type = (args.type || 'recent') as 'recent' | 'popular' | 'near-graduation';
46
+ const limit = Math.min(Math.max(1, parseInt(args.limit || '10', 10)), 50);
47
+
48
+ // Validate type
49
+ if (!['recent', 'popular', 'near-graduation'].includes(type)) {
50
+ throw new Error('Type must be "recent", "popular", or "near-graduation"');
51
+ }
52
+
53
+ // Validate minProgress if provided
54
+ if (args.minProgress) {
55
+ const progress = parseInt(args.minProgress, 10);
56
+ if (isNaN(progress) || progress < 0 || progress > 100) {
57
+ throw new Error('minProgress must be a number between 0 and 100');
58
+ }
59
+ }
60
+
61
+ // Validate maxPrice if provided
62
+ if (args.maxPrice) {
63
+ validateNumericAmount(args.maxPrice, 'maxPrice');
64
+ }
65
+
66
+ return [
67
+ {
68
+ role: 'user',
69
+ content: {
70
+ type: 'text',
71
+ text: createDiscoverTokensWorkflow({
72
+ type,
73
+ limit,
74
+ minProgress: args.minProgress,
75
+ maxPrice: args.maxPrice,
76
+ }),
77
+ },
78
+ },
79
+ ];
80
+ },
81
+ };
82
+
83
+ /**
84
+ * Export all discovery prompts
85
+ */
86
+ export const discoveryPrompts: MCPPrompt[] = [discoverTokensPrompt];
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Gala Launchpad MCP Prompts (Slash Commands)
3
+ *
4
+ * Provides user-friendly slash commands for common Launchpad workflows
5
+ */
6
+
7
+ import { tradingPrompts } from './trading.js';
8
+ import { portfolioPrompts } from './portfolio.js';
9
+ import { analysisPrompts } from './analysis.js';
10
+ import { utilityPrompts } from './utility.js';
11
+ import { creationPrompts } from './create-token.js';
12
+ import { discoveryPrompts } from './discover-tokens.js';
13
+ import { dexTradingPrompts } from './dex-trading.js';
14
+ import { liquidityPositionPrompts } from './liquidity-positions.js';
15
+ import type { MCPPrompt } from '../types/mcp.js';
16
+
17
+ /**
18
+ * All available prompts
19
+ */
20
+ export const prompts: MCPPrompt[] = [
21
+ ...tradingPrompts,
22
+ ...portfolioPrompts,
23
+ ...analysisPrompts,
24
+ ...creationPrompts,
25
+ ...discoveryPrompts,
26
+ ...dexTradingPrompts,
27
+ ...liquidityPositionPrompts,
28
+ ...utilityPrompts,
29
+ ];
30
+
31
+ /**
32
+ * Optimized prompt registry using Map for O(1) lookups
33
+ * Improves performance for large prompt collections
34
+ */
35
+ const promptMap = new Map<string, MCPPrompt>(
36
+ prompts.map((prompt) => [prompt.name, prompt])
37
+ );
38
+
39
+ /**
40
+ * Get prompt by name (optimized with Map lookup)
41
+ *
42
+ * @param name - Prompt name (e.g., 'galachain-launchpad:analyze-token')
43
+ * @returns Prompt object or undefined if not found
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const prompt = getPrompt('galachain-launchpad:buy-tokens');
48
+ * if (prompt) {
49
+ * const messages = prompt.handler({ tokenName: 'anime', galaAmount: '100' });
50
+ * }
51
+ * ```
52
+ */
53
+ export function getPrompt(name: string): MCPPrompt | undefined {
54
+ return promptMap.get(name);
55
+ }
56
+
57
+ /**
58
+ * Get all prompt names
59
+ *
60
+ * @returns Array of all registered prompt names
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const names = getPromptNames();
65
+ * // ['galachain-launchpad:analyze-token', 'galachain-launchpad:buy-tokens', ...]
66
+ * ```
67
+ */
68
+ export function getPromptNames(): string[] {
69
+ return Array.from(promptMap.keys());
70
+ }
71
+
72
+ /**
73
+ * Check if a prompt exists by name
74
+ *
75
+ * @param name - Prompt name to check
76
+ * @returns True if prompt exists, false otherwise
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * if (hasPrompt('galachain-launchpad:analyze-token')) {
81
+ * console.log('Prompt is available');
82
+ * }
83
+ * ```
84
+ */
85
+ export function hasPrompt(name: string): boolean {
86
+ return promptMap.has(name);
87
+ }
88
+
89
+ /**
90
+ * Get prompts by category
91
+ *
92
+ * @param category - Category name ('trading', 'portfolio', 'analysis', 'creation', 'discovery', 'dex', or 'utility')
93
+ * @returns Array of prompts in the specified category
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const tradingCommands = getPromptsByCategory('trading');
98
+ * // Returns [analyzeTokenPrompt, buyTokensPrompt, sellTokensPrompt, graduateTokenPrompt]
99
+ * const dexCommands = getPromptsByCategory('dex');
100
+ * // Returns [dexSwapPrompt]
101
+ * ```
102
+ */
103
+ export function getPromptsByCategory(
104
+ category: 'trading' | 'portfolio' | 'analysis' | 'creation' | 'discovery' | 'dex' | 'liquidity' | 'utility'
105
+ ): MCPPrompt[] {
106
+ switch (category) {
107
+ case 'trading':
108
+ return tradingPrompts;
109
+ case 'portfolio':
110
+ return portfolioPrompts;
111
+ case 'analysis':
112
+ return analysisPrompts;
113
+ case 'creation':
114
+ return creationPrompts;
115
+ case 'discovery':
116
+ return discoveryPrompts;
117
+ case 'dex':
118
+ return dexTradingPrompts;
119
+ case 'liquidity':
120
+ return liquidityPositionPrompts;
121
+ case 'utility':
122
+ return utilityPrompts;
123
+ default:
124
+ return [];
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Get prompt count
130
+ *
131
+ * @returns Total number of registered prompts
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * console.log(`Total prompts: ${getPromptCount()}`); // Total prompts: 15
136
+ * ```
137
+ */
138
+ export function getPromptCount(): number {
139
+ return promptMap.size;
140
+ }
141
+
142
+ /**
143
+ * Export individual prompt categories for documentation
144
+ */
145
+ export {
146
+ tradingPrompts,
147
+ portfolioPrompts,
148
+ analysisPrompts,
149
+ creationPrompts,
150
+ discoveryPrompts,
151
+ dexTradingPrompts,
152
+ liquidityPositionPrompts,
153
+ utilityPrompts,
154
+ };
@@ -0,0 +1,270 @@
1
+ /**
2
+ * DEX Liquidity Position Prompts
3
+ *
4
+ * Slash commands for managing liquidity positions on GalaSwap DEX
5
+ */
6
+
7
+ import type { MCPPrompt } from '../types/mcp.js';
8
+ import { validateNumericAmount } from '../utils/validation.js';
9
+
10
+ /**
11
+ * View My Liquidity Positions - List all open LP positions
12
+ *
13
+ * This prompt shows all open liquidity positions for the authenticated wallet.
14
+ */
15
+ export const myPositionsPrompt: MCPPrompt = {
16
+ name: 'galachain-launchpad:my-positions',
17
+ description:
18
+ 'View all your open liquidity positions on GalaSwap DEX with details about each position',
19
+ arguments: [],
20
+ handler: () => {
21
+ return [
22
+ {
23
+ role: 'user',
24
+ content: {
25
+ type: 'text',
26
+ text: `I want to view all my open liquidity positions on GalaSwap DEX.
27
+
28
+ **Action:**
29
+ Show me all my liquidity positions with the following information for each:
30
+ - Position ID
31
+ - Token pair (token0/token1)
32
+ - Fee tier
33
+ - Current liquidity amount
34
+ - Token amounts locked
35
+ - Accumulated trading fees
36
+
37
+ **Workflow:**
38
+ 1. Fetch all my open positions using gala_launchpad_get_user_liquidity_positions
39
+ 2. Display each position with key details
40
+ 3. Show total summary (number of positions, total accumulated fees)
41
+
42
+ Please use the following MCP tools:
43
+ - gala_launchpad_get_user_liquidity_positions: Retrieve all open positions for my wallet
44
+
45
+ Proceed with fetching my positions.`,
46
+ },
47
+ },
48
+ ];
49
+ },
50
+ };
51
+
52
+ /**
53
+ * Add Liquidity - Create new LP position with guided workflow
54
+ *
55
+ * Guides through adding liquidity to a pool with price range selection
56
+ */
57
+ export const addLiquidityPrompt: MCPPrompt = {
58
+ name: 'galachain-launchpad:add-liquidity',
59
+ description:
60
+ 'Add liquidity to a GalaSwap DEX pool. Guides through selecting token pair, price range, and amounts.',
61
+ arguments: [
62
+ {
63
+ name: 'token0',
64
+ description: 'First token symbol (e.g., GALA)',
65
+ required: true,
66
+ },
67
+ {
68
+ name: 'token1',
69
+ description: 'Second token symbol (e.g., GUSDC)',
70
+ required: true,
71
+ },
72
+ {
73
+ name: 'amount0',
74
+ description: 'Amount of token0 to provide (e.g., 1000)',
75
+ required: true,
76
+ },
77
+ {
78
+ name: 'amount1',
79
+ description: 'Amount of token1 to provide (e.g., 1000)',
80
+ required: true,
81
+ },
82
+ {
83
+ name: 'minPrice',
84
+ description: 'Minimum price boundary for LP range (e.g., 0.90)',
85
+ required: false,
86
+ },
87
+ {
88
+ name: 'maxPrice',
89
+ description: 'Maximum price boundary for LP range (e.g., 1.10)',
90
+ required: false,
91
+ },
92
+ {
93
+ name: 'feeTier',
94
+ description: 'Fee tier in basis points: 500, 3000, or 10000 (default: 3000)',
95
+ required: false,
96
+ },
97
+ ],
98
+ handler: (args) => {
99
+ // Validate amounts
100
+ validateNumericAmount(args.amount0, 'amount0');
101
+ validateNumericAmount(args.amount1, 'amount1');
102
+
103
+ const minPrice = args.minPrice || '0.95';
104
+ const maxPrice = args.maxPrice || '1.05';
105
+ const feeTier = args.feeTier || '3000';
106
+
107
+ return [
108
+ {
109
+ role: 'user',
110
+ content: {
111
+ type: 'text',
112
+ text: `I want to add liquidity to the ${args.token0}/${args.token1} pool on GalaSwap DEX.
113
+
114
+ **Liquidity Details:**
115
+ - Token Pair: ${args.token0} / ${args.token1}
116
+ - Amount of ${args.token0}: ${args.amount0}
117
+ - Amount of ${args.token1}: ${args.amount1}
118
+ - Price Range: ${minPrice} - ${maxPrice}
119
+ - Fee Tier: ${feeTier} basis points (${parseInt(feeTier) / 100}%)
120
+
121
+ **Workflow:**
122
+ 1. Check my wallet balances to ensure I have sufficient tokens
123
+ 2. Get pool information for the ${args.token0}/${args.token1} pair
124
+ 3. Add liquidity by price range with the specified amounts and price boundaries
125
+ 4. Confirm the position was created successfully
126
+
127
+ **Important:**
128
+ - Price range ${minPrice}-${maxPrice} means liquidity is only provided when the price is in this range
129
+ - Lower fee tiers (500 bps) for stablecoins, higher fees (3000-10000 bps) for volatile pairs
130
+ - I accept the estimated slippage shown in the quote
131
+
132
+ Please use the following MCP tools:
133
+ - gala_launchpad_get_swap_user_assets: Check my token balances
134
+ - gala_launchpad_get_swap_pool_info: Get ${args.token0}/${args.token1} pool details
135
+ - gala_launchpad_add_liquidity_by_price: Add liquidity with price range
136
+
137
+ Proceed with adding liquidity.`,
138
+ },
139
+ },
140
+ ];
141
+ },
142
+ };
143
+
144
+ /**
145
+ * Remove Liquidity - Close or reduce LP position
146
+ *
147
+ * Guides through removing liquidity from an existing position
148
+ */
149
+ export const removeLiquidityPrompt: MCPPrompt = {
150
+ name: 'galachain-launchpad:remove-liquidity',
151
+ description:
152
+ 'Remove liquidity from an existing position. Shows estimated tokens and fees to receive.',
153
+ arguments: [
154
+ {
155
+ name: 'positionId',
156
+ description: 'Position ID to remove liquidity from',
157
+ required: true,
158
+ },
159
+ {
160
+ name: 'percentage',
161
+ description: 'Percentage of liquidity to remove (0-100, default: 100 to close position)',
162
+ required: false,
163
+ },
164
+ ],
165
+ handler: (args) => {
166
+ const percentage = args.percentage || '100';
167
+
168
+ return [
169
+ {
170
+ role: 'user',
171
+ content: {
172
+ type: 'text',
173
+ text: `I want to remove ${percentage}% of liquidity from position ${args.positionId}.
174
+
175
+ **Removal Details:**
176
+ - Position ID: ${args.positionId}
177
+ - Removal Amount: ${percentage}% of liquidity
178
+ ${percentage === '100' ? '- Action: Close position completely' : '- Action: Reduce position by ' + percentage + '%'}
179
+
180
+ **Workflow:**
181
+ 1. Get position details (token pair, current liquidity, accumulated fees)
182
+ 2. Estimate tokens and fees that will be received when removing
183
+ 3. Show the breakdown of what I'll receive
184
+ 4. Execute the removal with slippage protection
185
+ 5. Verify the position was updated/closed
186
+
187
+ **Important:**
188
+ - Removing 100% closes the position
189
+ - Removing less keeps the position open with reduced liquidity
190
+ - Accumulated fees can be collected separately if desired
191
+ - Slippage protection ensures I receive acceptable amounts
192
+
193
+ Please use the following MCP tools:
194
+ - gala_launchpad_get_liquidity_position_by_id: Get position details
195
+ - gala_launchpad_estimate_remove_liquidity: Preview what I'll receive
196
+ - gala_launchpad_remove_liquidity: Execute the removal
197
+
198
+ Proceed with removing liquidity.`,
199
+ },
200
+ },
201
+ ];
202
+ },
203
+ };
204
+
205
+ /**
206
+ * Collect Fees - Harvest accumulated trading fees
207
+ *
208
+ * Guides through collecting accumulated fees from a position
209
+ */
210
+ export const collectFeesPrompt: MCPPrompt = {
211
+ name: 'galachain-launchpad:collect-fees',
212
+ description:
213
+ 'Collect accumulated trading fees from a liquidity position without modifying the position.',
214
+ arguments: [
215
+ {
216
+ name: 'positionId',
217
+ description: 'Position ID to collect fees from',
218
+ required: true,
219
+ },
220
+ ],
221
+ handler: (args) => {
222
+ return [
223
+ {
224
+ role: 'user',
225
+ content: {
226
+ type: 'text',
227
+ text: `I want to collect accumulated trading fees from position ${args.positionId}.
228
+
229
+ **Fee Collection Details:**
230
+ - Position ID: ${args.positionId}
231
+ - Action: Harvest accumulated trading fees
232
+ - Position Impact: Liquidity remains unchanged, only fees collected
233
+
234
+ **Workflow:**
235
+ 1. Get position details to show accumulated fees
236
+ 2. Show how much in fees is available to collect (in both tokens)
237
+ 3. Execute fee collection transaction
238
+ 4. Confirm fees were successfully collected
239
+
240
+ **Benefits:**
241
+ - Passive income from liquidity provision
242
+ - Fees accumulate continuously as trades happen
243
+ - Can be collected without closing the position
244
+ - Frees up rewards to reinvest or use elsewhere
245
+
246
+ **Important:**
247
+ - Fee collection doesn't affect your liquidity position
248
+ - Fees are only earned on trades within your price range
249
+ - Fee amounts depend on trading volume and your fee tier
250
+
251
+ Please use the following MCP tools:
252
+ - gala_launchpad_get_liquidity_position_by_id: Get position details and fee amounts
253
+ - gala_launchpad_collect_position_fees: Collect the accumulated fees
254
+
255
+ Proceed with collecting fees.`,
256
+ },
257
+ },
258
+ ];
259
+ },
260
+ };
261
+
262
+ /**
263
+ * Export all liquidity position prompts
264
+ */
265
+ export const liquidityPositionPrompts: MCPPrompt[] = [
266
+ myPositionsPrompt,
267
+ addLiquidityPrompt,
268
+ removeLiquidityPrompt,
269
+ collectFeesPrompt,
270
+ ];