mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-23 23:26:45 +00:00
Fix formatting issues and removing unusued libaries
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user