Files
solana-agent-kit/package.json
aryan d8c67311a5 Add Voltr check balance, deposit and withdraw strategy (#128)
# Pull Request Description

## Related Issue
Fixes # (issue number)

## Changes Made
This PR adds the following changes:
<!-- List the key changes made in this PR -->
- Query Voltr vault and strategies balances
- Withdraw from Voltr strategies
- Deposit into Voltr strategies
  
## Implementation Details
<!-- Provide technical details about the implementation -->
- utilises Voltr's SDK `@voltr/sdk` to instantiate a `VoltrClient`  
- find and fetch relevant accounts to create instructions using
`VoltrClient`

## Transaction executed by agent 
<!-- If applicable, provide example usage, transactions, or screenshots
-->
Example transaction:
https://solana.fm/tx/GnUd38TMhtBYNv29nNAyESEWLwjHhUW6hraNrPE3RTF6LtdqNtnoBBqEKptT5JaWqv6TiFp6MeooUa9Rt7vMAu9?cluster=mainnet-alpha
Demo: https://x.com/voltrxyz/status/1875204418465059189

## Prompt Used
<!-- If relevant, include the prompt or configuration used -->
Tested on autonomous mode.
``` 
async function runAutonomousMode(agent: any, config: any, interval = 10) {
  console.log("Starting autonomous mode...");

  let iterations = 0;

  while (true) {
    try {
      const evenThought =
        "1. Get the total amount and amount for each strategy of a Voltr vault: 3ab3KVY9GbDbUUbRnYNSBDQqABTDup7HmdgADHGpB8Bq. " +
        "2. Take note of the strategies id with the their respective amount. " +
        "3. Calculate the sum of all strategy amounts. " +
        "4. Subtract that sum from the vault total to get the excess amount. " +
        "5. Indicate the excess amount and the strategy id with the lowest amount.";

      const oddThought =
        "Using the latest excess amount, if it is 0 then do nothing. " +
        "Else if it is more than 0, deposit the excess amount into the lowest strategy and vault: 3ab3KVY9GbDbUUbRnYNSBDQqABTDup7HmdgADHGpB8Bq.";

      const thought = iterations % 2 === 0 ? evenThought : oddThought;

      const stream = await agent.stream(
        { messages: [new HumanMessage(thought)] },
        config,
      );

      for await (const chunk of stream) {
        if ("agent" in chunk) {
          for (const message of chunk.agent.messages) {
            console.log(message.content);
          }
        } else if ("tools" in chunk) {
          for (const message of chunk.tools.messages) {
            console.log(message.content);
          }
        }
        console.log("-------------------");
      }

      iterations++;

      await new Promise((resolve) => setTimeout(resolve, interval * 1000));
    } catch (error) {
      if (error instanceof Error) {
        console.error("Error:", error.message);
      }
      process.exit(1);
    }
  }
}
```

## Additional Notes
<!-- Any additional information that reviewers should know -->

## Checklist
- [x] I have tested these changes locally
- [x] I have updated the documentation
- [x] I have added a transaction link
- [x] I have added the prompt used to test it
2025-01-18 01:14:34 +05:30

86 lines
2.7 KiB
JSON

{
"name": "solana-agent-kit",
"version": "1.4.0",
"description": "connect any ai agents to solana protocols",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsc",
"docs": "typedoc src --out docs",
"test": "tsx test/index.ts",
"test:vercel-ai": "tsx test/agent_sdks/vercel_ai.ts",
"generate": "tsx src/utils/keypair.ts",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"prepare": "husky"
},
"engines": {
"node": ">=22.0.0",
"pnpm": ">=8.0.0"
},
"keywords": [],
"author": "sendaifun",
"license": "Apache-2.0",
"dependencies": {
"@3land/listings-sdk": "^0.0.6",
"@ai-sdk/openai": "^1.0.11",
"@bonfida/spl-name-service": "^3.0.7",
"@cks-systems/manifest-sdk": "0.1.59",
"@coral-xyz/anchor": "0.29",
"@drift-labs/sdk": "2.107.0-beta.3",
"@drift-labs/vaults-sdk": "^0.2.49",
"@langchain/core": "^0.3.26",
"@langchain/groq": "^0.1.2",
"@langchain/langgraph": "^0.2.36",
"@langchain/openai": "^0.3.16",
"@lightprotocol/compressed-token": "^0.17.1",
"@lightprotocol/stateless.js": "^0.17.1",
"@metaplex-foundation/mpl-core": "^1.1.1",
"@metaplex-foundation/mpl-token-metadata": "^3.3.0",
"@metaplex-foundation/mpl-toolbox": "^0.9.4",
"@metaplex-foundation/umi": "^0.9.2",
"@metaplex-foundation/umi-bundle-defaults": "^0.9.2",
"@metaplex-foundation/umi-web3js-adapters": "^0.9.2",
"@onsol/tldparser": "^0.6.7",
"@orca-so/common-sdk": "0.6.4",
"@orca-so/whirlpools-sdk": "^0.13.12",
"@pythnetwork/hermes-client": "^1.3.0",
"@raydium-io/raydium-sdk-v2": "0.1.95-alpha",
"@solana/spl-token": "^0.4.9",
"@solana/web3.js": "^1.98.0",
"@sqds/multisig": "^2.1.3",
"@tensor-oss/tensorswap-sdk": "^4.5.0",
"@tiplink/api": "^0.3.1",
"@voltr/vault-sdk": "^0.1.1",
"ai": "^4.0.22",
"bn.js": "^5.2.1",
"bs58": "^6.0.0",
"chai": "^5.1.2",
"decimal.js": "^10.4.3",
"dotenv": "^16.4.7",
"flash-sdk": "^2.24.3",
"form-data": "^4.0.1",
"langchain": "^0.3.8",
"openai": "^4.77.0",
"typedoc": "^0.27.6",
"zod": "^3.24.1"
},
"devDependencies": {
"@types/bn.js": "^5.1.6",
"@types/chai": "^5.0.1",
"@types/node": "^22.10.2",
"@typescript-eslint/eslint-plugin": "^8.18.2",
"@typescript-eslint/parser": "^8.18.2",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"husky": "^9.1.7",
"lint-staged": "^15.3.0",
"prettier": "^3.4.2",
"tsx": "^4.19.2",
"typescript": "^5.7.2"
},
"packageManager": "pnpm@9.15.3"
}