Skip to content

Fork of ai16z Eliza specifically for interacting with the Avalanche C-Chain

License

Notifications You must be signed in to change notification settings

anthonybautista/eliza-avalanche

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Eliza Avalanche Agent πŸ€–

A submission for Avalanche Bounty9000 #2: Create an Autonomous Agent That Interacts On-chain

Author

xrpant

Introduction

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.

My AI Agent

About

Yorquant

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:

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

Goals

  • 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

Capabilities

  • 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

New Components

1. client-avalanche

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);

2. client-arena

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);
  }
});

3. firebase-logger

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');

Getting Started

  1. Clone the repository:
git clone https://github.com/yourusername/eliza-avalanche
cd eliza-avalanche
  1. Install dependencies:
pnpm install
  1. Create environment file:
cp .env.example .env
  1. 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=
  1. Build the project:
pnpm build
  1. Start the agent:
pnpm start

Trading Strategy

The agent implements a sophisticated trading strategy defined in yorquant.ts that includes:

  1. Market Analysis:

    • Price trend monitoring
    • Supply change tracking
    • Volume analysis
    • Historical data evaluation
  2. Decision Making:

    • Automated trade execution
    • Risk management
    • Position sizing
    • Timing optimization
  3. Actions:

    • BUY_SHARES: Strategic share purchases
    • STAKE_YAK: Yield farming on idle AVAX
    • WITHDRAW_AND_BUY: Position reallocation

On-chain Transactions

Share Purchase History

The agent has executed several strategic share purchases on The Arena, demonstrating its autonomous trading capabilities:

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.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Acknowledgments

  • 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

About

Fork of ai16z Eliza specifically for interacting with the Avalanche C-Chain

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.1%
  • PLpgSQL 2.2%
  • JavaScript 0.9%
  • Shell 0.5%
  • CSS 0.2%
  • Dockerfile 0.1%