@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,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { encodeAbiParameters, encodeFunctionData } from "viem";
3
3
  import { ASSET_MANAGERS, MINIMAL_STRATEGY_HOOK } from "../../config/addresses.js";
4
+ import { accountAbi } from "../../abis/index.js";
4
5
  import { appendDataSuffix } from "../../utils/attribution.js";
5
6
  // Arcadia's bot initiator addresses per asset manager type
6
7
  const REBALANCER_INITIATOR = "0x163CcA8F161CBBB401a96aDf4Cbf4D74f3faD1Ed";
@@ -12,19 +13,6 @@ const DEFAULT_MAX_CLAIM_FEE = BigInt("100000000000000000"); // 10% (0.1 * 1e18)
12
13
  const DEFAULT_MAX_SWAP_FEE = BigInt("500000000000000"); // 0.05% (0.0005 * 1e18)
13
14
  const DEFAULT_MAX_TOLERANCE = BigInt("5000000000000000"); // 0.5% (0.005 * 1e18)
14
15
  const DEFAULT_MIN_LIQUIDITY_RATIO = BigInt("990000000000000000"); // 99% (0.99 * 1e18)
15
- const SET_ASSET_MANAGERS_ABI = [
16
- {
17
- type: "function",
18
- name: "setAssetManagers",
19
- inputs: [
20
- { name: "assetManagers", type: "address[]" },
21
- { name: "statuses", type: "bool[]" },
22
- { name: "datas", type: "bytes[]" },
23
- ],
24
- outputs: [],
25
- stateMutability: "nonpayable",
26
- },
27
- ];
28
16
  function encodeRebalancerMetadata(triggerLowerRatio, triggerUpperRatio, compoundLeftovers, minRebalanceTime) {
29
17
  const strategyParams = encodeAbiParameters([
30
18
  { name: "compound_leftovers", type: "string" },
@@ -125,56 +113,59 @@ function resolveAmAddress(amType, protocol) {
125
113
  }
126
114
  }
127
115
  export function registerConfigureAssetManagerTool(server, _chains) {
128
- server.tool("build_configure_asset_manager_tx", "Build an unsigned transaction to enable AND configure an asset manager on an Arcadia V3/V4 account. Unlike build_set_asset_manager_tx (which only grants permission), this also sets the initiator, fee limits, and strategy parameters in one transaction via setAssetManagers. Supports rebalancer (with trigger ratios and compound mode), compounder, yield claimer (with fee recipient), and merkl operator (with reward recipient). Pass pool_protocol to auto-resolve the correct AM address, or pass asset_manager_address directly. For addresses, call get_guide('automation'). Returns { transaction: { to, data, value, chainId } }.", {
129
- account_address: z.string().describe("Arcadia account address (must be V3 or V4)"),
130
- asset_manager_address: z
131
- .string()
132
- .optional()
133
- .describe("Asset manager contract address. Optional if pool_protocol is provided."),
134
- pool_protocol: z
135
- .enum(["slipstream", "slipstream_v2", "uniV3", "uniV4"])
136
- .optional()
137
- .describe("LP protocol — auto-resolves the correct AM address. Use instead of asset_manager_address."),
138
- am_type: z
139
- .enum(["rebalancer", "compounder", "yield_claimer", "merkl_operator"])
140
- .describe("Type of asset manager"),
141
- // Rebalancer-specific
142
- trigger_lower_ratio: z
143
- .number()
144
- .int()
145
- .default(0)
146
- .describe("Rebalancer: how far below the current lower tick to trigger rebalance, as int32 * 1e6 (default 0 = trigger exactly at boundary). Positive values trigger before going out of range."),
147
- trigger_upper_ratio: z
148
- .number()
149
- .int()
150
- .default(0)
151
- .describe("Rebalancer: how far above the current upper tick to trigger rebalance, as int32 * 1e6 (default 0 = trigger exactly at boundary). Positive values trigger before going out of range."),
152
- compound_leftovers: z
153
- .enum(["all", "none", "token0", "token1"])
154
- .default("all")
155
- .describe('Rebalancer: what to do with leftover tokens after rebalance (default "all" = compound both)'),
156
- min_rebalance_time: z
157
- .number()
158
- .int()
159
- .default(3600)
160
- .describe("Rebalancer: minimum seconds between rebalances (default 3600 = 1 hour)"),
161
- strategy_hook: z
162
- .string()
163
- .optional()
164
- .describe("Rebalancer: strategy hook address. Defaults to minimal hook (0x13beD1A58d87c0454872656c5328103aAe5eB86A). Only override for POL or custom hooks."),
165
- // Yield Claimer / Merkl Operator
166
- fee_recipient: z
167
- .string()
168
- .optional()
169
- .describe("yield_claimer: address to receive claimed fees (required for yield_claimer)"),
170
- reward_recipient: z
171
- .string()
172
- .optional()
173
- .describe("merkl_operator: address to receive Merkl rewards (required for merkl_operator)"),
174
- chain_id: z
175
- .number()
176
- .default(8453)
177
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
116
+ server.registerTool("build_configure_asset_manager_tx", {
117
+ description: "Build an unsigned transaction to enable AND configure an asset manager on an Arcadia V3/V4 account. Unlike build_set_asset_manager_tx (which only grants permission), this also sets the initiator, fee limits, and strategy parameters in one transaction via setAssetManagers. Supports rebalancer (with trigger ratios and compound mode), compounder, yield claimer (with fee recipient), and merkl operator (with reward recipient). Pass pool_protocol to auto-resolve the correct AM address, or pass asset_manager_address directly. For addresses, call get_guide('automation'). Returns { transaction: { to, data, value, chainId } }.",
118
+ inputSchema: {
119
+ account_address: z.string().describe("Arcadia account address (must be V3 or V4)"),
120
+ asset_manager_address: z
121
+ .string()
122
+ .optional()
123
+ .describe("Asset manager contract address. Optional if pool_protocol is provided."),
124
+ pool_protocol: z
125
+ .enum(["slipstream", "slipstream_v2", "uniV3", "uniV4"])
126
+ .optional()
127
+ .describe("LP protocol — auto-resolves the correct AM address. Use instead of asset_manager_address."),
128
+ am_type: z
129
+ .enum(["rebalancer", "compounder", "yield_claimer", "merkl_operator"])
130
+ .describe("Type of asset manager"),
131
+ // Rebalancer-specific
132
+ trigger_lower_ratio: z
133
+ .number()
134
+ .int()
135
+ .default(0)
136
+ .describe("Rebalancer: how far below the current lower tick to trigger rebalance, as int32 * 1e6 (default 0 = trigger exactly at boundary). Positive values trigger before going out of range."),
137
+ trigger_upper_ratio: z
138
+ .number()
139
+ .int()
140
+ .default(0)
141
+ .describe("Rebalancer: how far above the current upper tick to trigger rebalance, as int32 * 1e6 (default 0 = trigger exactly at boundary). Positive values trigger before going out of range."),
142
+ compound_leftovers: z
143
+ .enum(["all", "none", "token0", "token1"])
144
+ .default("all")
145
+ .describe('Rebalancer: what to do with leftover tokens after rebalance (default "all" = compound both)'),
146
+ min_rebalance_time: z
147
+ .number()
148
+ .int()
149
+ .default(3600)
150
+ .describe("Rebalancer: minimum seconds between rebalances (default 3600 = 1 hour)"),
151
+ strategy_hook: z
152
+ .string()
153
+ .optional()
154
+ .describe("Rebalancer: strategy hook address. Defaults to minimal hook (0x13beD1A58d87c0454872656c5328103aAe5eB86A). Only override for POL or custom hooks."),
155
+ // Yield Claimer / Merkl Operator
156
+ fee_recipient: z
157
+ .string()
158
+ .optional()
159
+ .describe("yield_claimer: address to receive claimed fees (required for yield_claimer)"),
160
+ reward_recipient: z
161
+ .string()
162
+ .optional()
163
+ .describe("merkl_operator: address to receive Merkl rewards (required for merkl_operator)"),
164
+ chain_id: z
165
+ .number()
166
+ .default(8453)
167
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
168
+ },
178
169
  }, async (params) => {
179
170
  try {
180
171
  // Resolve asset manager address from pool_protocol or direct address
@@ -221,7 +212,7 @@ export function registerConfigureAssetManagerTool(server, _chains) {
221
212
  }
222
213
  }
223
214
  const data = appendDataSuffix(encodeFunctionData({
224
- abi: SET_ASSET_MANAGERS_ABI,
215
+ abi: accountAbi,
225
216
  functionName: "setAssetManagers",
226
217
  args: [[amAddress], [true], [callbackData]],
227
218
  }));
@@ -255,4 +246,3 @@ export function registerConfigureAssetManagerTool(server, _chains) {
255
246
  }
256
247
  });
257
248
  }
258
- //# sourceMappingURL=configure-asset-manager.js.map
@@ -24,23 +24,26 @@ export function computeAccountAddress(factoryAddress, userSalt, walletAddress, i
24
24
  return getAddress(slice(raw, 12));
25
25
  }
26
26
  export function registerCreateAccountTool(server, chains) {
27
- server.tool("build_create_account_tx", "Build an unsigned transaction to create a new Arcadia account via the Factory contract. account_version: 3 with creditor → V3 margin account (can borrow/leverage). account_version: 0 or 4 → V4 spot account (no borrowing, creditor is ignored, any ERC20 allowed). Returns the predicted account address (deterministic via CREATE2).", {
28
- salt: z.number().describe("Unique salt (uint32) for deterministic account address"),
29
- wallet_address: z
30
- .string()
31
- .describe("Wallet address that will send the transaction (tx.origin, needed for address prediction)"),
32
- account_version: z
33
- .number()
34
- .default(0)
35
- .describe("Account version: 0 = latest (V4 spot), 3 = margin (can borrow). 1/2 = legacy."),
36
- creditor: z
37
- .string()
38
- .optional()
39
- .describe("Lending pool address for V3 margin account. Ignored for V4 spot accounts (version 0 or 4)."),
40
- chain_id: z
41
- .number()
42
- .default(8453)
43
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
27
+ server.registerTool("build_create_account_tx", {
28
+ description: "Build an unsigned transaction to create a new Arcadia account via the Factory contract. account_version: 3 with creditor → V3 margin account (can borrow/leverage). account_version: 0 or 4 → V4 spot account (no borrowing, creditor is ignored, any ERC20 allowed). Returns the predicted account address (deterministic via CREATE2).",
29
+ inputSchema: {
30
+ salt: z.number().describe("Unique salt (uint32) for deterministic account address"),
31
+ wallet_address: z
32
+ .string()
33
+ .describe("Wallet address that will send the transaction (tx.origin, needed for address prediction)"),
34
+ account_version: z
35
+ .number()
36
+ .default(0)
37
+ .describe("Account version: 0 = latest (V4 spot), 3 = margin (can borrow). 1/2 = legacy."),
38
+ creditor: z
39
+ .string()
40
+ .optional()
41
+ .describe("Lending pool address for V3 margin account. Ignored for V4 spot accounts (version 0 or 4)."),
42
+ chain_id: z
43
+ .number()
44
+ .default(8453)
45
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
46
+ },
44
47
  }, async (params) => {
45
48
  try {
46
49
  const data = appendDataSuffix(encodeFunctionData({
@@ -109,4 +112,3 @@ export function registerCreateAccountTool(server, chains) {
109
112
  }
110
113
  });
111
114
  }
112
- //# sourceMappingURL=create-account.js.map
@@ -1,38 +1,32 @@
1
1
  import { z } from "zod";
2
2
  import { encodeFunctionData } from "viem";
3
- import { getAccountAbi } from "../../abis/index.js";
3
+ import { accountAbi, getAccountAbi } from "../../abis/index.js";
4
4
  import { getPublicClient } from "../../clients/chain.js";
5
5
  import { appendDataSuffix } from "../../utils/attribution.js";
6
- const ACCOUNT_VERSION_ABI = [
7
- {
8
- type: "function",
9
- name: "ACCOUNT_VERSION",
10
- inputs: [],
11
- outputs: [{ type: "uint256" }],
12
- stateMutability: "view",
13
- },
14
- ];
15
6
  export function registerDepositTool(server, chains) {
16
- server.tool("build_deposit_tx", "Build an unsigned transaction to deposit assets into an Arcadia account as collateral. Supports ERC20 tokens and ERC721 NFTs (LP positions). NOT needed before build_add_liquidity_tx — that tool deposits from wallet atomically. Ensure the account is approved first (call get_allowance to check, then build_approve_tx if needed). Account version is auto-detected on-chain (override with account_version if needed).", {
17
- account_address: z.string().describe("Arcadia account address"),
18
- asset_addresses: z.array(z.string()).describe("Token contract addresses to deposit"),
19
- asset_amounts: z.array(z.string()).describe("Amounts in raw units/wei, one per asset"),
20
- asset_ids: z
21
- .array(z.number())
22
- .optional()
23
- .describe("Token IDs: 0 for ERC20, NFT token ID for ERC721"),
24
- asset_types: z
25
- .array(z.number())
26
- .optional()
27
- .describe("V4 only. Asset types per asset: 1=ERC20, 2=ERC721, 3=ERC1155. If omitted, inferred from asset_ids (non-zero → ERC721)."),
28
- account_version: z
29
- .number()
30
- .optional()
31
- .describe("Override account version (3 or 4). Auto-detected on-chain if omitted."),
32
- chain_id: z
33
- .number()
34
- .default(8453)
35
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
7
+ server.registerTool("build_deposit_tx", {
8
+ description: "Build an unsigned transaction to deposit assets into an Arcadia account as collateral. Supports ERC20 tokens and ERC721 NFTs (LP positions). NOT needed before build_add_liquidity_tx — that tool deposits from wallet atomically. Ensure the account is approved first (call get_allowance to check, then build_approve_tx if needed). Account version is auto-detected on-chain (override with account_version if needed).",
9
+ inputSchema: {
10
+ account_address: z.string().describe("Arcadia account address"),
11
+ asset_addresses: z.array(z.string()).describe("Token contract addresses to deposit"),
12
+ asset_amounts: z.array(z.string()).describe("Amounts in raw units/wei, one per asset"),
13
+ asset_ids: z
14
+ .array(z.number())
15
+ .optional()
16
+ .describe("Token IDs: 0 for ERC20, NFT token ID for ERC721"),
17
+ asset_types: z
18
+ .array(z.number())
19
+ .optional()
20
+ .describe("V4 only. Asset types per asset: 1=ERC20, 2=ERC721, 3=ERC1155. If omitted, inferred from asset_ids (non-zero → ERC721)."),
21
+ account_version: z
22
+ .number()
23
+ .optional()
24
+ .describe("Override account version (3 or 4). Auto-detected on-chain if omitted."),
25
+ chain_id: z
26
+ .number()
27
+ .default(8453)
28
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
29
+ },
36
30
  }, async (params) => {
37
31
  try {
38
32
  if (params.asset_addresses.length !== params.asset_amounts.length) {
@@ -52,7 +46,7 @@ export function registerDepositTool(server, chains) {
52
46
  const client = getPublicClient(params.chain_id, chains);
53
47
  version = Number(await client.readContract({
54
48
  address: params.account_address,
55
- abi: ACCOUNT_VERSION_ABI,
49
+ abi: accountAbi,
56
50
  functionName: "ACCOUNT_VERSION",
57
51
  }));
58
52
  }
@@ -101,4 +95,3 @@ export function registerDepositTool(server, chains) {
101
95
  }
102
96
  });
103
97
  }
104
- //# sourceMappingURL=deposit.js.map
@@ -3,18 +3,21 @@ import { encodeFunctionData } from "viem";
3
3
  import { poolAbi } from "../../abis/index.js";
4
4
  import { appendDataSuffix } from "../../utils/attribution.js";
5
5
  export function registerRepayTool(server, _chains) {
6
- server.tool("build_repay_tx", "Build an unsigned transaction to repay debt to an Arcadia lending pool from your wallet. Check allowance first (get_allowance), then approve the pool if needed (build_approve_tx). To repay using account collateral instead, use build_repay_with_collateral_tx.", {
7
- pool_address: z
8
- .string()
9
- .describe("Lending pool address. Base: LP_WETH=0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2, LP_USDC=0x3ec4a293Fb906DD2Cd440c20dECB250DeF141dF1, LP_CBBTC=0xa37E9b4369dc20940009030BfbC2088F09645e3B"),
10
- account_address: z.string().describe("Arcadia account address with debt"),
11
- amount: z
12
- .string()
13
- .describe("Amount in raw units, or 'max_uint256' to repay all debt in full"),
14
- chain_id: z
15
- .number()
16
- .default(8453)
17
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
6
+ server.registerTool("build_repay_tx", {
7
+ description: "Build an unsigned transaction to repay debt to an Arcadia lending pool from your wallet. Check allowance first (get_allowance), then approve the pool if needed (build_approve_tx). To repay using account collateral instead, use build_repay_with_collateral_tx.",
8
+ inputSchema: {
9
+ pool_address: z
10
+ .string()
11
+ .describe("Lending pool address. Base: LP_WETH=0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2, LP_USDC=0x3ec4a293Fb906DD2Cd440c20dECB250DeF141dF1, LP_CBBTC=0xa37E9b4369dc20940009030BfbC2088F09645e3B"),
12
+ account_address: z.string().describe("Arcadia account address with debt"),
13
+ amount: z
14
+ .string()
15
+ .describe("Amount in raw units, or 'max_uint256' to repay all debt in full"),
16
+ chain_id: z
17
+ .number()
18
+ .default(8453)
19
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
20
+ },
18
21
  }, async (params) => {
19
22
  try {
20
23
  const amount = params.amount === "max_uint256" ? 2n ** 256n - 1n : BigInt(params.amount);
@@ -53,4 +56,3 @@ export function registerRepayTool(server, _chains) {
53
56
  }
54
57
  });
55
58
  }
56
- //# sourceMappingURL=repay.js.map
@@ -1,34 +1,25 @@
1
1
  import { z } from "zod";
2
2
  import { encodeFunctionData } from "viem";
3
+ import { accountAbi } from "../../abis/index.js";
3
4
  import { appendDataSuffix } from "../../utils/attribution.js";
4
- const SET_ASSET_MANAGERS_ABI = [
5
- {
6
- type: "function",
7
- name: "setAssetManagers",
8
- inputs: [
9
- { name: "assetManagers", type: "address[]" },
10
- { name: "statuses", type: "bool[]" },
11
- { name: "datas", type: "bytes[]" },
12
- ],
13
- outputs: [],
14
- stateMutability: "nonpayable",
15
- },
16
- ];
17
5
  export function registerSetAssetManagerTool(server, _chains) {
18
- server.tool("build_set_asset_manager_tx", "Build an unsigned transaction to grant or revoke an asset manager's permission on an Arcadia V3/V4 account via setAssetManagers. This ONLY toggles the permission flag — it does NOT configure initiator, fees, or strategy parameters. For full setup (enable + configure in one tx), use build_configure_asset_manager_tx instead. For asset manager addresses, call get_guide('automation'). Returns { transaction: { to, data, value, chainId } }.", {
19
- account_address: z.string().describe("Arcadia account address (V3 or V4)"),
20
- asset_manager_address: z
21
- .string()
22
- .describe("Asset manager contract address to grant or revoke"),
23
- enabled: z.boolean().describe("True to grant permission, false to revoke"),
24
- chain_id: z
25
- .number()
26
- .default(8453)
27
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
6
+ server.registerTool("build_set_asset_manager_tx", {
7
+ description: "Build an unsigned transaction to grant or revoke an asset manager's permission on an Arcadia V3/V4 account via setAssetManagers. This ONLY toggles the permission flag — it does NOT configure initiator, fees, or strategy parameters. For full setup (enable + configure in one tx), use build_configure_asset_manager_tx instead. For asset manager addresses, call get_guide('automation'). Returns { transaction: { to, data, value, chainId } }.",
8
+ inputSchema: {
9
+ account_address: z.string().describe("Arcadia account address (V3 or V4)"),
10
+ asset_manager_address: z
11
+ .string()
12
+ .describe("Asset manager contract address to grant or revoke"),
13
+ enabled: z.boolean().describe("True to grant permission, false to revoke"),
14
+ chain_id: z
15
+ .number()
16
+ .default(8453)
17
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
18
+ },
28
19
  }, async (params) => {
29
20
  try {
30
21
  const data = appendDataSuffix(encodeFunctionData({
31
- abi: SET_ASSET_MANAGERS_ABI,
22
+ abi: accountAbi,
32
23
  functionName: "setAssetManagers",
33
24
  args: [[params.asset_manager_address], [params.enabled], ["0x"]],
34
25
  }));
@@ -62,4 +53,3 @@ export function registerSetAssetManagerTool(server, _chains) {
62
53
  }
63
54
  });
64
55
  }
65
- //# sourceMappingURL=set-asset-manager.js.map
@@ -1,20 +1,24 @@
1
1
  import { z } from "zod";
2
2
  import { createWalletClient, createPublicClient, http } from "viem";
3
3
  import { privateKeyToAccount } from "viem/accounts";
4
- import { base, optimism } from "viem/chains";
4
+ import { base, optimism, unichain } from "viem/chains";
5
5
  const VIEM_CHAINS = {
6
6
  8453: base,
7
7
  10: optimism,
8
+ 130: unichain,
8
9
  };
9
10
  export function registerSignAndSendTool(server, chains) {
10
- server.tool("sign_and_send_tx", "DEV ONLY — Sign and broadcast an unsigned transaction using a local private key (PK env var). For production, use a dedicated wallet MCP server (Fireblocks, Safe, Turnkey, etc.) instead of this tool. Takes the transaction object returned by any build_*_tx tool and submits it onchain.", {
11
- to: z.string().describe("Target contract address"),
12
- data: z.string().describe("Encoded calldata (hex)"),
13
- value: z.string().default("0").describe("Value in wei (default '0')"),
14
- chain_id: z
15
- .number()
16
- .default(8453)
17
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
11
+ server.registerTool("sign_and_send_tx", {
12
+ description: "DEV ONLY — Sign and broadcast an unsigned transaction using a local private key (PK env var). For production, use a dedicated wallet MCP server (Fireblocks, Safe, Turnkey, etc.) instead of this tool. Takes the transaction object returned by any build_*_tx tool and submits it onchain.",
13
+ inputSchema: {
14
+ to: z.string().describe("Target contract address"),
15
+ data: z.string().describe("Encoded calldata (hex)"),
16
+ value: z.string().default("0").describe("Value in wei (default '0')"),
17
+ chain_id: z
18
+ .number()
19
+ .default(8453)
20
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
21
+ },
18
22
  }, async (params) => {
19
23
  try {
20
24
  const pk = process.env.PK;
@@ -87,4 +91,3 @@ export function registerSignAndSendTool(server, chains) {
87
91
  }
88
92
  });
89
93
  }
90
- //# sourceMappingURL=sign-and-send.js.map
@@ -1,38 +1,32 @@
1
1
  import { z } from "zod";
2
2
  import { encodeFunctionData } from "viem";
3
- import { getAccountAbi } from "../../abis/index.js";
3
+ import { accountAbi, getAccountAbi } from "../../abis/index.js";
4
4
  import { getPublicClient } from "../../clients/chain.js";
5
5
  import { appendDataSuffix } from "../../utils/attribution.js";
6
- const ACCOUNT_VERSION_ABI = [
7
- {
8
- type: "function",
9
- name: "ACCOUNT_VERSION",
10
- inputs: [],
11
- outputs: [{ type: "uint256" }],
12
- stateMutability: "view",
13
- },
14
- ];
15
6
  export function registerWithdrawTool(server, chains) {
16
- server.tool("build_withdraw_tx", "Build an unsigned transaction to withdraw assets from an Arcadia account to the owner's wallet. Only the account owner can withdraw. Will revert if the account has debt and withdrawal would make it undercollateralized. Does not support max_uint256 — pass exact amounts from get_account_info. Account version is auto-detected on-chain (override with account_version if needed).", {
17
- account_address: z.string().describe("Arcadia account address"),
18
- asset_addresses: z.array(z.string()).describe("Token contract addresses to withdraw"),
19
- asset_amounts: z.array(z.string()).describe("Amounts in raw units/wei, one per asset"),
20
- asset_ids: z
21
- .array(z.number())
22
- .optional()
23
- .describe("Token IDs: 0 for ERC20, NFT token ID for ERC721"),
24
- asset_types: z
25
- .array(z.number())
26
- .optional()
27
- .describe("V4 only. Asset types per asset: 1=ERC20, 2=ERC721, 3=ERC1155. If omitted, inferred from asset_ids (non-zero → ERC721)."),
28
- account_version: z
29
- .number()
30
- .optional()
31
- .describe("Override account version (3 or 4). Auto-detected on-chain if omitted."),
32
- chain_id: z
33
- .number()
34
- .default(8453)
35
- .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
7
+ server.registerTool("build_withdraw_tx", {
8
+ description: "Build an unsigned transaction to withdraw assets from an Arcadia account to the owner's wallet. Only the account owner can withdraw. Will revert if the account has debt and withdrawal would make it undercollateralized. Does not support max_uint256 — pass exact amounts from get_account_info. Account version is auto-detected on-chain (override with account_version if needed).",
9
+ inputSchema: {
10
+ account_address: z.string().describe("Arcadia account address"),
11
+ asset_addresses: z.array(z.string()).describe("Token contract addresses to withdraw"),
12
+ asset_amounts: z.array(z.string()).describe("Amounts in raw units/wei, one per asset"),
13
+ asset_ids: z
14
+ .array(z.number())
15
+ .optional()
16
+ .describe("Token IDs: 0 for ERC20, NFT token ID for ERC721"),
17
+ asset_types: z
18
+ .array(z.number())
19
+ .optional()
20
+ .describe("V4 only. Asset types per asset: 1=ERC20, 2=ERC721, 3=ERC1155. If omitted, inferred from asset_ids (non-zero → ERC721)."),
21
+ account_version: z
22
+ .number()
23
+ .optional()
24
+ .describe("Override account version (3 or 4). Auto-detected on-chain if omitted."),
25
+ chain_id: z
26
+ .number()
27
+ .default(8453)
28
+ .describe("Chain ID: 8453 (Base), 10 (Optimism), or 130 (Unichain)"),
29
+ },
36
30
  }, async (params) => {
37
31
  try {
38
32
  if (params.asset_amounts.some((a) => a === "max_uint256")) {
@@ -62,7 +56,7 @@ export function registerWithdrawTool(server, chains) {
62
56
  const client = getPublicClient(params.chain_id, chains);
63
57
  version = Number(await client.readContract({
64
58
  address: params.account_address,
65
- abi: ACCOUNT_VERSION_ABI,
59
+ abi: accountAbi,
66
60
  functionName: "ACCOUNT_VERSION",
67
61
  }));
68
62
  }
@@ -111,4 +105,3 @@ export function registerWithdrawTool(server, chains) {
111
105
  }
112
106
  });
113
107
  }
114
- //# sourceMappingURL=withdraw.js.map
package/dist/types/api.js CHANGED
@@ -2,4 +2,3 @@
2
2
  // These are intentionally loose (Record-based) since the backend schema may evolve.
3
3
  // Tools format the raw responses before returning them.
4
4
  export {};
5
- //# sourceMappingURL=api.js.map
@@ -17,4 +17,3 @@ export function appendDataSuffix(calldata) {
17
17
  return calldata;
18
18
  return calldata + DATA_SUFFIX.slice(2);
19
19
  }
20
- //# sourceMappingURL=attribution.js.map
@@ -14,4 +14,3 @@ export function validateChainId(chainId) {
14
14
  }
15
15
  return chainId;
16
16
  }
17
- //# sourceMappingURL=validation.js.map
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@arcadia-finance/mcp-server",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "MCP server for Arcadia Finance — manage concentrated liquidity positions with leverage, automated rebalancing, and yield optimization.",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",
7
+ "packageManager": "yarn@4.13.0",
7
8
  "repository": {
8
9
  "type": "git",
9
10
  "url": "https://github.com/arcadia-finance/mcp-server.git"
@@ -23,6 +24,7 @@
23
24
  "dist",
24
25
  "!dist/**/*.d.ts",
25
26
  "!dist/**/*.js.map",
27
+ "skills",
26
28
  "README.md",
27
29
  "LICENSE.md"
28
30
  ],
@@ -30,7 +32,7 @@
30
32
  "arcadia-mcp": "./dist/index.js"
31
33
  },
32
34
  "scripts": {
33
- "build": "rm -rf dist && tsc && cp src/abis/*.json dist/abis/ && cp -r skills dist/skills",
35
+ "build": "rm -rf dist && tsc && cp src/abis/*.json dist/abis/",
34
36
  "dev": "tsx src/index.ts",
35
37
  "start": "node dist/index.js",
36
38
  "test": "vitest run",