@arcadia-finance/mcp-server 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +631 -68
- package/README.md +54 -38
- package/dist/clients/api.js +1 -1
- package/dist/index.js +15 -5
- package/dist/prompts/workflows.js +9 -9
- package/dist/tools/advanced/add-liquidity.js +14 -7
- package/dist/tools/advanced/close-position.js +12 -5
- package/dist/tools/advanced/position-actions.js +8 -1
- package/dist/tools/advanced/remove-liquidity.js +10 -3
- package/dist/tools/advanced/repay-with-collateral.js +9 -2
- package/dist/tools/advanced/swap.js +9 -2
- package/dist/tools/read/accounts.js +24 -3
- package/dist/tools/read/allowances.js +9 -2
- package/dist/tools/read/assets.js +8 -1
- package/dist/tools/read/balances.js +9 -2
- package/dist/tools/read/guides.js +8 -1
- package/dist/tools/read/points.js +8 -1
- package/dist/tools/read/pools.js +8 -1
- package/dist/tools/read/protocol.js +17 -3
- package/dist/tools/write/approve.js +9 -2
- package/dist/tools/write/borrow.js +10 -3
- package/dist/tools/write/configure-asset-manager.js +9 -2
- package/dist/tools/write/create-account.js +9 -2
- package/dist/tools/write/deposit.js +9 -2
- package/dist/tools/write/repay.js +9 -2
- package/dist/tools/write/set-asset-manager.js +9 -2
- package/dist/tools/write/sign-and-send.js +9 -2
- package/dist/tools/write/withdraw.js +10 -3
- package/package.json +2 -2
- package/server.json +9 -2
- package/skills/clamm-liquidity/SKILL.md +44 -44
- package/skills/clamm-liquidity/automation.md +7 -7
- package/skills/clamm-liquidity/selection.md +19 -19
- package/skills/clamm-liquidity/strategies.md +53 -53
package/README.md
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@arcadia-finance/mcp-server)
|
|
4
4
|
[](https://www.npmjs.com/package/@arcadia-finance/mcp-server)
|
|
5
5
|
[](https://smithery.ai/server/@arcadia-finance/mcp-server)
|
|
6
|
-
[](LICENSE.md)
|
|
7
7
|
[](https://www.typescriptlang.org/)
|
|
8
8
|
[](https://modelcontextprotocol.io/)
|
|
9
9
|
[](https://lobehub.com/mcp/arcadia-finance-mcp-server)
|
|
10
|
-
[](https://glama.ai/mcp/servers/@arcadia-finance/mcp-server)
|
|
11
11
|
|
|
12
12
|
MCP server for [Arcadia Finance](https://arcadia.finance), a platform to manage Uniswap and Aerodrome concentrated liquidity positions with built-in leverage, automated rebalancing, and yield optimization. Read protocol data and build unsigned transactions for LP management, borrowing, deposits, and more.
|
|
13
13
|
|
|
@@ -22,42 +22,42 @@ Designed for AI agents (Claude, Cursor, etc.) to interact with Arcadia onchain.
|
|
|
22
22
|
|
|
23
23
|
### Read Tools
|
|
24
24
|
|
|
25
|
-
| Tool
|
|
26
|
-
|
|
|
27
|
-
| `
|
|
28
|
-
| `
|
|
29
|
-
| `
|
|
30
|
-
| `
|
|
31
|
-
| `
|
|
32
|
-
| `
|
|
33
|
-
| `
|
|
34
|
-
| `
|
|
35
|
-
| `
|
|
36
|
-
| `
|
|
37
|
-
| `
|
|
25
|
+
| Tool | Description |
|
|
26
|
+
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
27
|
+
| `read.account_info` | Account overview: health factor, collateral, debt, positions, liquidation price. Pass `account_address` or `wallet_address`. |
|
|
28
|
+
| `read.account_history` | Historical account value over time. |
|
|
29
|
+
| `read.account_pnl` | PnL and yield data for an account. |
|
|
30
|
+
| `read.assets` | Supported collateral assets with addresses, types, decimals. Optional USD price lookup. |
|
|
31
|
+
| `read.wallet_balances` | On-chain ERC20 balances and native ETH for a wallet address. |
|
|
32
|
+
| `read.allowance` | Check ERC20 token allowances for a spender. Use before `write.approve` to avoid redundant approvals. |
|
|
33
|
+
| `read.points` | Points balance for a wallet, or leaderboard. |
|
|
34
|
+
| `read.lending_pools` | Pool data: TVL, APY, utilization, liquidity. Optional single-pool detail with APY history. |
|
|
35
|
+
| `read.strategies` | LP strategies with APY, underlyings, pool info. Optional detail or featured filter. |
|
|
36
|
+
| `read.recommendation` | Rebalancing recommendation for an account. |
|
|
37
|
+
| `read.guide` | Reference guides: automation setup, strategy selection, strategy templates. |
|
|
38
38
|
|
|
39
39
|
### Write Tools
|
|
40
40
|
|
|
41
41
|
Direct calldata encoding via viem. Each returns `{ to, data, value, chainId }`.
|
|
42
42
|
|
|
43
|
-
| Tool
|
|
44
|
-
|
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
43
|
+
| Tool | Description |
|
|
44
|
+
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
45
|
+
| `write.approve` | Approve an ERC20 token for spending. Required before depositing into an account. Call `read.allowance` first to check if already approved. |
|
|
46
|
+
| `write.create_account` | Create a new Arcadia account via Factory. |
|
|
47
|
+
| `write.deposit` | Deposit ERC20 tokens into an account. |
|
|
48
|
+
| `write.withdraw` | Withdraw assets from an account. |
|
|
49
|
+
| `write.borrow` | Borrow from a lending pool. |
|
|
50
|
+
| `write.repay` | Repay debt to a lending pool. |
|
|
51
|
+
| `write.set_asset_manager` | Grant or revoke an asset manager contract's permission on a V3/V4 account. For full setup with config, use `write.configure_asset_manager`. |
|
|
52
|
+
| `write.configure_asset_manager` | Enable AND configure an asset manager in one tx for V3/V4 accounts: sets initiator, fee limits, and strategy parameters (trigger thresholds, compound mode, recipients). |
|
|
53
53
|
|
|
54
54
|
### Dev Tools
|
|
55
55
|
|
|
56
56
|
Always registered but requires `PK` env var to function.
|
|
57
57
|
|
|
58
|
-
| Tool
|
|
59
|
-
|
|
|
60
|
-
| `
|
|
58
|
+
| Tool | Description |
|
|
59
|
+
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
60
|
+
| `dev.sign_and_send` | Sign and broadcast an unsigned transaction using a local private key (`PK` env var). Not for production — use a dedicated wallet MCP server instead. |
|
|
61
61
|
|
|
62
62
|
### Advanced Tools
|
|
63
63
|
|
|
@@ -65,12 +65,12 @@ Proxied via backend API. Handles swap routing, Tenderly simulation, optimal rati
|
|
|
65
65
|
|
|
66
66
|
| Tool | Description |
|
|
67
67
|
| -------------------------------- | ----------------------------------------------------------------------- |
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
68
|
+
| `advanced.add_liquidity` | Flash-action: deposit + swap + mint LP + optional leverage, atomically. |
|
|
69
|
+
| `advanced.remove_liquidity` | Remove/decrease LP position liquidity. |
|
|
70
|
+
| `advanced.swap` | Swap assets within an account (backend-routed). |
|
|
71
|
+
| `advanced.repay_with_collateral` | Repay debt by selling collateral (swap + repay in one tx). |
|
|
72
|
+
| `advanced.close_position` | Atomic close: burn LP + swap + repay debt in one tx. |
|
|
73
|
+
| `advanced.position_action` | Stake, unstake, or claim rewards for LP positions. |
|
|
74
74
|
|
|
75
75
|
## Transaction Signing
|
|
76
76
|
|
|
@@ -91,11 +91,11 @@ import { base } from "viem/chains";
|
|
|
91
91
|
const account = privateKeyToAccount("0x...");
|
|
92
92
|
const client = createWalletClient({ account, chain: base, transport: http() });
|
|
93
93
|
|
|
94
|
-
// tx = result from any
|
|
94
|
+
// tx = result from any write.* or advanced.* tool
|
|
95
95
|
const hash = await client.sendTransaction(tx);
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
-
**Built-in `
|
|
98
|
+
**Built-in `dev.sign_and_send` tool (development only):**
|
|
99
99
|
The server includes a dev-only signing tool that reads a private key from the `PK` environment variable. Set `PK` via a `.env` file or your MCP client config:
|
|
100
100
|
|
|
101
101
|
```bash
|
|
@@ -124,13 +124,25 @@ yarn build
|
|
|
124
124
|
| `RPC_URL_BASE` | No | RPC URL for Base (8453). Falls back to public RPC if not set. |
|
|
125
125
|
| `RPC_URL_OPTIMISM` | No | RPC URL for Optimism (10). Falls back to public RPC if not set. |
|
|
126
126
|
| `RPC_URL_UNICHAIN` | No | RPC URL for Unichain (130). Falls back to public RPC if not set. |
|
|
127
|
-
| `PK` | No | Private key (hex) for dev-only `
|
|
127
|
+
| `PK` | No | Private key (hex) for dev-only `dev.sign_and_send` tool. |
|
|
128
128
|
|
|
129
129
|
**Supported chains:** Base (8453), Optimism (10), Unichain (130)
|
|
130
130
|
|
|
131
131
|
## MCP Client Configuration
|
|
132
132
|
|
|
133
|
-
**
|
|
133
|
+
**Remote (no install needed):**
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"mcpServers": {
|
|
138
|
+
"arcadia-finance": {
|
|
139
|
+
"url": "https://mcp.arcadia.finance/mcp"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Via npx** (local stdio):
|
|
134
146
|
|
|
135
147
|
```json
|
|
136
148
|
{
|
|
@@ -149,6 +161,10 @@ yarn build
|
|
|
149
161
|
**Claude Code:**
|
|
150
162
|
|
|
151
163
|
```bash
|
|
164
|
+
# Remote
|
|
165
|
+
claude mcp add arcadia-finance --transport http https://mcp.arcadia.finance/mcp
|
|
166
|
+
|
|
167
|
+
# Local
|
|
152
168
|
claude mcp add arcadia-finance -- npx -y @arcadia-finance/mcp-server
|
|
153
169
|
```
|
|
154
170
|
|
package/dist/clients/api.js
CHANGED
|
@@ -28,7 +28,7 @@ export class ArcadiaApiClient {
|
|
|
28
28
|
}
|
|
29
29
|
else if (status === 500) {
|
|
30
30
|
hint =
|
|
31
|
-
" Internal backend error. Common causes: account has no creditor (spot account used where margin required), position does not exist in the account, unsupported asset type, or transient issue. Verify account and position details with
|
|
31
|
+
" Internal backend error. Common causes: account has no creditor (spot account used where margin required), position does not exist in the account, unsupported asset type, or transient issue. Verify account and position details with read.account_info, then retry once.";
|
|
32
32
|
}
|
|
33
33
|
else if (status === 502 || status === 503 || status === 504) {
|
|
34
34
|
hint = " Backend is temporarily unavailable. Retry after a few seconds.";
|
package/dist/index.js
CHANGED
|
@@ -47,7 +47,9 @@ if (transportMode === "http") {
|
|
|
47
47
|
try {
|
|
48
48
|
entry.transport.close();
|
|
49
49
|
}
|
|
50
|
-
catch {
|
|
50
|
+
catch {
|
|
51
|
+
/* already closed */
|
|
52
|
+
}
|
|
51
53
|
sessions.delete(id);
|
|
52
54
|
}, SESSION_TTL_MS);
|
|
53
55
|
}
|
|
@@ -56,13 +58,19 @@ if (transportMode === "http") {
|
|
|
56
58
|
const transport = new StreamableHTTPServerTransport({
|
|
57
59
|
sessionIdGenerator: () => crypto.randomUUID(),
|
|
58
60
|
onsessioninitialized: (sessionId) => {
|
|
59
|
-
sessions.set(sessionId, {
|
|
61
|
+
sessions.set(sessionId, {
|
|
62
|
+
server,
|
|
63
|
+
transport,
|
|
64
|
+
timer: setTimeout(() => {
|
|
60
65
|
try {
|
|
61
66
|
transport.close();
|
|
62
67
|
}
|
|
63
|
-
catch {
|
|
68
|
+
catch {
|
|
69
|
+
/* already closed */
|
|
70
|
+
}
|
|
64
71
|
sessions.delete(sessionId);
|
|
65
|
-
}, SESSION_TTL_MS)
|
|
72
|
+
}, SESSION_TTL_MS),
|
|
73
|
+
});
|
|
66
74
|
},
|
|
67
75
|
});
|
|
68
76
|
await server.connect(transport);
|
|
@@ -100,7 +108,9 @@ if (transportMode === "http") {
|
|
|
100
108
|
try {
|
|
101
109
|
transport.close();
|
|
102
110
|
}
|
|
103
|
-
catch {
|
|
111
|
+
catch {
|
|
112
|
+
/* ignore */
|
|
113
|
+
}
|
|
104
114
|
}
|
|
105
115
|
throw err;
|
|
106
116
|
}
|
|
@@ -16,10 +16,10 @@ export function registerWorkflowPrompts(server) {
|
|
|
16
16
|
`Analyze Arcadia account ${account_address} on chain ${chain_id ?? "8453"}.`,
|
|
17
17
|
"",
|
|
18
18
|
"Steps:",
|
|
19
|
-
"1. Call
|
|
20
|
-
"2. Call
|
|
21
|
-
"3. If leveraged (health_factor < 1), call
|
|
22
|
-
"4. Call
|
|
19
|
+
"1. Call read.account_info to get health factor, collateral, debt, positions, and automation status",
|
|
20
|
+
"2. Call read.account_pnl to check profitability and yield earned",
|
|
21
|
+
"3. If leveraged (health_factor < 1), call read.lending_pools to compare borrow APY vs fee APY",
|
|
22
|
+
"4. Call read.recommendation to check if rebalancing is needed",
|
|
23
23
|
"",
|
|
24
24
|
"Provide a summary covering:",
|
|
25
25
|
"- Health factor interpretation (1 = no debt/safest, >0.5 = healthy, <0.5 = monitor, <0.2 = action needed)",
|
|
@@ -48,9 +48,9 @@ export function registerWorkflowPrompts(server) {
|
|
|
48
48
|
`Find the best yield strategy on Arcadia (chain ${chain_id ?? "8453"})${deposit_token ? ` for depositing ${deposit_token}` : ""}.`,
|
|
49
49
|
"",
|
|
50
50
|
"Steps:",
|
|
51
|
-
"1. Call
|
|
52
|
-
"2. Call
|
|
53
|
-
"3. Call
|
|
51
|
+
"1. Call read.strategies(featured_only: true) to see top LP strategies with fee APY",
|
|
52
|
+
"2. Call read.strategies(strategy_id: <id>) for promising ones to see APY per range width",
|
|
53
|
+
"3. Call read.lending_pools to check borrow APY for leveraged strategies",
|
|
54
54
|
"4. Evaluate: net_APY = fee_APY - (leverage - 1) * borrow_APY > 0?",
|
|
55
55
|
"",
|
|
56
56
|
"For each viable strategy, assess:",
|
|
@@ -81,9 +81,9 @@ export function registerWorkflowPrompts(server) {
|
|
|
81
81
|
`Set up automation for Arcadia account ${account_address} on chain ${chain_id ?? "8453"}.`,
|
|
82
82
|
"",
|
|
83
83
|
"Steps:",
|
|
84
|
-
"1. Call
|
|
84
|
+
"1. Call read.account_info to check current positions and which asset managers are already enabled",
|
|
85
85
|
"2. Identify the LP protocol (Slipstream V1/V2, Uniswap V3/V4) from the position",
|
|
86
|
-
"3. For each automation type to enable, use
|
|
86
|
+
"3. For each automation type to enable, use write.configure_asset_manager:",
|
|
87
87
|
" - Rebalancer: match to LP protocol, set trigger ratios and compound_leftovers",
|
|
88
88
|
" - Compounder: match to LP protocol (compounds fees between rebalances)",
|
|
89
89
|
" - Yield Claimer: match to LP protocol, set fee_recipient",
|
|
@@ -11,14 +11,21 @@ function formatTokenAmount(value, decimals, maxFrac = 8) {
|
|
|
11
11
|
return frac ? `${whole}.${frac}` : whole;
|
|
12
12
|
}
|
|
13
13
|
export function registerAddLiquidityTool(server, api, chains) {
|
|
14
|
-
server.registerTool("
|
|
15
|
-
|
|
14
|
+
server.registerTool("advanced.add_liquidity", {
|
|
15
|
+
annotations: {
|
|
16
|
+
title: "Build Add Liquidity Transaction",
|
|
17
|
+
readOnlyHint: false,
|
|
18
|
+
destructiveHint: false,
|
|
19
|
+
idempotentHint: true,
|
|
20
|
+
openWorldHint: true,
|
|
21
|
+
},
|
|
22
|
+
description: "Multi-step flash-action: atomically combines [deposit from wallet] + [use account collateral] + [swap to optimal ratio] + [mint LP] + [borrow if leveraged] in ONE transaction. Do NOT call write.deposit separately. Capital sources: wallet tokens (deposits array), existing account collateral (use_account_assets=true), or both. Check allowances first (read.allowance), then approve if needed (write.approve). Supports depositing multiple tokens and minting multiple LP positions in one tx. Works with both margin accounts (can leverage) and spot accounts (no leverage). For workflows, call read.guide('strategies'). The returned calldata is time-sensitive — sign and broadcast within 30 seconds. If the transaction reverts due to price movement, rebuild and sign again immediately (retry at least once before giving up). Response includes tenderly_sim_url and tenderly_sim_status for pre-broadcast validation. expected_value_change is the estimated slippage/fee cost in the account's numeraire token (raw wei units, e.g. 18 decimals for WETH). Compare before.total_account_value and after.total_account_value for the full picture.",
|
|
16
23
|
inputSchema: {
|
|
17
24
|
account_address: z.string().describe("Arcadia account address"),
|
|
18
25
|
wallet_address: z.string().describe("Wallet address of the account owner"),
|
|
19
26
|
positions: z
|
|
20
27
|
.array(z.object({
|
|
21
|
-
strategy_id: z.number().describe("From
|
|
28
|
+
strategy_id: z.number().describe("From read.strategies tool"),
|
|
22
29
|
tick_lower: z
|
|
23
30
|
.number()
|
|
24
31
|
.optional()
|
|
@@ -39,7 +46,7 @@ export function registerAddLiquidityTool(server, api, chains) {
|
|
|
39
46
|
.describe("Token decimals (e.g. 6 for USDC, 18 for WETH). Default 18."),
|
|
40
47
|
}))
|
|
41
48
|
.optional()
|
|
42
|
-
.describe("Wallet tokens to deposit. Approve each token first (
|
|
49
|
+
.describe("Wallet tokens to deposit. Approve each token first (write.approve). Omit to use only account collateral."),
|
|
43
50
|
use_account_assets: z
|
|
44
51
|
.boolean()
|
|
45
52
|
.optional()
|
|
@@ -115,7 +122,7 @@ export function registerAddLiquidityTool(server, api, chains) {
|
|
|
115
122
|
content: [
|
|
116
123
|
{
|
|
117
124
|
type: "text",
|
|
118
|
-
text: "Error: Spot accounts cannot borrow. Set leverage to 0, or create a margin account (V3) with a creditor (lending pool) using
|
|
125
|
+
text: "Error: Spot accounts cannot borrow. Set leverage to 0, or create a margin account (V3) with a creditor (lending pool) using write.create_account.",
|
|
119
126
|
},
|
|
120
127
|
],
|
|
121
128
|
isError: true,
|
|
@@ -204,7 +211,7 @@ export function registerAddLiquidityTool(server, api, chains) {
|
|
|
204
211
|
content: [
|
|
205
212
|
{
|
|
206
213
|
type: "text",
|
|
207
|
-
text: "Error: use_account_assets=true but account overview is unavailable and no wallet deposits were provided. Provide deposits or deposit assets first via
|
|
214
|
+
text: "Error: use_account_assets=true but account overview is unavailable and no wallet deposits were provided. Provide deposits or deposit assets first via write.deposit.",
|
|
208
215
|
},
|
|
209
216
|
],
|
|
210
217
|
isError: true,
|
|
@@ -216,7 +223,7 @@ export function registerAddLiquidityTool(server, api, chains) {
|
|
|
216
223
|
content: [
|
|
217
224
|
{
|
|
218
225
|
type: "text",
|
|
219
|
-
text: "Error: use_account_assets=true but the account has no deposited assets, and no wallet deposits were provided. Deposit assets first via
|
|
226
|
+
text: "Error: use_account_assets=true but the account has no deposited assets, and no wallet deposits were provided. Deposit assets first via write.deposit or provide deposits.",
|
|
220
227
|
},
|
|
221
228
|
],
|
|
222
229
|
isError: true,
|
|
@@ -4,14 +4,21 @@ import { readAccountMetadata } from "./account-metadata.js";
|
|
|
4
4
|
import { formatAdvancedResponse } from "./format-response.js";
|
|
5
5
|
import { validateAddress, validateChainId } from "../../utils/validation.js";
|
|
6
6
|
export function registerClosePositionTool(server, api, chains) {
|
|
7
|
-
server.registerTool("
|
|
8
|
-
|
|
7
|
+
server.registerTool("advanced.close_position", {
|
|
8
|
+
annotations: {
|
|
9
|
+
title: "Build Close Position Transaction",
|
|
10
|
+
readOnlyHint: false,
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
idempotentHint: true,
|
|
13
|
+
openWorldHint: true,
|
|
14
|
+
},
|
|
15
|
+
description: `Atomic flash-action that closes an Arcadia account position in ONE transaction. Combines up to 3 steps atomically: [burn LP position] + [swap all tokens to a single target asset] + [repay debt]. Tokens remain in the account after closing — use write.withdraw to send them to your wallet.
|
|
9
16
|
|
|
10
|
-
ALWAYS try this tool first when closing/exiting a position. Only fall back to individual tools (
|
|
17
|
+
ALWAYS try this tool first when closing/exiting a position. Only fall back to individual tools (advanced.remove_liquidity, advanced.swap, advanced.repay_with_collateral, write.withdraw) if this tool fails.
|
|
11
18
|
|
|
12
19
|
Supports two modes:
|
|
13
20
|
- close_lp_only=true: Burns LP and leaves underlying tokens in the account. Use as step 1 if the full close fails, then call again with close_lp_only=false to swap+repay the remaining tokens.
|
|
14
|
-
- close_lp_only=false (default): Full atomic close — burns LP, swaps everything to receive_assets, repays debt. Remaining tokens stay in the account. Follow up with
|
|
21
|
+
- close_lp_only=false (default): Full atomic close — burns LP, swaps everything to receive_assets, repays debt. Remaining tokens stay in the account. Follow up with write.withdraw to send to wallet. Supports multiple receive assets with custom distribution.
|
|
15
22
|
|
|
16
23
|
The returned calldata is time-sensitive — sign and broadcast within 30 seconds. If the transaction reverts due to price movement, rebuild and sign again immediately (retry at least once before giving up). Response includes tenderly_sim_url and tenderly_sim_status for pre-broadcast validation.`,
|
|
17
24
|
inputSchema: {
|
|
@@ -23,7 +30,7 @@ The returned calldata is time-sensitive — sign and broadcast within 30 seconds
|
|
|
23
30
|
amount: z.string().describe("Amount to sell (use '1' for NFT positions)"),
|
|
24
31
|
decimals: z.number().describe("Token decimals (use 1 for NFT positions)"),
|
|
25
32
|
}))
|
|
26
|
-
.describe("Assets to close/sell from the account. For LP positions: asset_address = position manager, asset_id = NFT ID, amount = '1', decimals = 1. For ERC20 tokens: asset_id = 0, amount = full balance, decimals = token decimals. Get these from
|
|
33
|
+
.describe("Assets to close/sell from the account. For LP positions: asset_address = position manager, asset_id = NFT ID, amount = '1', decimals = 1. For ERC20 tokens: asset_id = 0, amount = full balance, decimals = token decimals. Get these from read.account_info."),
|
|
27
34
|
receive_assets: z
|
|
28
35
|
.array(z.object({
|
|
29
36
|
asset_address: z.string().describe("Target token address (e.g. USDC, WETH)"),
|
|
@@ -2,7 +2,14 @@ import { z } from "zod";
|
|
|
2
2
|
import { formatAdvancedResponse } from "./format-response.js";
|
|
3
3
|
import { validateAddress } from "../../utils/validation.js";
|
|
4
4
|
export function registerPositionActionsTool(server, api) {
|
|
5
|
-
server.registerTool("
|
|
5
|
+
server.registerTool("advanced.position_action", {
|
|
6
|
+
annotations: {
|
|
7
|
+
title: "Build Position Action Transaction",
|
|
8
|
+
readOnlyHint: false,
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
idempotentHint: true,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
},
|
|
6
13
|
description: "Flash-action: stake, unstake, or claim rewards for an LP position in one atomic transaction. The stake/unstake direction is auto-detected from asset_address: pass the non-staked position manager to stake, or the staked position manager to unstake. The returned calldata is time-sensitive — sign and broadcast within 30 seconds. If the transaction reverts due to price movement, rebuild and sign again immediately (retry at least once before giving up).",
|
|
7
14
|
inputSchema: {
|
|
8
15
|
account_address: z.string().describe("Arcadia account address"),
|
|
@@ -2,10 +2,17 @@ import { z } from "zod";
|
|
|
2
2
|
import { formatAdvancedResponse } from "./format-response.js";
|
|
3
3
|
import { validateAddress } from "../../utils/validation.js";
|
|
4
4
|
export function registerRemoveLiquidityTool(server, api) {
|
|
5
|
-
server.registerTool("
|
|
5
|
+
server.registerTool("advanced.remove_liquidity", {
|
|
6
|
+
annotations: {
|
|
7
|
+
title: "Build Remove Liquidity Transaction",
|
|
8
|
+
readOnlyHint: false,
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
idempotentHint: true,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
},
|
|
6
13
|
description: `Flash-action: PARTIALLY decreases liquidity from an LP position. The position remains open with reduced liquidity; underlying tokens stay in the account.
|
|
7
14
|
|
|
8
|
-
For FULL position exit (burn LP + swap + repay + withdraw), use
|
|
15
|
+
For FULL position exit (burn LP + swap + repay + withdraw), use advanced.close_position instead — it batches everything into one atomic transaction.
|
|
9
16
|
|
|
10
17
|
The returned calldata is time-sensitive — sign and broadcast within 30 seconds. If the transaction reverts due to price movement, rebuild and sign again immediately (retry at least once before giving up). Response includes tenderly_sim_url and tenderly_sim_status for pre-broadcast validation.`,
|
|
11
18
|
inputSchema: {
|
|
@@ -14,7 +21,7 @@ The returned calldata is time-sensitive — sign and broadcast within 30 seconds
|
|
|
14
21
|
asset_id: z.number().describe("NFT token ID"),
|
|
15
22
|
adjustment: z
|
|
16
23
|
.string()
|
|
17
|
-
.describe("Liquidity amount to remove (raw uint128 value as string). Must be less than total liquidity — for full removal use
|
|
24
|
+
.describe("Liquidity amount to remove (raw uint128 value as string). Must be less than total liquidity — for full removal use advanced.close_position."),
|
|
18
25
|
chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"),
|
|
19
26
|
},
|
|
20
27
|
}, async ({ account_address, asset_address, asset_id, adjustment, chain_id }) => {
|
|
@@ -2,8 +2,15 @@ import { z } from "zod";
|
|
|
2
2
|
import { formatAdvancedResponse } from "./format-response.js";
|
|
3
3
|
import { validateAddress } from "../../utils/validation.js";
|
|
4
4
|
export function registerRepayWithCollateralTool(server, api) {
|
|
5
|
-
server.registerTool("
|
|
6
|
-
|
|
5
|
+
server.registerTool("advanced.repay_with_collateral", {
|
|
6
|
+
annotations: {
|
|
7
|
+
title: "Build Repay With Collateral Transaction",
|
|
8
|
+
readOnlyHint: false,
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
idempotentHint: true,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
},
|
|
13
|
+
description: "Multi-step flash-action: swaps account collateral to debt token and repays in one atomic transaction. To repay from wallet instead, use write.repay. NOTE: If you are closing a position (remove LP + swap + repay + withdraw), prefer advanced.close_position which batches everything atomically. Only use this tool for standalone repayment while keeping the position active. The returned calldata is time-sensitive — sign and broadcast within 30 seconds. If the transaction reverts due to price movement, rebuild and sign again immediately (retry at least once before giving up). Response includes tenderly_sim_url and tenderly_sim_status for pre-broadcast validation.",
|
|
7
14
|
inputSchema: {
|
|
8
15
|
account_address: z.string().describe("Arcadia account address"),
|
|
9
16
|
amount_in: z.string().describe("Collateral amount to sell"),
|
|
@@ -2,8 +2,15 @@ import { z } from "zod";
|
|
|
2
2
|
import { formatAdvancedResponse } from "./format-response.js";
|
|
3
3
|
import { validateAddress } from "../../utils/validation.js";
|
|
4
4
|
export function registerSwapTool(server, api) {
|
|
5
|
-
server.registerTool("
|
|
6
|
-
|
|
5
|
+
server.registerTool("advanced.swap", {
|
|
6
|
+
annotations: {
|
|
7
|
+
title: "Build Swap Transaction",
|
|
8
|
+
readOnlyHint: false,
|
|
9
|
+
destructiveHint: false,
|
|
10
|
+
idempotentHint: true,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
},
|
|
13
|
+
description: "Flash-action: swaps assets within an Arcadia account in one atomic transaction. The backend finds the optimal swap route. NOTE: If you are closing a position (swap + repay + withdraw), prefer advanced.close_position which batches everything atomically. Only use this tool for standalone swaps within an active position. The returned calldata is time-sensitive — sign and broadcast within 30 seconds. If the transaction reverts due to price movement, rebuild and sign again immediately (retry at least once before giving up). Response includes tenderly_sim_url and tenderly_sim_status for pre-broadcast validation.",
|
|
7
14
|
inputSchema: {
|
|
8
15
|
account_address: z.string().describe("Arcadia account address"),
|
|
9
16
|
asset_from: z.string().describe("Token address to swap from"),
|
|
@@ -37,7 +37,14 @@ function trimOverview(overview) {
|
|
|
37
37
|
return trimmed;
|
|
38
38
|
}
|
|
39
39
|
export function registerAccountTools(server, api, chains) {
|
|
40
|
-
server.registerTool("
|
|
40
|
+
server.registerTool("read.account_info", {
|
|
41
|
+
annotations: {
|
|
42
|
+
title: "Get Account Info",
|
|
43
|
+
readOnlyHint: true,
|
|
44
|
+
destructiveHint: false,
|
|
45
|
+
idempotentHint: true,
|
|
46
|
+
openWorldHint: true,
|
|
47
|
+
},
|
|
41
48
|
description: "Get full overview of an Arcadia account: health factor, collateral value, debt, deposited assets, liquidation price, and automation status. Pass account_address for a specific account, or wallet_address to list all accounts owned by a wallet. Health factor = 1 - (used_margin / liquidation_value): 1 = no debt (safest), >0 = healthy, 0 = liquidation threshold, <0 = past liquidation. Higher is safer. On Base, also returns which asset managers are enabled (rebalancer, compounder, yield_claimer, merkl_operator, cow_swapper).",
|
|
42
49
|
inputSchema: {
|
|
43
50
|
account_address: z.string().optional().describe("Arcadia account address"),
|
|
@@ -173,7 +180,14 @@ export function registerAccountTools(server, api, chains) {
|
|
|
173
180
|
};
|
|
174
181
|
}
|
|
175
182
|
});
|
|
176
|
-
server.registerTool("
|
|
183
|
+
server.registerTool("read.account_history", {
|
|
184
|
+
annotations: {
|
|
185
|
+
title: "Get Account History",
|
|
186
|
+
readOnlyHint: true,
|
|
187
|
+
destructiveHint: false,
|
|
188
|
+
idempotentHint: true,
|
|
189
|
+
openWorldHint: true,
|
|
190
|
+
},
|
|
177
191
|
description: "Get historical collateral and debt values for an Arcadia account over time. Returns a time series of snapshots (timestamp, collateral_value, debt_value, net_value in USD). Useful for charting account performance over a period.",
|
|
178
192
|
inputSchema: {
|
|
179
193
|
account_address: z.string().describe("Arcadia account address"),
|
|
@@ -197,7 +211,14 @@ export function registerAccountTools(server, api, chains) {
|
|
|
197
211
|
};
|
|
198
212
|
}
|
|
199
213
|
});
|
|
200
|
-
server.registerTool("
|
|
214
|
+
server.registerTool("read.account_pnl", {
|
|
215
|
+
annotations: {
|
|
216
|
+
title: "Get Account PnL",
|
|
217
|
+
readOnlyHint: true,
|
|
218
|
+
destructiveHint: false,
|
|
219
|
+
idempotentHint: true,
|
|
220
|
+
openWorldHint: true,
|
|
221
|
+
},
|
|
201
222
|
description: "Get PnL (cost basis) and yield earned for an Arcadia account. Returns lifetime totals: cost basis vs current value (negative cost_basis = net profit withdrawn), net transfers per token, total yield earned in USD and per token. All monetary values are in USD unless suffixed otherwise.",
|
|
202
223
|
inputSchema: {
|
|
203
224
|
account_address: z.string().describe("Arcadia account address"),
|
|
@@ -5,8 +5,15 @@ import { getPublicClient } from "../../clients/chain.js";
|
|
|
5
5
|
import { validateAddress, validateChainId } from "../../utils/validation.js";
|
|
6
6
|
const MAX_UINT256 = 2n ** 256n - 1n;
|
|
7
7
|
export function registerAllowanceTools(server, chains) {
|
|
8
|
-
server.registerTool("
|
|
9
|
-
|
|
8
|
+
server.registerTool("read.allowance", {
|
|
9
|
+
annotations: {
|
|
10
|
+
title: "Get Token Allowance",
|
|
11
|
+
readOnlyHint: true,
|
|
12
|
+
destructiveHint: false,
|
|
13
|
+
idempotentHint: true,
|
|
14
|
+
openWorldHint: true,
|
|
15
|
+
},
|
|
16
|
+
description: "Check ERC20 token allowances for a spender address. Use before write.approve to avoid redundant approvals — skip approving if the current allowance is already sufficient.",
|
|
10
17
|
inputSchema: {
|
|
11
18
|
owner_address: z.string().describe("Token owner address (the wallet granting approval)"),
|
|
12
19
|
spender_address: z
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export function registerAssetTools(server, api) {
|
|
3
|
-
server.registerTool("
|
|
3
|
+
server.registerTool("read.assets", {
|
|
4
|
+
annotations: {
|
|
5
|
+
title: "Get Supported Assets",
|
|
6
|
+
readOnlyHint: true,
|
|
7
|
+
destructiveHint: false,
|
|
8
|
+
idempotentHint: true,
|
|
9
|
+
openWorldHint: true,
|
|
10
|
+
},
|
|
4
11
|
description: "Get supported collateral assets on Arcadia. Returns compact list (address, symbol, decimals, type) by default. Use asset_addresses for USD price lookup. Use search to filter by symbol substring.",
|
|
5
12
|
inputSchema: {
|
|
6
13
|
asset_addresses: z
|
|
@@ -4,8 +4,15 @@ import { erc20Abi } from "../../abis/index.js";
|
|
|
4
4
|
import { getPublicClient } from "../../clients/chain.js";
|
|
5
5
|
import { validateAddress, validateChainId } from "../../utils/validation.js";
|
|
6
6
|
export function registerBalanceTools(server, chains) {
|
|
7
|
-
server.registerTool("
|
|
8
|
-
|
|
7
|
+
server.registerTool("read.wallet_balances", {
|
|
8
|
+
annotations: {
|
|
9
|
+
title: "Get Wallet Balances",
|
|
10
|
+
readOnlyHint: true,
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
idempotentHint: true,
|
|
13
|
+
openWorldHint: true,
|
|
14
|
+
},
|
|
15
|
+
description: "Get native ETH and ERC20 token balances for a wallet address. Reads directly from chain via RPC multicall. Use before advanced.add_liquidity or write.deposit to verify the wallet has sufficient tokens.",
|
|
9
16
|
inputSchema: {
|
|
10
17
|
wallet_address: z.string().describe("Wallet address to check balances for"),
|
|
11
18
|
token_addresses: z.array(z.string()).describe("ERC20 token contract addresses to check"),
|
|
@@ -33,7 +33,14 @@ export function registerGuideTools(server) {
|
|
|
33
33
|
guides.set(topic, `Guide "${topic}" is not available in this installation.`);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
server.registerTool("
|
|
36
|
+
server.registerTool("read.guide", {
|
|
37
|
+
annotations: {
|
|
38
|
+
title: "Get Guide",
|
|
39
|
+
readOnlyHint: true,
|
|
40
|
+
destructiveHint: false,
|
|
41
|
+
idempotentHint: true,
|
|
42
|
+
openWorldHint: true,
|
|
43
|
+
},
|
|
37
44
|
description: "Get Arcadia workflow guides and reference documentation. Call this before multi-step workflows (opening LP positions, enabling automation, closing positions) or when you need contract addresses, asset manager addresses, or strategy parameters. Topics: overview (addresses + tool catalog), automation (rebalancer/compounder setup), strategies (step-by-step templates), selection (how to evaluate and parameterize strategies).",
|
|
38
45
|
inputSchema: {
|
|
39
46
|
topic: z
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export function registerPointsTools(server, api) {
|
|
3
|
-
server.registerTool("
|
|
3
|
+
server.registerTool("read.points", {
|
|
4
|
+
annotations: {
|
|
5
|
+
title: "Get Points",
|
|
6
|
+
readOnlyHint: true,
|
|
7
|
+
destructiveHint: false,
|
|
8
|
+
idempotentHint: true,
|
|
9
|
+
openWorldHint: true,
|
|
10
|
+
},
|
|
4
11
|
description: "Get Arcadia points balance for a wallet, or the points leaderboard (paginated) if no wallet is specified.",
|
|
5
12
|
inputSchema: {
|
|
6
13
|
wallet_address: z.string().optional().describe("Wallet address for points balance"),
|
package/dist/tools/read/pools.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export function registerPoolTools(server, api) {
|
|
3
|
-
server.registerTool("
|
|
3
|
+
server.registerTool("read.lending_pools", {
|
|
4
|
+
annotations: {
|
|
5
|
+
title: "Get Lending Pools",
|
|
6
|
+
readOnlyHint: true,
|
|
7
|
+
destructiveHint: false,
|
|
8
|
+
idempotentHint: true,
|
|
9
|
+
openWorldHint: true,
|
|
10
|
+
},
|
|
4
11
|
description: "Get Arcadia lending pool data: TVL, utilization, available liquidity. Key fields: interest_rate = current borrow cost, lending_apy = lender yield. All rates are decimal fractions (1.0 = 100%, 0.06 = 6%). Returns all pools, or a single pool with APY history if pool_address is provided.",
|
|
5
12
|
inputSchema: {
|
|
6
13
|
pool_address: z
|