recon-crypto-mcp 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 (204) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +153 -0
  3. package/dist/abis/aave-pool.d.ts +174 -0
  4. package/dist/abis/aave-pool.js +101 -0
  5. package/dist/abis/aave-pool.js.map +1 -0
  6. package/dist/abis/aave-ui-pool-data-provider.d.ts +232 -0
  7. package/dist/abis/aave-ui-pool-data-provider.js +107 -0
  8. package/dist/abis/aave-ui-pool-data-provider.js.map +1 -0
  9. package/dist/abis/access-control.d.ts +94 -0
  10. package/dist/abis/access-control.js +51 -0
  11. package/dist/abis/access-control.js.map +1 -0
  12. package/dist/abis/compound-comet.d.ts +120 -0
  13. package/dist/abis/compound-comet.js +84 -0
  14. package/dist/abis/compound-comet.js.map +1 -0
  15. package/dist/abis/eigenlayer-delegation-manager.d.ts +23 -0
  16. package/dist/abis/eigenlayer-delegation-manager.js +18 -0
  17. package/dist/abis/eigenlayer-delegation-manager.js.map +1 -0
  18. package/dist/abis/eigenlayer-strategy-manager.d.ts +53 -0
  19. package/dist/abis/eigenlayer-strategy-manager.js +47 -0
  20. package/dist/abis/eigenlayer-strategy-manager.js.map +1 -0
  21. package/dist/abis/erc20.d.ts +78 -0
  22. package/dist/abis/erc20.js +10 -0
  23. package/dist/abis/erc20.js.map +1 -0
  24. package/dist/abis/lido.d.ts +80 -0
  25. package/dist/abis/lido.js +60 -0
  26. package/dist/abis/lido.js.map +1 -0
  27. package/dist/abis/morpho-blue.d.ts +321 -0
  28. package/dist/abis/morpho-blue.js +193 -0
  29. package/dist/abis/morpho-blue.js.map +1 -0
  30. package/dist/abis/uniswap-pool.d.ts +70 -0
  31. package/dist/abis/uniswap-pool.js +53 -0
  32. package/dist/abis/uniswap-pool.js.map +1 -0
  33. package/dist/abis/uniswap-position-manager.d.ts +71 -0
  34. package/dist/abis/uniswap-position-manager.js +41 -0
  35. package/dist/abis/uniswap-position-manager.js.map +1 -0
  36. package/dist/config/cache.d.ts +12 -0
  37. package/dist/config/cache.js +12 -0
  38. package/dist/config/cache.js.map +1 -0
  39. package/dist/config/chains.d.ts +24 -0
  40. package/dist/config/chains.js +158 -0
  41. package/dist/config/chains.js.map +1 -0
  42. package/dist/config/contracts.d.ts +107 -0
  43. package/dist/config/contracts.js +123 -0
  44. package/dist/config/contracts.js.map +1 -0
  45. package/dist/config/user-config.d.ts +15 -0
  46. package/dist/config/user-config.js +93 -0
  47. package/dist/config/user-config.js.map +1 -0
  48. package/dist/data/apis/etherscan.d.ts +30 -0
  49. package/dist/data/apis/etherscan.js +109 -0
  50. package/dist/data/apis/etherscan.js.map +1 -0
  51. package/dist/data/cache.d.ts +18 -0
  52. package/dist/data/cache.js +47 -0
  53. package/dist/data/cache.js.map +1 -0
  54. package/dist/data/format.d.ts +6 -0
  55. package/dist/data/format.js +44 -0
  56. package/dist/data/format.js.map +1 -0
  57. package/dist/data/prices.d.ts +12 -0
  58. package/dist/data/prices.js +81 -0
  59. package/dist/data/prices.js.map +1 -0
  60. package/dist/data/rpc.d.ts +17 -0
  61. package/dist/data/rpc.js +68 -0
  62. package/dist/data/rpc.js.map +1 -0
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.js +344 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/modules/balances/index.d.ts +20 -0
  67. package/dist/modules/balances/index.js +49 -0
  68. package/dist/modules/balances/index.js.map +1 -0
  69. package/dist/modules/balances/schemas.d.ts +32 -0
  70. package/dist/modules/balances/schemas.js +21 -0
  71. package/dist/modules/balances/schemas.js.map +1 -0
  72. package/dist/modules/bitcoin/index.d.ts +26 -0
  73. package/dist/modules/bitcoin/index.js +128 -0
  74. package/dist/modules/bitcoin/index.js.map +1 -0
  75. package/dist/modules/bitcoin/schemas.d.ts +49 -0
  76. package/dist/modules/bitcoin/schemas.js +51 -0
  77. package/dist/modules/bitcoin/schemas.js.map +1 -0
  78. package/dist/modules/bitcoin/send.d.ts +52 -0
  79. package/dist/modules/bitcoin/send.js +158 -0
  80. package/dist/modules/bitcoin/send.js.map +1 -0
  81. package/dist/modules/bitcoin/utxo.d.ts +99 -0
  82. package/dist/modules/bitcoin/utxo.js +116 -0
  83. package/dist/modules/bitcoin/utxo.js.map +1 -0
  84. package/dist/modules/compound/actions.d.ts +8 -0
  85. package/dist/modules/compound/actions.js +154 -0
  86. package/dist/modules/compound/actions.js.map +1 -0
  87. package/dist/modules/compound/index.d.ts +26 -0
  88. package/dist/modules/compound/index.js +141 -0
  89. package/dist/modules/compound/index.js.map +1 -0
  90. package/dist/modules/compound/schemas.d.ts +95 -0
  91. package/dist/modules/compound/schemas.js +37 -0
  92. package/dist/modules/compound/schemas.js.map +1 -0
  93. package/dist/modules/execution/index.d.ts +51 -0
  94. package/dist/modules/execution/index.js +271 -0
  95. package/dist/modules/execution/index.js.map +1 -0
  96. package/dist/modules/execution/schemas.d.ts +183 -0
  97. package/dist/modules/execution/schemas.js +88 -0
  98. package/dist/modules/execution/schemas.js.map +1 -0
  99. package/dist/modules/feedback/index.d.ts +28 -0
  100. package/dist/modules/feedback/index.js +161 -0
  101. package/dist/modules/feedback/index.js.map +1 -0
  102. package/dist/modules/feedback/rate-limit.d.ts +15 -0
  103. package/dist/modules/feedback/rate-limit.js +110 -0
  104. package/dist/modules/feedback/rate-limit.js.map +1 -0
  105. package/dist/modules/feedback/schemas.d.ts +41 -0
  106. package/dist/modules/feedback/schemas.js +40 -0
  107. package/dist/modules/feedback/schemas.js.map +1 -0
  108. package/dist/modules/morpho/actions.d.ts +8 -0
  109. package/dist/modules/morpho/actions.js +265 -0
  110. package/dist/modules/morpho/actions.js.map +1 -0
  111. package/dist/modules/morpho/index.d.ts +26 -0
  112. package/dist/modules/morpho/index.js +94 -0
  113. package/dist/modules/morpho/index.js.map +1 -0
  114. package/dist/modules/morpho/schemas.d.ts +130 -0
  115. package/dist/modules/morpho/schemas.js +34 -0
  116. package/dist/modules/morpho/schemas.js.map +1 -0
  117. package/dist/modules/portfolio/index.d.ts +3 -0
  118. package/dist/modules/portfolio/index.js +197 -0
  119. package/dist/modules/portfolio/index.js.map +1 -0
  120. package/dist/modules/portfolio/schemas.d.ts +20 -0
  121. package/dist/modules/portfolio/schemas.js +15 -0
  122. package/dist/modules/portfolio/schemas.js.map +1 -0
  123. package/dist/modules/positions/aave.d.ts +22 -0
  124. package/dist/modules/positions/aave.js +197 -0
  125. package/dist/modules/positions/aave.js.map +1 -0
  126. package/dist/modules/positions/actions.d.ts +18 -0
  127. package/dist/modules/positions/actions.js +205 -0
  128. package/dist/modules/positions/actions.js.map +1 -0
  129. package/dist/modules/positions/index.d.ts +37 -0
  130. package/dist/modules/positions/index.js +59 -0
  131. package/dist/modules/positions/index.js.map +1 -0
  132. package/dist/modules/positions/schemas.d.ts +55 -0
  133. package/dist/modules/positions/schemas.js +25 -0
  134. package/dist/modules/positions/schemas.js.map +1 -0
  135. package/dist/modules/positions/uniswap.d.ts +4 -0
  136. package/dist/modules/positions/uniswap.js +181 -0
  137. package/dist/modules/positions/uniswap.js.map +1 -0
  138. package/dist/modules/prices/index.d.ts +19 -0
  139. package/dist/modules/prices/index.js +22 -0
  140. package/dist/modules/prices/index.js.map +1 -0
  141. package/dist/modules/security/index.d.ts +26 -0
  142. package/dist/modules/security/index.js +13 -0
  143. package/dist/modules/security/index.js.map +1 -0
  144. package/dist/modules/security/permissions.d.ts +8 -0
  145. package/dist/modules/security/permissions.js +96 -0
  146. package/dist/modules/security/permissions.js.map +1 -0
  147. package/dist/modules/security/risk-score.d.ts +18 -0
  148. package/dist/modules/security/risk-score.js +116 -0
  149. package/dist/modules/security/risk-score.js.map +1 -0
  150. package/dist/modules/security/schemas.d.ts +31 -0
  151. package/dist/modules/security/schemas.js +16 -0
  152. package/dist/modules/security/schemas.js.map +1 -0
  153. package/dist/modules/security/verification.d.ts +4 -0
  154. package/dist/modules/security/verification.js +82 -0
  155. package/dist/modules/security/verification.js.map +1 -0
  156. package/dist/modules/shared/approval.d.ts +71 -0
  157. package/dist/modules/shared/approval.js +130 -0
  158. package/dist/modules/shared/approval.js.map +1 -0
  159. package/dist/modules/staking/actions.d.ts +22 -0
  160. package/dist/modules/staking/actions.js +100 -0
  161. package/dist/modules/staking/actions.js.map +1 -0
  162. package/dist/modules/staking/eigenlayer.d.ts +14 -0
  163. package/dist/modules/staking/eigenlayer.js +105 -0
  164. package/dist/modules/staking/eigenlayer.js.map +1 -0
  165. package/dist/modules/staking/index.d.ts +24 -0
  166. package/dist/modules/staking/index.js +59 -0
  167. package/dist/modules/staking/index.js.map +1 -0
  168. package/dist/modules/staking/lido.d.ts +14 -0
  169. package/dist/modules/staking/lido.js +113 -0
  170. package/dist/modules/staking/lido.js.map +1 -0
  171. package/dist/modules/staking/schemas.d.ts +34 -0
  172. package/dist/modules/staking/schemas.js +20 -0
  173. package/dist/modules/staking/schemas.js.map +1 -0
  174. package/dist/modules/swap/index.d.ts +47 -0
  175. package/dist/modules/swap/index.js +376 -0
  176. package/dist/modules/swap/index.js.map +1 -0
  177. package/dist/modules/swap/lifi.d.ts +17 -0
  178. package/dist/modules/swap/lifi.js +44 -0
  179. package/dist/modules/swap/lifi.js.map +1 -0
  180. package/dist/modules/swap/oneinch.d.ts +26 -0
  181. package/dist/modules/swap/oneinch.js +33 -0
  182. package/dist/modules/swap/oneinch.js.map +1 -0
  183. package/dist/modules/swap/schemas.d.ts +65 -0
  184. package/dist/modules/swap/schemas.js +46 -0
  185. package/dist/modules/swap/schemas.js.map +1 -0
  186. package/dist/setup.d.ts +2 -0
  187. package/dist/setup.js +257 -0
  188. package/dist/setup.js.map +1 -0
  189. package/dist/signing/pre-sign-check.d.ts +8 -0
  190. package/dist/signing/pre-sign-check.js +231 -0
  191. package/dist/signing/pre-sign-check.js.map +1 -0
  192. package/dist/signing/session.d.ts +28 -0
  193. package/dist/signing/session.js +26 -0
  194. package/dist/signing/session.js.map +1 -0
  195. package/dist/signing/tx-store.d.ts +29 -0
  196. package/dist/signing/tx-store.js +85 -0
  197. package/dist/signing/tx-store.js.map +1 -0
  198. package/dist/signing/walletconnect.d.ts +33 -0
  199. package/dist/signing/walletconnect.js +226 -0
  200. package/dist/signing/walletconnect.js.map +1 -0
  201. package/dist/types/index.d.ts +222 -0
  202. package/dist/types/index.js +18 -0
  203. package/dist/types/index.js.map +1 -0
  204. package/package.json +134 -0
package/dist/index.js ADDED
@@ -0,0 +1,344 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { getLendingPositions, getLpPositions, getHealthAlerts, simulatePositionChange, } from "./modules/positions/index.js";
5
+ import { getLendingPositionsInput, getLpPositionsInput, getHealthAlertsInput, simulatePositionChangeInput, } from "./modules/positions/schemas.js";
6
+ import { checkContractSecurityHandler, checkPermissionRisksHandler, getProtocolRiskScoreHandler, } from "./modules/security/index.js";
7
+ import { checkContractSecurityInput, checkPermissionRisksInput, getProtocolRiskScoreInput, } from "./modules/security/schemas.js";
8
+ import { getStakingPositions, getStakingRewards, estimateStakingYield, } from "./modules/staking/index.js";
9
+ import { getStakingPositionsInput, getStakingRewardsInput, estimateStakingYieldInput, } from "./modules/staking/schemas.js";
10
+ import { getPortfolioSummary } from "./modules/portfolio/index.js";
11
+ import { getPortfolioSummaryInput } from "./modules/portfolio/schemas.js";
12
+ import { getSwapQuote, prepareSwap } from "./modules/swap/index.js";
13
+ import { getSwapQuoteInput, prepareSwapInput } from "./modules/swap/schemas.js";
14
+ import { pairLedgerLive, getLedgerStatus, prepareAaveSupply, prepareAaveWithdraw, prepareAaveBorrow, prepareAaveRepay, prepareLidoStake, prepareLidoUnstake, prepareEigenLayerDeposit, prepareNativeSend, prepareTokenSend, sendTransaction, getTransactionStatus, } from "./modules/execution/index.js";
15
+ import { pairLedgerLiveInput, getLedgerStatusInput, prepareAaveSupplyInput, prepareAaveWithdrawInput, prepareAaveBorrowInput, prepareAaveRepayInput, prepareLidoStakeInput, prepareLidoUnstakeInput, prepareEigenLayerDepositInput, prepareNativeSendInput, prepareTokenSendInput, sendTransactionInput, getTransactionStatusInput, } from "./modules/execution/schemas.js";
16
+ import { getTokenBalance, resolveName, reverseResolve } from "./modules/balances/index.js";
17
+ import { getTokenBalanceInput, resolveNameInput, reverseResolveInput, } from "./modules/balances/schemas.js";
18
+ import { getCompoundPositions } from "./modules/compound/index.js";
19
+ import { buildCompoundSupply, buildCompoundWithdraw, buildCompoundBorrow, buildCompoundRepay, } from "./modules/compound/actions.js";
20
+ import { getCompoundPositionsInput, prepareCompoundSupplyInput, prepareCompoundWithdrawInput, prepareCompoundBorrowInput, prepareCompoundRepayInput, } from "./modules/compound/schemas.js";
21
+ import { getMorphoPositions } from "./modules/morpho/index.js";
22
+ import { buildMorphoSupply, buildMorphoWithdraw, buildMorphoBorrow, buildMorphoRepay, buildMorphoSupplyCollateral, buildMorphoWithdrawCollateral, } from "./modules/morpho/actions.js";
23
+ import { getMorphoPositionsInput, prepareMorphoSupplyInput, prepareMorphoWithdrawInput, prepareMorphoBorrowInput, prepareMorphoRepayInput, prepareMorphoSupplyCollateralInput, prepareMorphoWithdrawCollateralInput, } from "./modules/morpho/schemas.js";
24
+ import { getTokenPriceInput, getTokenPriceTool } from "./modules/prices/index.js";
25
+ import { requestCapability, requestCapabilityInput } from "./modules/feedback/index.js";
26
+ import { issueHandles } from "./signing/tx-store.js";
27
+ import { readUserConfig } from "./config/user-config.js";
28
+ /**
29
+ * Wrap a plain async function into the shape MCP expects.
30
+ * Returns `{ content: [{ type: "text", text }] }` on success,
31
+ * `{ content, isError: true }` on failure.
32
+ */
33
+ function handler(fn) {
34
+ return async (args) => {
35
+ try {
36
+ const result = await fn(args);
37
+ return {
38
+ content: [
39
+ {
40
+ type: "text",
41
+ text: JSON.stringify(result, bigintReplacer, 2),
42
+ },
43
+ ],
44
+ };
45
+ }
46
+ catch (error) {
47
+ const message = error instanceof Error ? error.message : String(error);
48
+ return {
49
+ content: [{ type: "text", text: `Error: ${message}` }],
50
+ isError: true,
51
+ };
52
+ }
53
+ };
54
+ }
55
+ /**
56
+ * Handler wrapper for prepare_* tools that return UnsignedTx. Runs the function,
57
+ * then issues opaque handles across the tx and every `.next` node so
58
+ * `send_transaction` can re-hydrate the exact tx from server state. The agent
59
+ * never passes raw calldata to the signing path — it calls send_transaction
60
+ * with a handle, which closes the prompt-injection → arbitrary-calldata window.
61
+ */
62
+ function txHandler(fn) {
63
+ return handler(async (args) => issueHandles(await fn(args)));
64
+ }
65
+ /** JSON.stringify replacer that converts bigint to decimal string. */
66
+ function bigintReplacer(_key, value) {
67
+ return typeof value === "bigint" ? value.toString() : value;
68
+ }
69
+ async function main() {
70
+ // Check for at least one configured RPC path early. We don't hard-fail — the
71
+ // user may only use read-only tools with per-chain env vars. We just warn.
72
+ const cfg = readUserConfig();
73
+ const hasEnvChain = process.env.ETHEREUM_RPC_URL || process.env.ARBITRUM_RPC_URL;
74
+ const hasEnvProvider = process.env.RPC_PROVIDER && process.env.RPC_API_KEY;
75
+ if (!cfg && !hasEnvChain && !hasEnvProvider) {
76
+ console.error("[recon-crypto-mcp] warning: no RPC provider configured. Run `recon-crypto-mcp-setup` or set RPC_PROVIDER + RPC_API_KEY.");
77
+ }
78
+ const server = new McpServer({
79
+ name: "recon-crypto-mcp",
80
+ title: "Recon — Ledger-Signed Crypto Portfolio & DeFi",
81
+ version: "0.1.0",
82
+ websiteUrl: "https://github.com/szhygulin/recon-crypto-mcp",
83
+ }, {
84
+ instructions: [
85
+ "Recon is a self-custodial crypto-portfolio and DeFi tooling server for AI agents.",
86
+ "The user's private keys live on a Ledger hardware wallet; this server never holds or",
87
+ "broadcasts keys. Every state-changing transaction is prepared here (read-only) and",
88
+ "then forwarded to Ledger Live via WalletConnect so the user can review and approve it",
89
+ "on the physical device.",
90
+ "",
91
+ "USE THIS SERVER WHEN the user asks about:",
92
+ "- their crypto wallet, balances, tokens, ETH, ERC-20 holdings, or ENS name",
93
+ "- their DeFi positions on Ethereum, Arbitrum, or Polygon — Aave V3 lending/borrowing,",
94
+ " Compound V3 (Comet), Morpho Blue, Uniswap V3 LP, Lido staking, EigenLayer restaking",
95
+ "- portfolio value, cross-chain aggregation, health-factor / liquidation risk",
96
+ "- executing on-chain actions: supply, borrow, repay, withdraw, stake, unstake,",
97
+ " send ETH/tokens, swap, bridge",
98
+ "- token prices, ENS forward/reverse resolution",
99
+ "- assessing the security of a smart contract or DeFi protocol (verification, proxy",
100
+ " upgradeability, privileged roles, TVL/audit-based risk score)",
101
+ "",
102
+ "TYPICAL WORKFLOW for a transaction:",
103
+ "1. Call `get_ledger_status` first to discover the user's connected wallet address(es)",
104
+ " — resolve phrases like \"my wallet\" or \"account 2\" to a concrete 0x… address before",
105
+ " calling any other tool that takes a `wallet` argument.",
106
+ "2. If not paired yet, call `pair_ledger_live` and show the returned QR/URI.",
107
+ "3. Call a `prepare_*` tool to build the unsigned transaction (this returns a handle",
108
+ " plus a human-readable decoded preview; no calldata is exposed to the agent).",
109
+ "4. Show the decoded preview to the user and get explicit confirmation.",
110
+ "5. Call `send_transaction` with the handle and `confirmed: true` — Ledger Live will",
111
+ " prompt the user to review and physically sign on the device.",
112
+ "6. Optionally poll `get_transaction_status` for inclusion.",
113
+ "",
114
+ "READ-ONLY TOOLS need no pairing and can be called freely: get_lending_positions,",
115
+ "get_lp_positions, get_compound_positions, get_morpho_positions, get_staking_positions,",
116
+ "get_staking_rewards, estimate_staking_yield, get_portfolio_summary, get_swap_quote,",
117
+ "get_token_balance, get_token_price, resolve_ens_name, reverse_resolve_ens,",
118
+ "get_health_alerts, simulate_position_change, check_contract_security,",
119
+ "check_permission_risks, get_protocol_risk_score, get_transaction_status.",
120
+ "",
121
+ "SWAP/BRIDGE ROUTING: prefer `prepare_swap` (LiFi aggregator) over building DEX",
122
+ "router calls directly — LiFi handles route selection, approvals, and cross-chain",
123
+ "bridging uniformly.",
124
+ "",
125
+ "CAPABILITY GAPS: if the user asks for something this server cannot do (unsupported",
126
+ "protocol, chain, token, or a workflow none of the existing tools cover), call",
127
+ "`request_capability` to file a GitHub issue on the recon-crypto-mcp repo. By default it",
128
+ "returns a prefilled URL for the user to click — nothing is sent automatically. Use",
129
+ "this only after confirming no existing tool fits; it is rate-limited (3/hour,",
130
+ "10/day, dedup'd for 7 days). Never substitute this for completing the task.",
131
+ "",
132
+ "SECURITY: the `wallet` / `peerUrl` returned by `get_ledger_status` is self-reported",
133
+ "by the paired WalletConnect peer. Before the FIRST `send_transaction` of a session,",
134
+ "state the paired wallet name + URL back to the user and have them confirm it matches",
135
+ "their real Ledger Live install. The Ledger device's on-screen confirmation is the",
136
+ "ultimate authority — tell the user to verify the recipient, amount, and chain on",
137
+ "the device, not just in chat.",
138
+ ].join("\n"),
139
+ });
140
+ // ---- Module 1: Positions ----
141
+ server.registerTool("get_lending_positions", {
142
+ description: "Fetch all Aave V3 lending/borrowing positions for a wallet. Returns collateral, debt (both in USD and per-asset), health factor, LTV, and liquidation threshold across Ethereum and Arbitrum.",
143
+ inputSchema: getLendingPositionsInput.shape,
144
+ }, handler(getLendingPositions));
145
+ server.registerTool("get_lp_positions", {
146
+ description: "Fetch all Uniswap V3 liquidity-provider positions for a wallet. Returns token pair, current token amounts, fee tier, in-range status, uncollected fees (lower bound), and an approximate impermanent-loss estimate.",
147
+ inputSchema: getLpPositionsInput.shape,
148
+ }, handler(getLpPositions));
149
+ server.registerTool("get_health_alerts", {
150
+ description: "Check for Aave V3 lending positions approaching liquidation. Returns positions whose health factor is below the given threshold (default 1.5).",
151
+ inputSchema: getHealthAlertsInput.shape,
152
+ }, handler(getHealthAlerts));
153
+ server.registerTool("simulate_position_change", {
154
+ description: "Simulate the effect of adding or removing collateral, or borrowing/repaying debt on an Aave V3 position. Returns the projected health factor and collateral/debt totals. No transaction is sent.",
155
+ inputSchema: simulatePositionChangeInput.shape,
156
+ }, handler(simulatePositionChange));
157
+ // ---- Module 2: Security ----
158
+ server.registerTool("check_contract_security", {
159
+ description: "Check Etherscan verification status, EIP-1967 proxy pattern, implementation/admin slots, and the presence of dangerous admin functions (mint, pause, upgradeTo, etc.) for a given contract.",
160
+ inputSchema: checkContractSecurityInput.shape,
161
+ }, handler((a) => checkContractSecurityHandler(a)));
162
+ server.registerTool("check_permission_risks", {
163
+ description: "Enumerate privileged roles on a contract (Ownable.owner, AccessControl hints) and classify holders as EOA, Gnosis Safe multisig, or TimelockController.",
164
+ inputSchema: checkPermissionRisksInput.shape,
165
+ }, handler((a) => checkPermissionRisksHandler(a)));
166
+ server.registerTool("get_protocol_risk_score", {
167
+ description: "Return a 0-100 risk score for a DeFi protocol, combining TVL size, 30-day TVL trend, contract age, audit count (DefiLlama), and Immunefi bug-bounty status. Higher = safer.",
168
+ inputSchema: getProtocolRiskScoreInput.shape,
169
+ }, handler((a) => getProtocolRiskScoreHandler(a)));
170
+ // ---- Module 3: Staking ----
171
+ server.registerTool("get_staking_positions", {
172
+ description: "Fetch Lido (stETH/wstETH) and EigenLayer staking positions for a wallet across supported chains. Returns per-protocol staked amounts, USD value, APR, and EigenLayer delegation target.",
173
+ inputSchema: getStakingPositionsInput.shape,
174
+ }, handler(getStakingPositions));
175
+ server.registerTool("get_staking_rewards", {
176
+ description: "Estimate staking rewards earned over a given period (7d/30d/90d/1y) using the current APR as a proxy. This is an estimate, not an on-chain rewards query.",
177
+ inputSchema: getStakingRewardsInput.shape,
178
+ }, handler(getStakingRewards));
179
+ server.registerTool("estimate_staking_yield", {
180
+ description: "Project annual yield on a hypothetical staking amount for a given protocol (Lido or EigenLayer) using current APRs.",
181
+ inputSchema: estimateStakingYieldInput.shape,
182
+ }, handler(estimateStakingYield));
183
+ // ---- Module 4: Portfolio ----
184
+ server.registerTool("get_portfolio_summary", {
185
+ description: "Aggregate a complete portfolio view: native balances, top ERC-20 holdings, Aave V3 positions, Uniswap V3 LP positions, and staking — with USD totals and per-chain breakdown.",
186
+ inputSchema: getPortfolioSummaryInput.shape,
187
+ }, handler(getPortfolioSummary));
188
+ // ---- Module 5: Swap/Bridge (LiFi) ----
189
+ server.registerTool("get_swap_quote", {
190
+ description: "Get a LiFi aggregator quote for a token swap (same-chain) or bridge (cross-chain). Returns expected output, fees, execution time, and the underlying tool selected. No transaction is built.",
191
+ inputSchema: getSwapQuoteInput.shape,
192
+ }, handler(getSwapQuote));
193
+ server.registerTool("prepare_swap", {
194
+ description: "Prepare an unsigned swap or bridge transaction via LiFi aggregator. Same-chain swaps use the best DEX route; cross-chain swaps use a bridge + DEX combo. The returned tx can be sent via `send_transaction`.",
195
+ inputSchema: prepareSwapInput.shape,
196
+ }, txHandler(prepareSwap));
197
+ // ---- Module 6: Execution (Ledger Live) ----
198
+ server.registerTool("pair_ledger_live", {
199
+ description: "Initiate a WalletConnect v2 pairing session with Ledger Live. Returns a URI and ASCII QR code — paste into Ledger Live's WalletConnect screen to complete pairing. The session persists for future transactions.",
200
+ inputSchema: pairLedgerLiveInput.shape,
201
+ }, handler(pairLedgerLive));
202
+ server.registerTool("get_ledger_status", {
203
+ description: "Report whether a WalletConnect session with Ledger Live is active, which wallet it's connected to, and which accounts are exposed. " +
204
+ "Returns `accounts: 0x…[]` — the list of wallet addresses the user has connected. " +
205
+ "Call this FIRST whenever the user refers to their wallet(s) by position or nickname instead of by address — e.g. " +
206
+ '\"my wallet\", \"the first address\", \"account 2\", \"second wallet\" — so you can resolve the reference to a concrete 0x… ' +
207
+ "before invoking any prepare_* / swap / send / portfolio tool that takes a `wallet` argument. Do NOT ask the user to paste an " +
208
+ "address if it's already in `accounts` here. " +
209
+ "SECURITY: the returned `wallet`/`peerUrl` are self-reported by the paired app. Before the FIRST send_transaction of a session, " +
210
+ "state the paired wallet name + URL back to the user and ask them to confirm it matches their Ledger Live install — " +
211
+ "any WalletConnect peer can claim to be 'Ledger Live'. The physical Ledger device's on-screen confirmation is the final check.",
212
+ inputSchema: getLedgerStatusInput.shape,
213
+ }, handler(getLedgerStatus));
214
+ server.registerTool("prepare_aave_supply", {
215
+ description: "Build an unsigned Aave V3 supply transaction. If an ERC-20 approve() is required first, it is returned as the outer tx and the supply tx is embedded in `.next`. Both must be signed for the supply to succeed.",
216
+ inputSchema: prepareAaveSupplyInput.shape,
217
+ }, txHandler(prepareAaveSupply));
218
+ server.registerTool("prepare_aave_withdraw", {
219
+ description: "Build an unsigned Aave V3 withdraw transaction. Pass `amount: \"max\"` to withdraw the entire aToken balance.",
220
+ inputSchema: prepareAaveWithdrawInput.shape,
221
+ }, txHandler(prepareAaveWithdraw));
222
+ server.registerTool("prepare_aave_borrow", {
223
+ description: "Build an unsigned Aave V3 borrow transaction (variable rate — stable rate is deprecated and reverts on production markets). The borrower must already have sufficient collateral supplied.",
224
+ inputSchema: prepareAaveBorrowInput.shape,
225
+ }, txHandler(prepareAaveBorrow));
226
+ server.registerTool("prepare_aave_repay", {
227
+ description: "Build an unsigned Aave V3 repay transaction. If an ERC-20 approve() is required first, it is returned as the outer tx and repay is in `.next`. Pass `amount: \"max\"` to repay the full debt.",
228
+ inputSchema: prepareAaveRepayInput.shape,
229
+ }, txHandler(prepareAaveRepay));
230
+ server.registerTool("prepare_lido_stake", {
231
+ description: "Build an unsigned Lido stake transaction (wraps ETH into stETH via stETH.submit). The tx's value field is the ETH amount to stake.",
232
+ inputSchema: prepareLidoStakeInput.shape,
233
+ }, txHandler(prepareLidoStake));
234
+ server.registerTool("prepare_lido_unstake", {
235
+ description: "Build an unsigned Lido withdrawal request transaction. Wraps `requestWithdrawals` on the Lido Withdrawal Queue and includes an approve step if needed.",
236
+ inputSchema: prepareLidoUnstakeInput.shape,
237
+ }, txHandler(prepareLidoUnstake));
238
+ server.registerTool("prepare_eigenlayer_deposit", {
239
+ description: "Build an unsigned EigenLayer StrategyManager.depositIntoStrategy transaction. Includes an ERC-20 approve step if needed.",
240
+ inputSchema: prepareEigenLayerDepositInput.shape,
241
+ }, txHandler(prepareEigenLayerDeposit));
242
+ server.registerTool("send_transaction", {
243
+ description: "Forward an already-prepared transaction to Ledger Live via WalletConnect for user signing. The user must review and approve the tx in Ledger Live and on their Ledger device; this call blocks until the user signs or rejects. " +
244
+ "You MUST pass `confirmed: true` — the agent is affirming that the user has seen and acknowledged the decoded preview.",
245
+ inputSchema: sendTransactionInput.shape,
246
+ }, handler(sendTransaction));
247
+ server.registerTool("get_transaction_status", {
248
+ description: "Poll a transaction's status via the chain's RPC. Returns pending / success / failed, or unknown if the node hasn't seen it yet.",
249
+ inputSchema: getTransactionStatusInput.shape,
250
+ }, handler(getTransactionStatus));
251
+ // ---- Module 7: Balances & ENS ----
252
+ server.registerTool("get_token_balance", {
253
+ description: "Fetch a wallet's balance of any ERC-20 token or the chain's native coin. Pass `token: \"native\"` for ETH (or chain-native asset) or an ERC-20 contract address. Returns amount, decimals, symbol, and USD value.",
254
+ inputSchema: getTokenBalanceInput.shape,
255
+ }, handler(getTokenBalance));
256
+ server.registerTool("get_token_price", {
257
+ description: "Fetch the USD price of a token via DefiLlama. Pass `token: \"native\"` for the chain's native asset (ETH on ethereum/arbitrum, MATIC on polygon) or an ERC-20 contract address. Prefer this over get_swap_quote for pure price lookups — no wallet or liquidity simulation needed.",
258
+ inputSchema: getTokenPriceInput.shape,
259
+ }, handler(getTokenPriceTool));
260
+ server.registerTool("resolve_ens_name", {
261
+ description: "Resolve an ENS name (e.g. vitalik.eth) to an Ethereum address via mainnet ENS resolver. Returns null if unregistered.",
262
+ inputSchema: resolveNameInput.shape,
263
+ }, handler(resolveName));
264
+ server.registerTool("reverse_resolve_ens", {
265
+ description: "Reverse-resolve an Ethereum address to its primary ENS name. Returns null if no primary name is set.",
266
+ inputSchema: reverseResolveInput.shape,
267
+ }, handler(reverseResolve));
268
+ server.registerTool("prepare_native_send", {
269
+ description: "Build an unsigned native-coin send transaction (ETH on Ethereum/Arbitrum). Pass a human-readable amount like \"0.5\".",
270
+ inputSchema: prepareNativeSendInput.shape,
271
+ }, txHandler(prepareNativeSend));
272
+ server.registerTool("prepare_token_send", {
273
+ description: "Build an unsigned ERC-20 transfer transaction. Pass `amount: \"max\"` to send the full balance (resolved at build time).",
274
+ inputSchema: prepareTokenSendInput.shape,
275
+ }, txHandler(prepareTokenSend));
276
+ // ---- Module 8: Compound V3 ----
277
+ server.registerTool("get_compound_positions", {
278
+ description: "Fetch Compound V3 (Comet) positions for a wallet across supported markets (cUSDCv3, cUSDTv3, cWETHv3, etc.). Returns base-token supplied/borrowed, per-asset collateral, and USD totals.",
279
+ inputSchema: getCompoundPositionsInput.shape,
280
+ }, handler(getCompoundPositions));
281
+ server.registerTool("prepare_compound_supply", {
282
+ description: "Build an unsigned Compound V3 supply transaction (base token or collateral). If an ERC-20 approve() is required first, it is returned as the outer tx with supply in `.next`.",
283
+ inputSchema: prepareCompoundSupplyInput.shape,
284
+ }, txHandler(buildCompoundSupply));
285
+ server.registerTool("prepare_compound_withdraw", {
286
+ description: "Build an unsigned Compound V3 withdraw transaction. Pass `amount: \"max\"` to withdraw the full supplied balance.",
287
+ inputSchema: prepareCompoundWithdrawInput.shape,
288
+ }, txHandler(buildCompoundWithdraw));
289
+ server.registerTool("prepare_compound_borrow", {
290
+ description: "Build an unsigned Compound V3 borrow transaction — encoded as withdraw(baseToken) beyond the user's supplied balance. Base token is resolved on-chain from the Comet.",
291
+ inputSchema: prepareCompoundBorrowInput.shape,
292
+ }, txHandler(buildCompoundBorrow));
293
+ server.registerTool("prepare_compound_repay", {
294
+ description: "Build an unsigned Compound V3 repay transaction — encoded as supply(baseToken) against an outstanding borrow. Includes an approve step if needed. Pass `amount: \"max\"` for a full repay.",
295
+ inputSchema: prepareCompoundRepayInput.shape,
296
+ }, txHandler(buildCompoundRepay));
297
+ // ---- Module 9: Morpho Blue ----
298
+ server.registerTool("get_morpho_positions", {
299
+ description: "Fetch Morpho Blue positions for a wallet across a given list of market IDs. Each market is identified by a bytes32 id (keccak256 of its MarketParams). Returns per-market supplied/borrowed assets and collateral.",
300
+ inputSchema: getMorphoPositionsInput.shape,
301
+ }, handler(getMorphoPositions));
302
+ server.registerTool("prepare_morpho_supply", {
303
+ description: "Build an unsigned Morpho Blue supply transaction (deposits loan token for yield). Market params are resolved on-chain from the market id. Includes an approve step if needed.",
304
+ inputSchema: prepareMorphoSupplyInput.shape,
305
+ }, txHandler(buildMorphoSupply));
306
+ server.registerTool("prepare_morpho_withdraw", {
307
+ description: "Build an unsigned Morpho Blue withdraw transaction (withdraws supplied loan token). Explicit amount only — \"max\" is not supported; query your position first.",
308
+ inputSchema: prepareMorphoWithdrawInput.shape,
309
+ }, txHandler(buildMorphoWithdraw));
310
+ server.registerTool("prepare_morpho_borrow", {
311
+ description: "Build an unsigned Morpho Blue borrow transaction. Requires pre-existing collateral in the market.",
312
+ inputSchema: prepareMorphoBorrowInput.shape,
313
+ }, txHandler(buildMorphoBorrow));
314
+ server.registerTool("prepare_morpho_repay", {
315
+ description: "Build an unsigned Morpho Blue repay transaction. Includes an approve step if needed. Explicit amount only — \"max\" is not supported.",
316
+ inputSchema: prepareMorphoRepayInput.shape,
317
+ }, txHandler(buildMorphoRepay));
318
+ server.registerTool("prepare_morpho_supply_collateral", {
319
+ description: "Build an unsigned Morpho Blue supplyCollateral transaction — adds collateral to a market. Includes an approve step if needed.",
320
+ inputSchema: prepareMorphoSupplyCollateralInput.shape,
321
+ }, txHandler(buildMorphoSupplyCollateral));
322
+ server.registerTool("prepare_morpho_withdraw_collateral", {
323
+ description: "Build an unsigned Morpho Blue withdrawCollateral transaction — removes collateral from a market. Explicit amount only.",
324
+ inputSchema: prepareMorphoWithdrawCollateralInput.shape,
325
+ }, txHandler(buildMorphoWithdrawCollateral));
326
+ // ---- Module 10: Capability requests (agent → maintainers) ----
327
+ server.registerTool("request_capability", {
328
+ description: "File a capability request against the recon-crypto-mcp GitHub repository when the user asks for something this server cannot do " +
329
+ "(e.g. an unsupported protocol, chain, token, or missing tool). " +
330
+ "USE ONLY AFTER confirming no existing tool can accomplish the task. " +
331
+ "By default this returns a pre-filled GitHub issue URL — NO data is transmitted; the user must click through to submit. " +
332
+ "If the operator has configured RECON_FEEDBACK_ENDPOINT, it posts directly to that proxy instead. " +
333
+ "Rate-limited per install (30s between calls, 3/hour, 10/day, 7-day dedupe on identical summaries). " +
334
+ "Write clear, actionable summaries — this lands in a real issue tracker read by humans.",
335
+ inputSchema: requestCapabilityInput.shape,
336
+ }, handler(requestCapability));
337
+ const transport = new StdioServerTransport();
338
+ await server.connect(transport);
339
+ }
340
+ main().catch((err) => {
341
+ console.error("[recon-crypto-mcp] fatal:", err);
342
+ process.exit(1);
343
+ });
344
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,sBAAsB,GACvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA2B,GAC5B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE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yH;YACzH,mGAAmG;YACnG,qGAAqG;YACrG,wFAAwF;QAC1F,WAAW,EAAE,sBAAsB,CAAC,KAAK;KAC1C,EACD,OAAO,CAAC,iBAAiB,CAAC,CAC3B,CAAC;IAEF,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;IAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { GetTokenBalanceArgs, ResolveNameArgs, ReverseResolveArgs } from "./schemas.js";
2
+ import type { TokenAmount } from "../../types/index.js";
3
+ /**
4
+ * Fetch the balance of an arbitrary token (ERC-20 by address, or the chain's native coin).
5
+ * Returns `{ ...TokenAmount, zero: true }` when the wallet has no balance.
6
+ */
7
+ export declare function getTokenBalance(args: GetTokenBalanceArgs): Promise<TokenAmount>;
8
+ /**
9
+ * ENS forward resolution: name → address. Only Ethereum mainnet ENS is supported (viem routes
10
+ * through the mainnet resolver even for subdomains used cross-chain).
11
+ */
12
+ export declare function resolveName(args: ResolveNameArgs): Promise<{
13
+ name: string;
14
+ address: `0x${string}` | null;
15
+ }>;
16
+ /** ENS reverse resolution: address → primary name. Returns null if the address has no primary name set. */
17
+ export declare function reverseResolve(args: ReverseResolveArgs): Promise<{
18
+ address: `0x${string}`;
19
+ name: string | null;
20
+ }>;
@@ -0,0 +1,49 @@
1
+ import { getClient } from "../../data/rpc.js";
2
+ import { erc20Abi } from "../../abis/erc20.js";
3
+ import { makeTokenAmount } from "../../data/format.js";
4
+ import { getTokenPrice } from "../../data/prices.js";
5
+ import { NATIVE_SYMBOL } from "../../config/contracts.js";
6
+ /**
7
+ * Fetch the balance of an arbitrary token (ERC-20 by address, or the chain's native coin).
8
+ * Returns `{ ...TokenAmount, zero: true }` when the wallet has no balance.
9
+ */
10
+ export async function getTokenBalance(args) {
11
+ const wallet = args.wallet;
12
+ const chain = args.chain;
13
+ const client = getClient(chain);
14
+ if (args.token === "native") {
15
+ const [balance, price] = await Promise.all([
16
+ client.getBalance({ address: wallet }),
17
+ getTokenPrice(chain, "native"),
18
+ ]);
19
+ return makeTokenAmount(chain, "0x0000000000000000000000000000000000000000", balance, 18, NATIVE_SYMBOL[chain], price);
20
+ }
21
+ const token = args.token;
22
+ const [balance, decimals, symbol] = await client.multicall({
23
+ contracts: [
24
+ { address: token, abi: erc20Abi, functionName: "balanceOf", args: [wallet] },
25
+ { address: token, abi: erc20Abi, functionName: "decimals" },
26
+ { address: token, abi: erc20Abi, functionName: "symbol" },
27
+ ],
28
+ allowFailure: false,
29
+ });
30
+ const price = await getTokenPrice(chain, token);
31
+ return makeTokenAmount(chain, token, balance, Number(decimals), symbol, price);
32
+ }
33
+ /**
34
+ * ENS forward resolution: name → address. Only Ethereum mainnet ENS is supported (viem routes
35
+ * through the mainnet resolver even for subdomains used cross-chain).
36
+ */
37
+ export async function resolveName(args) {
38
+ const client = getClient("ethereum");
39
+ const address = await client.getEnsAddress({ name: args.name });
40
+ return { name: args.name, address };
41
+ }
42
+ /** ENS reverse resolution: address → primary name. Returns null if the address has no primary name set. */
43
+ export async function reverseResolve(args) {
44
+ const client = getClient("ethereum");
45
+ const address = args.address;
46
+ const name = await client.getEnsName({ address });
47
+ return { address, name };
48
+ }
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/balances/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,C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M,KAAK,GAAG,MAAM,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAChD,OAAO,eAAe,CACpB,KAAK,EACL,KAAK,EACL,OAAiB,EACjB,MAAM,CAAC,QAAQ,CAAC,EAChB,MAAgB,EAChB,KAAK,CACN,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAAqB;IAErB,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAChE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC;AACtC,CAAC;AAED,2GAA2G;AAC3G,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,IAAwB;IAExB,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAwB,CAAC;IAC9C,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAClD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { z } from "zod";
2
+ export declare const getTokenBalanceInput: z.ZodObject<{
3
+ wallet: z.ZodString;
4
+ /** "native" for the chain's native coin, otherwise an ERC-20 contract address. */
5
+ token: z.ZodUnion<[z.ZodLiteral<"native">, z.ZodString]>;
6
+ chain: z.ZodDefault<z.ZodEnum<[string, ...string[]]>>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ chain: string;
9
+ wallet: string;
10
+ token: string;
11
+ }, {
12
+ wallet: string;
13
+ token: string;
14
+ chain?: string | undefined;
15
+ }>;
16
+ export declare const resolveNameInput: z.ZodObject<{
17
+ name: z.ZodString;
18
+ }, "strip", z.ZodTypeAny, {
19
+ name: string;
20
+ }, {
21
+ name: string;
22
+ }>;
23
+ export declare const reverseResolveInput: z.ZodObject<{
24
+ address: z.ZodString;
25
+ }, "strip", z.ZodTypeAny, {
26
+ address: string;
27
+ }, {
28
+ address: string;
29
+ }>;
30
+ export type GetTokenBalanceArgs = z.infer<typeof getTokenBalanceInput>;
31
+ export type ResolveNameArgs = z.infer<typeof resolveNameInput>;
32
+ export type ReverseResolveArgs = z.infer<typeof reverseResolveInput>;
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ import { SUPPORTED_CHAINS } from "../../types/index.js";
3
+ const chainEnum = z.enum(SUPPORTED_CHAINS);
4
+ const walletSchema = z.string().regex(/^0x[a-fA-F0-9]{40}$/);
5
+ const tokenSchema = z.union([
6
+ z.literal("native"),
7
+ z.string().regex(/^0x[a-fA-F0-9]{40}$/),
8
+ ]);
9
+ export const getTokenBalanceInput = z.object({
10
+ wallet: walletSchema,
11
+ /** "native" for the chain's native coin, otherwise an ERC-20 contract address. */
12
+ token: tokenSchema,
13
+ chain: chainEnum.default("ethereum"),
14
+ });
15
+ export const resolveNameInput = z.object({
16
+ name: z.string().min(3),
17
+ });
18
+ export const reverseResolveInput = z.object({
19
+ address: walletSchema,
20
+ });
21
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/modules/balances/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,gBAAoD,CAAC,CAAC;AAC/E,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAC7D,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC;IAC1B,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IACnB,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,qBAAqB,CAAC;CACxC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,MAAM,EAAE,YAAY;IACpB,kFAAkF;IAClF,KAAK,EAAE,WAAW;IAClB,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC;CACrC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,OAAO,EAAE,YAAY;CACtB,CAAC,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { GetBitcoinBalanceArgs, GetBitcoinPortfolioArgs } from "./schemas.js";
2
+ export interface BitcoinBalance {
3
+ chain: "bitcoin";
4
+ address: string;
5
+ /** Confirmed balance in satoshis as a decimal string (JSON-safe). */
6
+ amountSats: string;
7
+ /** Unconfirmed (mempool-only) balance delta in satoshis. Can be negative for pending spends. */
8
+ unconfirmedSats: string;
9
+ /** Confirmed balance expressed in BTC (human-readable). */
10
+ formattedBtc: string;
11
+ symbol: "BTC";
12
+ decimals: 8;
13
+ priceUsd?: number;
14
+ valueUsd?: number;
15
+ }
16
+ export declare function getBitcoinBalance(args: GetBitcoinBalanceArgs): Promise<BitcoinBalance>;
17
+ export interface BitcoinPortfolio {
18
+ chain: "bitcoin";
19
+ addresses: string[];
20
+ balances: BitcoinBalance[];
21
+ totalSats: string;
22
+ totalBtc: string;
23
+ totalUsd?: number;
24
+ priceUsd?: number;
25
+ }
26
+ export declare function getBitcoinPortfolio(args: GetBitcoinPortfolioArgs): Promise<BitcoinPortfolio>;