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
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Amount to bridge | |
| fromChainId | Yes | Source chain ID | |
| toChainId | Yes | Destination chain ID | |
| tokenAddress | No | Token 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
- src/index.ts:460-476 (handler)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, }, },
- src/services/quote.ts:107-125 (helper)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(), }; }
- src/services/quote.ts:190-193 (helper)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(); }
- src/services/quote.ts:195-207 (helper)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'; }