Skip to main content
Glama

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

NameRequiredDescriptionDefault
amountYesThe amount of input tokens to swap
inputMintYesThe mint address of the input token
maxDynamicSlippageBpsNoMaximum slippage in basis points (optional)
outputMintYesThe mint address of the output token
signerYesThe 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

  • 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)}`); } }
  • 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'] } }
  • 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dcSpark/mcp-server-helius'

If you have feedback or need assistance with the MCP directory API, please join our Discord server