pharos-agent-kit
Version:
Connect AI Agents to Pharos protocols
58 lines • 1.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const zod_1 = require("zod");
const fetchPriceAction = {
name: "DEFILLAMA_FETCH_PRICE",
similes: [
"get token price",
"fetch price",
"check token price",
"get price from defillama",
],
description: "Fetches the price of one or more tokens using the DeFiLlama price API. Tokens are specified using chain:address format.",
examples: [
[
{
input: {
chainTokenAddrStrings: [
"ethereum:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
],
// searchWidth: "6h"
},
output: {
status: "success",
summary: {
prices: {
"ethereum:0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2": 1829,
},
},
},
explanation: "The user wants to fetch the price of WETH on Ethereum. The action returns the current price in USD.",
},
],
],
schema: zod_1.z.object({
chainTokenAddrStrings: zod_1.z
.array(zod_1.z.string())
.describe('Array of strings in format of "chain:token_address" (e.g. "ethereum:0x0000000000000000000000000000000000000000")'),
}),
handler: async (agent, input) => {
try {
const prices = await agent.fetchTokenPrices(input.chainTokenAddrStrings);
return {
status: "success",
summary: {
prices,
},
};
}
catch (error) {
return {
status: "error",
error: error.message,
};
}
},
};
exports.default = fetchPriceAction;
//# sourceMappingURL=fetch_price_action.js.map