@arcadia-finance/mcp-server 0.1.3 → 0.1.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/README.md +2 -0
- package/dist/clients/api.js +1 -1
- package/dist/config/addresses.js +78 -39
- package/dist/config/chains.js +2 -8
- package/dist/index.js +116 -9
- package/dist/prompts/index.js +4 -0
- package/dist/prompts/workflows.js +98 -0
- package/dist/resources/guides.js +38 -0
- package/dist/resources/index.js +4 -0
- package/dist/tools/advanced/add-liquidity.js +35 -19
- package/dist/tools/advanced/close-position.js +11 -11
- package/dist/tools/advanced/position-actions.js +4 -4
- package/dist/tools/advanced/remove-liquidity.js +4 -4
- package/dist/tools/advanced/repay-with-collateral.js +3 -4
- package/dist/tools/advanced/swap.js +5 -4
- package/dist/tools/read/accounts.js +20 -52
- package/dist/tools/read/allowances.js +6 -7
- package/dist/tools/read/assets.js +1 -4
- package/dist/tools/read/balances.js +5 -6
- package/dist/tools/read/guides.js +3 -18
- package/dist/tools/read/points.js +27 -6
- package/dist/tools/read/pools.js +22 -7
- package/dist/tools/read/protocol.js +14 -10
- package/dist/tools/write/approve.js +7 -7
- package/dist/tools/write/borrow.js +7 -11
- package/dist/tools/write/configure-asset-manager.js +39 -40
- package/dist/tools/write/create-account.js +10 -8
- package/dist/tools/write/deposit.js +8 -8
- package/dist/tools/write/repay.js +7 -7
- package/dist/tools/write/set-asset-manager.js +6 -6
- package/dist/tools/write/sign-and-send.js +1 -4
- package/dist/tools/write/withdraw.js +8 -8
- package/dist/utils/validation.js +1 -1
- package/package.json +3 -1
- package/server.json +2 -2
- package/skills/clamm-liquidity/automation.md +22 -24
- package/skills/clamm-liquidity/strategies.md +2 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { encodeAbiParameters, encodeFunctionData } from "viem";
|
|
3
|
-
import {
|
|
3
|
+
import { MINIMAL_STRATEGY_HOOK, getAmProtocolAddress, getStandaloneAmAddress, } from "../../config/addresses.js";
|
|
4
4
|
import { accountAbi } from "../../abis/index.js";
|
|
5
5
|
import { appendDataSuffix } from "../../utils/attribution.js";
|
|
6
|
+
import { validateAddress, validateChainId } from "../../utils/validation.js";
|
|
6
7
|
// Arcadia's bot initiator addresses per asset manager type
|
|
7
8
|
const REBALANCER_INITIATOR = "0x163CcA8F161CBBB401a96aDf4Cbf4D74f3faD1Ed";
|
|
8
9
|
const COMPOUNDER_INITIATOR = "0xb0f46DB8B96e265C1D93396444Eee952086C6f3D";
|
|
@@ -96,25 +97,27 @@ function encodeMerklOperatorCallbackData(initiator, rewardRecipient) {
|
|
|
96
97
|
const PROTOCOL_TO_AM_KEY = {
|
|
97
98
|
slipstream: "slipstreamV1",
|
|
98
99
|
slipstream_v2: "slipstreamV2",
|
|
100
|
+
staked_slipstream: "slipstreamV1",
|
|
101
|
+
staked_slipstream_v2: "slipstreamV2",
|
|
99
102
|
uniV3: "uniV3",
|
|
100
103
|
uniV4: "uniV4",
|
|
101
104
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return ASSET_MANAGERS.base.merklOperator;
|
|
105
|
+
const AM_TYPE_TO_CATEGORY = {
|
|
106
|
+
rebalancer: "rebalancers",
|
|
107
|
+
compounder: "compounders",
|
|
108
|
+
yield_claimer: "yieldClaimers",
|
|
109
|
+
};
|
|
110
|
+
function resolveAmAddress(chainId, amType, protocol) {
|
|
111
|
+
if (amType === "merkl_operator")
|
|
112
|
+
return getStandaloneAmAddress(chainId, "merklOperator");
|
|
113
|
+
if (!protocol) {
|
|
114
|
+
throw new Error("Provide asset_manager_address or pool_protocol to resolve the AM address. Protocol-specific AMs (rebalancer, compounder, yield_claimer) require pool_protocol.");
|
|
113
115
|
}
|
|
116
|
+
return getAmProtocolAddress(chainId, AM_TYPE_TO_CATEGORY[amType], PROTOCOL_TO_AM_KEY[protocol]);
|
|
114
117
|
}
|
|
115
118
|
export function registerConfigureAssetManagerTool(server, _chains) {
|
|
116
119
|
server.registerTool("build_configure_asset_manager_tx", {
|
|
117
|
-
description: "Build an unsigned transaction to enable AND configure an asset manager on an Arcadia V3/V4 account. Unlike build_set_asset_manager_tx (which only grants permission), this also sets the initiator, fee limits, and strategy parameters in one transaction via setAssetManagers. Supports rebalancer (with trigger ratios and compound mode), compounder, yield claimer (with fee recipient), and merkl operator (with reward recipient). Pass pool_protocol to auto-resolve the correct AM address, or pass asset_manager_address directly.
|
|
120
|
+
description: "Build an unsigned transaction to enable AND configure an asset manager on an Arcadia V3/V4 account. Unlike build_set_asset_manager_tx (which only grants permission), this also sets the initiator, fee limits, and strategy parameters in one transaction via setAssetManagers. Supports rebalancer (with trigger ratios and compound mode), compounder, yield claimer (with fee recipient), and merkl operator (with reward recipient). For cow_swapper, use build_set_asset_manager_tx instead (no callback data needed). Pass pool_protocol to auto-resolve the correct AM address (required for rebalancer/compounder/yield_claimer), or pass asset_manager_address directly. merkl_operator is protocol-agnostic and auto-resolves without pool_protocol. Returns { transaction: { to, data, value, chainId } }.",
|
|
118
121
|
inputSchema: {
|
|
119
122
|
account_address: z.string().describe("Arcadia account address (must be V3 or V4)"),
|
|
120
123
|
asset_manager_address: z
|
|
@@ -122,9 +125,16 @@ export function registerConfigureAssetManagerTool(server, _chains) {
|
|
|
122
125
|
.optional()
|
|
123
126
|
.describe("Asset manager contract address. Optional if pool_protocol is provided."),
|
|
124
127
|
pool_protocol: z
|
|
125
|
-
.enum([
|
|
128
|
+
.enum([
|
|
129
|
+
"slipstream",
|
|
130
|
+
"slipstream_v2",
|
|
131
|
+
"staked_slipstream",
|
|
132
|
+
"staked_slipstream_v2",
|
|
133
|
+
"uniV3",
|
|
134
|
+
"uniV4",
|
|
135
|
+
])
|
|
126
136
|
.optional()
|
|
127
|
-
.describe("LP protocol — auto-resolves the correct AM address.
|
|
137
|
+
.describe("LP protocol — auto-resolves the correct AM address. staked_slipstream and staked_slipstream_v2 are aliases for slipstream and slipstream_v2 (same AM contracts)."),
|
|
128
138
|
am_type: z
|
|
129
139
|
.enum(["rebalancer", "compounder", "yield_claimer", "merkl_operator"])
|
|
130
140
|
.describe("Type of asset manager"),
|
|
@@ -161,34 +171,21 @@ export function registerConfigureAssetManagerTool(server, _chains) {
|
|
|
161
171
|
.string()
|
|
162
172
|
.optional()
|
|
163
173
|
.describe("merkl_operator: address to receive Merkl rewards (required for merkl_operator)"),
|
|
164
|
-
chain_id: z
|
|
165
|
-
.number()
|
|
166
|
-
.default(8453)
|
|
167
|
-
.describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
|
|
174
|
+
chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
|
|
168
175
|
},
|
|
169
176
|
}, async (params) => {
|
|
170
177
|
try {
|
|
171
|
-
|
|
178
|
+
const validChainId = validateChainId(params.chain_id);
|
|
179
|
+
const validAccount = validateAddress(params.account_address, "account_address");
|
|
172
180
|
const amAddress = params.asset_manager_address ??
|
|
173
|
-
(params.pool_protocol
|
|
174
|
-
? resolveAmAddress(params.am_type, params.pool_protocol)
|
|
175
|
-
: undefined);
|
|
176
|
-
if (!amAddress) {
|
|
177
|
-
return {
|
|
178
|
-
content: [
|
|
179
|
-
{
|
|
180
|
-
type: "text",
|
|
181
|
-
text: "Error: Provide asset_manager_address or pool_protocol to resolve the AM address.",
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
isError: true,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
181
|
+
resolveAmAddress(validChainId, params.am_type, params.pool_protocol);
|
|
187
182
|
let callbackData;
|
|
188
183
|
switch (params.am_type) {
|
|
189
184
|
case "rebalancer": {
|
|
190
185
|
const metaData = encodeRebalancerMetadata(params.trigger_lower_ratio, params.trigger_upper_ratio, params.compound_leftovers, params.min_rebalance_time);
|
|
191
|
-
const strategyHook =
|
|
186
|
+
const strategyHook = params.strategy_hook
|
|
187
|
+
? validateAddress(params.strategy_hook, "strategy_hook")
|
|
188
|
+
: MINIMAL_STRATEGY_HOOK;
|
|
192
189
|
callbackData = encodeRebalancerCallbackData(REBALANCER_INITIATOR, strategyHook, metaData);
|
|
193
190
|
break;
|
|
194
191
|
}
|
|
@@ -200,21 +197,23 @@ export function registerConfigureAssetManagerTool(server, _chains) {
|
|
|
200
197
|
if (!params.fee_recipient) {
|
|
201
198
|
throw new Error("fee_recipient is required for yield_claimer");
|
|
202
199
|
}
|
|
203
|
-
|
|
200
|
+
const validFeeRecipient = validateAddress(params.fee_recipient, "fee_recipient");
|
|
201
|
+
callbackData = encodeYieldClaimerCallbackData(CLAIMER_INITIATOR, validFeeRecipient);
|
|
204
202
|
break;
|
|
205
203
|
}
|
|
206
204
|
case "merkl_operator": {
|
|
207
205
|
if (!params.reward_recipient) {
|
|
208
206
|
throw new Error("reward_recipient is required for merkl_operator");
|
|
209
207
|
}
|
|
210
|
-
|
|
208
|
+
const validRewardRecipient = validateAddress(params.reward_recipient, "reward_recipient");
|
|
209
|
+
callbackData = encodeMerklOperatorCallbackData(MERKL_INITIATOR, validRewardRecipient);
|
|
211
210
|
break;
|
|
212
211
|
}
|
|
213
212
|
}
|
|
214
213
|
const data = appendDataSuffix(encodeFunctionData({
|
|
215
214
|
abi: accountAbi,
|
|
216
215
|
functionName: "setAssetManagers",
|
|
217
|
-
args: [[amAddress], [true], [callbackData]],
|
|
216
|
+
args: [[validateAddress(amAddress, "asset_manager_address")], [true], [callbackData]],
|
|
218
217
|
}));
|
|
219
218
|
return {
|
|
220
219
|
content: [
|
|
@@ -223,10 +222,10 @@ export function registerConfigureAssetManagerTool(server, _chains) {
|
|
|
223
222
|
text: JSON.stringify({
|
|
224
223
|
description: `Configure and enable ${params.am_type} ${amAddress} on account ${params.account_address}`,
|
|
225
224
|
transaction: {
|
|
226
|
-
to:
|
|
225
|
+
to: validAccount,
|
|
227
226
|
data,
|
|
228
227
|
value: "0",
|
|
229
|
-
chainId:
|
|
228
|
+
chainId: validChainId,
|
|
230
229
|
},
|
|
231
230
|
}, null, 2),
|
|
232
231
|
},
|
|
@@ -4,6 +4,7 @@ import { factoryAbi } from "../../abis/index.js";
|
|
|
4
4
|
import { PROTOCOL } from "../../config/addresses.js";
|
|
5
5
|
import { getPublicClient } from "../../clients/chain.js";
|
|
6
6
|
import { appendDataSuffix } from "../../utils/attribution.js";
|
|
7
|
+
import { validateAddress, validateChainId } from "../../utils/validation.js";
|
|
7
8
|
// Arcadia Proxy bytecode from CreateProxyLib.sol — used to compute CREATE2 addresses.
|
|
8
9
|
const PROXY_BYTECODE = "0x608060405260405161017c38038061017c8339810160408190526100229161008d565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b0319166001600160a01b0383169081179091556040517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b905f90a2506100ba565b5f6020828403121561009d575f80fd5b81516001600160a01b03811681146100b3575f80fd5b9392505050565b60b6806100c65f395ff3fe608060405236603c57603a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5b546001600160a01b03166063565b005b603a7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc602c565b365f80375f80365f845af43d5f803e808015607c573d5ff35b3d5ffdfea2646970667358221220eeb8a2fa918a2057b66e1d3fa3930647dc7a4e56c99898cd9e280beec9d9ba9f64736f6c63430008160033000000000000000000000000";
|
|
9
10
|
export function computeAccountAddress(factoryAddress, userSalt, walletAddress, implementation) {
|
|
@@ -39,26 +40,27 @@ export function registerCreateAccountTool(server, chains) {
|
|
|
39
40
|
.string()
|
|
40
41
|
.optional()
|
|
41
42
|
.describe("Lending pool address for V3 margin account. Ignored for V4 spot accounts (version 0 or 4)."),
|
|
42
|
-
chain_id: z
|
|
43
|
-
.number()
|
|
44
|
-
.default(8453)
|
|
45
|
-
.describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
|
|
43
|
+
chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
|
|
46
44
|
},
|
|
47
45
|
}, async (params) => {
|
|
48
46
|
try {
|
|
47
|
+
const validChainId = validateChainId(params.chain_id);
|
|
48
|
+
const validWallet = validateAddress(params.wallet_address, "wallet_address");
|
|
49
49
|
const data = appendDataSuffix(encodeFunctionData({
|
|
50
50
|
abi: factoryAbi,
|
|
51
51
|
functionName: "createAccount",
|
|
52
52
|
args: [
|
|
53
53
|
params.salt,
|
|
54
54
|
BigInt(params.account_version),
|
|
55
|
-
|
|
55
|
+
params.creditor
|
|
56
|
+
? validateAddress(params.creditor, "creditor")
|
|
57
|
+
: "0x0000000000000000000000000000000000000000",
|
|
56
58
|
],
|
|
57
59
|
}));
|
|
58
60
|
// Try to predict the account address via CREATE2 (requires RPC)
|
|
59
61
|
let predictedAddress;
|
|
60
62
|
try {
|
|
61
|
-
const client = getPublicClient(
|
|
63
|
+
const client = getPublicClient(validChainId, chains);
|
|
62
64
|
let resolvedVersion = BigInt(params.account_version);
|
|
63
65
|
if (resolvedVersion === 0n) {
|
|
64
66
|
resolvedVersion = (await client.readContract({
|
|
@@ -73,7 +75,7 @@ export function registerCreateAccountTool(server, chains) {
|
|
|
73
75
|
functionName: "versionInformation",
|
|
74
76
|
args: [resolvedVersion],
|
|
75
77
|
}));
|
|
76
|
-
predictedAddress = computeAccountAddress(PROTOCOL.factory, params.salt,
|
|
78
|
+
predictedAddress = computeAccountAddress(PROTOCOL.factory, params.salt, validWallet, versionInfo[1]);
|
|
77
79
|
}
|
|
78
80
|
catch {
|
|
79
81
|
// RPC unavailable — skip address prediction
|
|
@@ -88,7 +90,7 @@ export function registerCreateAccountTool(server, chains) {
|
|
|
88
90
|
to: PROTOCOL.factory,
|
|
89
91
|
data,
|
|
90
92
|
value: "0",
|
|
91
|
-
chainId:
|
|
93
|
+
chainId: validChainId,
|
|
92
94
|
},
|
|
93
95
|
...(predictedAddress && { predicted_account_address: predictedAddress }),
|
|
94
96
|
next_steps: predictedAddress
|
|
@@ -3,6 +3,7 @@ import { encodeFunctionData } from "viem";
|
|
|
3
3
|
import { accountAbi, getAccountAbi } from "../../abis/index.js";
|
|
4
4
|
import { getPublicClient } from "../../clients/chain.js";
|
|
5
5
|
import { appendDataSuffix } from "../../utils/attribution.js";
|
|
6
|
+
import { validateAddress, validateChainId } from "../../utils/validation.js";
|
|
6
7
|
export function registerDepositTool(server, chains) {
|
|
7
8
|
server.registerTool("build_deposit_tx", {
|
|
8
9
|
description: "Build an unsigned transaction to deposit assets into an Arcadia account as collateral. Supports ERC20 tokens and ERC721 NFTs (LP positions). NOT needed before build_add_liquidity_tx — that tool deposits from wallet atomically. Ensure the account is approved first (call get_allowance to check, then build_approve_tx if needed). Account version is auto-detected on-chain (override with account_version if needed).",
|
|
@@ -22,10 +23,7 @@ export function registerDepositTool(server, chains) {
|
|
|
22
23
|
.number()
|
|
23
24
|
.optional()
|
|
24
25
|
.describe("Override account version (3 or 4). Auto-detected on-chain if omitted."),
|
|
25
|
-
chain_id: z
|
|
26
|
-
.number()
|
|
27
|
-
.default(8453)
|
|
28
|
-
.describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
|
|
26
|
+
chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
|
|
29
27
|
},
|
|
30
28
|
}, async (params) => {
|
|
31
29
|
try {
|
|
@@ -40,12 +38,14 @@ export function registerDepositTool(server, chains) {
|
|
|
40
38
|
isError: true,
|
|
41
39
|
};
|
|
42
40
|
}
|
|
41
|
+
const validChainId = validateChainId(params.chain_id);
|
|
42
|
+
const validAccount = validateAddress(params.account_address, "account_address");
|
|
43
43
|
// Auto-detect account version on-chain, or use override
|
|
44
44
|
let version = params.account_version ?? 0;
|
|
45
45
|
if (!version) {
|
|
46
|
-
const client = getPublicClient(
|
|
46
|
+
const client = getPublicClient(validChainId, chains);
|
|
47
47
|
version = Number(await client.readContract({
|
|
48
|
-
address:
|
|
48
|
+
address: validAccount,
|
|
49
49
|
abi: accountAbi,
|
|
50
50
|
functionName: "ACCOUNT_VERSION",
|
|
51
51
|
}));
|
|
@@ -72,10 +72,10 @@ export function registerDepositTool(server, chains) {
|
|
|
72
72
|
text: JSON.stringify({
|
|
73
73
|
description: `Deposit assets into Arcadia account (V${version})`,
|
|
74
74
|
transaction: {
|
|
75
|
-
to:
|
|
75
|
+
to: validAccount,
|
|
76
76
|
data,
|
|
77
77
|
value: "0",
|
|
78
|
-
chainId:
|
|
78
|
+
chainId: validChainId,
|
|
79
79
|
},
|
|
80
80
|
}, null, 2),
|
|
81
81
|
},
|
|
@@ -2,9 +2,10 @@ import { z } from "zod";
|
|
|
2
2
|
import { encodeFunctionData } from "viem";
|
|
3
3
|
import { poolAbi } from "../../abis/index.js";
|
|
4
4
|
import { appendDataSuffix } from "../../utils/attribution.js";
|
|
5
|
+
import { validateAddress } from "../../utils/validation.js";
|
|
5
6
|
export function registerRepayTool(server, _chains) {
|
|
6
7
|
server.registerTool("build_repay_tx", {
|
|
7
|
-
description: "Build an unsigned transaction to repay debt to an Arcadia lending pool from your wallet. Check allowance first (get_allowance), then approve the pool if needed (build_approve_tx). To repay using account collateral instead, use build_repay_with_collateral_tx.",
|
|
8
|
+
description: "Build an unsigned transaction to repay debt to an Arcadia lending pool from your wallet. This tool does not validate whether the account has outstanding debt — check with get_account_info first. Check allowance first (get_allowance), then approve the pool if needed (build_approve_tx). To repay using account collateral instead, use build_repay_with_collateral_tx.",
|
|
8
9
|
inputSchema: {
|
|
9
10
|
pool_address: z
|
|
10
11
|
.string()
|
|
@@ -13,18 +14,17 @@ export function registerRepayTool(server, _chains) {
|
|
|
13
14
|
amount: z
|
|
14
15
|
.string()
|
|
15
16
|
.describe("Amount in raw units, or 'max_uint256' to repay all debt in full"),
|
|
16
|
-
chain_id: z
|
|
17
|
-
.number()
|
|
18
|
-
.default(8453)
|
|
19
|
-
.describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
|
|
17
|
+
chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
|
|
20
18
|
},
|
|
21
19
|
}, async (params) => {
|
|
22
20
|
try {
|
|
21
|
+
const validAccount = validateAddress(params.account_address, "account_address");
|
|
22
|
+
const validPool = validateAddress(params.pool_address, "pool_address");
|
|
23
23
|
const amount = params.amount === "max_uint256" ? 2n ** 256n - 1n : BigInt(params.amount);
|
|
24
24
|
const data = appendDataSuffix(encodeFunctionData({
|
|
25
25
|
abi: poolAbi,
|
|
26
26
|
functionName: "repay",
|
|
27
|
-
args: [amount,
|
|
27
|
+
args: [amount, validAccount],
|
|
28
28
|
}));
|
|
29
29
|
return {
|
|
30
30
|
content: [
|
|
@@ -33,7 +33,7 @@ export function registerRepayTool(server, _chains) {
|
|
|
33
33
|
text: JSON.stringify({
|
|
34
34
|
description: "Repay debt to Arcadia lending pool",
|
|
35
35
|
transaction: {
|
|
36
|
-
to:
|
|
36
|
+
to: validPool,
|
|
37
37
|
data,
|
|
38
38
|
value: "0",
|
|
39
39
|
chainId: params.chain_id,
|
|
@@ -2,6 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { encodeFunctionData } from "viem";
|
|
3
3
|
import { accountAbi } from "../../abis/index.js";
|
|
4
4
|
import { appendDataSuffix } from "../../utils/attribution.js";
|
|
5
|
+
import { validateAddress } from "../../utils/validation.js";
|
|
5
6
|
export function registerSetAssetManagerTool(server, _chains) {
|
|
6
7
|
server.registerTool("build_set_asset_manager_tx", {
|
|
7
8
|
description: "Build an unsigned transaction to grant or revoke an asset manager's permission on an Arcadia V3/V4 account via setAssetManagers. This ONLY toggles the permission flag — it does NOT configure initiator, fees, or strategy parameters. For full setup (enable + configure in one tx), use build_configure_asset_manager_tx instead. For asset manager addresses, call get_guide('automation'). Returns { transaction: { to, data, value, chainId } }.",
|
|
@@ -11,17 +12,16 @@ export function registerSetAssetManagerTool(server, _chains) {
|
|
|
11
12
|
.string()
|
|
12
13
|
.describe("Asset manager contract address to grant or revoke"),
|
|
13
14
|
enabled: z.boolean().describe("True to grant permission, false to revoke"),
|
|
14
|
-
chain_id: z
|
|
15
|
-
.number()
|
|
16
|
-
.default(8453)
|
|
17
|
-
.describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
|
|
15
|
+
chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
|
|
18
16
|
},
|
|
19
17
|
}, async (params) => {
|
|
20
18
|
try {
|
|
19
|
+
const validAccount = validateAddress(params.account_address, "account_address");
|
|
20
|
+
const validAm = validateAddress(params.asset_manager_address, "asset_manager_address");
|
|
21
21
|
const data = appendDataSuffix(encodeFunctionData({
|
|
22
22
|
abi: accountAbi,
|
|
23
23
|
functionName: "setAssetManagers",
|
|
24
|
-
args: [[
|
|
24
|
+
args: [[validAm], [params.enabled], ["0x"]],
|
|
25
25
|
}));
|
|
26
26
|
return {
|
|
27
27
|
content: [
|
|
@@ -30,7 +30,7 @@ export function registerSetAssetManagerTool(server, _chains) {
|
|
|
30
30
|
text: JSON.stringify({
|
|
31
31
|
description: `${params.enabled ? "Grant" : "Revoke"} asset manager permission for ${params.asset_manager_address}`,
|
|
32
32
|
transaction: {
|
|
33
|
-
to:
|
|
33
|
+
to: validAccount,
|
|
34
34
|
data,
|
|
35
35
|
value: "0",
|
|
36
36
|
chainId: params.chain_id,
|
|
@@ -14,10 +14,7 @@ export function registerSignAndSendTool(server, chains) {
|
|
|
14
14
|
to: z.string().describe("Target contract address"),
|
|
15
15
|
data: z.string().describe("Encoded calldata (hex)"),
|
|
16
16
|
value: z.string().default("0").describe("Value in wei (default '0')"),
|
|
17
|
-
chain_id: z
|
|
18
|
-
.number()
|
|
19
|
-
.default(8453)
|
|
20
|
-
.describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
|
|
17
|
+
chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
|
|
21
18
|
},
|
|
22
19
|
}, async (params) => {
|
|
23
20
|
try {
|
|
@@ -3,6 +3,7 @@ import { encodeFunctionData } from "viem";
|
|
|
3
3
|
import { accountAbi, getAccountAbi } from "../../abis/index.js";
|
|
4
4
|
import { getPublicClient } from "../../clients/chain.js";
|
|
5
5
|
import { appendDataSuffix } from "../../utils/attribution.js";
|
|
6
|
+
import { validateAddress, validateChainId } from "../../utils/validation.js";
|
|
6
7
|
export function registerWithdrawTool(server, chains) {
|
|
7
8
|
server.registerTool("build_withdraw_tx", {
|
|
8
9
|
description: "Build an unsigned transaction to withdraw assets from an Arcadia account to the owner's wallet. Only the account owner can withdraw. Will revert if the account has debt and withdrawal would make it undercollateralized. Does not support max_uint256 — pass exact amounts from get_account_info. Account version is auto-detected on-chain (override with account_version if needed).",
|
|
@@ -22,10 +23,7 @@ export function registerWithdrawTool(server, chains) {
|
|
|
22
23
|
.number()
|
|
23
24
|
.optional()
|
|
24
25
|
.describe("Override account version (3 or 4). Auto-detected on-chain if omitted."),
|
|
25
|
-
chain_id: z
|
|
26
|
-
.number()
|
|
27
|
-
.default(8453)
|
|
28
|
-
.describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
|
|
26
|
+
chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
|
|
29
27
|
},
|
|
30
28
|
}, async (params) => {
|
|
31
29
|
try {
|
|
@@ -51,11 +49,13 @@ export function registerWithdrawTool(server, chains) {
|
|
|
51
49
|
isError: true,
|
|
52
50
|
};
|
|
53
51
|
}
|
|
52
|
+
const validChainId = validateChainId(params.chain_id);
|
|
53
|
+
const validAccount = validateAddress(params.account_address, "account_address");
|
|
54
54
|
let version = params.account_version ?? 0;
|
|
55
55
|
if (!version) {
|
|
56
|
-
const client = getPublicClient(
|
|
56
|
+
const client = getPublicClient(validChainId, chains);
|
|
57
57
|
version = Number(await client.readContract({
|
|
58
|
-
address:
|
|
58
|
+
address: validAccount,
|
|
59
59
|
abi: accountAbi,
|
|
60
60
|
functionName: "ACCOUNT_VERSION",
|
|
61
61
|
}));
|
|
@@ -82,10 +82,10 @@ export function registerWithdrawTool(server, chains) {
|
|
|
82
82
|
text: JSON.stringify({
|
|
83
83
|
description: `Withdraw assets from Arcadia account (V${version})`,
|
|
84
84
|
transaction: {
|
|
85
|
-
to:
|
|
85
|
+
to: validAccount,
|
|
86
86
|
data,
|
|
87
87
|
value: "0",
|
|
88
|
-
chainId:
|
|
88
|
+
chainId: validChainId,
|
|
89
89
|
},
|
|
90
90
|
}, null, 2),
|
|
91
91
|
},
|
package/dist/utils/validation.js
CHANGED
|
@@ -10,7 +10,7 @@ export function validateAddress(address, label = "address") {
|
|
|
10
10
|
}
|
|
11
11
|
export function validateChainId(chainId) {
|
|
12
12
|
if (!SUPPORTED_CHAIN_IDS.includes(chainId)) {
|
|
13
|
-
throw new Error(`Unsupported chain_id: ${chainId}.
|
|
13
|
+
throw new Error(`Unsupported chain_id: ${chainId}. Supported chains: Base (8453) and Unichain (130).`);
|
|
14
14
|
}
|
|
15
15
|
return chainId;
|
|
16
16
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcadia-finance/mcp-server",
|
|
3
3
|
"mcpName": "io.github.arcadia-finance/mcp-server",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"description": "MCP server for Arcadia Finance. Manage concentrated liquidity positions with leverage, automated rebalancing, and yield optimization on Base, Optimism, and Unichain.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "BUSL-1.1",
|
|
@@ -53,11 +53,13 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
56
|
+
"express": "^5.2.1",
|
|
56
57
|
"viem": "^2.0.0",
|
|
57
58
|
"zod": "^3.23.0"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"@eslint/js": "^9.0.0",
|
|
62
|
+
"@types/express": "^5.0.6",
|
|
61
63
|
"@types/node": "^22.0.0",
|
|
62
64
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
63
65
|
"@typescript-eslint/parser": "^8.0.0",
|
package/server.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "io.github.arcadia-finance/mcp-server",
|
|
4
4
|
"title": "Arcadia Finance",
|
|
5
5
|
"description": "Manage Uniswap and Aerodrome liquidity positions with automated rebalancing and leverage.",
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.4",
|
|
7
7
|
"websiteUrl": "https://arcadia.finance",
|
|
8
8
|
"repository": {
|
|
9
9
|
"url": "https://github.com/arcadia-finance/mcp-server",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
{
|
|
14
14
|
"registryType": "npm",
|
|
15
15
|
"identifier": "@arcadia-finance/mcp-server",
|
|
16
|
-
"version": "0.1.
|
|
16
|
+
"version": "0.1.4",
|
|
17
17
|
"transport": {
|
|
18
18
|
"type": "stdio"
|
|
19
19
|
},
|
|
@@ -48,14 +48,14 @@ To revoke any AM: `build_set_asset_manager_tx(..., enabled: false)` or `build_co
|
|
|
48
48
|
|
|
49
49
|
**What it does:** When the LP position goes out of range, Arcadia's bot repositions it to a new range centered on the current price. As part of every rebalance, the old position is burned and all pending fees and staking rewards are claimed — these are automatically compounded into the new position. The rebalancer therefore also acts as a compounder at every rebalance event.
|
|
50
50
|
|
|
51
|
-
**Which address:** Match to your LP protocol
|
|
51
|
+
**Which address:** Match to your LP protocol. The tool returns an error if a manager isn't available on the requested chain.
|
|
52
52
|
|
|
53
|
-
| Protocol | Address |
|
|
54
|
-
| ----------------------- | -------------------------------------------- |
|
|
55
|
-
| Aerodrome Slipstream V1 | `0x5802454749cc0c4A6F28D5001B4cD84432e2b79F` |
|
|
56
|
-
| Aerodrome Slipstream V2 | `0x953Ff365d0b562ceC658dc46B394E9282338d9Ea` |
|
|
57
|
-
| Uniswap V3 | `0xbA1D0c99c261F94b9C8b52465890Cca27dd993Bd` |
|
|
58
|
-
| Uniswap V4 | `0x01EDaF0067a10D18c88D2876c0A85Ee0096a5Ac0` |
|
|
53
|
+
| Protocol | Address | Chains |
|
|
54
|
+
| ----------------------- | -------------------------------------------- | --------- |
|
|
55
|
+
| Aerodrome Slipstream V1 | `0x5802454749cc0c4A6F28D5001B4cD84432e2b79F` | All |
|
|
56
|
+
| Aerodrome Slipstream V2 | `0x953Ff365d0b562ceC658dc46B394E9282338d9Ea` | Base only |
|
|
57
|
+
| Uniswap V3 | `0xbA1D0c99c261F94b9C8b52465890Cca27dd993Bd` | All |
|
|
58
|
+
| Uniswap V4 | `0x01EDaF0067a10D18c88D2876c0A85Ee0096a5Ac0` | All |
|
|
59
59
|
|
|
60
60
|
**Free rebalance quota (per owner across all accounts):**
|
|
61
61
|
|
|
@@ -83,14 +83,14 @@ Quota is also bypassed automatically when: gas cost < pending fees ÷ 2, or posi
|
|
|
83
83
|
|
|
84
84
|
**What it does:** Bot claims accumulated LP fees and reinvests them back into the position (compound interest instead of cash flow).
|
|
85
85
|
|
|
86
|
-
**Which address
|
|
86
|
+
**Which address:**
|
|
87
87
|
|
|
88
|
-
| Protocol | Address |
|
|
89
|
-
| ----------------------- | -------------------------------------------- |
|
|
90
|
-
| Aerodrome Slipstream V1 | `0x467837f44A71e3eAB90AEcfC995c84DC6B3cfCF7` |
|
|
91
|
-
| Aerodrome Slipstream V2 | `0x35e59448C7145482E56212510cC689612AB4F61f` |
|
|
92
|
-
| Uniswap V3 | `0x02e1fa043214E51eDf1F0478c6D0d3D5658a2DC3` |
|
|
93
|
-
| Uniswap V4 | `0xAA95c9c402b195D8690eCaea2341a76e3266B189` |
|
|
88
|
+
| Protocol | Address | Chains |
|
|
89
|
+
| ----------------------- | -------------------------------------------- | --------- |
|
|
90
|
+
| Aerodrome Slipstream V1 | `0x467837f44A71e3eAB90AEcfC995c84DC6B3cfCF7` | All |
|
|
91
|
+
| Aerodrome Slipstream V2 | `0x35e59448C7145482E56212510cC689612AB4F61f` | Base only |
|
|
92
|
+
| Uniswap V3 | `0x02e1fa043214E51eDf1F0478c6D0d3D5658a2DC3` | All |
|
|
93
|
+
| Uniswap V4 | `0xAA95c9c402b195D8690eCaea2341a76e3266B189` | All |
|
|
94
94
|
|
|
95
95
|
**When to add a compounder on top of a rebalancer:** The rebalancer compounds fees at rebalance time. Adding a compounder also compounds fees between rebalances — more frequent compounding, higher effective APY.
|
|
96
96
|
|
|
@@ -100,14 +100,14 @@ Quota is also bypassed automatically when: gas cost < pending fees ÷ 2, or posi
|
|
|
100
100
|
|
|
101
101
|
**What it does:** Bot periodically claims pending fees/emissions and sends them to a designated recipient (owner wallet, another account, or any address).
|
|
102
102
|
|
|
103
|
-
**Which address
|
|
103
|
+
**Which address:**
|
|
104
104
|
|
|
105
|
-
| Protocol | Address |
|
|
106
|
-
| ----------------------- | -------------------------------------------- |
|
|
107
|
-
| Aerodrome Slipstream V1 | `0x5a8278D37b7a787574b6Aa7E18d8C02D994f18Ba` |
|
|
108
|
-
| Aerodrome Slipstream V2 | `0xc8bF4B2c740FF665864E9494832520f18822871C` |
|
|
109
|
-
| Uniswap V3 | `0x75Ed28EA8601Ce9F5FbcAB1c2428f04A57aFaA16` |
|
|
110
|
-
| Uniswap V4 | `0xD8aa21AB7f9B8601CB7d7A776D3AFA1602d5D8D4` |
|
|
105
|
+
| Protocol | Address | Chains |
|
|
106
|
+
| ----------------------- | -------------------------------------------- | --------- |
|
|
107
|
+
| Aerodrome Slipstream V1 | `0x5a8278D37b7a787574b6Aa7E18d8C02D994f18Ba` | All |
|
|
108
|
+
| Aerodrome Slipstream V2 | `0xc8bF4B2c740FF665864E9494832520f18822871C` | Base only |
|
|
109
|
+
| Uniswap V3 | `0x75Ed28EA8601Ce9F5FbcAB1c2428f04A57aFaA16` | All |
|
|
110
|
+
| Uniswap V4 | `0xD8aa21AB7f9B8601CB7d7A776D3AFA1602d5D8D4` | All |
|
|
111
111
|
|
|
112
112
|
**Recipient config:** Set `fee_recipient` in `build_configure_asset_manager_tx` (V3/V4 accounts). Pass your wallet address or any destination address.
|
|
113
113
|
|
|
@@ -119,8 +119,6 @@ Quota is also bypassed automatically when: gas cost < pending fees ÷ 2, or posi
|
|
|
119
119
|
|
|
120
120
|
**When to enable:** When the pool you LP into has active Merkl campaigns. Check by looking at the pool APY breakdown in `get_strategies` — if there's a "Merkl" or "external rewards" component, enable this.
|
|
121
121
|
|
|
122
|
-
**Address:**
|
|
123
|
-
|
|
124
122
|
**Address (all chains):** `0x969F0251360b9Cf11c68f6Ce9587924c1B8b42C6`
|
|
125
123
|
|
|
126
124
|
**Always combine with rebalancer** when both are relevant — no conflict, extra free yield.
|
|
@@ -131,7 +129,7 @@ Quota is also bypassed automatically when: gas cost < pending fees ÷ 2, or posi
|
|
|
131
129
|
|
|
132
130
|
**What it does:** Bot places CoW Protocol batch auction swap orders to sell tokens accumulated in the account (e.g., claimed AERO emissions → USDC). Uses MEV-protected execution via CoW's batch auction mechanism.
|
|
133
131
|
|
|
134
|
-
**Address (Base):** `0xc928013A219EC9F18dE7B2dee6A50Ba626811854`
|
|
132
|
+
**Address (Base only):** `0xc928013A219EC9F18dE7B2dee6A50Ba626811854`
|
|
135
133
|
|
|
136
134
|
**Config:** Which tokens to sell and what to buy is configured in the Arcadia platform — not settable via MCP.
|
|
137
135
|
|
|
@@ -52,6 +52,8 @@ Close: disable rebalancer → unstake → atomic close (burn LP + swap + repay
|
|
|
52
52
|
|
|
53
53
|
### Step-by-step
|
|
54
54
|
|
|
55
|
+
> Addresses below are Base mainnet examples. Always verify current addresses via `get_lending_pools` and `get_assets` before executing.
|
|
56
|
+
|
|
55
57
|
```
|
|
56
58
|
// 1. FIND A POOL
|
|
57
59
|
get_strategies(chain_id: 8453)
|