Skip to main content
Glama

ValueRouter MCP Server

estimate_bridge_fees

Calculate bridge transaction fees across multiple blockchain networks using source and destination chain IDs, amount, and optional token address.

Instructions

Estimate fees for a bridge transaction

Input Schema

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

Input Schema (JSON Schema)

{ "additionalProperties": false, "properties": { "amount": { "description": "Amount to bridge", "type": "string" }, "fromChainId": { "description": "Source chain ID", "oneOf": [ { "type": "number" }, { "type": "string" } ] }, "toChainId": { "description": "Destination chain ID", "oneOf": [ { "type": "number" }, { "type": "string" } ] }, "tokenAddress": { "description": "Token address (optional, defaults to USDC)", "type": "string" } }, "required": [ "fromChainId", "toChainId", "amount" ], "type": "object" }

Implementation Reference

  • Primary handler function for the 'estimate_bridge_fees' tool. Parses input arguments, delegates fee estimation to QuoteService, and formats the 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 the listTools response, including name, description, and input schema definition.
    { 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 helper method in QuoteService that performs the actual fee estimation by calculating bridge fee and estimating gas fees.
    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 the amount and configured 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/ transaction fees based on source chain type.
    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