@arcadia-finance/mcp-server 0.2.1 → 0.3.0
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/README.md +51 -35
- package/dist/config/addresses.js +59 -4
- package/dist/index.js +37 -0
- package/dist/prompts/workflows.js +11 -8
- package/dist/tools/dev/send.js +12 -8
- package/dist/tools/index.js +16 -6
- package/dist/tools/output-schemas.js +128 -0
- package/dist/tools/read/account.js +135 -112
- package/dist/tools/read/asset-managers.js +158 -0
- package/dist/tools/read/assets.js +52 -16
- package/dist/tools/read/guides.js +24 -3
- package/dist/tools/read/points.js +14 -20
- package/dist/tools/read/pools.js +68 -39
- package/dist/tools/read/strategy.js +89 -44
- package/dist/tools/read/wallet.js +84 -6
- package/dist/tools/write/account/add-liquidity.js +9 -3
- package/dist/tools/write/account/borrow.js +13 -9
- package/dist/tools/write/account/close.js +5 -1
- package/dist/tools/write/account/create.js +14 -13
- package/dist/tools/write/account/deleverage.js +6 -2
- package/dist/tools/write/account/deposit.js +14 -10
- package/dist/tools/write/account/format-response.js +5 -4
- package/dist/tools/write/account/remove-liquidity.js +5 -1
- package/dist/tools/write/account/repay.js +14 -10
- package/dist/tools/write/account/stake.js +8 -2
- package/dist/tools/write/account/swap.js +5 -1
- package/dist/tools/write/account/withdraw.js +13 -9
- package/dist/tools/write/asset-managers/compounder.js +111 -0
- package/dist/tools/write/asset-managers/cow-swapper.js +49 -0
- package/dist/tools/write/asset-managers/encoding.js +162 -0
- package/dist/tools/write/asset-managers/merkl-operator.js +51 -0
- package/dist/tools/write/asset-managers/rebalancer.js +108 -0
- package/dist/tools/write/asset-managers/set-asset-managers.js +75 -0
- package/dist/tools/write/asset-managers/shared.js +29 -0
- package/dist/tools/write/asset-managers/yield-claimer.js +115 -0
- package/dist/tools/write/wallet/approve.js +14 -10
- package/package.json +2 -1
- package/server.json +26 -2
- package/skills/clamm-liquidity/SKILL.md +34 -28
- package/skills/clamm-liquidity/automation.md +83 -73
- package/skills/clamm-liquidity/selection.md +2 -2
- package/skills/clamm-liquidity/strategies.md +28 -30
- package/dist/tools/write/asset-manager/configure.js +0 -254
- package/dist/tools/write/asset-manager/set.js +0 -62
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://smithery.ai/server/@arcadia-finance/mcp-server)
|
|
6
6
|
[](LICENSE.md)
|
|
7
7
|
[](https://www.typescriptlang.org/)
|
|
8
|
-
[](https://modelcontextprotocol.io/)
|
|
9
9
|
[](https://lobehub.com/mcp/arcadia-finance-mcp-server)
|
|
10
10
|
[](https://glama.ai/mcp/servers/@arcadia-finance/mcp-server)
|
|
11
11
|
|
|
@@ -22,40 +22,52 @@ Designed for AI agents (Claude, Cursor, etc.) to interact with Arcadia onchain.
|
|
|
22
22
|
|
|
23
23
|
### Read Tools
|
|
24
24
|
|
|
25
|
-
| Tool | Description
|
|
26
|
-
| ------------------------------ |
|
|
27
|
-
| `read.account.info` | Account overview: health factor, collateral, debt, positions, liquidation price
|
|
28
|
-
| `read.account.history` | Historical account value over time.
|
|
29
|
-
| `read.account.pnl` | PnL and yield data for an account.
|
|
30
|
-
| `read.
|
|
31
|
-
| `read.wallet.balances` | On-chain ERC20 balances and native ETH for a wallet address.
|
|
32
|
-
| `read.wallet.
|
|
33
|
-
| `read.points`
|
|
34
|
-
| `read.
|
|
35
|
-
| `read.
|
|
36
|
-
| `read.
|
|
37
|
-
| `read.
|
|
25
|
+
| Tool | Description |
|
|
26
|
+
| ------------------------------ | ----------------------------------------------------------------------------------------------------------- |
|
|
27
|
+
| `read.account.info` | Account overview: health factor, collateral, debt, positions, liquidation price, automation status. |
|
|
28
|
+
| `read.account.history` | Historical account value over time. |
|
|
29
|
+
| `read.account.pnl` | PnL and yield data for an account. |
|
|
30
|
+
| `read.wallet.accounts` | List all Arcadia accounts owned by a wallet address. |
|
|
31
|
+
| `read.wallet.balances` | On-chain ERC20 balances and native ETH for a wallet address. |
|
|
32
|
+
| `read.wallet.allowances` | Check ERC20 token allowances for a spender. Use before `write.wallet.approve` to avoid redundant approvals. |
|
|
33
|
+
| `read.wallet.points` | Points balance for a specific wallet address. |
|
|
34
|
+
| `read.asset.list` | Supported collateral assets with addresses, types, decimals. |
|
|
35
|
+
| `read.asset.prices` | USD prices for one or more asset addresses. |
|
|
36
|
+
| `read.pool.list` | All lending pools: TVL, APY, utilization, liquidity. |
|
|
37
|
+
| `read.pool.info` | Single pool detail with APY history over time. |
|
|
38
|
+
| `read.point_leaderboard` | Paginated Arcadia points leaderboard. |
|
|
39
|
+
| `read.strategy.list` | LP strategies with APY, underlyings, pool info. Supports featured filter and pagination. |
|
|
40
|
+
| `read.strategy.info` | Full detail for a specific LP strategy: APY per range width, pool config. |
|
|
41
|
+
| `read.strategy.recommendation` | Rebalancing recommendation for an account. |
|
|
42
|
+
| `read.guides` | Reference guides: automation setup, strategy selection, strategy templates. |
|
|
43
|
+
| `read.asset_manager.intents` | Available automation intents with tool names, required params, and supported chains. |
|
|
38
44
|
|
|
39
45
|
### Write Tools
|
|
40
46
|
|
|
41
47
|
All write tools return unsigned transactions as `{ to, data, value, chainId }`.
|
|
42
48
|
|
|
43
|
-
| Tool
|
|
44
|
-
|
|
|
45
|
-
| `write.wallet.approve`
|
|
46
|
-
| `write.account.create`
|
|
47
|
-
| `write.account.deposit`
|
|
48
|
-
| `write.account.withdraw`
|
|
49
|
-
| `write.account.borrow`
|
|
50
|
-
| `write.account.repay`
|
|
51
|
-
| `write.account.add_liquidity`
|
|
52
|
-
| `write.account.remove_liquidity`
|
|
53
|
-
| `write.account.swap`
|
|
54
|
-
| `write.account.deleverage`
|
|
55
|
-
| `write.account.close`
|
|
56
|
-
| `write.account.stake`
|
|
57
|
-
| `write.asset_manager.
|
|
58
|
-
| `write.asset_manager.
|
|
49
|
+
| Tool | Description |
|
|
50
|
+
| ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
51
|
+
| `write.wallet.approve` | Approve an ERC20 token for spending. Required before depositing into an account. Call `read.wallet.allowances` first to check if already approved. |
|
|
52
|
+
| `write.account.create` | Create a new Arcadia account via Factory. |
|
|
53
|
+
| `write.account.deposit` | Deposit ERC20 tokens into an account. |
|
|
54
|
+
| `write.account.withdraw` | Withdraw assets from an account. |
|
|
55
|
+
| `write.account.borrow` | Borrow from a lending pool. |
|
|
56
|
+
| `write.account.repay` | Repay debt to a lending pool from wallet. |
|
|
57
|
+
| `write.account.add_liquidity` | Flash-action: deposit + swap + mint LP + optional leverage, atomically. |
|
|
58
|
+
| `write.account.remove_liquidity` | Remove/decrease LP position liquidity. |
|
|
59
|
+
| `write.account.swap` | Swap assets within an account (backend-routed). |
|
|
60
|
+
| `write.account.deleverage` | Repay debt by selling collateral (swap + repay in one tx). |
|
|
61
|
+
| `write.account.close` | Atomic close: burn LP + swap + repay debt in one tx. |
|
|
62
|
+
| `write.account.stake` | Stake, unstake, or claim rewards for LP positions. |
|
|
63
|
+
| `write.asset_manager.rebalancer` | Encode rebalancer automation args (strategy config, triggers, compound mode). |
|
|
64
|
+
| `write.asset_manager.compounder` | Encode standalone compounder args. |
|
|
65
|
+
| `write.asset_manager.compounder_staked` | Encode compounder + CowSwap coupled args (sell rewards, buy target token). |
|
|
66
|
+
| `write.asset_manager.yield_claimer` | Encode yield claimer args (claim fees to recipient). |
|
|
67
|
+
| `write.asset_manager.yield_claimer_cowswap` | Encode yield claimer + CowSwap coupled args. |
|
|
68
|
+
| `write.asset_manager.cow_swapper` | Encode direct CowSwap mode args (Base only). |
|
|
69
|
+
| `write.asset_manager.merkl_operator` | Encode Merkl operator args (claim external rewards). |
|
|
70
|
+
| `write.account.set_asset_managers` | Build unsigned setAssetManagers tx from encoded intent args. Combine multiple intents by merging arrays. |
|
|
59
71
|
|
|
60
72
|
### Dev Tools
|
|
61
73
|
|
|
@@ -112,11 +124,15 @@ yarn build
|
|
|
112
124
|
|
|
113
125
|
**Environment variables:**
|
|
114
126
|
|
|
115
|
-
| Variable | Required | Description
|
|
116
|
-
| ------------------ | -------- |
|
|
117
|
-
| `RPC_URL_BASE` | No | RPC URL for Base (8453).
|
|
118
|
-
| `RPC_URL_UNICHAIN` | No | RPC URL for Unichain (130).
|
|
119
|
-
| `PK` | No | Private key (hex) for dev-only `dev.send` tool.
|
|
127
|
+
| Variable | Required | Default | Transport | Description |
|
|
128
|
+
| ------------------ | -------- | ----------------------------- | --------- | -------------------------------------------------------------- |
|
|
129
|
+
| `RPC_URL_BASE` | No | Public RPC | Both | RPC URL for Base (8453). |
|
|
130
|
+
| `RPC_URL_UNICHAIN` | No | Public RPC | Both | RPC URL for Unichain (130). |
|
|
131
|
+
| `PK` | No | — | Both | Private key (hex) for dev-only `dev.send` tool. |
|
|
132
|
+
| `TRANSPORT` | No | `stdio` | — | Transport mode: `stdio` or `http`. |
|
|
133
|
+
| `PORT` | No | `3000` | HTTP | Listen port for HTTP transport. |
|
|
134
|
+
| `ALLOWED_ORIGINS` | No | `https://mcp.arcadia.finance` | HTTP | Comma-separated allowed Origin headers (CORS / DNS rebinding). |
|
|
135
|
+
| `RATE_LIMIT_RPM` | No | `60` | HTTP | Max requests per minute per session. |
|
|
120
136
|
|
|
121
137
|
**Supported chains:** Base (8453), Unichain (130)
|
|
122
138
|
|
package/dist/config/addresses.js
CHANGED
|
@@ -77,17 +77,50 @@ const CHAIN_STANDALONE_AMS = {
|
|
|
77
77
|
130: new Set(["merklOperator", "gasRelayer"]),
|
|
78
78
|
};
|
|
79
79
|
const CHAIN_NAMES = { 8453: "Base", 130: "Unichain" };
|
|
80
|
+
// Map LP asset names → dex_protocol values
|
|
81
|
+
const LP_NAME_TO_POOL_PROTOCOL = {
|
|
82
|
+
UniV3: "uniV3",
|
|
83
|
+
UniV4: "uniV4",
|
|
84
|
+
slipstream: "slipstream",
|
|
85
|
+
slipstream_v2: "slipstream_v2",
|
|
86
|
+
"Staked Slipstream": "staked_slipstream",
|
|
87
|
+
"Staked Slipstream V2": "staked_slipstream_v2",
|
|
88
|
+
"Wrapped Staked Slipstream": "staked_slipstream",
|
|
89
|
+
"Wrapped Staked Slipstream V2": "staked_slipstream_v2",
|
|
90
|
+
"Wrapped Aerodrome": "slipstream",
|
|
91
|
+
"Staked Aerodrome": "staked_slipstream",
|
|
92
|
+
};
|
|
93
|
+
export function lpNameToPoolProtocol(name) {
|
|
94
|
+
return LP_NAME_TO_POOL_PROTOCOL[name] ?? null;
|
|
95
|
+
}
|
|
96
|
+
// Map internal AM keys to user-facing dex_protocol values (used in error messages and account info)
|
|
97
|
+
export const AM_KEY_TO_POOL_PROTOCOL = {
|
|
98
|
+
slipstreamV1: "slipstream",
|
|
99
|
+
slipstreamV2: "slipstream_v2",
|
|
100
|
+
uniV3: "uniV3",
|
|
101
|
+
uniV4: "uniV4",
|
|
102
|
+
};
|
|
80
103
|
export function getAmProtocolAddress(chainId, category, protocol) {
|
|
81
104
|
if (!CHAIN_PROTOCOLS[chainId].has(protocol)) {
|
|
82
|
-
const available = [...CHAIN_PROTOCOLS[chainId]]
|
|
83
|
-
|
|
105
|
+
const available = [...CHAIN_PROTOCOLS[chainId]]
|
|
106
|
+
.map((k) => AM_KEY_TO_POOL_PROTOCOL[k])
|
|
107
|
+
.join(", ");
|
|
108
|
+
throw new Error(`${AM_KEY_TO_POOL_PROTOCOL[protocol]} is not available on ${CHAIN_NAMES[chainId]} (${chainId}). Available protocols: ${available}.`);
|
|
84
109
|
}
|
|
85
110
|
return AM_ADDRESSES[category][protocol];
|
|
86
111
|
}
|
|
112
|
+
const STANDALONE_TO_USER_FACING = {
|
|
113
|
+
merklOperator: "merkl_operator",
|
|
114
|
+
gasRelayer: "gas_relayer",
|
|
115
|
+
cowSwapper: "cow_swapper",
|
|
116
|
+
};
|
|
87
117
|
export function getStandaloneAmAddress(chainId, am) {
|
|
88
118
|
if (!CHAIN_STANDALONE_AMS[chainId].has(am)) {
|
|
89
|
-
const
|
|
90
|
-
|
|
119
|
+
const supportedChains = Object.entries(CHAIN_STANDALONE_AMS)
|
|
120
|
+
.filter(([, ams]) => ams.has(am))
|
|
121
|
+
.map(([id]) => `${CHAIN_NAMES[Number(id)]} (${id})`)
|
|
122
|
+
.join(", ");
|
|
123
|
+
throw new Error(`${STANDALONE_TO_USER_FACING[am]} is not available on ${CHAIN_NAMES[chainId]} (${chainId}). Supported chains: ${supportedChains}.`);
|
|
91
124
|
}
|
|
92
125
|
return AM_ADDRESSES[am];
|
|
93
126
|
}
|
|
@@ -130,3 +163,25 @@ export const STATE_VIEWERS = {
|
|
|
130
163
|
8453: "0xA3c0c9b65baD0b08107Aa264b0f3dB444b867A71",
|
|
131
164
|
130: "0x86e8631A016F9068C3f085fAF484Ee3F5fDee8f2",
|
|
132
165
|
};
|
|
166
|
+
// LP position manager address (lowercase) → dex_protocol value
|
|
167
|
+
// Chain-specific: non-staked LP position manager addresses differ per chain
|
|
168
|
+
export const CHAIN_POSITION_MANAGERS = {
|
|
169
|
+
8453: {
|
|
170
|
+
"0x827922686190790b37229fd06084350e74485b72": "slipstream",
|
|
171
|
+
"0xa990c6a764b73bf43cee5bb40339c3322fb9d55f": "slipstream_v2",
|
|
172
|
+
"0x03a520b32c04bf3beef7beb72e919cf822ed34f1": "uniV3",
|
|
173
|
+
"0x7c5f5a4bbd8fd63184577525326123b519429bdc": "uniV4",
|
|
174
|
+
},
|
|
175
|
+
130: {
|
|
176
|
+
"0x991d5546c4b442b4c5fdc4c8b8b8d131deb24702": "slipstream",
|
|
177
|
+
"0x943e6e07a7e8e791dafc44083e54041d743c46e9": "uniV3",
|
|
178
|
+
"0x4529a01c7a0410167c5740c487a8de60232617bf": "uniV4",
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
// Universal staked/wrapped-staked position manager addresses (same on all chains)
|
|
182
|
+
export const UNIVERSAL_POSITION_MANAGERS = {
|
|
183
|
+
"0x1dc7a0f5336f52724b650e39174cfcbbedd67bf1": "staked_slipstream", // StakedSlipstreamAM V1
|
|
184
|
+
"0xbed6c3e35b9b1e044b3bc71465769edfdc0fdd4c": "staked_slipstream_v2", // StakedSlipstreamAM V2
|
|
185
|
+
"0xd74339e0f10fce96894916b93e5cc7de89c98272": "staked_slipstream", // WrappedStakedSlipstream V1
|
|
186
|
+
"0x147a2ccbaf4521ad209a2875ae0b3c496f4b25a4": "staked_slipstream_v2", // WrappedStakedSlipstream V2
|
|
187
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,37 @@ if (transportMode === "http") {
|
|
|
36
36
|
const express = (await import("express")).default;
|
|
37
37
|
const app = express();
|
|
38
38
|
const port = parseInt(process.env.PORT ?? "3000", 10);
|
|
39
|
+
const ALLOWED_ORIGINS = (process.env.ALLOWED_ORIGINS ?? "https://mcp.arcadia.finance")
|
|
40
|
+
.split(",")
|
|
41
|
+
.map((o) => o.trim());
|
|
42
|
+
function validateOrigin(req, res) {
|
|
43
|
+
const origin = req.headers.origin;
|
|
44
|
+
if (!origin)
|
|
45
|
+
return true; // non-browser clients (curl, SDK) don't send Origin
|
|
46
|
+
if (!ALLOWED_ORIGINS.includes(origin)) {
|
|
47
|
+
res.status(403).send("Forbidden: invalid origin");
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
res.setHeader("Access-Control-Allow-Origin", origin);
|
|
51
|
+
res.setHeader("Access-Control-Allow-Headers", "Content-Type, mcp-session-id");
|
|
52
|
+
res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
|
|
53
|
+
res.setHeader("Access-Control-Expose-Headers", "mcp-session-id");
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
app.options("/mcp", (req, res) => {
|
|
57
|
+
if (!validateOrigin(req, res))
|
|
58
|
+
return;
|
|
59
|
+
res.status(204).end();
|
|
60
|
+
});
|
|
61
|
+
const rateLimit = (await import("express-rate-limit")).default;
|
|
62
|
+
const rpm = parseInt(process.env.RATE_LIMIT_RPM ?? "60", 10);
|
|
63
|
+
app.use("/mcp", rateLimit({
|
|
64
|
+
windowMs: 60_000,
|
|
65
|
+
max: rpm,
|
|
66
|
+
keyGenerator: (req) => req.headers["mcp-session-id"] || req.ip || "unknown",
|
|
67
|
+
standardHeaders: true,
|
|
68
|
+
legacyHeaders: false,
|
|
69
|
+
}));
|
|
39
70
|
const SESSION_TTL_MS = 30 * 60 * 1000; // 30 minutes
|
|
40
71
|
const sessions = new Map();
|
|
41
72
|
function touchSession(id) {
|
|
@@ -89,6 +120,8 @@ if (transportMode === "http") {
|
|
|
89
120
|
res.send("ok");
|
|
90
121
|
});
|
|
91
122
|
app.post("/mcp", async (req, res) => {
|
|
123
|
+
if (!validateOrigin(req, res))
|
|
124
|
+
return;
|
|
92
125
|
const sessionId = req.headers["mcp-session-id"];
|
|
93
126
|
const existing = sessionId ? sessions.get(sessionId) : undefined;
|
|
94
127
|
if (existing) {
|
|
@@ -117,6 +150,8 @@ if (transportMode === "http") {
|
|
|
117
150
|
}
|
|
118
151
|
});
|
|
119
152
|
app.get("/mcp", async (req, res) => {
|
|
153
|
+
if (!validateOrigin(req, res))
|
|
154
|
+
return;
|
|
120
155
|
const sessionId = req.headers["mcp-session-id"];
|
|
121
156
|
if (!sessionId || !sessions.has(sessionId)) {
|
|
122
157
|
res.status(400).send("Invalid or missing session ID");
|
|
@@ -126,6 +161,8 @@ if (transportMode === "http") {
|
|
|
126
161
|
await sessions.get(sessionId).transport.handleRequest(req, res);
|
|
127
162
|
});
|
|
128
163
|
app.delete("/mcp", async (req, res) => {
|
|
164
|
+
if (!validateOrigin(req, res))
|
|
165
|
+
return;
|
|
129
166
|
const sessionId = req.headers["mcp-session-id"];
|
|
130
167
|
if (!sessionId || !sessions.has(sessionId)) {
|
|
131
168
|
res.status(400).send("Invalid or missing session ID");
|
|
@@ -18,7 +18,7 @@ export function registerWorkflowPrompts(server) {
|
|
|
18
18
|
"Steps:",
|
|
19
19
|
"1. Call read.account.info to get health factor, collateral, debt, positions, and automation status",
|
|
20
20
|
"2. Call read.account.pnl to check profitability and yield earned",
|
|
21
|
-
"3. If leveraged (health_factor < 1), call read.
|
|
21
|
+
"3. If leveraged (health_factor < 1), call read.pool.list to compare borrow APY vs fee APY",
|
|
22
22
|
"4. Call read.strategy.recommendation to check if rebalancing is needed",
|
|
23
23
|
"",
|
|
24
24
|
"Provide a summary covering:",
|
|
@@ -49,8 +49,8 @@ export function registerWorkflowPrompts(server) {
|
|
|
49
49
|
"",
|
|
50
50
|
"Steps:",
|
|
51
51
|
"1. Call read.strategy.list(featured_only: true) to see top LP strategies with fee APY",
|
|
52
|
-
"2. Call read.strategy.
|
|
53
|
-
"3. Call read.
|
|
52
|
+
"2. Call read.strategy.info(strategy_id: <id>) for promising ones to see APY per range width",
|
|
53
|
+
"3. Call read.pool.list to check borrow APY for leveraged strategies",
|
|
54
54
|
"4. Evaluate: net_APY = fee_APY - (leverage - 1) * borrow_APY > 0?",
|
|
55
55
|
"",
|
|
56
56
|
"For each viable strategy, assess:",
|
|
@@ -83,11 +83,14 @@ export function registerWorkflowPrompts(server) {
|
|
|
83
83
|
"Steps:",
|
|
84
84
|
"1. Call read.account.info to check current positions and which asset managers are already enabled",
|
|
85
85
|
"2. Identify the LP protocol (Slipstream V1/V2, Uniswap V3/V4) from the position",
|
|
86
|
-
"3.
|
|
87
|
-
"
|
|
88
|
-
" -
|
|
89
|
-
" -
|
|
90
|
-
" -
|
|
86
|
+
"3. Call read.asset_manager.intents to see available automations",
|
|
87
|
+
"4. For each automation to enable, call the matching write.asset_manager.* tool:",
|
|
88
|
+
" - Rebalancer: write.asset_manager.rebalancer (set dex_protocol, trigger ratios, compound_leftovers)",
|
|
89
|
+
" - Compounder: write.asset_manager.compounder or write.asset_manager.compounder_staked (with CowSwap)",
|
|
90
|
+
" - Yield Claimer: write.asset_manager.yield_claimer or write.asset_manager.yield_claimer_cowswap",
|
|
91
|
+
" - Merkl Operator: write.asset_manager.merkl_operator (set reward_recipient)",
|
|
92
|
+
" - CowSwap Direct: write.asset_manager.cow_swapper (Base only)",
|
|
93
|
+
"5. Merge arrays from multiple intent calls if combining, then call write.account.set_asset_managers",
|
|
91
94
|
"",
|
|
92
95
|
"Ask which automations to enable and walk through each one.",
|
|
93
96
|
].join("\n"),
|
package/dist/tools/dev/send.js
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { createWalletClient, createPublicClient, http } from "viem";
|
|
3
3
|
import { privateKeyToAccount } from "viem/accounts";
|
|
4
4
|
import { base, unichain } from "viem/chains";
|
|
5
|
+
import { DevSendOutput } from "../output-schemas.js";
|
|
5
6
|
import { validateAddress } from "../../utils/validation.js";
|
|
6
7
|
const VIEM_CHAINS = {
|
|
7
8
|
8453: base,
|
|
@@ -17,6 +18,7 @@ export function registerSendTool(server, chains) {
|
|
|
17
18
|
openWorldHint: true,
|
|
18
19
|
},
|
|
19
20
|
description: "DEV ONLY — Sign and broadcast an unsigned transaction using a local private key (PK env var). For production, use a dedicated wallet MCP server (Fireblocks, Safe, Turnkey, etc.) instead of this tool. Takes the transaction object returned by any write.* tool and submits it onchain.",
|
|
21
|
+
outputSchema: DevSendOutput,
|
|
20
22
|
inputSchema: {
|
|
21
23
|
to: z.string().describe("Target contract address"),
|
|
22
24
|
data: z.string().describe("Encoded calldata (hex)"),
|
|
@@ -67,20 +69,22 @@ export function registerSendTool(server, chains) {
|
|
|
67
69
|
chain,
|
|
68
70
|
});
|
|
69
71
|
const receipt = await client.waitForTransactionReceipt({ hash, timeout: 60_000 });
|
|
72
|
+
const result = {
|
|
73
|
+
signer: account.address,
|
|
74
|
+
txHash: receipt.transactionHash,
|
|
75
|
+
status: receipt.status,
|
|
76
|
+
blockNumber: Number(receipt.blockNumber),
|
|
77
|
+
gasLimit: Number(gasLimit),
|
|
78
|
+
gasUsed: Number(receipt.gasUsed),
|
|
79
|
+
};
|
|
70
80
|
return {
|
|
71
81
|
content: [
|
|
72
82
|
{
|
|
73
83
|
type: "text",
|
|
74
|
-
text: JSON.stringify(
|
|
75
|
-
signer: account.address,
|
|
76
|
-
txHash: receipt.transactionHash,
|
|
77
|
-
status: receipt.status,
|
|
78
|
-
blockNumber: Number(receipt.blockNumber),
|
|
79
|
-
gasLimit: Number(gasLimit),
|
|
80
|
-
gasUsed: Number(receipt.gasUsed),
|
|
81
|
-
}, null, 2),
|
|
84
|
+
text: JSON.stringify(result, null, 2),
|
|
82
85
|
},
|
|
83
86
|
],
|
|
87
|
+
structuredContent: result,
|
|
84
88
|
};
|
|
85
89
|
}
|
|
86
90
|
catch (err) {
|
package/dist/tools/index.js
CHANGED
|
@@ -5,14 +5,19 @@ import { registerStrategyTools } from "./read/strategy.js";
|
|
|
5
5
|
import { registerPointsTools } from "./read/points.js";
|
|
6
6
|
import { registerGuideTools } from "./read/guides.js";
|
|
7
7
|
import { registerWalletTools } from "./read/wallet.js";
|
|
8
|
+
import { registerAssetManagerTools } from "./read/asset-managers.js";
|
|
8
9
|
import { registerCreateTool } from "./write/account/create.js";
|
|
9
10
|
import { registerDepositTool } from "./write/account/deposit.js";
|
|
10
11
|
import { registerWithdrawTool } from "./write/account/withdraw.js";
|
|
11
12
|
import { registerBorrowTool } from "./write/account/borrow.js";
|
|
12
13
|
import { registerRepayTool } from "./write/account/repay.js";
|
|
13
14
|
import { registerApproveTool } from "./write/wallet/approve.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
15
|
+
import { registerRebalancerTool } from "./write/asset-managers/rebalancer.js";
|
|
16
|
+
import { registerCompounderTools } from "./write/asset-managers/compounder.js";
|
|
17
|
+
import { registerYieldClaimerTools } from "./write/asset-managers/yield-claimer.js";
|
|
18
|
+
import { registerCowSwapperTool } from "./write/asset-managers/cow-swapper.js";
|
|
19
|
+
import { registerMerklOperatorTool } from "./write/asset-managers/merkl-operator.js";
|
|
20
|
+
import { registerSetAssetManagersTool } from "./write/asset-managers/set-asset-managers.js";
|
|
16
21
|
import { registerSendTool } from "./dev/send.js";
|
|
17
22
|
import { registerAddLiquidityTool } from "./write/account/add-liquidity.js";
|
|
18
23
|
import { registerRemoveLiquidityTool } from "./write/account/remove-liquidity.js";
|
|
@@ -28,7 +33,8 @@ export function registerAllTools(server, api, chains) {
|
|
|
28
33
|
registerStrategyTools(server, api);
|
|
29
34
|
registerPointsTools(server, api);
|
|
30
35
|
registerGuideTools(server);
|
|
31
|
-
registerWalletTools(server, chains);
|
|
36
|
+
registerWalletTools(server, chains, api);
|
|
37
|
+
registerAssetManagerTools(server);
|
|
32
38
|
// Write tools — account
|
|
33
39
|
registerCreateTool(server, chains);
|
|
34
40
|
registerDepositTool(server, chains);
|
|
@@ -43,9 +49,13 @@ export function registerAllTools(server, api, chains) {
|
|
|
43
49
|
registerCloseTool(server, api, chains);
|
|
44
50
|
// Write tools — wallet
|
|
45
51
|
registerApproveTool(server, chains);
|
|
46
|
-
// Write tools — asset
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
// Write tools — asset managers
|
|
53
|
+
registerRebalancerTool(server, chains);
|
|
54
|
+
registerCompounderTools(server, chains);
|
|
55
|
+
registerYieldClaimerTools(server, chains);
|
|
56
|
+
registerCowSwapperTool(server, chains);
|
|
57
|
+
registerMerklOperatorTool(server, chains);
|
|
58
|
+
registerSetAssetManagersTool(server, chains);
|
|
49
59
|
// Dev tools
|
|
50
60
|
registerSendTool(server, chains);
|
|
51
61
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const Transaction = z.object({
|
|
3
|
+
to: z.string(),
|
|
4
|
+
data: z.string(),
|
|
5
|
+
value: z.string(),
|
|
6
|
+
chainId: z.number(),
|
|
7
|
+
});
|
|
8
|
+
export const SimpleTransactionOutput = z.object({
|
|
9
|
+
description: z.string(),
|
|
10
|
+
transaction: Transaction,
|
|
11
|
+
predicted_account_address: z.string().optional(),
|
|
12
|
+
});
|
|
13
|
+
export const BatchedTransactionOutput = z.object({
|
|
14
|
+
description: z.string().optional(),
|
|
15
|
+
transaction: Transaction,
|
|
16
|
+
tenderly_sim_url: z.string().optional(),
|
|
17
|
+
tenderly_sim_status: z.enum(["true", "false", "unavailable"]).optional(),
|
|
18
|
+
expected_value_change: z.string().optional(),
|
|
19
|
+
before: z
|
|
20
|
+
.object({ total_account_value: z.string(), used_margin: z.string() })
|
|
21
|
+
.passthrough()
|
|
22
|
+
.optional(),
|
|
23
|
+
after: z
|
|
24
|
+
.object({ total_account_value: z.string(), used_margin: z.string() })
|
|
25
|
+
.passthrough()
|
|
26
|
+
.optional(),
|
|
27
|
+
});
|
|
28
|
+
export const IntentOutput = z.object({
|
|
29
|
+
description: z.string().optional(),
|
|
30
|
+
asset_managers: z.array(z.string()),
|
|
31
|
+
statuses: z.array(z.boolean()),
|
|
32
|
+
datas: z.array(z.string()),
|
|
33
|
+
strategy_name: z.string().optional(),
|
|
34
|
+
});
|
|
35
|
+
export const WalletBalancesOutput = z.object({
|
|
36
|
+
native: z.object({
|
|
37
|
+
symbol: z.string(),
|
|
38
|
+
balance: z.string(),
|
|
39
|
+
formatted: z.string(),
|
|
40
|
+
}),
|
|
41
|
+
tokens: z.array(z.object({
|
|
42
|
+
address: z.string(),
|
|
43
|
+
symbol: z.string(),
|
|
44
|
+
decimals: z.number(),
|
|
45
|
+
balance: z.string(),
|
|
46
|
+
formatted: z.string(),
|
|
47
|
+
})),
|
|
48
|
+
});
|
|
49
|
+
export const WalletAllowanceOutput = z.object({
|
|
50
|
+
tokens: z.array(z.object({
|
|
51
|
+
address: z.string(),
|
|
52
|
+
symbol: z.string(),
|
|
53
|
+
decimals: z.number(),
|
|
54
|
+
allowance: z.string(),
|
|
55
|
+
formatted: z.string(),
|
|
56
|
+
is_max_approval: z.boolean(),
|
|
57
|
+
})),
|
|
58
|
+
});
|
|
59
|
+
export const DevSendOutput = z.object({
|
|
60
|
+
signer: z.string(),
|
|
61
|
+
txHash: z.string(),
|
|
62
|
+
status: z.string(),
|
|
63
|
+
blockNumber: z.number(),
|
|
64
|
+
gasLimit: z.number(),
|
|
65
|
+
gasUsed: z.number(),
|
|
66
|
+
});
|
|
67
|
+
export const AccountInfoOutput = z
|
|
68
|
+
.object({
|
|
69
|
+
account_version: z.number().nullable(),
|
|
70
|
+
overview: z.record(z.unknown()).nullable(),
|
|
71
|
+
liquidation_price: z.record(z.unknown()).nullable(),
|
|
72
|
+
automation: z.record(z.unknown()).optional(),
|
|
73
|
+
context_notes: z.array(z.string()).optional(),
|
|
74
|
+
})
|
|
75
|
+
.passthrough();
|
|
76
|
+
export const AccountListOutput = z.object({
|
|
77
|
+
accounts: z.array(z.record(z.unknown())),
|
|
78
|
+
});
|
|
79
|
+
export const AccountHistoryOutput = z.object({
|
|
80
|
+
history: z.array(z.record(z.unknown())),
|
|
81
|
+
});
|
|
82
|
+
export const AccountPnlOutput = z.object({
|
|
83
|
+
pnl_cost_basis: z.record(z.unknown()),
|
|
84
|
+
yield_earned: z.record(z.unknown()),
|
|
85
|
+
});
|
|
86
|
+
export const AssetListOutput = z.object({
|
|
87
|
+
total: z.number(),
|
|
88
|
+
assets: z.array(z.object({
|
|
89
|
+
address: z.unknown(),
|
|
90
|
+
symbol: z.unknown(),
|
|
91
|
+
decimals: z.unknown(),
|
|
92
|
+
type: z.unknown(),
|
|
93
|
+
})),
|
|
94
|
+
});
|
|
95
|
+
export const AssetPricesOutput = z.object({
|
|
96
|
+
prices: z.record(z.number()),
|
|
97
|
+
});
|
|
98
|
+
export const PoolListOutput = z.object({
|
|
99
|
+
pools: z.array(z.record(z.unknown())),
|
|
100
|
+
});
|
|
101
|
+
export const PoolDetailOutput = z.object({
|
|
102
|
+
pool: z.record(z.unknown()),
|
|
103
|
+
apy_history: z.array(z.record(z.unknown())),
|
|
104
|
+
});
|
|
105
|
+
export const PointsWalletOutput = z.record(z.unknown());
|
|
106
|
+
export const PointsLeaderboardOutput = z.object({
|
|
107
|
+
total: z.number(),
|
|
108
|
+
offset: z.number(),
|
|
109
|
+
limit: z.number(),
|
|
110
|
+
leaderboard: z.array(z.record(z.unknown())),
|
|
111
|
+
});
|
|
112
|
+
export const StrategyListOutput = z.object({
|
|
113
|
+
total: z.number(),
|
|
114
|
+
offset: z.number(),
|
|
115
|
+
limit: z.number(),
|
|
116
|
+
strategies: z.array(z.record(z.unknown())),
|
|
117
|
+
});
|
|
118
|
+
export const StrategyDetailOutput = z.record(z.unknown());
|
|
119
|
+
export const StrategyRecommendationOutput = z.record(z.unknown());
|
|
120
|
+
export const GuideOutput = z.object({
|
|
121
|
+
topic: z.string(),
|
|
122
|
+
content: z.string(),
|
|
123
|
+
});
|
|
124
|
+
export const IntentsListOutput = z.object({
|
|
125
|
+
automations: z.array(z.record(z.unknown())),
|
|
126
|
+
shared_params: z.array(z.string()),
|
|
127
|
+
usage: z.string(),
|
|
128
|
+
});
|