@gala-chain/launchpad-mcp-server 1.14.0 → 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/README.md +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/schemas/common-schemas.d.ts +1 -1
- package/dist/schemas/common-schemas.d.ts.map +1 -1
- package/dist/schemas/common-schemas.js +1 -0
- package/dist/schemas/common-schemas.js.map +1 -1
- package/dist/tools/pools/fetchPriceHistory.js +2 -2
- package/dist/tools/pools/fetchPriceHistory.js.map +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/dist/utils/constraints.d.ts +9 -3
- package/dist/utils/constraints.d.ts.map +1 -1
- package/dist/utils/constraints.js +9 -1
- package/dist/utils/constraints.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,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch All Pools Tool
|
|
3
|
+
*
|
|
4
|
+
* Convenience tool that fetches all available pools with automatic pagination.
|
|
5
|
+
* Equivalent to calling fetchPools with limit: 0.
|
|
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 fetchAllPoolsTool: MCPTool = {
|
|
13
|
+
name: 'gala_launchpad_fetch_all_pools',
|
|
14
|
+
description: 'Fetch all available pools with automatic pagination. No page/limit parameters needed - returns ALL pools matching filters.',
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
search: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
minLength: 1,
|
|
21
|
+
maxLength: 100,
|
|
22
|
+
description: 'Optional search query (fuzzy match filter)',
|
|
23
|
+
},
|
|
24
|
+
tokenName: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
minLength: 3,
|
|
27
|
+
maxLength: 20,
|
|
28
|
+
pattern: '^[a-zA-Z0-9]{3,20}$',
|
|
29
|
+
description: 'Optional token name (exact match filter)',
|
|
30
|
+
},
|
|
31
|
+
type: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
enum: ['recent', 'popular'],
|
|
34
|
+
description: 'Type of pools to fetch (default: recent)',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
handler: withErrorHandling(async (sdk, args) => {
|
|
39
|
+
const result = await sdk.fetchAllPools({
|
|
40
|
+
...(args.search && { search: args.search }),
|
|
41
|
+
...(args.tokenName && { tokenName: args.tokenName }),
|
|
42
|
+
...(args.type && { type: args.type }),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return formatSuccess(result);
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch All Price History Tool
|
|
3
|
+
*
|
|
4
|
+
* Queries all historical token price data from DEX Backend API with automatic pagination.
|
|
5
|
+
* Uses the /price-oracle/fetch-price endpoint for complete price history retrieval.
|
|
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 fetchAllPriceHistoryTool: MCPTool = {
|
|
13
|
+
name: 'gala_launchpad_fetch_all_price_history',
|
|
14
|
+
description: `Fetch all historical price snapshots for DEX tokens from the DEX Backend API with automatic pagination.
|
|
15
|
+
|
|
16
|
+
**Endpoint:** \`/price-oracle/fetch-price\`
|
|
17
|
+
|
|
18
|
+
**Requirements:**
|
|
19
|
+
- DEX Backend API must be configured (dexBackendBaseUrl in SDK config)
|
|
20
|
+
- Node.js environment only (not available in browser)
|
|
21
|
+
- Token parameter is required
|
|
22
|
+
|
|
23
|
+
**Use Cases:**
|
|
24
|
+
- Complete historical price analysis and charting
|
|
25
|
+
- Full price trend identification over time periods
|
|
26
|
+
- Comprehensive volatility analysis
|
|
27
|
+
- Data export for external analytics
|
|
28
|
+
|
|
29
|
+
**Performance:** API-based queries with automatic pagination (max 100 items per page, combined into single result).`,
|
|
30
|
+
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
tokenId: {
|
|
35
|
+
oneOf: [
|
|
36
|
+
{
|
|
37
|
+
type: 'string',
|
|
38
|
+
description:
|
|
39
|
+
'Pipe-delimited format: "collection|category|type|additionalKey" (e.g., "Token|Unit|GUSDC|eth:...")',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
type: 'object',
|
|
43
|
+
properties: {
|
|
44
|
+
collection: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
description: 'Token collection (e.g., "Token")',
|
|
47
|
+
},
|
|
48
|
+
category: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: 'Token category (e.g., "Unit")',
|
|
51
|
+
},
|
|
52
|
+
type: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'Token type (e.g., "GUSDC")',
|
|
55
|
+
},
|
|
56
|
+
additionalKey: {
|
|
57
|
+
type: 'string',
|
|
58
|
+
description: 'Additional key (e.g., "eth:0x...")',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
required: ['collection', 'category', 'type', 'additionalKey'],
|
|
62
|
+
description: 'TokenClassKey object format',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
description: 'Token identifier (string or TokenClassKey object)',
|
|
66
|
+
},
|
|
67
|
+
from: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
format: 'date-time',
|
|
70
|
+
description: 'Start date for filtering (ISO 8601 format, defaults to 30 days ago)',
|
|
71
|
+
},
|
|
72
|
+
to: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
format: 'date-time',
|
|
75
|
+
description: 'End date for filtering (ISO 8601 format, defaults to now)',
|
|
76
|
+
},
|
|
77
|
+
sortOrder: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
enum: ['ASC', 'DESC'],
|
|
80
|
+
description: 'Sort order for results (default: DESC for newest-first)',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
required: ['tokenId'],
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
handler: withErrorHandling(async (sdk, args) => {
|
|
87
|
+
// Convert string dates to Date objects if provided
|
|
88
|
+
const options: any = {
|
|
89
|
+
tokenId: args.tokenId,
|
|
90
|
+
sortOrder: args.sortOrder,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
if (args.from) {
|
|
94
|
+
options.from = new Date(args.from);
|
|
95
|
+
}
|
|
96
|
+
if (args.to) {
|
|
97
|
+
options.to = new Date(args.to);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const result = await sdk.fetchAllPriceHistory(options);
|
|
101
|
+
return formatSuccess(result);
|
|
102
|
+
}),
|
|
103
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch Pool Details Tool
|
|
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
|
+
|
|
9
|
+
export const fetchPoolDetailsTool: MCPTool = {
|
|
10
|
+
name: 'gala_launchpad_fetch_pool_details',
|
|
11
|
+
description: 'Get detailed pool state from GalaChain bonding curve',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
tokenName: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
pattern: '^[a-z0-9_-]{2,20}$',
|
|
18
|
+
description: 'Token name',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
required: ['tokenName'],
|
|
22
|
+
},
|
|
23
|
+
handler: withErrorHandling(async (sdk, args) => {
|
|
24
|
+
const result = await sdk.fetchPoolDetails(args.tokenName);
|
|
25
|
+
return formatSuccess(result);
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch Pool Details for Calculation Tool (73% code reduction via factory pattern)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { createSimpleTokenFetchTool } from '../../utils/tool-factory.js';
|
|
6
|
+
|
|
7
|
+
export const fetchPoolDetailsForCalculationTool = createSimpleTokenFetchTool({
|
|
8
|
+
name: 'gala_launchpad_fetch_pool_details_for_calculation',
|
|
9
|
+
description: `Get optimized pool details for local bonding curve calculations.
|
|
10
|
+
|
|
11
|
+
Returns only essential calculation parameters:
|
|
12
|
+
- currentSupply: Current token supply (computed with full precision)
|
|
13
|
+
- remainingTokens: Tokens available for purchase
|
|
14
|
+
- maxSupply: Maximum token supply
|
|
15
|
+
- reverseBondingCurveMaxFeeFactor: Maximum reverse bonding curve fee (normalized to number)
|
|
16
|
+
- reverseBondingCurveMinFeeFactor: Minimum reverse bonding curve fee (normalized to number)
|
|
17
|
+
- reverseBondingCurveNetFeeFactor: Net fee factor (max - min, for convenience)
|
|
18
|
+
|
|
19
|
+
This is more efficient than fetchPoolDetails as it returns only fields needed for calculations.
|
|
20
|
+
Perfect for use with calculateBuyAmountLocal and calculateSellAmountLocal.`,
|
|
21
|
+
handler: (sdk, tokenName) => sdk.fetchPoolDetailsForCalculation(tokenName),
|
|
22
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch Pools Tool
|
|
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
|
+
|
|
9
|
+
export const fetchPoolsTool: MCPTool = {
|
|
10
|
+
name: 'gala_launchpad_fetch_pools',
|
|
11
|
+
description: 'Fetch token pools from Gala Launchpad with filtering and pagination',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
type: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
enum: ['recent', 'trending', 'user'],
|
|
18
|
+
description: 'Type of pools to fetch (default: recent)',
|
|
19
|
+
},
|
|
20
|
+
creatorAddress: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
pattern: '^(0x[a-fA-F0-9]{40}|eth\\|[a-fA-F0-9]{40})$',
|
|
23
|
+
description: 'Filter by creator address (optional)',
|
|
24
|
+
},
|
|
25
|
+
page: {
|
|
26
|
+
type: 'number',
|
|
27
|
+
minimum: 1,
|
|
28
|
+
description: 'Page number (default: 1)',
|
|
29
|
+
},
|
|
30
|
+
limit: {
|
|
31
|
+
type: 'number',
|
|
32
|
+
minimum: 1,
|
|
33
|
+
maximum: 100,
|
|
34
|
+
description: 'Results per page (default: 20)',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
handler: withErrorHandling(async (sdk, args) => {
|
|
39
|
+
const result = await sdk.fetchPools({
|
|
40
|
+
type: args.type || 'recent',
|
|
41
|
+
page: args.page || 1,
|
|
42
|
+
limit: args.limit || 20,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return formatSuccess(result);
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch Price History Tool
|
|
3
|
+
*
|
|
4
|
+
* Queries historical token price data from DEX Backend API.
|
|
5
|
+
* Uses the /price-oracle/fetch-price endpoint for paginated price history retrieval.
|
|
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
|
+
import { PAGE_SCHEMA, createLimitSchema } from '../../schemas/common-schemas.js';
|
|
12
|
+
|
|
13
|
+
export const fetchPriceHistoryTool: MCPTool = {
|
|
14
|
+
name: 'gala_launchpad_fetch_price_history',
|
|
15
|
+
description: `Fetch historical price snapshots for DEX tokens from the DEX Backend API.
|
|
16
|
+
|
|
17
|
+
**Endpoint:** \`/price-oracle/fetch-price\`
|
|
18
|
+
|
|
19
|
+
**Requirements:**
|
|
20
|
+
- DEX Backend API must be configured (dexBackendBaseUrl in SDK config)
|
|
21
|
+
- Node.js environment only (not available in browser)
|
|
22
|
+
- Token parameter is required
|
|
23
|
+
|
|
24
|
+
**Use Cases:**
|
|
25
|
+
- Historical price analysis and charting
|
|
26
|
+
- Price trend identification
|
|
27
|
+
- Volatility analysis over time periods
|
|
28
|
+
- Data export for external analytics
|
|
29
|
+
|
|
30
|
+
**Performance:** API-based queries with pagination support (max 50 items per page).`,
|
|
31
|
+
|
|
32
|
+
inputSchema: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: {
|
|
35
|
+
tokenId: {
|
|
36
|
+
oneOf: [
|
|
37
|
+
{
|
|
38
|
+
type: 'string',
|
|
39
|
+
description:
|
|
40
|
+
'Pipe-delimited format: "collection|category|type|additionalKey" (e.g., "Token|Unit|GUSDC|eth:...")',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: 'object',
|
|
44
|
+
properties: {
|
|
45
|
+
collection: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
description: 'Token collection (e.g., "Token")',
|
|
48
|
+
},
|
|
49
|
+
category: {
|
|
50
|
+
type: 'string',
|
|
51
|
+
description: 'Token category (e.g., "Unit")',
|
|
52
|
+
},
|
|
53
|
+
type: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
description: 'Token type (e.g., "GUSDC")',
|
|
56
|
+
},
|
|
57
|
+
additionalKey: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
description: 'Additional key (e.g., "eth:0x...")',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
required: ['collection', 'category', 'type', 'additionalKey'],
|
|
63
|
+
description: 'TokenClassKey object format',
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
description: 'Token identifier (string or TokenClassKey object)',
|
|
67
|
+
},
|
|
68
|
+
from: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
format: 'date-time',
|
|
71
|
+
description: 'Start date for filtering (ISO 8601 format, defaults to 30 days ago)',
|
|
72
|
+
},
|
|
73
|
+
to: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
format: 'date-time',
|
|
76
|
+
description: 'End date for filtering (ISO 8601 format, defaults to now)',
|
|
77
|
+
},
|
|
78
|
+
sortOrder: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
enum: ['ASC', 'DESC'],
|
|
81
|
+
description: 'Sort order for results (default: DESC for newest-first)',
|
|
82
|
+
},
|
|
83
|
+
page: PAGE_SCHEMA,
|
|
84
|
+
limit: createLimitSchema('priceHistory', 10),
|
|
85
|
+
},
|
|
86
|
+
required: ['tokenId'],
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
handler: withErrorHandling(async (sdk, args) => {
|
|
90
|
+
// Convert string dates to Date objects if provided
|
|
91
|
+
const options: any = {
|
|
92
|
+
tokenId: args.tokenId,
|
|
93
|
+
sortOrder: args.sortOrder,
|
|
94
|
+
page: args.page,
|
|
95
|
+
limit: args.limit,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
if (args.from) {
|
|
99
|
+
options.from = new Date(args.from);
|
|
100
|
+
}
|
|
101
|
+
if (args.to) {
|
|
102
|
+
options.to = new Date(args.to);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const result = await sdk.fetchPriceHistory(options);
|
|
106
|
+
return formatSuccess(result);
|
|
107
|
+
}),
|
|
108
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch Token Details Tool
|
|
3
|
+
*
|
|
4
|
+
* Queries the DEX API platform endpoint to retrieve comprehensive token metadata
|
|
5
|
+
* including image, decimals, description, verification status, network information,
|
|
6
|
+
* and trading capabilities.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { MCPTool } from '../../types/mcp.js';
|
|
10
|
+
import { formatSuccess } from '../../utils/response-formatter.js';
|
|
11
|
+
import { withErrorHandling } from '../../utils/error-handler.js';
|
|
12
|
+
|
|
13
|
+
export const fetchTokenDetailsTool: MCPTool = {
|
|
14
|
+
name: 'gala_launchpad_fetch_token_details',
|
|
15
|
+
description: `Fetch comprehensive token details from DEX API platform
|
|
16
|
+
|
|
17
|
+
**Endpoint:** \`/v1/tokens?tokenclasskeys=...\`
|
|
18
|
+
|
|
19
|
+
**Requirements:**
|
|
20
|
+
- DEX API platform must be configured (dexApiHttp client)
|
|
21
|
+
- Token identifier required in flexible format (string or object)
|
|
22
|
+
|
|
23
|
+
**Use Cases:**
|
|
24
|
+
- Retrieve complete token metadata and information
|
|
25
|
+
- Verify token specifications (decimals, symbol, description)
|
|
26
|
+
- Check verification status and trading capabilities
|
|
27
|
+
- Access token image and network information
|
|
28
|
+
- Analyze token details before trading
|
|
29
|
+
|
|
30
|
+
**Flexible Token Identification:**
|
|
31
|
+
Supports both pipe-delimited string and object formats for maximum flexibility.`,
|
|
32
|
+
|
|
33
|
+
inputSchema: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
tokenId: {
|
|
37
|
+
oneOf: [
|
|
38
|
+
{
|
|
39
|
+
type: 'string',
|
|
40
|
+
description:
|
|
41
|
+
'Pipe-delimited format: "collection|category|type|additionalKey" (e.g., "Token|Unit|GUSDC|eth:0x...")',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
collection: {
|
|
47
|
+
type: 'string',
|
|
48
|
+
description: 'Token collection (e.g., "Token")',
|
|
49
|
+
},
|
|
50
|
+
category: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
description: 'Token category (e.g., "Unit")',
|
|
53
|
+
},
|
|
54
|
+
type: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
description: 'Token type (e.g., "GUSDC")',
|
|
57
|
+
},
|
|
58
|
+
additionalKey: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
description: 'Additional key (e.g., "eth:0x...")',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
required: ['collection', 'category', 'type', 'additionalKey'],
|
|
64
|
+
description: 'TokenClassKey object format',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
description: 'Token identifier in flexible format (string or object)',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
required: ['tokenId'],
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
handler: withErrorHandling(async (sdk, args) => {
|
|
74
|
+
const result = await sdk.fetchTokenDetails(args.tokenId);
|
|
75
|
+
return formatSuccess(result);
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pool Management Tools
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { POOL_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
|
+
TOKEN_SYMBOL_SCHEMA,
|
|
12
|
+
ADDRESS_SCHEMA,
|
|
13
|
+
PAGE_SCHEMA,
|
|
14
|
+
createLimitSchema,
|
|
15
|
+
CALCULATION_MODE_SCHEMA,
|
|
16
|
+
CURRENT_SUPPLY_SCHEMA,
|
|
17
|
+
} from '../../schemas/common-schemas.js';
|
|
18
|
+
import { fetchPoolDetailsForCalculationTool } from './fetchPoolDetailsForCalculation.js';
|
|
19
|
+
import { fetchAllPoolsTool } from './fetchAllPools.js';
|
|
20
|
+
import { fetchPriceHistoryTool } from './fetchPriceHistory.js';
|
|
21
|
+
import { fetchAllPriceHistoryTool } from './fetchAllPriceHistory.js';
|
|
22
|
+
import { fetchTokenDetailsTool } from './fetchTokenDetails.js';
|
|
23
|
+
import {
|
|
24
|
+
createSimpleTokenFetchTool,
|
|
25
|
+
createBooleanCheckTool,
|
|
26
|
+
createResolutionTool,
|
|
27
|
+
createNoParamTool,
|
|
28
|
+
} from '../../utils/tool-factory.js';
|
|
29
|
+
import { resolutionToSeconds, dateToUnixTimestamp, DEFAULT_VOLUME_RESOLUTION } from '../../utils/default-values.js';
|
|
30
|
+
|
|
31
|
+
// 1. Fetch Pools
|
|
32
|
+
export const fetchPoolsTool: MCPTool = {
|
|
33
|
+
name: 'gala_launchpad_fetch_pools',
|
|
34
|
+
description: 'Fetch token pools from Gala Launchpad with filtering and pagination',
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
type: {
|
|
39
|
+
type: 'string',
|
|
40
|
+
enum: Object.values(POOL_TYPES),
|
|
41
|
+
description: 'Type of pools to fetch (default: recent)',
|
|
42
|
+
},
|
|
43
|
+
creatorAddress: {
|
|
44
|
+
...ADDRESS_SCHEMA,
|
|
45
|
+
description: 'Filter by creator address (optional)',
|
|
46
|
+
},
|
|
47
|
+
page: PAGE_SCHEMA,
|
|
48
|
+
limit: createLimitSchema('pool', 20),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
handler: withErrorHandling(async (sdk, args) => {
|
|
52
|
+
const result = await sdk.fetchPools({
|
|
53
|
+
type: args.type || 'recent',
|
|
54
|
+
page: args.page || 1,
|
|
55
|
+
limit: args.limit || 20,
|
|
56
|
+
});
|
|
57
|
+
return formatSuccess(result);
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// 2. Fetch Pool Details (73% code reduction via factory pattern)
|
|
62
|
+
export const fetchPoolDetailsTool = createSimpleTokenFetchTool({
|
|
63
|
+
name: 'gala_launchpad_fetch_pool_details',
|
|
64
|
+
description: 'Get detailed pool state from GalaChain bonding curve',
|
|
65
|
+
handler: (sdk, tokenName) => sdk.fetchPoolDetails(tokenName),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// 3. Fetch Token Distribution (73% code reduction via factory pattern)
|
|
69
|
+
export const fetchTokenDistributionTool = createSimpleTokenFetchTool({
|
|
70
|
+
name: 'gala_launchpad_fetch_token_distribution',
|
|
71
|
+
description: 'Get holder distribution and supply metrics',
|
|
72
|
+
handler: (sdk, tokenName) => sdk.fetchTokenDistribution(tokenName),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// 4. Fetch Token Badges (73% code reduction via factory pattern)
|
|
76
|
+
export const fetchTokenBadgesTool = createSimpleTokenFetchTool({
|
|
77
|
+
name: 'gala_launchpad_fetch_token_badges',
|
|
78
|
+
description: 'Get achievement badges for volume and engagement',
|
|
79
|
+
handler: (sdk, tokenName) => sdk.fetchTokenBadges(tokenName),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// 5. Fetch Volume Data (using centralized default values utilities)
|
|
83
|
+
export const fetchVolumeDataTool: MCPTool = {
|
|
84
|
+
name: 'gala_launchpad_fetch_volume_data',
|
|
85
|
+
description: 'Get OHLCV (candlestick) data for charting',
|
|
86
|
+
inputSchema: {
|
|
87
|
+
type: 'object',
|
|
88
|
+
properties: {
|
|
89
|
+
tokenName: TOKEN_NAME_SCHEMA,
|
|
90
|
+
from: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
format: 'date-time',
|
|
93
|
+
description: 'Start date (ISO 8601)',
|
|
94
|
+
},
|
|
95
|
+
to: {
|
|
96
|
+
type: 'string',
|
|
97
|
+
format: 'date-time',
|
|
98
|
+
description: 'End date (ISO 8601)',
|
|
99
|
+
},
|
|
100
|
+
resolution: {
|
|
101
|
+
type: 'string',
|
|
102
|
+
enum: ['1m', '5m', '15m', '1h', '4h', '1d'],
|
|
103
|
+
description: 'Time resolution (default: 1h)',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
required: ['tokenName'],
|
|
107
|
+
},
|
|
108
|
+
handler: withErrorHandling(async (sdk, args) => {
|
|
109
|
+
const result = await sdk.fetchVolumeData({
|
|
110
|
+
tokenName: args.tokenName,
|
|
111
|
+
from: dateToUnixTimestamp(args.from),
|
|
112
|
+
to: dateToUnixTimestamp(args.to),
|
|
113
|
+
resolution: resolutionToSeconds(args.resolution, DEFAULT_VOLUME_RESOLUTION),
|
|
114
|
+
});
|
|
115
|
+
return formatSuccess(result);
|
|
116
|
+
}),
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// 6. Fetch Token Spot Price (General DEX Tokens)
|
|
120
|
+
export const fetchTokenSpotPriceTool: MCPTool = {
|
|
121
|
+
name: 'gala_launchpad_fetch_token_spot_price',
|
|
122
|
+
description: 'Fetch USD spot price for DEX tokens (GALA, SILK, MUSIC, etc.)',
|
|
123
|
+
inputSchema: {
|
|
124
|
+
type: 'object',
|
|
125
|
+
properties: {
|
|
126
|
+
symbols: {
|
|
127
|
+
oneOf: [
|
|
128
|
+
{ type: 'string' },
|
|
129
|
+
{
|
|
130
|
+
type: 'array',
|
|
131
|
+
items: { type: 'string' },
|
|
132
|
+
minItems: 1
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
description: 'Single symbol string or array of symbols (e.g., "GALA" or ["GALA", "SILK", "MUSIC"])',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
required: ['symbols'],
|
|
139
|
+
},
|
|
140
|
+
handler: withErrorHandling(async (sdk, args) => {
|
|
141
|
+
const result = await sdk.fetchTokenSpotPrice(args.symbols);
|
|
142
|
+
return formatSuccess(result);
|
|
143
|
+
}),
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// 7. Fetch GALA Spot Price (45% code reduction via factory pattern)
|
|
147
|
+
export const fetchGalaSpotPriceTool = createNoParamTool({
|
|
148
|
+
name: 'gala_launchpad_fetch_gala_spot_price',
|
|
149
|
+
description: 'Fetch current GALA USD spot price (convenience method)',
|
|
150
|
+
handler: (sdk) => sdk.fetchGalaSpotPrice(),
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// 8. Fetch Launchpad Token Spot Price
|
|
154
|
+
export const fetchLaunchpadTokenSpotPriceTool: MCPTool = {
|
|
155
|
+
name: 'gala_launchpad_fetch_launchpad_token_spot_price',
|
|
156
|
+
description: `Fetch USD spot price for a launchpad token by name.
|
|
157
|
+
|
|
158
|
+
Performance optimization: Provide currentSupply to avoid fetching pool details twice.`,
|
|
159
|
+
inputSchema: {
|
|
160
|
+
type: 'object',
|
|
161
|
+
properties: {
|
|
162
|
+
tokenName: {
|
|
163
|
+
...TOKEN_NAME_SCHEMA,
|
|
164
|
+
description: 'Token name (e.g., "dragnrkti", "rocketri", "unicornri")',
|
|
165
|
+
},
|
|
166
|
+
calculateAmountMode: CALCULATION_MODE_SCHEMA,
|
|
167
|
+
currentSupply: CURRENT_SUPPLY_SCHEMA,
|
|
168
|
+
},
|
|
169
|
+
required: ['tokenName'],
|
|
170
|
+
},
|
|
171
|
+
handler: withErrorHandling(async (sdk, args) => {
|
|
172
|
+
// Build options object only if mode or supply provided
|
|
173
|
+
const options = args.calculateAmountMode || args.currentSupply
|
|
174
|
+
? {
|
|
175
|
+
tokenName: args.tokenName,
|
|
176
|
+
calculateAmountMode: args.calculateAmountMode,
|
|
177
|
+
currentSupply: args.currentSupply,
|
|
178
|
+
}
|
|
179
|
+
: args.tokenName;
|
|
180
|
+
|
|
181
|
+
const result = await sdk.fetchLaunchpadTokenSpotPrice(options);
|
|
182
|
+
return formatSuccess(result);
|
|
183
|
+
}),
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// 9. Check Token Name (60% code reduction via factory pattern)
|
|
187
|
+
export const checkTokenNameTool = createBooleanCheckTool({
|
|
188
|
+
name: 'gala_launchpad_check_token_name',
|
|
189
|
+
description: 'Check if token name is available',
|
|
190
|
+
paramName: 'tokenName',
|
|
191
|
+
paramSchema: TOKEN_NAME_SCHEMA,
|
|
192
|
+
handler: (sdk, tokenName) => sdk.isTokenNameAvailable(tokenName),
|
|
193
|
+
messages: {
|
|
194
|
+
true: 'Token name is available',
|
|
195
|
+
false: 'Token name is already taken',
|
|
196
|
+
},
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// 10. Check Token Symbol (60% code reduction via factory pattern)
|
|
200
|
+
export const checkTokenSymbolTool = createBooleanCheckTool({
|
|
201
|
+
name: 'gala_launchpad_check_token_symbol',
|
|
202
|
+
description: 'Check if token symbol is available',
|
|
203
|
+
paramName: 'symbol',
|
|
204
|
+
paramSchema: TOKEN_SYMBOL_SCHEMA,
|
|
205
|
+
handler: (sdk, symbol) => sdk.isTokenSymbolAvailable(symbol),
|
|
206
|
+
messages: {
|
|
207
|
+
true: 'Token symbol is available',
|
|
208
|
+
false: 'Token symbol is already taken',
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// 11. Resolve Vault Address (73% code reduction via factory pattern)
|
|
213
|
+
export const resolveVaultAddressTool = createResolutionTool({
|
|
214
|
+
name: 'gala_launchpad_resolve_vault_address',
|
|
215
|
+
description: 'Get GalaChain vault address for a token (useful for debugging)',
|
|
216
|
+
resolver: (sdk, tokenName) => sdk.resolveVaultAddress(tokenName),
|
|
217
|
+
resultKey: 'vaultAddress',
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// 12. Resolve Token Class Key (73% code reduction via factory pattern)
|
|
221
|
+
export const resolveTokenClassKeyTool = createResolutionTool({
|
|
222
|
+
name: 'gala_launchpad_resolve_token_class_key',
|
|
223
|
+
description: 'Get GalaChain TokenClassKey for a launchpad token (useful for direct GalaChain operations)',
|
|
224
|
+
resolver: (sdk, tokenName) => sdk.resolveTokenClassKey(tokenName),
|
|
225
|
+
resultKey: 'tokenClassKey',
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
export const poolTools: MCPTool[] = [
|
|
229
|
+
fetchPoolsTool,
|
|
230
|
+
fetchAllPoolsTool,
|
|
231
|
+
fetchPoolDetailsTool,
|
|
232
|
+
fetchPoolDetailsForCalculationTool,
|
|
233
|
+
fetchTokenDetailsTool,
|
|
234
|
+
fetchTokenDistributionTool,
|
|
235
|
+
fetchTokenBadgesTool,
|
|
236
|
+
fetchVolumeDataTool,
|
|
237
|
+
fetchTokenSpotPriceTool,
|
|
238
|
+
fetchGalaSpotPriceTool,
|
|
239
|
+
fetchLaunchpadTokenSpotPriceTool,
|
|
240
|
+
fetchPriceHistoryTool,
|
|
241
|
+
fetchAllPriceHistoryTool,
|
|
242
|
+
checkTokenNameTool,
|
|
243
|
+
checkTokenSymbolTool,
|
|
244
|
+
resolveVaultAddressTool,
|
|
245
|
+
resolveTokenClassKeyTool,
|
|
246
|
+
];
|