@gala-chain/launchpad-mcp-server 1.24.1 → 1.25.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 (101) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/generated/version.d.ts +1 -1
  3. package/dist/generated/version.js +1 -1
  4. package/dist/tools/index.d.ts +2 -2
  5. package/dist/tools/index.js +3 -3
  6. package/dist/tools/pools/index.d.ts.map +1 -1
  7. package/dist/tools/pools/index.js +4 -0
  8. package/dist/tools/pools/index.js.map +1 -1
  9. package/dist/tools/pools/onDexPoolCreation.d.ts +6 -0
  10. package/dist/tools/pools/onDexPoolCreation.d.ts.map +1 -0
  11. package/dist/tools/pools/onDexPoolCreation.js +60 -0
  12. package/dist/tools/pools/onDexPoolCreation.js.map +1 -0
  13. package/dist/tools/pools/onLaunchpadTokenCreation.d.ts +6 -0
  14. package/dist/tools/pools/onLaunchpadTokenCreation.d.ts.map +1 -0
  15. package/dist/tools/pools/onLaunchpadTokenCreation.js +54 -0
  16. package/dist/tools/pools/onLaunchpadTokenCreation.js.map +1 -0
  17. package/package.json +2 -2
  18. package/docs/AI-AGENT-PATTERNS.md +0 -555
  19. package/docs/CONSTRAINTS-REFERENCE.md +0 -454
  20. package/docs/PROMPT-TOOL-MAPPING.md +0 -352
  21. package/docs/examples/default-values-pattern.md +0 -240
  22. package/docs/examples/tool-factory-pattern.md +0 -217
  23. package/jest.config.js +0 -94
  24. package/src/__tests__/integration/fetchTokenDetails.integration.test.ts +0 -258
  25. package/src/__tests__/integration/poolTools.integration.test.ts +0 -185
  26. package/src/__tests__/server.test.ts +0 -255
  27. package/src/constants/mcpToolNames.ts +0 -183
  28. package/src/index.ts +0 -19
  29. package/src/prompts/__tests__/promptStructure.test.ts +0 -187
  30. package/src/prompts/__tests__/registry.test.ts +0 -349
  31. package/src/prompts/analysis.ts +0 -380
  32. package/src/prompts/balances.ts +0 -182
  33. package/src/prompts/create-token.ts +0 -123
  34. package/src/prompts/creation-utils.ts +0 -103
  35. package/src/prompts/dex-trading.ts +0 -86
  36. package/src/prompts/discover-tokens.ts +0 -86
  37. package/src/prompts/explore-dex-pools.ts +0 -138
  38. package/src/prompts/index.ts +0 -178
  39. package/src/prompts/liquidity-positions.ts +0 -237
  40. package/src/prompts/pools.ts +0 -496
  41. package/src/prompts/portfolio.ts +0 -208
  42. package/src/prompts/social.ts +0 -94
  43. package/src/prompts/trading-calculations.ts +0 -414
  44. package/src/prompts/trading.ts +0 -160
  45. package/src/prompts/transfers.ts +0 -97
  46. package/src/prompts/utility-tools.ts +0 -266
  47. package/src/prompts/utility.ts +0 -77
  48. package/src/prompts/utils/handlerHelpers.ts +0 -55
  49. package/src/prompts/utils/textTemplates.ts +0 -73
  50. package/src/prompts/utils/workflowTemplates.ts +0 -511
  51. package/src/schemas/common-schemas.ts +0 -393
  52. package/src/scripts/test-all-prompts.ts +0 -184
  53. package/src/server.ts +0 -367
  54. package/src/tools/__tests__/dex-tools.test.ts +0 -562
  55. package/src/tools/__tests__/liquidity-positions.test.ts +0 -673
  56. package/src/tools/balance/index.ts +0 -174
  57. package/src/tools/creation/index.ts +0 -182
  58. package/src/tools/dex/fetchAllDexPools.ts +0 -45
  59. package/src/tools/dex/fetchDexPools.ts +0 -58
  60. package/src/tools/dex/index.ts +0 -231
  61. package/src/tools/dex/liquidity-positions.ts +0 -547
  62. package/src/tools/index.ts +0 -94
  63. package/src/tools/pools/fetchAllPools.ts +0 -47
  64. package/src/tools/pools/fetchAllPriceHistory.ts +0 -119
  65. package/src/tools/pools/fetchPoolDetails.ts +0 -27
  66. package/src/tools/pools/fetchPoolDetailsForCalculation.ts +0 -22
  67. package/src/tools/pools/fetchPools.ts +0 -47
  68. package/src/tools/pools/fetchPriceHistory.ts +0 -124
  69. package/src/tools/pools/fetchTokenDetails.ts +0 -77
  70. package/src/tools/pools/index.ts +0 -284
  71. package/src/tools/social/index.ts +0 -64
  72. package/src/tools/trading/index.ts +0 -605
  73. package/src/tools/transfers/index.ts +0 -75
  74. package/src/tools/utils/clearCache.ts +0 -36
  75. package/src/tools/utils/createWallet.ts +0 -19
  76. package/src/tools/utils/explainSdkUsage.ts +0 -1446
  77. package/src/tools/utils/getAddress.ts +0 -12
  78. package/src/tools/utils/getCacheInfo.ts +0 -14
  79. package/src/tools/utils/getConfig.ts +0 -21
  80. package/src/tools/utils/getEnvironment.ts +0 -17
  81. package/src/tools/utils/getEthereumAddress.ts +0 -12
  82. package/src/tools/utils/getUrlByTokenName.ts +0 -12
  83. package/src/tools/utils/getVersion.ts +0 -25
  84. package/src/tools/utils/getWallet.ts +0 -25
  85. package/src/tools/utils/hasWallet.ts +0 -15
  86. package/src/tools/utils/index.ts +0 -37
  87. package/src/tools/utils/isTokenGraduated.ts +0 -16
  88. package/src/tools/utils/setWallet.ts +0 -41
  89. package/src/tools/utils/switchEnvironment.ts +0 -28
  90. package/src/types/mcp.ts +0 -72
  91. package/src/utils/__tests__/validation.test.ts +0 -147
  92. package/src/utils/constraints.ts +0 -155
  93. package/src/utils/default-values.ts +0 -208
  94. package/src/utils/error-handler.ts +0 -69
  95. package/src/utils/error-templates.ts +0 -273
  96. package/src/utils/response-formatter.ts +0 -51
  97. package/src/utils/tool-factory.ts +0 -303
  98. package/src/utils/tool-registry.ts +0 -296
  99. package/src/utils/validation.ts +0 -429
  100. package/tests/wallet-management-integration.test.ts +0 -284
  101. package/tsconfig.json +0 -23
@@ -1,605 +0,0 @@
1
- /**
2
- * Trading Operations Tools
3
- */
4
-
5
- import { TRADING_TYPES } from '@gala-chain/launchpad-sdk';
6
- import type { MCPTool } from '../../types/mcp.js';
7
- import { formatSuccess } from '../../utils/response-formatter.js';
8
- import { withErrorHandling } from '../../utils/error-handler.js';
9
- import {
10
- TOKEN_NAME_SCHEMA,
11
- DECIMAL_AMOUNT_SCHEMA,
12
- PRIVATE_KEY_SCHEMA,
13
- ADDRESS_SCHEMA,
14
- PAGE_SCHEMA,
15
- createLimitSchema,
16
- TRANSACTION_ID_SCHEMA,
17
- DATE_TIME_SCHEMA,
18
- SORT_ORDER_SCHEMA,
19
- SLIPPAGE_TOLERANCE_SCHEMA,
20
- RBC_FEE_SLIPPAGE_SCHEMA,
21
- CALCULATION_MODE_SCHEMA,
22
- CURRENT_SUPPLY_SCHEMA,
23
- } from '../../schemas/common-schemas.js';
24
- import { applyOperationPaginationDefaults } from '../../utils/default-values.js';
25
-
26
- // 1. Calculate Buy Amount
27
- export const calculateBuyAmountTool: MCPTool = {
28
- name: 'gala_launchpad_calculate_buy_amount',
29
- description: 'Calculate token amounts for buying with fee breakdown',
30
- inputSchema: {
31
- type: 'object',
32
- properties: {
33
- tokenName: TOKEN_NAME_SCHEMA,
34
- amount: {
35
- ...DECIMAL_AMOUNT_SCHEMA,
36
- description: 'Amount in standard decimal format (e.g., "1" for 1 GALA)',
37
- },
38
- type: {
39
- type: 'string',
40
- enum: Object.values(TRADING_TYPES),
41
- description: `Trade calculation type:
42
-
43
- - 'native': You specify GALA amount to spend
44
- Example: "I want to spend 10 GALA to buy tokens" → type: 'native', amount: '10'
45
-
46
- - 'exact': You specify exact token amount to buy
47
- Example: "I want to buy exactly 1000 WOO tokens" → type: 'exact', amount: '1000'
48
-
49
- Most common: Use 'native' when you know how much GALA to spend`,
50
- },
51
- },
52
- required: ['tokenName', 'amount', 'type'],
53
- },
54
- handler: withErrorHandling(async (sdk, args) => {
55
- const result = await sdk.calculateBuyAmount({
56
- tokenName: args.tokenName,
57
- amount: args.amount,
58
- type: args.type,
59
- });
60
- return formatSuccess(result);
61
- }),
62
- };
63
-
64
- // 2. Calculate Sell Amount
65
- export const calculateSellAmountTool: MCPTool = {
66
- name: 'gala_launchpad_calculate_sell_amount',
67
- description: 'Calculate GALA amounts for selling tokens',
68
- inputSchema: {
69
- type: 'object',
70
- properties: {
71
- tokenName: TOKEN_NAME_SCHEMA,
72
- amount: DECIMAL_AMOUNT_SCHEMA,
73
- type: {
74
- type: 'string',
75
- enum: Object.values(TRADING_TYPES),
76
- description: `Trade calculation type:
77
-
78
- - 'native': You specify GALA amount you want to receive
79
- Example: "I want to receive 10 GALA from selling tokens" → type: 'native', amount: '10'
80
-
81
- - 'exact': You specify exact token amount to sell
82
- Example: "I want to sell exactly 1000 WOO tokens" → type: 'exact', amount: '1000'
83
-
84
- Most common: Use 'native' when you know how much GALA you want to receive`,
85
- },
86
- },
87
- required: ['tokenName', 'amount', 'type'],
88
- },
89
- handler: withErrorHandling(async (sdk, args) => {
90
- const result = await sdk.calculateSellAmount({
91
- tokenName: args.tokenName,
92
- amount: args.amount,
93
- type: args.type,
94
- });
95
- return formatSuccess(result);
96
- }),
97
- };
98
-
99
- // 3. Buy Tokens
100
- export const buyTokensTool: MCPTool = {
101
- name: 'gala_launchpad_buy_tokens',
102
- description: `Execute token purchase with slippage protection.
103
-
104
- WORKFLOW:
105
- 1. calculateBuyAmount() → Get expected output (result.amount AND result.reverseBondingCurveFee)
106
- 2. buy() → Execute trade with BOTH expectedAmount AND maxAcceptableReverseBondingCurveFee
107
- 3. fetchTrades() → Verify trade completed
108
-
109
- CRITICAL: Extract BOTH parameters from calculateBuyAmount:
110
- - result.amount → expectedAmount
111
- - result.reverseBondingCurveFee → maxAcceptableReverseBondingCurveFee
112
- Omitting reverseBondingCurveFee may cause transaction failures!
113
-
114
- RETURNS: Transaction details including input/output amounts and transaction ID`,
115
- inputSchema: {
116
- type: 'object',
117
- properties: {
118
- tokenName: TOKEN_NAME_SCHEMA,
119
- amount: {
120
- ...DECIMAL_AMOUNT_SCHEMA,
121
- description: 'Amount to spend/buy',
122
- },
123
- type: {
124
- type: 'string',
125
- enum: Object.values(TRADING_TYPES),
126
- description: `Trade type (must match what you used in calculateBuyAmount):
127
-
128
- - 'native': Spending GALA amount
129
- - 'exact': Buying exact token amount`,
130
- },
131
- expectedAmount: {
132
- ...DECIMAL_AMOUNT_SCHEMA,
133
- description: `Expected token output amount from calculateBuyAmount (REQUIRED).
134
-
135
- CRITICAL: This is the 'amount' field from calculateBuyAmount result, NOT your input amount.
136
-
137
- WORKFLOW:
138
- 1. Call calculateBuyAmount({ tokenName, amount, type })
139
- 2. Extract result.amount from the response
140
- 3. Use result.amount as this expectedAmount parameter
141
-
142
- EXAMPLE:
143
- const calc = await calculateBuyAmount({ tokenName: 'woohoo', amount: '10', type: 'native' });
144
- // calc.amount = "16843.7579794843252"
145
- await buy({ tokenName: 'woohoo', amount: '10', type: 'native', expectedAmount: calc.amount, ... });
146
- // Use calc.amount ("16843.7579794843252"), NOT the input '10'`,
147
- },
148
- maxAcceptableReverseBondingCurveFee: {
149
- ...DECIMAL_AMOUNT_SCHEMA,
150
- description: 'RECOMMENDED: Base reverse bonding curve fee from calculateBuyAmount (GALA). Use result.reverseBondingCurveFee. Omitting this may cause transaction failures. Works with maxAcceptableReverseBondingCurveFeeSlippageFactor for automatic slippage adjustment.',
151
- },
152
- maxAcceptableReverseBondingCurveFeeSlippageFactor: RBC_FEE_SLIPPAGE_SCHEMA,
153
- slippageToleranceFactor: SLIPPAGE_TOLERANCE_SCHEMA,
154
- privateKey: PRIVATE_KEY_SCHEMA,
155
- },
156
- required: ['tokenName', 'amount', 'type', 'expectedAmount', 'slippageToleranceFactor'],
157
- },
158
- handler: withErrorHandling(async (sdk, args) => {
159
- const result = await sdk.buy({
160
- tokenName: args.tokenName,
161
- amount: args.amount,
162
- type: args.type,
163
- expectedAmount: args.expectedAmount,
164
- maxAcceptableReverseBondingCurveFee: args.maxAcceptableReverseBondingCurveFee,
165
- maxAcceptableReverseBondingCurveFeeSlippageFactor: args.maxAcceptableReverseBondingCurveFeeSlippageFactor,
166
- slippageToleranceFactor: args.slippageToleranceFactor,
167
- privateKey: args.privateKey,
168
- });
169
- return formatSuccess(result);
170
- }),
171
- };
172
-
173
- // 4. Sell Tokens
174
- export const sellTokensTool: MCPTool = {
175
- name: 'gala_launchpad_sell_tokens',
176
- description: `Execute token sale with slippage protection.
177
-
178
- WORKFLOW:
179
- 1. calculateSellAmount() → Get expected output (result.amount AND result.reverseBondingCurveFee)
180
- 2. sell() → Execute trade with BOTH expectedAmount AND maxAcceptableReverseBondingCurveFee
181
- 3. fetchTrades() → Verify trade completed
182
-
183
- CRITICAL: Extract BOTH parameters from calculateSellAmount:
184
- - result.amount → expectedAmount
185
- - result.reverseBondingCurveFee → maxAcceptableReverseBondingCurveFee
186
- Omitting reverseBondingCurveFee may cause transaction failures!
187
-
188
- RETURNS: Transaction details including input/output amounts and transaction ID`,
189
- inputSchema: {
190
- type: 'object',
191
- properties: {
192
- tokenName: TOKEN_NAME_SCHEMA,
193
- amount: {
194
- ...DECIMAL_AMOUNT_SCHEMA,
195
- description: 'Amount to sell/receive',
196
- },
197
- type: {
198
- type: 'string',
199
- enum: Object.values(TRADING_TYPES),
200
- description: `Trade type (must match what you used in calculateSellAmount):
201
-
202
- - 'native': Receiving GALA amount
203
- - 'exact': Selling exact token amount`,
204
- },
205
- expectedAmount: {
206
- ...DECIMAL_AMOUNT_SCHEMA,
207
- description: `Expected GALA output amount from calculateSellAmount (REQUIRED).
208
-
209
- CRITICAL: This is the 'amount' field from calculateSellAmount result, NOT your input amount.
210
-
211
- WORKFLOW:
212
- 1. Call calculateSellAmount({ tokenName, amount, type })
213
- 2. Extract result.amount from the response
214
- 3. Use result.amount as this expectedAmount parameter
215
-
216
- EXAMPLE:
217
- const calc = await calculateSellAmount({ tokenName: 'woohoo', amount: '10', type: 'native' });
218
- // calc.amount = "16843.7579794843252"
219
- await sell({ tokenName: 'woohoo', amount: '10', type: 'native', expectedAmount: calc.amount, ... });
220
- // Use calc.amount ("16843.7579794843252"), NOT the input '10'`,
221
- },
222
- maxAcceptableReverseBondingCurveFee: {
223
- ...DECIMAL_AMOUNT_SCHEMA,
224
- description: 'RECOMMENDED: Base reverse bonding curve fee from calculateSellAmount (GALA). Use result.reverseBondingCurveFee. Omitting this may cause transaction failures. Works with maxAcceptableReverseBondingCurveFeeSlippageFactor for automatic slippage adjustment.',
225
- },
226
- maxAcceptableReverseBondingCurveFeeSlippageFactor: RBC_FEE_SLIPPAGE_SCHEMA,
227
- slippageToleranceFactor: SLIPPAGE_TOLERANCE_SCHEMA,
228
- privateKey: PRIVATE_KEY_SCHEMA,
229
- },
230
- required: ['tokenName', 'amount', 'type', 'expectedAmount', 'slippageToleranceFactor'],
231
- },
232
- handler: withErrorHandling(async (sdk, args) => {
233
- const result = await sdk.sell({
234
- tokenName: args.tokenName,
235
- amount: args.amount,
236
- type: args.type,
237
- expectedAmount: args.expectedAmount,
238
- maxAcceptableReverseBondingCurveFee: args.maxAcceptableReverseBondingCurveFee,
239
- maxAcceptableReverseBondingCurveFeeSlippageFactor: args.maxAcceptableReverseBondingCurveFeeSlippageFactor,
240
- slippageToleranceFactor: args.slippageToleranceFactor,
241
- privateKey: args.privateKey,
242
- });
243
- return formatSuccess(result);
244
- }),
245
- };
246
-
247
- // 5. Fetch Trades
248
- export const fetchTradesTool: MCPTool = {
249
- name: 'gala_launchpad_fetch_trades',
250
- description: 'Get trade history with filtering',
251
- inputSchema: {
252
- type: 'object',
253
- properties: {
254
- tokenName: TOKEN_NAME_SCHEMA,
255
- tradeType: {
256
- type: 'string',
257
- enum: ['BUY', 'SELL'],
258
- description: 'Filter by trade type',
259
- },
260
- userAddress: {
261
- ...ADDRESS_SCHEMA,
262
- description: 'Filter by user address',
263
- },
264
- page: PAGE_SCHEMA,
265
- limit: createLimitSchema('trade', 20),
266
- startDate: {
267
- ...DATE_TIME_SCHEMA,
268
- description: 'Filter by start date',
269
- },
270
- endDate: {
271
- ...DATE_TIME_SCHEMA,
272
- description: 'Filter by end date',
273
- },
274
- sortOrder: SORT_ORDER_SCHEMA,
275
- },
276
- },
277
- handler: withErrorHandling(async (sdk, args) => {
278
- const pagination = applyOperationPaginationDefaults(args, 'trade');
279
- const result = await sdk.fetchTrades({
280
- tokenName: args.tokenName,
281
- tradeType: args.tradeType,
282
- userAddress: args.userAddress,
283
- ...pagination,
284
- startDate: args.startDate,
285
- endDate: args.endDate,
286
- sortOrder: args.sortOrder || 'DESC',
287
- });
288
- return formatSuccess(result);
289
- }),
290
- };
291
-
292
- // 6. Calculate Initial Buy
293
- export const calculateInitialBuyTool: MCPTool = {
294
- name: 'gala_launchpad_calculate_initial_buy',
295
- description: 'Calculate amounts for initial token purchase during creation (pre-mint phase)',
296
- inputSchema: {
297
- type: 'object',
298
- properties: {
299
- amount: {
300
- ...DECIMAL_AMOUNT_SCHEMA,
301
- description: 'GALA amount to spend for initial buy (standard decimal format, e.g., "100" for 100 GALA)',
302
- },
303
- },
304
- required: ['amount'],
305
- },
306
- handler: withErrorHandling(async (sdk, args) => {
307
- const result = await sdk.calculateInitialBuyAmount(args.amount);
308
- return formatSuccess(result);
309
- }),
310
- };
311
-
312
- // 7. Get Bundler Transaction Result
313
- export const getBundlerTransactionResultTool: MCPTool = {
314
- name: 'gala_launchpad_get_bundler_transaction_result',
315
- description: `Get bundle transaction result by ID via HTTP (not WebSocket).
316
-
317
- Returns lightweight status: { id: string, method: string, status: string }
318
-
319
- Status values: "COMPLETED", "FAILED", "PENDING", "PROCESSING"
320
-
321
- Use cases:
322
- - Check transaction status when WebSocket times out
323
- - Get definitive transaction state
324
- - Verify trade/launch completion
325
-
326
- Note: This is a synchronous HTTP call, not WebSocket monitoring.`,
327
- inputSchema: {
328
- type: 'object',
329
- properties: {
330
- transactionId: TRANSACTION_ID_SCHEMA,
331
- },
332
- required: ['transactionId'],
333
- },
334
- handler: withErrorHandling(async (sdk, args) => {
335
- const result = await sdk.getBundlerTransactionResult(args.transactionId);
336
- return formatSuccess(result);
337
- }),
338
- };
339
-
340
- // 8. Calculate Buy Amount for Graduation
341
- export const calculateBuyAmountForGraduationTool: MCPTool = {
342
- name: 'gala_launchpad_calculate_buy_amount_for_graduation',
343
- description: `Calculate amount needed to graduate a token pool.
344
-
345
- Convenience method that:
346
- 1. Fetches pool details to get remaining tokens
347
- 2. Calls calculateBuyAmount with exact remaining amount
348
- 3. Returns standard AmountCalculationResult
349
-
350
- Performance optimization: Provide currentSupply to avoid fetching pool details twice.
351
-
352
- RETURNS: Same as calculateBuyAmount - complete cost breakdown including
353
- totalCost, amount, transactionFee, gasFee, reverseBondingCurveFee`,
354
- inputSchema: {
355
- type: 'object',
356
- properties: {
357
- tokenName: TOKEN_NAME_SCHEMA,
358
- calculateAmountMode: CALCULATION_MODE_SCHEMA,
359
- currentSupply: CURRENT_SUPPLY_SCHEMA,
360
- },
361
- required: ['tokenName'],
362
- },
363
- handler: withErrorHandling(async (sdk, args) => {
364
- // Build options object only if mode or supply provided
365
- const options = args.calculateAmountMode || args.currentSupply
366
- ? {
367
- tokenName: args.tokenName,
368
- calculateAmountMode: args.calculateAmountMode,
369
- currentSupply: args.currentSupply,
370
- }
371
- : args.tokenName;
372
-
373
- const result = await sdk.calculateBuyAmountForGraduation(options);
374
- return formatSuccess(result);
375
- }),
376
- };
377
-
378
- // 9. Graduate Token
379
- export const graduateTokenTool: MCPTool = {
380
- name: 'gala_launchpad_graduate_token',
381
- description: `Graduate a token pool by buying all remaining tokens in one transaction.
382
-
383
- WORKFLOW (automatic):
384
- 1. Calls calculateBuyAmountForGraduation() internally
385
- 2. Executes buy() with exact remaining token amount
386
- 3. Returns transaction result
387
-
388
- Performance optimization: Provide currentSupply to avoid fetching pool details twice.
389
-
390
- CRITICAL: This is a convenience method that combines multiple operations.
391
- Throws error if token is already graduated.
392
- slippageToleranceFactor is optional and uses SDK defaults if not provided.
393
-
394
- RETURNS: TradeResult with transaction details including amounts and transaction ID`,
395
- inputSchema: {
396
- type: 'object',
397
- properties: {
398
- tokenName: TOKEN_NAME_SCHEMA,
399
- slippageToleranceFactor: SLIPPAGE_TOLERANCE_SCHEMA,
400
- maxAcceptableReverseBondingCurveFeeSlippageFactor: RBC_FEE_SLIPPAGE_SCHEMA,
401
- privateKey: PRIVATE_KEY_SCHEMA,
402
- calculateAmountMode: CALCULATION_MODE_SCHEMA,
403
- currentSupply: CURRENT_SUPPLY_SCHEMA,
404
- },
405
- required: ['tokenName'], // Only tokenName is required
406
- },
407
- handler: withErrorHandling(async (sdk, args) => {
408
- const result = await sdk.graduateToken({
409
- tokenName: args.tokenName,
410
- slippageToleranceFactor: args.slippageToleranceFactor,
411
- maxAcceptableReverseBondingCurveFeeSlippageFactor: args.maxAcceptableReverseBondingCurveFeeSlippageFactor,
412
- privateKey: args.privateKey,
413
- calculateAmountMode: args.calculateAmountMode,
414
- currentSupply: args.currentSupply,
415
- });
416
- return formatSuccess(result);
417
- }),
418
- };
419
-
420
- // 10. Calculate Buy Amount (Local)
421
- export const calculateBuyAmountLocalTool: MCPTool = {
422
- name: 'gala_launchpad_calculate_buy_amount_local',
423
- description: `Calculate buy amounts using LOCAL bonding curve formulas (instant, no network call).
424
-
425
- Uses client-side exponential bonding curve calculations for instant quotes.
426
- Perfect for price discovery, UI updates, and offline scenarios.
427
-
428
- ACCURACY: Matches external calculations with <0.01% difference.
429
-
430
- RETURNS: { amount, reverseBondingCurveFee: "0", transactionFee, gasFee }`,
431
- inputSchema: {
432
- type: 'object',
433
- properties: {
434
- tokenName: TOKEN_NAME_SCHEMA,
435
- amount: {
436
- ...DECIMAL_AMOUNT_SCHEMA,
437
- description: 'Amount in standard decimal format (e.g., "1" for 1 GALA)',
438
- },
439
- type: {
440
- type: 'string',
441
- enum: Object.values(TRADING_TYPES),
442
- description: `Trade calculation type:
443
- - 'native': Spend GALA amount
444
- - 'exact': Buy exact token amount`,
445
- },
446
- },
447
- required: ['tokenName', 'amount', 'type'],
448
- },
449
- handler: withErrorHandling(async (sdk, args) => {
450
- const result = await sdk.calculateBuyAmountLocal({
451
- tokenName: args.tokenName,
452
- amount: args.amount,
453
- type: args.type,
454
- });
455
- return formatSuccess(result);
456
- }),
457
- };
458
-
459
- // 11. Calculate Buy Amount (External)
460
- export const calculateBuyAmountExternalTool: MCPTool = {
461
- name: 'gala_launchpad_calculate_buy_amount_external',
462
- description: `Calculate buy amounts using EXTERNAL GalaChain network call (real-time).
463
-
464
- Explicit external calculation - queries GalaChain network for real-time pricing.
465
- Identical to calculateBuyAmount but makes the network dependency explicit.
466
-
467
- RETURNS: { amount, reverseBondingCurveFee, transactionFee, gasFee }`,
468
- inputSchema: {
469
- type: 'object',
470
- properties: {
471
- tokenName: TOKEN_NAME_SCHEMA,
472
- amount: {
473
- ...DECIMAL_AMOUNT_SCHEMA,
474
- description: 'Amount in standard decimal format',
475
- },
476
- type: {
477
- type: 'string',
478
- enum: Object.values(TRADING_TYPES),
479
- description: `Trade calculation type:
480
- - 'native': Spend GALA amount
481
- - 'exact': Buy exact token amount`,
482
- },
483
- },
484
- required: ['tokenName', 'amount', 'type'],
485
- },
486
- handler: withErrorHandling(async (sdk, args) => {
487
- const result = await sdk.calculateBuyAmountExternal({
488
- tokenName: args.tokenName,
489
- amount: args.amount,
490
- type: args.type,
491
- });
492
- return formatSuccess(result);
493
- }),
494
- };
495
-
496
- // 12. Calculate Sell Amount (Local)
497
- export const calculateSellAmountLocalTool: MCPTool = {
498
- name: 'gala_launchpad_calculate_sell_amount_local',
499
- description: `Calculate sell amounts using LOCAL bonding curve formulas (instant, no network call).
500
-
501
- Uses client-side calculations with reverse bonding curve fee support.
502
- Requires pool details (maxSupply, fee parameters) to calculate accurately.
503
-
504
- ACCURACY: Matches external calculations with <0.01% difference.
505
-
506
- RETURNS: { amount, reverseBondingCurveFee, transactionFee, gasFee }`,
507
- inputSchema: {
508
- type: 'object',
509
- properties: {
510
- tokenName: TOKEN_NAME_SCHEMA,
511
- amount: {
512
- ...DECIMAL_AMOUNT_SCHEMA,
513
- description: 'Amount to sell/receive',
514
- },
515
- type: {
516
- type: 'string',
517
- enum: Object.values(TRADING_TYPES),
518
- description: `Trade calculation type:
519
- - 'native': Receive GALA amount
520
- - 'exact': Sell exact token amount`,
521
- },
522
- maxSupply: {
523
- ...DECIMAL_AMOUNT_SCHEMA,
524
- description: 'Token maximum supply (get from fetchPoolDetails)',
525
- },
526
- reverseBondingCurveMinFeeFactor: {
527
- type: 'number',
528
- minimum: 0,
529
- maximum: 1,
530
- description: 'Min reverse bonding curve fee factor (get from poolDetails.reverseBondingCurveMinFeeFactor)',
531
- },
532
- reverseBondingCurveMaxFeeFactor: {
533
- type: 'number',
534
- minimum: 0,
535
- maximum: 1,
536
- description: 'Max reverse bonding curve fee factor (get from poolDetails.reverseBondingCurveMaxFeeFactor)',
537
- },
538
- },
539
- required: ['tokenName', 'amount', 'type', 'maxSupply', 'reverseBondingCurveMinFeeFactor', 'reverseBondingCurveMaxFeeFactor'],
540
- },
541
- handler: withErrorHandling(async (sdk, args) => {
542
- const result = await sdk.calculateSellAmountLocal({
543
- tokenName: args.tokenName,
544
- amount: args.amount,
545
- type: args.type,
546
- maxSupply: args.maxSupply,
547
- reverseBondingCurveMinFeeFactor: args.reverseBondingCurveMinFeeFactor,
548
- reverseBondingCurveMaxFeeFactor: args.reverseBondingCurveMaxFeeFactor,
549
- });
550
- return formatSuccess(result);
551
- }),
552
- };
553
-
554
- // 13. Calculate Sell Amount (External)
555
- export const calculateSellAmountExternalTool: MCPTool = {
556
- name: 'gala_launchpad_calculate_sell_amount_external',
557
- description: `Calculate sell amounts using EXTERNAL GalaChain network call (real-time).
558
-
559
- Explicit external calculation - queries GalaChain network for real-time pricing.
560
- Identical to calculateSellAmount but makes the network dependency explicit.
561
-
562
- RETURNS: { amount, reverseBondingCurveFee, transactionFee, gasFee }`,
563
- inputSchema: {
564
- type: 'object',
565
- properties: {
566
- tokenName: TOKEN_NAME_SCHEMA,
567
- amount: {
568
- ...DECIMAL_AMOUNT_SCHEMA,
569
- description: 'Amount to sell/receive',
570
- },
571
- type: {
572
- type: 'string',
573
- enum: Object.values(TRADING_TYPES),
574
- description: `Trade calculation type:
575
- - 'native': Receive GALA amount
576
- - 'exact': Sell exact token amount`,
577
- },
578
- },
579
- required: ['tokenName', 'amount', 'type'],
580
- },
581
- handler: withErrorHandling(async (sdk, args) => {
582
- const result = await sdk.calculateSellAmountExternal({
583
- tokenName: args.tokenName,
584
- amount: args.amount,
585
- type: args.type,
586
- });
587
- return formatSuccess(result);
588
- }),
589
- };
590
-
591
- export const tradingTools: MCPTool[] = [
592
- calculateBuyAmountTool,
593
- calculateSellAmountTool,
594
- buyTokensTool,
595
- sellTokensTool,
596
- fetchTradesTool,
597
- calculateInitialBuyTool,
598
- getBundlerTransactionResultTool,
599
- calculateBuyAmountForGraduationTool,
600
- graduateTokenTool,
601
- calculateBuyAmountLocalTool,
602
- calculateBuyAmountExternalTool,
603
- calculateSellAmountLocalTool,
604
- calculateSellAmountExternalTool,
605
- ];
@@ -1,75 +0,0 @@
1
- /**
2
- * Token Transfer Tools
3
- */
4
-
5
- import type { MCPTool } from '../../types/mcp.js';
6
- import { formatSuccess } from '../../utils/response-formatter.js';
7
- import { withErrorHandling } from '../../utils/error-handler.js';
8
- import {
9
- ADDRESS_SCHEMA,
10
- TOKEN_NAME_SCHEMA,
11
- DECIMAL_AMOUNT_SCHEMA,
12
- INTEGER_AMOUNT_SCHEMA,
13
- UNIQUE_KEY_SCHEMA,
14
- PRIVATE_KEY_SCHEMA,
15
- } from '../../schemas/common-schemas.js';
16
-
17
- // 1. Transfer GALA
18
- export const transferGalaTool: MCPTool = {
19
- name: 'gala_launchpad_transfer_gala',
20
- description: 'Transfer GALA tokens via GalaChain',
21
- inputSchema: {
22
- type: 'object',
23
- properties: {
24
- recipientAddress: {
25
- ...ADDRESS_SCHEMA,
26
- description: 'Recipient wallet address',
27
- },
28
- amount: DECIMAL_AMOUNT_SCHEMA,
29
- uniqueKey: UNIQUE_KEY_SCHEMA,
30
- privateKey: PRIVATE_KEY_SCHEMA,
31
- },
32
- required: ['recipientAddress', 'amount'],
33
- },
34
- handler: withErrorHandling(async (sdk, args) => {
35
- const result = await sdk.transferGala({
36
- recipientAddress: args.recipientAddress,
37
- amount: args.amount,
38
- uniqueKey: args.uniqueKey,
39
- privateKey: args.privateKey,
40
- });
41
- return formatSuccess(result);
42
- }),
43
- };
44
-
45
- // 2. Transfer Token
46
- export const transferTokenTool: MCPTool = {
47
- name: 'gala_launchpad_transfer_token',
48
- description: 'Transfer launchpad tokens via GalaChain',
49
- inputSchema: {
50
- type: 'object',
51
- properties: {
52
- to: {
53
- ...ADDRESS_SCHEMA,
54
- description: 'Recipient wallet address',
55
- },
56
- tokenName: TOKEN_NAME_SCHEMA,
57
- amount: INTEGER_AMOUNT_SCHEMA,
58
- uniqueKey: UNIQUE_KEY_SCHEMA,
59
- privateKey: PRIVATE_KEY_SCHEMA,
60
- },
61
- required: ['to', 'tokenName', 'amount'],
62
- },
63
- handler: withErrorHandling(async (sdk, args) => {
64
- const result = await sdk.transferToken({
65
- to: args.to,
66
- tokenName: args.tokenName,
67
- amount: args.amount,
68
- uniqueKey: args.uniqueKey,
69
- privateKey: args.privateKey,
70
- });
71
- return formatSuccess(result);
72
- }),
73
- };
74
-
75
- export const transferTools: MCPTool[] = [transferGalaTool, transferTokenTool];