@michaleffffff/mcp-trading-server 2.3.2 → 2.3.4

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/dist/server.js CHANGED
@@ -81,7 +81,7 @@ function zodSchemaToJsonSchema(zodSchema) {
81
81
  };
82
82
  }
83
83
  // ─── MCP Server ───
84
- const server = new Server({ name: "myx-mcp-trading-server", version: "2.3.1" }, { capabilities: { tools: {}, resources: {}, prompts: {} } });
84
+ const server = new Server({ name: "myx-mcp-trading-server", version: "2.3.4" }, { capabilities: { tools: {}, resources: {}, prompts: {} } });
85
85
  // List tools
86
86
  server.setRequestHandler(ListToolsRequestSchema, async () => {
87
87
  return {
@@ -1,5 +1,6 @@
1
1
  import { pool, quote, base } from "@myx-trade/sdk";
2
2
  import { getChainId, resolveClient } from "../auth/resolveClient.js";
3
+ import { ensureUnits } from "../utils/units.js";
3
4
  /**
4
5
  * 创建合约市场池子
5
6
  */
@@ -27,7 +28,8 @@ export async function getPoolDetail(poolId) {
27
28
  */
28
29
  export async function getLiquidityInfo(client, poolId, marketPrice) {
29
30
  const chainId = getChainId();
30
- return client.utils.getLiquidityInfo({ chainId, poolId, marketPrice });
31
+ const price30 = ensureUnits(marketPrice, 30, "marketPrice");
32
+ return client.utils.getLiquidityInfo({ chainId, poolId, marketPrice: price30 });
31
33
  }
32
34
  /**
33
35
  * Quote 池 deposit
@@ -112,6 +112,7 @@ export async function closePosition(client, address, args) {
112
112
  throw new Error("direction is required (0=LONG, 1=SHORT), must match position direction.");
113
113
  }
114
114
  const price30 = parseHumanUnits(args.price, 30, "price");
115
+ const sizeWei = ensureUnits(args.size, 18, "size");
115
116
  const dir = resolveDirection(args.direction);
116
117
  return client.order.createDecreaseOrder({
117
118
  chainId,
@@ -122,7 +123,7 @@ export async function closePosition(client, address, args) {
122
123
  triggerType: TriggerType.NONE,
123
124
  direction: dir,
124
125
  collateralAmount: "0",
125
- size: args.size,
126
+ size: sizeWei,
126
127
  price: price30,
127
128
  postOnly: false,
128
129
  slippagePct: args.slippagePct ?? "100",
@@ -9,7 +9,7 @@ export const closePositionTool = {
9
9
  positionId: z.string().describe("Position ID to close"),
10
10
  direction: z.union([z.literal(0), z.literal(1)]).describe("0 = LONG, 1 = SHORT (must match position direction)"),
11
11
  leverage: z.number().describe("Position leverage"),
12
- size: z.string().describe("Size to close (18 decimals)"),
12
+ size: z.string().describe("Size to close (human-readable or 18-decimal raw units)"),
13
13
  price: z.string().describe("Price in human-readable units"),
14
14
  slippagePct: z.string().optional().describe("Slippage in bps, default '100'"),
15
15
  quoteToken: z.string().optional().describe("Quote token address"),
@@ -40,7 +40,7 @@ export const getLiquidityInfoTool = {
40
40
  description: "Get pool liquidity utilization and depth information.",
41
41
  schema: {
42
42
  poolId: z.string().describe("Pool ID"),
43
- marketPrice: z.string().describe("Current market price (30 decimals)"),
43
+ marketPrice: z.string().describe("Current market price (can be human-readable e.g. '0.69' or 30-decimal raw units)"),
44
44
  },
45
45
  handler: async (args) => {
46
46
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michaleffffff/mcp-trading-server",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "myx-mcp": "dist/server.js"
@@ -15,11 +15,11 @@
15
15
  "test": "tsx tests/test_sepolia.ts"
16
16
  },
17
17
  "dependencies": {
18
- "@modelcontextprotocol/sdk": "^0.5.0",
18
+ "@modelcontextprotocol/sdk": "^1.27.1",
19
19
  "@myx-trade/sdk": "^0.1.269",
20
- "dotenv": "^16.4.5",
20
+ "dotenv": "^17.3.1",
21
21
  "ethers": "^6.13.1",
22
- "zod": "^3.23.8"
22
+ "zod": "^4.3.6"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^20.0.0",