pharos-agent-kit
Version:
Connect AI Agents to Pharos protocols
43 lines • 1.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchPriceTool = fetchPriceTool;
const tools_1 = require("@langchain/core/tools");
const zod_1 = require("zod");
const tools_2 = require("../../tools");
function fetchPriceTool(_agent) {
return new tools_1.DynamicStructuredTool({
name: "fetch_price",
description: "Fetch the price of a token",
schema: zod_1.z.object({
chainTokenAddrStrings: zod_1.z
.array(zod_1.z.string())
.describe('String array of strings in format of "chain:token_address" (e.g. "ethereum:0x0000000000000000000000000000000000000000")'),
searchWidth: zod_1.z
.string()
.optional()
.describe("The width of the search window for the price data. Default is '6h'"),
}),
func: async (input) => {
try {
const { chainTokenAddrStrings, searchWidth } = input;
const prices = await (0, tools_2.fetchPrices)({
chainTokenAddrStrings,
searchWidth,
});
return {
prices,
status: "success",
};
}
catch (error) {
return {
status: "error",
summary: {
error: error.message,
},
};
}
},
});
}
//# sourceMappingURL=fetch_price.js.map