Skip to content

Commit 9ce407a

Browse files
authored
Merge pull request #15 from elizaOS/feat/defi-plugins
add defi plugins
2 parents 878620b + 2f4f8b5 commit 9ce407a

File tree

12 files changed

+2342
-1
lines changed

12 files changed

+2342
-1
lines changed

docs.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,31 @@
296296
]
297297
}
298298
]
299+
},
300+
{
301+
"group": "DeFi Plugins",
302+
"pages": [
303+
{
304+
"group": "EVM",
305+
"pages": [
306+
"plugins/defi/evm",
307+
"plugins/defi/evm/complete-documentation",
308+
"plugins/defi/evm/defi-operations-flow",
309+
"plugins/defi/evm/examples",
310+
"plugins/defi/evm/testing-guide"
311+
]
312+
},
313+
{
314+
"group": "Solana",
315+
"pages": [
316+
"plugins/defi/solana",
317+
"plugins/defi/solana/complete-documentation",
318+
"plugins/defi/solana/defi-operations-flow",
319+
"plugins/defi/solana/examples",
320+
"plugins/defi/solana/testing-guide"
321+
]
322+
}
323+
]
299324
}
300325
]
301326
}

plugins/defi/evm.mdx

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
---
2+
title: "Overview"
3+
description: "Integrate EVM blockchain capabilities into your AI agent"
4+
---
5+
6+
The EVM plugin enables AI agents to interact with Ethereum Virtual Machine (EVM) compatible blockchains, supporting token transfers, swaps, bridging, and governance operations across 30+ networks.
7+
8+
## Features
9+
10+
- **Multi-chain Support**: Works with Ethereum, Base, Arbitrum, Optimism, Polygon, BSC, Avalanche, and many more
11+
- **Token Operations**: Transfer native tokens and ERC20 tokens
12+
- **DeFi Integration**: Swap tokens and bridge across chains using LiFi and Bebop
13+
- **Governance**: Create proposals, vote, queue, and execute governance actions
14+
- **Wallet Management**: Multi-chain balance tracking with automatic updates
15+
- **TEE Support**: Secure wallet derivation in Trusted Execution Environments
16+
17+
## Installation
18+
19+
```bash
20+
bun install @elizaos/plugin-evm
21+
```
22+
23+
## Configuration
24+
25+
The plugin requires the following environment variables:
26+
27+
```env
28+
# Required
29+
EVM_PRIVATE_KEY=your_private_key_here
30+
31+
# Optional - Custom RPC endpoints
32+
ETHEREUM_PROVIDER_ETHEREUM=https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY
33+
ETHEREUM_PROVIDER_BASE=https://base-mainnet.g.alchemy.com/v2/YOUR_KEY
34+
35+
# Optional - TEE Configuration
36+
TEE_MODE=true
37+
WALLET_SECRET_SALT=your_secret_salt
38+
```
39+
40+
## Usage
41+
42+
```typescript
43+
import { evmPlugin } from '@elizaos/plugin-evm';
44+
import { AgentRuntime } from '@elizaos/core';
45+
46+
// Initialize the agent with EVM plugin
47+
const runtime = new AgentRuntime({
48+
plugins: [evmPlugin],
49+
// ... other configuration
50+
});
51+
```
52+
53+
## Actions
54+
55+
### Transfer Tokens
56+
Transfer native tokens or ERC20 tokens between addresses.
57+
58+
Example prompts:
59+
- "Send 0.1 ETH to 0x742d35Cc6634C0532925a3b844Bc454e4438f44e"
60+
- "Transfer 100 USDC to vitalik.eth on Base"
61+
- "Send 50 DAI to 0x123... on Polygon"
62+
63+
### Swap Tokens
64+
Exchange tokens on the same chain using optimal routes.
65+
66+
Example prompts:
67+
- "Swap 1 ETH for USDC"
68+
- "Exchange 100 USDT for DAI on Arbitrum"
69+
- "Trade my WETH for USDC on Base"
70+
71+
### Bridge Tokens
72+
Transfer tokens across different chains.
73+
74+
Example prompts:
75+
- "Bridge 100 USDC from Ethereum to Arbitrum"
76+
- "Move 0.5 ETH from Base to Optimism"
77+
- "Transfer DAI from Polygon to Ethereum"
78+
79+
### Governance Actions
80+
Participate in DAO governance using OpenZeppelin Governor contracts.
81+
82+
Example prompts:
83+
- "Create a proposal to increase the treasury allocation"
84+
- "Vote FOR on proposal #42"
85+
- "Queue proposal #37 for execution"
86+
- "Execute the queued proposal #35"
87+
88+
## Providers
89+
90+
The plugin includes providers that give your agent awareness of:
91+
- **Wallet balances** across all configured chains
92+
- **Token metadata** and current prices
93+
- **Transaction history** and status
94+
95+
## Supported Chains
96+
97+
The plugin supports all chains available in viem, including:
98+
- Ethereum Mainnet
99+
- Layer 2s: Arbitrum, Optimism, Base, zkSync
100+
- Alternative L1s: Polygon, BSC, Avalanche
101+
- And many more...
102+
103+
## Advanced Features
104+
105+
### Custom Chain Configuration
106+
Add custom RPC endpoints for any supported chain:
107+
108+
```env
109+
ETHEREUM_PROVIDER_OPTIMISM=https://opt-mainnet.g.alchemy.com/v2/YOUR_KEY
110+
ETHEREUM_PROVIDER_ARBITRUM=https://arb-mainnet.g.alchemy.com/v2/YOUR_KEY
111+
```
112+
113+
### TEE Wallet Derivation
114+
For enhanced security, enable TEE mode to derive wallets in Trusted Execution Environments:
115+
116+
```env
117+
TEE_MODE=true
118+
WALLET_SECRET_SALT=your_unique_salt
119+
```
120+
121+
### Multi-Aggregator Swaps
122+
The plugin automatically finds the best swap routes using multiple aggregators:
123+
- Primary: LiFi SDK
124+
- Secondary: Bebop
125+
126+
## Error Handling
127+
128+
The plugin includes comprehensive error handling for common scenarios:
129+
- Insufficient balance
130+
- Network congestion
131+
- Failed transactions
132+
- Invalid addresses
133+
- Slippage protection
134+
135+
## Security Considerations
136+
137+
- Never hardcode private keys in your code
138+
- Use environment variables for sensitive data
139+
- Validate all user inputs
140+
- Set appropriate slippage tolerances
141+
- Monitor gas prices and limits
142+
143+
## Next Steps
144+
145+
- [Complete Documentation →](./evm/complete-documentation)
146+
- [DeFi Operations Flow →](./evm/defi-operations-flow)
147+
- [Examples →](./evm/examples)
148+
- [Testing Guide →](./evm/testing-guide)

0 commit comments

Comments
 (0)