execute_swap
Execute cryptocurrency swap transactions using pre-quoted data to complete trades across multiple blockchains.
Instructions
Execute a swap transaction (requires quote data)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| quoteData | Yes | Quote data from get_swap_quote |
Implementation Reference
- src/toolService.js:72-109 (handler)The primary handler function for the 'execute_swap' tool. It validates the quoteData and user private key, extracts the chainId, signs the transaction, broadcasts it via BlockchainService, and returns success details with transaction hash.async executeSwap(quoteData) { if (!quoteData) { throw new Error("Quote data is required for swap execution"); } if (!this.userPrivateKey) { throw new Error("User private key is required for swap execution"); } try { // Extract chain ID from quote data const chainId = quoteData.chainId || quoteData.transaction?.chainId; if (!chainId) { throw new Error("Chain ID not found in quote data"); } console.log("š Executing swap transaction..."); // Sign and broadcast the transaction using blockchain service const result = await this.blockchain.signAndBroadcastTransaction( chainId, quoteData ); return { message: "Swap executed successfully", data: result, nextSteps: [ "1. Transaction has been broadcasted to the blockchain", "2. Wait for confirmation (usually 1-3 minutes)", "3. Check transaction status on block explorer", `4. Transaction hash: ${result.hash}`, ], }; } catch (error) { throw new Error(`Swap execution failed: ${error.message}`); } }
- src/index.js:157-170 (schema)The input schema definition for the 'execute_swap' tool, specifying that it requires an object 'quoteData' from the prior get_swap_quote tool.{ name: TOOL_NAMES.EXECUTE_SWAP, description: "Execute a swap transaction (requires quote data)", inputSchema: { type: "object", properties: { quoteData: { type: "object", description: "Quote data from get_swap_quote", }, }, required: ["quoteData"], }, },
- src/index.js:992-994 (registration)The dispatch/registration case in the main tool handler switch statement that routes calls to 'execute_swap' to the ToolService.executeSwap method.case TOOL_NAMES.EXECUTE_SWAP: result = await toolService.executeSwap(args.quoteData); break;
- src/constants.js:6-6 (registration)Constant definition mapping EXECUTE_SWAP to the tool name string 'execute_swap' used throughout the codebase.EXECUTE_SWAP: "execute_swap",