@arcadia-finance/mcp-server 0.1.3 → 0.1.5

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 (38) hide show
  1. package/LICENSE.md +631 -68
  2. package/README.md +20 -2
  3. package/dist/clients/api.js +1 -1
  4. package/dist/config/addresses.js +78 -39
  5. package/dist/config/chains.js +2 -8
  6. package/dist/index.js +126 -9
  7. package/dist/prompts/index.js +4 -0
  8. package/dist/prompts/workflows.js +98 -0
  9. package/dist/resources/guides.js +38 -0
  10. package/dist/resources/index.js +4 -0
  11. package/dist/tools/advanced/add-liquidity.js +42 -19
  12. package/dist/tools/advanced/close-position.js +18 -11
  13. package/dist/tools/advanced/position-actions.js +11 -4
  14. package/dist/tools/advanced/remove-liquidity.js +11 -4
  15. package/dist/tools/advanced/repay-with-collateral.js +10 -4
  16. package/dist/tools/advanced/swap.js +12 -4
  17. package/dist/tools/read/accounts.js +41 -52
  18. package/dist/tools/read/allowances.js +13 -7
  19. package/dist/tools/read/assets.js +8 -4
  20. package/dist/tools/read/balances.js +12 -6
  21. package/dist/tools/read/guides.js +10 -18
  22. package/dist/tools/read/points.js +34 -6
  23. package/dist/tools/read/pools.js +29 -7
  24. package/dist/tools/read/protocol.js +28 -10
  25. package/dist/tools/write/approve.js +14 -7
  26. package/dist/tools/write/borrow.js +14 -11
  27. package/dist/tools/write/configure-asset-manager.js +46 -40
  28. package/dist/tools/write/create-account.js +17 -8
  29. package/dist/tools/write/deposit.js +15 -8
  30. package/dist/tools/write/repay.js +14 -7
  31. package/dist/tools/write/set-asset-manager.js +13 -6
  32. package/dist/tools/write/sign-and-send.js +8 -4
  33. package/dist/tools/write/withdraw.js +15 -8
  34. package/dist/utils/validation.js +1 -1
  35. package/package.json +4 -2
  36. package/server.json +9 -2
  37. package/skills/clamm-liquidity/automation.md +22 -24
  38. package/skills/clamm-liquidity/strategies.md +2 -0
@@ -2,8 +2,16 @@ import { z } from "zod";
2
2
  import { getPublicClient } from "../../clients/chain.js";
3
3
  import { readAccountMetadata } from "./account-metadata.js";
4
4
  import { formatAdvancedResponse } from "./format-response.js";
5
+ import { validateAddress, validateChainId } from "../../utils/validation.js";
5
6
  export function registerClosePositionTool(server, api, chains) {
6
7
  server.registerTool("build_close_position_tx", {
8
+ annotations: {
9
+ title: "Build Close Position Transaction",
10
+ readOnlyHint: false,
11
+ destructiveHint: false,
12
+ idempotentHint: true,
13
+ openWorldHint: true,
14
+ },
7
15
  description: `Atomic flash-action that closes an Arcadia account position in ONE transaction. Combines up to 3 steps atomically: [burn LP position] + [swap all tokens to a single target asset] + [repay debt]. Tokens remain in the account after closing — use build_withdraw_tx to send them to your wallet.
8
16
 
9
17
  ALWAYS try this tool first when closing/exiting a position. Only fall back to individual tools (build_remove_liquidity_tx, build_swap_tx, build_repay_with_collateral_tx, build_withdraw_tx) if this tool fails.
@@ -40,13 +48,12 @@ The returned calldata is time-sensitive — sign and broadcast within 30 seconds
40
48
  .default(false)
41
49
  .describe("true = only burn LP positions, leave underlying tokens in account. false = full close (burn + swap + repay)."),
42
50
  slippage: z.number().optional().default(100).describe("Basis points, 100 = 1%"),
43
- chain_id: z
44
- .number()
45
- .default(8453)
46
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
51
+ chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
47
52
  },
48
53
  }, async ({ account_address, assets, receive_assets, close_lp_only, slippage, chain_id }) => {
49
54
  try {
55
+ const validChainId = validateChainId(chain_id);
56
+ const validAccount = validateAddress(account_address, "account_address");
50
57
  const actionType = close_lp_only ? "account.closing-lp" : "account.closing-position";
51
58
  if (!close_lp_only && (!receive_assets || receive_assets.length === 0)) {
52
59
  return {
@@ -88,8 +95,8 @@ The returned calldata is time-sensitive — sign and broadcast within 30 seconds
88
95
  version = accountStub?.creation_version ?? 3;
89
96
  }
90
97
  else {
91
- const client = getPublicClient(chain_id, chains);
92
- const metadata = await readAccountMetadata(client, account_address);
98
+ const client = getPublicClient(validChainId, chains);
99
+ const metadata = await readAccountMetadata(client, validAccount);
93
100
  owner = metadata.owner;
94
101
  creditor = metadata.creditor;
95
102
  numeraire = metadata.numeraire;
@@ -169,12 +176,12 @@ The returned calldata is time-sensitive — sign and broadcast within 30 seconds
169
176
  };
170
177
  const result = await api.getBundleCalldata(body);
171
178
  const res = result;
172
- if (result.tenderly_sim_status === "false") {
173
- const simUrl = result.tenderly_sim_url
174
- ? `\nTenderly simulation: ${result.tenderly_sim_url}`
179
+ if (res.tenderly_sim_status === "false") {
180
+ const simUrl = res.tenderly_sim_url
181
+ ? `\nTenderly simulation: ${res.tenderly_sim_url}`
175
182
  : "";
176
- const simError = result.tenderly_sim_error
177
- ? `\nRevert reason: ${result.tenderly_sim_error}`
183
+ const simError = res.tenderly_sim_error
184
+ ? `\nRevert reason: ${res.tenderly_sim_error}`
178
185
  : "";
179
186
  return {
180
187
  content: [
@@ -1,20 +1,27 @@
1
1
  import { z } from "zod";
2
2
  import { formatAdvancedResponse } from "./format-response.js";
3
+ import { validateAddress } from "../../utils/validation.js";
3
4
  export function registerPositionActionsTool(server, api) {
4
5
  server.registerTool("build_position_action_tx", {
6
+ annotations: {
7
+ title: "Build Position Action Transaction",
8
+ readOnlyHint: false,
9
+ destructiveHint: false,
10
+ idempotentHint: true,
11
+ openWorldHint: true,
12
+ },
5
13
  description: "Flash-action: stake, unstake, or claim rewards for an LP position in one atomic transaction. The stake/unstake direction is auto-detected from asset_address: pass the non-staked position manager to stake, or the staked position manager to unstake. The returned calldata is time-sensitive — sign and broadcast within 30 seconds. If the transaction reverts due to price movement, rebuild and sign again immediately (retry at least once before giving up).",
6
14
  inputSchema: {
7
15
  account_address: z.string().describe("Arcadia account address"),
8
16
  action: z.enum(["stake", "unstake", "claim"]).describe("Action to perform"),
9
17
  asset_address: z.string().describe("Position manager contract address"),
10
18
  asset_id: z.number().describe("NFT token ID of the LP position"),
11
- chain_id: z
12
- .number()
13
- .default(8453)
14
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
19
+ chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
15
20
  },
16
21
  }, async ({ account_address, action, asset_address, asset_id, chain_id }) => {
17
22
  try {
23
+ validateAddress(account_address, "account_address");
24
+ validateAddress(asset_address, "asset_address");
18
25
  if (action === "claim") {
19
26
  const result = await api.getClaimCalldata({
20
27
  chain_id,
@@ -1,7 +1,15 @@
1
1
  import { z } from "zod";
2
2
  import { formatAdvancedResponse } from "./format-response.js";
3
+ import { validateAddress } from "../../utils/validation.js";
3
4
  export function registerRemoveLiquidityTool(server, api) {
4
5
  server.registerTool("build_remove_liquidity_tx", {
6
+ annotations: {
7
+ title: "Build Remove Liquidity Transaction",
8
+ readOnlyHint: false,
9
+ destructiveHint: false,
10
+ idempotentHint: true,
11
+ openWorldHint: true,
12
+ },
5
13
  description: `Flash-action: PARTIALLY decreases liquidity from an LP position. The position remains open with reduced liquidity; underlying tokens stay in the account.
6
14
 
7
15
  For FULL position exit (burn LP + swap + repay + withdraw), use build_close_position_tx instead — it batches everything into one atomic transaction.
@@ -14,13 +22,12 @@ The returned calldata is time-sensitive — sign and broadcast within 30 seconds
14
22
  adjustment: z
15
23
  .string()
16
24
  .describe("Liquidity amount to remove (raw uint128 value as string). Must be less than total liquidity — for full removal use build_close_position_tx."),
17
- chain_id: z
18
- .number()
19
- .default(8453)
20
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
25
+ chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
21
26
  },
22
27
  }, async ({ account_address, asset_address, asset_id, adjustment, chain_id }) => {
23
28
  try {
29
+ validateAddress(account_address, "account_address");
30
+ validateAddress(asset_address, "asset_address");
24
31
  const result = await api.getDecreaseLiquidityCalldata({
25
32
  chain_id,
26
33
  account_address,
@@ -1,7 +1,15 @@
1
1
  import { z } from "zod";
2
2
  import { formatAdvancedResponse } from "./format-response.js";
3
+ import { validateAddress } from "../../utils/validation.js";
3
4
  export function registerRepayWithCollateralTool(server, api) {
4
5
  server.registerTool("build_repay_with_collateral_tx", {
6
+ annotations: {
7
+ title: "Build Repay With Collateral Transaction",
8
+ readOnlyHint: false,
9
+ destructiveHint: false,
10
+ idempotentHint: true,
11
+ openWorldHint: true,
12
+ },
5
13
  description: "Multi-step flash-action: swaps account collateral to debt token and repays in one atomic transaction. To repay from wallet instead, use build_repay_tx. NOTE: If you are closing a position (remove LP + swap + repay + withdraw), prefer build_close_position_tx which batches everything atomically. Only use this tool for standalone repayment while keeping the position active. The returned calldata is time-sensitive — sign and broadcast within 30 seconds. If the transaction reverts due to price movement, rebuild and sign again immediately (retry at least once before giving up). Response includes tenderly_sim_url and tenderly_sim_status for pre-broadcast validation.",
6
14
  inputSchema: {
7
15
  account_address: z.string().describe("Arcadia account address"),
@@ -10,13 +18,11 @@ export function registerRepayWithCollateralTool(server, api) {
10
18
  numeraire: z.string().describe("Debt token address"),
11
19
  creditor: z.string().describe("Lending pool address"),
12
20
  slippage: z.number().optional().default(100).describe("Basis points, 100 = 1%"),
13
- chain_id: z
14
- .number()
15
- .default(8453)
16
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
21
+ chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
17
22
  },
18
23
  }, async ({ account_address, amount_in, asset_from, numeraire, creditor, slippage, chain_id }) => {
19
24
  try {
25
+ validateAddress(account_address, "account_address");
20
26
  const result = await api.getRepayCalldata({
21
27
  amount_in,
22
28
  chain_id,
@@ -1,7 +1,15 @@
1
1
  import { z } from "zod";
2
2
  import { formatAdvancedResponse } from "./format-response.js";
3
+ import { validateAddress } from "../../utils/validation.js";
3
4
  export function registerSwapTool(server, api) {
4
5
  server.registerTool("build_swap_tx", {
6
+ annotations: {
7
+ title: "Build Swap Transaction",
8
+ readOnlyHint: false,
9
+ destructiveHint: false,
10
+ idempotentHint: true,
11
+ openWorldHint: true,
12
+ },
5
13
  description: "Flash-action: swaps assets within an Arcadia account in one atomic transaction. The backend finds the optimal swap route. NOTE: If you are closing a position (swap + repay + withdraw), prefer build_close_position_tx which batches everything atomically. Only use this tool for standalone swaps within an active position. The returned calldata is time-sensitive — sign and broadcast within 30 seconds. If the transaction reverts due to price movement, rebuild and sign again immediately (retry at least once before giving up). Response includes tenderly_sim_url and tenderly_sim_status for pre-broadcast validation.",
6
14
  inputSchema: {
7
15
  account_address: z.string().describe("Arcadia account address"),
@@ -9,13 +17,13 @@ export function registerSwapTool(server, api) {
9
17
  asset_to: z.string().describe("Token address to swap to"),
10
18
  amount_in: z.string().describe("Raw units"),
11
19
  slippage: z.number().optional().default(100).describe("Basis points, 100 = 1%"),
12
- chain_id: z
13
- .number()
14
- .default(8453)
15
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
20
+ chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
16
21
  },
17
22
  }, async ({ account_address, asset_from, asset_to, amount_in, slippage, chain_id }) => {
18
23
  try {
24
+ validateAddress(account_address, "account_address");
25
+ validateAddress(asset_from, "asset_from");
26
+ validateAddress(asset_to, "asset_to");
19
27
  const result = await api.getSwapCalldata({
20
28
  amount_in,
21
29
  chain_id,
@@ -1,7 +1,8 @@
1
1
  import { z } from "zod";
2
2
  import { accountAbi } from "../../abis/index.js";
3
3
  import { getPublicClient } from "../../clients/chain.js";
4
- import { ASSET_MANAGERS } from "../../config/addresses.js";
4
+ import { getChainAmChecks } from "../../config/addresses.js";
5
+ import { validateAddress, validateChainId } from "../../utils/validation.js";
5
6
  function trimOverview(overview) {
6
7
  const trimmed = { ...overview };
7
8
  if (Array.isArray(trimmed.historic_actions)) {
@@ -37,6 +38,13 @@ function trimOverview(overview) {
37
38
  }
38
39
  export function registerAccountTools(server, api, chains) {
39
40
  server.registerTool("get_account_info", {
41
+ annotations: {
42
+ title: "Get Account Info",
43
+ readOnlyHint: true,
44
+ destructiveHint: false,
45
+ idempotentHint: true,
46
+ openWorldHint: true,
47
+ },
40
48
  description: "Get full overview of an Arcadia account: health factor, collateral value, debt, deposited assets, liquidation price, and automation status. Pass account_address for a specific account, or wallet_address to list all accounts owned by a wallet. Health factor = 1 - (used_margin / liquidation_value): 1 = no debt (safest), >0 = healthy, 0 = liquidation threshold, <0 = past liquidation. Higher is safer. On Base, also returns which asset managers are enabled (rebalancer, compounder, yield_claimer, merkl_operator, cow_swapper).",
41
49
  inputSchema: {
42
50
  account_address: z.string().optional().describe("Arcadia account address"),
@@ -44,25 +52,25 @@ export function registerAccountTools(server, api, chains) {
44
52
  .string()
45
53
  .optional()
46
54
  .describe("Wallet address to list all owned accounts (returns summary: address, name). Call again with a specific account_address for full details like health factor, collateral, and debt."),
47
- chain_id: z
48
- .number()
49
- .default(8453)
50
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
55
+ chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
51
56
  },
52
57
  }, async ({ account_address, wallet_address, chain_id }) => {
53
58
  try {
59
+ const validChainId = validateChainId(chain_id);
54
60
  if (wallet_address) {
55
- const result = await api.getAccounts(chain_id, wallet_address);
61
+ validateAddress(wallet_address, "wallet_address");
62
+ const result = await api.getAccounts(validChainId, wallet_address);
56
63
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
57
64
  }
58
65
  if (account_address) {
59
- const client = getPublicClient(chain_id, chains);
66
+ const validAccount = validateAddress(account_address, "account_address");
67
+ const client = getPublicClient(validChainId, chains);
60
68
  const [overview, liquidation_price, accountVersion] = await Promise.all([
61
- api.getAccountOverview(chain_id, account_address).catch(() => null),
62
- api.getLiquidationPrice(chain_id, account_address).catch(() => null),
69
+ api.getAccountOverview(validChainId, account_address).catch(() => null),
70
+ api.getLiquidationPrice(validChainId, account_address).catch(() => null),
63
71
  client
64
72
  .readContract({
65
- address: account_address,
73
+ address: validAccount,
66
74
  abi: accountAbi,
67
75
  functionName: "ACCOUNT_VERSION",
68
76
  })
@@ -99,34 +107,14 @@ export function registerAccountTools(server, api, chains) {
99
107
  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.`);
100
108
  }
101
109
  }
102
- // Check which asset managers are enabled (Base only — no AMs deployed on other chains yet)
103
110
  let automation = null;
104
111
  const owner = overview?.owner;
105
- if (owner && chain_id === 8453) {
106
- const am = ASSET_MANAGERS.base;
107
- const amChecks = [
108
- ...Object.entries(am.rebalancers).map(([k, v]) => ({
109
- group: "rebalancer",
110
- protocol: k,
111
- address: v,
112
- })),
113
- ...Object.entries(am.compounders).map(([k, v]) => ({
114
- group: "compounder",
115
- protocol: k,
116
- address: v,
117
- })),
118
- ...Object.entries(am.yieldClaimers).map(([k, v]) => ({
119
- group: "yield_claimer",
120
- protocol: k,
121
- address: v,
122
- })),
123
- { group: "merkl_operator", protocol: null, address: am.merklOperator },
124
- { group: "cow_swapper", protocol: null, address: am.cowSwapper },
125
- ];
112
+ if (owner) {
113
+ const amChecks = getChainAmChecks(validChainId);
126
114
  automation = await client
127
115
  .multicall({
128
116
  contracts: amChecks.map((c) => ({
129
- address: account_address,
117
+ address: validAccount,
130
118
  abi: accountAbi,
131
119
  functionName: "isAssetManager",
132
120
  args: [owner, c.address],
@@ -134,13 +122,9 @@ export function registerAccountTools(server, api, chains) {
134
122
  allowFailure: true,
135
123
  })
136
124
  .then((results) => {
137
- const out = {
138
- rebalancer: null,
139
- compounder: null,
140
- yield_claimer: null,
141
- merkl_operator: false,
142
- cow_swapper: false,
143
- };
125
+ const out = {};
126
+ for (const c of amChecks)
127
+ out[c.group] = false;
144
128
  results.forEach((r, i) => {
145
129
  if (r.status !== "success" || !r.result)
146
130
  return;
@@ -156,9 +140,6 @@ export function registerAccountTools(server, api, chains) {
156
140
  })
157
141
  .catch(() => null);
158
142
  }
159
- else if (owner && chain_id !== 8453) {
160
- notes.push("Automation status is only available on Base (chain 8453).");
161
- }
162
143
  const result = {
163
144
  account_version: accountVersion,
164
145
  overview: overview ? trimOverview(overview) : null,
@@ -200,14 +181,18 @@ export function registerAccountTools(server, api, chains) {
200
181
  }
201
182
  });
202
183
  server.registerTool("get_account_history", {
184
+ annotations: {
185
+ title: "Get Account History",
186
+ readOnlyHint: true,
187
+ destructiveHint: false,
188
+ idempotentHint: true,
189
+ openWorldHint: true,
190
+ },
203
191
  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 in USD). Useful for charting account performance over a period.",
204
192
  inputSchema: {
205
193
  account_address: z.string().describe("Arcadia account address"),
206
194
  days: z.number().default(14).describe("Number of days of history (default 14)"),
207
- chain_id: z
208
- .number()
209
- .default(8453)
210
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
195
+ chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
211
196
  },
212
197
  }, async ({ account_address, days, chain_id }) => {
213
198
  try {
@@ -227,13 +212,17 @@ export function registerAccountTools(server, api, chains) {
227
212
  }
228
213
  });
229
214
  server.registerTool("get_account_pnl", {
230
- description: "Get PnL (cost basis) and yield earned for an Arcadia account. Returns lifetime totals: cost basis vs current value, net transfers per token, total yield earned in USD and per token.",
215
+ annotations: {
216
+ title: "Get Account PnL",
217
+ readOnlyHint: true,
218
+ destructiveHint: false,
219
+ idempotentHint: true,
220
+ openWorldHint: true,
221
+ },
222
+ 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. All monetary values are in USD unless suffixed otherwise.",
231
223
  inputSchema: {
232
224
  account_address: z.string().describe("Arcadia account address"),
233
- chain_id: z
234
- .number()
235
- .default(8453)
236
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
225
+ chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
237
226
  },
238
227
  }, async ({ account_address, chain_id }) => {
239
228
  try {
@@ -2,9 +2,17 @@ import { z } from "zod";
2
2
  import { formatUnits } from "viem";
3
3
  import { erc20Abi } from "../../abis/index.js";
4
4
  import { getPublicClient } from "../../clients/chain.js";
5
+ import { validateAddress, validateChainId } from "../../utils/validation.js";
5
6
  const MAX_UINT256 = 2n ** 256n - 1n;
6
7
  export function registerAllowanceTools(server, chains) {
7
8
  server.registerTool("get_allowance", {
9
+ annotations: {
10
+ title: "Get Token Allowance",
11
+ readOnlyHint: true,
12
+ destructiveHint: false,
13
+ idempotentHint: true,
14
+ openWorldHint: true,
15
+ },
8
16
  description: "Check ERC20 token allowances for a spender address. Use before build_approve_tx to avoid redundant approvals — skip approving if the current allowance is already sufficient.",
9
17
  inputSchema: {
10
18
  owner_address: z.string().describe("Token owner address (the wallet granting approval)"),
@@ -12,16 +20,14 @@ export function registerAllowanceTools(server, chains) {
12
20
  .string()
13
21
  .describe("Spender address to check allowance for (e.g. Arcadia account address)"),
14
22
  token_addresses: z.array(z.string()).describe("ERC20 token contract addresses to check"),
15
- chain_id: z
16
- .number()
17
- .default(8453)
18
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
23
+ chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
19
24
  },
20
25
  }, async ({ owner_address, spender_address, token_addresses, chain_id }) => {
21
26
  try {
22
- const client = getPublicClient(chain_id, chains);
23
- const owner = owner_address;
24
- const spender = spender_address;
27
+ const validChainId = validateChainId(chain_id);
28
+ const owner = validateAddress(owner_address, "owner_address");
29
+ const spender = validateAddress(spender_address, "spender_address");
30
+ const client = getPublicClient(validChainId, chains);
25
31
  const calls = token_addresses.flatMap((addr) => [
26
32
  {
27
33
  address: addr,
@@ -1,6 +1,13 @@
1
1
  import { z } from "zod";
2
2
  export function registerAssetTools(server, api) {
3
3
  server.registerTool("get_assets", {
4
+ annotations: {
5
+ title: "Get Supported Assets",
6
+ readOnlyHint: true,
7
+ destructiveHint: false,
8
+ idempotentHint: true,
9
+ openWorldHint: true,
10
+ },
4
11
  description: "Get supported collateral assets on Arcadia. Returns compact list (address, symbol, decimals, type) by default. Use asset_addresses for USD price lookup. Use search to filter by symbol substring.",
5
12
  inputSchema: {
6
13
  asset_addresses: z
@@ -11,10 +18,7 @@ export function registerAssetTools(server, api) {
11
18
  .string()
12
19
  .optional()
13
20
  .describe("Filter assets by symbol (case-insensitive substring match)"),
14
- chain_id: z
15
- .number()
16
- .default(8453)
17
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
21
+ chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
18
22
  },
19
23
  }, async ({ asset_addresses, search, chain_id }) => {
20
24
  try {
@@ -2,21 +2,27 @@ import { z } from "zod";
2
2
  import { formatUnits } from "viem";
3
3
  import { erc20Abi } from "../../abis/index.js";
4
4
  import { getPublicClient } from "../../clients/chain.js";
5
+ import { validateAddress, validateChainId } from "../../utils/validation.js";
5
6
  export function registerBalanceTools(server, chains) {
6
7
  server.registerTool("get_wallet_balances", {
8
+ annotations: {
9
+ title: "Get Wallet Balances",
10
+ readOnlyHint: true,
11
+ destructiveHint: false,
12
+ idempotentHint: true,
13
+ openWorldHint: true,
14
+ },
7
15
  description: "Get native ETH and ERC20 token balances for a wallet address. Reads directly from chain via RPC multicall. Use before build_add_liquidity_tx or build_deposit_tx to verify the wallet has sufficient tokens.",
8
16
  inputSchema: {
9
17
  wallet_address: z.string().describe("Wallet address to check balances for"),
10
18
  token_addresses: z.array(z.string()).describe("ERC20 token contract addresses to check"),
11
- chain_id: z
12
- .number()
13
- .default(8453)
14
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
19
+ chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
15
20
  },
16
21
  }, async ({ wallet_address, token_addresses, chain_id }) => {
17
22
  try {
18
- const client = getPublicClient(chain_id, chains);
19
- const wallet = wallet_address;
23
+ const validChainId = validateChainId(chain_id);
24
+ const wallet = validateAddress(wallet_address, "wallet_address");
25
+ const client = getPublicClient(validChainId, chains);
20
26
  // Build multicall: for each token get balanceOf, decimals, symbol
21
27
  const calls = token_addresses.flatMap((addr) => [
22
28
  {
@@ -34,28 +34,20 @@ export function registerGuideTools(server) {
34
34
  }
35
35
  }
36
36
  server.registerTool("get_guide", {
37
+ annotations: {
38
+ title: "Get Guide",
39
+ readOnlyHint: true,
40
+ destructiveHint: false,
41
+ idempotentHint: true,
42
+ openWorldHint: true,
43
+ },
37
44
  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).",
38
45
  inputSchema: {
39
46
  topic: z
40
47
  .enum(TOPIC_KEYS)
41
48
  .describe("overview = addresses + tool catalog, automation = rebalancer/compounder/claimer setup, strategies = step-by-step LP templates, selection = pool evaluation + leverage sizing"),
42
49
  },
43
- }, async ({ topic }) => {
44
- try {
45
- return {
46
- content: [{ type: "text", text: guides.get(topic) }],
47
- };
48
- }
49
- catch (err) {
50
- return {
51
- content: [
52
- {
53
- type: "text",
54
- text: `Error: ${err instanceof Error ? err.message : String(err)}`,
55
- },
56
- ],
57
- isError: true,
58
- };
59
- }
60
- });
50
+ }, async ({ topic }) => ({
51
+ content: [{ type: "text", text: guides.get(topic) }],
52
+ }));
61
53
  }
@@ -1,16 +1,44 @@
1
1
  import { z } from "zod";
2
2
  export function registerPointsTools(server, api) {
3
3
  server.registerTool("get_points", {
4
- description: "Get Arcadia points balance for a wallet, or the points leaderboard if no wallet is specified.",
4
+ annotations: {
5
+ title: "Get Points",
6
+ readOnlyHint: true,
7
+ destructiveHint: false,
8
+ idempotentHint: true,
9
+ openWorldHint: true,
10
+ },
11
+ description: "Get Arcadia points balance for a wallet, or the points leaderboard (paginated) if no wallet is specified.",
5
12
  inputSchema: {
6
13
  wallet_address: z.string().optional().describe("Wallet address for points balance"),
14
+ limit: z
15
+ .number()
16
+ .default(25)
17
+ .describe("Max leaderboard entries to return (default 25, ignored when wallet_address is provided)"),
18
+ offset: z.number().default(0).describe("Skip first N leaderboard entries for pagination"),
7
19
  },
8
- }, async ({ wallet_address }) => {
20
+ }, async ({ wallet_address, limit, offset }) => {
9
21
  try {
10
- const result = wallet_address
11
- ? await api.getPoints(wallet_address)
12
- : await api.getPointsLeaderboard();
13
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
22
+ if (wallet_address) {
23
+ const result = await api.getPoints(wallet_address);
24
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
25
+ }
26
+ const all = await api.getPointsLeaderboard();
27
+ const list = Array.isArray(all)
28
+ ? all
29
+ : all.data;
30
+ if (Array.isArray(list)) {
31
+ const page = list.slice(offset, offset + limit);
32
+ return {
33
+ content: [
34
+ {
35
+ type: "text",
36
+ text: JSON.stringify({ total: list.length, offset, limit, leaderboard: page }, null, 2),
37
+ },
38
+ ],
39
+ };
40
+ }
41
+ return { content: [{ type: "text", text: JSON.stringify(all, null, 2) }] };
14
42
  }
15
43
  catch (err) {
16
44
  return {
@@ -1,25 +1,47 @@
1
1
  import { z } from "zod";
2
2
  export function registerPoolTools(server, api) {
3
3
  server.registerTool("get_lending_pools", {
4
- description: "Get Arcadia lending pool data: TVL, supply/borrow APY, utilization, available liquidity. Returns all pools, or a single pool with APY history if pool_address is provided.",
4
+ annotations: {
5
+ title: "Get Lending Pools",
6
+ readOnlyHint: true,
7
+ destructiveHint: false,
8
+ idempotentHint: true,
9
+ openWorldHint: true,
10
+ },
11
+ description: "Get Arcadia lending pool data: 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%). Returns all pools, or a single pool with APY history if pool_address is provided.",
5
12
  inputSchema: {
6
13
  pool_address: z
7
14
  .string()
8
15
  .optional()
9
16
  .describe("Pool address for detailed info with APY history"),
10
17
  days: z.number().default(14).describe("Number of days of APY history"),
11
- chain_id: z
12
- .number()
13
- .default(8453)
14
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
18
+ chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
15
19
  },
16
20
  }, async ({ pool_address, days, chain_id }) => {
17
21
  try {
18
22
  if (pool_address) {
19
- const [pool, apy_history] = await Promise.all([
20
- api.getPoolsData(chain_id, pool_address),
23
+ const [allPools, apy_history] = await Promise.all([
24
+ api.getPools(chain_id),
21
25
  api.getPoolApyHistory(chain_id, pool_address, days),
22
26
  ]);
27
+ const poolList = Array.isArray(allPools)
28
+ ? allPools
29
+ : allPools.data;
30
+ const pool = Array.isArray(poolList)
31
+ ? poolList.find((p) => (p.address ?? p.pool_address)?.toLowerCase() ===
32
+ pool_address.toLowerCase())
33
+ : null;
34
+ if (!pool) {
35
+ return {
36
+ content: [
37
+ {
38
+ type: "text",
39
+ text: `Error: Pool ${pool_address} not found on chain ${chain_id}.`,
40
+ },
41
+ ],
42
+ isError: true,
43
+ };
44
+ }
23
45
  return {
24
46
  content: [
25
47
  { type: "text", text: JSON.stringify({ pool, apy_history }, null, 2) },