{"id":25239541,"url":"https://github.com/solagent99/solana_aiagent_trading","last_synced_at":"2025-04-05T19:44:15.987Z","repository":{"id":275474984,"uuid":"924750497","full_name":"solagent99/Solana_AIAgent_Trading","owner":"solagent99","description":"🔥Blockchain AI Agent for Solana Trading -AI Agent Trading Tool for the Solana memecoin - Solana AI Agent for Trading - Groundbreaking Solana AI Agent Strategy","archived":false,"fork":false,"pushed_at":"2025-02-07T16:10:30.000Z","size":3396,"stargazers_count":83,"open_issues_count":0,"forks_count":79,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-11T18:43:52.754Z","etag":null,"topics":["ai","aiagent","blockchain","langchain","solana","trading"],"latest_commit_sha":null,"homepage":"https://ai-agent-trading.vercel.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/solagent99.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-30T15:36:32.000Z","updated_at":"2025-02-11T13:59:44.000Z","dependencies_parsed_at":"2025-02-02T19:45:50.522Z","dependency_job_id":null,"html_url":"https://github.com/solagent99/Solana_AIAgent_Trading","commit_stats":null,"previous_names":["solagent99/solana_aiagent_trading"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solagent99%2FSolana_AIAgent_Trading","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solagent99%2FSolana_AIAgent_Trading/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solagent99%2FSolana_AIAgent_Trading/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solagent99%2FSolana_AIAgent_Trading/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solagent99","download_url":"https://codeload.github.com/solagent99/Solana_AIAgent_Trading/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393535,"owners_count":20931809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","aiagent","blockchain","langchain","solana","trading"],"created_at":"2025-02-11T18:29:08.166Z","updated_at":"2025-04-05T19:44:15.953Z","avatar_url":"https://github.com/solagent99.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# Solana AI Agent Trading Tool\n\n\u003c/div\u003e\n\nAn open-source trading toolkit for connecting AI agents to Solana protocols. Now, any agent, using any model can autonomously perform 15+ Solana actions:\n\n- Trade tokens\n- Launch new tokens\n- Lend assets\n- Send compressed airdrops\n- Execute blinks\n- Launch tokens on AMMs\n- And more...\n\n# 💬 Contact Me\n\nIf you have any question or something, feel free to reach out me anytime via telegram, discord or twitter.\n\u003cbr\u003e\n#### 🌹 You're always welcome 🌹\n\nTelegram: [@Leo](https://t.me/shinnyleo0912) \u003cbr\u003e\n\n[![Run on Repl.it](https://replit.com/badge/github/sendaifun/solana-agent-kit)](https://replit.com/@sendaifun/Solana-Agent-Kit)\n\u003e Replit template created by [Arpit Singh](https://github.com/The-x-35)\n\n## 🔧 Core Blockchain Features\n\n- **Token Operations**\n  - Deploy SPL tokens by Metaplex\n  - Transfer assets\n  - Balance checks\n  - Stake SOL\n  - Zk compressed Airdrop by Light Protocol and Helius\n- **NFTs on 3.Land**\n  - Create your own collection\n  - NFT creation and automatic listing on 3.land\n  - List your NFT for sale in any SPL token\n- **NFT Management via Metaplex**\n  - Collection deployment\n  - NFT minting\n  - Metadata management\n  - Royalty configuration\n\n- **DeFi Integration**\n  - Jupiter Exchange swaps\n  - Launch on Pump via PumpPortal\n  - Raydium pool creation (CPMM, CLMM, AMMv4)\n  - Orca Whirlpool integration\n  - Manifest market creation, and limit orders\n  - Meteora Dynamic AMM, DLMM Pool, and Alpha Vault\n  - Openbook market creation\n  - Register and Resolve SNS\n  - Jito Bundles\n  - Pyth Price feeds for fetching Asset Prices\n  - Register/resolve Alldomains\n  - Perpetuals Trading with Adrena Protocol\n  - Drift Vaults, Perps, Lending and Borrowing\n\n- **Solana Blinks**\n   - Lending by Lulo (Best APR for USDC)\n   - Send Arcade Games\n   - JupSOL staking\n   - Solayer SOL (sSOL)staking\n\n- **Non-Financial Actions**\n  - Gib Work for registering bounties\n\n## 🤖 AI Integration Features\n\n- **LangChain Integration**\n  - Ready-to-use LangChain tools for blockchain operations\n  - Autonomous agent support with React framework\n  - Memory management for persistent interactions\n  - Streaming responses for real-time feedback\n\n- **Vercel AI SDK Integration**\n  - Vercel AI SDK for AI agent integration\n  - Framework agnostic support\n  - Quick and easy toolkit setup\n\n- **Autonomous Modes**\n  - Interactive chat mode for guided operations\n  - Autonomous mode for independent agent actions\n  - Configurable action intervals\n  - Built-in error handling and recovery\n\n- **AI Tools**\n  - DALL-E integration for NFT artwork generation\n  - Natural language processing for blockchain commands\n  - Price feed integration for market analysis\n  - Automated decision-making capabilities\n\n## 📃 Documentation\nYou can view the full documentation of the kit at [docs.solanaagentkit.xyz](https://docs.solanaagentkit.xyz)\n\n## 📦 Installation\n\n```bash\nnpm install solana-agent-kit\n```\n\n## Quick Start\n\n```typescript\nimport { SolanaAgentKit, createSolanaTools } from \"solana-agent-kit\";\n\n// Initialize with private key and optional RPC URL\nconst agent = new SolanaAgentKit(\n  \"your-wallet-private-key-as-base58\",\n  \"https://api.mainnet-beta.solana.com\",\n  \"your-openai-api-key\"\n);\n\n// Create LangChain tools\nconst tools = createSolanaTools(agent);\n```\n\n## Usage Examples\n\n### Deploy a New Token\n\n```typescript\nconst result = await agent.deployToken(\n  \"my ai token\", // name\n  \"uri\", // uri\n  \"token\", // symbol\n  9, // decimals\n  1000000 // initial supply\n);\n\nconsole.log(\"Token Mint Address:\", result.mint.toString());\n```\n### Create NFT Collection on 3Land\n```typescript\nconst isDevnet = false; // (Optional) if not present TX takes place in Mainnet\nconst priorityFeeParam = 1000000; // (Optional) if not present the default priority fee will be 50000\n\n const collectionOpts: CreateCollectionOptions = {\n    collectionName: \"\",\n    collectionSymbol: \"\",\n    collectionDescription: \"\",\n    mainImageUrl: \"\"\n  };\n\nconst result = await agent.create3LandCollection(\n      collectionOpts,\n      isDevnet, // (Optional) if not present TX takes place in Mainnet\n      priorityFeeParam, //(Optional)\n    );\n```\n\n### Create NFT on 3Land\nWhen creating an NFT using 3Land's tool, it automatically goes for sale on 3.land website\n```typescript\nconst isDevnet = true; // (Optional) if not present TX takes place in Mainnet\nconst withPool = true; // (Optional) only present if NFT will be created with a Liquidity Pool for a specific SPL token\nconst priorityFeeParam = 1000000; // (Optional) if not present the default priority fee will be 50000\nconst collectionAccount = \"\"; //hash for the collection\nconst createItemOptions: CreateSingleOptions = {\n  itemName: \"\",\n  sellerFee: 500, //5%\n  itemAmount: 100, //total items to be created\n  itemSymbol: \"\",\n  itemDescription: \"\",\n  traits: [\n    { trait_type: \"\", value: \"\" },\n  ],\n  price: 0, //100000000 == 0.1 sol, can be set to 0 for a free mint\n  splHash: \"\", //present if listing is on a specific SPL token, if not present sale will be on $SOL, must be present if \"withPool\" is true\n  poolName: \"\", // Only present if \"withPool\" is true\n  mainImageUrl: \"\",\n};\nconst result = await agent.create3LandNft(\n  collectionAccount,\n  createItemOptions,\n  isDevnet, // (Optional) if not present TX takes place in Mainnet\n  withPool\n  priorityFeeParam, //(Optional)\n);\n\n```\n\n\n### Create NFT Collection\n\n```typescript\nconst collection = await agent.deployCollection({\n  name: \"My NFT Collection\",\n  uri: \"https://arweave.net/metadata.json\",\n  royaltyBasisPoints: 500, // 5%\n  creators: [\n    {\n      address: \"creator-wallet-address\",\n      percentage: 100,\n    },\n  ],\n});\n```\n\n### Swap Tokens\n\n```typescript\nimport { PublicKey } from \"@solana/web3.js\";\n\nconst signature = await agent.trade(\n  new PublicKey(\"target-token-mint\"),\n  100, // amount\n  new PublicKey(\"source-token-mint\"),\n  300 // 3% slippage\n);\n```\n\n### Lend Tokens\n\n```typescript\nimport { PublicKey } from \"@solana/web3.js\";\n\nconst signature = await agent.lendAssets(\n  100 // amount of USDC to lend\n);\n```\n\n### Stake SOL\n\n```typescript\nconst signature = await agent.stake(\n  1 // amount in SOL to stake\n);\n```\n\n### Stake SOL on Solayer\n\n```typescript\nconst signature = await agent.restake(\n  1 // amount in SOL to stake\n);\n\n```\n\n### Send an SPL Token Airdrop via ZK Compression\n\n```typescript\nimport { PublicKey } from \"@solana/web3.js\";\n\n(async () =\u003e {\n  console.log(\n    \"~Airdrop cost estimate:\",\n    getAirdropCostEstimate(\n      1000, // recipients\n      30_000 // priority fee in lamports\n    )\n  );\n\n  const signature = await agent.sendCompressedAirdrop(\n    new PublicKey(\"JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN\"), // mint\n    42, // amount per recipient\n    [\n      new PublicKey(\"1nc1nerator11111111111111111111111111111111\"),\n      // ... add more recipients\n    ],\n    30_000 // priority fee in lamports\n  );\n})();\n```\n\n### Fetch Price Data from Pyth\n\n```typescript\n\nconst priceFeedID = await agent.getPythPriceFeedID(\"SOL\");\n\nconst price = await agent.getPythPrice(priceFeedID);\n\nconsole.log(\"Price of SOL/USD:\", price);\n```\n\n### Open PERP Trade\n\n```typescript\nimport { PublicKey } from \"@solana/web3.js\";\n\nconst signature = await agent.openPerpTradeLong({\n  price: 300, // $300 SOL Max price\n  collateralAmount: 10, // 10 jitoSOL in\n  collateralMint: new PublicKey(\"J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn\"), // jitoSOL\n  leverage: 50000, // x5\n  tradeMint: new PublicKey(\"J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn\"), // jitoSOL\n  slippage: 0.3, // 0.3%\n});\n```\n\n### Close PERP Trade\n\n```typescript\nimport { PublicKey } from \"@solana/web3.js\";\n\nconst signature = await agent.closePerpTradeLong({\n  price: 200, // $200 SOL price\n  tradeMint: new PublicKey(\"J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn\"), // jitoSOL\n});\n```\n\n### Close Empty Token Accounts\n\n``` typescript\n\nconst { signature } = await agent.closeEmptyTokenAccounts();\n```\n\n### Create a Drift account\n\nCreate a drift account with an initial token deposit.\n\n```typescript\nconst result = await agent.createDriftUserAccount()\n```\n\n### Create a Drift Vault\n\nCreate a drift vault.\n\n```typescript\nconst signature = await agent.createDriftVault({\n  name: \"my-drift-vault\",\n  marketName: \"USDC-SPOT\",\n  redeemPeriod: 1, // in days\n  maxTokens: 100000, // in token units e.g 100000 USDC\n  minDepositAmount: 5, // in token units e.g 5 USDC\n  managementFee: 1, // 1%\n  profitShare: 10, // 10%\n  hurdleRate: 5, // 5%\n  permissioned: false, // public vault or whitelist\n})\n```\n\n### Deposit into a Drift Vault\n\nDeposit tokens into a drift vault.\n\n```typescript\nconst signature = await agent.depositIntoDriftVault(100, \"41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU\")\n```\n\n### Deposit into your Drift account\n\nDeposit tokens into your drift account.\n\n```typescript\nconst {txSig} = await agent.depositToDriftUserAccount(100, \"USDC\")\n```\n\n### Derive a Drift Vault address\n\nDerive a drift vault address.\n\n```typescript\nconst vaultPublicKey = await agent.deriveDriftVaultAddress(\"my-drift-vault\")\n```\n\n### Do you have a Drift account\n\nCheck if agent has a drift account.\n\n```typescript\nconst {hasAccount, account} = await agent.doesUserHaveDriftAccount()\n```\n\n### Get Drift account information\n\nGet drift account information.\n\n```typescript\nconst accountInfo = await agent.driftUserAccountInfo()\n```\n\n### Request withdrawal from Drift vault\n\nRequest withdrawal from drift vault.\n\n```typescript\nconst signature = await agent.requestWithdrawalFromDriftVault(100, \"41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU\")\n```\n\n### Carry out a perpetual trade using a Drift vault\n\nOpen a perpertual trade using a drift vault that is delegated to you.\n\n```typescript\nconst signature = await agent.tradeUsingDelegatedDriftVault({\n  vault: \"41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU\",\n  amount: 500,\n  symbol: \"SOL\",\n  action: \"long\",\n  type: \"limit\",\n  price: 180 // Please long limit order at $180/SOL\n})\n```\n\n### Carry out a perpetual trade using your Drift account\n\nOpen a perpertual trade using your drift account.\n\n```typescript\nconst signature = await agent.tradeUsingDriftPerpAccount({\n  amount: 500,\n  symbol: \"SOL\",\n  action: \"long\",\n  type: \"limit\",\n  price: 180 // Please long limit order at $180/SOL\n})\n```\n\n### Update Drift vault parameters\n\nUpdate drift vault parameters.\n\n```typescript\nconst signature = await agent.updateDriftVault({\n  name: \"my-drift-vault\",\n  marketName: \"USDC-SPOT\",\n  redeemPeriod: 1, // in days\n  maxTokens: 100000, // in token units e.g 100000 USDC\n  minDepositAmount: 5, // in token units e.g 5 USDC\n  managementFee: 1, // 1%\n  profitShare: 10, // 10%\n  hurdleRate: 5, // 5%\n  permissioned: false, // public vault or whitelist\n})\n```\n\n### Withdraw from Drift account\n\nWithdraw tokens from your drift account.\n\n```typescript\nconst {txSig} = await agent.withdrawFromDriftAccount(100, \"USDC\")\n```\n\n### Borrow from Drift\n\nBorrow tokens from drift.\n\n```typescript\nconst {txSig} = await agent.withdrawFromDriftAccount(1, \"SOL\", true)\n```\n\n### Repay Drift loan\n\nRepay a loan from drift.\n\n```typescript\nconst {txSig} = await agent.depositToDriftUserAccount(1, \"SOL\", true)\n```\n\n### Withdraw from Drift vault\n\nWithdraw tokens from a drift vault after the redemption period has elapsed.\n\n```typescript\nconst signature = await agent.withdrawFromDriftVault( \"41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU\")\n```\n\n### Update the address a Drift vault is delegated to\n\nUpdate the address a drift vault is delegated to.\n\n```typescript\nconst signature = await agent.updateDriftVaultDelegate(\"41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU\", \"new-address\")\n```\n\n### Get Voltr Vault Position Values\n\nGet the current position values and total value of assets in a Voltr vault.\n\n```typescript\nconst values = await agent.voltrGetPositionValues(\"7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K\")\n```\n\n### Deposit into Voltr Strategy\n\nDeposit assets into a specific strategy within a Voltr vault.\n\n```typescript\nconst signature = await agent.voltrDepositStrategy(\n  new BN(\"1000000000\"), // amount in base units (e.g., 1 USDC = 1000000)\n  \"7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K\", // vault\n  \"9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk\"  // strategy\n)\n```\n\n### Withdraw from Voltr Strategy\n\nWithdraw assets from a specific strategy within a Voltr vault.\n\n```typescript\nconst signature = await agent.voltrWithdrawStrategy(\n  new BN(\"1000000000\"), // amount in base units (e.g., 1 USDC = 1000000)\n  \"7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K\", // vault\n  \"9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk\"  // strategy\n)\n```\n\n### Get a Solana asset by its ID\n\n```typescript\nconst asset = await agent.getAsset(\"41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU\")\n```\n\n### Get a price inference from Allora\n\nGet the price for a given token and timeframe from Allora's API\n\n```typescript\nconst sol5mPrice = await agent.getPriceInference(\"SOL\", \"5m\");\nconsole.log(\"5m price inference of SOL/USD:\", sol5mPrice);\n```\n\n### List all topics from Allora\n\n```typescript\nconst topics = await agent.getAllTopics();\nconsole.log(\"Allora topics:\", topics);\n```\n\n### Get an inference for an specific topic from Allora\n\n```typescript\nconst inference = await agent.getInferenceByTopicId(42);\nconsole.log(\"Allora inference for topic 42:\", inference);\n```\n\n## Examples\n\n### LangGraph Multi-Agent System\n\nThe repository includes an advanced example of building a multi-agent system using LangGraph and Solana Agent Kit. Located in `examples/agent-kit-langgraph`, this example demonstrates:\n\n- Multi-agent architecture using LangGraph's StateGraph\n- Specialized agents for different tasks:\n  - General purpose agent for basic queries\n  - Transfer/Swap agent for transaction operations\n  - Read agent for blockchain data queries\n  - Manager agent for routing and orchestration\n- Fully typed TypeScript implementation\n- Environment-based configuration\n\nCheck out the [LangGraph example](examples/agent-kit-langgraph) for a complete implementation of an advanced Solana agent system.\n\n## Dependencies\n\nThe toolkit relies on several key Solana and Metaplex libraries:\n\n- @solana/web3.js\n- @solana/spl-token\n- @metaplex-foundation/digital-asset-standard-api\n- @metaplex-foundation/mpl-token-metadata\n- @metaplex-foundation/mpl-core\n- @metaplex-foundation/umi\n- @lightprotocol/compressed-token\n- @lightprotocol/stateless.js\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\nRefer to [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines on how to contribute to this project.\n\n## Contributors\n\n\u003ca href=\"https://github.com/sendaifun/solana-agent-kit/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=sendaifun/solana-agent-kit\" /\u003e\n\u003c/a\u003e\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=sendaifun/solana-agent-kit\u0026type=Date)](https://star-history.com/#sendaifun/solana-agent-kit\u0026Date)\n\n## License\n\nApache-2 License\n\n## Funding\n\nIf you wanna give back any tokens or donations to the OSS community -- The Public Solana Agent Kit Treasury Address:\n\nSolana Network : EKHTbXpsm6YDgJzMkFxNU1LNXeWcUW7Ezf8mjUNQQ4Pa\n\n## Security\n\nThis toolkit handles private keys and transactions. Always ensure you're using it in a secure environment and never share your private keys.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolagent99%2Fsolana_aiagent_trading","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolagent99%2Fsolana_aiagent_trading","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolagent99%2Fsolana_aiagent_trading/lists"}