Skip to content

Commit

Permalink
Merge pull request #1 from NeurProjects/main
Browse files Browse the repository at this point in the history
Added code
  • Loading branch information
QuarkGrandNagus authored Jan 7, 2025
2 parents 0fde782 + c806d07 commit 0bb606b
Show file tree
Hide file tree
Showing 36 changed files with 4,584 additions and 1,371 deletions.
13 changes: 12 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,15 @@ PRIVY_APP_SECRET=
WALLET_ENCRYPTION_KEY=
NEXT_PUBLIC_IMGBB_API_KEY=
ANTHROPIC_API_KEY=
DATABASE_URL=
DATABASE_URL=
DIRECT_URL=
CRON_SECRET=
HELIUS_API_KEY=
# coingecko api key and base url
CG_API_KEY=
CG_BASE_URL=
TELEGRAM_BOT_TOKEN=
TELEGRAM_BOT_USERNAME=<optional>
DISCORD_BOT_TOKEN=
DISCORD_GUILD_ID=
DISCORD_ROLE_ID=
14 changes: 14 additions & 0 deletions CHANGELOGS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelogs

## v0.1.13

- Telegram notification tool
- Discord Privy config, EAP role linking

## v0.1.12

- Utilize PPQ for AI model endpoint

## v0.1.11

- Initial implementation of price charts
- Initial implementation of automated actions (recurring actions configured and executed by the agent)

## v0.1.10

- Message token tracking (model usage) for backend analysis
Expand Down
12 changes: 11 additions & 1 deletion LOCAL_DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ This describes steps to spin up Neur.sh locally:

## Environment Variables

You will need to sign up for [Privy](https://www.privy.io/) and create a development app, aslo have an [OpenAI](https://platform.openai.com/) or [Anthropic](https://www.anthropic.com/) API key. You also need to have
You will need to sign up for [Privy](https://www.privy.io/) and create a development app.

Choice of model provider:
- [PPQ](https://www.ppq.ai/) API key
- [Anthropic](https://www.anthropic.com/) API key
- [OpenAI](https://platform.openai.com/) API key


You also need to have

- [ImgBB](https://api.imgbb.com/) API key for image uploads
- [Jina AI](https://jina.ai/) API key for url retrieval
Expand All @@ -14,6 +22,8 @@ Create a `.env` file:
```
# Secrets
OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
OPENAI_BASE_URL=<YOUR_OPENAI_BASE_URL> # Recommended: https://api.ppq.ai
OPENAI_MODEL_NAME=<YOUR_OPENAI_MODEL_NAME> # Recommended: claude-3.5-sonnet
PRIVY_APP_SECRET=<YOUR_PRIVY_APP_SECRET>
WALLET_ENCRYPTION_KEY=<YOUR_WALLET_ENCRYPTION_KEY>
JINA_API_KEY=<YOUR_JINA_API_KEY>
Expand Down
40 changes: 23 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neur-app",
"version": "0.1.10",
"version": "0.1.13",
"private": true,
"scripts": {
"vercel-build": "pnpm npx prisma generate && next build",
Expand All @@ -17,13 +17,13 @@
"format:check": "prettier --check \"**/*.{ts,tsx,md,json,js,jsx}\""
},
"dependencies": {
"@ai-sdk/anthropic": "^1.0.5",
"@ai-sdk/openai": "^1.0.10",
"@ai-sdk/anthropic": "^1.0.6",
"@ai-sdk/openai": "^1.0.13",
"@bonfida/spl-name-service": "^3.0.7",
"@mem0/vercel-ai-provider": "^0.0.10",
"@prisma/client": "6.1.0",
"@privy-io/react-auth": "^1.98.2",
"@privy-io/server-auth": "^1.17.0",
"@privy-io/react-auth": "^1.99.0",
"@privy-io/server-auth": "^1.17.2",
"@radix-ui/react-accordion": "^1.2.2",
"@radix-ui/react-alert-dialog": "^1.1.4",
"@radix-ui/react-avatar": "^1.1.2",
Expand All @@ -41,47 +41,53 @@
"@solana/web3.js": "1.98.0",
"@vercel/analytics": "^1.4.1",
"@vercel/speed-insights": "^1.1.0",
"ai": "^4.0.20",
"ai": "^4.0.27",
"bs58": "^6.0.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"framer-motion": "^11.15.0",
"framer-motion": "^11.16.0",
"helius-sdk": "^1.4.1",
"keyv": "4.5.4",
"lodash": "^4.17.21",
"lucide-react": "^0.468.0",
"mem0ai": "^1.0.29",
"mem0ai": "^1.0.30",
"next": "15.1.2",
"next-safe-action": "^7.10.2",
"next-themes": "^0.4.4",
"node-fetch": "^3.3.2",
"react": "^19.0.0",
"react-day-picker": "8.10.1",
"react-dom": "^19.0.0",
"react-markdown": "^9.0.1",
"react-markdown": "^9.0.3",
"react-particles": "^2.12.2",
"react-tweet": "^3.2.1",
"recharts": "^2.15.0",
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.0",
"solana-agent-kit": "1.3.2",
"sonner": "^1.7.1",
"swr": "^2.2.5",
"tailwind-merge": "^2.5.5",
"swr": "^2.3.0",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"tsparticles-slim": "^2.12.0",
"uuid": "^11.0.3",
"uuid": "^11.0.4",
"yet-another-react-lightbox": "^3.21.7",
"zod": "^3.24.1",
"zustand": "^5.0.2"
},
"devDependencies": {
"@eslint/eslintrc": "^3.2.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^20.17.10",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@types/lodash": "^4.17.14",
"@types/node": "^20.17.12",
"@types/react": "^19.0.3",
"@types/react-dom": "^19.0.2",
"eslint": "^9.17.0",
"eslint-config-next": "15.1.0",
"postcss": "^8.4.49",
"prettier": "^3.2.5",
"prettier-plugin-tailwindcss": "^0.5.12",
"prettier": "^3.4.2",
"prettier-plugin-tailwindcss": "^0.5.14",
"prisma": "^6.1.0",
"tailwind-scrollbar": "^3.1.0",
"tailwindcss": "^3.4.17",
Expand Down
46 changes: 44 additions & 2 deletions patches/solana-agent-kit.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,55 @@
diff --git a/dist/tools/trade.js b/dist/tools/trade.js
index 280aa7564613238857477f791f7f7522a8faca83..47ad1ffee7884cb6a2e19e00d410fb2677ad8e2c 100644
index 280aa7564613238857477f791f7f7522a8faca83..b9345cbcc4ffc31665e51ecc9ad6396dc2a693fc 100755
--- a/dist/tools/trade.js
+++ b/dist/tools/trade.js
@@ -29,7 +29,7 @@ async function trade(agent, outputMint, inputAmount, inputMint = constants_1.TOK
@@ -4,6 +4,10 @@ exports.trade = trade;
const web3_js_1 = require("@solana/web3.js");
const constants_1 = require("../constants");
const spl_token_1 = require("@solana/spl-token");
+const { Helius } = require("helius-sdk");
+
+const helius = new Helius(process.env.HELIUS_API_KEY);
+
/**
* Swap tokens using Jupiter Exchange
* @param agent SolanaAgentKit instance
@@ -29,7 +33,8 @@ async function trade(agent, outputMint, inputAmount, inputMint = constants_1.TOK
`&amount=${scaledAmount}` +
`&slippageBps=${slippageBps}` +
`&onlyDirectRoutes=true` +
- `&maxAccounts=20` +
+ `&maxAccounts=64` +
+ `&asLegacyTransaction=true` +
`${agent.config.JUPITER_FEE_BPS ? `&platformFeeBps=${agent.config.JUPITER_FEE_BPS}` : ""}`)).json();
// Get serialized transaction
let feeAccount;
@@ -49,17 +54,25 @@ async function trade(agent, outputMint, inputAmount, inputMint = constants_1.TOK
quoteResponse,
userPublicKey: agent.wallet_address.toString(),
wrapAndUnwrapSol: true,
- dynamicComputeUnitLimit: true,
+ dynamicComputeUnitLimit: false,
prioritizationFeeLamports: "auto",
feeAccount: feeAccount ? feeAccount.toString() : null,
+ asLegacyTransaction: true,
}),
})).json();
// Deserialize transaction
const swapTransactionBuf = Buffer.from(swapTransaction, "base64");
- const transaction = web3_js_1.VersionedTransaction.deserialize(swapTransactionBuf);
+ const transaction = web3_js_1.Transaction.from(swapTransactionBuf);
+
+ // Remove the instruction that sets the compute unit price/limit
+ const filteredInstructions = transaction.instructions.filter((instruction) => {
+ const programId = instruction.programId;
+ return !programId.equals(web3_js_1.ComputeBudgetProgram.programId);
+ });
+
// Sign and send transaction
- transaction.sign([agent.wallet]);
- const signature = await agent.connection.sendTransaction(transaction);
+ const signature = await helius.rpc.sendSmartTransaction(filteredInstructions, [agent.wallet]);
+
return signature;
}
catch (error) {
Loading

0 comments on commit 0bb606b

Please sign in to comment.