Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Pyth Data Plugin #2434

Merged
merged 10 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -647,3 +647,40 @@ INSTAGRAM_POST_INTERVAL_MAX=120 # Default: 120 minutes
INSTAGRAM_ENABLE_ACTION_PROCESSING=false # Enable/disable action processing
INSTAGRAM_ACTION_INTERVAL=5 # Interval between actions in minutes
INSTAGRAM_MAX_ACTIONS=1 # Maximum number of actions to process at once

####################################
#### Pyth Plugin Configuration ####
####################################
# Network Environment (mainnet or testnet)git
PYTH_NETWORK_ENV=mainnet

# Mainnet Network Configuration
PYTH_MAINNET_HERMES_URL=https://hermes.pyth.network
PYTH_MAINNET_WSS_URL=wss://hermes.pyth.network/ws
PYTH_MAINNET_PYTHNET_URL=https://pythnet.rpcpool.com
PYTH_MAINNET_CONTRACT_REGISTRY=https://pyth.network/developers/price-feed-ids
PYTH_MAINNET_PROGRAM_KEY=

# Testnet Network Configuration
PYTH_TESTNET_HERMES_URL=https://hermes.pyth.network
PYTH_TESTNET_WSS_URL=wss://hermes.pyth.network/ws
PYTH_TESTNET_PYTHNET_URL=https://pythnet.rpcpool.com
PYTH_TESTNET_CONTRACT_REGISTRY=https://pyth.network/developers/price-feed-ids#testnet
PYTH_TESTNET_PROGRAM_KEY=

# Connection Settings
PYTH_MAX_RETRIES=3
PYTH_RETRY_DELAY=1000
PYTH_TIMEOUT=5000
PYTH_GRANULAR_LOG=true
PYTH_LOG_LEVEL=debug
PYTH_LOG_LEVEL=info

# Runtime Settings
RUNTIME_CHECK_MODE=false

# Pyth Price Streaming and test ID
PYTH_ENABLE_PRICE_STREAMING=true
PYTH_MAX_PRICE_STREAMS=2
PYTH_TEST_ID01=0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43
PYTH_TEST_ID02=0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace
13 changes: 12 additions & 1 deletion agent/package.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lots of duplicate keys

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all fixed.
Git exploded

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@elizaos/agent",
"version": "0.1.9-alpha.1",
"version": "0.1.9-alpha.1",
"main": "src/index.ts",
"type": "module",
"scripts": {
Expand Down Expand Up @@ -31,14 +32,18 @@
"@elizaos/client-telegram": "workspace:*",
"@elizaos/client-twitter": "workspace:*",
"@elizaos/client-instagram": "workspace:*",
"@elizaos/client-instagram": "workspace:*",
"@elizaos/client-slack": "workspace:*",
"@elizaos/core": "workspace:*",
"@elizaos/plugin-0g": "workspace:*",
"@elizaos/plugin-abstract": "workspace:*",
"@elizaos/plugin-agentkit": "workspace:*",
"@elizaos/plugin-agentkit": "workspace:*",
"@elizaos/plugin-aptos": "workspace:*",
"@elizaos/plugin-birdeye": "workspace:*",
"@elizaos/plugin-coingecko": "workspace:*",
"@elizaos/plugin-birdeye": "workspace:*",
"@elizaos/plugin-coingecko": "workspace:*",
"@elizaos/plugin-coinmarketcap": "workspace:*",
"@elizaos/plugin-binance": "workspace:*",
"@elizaos/plugin-avail": "workspace:*",
Expand All @@ -53,6 +58,7 @@
"@elizaos/plugin-gitbook": "workspace:*",
"@elizaos/plugin-story": "workspace:*",
"@elizaos/plugin-gitcoin-passport": "workspace:*",
"@elizaos/plugin-gitcoin-passport": "workspace:*",
"@elizaos/plugin-goat": "workspace:*",
"@elizaos/plugin-lensNetwork": "workspace:*",
"@elizaos/plugin-icp": "workspace:*",
Expand All @@ -63,8 +69,10 @@
"@elizaos/plugin-node": "workspace:*",
"@elizaos/plugin-solana": "workspace:*",
"@elizaos/plugin-injective": "workspace:*",
"@elizaos/plugin-injective": "workspace:*",
"@elizaos/plugin-solana-agentkit": "workspace:*",
"@elizaos/plugin-squid-router": "workspace:*",
"@elizaos/plugin-squid-router": "workspace:*",
"@elizaos/plugin-autonome": "workspace:*",
"@elizaos/plugin-starknet": "workspace:*",
"@elizaos/plugin-stargaze": "workspace:*",
Expand All @@ -88,10 +96,12 @@
"@elizaos/plugin-video-generation": "workspace:*",
"@elizaos/plugin-web-search": "workspace:*",
"@elizaos/plugin-dexscreener": "workspace:*",
"@elizaos/plugin-dexscreener": "workspace:*",
"@elizaos/plugin-letzai": "workspace:*",
"@elizaos/plugin-thirdweb": "workspace:*",
"@elizaos/plugin-genlayer": "workspace:*",
"@elizaos/plugin-tee-verifiable-log": "workspace:*",
"@elizaos/plugin-tee-verifiable-log": "workspace:*",
"@elizaos/plugin-depin": "workspace:*",
"@elizaos/plugin-open-weather": "workspace:*",
"@elizaos/plugin-obsidian": "workspace:*",
Expand All @@ -103,6 +113,7 @@
"@elizaos/plugin-quai": "workspace:*",
"@elizaos/plugin-b2": "workspace:*",
"@elizaos/plugin-nft-collections": "workspace:*",
"@elizaos/plugin-pyth-data": "workspace:*",
"readline": "1.3.0",
"ws": "8.18.0",
"yargs": "17.7.2"
Expand All @@ -114,4 +125,4 @@
"ts-node": "10.9.2",
"tsup": "8.3.5"
}
}
}
6 changes: 5 additions & 1 deletion agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { zgPlugin } from "@elizaos/plugin-0g";
import { bootstrapPlugin } from "@elizaos/plugin-bootstrap";
import createGoatPlugin from "@elizaos/plugin-goat";
// import { intifacePlugin } from "@elizaos/plugin-intiface";
import { DirectClient } from "@elizaos/client-direct";
AIFlowML marked this conversation as resolved.
Show resolved Hide resolved
import { ThreeDGenerationPlugin } from "@elizaos/plugin-3d-generation";
import { abstractPlugin } from "@elizaos/plugin-abstract";
import { akashPlugin } from "@elizaos/plugin-akash";
Expand Down Expand Up @@ -103,6 +102,7 @@ import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
import { hyperliquidPlugin } from "@elizaos/plugin-hyperliquid";
import { echoChambersPlugin } from "@elizaos/plugin-echochambers";
import { dexScreenerPlugin } from "@elizaos/plugin-dexscreener";
import { pythDataPlugin } from "@elizaos/plugin-pyth-data";

import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
import Database from "better-sqlite3";
Expand Down Expand Up @@ -1018,6 +1018,10 @@ export async function createAgent(
getSecret(character, "RESERVOIR_API_KEY")
? createNFTCollectionsPlugin()
: null,
getSecret(character, "PYTH_TESTNET_PROGRAM_KEY") ||
getSecret(character, "PYTH_MAINNET_PROGRAM_KEY")
? pythDataPlugin
: null,
].filter(Boolean),
providers: [],
actions: [],
Expand Down
2 changes: 1 addition & 1 deletion characters/dobby.character.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Dobby",
"clients": [],
"modelProvider": "anthropic",
"modelProvider": "openai",
"settings": {
"voice": {
"model": "en_GB-danny-low"
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-iq6900/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "dist/index.d.ts",
"dependencies": {
"@elizaos/core": "workspace:*",
"@solana/web3.js": "1.95.8"
"@solana/web3.js": "^1.95.8"
},
"devDependencies": {
"tsup": "8.3.5",
Expand Down
17 changes: 6 additions & 11 deletions packages/plugin-iq6900/src/functions/bringIQData.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { elizaLogger } from "@elizaos/core";

import { Connection, PublicKey } from "@solana/web3.js";
const network = process.env.IQSOlRPC||"https://api.mainnet-beta.solana.com";
const network = process.env.IQSOlRPC || "https://api.mainnet-beta.solana.com";
const stringAddress = process.env.IQ_WALLET_ADDRESS;

const connection = new Connection(network, "confirmed");
Expand All @@ -10,18 +10,14 @@ const iqHost = "https://solanacontractapi.uc.r.appspot.com";

async function fetchDBPDA(): Promise<string> {
try {
if(stringAddress){
if (stringAddress) {
elizaLogger.info("Connecting to Solana...(IQ6900)");
elizaLogger.info("Your Address:" + stringAddress);
const response = await fetch(`${iqHost}/getDBPDA/${stringAddress}`);
const data = await response.json();
if (response.ok) {
return data.DBPDA as string;
} else {
throw new Error(data.error || "Failed to fetch PDA");
}
}else{
return "null";
}
} catch (error) {
console.error("Error fetching PDA:", error);
Expand Down Expand Up @@ -160,8 +156,8 @@ async function fetchSignaturesForAddress(
}

async function findRecentJsonSignature(): Promise<string> {

const dbAddress = await fetchDBPDA();
if (!dbAddress) return;
const signatures = await fetchSignaturesForAddress(
new PublicKey(dbAddress)
);
Expand All @@ -170,15 +166,14 @@ async function findRecentJsonSignature(): Promise<string> {
const commit = await extractCommitMessage(signature);
if (commit !== "null") return signature;
}
return "null";
return;
}

export async function bringAgentWithWalletAddress() {

const recent = await findRecentJsonSignature();
if (recent === "null") {
if (!recent) {
elizaLogger.error("Cannot found onchain data in this wallet.");
return "null";
return;
}
const result = await bringCode(recent);
const json_string = result.json_data;
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-nft-generation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
"@openzeppelin/contracts": "^5.1.0",
"@solana-developers/helpers": "^2.5.6",
"@solana/web3.js": "1.95.5",
"@solana/web3.js": "1.95.8",
"axios": "^1.7.9",
"bs58": "6.0.0",
"express": "4.21.1",
Expand Down
Binary file added packages/plugin-pyth-data/assets/Pyth.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions packages/plugin-pyth-data/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import eslintGlobalConfig from "../../eslint.config.mjs";

export default [
...eslintGlobalConfig,
{
files: ["src/**/*.ts"],
rules: {
// Disable problematic rules
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-call": "off",
},
},
];
59 changes: 59 additions & 0 deletions packages/plugin-pyth-data/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "@elizaos/plugin-pyth-data",
"version": "1.0.0",
"description": "Pyth Network data plugin for Eliza",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsup --format esm --dts",
"test": "vitest",
"lint": "eslint src --ext .ts",
"clean": "rimraf dist",
"build:schemas": "openapi-zod-client ./schema.json --output src/types/zodSchemas.ts",
"pull:schema": "curl -o schema.json -z schema.json https://hermes.pyth.network/docs/openapi.json",
"prebuild": "pnpm run pull:schema && pnpm run build:schemas"
},
"dependencies": {
"@elizaos/core": "^0.1.7",
"@pythnetwork/client": "^2.22.0",
"@pythnetwork/hermes-client": "^1.3.0",
"@solana/web3.js": "1.95.8",
"@zodios/core": "^10.9.6",
"ajv": "^8.12.0",
"buffer": "6.0.3",
"chalk": "^5.4.1",
"cli-table3": "^0.6.5",
"cross-fetch": "^4.0.0",
"eventsource": "^3.0.2",
"jstat": "^1.9.6",
"ora": "^8.1.1",
"zod": "^3.23.8"
},
"devDependencies": {
"@types/node": "^20.8.2",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"eslint": "^8.50.0",
"openapi-zod-client": "^1.18.1",
"rimraf": "^5.0.5",
"tsup": "^8.0.0",
"typescript": "^5.2.2",
"vitest": "^1.0.0"
},
"peerDependencies": {
"@elizaos/core": "^0.1.7"
},
"engines": {
"node": ">=16.0.0"
},
"keywords": [
"eliza",
"plugin",
"pyth",
"oracle",
"price-feed"
],
"author": "Eliza Team",
"license": "MIT"
}
Loading
Loading