A submission for Avalanche Bounty9000 #2: Create an Autonomous Agent That Interacts On-chain
This project is a fork of the Eliza Framework specifically enhanced for Avalanche C-Chain interactions. While the original Eliza framework provides a robust foundation for AI agents, this fork adds specialized capabilities for DeFi operations and social interactions on Avalanche.
Note: If you're looking for general agent development, please refer to the original Eliza repository. This fork is specifically for Avalanche-focused development.
Meet Yorquant, an autonomous agent built utilizing ChatGPT-4o-mini that integrates DeFi operations with social interactions. You can follow Yorquant's activities across multiple platforms:
- π yorquant.ai - Real-time dashboard of trades and interactions
- ποΈ arena.social/YorquantAI - Arena social profile
- π¦ @YorquantAI - Twitter updates
The agent integrates:
- Advanced DeFi operations on Avalanche C-Chain
- Social engagement through The Arena platform
- Data-driven trading decisions with real-time market analysis
- Comprehensive activity logging via Firebase
- Demonstrate sophisticated autonomous DeFi operations on Avalanche
- Showcase integration between on-chain and social activities
- Provide a framework for building complex trading strategies
- Create a self-documenting system through Firebase logging
- Automated token swapping and liquidity provision
- Yield farming management with Yield Yak
- Arena social engagement and ticket purchasing
- Real-time activity logging and monitoring
- Custom trade logic evaluation
- Market trend analysis and decision making
A specialized client for Avalanche C-Chain interactions that provides advanced DeFi capabilities.
Key Features:
- Token swaps via Trader Joe SDK
- Yield Yak farm interactions
- Arena ticket purchasing
- Custom trade logic evaluation
Configuration:
AVALANCHE_PRIVATE_KEY=your_private_key
TRADE_INTERVAL_MINUTES=180
HISTORY_INTERVAL=60
PAPER_TRADE=true
Usage Example:
import { AvalancheClientInterface } from "@ai16z/client-avalanche";
import { setupTradeLogic } from './tradeLogic/yorquant';
// Initialize Avalanche client with custom trade logic
const avalancheClient = await AvalancheClientInterface.start(runtime);
// Set up trading parameters
const tradeConfig = {
interval: process.env.TRADE_INTERVAL_MINUTES,
paperTrading: process.env.PAPER_TRADE === 'true',
minAvaxBalance: '1.0',
maxShares: '100'
};
// Initialize trade logic
setupTradeLogic(tradeConfig);
// Example trade execution
const tradeAction = {
type: 'BUY_SHARES',
amount: BigInt(1),
additionalInfo: 'Strategic purchase during low activity'
};
await executeTrade(client, tradeAction, sharesAccount, tradingAccount, config);
Enables sophisticated social interactions within The Arena network.
Key Features:
- Notification monitoring and response
- Thread creation and management
- Chat message handling
- Context-aware responses
Configuration:
AVALANCHE_PRIVATE_KEY=your_private_key
ARENA_BEARER_TOKEN=your_token
ARENA_DRY_RUN=false
ARENA_GROUP_ID=your_group_id
Usage Example:
import { ArenaClientInterface } from "@ai16z/client-arena";
// Initialize Arena client
const arenaClient = new ArenaClientInterface({
bearerToken: process.env.ARENA_BEARER_TOKEN,
groupId: process.env.ARENA_GROUP_ID
});
// Example: Post a thread
const thread = await arenaClient.postThread(
"Exploring the latest DeFi innovations on Avalanche"
);
// Example: Monitor and respond to notifications
arenaClient.on('notification', async (notification) => {
if (notification.type === 'reply') {
const context = await arenaClient.getThreadContext(notification.threadId);
const response = await generateResponse(context);
await arenaClient.replyToThread(notification.threadId, response);
}
});
A comprehensive logging solution using Firebase Realtime Database.
Features:
- Direct logging to Firebase
- Structured data storage
- Real-time monitoring capabilities
Configuration:
FIREBASE_DATABASE_URL=your_database_url
FIREBASE_SERVICE_ACCOUNT=your_service_account_json
Usage Example:
import { createFirebaseLogger } from '@ai16z/firebase-logger';
// Initialize logger
const firebaseLogger = createFirebaseLogger({
serviceAccount: process.env.FIREBASE_SERVICE_ACCOUNT,
databaseURL: process.env.FIREBASE_DATABASE_URL
});
// Log trading activity
await runtime.logToFirebase('trades', {
action: 'STAKE_YAK',
amount: '10.5',
token: 'AVAX',
timestamp: Date.now()
}, 'transaction');
- Clone the repository:
git clone https://github.com/yourusername/eliza-avalanche
cd eliza-avalanche
- Install dependencies:
pnpm install
- Create environment file:
cp .env.example .env
- Configure environment variables in
.env
:
# Avalanche Configuration
AVALANCHE_PRIVATE_KEY=
TRADE_INTERVAL_MINUTES=180
HISTORY_INTERVAL=60
PAPER_TRADE=true
# Arena Configuration
ARENA_BEARER_TOKEN=
ARENA_DRY_RUN=false
ARENA_GROUP_ID=
# Firebase Configuration
FIREBASE_DATABASE_URL=
FIREBASE_SERVICE_ACCOUNT=
- Build the project:
pnpm build
- Start the agent:
pnpm start
The agent implements a sophisticated trading strategy defined in yorquant.ts
that includes:
-
Market Analysis:
- Price trend monitoring
- Supply change tracking
- Volume analysis
- Historical data evaluation
-
Decision Making:
- Automated trade execution
- Risk management
- Position sizing
- Timing optimization
-
Actions:
- BUY_SHARES: Strategic share purchases
- STAKE_YAK: Yield farming on idle AVAX
- WITHDRAW_AND_BUY: Position reallocation
The agent has executed several strategic share purchases on The Arena, demonstrating its autonomous trading capabilities:
- Buy 0.113 AVAX worth of shares - Dec 01, 2024 21:06:36 UTC
- Buy 3.105 AVAX worth of shares - Dec 04, 2024 07:54:15 UTC
- Buy 2.816 AVAX worth of shares - Dec 04, 2024 22:02:37 UTC
- Buy 2.677 AVAX worth of shares - Dec 05, 2024 04:03:20 UTC
- Buy 2.816 AVAX worth of shares - Dec 05, 2024 07:03:36 UTC
- Buy 3.105 AVAX worth of shares - Dec 05, 2024 10:03:51 UTC
- Buy 3.407 AVAX worth of shares - Dec 05, 2024 16:04:15 UTC
- Buy 3.564 AVAX worth of shares - Dec 05, 2024 21:19:13 UTC
The transactions show a pattern of regular purchases with varying amounts based on market conditions and the agent's trading strategy. The agent has demonstrated consistent activity over multiple days with successful execution of trades ranging from 0.113 to 3.564 AVAX.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT
- Eliza Framework for the core agent framework
- Avalanche Foundation for the bounty program
- The Arena for social integration capabilities
- Trader Joe team for the DEX SDK
- Yield Yak team for farming capabilities