web3agent-aof
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

AI Onchain Framework

A powerful framework for AI-powered onchain operations and DeFi interactions.

Features

  • Smart Order Routing

    • Multi-DEX aggregation
    • Split order optimization
    • Gas-aware routing
    • Price impact analysis
  • Portfolio Analytics

    • Risk metrics tracking
    • Performance analysis
    • Position management
    • Real-time portfolio monitoring
  • Gas Optimization

    • Dynamic gas pricing
    • MEV protection
    • Transaction simulation
    • Network congestion monitoring
  • Cross-Chain Bridge

    • Multi-bridge support (LayerZero, Hop, Across)
    • Best route finding
    • Bridge fee optimization
    • Transaction monitoring

Installation

npm install ai-onchain-framework

Quick Start

import { EVMAgent } from 'ai-onchain-framework';

// Initialize agent
const agent = new EVMAgent({
  rpcUrl: process.env.RPC_URL,
  privateKey: process.env.PRIVATE_KEY
});

// Smart order routing
const route = await agent.findBestRoute({
  tokenIn: '0x...',  // USDC
  tokenOut: '0x...', // WETH
  amount: '1000000000', // 1000 USDC
  maxSlippage: 0.5,
  protocols: ['Uniswap', '1inch']
});

// Execute swap
await agent.executeRoute(route);

// Portfolio analysis
const portfolio = await agent.analyzePortfolio([
  '0x...', // USDC
  '0x...'  // WETH
]);

// Bridge assets
const bridgeQuote = await agent.getBridgeQuote({
  sourceChain: 'ethereum',
  targetChain: 'bnb',
  token: '0x...', // USDC
  amount: '1000000000',
  bridgeProtocol: 'LayerZero'
});

await agent.bridge(bridgeQuote);

// Monitor price changes
agent.on('priceChange', (data) => {
  console.log(`Price changed: ${data.token} ${data.price}`);
});

// Monitor health factor
agent.on('healthFactorChange', (data) => {
  console.log(`Health factor: ${data.healthFactor}`);
});

Advanced Usage

Gas Optimization

// Set gas strategy
await agent.setGasStrategy({
  type: 'aggressive',
  maxPriorityFee: BigInt(3000000000), // 3 Gwei
  maxFeePerGas: BigInt(50000000000),  // 50 Gwei
  flashbotsEnabled: true
});

// Enable MEV protection
await agent.enableMEVProtection();

Split Orders

const splitRoute = await agent.splitOrder({
  tokenIn: '0x...',  // USDC
  tokenOut: '0x...', // WETH
  amount: '5000000000', // 5000 USDC
  maxSlippage: 0.5,
  protocols: ['Uniswap', '1inch', 'Paraswap'],
  maxSplits: 3
});

Portfolio Management

// Get portfolio analytics
const analytics = await agent.analyzePortfolio([
  '0x...', // USDC
  '0x...'  // WETH
]);

console.log(`Portfolio Value: ${analytics.totalValue}`);
console.log(`Sharpe Ratio: ${analytics.sharpeRatio}`);
console.log(`Max Drawdown: ${analytics.maxDrawdown}%`);

Configuration

Create a .env file:

RPC_URL=your_rpc_url
PRIVATE_KEY=your_private_key

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting PRs.

License

MIT

Package Sidebar

Install

npm i web3agent-aof

Weekly Downloads

6

Version

1.0.0

License

MIT

Unpacked Size

215 kB

Total Files

162

Last publish

Collaborators

  • sagarjethi