@arcadia-finance/mcp-server 0.1.5 → 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.
@@ -4,17 +4,17 @@ These are templates and examples — not the only valid approaches. Adapt parame
4
4
 
5
5
  ## Key Parameter Notes
6
6
 
7
- - **`build_add_liquidity_tx`** capital sources: `deposits` array (wallet tokens), `use_account_assets=true` (existing account collateral), or both. Supports depositing multiple tokens and minting multiple LP positions in one tx. The backend swaps everything to the optimal ratio for the LP. You do NOT need to `build_deposit_tx` first — `build_add_liquidity_tx` handles the wallet transfer atomically. Check allowances first (`get_allowance`), then approve if needed (`build_approve_tx`).
7
+ - **`advanced.add_liquidity`** capital sources: `deposits` array (wallet tokens), `use_account_assets=true` (existing account collateral), or both. Supports depositing multiple tokens and minting multiple LP positions in one tx. The backend swaps everything to the optimal ratio for the LP. You do NOT need to `write.deposit` first — `advanced.add_liquidity` handles the wallet transfer atomically. Check allowances first (`read.allowance`), then approve if needed (`write.approve`).
8
8
  - **V4 spot accounts CAN mint LP** but cannot leverage (set `leverage: 0`). V3 margin accounts (created with a `creditor`) can both mint LP and leverage. If the user wants leveraged LP, create a V3 margin account with a creditor (`account_version: 3`).
9
- - **`numeraire`** in `build_repay_with_collateral_tx`: the debt token you're repaying (e.g. WETH when repaying WETH debt). `build_add_liquidity_tx` auto-detects numeraire — no param needed.
10
- - **`leverage`**: `0` = no leverage. `2` = 2x. Do NOT use `1` for no leverage — use `0`. When `leverage > 0`, borrowing is handled internally by `build_add_liquidity_tx` — do NOT call `build_borrow_tx` separately.
11
- - **LP NFT details**: after `build_add_liquidity_tx`, call `get_account_info` to find `asset_address` (the position manager contract) and `asset_id` (NFT token ID) in the positions list — needed for unstake/remove/claim actions.
12
- - **`amount: "max_uint256"`** in `build_repay_tx` repays all debt in full.
9
+ - **`numeraire`** in `advanced.repay_with_collateral`: the debt token you're repaying (e.g. WETH when repaying WETH debt). `advanced.add_liquidity` auto-detects numeraire — no param needed.
10
+ - **`leverage`**: `0` = no leverage. `2` = 2x. Do NOT use `1` for no leverage — use `0`. When `leverage > 0`, borrowing is handled internally by `advanced.add_liquidity` — do NOT call `write.borrow` separately.
11
+ - **LP NFT details**: after `advanced.add_liquidity`, call `read.account_info` to find `asset_address` (the position manager contract) and `asset_id` (NFT token ID) in the positions list — needed for unstake/remove/claim actions.
12
+ - **`amount: "max_uint256"`** in `write.repay` repays all debt in full.
13
13
  - **`slippage`** is in basis points: 100 = 1%, 50 = 0.5%.
14
- - **`salt`** in `build_create_account_tx` is a random uint32 used for deterministic address derivation. Use any random 32-bit integer (e.g. `Math.floor(Math.random() * 2**32)`).
15
- - **`creditor`** = the lending pool address you want to borrow from. Set at account creation via `build_create_account_tx`. Determines which asset the account can borrow. **Required for leveraged LP strategies.** Omit for spot-only accounts (no borrowing, but LP minting still works with `leverage: 0`).
16
- - **`build_withdraw_tx`**: pass exact amounts from `get_account_info`. Does NOT support `"max_uint256"` — will error.
17
- - **Getting the account address after creation:** The address is deterministic from the salt. It's visible in the tx receipt events. Or call `get_account_info(wallet_address: ...)` after creation to list all accounts.
14
+ - **`salt`** in `write.create_account` is a random uint32 used for deterministic address derivation. Use any random 32-bit integer (e.g. `Math.floor(Math.random() * 2**32)`).
15
+ - **`creditor`** = the lending pool address you want to borrow from. Set at account creation via `write.create_account`. Determines which asset the account can borrow. **Required for leveraged LP strategies.** Omit for spot-only accounts (no borrowing, but LP minting still works with `leverage: 0`).
16
+ - **`write.withdraw`**: pass exact amounts from `read.account_info`. Does NOT support `"max_uint256"` — will error.
17
+ - **Getting the account address after creation:** The address is deterministic from the salt. It's visible in the tx receipt events. Or call `read.account_info(wallet_address: ...)` after creation to list all accounts.
18
18
 
19
19
  ---
20
20
 
@@ -22,14 +22,14 @@ These are templates and examples — not the only valid approaches. Adapt parame
22
22
 
23
23
  ```
24
24
  Open: check allowances → approve tokens if needed → create account → add liquidity (atomic: deposit + swap + mint + borrow) → enable automation
25
- Monitor: get_account_info (health), get_account_pnl (profitability)
25
+ Monitor: read.account_info (health), read.account_pnl (profitability)
26
26
  Adjust: add collateral or repay debt if health drops; remove + re-add liquidity to manually rebalance range
27
27
  Close: disable rebalancer → unstake → atomic close (burn LP + swap + repay) → withdraw
28
28
  ```
29
29
 
30
30
  ### Batching vs splitting
31
31
 
32
- **Default: always use atomic tools.** `build_add_liquidity_tx` batches opening, `build_close_position_tx` batches closing, `build_repay_with_collateral_tx` batches debt repayment from collateral. These reduce transaction count and eliminate exposure to price movement between steps.
32
+ **Default: always use atomic tools.** `advanced.add_liquidity` batches opening, `advanced.close_position` batches closing, `advanced.repay_with_collateral` batches debt repayment from collateral. These reduce transaction count and eliminate exposure to price movement between steps.
33
33
 
34
34
  **When to split:** In high-volatility markets or for low-liquidity pools, atomic transactions may revert because on-chain state diverges from when the backend computed the calldata. If an atomic tool fails, fall back to individual tools with tighter slippage. Always try atomic first — split only on failure.
35
35
 
@@ -52,38 +52,38 @@ Close: disable rebalancer → unstake → atomic close (burn LP + swap + repay
52
52
 
53
53
  ### Step-by-step
54
54
 
55
- > Addresses below are Base mainnet examples. Always verify current addresses via `get_lending_pools` and `get_assets` before executing.
55
+ > Addresses below are Base mainnet examples. Always verify current addresses via `read.lending_pools` and `read.assets` before executing.
56
56
 
57
57
  ```
58
58
  // 1. FIND A POOL
59
- get_strategies(chain_id: 8453)
59
+ read.strategies(chain_id: 8453)
60
60
  → Filter for volatile/stable pair (WETH/USDC, cbBTC/USDC, etc.)
61
61
  → Note: strategy_id (integer), pool_protocol (Slipstream V1/V2, UniV3, UniV4), fee_APY
62
62
 
63
63
  // 2. CHECK BORROW COST
64
- get_lending_pools(chain_id: 8453)
64
+ read.lending_pools(chain_id: 8453)
65
65
  → Find the WETH lending pool (address: 0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2)
66
66
  → If borrow_apy > fee_apy → stop, strategy not profitable
67
67
 
68
68
  // 3. CREATE MARGIN ACCOUNT (V3 + creditor = can borrow/leverage)
69
- build_create_account_tx(
69
+ write.create_account(
70
70
  salt: <random uint32, e.g. 3141592653>,
71
71
  account_version: 3, // V3 margin — required for leverage
72
72
  creditor: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", // WETH lending pool — enables borrow
73
73
  chain_id: 8453
74
74
  )
75
75
  → Submit tx, note deployed account address from tx receipt
76
- → Or call get_account_info(wallet_address: ...) to find the new account address
76
+ → Or call read.account_info(wallet_address: ...) to find the new account address
77
77
 
78
78
  // 4. CHECK ALLOWANCE + APPROVE (skip approve if already sufficient)
79
- get_allowance(
79
+ read.allowance(
80
80
  owner_address: <owner_wallet>,
81
81
  spender_address: <account_address>,
82
82
  token_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], // USDC
83
83
  chain_id: 8453
84
84
  )
85
85
  // → If allowance is insufficient or zero:
86
- build_approve_tx(
86
+ write.approve(
87
87
  token_address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC
88
88
  spender_address: <account_address>,
89
89
  amount: "max_uint256",
@@ -91,8 +91,8 @@ build_approve_tx(
91
91
  )
92
92
 
93
93
  // 5. OPEN LEVERAGED LP (atomic: pull USDC from wallet + borrow WETH + swap to ratio + mint LP)
94
- // No separate build_deposit_tx needed — build_add_liquidity_tx handles the wallet transfer atomically.
95
- build_add_liquidity_tx(
94
+ // No separate write.deposit needed — advanced.add_liquidity handles the wallet transfer atomically.
95
+ advanced.add_liquidity(
96
96
  account_address: <account_address>,
97
97
  wallet_address: <owner_wallet>,
98
98
  positions: [{ strategy_id: <integer from step 1> }],
@@ -103,7 +103,7 @@ build_add_liquidity_tx(
103
103
  )
104
104
 
105
105
  // 6. ENABLE AND CONFIGURE REBALANCER (match address to LP protocol from step 1)
106
- build_configure_asset_manager_tx(
106
+ write.configure_asset_manager(
107
107
  account_address: <account_address>,
108
108
  asset_manager_address: "0x953Ff365d0b562ceC658dc46B394E9282338d9Ea", // Slipstream V2
109
109
  am_type: "rebalancer",
@@ -116,7 +116,7 @@ build_configure_asset_manager_tx(
116
116
  // → Range width and reposition mode must be configured in the Arcadia platform
117
117
 
118
118
  // 7. ENABLE MERKL (if pool has Merkl incentives — check fee APY breakdown in step 1)
119
- build_configure_asset_manager_tx(
119
+ write.configure_asset_manager(
120
120
  account_address: <account_address>,
121
121
  asset_manager_address: "0x969F0251360b9Cf11c68f6Ce9587924c1B8b42C6",
122
122
  am_type: "merkl_operator",
@@ -129,7 +129,7 @@ build_configure_asset_manager_tx(
129
129
 
130
130
  ```
131
131
  // Run periodically (daily or on request)
132
- get_account_info(account_address: <account_address>, chain_id: 8453)
132
+ read.account_info(account_address: <account_address>, chain_id: 8453)
133
133
  → health_factor = 1 - (used_margin / liquidation_value). Higher = safer.
134
134
  1 → no debt (safest)
135
135
  > 0.5 → healthy
@@ -144,10 +144,10 @@ typically a few dollars in value) to the debt when computing used_margin
144
144
  dominates, pushing HF lower than the leverage ratio suggests — e.g. HF ~0.3 at 2×
145
145
  instead of ~0.5–0.7. Increase position size for a healthier starting HF.
146
146
 
147
- get_account_pnl(account_address: <account_address>, chain_id: 8453)
147
+ read.account_pnl(account_address: <account_address>, chain_id: 8453)
148
148
  → If net yield is consistently negative → evaluate exit
149
149
 
150
- get_lending_pools(chain_id: 8453)
150
+ read.lending_pools(chain_id: 8453)
151
151
  → If borrow_APY risen above fee_APY → exit signal
152
152
  ```
153
153
 
@@ -156,15 +156,15 @@ get_lending_pools(chain_id: 8453)
156
156
  ```
157
157
  // Option A: Add collateral (raises health factor, cheapest)
158
158
  // Check allowance first — skip approve if already sufficient
159
- get_allowance(owner_address: <wallet>, spender_address: <account>, token_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], chain_id: 8453)
160
- build_approve_tx(token_address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", spender_address: <account>, amount: "max_uint256", chain_id: 8453)
161
- build_deposit_tx(account_address: <account>, asset_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], asset_amounts: ["<amount>"], chain_id: 8453)
159
+ read.allowance(owner_address: <wallet>, spender_address: <account>, token_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], chain_id: 8453)
160
+ write.approve(token_address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", spender_address: <account>, amount: "max_uint256", chain_id: 8453)
161
+ write.deposit(account_address: <account>, asset_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], asset_amounts: ["<amount>"], chain_id: 8453)
162
162
 
163
163
  // Option B: Repay some WETH debt (reduces leverage)
164
164
  // NOTE: you must approve the WETH pool to spend WETH from your wallet first — check allowance, then approve if needed
165
- get_allowance(owner_address: <wallet>, spender_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", token_addresses: ["0x4200000000000000000000000000000000000006"], chain_id: 8453)
166
- build_approve_tx(token_address: "0x4200000000000000000000000000000000000006", spender_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", amount: "max_uint256", chain_id: 8453)
167
- build_repay_tx(
165
+ read.allowance(owner_address: <wallet>, spender_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", token_addresses: ["0x4200000000000000000000000000000000000006"], chain_id: 8453)
166
+ write.approve(token_address: "0x4200000000000000000000000000000000000006", spender_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", amount: "max_uint256", chain_id: 8453)
167
+ write.repay(
168
168
  pool_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", // WETH pool
169
169
  account_address: <account>,
170
170
  amount: "<raw_weth_amount_in_wei>", // e.g. "100000000000000000" = 0.1 WETH
@@ -172,7 +172,7 @@ build_repay_tx(
172
172
  )
173
173
 
174
174
  // Option C: Atomic sell USDC collateral → repay WETH debt (one flash tx, no wallet WETH needed)
175
- build_repay_with_collateral_tx(
175
+ advanced.repay_with_collateral(
176
176
  account_address: <account>,
177
177
  asset_from: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // sell USDC from account
178
178
  amount_in: "<usdc_amount_to_sell>", // collateral amount to sell (input side, NOT debt amount)
@@ -191,7 +191,7 @@ build_repay_with_collateral_tx(
191
191
 
192
192
  ```
193
193
  // 0. Disable automation first (prevents rebalancer from acting during close)
194
- build_set_asset_manager_tx(
194
+ write.set_asset_manager(
195
195
  account_address: <account>,
196
196
  asset_manager_address: "0x953Ff365d0b562ceC658dc46B394E9282338d9Ea",
197
197
  enabled: false,
@@ -199,13 +199,13 @@ build_set_asset_manager_tx(
199
199
  )
200
200
 
201
201
  // 1. Get account state — need asset list for the close call
202
- get_account_info(account_address: <account>, chain_id: 8453)
202
+ read.account_info(account_address: <account>, chain_id: 8453)
203
203
 
204
204
  // 2. Unstake if staked (required before close)
205
- build_position_action_tx(action: "unstake", asset_address: <staked_pm_address>, asset_id: <nft_id>, account_address: <account>, chain_id: 8453)
205
+ advanced.position_action(action: "unstake", asset_address: <staked_pm_address>, asset_id: <nft_id>, account_address: <account>, chain_id: 8453)
206
206
 
207
207
  // 3. Atomic close: burns LP + swaps all tokens to USDC + repays debt — ONE transaction
208
- build_close_position_tx(
208
+ advanced.close_position(
209
209
  account_address: <account>,
210
210
  assets: [
211
211
  { asset_address: "<position_manager>", asset_id: <nft_id>, amount: "1", decimals: 1 }
@@ -216,7 +216,7 @@ build_close_position_tx(
216
216
  )
217
217
 
218
218
  // 4. Withdraw remaining assets to wallet
219
- build_withdraw_tx(
219
+ write.withdraw(
220
220
  account_address: <account>,
221
221
  asset_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],
222
222
  asset_amounts: ["<balance>"],
@@ -228,19 +228,19 @@ build_withdraw_tx(
228
228
 
229
229
  If the full atomic close fails, split into two steps:
230
230
 
231
- 1. `build_close_position_tx(close_lp_only=true)` — burns LP only, tokens stay in account
232
- 2. Then use individual tools: `build_repay_with_collateral_tx` → `build_withdraw_tx`
231
+ 1. `advanced.close_position(close_lp_only=true)` — burns LP only, tokens stay in account
232
+ 2. Then use individual tools: `advanced.repay_with_collateral` → `write.withdraw`
233
233
 
234
234
  #### Last resort: Manual step-by-step
235
235
 
236
236
  Only if both atomic approaches fail:
237
237
 
238
238
  ```
239
- build_position_action_tx(action: "claim", ...) // claim fees
240
- build_remove_liquidity_tx(adjustment: <amount>) // partial decrease
241
- build_repay_with_collateral_tx(...) // swap collateral → repay debt
242
- build_repay_tx(amount: "max_uint256") // repay remaining from wallet
243
- build_withdraw_tx(...) // withdraw all to wallet
239
+ advanced.position_action(action: "claim", ...) // claim fees
240
+ advanced.remove_liquidity(adjustment: <amount>) // partial decrease
241
+ advanced.repay_with_collateral(...) // swap collateral → repay debt
242
+ write.repay(amount: "max_uint256") // repay remaining from wallet
243
+ write.withdraw(...) // withdraw all to wallet
244
244
  ```
245
245
 
246
246
  **Key risks:**
@@ -283,23 +283,23 @@ The `protocol_owned_liquidity` strategy type uses a dynamic range algorithm (k1/
283
283
  // Same tools, different intent — no leverage, wider slippage tolerance
284
284
 
285
285
  // 1. Check allowance + approve treasury tokens (skip approve if already sufficient)
286
- get_allowance(owner_address: <treasury_wallet>, spender_address: <account>, token_addresses: [<token>], chain_id: 8453)
287
- build_approve_tx(token_address: <token>, spender_address: <account>, amount: "max_uint256", chain_id: 8453)
286
+ read.allowance(owner_address: <treasury_wallet>, spender_address: <account>, token_addresses: [<token>], chain_id: 8453)
287
+ write.approve(token_address: <token>, spender_address: <account>, amount: "max_uint256", chain_id: 8453)
288
288
 
289
289
  // 2. Create account (separate from retail positions)
290
290
  // For POL without leverage, a spot account (V4) works fine.
291
291
  // Use V3 + creditor only if you want the option to leverage later.
292
- build_create_account_tx(
292
+ write.create_account(
293
293
  salt: <random uint32>,
294
294
  account_version: 0, // V4 spot — no leverage needed for POL
295
295
  chain_id: 8453
296
296
  )
297
297
 
298
298
  // 3. Deposit treasury tokens
299
- build_deposit_tx(account_address: <account>, ...)
299
+ write.deposit(account_address: <account>, ...)
300
300
 
301
301
  // 4. Open LP (no leverage — deposits are pulled from wallet)
302
- build_add_liquidity_tx(
302
+ advanced.add_liquidity(
303
303
  account_address: <account>,
304
304
  wallet_address: <treasury_wallet>,
305
305
  positions: [{ strategy_id: <from step 1> }],
@@ -310,7 +310,7 @@ build_add_liquidity_tx(
310
310
  )
311
311
 
312
312
  // 5. Enable rebalancer with POL strategy hook
313
- build_configure_asset_manager_tx(
313
+ write.configure_asset_manager(
314
314
  account_address: <account>,
315
315
  asset_manager_address: <rebalancer matching LP protocol>,
316
316
  am_type: "rebalancer",
@@ -329,11 +329,11 @@ build_configure_asset_manager_tx(
329
329
  ### Monitoring for POL
330
330
 
331
331
  ```
332
- get_account_info → verify position is in range (primary check — no liquidation risk since no leverage)
333
- get_account_pnl → track IL vs. fee income
332
+ read.account_info → verify position is in range (primary check — no liquidation risk since no leverage)
333
+ read.account_pnl → track IL vs. fee income
334
334
  Note: net negative IL is EXPECTED and ACCEPTABLE for POL
335
335
  The treasury is "paying" for market liquidity
336
- get_recommendation → check if rebalancing is needed
336
+ read.recommendation → check if rebalancing is needed
337
337
  ```
338
338
 
339
339
  **POL monitoring goal:** Ensure sufficient liquidity is deployed and treasury capital is not eroding excessively — not maximizing return.