forked from elizaOS/eliza
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
330 additions
and
21 deletions.
There are no files selected for viewing
206 changes: 206 additions & 0 deletions
206
packages/plugin-depin/src/actions/fetchDepinscanData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
import { | ||
elizaLogger, | ||
generateText, | ||
HandlerCallback, | ||
ModelClass, | ||
type IAgentRuntime, | ||
type Memory, | ||
type State, | ||
} from "@ai16z/eliza"; | ||
|
||
import { DepinDataProvider } from "../providers/depinData"; | ||
import { DepinScanMetrics, DepinScanProject } from "../types/depin"; | ||
|
||
export const fetchDepinscanDataAction = { | ||
name: "DEPINSCAN_DATA", | ||
description: "Fetches metrics and projects data from DePINScan", | ||
handler: async ( | ||
runtime: IAgentRuntime, | ||
_message: Memory, | ||
state: State, | ||
_options: any, | ||
callback?: HandlerCallback | ||
) => { | ||
elizaLogger.log("Fetch DePINScan action handler called"); | ||
|
||
try { | ||
const metrics = await DepinDataProvider.fetchDepinscanMetrics(); | ||
const projects = await DepinDataProvider.fetchDepinscanProjects(); | ||
|
||
const response = await generateText({ | ||
runtime, | ||
context: depinAnalysisTemplate(state, metrics, projects), | ||
modelClass: ModelClass.LARGE, | ||
}); | ||
|
||
if (callback) { | ||
callback({ | ||
text: response, | ||
content: { | ||
success: true, | ||
metrics, | ||
projects: JSON.stringify(projects, (key, value) => | ||
typeof value === "bigint" ? value.toString() : value | ||
), | ||
}, | ||
}); | ||
} | ||
|
||
return true; | ||
} catch (error) { | ||
console.error("Error during DePINScan data fetching:", error); | ||
if (callback) { | ||
callback({ | ||
text: `Error fetching DePINScan data: ${error.message}`, | ||
content: { error: error.message }, | ||
}); | ||
} | ||
return false; | ||
} | ||
}, | ||
validate: async (_runtime: IAgentRuntime) => { | ||
return true; | ||
}, | ||
examples: [ | ||
[ | ||
{ | ||
user: "user", | ||
content: { | ||
text: "Which DePIN project has the highest market cap?", | ||
}, | ||
}, | ||
{ | ||
user: "assistant", | ||
content: { | ||
text: "The DePIN project with the highest market cap is Solana, with a market cap of $106,247,097,756.01.", | ||
action: "DEPINSCAN_DATA", | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
user: "user", | ||
content: { | ||
text: "Show me all projects running on Solana.", | ||
}, | ||
}, | ||
{ | ||
user: "assistant", | ||
content: { | ||
text: "The following projects are running on Solana: Solana and Render.", | ||
action: "DEPINSCAN_DATA", | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
user: "user", | ||
content: { | ||
text: "What are the categories of the Render project?", | ||
}, | ||
}, | ||
{ | ||
user: "assistant", | ||
content: { | ||
text: "The Render project belongs to the following categories: Server, AI.", | ||
action: "DEPINSCAN_DATA", | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
user: "user", | ||
content: { | ||
text: "Compare the token prices of Solana and Render.", | ||
}, | ||
}, | ||
{ | ||
user: "assistant", | ||
content: { | ||
text: "Solana (SOL) is priced at $221.91, while Render (RNDR) is priced at $9.02.", | ||
action: "DEPINSCAN_DATA", | ||
}, | ||
}, | ||
], | ||
[ | ||
{ | ||
user: "user", | ||
content: { | ||
text: "What is the network status of all listed projects?", | ||
}, | ||
}, | ||
{ | ||
user: "assistant", | ||
content: { | ||
text: "Both Solana and Render are currently on the Mainnet.", | ||
action: "DEPINSCAN_DATA", | ||
}, | ||
}, | ||
], | ||
], | ||
similes: [ | ||
"ANALYZE_PROJECTS", | ||
"FILTER_PROJECTS", | ||
"GET_PROJECT_CATEGORIES", | ||
"COMPARE_TOKEN_PRICES", | ||
"GET_NETWORK_STATUS", | ||
], | ||
}; | ||
|
||
const depinAnalysisTemplate = ( | ||
state: State, | ||
metrics: DepinScanMetrics, | ||
projects: DepinScanProject | ||
) => | ||
` | ||
### 📊 DePIN Analysis Request | ||
#### 🗂️ **State Information** | ||
\`\`\` | ||
${state} | ||
\`\`\` | ||
#### 📈 **Metrics Data** | ||
\`\`\` | ||
${metrics} | ||
\`\`\` | ||
#### 🏗️ **Projects Data** | ||
\`\`\` | ||
${JSON.stringify(projects, (key, value) => | ||
typeof value === "bigint" ? value.toString() : value | ||
)} | ||
\`\`\` | ||
--- | ||
### 📝 **Instructions for the Agent** | ||
Based on the state information, metrics, and project data provided above, perform the analysis requested by the user. | ||
While focusing on the user's specific request, you may optionally include the following types of analysis if relevant: | ||
1. **Top Projects by Market Cap**: | ||
- Identify the projects with the highest market capitalization and list them in descending order. | ||
2. **Token Price Insights**: | ||
- Compare the token prices of different projects and highlight any significant differences. | ||
3. **Network Status Overview**: | ||
- Group the projects based on their network status (e.g., Mainnet, Testnet). | ||
4. **Layer 1 Distribution**: | ||
- Analyze how many projects are deployed on each Layer 1 blockchain. | ||
5. **Categories Breakdown**: | ||
- List the different categories each project belongs to and summarize the focus areas. | ||
6. **Key Insights**: | ||
- Provide high-level observations based on the data, such as trends, notable outliers, or potential opportunities. | ||
--- | ||
### 🎯 **Agent’s Objective** | ||
Prioritize delivering the analysis requested by the user. Include additional insights or analysis types from the list above **only if they support or enhance the user’s request**. | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import type { Plugin } from "@ai16z/eliza"; | ||
|
||
import { depinDataProvider } from "./providers/depinData"; | ||
import { fetchDepinscanDataAction } from "./actions/fetchDepinscanData"; | ||
|
||
export const depinPlugin: Plugin = { | ||
name: "depin", | ||
description: "DePIN plugin", | ||
providers: [depinDataProvider], | ||
evaluators: [], | ||
services: [], | ||
actions: [], | ||
actions: [fetchDepinscanDataAction], | ||
}; | ||
|
||
export default depinPlugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
export const mockDepinscanMetrics = [ | ||
{ | ||
date: "2024-12-17", | ||
total_projects: "291", | ||
market_cap: "36046044620.57570635160", | ||
total_device: "19416950", | ||
}, | ||
]; | ||
|
||
export const mockDepinscanProjects = [ | ||
{ | ||
project_name: "Solana", | ||
slug: "solana", | ||
logo: "https://depinscan-prod.s3.us-east-1.amazonaws.com/next-s3-uploads/3160a9ec-42df-4f02-9db6-5aadc61323d8/solana.svg", | ||
description: | ||
"Solana is a general purpose layer 1 blockchain that works well for DePIN (decentralized physical infrastructure Network) projects due to its low transaction cost, high-throughput speed, scalability and existing Solana DePIN ecosystem. The most renowned Solana DePIN projects include Helium, Hivemapper and Render.", | ||
trusted_metric: true, | ||
token: "SOL", | ||
layer_1: ["Solana"], | ||
categories: ["Chain"], | ||
market_cap: "106247097756.0147", | ||
token_price: "221.91", | ||
total_devices: 0, | ||
network_status: "Mainnet", | ||
avg_device_cost: "", | ||
days_to_breakeven: "", | ||
estimated_daily_earnings: "", | ||
chainid: "", | ||
coingecko_id: "solana", | ||
fully_diluted_valuation: "131508718985", | ||
}, | ||
{ | ||
project_name: "Render", | ||
slug: "render", | ||
logo: "https://depinscan-prod.s3.amazonaws.com/depin/9e5f0bb330344d580b9e30d338d6ab6d.png", | ||
description: | ||
"Render is a decentralized rendering platform supporting next-generation media production.", | ||
trusted_metric: true, | ||
token: "RNDR", | ||
layer_1: ["Solana"], | ||
categories: ["Server", "AI"], | ||
market_cap: "4659773671.856073", | ||
token_price: "9.02", | ||
total_devices: 0, | ||
network_status: "Mainnet", | ||
avg_device_cost: "", | ||
days_to_breakeven: "", | ||
estimated_daily_earnings: "", | ||
chainid: "1", | ||
coingecko_id: "render-token", | ||
fully_diluted_valuation: "4705509105", | ||
}, | ||
]; |
Oops, something went wrong.