UNPKG

@dbotx/copy-trading-mcp-server

Version:

Copy Trading MCP Server - Supports creating and managing complex copy trading tasks, automatically following other users' trading strategies

186 lines 9.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WalletQueryRequestSchema = exports.DeleteCopyTradingRequestSchema = exports.SwitchCopyTradingRequestSchema = exports.EditCopyTradingRequestSchema = exports.CreateCopyTradingRequestSchema = exports.SellSettingsSchema = exports.BuySettingsSchema = exports.PnlGroupSchema = exports.SellSpeedTypeSchema = exports.SellAmountTypeSchema = exports.SellModeSchema = exports.BuyAmountTypeSchema = exports.ChainSchema = void 0; exports.getWalletIdByChain = getWalletIdByChain; exports.validateWalletIdConfig = validateWalletIdConfig; const zod_1 = require("zod"); // Base type definitions exports.ChainSchema = zod_1.z.enum(['solana', 'ethereum', 'base', 'bsc', 'tron']); exports.BuyAmountTypeSchema = zod_1.z.enum(['fixed_amount', 'fixed_ratio', 'follow_amount']); exports.SellModeSchema = zod_1.z.enum(['mixed', 'only_copy', 'only_pnl']); exports.SellAmountTypeSchema = zod_1.z.enum(['all', 'follow_ratio', 'x_target_ratio']); exports.SellSpeedTypeSchema = zod_1.z.enum(['fast', 'accurate']); // Take-profit/Stop-loss groups exports.PnlGroupSchema = zod_1.z.object({ pricePercent: zod_1.z.number().min(0).max(1), amountPercent: zod_1.z.number().min(0).max(1), }); // Buy settings exports.BuySettingsSchema = zod_1.z.object({ enabled: zod_1.z.boolean().default(true), startHour: zod_1.z.number().int().min(0).max(23).default(0), endHour: zod_1.z.number().int().min(0).max(23).default(23), buyAmountType: exports.BuyAmountTypeSchema.default('follow_amount'), maxBuyAmountUI: zod_1.z.string().min(1), buyRatio: zod_1.z.number().min(0).max(10).default(1), maxBalanceUI: zod_1.z.number().min(0).default(100), reservedAmountUI: zod_1.z.number().min(0).default(0.01), targetMinAmountUI: zod_1.z.number().min(0).default(0), targetMaxAmountUI: zod_1.z.number().min(0).default(999999), minTokenMCUSD: zod_1.z.number().min(0).default(0), maxTokenMCUSD: zod_1.z.number().min(0).default(999999999), maxBuyTax: zod_1.z.number().min(0).max(1).optional(), maxSellTax: zod_1.z.number().min(0).max(1).optional(), customFeeAndTip: zod_1.z.boolean().default(false), priorityFee: zod_1.z.string().default('0.0001'), gasFeeDelta: zod_1.z.number().int().min(0).default(5), maxFeePerGas: zod_1.z.number().int().min(0).default(100), jitoEnabled: zod_1.z.boolean().default(true), jitoTip: zod_1.z.number().min(0).default(0.001), maxSlippage: zod_1.z.number().min(0).max(1).default(0.1), skipFreezableToken: zod_1.z.boolean().default(false), skipMintableToken: zod_1.z.boolean().default(false), skipDelegatedToken: zod_1.z.boolean().default(false), skipNotOpensource: zod_1.z.boolean().default(false), skipHoneyPot: zod_1.z.boolean().default(false), skipTargetIncreasePosition: zod_1.z.boolean().default(false), minBurnedLp: zod_1.z.number().min(0).max(1).default(0), minLpUsd: zod_1.z.number().min(0).default(0), minTokenAgeMs: zod_1.z.number().min(0).default(0), maxTokenAgeMs: zod_1.z.number().min(0).default(999999999999), maxTopHoldPercent: zod_1.z.number().min(0).max(1).default(1), maxBuyTimesPerToken: zod_1.z.number().int().min(1).default(999), maxBuyAmountPerToken: zod_1.z.number().min(0).default(999999), buyExist: zod_1.z.boolean().default(false), buyOncePerWallet: zod_1.z.boolean().default(false), concurrentNodes: zod_1.z.number().int().min(1).max(3).default(2), retries: zod_1.z.number().int().min(0).max(10).default(1), }); // Sell settings exports.SellSettingsSchema = zod_1.z.object({ enabled: zod_1.z.boolean().default(true), startHour: zod_1.z.number().int().min(0).max(23).default(0), endHour: zod_1.z.number().int().min(0).max(23).default(23), mode: exports.SellModeSchema.default('mixed'), sellAmountType: exports.SellAmountTypeSchema.default('all'), xTargetRatio: zod_1.z.number().min(0).max(100).default(1), sellSpeedType: exports.SellSpeedTypeSchema.default('accurate'), targetMinAmountUI: zod_1.z.number().min(0).default(0), targetMaxAmountUI: zod_1.z.number().min(0).default(999999), stopEarnPercent: zod_1.z.number().min(0).optional(), stopLossPercent: zod_1.z.number().min(0).optional(), stopEarnGroup: zod_1.z.array(exports.PnlGroupSchema).max(6).optional(), stopLossGroup: zod_1.z.array(exports.PnlGroupSchema).max(6).optional(), trailingStopGroup: zod_1.z.array(exports.PnlGroupSchema).max(1).optional(), pnlOrderExpireDelta: zod_1.z.number().int().min(0).max(432000000).default(43200000), pnlOrderExpireExecute: zod_1.z.boolean().default(false), pnlOrderUseMidPrice: zod_1.z.boolean().default(false), sellMode: zod_1.z.enum(['smart', 'normal']).default('smart'), migrateSellPercent: zod_1.z.number().min(0).max(1).default(0), minDevSellPercent: zod_1.z.number().min(0).max(1).default(0.5), devSellPercent: zod_1.z.number().min(0).max(1).default(1), customFeeAndTip: zod_1.z.boolean().default(false), priorityFee: zod_1.z.string().default('0.0001'), gasFeeDelta: zod_1.z.number().int().min(0).default(5), maxFeePerGas: zod_1.z.number().int().min(0).default(100), jitoEnabled: zod_1.z.boolean().default(true), jitoTip: zod_1.z.number().min(0).default(0.001), maxSlippage: zod_1.z.number().min(0).max(1).default(0.1), concurrentNodes: zod_1.z.number().int().min(1).max(3).default(2), retries: zod_1.z.number().int().min(0).max(10).default(1), }); // Create copy trading task request exports.CreateCopyTradingRequestSchema = zod_1.z.object({ enabled: zod_1.z.boolean().default(true), name: zod_1.z.string().min(1), chain: exports.ChainSchema.default('solana'), dexFilter: zod_1.z.array(zod_1.z.string()).optional(), targetIds: zod_1.z.array(zod_1.z.string()).min(1).max(10), tokenBlacklist: zod_1.z.array(zod_1.z.string()).max(20).optional(), walletId: zod_1.z.string().min(1).optional(), groupId: zod_1.z.string().optional(), buySettings: exports.BuySettingsSchema, sellSettings: exports.SellSettingsSchema, }); // Edit copy trading task request exports.EditCopyTradingRequestSchema = zod_1.z.object({ id: zod_1.z.string().min(1), enabled: zod_1.z.boolean(), name: zod_1.z.string().min(1), chain: exports.ChainSchema, dexFilter: zod_1.z.array(zod_1.z.string()).optional(), targetIds: zod_1.z.array(zod_1.z.string()).min(1).max(10), tokenBlacklist: zod_1.z.array(zod_1.z.string()).max(20).optional(), walletId: zod_1.z.string().min(1).optional(), groupId: zod_1.z.string().optional(), buySettings: exports.BuySettingsSchema, sellSettings: exports.SellSettingsSchema, }); // Switch copy trading task request exports.SwitchCopyTradingRequestSchema = zod_1.z.object({ id: zod_1.z.string().min(1), enabled: zod_1.z.boolean(), closePnlOrder: zod_1.z.boolean().default(false), }); // Delete copy trading task request exports.DeleteCopyTradingRequestSchema = zod_1.z.object({ id: zod_1.z.string().min(1), deletePnlOrder: zod_1.z.boolean().default(false), }); // Wallet query types exports.WalletQueryRequestSchema = zod_1.z.object({ type: zod_1.z.enum(['solana', 'evm']).optional(), page: zod_1.z.number().int().min(0).default(0), size: zod_1.z.number().int().min(1).max(20).default(20), }); /** * Get wallet ID based on chain */ function getWalletIdByChain(chain) { const chainUpperCase = chain.toUpperCase(); // Check specific chain first const specificWalletId = process.env[`DBOT_WALLET_ID_${chainUpperCase}`]; if (specificWalletId) { return specificWalletId; } // Fall back to generic chain type let fallbackKey = ''; switch (chain) { case 'solana': fallbackKey = 'DBOT_WALLET_ID_SOLANA'; break; case 'ethereum': case 'base': case 'bsc': fallbackKey = 'DBOT_WALLET_ID_EVM'; break; case 'tron': fallbackKey = 'DBOT_WALLET_ID_TRON'; break; default: fallbackKey = 'DBOT_WALLET_ID_EVM'; } const fallbackWalletId = process.env[fallbackKey]; if (fallbackWalletId) { return fallbackWalletId; } throw new Error(`No wallet ID configured for chain ${chain}. Please configure at least one of the following environment variables: DBOT_WALLET_ID_SOLANA, DBOT_WALLET_ID_EVM, DBOT_WALLET_ID_TRON, DBOT_WALLET_ID_BASE, DBOT_WALLET_ID_ARBITRUM, DBOT_WALLET_ID_BSC`); } /** * Check if at least one wallet ID is configured */ function validateWalletIdConfig() { const requiredEnvVars = [ 'DBOT_WALLET_ID_SOLANA', 'DBOT_WALLET_ID_EVM', 'DBOT_WALLET_ID_TRON', 'DBOT_WALLET_ID_BASE', 'DBOT_WALLET_ID_ARBITRUM', 'DBOT_WALLET_ID_BSC' ]; const hasAtLeastOne = requiredEnvVars.some(envVar => process.env[envVar]); if (!hasAtLeastOne) { throw new Error(`At least one wallet ID must be configured. Please set one of the following environment variables: ${requiredEnvVars.join(', ')}`); } } //# sourceMappingURL=types.js.map