@arcadia-finance/mcp-server 0.1.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.
Files changed (59) hide show
  1. package/LICENSE.md +97 -0
  2. package/README.md +186 -0
  3. package/dist/abis/account.json +1012 -0
  4. package/dist/abis/account_v4.json +1027 -0
  5. package/dist/abis/chainlink.json +509 -0
  6. package/dist/abis/erc20.json +299 -0
  7. package/dist/abis/factory.json +938 -0
  8. package/dist/abis/gauge_helper.json +84 -0
  9. package/dist/abis/index.js +26 -0
  10. package/dist/abis/mainreg.json +1172 -0
  11. package/dist/abis/nftmanager.json +1221 -0
  12. package/dist/abis/nftmanager_v4.json +1297 -0
  13. package/dist/abis/pool.json +2136 -0
  14. package/dist/abis/slipstream_nftmanager.json +1312 -0
  15. package/dist/abis/staked_aero_am.json +1220 -0
  16. package/dist/abis/staked_slipstream_am.json +1131 -0
  17. package/dist/abis/state_viewer.json +365 -0
  18. package/dist/abis/tranche.json +1004 -0
  19. package/dist/abis/wrapped_aero_am.json +1232 -0
  20. package/dist/abis/wrapped_staked_slipstream_am.json +338 -0
  21. package/dist/clients/api.js +189 -0
  22. package/dist/clients/chain.js +30 -0
  23. package/dist/config/addresses.js +94 -0
  24. package/dist/config/chains.js +31 -0
  25. package/dist/index.js +29 -0
  26. package/dist/skills/clamm-liquidity/SKILL.md +167 -0
  27. package/dist/skills/clamm-liquidity/automation.md +138 -0
  28. package/dist/skills/clamm-liquidity/selection.md +183 -0
  29. package/dist/skills/clamm-liquidity/strategies.md +337 -0
  30. package/dist/tools/advanced/account-metadata.js +46 -0
  31. package/dist/tools/advanced/add-liquidity.js +310 -0
  32. package/dist/tools/advanced/close-position.js +208 -0
  33. package/dist/tools/advanced/format-response.js +26 -0
  34. package/dist/tools/advanced/position-actions.js +95 -0
  35. package/dist/tools/advanced/remove-liquidity.js +68 -0
  36. package/dist/tools/advanced/repay-with-collateral.js +66 -0
  37. package/dist/tools/advanced/swap.js +64 -0
  38. package/dist/tools/index.js +52 -0
  39. package/dist/tools/read/accounts.js +243 -0
  40. package/dist/tools/read/allowances.js +86 -0
  41. package/dist/tools/read/assets.js +54 -0
  42. package/dist/tools/read/balances.js +93 -0
  43. package/dist/tools/read/guides.js +59 -0
  44. package/dist/tools/read/points.js +25 -0
  45. package/dist/tools/read/pools.js +48 -0
  46. package/dist/tools/read/protocol.js +94 -0
  47. package/dist/tools/write/approve.js +99 -0
  48. package/dist/tools/write/borrow.js +87 -0
  49. package/dist/tools/write/configure-asset-manager.js +258 -0
  50. package/dist/tools/write/create-account.js +112 -0
  51. package/dist/tools/write/deposit.js +104 -0
  52. package/dist/tools/write/repay.js +56 -0
  53. package/dist/tools/write/set-asset-manager.js +65 -0
  54. package/dist/tools/write/sign-and-send.js +90 -0
  55. package/dist/tools/write/withdraw.js +114 -0
  56. package/dist/types/api.js +5 -0
  57. package/dist/utils/attribution.js +20 -0
  58. package/dist/utils/validation.js +17 -0
  59. package/package.json +67 -0
@@ -0,0 +1,337 @@
1
+ # Strategy Templates
2
+
3
+ These are templates and examples — not the only valid approaches. Adapt parameters to current conditions. Use selection.md to evaluate whether a strategy fits before executing.
4
+
5
+ ## Key Parameter Notes
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`).
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.
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.
18
+
19
+ ---
20
+
21
+ ## Core Lifecycle (all strategies)
22
+
23
+ ```
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)
26
+ Adjust: add collateral or repay debt if health drops; remove + re-add liquidity to manually rebalance range
27
+ Close: disable rebalancer → unstake → atomic close (burn LP + swap + repay) → withdraw
28
+ ```
29
+
30
+ ### Batching vs splitting
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.
33
+
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
+
36
+ ---
37
+
38
+ ## Strategy A: Delta Neutral Leveraged LP
39
+
40
+ **Goal:** Earn LP trading fees with minimal directional exposure to the volatile asset.
41
+
42
+ **Mechanism:** In a VOLATILE/STABLE pool (e.g., WETH/USDC), borrow the volatile asset (WETH) to fund the LP position. Your LP long exposure ≈ your debt short exposure → approximately delta neutral.
43
+
44
+ **Why it works:**
45
+
46
+ - LP position is ~50% WETH, ~50% USDC by value at any given price
47
+ - You borrow WETH to provide it → WETH debt ≈ WETH held in LP
48
+ - Net WETH exposure ≈ 0 (small residual from IL)
49
+ - You earn LP fees on the full leveraged notional
50
+
51
+ **Preconditions:** `fee_APY > borrow_APY` (check selection.md §1)
52
+
53
+ ### Step-by-step
54
+
55
+ ```
56
+ // 1. FIND A POOL
57
+ get_strategies(chain_id: 8453)
58
+ → Filter for volatile/stable pair (WETH/USDC, cbBTC/USDC, etc.)
59
+ → Note: strategy_id (integer), pool_protocol (Slipstream V1/V2, UniV3, UniV4), fee_APY
60
+
61
+ // 2. CHECK BORROW COST
62
+ get_lending_pools(chain_id: 8453)
63
+ → Find the WETH lending pool (address: 0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2)
64
+ → If borrow_apy > fee_apy → stop, strategy not profitable
65
+
66
+ // 3. CREATE MARGIN ACCOUNT (V3 + creditor = can borrow/leverage)
67
+ build_create_account_tx(
68
+ salt: <random uint32, e.g. 3141592653>,
69
+ account_version: 3, // V3 margin — required for leverage
70
+ creditor: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", // WETH lending pool — enables borrow
71
+ chain_id: 8453
72
+ )
73
+ → Submit tx, note deployed account address from tx receipt
74
+ → Or call get_account_info(wallet_address: ...) to find the new account address
75
+
76
+ // 4. CHECK ALLOWANCE + APPROVE (skip approve if already sufficient)
77
+ get_allowance(
78
+ owner_address: <owner_wallet>,
79
+ spender_address: <account_address>,
80
+ token_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], // USDC
81
+ chain_id: 8453
82
+ )
83
+ // → If allowance is insufficient or zero:
84
+ build_approve_tx(
85
+ token_address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC
86
+ spender_address: <account_address>,
87
+ amount: "max_uint256",
88
+ chain_id: 8453
89
+ )
90
+
91
+ // 5. OPEN LEVERAGED LP (atomic: pull USDC from wallet + borrow WETH + swap to ratio + mint LP)
92
+ // No separate build_deposit_tx needed — build_add_liquidity_tx handles the wallet transfer atomically.
93
+ build_add_liquidity_tx(
94
+ account_address: <account_address>,
95
+ wallet_address: <owner_wallet>,
96
+ positions: [{ strategy_id: <integer from step 1> }],
97
+ deposits: [{ asset: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", amount: "10000000000", decimals: 6 }], // 10,000 USDC — pulled from wallet
98
+ leverage: 2, // 2 = 2x leverage (0 = no leverage, 3 = 3x, etc.)
99
+ slippage: 100, // 100 = 1% slippage tolerance (basis points)
100
+ chain_id: 8453
101
+ )
102
+
103
+ // 6. ENABLE AND CONFIGURE REBALANCER (match address to LP protocol from step 1)
104
+ build_configure_asset_manager_tx(
105
+ account_address: <account_address>,
106
+ asset_manager_address: "0x953Ff365d0b562ceC658dc46B394E9282338d9Ea", // Slipstream V2
107
+ am_type: "rebalancer",
108
+ trigger_lower_ratio: 0, // 0 = trigger exactly at boundary. Values scaled by 1e6: 50000 = 5% before boundary
109
+ trigger_upper_ratio: 0, // same as above — must be integer
110
+ compound_leftovers: "all", // "all" | "none" | "token0" | "token1"
111
+ min_rebalance_time: 3600, // minimum seconds between rebalances (3600 = 1 hour)
112
+ chain_id: 8453
113
+ )
114
+ // → Range width and reposition mode must be configured in the Arcadia platform
115
+
116
+ // 7. ENABLE MERKL (if pool has Merkl incentives — check fee APY breakdown in step 1)
117
+ build_configure_asset_manager_tx(
118
+ account_address: <account_address>,
119
+ asset_manager_address: "0x969F0251360b9Cf11c68f6Ce9587924c1B8b42C6",
120
+ am_type: "merkl_operator",
121
+ reward_recipient: <owner_wallet>,
122
+ chain_id: 8453
123
+ )
124
+ ```
125
+
126
+ ### Monitoring
127
+
128
+ ```
129
+ // Run periodically (daily or on request)
130
+ get_account_info(account_address: <account_address>, chain_id: 8453)
131
+ → health_factor = 1 - (used_margin / liquidation_value). Higher = safer.
132
+ 1 → no debt (safest)
133
+ > 0.5 → healthy
134
+ 0.2–0.5 → monitor closely, consider adding collateral or reducing debt
135
+ < 0.2 → ACTION REQUIRED — close to liquidation
136
+ 0 → liquidation threshold
137
+ < 0 → past liquidation
138
+
139
+ Note: Each lending pool adds a fixed minimum margin (denominated in the pool's numeraire,
140
+ typically a few dollars in value) to the debt when computing used_margin
141
+ (used_margin = open_debt + minimum_margin). For small positions this fixed overhead
142
+ dominates, pushing HF lower than the leverage ratio suggests — e.g. HF ~0.3 at 2×
143
+ instead of ~0.5–0.7. Increase position size for a healthier starting HF.
144
+
145
+ get_account_pnl(account_address: <account_address>, chain_id: 8453)
146
+ → If net yield is consistently negative → evaluate exit
147
+
148
+ get_lending_pools(chain_id: 8453)
149
+ → If borrow_APY risen above fee_APY → exit signal
150
+ ```
151
+
152
+ ### Responding to health factor drops
153
+
154
+ ```
155
+ // Option A: Add collateral (raises health factor, cheapest)
156
+ // Check allowance first — skip approve if already sufficient
157
+ get_allowance(owner_address: <wallet>, spender_address: <account>, token_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], chain_id: 8453)
158
+ build_approve_tx(token_address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", spender_address: <account>, amount: "max_uint256", chain_id: 8453)
159
+ build_deposit_tx(account_address: <account>, asset_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"], asset_amounts: ["<amount>"], chain_id: 8453)
160
+
161
+ // Option B: Repay some WETH debt (reduces leverage)
162
+ // NOTE: you must approve the WETH pool to spend WETH from your wallet first — check allowance, then approve if needed
163
+ get_allowance(owner_address: <wallet>, spender_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", token_addresses: ["0x4200000000000000000000000000000000000006"], chain_id: 8453)
164
+ build_approve_tx(token_address: "0x4200000000000000000000000000000000000006", spender_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", amount: "max_uint256", chain_id: 8453)
165
+ build_repay_tx(
166
+ pool_address: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", // WETH pool
167
+ account_address: <account>,
168
+ amount: "<raw_weth_amount_in_wei>", // e.g. "100000000000000000" = 0.1 WETH
169
+ chain_id: 8453
170
+ )
171
+
172
+ // Option C: Atomic sell USDC collateral → repay WETH debt (one flash tx, no wallet WETH needed)
173
+ build_repay_with_collateral_tx(
174
+ account_address: <account>,
175
+ asset_from: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // sell USDC from account
176
+ amount_in: "<usdc_amount_to_sell>", // collateral amount to sell (input side, NOT debt amount)
177
+ numeraire: "0x4200000000000000000000000000000000000006", // WETH = debt token being repaid (NOT the stable side here)
178
+ creditor: "0x803ea69c7e87D1d6C86adeB40CB636cC0E6B98E2", // WETH lending pool
179
+ slippage: 100,
180
+ chain_id: 8453
181
+ )
182
+ ```
183
+
184
+ ### Closing
185
+
186
+ **ALWAYS try the atomic close first** — it batches everything into 1-2 transactions instead of 6+.
187
+
188
+ #### Preferred: Atomic close (1-2 transactions)
189
+
190
+ ```
191
+ // 0. Disable automation first (prevents rebalancer from acting during close)
192
+ build_set_asset_manager_tx(
193
+ account_address: <account>,
194
+ asset_manager_address: "0x953Ff365d0b562ceC658dc46B394E9282338d9Ea",
195
+ enabled: false,
196
+ chain_id: 8453
197
+ )
198
+
199
+ // 1. Get account state — need asset list for the close call
200
+ get_account_info(account_address: <account>, chain_id: 8453)
201
+
202
+ // 2. Unstake if staked (required before close)
203
+ build_position_action_tx(action: "unstake", asset_address: <staked_pm_address>, asset_id: <nft_id>, account_address: <account>, chain_id: 8453)
204
+
205
+ // 3. Atomic close: burns LP + swaps all tokens to USDC + repays debt — ONE transaction
206
+ build_close_position_tx(
207
+ account_address: <account>,
208
+ assets: [
209
+ { asset_address: "<position_manager>", asset_id: <nft_id>, amount: "1", decimals: 1 }
210
+ ],
211
+ receive_assets: [{ asset_address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", decimals: 6 }], // receive USDC
212
+ slippage: 100,
213
+ chain_id: 8453
214
+ )
215
+
216
+ // 4. Withdraw remaining assets to wallet
217
+ build_withdraw_tx(
218
+ account_address: <account>,
219
+ asset_addresses: ["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],
220
+ asset_amounts: ["<balance>"],
221
+ chain_id: 8453
222
+ )
223
+ ```
224
+
225
+ #### Fallback: Two-step close (if atomic fails)
226
+
227
+ If the full atomic close fails, split into two steps:
228
+
229
+ 1. `build_close_position_tx(close_lp_only=true)` — burns LP only, tokens stay in account
230
+ 2. Then use individual tools: `build_repay_with_collateral_tx` → `build_withdraw_tx`
231
+
232
+ #### Last resort: Manual step-by-step
233
+
234
+ Only if both atomic approaches fail:
235
+
236
+ ```
237
+ build_position_action_tx(action: "claim", ...) // claim fees
238
+ build_remove_liquidity_tx(adjustment: <amount>) // partial decrease
239
+ build_repay_with_collateral_tx(...) // swap collateral → repay debt
240
+ build_repay_tx(amount: "max_uint256") // repay remaining from wallet
241
+ build_withdraw_tx(...) // withdraw all to wallet
242
+ ```
243
+
244
+ **Key risks:**
245
+
246
+ - IL: WETH price deviation from entry accumulates IL. Rebalancer mitigates but doesn't eliminate.
247
+ - Liquidation: If WETH pumps sharply, health factor drops toward 0. Keep health factor above 0.5.
248
+ - Borrow cost: WETH utilization spikes can make strategy unprofitable quickly.
249
+ - Agent role: periodic health monitoring only — the rebalancer handles range management.
250
+
251
+ ---
252
+
253
+ ## Strategy B: Protocol Owned Liquidity (POL)
254
+
255
+ **IMPORTANT: Different objective.** POL is NOT a yield-maximizing strategy. It prioritizes capital preservation and reliable market liquidity provision.
256
+
257
+ **Who uses it:** DAOs, protocols, and treasuries that need to:
258
+
259
+ - Maintain consistent liquidity for their token pair at all times
260
+ - Protect treasury capital from large IL
261
+ - Provide deep liquidity to traders regardless of yield
262
+
263
+ ### How POL differs from retail LP
264
+
265
+ | Dimension | Retail (delta neutral) | Protocol Owned Liquidity |
266
+ | -------------- | -------------------------- | ------------------------------------ |
267
+ | Objective | Maximize fees + yield | Reliable market presence |
268
+ | Range | Narrow (high fee capture) | Wide or dynamic (capital protection) |
269
+ | Rebalancing | Aggressive (stay in range) | Conservative (minimize cost) |
270
+ | Leverage | Yes | No — protect principal |
271
+ | IL tolerance | Moderate (offset by fees) | Low — preserving treasury |
272
+ | Success metric | Fee APY > borrow APY | Liquidity depth maintained |
273
+
274
+ ### POL rebalancer behavior
275
+
276
+ The `protocol_owned_liquidity` strategy type uses a dynamic range algorithm (k1/k2 coefficients) that adjusts range width based on price deviation. It maintains a "base range" for core liquidity plus a "limit order" component for excess. The rebalance threshold determines how far price must move before repositioning. This results in fewer rebalances (lower cost) at the expense of occasionally being partially out-of-range.
277
+
278
+ ### Setup
279
+
280
+ ```
281
+ // Same tools, different intent — no leverage, wider slippage tolerance
282
+
283
+ // 1. Check allowance + approve treasury tokens (skip approve if already sufficient)
284
+ get_allowance(owner_address: <treasury_wallet>, spender_address: <account>, token_addresses: [<token>], chain_id: 8453)
285
+ build_approve_tx(token_address: <token>, spender_address: <account>, amount: "max_uint256", chain_id: 8453)
286
+
287
+ // 2. Create account (separate from retail positions)
288
+ // For POL without leverage, a spot account (V4) works fine.
289
+ // Use V3 + creditor only if you want the option to leverage later.
290
+ build_create_account_tx(
291
+ salt: <random uint32>,
292
+ account_version: 0, // V4 spot — no leverage needed for POL
293
+ chain_id: 8453
294
+ )
295
+
296
+ // 3. Deposit treasury tokens
297
+ build_deposit_tx(account_address: <account>, ...)
298
+
299
+ // 4. Open LP (no leverage — deposits are pulled from wallet)
300
+ build_add_liquidity_tx(
301
+ account_address: <account>,
302
+ wallet_address: <treasury_wallet>,
303
+ positions: [{ strategy_id: <from step 1> }],
304
+ deposits: [{ asset: <token_address>, amount: <raw_amount>, decimals: <decimals> }],
305
+ leverage: 0, // 0 = no leverage (NOT 1 — use 0 for unleveraged)
306
+ slippage: 200, // 2% — wider tolerance for POL
307
+ chain_id: 8453
308
+ )
309
+
310
+ // 5. Enable rebalancer with POL strategy hook
311
+ build_configure_asset_manager_tx(
312
+ account_address: <account>,
313
+ asset_manager_address: <rebalancer matching LP protocol>,
314
+ am_type: "rebalancer",
315
+ strategy_hook: "0x13beD1A58d87c0454872656c5328103aAe5eB86A", // POL dynamic range algorithm
316
+ trigger_lower_ratio: 0,
317
+ trigger_upper_ratio: 0,
318
+ compound_leftovers: "all",
319
+ min_rebalance_time: 3600,
320
+ chain_id: 8453
321
+ )
322
+ // → POL tuning params (base_range, k1, k2, rebalance_threshold) configured in Arcadia platform
323
+ ```
324
+
325
+ **MCP limitation:** POL tuning parameters are configured in the Arcadia platform backend, not via MCP tools. Agents can deploy and enable the rebalancer contract, but specific POL parameterization requires platform access.
326
+
327
+ ### Monitoring for POL
328
+
329
+ ```
330
+ get_account_info → verify position is in range (primary check — no liquidation risk since no leverage)
331
+ get_account_pnl → track IL vs. fee income
332
+ Note: net negative IL is EXPECTED and ACCEPTABLE for POL
333
+ The treasury is "paying" for market liquidity
334
+ get_recommendation → check if rebalancing is needed
335
+ ```
336
+
337
+ **POL monitoring goal:** Ensure sufficient liquidity is deployed and treasury capital is not eroding excessively — not maximizing return.
@@ -0,0 +1,46 @@
1
+ const OWNER_ABI = [
2
+ {
3
+ type: "function",
4
+ name: "owner",
5
+ inputs: [],
6
+ outputs: [{ type: "address" }],
7
+ stateMutability: "view",
8
+ },
9
+ ];
10
+ const CREDITOR_ABI = [
11
+ {
12
+ type: "function",
13
+ name: "creditor",
14
+ inputs: [],
15
+ outputs: [{ type: "address" }],
16
+ stateMutability: "view",
17
+ },
18
+ ];
19
+ const NUMERAIRE_ABI = [
20
+ {
21
+ type: "function",
22
+ name: "numeraire",
23
+ inputs: [],
24
+ outputs: [{ type: "address" }],
25
+ stateMutability: "view",
26
+ },
27
+ ];
28
+ const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
29
+ // Reads owner, creditor, numeraire on-chain via multicall.
30
+ // Used as fallback when getAccountOverview fails.
31
+ export async function readAccountMetadata(client, accountAddress) {
32
+ const results = await client.multicall({
33
+ contracts: [
34
+ { address: accountAddress, abi: OWNER_ABI, functionName: "owner" },
35
+ { address: accountAddress, abi: CREDITOR_ABI, functionName: "creditor" },
36
+ { address: accountAddress, abi: NUMERAIRE_ABI, functionName: "numeraire" },
37
+ ],
38
+ allowFailure: true,
39
+ });
40
+ return {
41
+ owner: results[0].status === "success" ? results[0].result : ZERO_ADDRESS,
42
+ creditor: results[1].status === "success" ? results[1].result : ZERO_ADDRESS,
43
+ numeraire: results[2].status === "success" ? results[2].result : ZERO_ADDRESS,
44
+ };
45
+ }
46
+ //# sourceMappingURL=account-metadata.js.map