@gala-chain/launchpad-mcp-server 1.14.1 → 1.14.2
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.
- package/CHANGELOG.md +16 -0
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/tools/utils/explainSdkUsage.d.ts.map +1 -1
- package/dist/tools/utils/explainSdkUsage.js +441 -20
- package/dist/tools/utils/explainSdkUsage.js.map +1 -1
- package/docs/AI-AGENT-PATTERNS.md +555 -0
- package/docs/CONSTRAINTS-REFERENCE.md +454 -0
- package/docs/PROMPT-TOOL-MAPPING.md +352 -0
- package/docs/examples/default-values-pattern.md +240 -0
- package/docs/examples/tool-factory-pattern.md +217 -0
- package/jest.config.js +94 -0
- package/package.json +2 -2
- package/src/__tests__/integration/fetchTokenDetails.integration.test.ts +258 -0
- package/src/__tests__/integration/poolTools.integration.test.ts +185 -0
- package/src/constants/mcpToolNames.ts +141 -0
- package/src/index.ts +19 -0
- package/src/prompts/__tests__/promptStructure.test.ts +114 -0
- package/src/prompts/__tests__/registry.test.ts +145 -0
- package/src/prompts/analysis.ts +429 -0
- package/src/prompts/index.ts +127 -0
- package/src/prompts/portfolio.ts +242 -0
- package/src/prompts/trading.ts +191 -0
- package/src/prompts/utility.ts +43 -0
- package/src/prompts/utils/workflowTemplates.ts +344 -0
- package/src/schemas/common-schemas.ts +393 -0
- package/src/scripts/test-all-prompts.ts +184 -0
- package/src/server.ts +241 -0
- package/src/tools/balance/index.ts +174 -0
- package/src/tools/creation/index.ts +182 -0
- package/src/tools/index.ts +80 -0
- package/src/tools/pools/fetchAllPools.ts +47 -0
- package/src/tools/pools/fetchAllPriceHistory.ts +103 -0
- package/src/tools/pools/fetchPoolDetails.ts +27 -0
- package/src/tools/pools/fetchPoolDetailsForCalculation.ts +22 -0
- package/src/tools/pools/fetchPools.ts +47 -0
- package/src/tools/pools/fetchPriceHistory.ts +108 -0
- package/src/tools/pools/fetchTokenDetails.ts +77 -0
- package/src/tools/pools/index.ts +246 -0
- package/src/tools/social/index.ts +64 -0
- package/src/tools/trading/index.ts +605 -0
- package/src/tools/transfers/index.ts +75 -0
- package/src/tools/utils/clearCache.ts +36 -0
- package/src/tools/utils/createWallet.ts +19 -0
- package/src/tools/utils/explainSdkUsage.ts +1277 -0
- package/src/tools/utils/getAddress.ts +12 -0
- package/src/tools/utils/getCacheInfo.ts +14 -0
- package/src/tools/utils/getConfig.ts +11 -0
- package/src/tools/utils/getEthereumAddress.ts +12 -0
- package/src/tools/utils/getUrlByTokenName.ts +12 -0
- package/src/tools/utils/getVersion.ts +25 -0
- package/src/tools/utils/index.ts +27 -0
- package/src/tools/utils/isTokenGraduated.ts +16 -0
- package/src/types/mcp.ts +72 -0
- package/src/utils/__tests__/validation.test.ts +147 -0
- package/src/utils/constraints.ts +155 -0
- package/src/utils/default-values.ts +208 -0
- package/src/utils/error-handler.ts +69 -0
- package/src/utils/error-templates.ts +273 -0
- package/src/utils/response-formatter.ts +51 -0
- package/src/utils/tool-factory.ts +257 -0
- package/src/utils/tool-registry.ts +296 -0
- package/src/utils/validation.ts +336 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Template Utilities
|
|
3
|
+
*
|
|
4
|
+
* Reusable templates for common workflow patterns in prompts.
|
|
5
|
+
* Reduces duplication and ensures consistency across slash commands.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { MCP_TOOLS } from '../../constants/mcpToolNames.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for trading workflow generation
|
|
12
|
+
*/
|
|
13
|
+
export interface TradingWorkflowConfig {
|
|
14
|
+
operation: 'buy' | 'sell' | 'graduate';
|
|
15
|
+
tokenName: string;
|
|
16
|
+
amount?: string;
|
|
17
|
+
amountType?: 'gala' | 'tokens';
|
|
18
|
+
slippage?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Create a complete trading workflow with all standard steps
|
|
23
|
+
*
|
|
24
|
+
* @param config - Trading workflow configuration
|
|
25
|
+
* @returns Formatted workflow text with numbered steps
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const workflow = createTradingWorkflow({
|
|
30
|
+
* operation: 'buy',
|
|
31
|
+
* tokenName: 'anime',
|
|
32
|
+
* amount: '100',
|
|
33
|
+
* amountType: 'gala',
|
|
34
|
+
* slippage: '1'
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function createTradingWorkflow(config: TradingWorkflowConfig): string {
|
|
39
|
+
const { operation, tokenName, amount, amountType, slippage = '1' } = config;
|
|
40
|
+
|
|
41
|
+
switch (operation) {
|
|
42
|
+
case 'buy':
|
|
43
|
+
return createBuyWorkflow(tokenName, amount!, amountType!, slippage);
|
|
44
|
+
case 'sell':
|
|
45
|
+
return createSellWorkflow(tokenName, amount!, slippage);
|
|
46
|
+
case 'graduate':
|
|
47
|
+
return createGraduationWorkflow(tokenName, slippage);
|
|
48
|
+
default:
|
|
49
|
+
throw new Error(`Unknown operation: ${operation}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Create buy tokens workflow
|
|
55
|
+
*/
|
|
56
|
+
function createBuyWorkflow(
|
|
57
|
+
tokenName: string,
|
|
58
|
+
amount: string,
|
|
59
|
+
amountType: 'gala' | 'tokens',
|
|
60
|
+
slippage: string
|
|
61
|
+
): string {
|
|
62
|
+
const slippageFactor = parseFloat(slippage) / 100;
|
|
63
|
+
const typeParam = amountType === 'gala' ? 'native' : 'exact';
|
|
64
|
+
const amountLabel = amountType === 'gala' ? 'GALA to spend' : 'Tokens to buy';
|
|
65
|
+
|
|
66
|
+
return `Help me buy tokens on Gala Launchpad:
|
|
67
|
+
|
|
68
|
+
Token: ${tokenName}
|
|
69
|
+
${amountLabel}: ${amount}
|
|
70
|
+
Slippage tolerance: ${slippage}%
|
|
71
|
+
|
|
72
|
+
Please follow this workflow:
|
|
73
|
+
|
|
74
|
+
1. Calculate buy amount using ${MCP_TOOLS.CALCULATE_BUY_AMOUNT}:
|
|
75
|
+
- tokenName: "${tokenName}"
|
|
76
|
+
- amount: "${amount}"
|
|
77
|
+
- type: "${typeParam}" (${amountType === 'gala' ? 'spending GALA' : 'buying exact tokens'})
|
|
78
|
+
|
|
79
|
+
2. Show me the breakdown:
|
|
80
|
+
- Tokens I'll receive
|
|
81
|
+
- Transaction fee
|
|
82
|
+
- Gas fee
|
|
83
|
+
- Reverse bonding curve fee
|
|
84
|
+
- Total cost
|
|
85
|
+
|
|
86
|
+
3. Ask for confirmation before executing
|
|
87
|
+
|
|
88
|
+
4. If I confirm, execute the buy using ${MCP_TOOLS.BUY_TOKENS} with:
|
|
89
|
+
- expectedAmount from calculation
|
|
90
|
+
- maxAcceptableReverseBondingCurveFee from calculation
|
|
91
|
+
- slippageToleranceFactor: ${slippageFactor}
|
|
92
|
+
|
|
93
|
+
5. After purchase, show transaction ID and verify balance`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Create sell tokens workflow
|
|
98
|
+
*/
|
|
99
|
+
function createSellWorkflow(
|
|
100
|
+
tokenName: string,
|
|
101
|
+
amount: string,
|
|
102
|
+
slippage: string
|
|
103
|
+
): string {
|
|
104
|
+
const slippageFactor = parseFloat(slippage) / 100;
|
|
105
|
+
|
|
106
|
+
return `Help me sell tokens on Gala Launchpad:
|
|
107
|
+
|
|
108
|
+
Token: ${tokenName}
|
|
109
|
+
Tokens to sell: ${amount}
|
|
110
|
+
Slippage tolerance: ${slippage}%
|
|
111
|
+
|
|
112
|
+
Please follow this workflow:
|
|
113
|
+
|
|
114
|
+
1. Check my token balance using ${MCP_TOOLS.FETCH_TOKEN_BALANCE}
|
|
115
|
+
|
|
116
|
+
2. Calculate sell amount using ${MCP_TOOLS.CALCULATE_SELL_AMOUNT}:
|
|
117
|
+
- tokenName: "${tokenName}"
|
|
118
|
+
- amount: "${amount}"
|
|
119
|
+
- type: "exact" (selling exact token amount)
|
|
120
|
+
|
|
121
|
+
3. Show me the breakdown:
|
|
122
|
+
- GALA I'll receive
|
|
123
|
+
- Transaction fee
|
|
124
|
+
- Gas fee
|
|
125
|
+
- Reverse bonding curve fee
|
|
126
|
+
- Net proceeds
|
|
127
|
+
|
|
128
|
+
4. Ask for confirmation before executing
|
|
129
|
+
|
|
130
|
+
5. If I confirm, execute the sell using ${MCP_TOOLS.SELL_TOKENS} with:
|
|
131
|
+
- expectedAmount from calculation
|
|
132
|
+
- maxAcceptableReverseBondingCurveFee from calculation
|
|
133
|
+
- slippageToleranceFactor: ${slippageFactor}
|
|
134
|
+
|
|
135
|
+
6. After sale, show transaction ID and verify updated balance`;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Create token graduation workflow
|
|
140
|
+
*/
|
|
141
|
+
function createGraduationWorkflow(tokenName: string, slippage: string): string {
|
|
142
|
+
const slippageFactor = parseFloat(slippage) / 100;
|
|
143
|
+
|
|
144
|
+
return `Help me graduate the token "${tokenName}" on Gala Launchpad:
|
|
145
|
+
|
|
146
|
+
Slippage tolerance: ${slippage}%
|
|
147
|
+
|
|
148
|
+
Please follow this workflow:
|
|
149
|
+
|
|
150
|
+
1. Check if token is already graduated using ${MCP_TOOLS.FETCH_POOL_DETAILS}
|
|
151
|
+
- If saleStatus is "Completed", inform me it's already graduated
|
|
152
|
+
|
|
153
|
+
2. Fetch optimized pool details using ${MCP_TOOLS.FETCH_POOL_DETAILS_FOR_CALCULATION}
|
|
154
|
+
|
|
155
|
+
3. Calculate graduation cost using ${MCP_TOOLS.CALCULATE_BUY_AMOUNT_FOR_GRADUATION} with:
|
|
156
|
+
- calculateAmountMode: "local"
|
|
157
|
+
- currentSupply from pool details
|
|
158
|
+
|
|
159
|
+
4. Show me the breakdown:
|
|
160
|
+
- GALA required to graduate: [amount field - this is GALA cost, NOT token quantity!]
|
|
161
|
+
- Transaction fee
|
|
162
|
+
- Gas fee
|
|
163
|
+
- Total cost
|
|
164
|
+
|
|
165
|
+
5. Check my GALA balance using ${MCP_TOOLS.FETCH_GALA_BALANCE}
|
|
166
|
+
- Verify I have enough GALA for graduation
|
|
167
|
+
|
|
168
|
+
6. Ask for confirmation before executing
|
|
169
|
+
|
|
170
|
+
7. If I confirm, execute graduation using ${MCP_TOOLS.GRADUATE_TOKEN} with:
|
|
171
|
+
- tokenName: "${tokenName}"
|
|
172
|
+
- slippageToleranceFactor: ${slippageFactor}
|
|
173
|
+
- calculateAmountMode: "local"
|
|
174
|
+
- currentSupply from pool details (optimization!)
|
|
175
|
+
|
|
176
|
+
8. After graduation:
|
|
177
|
+
- Show transaction ID
|
|
178
|
+
- Verify pool status changed to "Completed"
|
|
179
|
+
- Get frontend URL using ${MCP_TOOLS.GET_URL_BY_TOKEN_NAME}
|
|
180
|
+
|
|
181
|
+
IMPORTANT: The "amount" field in graduation calculations is GALA cost, not token quantity!`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Format a list of steps with numbers
|
|
186
|
+
*
|
|
187
|
+
* @param steps - Array of step descriptions
|
|
188
|
+
* @returns Formatted steps with numbering
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* formatWorkflowSteps([
|
|
193
|
+
* 'Fetch pool details',
|
|
194
|
+
* 'Calculate price',
|
|
195
|
+
* 'Show results'
|
|
196
|
+
* ]);
|
|
197
|
+
* // Returns:
|
|
198
|
+
* // "1. Fetch pool details
|
|
199
|
+
* // 2. Calculate price
|
|
200
|
+
* // 3. Show results"
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export function formatWorkflowSteps(steps: string[]): string {
|
|
204
|
+
return steps.map((step, index) => `${index + 1}. ${step}`).join('\n\n');
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Create a standard confirmation step for destructive operations
|
|
209
|
+
*
|
|
210
|
+
* @param operation - Operation name (e.g., 'buy', 'sell', 'graduate')
|
|
211
|
+
* @returns Confirmation step text
|
|
212
|
+
*/
|
|
213
|
+
export function createConfirmationStep(operation: string): string {
|
|
214
|
+
return `Ask for confirmation before executing the ${operation} operation`;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Create a standard verification step after transaction
|
|
219
|
+
*
|
|
220
|
+
* @param operation - Operation name
|
|
221
|
+
* @param verifications - Array of verification checks to perform
|
|
222
|
+
* @returns Verification step text
|
|
223
|
+
*/
|
|
224
|
+
export function createVerificationStep(
|
|
225
|
+
operation: string,
|
|
226
|
+
verifications: string[]
|
|
227
|
+
): string {
|
|
228
|
+
const checks = verifications
|
|
229
|
+
.map((check, index) => ` ${String.fromCharCode(97 + index)}. ${check}`)
|
|
230
|
+
.join('\n');
|
|
231
|
+
|
|
232
|
+
return `After ${operation} completes:\n${checks}`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Create an optimized performance note for LOCAL calculations
|
|
237
|
+
*
|
|
238
|
+
* @returns Performance optimization guidance text
|
|
239
|
+
*/
|
|
240
|
+
export function createPerformanceNote(): string {
|
|
241
|
+
return `Use the performance optimization pattern from SDK v3.9.0 to minimize network calls.`;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Create a cost breakdown display template
|
|
246
|
+
*
|
|
247
|
+
* @param operation - Operation type for context
|
|
248
|
+
* @returns Cost breakdown template text
|
|
249
|
+
*/
|
|
250
|
+
export function createCostBreakdown(operation: 'buy' | 'sell' | 'graduate'): string {
|
|
251
|
+
switch (operation) {
|
|
252
|
+
case 'buy':
|
|
253
|
+
return `Show me the breakdown:
|
|
254
|
+
- Tokens I'll receive
|
|
255
|
+
- Transaction fee
|
|
256
|
+
- Gas fee
|
|
257
|
+
- Reverse bonding curve fee
|
|
258
|
+
- Total cost`;
|
|
259
|
+
case 'sell':
|
|
260
|
+
return `Show me the breakdown:
|
|
261
|
+
- GALA I'll receive
|
|
262
|
+
- Transaction fee
|
|
263
|
+
- Gas fee
|
|
264
|
+
- Reverse bonding curve fee
|
|
265
|
+
- Net proceeds`;
|
|
266
|
+
case 'graduate':
|
|
267
|
+
return `Show me the breakdown:
|
|
268
|
+
- GALA required to graduate
|
|
269
|
+
- Transaction fee
|
|
270
|
+
- Gas fee
|
|
271
|
+
- Total cost`;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Create a balance check step
|
|
277
|
+
*
|
|
278
|
+
* @param assetType - Type of asset to check ('GALA' or token name)
|
|
279
|
+
* @returns Balance check step text
|
|
280
|
+
*/
|
|
281
|
+
export function createBalanceCheckStep(assetType: 'GALA' | string): string {
|
|
282
|
+
if (assetType === 'GALA') {
|
|
283
|
+
return `Check my GALA balance using ${MCP_TOOLS.FETCH_GALA_BALANCE}`;
|
|
284
|
+
}
|
|
285
|
+
return `Check my ${assetType} token balance using ${MCP_TOOLS.FETCH_TOKEN_BALANCE}`;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Create analysis workflow for token evaluation
|
|
290
|
+
*
|
|
291
|
+
* @param tokenName - Token to analyze
|
|
292
|
+
* @returns Complete analysis workflow
|
|
293
|
+
*/
|
|
294
|
+
export function createAnalysisWorkflow(tokenName: string): string {
|
|
295
|
+
return `Analyze the token "${tokenName}" using the Gala Launchpad MCP server:
|
|
296
|
+
|
|
297
|
+
1. Fetch optimized pool details using ${MCP_TOOLS.FETCH_POOL_DETAILS_FOR_CALCULATION}
|
|
298
|
+
2. Calculate current USD spot price using LOCAL mode with the currentSupply
|
|
299
|
+
3. Calculate graduation cost using LOCAL mode with the currentSupply
|
|
300
|
+
4. Show remaining tokens and pool status (saleStatus)
|
|
301
|
+
5. Calculate pool progress percentage: (currentSupply / maxSupply * 100)
|
|
302
|
+
|
|
303
|
+
${createPerformanceNote()}
|
|
304
|
+
|
|
305
|
+
Provide a brief analysis including:
|
|
306
|
+
- Current token price in USD
|
|
307
|
+
- Total GALA required to graduate the pool
|
|
308
|
+
- How close the token is to graduation (percentage)
|
|
309
|
+
- Whether this would be a good time to buy or wait`;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Create portfolio analysis workflow
|
|
314
|
+
*
|
|
315
|
+
* @returns Complete portfolio analysis workflow
|
|
316
|
+
*/
|
|
317
|
+
export function createPortfolioWorkflow(): string {
|
|
318
|
+
return `Analyze my complete Gala Launchpad portfolio:
|
|
319
|
+
|
|
320
|
+
1. Get GALA balance using ${MCP_TOOLS.FETCH_GALA_BALANCE}
|
|
321
|
+
|
|
322
|
+
2. Get all tokens I'm holding using ${MCP_TOOLS.FETCH_TOKENS_HELD}
|
|
323
|
+
- Use pagination if needed to get all tokens
|
|
324
|
+
|
|
325
|
+
3. For each token, calculate USD value using optimized pattern:
|
|
326
|
+
a. Fetch pool details once: ${MCP_TOOLS.FETCH_POOL_DETAILS_FOR_CALCULATION}
|
|
327
|
+
b. Calculate spot price: ${MCP_TOOLS.FETCH_LAUNCHPAD_TOKEN_SPOT_PRICE} with LOCAL mode
|
|
328
|
+
c. Multiply token balance by spot price for USD value
|
|
329
|
+
|
|
330
|
+
4. Calculate GALA USD value using ${MCP_TOOLS.FETCH_GALA_SPOT_PRICE}
|
|
331
|
+
|
|
332
|
+
5. Present a comprehensive portfolio summary:
|
|
333
|
+
- GALA balance and USD value
|
|
334
|
+
- Each token holding with:
|
|
335
|
+
* Token name
|
|
336
|
+
* Balance
|
|
337
|
+
* USD spot price
|
|
338
|
+
* Total USD value
|
|
339
|
+
- Total portfolio value in USD
|
|
340
|
+
- Top 3 holdings by value
|
|
341
|
+
- Number of different tokens held
|
|
342
|
+
|
|
343
|
+
${createPerformanceNote()}`;
|
|
344
|
+
}
|