@arcadia-finance/mcp-server 0.2.0 → 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 +61 -53
- package/dist/clients/api.js +2 -2
- package/dist/config/addresses.js +59 -4
- package/dist/index.js +38 -1
- package/dist/prompts/workflows.js +16 -13
- package/dist/tools/{write/sign-and-send.js → dev/send.js} +20 -15
- package/dist/tools/index.js +42 -32
- package/dist/tools/output-schemas.js +128 -0
- package/dist/tools/read/account.js +288 -0
- package/dist/tools/read/asset-managers.js +158 -0
- package/dist/tools/read/assets.js +52 -16
- package/dist/tools/read/guides.js +25 -4
- package/dist/tools/read/points.js +14 -20
- package/dist/tools/read/pools.js +72 -33
- package/dist/tools/read/strategy.js +162 -0
- package/dist/tools/read/wallet.js +222 -0
- package/dist/tools/{advanced → write/account}/add-liquidity.js +19 -13
- package/dist/tools/write/{borrow.js → account/borrow.js} +19 -15
- package/dist/tools/{advanced/close-position.js → write/account/close.js} +20 -17
- package/dist/tools/write/{create-account.js → account/create.js} +21 -20
- package/dist/tools/{advanced/repay-with-collateral.js → write/account/deleverage.js} +15 -8
- package/dist/tools/write/{deposit.js → account/deposit.js} +19 -15
- package/dist/tools/{advanced → write/account}/format-response.js +6 -5
- package/dist/tools/{advanced/account-metadata.js → write/account/metadata.js} +1 -1
- package/dist/tools/{advanced → write/account}/remove-liquidity.js +15 -12
- package/dist/tools/write/{repay.js → account/repay.js} +29 -14
- package/dist/tools/{advanced/position-actions.js → write/account/stake.js} +18 -13
- package/dist/tools/{advanced → write/account}/swap.js +9 -5
- package/dist/tools/write/{withdraw.js → account/withdraw.js} +20 -16
- 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/{approve.js → wallet/approve.js} +18 -14
- package/package.json +3 -2
- package/server.json +26 -8
- package/skills/clamm-liquidity/SKILL.md +53 -47
- package/skills/clamm-liquidity/automation.md +83 -73
- package/skills/clamm-liquidity/selection.md +13 -13
- package/skills/clamm-liquidity/strategies.md +69 -71
- package/dist/tools/read/accounts.js +0 -265
- package/dist/tools/read/allowances.js +0 -72
- package/dist/tools/read/balances.js +0 -79
- package/dist/tools/read/protocol.js +0 -117
- package/dist/tools/write/configure-asset-manager.js +0 -254
- package/dist/tools/write/set-asset-manager.js +0 -62
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { formatUnits } from "viem";
|
|
3
|
-
import { erc20Abi } from "../../abis/index.js";
|
|
4
|
-
import { getPublicClient } from "../../clients/chain.js";
|
|
5
|
-
import { validateAddress, validateChainId } from "../../utils/validation.js";
|
|
6
|
-
export function registerBalanceTools(server, chains) {
|
|
7
|
-
server.registerTool("read.wallet_balances", {
|
|
8
|
-
annotations: {
|
|
9
|
-
title: "Get Wallet Balances",
|
|
10
|
-
readOnlyHint: true,
|
|
11
|
-
destructiveHint: false,
|
|
12
|
-
idempotentHint: true,
|
|
13
|
-
openWorldHint: true,
|
|
14
|
-
},
|
|
15
|
-
description: "Get native ETH and ERC20 token balances for a wallet address. Reads directly from chain via RPC multicall. Use before advanced.add_liquidity or write.deposit to verify the wallet has sufficient tokens.",
|
|
16
|
-
inputSchema: {
|
|
17
|
-
wallet_address: z.string().describe("Wallet address to check balances for"),
|
|
18
|
-
token_addresses: z.array(z.string()).describe("ERC20 token contract addresses to check"),
|
|
19
|
-
chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
|
|
20
|
-
},
|
|
21
|
-
}, async ({ wallet_address, token_addresses, chain_id }) => {
|
|
22
|
-
try {
|
|
23
|
-
const validChainId = validateChainId(chain_id);
|
|
24
|
-
const wallet = validateAddress(wallet_address, "wallet_address");
|
|
25
|
-
const client = getPublicClient(validChainId, chains);
|
|
26
|
-
// Build multicall: for each token get balanceOf, decimals, symbol
|
|
27
|
-
const calls = token_addresses.flatMap((addr) => [
|
|
28
|
-
{
|
|
29
|
-
address: addr,
|
|
30
|
-
abi: erc20Abi,
|
|
31
|
-
functionName: "balanceOf",
|
|
32
|
-
args: [wallet],
|
|
33
|
-
},
|
|
34
|
-
{ address: addr, abi: erc20Abi, functionName: "decimals" },
|
|
35
|
-
{ address: addr, abi: erc20Abi, functionName: "symbol" },
|
|
36
|
-
]);
|
|
37
|
-
const [nativeBalance, ...multicallResults] = await Promise.all([
|
|
38
|
-
client.getBalance({ address: wallet }),
|
|
39
|
-
...(calls.length > 0 ? [client.multicall({ contracts: calls, allowFailure: true })] : []),
|
|
40
|
-
]);
|
|
41
|
-
const results = (multicallResults[0] ?? []);
|
|
42
|
-
const tokens = token_addresses.map((addr, i) => {
|
|
43
|
-
const balRes = results[i * 3];
|
|
44
|
-
const decRes = results[i * 3 + 1];
|
|
45
|
-
const symRes = results[i * 3 + 2];
|
|
46
|
-
const balance = balRes?.status === "success" ? String(balRes.result) : "0";
|
|
47
|
-
const decimals = decRes?.status === "success" ? Number(decRes.result) : 18;
|
|
48
|
-
const symbol = symRes?.status === "success" ? String(symRes.result) : "???";
|
|
49
|
-
return {
|
|
50
|
-
address: addr,
|
|
51
|
-
symbol,
|
|
52
|
-
decimals,
|
|
53
|
-
balance,
|
|
54
|
-
formatted: formatUnits(BigInt(balance), decimals),
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
const result = {
|
|
58
|
-
native: {
|
|
59
|
-
symbol: "ETH",
|
|
60
|
-
balance: String(nativeBalance),
|
|
61
|
-
formatted: formatUnits(nativeBalance, 18),
|
|
62
|
-
},
|
|
63
|
-
tokens,
|
|
64
|
-
};
|
|
65
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
return {
|
|
69
|
-
content: [
|
|
70
|
-
{
|
|
71
|
-
type: "text",
|
|
72
|
-
text: `Error: ${err instanceof Error ? err.message : String(err)}`,
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
isError: true,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export function registerProtocolTools(server, api) {
|
|
3
|
-
server.registerTool("read.strategies", {
|
|
4
|
-
annotations: {
|
|
5
|
-
title: "Get Strategies",
|
|
6
|
-
readOnlyHint: true,
|
|
7
|
-
destructiveHint: false,
|
|
8
|
-
idempotentHint: true,
|
|
9
|
-
openWorldHint: true,
|
|
10
|
-
},
|
|
11
|
-
description: "Get Arcadia LP strategies. Use featured_only=true for curated top strategies (recommended first call). Use strategy_id for full detail on a specific strategy — includes APY per range width (narrower range = higher APY but more rebalancing cost/risk). Without filters, returns a compact summary with 7d avg APY for the strategy's default range. Increase limit or use offset for pagination. All APY values are decimal fractions (1.0 = 100%, 0.05 = 5%).",
|
|
12
|
-
inputSchema: {
|
|
13
|
-
strategy_id: z.number().optional().describe("Strategy ID for full detail"),
|
|
14
|
-
featured_only: z
|
|
15
|
-
.boolean()
|
|
16
|
-
.default(false)
|
|
17
|
-
.describe("Return only featured/curated strategies (recommended)"),
|
|
18
|
-
limit: z
|
|
19
|
-
.number()
|
|
20
|
-
.default(25)
|
|
21
|
-
.describe("Max strategies to return in compact list (default 25)"),
|
|
22
|
-
offset: z.number().default(0).describe("Skip first N strategies for pagination"),
|
|
23
|
-
chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
|
|
24
|
-
},
|
|
25
|
-
}, async ({ strategy_id, featured_only, limit, offset, chain_id }) => {
|
|
26
|
-
try {
|
|
27
|
-
let result;
|
|
28
|
-
if (strategy_id !== undefined) {
|
|
29
|
-
result = await api.getStrategyInfo(chain_id, strategy_id);
|
|
30
|
-
}
|
|
31
|
-
else if (featured_only) {
|
|
32
|
-
result = await api.getFeatured(chain_id);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
const all = await api.getStrategies(chain_id);
|
|
36
|
-
const list = Array.isArray(all) ? all : all.data;
|
|
37
|
-
if (Array.isArray(list)) {
|
|
38
|
-
const total = list.length;
|
|
39
|
-
const effectiveOffset = offset ?? 0;
|
|
40
|
-
const effectiveLimit = limit ?? 25;
|
|
41
|
-
const page = list.slice(effectiveOffset, effectiveOffset + effectiveLimit);
|
|
42
|
-
result = {
|
|
43
|
-
total,
|
|
44
|
-
offset: effectiveOffset,
|
|
45
|
-
limit: effectiveLimit,
|
|
46
|
-
strategies: page.map((s) => ({
|
|
47
|
-
strategy_id: s.strategy_id,
|
|
48
|
-
name: s.strategy_name,
|
|
49
|
-
strategy_apy_7d: s.strategy_apy,
|
|
50
|
-
tvl: s.tvl,
|
|
51
|
-
underlyings: s.underlyings?.map((u) => ({
|
|
52
|
-
address: u.underlying_address,
|
|
53
|
-
symbol: u.underlying_symbol,
|
|
54
|
-
})),
|
|
55
|
-
max_leverage: s.max_leverage,
|
|
56
|
-
})),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
result = all;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
return {
|
|
67
|
-
content: [
|
|
68
|
-
{
|
|
69
|
-
type: "text",
|
|
70
|
-
text: `Error: ${err instanceof Error ? err.message : String(err)}`,
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
isError: true,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
server.registerTool("read.recommendation", {
|
|
78
|
-
annotations: {
|
|
79
|
-
title: "Get Recommendation",
|
|
80
|
-
readOnlyHint: true,
|
|
81
|
-
destructiveHint: false,
|
|
82
|
-
idempotentHint: true,
|
|
83
|
-
openWorldHint: true,
|
|
84
|
-
},
|
|
85
|
-
description: "Get a rebalancing recommendation for an Arcadia account — suggests asset changes to optimize yield. Uses 1d APY (not 7d like read.strategies list view), so recommended strategies may differ from the list ranking.",
|
|
86
|
-
inputSchema: {
|
|
87
|
-
account_address: z.string().describe("Arcadia account address"),
|
|
88
|
-
chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
|
|
89
|
-
},
|
|
90
|
-
}, async ({ account_address, chain_id }) => {
|
|
91
|
-
try {
|
|
92
|
-
const result = await api.getRecommendation(chain_id, account_address);
|
|
93
|
-
const rec = result;
|
|
94
|
-
if (Array.isArray(rec.added_assets) &&
|
|
95
|
-
rec.added_assets.length === 0 &&
|
|
96
|
-
Array.isArray(rec.removed_assets) &&
|
|
97
|
-
rec.removed_assets.length === 0 &&
|
|
98
|
-
Number(rec.current_apy ?? 0) === 0 &&
|
|
99
|
-
Number(rec.proposed_apy ?? 0) === 0) {
|
|
100
|
-
rec.context_note =
|
|
101
|
-
"Account has no active positions — no rebalancing recommendations available.";
|
|
102
|
-
}
|
|
103
|
-
return { content: [{ type: "text", text: JSON.stringify(rec, null, 2) }] };
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
106
|
-
return {
|
|
107
|
-
content: [
|
|
108
|
-
{
|
|
109
|
-
type: "text",
|
|
110
|
-
text: `Error: ${err instanceof Error ? err.message : String(err)}`,
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
isError: true,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { encodeAbiParameters, encodeFunctionData } from "viem";
|
|
3
|
-
import { MINIMAL_STRATEGY_HOOK, getAmProtocolAddress, getStandaloneAmAddress, } from "../../config/addresses.js";
|
|
4
|
-
import { accountAbi } from "../../abis/index.js";
|
|
5
|
-
import { appendDataSuffix } from "../../utils/attribution.js";
|
|
6
|
-
import { validateAddress, validateChainId } from "../../utils/validation.js";
|
|
7
|
-
// Arcadia's bot initiator addresses per asset manager type
|
|
8
|
-
const REBALANCER_INITIATOR = "0x163CcA8F161CBBB401a96aDf4Cbf4D74f3faD1Ed";
|
|
9
|
-
const COMPOUNDER_INITIATOR = "0xb0f46DB8B96e265C1D93396444Eee952086C6f3D";
|
|
10
|
-
const CLAIMER_INITIATOR = "0xDc9B596ce15F859673D1Be72e2Aadd41DD3aC4fE";
|
|
11
|
-
const MERKL_INITIATOR = "0x521541D932B15631e8a1B037f17457C801722bA0";
|
|
12
|
-
// Default fee limits matching the dapp defaults
|
|
13
|
-
const DEFAULT_MAX_CLAIM_FEE = BigInt("100000000000000000"); // 10% (0.1 * 1e18)
|
|
14
|
-
const DEFAULT_MAX_SWAP_FEE = BigInt("500000000000000"); // 0.05% (0.0005 * 1e18)
|
|
15
|
-
const DEFAULT_MAX_TOLERANCE = BigInt("5000000000000000"); // 0.5% (0.005 * 1e18)
|
|
16
|
-
const DEFAULT_MIN_LIQUIDITY_RATIO = BigInt("990000000000000000"); // 99% (0.99 * 1e18)
|
|
17
|
-
function encodeRebalancerMetadata(triggerLowerRatio, triggerUpperRatio, compoundLeftovers, minRebalanceTime) {
|
|
18
|
-
const strategyParams = encodeAbiParameters([
|
|
19
|
-
{ name: "compound_leftovers", type: "string" },
|
|
20
|
-
{ name: "optimal_token0_ratio", type: "uint32" },
|
|
21
|
-
{ name: "trigger_tick_lower_ratio", type: "int32" },
|
|
22
|
-
{ name: "trigger_tick_upper_ratio", type: "int32" },
|
|
23
|
-
{ name: "min_rebalance_time", type: "uint64" },
|
|
24
|
-
{ name: "max_rebalance_time", type: "uint64" },
|
|
25
|
-
], [
|
|
26
|
-
compoundLeftovers,
|
|
27
|
-
500000, // 50% optimal token0 ratio (default)
|
|
28
|
-
triggerLowerRatio,
|
|
29
|
-
triggerUpperRatio,
|
|
30
|
-
BigInt(minRebalanceTime),
|
|
31
|
-
BigInt(1e12), // effectively no max
|
|
32
|
-
]);
|
|
33
|
-
return encodeAbiParameters([
|
|
34
|
-
{ name: "version", type: "uint8" },
|
|
35
|
-
{ name: "strategy", type: "string" },
|
|
36
|
-
{ name: "data", type: "bytes" },
|
|
37
|
-
], [1, triggerLowerRatio === 0 && triggerUpperRatio === 0 ? "default" : "custom", strategyParams]);
|
|
38
|
-
}
|
|
39
|
-
function encodeRebalancerCallbackData(initiator, strategyHook, metaData) {
|
|
40
|
-
// strategyData must be ABI-encoded empty bytes, not raw "0x".
|
|
41
|
-
// The hook's setStrategy does abi.decode(strategyData, (bytes)) which needs
|
|
42
|
-
// at least 64 bytes (offset + length) to decode successfully.
|
|
43
|
-
const emptyStrategyData = encodeAbiParameters([{ type: "bytes" }], ["0x"]);
|
|
44
|
-
return encodeAbiParameters([
|
|
45
|
-
{ name: "initiator", type: "address" },
|
|
46
|
-
{ name: "maxClaimFee", type: "uint256" },
|
|
47
|
-
{ name: "maxSwapFee", type: "uint256" },
|
|
48
|
-
{ name: "maxTolerance", type: "uint256" },
|
|
49
|
-
{ name: "minLiquidityRatio", type: "uint256" },
|
|
50
|
-
{ name: "strategyHook", type: "address" },
|
|
51
|
-
{ name: "strategyData", type: "bytes" },
|
|
52
|
-
{ name: "metaData_", type: "bytes" },
|
|
53
|
-
], [
|
|
54
|
-
initiator,
|
|
55
|
-
DEFAULT_MAX_CLAIM_FEE,
|
|
56
|
-
DEFAULT_MAX_SWAP_FEE,
|
|
57
|
-
DEFAULT_MAX_TOLERANCE,
|
|
58
|
-
DEFAULT_MIN_LIQUIDITY_RATIO,
|
|
59
|
-
strategyHook,
|
|
60
|
-
emptyStrategyData,
|
|
61
|
-
metaData,
|
|
62
|
-
]);
|
|
63
|
-
}
|
|
64
|
-
function encodeCompounderCallbackData(initiator) {
|
|
65
|
-
return encodeAbiParameters([
|
|
66
|
-
{ name: "initiator", type: "address" },
|
|
67
|
-
{ name: "maxClaimFee", type: "uint256" },
|
|
68
|
-
{ name: "maxSwapFee", type: "uint256" },
|
|
69
|
-
{ name: "maxTolerance", type: "uint256" },
|
|
70
|
-
{ name: "minLiquidityRatio", type: "uint256" },
|
|
71
|
-
{ name: "metaData_", type: "bytes" },
|
|
72
|
-
], [
|
|
73
|
-
initiator,
|
|
74
|
-
DEFAULT_MAX_CLAIM_FEE,
|
|
75
|
-
DEFAULT_MAX_SWAP_FEE,
|
|
76
|
-
DEFAULT_MAX_TOLERANCE,
|
|
77
|
-
DEFAULT_MIN_LIQUIDITY_RATIO,
|
|
78
|
-
"0x",
|
|
79
|
-
]);
|
|
80
|
-
}
|
|
81
|
-
function encodeYieldClaimerCallbackData(initiator, feeRecipient) {
|
|
82
|
-
return encodeAbiParameters([
|
|
83
|
-
{ name: "initiator", type: "address" },
|
|
84
|
-
{ name: "feeRecipient", type: "address" },
|
|
85
|
-
{ name: "maxClaimFee", type: "uint256" },
|
|
86
|
-
{ name: "metaData_", type: "bytes" },
|
|
87
|
-
], [initiator, feeRecipient, DEFAULT_MAX_CLAIM_FEE, "0x"]);
|
|
88
|
-
}
|
|
89
|
-
function encodeMerklOperatorCallbackData(initiator, rewardRecipient) {
|
|
90
|
-
return encodeAbiParameters([
|
|
91
|
-
{ name: "initiator", type: "address" },
|
|
92
|
-
{ name: "rewardRecipient", type: "address" },
|
|
93
|
-
{ name: "maxClaimFee", type: "uint256" },
|
|
94
|
-
{ name: "metaData_", type: "bytes" },
|
|
95
|
-
], [initiator, rewardRecipient, DEFAULT_MAX_CLAIM_FEE, "0x"]);
|
|
96
|
-
}
|
|
97
|
-
const PROTOCOL_TO_AM_KEY = {
|
|
98
|
-
slipstream: "slipstreamV1",
|
|
99
|
-
slipstream_v2: "slipstreamV2",
|
|
100
|
-
staked_slipstream: "slipstreamV1",
|
|
101
|
-
staked_slipstream_v2: "slipstreamV2",
|
|
102
|
-
uniV3: "uniV3",
|
|
103
|
-
uniV4: "uniV4",
|
|
104
|
-
};
|
|
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.");
|
|
115
|
-
}
|
|
116
|
-
return getAmProtocolAddress(chainId, AM_TYPE_TO_CATEGORY[amType], PROTOCOL_TO_AM_KEY[protocol]);
|
|
117
|
-
}
|
|
118
|
-
export function registerConfigureAssetManagerTool(server, _chains) {
|
|
119
|
-
server.registerTool("write.configure_asset_manager", {
|
|
120
|
-
annotations: {
|
|
121
|
-
title: "Build Configure Asset Manager Transaction",
|
|
122
|
-
readOnlyHint: false,
|
|
123
|
-
destructiveHint: false,
|
|
124
|
-
idempotentHint: true,
|
|
125
|
-
openWorldHint: false,
|
|
126
|
-
},
|
|
127
|
-
description: "Build an unsigned transaction to enable AND configure an asset manager on an Arcadia V3/V4 account. Unlike write.set_asset_manager (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 write.set_asset_manager 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 } }.",
|
|
128
|
-
inputSchema: {
|
|
129
|
-
account_address: z.string().describe("Arcadia account address (must be V3 or V4)"),
|
|
130
|
-
asset_manager_address: z
|
|
131
|
-
.string()
|
|
132
|
-
.optional()
|
|
133
|
-
.describe("Asset manager contract address. Optional if pool_protocol is provided."),
|
|
134
|
-
pool_protocol: z
|
|
135
|
-
.enum([
|
|
136
|
-
"slipstream",
|
|
137
|
-
"slipstream_v2",
|
|
138
|
-
"staked_slipstream",
|
|
139
|
-
"staked_slipstream_v2",
|
|
140
|
-
"uniV3",
|
|
141
|
-
"uniV4",
|
|
142
|
-
])
|
|
143
|
-
.optional()
|
|
144
|
-
.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)."),
|
|
145
|
-
am_type: z
|
|
146
|
-
.enum(["rebalancer", "compounder", "yield_claimer", "merkl_operator"])
|
|
147
|
-
.describe("Type of asset manager"),
|
|
148
|
-
// Rebalancer-specific
|
|
149
|
-
trigger_lower_ratio: z
|
|
150
|
-
.number()
|
|
151
|
-
.int()
|
|
152
|
-
.default(0)
|
|
153
|
-
.describe("Rebalancer: how far below the current lower tick to trigger rebalance, as int32 * 1e6 (default 0 = trigger exactly at boundary). Positive values trigger before going out of range."),
|
|
154
|
-
trigger_upper_ratio: z
|
|
155
|
-
.number()
|
|
156
|
-
.int()
|
|
157
|
-
.default(0)
|
|
158
|
-
.describe("Rebalancer: how far above the current upper tick to trigger rebalance, as int32 * 1e6 (default 0 = trigger exactly at boundary). Positive values trigger before going out of range."),
|
|
159
|
-
compound_leftovers: z
|
|
160
|
-
.enum(["all", "none", "token0", "token1"])
|
|
161
|
-
.default("all")
|
|
162
|
-
.describe('Rebalancer: what to do with leftover tokens after rebalance (default "all" = compound both)'),
|
|
163
|
-
min_rebalance_time: z
|
|
164
|
-
.number()
|
|
165
|
-
.int()
|
|
166
|
-
.default(3600)
|
|
167
|
-
.describe("Rebalancer: minimum seconds between rebalances (default 3600 = 1 hour)"),
|
|
168
|
-
strategy_hook: z
|
|
169
|
-
.string()
|
|
170
|
-
.optional()
|
|
171
|
-
.describe("Rebalancer: strategy hook address. Defaults to minimal hook (0x13beD1A58d87c0454872656c5328103aAe5eB86A). Only override for POL or custom hooks."),
|
|
172
|
-
// Yield Claimer / Merkl Operator
|
|
173
|
-
fee_recipient: z
|
|
174
|
-
.string()
|
|
175
|
-
.optional()
|
|
176
|
-
.describe("yield_claimer: address to receive claimed fees (required for yield_claimer)"),
|
|
177
|
-
reward_recipient: z
|
|
178
|
-
.string()
|
|
179
|
-
.optional()
|
|
180
|
-
.describe("merkl_operator: address to receive Merkl rewards (required for merkl_operator)"),
|
|
181
|
-
chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
|
|
182
|
-
},
|
|
183
|
-
}, async (params) => {
|
|
184
|
-
try {
|
|
185
|
-
const validChainId = validateChainId(params.chain_id);
|
|
186
|
-
const validAccount = validateAddress(params.account_address, "account_address");
|
|
187
|
-
const amAddress = params.asset_manager_address ??
|
|
188
|
-
resolveAmAddress(validChainId, params.am_type, params.pool_protocol);
|
|
189
|
-
let callbackData;
|
|
190
|
-
switch (params.am_type) {
|
|
191
|
-
case "rebalancer": {
|
|
192
|
-
const metaData = encodeRebalancerMetadata(params.trigger_lower_ratio, params.trigger_upper_ratio, params.compound_leftovers, params.min_rebalance_time);
|
|
193
|
-
const strategyHook = params.strategy_hook
|
|
194
|
-
? validateAddress(params.strategy_hook, "strategy_hook")
|
|
195
|
-
: MINIMAL_STRATEGY_HOOK;
|
|
196
|
-
callbackData = encodeRebalancerCallbackData(REBALANCER_INITIATOR, strategyHook, metaData);
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
case "compounder": {
|
|
200
|
-
callbackData = encodeCompounderCallbackData(COMPOUNDER_INITIATOR);
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
case "yield_claimer": {
|
|
204
|
-
if (!params.fee_recipient) {
|
|
205
|
-
throw new Error("fee_recipient is required for yield_claimer");
|
|
206
|
-
}
|
|
207
|
-
const validFeeRecipient = validateAddress(params.fee_recipient, "fee_recipient");
|
|
208
|
-
callbackData = encodeYieldClaimerCallbackData(CLAIMER_INITIATOR, validFeeRecipient);
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
case "merkl_operator": {
|
|
212
|
-
if (!params.reward_recipient) {
|
|
213
|
-
throw new Error("reward_recipient is required for merkl_operator");
|
|
214
|
-
}
|
|
215
|
-
const validRewardRecipient = validateAddress(params.reward_recipient, "reward_recipient");
|
|
216
|
-
callbackData = encodeMerklOperatorCallbackData(MERKL_INITIATOR, validRewardRecipient);
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
const data = appendDataSuffix(encodeFunctionData({
|
|
221
|
-
abi: accountAbi,
|
|
222
|
-
functionName: "setAssetManagers",
|
|
223
|
-
args: [[validateAddress(amAddress, "asset_manager_address")], [true], [callbackData]],
|
|
224
|
-
}));
|
|
225
|
-
return {
|
|
226
|
-
content: [
|
|
227
|
-
{
|
|
228
|
-
type: "text",
|
|
229
|
-
text: JSON.stringify({
|
|
230
|
-
description: `Configure and enable ${params.am_type} ${amAddress} on account ${params.account_address}`,
|
|
231
|
-
transaction: {
|
|
232
|
-
to: validAccount,
|
|
233
|
-
data,
|
|
234
|
-
value: "0",
|
|
235
|
-
chainId: validChainId,
|
|
236
|
-
},
|
|
237
|
-
}, null, 2),
|
|
238
|
-
},
|
|
239
|
-
],
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
catch (err) {
|
|
243
|
-
return {
|
|
244
|
-
content: [
|
|
245
|
-
{
|
|
246
|
-
type: "text",
|
|
247
|
-
text: `Error: ${err instanceof Error ? err.message : String(err)}`,
|
|
248
|
-
},
|
|
249
|
-
],
|
|
250
|
-
isError: true,
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { encodeFunctionData } from "viem";
|
|
3
|
-
import { accountAbi } from "../../abis/index.js";
|
|
4
|
-
import { appendDataSuffix } from "../../utils/attribution.js";
|
|
5
|
-
import { validateAddress } from "../../utils/validation.js";
|
|
6
|
-
export function registerSetAssetManagerTool(server, _chains) {
|
|
7
|
-
server.registerTool("write.set_asset_manager", {
|
|
8
|
-
annotations: {
|
|
9
|
-
title: "Build Set Asset Manager Transaction",
|
|
10
|
-
readOnlyHint: false,
|
|
11
|
-
destructiveHint: false,
|
|
12
|
-
idempotentHint: true,
|
|
13
|
-
openWorldHint: false,
|
|
14
|
-
},
|
|
15
|
-
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 write.configure_asset_manager instead. For asset manager addresses, call read.guide('automation'). Returns { transaction: { to, data, value, chainId } }.",
|
|
16
|
-
inputSchema: {
|
|
17
|
-
account_address: z.string().describe("Arcadia account address (V3 or V4)"),
|
|
18
|
-
asset_manager_address: z
|
|
19
|
-
.string()
|
|
20
|
-
.describe("Asset manager contract address to grant or revoke"),
|
|
21
|
-
enabled: z.boolean().describe("True to grant permission, false to revoke"),
|
|
22
|
-
chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
|
|
23
|
-
},
|
|
24
|
-
}, async (params) => {
|
|
25
|
-
try {
|
|
26
|
-
const validAccount = validateAddress(params.account_address, "account_address");
|
|
27
|
-
const validAm = validateAddress(params.asset_manager_address, "asset_manager_address");
|
|
28
|
-
const data = appendDataSuffix(encodeFunctionData({
|
|
29
|
-
abi: accountAbi,
|
|
30
|
-
functionName: "setAssetManagers",
|
|
31
|
-
args: [[validAm], [params.enabled], ["0x"]],
|
|
32
|
-
}));
|
|
33
|
-
return {
|
|
34
|
-
content: [
|
|
35
|
-
{
|
|
36
|
-
type: "text",
|
|
37
|
-
text: JSON.stringify({
|
|
38
|
-
description: `${params.enabled ? "Grant" : "Revoke"} asset manager permission for ${params.asset_manager_address}`,
|
|
39
|
-
transaction: {
|
|
40
|
-
to: validAccount,
|
|
41
|
-
data,
|
|
42
|
-
value: "0",
|
|
43
|
-
chainId: params.chain_id,
|
|
44
|
-
},
|
|
45
|
-
}, null, 2),
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
return {
|
|
52
|
-
content: [
|
|
53
|
-
{
|
|
54
|
-
type: "text",
|
|
55
|
-
text: `Error: ${err instanceof Error ? err.message : String(err)}`,
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
isError: true,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|