@arcadia-finance/mcp-server 0.5.1 → 0.6.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 (55) hide show
  1. package/README.md +58 -52
  2. package/dist/clients/api.js +52 -11
  3. package/dist/clients/chain.js +25 -0
  4. package/dist/config/addresses.js +22 -2
  5. package/dist/config/chains.js +12 -4
  6. package/dist/index.js +36 -134
  7. package/dist/prompts/workflows.js +54 -18
  8. package/dist/resources/guides.js +1 -1
  9. package/dist/tools/aero.js +157 -0
  10. package/dist/tools/dev/send.js +4 -4
  11. package/dist/tools/index.js +6 -0
  12. package/dist/tools/output-schemas.js +103 -29
  13. package/dist/tools/read/account.js +57 -15
  14. package/dist/tools/read/aero-upgrade.js +53 -0
  15. package/dist/tools/read/asset-managers.js +9 -9
  16. package/dist/tools/read/assets.js +9 -9
  17. package/dist/tools/read/guides.js +4 -4
  18. package/dist/tools/read/points.js +4 -4
  19. package/dist/tools/read/pools.js +10 -9
  20. package/dist/tools/read/shapes.js +48 -0
  21. package/dist/tools/read/strategy.js +14 -13
  22. package/dist/tools/read/wallet.js +15 -15
  23. package/dist/tools/write/account/add-liquidity.js +9 -9
  24. package/dist/tools/write/account/aero-upgrade.js +124 -0
  25. package/dist/tools/write/account/borrow.js +5 -5
  26. package/dist/tools/write/account/close.js +8 -8
  27. package/dist/tools/write/account/create.js +3 -3
  28. package/dist/tools/write/account/deleverage.js +4 -4
  29. package/dist/tools/write/account/deposit.js +4 -4
  30. package/dist/tools/write/account/format-response.js +1 -1
  31. package/dist/tools/write/account/remove-liquidity.js +6 -6
  32. package/dist/tools/write/account/repay.js +4 -4
  33. package/dist/tools/write/account/stake.js +5 -5
  34. package/dist/tools/write/account/swap.js +4 -4
  35. package/dist/tools/write/account/withdraw.js +5 -5
  36. package/dist/tools/write/asset-managers/automations.js +14 -14
  37. package/dist/tools/write/asset-managers/intents.js +10 -7
  38. package/dist/tools/write/pool/deposit.js +5 -5
  39. package/dist/tools/write/pool/redeem.js +4 -4
  40. package/dist/tools/write/wallet/approve.js +4 -4
  41. package/dist/tools/write/wallet/upgrade-velo.js +76 -0
  42. package/dist/utils/analytics.js +68 -0
  43. package/dist/utils/http-config.js +4 -4
  44. package/llms-full.txt +114 -77
  45. package/llms.txt +47 -44
  46. package/package.json +8 -4
  47. package/server.json +10 -4
  48. package/skills/clamm-liquidity/SKILL.md +101 -83
  49. package/skills/clamm-liquidity/automation.md +14 -14
  50. package/skills/clamm-liquidity/selection.md +13 -13
  51. package/skills/clamm-liquidity/strategies.md +135 -53
  52. package/skills/openclaw/SKILL.md +3 -3
  53. package/skills/openclaw/arcadia.sh +24 -45
  54. package/skills/openclaw/contracts.md +19 -16
  55. package/dist/utils/tool-naming.js +0 -91
@@ -16,14 +16,8 @@ export const BatchedTransactionOutput = z.object({
16
16
  tenderly_sim_url: z.string().optional(),
17
17
  tenderly_sim_status: z.enum(["success", "failure", "unavailable"]).optional(),
18
18
  expected_value_change: z.string().optional(),
19
- before: z
20
- .object({ total_account_value: z.string(), used_margin: z.string() })
21
- .passthrough()
22
- .optional(),
23
- after: z
24
- .object({ total_account_value: z.string(), used_margin: z.string() })
25
- .passthrough()
26
- .optional(),
19
+ before: z.object({ total_account_value: z.string(), used_margin: z.string() }).loose().optional(),
20
+ after: z.object({ total_account_value: z.string(), used_margin: z.string() }).loose().optional(),
27
21
  });
28
22
  const ResolvedManager = z.object({
29
23
  manager: z.string(),
@@ -62,9 +56,9 @@ export const AutomationsStateOutput = z.object({
62
56
  chain_id: z.number(),
63
57
  read_ok: z.boolean(),
64
58
  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(),
59
+ enabled: z.array(z.record(z.string(), z.unknown())),
60
+ deprecated: z.array(z.record(z.string(), z.unknown())),
61
+ merkl: z.record(z.string(), z.unknown()).nullish(),
68
62
  warnings: z.array(z.string()),
69
63
  });
70
64
  export const WalletBalancesOutput = z.object({
@@ -102,21 +96,21 @@ export const DevSendOutput = z.object({
102
96
  export const AccountInfoOutput = z
103
97
  .object({
104
98
  account_version: z.number().nullable(),
105
- overview: z.record(z.unknown()).nullable(),
106
- liquidation_price: z.record(z.unknown()).nullable(),
107
- automation: z.record(z.unknown()).optional(),
99
+ overview: z.record(z.string(), z.unknown()).nullable(),
100
+ liquidation_price: z.record(z.string(), z.unknown()).nullable(),
101
+ automation: z.record(z.string(), z.unknown()).optional(),
108
102
  context_notes: z.array(z.string()).optional(),
109
103
  })
110
- .passthrough();
104
+ .loose();
111
105
  export const AccountListOutput = z.object({
112
- accounts: z.array(z.record(z.unknown())),
106
+ accounts: z.array(z.record(z.string(), z.unknown())),
113
107
  });
114
108
  export const AccountHistoryOutput = z.object({
115
- history: z.array(z.record(z.unknown())),
109
+ history: z.array(z.record(z.string(), z.unknown())),
116
110
  });
117
111
  export const AccountPnlOutput = z.object({
118
- pnl_cost_basis: z.record(z.unknown()),
119
- yield_earned: z.record(z.unknown()),
112
+ pnl_cost_basis: z.record(z.string(), z.unknown()),
113
+ yield_earned: z.record(z.string(), z.unknown()),
120
114
  });
121
115
  export const AssetListOutput = z.object({
122
116
  total: z.number(),
@@ -128,39 +122,119 @@ export const AssetListOutput = z.object({
128
122
  })),
129
123
  });
130
124
  export const AssetPricesOutput = z.object({
131
- prices: z.record(z.number()),
125
+ prices: z.record(z.string(), z.number()),
132
126
  });
133
127
  export const PoolListOutput = z.object({
134
- pools: z.array(z.record(z.unknown())),
128
+ pools: z.array(z.record(z.string(), z.unknown())),
135
129
  context_notes: z.array(z.string()).optional(),
136
130
  });
137
131
  export const PoolDetailOutput = z.object({
138
- pool: z.record(z.unknown()),
139
- apy_history: z.array(z.record(z.unknown())),
132
+ pool: z.record(z.string(), z.unknown()),
133
+ apy_history: z.array(z.record(z.string(), z.unknown())),
140
134
  });
141
- export const PointsWalletOutput = z.object({}).passthrough();
135
+ export const PointsWalletOutput = z.object({}).loose();
142
136
  export const PointsLeaderboardOutput = z.object({
143
137
  total: z.number(),
144
138
  offset: z.number(),
145
139
  limit: z.number(),
146
- leaderboard: z.array(z.record(z.unknown())),
140
+ leaderboard: z.array(z.record(z.string(), z.unknown())),
147
141
  });
148
142
  export const StrategyListOutput = z.object({
149
143
  total: z.number(),
150
144
  offset: z.number(),
151
145
  limit: z.number(),
152
- strategies: z.array(z.record(z.unknown())),
146
+ strategies: z.array(z.record(z.string(), z.unknown())),
153
147
  context_notes: z.array(z.string()).optional(),
154
148
  });
155
- export const StrategyDetailOutput = z.object({}).passthrough();
156
- export const StrategyRecommendationOutput = z.object({}).passthrough();
149
+ export const StrategyDetailOutput = z.object({}).loose();
150
+ export const StrategyRecommendationOutput = z.object({}).loose();
157
151
  export const GuideOutput = z.object({
158
152
  topic: z.string(),
159
153
  content: z.string(),
160
154
  });
161
155
  export const IntentsListOutput = z.object({
162
- automations: z.array(z.record(z.unknown())),
156
+ automations: z.array(z.record(z.string(), z.unknown())),
163
157
  availability_error: z.string().optional(),
164
158
  shared_params: z.array(z.string()),
165
159
  usage: z.string(),
166
160
  });
161
+ const ManagerToReconnect = z.object({
162
+ kind: z.string(),
163
+ old_address: z.string(),
164
+ new_address: z.string().nullable(),
165
+ initiator: z.string().nullable(),
166
+ });
167
+ const AeroPlanStatus = z.enum([
168
+ "ready",
169
+ "choices_required",
170
+ "waiting",
171
+ "not_open",
172
+ "nothing_to_upgrade",
173
+ ]);
174
+ export const AeroUpgradeCandidatesOutput = z.object({
175
+ chain_id: z.number(),
176
+ owner_address: z.string().nullable(),
177
+ opens_at: z.number().nullable(),
178
+ checked_at: z.number(),
179
+ accounts: z.array(z.object({
180
+ account_address: z.string(),
181
+ is_spot: z.boolean(),
182
+ status: AeroPlanStatus,
183
+ positions: z.number(),
184
+ old_aero: z.string(),
185
+ movable: z.number(),
186
+ waiting: z.number(),
187
+ blocked: z.number(),
188
+ })),
189
+ failed_accounts: z.array(z.object({ account_address: z.string(), error: z.string() })),
190
+ });
191
+ const AeroUpgradePlanOutput = z.object({
192
+ description: z.string(),
193
+ account_address: z.string(),
194
+ // The account owner: the only address that can send the transaction.
195
+ owner: z.string(),
196
+ status: AeroPlanStatus,
197
+ status_note: z.string(),
198
+ // Absent while nothing can go now, and when the transaction's simulation failed.
199
+ transaction: Transaction.optional(),
200
+ gas: z.string().optional(),
201
+ error: z.string().optional(),
202
+ tenderly_sim_url: z.string().optional(),
203
+ tenderly_sim_status: z.enum(["success", "failure", "unavailable"]),
204
+ simulation_note: z.string().optional(),
205
+ // Net per token, from the simulation: positive into the account, negative out.
206
+ asset_changes: z.array(z.object({
207
+ token: z.string(),
208
+ standard: z.string(),
209
+ amount: z.string(),
210
+ decimals: z.number().nullable(),
211
+ protocol: z.string().nullable(),
212
+ })),
213
+ opens_at: z.number().nullable(),
214
+ price_tolerance_bps: z.number(),
215
+ items: z.array(z.record(z.string(), z.unknown())),
216
+ managers_to_reconnect: z.array(ManagerToReconnect),
217
+ old_managers_still_needed: z.boolean(),
218
+ next_steps: z.array(z.string()),
219
+ });
220
+ // One account: the plan fields. Several accounts: `results`, one plan or
221
+ // `{account_address, status: "error", error}` per account.
222
+ export const AeroUpgradeOutput = AeroUpgradePlanOutput.partial().extend({
223
+ description: z.string(),
224
+ chain_id: z.number().optional(),
225
+ max_gas_per_tx: z.number().optional(),
226
+ results: z.array(z.record(z.string(), z.unknown())).optional(),
227
+ multisends: z.array(z.array(z.string())).optional(),
228
+ next_steps: z.array(z.string()),
229
+ });
230
+ export const VeloUpgradeOutput = z.object({
231
+ description: z.string(),
232
+ transactions: z.array(z.object({ description: z.string(), transaction: Transaction })),
233
+ destination_chain_id: z.number(),
234
+ recipient: z.string(),
235
+ old_token: z.string(),
236
+ new_token: z.string(),
237
+ amount_in: z.string(),
238
+ expected_amount_out: z.string(),
239
+ fee_wei: z.string(),
240
+ });
@@ -5,6 +5,48 @@ import { getPublicClient } from "../../clients/chain.js";
5
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
+ /**
9
+ * Normalise `/accounts/historic_account_values` into a time series.
10
+ *
11
+ * The endpoint answers `{ values: { "<unix seconds>": <net value>, ... } }` — an
12
+ * object keyed by timestamp, not an array. Coercing a non-array response to `[]`
13
+ * therefore discarded every snapshot and reported it as "no history", which is
14
+ * indistinguishable from an account that genuinely has none.
15
+ *
16
+ * Both shapes are accepted so this survives the endpoint changing, and anything
17
+ * that is neither throws rather than reporting an empty series: a read that did
18
+ * not work has to look different from a read that found nothing.
19
+ */
20
+ export function normalizeAccountHistory(raw) {
21
+ if (Array.isArray(raw))
22
+ return raw;
23
+ if (raw === null || raw === undefined)
24
+ return [];
25
+ const hasValues = typeof raw === "object" && raw !== null && "values" in raw;
26
+ const values = raw.values;
27
+ // A `values` key that is present but carries nothing is the empty window this
28
+ // function claims to handle — an array or null there is an answer, not an
29
+ // unrecognised shape.
30
+ if (hasValues && (values === null || values === undefined))
31
+ return [];
32
+ if (Array.isArray(values))
33
+ return values;
34
+ if (values && typeof values === "object") {
35
+ return Object.entries(values)
36
+ .map(([timestamp, netValue]) => {
37
+ // A non-numeric key would become NaN, which sorts unpredictably and
38
+ // serialises to null. For a function whose point is refusing to mangle
39
+ // unexpected shapes, that gets the same throw as an unknown shape.
40
+ const parsed = Number(timestamp);
41
+ if (!Number.isFinite(parsed)) {
42
+ throw new Error(`Unexpected account-history timestamp key: ${JSON.stringify(timestamp)}`);
43
+ }
44
+ return { timestamp: parsed, net_value: netValue };
45
+ })
46
+ .sort((a, b) => a.timestamp - b.timestamp);
47
+ }
48
+ throw new Error(`Unexpected account-history response shape: ${JSON.stringify(raw).slice(0, 200)}`);
49
+ }
8
50
  function trimOverview(overview, chainId) {
9
51
  const trimmed = { ...overview };
10
52
  if (Array.isArray(trimmed.historic_actions)) {
@@ -53,7 +95,7 @@ function trimOverview(overview, chainId) {
53
95
  return trimmed;
54
96
  }
55
97
  export function registerAccountTools(server, api, chains) {
56
- server.registerTool("read.account.info", {
98
+ server.registerTool("read_account_info", {
57
99
  annotations: {
58
100
  title: "Get Account Info",
59
101
  readOnlyHint: true,
@@ -62,13 +104,13 @@ export function registerAccountTools(server, api, chains) {
62
104
  openWorldHint: true,
63
105
  },
64
106
  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.",
68
- inputSchema: {
107
+ "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. " +
108
+ "LP positions in assets[] include a dex_protocol field (slipstream, slipstream_v2, slipstream_v3, metadexcl_v1, staked_slipstream, staked_slipstream_v2, staked_slipstream_v3, staked_metadexcl_v1, uniV3, uniV4). metadexcl_v1 is Aero CL, live on Base, Optimism and Robinhood for spot and margin accounts. Slipstream V2 is Base-only. V3 is available on Base and Optimism. Unichain supports Slipstream V1, uniV3 and 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. " +
109
+ "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.",
110
+ inputSchema: z.object({
69
111
  account_address: z.string().describe("Arcadia account address"),
70
112
  chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION),
71
- },
113
+ }),
72
114
  outputSchema: AccountInfoOutput,
73
115
  }, async ({ account_address, chain_id }) => {
74
116
  try {
@@ -187,7 +229,7 @@ export function registerAccountTools(server, api, chains) {
187
229
  }
188
230
  }
189
231
  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.");
232
+ 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
233
  }
192
234
  for (const w of state.warnings ?? [])
193
235
  notes.push(`Automation state: ${w}`);
@@ -226,7 +268,7 @@ export function registerAccountTools(server, api, chains) {
226
268
  };
227
269
  }
228
270
  });
229
- server.registerTool("read.account.history", {
271
+ server.registerTool("read_account_history", {
230
272
  annotations: {
231
273
  title: "Get Account History",
232
274
  readOnlyHint: true,
@@ -234,12 +276,12 @@ export function registerAccountTools(server, api, chains) {
234
276
  idempotentHint: true,
235
277
  openWorldHint: true,
236
278
  },
237
- description: "Get historical collateral and debt values for an Arcadia account over time. Returns a time series of snapshots (timestamp, collateral_value, debt_value, net_value). Each value is the account's net value in USD (human-readable, not raw units). Useful for charting account performance over a period.",
238
- inputSchema: {
279
+ description: "Get an Arcadia account's historical net value over time. Returns a time series of snapshots, oldest first, each `{ timestamp, net_value }` — `timestamp` is unix seconds and `net_value` is USD (human-readable, not raw units). Useful for charting account performance over a period. An empty `history` means the account has no snapshots in the window, not that the read failed.",
280
+ inputSchema: z.object({
239
281
  account_address: z.string().describe("Arcadia account address"),
240
282
  days: z.number().default(14).describe("Number of days of history (default 14)"),
241
283
  chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION),
242
- },
284
+ }),
243
285
  outputSchema: AccountHistoryOutput,
244
286
  }, async ({ account_address, days, chain_id }) => {
245
287
  try {
@@ -251,7 +293,7 @@ export function registerAccountTools(server, api, chains) {
251
293
  };
252
294
  }
253
295
  const raw = await api.getAccountHistory(validChainId, account_address, days);
254
- const result = { history: Array.isArray(raw) ? raw : [] };
296
+ const result = { history: normalizeAccountHistory(raw) };
255
297
  return {
256
298
  content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
257
299
  structuredContent: result,
@@ -269,7 +311,7 @@ export function registerAccountTools(server, api, chains) {
269
311
  };
270
312
  }
271
313
  });
272
- server.registerTool("read.account.pnl", {
314
+ server.registerTool("read_account_pnl", {
273
315
  annotations: {
274
316
  title: "Get Account PnL",
275
317
  readOnlyHint: true,
@@ -278,10 +320,10 @@ export function registerAccountTools(server, api, chains) {
278
320
  openWorldHint: true,
279
321
  },
280
322
  description: "Get PnL (cost basis) and yield earned for an Arcadia account. Returns lifetime totals: cost basis vs current value (negative cost_basis = net profit withdrawn), net transfers per token, total yield earned in USD and per token. cost_basis, current_value, cost_diff are in USD (human-readable). Per-token fields (net_transfers, summed_yields_earned) are in raw token units.",
281
- inputSchema: {
323
+ inputSchema: z.object({
282
324
  account_address: z.string().describe("Arcadia account address"),
283
325
  chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION),
284
- },
326
+ }),
285
327
  outputSchema: AccountPnlOutput,
286
328
  }, async ({ account_address, chain_id }) => {
287
329
  try {
@@ -0,0 +1,53 @@
1
+ import { z } from "zod";
2
+ import { validateAddress } from "../../utils/validation.js";
3
+ import { aeroErrorResult, validateAeroChain } from "../aero.js";
4
+ import { AeroUpgradeCandidatesOutput } from "../output-schemas.js";
5
+ export function registerAeroUpgradeReadTool(server, api) {
6
+ server.registerTool("read_account_aero_upgrade", {
7
+ annotations: {
8
+ title: "Check Aero Upgrade Candidates",
9
+ readOnlyHint: true,
10
+ destructiveHint: false,
11
+ idempotentHint: true,
12
+ openWorldHint: true,
13
+ },
14
+ description: "Which Arcadia accounts have something to upgrade to Aero (MetadexCL V1): Slipstream V1 to V3 positions (Aerodrome on Base, Velodrome on Optimism, staked or not) and old AERO. Pass wallet_address for every account of a wallet, or account_address for one. " +
15
+ "Per account: status (ready | choices_required | waiting | not_open | nothing_to_upgrade), positions (every Slipstream position on it), movable (ready or needing a pool choice), waiting, blocked, old_aero (raw, 18 decimals). Accounts without a Slipstream position or old AERO are left out, including accounts whose positions already moved but whose automations still run on the old Slipstream managers: when read_asset_manager_current shows Slipstream managers on an account that only holds metadexcl_v1 positions, call write_account_aero_upgrade for it to get managers_to_reconnect. failed_accounts lists the accounts whose check failed, with the error: an empty accounts list means nothing to do only when failed_accounts is empty too. Otherwise tell the user those accounts could not be checked and retry later. opens_at is when the AERO token upgrade opens on Base. " +
16
+ "No calldata, prices or simulation: this is the cheap check. For the plan and the transaction call write_account_aero_upgrade. Chains: Base (8453), Optimism (10); Robinhood (4663) has no Slipstream positions and answers an empty list.",
17
+ inputSchema: z.object({
18
+ wallet_address: z
19
+ .string()
20
+ .optional()
21
+ .describe("Wallet whose accounts to check. Pass this or account_address, not both."),
22
+ account_address: z.string().optional().describe("One Arcadia account to check"),
23
+ chain_id: z
24
+ .number()
25
+ .default(8453)
26
+ .describe("Chain ID: 8453 (Base), 10 (Optimism) or 4663 (Robinhood, nothing to upgrade)"),
27
+ }),
28
+ outputSchema: AeroUpgradeCandidatesOutput,
29
+ }, async ({ wallet_address, account_address, chain_id }) => {
30
+ try {
31
+ if ((wallet_address === undefined) === (account_address === undefined)) {
32
+ throw new Error("Pass exactly one of wallet_address and account_address.");
33
+ }
34
+ const chainId = validateAeroChain(chain_id);
35
+ const result = await api.getAeroUpgradeCandidates({
36
+ chain_id: chainId,
37
+ owner_address: wallet_address === undefined
38
+ ? undefined
39
+ : validateAddress(wallet_address, "wallet_address"),
40
+ account_address: account_address === undefined
41
+ ? undefined
42
+ : validateAddress(account_address, "account_address"),
43
+ });
44
+ return {
45
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
46
+ structuredContent: result,
47
+ };
48
+ }
49
+ catch (err) {
50
+ return aeroErrorResult(err);
51
+ }
52
+ });
53
+ }
@@ -46,9 +46,9 @@ const INTENT_CATALOG = [
46
46
  needs_position_context: true,
47
47
  },
48
48
  ];
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.";
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
50
  export function registerAssetManagerTools(server, api) {
51
- server.registerTool("read.asset_manager.intents", {
51
+ server.registerTool("read_asset_manager_intents", {
52
52
  annotations: {
53
53
  title: "List Available Automations",
54
54
  readOnlyHint: true,
@@ -60,7 +60,7 @@ export function registerAssetManagerTools(server, api) {
60
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
61
  "Pass position_id as well to scope availability to one LP position. Without account_address this returns the catalog only.",
62
62
  outputSchema: IntentsListOutput,
63
- inputSchema: {
63
+ inputSchema: z.object({
64
64
  account_address: z
65
65
  .string()
66
66
  .optional()
@@ -74,7 +74,7 @@ export function registerAssetManagerTools(server, api) {
74
74
  .number()
75
75
  .default(8453)
76
76
  .describe("Chain id: 8453 Base, 130 Unichain, 10 Optimism"),
77
- },
77
+ }),
78
78
  }, async (params) => {
79
79
  try {
80
80
  const chainId = validateChainId(params.chain_id);
@@ -107,7 +107,7 @@ export function registerAssetManagerTools(server, api) {
107
107
  automations,
108
108
  ...(availabilityError
109
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.`,
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
111
  }
112
112
  : {}),
113
113
  shared_params: [
@@ -134,7 +134,7 @@ export function registerAssetManagerTools(server, api) {
134
134
  };
135
135
  }
136
136
  });
137
- server.registerTool("read.asset_manager.current", {
137
+ server.registerTool("read_asset_manager_current", {
138
138
  annotations: {
139
139
  title: "Read Current Account Automations",
140
140
  readOnlyHint: true,
@@ -144,16 +144,16 @@ export function registerAssetManagerTools(server, api) {
144
144
  },
145
145
  description: "Read which asset managers are currently enabled on an account, with their decoded on-chain configuration. " +
146
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. " +
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
148
  "read_ok is false when chain state could not be read, in which case the result is unreliable rather than empty.",
149
149
  outputSchema: AutomationsStateOutput,
150
- inputSchema: {
150
+ inputSchema: z.object({
151
151
  account_address: z.string().describe("Arcadia account address"),
152
152
  chain_id: z
153
153
  .number()
154
154
  .default(8453)
155
155
  .describe("Chain id: 8453 Base, 130 Unichain, 10 Optimism"),
156
- },
156
+ }),
157
157
  }, async (params) => {
158
158
  try {
159
159
  const chainId = validateChainId(params.chain_id);
@@ -1,8 +1,9 @@
1
1
  import { z } from "zod";
2
+ import { expectArrayOrWrapped } from "./shapes.js";
2
3
  import { CHAIN_ID_DESCRIPTION } from "../../config/chains.js";
3
4
  import { AssetListOutput, AssetPricesOutput } from "../output-schemas.js";
4
5
  export function registerAssetTools(server, api) {
5
- server.registerTool("read.asset.list", {
6
+ server.registerTool("read_asset_list", {
6
7
  annotations: {
7
8
  title: "List Supported Assets",
8
9
  readOnlyHint: true,
@@ -10,20 +11,19 @@ export function registerAssetTools(server, api) {
10
11
  idempotentHint: true,
11
12
  openWorldHint: true,
12
13
  },
13
- description: "List supported collateral assets on Arcadia. Returns compact list (address, symbol, decimals, type). Use search to filter by symbol substring. For USD prices, use read.asset.prices.",
14
- inputSchema: {
14
+ description: "List supported collateral assets on Arcadia. Returns compact list (address, symbol, decimals, type). Use search to filter by symbol substring. For USD prices, use read_asset_prices.",
15
+ inputSchema: z.object({
15
16
  search: z
16
17
  .string()
17
18
  .optional()
18
19
  .describe("Filter assets by symbol (case-insensitive substring match)"),
19
20
  chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION),
20
- },
21
+ }),
21
22
  outputSchema: AssetListOutput,
22
23
  }, async ({ search, chain_id }) => {
23
24
  try {
24
25
  const raw = await api.getAssets(chain_id);
25
- const obj = raw;
26
- const allAssets = (Array.isArray(raw) ? raw : (obj.assets ?? obj.data ?? []));
26
+ const allAssets = expectArrayOrWrapped(raw, "assets", "assets", "data");
27
27
  let assets = allAssets.map((a) => ({
28
28
  address: a.address ?? a.asset_address,
29
29
  symbol: a.name ?? a.symbol ?? a.asset_symbol,
@@ -52,7 +52,7 @@ export function registerAssetTools(server, api) {
52
52
  };
53
53
  }
54
54
  });
55
- server.registerTool("read.asset.prices", {
55
+ server.registerTool("read_asset_prices", {
56
56
  annotations: {
57
57
  title: "Get Asset Prices",
58
58
  readOnlyHint: true,
@@ -61,12 +61,12 @@ export function registerAssetTools(server, api) {
61
61
  openWorldHint: true,
62
62
  },
63
63
  description: "Get USD prices for one or more asset addresses. Pass a single address or comma-separated addresses. Returns a price map keyed by address.",
64
- inputSchema: {
64
+ inputSchema: z.object({
65
65
  asset_addresses: z
66
66
  .string()
67
67
  .describe("Single address or comma-separated addresses for price lookup"),
68
68
  chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION),
69
- },
69
+ }),
70
70
  outputSchema: AssetPricesOutput,
71
71
  }, async ({ asset_addresses, chain_id }) => {
72
72
  try {
@@ -14,7 +14,7 @@ const TOPICS = {
14
14
  },
15
15
  strategies: {
16
16
  file: "strategies.md",
17
- summary: "Step-by-step strategy templates: delta neutral leveraged LP, protocol owned liquidity, closing sequences",
17
+ summary: "Step-by-step strategy templates: delta neutral leveraged LP, protocol owned liquidity, closing sequences, moving Slipstream positions to Aero",
18
18
  },
19
19
  selection: {
20
20
  file: "selection.md",
@@ -34,7 +34,7 @@ export function registerGuideTools(server) {
34
34
  guides.set(topic, `Guide "${topic}" is not available in this installation.`);
35
35
  }
36
36
  }
37
- server.registerTool("read.guides", {
37
+ server.registerTool("read_guides", {
38
38
  annotations: {
39
39
  title: "Get Guide",
40
40
  readOnlyHint: true,
@@ -43,12 +43,12 @@ export function registerGuideTools(server) {
43
43
  openWorldHint: true,
44
44
  },
45
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
- inputSchema: {
46
+ inputSchema: z.object({
47
47
  topic: z
48
48
  .enum(TOPIC_KEYS)
49
49
  .optional()
50
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 }) => {
54
54
  if (!topic) {
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { PointsLeaderboardOutput } from "../output-schemas.js";
3
3
  export function registerPointsTools(server, api) {
4
- server.registerTool("read.point_leaderboard", {
4
+ server.registerTool("read_point_leaderboard", {
5
5
  annotations: {
6
6
  title: "Get Points Leaderboard",
7
7
  readOnlyHint: true,
@@ -9,11 +9,11 @@ export function registerPointsTools(server, api) {
9
9
  idempotentHint: true,
10
10
  openWorldHint: true,
11
11
  },
12
- description: "Get the Arcadia points leaderboard (paginated). For a specific wallet's points balance, use read.wallet.points.",
13
- inputSchema: {
12
+ description: "Get the Arcadia points leaderboard (paginated). For a specific wallet's points balance, use read_wallet_points.",
13
+ inputSchema: z.object({
14
14
  limit: z.number().default(25).describe("Max leaderboard entries to return (default 25)"),
15
15
  offset: z.number().default(0).describe("Skip first N leaderboard entries for pagination"),
16
- },
16
+ }),
17
17
  outputSchema: PointsLeaderboardOutput,
18
18
  }, async ({ limit, offset }) => {
19
19
  try {
@@ -1,8 +1,9 @@
1
+ import { expectArray } from "./shapes.js";
1
2
  import { z } from "zod";
2
3
  import { CHAIN_ID_DESCRIPTION } from "../../config/chains.js";
3
4
  import { PoolListOutput, PoolDetailOutput } from "../output-schemas.js";
4
5
  export function registerPoolTools(server, api) {
5
- server.registerTool("read.pool.list", {
6
+ server.registerTool("read_pool_list", {
6
7
  annotations: {
7
8
  title: "List Lending Pools",
8
9
  readOnlyHint: true,
@@ -10,10 +11,10 @@ export function registerPoolTools(server, api) {
10
11
  idempotentHint: true,
11
12
  openWorldHint: true,
12
13
  },
13
- description: "List all Arcadia lending pools: TVL, utilization, available liquidity. Key fields: interest_rate = current borrow cost, lending_apy = lender yield. All rates are decimal fractions (1.0 = 100%, 0.06 = 6%). For APY history on a specific pool, use read.pool.info.",
14
- inputSchema: {
14
+ description: "List all Arcadia lending pools: TVL, utilization, available liquidity. Key fields: interest_rate = current borrow cost, lending_apy = lender yield. All rates are decimal fractions (1.0 = 100%, 0.06 = 6%). For APY history on a specific pool, use read_pool_info.",
15
+ inputSchema: z.object({
15
16
  chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION),
16
- },
17
+ }),
17
18
  outputSchema: PoolListOutput,
18
19
  }, async ({ chain_id }) => {
19
20
  try {
@@ -28,7 +29,7 @@ export function registerPoolTools(server, api) {
28
29
  structuredContent: empty,
29
30
  };
30
31
  }
31
- const wrapped = { pools: Array.isArray(result) ? result : [] };
32
+ const wrapped = { pools: expectArray(result, "pools") };
32
33
  return {
33
34
  content: [{ type: "text", text: JSON.stringify(wrapped, null, 2) }],
34
35
  structuredContent: wrapped,
@@ -46,7 +47,7 @@ export function registerPoolTools(server, api) {
46
47
  };
47
48
  }
48
49
  });
49
- server.registerTool("read.pool.info", {
50
+ server.registerTool("read_pool_info", {
50
51
  annotations: {
51
52
  title: "Get Pool Info",
52
53
  readOnlyHint: true,
@@ -54,12 +55,12 @@ export function registerPoolTools(server, api) {
54
55
  idempotentHint: true,
55
56
  openWorldHint: true,
56
57
  },
57
- description: "Get detailed info for a single lending pool including APY history over time. Useful for analyzing rate trends and comparing pools. Use read.pool.list to discover pool addresses.",
58
- inputSchema: {
58
+ description: "Get detailed info for a single lending pool including APY history over time. Useful for analyzing rate trends and comparing pools. Use read_pool_list to discover pool addresses.",
59
+ inputSchema: z.object({
59
60
  pool_address: z.string().describe("Pool address"),
60
61
  days: z.number().default(14).describe("Number of days of APY history"),
61
62
  chain_id: z.number().default(8453).describe(CHAIN_ID_DESCRIPTION),
62
- },
63
+ }),
63
64
  outputSchema: PoolDetailOutput,
64
65
  }, async ({ pool_address, days, chain_id }) => {
65
66
  try {