@dbotx/limit-order-mcp-server
Version:
Limit Order MCP Server - Supporting multi-chain limit orders, precise price triggers, and flexible order management. A professional cross-chain MCP trading service supporting DEX trading on multiple chains including Solana, Ethereum, BSC and more.
146 lines • 6.56 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WalletQueryRequestSchema = exports.LimitOrdersRequestSchema = exports.DeleteAllLimitOrderRequestSchema = exports.DeleteLimitOrdersRequestSchema = exports.DeleteLimitOrderRequestSchema = exports.SwitchLimitOrderRequestSchema = exports.EditLimitOrderRequestSchema = exports.CreateLimitOrderRequestSchema = exports.LimitOrderSettingSchema = exports.TriggerDirectionSchema = exports.TradeTypeSchema = exports.ChainSchema = void 0;
exports.getWalletIdByChain = getWalletIdByChain;
exports.validateWalletIdConfig = validateWalletIdConfig;
const zod_1 = require("zod");
// Basic type definitions
exports.ChainSchema = zod_1.z.enum(['solana', 'ethereum', 'base', 'bsc', 'tron']);
exports.TradeTypeSchema = zod_1.z.enum(['buy', 'sell']);
exports.TriggerDirectionSchema = zod_1.z.enum(['up', 'down']);
// Limit order settings
exports.LimitOrderSettingSchema = zod_1.z.object({
enabled: zod_1.z.boolean().default(true),
tradeType: exports.TradeTypeSchema,
triggerPriceUsd: zod_1.z.string().min(1),
triggerDirection: exports.TriggerDirectionSchema,
currencyAmountUI: zod_1.z.number().min(0),
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),
expireDelta: zod_1.z.number().int().min(0).max(432000000).default(432000000),
expireExecute: zod_1.z.boolean().default(false),
useMidPrice: zod_1.z.boolean().default(false),
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 limit order request - supports multiple settings
exports.CreateLimitOrderRequestSchema = zod_1.z.object({
chain: exports.ChainSchema.default('solana'),
pair: zod_1.z.string().min(1),
walletId: zod_1.z.string().min(1).optional(),
groupId: zod_1.z.string().optional(),
settings: zod_1.z.array(exports.LimitOrderSettingSchema).min(1),
});
// Edit limit order request
exports.EditLimitOrderRequestSchema = zod_1.z.object({
id: zod_1.z.string().min(1),
enabled: zod_1.z.boolean().optional(),
groupId: zod_1.z.string().optional(),
triggerPriceUsd: zod_1.z.string().min(1).optional(),
triggerDirection: exports.TriggerDirectionSchema.optional(),
currencyAmountUI: zod_1.z.number().min(0).optional(),
customFeeAndTip: zod_1.z.boolean().optional(),
priorityFee: zod_1.z.string().optional(),
gasFeeDelta: zod_1.z.number().int().min(0).optional(),
maxFeePerGas: zod_1.z.number().int().min(0).optional(),
jitoEnabled: zod_1.z.boolean().optional(),
jitoTip: zod_1.z.number().min(0).optional(),
expireDelta: zod_1.z.number().int().min(0).max(432000000).optional(),
expireExecute: zod_1.z.boolean().optional(),
useMidPrice: zod_1.z.boolean().optional(),
maxSlippage: zod_1.z.number().min(0).max(1).optional(),
concurrentNodes: zod_1.z.number().int().min(1).max(3).optional(),
retries: zod_1.z.number().int().min(0).max(10).optional(),
});
// Switch limit order status request
exports.SwitchLimitOrderRequestSchema = zod_1.z.object({
id: zod_1.z.string().min(1),
enabled: zod_1.z.boolean(),
});
// Delete limit order request
exports.DeleteLimitOrderRequestSchema = zod_1.z.object({
id: zod_1.z.string().min(1),
});
// Batch delete limit orders request
exports.DeleteLimitOrdersRequestSchema = zod_1.z.object({
ids: zod_1.z.array(zod_1.z.string()).min(1),
});
// Delete all limit orders request
exports.DeleteAllLimitOrderRequestSchema = zod_1.z.object({
source: zod_1.z.enum(['normal', 'pnl_for_follow', 'pnl_for_swap']),
});
// Get limit orders request
exports.LimitOrdersRequestSchema = zod_1.z.object({
page: zod_1.z.number().int().min(0).default(0),
size: zod_1.z.number().int().min(1).max(20).default(20),
chain: exports.ChainSchema.optional(),
pair: zod_1.z.string().optional(),
state: zod_1.z.enum(['init', 'done', 'expired', 'canceled']).optional().default('init'),
enabled: zod_1.z.boolean().optional(),
groupId: zod_1.z.string().optional(),
token: zod_1.z.string().optional(),
sortBy: zod_1.z.string().optional(),
sort: zod_1.z.number().optional().default(-1),
});
// 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