helius_execute_jupiter_swap
Swap tokens on Solana using Jupiter DEX aggregator. Specify input/output tokens, amount, and signer to execute trades.
Instructions
Execute a token swap using Jupiter
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inputMint | Yes | The mint address of the input token | |
| outputMint | Yes | The mint address of the output token | |
| amount | Yes | The amount of input tokens to swap | |
| maxDynamicSlippageBps | No | Maximum slippage in basis points (optional) | |
| signer | Yes | The signer public key |
Implementation Reference
- src/handlers/helius.ts:519-541 (handler)The main handler function that executes the Jupiter swap using Helius RPC, validates inputs, calls rpc.executeJupiterSwap, and handles responses/errors.export const executeJupiterSwapHandler = async (input: ExecuteJupiterSwapInput): Promise<ToolResultSchema> => { try { // Validate the signer is a valid public key format const signerPublicKey = validatePublicKey(input.signer); if (!(signerPublicKey instanceof PublicKey)) { return signerPublicKey; } const params = { inputMint: input.inputMint, outputMint: input.outputMint, amount: input.amount, maxDynamicSlippageBps: input.maxDynamicSlippageBps }; // The actual implementation expects a Signer object, but our mock likely accepts a string // We'll use the string and let the type casting handle it const result = await (helius as any as Helius).rpc.executeJupiterSwap(params, input.signer as any); return createSuccessResponse(`Jupiter swap executed: ${JSON.stringify(result, null, 2)}`); } catch (error) { return createErrorResponse(`Error executing Jupiter swap: ${error instanceof Error ? error.message : String(error)}`); } }
- src/tools.ts:516-530 (schema)Input schema definition for the 'helius_execute_jupiter_swap' tool, defining parameters like inputMint, outputMint, amount, slippage, and signer.{ name: 'helius_execute_jupiter_swap', description: 'Execute a token swap using Jupiter', inputSchema: { type: 'object', properties: { inputMint: { type: 'string', description: 'The mint address of the input token' }, outputMint: { type: 'string', description: 'The mint address of the output token' }, amount: { type: 'number', description: 'The amount of input tokens to swap' }, maxDynamicSlippageBps: { type: 'number', description: 'Maximum slippage in basis points (optional)' }, signer: { type: 'string', description: 'The signer public key' } }, required: ['inputMint', 'outputMint', 'amount', 'signer'] } }
- src/tools.ts:590-590 (registration)Registration of the tool name to its handler function in the handlers dictionary."helius_execute_jupiter_swap": executeJupiterSwapHandler
- src/handlers/helius.types.ts:275-281 (schema)TypeScript type definition for the ExecuteJupiterSwapInput used in the handler function signature.export type ExecuteJupiterSwapInput = { inputMint: string; outputMint: string; amount: number; maxDynamicSlippageBps?: number; signer: string; }