JSPM

web3agent-aof

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q24228F
  • License MIT

AI Framework for Onchain Operations and DeFi Interactions

Package Exports

  • web3agent-aof
  • web3agent-aof/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (web3agent-aof) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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