Fix formatting issues and removing unusued libaries

This commit is contained in:
Fahri Bilici
2024-12-30 22:31:15 +01:00
parent 3b4fddd65a
commit c00515f3d2
35 changed files with 574 additions and 662 deletions

View File

@@ -1,8 +1,6 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { PriceServiceConnection } from "@pythnetwork/price-service-client";
import BN from "bn.js";
import { pythFetchPrice } from "../tools";
const pythFetchPriceAction: Action = {
@@ -13,28 +11,29 @@ const pythFetchPriceAction: Action = {
"pyth oracle price",
"fetch from pyth",
"pyth price feed",
"oracle price"
"oracle price",
],
description: "Fetch the current price from a Pyth oracle price feed",
examples: [
[
{
input: {
priceFeedId: "Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD" // SOL/USD price feed
priceFeedId: "Gnt27xtC473ZT2Mw5u8wZ68Z3gULkSTb5DuxJy7eJotD", // SOL/USD price feed
},
output: {
status: "success",
price: "23.45",
message: "Current price: $23.45"
message: "Current price: $23.45",
},
explanation: "Get the current SOL/USD price from Pyth oracle"
}
]
explanation: "Get the current SOL/USD price from Pyth oracle",
},
],
],
schema: z.object({
priceFeedId: z.string()
priceFeedId: z
.string()
.min(1)
.describe("The Pyth price feed ID to fetch the price from")
.describe("The Pyth price feed ID to fetch the price from"),
}),
handler: async (_agent: SolanaAgentKit, input: Record<string, any>) => {
try {
@@ -45,15 +44,15 @@ const pythFetchPriceAction: Action = {
return {
status: "success",
price: priceStr,
message: `Current price: $${priceStr}`
message: `Current price: $${priceStr}`,
};
} catch (error: any) {
return {
status: "error",
message: `Failed to fetch price from Pyth: ${error.message}`
message: `Failed to fetch price from Pyth: ${error.message}`,
};
}
}
},
};
export default pythFetchPriceAction;
export default pythFetchPriceAction;