helius_execute_jupiter_swap
Swap tokens on the Solana blockchain using Jupiter DEX by specifying input/output mint addresses, amount, and signer public key. Configure maximum slippage for optimized execution.
Instructions
Execute a token swap using Jupiter
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | The amount of input tokens to swap | |
| inputMint | Yes | The mint address of the input token | |
| maxDynamicSlippageBps | No | Maximum slippage in basis points (optional) | |
| outputMint | Yes | The mint address of the output token | |
| signer | Yes | The signer public key |
Input Schema (JSON Schema)
{
"properties": {
"amount": {
"description": "The amount of input tokens to swap",
"type": "number"
},
"inputMint": {
"description": "The mint address of the input token",
"type": "string"
},
"maxDynamicSlippageBps": {
"description": "Maximum slippage in basis points (optional)",
"type": "number"
},
"outputMint": {
"description": "The mint address of the output token",
"type": "string"
},
"signer": {
"description": "The signer public key",
"type": "string"
}
},
"required": [
"inputMint",
"outputMint",
"amount",
"signer"
],
"type": "object"
}
Implementation Reference
- src/handlers/helius.ts:519-541 (handler)The main handler function implementing the logic to execute a Jupiter token swap using Helius RPC, including input validation and calling the underlying Helius method.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)Tool registration in the tools array including the name, description, and JSON input schema for validation.{ 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/handlers/helius.types.ts:275-281 (schema)TypeScript interface defining the input shape for the executeJupiterSwapHandler.export type ExecuteJupiterSwapInput = { inputMint: string; outputMint: string; amount: number; maxDynamicSlippageBps?: number; signer: string; }
- src/tools.ts:590-590 (registration)Mapping of tool name to its handler function in the central handlers dictionary."helius_execute_jupiter_swap": executeJupiterSwapHandler