@arcadia-finance/mcp-server 0.1.0 → 0.1.2

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 (43) hide show
  1. package/README.md +17 -0
  2. package/dist/abis/account.json +23 -0
  3. package/dist/abis/account_v4.json +23 -0
  4. package/dist/abis/index.js +0 -1
  5. package/dist/clients/api.js +10 -4
  6. package/dist/clients/chain.js +0 -1
  7. package/dist/config/addresses.js +0 -1
  8. package/dist/config/chains.js +0 -1
  9. package/dist/index.js +1 -2
  10. package/dist/tools/advanced/account-metadata.js +4 -31
  11. package/dist/tools/advanced/add-liquidity.js +41 -39
  12. package/dist/tools/advanced/close-position.js +34 -32
  13. package/dist/tools/advanced/format-response.js +0 -1
  14. package/dist/tools/advanced/position-actions.js +12 -10
  15. package/dist/tools/advanced/remove-liquidity.js +15 -13
  16. package/dist/tools/advanced/repay-with-collateral.js +14 -12
  17. package/dist/tools/advanced/swap.js +13 -11
  18. package/dist/tools/index.js +0 -1
  19. package/dist/tools/read/accounts.js +79 -46
  20. package/dist/tools/read/allowances.js +17 -37
  21. package/dist/tools/read/assets.js +16 -14
  22. package/dist/tools/read/balances.js +14 -34
  23. package/dist/tools/read/guides.js +7 -5
  24. package/dist/tools/read/points.js +5 -3
  25. package/dist/tools/read/pools.js +15 -19
  26. package/dist/tools/read/protocol.js +27 -22
  27. package/dist/tools/write/approve.js +23 -44
  28. package/dist/tools/write/borrow.js +14 -12
  29. package/dist/tools/write/configure-asset-manager.js +55 -65
  30. package/dist/tools/write/create-account.js +20 -18
  31. package/dist/tools/write/deposit.js +25 -32
  32. package/dist/tools/write/repay.js +15 -13
  33. package/dist/tools/write/set-asset-manager.js +15 -25
  34. package/dist/tools/write/sign-and-send.js +13 -10
  35. package/dist/tools/write/withdraw.js +25 -32
  36. package/dist/types/api.js +0 -1
  37. package/dist/utils/attribution.js +0 -1
  38. package/dist/utils/validation.js +0 -1
  39. package/package.json +7 -6
  40. /package/{dist/skills → skills}/clamm-liquidity/SKILL.md +0 -0
  41. /package/{dist/skills → skills}/clamm-liquidity/automation.md +0 -0
  42. /package/{dist/skills → skills}/clamm-liquidity/selection.md +0 -0
  43. /package/{dist/skills → skills}/clamm-liquidity/strategies.md +0 -0
@@ -1,35 +1,54 @@
1
1
  import { z } from "zod";
2
+ import { accountAbi } from "../../abis/index.js";
2
3
  import { getPublicClient } from "../../clients/chain.js";
3
4
  import { ASSET_MANAGERS } from "../../config/addresses.js";
4
- const ACCOUNT_VERSION_ABI = [
5
- {
6
- type: "function",
7
- name: "ACCOUNT_VERSION",
8
- inputs: [],
9
- outputs: [{ type: "uint256" }],
10
- stateMutability: "view",
11
- },
12
- ];
13
- const IS_ASSET_MANAGER_ABI = [
14
- {
15
- type: "function",
16
- name: "isAssetManager",
17
- inputs: [{ type: "address" }, { type: "address" }],
18
- outputs: [{ type: "bool" }],
19
- stateMutability: "view",
20
- },
21
- ];
5
+ function trimOverview(overview) {
6
+ const trimmed = { ...overview };
7
+ if (Array.isArray(trimmed.historic_actions)) {
8
+ trimmed.historic_actions_count = trimmed.historic_actions.length;
9
+ delete trimmed.historic_actions;
10
+ }
11
+ if (Array.isArray(trimmed.assets)) {
12
+ trimmed.assets = trimmed.assets.map((a) => {
13
+ const { related_strategies, asset_details: _ad, ...rest } = a;
14
+ const asset = { ...rest };
15
+ if (Array.isArray(related_strategies) && related_strategies.length > 0) {
16
+ asset.strategy_count = related_strategies.length;
17
+ }
18
+ return asset;
19
+ });
20
+ }
21
+ delete trimmed.total_value_spot;
22
+ delete trimmed.total_value_spot_usd;
23
+ delete trimmed.net_numeraire_spot;
24
+ delete trimmed.debt_numeraire_spot;
25
+ delete trimmed.debt_usd_spot;
26
+ if (trimmed.health_factor === 1) {
27
+ delete trimmed.maintenance_margin;
28
+ delete trimmed.maintenance_margin_usd;
29
+ delete trimmed.collateral_value_account;
30
+ delete trimmed.collateral_value_account_usd;
31
+ delete trimmed.liquidation_value_account;
32
+ delete trimmed.liquidation_value_account_usd;
33
+ delete trimmed.used_margin;
34
+ delete trimmed.used_margin_usd;
35
+ }
36
+ return trimmed;
37
+ }
22
38
  export function registerAccountTools(server, api, chains) {
23
- server.tool("get_account_info", "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).", {
24
- account_address: z.string().optional().describe("Arcadia account address"),
25
- wallet_address: z
26
- .string()
27
- .optional()
28
- .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."),
29
- chain_id: z
30
- .number()
31
- .default(8453)
32
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
39
+ server.registerTool("get_account_info", {
40
+ 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
+ inputSchema: {
42
+ account_address: z.string().optional().describe("Arcadia account address"),
43
+ wallet_address: z
44
+ .string()
45
+ .optional()
46
+ .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)"),
51
+ },
33
52
  }, async ({ account_address, wallet_address, chain_id }) => {
34
53
  try {
35
54
  if (wallet_address) {
@@ -44,7 +63,7 @@ export function registerAccountTools(server, api, chains) {
44
63
  client
45
64
  .readContract({
46
65
  address: account_address,
47
- abi: ACCOUNT_VERSION_ABI,
66
+ abi: accountAbi,
48
67
  functionName: "ACCOUNT_VERSION",
49
68
  })
50
69
  .then((v) => Number(v))
@@ -108,7 +127,7 @@ export function registerAccountTools(server, api, chains) {
108
127
  .multicall({
109
128
  contracts: amChecks.map((c) => ({
110
129
  address: account_address,
111
- abi: IS_ASSET_MANAGER_ABI,
130
+ abi: accountAbi,
112
131
  functionName: "isAssetManager",
113
132
  args: [owner, c.address],
114
133
  })),
@@ -142,7 +161,7 @@ export function registerAccountTools(server, api, chains) {
142
161
  }
143
162
  const result = {
144
163
  account_version: accountVersion,
145
- overview,
164
+ overview: overview ? trimOverview(overview) : null,
146
165
  liquidation_price,
147
166
  };
148
167
  if (automation)
@@ -180,13 +199,16 @@ export function registerAccountTools(server, api, chains) {
180
199
  };
181
200
  }
182
201
  });
183
- server.tool("get_account_history", "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.", {
184
- account_address: z.string().describe("Arcadia account address"),
185
- days: z.number().default(14).describe("Number of days of history (default 14)"),
186
- chain_id: z
187
- .number()
188
- .default(8453)
189
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
202
+ server.registerTool("get_account_history", {
203
+ 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
+ inputSchema: {
205
+ account_address: z.string().describe("Arcadia account address"),
206
+ 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)"),
211
+ },
190
212
  }, async ({ account_address, days, chain_id }) => {
191
213
  try {
192
214
  const result = await api.getAccountHistory(chain_id, account_address, days);
@@ -204,19 +226,31 @@ export function registerAccountTools(server, api, chains) {
204
226
  };
205
227
  }
206
228
  });
207
- server.tool("get_account_pnl", "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.", {
208
- account_address: z.string().describe("Arcadia account address"),
209
- chain_id: z
210
- .number()
211
- .default(8453)
212
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
229
+ 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.",
231
+ inputSchema: {
232
+ 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)"),
237
+ },
213
238
  }, async ({ account_address, chain_id }) => {
214
239
  try {
215
240
  const [pnlRaw, yieldRaw] = await Promise.all([
216
241
  api.getPnlCostBasis(chain_id, account_address),
217
242
  api.getYieldEarned(chain_id, account_address),
218
243
  ]);
219
- const { direct_deposits: _, ...pnl } = pnlRaw;
244
+ const { direct_deposits: _, flashaction_deposits, flashaction_withdrawals, direct_withdrawals, yield_withdrawals, ...pnl } = pnlRaw;
245
+ if (Array.isArray(flashaction_deposits) && flashaction_deposits.length > 0)
246
+ pnl.flashaction_deposit_count = flashaction_deposits.length;
247
+ if (Array.isArray(flashaction_withdrawals) && flashaction_withdrawals.length > 0)
248
+ pnl.flashaction_withdrawal_count =
249
+ flashaction_withdrawals.length;
250
+ if (Array.isArray(direct_withdrawals) && direct_withdrawals.length > 0)
251
+ pnl.direct_withdrawal_count = direct_withdrawals.length;
252
+ if (Array.isArray(yield_withdrawals) && yield_withdrawals.length > 0)
253
+ pnl.yield_withdrawal_count = yield_withdrawals.length;
220
254
  const { daily_yields: _dy, daily_yields_usd: _dyu, ...yieldData } = yieldRaw;
221
255
  return {
222
256
  content: [
@@ -240,4 +274,3 @@ export function registerAccountTools(server, api, chains) {
240
274
  }
241
275
  });
242
276
  }
243
- //# sourceMappingURL=accounts.js.map
@@ -1,41 +1,22 @@
1
1
  import { z } from "zod";
2
2
  import { formatUnits } from "viem";
3
+ import { erc20Abi } from "../../abis/index.js";
3
4
  import { getPublicClient } from "../../clients/chain.js";
4
- const ERC20_ABI = [
5
- {
6
- type: "function",
7
- name: "allowance",
8
- inputs: [{ type: "address" }, { type: "address" }],
9
- outputs: [{ type: "uint256" }],
10
- stateMutability: "view",
11
- },
12
- {
13
- type: "function",
14
- name: "decimals",
15
- inputs: [],
16
- outputs: [{ type: "uint8" }],
17
- stateMutability: "view",
18
- },
19
- {
20
- type: "function",
21
- name: "symbol",
22
- inputs: [],
23
- outputs: [{ type: "string" }],
24
- stateMutability: "view",
25
- },
26
- ];
27
5
  const MAX_UINT256 = 2n ** 256n - 1n;
28
6
  export function registerAllowanceTools(server, chains) {
29
- server.tool("get_allowance", "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.", {
30
- owner_address: z.string().describe("Token owner address (the wallet granting approval)"),
31
- spender_address: z
32
- .string()
33
- .describe("Spender address to check allowance for (e.g. Arcadia account address)"),
34
- token_addresses: z.array(z.string()).describe("ERC20 token contract addresses to check"),
35
- chain_id: z
36
- .number()
37
- .default(8453)
38
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
7
+ server.registerTool("get_allowance", {
8
+ 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
+ inputSchema: {
10
+ owner_address: z.string().describe("Token owner address (the wallet granting approval)"),
11
+ spender_address: z
12
+ .string()
13
+ .describe("Spender address to check allowance for (e.g. Arcadia account address)"),
14
+ 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)"),
19
+ },
39
20
  }, async ({ owner_address, spender_address, token_addresses, chain_id }) => {
40
21
  try {
41
22
  const client = getPublicClient(chain_id, chains);
@@ -44,12 +25,12 @@ export function registerAllowanceTools(server, chains) {
44
25
  const calls = token_addresses.flatMap((addr) => [
45
26
  {
46
27
  address: addr,
47
- abi: ERC20_ABI,
28
+ abi: erc20Abi,
48
29
  functionName: "allowance",
49
30
  args: [owner, spender],
50
31
  },
51
- { address: addr, abi: ERC20_ABI, functionName: "decimals" },
52
- { address: addr, abi: ERC20_ABI, functionName: "symbol" },
32
+ { address: addr, abi: erc20Abi, functionName: "decimals" },
33
+ { address: addr, abi: erc20Abi, functionName: "symbol" },
53
34
  ]);
54
35
  const results = (await client.multicall({ contracts: calls, allowFailure: true }));
55
36
  const tokens = token_addresses.map((addr, i) => {
@@ -83,4 +64,3 @@ export function registerAllowanceTools(server, chains) {
83
64
  }
84
65
  });
85
66
  }
86
- //# sourceMappingURL=allowances.js.map
@@ -1,18 +1,21 @@
1
1
  import { z } from "zod";
2
2
  export function registerAssetTools(server, api) {
3
- server.tool("get_assets", "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.", {
4
- asset_addresses: z
5
- .string()
6
- .optional()
7
- .describe("Single address or comma-separated addresses for price lookup"),
8
- search: z
9
- .string()
10
- .optional()
11
- .describe("Filter assets by symbol (case-insensitive substring match)"),
12
- chain_id: z
13
- .number()
14
- .default(8453)
15
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
3
+ server.registerTool("get_assets", {
4
+ 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
+ inputSchema: {
6
+ asset_addresses: z
7
+ .string()
8
+ .optional()
9
+ .describe("Single address or comma-separated addresses for price lookup"),
10
+ search: z
11
+ .string()
12
+ .optional()
13
+ .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)"),
18
+ },
16
19
  }, async ({ asset_addresses, search, chain_id }) => {
17
20
  try {
18
21
  if (asset_addresses) {
@@ -51,4 +54,3 @@ export function registerAssetTools(server, api) {
51
54
  }
52
55
  });
53
56
  }
54
- //# sourceMappingURL=assets.js.map
@@ -1,37 +1,18 @@
1
1
  import { z } from "zod";
2
2
  import { formatUnits } from "viem";
3
+ import { erc20Abi } from "../../abis/index.js";
3
4
  import { getPublicClient } from "../../clients/chain.js";
4
- const ERC20_ABI = [
5
- {
6
- type: "function",
7
- name: "balanceOf",
8
- inputs: [{ type: "address" }],
9
- outputs: [{ type: "uint256" }],
10
- stateMutability: "view",
11
- },
12
- {
13
- type: "function",
14
- name: "decimals",
15
- inputs: [],
16
- outputs: [{ type: "uint8" }],
17
- stateMutability: "view",
18
- },
19
- {
20
- type: "function",
21
- name: "symbol",
22
- inputs: [],
23
- outputs: [{ type: "string" }],
24
- stateMutability: "view",
25
- },
26
- ];
27
5
  export function registerBalanceTools(server, chains) {
28
- server.tool("get_wallet_balances", "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.", {
29
- wallet_address: z.string().describe("Wallet address to check balances for"),
30
- token_addresses: z.array(z.string()).describe("ERC20 token contract addresses to check"),
31
- chain_id: z
32
- .number()
33
- .default(8453)
34
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
6
+ server.registerTool("get_wallet_balances", {
7
+ 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
+ inputSchema: {
9
+ wallet_address: z.string().describe("Wallet address to check balances for"),
10
+ 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)"),
15
+ },
35
16
  }, async ({ wallet_address, token_addresses, chain_id }) => {
36
17
  try {
37
18
  const client = getPublicClient(chain_id, chains);
@@ -40,12 +21,12 @@ export function registerBalanceTools(server, chains) {
40
21
  const calls = token_addresses.flatMap((addr) => [
41
22
  {
42
23
  address: addr,
43
- abi: ERC20_ABI,
24
+ abi: erc20Abi,
44
25
  functionName: "balanceOf",
45
26
  args: [wallet],
46
27
  },
47
- { address: addr, abi: ERC20_ABI, functionName: "decimals" },
48
- { address: addr, abi: ERC20_ABI, functionName: "symbol" },
28
+ { address: addr, abi: erc20Abi, functionName: "decimals" },
29
+ { address: addr, abi: erc20Abi, functionName: "symbol" },
49
30
  ]);
50
31
  const [nativeBalance, ...multicallResults] = await Promise.all([
51
32
  client.getBalance({ address: wallet }),
@@ -90,4 +71,3 @@ export function registerBalanceTools(server, chains) {
90
71
  }
91
72
  });
92
73
  }
93
- //# sourceMappingURL=balances.js.map
@@ -33,10 +33,13 @@ export function registerGuideTools(server) {
33
33
  guides.set(topic, `Guide "${topic}" is not available in this installation.`);
34
34
  }
35
35
  }
36
- server.tool("get_guide", "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).", {
37
- topic: z
38
- .enum(TOPIC_KEYS)
39
- .describe("overview = addresses + tool catalog, automation = rebalancer/compounder/claimer setup, strategies = step-by-step LP templates, selection = pool evaluation + leverage sizing"),
36
+ server.registerTool("get_guide", {
37
+ 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
+ inputSchema: {
39
+ topic: z
40
+ .enum(TOPIC_KEYS)
41
+ .describe("overview = addresses + tool catalog, automation = rebalancer/compounder/claimer setup, strategies = step-by-step LP templates, selection = pool evaluation + leverage sizing"),
42
+ },
40
43
  }, async ({ topic }) => {
41
44
  try {
42
45
  return {
@@ -56,4 +59,3 @@ export function registerGuideTools(server) {
56
59
  }
57
60
  });
58
61
  }
59
- //# sourceMappingURL=guides.js.map
@@ -1,7 +1,10 @@
1
1
  import { z } from "zod";
2
2
  export function registerPointsTools(server, api) {
3
- server.tool("get_points", "Get Arcadia points balance for a wallet, or the points leaderboard if no wallet is specified.", {
4
- wallet_address: z.string().optional().describe("Wallet address for points balance"),
3
+ server.registerTool("get_points", {
4
+ description: "Get Arcadia points balance for a wallet, or the points leaderboard if no wallet is specified.",
5
+ inputSchema: {
6
+ wallet_address: z.string().optional().describe("Wallet address for points balance"),
7
+ },
5
8
  }, async ({ wallet_address }) => {
6
9
  try {
7
10
  const result = wallet_address
@@ -22,4 +25,3 @@ export function registerPointsTools(server, api) {
22
25
  }
23
26
  });
24
27
  }
25
- //# sourceMappingURL=points.js.map
@@ -1,28 +1,25 @@
1
1
  import { z } from "zod";
2
2
  export function registerPoolTools(server, api) {
3
- server.tool("get_lending_pools", "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
- pool_address: z
5
- .string()
6
- .optional()
7
- .describe("Pool address for detailed info with APY history"),
8
- days: z.number().default(14).describe("Number of days of APY history"),
9
- chain_id: z
10
- .number()
11
- .default(8453)
12
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
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.",
5
+ inputSchema: {
6
+ pool_address: z
7
+ .string()
8
+ .optional()
9
+ .describe("Pool address for detailed info with APY history"),
10
+ 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)"),
15
+ },
13
16
  }, async ({ pool_address, days, chain_id }) => {
14
17
  try {
15
18
  if (pool_address) {
16
- const [poolsData, apy_history] = await Promise.all([
17
- api.getPoolsData(chain_id),
19
+ const [pool, apy_history] = await Promise.all([
20
+ api.getPoolsData(chain_id, pool_address),
18
21
  api.getPoolApyHistory(chain_id, pool_address, days),
19
22
  ]);
20
- const pools = Array.isArray(poolsData)
21
- ? poolsData
22
- : poolsData.data;
23
- const pool = Array.isArray(pools)
24
- ? pools.find((p) => String(p.pool_address ?? p.address).toLowerCase() === pool_address.toLowerCase())
25
- : undefined;
26
23
  return {
27
24
  content: [
28
25
  { type: "text", text: JSON.stringify({ pool, apy_history }, null, 2) },
@@ -45,4 +42,3 @@ export function registerPoolTools(server, api) {
45
42
  }
46
43
  });
47
44
  }
48
- //# sourceMappingURL=pools.js.map
@@ -1,20 +1,23 @@
1
1
  import { z } from "zod";
2
2
  export function registerProtocolTools(server, api) {
3
- server.tool("get_strategies", "Get Arcadia LP strategies. Use featured_only=true for curated top strategies (recommended first call). Use strategy_id for full detail on a specific strategy — includes APY per range width (narrower range = higher APY but more rebalancing cost/risk). Without filters, returns a compact summary with 7d avg APY for the strategy's default range. Increase limit or use offset for pagination.", {
4
- strategy_id: z.number().optional().describe("Strategy ID for full detail"),
5
- featured_only: z
6
- .boolean()
7
- .default(false)
8
- .describe("Return only featured/curated strategies (recommended)"),
9
- limit: z
10
- .number()
11
- .default(25)
12
- .describe("Max strategies to return in compact list (default 25)"),
13
- offset: z.number().default(0).describe("Skip first N strategies for pagination"),
14
- chain_id: z
15
- .number()
16
- .default(8453)
17
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
3
+ server.registerTool("get_strategies", {
4
+ description: "Get Arcadia LP strategies. Use featured_only=true for curated top strategies (recommended first call). Use strategy_id for full detail on a specific strategy — includes APY per range width (narrower range = higher APY but more rebalancing cost/risk). Without filters, returns a compact summary with 7d avg APY for the strategy's default range. Increase limit or use offset for pagination.",
5
+ inputSchema: {
6
+ strategy_id: z.number().optional().describe("Strategy ID for full detail"),
7
+ featured_only: z
8
+ .boolean()
9
+ .default(false)
10
+ .describe("Return only featured/curated strategies (recommended)"),
11
+ limit: z
12
+ .number()
13
+ .default(25)
14
+ .describe("Max strategies to return in compact list (default 25)"),
15
+ offset: z.number().default(0).describe("Skip first N strategies for pagination"),
16
+ chain_id: z
17
+ .number()
18
+ .default(8453)
19
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
20
+ },
18
21
  }, async ({ strategy_id, featured_only, limit, offset, chain_id }) => {
19
22
  try {
20
23
  let result;
@@ -67,12 +70,15 @@ export function registerProtocolTools(server, api) {
67
70
  };
68
71
  }
69
72
  });
70
- server.tool("get_recommendation", "Get a rebalancing recommendation for an Arcadia account — suggests asset changes to optimize yield. Uses 1d APY (not 7d like get_strategies list view), so recommended strategies may differ from the list ranking.", {
71
- account_address: z.string().describe("Arcadia account address"),
72
- chain_id: z
73
- .number()
74
- .default(8453)
75
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
73
+ server.registerTool("get_recommendation", {
74
+ description: "Get a rebalancing recommendation for an Arcadia account — suggests asset changes to optimize yield. Uses 1d APY (not 7d like get_strategies list view), so recommended strategies may differ from the list ranking.",
75
+ inputSchema: {
76
+ account_address: z.string().describe("Arcadia account address"),
77
+ chain_id: z
78
+ .number()
79
+ .default(8453)
80
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
81
+ },
76
82
  }, async ({ account_address, chain_id }) => {
77
83
  try {
78
84
  const result = await api.getRecommendation(chain_id, account_address);
@@ -91,4 +97,3 @@ export function registerProtocolTools(server, api) {
91
97
  }
92
98
  });
93
99
  }
94
- //# sourceMappingURL=protocol.js.map
@@ -1,56 +1,36 @@
1
1
  import { z } from "zod";
2
2
  import { encodeFunctionData } from "viem";
3
+ import { erc20Abi, nftmanagerAbi } from "../../abis/index.js";
3
4
  import { appendDataSuffix } from "../../utils/attribution.js";
4
- const ERC20_APPROVE_ABI = [
5
- {
6
- type: "function",
7
- name: "approve",
8
- inputs: [
9
- { name: "spender", type: "address" },
10
- { name: "amount", type: "uint256" },
11
- ],
12
- outputs: [{ name: "", type: "bool" }],
13
- stateMutability: "nonpayable",
14
- },
15
- ];
16
- const ERC721_SET_APPROVAL_FOR_ALL_ABI = [
17
- {
18
- type: "function",
19
- name: "setApprovalForAll",
20
- inputs: [
21
- { name: "operator", type: "address" },
22
- { name: "approved", type: "bool" },
23
- ],
24
- outputs: [],
25
- stateMutability: "nonpayable",
26
- },
27
- ];
28
5
  const MAX_UINT256 = 2n ** 256n - 1n;
29
6
  export function registerApproveTool(server, _chains) {
30
- server.tool("build_approve_tx", "Build an unsigned approval transaction. For ERC20 tokens: generates approve(spender, amount). For ERC721/ERC1155 NFTs (e.g. LP positions): generates setApprovalForAll(operator, true). Required before build_deposit_tx or build_add_liquidity_tx (when depositing from wallet). Tip: call get_allowance first to check if approval already exists — skip this if the current allowance is sufficient.", {
31
- token_address: z.string().describe("Token contract address to approve"),
32
- spender_address: z
33
- .string()
34
- .describe("Address being approved — use the Arcadia account address for deposits"),
35
- asset_type: z
36
- .enum(["erc20", "erc721", "erc1155"])
37
- .default("erc20")
38
- .describe("Token type: 'erc20' (default) for fungible tokens, 'erc721' or 'erc1155' for NFTs (LP positions)"),
39
- amount: z
40
- .string()
41
- .default("max_uint256")
42
- .describe("ERC20 only: amount in raw units, or 'max_uint256' for unlimited. Ignored for NFTs."),
43
- chain_id: z
44
- .number()
45
- .default(8453)
46
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
7
+ server.registerTool("build_approve_tx", {
8
+ description: "Build an unsigned approval transaction. For ERC20 tokens: generates approve(spender, amount). For ERC721/ERC1155 NFTs (e.g. LP positions): generates setApprovalForAll(operator, true). Required before build_deposit_tx or build_add_liquidity_tx (when depositing from wallet). Tip: call get_allowance first to check if approval already exists — skip this if the current allowance is sufficient.",
9
+ inputSchema: {
10
+ token_address: z.string().describe("Token contract address to approve"),
11
+ spender_address: z
12
+ .string()
13
+ .describe("Address being approved — use the Arcadia account address for deposits"),
14
+ asset_type: z
15
+ .enum(["erc20", "erc721", "erc1155"])
16
+ .default("erc20")
17
+ .describe("Token type: 'erc20' (default) for fungible tokens, 'erc721' or 'erc1155' for NFTs (LP positions)"),
18
+ amount: z
19
+ .string()
20
+ .default("max_uint256")
21
+ .describe("ERC20 only: amount in raw units, or 'max_uint256' for unlimited. Ignored for NFTs."),
22
+ chain_id: z
23
+ .number()
24
+ .default(8453)
25
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
26
+ },
47
27
  }, async (params) => {
48
28
  try {
49
29
  let data;
50
30
  let description;
51
31
  if (params.asset_type === "erc721" || params.asset_type === "erc1155") {
52
32
  data = encodeFunctionData({
53
- abi: ERC721_SET_APPROVAL_FOR_ALL_ABI,
33
+ abi: nftmanagerAbi,
54
34
  functionName: "setApprovalForAll",
55
35
  args: [params.spender_address, true],
56
36
  });
@@ -59,7 +39,7 @@ export function registerApproveTool(server, _chains) {
59
39
  else {
60
40
  const amount = !params.amount || params.amount === "max_uint256" ? MAX_UINT256 : BigInt(params.amount);
61
41
  data = encodeFunctionData({
62
- abi: ERC20_APPROVE_ABI,
42
+ abi: erc20Abi,
63
43
  functionName: "approve",
64
44
  args: [params.spender_address, amount],
65
45
  });
@@ -96,4 +76,3 @@ export function registerApproveTool(server, _chains) {
96
76
  }
97
77
  });
98
78
  }
99
- //# sourceMappingURL=approve.js.map