Commit Graph

612 Commits

Author SHA1 Message Date
aryan
9267cc3111 Integrate Metaplex DAS API (#215)
# Pull Request Description
This PR implements the [Metaplex DAS
API](https://developers.metaplex.com/das-api) to the Solana Agent Kit

## Changes Made
This PR adds the following new tools and actions:
- Get Asset by ID
- Get Assets by Authority
- Get Assets by Creator
- Search/Lookup Assets by different criteria
  
## Implementation Details
- The actions and tools are implemented to their respective files in the
`metaplex/` folders of `actions`, `tools` and `langchain` directories.
- The actions were added as part of the SolanaAgentKit class and
exported under `createSolanaTools` function.
- The actions utilize the
`@metaplex-foundation/digital-asset-standard-api` SDK.

## Prompt Used

[prompts.txt](https://github.com/user-attachments/files/18442209/prompts.txt)

## Checklist
- [x] I have tested these changes locally
- [x] I have updated the documentation
- [x] I have added the prompt used to test it
2025-01-18 16:31:43 +05:30
Damjan
331482ac6a Update get_asset.ts 2025-01-18 10:06:09 +01:00
Damjan
925d0cf82b Merge remote-tracking branch 'sak/main' 2025-01-18 09:55:55 +01:00
aryan
343cf4c2d7 chore: docs + lint 2025-01-18 01:55:15 +05:30
aryan
54382a542e feat: Create Meteora pools (#203)
# Pull Request Description
This PR helps to create Meteora Dynamic and DLMM pool with prompt.

## Related Issue
Fixes # (issue number)

## Changes Made
This PR adds the following changes:
<!-- List the key changes made in this PR -->
- 
- 
  
## Implementation Details
<!-- Provide technical details about the implementation -->
- The agent kit uses the functions from the `dynamic-amm-sdk` and the
`dlmm-sdk` to create Meteora pools.
- Both the tools to create pools have the parameter
`computeUnitMicroLamports` to allow user inputs the priority fee so that
the transaction can be landed faster.

## Transaction executed by agent 
<!-- If applicable, provide example usage, transactions, or screenshots
-->
Example transaction: 
- Create Meteora Dynamic pool:
https://solscan.io/tx/3g1NEaiLAmrdewxTMP861MzZiubGs1K52PuADQpngX7frpABugUv1UfdKsyqFtvBjGcHqFW9wASMGtL8itADHujG
- Create Meteora DLMM pool:
https://solscan.io/tx/2zA6vzGAZZy3yQR9ZRNYw478gKtYLQpguiFAvbsedE7Sii65AVpoXM1YqQe3x1KsRxfqkqhZBdDaHpQ9hoq2hrZF

## Prompt Used
<!-- If relevant, include the prompt or configuration used -->
- Prompt to create Meteora Dynamic pool:
```
create meteora dynamic pool
```
- Prompt to input Dynamic pool params:
```
tokenAMint DVMkqJAx16dHV29RtHrFLe7VzbWCG64KCFfzgWQYvbVn tokenBMint So11111111111111111111111111111111111111112 tokenAAmount 100 tokenBAmount 0.01 tradeFeeNumerator 2500
```

- Prompt to create Meteora DLMM pool:
```
create meteora dlmm pool
```
- Prompt to input DLMM pool params:
```
tokenAMint DVMkqJAx16dHV29RtHrFLe7VzbWCG64KCFfzgWQYvbVn tokenBMint So11111111111111111111111111111111111111112 binStep 20 initialPrice 0.25 feeBps 20
```

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

## Checklist
- [x] I have tested these changes locally
- [ ] 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:50:45 +05:30
aryan
89aed5452c Merge branch 'main' into quangkeu95/main 2025-01-18 01:49:33 +05:30
aryan
68cb11b0e6 fix: Drift protocol team review implementation (#210)
# Pull Request Description

This PR fixes an issue with validating if a user has a drift account or
not. I noticed this while preparing a demo video to showcase how it
works. It also fixes the gas fee required to borrow funds from drift.

The PR also contains changes requested by the Drift Protocol team. The
changes include:
1. Addition of actions to stake and unstake from their insurance fund
2. Addition of actions to swap spot tokens
3. Addition of actions to get information such as the lend and borrow
apy, quote trade price impact and prices, and funding rates.
4. Addition of an action that gets available spot and perp markets.

# Tests and prompts used
![Image 16-01-2025 at 20
27](https://github.com/user-attachments/assets/09ee0f49-aae4-47cb-98a2-b49f2e5879bb)
![Image 16-01-2025 at 20
25](https://github.com/user-attachments/assets/b748c18f-d8d0-4469-9b61-07163e5224ab)
![Image 16-01-2025 at 19 58
(1)](https://github.com/user-attachments/assets/23a4afc6-5215-40eb-9959-4bba50c5f115)
![Image 16-01-2025 at 19
58](https://github.com/user-attachments/assets/1928a162-0a3a-4490-bc5d-ccdccfb320bb)
![Image 16-01-2025 at 19
57](https://github.com/user-attachments/assets/1989d7a5-1e28-4caa-a66e-71945252b653)
![Image 16-01-2025 at 19 56
(1)](https://github.com/user-attachments/assets/17eb2b84-1eff-4a75-bf4a-01345334d527)
![Image 16-01-2025 at 19
56](https://github.com/user-attachments/assets/8e78bc8e-3506-46c1-b79c-a8b77d597c1b)
![Image 16-01-2025 at 19
41](https://github.com/user-attachments/assets/b507f3ce-00fd-4b22-a851-a614d30a28a8)
2025-01-18 01:36:12 +05:30
aryan
d67747b70d Merge branch 'main' into feat/drift-tool 2025-01-18 01:34:39 +05:30
aryan
34f2e944cc feat: deposit and withdraw with lulo (#117)
# Pull Request Description

## Related Issue
Fixes # (issue number)

## Changes Made
This PR adds the following changes:
<!-- List the key changes made in this PR -->
-  deposit and withdraw with lulo
  
## Implementation Details
<!-- Provide technical details about the implementation -->
doc api: https://docs.lulo.fi/api-docs

## Transaction executed by agent 
<!-- If applicable, provide example usage, transactions, or screenshots
-->
Example transaction: 
1. Lend:
https://solscan.io/tx/4931BjyRpZstvvppSQrGiPR3aUko8jVadWk2UMXEwGvNh7uebNPv9KKAucezVc93XJ8NaWqeYA4iA49fzsNrtoVC
2. Withdraw:

https://solscan.io/tx/4JTjkAWG8ax19XXvQKyMiWcP5Z3j8SGdDuZEjBENMZJD29auHSyjgZuxNYqJWhBDqEEbG3eoFV5JKz9jDhsxUAkT

## Prompt Used
<!-- If relevant, include the prompt or configuration used -->
```
Lend 0.01 SOL to earn yield on Lulo

Withdraw 0.01 SOL with lulo

```

## Additional Notes
<!-- Any additional information that reviewers should know -->
<img width="1273" alt="image"
src="https://github.com/user-attachments/assets/e8463466-4ebd-4a87-8f9d-dd068b8026fc"
/>


## 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:19:20 +05:30
aryan
deb75d54c1 Merge branch 'main' into deposit_and_withdraw_with_lulo 2025-01-18 01:19:10 +05:30
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
aryan
6c124ac1cc Implemented NFT creation with Liquidity Pool (#224)
# Pull Request Description

## Changes Made
This PR adds the following changes:

- Implemented NFT creation with integrated liquidity pools in 3land
create NFT functionality

  
## Implementation Details

- Each NFT can be created with an associated liquidity pool
- Liquidity pools are identified by a unique poolName per wallet
- Multiple NFT editions can be created for the same liquidity pool
- Liquidity pools support any SPL token
- The SPL token used for the liquidity pool matches the NFT edition
token
- Sale proceeds (primary and secondary) are directed to the liquidity
pool
- Royalties from sales are automatically added to the liquidity pool
- NFT holders can burn their NFT to reclaim their investment
- Wallet addresses are restricted to one liquidity pool per poolName per
SPL token

## Transaction executed when testing
Example transactions created using solana-agent-kit:

1. First NFT edition with pool (pool 1):
https://dev.3.land/item/fXajTSwvrFCzaSL9mKE1KtTZ9wpChHC8egeXarMx3oD

2. Second edition with same pool (pool 1):
https://dev.3.land/item/8LdRScybmPQXkDdF2wafMSQ159ZDwckG1Pq7EkwGMFwW

3. Third edition with new pool (same SPL token):
https://dev.3.land/item/4HogLfgrgMYPpDqQK6Kw4kyGVtc7iu5ftBZuVRiPLm94

4. Fourth edition with new pool (different SPL token):
https://dev.3.land/item/FmPSPrNw9AoCCvUceHoXHuaFp2nC7GZEqyBsGpWEsMDM

## Additional Notes

- All features have been thoroughly tested and verified working
- The implementation maintains backward compatibility with existing NFT
creation
- Liquidity pool operations are atomic and maintain consistent state
- Pool naming restrictions prevent confusion and potential conflicts

## Checklist
- [X ] I have tested these changes locally
- [ X] I have updated the documentation
- [X ] I have added a transaction link
2025-01-18 01:12:12 +05:30
biccsdev
6bbb6d489c implemented nft creation with LP 2025-01-17 12:14:47 -06:00
michaelessiet
e4fa501c52 chore: add minimum compute price to constants 2025-01-17 17:23:15 +01:00
michaelessiet
67fa8217a7 fix: revert all changes in vercel ai test file 2025-01-17 17:15:05 +01:00
michaelessiet
0c840d9bcb feat: add more drift actions 2025-01-17 17:12:34 +01:00
quangkeu95
15172ee8c6 fix: Allow input normal token amounts 2025-01-17 15:20:57 +07:00
michaelessiet
79fe5b0cb4 fix: bugs noticed during testing 2025-01-16 21:33:07 +01:00
michaelessiet
97e9673089 feat: add more drift actions 2025-01-16 19:39:47 +01:00
Damjan
7df99ae897 Update README.md 2025-01-16 16:51:10 +01:00
michaelessiet
00f033ccf0 merge: main 2025-01-16 15:50:24 +01:00
Damjan
611de50acd Tool fixes and updates 2025-01-16 14:43:41 +01:00
Damjan
4d213665d3 Implement searchAssets tool 2025-01-16 14:22:50 +01:00
Damjan
a4774374b3 Implement getAssetsByCreator tool 2025-01-16 14:13:30 +01:00
Damjan
be0287c5a9 Implement getAssetsByAuthority tool 2025-01-16 14:02:56 +01:00
Damjan
651ee9623e Implement getAsset tool 2025-01-16 13:44:55 +01:00
jakeyvee
7cf2e80971 chore: resolve merge conflights 2025-01-16 15:21:20 +08:00
biccsdev
dc520dff08 Merge branch 'main' of github.com:3-land/solana-agent-kit into main 2025-01-15 11:49:29 -06:00
aryan
975dd7932b feat: add drift tools to langchain (#212)
# Pull Request Description

This PR is the langchain implementation of #207 

## Changes Made
This PR adds the following changes:
<!-- List the key changes made in this PR -->
- This PR adds files that implement the drift actions in a way
compatible with langchain
  
## Implementation Details
<!-- Provide technical details about the implementation -->
- Just a quick conversion of the drift actions to langchain tool classes

## Transaction executed by agent and prompt used
<!-- If applicable, provide example usage, transactions, or screenshots
-->
Example transaction: 
<img width="998" alt="Screenshot 2025-01-15 at 17 43 42"
src="https://github.com/user-attachments/assets/25f12c26-0f1a-470a-a566-028a54adf995"
/>
<img width="998" alt="Screenshot 2025-01-15 at 17 43 27"
src="https://github.com/user-attachments/assets/b07c6089-f5fc-4498-9d5a-14c5698c21a9"
/>
<img width="998" alt="Screenshot 2025-01-15 at 17 43 02"
src="https://github.com/user-attachments/assets/69067241-bb22-429b-9021-024c526ec25f"
/>

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

## Checklist
- [x] I have tested these changes locally
- [ ] I have updated the documentation
- [ ] I have added a transaction link
- [x] I have added the prompt used to test it
2025-01-15 22:19:05 +05:30
michaelessiet
ccbdc27f63 feat: add drift tools to langchain 2025-01-15 17:37:54 +01:00
aryan
3a338940dc feat: get all token balances (#113)
# Pull Request Description

## Related Issue
This doesn't fix any pre-existing issue, but is an attempt to claim the
bring your own idea bounty.

## Changes Made
This PR adds the following changes:
<!-- List the key changes made in this PR -->
- when token address is not supplied get_balance returns an object
containing the amount of sol an address has but also the balance of each
of it's non-TOKEN2022 token accounts
- 
  
## Implementation Details
<!-- Provide technical details about the implementation -->
- While reading the Solana RPC docs I came across an endpoint that
fetches all the token accounts owned by an address returns their
balances along with that.
- So with this data I thought why not just implement get_balance to be
more comprehensive than just simple `number` values

## Transaction executed by agent 
<!-- If applicable, provide example usage, transactions, or screenshots
-->
Example transaction: 
<img width="610" alt="Screenshot 2025-01-11 at 18 10 20"
src="https://github.com/user-attachments/assets/f242af3c-8703-42aa-8a65-a6dd9b369392"
/>



## Prompt Used
<!-- If relevant, include the prompt or configuration used -->
```
What's my balance
```

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

## Checklist
- [x] I have tested these changes locally
- [ ] I have updated the documentation
- [ ] I have added a transaction link
- [x] I have added the prompt used to test it
2025-01-15 20:40:53 +05:30
aryan
39cdf19b2f Merge branch 'main' into feature/totalbalance 2025-01-15 20:40:44 +05:30
aryan
ec7066b0a4 fix: failing CI workflow (#211)
# Pull Request Description

This PR fixes the failing CI workflow
2025-01-15 20:33:57 +05:30
michaelessiet
6635d0e934 fix: failing CI workflow 2025-01-15 15:45:30 +01:00
michaelessiet
484a64de85 fix: drift user account info fetching 2025-01-15 14:52:13 +01:00
jakeyvee
e3c93222de chore: export voltr folder instead of indiv files in tools 2025-01-15 21:28:09 +08:00
jakeyvee
2971bdaef4 feat: include Voltr into readme 2025-01-15 21:21:13 +08:00
jakeyvee
04cd1b2e28 chore: merge Voltr changes into remote branch 2025-01-15 21:18:14 +08:00
michaelessiet
15e428ba4c chore: catch up remote 2025-01-15 13:30:03 +01:00
michaelessiet
df01cc3267 merge: main 2025-01-15 13:28:58 +01:00
jakeyvee
c71f2159fd fix: changes for Voltr vault program upgrade 2025-01-15 18:15:35 +08:00
aryan
a65463a77b chore: docs + lint 2025-01-15 02:55:30 +05:30
aryan
47be1a8359 Feat: Drift integration (#207)
# Pull Request Description

This PR adds [Drift protocol](https://drift.trade) to SolanaAgentKit.
Functionality implemented includes:
1. Vault management: creation, depositing, trading, and withdrawal
2. Perpetual trading: trade opening, closing, and order creation
3. Account management: create, deposit, withdraw, lend and borrow

## Changes Made
This PR adds the following changes:
<!-- List the key changes made in this PR -->
- This PR adds drift protocol to the SDK
  
## Implementation Details
<!-- Provide technical details about the implementation -->
- This integration required the following SDKs to be installed
`@drift-labs/sdk`, `@drift-labs/vaults`.
- These SDKs were required in order to interface with the Drift programs
- These SDKs also provided utility functions and constants that made
integration a whole lot easier

## Transaction executed by agent and prompts used
<!-- If applicable, provide example usage, transactions, or screenshots
-->
Example transaction: 
<img width="771" alt="Screenshot 2025-01-14 at 21 20 42"
src="https://github.com/user-attachments/assets/da4639c6-ffd7-461e-bb36-a31435dbbb52"
/>
<img width="771" alt="Screenshot 2025-01-14 at 21 21 56"
src="https://github.com/user-attachments/assets/90652b78-9c6e-4e16-8cd0-13d276ac5747"
/>
<img width="771" alt="Screenshot 2025-01-14 at 21 23 28"
src="https://github.com/user-attachments/assets/40a63cd5-5a7f-491b-80c0-905335713bc8"
/>
<img width="771" alt="Screenshot 2025-01-14 at 21 25 40"
src="https://github.com/user-attachments/assets/ec380ded-486d-4403-88c4-207948f3dbc3"
/>
<img width="771" alt="Screenshot 2025-01-14 at 21 27 30"
src="https://github.com/user-attachments/assets/0a4d80a3-f352-497e-9030-462856b9a783"
/>

**Transaction Links**:
-
https://solscan.io/tx/4BondSu3JArkMiHYwFbaExweu3DMcBKiks4uP7oKdmj7Tb3NzdvX5foPdFhbXiSgfmG3t8MtHchkPHshN1d1i5qx
-
https://solscan.io/tx/3qEr1hPCmcmn4nmf31RJAP7ZjkWLm5ehmYfxEUvK8S1jLAUAiVwy35P7oVv5xTEoPr168oRCXZP2zcaq6K6V2bdD

-https://solscan.io/tx/22zDZ8CUn11yRWR8Guj5p7X2r5XSUyFo12FxHReAdauuzwaM9Pg3VsP5uJf8LopzAm4yYtgBMzd59m96KtZf8TPf

## Prompt Used
<!-- If relevant, include the prompt or configuration used -->
```
Create a drift account and deposit 2 usdc into my drift account
```

## 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-15 02:44:45 +05:30
Michael Essiet
ea96aa2d79 Merge branch 'main' into feat/drift-tool 2025-01-14 21:35:11 +01:00
michaelessiet
fd95ac8682 chore: drift integration docs 2025-01-14 21:07:24 +01:00
michaelessiet
2f05af13cb fix: drift vault deposits and withdrawals 2025-01-14 20:33:18 +01:00
michaelessiet
4d50d2f260 fix: drift vault experience 2025-01-14 15:08:18 +01:00
michaelessiet
f0d84f6924 feat: add drift functions to agent class 2025-01-14 12:43:28 +01:00
Arihant Bansal
6233203361 feat: update contributing docs (#206)
# Pull Request Description

## Related Issue
Fixes # (issue number)

## Changes Made
This PR adds the following changes:
<!-- List the key changes made in this PR -->
- 
- 
  
## Implementation Details
<!-- Provide technical details about the implementation -->
- 
- 

## Transaction executed by agent 
<!-- If applicable, provide example usage, transactions, or screenshots
-->
Example transaction: 

## Prompt Used
<!-- If relevant, include the prompt or configuration used -->
```
```

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

## Checklist
- [ ] I have tested these changes locally
- [ ] I have updated the documentation
- [ ] I have added a transaction link
- [ ] I have added the prompt used to test it
2025-01-14 16:25:35 +05:30
Arihant Bansal
82847f5723 feat: update contributing docs 2025-01-14 16:20:56 +05:30