Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
microchipgnu committed Dec 18, 2024
0 parents commit 22bed60
Show file tree
Hide file tree
Showing 21 changed files with 1,550 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ZERION_API_KEY=
ONEINCH_AUTH_KEY=

SLIPPAGE_BPS=100
SAFE_SALT_NONCE=130811896738364156958237239906781888512
25 changes: 25 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true,
"env": {
"node": true,
"es2021": true
},
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module"
// "project": "./tsconfig.json"
},
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"no-console": "off"
}
}
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Bun
run: |
curl -fsSL https://bun.sh/install | bash
export BUN_INSTALL="$HOME/.bun"
echo "BUN_INSTALL=$HOME/.bun" >> $GITHUB_ENV
echo "$BUN_INSTALL/bin" >> $GITHUB_PATH
- name: Install dependencies
run: |
npm install -g node-gyp
bun install
- name: Lint, Test & Build
env:
SAFE_SALT_NONCE: "0"
run: |
bun lint
bun test
bun run build
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# build
dist/

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

.env
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Uniswap AI Agent by [Bitte](https://www.bitte.ai/)

This is a [Next.js](https://nextjs.org) project that implements an AI-powered agent for interacting with Uniswap V3. The agent helps users generate and execute transactions on Uniswap Fusion across supported EVM networks.

## Features

- Generate transaction data for Uniswap V3
- Support for selling native assets (ETH, xDAI, POL, BNB)
- ERC20 token transfers
- WETH wrapping and unwrapping
- Price quotes and fee estimation for trades
- Support for multiple EVM networks

## API Endpoints

The agent exposes several endpoints:

- `/api/tools/uniswap`: Quote prices and generate swap transactions

## Local Development

First, install the dependencies:

```bash
bun install
```

Then, run the development server:

```bash
bun dev
bun dev-testnet
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the Swagger UI.

## Environment Setup

The application requires the following environment variables:

- `BITTE_KEY`: JSON containing the account ID

## Learn More

To learn more about the technologies used in this project:

- [Uniswap Documentation](https://app.uniswap.org/) - Learn about Uniswap
- [Bitte Documentation](https://docs.bitte.ai/) - Learn about Bitte and building AI agents
- [Next.js Documentation](https://nextjs.org/docs) - Learn about Next.js features and API

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme).

Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
Binary file added bun.lockb
Binary file not shown.
25 changes: 25 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { pathsToModuleNameMapper } from 'ts-jest';
import { compilerOptions } from './tsconfig.json';

const jestConfig = {
preset: 'ts-jest',
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': ['ts-jest', { tsconfig: 'tsconfig.json', useESM: true }],
'^.+\\.jsx?$': 'babel-jest',
},
extensionsToTreatAsEsm: ['.ts', '.tsx'],
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/',
}),
'^(\\.{1,2}/.*)\\.js$': '$1',
},
setupFiles: ['dotenv/config'],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'node'],
transformIgnorePatterns: [
'node_modules/(?!(@bitteprotocol/agent-sdk)/)',
],
};

export default jestConfig;
47 changes: 47 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "bitte-uniswap-agent",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "concurrently \"tsx src/server.ts\" \"make-agent dev -p 3000\"",
"dev-testnet": "concurrently \"tsx src/server.ts\" \"make-agent dev -p 3000 -t\"",
"build": "tsc",
"start": "tsx src/server.ts",
"serve": "bun dist/server.js",
"lint": "eslint '{src,tests}/**/*.{js,jsx,ts,tsx}'",
"fmt": "eslint --fix '{src,tests}/**/*.{js,jsx,ts,tsx}' && prettier --write '{src,tests}/**/*.{js,jsx,ts,tsx}'",
"test": "jest --config jest.config.ts"
},
"dependencies": {
"@bitteprotocol/agent-sdk": "^0.0.10",
"@uniswap/sdk-core": "^6.1.0",
"@uniswap/smart-order-router": "^4.8.6",
"cors": "^2.8.5",
"ethers": "^5.7.2",
"express": "^4.21.2",
"near-safe": "^0.9.4",
"swagger-ui-express": "^5.0.1",
"viem": "^2.21.54",
"zerion-sdk": "^0.0.13"
},
"devDependencies": {
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/jest": "^29.5.14",
"@types/node": "^22.10.1",
"@types/swagger-ui-express": "^4.1.7",
"@typescript-eslint/eslint-plugin": "^8.17.0",
"concurrently": "^9.1.0",
"dotenv": "^16.4.7",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"jest": "^29.7.0",
"make-agent": "^0.0.25",
"prettier": "^3.4.2",
"ts-jest": "^29.2.5",
"tsx": "^4.19.2",
"typescript": "^5.7.2"
}
}
22 changes: 22 additions & 0 deletions public/uniswap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 22bed60

Please sign in to comment.