zano-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 (113) hide show
  1. package/README.md +195 -0
  2. package/dist/clients/daemon.d.ts +6 -0
  3. package/dist/clients/daemon.d.ts.map +1 -0
  4. package/dist/clients/daemon.js +30 -0
  5. package/dist/clients/daemon.js.map +1 -0
  6. package/dist/clients/trade.d.ts +8 -0
  7. package/dist/clients/trade.d.ts.map +1 -0
  8. package/dist/clients/trade.js +33 -0
  9. package/dist/clients/trade.js.map +1 -0
  10. package/dist/clients/wallet.d.ts +8 -0
  11. package/dist/clients/wallet.d.ts.map +1 -0
  12. package/dist/clients/wallet.js +45 -0
  13. package/dist/clients/wallet.js.map +1 -0
  14. package/dist/config.d.ts +30 -0
  15. package/dist/config.d.ts.map +1 -0
  16. package/dist/config.js +42 -0
  17. package/dist/config.js.map +1 -0
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +15 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/logger.d.ts +9 -0
  23. package/dist/logger.d.ts.map +1 -0
  24. package/dist/logger.js +28 -0
  25. package/dist/logger.js.map +1 -0
  26. package/dist/prompts/index.d.ts +4 -0
  27. package/dist/prompts/index.d.ts.map +1 -0
  28. package/dist/prompts/index.js +54 -0
  29. package/dist/prompts/index.js.map +1 -0
  30. package/dist/resources/index.d.ts +4 -0
  31. package/dist/resources/index.d.ts.map +1 -0
  32. package/dist/resources/index.js +60 -0
  33. package/dist/resources/index.js.map +1 -0
  34. package/dist/server.d.ts +4 -0
  35. package/dist/server.d.ts.map +1 -0
  36. package/dist/server.js +22 -0
  37. package/dist/server.js.map +1 -0
  38. package/dist/tools/assets/definitions.d.ts +127 -0
  39. package/dist/tools/assets/definitions.d.ts.map +1 -0
  40. package/dist/tools/assets/definitions.js +43 -0
  41. package/dist/tools/assets/definitions.js.map +1 -0
  42. package/dist/tools/assets/handlers.d.ts +21 -0
  43. package/dist/tools/assets/handlers.d.ts.map +1 -0
  44. package/dist/tools/assets/handlers.js +115 -0
  45. package/dist/tools/assets/handlers.js.map +1 -0
  46. package/dist/tools/daemon/definitions.d.ts +139 -0
  47. package/dist/tools/daemon/definitions.d.ts.map +1 -0
  48. package/dist/tools/daemon/definitions.js +55 -0
  49. package/dist/tools/daemon/definitions.js.map +1 -0
  50. package/dist/tools/daemon/handlers.d.ts +30 -0
  51. package/dist/tools/daemon/handlers.d.ts.map +1 -0
  52. package/dist/tools/daemon/handlers.js +274 -0
  53. package/dist/tools/daemon/handlers.js.map +1 -0
  54. package/dist/tools/register.d.ts +4 -0
  55. package/dist/tools/register.d.ts.map +1 -0
  56. package/dist/tools/register.js +93 -0
  57. package/dist/tools/register.js.map +1 -0
  58. package/dist/tools/swap/definitions.d.ts +103 -0
  59. package/dist/tools/swap/definitions.d.ts.map +1 -0
  60. package/dist/tools/swap/definitions.js +28 -0
  61. package/dist/tools/swap/definitions.js.map +1 -0
  62. package/dist/tools/swap/handlers.d.ts +17 -0
  63. package/dist/tools/swap/handlers.d.ts.map +1 -0
  64. package/dist/tools/swap/handlers.js +98 -0
  65. package/dist/tools/swap/handlers.js.map +1 -0
  66. package/dist/tools/trade/definitions.d.ts +137 -0
  67. package/dist/tools/trade/definitions.d.ts.map +1 -0
  68. package/dist/tools/trade/definitions.js +48 -0
  69. package/dist/tools/trade/definitions.js.map +1 -0
  70. package/dist/tools/trade/handlers.d.ts +23 -0
  71. package/dist/tools/trade/handlers.d.ts.map +1 -0
  72. package/dist/tools/trade/handlers.js +196 -0
  73. package/dist/tools/trade/handlers.js.map +1 -0
  74. package/dist/tools/wallet/definitions.d.ts +158 -0
  75. package/dist/tools/wallet/definitions.d.ts.map +1 -0
  76. package/dist/tools/wallet/definitions.js +73 -0
  77. package/dist/tools/wallet/definitions.js.map +1 -0
  78. package/dist/tools/wallet/handlers.d.ts +28 -0
  79. package/dist/tools/wallet/handlers.d.ts.map +1 -0
  80. package/dist/tools/wallet/handlers.js +214 -0
  81. package/dist/tools/wallet/handlers.js.map +1 -0
  82. package/dist/utils/constants.d.ts +25 -0
  83. package/dist/utils/constants.d.ts.map +1 -0
  84. package/dist/utils/constants.js +19 -0
  85. package/dist/utils/constants.js.map +1 -0
  86. package/dist/utils/formatting.d.ts +14 -0
  87. package/dist/utils/formatting.d.ts.map +1 -0
  88. package/dist/utils/formatting.js +68 -0
  89. package/dist/utils/formatting.js.map +1 -0
  90. package/package.json +43 -0
  91. package/src/clients/daemon.ts +41 -0
  92. package/src/clients/trade.ts +51 -0
  93. package/src/clients/wallet.ts +59 -0
  94. package/src/config.ts +56 -0
  95. package/src/index.ts +20 -0
  96. package/src/logger.ts +33 -0
  97. package/src/prompts/index.ts +80 -0
  98. package/src/resources/index.ts +73 -0
  99. package/src/server.ts +26 -0
  100. package/src/tools/assets/definitions.ts +58 -0
  101. package/src/tools/assets/handlers.ts +140 -0
  102. package/src/tools/daemon/definitions.ts +86 -0
  103. package/src/tools/daemon/handlers.ts +349 -0
  104. package/src/tools/register.ts +194 -0
  105. package/src/tools/swap/definitions.ts +36 -0
  106. package/src/tools/swap/handlers.ts +139 -0
  107. package/src/tools/trade/definitions.ts +67 -0
  108. package/src/tools/trade/handlers.ts +264 -0
  109. package/src/tools/wallet/definitions.ts +92 -0
  110. package/src/tools/wallet/handlers.ts +268 -0
  111. package/src/utils/constants.ts +24 -0
  112. package/src/utils/formatting.ts +78 -0
  113. package/tsconfig.json +19 -0
@@ -0,0 +1,194 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import type { Config } from "../config.js";
3
+ import { DaemonClient } from "../clients/daemon.js";
4
+ import { WalletClient } from "../clients/wallet.js";
5
+ import { TradeClient } from "../clients/trade.js";
6
+ import { DaemonHandlers } from "./daemon/handlers.js";
7
+ import { WalletHandlers } from "./wallet/handlers.js";
8
+ import { AssetHandlers } from "./assets/handlers.js";
9
+ import { SwapHandlers } from "./swap/handlers.js";
10
+ import { TradeHandlers } from "./trade/handlers.js";
11
+ import * as daemonDefs from "./daemon/definitions.js";
12
+ import * as walletDefs from "./wallet/definitions.js";
13
+ import * as assetDefs from "./assets/definitions.js";
14
+ import * as swapDefs from "./swap/definitions.js";
15
+ import * as tradeDefs from "./trade/definitions.js";
16
+ import { logger } from "../logger.js";
17
+
18
+ export function registerAllTools(server: McpServer, config: Config): void {
19
+ const daemonClient = new DaemonClient(config.daemonUrl);
20
+ registerDaemonTools(server, daemonClient);
21
+
22
+ if (config.walletUrl) {
23
+ const walletClient = new WalletClient(config.walletUrl, config.walletAuth);
24
+ registerWalletTools(server, new WalletHandlers(walletClient, daemonClient));
25
+ registerAssetTools(server, new AssetHandlers(walletClient));
26
+ registerSwapTools(server, new SwapHandlers(walletClient));
27
+ logger.info("Wallet/Asset/Swap tools registered");
28
+ } else {
29
+ logger.info("No ZANO_WALLET_URL set - wallet/asset/swap tools disabled");
30
+ }
31
+
32
+ const tradeClient = new TradeClient(config.tradeUrl, config.tradeToken);
33
+ registerTradeTools(server, new TradeHandlers(tradeClient), !!config.tradeToken);
34
+ logger.info("Trade tools registered");
35
+ }
36
+
37
+ function registerDaemonTools(server: McpServer, client: DaemonClient): void {
38
+ const h = new DaemonHandlers(client);
39
+
40
+ server.tool(
41
+ "get_network_info",
42
+ "Get Zano network status including height, difficulty, hashrate, connections, version",
43
+ daemonDefs.GetNetworkInfoShape,
44
+ async () => h.getNetworkInfo(),
45
+ );
46
+
47
+ server.tool(
48
+ "get_height",
49
+ "Get current Zano blockchain height",
50
+ daemonDefs.GetHeightShape,
51
+ async () => h.getHeight(),
52
+ );
53
+
54
+ server.tool(
55
+ "get_block_by_height",
56
+ "Get block header at a specific height",
57
+ daemonDefs.GetBlockByHeightShape,
58
+ async (args) => h.getBlockByHeight(args),
59
+ );
60
+
61
+ server.tool(
62
+ "get_block_by_hash",
63
+ "Get block header by its hash",
64
+ daemonDefs.GetBlockByHashShape,
65
+ async (args) => h.getBlockByHash(args),
66
+ );
67
+
68
+ server.tool(
69
+ "get_last_block",
70
+ "Get the latest block header",
71
+ daemonDefs.GetLastBlockShape,
72
+ async () => h.getLastBlock(),
73
+ );
74
+
75
+ server.tool(
76
+ "get_block_details",
77
+ "Get full block details including transactions",
78
+ daemonDefs.GetBlockDetailsShape,
79
+ async (args) => h.getBlockDetails(args),
80
+ );
81
+
82
+ server.tool(
83
+ "get_transaction",
84
+ "Get transaction details by hash",
85
+ daemonDefs.GetTransactionShape,
86
+ async (args) => h.getTransaction(args),
87
+ );
88
+
89
+ server.tool(
90
+ "get_transactions",
91
+ "Batch lookup of multiple transactions by their hashes",
92
+ daemonDefs.GetTransactionsShape,
93
+ async (args) => h.getTransactions(args),
94
+ );
95
+
96
+ server.tool(
97
+ "get_pool_info",
98
+ "Get mempool (transaction pool) status and pending transactions",
99
+ daemonDefs.GetPoolInfoShape,
100
+ async () => h.getPoolInfo(),
101
+ );
102
+
103
+ server.tool(
104
+ "get_asset_info",
105
+ "Get metadata for a registered asset by its ID",
106
+ daemonDefs.GetAssetInfoShape,
107
+ async (args) => h.getAssetInfo(args),
108
+ );
109
+
110
+ server.tool(
111
+ "get_assets_list",
112
+ "List all registered assets on the Zano blockchain",
113
+ daemonDefs.GetAssetsListShape,
114
+ async (args) => h.getAssetsList(args),
115
+ );
116
+
117
+ server.tool(
118
+ "resolve_alias",
119
+ "Resolve a Zano alias to its address",
120
+ daemonDefs.ResolveAliasShape,
121
+ async (args) => h.resolveAlias(args),
122
+ );
123
+
124
+ server.tool(
125
+ "get_alias_by_address",
126
+ "Look up the alias for a Zano address",
127
+ daemonDefs.GetAliasByAddressShape,
128
+ async (args) => h.getAliasByAddress(args),
129
+ );
130
+
131
+ server.tool(
132
+ "search_blockchain",
133
+ "Search the blockchain by hash, alias, or address",
134
+ daemonDefs.SearchBlockchainShape,
135
+ async (args) => h.searchBlockchain(args),
136
+ );
137
+
138
+ server.tool(
139
+ "validate_signature",
140
+ "Verify a signed message against an address",
141
+ daemonDefs.ValidateSignatureShape,
142
+ async (args) => h.validateSignature(args),
143
+ );
144
+
145
+ logger.info("Daemon tools registered (15 tools)");
146
+ }
147
+
148
+ /* eslint-disable @typescript-eslint/no-explicit-any */
149
+
150
+ function registerWalletTools(server: McpServer, h: WalletHandlers): void {
151
+ server.tool("get_balance", "Get wallet balance for all assets", walletDefs.GetBalanceShape, async () => h.getBalance());
152
+ server.tool("get_address", "Get wallet public address", walletDefs.GetAddressShape, async () => h.getAddress());
153
+ server.tool("get_wallet_status", "Get wallet sync status and info", walletDefs.GetWalletStatusShape, async () => h.getWalletStatus());
154
+ server.tool("transfer", "Send ZANO or assets to an address. Amounts in human-readable units.", walletDefs.TransferShape, async (args: any) => h.transfer(args));
155
+ server.tool("get_recent_transactions", "Get recent wallet transactions", walletDefs.GetRecentTransactionsShape, async (args: any) => h.getRecentTransactions(args));
156
+ server.tool("search_transactions", "Search wallet transactions by criteria", walletDefs.SearchTransactionsShape, async (args: any) => h.searchTransactions(args));
157
+ server.tool("sign_message", "Sign arbitrary data with the wallet", walletDefs.SignMessageShape, async (args: any) => h.signMessage(args));
158
+ server.tool("save_wallet", "Persist wallet state to disk", walletDefs.SaveWalletShape, async () => h.saveWallet());
159
+ server.tool("make_integrated_address", "Create an integrated address with payment ID", walletDefs.MakeIntegratedAddressShape, async (args: any) => h.makeIntegratedAddress(args));
160
+ server.tool("split_integrated_address", "Decode an integrated address", walletDefs.SplitIntegratedAddressShape, async (args: any) => h.splitIntegratedAddress(args));
161
+ server.tool("get_mining_history", "Get PoS staking reward history", walletDefs.GetMiningHistoryShape, async (args: any) => h.getMiningHistory(args));
162
+ server.tool("sweep_below", "Consolidate small outputs below a threshold", walletDefs.SweepBelowShape, async (args: any) => h.sweepBelow(args));
163
+ }
164
+
165
+ function registerAssetTools(server: McpServer, h: AssetHandlers): void {
166
+ server.tool("deploy_asset", "Deploy a new asset on Zano", assetDefs.DeployAssetShape, async (args: any) => h.deployAsset(args));
167
+ server.tool("emit_asset", "Mint additional supply of an asset", assetDefs.EmitAssetShape, async (args: any) => h.emitAsset(args));
168
+ server.tool("burn_asset", "Burn tokens of an asset", assetDefs.BurnAssetShape, async (args: any) => h.burnAsset(args));
169
+ server.tool("update_asset", "Update asset metadata", assetDefs.UpdateAssetShape, async (args: any) => h.updateAsset(args));
170
+ server.tool("transfer_asset_ownership", "Transfer ownership of an asset", assetDefs.TransferAssetOwnershipShape, async (args: any) => h.transferAssetOwnership(args));
171
+ server.tool("whitelist_asset", "Add an asset to the wallet whitelist", assetDefs.WhitelistAssetShape, async (args: any) => h.whitelistAsset(args));
172
+ server.tool("remove_asset_from_whitelist", "Remove an asset from the wallet whitelist", assetDefs.RemoveAssetFromWhitelistShape, async (args: any) => h.removeAssetFromWhitelist(args));
173
+ }
174
+
175
+ function registerSwapTools(server: McpServer, h: SwapHandlers): void {
176
+ server.tool("create_swap_proposal", "Create an ionic swap proposal. Amounts in human-readable units.", swapDefs.CreateSwapProposalShape, async (args: any) => h.createSwapProposal(args));
177
+ server.tool("get_swap_info", "Get details of an ionic swap proposal", swapDefs.GetSwapInfoShape, async (args: any) => h.getSwapInfo(args));
178
+ server.tool("accept_swap", "Accept and execute an ionic swap proposal", swapDefs.AcceptSwapShape, async (args: any) => h.acceptSwap(args));
179
+ }
180
+
181
+ function registerTradeTools(server: McpServer, h: TradeHandlers, hasAuth: boolean): void {
182
+ server.tool("get_trading_pair", "Get trading pair info by ID", tradeDefs.GetTradingPairShape, async (args: any) => h.getTradingPair(args));
183
+ server.tool("get_order_book", "Get order book for a trading pair", tradeDefs.GetOrderBookShape, async (args: any) => h.getOrderBook(args));
184
+
185
+ if (hasAuth) {
186
+ server.tool("create_order", "Create a buy/sell order on the DEX", tradeDefs.CreateOrderShape, async (args: any) => h.createOrder(args));
187
+ server.tool("cancel_order", "Cancel an active order", tradeDefs.CancelOrderShape, async (args: any) => h.cancelOrder(args));
188
+ server.tool("get_my_orders", "Get your active orders for a pair", tradeDefs.GetMyOrdersShape, async (args: any) => h.getMyOrders(args));
189
+ server.tool("apply_order", "Apply to match with another order (initiator role)", tradeDefs.ApplyOrderShape, async (args: any) => h.applyOrder(args));
190
+ server.tool("confirm_trade", "Confirm a finalized trade transaction", tradeDefs.ConfirmTradeShape, async (args: any) => h.confirmTrade(args));
191
+ server.tool("get_active_trade", "Get active transaction by order IDs", tradeDefs.GetActiveTradeShape, async (args: any) => h.getActiveTrade(args));
192
+ server.tool("dex_authenticate", "Authenticate with the Zano Trade API", tradeDefs.DexAuthenticateShape, async (args: any) => h.dexAuthenticate(args));
193
+ }
194
+ }
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+
3
+ const SwapAsset = z.object({
4
+ asset_id: z.string().describe("Asset ID"),
5
+ amount: z.string().describe("Amount in human-readable units"),
6
+ });
7
+
8
+ export const CreateSwapProposalShape = {
9
+ to_finalizer: z
10
+ .array(SwapAsset)
11
+ .describe("Assets to send TO the finalizer (what you give)"),
12
+ to_initiator: z
13
+ .array(SwapAsset)
14
+ .describe("Assets to receive FROM the finalizer (what you get)"),
15
+ destination_address: z.string().describe("Finalizer's Zano address"),
16
+ mixins: z.number().int().default(10).describe("Privacy parameter (default: 10)"),
17
+ fee: z.string().optional().describe("Fee in ZANO human units (default: 0.01)"),
18
+ expiration_time: z.number().int().default(0).describe("Expiration timestamp (0 = no expiry)"),
19
+ };
20
+
21
+ export const GetSwapInfoShape = {
22
+ hex_raw_proposal: z.string().describe("Hex-encoded swap proposal"),
23
+ };
24
+
25
+ export const AcceptSwapShape = {
26
+ hex_raw_proposal: z.string().describe("Hex-encoded swap proposal to accept"),
27
+ };
28
+
29
+ // Schemas and types
30
+ export const CreateSwapProposalSchema = z.object(CreateSwapProposalShape);
31
+ export const GetSwapInfoSchema = z.object(GetSwapInfoShape);
32
+ export const AcceptSwapSchema = z.object(AcceptSwapShape);
33
+
34
+ export type CreateSwapProposalInput = z.infer<typeof CreateSwapProposalSchema>;
35
+ export type GetSwapInfoInput = z.infer<typeof GetSwapInfoSchema>;
36
+ export type AcceptSwapInput = z.infer<typeof AcceptSwapSchema>;
@@ -0,0 +1,139 @@
1
+ import { WalletClient } from "../../clients/wallet.js";
2
+ import {
3
+ humanToAtomic,
4
+ atomicToHuman,
5
+ formatAssetAmount,
6
+ getAssetInfo,
7
+ } from "../../utils/formatting.js";
8
+ import { ZANO_ASSET_ID, ZANO_DECIMALS, DEFAULT_FEE } from "../../utils/constants.js";
9
+ import type {
10
+ CreateSwapProposalInput,
11
+ GetSwapInfoInput,
12
+ AcceptSwapInput,
13
+ } from "./definitions.js";
14
+
15
+ type ToolResult = { content: Array<{ type: "text"; text: string }> };
16
+ function textResult(text: string): ToolResult {
17
+ return { content: [{ type: "text", text }] };
18
+ }
19
+ function errorResult(error: unknown): ToolResult {
20
+ const msg = error instanceof Error ? error.message : String(error);
21
+ return textResult(`Error: ${msg}`);
22
+ }
23
+
24
+ export class SwapHandlers {
25
+ private client: WalletClient;
26
+
27
+ constructor(client: WalletClient) {
28
+ this.client = client;
29
+ }
30
+
31
+ async createSwapProposal(input: CreateSwapProposalInput): Promise<ToolResult> {
32
+ try {
33
+ const toFinalizer = input.to_finalizer.map((a) => {
34
+ const info = getAssetInfo(a.asset_id);
35
+ const decimals = info?.decimals ?? ZANO_DECIMALS;
36
+ return {
37
+ asset_id: a.asset_id,
38
+ amount: humanToAtomic(a.amount, decimals),
39
+ };
40
+ });
41
+
42
+ const toInitiator = input.to_initiator.map((a) => {
43
+ const info = getAssetInfo(a.asset_id);
44
+ const decimals = info?.decimals ?? ZANO_DECIMALS;
45
+ return {
46
+ asset_id: a.asset_id,
47
+ amount: humanToAtomic(a.amount, decimals),
48
+ };
49
+ });
50
+
51
+ const fee = input.fee
52
+ ? humanToAtomic(input.fee, ZANO_DECIMALS)
53
+ : String(DEFAULT_FEE);
54
+
55
+ const res = await this.client.call<{ hex_raw_proposal: string }>(
56
+ "ionic_swap_generate_proposal",
57
+ {
58
+ proposal: {
59
+ to_finalizer: toFinalizer,
60
+ to_initiator: toInitiator,
61
+ mixins: input.mixins,
62
+ fee_paid_by_a: Number(fee),
63
+ expiration_time: input.expiration_time,
64
+ },
65
+ destination_address: input.destination_address,
66
+ },
67
+ );
68
+
69
+ const lines = [
70
+ "Swap Proposal Created",
71
+ "",
72
+ "You send (to finalizer):",
73
+ ];
74
+ for (const a of input.to_finalizer) {
75
+ lines.push(` ${a.amount} ${getAssetInfo(a.asset_id)?.ticker || a.asset_id.slice(0, 12)}`);
76
+ }
77
+ lines.push("", "You receive (from finalizer):");
78
+ for (const a of input.to_initiator) {
79
+ lines.push(` ${a.amount} ${getAssetInfo(a.asset_id)?.ticker || a.asset_id.slice(0, 12)}`);
80
+ }
81
+ lines.push("", `Hex proposal: ${res.hex_raw_proposal.slice(0, 40)}...`);
82
+ lines.push(`Full hex length: ${res.hex_raw_proposal.length} chars`);
83
+
84
+ return textResult(lines.join("\n"));
85
+ } catch (e) {
86
+ return errorResult(e);
87
+ }
88
+ }
89
+
90
+ async getSwapInfo(input: GetSwapInfoInput): Promise<ToolResult> {
91
+ try {
92
+ const res = await this.client.call<{ proposal: Record<string, unknown> }>(
93
+ "ionic_swap_get_proposal_info",
94
+ { hex_raw_proposal: input.hex_raw_proposal },
95
+ );
96
+
97
+ const proposal = res.proposal;
98
+ const lines = ["Swap Proposal Details"];
99
+
100
+ const toFinalizer = (proposal.to_finalizer || []) as Array<{ asset_id: string; amount: string | number }>;
101
+ const toInitiator = (proposal.to_initiator || []) as Array<{ asset_id: string; amount: string | number }>;
102
+
103
+ lines.push("", "Initiator sends (to finalizer):");
104
+ for (const a of toFinalizer) {
105
+ lines.push(` ${formatAssetAmount(a.amount, a.asset_id)}`);
106
+ }
107
+
108
+ lines.push("", "Finalizer sends (to initiator):");
109
+ for (const a of toInitiator) {
110
+ lines.push(` ${formatAssetAmount(a.amount, a.asset_id)}`);
111
+ }
112
+
113
+ lines.push(
114
+ "",
115
+ `Fee: ${proposal.fee_paid_by_a ? atomicToHuman(BigInt(String(proposal.fee_paid_by_a)), ZANO_DECIMALS) + " ZANO" : "N/A"}`,
116
+ `Mixins: ${proposal.mixins || "N/A"}`,
117
+ `Expiration: ${proposal.expiration_time === 0 ? "None" : String(proposal.expiration_time)}`,
118
+ );
119
+
120
+ return textResult(lines.join("\n"));
121
+ } catch (e) {
122
+ return errorResult(e);
123
+ }
124
+ }
125
+
126
+ async acceptSwap(input: AcceptSwapInput): Promise<ToolResult> {
127
+ try {
128
+ const res = await this.client.call<{ result_tx_id: string }>(
129
+ "ionic_swap_accept_proposal",
130
+ { hex_raw_proposal: input.hex_raw_proposal },
131
+ );
132
+ return textResult(
133
+ `Swap accepted and executed!\nTransaction ID: ${res.result_tx_id}`,
134
+ );
135
+ } catch (e) {
136
+ return errorResult(e);
137
+ }
138
+ }
139
+ }
@@ -0,0 +1,67 @@
1
+ import { z } from "zod";
2
+
3
+ export const GetTradingPairShape = {
4
+ id: z.number().int().describe("Trading pair ID"),
5
+ };
6
+
7
+ export const GetOrderBookShape = {
8
+ pairId: z.number().int().describe("Trading pair ID"),
9
+ };
10
+
11
+ export const DexAuthenticateShape = {
12
+ address: z.string().describe("Zano wallet address"),
13
+ alias: z.string().optional().describe("Zano alias (optional)"),
14
+ message: z.string().describe("Message that was signed"),
15
+ signature: z.string().describe("Signature from wallet sign_message"),
16
+ };
17
+
18
+ export const CreateOrderShape = {
19
+ type: z.enum(["buy", "sell"]).describe("Order type"),
20
+ price: z.string().describe("Price per unit"),
21
+ amount: z.string().describe("Amount of asset"),
22
+ pairId: z.number().int().describe("Trading pair ID"),
23
+ };
24
+
25
+ export const CancelOrderShape = {
26
+ orderId: z.number().int().describe("Order ID to cancel"),
27
+ };
28
+
29
+ export const GetMyOrdersShape = {
30
+ pairId: z.number().int().describe("Trading pair ID"),
31
+ };
32
+
33
+ export const ApplyOrderShape = {
34
+ id: z.string().describe("Tip ID (from applyTips)"),
35
+ connected_order_id: z.string().describe("Your order ID that the tip matches"),
36
+ hex_raw_proposal: z.string().describe("Encrypted ionic swap proposal hex"),
37
+ };
38
+
39
+ export const ConfirmTradeShape = {
40
+ transactionId: z.number().int().describe("Transaction ID to confirm"),
41
+ };
42
+
43
+ export const GetActiveTradeShape = {
44
+ firstOrderId: z.number().int().describe("First order ID"),
45
+ secondOrderId: z.number().int().describe("Second order ID"),
46
+ };
47
+
48
+ // Schemas and types
49
+ export const GetTradingPairSchema = z.object(GetTradingPairShape);
50
+ export const GetOrderBookSchema = z.object(GetOrderBookShape);
51
+ export const DexAuthenticateSchema = z.object(DexAuthenticateShape);
52
+ export const CreateOrderSchema = z.object(CreateOrderShape);
53
+ export const CancelOrderSchema = z.object(CancelOrderShape);
54
+ export const GetMyOrdersSchema = z.object(GetMyOrdersShape);
55
+ export const ApplyOrderSchema = z.object(ApplyOrderShape);
56
+ export const ConfirmTradeSchema = z.object(ConfirmTradeShape);
57
+ export const GetActiveTradeSchema = z.object(GetActiveTradeShape);
58
+
59
+ export type GetTradingPairInput = z.infer<typeof GetTradingPairSchema>;
60
+ export type GetOrderBookInput = z.infer<typeof GetOrderBookSchema>;
61
+ export type DexAuthenticateInput = z.infer<typeof DexAuthenticateSchema>;
62
+ export type CreateOrderInput = z.infer<typeof CreateOrderSchema>;
63
+ export type CancelOrderInput = z.infer<typeof CancelOrderSchema>;
64
+ export type GetMyOrdersInput = z.infer<typeof GetMyOrdersSchema>;
65
+ export type ApplyOrderInput = z.infer<typeof ApplyOrderSchema>;
66
+ export type ConfirmTradeInput = z.infer<typeof ConfirmTradeSchema>;
67
+ export type GetActiveTradeInput = z.infer<typeof GetActiveTradeSchema>;