@michaleffffff/mcp-trading-server 3.0.7 → 3.0.15
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 +101 -0
- package/README.md +93 -2
- package/TOOL_EXAMPLES.md +301 -51
- package/dist/prompts/tradingGuide.js +4 -2
- package/dist/server.js +95 -4
- package/dist/services/poolService.js +430 -6
- package/dist/services/tradeService.js +62 -2
- package/dist/tools/closePosition.js +1 -1
- package/dist/tools/createPerpMarket.js +132 -5
- package/dist/tools/executeTrade.js +6 -1
- package/dist/tools/getBaseDetail.js +129 -3
- package/dist/tools/getOrders.js +30 -2
- package/dist/tools/manageTpSl.js +162 -25
- package/dist/tools/openPositionSimple.js +5 -0
- package/dist/tools/searchTools.js +237 -12
- package/dist/utils/injectProvider.js +1 -0
- package/dist/utils/mappings.js +23 -7
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,106 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.0.15 - 2026-03-18
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Hardened trading parameter compatibility with SDK `v1.0.2`:
|
|
7
|
+
- `execute_trade` / `close_position` now enforce `timeInForce=IOC` only (`0` / `IOC`).
|
|
8
|
+
- Added `poolId` ↔ `marketId` consistency validation on `execute_trade`.
|
|
9
|
+
- Added preflight size/notional validation so `size` is treated strictly as BASE quantity instead of mistaken USD order value.
|
|
10
|
+
- Hardened `get_base_detail`:
|
|
11
|
+
- If SDK returns empty data for a valid active base token, MCP now falls back to market search + market detail to synthesize base metadata instead of returning false `NOT_FOUND`.
|
|
12
|
+
|
|
13
|
+
## 3.0.14 - 2026-03-18
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- Improved `open_position_simple` compatibility for MCP/LLM callers:
|
|
17
|
+
- Accepts optional `marketId` input without triggering schema rejection.
|
|
18
|
+
- Validates supplied `marketId` against the market resolved from `poolId` / `keyword`.
|
|
19
|
+
- Added regression coverage for `dryRun` calls that include `marketId`.
|
|
20
|
+
|
|
21
|
+
## 3.0.13 - 2026-03-18
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Updated docs to better reflect the consolidated toolset:
|
|
25
|
+
- Added a `Legacy Mapping` section to `README.md`
|
|
26
|
+
- Added a `Tool Discovery` workflow using `search_tools`
|
|
27
|
+
- Added a dedicated `Parameter Format Guide` with canonical examples
|
|
28
|
+
- Rebuilt `TOOL_EXAMPLES.md` into a current, MCP-first example handbook with clearer payload formats for trading, liquidity, account, and discovery workflows.
|
|
29
|
+
- Improved `search_tools`:
|
|
30
|
+
- Searches legacy tool names, aliases, categories, and intent phrases
|
|
31
|
+
- Returns categories, aliases, required args, and common parameter hints
|
|
32
|
+
- Returns fallback suggestions when no exact match is found
|
|
33
|
+
- Updated `trading_best_practices` prompt to reference `search_tools`, consolidated tools, and tolerant enum handling.
|
|
34
|
+
|
|
35
|
+
## 3.0.12 - 2026-03-18
|
|
36
|
+
|
|
37
|
+
### Changed
|
|
38
|
+
- Expanded MCP server-side alias normalization beyond case-insensitive enums:
|
|
39
|
+
- `direction`: supports `buy/sell`, `long/short`, `bull/bear`
|
|
40
|
+
- `action`: supports `add/remove/increase/decrease` and normalizes to `deposit/withdraw`
|
|
41
|
+
- `orderType`: supports case-insensitive `market/limit/stop/conditional`
|
|
42
|
+
- `triggerType`: supports case-insensitive `none/gte/lte`
|
|
43
|
+
- This keeps tool schemas strict while making AI/tool callers more tolerant of natural-language style inputs.
|
|
44
|
+
|
|
45
|
+
## 3.0.11 - 2026-03-18
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
- Improved MCP argument normalization for string enums:
|
|
49
|
+
- `z.enum(...)` inputs are now matched case-insensitively at the server layer before Zod validation.
|
|
50
|
+
- Lowercase/mixed-case inputs like `open`, `history`, `all`, `base`, `quote`, `long`, `short` now normalize to canonical enum values automatically.
|
|
51
|
+
- This reduces avoidable `INVALID_PARAM` errors for AI callers while preserving the same canonical tool schemas.
|
|
52
|
+
|
|
53
|
+
## 3.0.10 - 2026-03-18
|
|
54
|
+
|
|
55
|
+
### Fixed
|
|
56
|
+
- Hardened `manage_tp_sl` delete behavior (`tpPrice=0` + `slPrice=0`):
|
|
57
|
+
- Added a unified cancellation path helper to always map delete intent to `cancelAllOrders` (by `orderId` or by `positionId`).
|
|
58
|
+
- Added fallback recovery for SDK/contract `InvalidParameter` reverts (including selector `0x613970e0`) so zero-price delete intent will still downgrade to explicit cancellation instead of failing.
|
|
59
|
+
|
|
60
|
+
## 3.0.9 - 2026-03-18
|
|
61
|
+
|
|
62
|
+
### Fixed
|
|
63
|
+
- Fixed `create_perp_market` observability and compatibility:
|
|
64
|
+
- Added strict `marketId` (66-char hash) and `baseToken` address validation.
|
|
65
|
+
- Added structured error payloads with decoded contract selector hints (e.g. `PoolExists(PoolId)`).
|
|
66
|
+
- Added fallback for SDK v1.0.2 write-path incompatibility (`deployPool is not a function`) by directly calling `PoolManager.deployPool`.
|
|
67
|
+
- Fixed `manage_tp_sl` delete semantics:
|
|
68
|
+
- `tpPrice=0` + `slPrice=0` now maps to explicit TP/SL order cancellation (by `orderId` or by `positionId`) instead of sending invalid on-chain TP/SL orders.
|
|
69
|
+
- Fixed `get_base_detail` null-read behavior:
|
|
70
|
+
- `success + null` is now returned as a structured error (`NOT_FOUND`) with chain/base context.
|
|
71
|
+
- Fixed `get_orders` OPEN status mapping:
|
|
72
|
+
- Removed `Unknown(undefined)` and normalized missing OPEN status to `Open`.
|
|
73
|
+
- Fixed LP SDK wait incompatibility:
|
|
74
|
+
- Added submitted tx-hash recovery path when SDK returns `...wait is not a function` after broadcast (e.g., BASE withdraw).
|
|
75
|
+
- Hardened direct LP router fallback:
|
|
76
|
+
- Added token allowance auto-approval before fallback deposit.
|
|
77
|
+
|
|
78
|
+
### Verified (Real Funds, Arbitrum Sepolia 421614)
|
|
79
|
+
- Deployed and minted new base token to active wallet:
|
|
80
|
+
- token: `0xDae49922Ff1699CA2A6cc4eE835B2c5a9f3Fe870`
|
|
81
|
+
- deploy tx: `0x99e69d66cac1b3a033281bae45dd421bba37794e1a80c1a12eddded99c48acce`
|
|
82
|
+
- Created new perp pool for the token (marketId: `0x2a3fee38e8beba148141bea5cab0bcbbb0cf24fd5509117346991cc438cb2fe6`):
|
|
83
|
+
- create tx: `0x97266886c673cee13531837bcf9a0524034bd85a018036f3557c4d126fef3771`
|
|
84
|
+
- derived poolId: `0x6c1a8af5123a0cf636293aff3fce2ea6addd4bce172c39c6467d4dc95ac3f83e`
|
|
85
|
+
- BASE LP add/remove validated on the new pool:
|
|
86
|
+
- add approval tx: `0xa2739346558f43f474953c7c93be05f0c66f2659f80d8b07804823f03926bdb0`
|
|
87
|
+
- add tx: `0x6a10d7dc5d2794643b10bc2b53080bfa8df1c99eedf35cd48a46edaa6d97d832`
|
|
88
|
+
- remove tx: `0x4148585452d259f6a9928404c7b8d324013e7ee13859392302ab78aa34fab2bc`
|
|
89
|
+
|
|
90
|
+
## 3.0.8 - 2026-03-18
|
|
91
|
+
|
|
92
|
+
### Fixed
|
|
93
|
+
- Fixed `manage_liquidity` QUOTE pool ABI mismatch (`Expected length params=1, values=2`) by adding a safe fallback path:
|
|
94
|
+
- Keep SDK LP call as primary path.
|
|
95
|
+
- On SDK ABI-overload mismatch, switch to explicit-signature router transaction path (`depositQuote`/`withdrawQuote`) to avoid overloaded function ambiguity.
|
|
96
|
+
- Added the same overload-mismatch fallback for BASE pool LP operations (`depositBase`/`withdrawBase`) to prevent the same class of failure.
|
|
97
|
+
- Added SDK ABI-mismatch log suppression for LP calls to avoid noisy stack traces when fallback is activated.
|
|
98
|
+
|
|
99
|
+
### Verified
|
|
100
|
+
- Executed a real QUOTE remove liquidity transaction via MCP after the fix:
|
|
101
|
+
- txHash: `0x69e089b805cccd3b14d0c511309a0ce2aecf988344ec23ae27df929ad99af390`
|
|
102
|
+
- status: success (confirmed on-chain)
|
|
103
|
+
|
|
3
104
|
## 3.0.7 - 2026-03-18
|
|
4
105
|
|
|
5
106
|
### Changed
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ A production-ready MCP (Model Context Protocol) server for deep integration with
|
|
|
6
6
|
|
|
7
7
|
# Release Notes
|
|
8
8
|
|
|
9
|
-
- **Current release: 3.0.
|
|
9
|
+
- **Current release: 3.0.15**
|
|
10
10
|
- **SDK baseline**: `@myx-trade/sdk@^1.0.2` compatibility completed.
|
|
11
11
|
- **Refinement**: Consolidated 40+ specialized tools into ~26 high-level unified tools.
|
|
12
12
|
- **Improved UX**: Enhanced AI parameter parsing, automated unit conversion, and structured error reporting.
|
|
@@ -44,6 +44,7 @@ QUOTE_TOKEN_DECIMALS=18
|
|
|
44
44
|
### 📈 Market Analysis
|
|
45
45
|
* **`find_pool`**: Discover active markets by keyword/symbol (e.g., "BTC", "ETH").
|
|
46
46
|
* **`list_pools`**: List all tradable assets on the current chain.
|
|
47
|
+
* **`search_tools`**: Discover the right MCP tool by keyword, legacy tool name, or intent phrase.
|
|
47
48
|
* **`get_price`**: Fetch real-time prices (Impact Market Price or Oracle Price).
|
|
48
49
|
* **`get_pool_metadata`**: Comprehensive metrics (Fees, Open Interest, Liquidity Depth).
|
|
49
50
|
* **`get_kline`**: Fetch candlestick data for technical analysis.
|
|
@@ -54,7 +55,7 @@ QUOTE_TOKEN_DECIMALS=18
|
|
|
54
55
|
* **`close_position`**: Strategy-based closing of specific positions.
|
|
55
56
|
* **`close_all_positions`**: Emergency exit for all positions in a specific pool.
|
|
56
57
|
* **`cancel_orders`**: Unified cancellation (Single ID, Pool-wide, or Account-wide).
|
|
57
|
-
* **`manage_tp_sl`**: Adjust protection orders for active positions or pending orders.
|
|
58
|
+
* **`manage_tp_sl`**: Adjust protection orders for active positions or pending orders. Deletion is supported via `tpPrice=0` + `slPrice=0`.
|
|
58
59
|
* **`adjust_margin`**: Add or remove collateral to manage liquidation risk.
|
|
59
60
|
|
|
60
61
|
### 📁 Account & Portfolio
|
|
@@ -75,6 +76,96 @@ QUOTE_TOKEN_DECIMALS=18
|
|
|
75
76
|
|
|
76
77
|
---
|
|
77
78
|
|
|
79
|
+
# Tool Discovery
|
|
80
|
+
|
|
81
|
+
When a client or LLM is unsure which tool to call:
|
|
82
|
+
|
|
83
|
+
1. Use `search_tools(keyword="open order")` or `search_tools(keyword="get_market_price")`
|
|
84
|
+
2. Read the returned `aliases`, `category`, and `commonArgs`
|
|
85
|
+
3. Confirm market context with `find_pool`
|
|
86
|
+
4. Call the recommended high-level tool instead of a removed legacy tool
|
|
87
|
+
|
|
88
|
+
Examples:
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{ "name": "search_tools", "arguments": { "keyword": "get_open_orders" } }
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{ "name": "search_tools", "arguments": { "keyword": "add base lp" } }
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
# Parameter Format Guide
|
|
101
|
+
|
|
102
|
+
Use these conventions when generating tool arguments:
|
|
103
|
+
|
|
104
|
+
- `poolId`: Prefer a real hex pool id from `find_pool` or `list_pools`
|
|
105
|
+
- `keyword`: Use a market symbol like `"BTC"`, `"ETH"`, `"ARB"`
|
|
106
|
+
- `direction`: `LONG` / `SHORT` are canonical; lowercase and aliases like `buy` / `sell` are tolerated
|
|
107
|
+
- `status`: `OPEN` / `HISTORY` / `ALL` are canonical; lowercase is tolerated
|
|
108
|
+
- `poolType`: `BASE` / `QUOTE` are canonical; lowercase is tolerated
|
|
109
|
+
- `orderType`: `MARKET` / `LIMIT` / `STOP` / `CONDITIONAL`
|
|
110
|
+
- `timeInForce`: SDK `v1.0.2` currently supports `IOC` only, so use `0` or `"IOC"`
|
|
111
|
+
- `size`: base token quantity, not USD notional; expected order value is usually `collateralAmount * leverage`
|
|
112
|
+
- Human units: `"100"` means 100 USDC or 100 token units depending on field
|
|
113
|
+
- Raw units: `"raw:1000000"` means exact on-chain integer units
|
|
114
|
+
|
|
115
|
+
Examples:
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"name": "get_orders",
|
|
120
|
+
"arguments": { "status": "OPEN", "limit": 20 }
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"name": "manage_liquidity",
|
|
127
|
+
"arguments": {
|
|
128
|
+
"poolId": "0x...",
|
|
129
|
+
"poolType": "BASE",
|
|
130
|
+
"action": "deposit",
|
|
131
|
+
"amount": 1000,
|
|
132
|
+
"slippage": 0.01
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"name": "open_position_simple",
|
|
140
|
+
"arguments": {
|
|
141
|
+
"keyword": "ARB",
|
|
142
|
+
"direction": "LONG",
|
|
143
|
+
"collateralAmount": "100",
|
|
144
|
+
"leverage": 5,
|
|
145
|
+
"orderType": "LIMIT",
|
|
146
|
+
"price": "2.5"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
# Legacy Mapping
|
|
154
|
+
|
|
155
|
+
Common old-to-new tool mappings:
|
|
156
|
+
|
|
157
|
+
- `get_market_price` / `get_oracle_price` -> `get_price`
|
|
158
|
+
- `get_market_detail` / `get_pool_info` / `get_liquidity_info` / `get_pool_level_config` -> `get_pool_metadata`
|
|
159
|
+
- `get_pool_list` / `get_pool_symbol_all` -> `list_pools`
|
|
160
|
+
- `search_market` / `get_pool_by_symbol` -> `find_pool`
|
|
161
|
+
- `get_open_orders` / `get_order_history` -> `get_orders`
|
|
162
|
+
- `get_positions` / `get_position_history` -> `get_positions_all`
|
|
163
|
+
- `cancel_order` / `cancel_all_orders` -> `cancel_orders`
|
|
164
|
+
- `set_tp_sl` / `update_order_tp_sl` -> `manage_tp_sl`
|
|
165
|
+
- `get_account` / `get_account_info` / `get_balances` / `get_margin_balance` -> `get_account_snapshot`
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
78
169
|
# Documentation
|
|
79
170
|
|
|
80
171
|
For detailed implementation examples and parameter guides, see:
|
package/TOOL_EXAMPLES.md
CHANGED
|
@@ -1,137 +1,387 @@
|
|
|
1
|
-
# MYX MCP Tool Examples Handbook (v3.0.
|
|
1
|
+
# MYX MCP Tool Examples Handbook (v3.0.15)
|
|
2
2
|
|
|
3
|
-
This guide provides practical payload examples for the
|
|
4
|
-
All examples
|
|
3
|
+
This guide provides practical MCP payload examples for the current unified toolset.
|
|
4
|
+
All examples use the MCP format:
|
|
5
|
+
|
|
6
|
+
```json
|
|
7
|
+
{ "name": "tool_name", "arguments": { "...": "..." } }
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Discovery First
|
|
13
|
+
|
|
14
|
+
### `search_tools`
|
|
15
|
+
Find the right tool by intent phrase, old tool name, or keyword.
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"name": "search_tools",
|
|
20
|
+
"arguments": { "keyword": "get_open_orders" }
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"name": "search_tools",
|
|
27
|
+
"arguments": { "keyword": "add base lp" }
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### `find_pool`
|
|
32
|
+
Resolve a market keyword to a tradable `poolId`.
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"name": "find_pool",
|
|
37
|
+
"arguments": { "keyword": "ETH", "limit": 5 }
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### `list_pools`
|
|
42
|
+
Browse all current markets on the active chain.
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"name": "list_pools",
|
|
47
|
+
"arguments": {}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
5
50
|
|
|
6
51
|
---
|
|
7
52
|
|
|
8
|
-
##
|
|
53
|
+
## Trading
|
|
54
|
+
|
|
55
|
+
### `open_position_simple`
|
|
56
|
+
Recommended high-level entry tool.
|
|
9
57
|
|
|
10
|
-
### `open_position_simple` (Recommended)
|
|
11
|
-
High-level tool that computes size and fees automatically.
|
|
12
58
|
```json
|
|
13
59
|
{
|
|
14
60
|
"name": "open_position_simple",
|
|
15
61
|
"arguments": {
|
|
16
|
-
"keyword": "
|
|
62
|
+
"keyword": "ARB",
|
|
63
|
+
"marketId": "0x...",
|
|
17
64
|
"direction": "LONG",
|
|
18
65
|
"collateralAmount": "100",
|
|
19
|
-
"leverage":
|
|
20
|
-
"
|
|
21
|
-
"
|
|
66
|
+
"leverage": 5,
|
|
67
|
+
"orderType": "LIMIT",
|
|
68
|
+
"price": "2.5",
|
|
69
|
+
"tpPrice": "2.9",
|
|
70
|
+
"slPrice": "2.2"
|
|
22
71
|
}
|
|
23
72
|
}
|
|
24
73
|
```
|
|
25
74
|
|
|
26
|
-
|
|
27
|
-
|
|
75
|
+
`marketId` is optional on `open_position_simple`. If supplied, it is validated against the market resolved from `poolId` or `keyword`.
|
|
76
|
+
`size` is always the base-asset quantity, not the USD notional. For example, a 500 USD order at price 1200 implies `size ≈ 0.416666...`.
|
|
77
|
+
|
|
78
|
+
Raw-units example:
|
|
79
|
+
|
|
28
80
|
```json
|
|
29
|
-
// Mode 1: Specific IDs
|
|
30
81
|
{
|
|
31
|
-
"name": "
|
|
32
|
-
"arguments": {
|
|
82
|
+
"name": "open_position_simple",
|
|
83
|
+
"arguments": {
|
|
84
|
+
"poolId": "0x...",
|
|
85
|
+
"direction": "SHORT",
|
|
86
|
+
"collateralAmount": "raw:100000000",
|
|
87
|
+
"leverage": 10,
|
|
88
|
+
"orderType": "MARKET"
|
|
89
|
+
}
|
|
33
90
|
}
|
|
91
|
+
```
|
|
34
92
|
|
|
35
|
-
|
|
93
|
+
### `execute_trade`
|
|
94
|
+
Low-level increase-order tool when you want full control.
|
|
95
|
+
|
|
96
|
+
```json
|
|
36
97
|
{
|
|
37
|
-
"name": "
|
|
38
|
-
"arguments": {
|
|
98
|
+
"name": "execute_trade",
|
|
99
|
+
"arguments": {
|
|
100
|
+
"poolId": "0x...",
|
|
101
|
+
"marketId": "0x...",
|
|
102
|
+
"direction": "LONG",
|
|
103
|
+
"orderType": "LIMIT",
|
|
104
|
+
"price": "2500",
|
|
105
|
+
"size": "0.2",
|
|
106
|
+
"collateralAmount": "100",
|
|
107
|
+
"timeInForce": 0,
|
|
108
|
+
"leverage": 5
|
|
109
|
+
}
|
|
39
110
|
}
|
|
111
|
+
```
|
|
40
112
|
|
|
41
|
-
|
|
113
|
+
`timeInForce` should be `0` (or `"IOC"` in string form) for SDK `v1.0.2`.
|
|
114
|
+
|
|
115
|
+
### `close_position`
|
|
116
|
+
Close or reduce a position. Use `ALL` for a full close.
|
|
117
|
+
|
|
118
|
+
```json
|
|
42
119
|
{
|
|
43
|
-
"name": "
|
|
44
|
-
"arguments": {
|
|
120
|
+
"name": "close_position",
|
|
121
|
+
"arguments": {
|
|
122
|
+
"poolId": "0x...",
|
|
123
|
+
"positionId": "0x...",
|
|
124
|
+
"direction": "LONG",
|
|
125
|
+
"orderType": "MARKET",
|
|
126
|
+
"collateralAmount": "ALL",
|
|
127
|
+
"size": "ALL",
|
|
128
|
+
"price": "2200",
|
|
129
|
+
"timeInForce": 0,
|
|
130
|
+
"postOnly": false,
|
|
131
|
+
"slippagePct": "50",
|
|
132
|
+
"executionFeeToken": "0x...",
|
|
133
|
+
"leverage": 5
|
|
134
|
+
}
|
|
45
135
|
}
|
|
46
136
|
```
|
|
47
137
|
|
|
48
138
|
### `manage_tp_sl`
|
|
49
|
-
|
|
139
|
+
Create or update TP/SL on an open position.
|
|
140
|
+
|
|
50
141
|
```json
|
|
51
142
|
{
|
|
52
143
|
"name": "manage_tp_sl",
|
|
53
144
|
"arguments": {
|
|
54
|
-
"poolId": "
|
|
55
|
-
"positionId": "
|
|
145
|
+
"poolId": "0x...",
|
|
146
|
+
"positionId": "0x...",
|
|
147
|
+
"direction": "LONG",
|
|
56
148
|
"leverage": 5,
|
|
57
|
-
"tpPrice": "
|
|
58
|
-
"slPrice": "
|
|
149
|
+
"tpPrice": "2800",
|
|
150
|
+
"slPrice": "2300"
|
|
59
151
|
}
|
|
60
152
|
}
|
|
61
153
|
```
|
|
62
154
|
|
|
63
|
-
|
|
155
|
+
Delete both TP/SL orders:
|
|
64
156
|
|
|
65
|
-
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"name": "manage_tp_sl",
|
|
160
|
+
"arguments": {
|
|
161
|
+
"poolId": "0x...",
|
|
162
|
+
"positionId": "0x...",
|
|
163
|
+
"tpPrice": "0",
|
|
164
|
+
"slPrice": "0"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### `cancel_orders`
|
|
170
|
+
Supports single-order, pool-wide, or account-wide cancellation.
|
|
66
171
|
|
|
67
|
-
### `find_pool`
|
|
68
|
-
Keyword or symbol based discovery.
|
|
69
172
|
```json
|
|
70
173
|
{
|
|
71
|
-
"name": "
|
|
72
|
-
"arguments": { "
|
|
174
|
+
"name": "cancel_orders",
|
|
175
|
+
"arguments": { "orderIds": ["123", "124"] }
|
|
73
176
|
}
|
|
74
177
|
```
|
|
75
178
|
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"name": "cancel_orders",
|
|
182
|
+
"arguments": { "poolId": "0x..." }
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"name": "cancel_orders",
|
|
189
|
+
"arguments": { "cancelAll": true }
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Market Data
|
|
196
|
+
|
|
76
197
|
### `get_price`
|
|
77
|
-
|
|
198
|
+
Read either market or oracle price.
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
{
|
|
202
|
+
"name": "get_price",
|
|
203
|
+
"arguments": {
|
|
204
|
+
"poolId": "0x...",
|
|
205
|
+
"priceType": "market"
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
78
210
|
```json
|
|
79
211
|
{
|
|
80
212
|
"name": "get_price",
|
|
81
|
-
"arguments": {
|
|
82
|
-
"poolId": "0x...",
|
|
83
|
-
"priceType": "
|
|
213
|
+
"arguments": {
|
|
214
|
+
"poolId": "0x...",
|
|
215
|
+
"priceType": "oracle"
|
|
84
216
|
}
|
|
85
217
|
}
|
|
86
218
|
```
|
|
87
219
|
|
|
88
220
|
### `get_pool_metadata`
|
|
89
|
-
|
|
221
|
+
Unified pool detail, config, and liquidity info.
|
|
222
|
+
|
|
90
223
|
```json
|
|
91
224
|
{
|
|
92
225
|
"name": "get_pool_metadata",
|
|
93
|
-
"arguments": {
|
|
226
|
+
"arguments": {
|
|
227
|
+
"poolId": "0x...",
|
|
228
|
+
"includeConfig": true,
|
|
229
|
+
"includeLiquidity": true
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### `get_kline`
|
|
235
|
+
Read chart data. Use `limit: 1` for the latest bar.
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"name": "get_kline",
|
|
240
|
+
"arguments": {
|
|
241
|
+
"poolId": "0x...",
|
|
242
|
+
"interval": "1m",
|
|
243
|
+
"limit": 50
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Liquidity
|
|
251
|
+
|
|
252
|
+
### `manage_liquidity`
|
|
253
|
+
Add or remove BASE/QUOTE LP.
|
|
254
|
+
|
|
255
|
+
```json
|
|
256
|
+
{
|
|
257
|
+
"name": "manage_liquidity",
|
|
258
|
+
"arguments": {
|
|
259
|
+
"poolId": "0x...",
|
|
260
|
+
"poolType": "BASE",
|
|
261
|
+
"action": "deposit",
|
|
262
|
+
"amount": 1000,
|
|
263
|
+
"slippage": 0.01
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Alias-friendly form also works:
|
|
269
|
+
|
|
270
|
+
```json
|
|
271
|
+
{
|
|
272
|
+
"name": "manage_liquidity",
|
|
273
|
+
"arguments": {
|
|
274
|
+
"poolId": "0x...",
|
|
275
|
+
"poolType": "base",
|
|
276
|
+
"action": "add",
|
|
277
|
+
"amount": 1000,
|
|
278
|
+
"slippage": 0.01
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### `get_lp_price`
|
|
284
|
+
Read LP NAV price for BASE or QUOTE side.
|
|
285
|
+
|
|
286
|
+
```json
|
|
287
|
+
{
|
|
288
|
+
"name": "get_lp_price",
|
|
289
|
+
"arguments": {
|
|
290
|
+
"poolId": "0x...",
|
|
291
|
+
"poolType": "QUOTE"
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### `get_my_lp_holdings`
|
|
297
|
+
Read current LP balances across pools.
|
|
298
|
+
|
|
299
|
+
```json
|
|
300
|
+
{
|
|
301
|
+
"name": "get_my_lp_holdings",
|
|
302
|
+
"arguments": {
|
|
303
|
+
"includeZero": false,
|
|
304
|
+
"maxPools": 20
|
|
305
|
+
}
|
|
94
306
|
}
|
|
95
307
|
```
|
|
96
308
|
|
|
97
309
|
---
|
|
98
310
|
|
|
99
|
-
##
|
|
311
|
+
## Account And Monitoring
|
|
100
312
|
|
|
101
313
|
### `get_account_snapshot`
|
|
102
|
-
|
|
314
|
+
Read wallet balance, trading account info, and VIP snapshot.
|
|
315
|
+
|
|
103
316
|
```json
|
|
104
317
|
{
|
|
105
318
|
"name": "get_account_snapshot",
|
|
106
|
-
"arguments": {
|
|
319
|
+
"arguments": {
|
|
320
|
+
"poolId": "0x..."
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### `check_account_ready`
|
|
326
|
+
Pre-check whether collateral is available before trading.
|
|
327
|
+
|
|
328
|
+
```json
|
|
329
|
+
{
|
|
330
|
+
"name": "check_account_ready",
|
|
331
|
+
"arguments": {
|
|
332
|
+
"poolId": "0x...",
|
|
333
|
+
"collateralAmount": "100"
|
|
334
|
+
}
|
|
107
335
|
}
|
|
108
336
|
```
|
|
109
337
|
|
|
110
338
|
### `get_orders`
|
|
111
|
-
|
|
339
|
+
Read open orders, history, or both.
|
|
340
|
+
|
|
112
341
|
```json
|
|
113
342
|
{
|
|
114
343
|
"name": "get_orders",
|
|
115
|
-
"arguments": {
|
|
116
|
-
"status": "
|
|
117
|
-
"
|
|
344
|
+
"arguments": {
|
|
345
|
+
"status": "OPEN",
|
|
346
|
+
"poolId": "0x...",
|
|
347
|
+
"limit": 20
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
Lowercase is also accepted:
|
|
353
|
+
|
|
354
|
+
```json
|
|
355
|
+
{
|
|
356
|
+
"name": "get_orders",
|
|
357
|
+
"arguments": {
|
|
358
|
+
"status": "open",
|
|
359
|
+
"limit": 20
|
|
118
360
|
}
|
|
119
361
|
}
|
|
120
362
|
```
|
|
121
363
|
|
|
122
364
|
### `get_positions_all`
|
|
123
|
-
|
|
365
|
+
Read open positions, history, or both.
|
|
366
|
+
|
|
124
367
|
```json
|
|
125
368
|
{
|
|
126
369
|
"name": "get_positions_all",
|
|
127
|
-
"arguments": {
|
|
370
|
+
"arguments": {
|
|
371
|
+
"status": "ALL",
|
|
372
|
+
"poolId": "0x...",
|
|
373
|
+
"limit": 20
|
|
374
|
+
}
|
|
128
375
|
}
|
|
129
376
|
```
|
|
130
377
|
|
|
131
378
|
---
|
|
132
379
|
|
|
133
|
-
##
|
|
380
|
+
## Parameter Conventions
|
|
134
381
|
|
|
135
|
-
1.
|
|
136
|
-
2.
|
|
137
|
-
3.
|
|
382
|
+
1. Use `find_pool` before trading if you do not already have a `poolId`.
|
|
383
|
+
2. Human-readable units are allowed on high-level tools, such as `"100"` or `"0.5"`.
|
|
384
|
+
3. Exact on-chain values can be passed with the `raw:` prefix.
|
|
385
|
+
4. Canonical enums are still preferred:
|
|
386
|
+
`OPEN|HISTORY|ALL`, `BASE|QUOTE`, `LONG|SHORT`, `MARKET|LIMIT|STOP`.
|
|
387
|
+
5. The server tolerates common lowercase and alias forms for better AI compatibility.
|
|
@@ -12,12 +12,12 @@ export const tradingGuidePrompt = {
|
|
|
12
12
|
content: {
|
|
13
13
|
type: "text",
|
|
14
14
|
text: `
|
|
15
|
-
# MYX Trading MCP Best Practices (v3.0.
|
|
15
|
+
# MYX Trading MCP Best Practices (v3.0.12)
|
|
16
16
|
|
|
17
17
|
You are an expert crypto trader using the MYX Protocol. To ensure successful execution and safe handling of user funds, follow these patterns:
|
|
18
18
|
|
|
19
19
|
## 1. The Standard Workflow
|
|
20
|
-
1. **Discovery**: Use \`find_pool\` with a keyword (e.g. "BTC") to get the \`poolId\`.
|
|
20
|
+
1. **Discovery**: Use \`search_tools\` if the intent is unclear, then use \`find_pool\` with a keyword (e.g. "BTC") to get the \`poolId\`.
|
|
21
21
|
2. **Context**: Use \`get_account_snapshot\` (with \`poolId\`) to check balances, trading metrics, and VIP tier. Use \`get_price\` for real-time market/oracle prices.
|
|
22
22
|
3. **Pre-check**: Use \`check_account_ready\` to ensure the trading account has enough collateral.
|
|
23
23
|
4. **Execution**: Prefer \`open_position_simple\` for entry. It supports Stop-Loss (\`slPrice\`) and Take-Profit (\`tpPrice\`) in one call.
|
|
@@ -26,10 +26,12 @@ You are an expert crypto trader using the MYX Protocol. To ensure successful exe
|
|
|
26
26
|
|
|
27
27
|
## 2. Parameter Tips
|
|
28
28
|
- **Consolidated Tools**: Many legacy tools have been merged. Always use the high-level versions (e.g., \`get_price\` instead of \`get_market_price\`).
|
|
29
|
+
- **Discovery**: \`search_tools\` understands legacy names like \`get_open_orders\` and intent phrases like \`add base lp\`.
|
|
29
30
|
- **Unit Prefixes**: Prefer \`human:\` for readable amounts (e.g., "100" USDC) and \`raw:\` for exact on-chain units.
|
|
30
31
|
- **Slippage**: Default is 100 (1%). For volatile tokens, consider 200-300 (2-3%).
|
|
31
32
|
- **Fees**: Use \`get_pool_metadata\` to view current fee tiers and pool configuration.
|
|
32
33
|
- **LP Strategy**: Use \`get_my_lp_holdings\` to monitor liquidity positions. Naming follows \`mBASE.QUOTE\` (e.g., \`mBTC.USDC\`).
|
|
34
|
+
- **Enum Tolerance**: The server tolerates common lowercase or alias inputs such as \`open\`, \`base\`, \`buy\`, and \`add\`, but canonical forms are still preferred in documentation.
|
|
33
35
|
|
|
34
36
|
Current Session:
|
|
35
37
|
- Wallet: ${address}
|