UNPKG

@gala-chain/launchpad-mcp-server

Version:

MCP server for Gala Launchpad - 102 tools (pool management, event watchers, GSwap DEX trading, price history, token creation, wallet management, DEX pool discovery, liquidity positions, token locks, locked token queries, composite pool data, cross-chain b

262 lines (259 loc) 12.2 kB
"use strict"; /** * Pool Management Tools */ Object.defineProperty(exports, "__esModule", { value: true }); exports.poolTools = exports.resolveTokenClassKeyTool = exports.resolveVaultAddressTool = exports.checkTokenSymbolTool = exports.checkTokenNameTool = exports.fetchLaunchpadTokenSpotPriceTool = exports.fetchGalaPriceTool = exports.fetchTokenPriceTool = exports.fetchVolumeDataTool = exports.fetchTokenBadgesTool = exports.fetchTokenDistributionTool = exports.fetchPoolDetailsTool = exports.fetchPoolsTool = void 0; const launchpad_sdk_1 = require("@gala-chain/launchpad-sdk"); const response_formatter_js_1 = require("../../utils/response-formatter.js"); const error_handler_js_1 = require("../../utils/error-handler.js"); const common_schemas_js_1 = require("../../schemas/common-schemas.js"); const fetchPoolDetailsForCalculation_js_1 = require("./fetchPoolDetailsForCalculation.js"); const fetchAllPools_js_1 = require("./fetchAllPools.js"); const fetchPriceHistory_js_1 = require("./fetchPriceHistory.js"); const fetchAllPriceHistory_js_1 = require("./fetchAllPriceHistory.js"); const fetchTokenDetails_js_1 = require("./fetchTokenDetails.js"); const onDexPoolCreation_js_1 = require("./onDexPoolCreation.js"); const onLaunchpadTokenCreation_js_1 = require("./onLaunchpadTokenCreation.js"); const tool_factory_js_1 = require("../../utils/tool-factory.js"); const default_values_js_1 = require("../../utils/default-values.js"); // 1. Fetch Pools exports.fetchPoolsTool = { name: 'gala_launchpad_fetch_pools', description: 'Fetch token pools from Gala Launchpad with filtering and pagination', inputSchema: { type: 'object', properties: { type: { type: 'string', enum: Object.values(launchpad_sdk_1.POOL_TYPES), description: 'Type of pools to fetch (default: recent)', }, creatorAddress: { ...common_schemas_js_1.ADDRESS_SCHEMA, description: 'Filter by creator address (optional)', }, page: common_schemas_js_1.PAGE_SCHEMA, limit: (0, common_schemas_js_1.createLimitSchema)('pool', 20), }, }, handler: (0, error_handler_js_1.withErrorHandling)(async (sdk, args) => { const result = await sdk.fetchPools({ type: args.type || 'recent', page: args.page || 1, limit: args.limit || 20, }); return (0, response_formatter_js_1.formatSuccess)(result); }), }; // 2. Fetch Pool Details (73% code reduction via factory pattern) exports.fetchPoolDetailsTool = (0, tool_factory_js_1.createSimpleTokenFetchTool)({ name: 'gala_launchpad_fetch_pool_details', description: 'Get detailed pool state from GalaChain bonding curve', handler: (sdk, tokenName) => sdk.fetchPoolDetails(tokenName), }); // 3. Fetch Token Distribution (73% code reduction via factory pattern) exports.fetchTokenDistributionTool = (0, tool_factory_js_1.createSimpleTokenFetchTool)({ name: 'gala_launchpad_fetch_token_distribution', description: 'Get holder distribution and supply metrics', handler: (sdk, tokenName) => sdk.fetchTokenDistribution(tokenName), }); // 4. Fetch Token Badges (73% code reduction via factory pattern) exports.fetchTokenBadgesTool = (0, tool_factory_js_1.createSimpleTokenFetchTool)({ name: 'gala_launchpad_fetch_token_badges', description: 'Get achievement badges for volume and engagement', handler: (sdk, tokenName) => sdk.fetchTokenBadges(tokenName), }); // 5. Fetch Volume Data (using centralized default values utilities) exports.fetchVolumeDataTool = { name: 'gala_launchpad_fetch_volume_data', description: 'Get OHLCV (candlestick) data for charting', inputSchema: { type: 'object', properties: { tokenName: common_schemas_js_1.TOKEN_NAME_SCHEMA, from: { type: 'string', format: 'date-time', description: 'Start date (ISO 8601)', }, to: { type: 'string', format: 'date-time', description: 'End date (ISO 8601)', }, resolution: { type: 'string', enum: ['1m', '5m', '15m', '1h', '4h', '1d'], description: 'Time resolution (default: 1h)', }, }, required: ['tokenName'], }, handler: (0, error_handler_js_1.withErrorHandling)(async (sdk, args) => { const result = await sdk.fetchVolumeData({ tokenName: args.tokenName, from: (0, default_values_js_1.dateToUnixTimestamp)(args.from), to: (0, default_values_js_1.dateToUnixTimestamp)(args.to), resolution: (0, default_values_js_1.resolutionToSeconds)(args.resolution, default_values_js_1.DEFAULT_VOLUME_RESOLUTION), }); return (0, response_formatter_js_1.formatSuccess)(result); }), }; // 6. Fetch Token Spot Price (Smart Router - Launchpad or DEX) exports.fetchTokenPriceTool = { name: 'gala_launchpad_fetch_token_spot_price', description: `Fetch USD spot price for ANY token with smart routing Routes to the correct backend automatically: - **tokenName** → Launchpad token (detects graduation status) - **tokenId** → DEX token via /v1/trade/price endpoint`, inputSchema: { type: 'object', properties: { tokenName: { ...common_schemas_js_1.TOKEN_NAME_SCHEMA, description: 'Launchpad token name (e.g., "galadog", "anime") - auto-detects graduation status', }, tokenId: { oneOf: [ { type: 'string', description: 'Pipe-delimited format: "collection|category|type|additionalKey" (e.g., "GUSDC|Unit|none|eth:0x...")', }, { type: 'object', properties: { collection: { type: 'string', description: 'Token collection (e.g., "Token")', }, category: { type: 'string', description: 'Token category (e.g., "Unit")', }, type: { type: 'string', description: 'Token type (e.g., "GUSDC")', }, additionalKey: { type: 'string', description: 'Additional key (e.g., "eth:0x...")', }, }, required: ['collection', 'category', 'type', 'additionalKey'], description: 'TokenClassKey object format', }, ], description: 'DEX token identifier in flexible format (string or object)', }, currentSupply: common_schemas_js_1.CURRENT_SUPPLY_SCHEMA, calculateAmountMode: common_schemas_js_1.CALCULATION_MODE_SCHEMA, }, }, handler: (0, error_handler_js_1.withErrorHandling)(async (sdk, args) => { const result = await sdk.fetchTokenPrice({ tokenName: args.tokenName, tokenId: args.tokenId, currentSupply: args.currentSupply, calculateAmountMode: args.calculateAmountMode, }); return (0, response_formatter_js_1.formatSuccess)(result); }), }; // 7. Fetch GALA Spot Price (45% code reduction via factory pattern) exports.fetchGalaPriceTool = (0, tool_factory_js_1.createNoParamTool)({ name: 'gala_launchpad_fetch_gala_spot_price', description: 'Fetch current GALA USD spot price (convenience method)', handler: (sdk) => sdk.fetchGalaPrice(), }); // 8. Fetch Launchpad Token Spot Price (DEPRECATED) exports.fetchLaunchpadTokenSpotPriceTool = { name: 'gala_launchpad_fetch_launchpad_token_spot_price', description: `⚠️ **DEPRECATED** - Use gala_launchpad_fetch_token_spot_price with { tokenName } instead. Will be removed in v4.0.0. Fetch USD spot price for a launchpad token by name. Performance optimization: Provide currentSupply to avoid fetching pool details twice.`, inputSchema: { type: 'object', properties: { tokenName: { ...common_schemas_js_1.TOKEN_NAME_SCHEMA, description: 'Token name (e.g., "dragnrkti", "rocketri", "unicornri")', }, calculateAmountMode: common_schemas_js_1.CALCULATION_MODE_SCHEMA, currentSupply: common_schemas_js_1.CURRENT_SUPPLY_SCHEMA, }, required: ['tokenName'], }, handler: (0, error_handler_js_1.withErrorHandling)(async (sdk, args) => { // Build options object only if mode or supply provided const options = args.calculateAmountMode || args.currentSupply ? { tokenName: args.tokenName, calculateAmountMode: args.calculateAmountMode, currentSupply: args.currentSupply, } : args.tokenName; const result = await sdk.fetchLaunchpadTokenSpotPrice(options); return (0, response_formatter_js_1.formatSuccess)(result); }), }; // 9. Check Token Name (60% code reduction via factory pattern) exports.checkTokenNameTool = (0, tool_factory_js_1.createBooleanCheckTool)({ name: 'gala_launchpad_check_token_name', description: 'Check if token name is available', paramName: 'tokenName', paramSchema: common_schemas_js_1.TOKEN_NAME_SCHEMA, handler: (sdk, tokenName) => sdk.isTokenNameAvailable(tokenName), messages: { true: 'Token name is available', false: 'Token name is already taken', }, }); // 10. Check Token Symbol (60% code reduction via factory pattern) exports.checkTokenSymbolTool = (0, tool_factory_js_1.createBooleanCheckTool)({ name: 'gala_launchpad_check_token_symbol', description: 'Check if token symbol is available', paramName: 'symbol', paramSchema: common_schemas_js_1.TOKEN_SYMBOL_SCHEMA, handler: (sdk, symbol) => sdk.isTokenSymbolAvailable(symbol), messages: { true: 'Token symbol is available', false: 'Token symbol is already taken', }, }); // 11. Resolve Vault Address (73% code reduction via factory pattern) exports.resolveVaultAddressTool = (0, tool_factory_js_1.createResolutionTool)({ name: 'gala_launchpad_resolve_vault_address', description: 'Get GalaChain vault address for a token (useful for debugging)', resolver: (sdk, tokenName) => sdk.resolveVaultAddress(tokenName), resultKey: 'vaultAddress', }); // 12. Resolve Token Class Key (73% code reduction via factory pattern) exports.resolveTokenClassKeyTool = (0, tool_factory_js_1.createResolutionTool)({ name: 'gala_launchpad_resolve_token_class_key', description: 'Get GalaChain TokenClassKey for a launchpad token (useful for direct GalaChain operations)', resolver: (sdk, tokenName) => sdk.resolveTokenClassKey(tokenName), resultKey: 'tokenClassKey', }); exports.poolTools = [ exports.fetchPoolsTool, fetchAllPools_js_1.fetchAllPoolsTool, exports.fetchPoolDetailsTool, fetchPoolDetailsForCalculation_js_1.fetchPoolDetailsForCalculationTool, fetchTokenDetails_js_1.fetchTokenDetailsTool, exports.fetchTokenDistributionTool, exports.fetchTokenBadgesTool, exports.fetchVolumeDataTool, exports.fetchTokenPriceTool, exports.fetchGalaPriceTool, exports.fetchLaunchpadTokenSpotPriceTool, fetchPriceHistory_js_1.fetchPriceHistoryTool, fetchAllPriceHistory_js_1.fetchAllPriceHistoryTool, exports.checkTokenNameTool, exports.checkTokenSymbolTool, exports.resolveVaultAddressTool, exports.resolveTokenClassKeyTool, onDexPoolCreation_js_1.onDexPoolCreationTool, onLaunchpadTokenCreation_js_1.onLaunchpadTokenCreationTool, ]; //# sourceMappingURL=index.js.map