import { z } from "zod";
import { getBridgeQuote } from "../services/bridge-api.js";
const schema = z.object({
fromAmountBaseUnit: z
.string()
.describe("Amount to bridge in base units (as string)"),
fromChainId: z.string().describe("Source chain ID"),
fromTokenAddress: z.string().describe("Source token address"),
recipientAddress: z.string().describe("Recipient address"),
toChainId: z.string().describe("Destination chain ID"),
toTokenAddress: z.string().describe("Destination token address"),
});
export const getBridgeQuoteTool = {
name: "get_bridge_quote",
description:
"Get a bridge quote from /quote. Source: token/chain from get_supported_assets. Requires fromAmountBaseUnit and recipientAddress. Example: fromChainId=137, toChainId=137.",
parameters: schema,
execute: async (args: z.infer<typeof schema>) => {
try {
const data = await getBridgeQuote(args);
return JSON.stringify(data, null, 2);
} catch (error) {
return JSON.stringify({ error: error instanceof Error ? error.message : String(error) });
}
},
};