@arcadia-finance/mcp-server 0.1.0 → 0.1.1

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 (42) hide show
  1. package/dist/abis/account.json +23 -0
  2. package/dist/abis/account_v4.json +23 -0
  3. package/dist/abis/index.js +0 -1
  4. package/dist/clients/api.js +10 -4
  5. package/dist/clients/chain.js +0 -1
  6. package/dist/config/addresses.js +0 -1
  7. package/dist/config/chains.js +0 -1
  8. package/dist/index.js +0 -1
  9. package/dist/tools/advanced/account-metadata.js +4 -31
  10. package/dist/tools/advanced/add-liquidity.js +41 -39
  11. package/dist/tools/advanced/close-position.js +34 -32
  12. package/dist/tools/advanced/format-response.js +0 -1
  13. package/dist/tools/advanced/position-actions.js +12 -10
  14. package/dist/tools/advanced/remove-liquidity.js +15 -13
  15. package/dist/tools/advanced/repay-with-collateral.js +14 -12
  16. package/dist/tools/advanced/swap.js +13 -11
  17. package/dist/tools/index.js +0 -1
  18. package/dist/tools/read/accounts.js +35 -44
  19. package/dist/tools/read/allowances.js +17 -37
  20. package/dist/tools/read/assets.js +16 -14
  21. package/dist/tools/read/balances.js +14 -34
  22. package/dist/tools/read/guides.js +7 -5
  23. package/dist/tools/read/points.js +5 -3
  24. package/dist/tools/read/pools.js +15 -19
  25. package/dist/tools/read/protocol.js +27 -22
  26. package/dist/tools/write/approve.js +23 -44
  27. package/dist/tools/write/borrow.js +14 -12
  28. package/dist/tools/write/configure-asset-manager.js +55 -65
  29. package/dist/tools/write/create-account.js +20 -18
  30. package/dist/tools/write/deposit.js +25 -32
  31. package/dist/tools/write/repay.js +15 -13
  32. package/dist/tools/write/set-asset-manager.js +15 -25
  33. package/dist/tools/write/sign-and-send.js +13 -10
  34. package/dist/tools/write/withdraw.js +25 -32
  35. package/dist/types/api.js +0 -1
  36. package/dist/utils/attribution.js +0 -1
  37. package/dist/utils/validation.js +0 -1
  38. package/package.json +4 -2
  39. /package/{dist/skills → skills}/clamm-liquidity/SKILL.md +0 -0
  40. /package/{dist/skills → skills}/clamm-liquidity/automation.md +0 -0
  41. /package/{dist/skills → skills}/clamm-liquidity/selection.md +0 -0
  42. /package/{dist/skills → skills}/clamm-liquidity/strategies.md +0 -0
@@ -1,35 +1,21 @@
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
- ];
22
5
  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)"),
6
+ server.registerTool("get_account_info", {
7
+ 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).",
8
+ inputSchema: {
9
+ account_address: z.string().optional().describe("Arcadia account address"),
10
+ wallet_address: z
11
+ .string()
12
+ .optional()
13
+ .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."),
14
+ chain_id: z
15
+ .number()
16
+ .default(8453)
17
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
18
+ },
33
19
  }, async ({ account_address, wallet_address, chain_id }) => {
34
20
  try {
35
21
  if (wallet_address) {
@@ -44,7 +30,7 @@ export function registerAccountTools(server, api, chains) {
44
30
  client
45
31
  .readContract({
46
32
  address: account_address,
47
- abi: ACCOUNT_VERSION_ABI,
33
+ abi: accountAbi,
48
34
  functionName: "ACCOUNT_VERSION",
49
35
  })
50
36
  .then((v) => Number(v))
@@ -108,7 +94,7 @@ export function registerAccountTools(server, api, chains) {
108
94
  .multicall({
109
95
  contracts: amChecks.map((c) => ({
110
96
  address: account_address,
111
- abi: IS_ASSET_MANAGER_ABI,
97
+ abi: accountAbi,
112
98
  functionName: "isAssetManager",
113
99
  args: [owner, c.address],
114
100
  })),
@@ -180,13 +166,16 @@ export function registerAccountTools(server, api, chains) {
180
166
  };
181
167
  }
182
168
  });
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)"),
169
+ server.registerTool("get_account_history", {
170
+ 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.",
171
+ inputSchema: {
172
+ account_address: z.string().describe("Arcadia account address"),
173
+ days: z.number().default(14).describe("Number of days of history (default 14)"),
174
+ chain_id: z
175
+ .number()
176
+ .default(8453)
177
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
178
+ },
190
179
  }, async ({ account_address, days, chain_id }) => {
191
180
  try {
192
181
  const result = await api.getAccountHistory(chain_id, account_address, days);
@@ -204,12 +193,15 @@ export function registerAccountTools(server, api, chains) {
204
193
  };
205
194
  }
206
195
  });
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)"),
196
+ server.registerTool("get_account_pnl", {
197
+ 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.",
198
+ inputSchema: {
199
+ account_address: z.string().describe("Arcadia account address"),
200
+ chain_id: z
201
+ .number()
202
+ .default(8453)
203
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
204
+ },
213
205
  }, async ({ account_address, chain_id }) => {
214
206
  try {
215
207
  const [pnlRaw, yieldRaw] = await Promise.all([
@@ -240,4 +232,3 @@ export function registerAccountTools(server, api, chains) {
240
232
  }
241
233
  });
242
234
  }
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
@@ -3,17 +3,20 @@ import { encodeFunctionData } from "viem";
3
3
  import { poolAbi } from "../../abis/index.js";
4
4
  import { appendDataSuffix } from "../../utils/attribution.js";
5
5
  export function registerBorrowTool(server, _chains, api) {
6
- server.tool("build_borrow_tx", "Build an unsigned transaction to borrow from an Arcadia lending pool against account collateral. Only works with margin accounts (created with a creditor/lending pool). Spot accounts (no creditor) cannot borrow — the tool will validate this and reject. Before borrowing, verify the account has positive free margin via get_account_info: collateral_value must exceed used_margin.", {
7
- pool_address: z
8
- .string()
9
- .describe("Lending pool: LP_WETH=0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2, LP_USDC=0x3ec4a293Fb906DD2Cd440c20dECB250DeF141dF1, LP_CBBTC=0xa37E9b4369dc20940009030BfbC2088F09645e3B"),
10
- account_address: z.string().describe("Arcadia account address used as collateral"),
11
- amount: z.string().describe("Amount in raw units"),
12
- to: z.string().describe("Address to receive borrowed tokens"),
13
- chain_id: z
14
- .number()
15
- .default(8453)
16
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
6
+ server.registerTool("build_borrow_tx", {
7
+ description: "Build an unsigned transaction to borrow from an Arcadia lending pool against account collateral. Only works with margin accounts (created with a creditor/lending pool). Spot accounts (no creditor) cannot borrow — the tool will validate this and reject. Before borrowing, verify the account has positive free margin via get_account_info: collateral_value must exceed used_margin.",
8
+ inputSchema: {
9
+ pool_address: z
10
+ .string()
11
+ .describe("Lending pool: LP_WETH=0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2, LP_USDC=0x3ec4a293Fb906DD2Cd440c20dECB250DeF141dF1, LP_CBBTC=0xa37E9b4369dc20940009030BfbC2088F09645e3B"),
12
+ account_address: z.string().describe("Arcadia account address used as collateral"),
13
+ amount: z.string().describe("Amount in raw units"),
14
+ to: z.string().describe("Address to receive borrowed tokens"),
15
+ chain_id: z
16
+ .number()
17
+ .default(8453)
18
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
19
+ },
17
20
  }, async (params) => {
18
21
  try {
19
22
  // Validate: account must have a creditor (margin account)
@@ -84,4 +87,3 @@ export function registerBorrowTool(server, _chains, api) {
84
87
  }
85
88
  });
86
89
  }
87
- //# sourceMappingURL=borrow.js.map