Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apt-yield/
13 changes: 13 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[submodule "apt-yield/lib/forge-std"]
path = apt-yield/lib/forge-std
url = https://github.com/foundry-rs/forge-std

[submodule "apt-yield/lib/agent-kit"]
path = apt-yield/lib/agent-kit
url = https://github.com/warden-protocol/agent-kit
[submodule "apt-yield/lib/openzeppelin-contracts"]
path = apt-yield/lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "apt-yield/lib/v2-periphery"]
path = apt-yield/lib/v2-periphery
url = https://github.com/Uniswap/v2-periphery
120 changes: 120 additions & 0 deletions autofi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env.production

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# End of https://mrkandreev.name/snippets/gitignore-generator/#Node
100 changes: 100 additions & 0 deletions autofi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# AI-Powered DeFi Trading Agent

An AI-powered decentralized finance (DeFi) trading agent that automates buy/sell decisions and executes trades using the Warden Protocol for secure transaction signing. Built with TypeScript, this agent leverages real-time price data, historical trends, and predictive analytics to make informed trading decisions.

---

## Features

- **AI-Driven Decision Making**:
- Fetches real-time token prices using Warden's `get_price` tool.
- Predicts future price movements using a linear regression model.
- Executes trades based on predefined thresholds.

- **Warden Protocol Integration**:
- Securely signs transactions using Warden's key management system.
- Utilizes Warden's `get_spaces` tool for transaction authorization.
- Ensures secure and permissioned access to trading operations.

- **Sepolia Testnet Deployment**:
- Fully operational on the Sepolia Ethereum testnet.
- Uses testnet tokens and ETH for safe experimentation.
- Comprehensive logging and error handling for debugging.

- **Modular and Extensible Design**:
- Built in TypeScript for type safety and scalability.
- Modular architecture for easy integration of new strategies or protocols.
- Includes utilities for price fetching, space management, and transaction processing.

---

## Getting Started

### Prerequisites

- Node.js (v18 or higher)
- Yarn or npm
- Sepolia testnet ETH .
- RPC URL

### Installation

1. Clone the repository:
```bash
git clone https://github.com/vnitin08/agent-kit-examples.git
cd autofi
2. Install dependencies:
```bash
yarn install
# or
npm install
3. Set up environment variables:
Create a .env file in the root directory:
```bash
PRIVATE_KEY
RPC_URL
KEY_ID
4. Start the Agent
```
npm run start:bot
## Usage

### Fetching Token Prices

To fetch the current price of a token:

import { getTokenPrice } from './getTokenPrice';

const price = await getTokenPrice('ETH');
console.log(`Current ETH price: $${price}`);

### Predicting Future Prices

To predict the future price of a token:

import { predictFuturePrice } from './pricePrediction';

const predictedPrice = await predictFuturePrice('ETH');
console.log(`Predicted ETH price: $${predictedPrice}`);

# 🔐 Role of Warden Protocol

Warden Protocol provides secure transaction signing and execution for AUTOFI:

Keychain: Stores and manages private keys securely.

Spaces: Enables decentralized, permissionless execution of trade orders.

Automation: Ensures autonomous execution of transactions without user intervention.

# 📜 Future Improvements

✅ Expand AI models for better predictive accuracy

✅ Multi-chain support (Polygon, Arbitrum)

✅ Integrate with DEX.

✅ Implement a strategy marketplace for AI-driven trading signals


19 changes: 19 additions & 0 deletions autofi/autofi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { getTokenPrice } from './src/getTokenPrice';
import { predictFuturePrice } from './src/pricePrediction';
// import { calculateAPR } from './src/aprCalculator';


async function main() {
const tokenSymbol = 'ETH'; // Replace with the token symbol you want to fetch

// Fetch the current price
const currentPrice = await getTokenPrice(tokenSymbol);
// console.log(`Current price of ${tokenSymbol}: $${currentPrice}`);

// Predict the future price
const predictedPrice = await predictFuturePrice(tokenSymbol);
console.log(`Predicted price of ${tokenSymbol} in 1 hour: $${predictedPrice}`);

}

main();
Loading