@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.
Files changed (34) hide show
  1. package/README.md +5 -10
  2. package/dist/clients/api.js +23 -0
  3. package/dist/config/addresses.js +49 -188
  4. package/dist/index.js +4 -2
  5. package/dist/prompts/workflows.js +15 -13
  6. package/dist/resources/guides.js +1 -1
  7. package/dist/tools/dev/send.js +7 -5
  8. package/dist/tools/index.js +4 -14
  9. package/dist/tools/output-schemas.js +42 -6
  10. package/dist/tools/read/account.js +80 -42
  11. package/dist/tools/read/asset-managers.js +138 -113
  12. package/dist/tools/read/guides.js +3 -3
  13. package/dist/tools/write/asset-managers/automations.js +241 -0
  14. package/dist/tools/write/asset-managers/intents.js +247 -0
  15. package/dist/tools/write/asset-managers/shared.js +0 -26
  16. package/dist/utils/http-config.js +37 -0
  17. package/dist/utils/validation.js +16 -0
  18. package/llms-full.txt +39 -80
  19. package/llms.txt +9 -14
  20. package/package.json +1 -1
  21. package/server.json +2 -2
  22. package/skills/clamm-liquidity/SKILL.md +90 -69
  23. package/skills/clamm-liquidity/automation.md +153 -76
  24. package/skills/clamm-liquidity/selection.md +6 -5
  25. package/skills/clamm-liquidity/strategies.md +40 -34
  26. package/skills/openclaw/SKILL.md +3 -3
  27. package/skills/openclaw/contracts.md +29 -16
  28. package/dist/tools/write/asset-managers/compounder.js +0 -113
  29. package/dist/tools/write/asset-managers/cow-swapper.js +0 -50
  30. package/dist/tools/write/asset-managers/encoding.js +0 -162
  31. package/dist/tools/write/asset-managers/merkl-operator.js +0 -52
  32. package/dist/tools/write/asset-managers/rebalancer.js +0 -109
  33. package/dist/tools/write/asset-managers/set-asset-managers.js +0 -76
  34. package/dist/tools/write/asset-managers/yield-claimer.js +0 -117
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
  import { CHAIN_ID_DESCRIPTION } from "../../config/chains.js";
3
3
  import { accountAbi } from "../../abis/index.js";
4
4
  import { getPublicClient } from "../../clients/chain.js";
5
- import { getChainAmChecks, AM_KEY_TO_POOL_PROTOCOL, CHAIN_POSITION_MANAGERS, UNIVERSAL_POSITION_MANAGERS, } from "../../config/addresses.js";
5
+ import { AUTOMATION_GROUPS, backendProtocolToDexProtocol, GAS_RELAYER, positionManagerToDexProtocol, } from "../../config/addresses.js";
6
6
  import { validateAddress, validateChainId } from "../../utils/validation.js";
7
7
  import { AccountInfoOutput, AccountHistoryOutput, AccountPnlOutput } from "../output-schemas.js";
8
8
  function trimOverview(overview, chainId) {
@@ -28,8 +28,7 @@ function trimOverview(overview, chainId) {
28
28
  asset.token1 = details.token1;
29
29
  }
30
30
  if (typeof rest.address === "string") {
31
- const addr = rest.address.toLowerCase();
32
- const dexProtocol = CHAIN_POSITION_MANAGERS[chainId]?.[addr] ?? UNIVERSAL_POSITION_MANAGERS[addr];
31
+ const dexProtocol = positionManagerToDexProtocol(chainId, rest.address);
33
32
  if (dexProtocol)
34
33
  asset.dex_protocol = dexProtocol;
35
34
  }
@@ -62,7 +61,10 @@ export function registerAccountTools(server, api, chains) {
62
61
  idempotentHint: true,
63
62
  openWorldHint: true,
64
63
  },
65
- description: "Get full overview of an Arcadia account: health factor, collateral value, debt, deposited assets, liquidation price, and automation status. Health factor = 1 - (used_margin / liquidation_value): 1 = no debt (safest), >0 = healthy, 0 = liquidation threshold, <0 = past liquidation. Higher is safer. On all supported chains returns an `automation` object showing which asset managers are enabled (rebalancer, compounder, yield_claimer, merkl_operator, gas_relayer, cow_swapper). Automation detection spans every asset-manager version deployed on the selected chain, so registrations made on older versions are still reported as active; the returned value is the user-facing dex_protocol (e.g. 'slipstream') with no version suffix. LP positions in assets[] include a dex_protocol field (slipstream, slipstream_v2, slipstream_v3, staked_slipstream, staked_slipstream_v2, staked_slipstream_v3, uniV3, uniV4) — use this as the dex_protocol param for write.asset_manager.* tools. Slipstream V2 and V3 pools are Base-only; Unichain and Optimism support only Slipstream V1, uniV3, and uniV4. The automation object uses internal AM key names (slipstreamV1, slipstreamV2, slipstreamV3, uniV3, uniV4): map slipstreamV1 → 'slipstream'/'staked_slipstream', slipstreamV2 → 'slipstream_v2'/'staked_slipstream_v2', slipstreamV3 → 'slipstream_v3'/'staked_slipstream_v3', uniV3 → 'uniV3', uniV4 → 'uniV4'. Numeric fields without a _usd suffix are in the account's numeraire token raw units (divide by 10^decimals: 6 for USDC, 18 for WETH, 8 for cbBTC). Fields ending in _usd are in USD with 18 decimals (divide by 1e18). health_factor is unitless. Asset amounts are raw token units. To list all accounts for a wallet, use read.wallet.accounts.",
64
+ description: "Get full overview of an Arcadia account: health factor, collateral value, debt, deposited assets, liquidation price, and automation status. Health factor = 1 - (used_margin / liquidation_value): 1 = no debt (safest), >0 = healthy, 0 = liquidation threshold, <0 = past liquidation. Higher is safer. " +
65
+ "The `automation` object reports which asset managers are enabled (rebalancer, compounder, yield_claimer, cow_swapper, merkl_operator, gas_relayer), each as the position's dex_protocol when protocol-specific or true when account-level, plus `inferred_intents` (the automations those managers add up to), `merkl` claim state, and `deprecated_managers` for any superseded deployment still set on the account. Superseded managers should be cleared: write.account.automations disables them as part of a save. For the full decoded per-manager config use read.asset_manager.current. " +
66
+ "LP positions in assets[] include a dex_protocol field (slipstream, slipstream_v2, slipstream_v3, staked_slipstream, staked_slipstream_v2, staked_slipstream_v3, uniV3, uniV4). To configure automations, prefer passing the position's id as position_id to write.account.automations, which resolves the protocol and tokens for you; the dex_protocol value is also accepted directly as its `protocol` param. Slipstream V2 is Base-only. V3 is available on Base and Optimism. Unichain supports only Slipstream V1, uniV3, and uniV4. " +
67
+ "Numeric fields without a _usd suffix are in the account's numeraire token raw units (divide by 10^decimals: 6 for USDC, 18 for WETH, 8 for cbBTC). Fields ending in _usd are in USD with 18 decimals (divide by 1e18). health_factor is unitless. Asset amounts are raw token units. To list all accounts for a wallet, use read.wallet.accounts.",
66
68
  inputSchema: {
67
69
  account_address: z.string().describe("Arcadia account address"),
68
70
  chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION),
@@ -73,7 +75,9 @@ export function registerAccountTools(server, api, chains) {
73
75
  const validChainId = validateChainId(chain_id);
74
76
  const validAccount = validateAddress(account_address, "account_address");
75
77
  const client = getPublicClient(validChainId, chains);
76
- const [overview, liquidation_price, accountVersion] = await Promise.all([
78
+ // The automations read is issued alongside the others rather than after, so
79
+ // sourcing automation state from the backend costs no extra round-trip.
80
+ const [overview, liquidation_price, accountVersion, automationState] = await Promise.all([
77
81
  api.getAccountOverview(validChainId, account_address).catch(() => null),
78
82
  api.getLiquidationPrice(validChainId, account_address).catch(() => null),
79
83
  client
@@ -84,6 +88,10 @@ export function registerAccountTools(server, api, chains) {
84
88
  })
85
89
  .then((v) => Number(v))
86
90
  .catch(() => null),
91
+ api
92
+ .getCurrentAutomations(validAccount, validChainId)
93
+ .then((s) => ({ ok: true, state: s }))
94
+ .catch((e) => ({ ok: false, error: e })),
87
95
  ]);
88
96
  if (!overview && !liquidation_price && !accountVersion) {
89
97
  return {
@@ -115,45 +123,75 @@ export function registerAccountTools(server, api, chains) {
115
123
  notes.push(`liquidation_price is extremely high ($${liqPrice.toLocaleString()}) — this is typical for delta-neutral positions where both sides of the LP move together. Liquidation is very unlikely.`);
116
124
  }
117
125
  }
126
+ // Automation state comes from the backend's automations reader, which owns
127
+ // the asset-manager address book (including superseded deployments) and
128
+ // decodes each manager's on-chain config.
118
129
  let automation = null;
119
- const owner = overview?.owner;
120
- if (owner) {
121
- const amChecks = getChainAmChecks(validChainId);
122
- automation = await client
123
- .multicall({
124
- contracts: amChecks.map((c) => ({
125
- address: validAccount,
126
- abi: accountAbi,
127
- functionName: "isAssetManager",
128
- args: [owner, c.address],
129
- })),
130
- allowFailure: true,
131
- })
132
- .then((results) => {
133
- const out = {};
134
- for (const c of amChecks)
135
- out[c.group] = false;
136
- let activeProtocol = null;
137
- results.forEach((r, i) => {
138
- if (r.status !== "success" || !r.result)
139
- return;
140
- const check = amChecks[i];
141
- if (check.protocol) {
142
- const userFacing = AM_KEY_TO_POOL_PROTOCOL[check.protocol];
143
- out[check.group] = userFacing ?? check.protocol;
144
- if (!activeProtocol)
145
- activeProtocol = userFacing ?? check.protocol;
146
- }
147
- else {
148
- out[check.group] = true;
149
- }
150
- });
151
- if (activeProtocol) {
152
- out.dex_protocol = activeProtocol;
130
+ if (!automationState.ok) {
131
+ const e = automationState.error;
132
+ notes.push(`Automation state unavailable: ${e instanceof Error ? e.message : String(e)}. Other account data is unaffected.`);
133
+ }
134
+ else {
135
+ const state = automationState.state;
136
+ const managers = state.enabled ?? [];
137
+ const out = {};
138
+ for (const group of AUTOMATION_GROUPS)
139
+ out[group] = false;
140
+ let activeProtocol = null;
141
+ for (const m of managers) {
142
+ if (m.deprecated)
143
+ continue;
144
+ if (!m.protocol) {
145
+ out[m.manager] = true; // account-level manager, no protocol to report
146
+ continue;
153
147
  }
154
- return out;
155
- })
156
- .catch(() => null);
148
+ const dexProtocol = backendProtocolToDexProtocol(m.protocol);
149
+ if (!dexProtocol) {
150
+ // A protocol this server does not know yet. Report it verbatim rather
151
+ // than as `true`, which would misreport it as account-level.
152
+ out[m.manager] = m.protocol;
153
+ notes.push(`Automation state: unrecognised protocol "${m.protocol}" on the ${m.manager}, reported verbatim. This MCP server may be out of date.`);
154
+ continue;
155
+ }
156
+ out[m.manager] = dexProtocol;
157
+ if (!activeProtocol)
158
+ activeProtocol = dexProtocol;
159
+ }
160
+ if (activeProtocol)
161
+ out.dex_protocol = activeProtocol;
162
+ out.inferred_intents = state.inferred_intents ?? [];
163
+ const deprecated = managers.filter((m) => m.deprecated);
164
+ if (deprecated.length > 0) {
165
+ out.deprecated_managers = deprecated.map((m) => ({
166
+ manager: m.manager,
167
+ address: m.address,
168
+ version: m.version ?? null,
169
+ }));
170
+ }
171
+ if (state.merkl)
172
+ out.merkl = state.merkl;
173
+ // The gas relayer is an asset manager but no intent configures it, so the
174
+ // backend's reader does not cover it. Probe it directly to keep reporting it.
175
+ const owner = overview?.owner;
176
+ if (owner) {
177
+ try {
178
+ out.gas_relayer = await client.readContract({
179
+ address: validAccount,
180
+ abi: accountAbi,
181
+ functionName: "isAssetManager",
182
+ args: [owner, GAS_RELAYER],
183
+ });
184
+ }
185
+ catch (relayerErr) {
186
+ notes.push(`gas_relayer state could not be read: ${relayerErr instanceof Error ? relayerErr.message : String(relayerErr)}. Other automation fields are unaffected.`);
187
+ }
188
+ }
189
+ if (!state.read_ok) {
190
+ notes.push("Automation state could not be confirmed on-chain, so the automation object may be incomplete. Retry, or read it directly with read.asset_manager.current.");
191
+ }
192
+ for (const w of state.warnings ?? [])
193
+ notes.push(`Automation state: ${w}`);
194
+ automation = out;
157
195
  }
158
196
  const result = {
159
197
  account_version: accountVersion,
@@ -1,152 +1,177 @@
1
1
  import { z } from "zod";
2
- import { validateChainId } from "../../utils/validation.js";
3
- import { IntentsListOutput } from "../output-schemas.js";
4
- import { getChainDexProtocols } from "../../config/addresses.js";
5
- const POOL_PROTOCOLS = [
6
- "slipstream",
7
- "slipstream_v2",
8
- "slipstream_v3",
9
- "staked_slipstream",
10
- "staked_slipstream_v2",
11
- "staked_slipstream_v3",
12
- "uniV3",
13
- "uniV4",
14
- ];
15
- const DEX_PROTOCOL_PARAM = {
16
- name: "dex_protocol",
17
- type: "enum",
18
- values: POOL_PROTOCOLS,
19
- hint: "LP DEX protocol of the position",
20
- };
21
- const ALL_CHAINS = [8453, 130, 10];
22
- const BASE_ONLY = [8453];
23
- const INTENTS = [
24
- {
25
- id: "rebalancer",
26
- tool: "write.asset_manager.rebalancer",
27
- description: "Repositions LP when out of range, compounds fees and rewards. Configurable triggers, cooldowns, and token composition.",
28
- sets_managers: ["rebalancer"],
29
- required_params: [DEX_PROTOCOL_PARAM],
30
- optional_params: [
31
- "compound_leftovers",
32
- "optimal_token0_ratio",
33
- "trigger_lower_ratio",
34
- "trigger_upper_ratio",
35
- "min_rebalance_time",
36
- "max_rebalance_time",
37
- "strategy_hook",
38
- ],
39
- chains: ALL_CHAINS,
40
- },
41
- {
42
- id: "compounder",
43
- tool: "write.asset_manager.compounder",
44
- description: "Claims LP fees and reinvests into position. Pair with rebalancer for compounding between rebalances.",
45
- sets_managers: ["compounder"],
46
- required_params: [DEX_PROTOCOL_PARAM],
47
- optional_params: [],
48
- chains: ALL_CHAINS,
49
- },
2
+ import { validateAddress, validateChainId } from "../../utils/validation.js";
3
+ import { AutomationsStateOutput, IntentsListOutput } from "../output-schemas.js";
4
+ const INTENT_CATALOG = [
50
5
  {
51
- id: "compounder_staked",
52
- tool: "write.asset_manager.compounder_staked",
53
- description: "Compounder + CowSwap for staked LP positions (e.g. staked Slipstream/Aerodrome). Claims staked rewards (AERO) — staked positions earn staking rewards only, not LP fees. Swaps rewards to a target token via CowSwap batch auction, then compounds back into the LP. Base only.",
54
- sets_managers: ["cow_swapper", "compounder"],
55
- required_params: [
56
- DEX_PROTOCOL_PARAM,
57
- { name: "sell_tokens", type: "string[]", hint: "array of ERC20 addresses to sell" },
58
- { name: "buy_token", type: "string", hint: "ERC20 address to buy" },
59
- ],
60
- optional_params: [],
61
- chains: BASE_ONLY,
6
+ kind: "compound_fees",
7
+ description: "Reinvest earned fees and rewards back into the LP. On a staked position whose reward token is not a pool token, the reward is swapped to a pool token via CowSwap and folded in.",
8
+ params: ["tokens (token0|token1|reward)[], omit for all yielding tokens"],
9
+ needs_position_context: true,
62
10
  },
63
11
  {
64
- id: "yield_claimer",
65
- tool: "write.asset_manager.yield_claimer",
66
- description: "Claims pending fees/emissions and sends to a designated recipient address.",
67
- sets_managers: ["yield_claimer"],
68
- required_params: [
69
- DEX_PROTOCOL_PARAM,
70
- { name: "fee_recipient", type: "address", hint: "address to receive claimed fees" },
12
+ kind: "claim_rewards",
13
+ description: "Claim pending yield out of the position, either as-earned or converted to a single token via CowSwap.",
14
+ params: [
15
+ "config.mode (as_earned|convert_to)",
16
+ "config.destination (account|wallet)",
17
+ "config.buy_token (address, required when converting)",
18
+ "config.recipient (address, overrides destination)",
19
+ "config.tokens (token0|token1|reward)[]",
20
+ "config.convert_tokens (token0|token1|reward)[]: convert a subset, claim the rest as-earned",
71
21
  ],
72
- optional_params: [],
73
- chains: ALL_CHAINS,
22
+ needs_position_context: true,
74
23
  },
75
24
  {
76
- id: "yield_claimer_cowswap",
77
- tool: "write.asset_manager.yield_claimer_cowswap",
78
- description: "Yield claimer coupled with CowSwap. Claims fees, swaps to target token via batch auction, sends to recipient.",
79
- sets_managers: ["cow_swapper", "yield_claimer"],
80
- required_params: [
81
- DEX_PROTOCOL_PARAM,
82
- { name: "sell_tokens", type: "string[]", hint: "array of ERC20 addresses to sell" },
83
- { name: "buy_token", type: "string", hint: "ERC20 address to buy" },
84
- { name: "fee_recipient", type: "address", hint: "address to receive claimed fees" },
85
- ],
86
- optional_params: [],
87
- chains: BASE_ONLY,
25
+ kind: "add_to_lp",
26
+ description: "Fold idle pool-token balances (deposits, rebalance leftovers) back into the LP. Opt-in per token.",
27
+ params: ["tokens (token0|token1)[], omit for both"],
28
+ needs_position_context: true,
88
29
  },
89
30
  {
90
- id: "cow_swapper",
91
- tool: "write.asset_manager.cow_swapper",
92
- description: "Standalone CowSwap mode. Swap any ERC20 via batch auctions. Each swap requires account owner signature.",
93
- sets_managers: ["cow_swapper"],
94
- required_params: [],
95
- optional_params: [],
96
- chains: BASE_ONLY,
31
+ kind: "claim_merkl",
32
+ description: "Auto-claim Merkl incentive rewards. Independent of the other automations and needs no position context.",
33
+ params: ["config.destination (account|wallet)", "config.reward_recipient (address)"],
34
+ needs_position_context: false,
97
35
  },
98
36
  {
99
- id: "merkl_operator",
100
- tool: "write.asset_manager.merkl_operator",
101
- description: "Claims external Merkl incentive rewards. Enable when pool has active Merkl campaigns. Combine with rebalancer for extra yield.",
102
- sets_managers: ["merkl_operator"],
103
- required_params: [
104
- { name: "reward_recipient", type: "address", hint: "address to receive Merkl rewards" },
37
+ kind: "rebalance",
38
+ description: "Reposition the LP when it moves out of range, or on a take-profit / POL strategy. Claims and compounds yield as part of the rebalance.",
39
+ params: [
40
+ "strategy.kind (out_of_range|take_profit|protocol_owned_liquidity)",
41
+ "out_of_range: optimal_token0_ratio, trigger_lower_tick_ratio, trigger_upper_tick_ratio, min_rebalance_time, max_rebalance_time",
42
+ "take_profit: profit_token, take_profit_trigger_type/threshold, take_profit_reposition_mode, has_reversal, reversal_*",
43
+ "protocol_owned_liquidity: initial_range, base_range, k1, k2, rebalance_threshold, limit_order_withdrawal_threshold, fraction_excess_to_limit_order, deadzone, target_token0_ratio",
44
+ "max_tolerance, min_liquidity_ratio (1e18-scaled overrides)",
105
45
  ],
106
- optional_params: [],
107
- chains: ALL_CHAINS,
46
+ needs_position_context: true,
108
47
  },
109
48
  ];
110
- export function registerAssetManagerTools(server) {
49
+ const USAGE = "Build an intents array from these kinds and pass it to write.account.automations (full desired state) or write.account.automations_delta (change one automation, leave the rest alone). The backend resolves the asset managers, validates the combination and returns the unsigned transaction.";
50
+ export function registerAssetManagerTools(server, api) {
111
51
  server.registerTool("read.asset_manager.intents", {
112
52
  annotations: {
113
53
  title: "List Available Automations",
114
54
  readOnlyHint: true,
115
55
  destructiveHint: false,
116
56
  idempotentHint: true,
117
- openWorldHint: false,
57
+ openWorldHint: true,
118
58
  },
119
- description: "List all available automation intents with their tool names, required parameters, and supported chains. Use this to discover which automations can be configured and what each one does. Each intent has a corresponding write.asset_manager.{id} tool that returns encoded args. To apply automations, call the intent tools then pass the combined result to write.account.set_asset_managers. All intent tools accept enabled=false to disable. Multiple intents can be combined by merging their returned arrays into a single set_asset_managers call.",
59
+ description: "List the automation intents Arcadia supports, with the parameters each one accepts. " +
60
+ "Pass account_address to also get per-account availability: which intents can be enabled right now and, for any that cannot, the compatibility rule blocking it. " +
61
+ "Pass position_id as well to scope availability to one LP position. Without account_address this returns the catalog only.",
62
+ outputSchema: IntentsListOutput,
120
63
  inputSchema: {
121
- chain_id: z
64
+ account_address: z
65
+ .string()
66
+ .optional()
67
+ .describe("Arcadia account address. Include it to get live per-account availability."),
68
+ position_id: z
122
69
  .number()
70
+ .int()
123
71
  .optional()
124
- .describe("Filter to automations available on this chain. Omit to see all."),
72
+ .describe("LP position (NFT) id to scope availability to. Requires account_address."),
73
+ chain_id: z
74
+ .number()
75
+ .default(8453)
76
+ .describe("Chain id: 8453 Base, 130 Unichain, 10 Optimism"),
125
77
  },
126
- outputSchema: IntentsListOutput,
127
78
  }, async (params) => {
128
79
  try {
129
- let filtered = INTENTS;
130
- if (params.chain_id !== undefined) {
131
- const validChainId = validateChainId(params.chain_id);
132
- const chainDexProtocols = getChainDexProtocols(validChainId);
133
- filtered = INTENTS.filter((i) => i.chains.includes(validChainId)).map((intent) => ({
134
- ...intent,
135
- required_params: intent.required_params.map((p) => p.name === "dex_protocol" ? { ...p, values: chainDexProtocols } : p),
136
- }));
80
+ const chainId = validateChainId(params.chain_id);
81
+ if (params.position_id !== undefined && !params.account_address) {
82
+ throw new Error("position_id requires account_address.");
83
+ }
84
+ let automations = INTENT_CATALOG.map((i) => ({ ...i }));
85
+ // The catalog is static, so an availability outage degrades to catalog-only
86
+ // with the reason stated rather than failing the whole call. The absent
87
+ // `available` fields plus availability_error say what is missing; nothing
88
+ // is guessed.
89
+ let availabilityError = null;
90
+ if (params.account_address) {
91
+ const account = validateAddress(params.account_address, "account_address");
92
+ try {
93
+ const live = await api.getAvailableAutomations(account, chainId, params.position_id);
94
+ const byKind = new Map(live.intents.map((i) => [i.kind, i]));
95
+ automations = automations.map((doc) => {
96
+ const entry = byKind.get(doc.kind);
97
+ return entry
98
+ ? { ...doc, available: entry.available, unavailable_reason: entry.reason ?? null }
99
+ : doc;
100
+ });
101
+ }
102
+ catch (err) {
103
+ availabilityError = err instanceof Error ? err.message : String(err);
104
+ }
137
105
  }
138
106
  const result = {
139
- automations: filtered,
140
- shared_params: ["enabled (boolean, default true)", "chain_id (number, default 8453)"],
141
- usage: "1. Call the intent tool (e.g. write.asset_manager.rebalancer) with enabled + chain_id to get encoded args. 2. Optionally merge arrays from multiple intent calls. 3. Pass to write.account.set_asset_managers to build the unsigned tx.",
107
+ automations,
108
+ ...(availabilityError
109
+ ? {
110
+ availability_error: `Per-account availability could not be read: ${availabilityError}. The catalog below is complete, but no intent is annotated as available or blocked. write.account.automations still validates the combination.`,
111
+ }
112
+ : {}),
113
+ shared_params: [
114
+ "enabled (boolean, default true): set false to disable an intent's managers",
115
+ "position_id (number): scopes the intent and auto-fetches position context",
116
+ "chain_id (number, default 8453)",
117
+ ],
118
+ usage: USAGE,
142
119
  };
120
+ return {
121
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
122
+ structuredContent: result,
123
+ };
124
+ }
125
+ catch (err) {
143
126
  return {
144
127
  content: [
145
128
  {
146
129
  type: "text",
147
- text: JSON.stringify(result, null, 2),
130
+ text: `Error: ${err instanceof Error ? err.message : String(err)}`,
148
131
  },
149
132
  ],
133
+ isError: true,
134
+ };
135
+ }
136
+ });
137
+ server.registerTool("read.asset_manager.current", {
138
+ annotations: {
139
+ title: "Read Current Account Automations",
140
+ readOnlyHint: true,
141
+ destructiveHint: false,
142
+ idempotentHint: true,
143
+ openWorldHint: true,
144
+ },
145
+ description: "Read which asset managers are currently enabled on an account, with their decoded on-chain configuration. " +
146
+ "Returns the active managers (address, protocol, initiator, decoded strategy metadata, slippage and value-loss caps, fee recipient), the intents they map to, and Merkl claim state including whether reward tokens still need registering. " +
147
+ "Managers from superseded deployments are listed separately under `deprecated`: pass their addresses to write.account.automations_delta to clear them, or run write.account.automations which disables them as part of the save. " +
148
+ "read_ok is false when chain state could not be read, in which case the result is unreliable rather than empty.",
149
+ outputSchema: AutomationsStateOutput,
150
+ inputSchema: {
151
+ account_address: z.string().describe("Arcadia account address"),
152
+ chain_id: z
153
+ .number()
154
+ .default(8453)
155
+ .describe("Chain id: 8453 Base, 130 Unichain, 10 Optimism"),
156
+ },
157
+ }, async (params) => {
158
+ try {
159
+ const chainId = validateChainId(params.chain_id);
160
+ const account = validateAddress(params.account_address, "account_address");
161
+ const state = await api.getCurrentAutomations(account, chainId);
162
+ const all = state.enabled ?? [];
163
+ const result = {
164
+ account: state.account,
165
+ chain_id: state.chain_id,
166
+ read_ok: state.read_ok,
167
+ inferred_intents: state.inferred_intents ?? [],
168
+ enabled: all.filter((m) => !m.deprecated),
169
+ deprecated: all.filter((m) => m.deprecated),
170
+ merkl: (state.merkl ?? null),
171
+ warnings: state.warnings ?? [],
172
+ };
173
+ return {
174
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
150
175
  structuredContent: result,
151
176
  };
152
177
  }
@@ -10,7 +10,7 @@ const TOPICS = {
10
10
  },
11
11
  automation: {
12
12
  file: "automation.md",
13
- summary: "Rebalancer, compounder, yield claimer, merkl operator, CoW swapper setup and addresses",
13
+ summary: "Intent-based automation setup: compound fees, claim rewards, add to LP, rebalance, claim Merkl",
14
14
  },
15
15
  strategies: {
16
16
  file: "strategies.md",
@@ -42,12 +42,12 @@ export function registerGuideTools(server) {
42
42
  idempotentHint: true,
43
43
  openWorldHint: true,
44
44
  },
45
- description: "Get Arcadia workflow guides and reference documentation. Call this before multi-step workflows (opening LP positions, enabling automation, closing positions) or when you need contract addresses, asset manager addresses, or strategy parameters. Topics: overview (addresses + tool catalog), automation (rebalancer/compounder setup), strategies (step-by-step templates), selection (how to evaluate and parameterize strategies).",
45
+ description: "Get Arcadia workflow guides and reference documentation. Call this before multi-step workflows (opening LP positions, enabling automation, closing positions) or when you need contract addresses, asset manager addresses, or strategy parameters. Topics: overview (addresses + tool catalog), automation (intent-based automation setup), strategies (step-by-step templates), selection (how to evaluate and parameterize strategies).",
46
46
  inputSchema: {
47
47
  topic: z
48
48
  .enum(TOPIC_KEYS)
49
49
  .optional()
50
- .describe("overview = addresses + tool catalog, automation = rebalancer/compounder/claimer setup, strategies = step-by-step LP templates, selection = pool evaluation + leverage sizing"),
50
+ .describe("overview = addresses + tool catalog, automation = intent-based automation setup, strategies = step-by-step LP templates, selection = pool evaluation + leverage sizing"),
51
51
  },
52
52
  outputSchema: GuideOutput,
53
53
  }, async ({ topic }) => {