Skip to main content
Glama
RWAValueRouter

ValueRouter MCP Server

estimate_bridge_fees

Calculate bridge transaction fees for transferring tokens between blockchain networks. Provide source and destination chain IDs with amount to estimate costs.

Instructions

Estimate fees for a bridge transaction

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fromChainIdYesSource chain ID
toChainIdYesDestination chain ID
amountYesAmount to bridge
tokenAddressNoToken address (optional, defaults to USDC)

Implementation Reference

  • Primary MCP tool handler for 'estimate_bridge_fees' that extracts arguments and delegates to QuoteService.estimateFees, handles errors and formats response.
    private async estimateBridgeFees(args: any): Promise<MCPToolResult> { try { const { fromChainId, toChainId, amount, tokenAddress } = args; const result = await this.quoteService.estimateFees( fromChainId, toChainId, amount, tokenAddress ); return createSuccessResponse(result); } catch (error) { return createErrorResponse( error instanceof Error ? error.message : String(error), 'FEE_ESTIMATION_ERROR' ); } }
  • src/index.ts:291-323 (registration)
    Tool registration in ListTools handler, including name, description, and input schema.
    { name: 'estimate_bridge_fees', description: 'Estimate fees for a bridge transaction', inputSchema: { type: 'object', properties: { fromChainId: { oneOf: [ { type: 'number' }, { type: 'string' }, ], description: 'Source chain ID', }, toChainId: { oneOf: [ { type: 'number' }, { type: 'string' }, ], description: 'Destination chain ID', }, amount: { type: 'string', description: 'Amount to bridge', }, tokenAddress: { type: 'string', description: 'Token address (optional, defaults to USDC)', }, }, required: ['fromChainId', 'toChainId', 'amount'], additionalProperties: false, }, },
  • Core fee estimation logic called by the tool handler, computes bridge fee and gas fee, returns structured result.
    async estimateFees( fromChainId: SupportedChainId, toChainId: SupportedChainId, amount: string, tokenAddress?: string ): Promise<{ bridgeFee: string; gasFee: string; totalFee: string; }> { const bridgeFee = this.calculateBridgeFee(amount); const gasFee = await this.estimateGasFees(fromChainId, toChainId); return { bridgeFee, gasFee, totalFee: (BigInt(bridgeFee) + BigInt(gasFee)).toString(), }; }
  • Helper function to calculate the bridge fee based on amount and FEE_CONFIG.BRIDGE_FEE_BPS.
    private calculateBridgeFee(amount: string): string { const bridgeFeeAmount = (BigInt(amount) * BigInt(FEE_CONFIG.BRIDGE_FEE_BPS)) / BigInt(10000); return bridgeFeeAmount.toString(); }
  • Helper function to estimate gas fees based on source chain type with hardcoded values.
    private async estimateGasFees(fromChainId: SupportedChainId, toChainId: SupportedChainId): Promise<string> { if (isEVMChain(fromChainId)) { return ethers.utils.parseEther('0.01').toString(); // ~$20-30 on mainnet } else if (isSolanaChain(fromChainId)) { return '5000'; // ~0.000005 SOL } else if (isSuiChain(fromChainId)) { return '1000000'; // ~0.001 SUI } else if (isCosmosChain(fromChainId)) { return '5000'; // varies by chain } return '0'; }

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