Skip to main content
Glama
RWAValueRouter

ValueRouter MCP Server

get_bridge_quote

Obtain a quote for bridging USDC or other tokens between blockchain networks by specifying source and destination chains, tokens, and amount.

Instructions

Get a quote for bridging USDC or other tokens between chains

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromChainIdYesSource chain ID
toChainIdYesDestination chain ID
fromTokenYes
toTokenYes
amountYesAmount to bridge in smallest unit (wei, lamports, etc.)
slippageBpsNoSlippage tolerance in basis points (100 = 1%)
userAddressNoUser address for better quote accuracy (optional)

Implementation Reference

  • Core handler function in QuoteService that computes the bridge quote, including fee calculations, slippage adjustment, and simulated routing.
    async getQuote(request: QuoteRequest): Promise<QuoteResponse> { const { fromChainId, toChainId, fromToken, toToken, amount, slippageBps = 100 } = request; const fromChainIdTyped = fromChainId as SupportedChainId; const toChainIdTyped = toChainId as SupportedChainId; // Validate chains if (!CHAIN_INFO[fromChainIdTyped] || !CHAIN_INFO[toChainIdTyped]) { throw new Error(`Unsupported chain: ${fromChainId} or ${toChainId}`); } // Calculate bridge fees const bridgeFeeAmount = this.calculateBridgeFee(amount); const estimatedGas = await this.estimateGasFees(fromChainIdTyped, toChainIdTyped); // For now, we'll simulate quote calculation // In production, this would call actual DEX aggregators and bridge services const quote = await this.calculateQuote( fromChainIdTyped, toChainIdTyped, fromToken, toToken, amount, slippageBps ); const toAmountBig = BigInt(quote.toAmount); const slippageAmount = (toAmountBig * BigInt(slippageBps)) / BigInt(10000); const toAmountMin = (toAmountBig - slippageAmount).toString(); return { fromChainId, toChainId, fromToken, toToken, fromAmount: amount, toAmount: quote.toAmount, toAmountMin, bridgeFee: bridgeFeeAmount, gasFee: estimatedGas, totalFee: (BigInt(bridgeFeeAmount) + BigInt(estimatedGas)).toString(), estimatedTime: this.estimateCompletionTime(fromChainIdTyped, toChainIdTyped), priceImpact: quote.priceImpact, route: quote.route, validUntil: Date.now() + 60 * 1000, // 1 minute }; }
  • MCP tool handler wrapper that parses input using QuoteRequestSchema and delegates to QuoteService.getQuote.
    private async getBridgeQuote(args: any): Promise<MCPToolResult> { try { const request = QuoteRequestSchema.parse(args); const result = await this.quoteService.getQuote(request); return createSuccessResponse(result); } catch (error) { return createErrorResponse( error instanceof Error ? error.message : String(error), 'QUOTE_ERROR' ); } }
  • Zod schema for validating the input parameters of the get_bridge_quote tool.
    export const QuoteRequestSchema = z.object({ fromChainId: z.union([z.number(), z.string()]), toChainId: z.union([z.number(), z.string()]), fromToken: TokenSchema, toToken: TokenSchema, amount: z.string(), // Amount in smallest unit (wei, lamports, etc.) slippageBps: z.number().optional().default(100), // 1% default slippage userAddress: z.string().optional(), // For better quote accuracy });
  • src/index.ts:100-163 (registration)
    Tool registration in ListTools handler, defining name, description, and input schema for get_bridge_quote.
    { name: 'get_bridge_quote', description: 'Get a quote for bridging USDC or other tokens between chains', inputSchema: { type: 'object', properties: { fromChainId: { oneOf: [ { type: 'number' }, { type: 'string' }, ], description: 'Source chain ID', }, toChainId: { oneOf: [ { type: 'number' }, { type: 'string' }, ], description: 'Destination chain ID', }, fromToken: { type: 'object', properties: { address: { type: 'string' }, chainId: { oneOf: [{ type: 'number' }, { type: 'string' }] }, symbol: { type: 'string' }, name: { type: 'string' }, decimals: { type: 'number' }, logoURI: { type: 'string' }, isNative: { type: 'boolean' }, }, required: ['address', 'chainId', 'symbol', 'name', 'decimals'], }, toToken: { type: 'object', properties: { address: { type: 'string' }, chainId: { oneOf: [{ type: 'number' }, { type: 'string' }] }, symbol: { type: 'string' }, name: { type: 'string' }, decimals: { type: 'number' }, logoURI: { type: 'string' }, isNative: { type: 'boolean' }, }, required: ['address', 'chainId', 'symbol', 'name', 'decimals'], }, amount: { type: 'string', description: 'Amount to bridge in smallest unit (wei, lamports, etc.)', }, slippageBps: { type: 'number', description: 'Slippage tolerance in basis points (100 = 1%)', default: 100, }, userAddress: { type: 'string', description: 'User address for better quote accuracy (optional)', }, }, required: ['fromChainId', 'toChainId', 'fromToken', 'toToken', 'amount'], additionalProperties: false, }, },
  • Key helper method that simulates the quote calculation for direct USDC bridges or swap+bridge routes.
    private async calculateQuote( fromChainId: SupportedChainId, toChainId: SupportedChainId, fromToken: Token, toToken: Token, amount: string, slippageBps: number ): Promise<{ toAmount: string; priceImpact: string; route: { steps: { type: "swap" | "bridge"; chainId: SupportedChainId; fromToken: Token; toToken: Token; amount: string; protocol: string; }[]; }; }> { // For USDC-to-USDC bridging, it's 1:1 minus fees if (fromToken.symbol === 'USDC' && toToken.symbol === 'USDC') { const bridgeFee = this.calculateBridgeFee(amount); const toAmount = (BigInt(amount) - BigInt(bridgeFee)).toString(); return { toAmount, priceImpact: '0.01', // 1% for bridge fee route: { steps: [{ type: "bridge", chainId: fromChainId, fromToken, toToken, amount, protocol: "ValueRouter" }] }, }; } // For other token swaps, we'd need to call external APIs // For now, simulate with some basic calculations const mockToAmount = (BigInt(amount) * BigInt(95) / BigInt(100)).toString(); // 5% slippage simulation return { toAmount: mockToAmount, priceImpact: '0.05', // 5% price impact route: { steps: [ { type: "swap", chainId: fromChainId, fromToken, toToken: { ...toToken, chainId: fromChainId }, amount, protocol: "DEX" }, { type: "bridge", chainId: toChainId, fromToken: { ...toToken, chainId: fromChainId }, toToken, amount: mockToAmount, protocol: "ValueRouter" } ] }, }; }

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/RWAValueRouter/MCP'

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