@arcadia-finance/mcp-server 0.4.5 → 0.5.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 +5 -10
- package/dist/clients/api.js +23 -0
- package/dist/config/addresses.js +49 -188
- package/dist/index.js +4 -2
- package/dist/prompts/workflows.js +15 -13
- package/dist/resources/guides.js +1 -1
- package/dist/tools/dev/send.js +7 -5
- package/dist/tools/index.js +4 -14
- package/dist/tools/output-schemas.js +42 -6
- package/dist/tools/read/account.js +80 -42
- package/dist/tools/read/asset-managers.js +138 -113
- package/dist/tools/read/guides.js +3 -3
- package/dist/tools/write/asset-managers/automations.js +241 -0
- package/dist/tools/write/asset-managers/intents.js +247 -0
- package/dist/tools/write/asset-managers/shared.js +0 -26
- package/dist/utils/http-config.js +37 -0
- package/dist/utils/validation.js +16 -0
- package/llms-full.txt +39 -80
- package/llms.txt +9 -14
- package/package.json +1 -1
- package/server.json +2 -2
- package/skills/clamm-liquidity/SKILL.md +90 -69
- package/skills/clamm-liquidity/automation.md +153 -76
- package/skills/clamm-liquidity/selection.md +6 -5
- package/skills/clamm-liquidity/strategies.md +40 -34
- package/skills/openclaw/SKILL.md +3 -3
- package/skills/openclaw/contracts.md +29 -16
- package/dist/tools/write/asset-managers/compounder.js +0 -113
- package/dist/tools/write/asset-managers/cow-swapper.js +0 -50
- package/dist/tools/write/asset-managers/encoding.js +0 -162
- package/dist/tools/write/asset-managers/merkl-operator.js +0 -52
- package/dist/tools/write/asset-managers/rebalancer.js +0 -109
- package/dist/tools/write/asset-managers/set-asset-managers.js +0 -76
- package/dist/tools/write/asset-managers/yield-claimer.js +0 -117
package/README.md
CHANGED
|
@@ -40,7 +40,8 @@ Designed for AI agents (Claude, Cursor, etc.) to interact with Arcadia onchain.
|
|
|
40
40
|
| `read.strategy.info` | Full detail for a specific LP strategy: APY per range width, pool config. |
|
|
41
41
|
| `read.strategy.recommendation` | Rebalancing recommendation for an account. |
|
|
42
42
|
| `read.guides` | Reference guides: automation setup, strategy selection, strategy templates. |
|
|
43
|
-
| `read.asset_manager.intents` |
|
|
43
|
+
| `read.asset_manager.intents` | Automation intents and their params; add `account_address` for live per-account availability. |
|
|
44
|
+
| `read.asset_manager.current` | Automations enabled on an account: decoded config, mapped intents, Merkl state, superseded managers. |
|
|
44
45
|
|
|
45
46
|
### Write Tools
|
|
46
47
|
|
|
@@ -62,14 +63,8 @@ All write tools return unsigned transactions as `{ to, data, value, chainId }`.
|
|
|
62
63
|
| `write.account.deleverage` | Repay debt by selling collateral (swap + repay in one tx). |
|
|
63
64
|
| `write.account.close` | Atomic close: burn LP + swap + repay debt in one tx. |
|
|
64
65
|
| `write.account.stake` | Stake, unstake, or claim rewards for LP positions. |
|
|
65
|
-
| `write.
|
|
66
|
-
| `write.
|
|
67
|
-
| `write.asset_manager.compounder_staked` | Encode compounder + CowSwap coupled args (sell rewards, buy target token). |
|
|
68
|
-
| `write.asset_manager.yield_claimer` | Encode yield claimer args (claim fees to recipient). |
|
|
69
|
-
| `write.asset_manager.yield_claimer_cowswap` | Encode yield claimer + CowSwap coupled args. |
|
|
70
|
-
| `write.asset_manager.cow_swapper` | Encode direct CowSwap mode args (Base only). |
|
|
71
|
-
| `write.asset_manager.merkl_operator` | Encode Merkl operator args (claim external rewards). |
|
|
72
|
-
| `write.account.set_asset_managers` | Build unsigned setAssetManagers tx from encoded intent args. Combine multiple intents by merging arrays. |
|
|
66
|
+
| `write.account.automations` | Configure automations from an intents array (full desired state). Returns the unsigned setAssetManagers tx. |
|
|
67
|
+
| `write.account.automations_delta` | Enable/disable individual automations, leaving the rest untouched. |
|
|
73
68
|
|
|
74
69
|
### Dev Tools
|
|
75
70
|
|
|
@@ -217,7 +212,7 @@ Available skills:
|
|
|
217
212
|
|
|
218
213
|
| Skill | Description |
|
|
219
214
|
| ----------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
220
|
-
| `clamm-liquidity` | Concentrated liquidity management: concepts,
|
|
215
|
+
| `clamm-liquidity` | Concentrated liquidity management: concepts, intent-based automation, and step-by-step workflows. |
|
|
221
216
|
|
|
222
217
|
## Reporting Issues
|
|
223
218
|
|
package/dist/clients/api.js
CHANGED
|
@@ -192,4 +192,27 @@ export class ArcadiaApiClient {
|
|
|
192
192
|
position_id: asset_id,
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
|
+
// ── Automations (intent compiler) ────────────────────────────────
|
|
196
|
+
// The backend owns intent resolution, compatibility validation and metadata
|
|
197
|
+
// encoding. These endpoints return finished setAssetManagers calldata.
|
|
198
|
+
async previewAutomations(account, chainId, body) {
|
|
199
|
+
return this.post(`/automations/${account}/preview?chain_id=${chainId}`, body);
|
|
200
|
+
}
|
|
201
|
+
async saveAutomations(account, chainId, body) {
|
|
202
|
+
return this.post(`/automations/${account}/save?chain_id=${chainId}`, body);
|
|
203
|
+
}
|
|
204
|
+
async applyAutomationsDelta(account, chainId, body) {
|
|
205
|
+
return this.post(`/automations/${account}/apply?chain_id=${chainId}`, body);
|
|
206
|
+
}
|
|
207
|
+
async getCurrentAutomations(account, chainId) {
|
|
208
|
+
return this.get(`/automations/${account}`, {
|
|
209
|
+
chain_id: chainId,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
async getAvailableAutomations(account, chainId, positionId) {
|
|
213
|
+
const params = { chain_id: chainId };
|
|
214
|
+
if (positionId !== undefined)
|
|
215
|
+
params.position_id = positionId;
|
|
216
|
+
return this.get(`/automations/${account}/available`, params);
|
|
217
|
+
}
|
|
195
218
|
}
|
package/dist/config/addresses.js
CHANGED
|
@@ -62,196 +62,40 @@ export const TOKENS = {
|
|
|
62
62
|
WSTETH: { address: "0x1F32b1c2345538c0c6f582fCB022739c4A194Ebb", decimals: 18 },
|
|
63
63
|
},
|
|
64
64
|
};
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const COMPOUNDERS_V2_1_1 = {
|
|
86
|
-
slipstreamV1: "0x467837f44A71e3eAB90AEcfC995c84DC6B3cfCF7",
|
|
87
|
-
slipstreamV2: "0x35e59448C7145482E56212510cC689612AB4F61f",
|
|
88
|
-
slipstreamV3: "0xd42A3Ac56456bD5422835B36C35Cacb6448ddCd9",
|
|
89
|
-
uniV3: "0x02e1fa043214E51eDf1F0478c6D0d3D5658a2DC3",
|
|
90
|
-
uniV4: "0xAA95c9c402b195D8690eCaea2341a76e3266B189",
|
|
91
|
-
};
|
|
92
|
-
const COMPOUNDERS_V2_0_1 = {
|
|
93
|
-
slipstreamV1: "0x4694c34d153EE777CC07d01AC433bcC010A20EBd",
|
|
94
|
-
uniV3: "0x80D3548bc54710d46201D554712E8638fD51326D",
|
|
95
|
-
uniV4: "0xCfF15E24a453aFAd454533E6D10889A84e2A68e1",
|
|
96
|
-
};
|
|
97
|
-
const YIELD_CLAIMERS_V2_1_1 = {
|
|
98
|
-
slipstreamV1: "0x5a8278D37b7a787574b6Aa7E18d8C02D994f18Ba",
|
|
99
|
-
slipstreamV2: "0xc8bF4B2c740FF665864E9494832520f18822871C",
|
|
100
|
-
slipstreamV3: "0x8c1Fbf38118fD5A704b6E7babcB7AF1a9A291980",
|
|
101
|
-
uniV3: "0x75Ed28EA8601Ce9F5FbcAB1c2428f04A57aFaA16",
|
|
102
|
-
uniV4: "0xD8aa21AB7f9B8601CB7d7A776D3AFA1602d5D8D4",
|
|
103
|
-
};
|
|
104
|
-
const YIELD_CLAIMERS_V2_0_1 = {
|
|
105
|
-
slipstreamV1: "0x1f75aBF8a24782053B351D9b4EA6d1236ED59105",
|
|
106
|
-
uniV3: "0x40462e71Effd9974Fee04B6b327B701D663f753e",
|
|
107
|
-
uniV4: "0x3BC2B398eEEE9807ff76fdb4E11526dE0Ee80cEa",
|
|
108
|
-
};
|
|
109
|
-
// Deployed versions per chain, newest first. The first entry is treated as
|
|
110
|
-
// the "current" version (used for new registrations). Older entries are
|
|
111
|
-
// probed in read.account.info so users registered on older versions are
|
|
112
|
-
// reported as active. See multichain-deploy-scripts Arcadia.sol for source.
|
|
113
|
-
const CHAIN_AM_VERSIONS = {
|
|
114
|
-
8453: {
|
|
115
|
-
rebalancers: [REBALANCERS_V2_1_1, REBALANCERS_V2_1_0, REBALANCERS_V2_0_1],
|
|
116
|
-
compounders: [COMPOUNDERS_V2_1_1, COMPOUNDERS_V2_0_1],
|
|
117
|
-
yieldClaimers: [YIELD_CLAIMERS_V2_1_1, YIELD_CLAIMERS_V2_0_1],
|
|
118
|
-
},
|
|
119
|
-
130: {
|
|
120
|
-
rebalancers: [REBALANCERS_V2_1_1, REBALANCERS_V2_1_0],
|
|
121
|
-
compounders: [COMPOUNDERS_V2_1_1],
|
|
122
|
-
yieldClaimers: [YIELD_CLAIMERS_V2_1_1],
|
|
123
|
-
},
|
|
124
|
-
10: {
|
|
125
|
-
rebalancers: [REBALANCERS_V2_1_1],
|
|
126
|
-
compounders: [COMPOUNDERS_V2_1_1],
|
|
127
|
-
yieldClaimers: [YIELD_CLAIMERS_V2_1_1],
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
const STANDALONE_AM_ADDRESSES = {
|
|
131
|
-
merklOperator: "0x969F0251360b9Cf11c68f6Ce9587924c1B8b42C6",
|
|
132
|
-
gasRelayer: "0xD938C8d04cF91094fecAF0A2018EAac483a40137",
|
|
133
|
-
cowSwapper: "0xFfC742E68D41389BE9Ef1aFD518F036064DA2Bb6",
|
|
134
|
-
};
|
|
135
|
-
// Per-chain availability — update these when deploying to new chains.
|
|
136
|
-
// Slipstream V3 position manager is only live on Base; Unichain and Optimism have V1 only.
|
|
137
|
-
const CHAIN_PROTOCOLS = {
|
|
138
|
-
8453: new Set(["slipstreamV1", "slipstreamV2", "slipstreamV3", "uniV3", "uniV4"]),
|
|
139
|
-
130: new Set(["slipstreamV1", "uniV3", "uniV4"]),
|
|
140
|
-
10: new Set(["slipstreamV1", "uniV3", "uniV4"]),
|
|
141
|
-
};
|
|
142
|
-
const CHAIN_STANDALONE_AMS = {
|
|
143
|
-
8453: new Set(["merklOperator", "gasRelayer", "cowSwapper"]),
|
|
144
|
-
130: new Set(["merklOperator", "gasRelayer"]),
|
|
145
|
-
10: new Set(["merklOperator", "gasRelayer"]),
|
|
146
|
-
};
|
|
147
|
-
const CHAIN_NAMES = { 8453: "Base", 130: "Unichain", 10: "Optimism" };
|
|
148
|
-
// Map LP asset names → dex_protocol values
|
|
149
|
-
const LP_NAME_TO_POOL_PROTOCOL = {
|
|
150
|
-
UniV3: "uniV3",
|
|
151
|
-
UniV4: "uniV4",
|
|
152
|
-
slipstream: "slipstream",
|
|
65
|
+
// Asset-manager addresses are NOT duplicated here. The automations backend owns
|
|
66
|
+
// the address book (current + superseded deployments, per chain and protocol) and
|
|
67
|
+
// returns finished setAssetManagers calldata, so the only mapping the MCP server
|
|
68
|
+
// needs is between the backend's protocol vocabulary and the dex_protocol values
|
|
69
|
+
// the read tools report.
|
|
70
|
+
/** Asset-manager groups the automations reader can report on an account. */
|
|
71
|
+
export const AUTOMATION_GROUPS = [
|
|
72
|
+
"rebalancer",
|
|
73
|
+
"compounder",
|
|
74
|
+
"yield_claimer",
|
|
75
|
+
"cow_swapper",
|
|
76
|
+
"merkl_operator",
|
|
77
|
+
];
|
|
78
|
+
// The gas relayer pulls deposited AAA to pay for rebalances beyond the free
|
|
79
|
+
// quota. It is registered as an asset manager but is not part of the automations
|
|
80
|
+
// address book (no intent configures it), so it is not in the backend's reader
|
|
81
|
+
// and stays here. Same address on every supported chain.
|
|
82
|
+
export const GAS_RELAYER = "0xD938C8d04cF91094fecAF0A2018EAac483a40137";
|
|
83
|
+
const BACKEND_PROTOCOL_TO_DEX_PROTOCOL = {
|
|
84
|
+
slipstream_v1: "slipstream",
|
|
153
85
|
slipstream_v2: "slipstream_v2",
|
|
154
86
|
slipstream_v3: "slipstream_v3",
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
export function
|
|
165
|
-
return
|
|
166
|
-
}
|
|
167
|
-
// Map internal AM keys to user-facing dex_protocol values (used in error messages and account info)
|
|
168
|
-
export const AM_KEY_TO_POOL_PROTOCOL = {
|
|
169
|
-
slipstreamV1: "slipstream",
|
|
170
|
-
slipstreamV2: "slipstream_v2",
|
|
171
|
-
slipstreamV3: "slipstream_v3",
|
|
172
|
-
uniV3: "uniV3",
|
|
173
|
-
uniV4: "uniV4",
|
|
174
|
-
};
|
|
175
|
-
// User-facing dex_protocol values available on a chain. Slipstream AMs are
|
|
176
|
-
// shared between plain and staked pools, so each slipstreamV* on a chain
|
|
177
|
-
// contributes both `slipstream_vN` and `staked_slipstream_vN`.
|
|
178
|
-
export function getChainDexProtocols(chainId) {
|
|
179
|
-
const values = [];
|
|
180
|
-
for (const protocol of CHAIN_PROTOCOLS[chainId]) {
|
|
181
|
-
const base = AM_KEY_TO_POOL_PROTOCOL[protocol];
|
|
182
|
-
values.push(base);
|
|
183
|
-
if (protocol.startsWith("slipstream")) {
|
|
184
|
-
values.push(base.replace(/^slipstream/, "staked_slipstream"));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return values;
|
|
188
|
-
}
|
|
189
|
-
export function getAmProtocolAddress(chainId, category, protocol) {
|
|
190
|
-
if (!CHAIN_PROTOCOLS[chainId].has(protocol)) {
|
|
191
|
-
const available = [...CHAIN_PROTOCOLS[chainId]]
|
|
192
|
-
.map((k) => AM_KEY_TO_POOL_PROTOCOL[k])
|
|
193
|
-
.join(", ");
|
|
194
|
-
throw new Error(`${AM_KEY_TO_POOL_PROTOCOL[protocol]} is not available on ${CHAIN_NAMES[chainId]} (${chainId}). Available protocols: ${available}.`);
|
|
195
|
-
}
|
|
196
|
-
// Write tools always target the current (newest) version for that chain.
|
|
197
|
-
const current = CHAIN_AM_VERSIONS[chainId][category][0][protocol];
|
|
198
|
-
if (!current) {
|
|
199
|
-
throw new Error(`No ${category} address for ${AM_KEY_TO_POOL_PROTOCOL[protocol]} on ${CHAIN_NAMES[chainId]} (${chainId}).`);
|
|
200
|
-
}
|
|
201
|
-
return current;
|
|
202
|
-
}
|
|
203
|
-
const STANDALONE_TO_USER_FACING = {
|
|
204
|
-
merklOperator: "merkl_operator",
|
|
205
|
-
gasRelayer: "gas_relayer",
|
|
206
|
-
cowSwapper: "cow_swapper",
|
|
207
|
-
};
|
|
208
|
-
export function getStandaloneAmAddress(chainId, am) {
|
|
209
|
-
if (!CHAIN_STANDALONE_AMS[chainId].has(am)) {
|
|
210
|
-
const supportedChains = Object.entries(CHAIN_STANDALONE_AMS)
|
|
211
|
-
.filter(([, ams]) => ams.has(am))
|
|
212
|
-
.map(([id]) => `${CHAIN_NAMES[Number(id)]} (${id})`)
|
|
213
|
-
.join(", ");
|
|
214
|
-
throw new Error(`${STANDALONE_TO_USER_FACING[am]} is not available on ${CHAIN_NAMES[chainId]} (${chainId}). Supported chains: ${supportedChains}.`);
|
|
215
|
-
}
|
|
216
|
-
return STANDALONE_AM_ADDRESSES[am];
|
|
87
|
+
slipstream_v3_op: "slipstream_v3",
|
|
88
|
+
uniswap_v3: "uniV3",
|
|
89
|
+
uniswap_v4: "uniV4",
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Backend protocol name to the dex_protocol value the read tools use.
|
|
93
|
+
* Returns null for an unrecognised name so callers can surface it rather than
|
|
94
|
+
* silently reporting a wrong protocol.
|
|
95
|
+
*/
|
|
96
|
+
export function backendProtocolToDexProtocol(protocol) {
|
|
97
|
+
return BACKEND_PROTOCOL_TO_DEX_PROTOCOL[protocol] ?? null;
|
|
217
98
|
}
|
|
218
|
-
const CATEGORY_TO_GROUP = {
|
|
219
|
-
rebalancers: "rebalancer",
|
|
220
|
-
compounders: "compounder",
|
|
221
|
-
yieldClaimers: "yield_claimer",
|
|
222
|
-
};
|
|
223
|
-
const STANDALONE_TO_GROUP = {
|
|
224
|
-
merklOperator: "merkl_operator",
|
|
225
|
-
gasRelayer: "gas_relayer",
|
|
226
|
-
cowSwapper: "cow_swapper",
|
|
227
|
-
};
|
|
228
|
-
export function getChainAmChecks(chainId) {
|
|
229
|
-
const protocols = CHAIN_PROTOCOLS[chainId];
|
|
230
|
-
const standalone = CHAIN_STANDALONE_AMS[chainId];
|
|
231
|
-
const checks = [];
|
|
232
|
-
// Fan out across every deployed version so users registered on an older
|
|
233
|
-
// version (e.g. V2.1.0 on Base) are still reported as active.
|
|
234
|
-
for (const category of ["rebalancers", "compounders", "yieldClaimers"]) {
|
|
235
|
-
for (const versionMap of CHAIN_AM_VERSIONS[chainId][category]) {
|
|
236
|
-
for (const protocol of protocols) {
|
|
237
|
-
const address = versionMap[protocol];
|
|
238
|
-
if (!address)
|
|
239
|
-
continue;
|
|
240
|
-
checks.push({ group: CATEGORY_TO_GROUP[category], protocol, address });
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
for (const am of standalone) {
|
|
245
|
-
checks.push({
|
|
246
|
-
group: STANDALONE_TO_GROUP[am],
|
|
247
|
-
protocol: null,
|
|
248
|
-
address: STANDALONE_AM_ADDRESSES[am],
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
return checks;
|
|
252
|
-
}
|
|
253
|
-
// Minimal strategy hook — required for rebalancer onSetAssetManager callback
|
|
254
|
-
export const MINIMAL_STRATEGY_HOOK = "0x13beD1A58d87c0454872656c5328103aAe5eB86A";
|
|
255
99
|
// Chain-specific addresses
|
|
256
100
|
export const STATE_VIEWERS = {
|
|
257
101
|
8453: "0xA3c0c9b65baD0b08107Aa264b0f3dB444b867A71",
|
|
@@ -275,11 +119,14 @@ export const CHAIN_POSITION_MANAGERS = {
|
|
|
275
119
|
},
|
|
276
120
|
10: {
|
|
277
121
|
"0x416b433906b1b72fa758e166e239c43d68dc6f29": "slipstream", // Velodrome Slipstream V1
|
|
122
|
+
"0xf7f8ccce99ca2896ec75d3a399d152db96808399": "slipstream_v3",
|
|
278
123
|
"0xc36442b4a4522e871399cd717abdd847ab11fe88": "uniV3",
|
|
279
124
|
"0x3c3ea4b57a46241e54610e5f022e5c45859a1017": "uniV4",
|
|
280
125
|
},
|
|
281
126
|
};
|
|
282
|
-
//
|
|
127
|
+
// Staked / wrapped-staked position managers. V1 and V2 are deployed at the same
|
|
128
|
+
// address on every chain; the V3 pair was deployed at different addresses on
|
|
129
|
+
// Optimism, so those are chain-scoped and take precedence over the shared table.
|
|
283
130
|
export const UNIVERSAL_POSITION_MANAGERS = {
|
|
284
131
|
"0x1dc7a0f5336f52724b650e39174cfcbbedd67bf1": "staked_slipstream", // StakedSlipstreamAM V1
|
|
285
132
|
"0xbed6c3e35b9b1e044b3bc71465769edfdc0fdd4c": "staked_slipstream_v2", // StakedSlipstreamAM V2
|
|
@@ -288,3 +135,17 @@ export const UNIVERSAL_POSITION_MANAGERS = {
|
|
|
288
135
|
"0x147a2ccbaf4521ad209a2875ae0b3c496f4b25a4": "staked_slipstream_v2", // WrappedStakedSlipstream V2
|
|
289
136
|
"0x9189bc25f8fac157b4d87b0b3c14f56ba1477d53": "staked_slipstream_v3", // WrappedStakedSlipstream V3
|
|
290
137
|
};
|
|
138
|
+
export const CHAIN_STAKED_POSITION_MANAGERS = {
|
|
139
|
+
10: {
|
|
140
|
+
"0xf6a87d944204bb5fdb9cf5534c03c46895f78ecd": "staked_slipstream_v3", // StakedSlipstreamAM V3 (OP)
|
|
141
|
+
"0xc4d3d804ed64c1f78097799208d46b1db4252749": "staked_slipstream_v3", // WrappedStakedSlipstream V3 (OP)
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
/** dex_protocol for an LP position manager address on a chain, or null if unknown. */
|
|
145
|
+
export function positionManagerToDexProtocol(chainId, address) {
|
|
146
|
+
const key = address.toLowerCase();
|
|
147
|
+
return (CHAIN_STAKED_POSITION_MANAGERS[chainId]?.[key] ??
|
|
148
|
+
UNIVERSAL_POSITION_MANAGERS[key] ??
|
|
149
|
+
CHAIN_POSITION_MANAGERS[chainId]?.[key] ??
|
|
150
|
+
null);
|
|
151
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import { registerAllTools } from "./tools/index.js";
|
|
|
16
16
|
import { registerAllResources } from "./resources/index.js";
|
|
17
17
|
import { registerAllPrompts } from "./prompts/index.js";
|
|
18
18
|
import { wrapServerForHttp, convertToolNames } from "./utils/tool-naming.js";
|
|
19
|
+
import { applyTrustProxyFromEnv, parseListenPort, parseRateLimitRpm } from "./utils/http-config.js";
|
|
19
20
|
const require = createRequire(import.meta.url);
|
|
20
21
|
const pkg = require("../package.json");
|
|
21
22
|
const apiClient = new ArcadiaApiClient();
|
|
@@ -37,7 +38,8 @@ if (transportMode === "http") {
|
|
|
37
38
|
const { StreamableHTTPServerTransport } = await import("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
38
39
|
const express = (await import("express")).default;
|
|
39
40
|
const app = express();
|
|
40
|
-
|
|
41
|
+
applyTrustProxyFromEnv(app, process.env.TRUST_PROXY);
|
|
42
|
+
const port = parseListenPort(process.env.PORT);
|
|
41
43
|
const ALLOWED_ORIGINS = (process.env.ALLOWED_ORIGINS ?? "https://mcp.arcadia.finance")
|
|
42
44
|
.split(",")
|
|
43
45
|
.map((o) => o.trim());
|
|
@@ -61,7 +63,7 @@ if (transportMode === "http") {
|
|
|
61
63
|
res.status(204).end();
|
|
62
64
|
});
|
|
63
65
|
const { default: rateLimit, ipKeyGenerator } = await import("express-rate-limit");
|
|
64
|
-
const rpm =
|
|
66
|
+
const rpm = parseRateLimitRpm(process.env.RATE_LIMIT_RPM);
|
|
65
67
|
app.use("/mcp", rateLimit({
|
|
66
68
|
windowMs: 60_000,
|
|
67
69
|
max: rpm,
|
|
@@ -57,7 +57,7 @@ export function registerWorkflowPrompts(server) {
|
|
|
57
57
|
"- Pair type (volatile/stable, correlated, stable/stable)",
|
|
58
58
|
"- Recommended range width given volatility",
|
|
59
59
|
"- Leverage sizing (target health factor >= 0.5 at entry)",
|
|
60
|
-
"- Automation combo (
|
|
60
|
+
"- Automation combo (rebalance + compound_fees/claim_rewards + claim_merkl if applicable)",
|
|
61
61
|
"",
|
|
62
62
|
"Recommend the top 1-3 strategies with reasoning.",
|
|
63
63
|
].join("\n"),
|
|
@@ -66,7 +66,7 @@ export function registerWorkflowPrompts(server) {
|
|
|
66
66
|
],
|
|
67
67
|
}));
|
|
68
68
|
server.registerPrompt("setup-automation", {
|
|
69
|
-
description: "
|
|
69
|
+
description: "Configure automations (compounding, claiming, rebalancing, Merkl) for an Arcadia account.",
|
|
70
70
|
argsSchema: {
|
|
71
71
|
account_address: z.string().describe("Arcadia account address"),
|
|
72
72
|
chain_id: z.string().optional().describe("Chain ID (default: 8453 Base)"),
|
|
@@ -81,18 +81,20 @@ export function registerWorkflowPrompts(server) {
|
|
|
81
81
|
`Set up automation for Arcadia account ${account_address} on chain ${chain_id ?? "8453"}.`,
|
|
82
82
|
"",
|
|
83
83
|
"Steps:",
|
|
84
|
-
"1. Call read.account.info to
|
|
85
|
-
"2.
|
|
86
|
-
"3. Call read.asset_manager.intents to see available
|
|
87
|
-
"4.
|
|
88
|
-
" -
|
|
89
|
-
" -
|
|
90
|
-
" -
|
|
91
|
-
" -
|
|
92
|
-
" -
|
|
93
|
-
"5.
|
|
84
|
+
"1. Call read.account.info to see the account's positions and note the LP position id",
|
|
85
|
+
"2. Call read.asset_manager.current to see what is already enabled, including any superseded managers to clear",
|
|
86
|
+
"3. Call read.asset_manager.intents with the account address to see which intents are available and why any are blocked",
|
|
87
|
+
"4. Ask which automations the user wants, then build one intents array covering all of them:",
|
|
88
|
+
" - compound_fees: reinvest fees and rewards into the LP",
|
|
89
|
+
" - claim_rewards: claim yield out, optionally converted to one token via CowSwap",
|
|
90
|
+
" - add_to_lp: fold idle pool-token balances back into the LP",
|
|
91
|
+
" - rebalance: reposition when out of range (or take_profit / POL strategy)",
|
|
92
|
+
" - claim_merkl: auto-claim Merkl incentive rewards",
|
|
93
|
+
"5. Call write.account.automations with the account, the LP position_id and that intents array",
|
|
94
94
|
"",
|
|
95
|
-
"
|
|
95
|
+
"The intents array is the complete desired state, so include every automation the user wants kept, not just the new ones.",
|
|
96
|
+
"If a compatibility rule rejects the combination, read errors[].reason, adjust and retry.",
|
|
97
|
+
"To change one automation without restating the rest, use write.account.automations_delta.",
|
|
96
98
|
].join("\n"),
|
|
97
99
|
},
|
|
98
100
|
},
|
package/dist/resources/guides.js
CHANGED
|
@@ -8,7 +8,7 @@ const GUIDES = {
|
|
|
8
8
|
},
|
|
9
9
|
automation: {
|
|
10
10
|
file: "automation.md",
|
|
11
|
-
description: "
|
|
11
|
+
description: "Intent-based automation setup: compound fees, claim rewards, add to LP, rebalance, claim Merkl",
|
|
12
12
|
},
|
|
13
13
|
strategies: {
|
|
14
14
|
file: "strategies.md",
|
package/dist/tools/dev/send.js
CHANGED
|
@@ -4,7 +4,7 @@ import { privateKeyToAccount } from "viem/accounts";
|
|
|
4
4
|
import { base, optimism, unichain } from "viem/chains";
|
|
5
5
|
import { CHAIN_ID_DESCRIPTION } from "../../config/chains.js";
|
|
6
6
|
import { DevSendOutput } from "../output-schemas.js";
|
|
7
|
-
import { validateAddress } from "../../utils/validation.js";
|
|
7
|
+
import { validateAddress, validateHexCalldata, parseWeiDecimalString, } from "../../utils/validation.js";
|
|
8
8
|
const VIEM_CHAINS = {
|
|
9
9
|
8453: base,
|
|
10
10
|
130: unichain,
|
|
@@ -42,6 +42,8 @@ export function registerSendTool(server, chains) {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
const validTo = validateAddress(params.to, "to");
|
|
45
|
+
const calldata = validateHexCalldata(params.data, "data");
|
|
46
|
+
const valueWei = parseWeiDecimalString(params.value, "value");
|
|
45
47
|
const chain = VIEM_CHAINS[params.chain_id];
|
|
46
48
|
const chainConfig = chains[params.chain_id];
|
|
47
49
|
if (!chainConfig) {
|
|
@@ -59,14 +61,14 @@ export function registerSendTool(server, chains) {
|
|
|
59
61
|
const gasEstimate = await client.estimateGas({
|
|
60
62
|
account: account.address,
|
|
61
63
|
to: validTo,
|
|
62
|
-
data:
|
|
63
|
-
value:
|
|
64
|
+
data: calldata,
|
|
65
|
+
value: valueWei,
|
|
64
66
|
});
|
|
65
67
|
const gasLimit = (gasEstimate * 120n) / 100n;
|
|
66
68
|
const hash = await wallet.sendTransaction({
|
|
67
69
|
to: validTo,
|
|
68
|
-
data:
|
|
69
|
-
value:
|
|
70
|
+
data: calldata,
|
|
71
|
+
value: valueWei,
|
|
70
72
|
gas: gasLimit,
|
|
71
73
|
chain,
|
|
72
74
|
});
|
package/dist/tools/index.js
CHANGED
|
@@ -14,12 +14,7 @@ import { registerRepayTool } from "./write/account/repay.js";
|
|
|
14
14
|
import { registerApproveTool } from "./write/wallet/approve.js";
|
|
15
15
|
import { registerPoolDepositTool } from "./write/pool/deposit.js";
|
|
16
16
|
import { registerPoolRedeemTool } from "./write/pool/redeem.js";
|
|
17
|
-
import {
|
|
18
|
-
import { registerCompounderTools } from "./write/asset-managers/compounder.js";
|
|
19
|
-
import { registerYieldClaimerTools } from "./write/asset-managers/yield-claimer.js";
|
|
20
|
-
import { registerCowSwapperTool } from "./write/asset-managers/cow-swapper.js";
|
|
21
|
-
import { registerMerklOperatorTool } from "./write/asset-managers/merkl-operator.js";
|
|
22
|
-
import { registerSetAssetManagersTool } from "./write/asset-managers/set-asset-managers.js";
|
|
17
|
+
import { registerAutomationsTools } from "./write/asset-managers/automations.js";
|
|
23
18
|
import { registerSendTool } from "./dev/send.js";
|
|
24
19
|
import { registerAddLiquidityTool } from "./write/account/add-liquidity.js";
|
|
25
20
|
import { registerRemoveLiquidityTool } from "./write/account/remove-liquidity.js";
|
|
@@ -36,7 +31,7 @@ export function registerAllTools(server, api, chains) {
|
|
|
36
31
|
registerPointsTools(server, api);
|
|
37
32
|
registerGuideTools(server);
|
|
38
33
|
registerWalletTools(server, chains, api);
|
|
39
|
-
registerAssetManagerTools(server);
|
|
34
|
+
registerAssetManagerTools(server, api);
|
|
40
35
|
// Write tools — account
|
|
41
36
|
registerCreateTool(server, chains);
|
|
42
37
|
registerDepositTool(server, chains);
|
|
@@ -54,13 +49,8 @@ export function registerAllTools(server, api, chains) {
|
|
|
54
49
|
// Write tools — pool (lending tranches, ERC-4626)
|
|
55
50
|
registerPoolDepositTool(server, chains);
|
|
56
51
|
registerPoolRedeemTool(server, chains);
|
|
57
|
-
// Write tools
|
|
58
|
-
|
|
59
|
-
registerCompounderTools(server, chains);
|
|
60
|
-
registerYieldClaimerTools(server, chains);
|
|
61
|
-
registerCowSwapperTool(server, chains);
|
|
62
|
-
registerMerklOperatorTool(server, chains);
|
|
63
|
-
registerSetAssetManagersTool(server, chains);
|
|
52
|
+
// Write tools: asset managers (intent-based, compiled by the backend)
|
|
53
|
+
registerAutomationsTools(server, api);
|
|
64
54
|
// Dev tools
|
|
65
55
|
registerSendTool(server, chains);
|
|
66
56
|
}
|
|
@@ -25,12 +25,47 @@ export const BatchedTransactionOutput = z.object({
|
|
|
25
25
|
.passthrough()
|
|
26
26
|
.optional(),
|
|
27
27
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
const ResolvedManager = z.object({
|
|
29
|
+
manager: z.string(),
|
|
30
|
+
address: z.string(),
|
|
31
|
+
enabled: z.boolean(),
|
|
32
|
+
strategy: z.string().nullish(),
|
|
33
|
+
serving_intents: z.array(z.string()),
|
|
34
|
+
});
|
|
35
|
+
const DiffEntry = z.object({
|
|
36
|
+
manager: z.string(),
|
|
37
|
+
address: z.string(),
|
|
38
|
+
enabled: z.boolean(),
|
|
39
|
+
});
|
|
40
|
+
export const AutomationsPlanOutput = z.object({
|
|
41
|
+
description: z.string(),
|
|
42
|
+
valid: z.boolean(),
|
|
43
|
+
errors: z.array(z.object({ rule: z.string(), severity: z.string(), reason: z.string() })),
|
|
44
|
+
warnings: z.array(z.string()),
|
|
45
|
+
human_summary: z.array(z.string()),
|
|
46
|
+
plan: z.array(ResolvedManager),
|
|
47
|
+
diff: z
|
|
48
|
+
.object({
|
|
49
|
+
added: z.array(DiffEntry),
|
|
50
|
+
removed: z.array(DiffEntry),
|
|
51
|
+
updated: z.array(DiffEntry),
|
|
52
|
+
})
|
|
53
|
+
.optional(),
|
|
54
|
+
transaction: Transaction.optional(),
|
|
55
|
+
simulation_url: z.string().optional(),
|
|
56
|
+
tenderly_sim_status: z.enum(["success", "failure", "unavailable"]).optional(),
|
|
57
|
+
no_changes_needed: z.boolean().optional(),
|
|
58
|
+
preview_only: z.boolean().optional(),
|
|
59
|
+
});
|
|
60
|
+
export const AutomationsStateOutput = z.object({
|
|
61
|
+
account: z.string(),
|
|
62
|
+
chain_id: z.number(),
|
|
63
|
+
read_ok: z.boolean(),
|
|
64
|
+
inferred_intents: z.array(z.string()),
|
|
65
|
+
enabled: z.array(z.record(z.unknown())),
|
|
66
|
+
deprecated: z.array(z.record(z.unknown())),
|
|
67
|
+
merkl: z.record(z.unknown()).nullish(),
|
|
68
|
+
warnings: z.array(z.string()),
|
|
34
69
|
});
|
|
35
70
|
export const WalletBalancesOutput = z.object({
|
|
36
71
|
native: z.object({
|
|
@@ -125,6 +160,7 @@ export const GuideOutput = z.object({
|
|
|
125
160
|
});
|
|
126
161
|
export const IntentsListOutput = z.object({
|
|
127
162
|
automations: z.array(z.record(z.unknown())),
|
|
163
|
+
availability_error: z.string().optional(),
|
|
128
164
|
shared_params: z.array(z.string()),
|
|
129
165
|
usage: z.string(),
|
|
130
166
|
});
|