Merge branch 'main' into quangkeu95/main

This commit is contained in:
aryan
2025-01-18 01:49:33 +05:30
130 changed files with 13458 additions and 4458 deletions

View File

@@ -4,4 +4,5 @@ SOLANA_PRIVATE_KEY=
JUPITER_REFERRAL_ACCOUNT= JUPITER_REFERRAL_ACCOUNT=
JUPITER_FEE_BPS= JUPITER_FEE_BPS=
FLASH_PRIVILEGE= referral | nft | none FLASH_PRIVILEGE= referral | nft | none
FLEXLEND_API_KEY=
HELIUS_API_KEY= HELIUS_API_KEY=

View File

@@ -13,6 +13,7 @@
"no-constant-condition": "off", "no-constant-condition": "off",
"@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }], "@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
"no-console": ["warn", { "allow": ["warn", "error"] }], "no-console": ["warn", { "allow": ["warn", "error"] }],
"curly": ["error", "all"], "curly": ["error", "all"],

View File

@@ -14,6 +14,9 @@ jobs:
with: with:
version: 9.4.0 version: 9.4.0
- name: Install node-gyp prerequisites
run: sudo apt update && sudo apt install -y build-essential python3 pkg-config libudev-dev libusb-1.0-0-dev
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: "23" node-version: "23"

217
README.md
View File

@@ -56,6 +56,7 @@ Anyone - whether an SF-based AI researcher or a crypto-native builder - can brin
- Pyth Price feeds for fetching Asset Prices - Pyth Price feeds for fetching Asset Prices
- Register/resolve Alldomains - Register/resolve Alldomains
- Perpetuals Trading with Adrena Protocol - Perpetuals Trading with Adrena Protocol
- Drift Vaults, Perps, Lending and Borrowing
- **Solana Blinks** - **Solana Blinks**
- Lending by Lulo (Best APR for USDC) - Lending by Lulo (Best APR for USDC)
@@ -133,10 +134,7 @@ console.log("Token Mint Address:", result.mint.toString());
``` ```
### Create NFT Collection on 3Land ### Create NFT Collection on 3Land
```typescript ```typescript
const optionsWithBase58: StoreInitOptions = { const isDevnet = true; // (Optional) if not present TX takes place in Mainnet
privateKey: "",
isMainnet: true, // if false, collection will be created on devnet 3.land (dev.3.land)
};
const collectionOpts: CreateCollectionOptions = { const collectionOpts: CreateCollectionOptions = {
collectionName: "", collectionName: "",
@@ -146,18 +144,16 @@ const optionsWithBase58: StoreInitOptions = {
}; };
const result = await agent.create3LandCollection( const result = await agent.create3LandCollection(
optionsWithBase58, collectionOpts,
collectionOpts isDevnet, // (Optional) if not present TX takes place in Mainnet
); );
``` ```
### Create NFT on 3Land ### Create NFT on 3Land
When creating an NFT using 3Land's tool, it automatically goes for sale on 3.land website When creating an NFT using 3Land's tool, it automatically goes for sale on 3.land website
```typescript ```typescript
const optionsWithBase58: StoreInitOptions = { const isDevnet = true; // (Optional) if not present TX takes place in Mainnet
privateKey: "", const withPool = true; // (Optional) only present if NFT will be created with a Liquidity Pool for a specific SPL token
isMainnet: true, // if false, listing will be on devnet 3.land (dev.3.land)
};
const collectionAccount = ""; //hash for the collection const collectionAccount = ""; //hash for the collection
const createItemOptions: CreateSingleOptions = { const createItemOptions: CreateSingleOptions = {
itemName: "", itemName: "",
@@ -169,15 +165,15 @@ const createItemOptions: CreateSingleOptions = {
{ trait_type: "", value: "" }, { trait_type: "", value: "" },
], ],
price: 0, //100000000 == 0.1 sol, can be set to 0 for a free mint price: 0, //100000000 == 0.1 sol, can be set to 0 for a free mint
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
poolName: "", // Only present if "withPool" is true
mainImageUrl: "", mainImageUrl: "",
splHash: "", //present if listing is on a specific SPL token, if not present sale will be on $SOL
}; };
const isMainnet = true;
const result = await agent.create3LandNft( const result = await agent.create3LandNft(
optionsWithBase58,
collectionAccount, collectionAccount,
createItemOptions, createItemOptions,
isMainnet isDevnet, // (Optional) if not present TX takes place in Mainnet
withPool
); );
``` ```
@@ -309,6 +305,199 @@ const signature = await agent.closePerpTradeLong({
const { signature } = await agent.closeEmptyTokenAccounts(); const { signature } = await agent.closeEmptyTokenAccounts();
``` ```
### Create a Drift account
Create a drift account with an initial token deposit.
```typescript
const result = await agent.createDriftUserAccount()
```
### Create a Drift Vault
Create a drift vault.
```typescript
const signature = await agent.createDriftVault({
name: "my-drift-vault",
marketName: "USDC-SPOT",
redeemPeriod: 1, // in days
maxTokens: 100000, // in token units e.g 100000 USDC
minDepositAmount: 5, // in token units e.g 5 USDC
managementFee: 1, // 1%
profitShare: 10, // 10%
hurdleRate: 5, // 5%
permissioned: false, // public vault or whitelist
})
```
### Deposit into a Drift Vault
Deposit tokens into a drift vault.
```typescript
const signature = await agent.depositIntoDriftVault(100, "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU")
```
### Deposit into your Drift account
Deposit tokens into your drift account.
```typescript
const {txSig} = await agent.depositToDriftUserAccount(100, "USDC")
```
### Derive a Drift Vault address
Derive a drift vault address.
```typescript
const vaultPublicKey = await agent.deriveDriftVaultAddress("my-drift-vault")
```
### Do you have a Drift account
Check if agent has a drift account.
```typescript
const {hasAccount, account} = await agent.doesUserHaveDriftAccount()
```
### Get Drift account information
Get drift account information.
```typescript
const accountInfo = await agent.driftUserAccountInfo()
```
### Request withdrawal from Drift vault
Request withdrawal from drift vault.
```typescript
const signature = await agent.requestWithdrawalFromDriftVault(100, "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU")
```
### Carry out a perpetual trade using a Drift vault
Open a perpertual trade using a drift vault that is delegated to you.
```typescript
const signature = await agent.tradeUsingDelegatedDriftVault({
vault: "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU",
amount: 500,
symbol: "SOL",
action: "long",
type: "limit",
price: 180 // Please long limit order at $180/SOL
})
```
### Carry out a perpetual trade using your Drift account
Open a perpertual trade using your drift account.
```typescript
const signature = await agent.tradeUsingDriftPerpAccount({
amount: 500,
symbol: "SOL",
action: "long",
type: "limit",
price: 180 // Please long limit order at $180/SOL
})
```
### Update Drift vault parameters
Update drift vault parameters.
```typescript
const signature = await agent.updateDriftVault({
name: "my-drift-vault",
marketName: "USDC-SPOT",
redeemPeriod: 1, // in days
maxTokens: 100000, // in token units e.g 100000 USDC
minDepositAmount: 5, // in token units e.g 5 USDC
managementFee: 1, // 1%
profitShare: 10, // 10%
hurdleRate: 5, // 5%
permissioned: false, // public vault or whitelist
})
```
### Withdraw from Drift account
Withdraw tokens from your drift account.
```typescript
const {txSig} = await agent.withdrawFromDriftAccount(100, "USDC")
```
### Borrow from Drift
Borrow tokens from drift.
```typescript
const {txSig} = await agent.withdrawFromDriftAccount(1, "SOL", true)
```
### Repay Drift loan
Repay a loan from drift.
```typescript
const {txSig} = await agent.depositToDriftUserAccount(1, "SOL", true)
```
### Withdraw from Drift vault
Withdraw tokens from a drift vault after the redemption period has elapsed.
```typescript
const signature = await agent.withdrawFromDriftVault( "41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU")
```
### Update the address a Drift vault is delegated to
Update the address a drift vault is delegated to.
```typescript
const signature = await agent.updateDriftVaultDelegate("41Y8C4oxk4zgJT1KXyQr35UhZcfsp5mP86Z2G7UUzojU", "new-address")
```
### Get Voltr Vault Position Values
Get the current position values and total value of assets in a Voltr vault.
```typescript
const values = await agent.voltrGetPositionValues("7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K")
```
### Deposit into Voltr Strategy
Deposit assets into a specific strategy within a Voltr vault.
```typescript
const signature = await agent.voltrDepositStrategy(
new BN("1000000000"), // amount in base units (e.g., 1 USDC = 1000000)
"7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K", // vault
"9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk" // strategy
)
```
### Withdraw from Voltr Strategy
Withdraw assets from a specific strategy within a Voltr vault.
```typescript
const signature = await agent.voltrWithdrawStrategy(
new BN("1000000000"), // amount in base units (e.g., 1 USDC = 1000000)
"7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K", // vault
"9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk" // strategy
)
```
## Examples ## Examples
### LangGraph Multi-Agent System ### LangGraph Multi-Agent System

View File

@@ -1 +1 @@
window.navigationData = "eJyNllGTkzAQgP9LnjvWq96pfaut1ep57dwxvjg+7IWlZAgJkyzajuN/d0o7B5Sw8MID++23sMkSfv4VhAcSc/FkNRhY7NHQN0ViIgqgVMyF1OA9+mk7/iqlXIuJyJSJxfxm9v7f5MW0kKSsqQ3KELoEJPrpOdROnt3edZI/HSAvNDKOC8GpPgLJdOtidDsgQhd+pA7FKZdWa6zqr7DQ9pijoaA1BI4Tb4vT1Q9YLxSvNIna93hOITbZIZB14exzjEtfI8l055TER/SFNT68lF2MlWrw6VJbj5GDGHfgIA/3KUgOqkdZRwo/q+c/1mVVqzACnz1ifxv6YK7A17JQhC6yGZoVEATF1xAnvC+1XUhpS0MrJFDas0vXj3NFvitD9SZ+WEdsjV6aK3EZ5d5VbMQ5za7Mi6Q091AambJPGSSH1OvSVKvCTXuAY7VHSkfOXRgdklfwGjHerDaEea/5ihulHRYOqao2LVOUWdBThznJFzCxxsZnj44F+unl9lXm6w/vbm5nzbNrGW22D0919m9wCp716dA6h9qGN81kWU3/+ZSNrNWNPZGUppoAP+1AbeHd247wBzqJerEZULYwRooHlCXh9RFf61oAI0qUifstdZRR7JFa/wLB1+tAHeGv/7OFIBQ=" window.navigationData = "eJyNllGTkzAQgP8Lzx3r9bxT+1Zbq+h57dwx3oPjwzZsS4aQMMmi7Tj+d6fQEShh4YUH9ttvYSGb/PgTEB4pmAfPRoGGxQE1fZUUTIIcKAnmgVDgHLppO/4qoUwFkyCVOg7mN7N3fyf/TQtB0ujaIDWh3YNAN61C7eTZ3X0n+eMRslwh47gQnOoDkEg2Nka7BSK0/kfqUJxyaZTCsv4Kc2VOGWryWn3gOPEmP1/dgPVC8Uq9l4cezznEJlsEMtafXcW49DWSSLZWCnxClxvt/J+yi7FSBS5ZKuMwshDjFixk/j55yUH1KOtI4Se5+21sWrYKI3DpE/a3oQ/mCnxGJQv3grvEmDSM2Tb3sKP14+Vj1F+KXBLayKSoV0DgtV5DnPChUGYhhCk0rZBAKsc+cD/OFfkmNdXL73EdsTV6aa7EZQj1/n+NOKfZWmmspNMa+cXn4VhtkeX7Qj9AoUXCi33kkHpd6PJjc+PPw7HaEyUjB5EfHZKX8BoxDlchYdZrvuJGaYeFQ6qyTcsERer11GF2DoCOFTb2ATrl50Vf3b7KfP3+7c3drLmZL6Nw8/hcZ/8CK2Gnzrt4FWobbpvJohyH1bEjMkY1/ol9ocuF5aYdqC28f9MRfkcrUC3CAWULY6R4RFEQXp95al0LYER7qeN+Sx1lFAek1uHI+3odqCP8+Q8guIFL"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,2 +1,2 @@
<!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>executeAction | solana-agent-kit</title><meta name="description" content="Documentation for solana-agent-kit"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">solana-agent-kit</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">solana-agent-kit</a></li><li><a href="executeAction.html">executeAction</a></li></ul><h1>Function executeAction</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="executeaction" class="tsd-anchor"></a><span class="tsd-kind-call-signature">executeAction</span><span class="tsd-signature-symbol">(</span><br/>    <span class="tsd-kind-parameter">action</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Action</span><span class="tsd-signature-symbol">,</span><br/>    <span class="tsd-kind-parameter">agent</span><span class="tsd-signature-symbol">:</span> <a href="../classes/SolanaAgentKit.html" class="tsd-signature-type tsd-kind-class">SolanaAgentKit</a><span class="tsd-signature-symbol">,</span><br/>    <span class="tsd-kind-parameter">input</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span><a href="#executeaction" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Execute an action with the given input</p> <!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>executeAction | solana-agent-kit</title><meta name="description" content="Documentation for solana-agent-kit"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">solana-agent-kit</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">solana-agent-kit</a></li><li><a href="executeAction.html">executeAction</a></li></ul><h1>Function executeAction</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="executeaction" class="tsd-anchor"></a><span class="tsd-kind-call-signature">executeAction</span><span class="tsd-signature-symbol">(</span><br/>    <span class="tsd-kind-parameter">action</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Action</span><span class="tsd-signature-symbol">,</span><br/>    <span class="tsd-kind-parameter">agent</span><span class="tsd-signature-symbol">:</span> <a href="../classes/SolanaAgentKit.html" class="tsd-signature-type tsd-kind-class">SolanaAgentKit</a><span class="tsd-signature-symbol">,</span><br/>    <span class="tsd-kind-parameter">input</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span><a href="#executeaction" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Execute an action with the given input</p>
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">action</span>: <span class="tsd-signature-type">Action</span></span></li><li><span><span class="tsd-kind-parameter">agent</span>: <a href="../classes/SolanaAgentKit.html" class="tsd-signature-type tsd-kind-class">SolanaAgentKit</a></span></li><li><span><span class="tsd-kind-parameter">input</span>: <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/4c4cbb013e8b9fd3407901334ee205e1dc7f3a0f/src/utils/actionExecutor.ts#L20">utils/actionExecutor.ts:20</a></li></ul></aside></li></ul></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">solana-agent-kit</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html> </div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">action</span>: <span class="tsd-signature-type">Action</span></span></li><li><span><span class="tsd-kind-parameter">agent</span>: <a href="../classes/SolanaAgentKit.html" class="tsd-signature-type tsd-kind-class">SolanaAgentKit</a></span></li><li><span><span class="tsd-kind-parameter">input</span>: <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol">&lt;</span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">&gt;</span><span class="tsd-signature-symbol">&gt;</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/47be1a835935cbf4f7a478c4d50759402e9dbafa/src/utils/actionExecutor.ts#L20">src/utils/actionExecutor.ts:20</a></li></ul></aside></li></ul></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">solana-agent-kit</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>

View File

@@ -1,2 +1,2 @@
<!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>findAction | solana-agent-kit</title><meta name="description" content="Documentation for solana-agent-kit"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">solana-agent-kit</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">solana-agent-kit</a></li><li><a href="findAction.html">findAction</a></li></ul><h1>Function findAction</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="findaction" class="tsd-anchor"></a><span class="tsd-kind-call-signature">findAction</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">query</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Action</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">undefined</span><a href="#findaction" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Find an action by its name or one of its similes</p> <!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>findAction | solana-agent-kit</title><meta name="description" content="Documentation for solana-agent-kit"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">solana-agent-kit</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">solana-agent-kit</a></li><li><a href="findAction.html">findAction</a></li></ul><h1>Function findAction</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="findaction" class="tsd-anchor"></a><span class="tsd-kind-call-signature">findAction</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">query</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Action</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">undefined</span><a href="#findaction" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Find an action by its name or one of its similes</p>
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">query</span>: <span class="tsd-signature-type">string</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Action</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">undefined</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/4c4cbb013e8b9fd3407901334ee205e1dc7f3a0f/src/utils/actionExecutor.ts#L8">utils/actionExecutor.ts:8</a></li></ul></aside></li></ul></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">solana-agent-kit</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html> </div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">query</span>: <span class="tsd-signature-type">string</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Action</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">undefined</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/47be1a835935cbf4f7a478c4d50759402e9dbafa/src/utils/actionExecutor.ts#L8">src/utils/actionExecutor.ts:8</a></li></ul></aside></li></ul></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">solana-agent-kit</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>

View File

@@ -1,2 +1,2 @@
<!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>getActionExamples | solana-agent-kit</title><meta name="description" content="Documentation for solana-agent-kit"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">solana-agent-kit</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">solana-agent-kit</a></li><li><a href="getActionExamples.html">getActionExamples</a></li></ul><h1>Function getActionExamples</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="getactionexamples" class="tsd-anchor"></a><span class="tsd-kind-call-signature">getActionExamples</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">action</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Action</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><a href="#getactionexamples" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Get examples for an action</p> <!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>getActionExamples | solana-agent-kit</title><meta name="description" content="Documentation for solana-agent-kit"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">solana-agent-kit</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">solana-agent-kit</a></li><li><a href="getActionExamples.html">getActionExamples</a></li></ul><h1>Function getActionExamples</h1></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="getactionexamples" class="tsd-anchor"></a><span class="tsd-kind-call-signature">getActionExamples</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">action</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Action</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><a href="#getactionexamples" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-comment tsd-typography"><p>Get examples for an action</p>
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">action</span>: <span class="tsd-signature-type">Action</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/4c4cbb013e8b9fd3407901334ee205e1dc7f3a0f/src/utils/actionExecutor.ts#L58">utils/actionExecutor.ts:58</a></li></ul></aside></li></ul></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">solana-agent-kit</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html> </div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">action</span>: <span class="tsd-signature-type">Action</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/47be1a835935cbf4f7a478c4d50759402e9dbafa/src/utils/actionExecutor.ts#L58">src/utils/actionExecutor.ts:58</a></li></ul></aside></li></ul></section></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">solana-agent-kit</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>

File diff suppressed because one or more lines are too long

View File

@@ -1,16 +1,16 @@
<!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Action | solana-agent-kit</title><meta name="description" content="Documentation for solana-agent-kit"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">solana-agent-kit</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">solana-agent-kit</a></li><li><a href="Action.html">Action</a></li></ul><h1>Interface Action</h1></div><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><p>Main Action interface inspired by ELIZA <!DOCTYPE html><html class="default" lang="en" data-base=".."><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Action | solana-agent-kit</title><meta name="description" content="Documentation for solana-agent-kit"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">solana-agent-kit</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../modules.html">solana-agent-kit</a></li><li><a href="Action.html">Action</a></li></ul><h1>Interface Action</h1></div><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><p>Main Action interface inspired by ELIZA
This interface makes it easier to implement actions across different frameworks</p> This interface makes it easier to implement actions across different frameworks</p>
</div><div class="tsd-comment tsd-typography"></div></section><div class="tsd-signature"><span class="tsd-signature-keyword">interface</span> <span class="tsd-kind-interface">Action</span> <span class="tsd-signature-symbol">{</span><br/>    <a class="tsd-kind-property" href="Action.html#description">description</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="Action.html#examples">examples</a><span class="tsd-signature-symbol">:</span> <a href="ActionExample.html" class="tsd-signature-type tsd-kind-interface">ActionExample</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="Action.html#handler">handler</a><span class="tsd-signature-symbol">:</span> <a href="../types/Handler.html" class="tsd-signature-type tsd-kind-type-alias">Handler</a><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="Action.html#name">name</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="Action.html#schema">schema</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">ZodType</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="Action.html#similes">similes</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">;</span><br/><span class="tsd-signature-symbol">}</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/4c4cbb013e8b9fd3407901334ee205e1dc7f3a0f/src/types/index.ts#L126">types/index.ts:126</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="Action.html#description" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>description</span></a> </div><div class="tsd-comment tsd-typography"></div></section><div class="tsd-signature"><span class="tsd-signature-keyword">interface</span> <span class="tsd-kind-interface">Action</span> <span class="tsd-signature-symbol">{</span><br/>    <a class="tsd-kind-property" href="Action.html#description">description</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="Action.html#examples">examples</a><span class="tsd-signature-symbol">:</span> <a href="ActionExample.html" class="tsd-signature-type tsd-kind-interface">ActionExample</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="Action.html#handler">handler</a><span class="tsd-signature-symbol">:</span> <a href="../types/Handler.html" class="tsd-signature-type tsd-kind-type-alias">Handler</a><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="Action.html#name">name</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="Action.html#schema">schema</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">ZodType</span><span class="tsd-signature-symbol">;</span><br/>    <a class="tsd-kind-property" href="Action.html#similes">similes</a><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">;</span><br/><span class="tsd-signature-symbol">}</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/47be1a835935cbf4f7a478c4d50759402e9dbafa/src/types/index.ts#L127">src/types/index.ts:127</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><h5 class="tsd-index-heading uppercase" role="button" aria-expanded="false" tabIndex="0"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-chevronSmall"></use></svg> Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="Action.html#description" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>description</span></a>
<a href="Action.html#examples" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>examples</span></a> <a href="Action.html#examples" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>examples</span></a>
<a href="Action.html#handler" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>handler</span></a> <a href="Action.html#handler" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>handler</span></a>
<a href="Action.html#name" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>name</span></a> <a href="Action.html#name" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>name</span></a>
<a href="Action.html#schema" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>schema</span></a> <a href="Action.html#schema" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>schema</span></a>
<a href="Action.html#similes" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>similes</span></a> <a href="Action.html#similes" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>similes</span></a>
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Properties</h2></summary><section><section class="tsd-panel tsd-member"><a id="description" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>description</span><a href="#description" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">description</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><div class="tsd-comment tsd-typography"><p>Detailed description of what the action does</p> </div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><h2><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg> Properties</h2></summary><section><section class="tsd-panel tsd-member"><a id="description" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>description</span><a href="#description" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">description</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><div class="tsd-comment tsd-typography"><p>Detailed description of what the action does</p>
</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/4c4cbb013e8b9fd3407901334ee205e1dc7f3a0f/src/types/index.ts#L140">types/index.ts:140</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="examples" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>examples</span><a href="#examples" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">examples</span><span class="tsd-signature-symbol">:</span> <a href="ActionExample.html" class="tsd-signature-type tsd-kind-interface">ActionExample</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span></div><div class="tsd-comment tsd-typography"><p>Array of example inputs and outputs for the action </div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/47be1a835935cbf4f7a478c4d50759402e9dbafa/src/types/index.ts#L141">src/types/index.ts:141</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="examples" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>examples</span><a href="#examples" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">examples</span><span class="tsd-signature-symbol">:</span> <a href="ActionExample.html" class="tsd-signature-type tsd-kind-interface">ActionExample</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span></div><div class="tsd-comment tsd-typography"><p>Array of example inputs and outputs for the action
Each inner array represents a group of related examples</p> Each inner array represents a group of related examples</p>
</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/4c4cbb013e8b9fd3407901334ee205e1dc7f3a0f/src/types/index.ts#L146">types/index.ts:146</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="handler" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>handler</span><a href="#handler" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">handler</span><span class="tsd-signature-symbol">:</span> <a href="../types/Handler.html" class="tsd-signature-type tsd-kind-type-alias">Handler</a></div><div class="tsd-comment tsd-typography"><p>Function that executes the action</p> </div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/47be1a835935cbf4f7a478c4d50759402e9dbafa/src/types/index.ts#L147">src/types/index.ts:147</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="handler" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>handler</span><a href="#handler" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">handler</span><span class="tsd-signature-symbol">:</span> <a href="../types/Handler.html" class="tsd-signature-type tsd-kind-type-alias">Handler</a></div><div class="tsd-comment tsd-typography"><p>Function that executes the action</p>
</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/4c4cbb013e8b9fd3407901334ee205e1dc7f3a0f/src/types/index.ts#L156">types/index.ts:156</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="name" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>name</span><a href="#name" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">name</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><div class="tsd-comment tsd-typography"><p>Unique name of the action</p> </div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/47be1a835935cbf4f7a478c4d50759402e9dbafa/src/types/index.ts#L157">src/types/index.ts:157</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="name" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>name</span><a href="#name" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">name</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span></div><div class="tsd-comment tsd-typography"><p>Unique name of the action</p>
</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/4c4cbb013e8b9fd3407901334ee205e1dc7f3a0f/src/types/index.ts#L130">types/index.ts:130</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="schema" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>schema</span><a href="#schema" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">schema</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">ZodType</span></div><div class="tsd-comment tsd-typography"><p>Zod schema for input validation</p> </div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/47be1a835935cbf4f7a478c4d50759402e9dbafa/src/types/index.ts#L131">src/types/index.ts:131</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="schema" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>schema</span><a href="#schema" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">schema</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">ZodType</span></div><div class="tsd-comment tsd-typography"><p>Zod schema for input validation</p>
</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/4c4cbb013e8b9fd3407901334ee205e1dc7f3a0f/src/types/index.ts#L151">types/index.ts:151</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="similes" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>similes</span><a href="#similes" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">similes</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></div><div class="tsd-comment tsd-typography"><p>Alternative names/phrases that can trigger this action</p> </div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/47be1a835935cbf4f7a478c4d50759402e9dbafa/src/types/index.ts#L152">src/types/index.ts:152</a></li></ul></aside></section><section class="tsd-panel tsd-member"><a id="similes" class="tsd-anchor"></a><h3 class="tsd-anchor-link"><span>similes</span><a href="#similes" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">similes</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">[]</span></div><div class="tsd-comment tsd-typography"><p>Alternative names/phrases that can trigger this action</p>
</div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/4c4cbb013e8b9fd3407901334ee205e1dc7f3a0f/src/types/index.ts#L135">types/index.ts:135</a></li></ul></aside></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#description" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>description</span></a><a href="#examples" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>examples</span></a><a href="#handler" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>handler</span></a><a href="#name" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>name</span></a><a href="#schema" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>schema</span></a><a href="#similes" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>similes</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">solana-agent-kit</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html> </div><div class="tsd-comment tsd-typography"></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/sendaifun/solana-agent-kit/blob/47be1a835935cbf4f7a478c4d50759402e9dbafa/src/types/index.ts#L136">src/types/index.ts:136</a></li></ul></aside></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#description" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>description</span></a><a href="#examples" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>examples</span></a><a href="#handler" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>handler</span></a><a href="#name" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>name</span></a><a href="#schema" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>schema</span></a><a href="#similes" class=""><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1024"></use></svg><span>similes</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">solana-agent-kit</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -9,23 +9,23 @@ Extending the **Solana Agent Kit** with custom tools allows you to add specializ
3. Add supporting functions in SolanaAgentKit 3. Add supporting functions in SolanaAgentKit
4. Implement the Langchain tool class 4. Implement the Langchain tool class
5. Export the Langchain tool 5. Export the Langchain tool
6. Define Action class for given tool 6. Export your protocol's langchain tools (if not already exported)
7. Export Action 7. Define Action class for given tool
8. Use the custom tool 8. Export Action
9. Use the custom tool
## Implementation Guide ## Implementation Guide
### 1. Create a New Tool File ### 1. Create a New Tool File
Create a new TypeScript file in the `src/tools/` directory for your tool (e.g., `custom_tool.ts`). Create a new TypeScript file in the `src/tools/your_protocol` directory for your tool (e.g., `custom_tool.ts`). If the `src/tools/your_protocol` directory does not exist, create it.
### 2. Export the Tool (if not already exported)
### 2. Export the Tool
> `src/tools/index.ts` > `src/tools/index.ts`
```typescript:src/tools/index.ts ```typescript:src/tools/index.ts
export * from "./request_faucet_funds"; export * from "./squads";
export * from "./deploy_token"; export * from "./jupiter";
export * from "./custom_tool"; // Add your new tool export * from "./your_protocol"; // Add your protocol here if it's not already in the list
``` ```
### 3. Add Supporting Functions to SolanaAgentKit ### 3. Add Supporting Functions to SolanaAgentKit
@@ -42,10 +42,10 @@ export class SolanaAgentKit {
``` ```
### 4. Implement the Langchain Tool Class ### 4. Implement the Langchain Tool Class
> `src/langchain/index.ts` > `src/langchain/your_protocol/custom_tool.ts`
```typescript:src/langchain/index.ts ```typescript:src/langchain/your_protocol/custom_tool.ts
import { Tool } from "langchain/tools"; import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../agent"; import { SolanaAgentKit } from "../../agent";
export class CustomTool extends Tool { export class CustomTool extends Tool {
name = "custom_tool"; name = "custom_tool";
@@ -75,26 +75,26 @@ export class CustomTool extends Tool {
``` ```
### 5. Export Langchain Tool ### 5. Export Langchain Tool
> `src/langchain/index.ts` > `src/langchain/your_protocol/index.ts`
```typescript:src/langchain/index.ts ```typescript:src/langchain/your_protocol/index.ts
import { CustomTool } from "../tools"; export * from "./custom_tool";
export function createSolanaTools(agent: SolanaAgentKit) {
return [
// ... existing tools ...
new CustomTool(agent),
];
}
``` ```
### 6. Define Action class for given tool ### 6. Export your protocol's langchain tools (if not already exported)
> `src/langchain/index.ts`
```typescript:src/langchain/index.ts
export * from "./tiplink";
export * from "./your_protocol"; // Add your protocol here if it's not already in the list
```
> `src/actions/custom_action.ts` ### 7. Define Action class for given tool
```typescript:src/actions/custom_action.ts
import { Action } from "../types/action"; > `src/actions/your_protocol/custom_action.ts`
import { SolanaAgentKit } from "../agent"; ```typescript:src/actions/your_protocol/custom_action.ts
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod"; import { z } from "zod";
import { custom_tool } from "../tools"; import { custom_tool } from "../../tools";
const customAction: Action = { const customAction: Action = {
name: "CUSTOM_ACTION", name: "CUSTOM_ACTION",
@@ -121,11 +121,10 @@ const customAction: Action = {
}; };
``` ```
### 7. Export Action ### 8. Export Action
> `src/actions/index.ts` > `src/actions/index.ts`
```typescript:src/actions/index.ts ```typescript:src/actions/index.ts
export * from "./balance"; import customAction from "./your_protocol/custom_action";
export * from "./custom_action";
export const ACTIONS = { export const ACTIONS = {
// ... existing actions ... // ... existing actions ...
@@ -133,7 +132,7 @@ export const ACTIONS = {
} }
``` ```
### 8. Usage Example ### 9. Usage Example
Add a code example in the `README.md` file. Add a code example in the `README.md` file.

View File

@@ -23,11 +23,13 @@
"author": "sendaifun", "author": "sendaifun",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@3land/listings-sdk": "^0.0.4", "@3land/listings-sdk": "^0.0.6",
"@ai-sdk/openai": "^1.0.11", "@ai-sdk/openai": "^1.0.11",
"@bonfida/spl-name-service": "^3.0.7", "@bonfida/spl-name-service": "^3.0.7",
"@cks-systems/manifest-sdk": "0.1.59", "@cks-systems/manifest-sdk": "0.1.59",
"@coral-xyz/anchor": "0.29", "@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/core": "^0.3.26",
"@langchain/groq": "^0.1.2", "@langchain/groq": "^0.1.2",
"@langchain/langgraph": "^0.2.36", "@langchain/langgraph": "^0.2.36",
@@ -53,6 +55,7 @@
"@sqds/multisig": "^2.1.3", "@sqds/multisig": "^2.1.3",
"@tensor-oss/tensorswap-sdk": "^4.5.0", "@tensor-oss/tensorswap-sdk": "^4.5.0",
"@tiplink/api": "^0.3.1", "@tiplink/api": "^0.3.1",
"@voltr/vault-sdk": "^0.1.1",
"ai": "^4.0.22", "ai": "^4.0.22",
"bn.js": "^5.2.1", "bn.js": "^5.2.1",
"bs58": "^6.0.0", "bs58": "^6.0.0",
@@ -80,5 +83,6 @@
"prettier": "^3.4.2", "prettier": "^3.4.2",
"tsx": "^4.19.2", "tsx": "^4.19.2",
"typescript": "^5.7.2" "typescript": "^5.7.2"
} },
"packageManager": "pnpm@9.15.3"
} }

11700
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
import { MainnetSpotMarkets } from "@drift-labs/sdk";
import type { Action } from "../../types";
import { z } from "zod";
import {
getAvailableDriftPerpMarkets,
getAvailableDriftSpotMarkets,
} from "../../tools";
const availableDriftMarketsAction: Action = {
name: "AVAILABLE_DRIFT_MARKETS",
description: "Get a list of available drift markets",
similes: [
"get drift markets",
"drift markets",
"available drift markets",
"get available drift perp markets",
"get available spot markets on drift",
],
examples: [
[
{
input: {
marketType: "spot",
},
output: {
status: "success",
message: `The list of available spot markets are ${MainnetSpotMarkets.map((v) => v.symbol).join(", ")}`,
data: MainnetSpotMarkets,
},
explanation: "Get the list of available spot markets/tokens on drift",
},
],
],
schema: z.object({
marketType: z
.enum(["spot", "perp"])
.describe("Type of market to get")
.optional(),
}),
handler: async (agent, input) => {
switch (input.marketType) {
case "perp":
return getAvailableDriftPerpMarkets();
case "spot":
return getAvailableDriftSpotMarkets();
default:
return {
spot: getAvailableDriftSpotMarkets(),
perp: getAvailableDriftPerpMarkets(),
};
}
},
};
export default availableDriftMarketsAction;

View File

@@ -0,0 +1,64 @@
import { z } from "zod";
import type { Action } from "../../types";
import { createDriftUserAccount } from "../../tools";
const createDriftUserAccountAction: Action = {
name: "CREATE_DRIFT_USER_ACCOUNT",
similes: [
"create drift account",
"create drift user account",
"create user account on drift",
],
description: "Create a new user account on Drift protocol",
examples: [
[
{
input: {
amount: 100,
symbol: "SOL",
},
output: {
status: "success",
message: "User account created with 100 SOL successfully deposited",
account: "4xKpN2...",
},
explanation: "Create a new user account with 100 SOL",
},
],
],
schema: z.object({
amount: z
.number()
.positive()
.describe(
"Amount of the token to deposit. In normal token amounts e.g 50 SOL, 100 USDC, etc",
),
symbol: z.string().describe("Symbol of the token to deposit"),
}),
handler: async (agent, input) => {
try {
const res = await createDriftUserAccount(
agent,
input.amount,
input.symbol,
);
return {
status: "success",
message:
res.message ??
`User account created with ${input.amount} ${input.symobl} successfully deposited.`,
account: res.account,
signature: res.txSignature,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error message is a string
message: `Failed to create user account: ${e.message}`,
};
}
},
};
export default createDriftUserAccountAction;

View File

@@ -0,0 +1,113 @@
import { z } from "zod";
import type { Action } from "../../types";
import type { SolanaAgentKit } from "../..";
import { createVault } from "../../tools";
const createDriftVaultAction: Action = {
name: "CREATE_DRIFT_VAULT",
similes: ["create a drift vault", "open a drift vault", "create vault"],
description:
"Create a new drift vault delegating the agents address as the owner.",
examples: [
[
{
input: {
name: "My Drift Vault",
marketName: "SOL-SPOT",
redeemPeriod: 30,
maxTokens: 1000,
minDepositAmount: 100,
managementFee: 10,
profitShare: 5,
hurdleRate: 0.1,
permissioned: false,
},
output: {
status: "success",
message: "Drift vault created successfully",
signature:
"2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBDadwunHw8reXFxRWT7khbFsQ9JT3zK4RYDLNDFDRYvM3wJk",
},
explanation: "Create a drift vault",
},
],
],
schema: z.object({
name: z
.string()
.min(5, "Name must be at least 5 characters")
.describe("Has to be unique. 2 Vaults can not have the same name."),
// regex matches SOL-SPOT
marketName: z
.string()
.describe('Market name must be in the format "TOKEN-SPOT"'),
redeemPeriod: z
.number()
.int()
.min(1, "Redeem period must be at least 1")
.describe(
"Number of days to wait before funds deposited in a vault can be redeemed ",
),
maxTokens: z
.number()
.int()
.min(100, "Max tokens must be at least 100")
.describe(
"The maximum amount of tokens the vault will be accomodating. For example some vaults have a cap at 10 million USDC. This amount should be normal token amounts e.g 50 SOL, 100 USDC, etc",
),
minDepositAmount: z
.number()
.positive()
.describe(
"Minimum deposit amount in normal token values e.g 50 SOL, 100 USDC, etc",
),
managementFee: z
.number()
.positive()
.max(20)
.describe(
"How much of a fee you'll be taking to manage depositors funds. This is in percentage e.g 2 for 2%",
),
profitShare: z
.number()
.positive()
.max(90)
.optional()
.default(5)
.describe(
"How much of the profit you'll be sharing with depositors. This is in percentage e.g 2 for 2%. Defaults to 5%",
),
hurdleRate: z.number().optional(),
permissioned: z
.boolean()
.optional()
.describe("Should the vault have a whitelist of not"),
}),
handler: async (agent: SolanaAgentKit, input) => {
try {
const tx = await createVault(
agent,
// @ts-expect-error - zod schema validation
{
...input,
},
);
return {
status: "success",
message:
"Drift vault created successfully. Please note down the name of your vault as it is unique and was used to derive your vault address",
vaultName: input.name,
signature: tx,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - e is not a string
message: `Failed to create drift vault: ${e.message}`,
};
}
},
};
export default createDriftVaultAction;

View File

@@ -0,0 +1,58 @@
import { z } from "zod";
import type { Action } from "../../types";
import { depositIntoVault } from "../../tools";
const depositIntoDriftVaultAction: Action = {
name: "DEPOSIT_INTO_DRIFT_VAULT",
description: "Deposit funds into an existing drift vault",
similes: ["deposit into drift vault", "add funds to drift vault"],
examples: [
[
{
input: {
amount: 100,
vaultAddress: "2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBD",
},
output: {
status: "success",
message: "Funds deposited successfully",
signature:
"2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBDadwunHw8reXFxRWT7khbFsQ9JT3zK4RYDLNDFDRYvM3wJk",
},
explanation: "Deposit 100 USDC into a drift vault",
},
],
],
schema: z.object({
vaultAddress: z.string(),
amount: z
.number()
.positive()
.describe(
"The amount in tokens you'd like to deposit into the vault in normal token amounts e.g 50 SOL, 100 USDC, etc",
),
}),
handler: async (agent, input) => {
try {
const tx = await depositIntoVault(
agent,
input.amount as number,
input.vaultAddress as string,
);
return {
status: "success",
message: "Funds deposited successfully",
signature: tx,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error message
message: `Failed to deposit funds: ${e.message}`,
};
}
},
};
export default depositIntoDriftVaultAction;

View File

@@ -0,0 +1,73 @@
import { z } from "zod";
import type { SolanaAgentKit } from "../../agent";
import type { Action } from "../../types";
import { depositToDriftUserAccount } from "../../tools";
const depositToDriftUserAccountAction: Action = {
name: "DEPOSIT_TO_DRIFT_USER_ACCOUNT",
description: "Deposit funds into your drift user account",
similes: [
"deposit into drift user account",
"add funds to drift user account",
"add funds to my drift account",
"deposit collateral into drift account",
],
examples: [
[
{
input: {
amount: 100,
symbol: "usdc",
},
output: {
status: "success",
message: "Funds deposited successfully",
signature:
"2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBDadwunHw8reXFxRWT7khbFsQ9JT3zK4RYDLNDFDRYvM3wJk",
},
explanation: "Deposit 100 USDC into your drift user account",
},
],
],
schema: z.object({
amount: z
.number()
.positive()
.describe(
"The amount in tokens you'd like to deposit into your drift user account in normal token amounts e.g 50 SOL, 100 USDC, etc",
),
symbol: z
.string()
.toUpperCase()
.describe("The symbol of the token you'd like to deposit"),
repay: z
.boolean()
.optional()
.default(false)
.describe("Whether or not to repay the borrowed funds in the account"),
}),
handler: async (agent: SolanaAgentKit, input) => {
try {
const tx = await depositToDriftUserAccount(
agent,
input.amount as number,
input.symbol as string,
input.repay as boolean,
);
return {
status: "success",
message: "Funds deposited successfully",
signature: tx,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error message
message: `Failed to deposit funds: ${e.message}`,
};
}
},
};
export default depositToDriftUserAccountAction;

View File

@@ -0,0 +1,46 @@
import { z } from "zod";
import type { Action } from "../../types";
import { getVaultAddress } from "../../tools";
const deriveDriftVaultAddressAction: Action = {
name: "DERIVE_DRIFT_VAULT_ADDRESS_ACTION",
similes: ["derive drift vault address", "get drift vault address"],
description: "Derive a drift vault address from the vaults name",
examples: [
[
{
input: {
name: "My Drift Vault",
},
output: {
status: "success",
message: "Vault address derived successfully",
address: "2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBD",
},
explanation: "Derive a drift vault address",
},
],
],
schema: z.object({
name: z.string().describe("The name of the vault to derive the address of"),
}),
handler: async (agent, input) => {
try {
const address = await getVaultAddress(agent, input.name as string);
return {
status: "success",
message: "Vault address derived successfully",
address,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error message
message: `Failed to derive vault address: ${e.message}`,
};
}
},
};
export default deriveDriftVaultAddressAction;

View File

@@ -0,0 +1,53 @@
import { z } from "zod";
import { doesUserHaveDriftAccount } from "../../tools";
import type { Action } from "../../types";
export const doesUserHaveDriftAccountAction: Action = {
name: "DOES_USER_HAVE_DRIFT_ACCOUNT",
description: "Check if a user has a Drift account",
similes: [
"check if user has drift account",
"check if user has account on drift",
"do I have an account on drift",
],
examples: [
[
{
input: {},
output: {
status: "success",
message: "Nice! You have a Drift account",
account: "4xKpN2...",
},
explanation: "Check if a user has a Drift account",
},
],
],
schema: z.object({}),
handler: async (agent) => {
try {
const res = await doesUserHaveDriftAccount(agent);
if (!res.hasAccount) {
return {
status: "error",
message: "You do not have a Drift account",
};
}
return {
status: "success",
message: "Nice! You have a Drift account",
account: res.account,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error message is a string
message: `Failed to check if you have a Drift account: ${e.message}`,
};
}
},
};
export default doesUserHaveDriftAccountAction;

View File

@@ -0,0 +1,39 @@
import { z } from "zod";
import type { Action } from "../../types";
import { driftUserAccountInfo } from "../../tools";
const driftUserAccountInfoAction: Action = {
name: "DRIFT_USER_ACCOUNT_INFO",
similes: ["get drift user account info", "get drift account info"],
description: "Get information about your drift account",
examples: [
[
{
input: {},
explanation: "Get information about your drift account",
output: {
status: "success",
data: {},
},
},
],
],
schema: z.object({}),
handler: async (agent) => {
try {
const accountInfo = await driftUserAccountInfo(agent);
return {
status: "success",
data: accountInfo,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error message is a string
message: `Failed to get drift account info: ${e.message}`,
};
}
},
};
export default driftUserAccountInfoAction;

View File

@@ -0,0 +1,65 @@
import { z } from "zod";
import type { Action } from "../../types";
import { getEntryQuoteOfPerpTrade } from "../../tools";
const entryQuoteOfPerpTradeAction: Action = {
name: "DRIFT_GET_ENTRY_QUOTE_OF_PERP_TRADE_ACTION",
description: "Get the entry quote of a perpetual trade on Drift",
similes: [
"get the entry quote of a perpetual trade on drift",
"get the entry quote of a perp trade on drift",
"get the entry quote of the BTC-PERP trade on drift",
"get the entry quote of the SOL-PERP trade on drift",
"get the entry quote of a 1000 USDC long on the SOL-PERP market",
"get the entry quote of a 1000 USDC short on the SOL-PERP market",
"quote for a $1000 long on the BTC-PERP market",
],
examples: [
[
{
input: {
marketSymbol: "BTC-PERP",
type: "long",
amount: 1000,
},
output: {
status: "success",
data: {
entryPrice: 100000,
priceImpact: 0.0001,
bestPrice: 100001,
worstPrice: 99999,
baseFilled: 1000,
quoteFilled: 1000,
},
},
explanation:
"Get the entry quote of a $1000 long on the BTC-PERP market",
},
],
],
schema: z.object({
marketSymbol: z.string().describe("Symbol of the perpetual market"),
type: z.enum(["long", "short"]).describe("Type of trade"),
amount: z.number().positive().describe("Amount to trade"),
}),
handler: async (agent, input) => {
try {
const data = await getEntryQuoteOfPerpTrade(
input.marketSymbol,
input.amount,
input.type,
);
return data;
} catch (e) {
return {
status: "error",
// @ts-expect-error error is not a string
message: e.message,
};
}
},
};
export default entryQuoteOfPerpTradeAction;

View File

@@ -0,0 +1,52 @@
import { z } from "zod";
import type { Action } from "../../types";
import { getLendingAndBorrowAPY } from "../../tools";
const lendAndBorrowAPYAction: Action = {
name: "DRIFT_GET_LEND_AND_BORROW_APY_ACTION",
description: "Get the lending and borrowing APY (in %) of a token on Drift",
similes: [
"get the lending and borrowing APY of a token on drift",
"get the lending and borrowing APY of a token on drift",
"get the lending and borrowing APY of the USDC token on drift",
"get the lending and borrowing APY of the SOL token on drift",
],
examples: [
[
{
input: {
symbol: "USDC",
},
output: {
status: "success",
data: {
lendingAPY: 10,
borrowingAPY: 12.1,
},
},
explanation: "Get the lending and borrowing APY of the USDC token",
},
],
],
schema: z.object({
symbol: z.string().describe("Symbol of the token"),
}),
handler: async (agent, input) => {
try {
const data = await getLendingAndBorrowAPY(agent, input.symbol);
return {
status: "success",
data,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error error is not a string
message: e.message,
};
}
},
};
export default lendAndBorrowAPYAction;

View File

@@ -0,0 +1,61 @@
import { z } from "zod";
import type { Action } from "../../types";
import { calculatePerpMarketFundingRate } from "../../tools";
const perpMarktetFundingRateAction: Action = {
name: "DRIFT_PERP_MARKET_FUNDING_RATE_ACTION",
description: "Get the funding rate of a perpetual market on Drift",
similes: [
"get the yearly funding rate of a perpetual market on drift",
"get the funding rate of a perp market on drift",
"get the hourly funding rate of a perpetual market on drift",
"get the funding rate of the BTC-PERP market on drift",
"get the funding rate of the SOL-PERP market on drift",
],
examples: [
[
{
input: {
marketSymbol: "BTC-PERP",
},
output: {
status: "success",
data: {
longRate: 0.0001,
shortRate: 0.0002,
},
},
explanation: "Get the funding rate of the BTC-PERP market",
},
],
],
schema: z.object({
marketSymbol: z
.string()
.toUpperCase()
.describe("Symbol of the perpetual market"),
period: z.enum(["year", "hour"]).default("hour").optional(),
}),
handler: async (agent, input) => {
try {
const data = await calculatePerpMarketFundingRate(
agent,
input.marketSymbol,
input.period,
);
return {
status: "success",
data,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error error is not a string
message: e.message,
};
}
},
};
export default perpMarktetFundingRateAction;

View File

@@ -0,0 +1,61 @@
import { z } from "zod";
import type { Action } from "../../types";
import { requestUnstakeFromDriftInsuranceFund } from "../../tools";
const requestUnstakeFromDriftInsuranceFundAction: Action = {
name: "REQUEST_UNSTAKE_FROM_DRIFT_INSURANCE_FUND_ACTION",
description:
"Request to unstake a certain amount of a token from the Drift Insurance Fund",
similes: [
"request an unstake from the drift insurance fund",
"request to unstake an amount from the drift insurance fund",
],
examples: [
[
{
input: {
amount: 100,
symbol: "SOL",
},
output: {
status: "success",
message: "Requested to unstake 100 SOL from the Drift Insurance Fund",
signature: "4FdasklhiIHyOI",
},
explanation: "Request to unstake 100 SOL from the Drift Insurance Fund",
},
],
],
schema: z.object({
amount: z
.number()
.positive()
.describe("Amount to unstake in normal units e.g 50 === 50 SOL"),
symbol: z.string().describe("Symbol of the token to unstake"),
}),
handler: async (agent, input) => {
try {
const tx = await requestUnstakeFromDriftInsuranceFund(
agent,
input.amount,
input.symbol,
);
return {
status: "success",
message: `Requested to unstake ${input.amount} ${input.symbol} from the Drift Insurance Fund`,
data: {
signature: tx,
},
};
} catch (e) {
return {
status: "error",
// @ts-expect-error error is not a string
message: e.message,
};
}
},
};
export default requestUnstakeFromDriftInsuranceFundAction;

View File

@@ -0,0 +1,59 @@
import { z } from "zod";
import type { Action } from "../../types";
import type { SolanaAgentKit } from "../../agent";
import { requestWithdrawalFromVault } from "../../tools";
const requestWithdrawalFromVaultAction: Action = {
name: "REQUEST_WITHDRAWAL_FROM_DRIFT_VAULT",
description: "Request a withdrawal from an existing drift vault",
similes: ["withdraw from drift vault", "request withdrawal from vault"],
examples: [
[
{
input: {
amount: 100,
vaultAddress: "2nFeP7taii",
},
output: {
status: "success",
message: "Withdrawal request successful",
signature:
"2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBDadwunHw8reXFxRWT7khbFsQ9JT3zK4RYDLNDFDRYvM3wJk",
},
explanation: "Request a withdrawal of 100 USDC from a drift vault",
},
],
],
schema: z.object({
vaultAddress: z.string(),
amount: z
.number()
.positive()
.describe(
"Amount of shares you would like to withdraw from the vault in normal token amounts e.g 50 SOL, 100 USDC, etc",
),
}),
handler: async (agent: SolanaAgentKit, input) => {
try {
const tx = await requestWithdrawalFromVault(
agent,
input.amount as number,
input.vaultAddress as string,
);
return {
status: "success",
message: "Withdrawal request successful",
signature: tx,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error message
message: `Failed to request withdrawal: ${e.message}`,
};
}
},
};
export default requestWithdrawalFromVaultAction;

View File

@@ -0,0 +1,59 @@
import { z } from "zod";
import type { Action } from "../../types";
import { stakeToDriftInsuranceFund } from "../../tools";
const stakeToDriftInsuranceFundAction: Action = {
name: "STAKE_TO_DRIFT_INSURANCE_FUND_ACTION",
description: "Stake a token to Drift Insurance Fund",
similes: ["Stake a token to Drift Insurance Fund"],
examples: [
[
{
input: {
amount: 100,
symbol: "SOL",
},
output: {
status: "success",
message: "Staked 100 SOL to the Drift Insurance Fund",
data: {
signature: "signature",
},
},
explanation: "Stake 100 SOL to the Drift Insurance Fund",
},
],
],
schema: z.object({
amount: z
.number()
.positive()
.describe("Amount to stake in normal units e.g 50 === 50 SOL"),
symbol: z.string().describe("Symbol of the token stake"),
}),
handler: async (agent, input) => {
try {
const tx = await stakeToDriftInsuranceFund(
agent,
input.amount,
input.symbol,
);
return {
status: "sucess",
message: `Staked ${input.amount} ${input.symbol} to the Drift Insurance Fund`,
data: {
signature: tx,
},
};
} catch (error) {
return {
status: "error",
// @ts-expect-error error is not a string
message: error.message,
};
}
},
};
export default stakeToDriftInsuranceFundAction;

View File

@@ -0,0 +1,78 @@
import { z } from "zod";
import type { Action } from "../../types";
import { swapSpotToken } from "../../tools";
const driftSpotTokenSwapAction: Action = {
name: "DRIFT_SPOT_TOKEN_SWAP_ACTION",
description: "Swap a token for another token on Drift",
similes: [
"swap a token for another token on drift",
"exchange a token for another token on drift",
"trade a token for another token on drift",
"swap usdc to 5 sol on drift (in this case 5 sol is the toAmount)",
"swap 5 usdt to DRIFT on drift (in this case 5 usdt is the fromAmount)",
],
examples: [
[
{
input: {
fromSymbol: "SOL",
toSymbol: "USDC",
fromAmount: 100,
},
output: {
status: "success",
message: "Swapped 100 SOL for USDC on Drift",
signature: "4FdasklhiIHyOI",
},
explanation: "Swap 100 SOL for USDC on Drift",
},
],
],
schema: z.object({
fromSymbol: z.string().describe("Symbol of the token to swap from"),
toSymbol: z.string().describe("Symbol of the token to swap to"),
fromAmount: z
.number()
.positive()
.describe("Amount to swap from e.g 50 === 50 SOL")
.optional(),
toAmount: z
.number()
.positive()
.describe("Amount to swap to e.g 5000 === 5000 USDC")
.optional(),
slippage: z
.number()
.positive()
.describe("Slippage tolerance in percentage e.g 0.5 === 0.5%")
.default(0.5),
}),
handler: async (agent, input) => {
try {
const tx = await swapSpotToken(agent, {
fromSymbol: input.fromSymbol,
toSymbol: input.toSymbol,
fromAmount: input.fromAmount,
toAmount: input.toAmount,
slippage: input.slippage,
});
return {
status: "success",
message: `Swapped ${input.fromAmount} ${input.fromSymbol} for ${input.toAmount} ${input.toSymbol} on Drift`,
data: {
signature: tx,
},
};
} catch (e) {
return {
status: "error",
// @ts-expect-error error is not a string
message: e.message,
};
}
},
};
export default driftSpotTokenSwapAction;

View File

@@ -0,0 +1,123 @@
import { z } from "zod";
import type { Action } from "../../types";
import type { SolanaAgentKit } from "../../agent";
import { tradeDriftVault } from "../../tools";
const tradeDelegatedDriftVaultAction: Action = {
name: "TRADE_DELEGATED_DRIFT_VAULT",
similes: [
"trade delegated drift vault",
"trade delegated vault",
"trade vault",
"trade drift vault",
"trade delegated vault",
"trade vault",
"trade drift vault",
"open drift vault trade",
],
description: "Carry out trades in a Drift vault.",
examples: [
[
{
input: {
vaultAddress: "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w",
amount: 100,
symbol: "SOL",
action: "buy",
type: "market",
},
output: {
status: "success",
message: "Trade successful",
transactionId: "7nE9GvcwsqzYxmJLSrYmSB1V1YoJWVK1KWzAcWAzjXkN",
amount: 100,
symbol: "SOL",
action: "buy",
type: "market",
},
explanation: "Buy 100 SOL in the vault",
},
],
[
{
input: {
vaultAddress: "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w",
amount: 50,
symbol: "SOL",
action: "sell",
type: "limit",
price: 200,
},
output: {
status: "success",
message: "Order placed successful",
transactionId: "8nE9GvcwsqzYxmJLSrYmSB1V1YoJWVK1KWzAcWAzjXkM",
amount: 50,
symbol: "SOL",
action: "sell",
type: "limit",
price: 200,
},
explanation: "Sell 50 SOL in the vault at $200",
},
],
],
schema: z.object({
vaultAddress: z.string().describe("Address of the Drift vault to trade in"),
amount: z
.number()
.positive()
.describe(
"Amount to trade in normal token amounts e.g 50 SOL, 100 USDC, etc",
),
symbol: z.string().describe("Symbol of the token to trade"),
action: z.enum(["long", "short"]).describe("Trade action - long or short"),
type: z.enum(["market", "limit"]).describe("Trade type - market or limit"),
price: z
.number()
.positive()
.optional()
.describe("USD price for limit order"),
}),
handler: async (agent: SolanaAgentKit, input) => {
try {
const params = {
vaultAddress: input.vaultAddress as string,
amount: input.amount as number,
symbol: input.symbol as string,
action: input.action as "long" | "short",
type: input.type as "market" | "limit",
price: input.price as number | undefined,
};
// Carry out the trade
const transactionId = await tradeDriftVault(
agent,
params.vaultAddress,
params.amount,
params.symbol,
params.action,
params.type,
params.price,
);
return {
status: "success",
message:
params.type === "limit"
? "Order placed successfully"
: "Trade successful",
transactionId,
...params,
};
} catch (error) {
return {
status: "error",
// @ts-expect-error error is not a string
message: error.message,
};
}
},
};
export default tradeDelegatedDriftVaultAction;

View File

@@ -0,0 +1,95 @@
import { z } from "zod";
import type { Action } from "../../types";
import { driftPerpTrade } from "../../tools";
export const tradeDriftPerpAccountAction: Action = {
name: "TRADE_DRIFT_PERP_ACCOUNT",
similes: [
"trade drift perp account",
"trade drift perp",
"trade drift perpetual account",
"trade perp account",
"trade account",
],
description: "Trade a perpetual account on Drift protocol",
examples: [
[
{
input: {
amount: 100,
symbol: "SOL",
action: "long",
type: "market",
},
output: {
status: "success",
message: "Trade successful",
},
explanation: "Open a $100 long position on SOL.",
},
],
[
{
input: {
amount: 50,
symbol: "BTC",
action: "short",
type: "limit",
price: 50000,
},
output: {
status: "success",
message: "Trade successful",
},
explanation: "$50 short position on BTC at $50,000.",
},
],
],
schema: z.object({
amount: z
.number()
.positive()
.describe(
"The amount of the token to trade in normal token amounts e.g 50 SOL, 100 USDC",
),
symbol: z
.string()
.toUpperCase()
.describe("Symbol of the token to open a position on "),
action: z
.enum(["long", "short"])
.describe(
"The action you would like to carry out whether it be a long or a short",
),
type: z
.enum(["market", "limit"])
.describe(
"The type of trade you would like to open, market or limit order",
),
price: z.number().positive().optional().describe("USD price of the token"),
}),
handler: async (agent, input) => {
try {
const signature = await driftPerpTrade(agent, {
action: input.action,
amount: input.amount,
symbol: input.symbol,
type: input.type,
price: input.price,
});
return {
status: "success",
signature: signature,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error message is a string
message: `Failed to trade perp account: ${e.message}`,
};
}
},
};
export default tradeDriftPerpAccountAction;

View File

@@ -0,0 +1,51 @@
import { z } from "zod";
import type { Action } from "../../types";
import { unstakeFromDriftInsuranceFund } from "../../tools";
const unstakeFromDriftInsuranceFundAction: Action = {
name: "UNSTAKE_FROM_DRIFT_INSURANCE_FUND_ACTION",
description:
"Unstake requested unstake token from the Drift Insurance fund once the cool period has elapsed",
similes: [
"unstake from the drift insurance fund",
"withdraw from the drift insurance fund",
"take out funds from the drift insurance fund",
],
examples: [
[
{
input: {
symbol: "SOL",
},
output: {
status: "success",
message: "Unstaked your SOL from the Drift Insurance Fund",
signature: "4FdasklhiIHyOI",
},
explanation: "Unstake SOL from the Drift Insurance Fund",
},
],
],
schema: z.object({
symbol: z.string().describe("Symbol of the token to unstake"),
}),
handler: async (agent, input) => {
try {
const tx = await unstakeFromDriftInsuranceFund(agent, input.symbol);
return {
status: "success",
message: `Unstaked your ${input.symbol} from the Drift Insurance Fund`,
signature: tx,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error error is not a string
message: e.message,
};
}
},
};
export default unstakeFromDriftInsuranceFundAction;

View File

@@ -0,0 +1,53 @@
import { z } from "zod";
import type { Action } from "../../types";
import { updateVaultDelegate } from "../../tools";
const updateDriftVaultDelegateAction: Action = {
name: "UPDATE_DRIFT_VAULT_DELEGATE_ACTION",
similes: ["update drift vault delegate", "change drift vault delegate"],
description: "Update the delegate of a drift vault",
examples: [
[
{
input: {
vaultAddress: "2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBD",
newDelegate: "2nFeP7tai",
},
output: {
status: "success",
message: "Vault delegate updated successfully",
signature:
"2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBDadwunHw8reXFxRWT7khbFsQ9JT3zK4RYDLNDFDRYvM3wJk",
},
explanation: "Update the delegate of a drift vault to another address",
},
],
],
schema: z.object({
vaultAddress: z.string().describe("vault's address"),
newDelegate: z.string().describe("new address to delegate the vault to"),
}),
handler: async (agent, input) => {
try {
const tx = await updateVaultDelegate(
agent,
input.vaultAddress as string,
input.newDelegate as string,
);
return {
status: "success",
message: "Vault delegate updated successfully",
signature: tx,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error message
message: `Failed to update vault delegate: ${e.message}`,
};
}
},
};
export default updateDriftVaultDelegateAction;

View File

@@ -0,0 +1,106 @@
import { z } from "zod";
import type { Action } from "../../types";
import type { SolanaAgentKit } from "../../agent";
import { updateVault } from "../../tools";
const updateDriftVaultAction: Action = {
name: "UPDATE_DRIFT_VAULT",
similes: ["update a drift vault", "modify a drift vault", "update vault"],
description: "Update an existing drift vault with new settings.",
examples: [
[
{
input: {
redeemPeriod: 30,
maxTokens: 10000,
minDepositAmount: 10,
managementFee: 5,
profitShare: 10,
handleRate: 0.1,
permissioned: false,
vaultAddress: "2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBD",
},
output: {
status: "success",
message: "Drift vault updated successfully",
signature:
"2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBDadwunHw8reXFxRWT7khbFsQ9JT3zK4RYDLNDFDRYvM3wJk",
},
explanation: "Update a drift vault",
},
],
],
schema: z.object({
vaultAddress: z.string(),
name: z.string().min(5, "Name must be at least 5 characters").optional(),
// regex matches SOL-SPOT
marketName: z
.string()
.regex(/^([A-Za-z0-9]{2,7})-SPOT$/)
.optional(),
redeemPeriod: z
.number()
.int()
.min(1, "Redeem period must be at least 1 day")
.optional(),
maxTokens: z
.number()
.int()
.min(100, "Max tokens must be at least be 100 units")
.optional()
.describe(
"The maximum number of tokens the vault is willing to accept and manage",
),
minDepositAmount: z
.number()
.positive()
.optional()
.describe(
"The minimum amount that is allowed to be deposited into the vault in normal token amounts e.g 10 USDC",
),
managementFee: z
.number()
.positive()
.max(20)
.optional()
.describe("The percentage fee the vault takes for asset management"),
profitShare: z
.number()
.positive()
.max(90)
.optional()
.describe("Profit share in percentage e.g 2 === 2%"),
handleRate: z.number().optional(),
permissioned: z
.boolean()
.optional()
.describe("Should the vault have a whitelist of not"),
}),
handler: async (agent: SolanaAgentKit, input) => {
try {
const tx = await updateVault(agent, input.vaultAddress, {
hurdleRate: input.hurdleRate,
maxTokens: input.maxTokens,
minDepositAmount: input.minDepositAmount,
profitShare: input.profitShare,
managementFee: input.managementFee,
permissioned: input.permissioned,
redeemPeriod: input.redeemPeriod,
});
return {
status: "success",
message: "Drift vault parameters updated successfully",
signature: tx,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error message
message: `Failed to update drift vault: ${e.message}`,
};
}
},
};
export default updateDriftVaultAction;

View File

@@ -0,0 +1,57 @@
import { z } from "zod";
import type { Action } from "../../types";
import { getVaultInfo } from "../../tools";
import type { SolanaAgentKit } from "../../agent";
const vaultInfoAction: Action = {
name: "DRIFT_VAULT_INFO",
similes: ["get drift vault info", "vault info", "vault information"],
description: "Get information about a drift vault",
examples: [
[
{
input: {
vaultNameOrAddress: "test-vault",
},
output: {
status: "success",
message: "Vault info retrieved successfully",
data: {
name: "My Drift Vault",
marketName: "SOL-SPOT",
redeemPeriod: 30,
maxTokens: 1000,
minDepositAmount: 100,
managementFee: 10,
profitShare: 5,
hurdleRate: 0.1,
permissioned: false,
},
},
explanation: "Get information about a drift vault",
},
],
],
schema: z.object({
vaultNameOrAddress: z.string().describe("Name or address of the vault"),
}),
handler: async (agent: SolanaAgentKit, input) => {
try {
const vaultInfo = await getVaultInfo(agent, input.vaultNameOrAddress);
return {
status: "success",
message: "Vault info retrieved successfully",
data: vaultInfo,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error message
message: `Failed to retrieve vault info: ${e.message}`,
};
}
},
};
export default vaultInfoAction;

View File

@@ -0,0 +1,77 @@
import { z } from "zod";
import type { Action } from "../../types";
import { withdrawFromDriftUserAccount } from "../../tools";
const withdrawFromDriftAccountAction: Action = {
name: "WITHDRAW_OR_BORROW_FROM_DRIFT_ACCOUNT",
description: "Withdraw funds from your drift account",
similes: [
"withdraw from drift account",
"withdraw funds from drift account",
"withdraw funds from my drift account",
"borrow from drift account",
"borrow funds from my drift account",
"borrow from drift",
"withdraw from drift",
],
examples: [
[
{
input: {
amount: 100,
symbol: "usdc",
},
output: {
status: "success",
message: "Funds withdrawn successfully",
signature:
"2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBDadwunHw8reXFxRWT7khbFsQ9JT3zK4RYDLNDFDRYvM3wJk",
},
explanation: "Withdraw 100 USDC from your drift account",
},
],
],
schema: z.object({
amount: z
.number()
.positive()
.describe(
"The amount in tokens you'd like to withdraw from your drift account in normal token amounts, e.g 50 SOL, 100 USDC, etc",
),
symbol: z
.string()
.toUpperCase()
.describe("The symbol of the token you'd like to withdraw"),
isBorrow: z
.boolean()
.optional()
.default(false)
.describe(
"Whether or not to borrow funds based on collateral provided instead of withdrawing",
),
}),
handler: async (agent, input) => {
try {
const tx = await withdrawFromDriftUserAccount(
agent,
input.amount,
input.symbol,
input.isBorrow,
);
return {
status: "success",
message: "Funds withdrawn successfully",
signature: tx,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error message is a string
message: `Failed to withdraw funds: ${e.message}`,
};
}
},
};
export default withdrawFromDriftAccountAction;

View File

@@ -0,0 +1,52 @@
import { z } from "zod";
import type { Action } from "../../types";
import type { SolanaAgentKit } from "../../agent";
import { withdrawFromDriftVault } from "../../tools";
const withdrawFromVaultAction: Action = {
name: "WITHDRAW_FROM_DRIFT_VAULT",
description:
"Withdraw funds from a vault given the redemption time has elapsed.",
similes: ["withdraw from drift vault", "redeem funds from vault"],
examples: [
[
{
input: {
vaultAddress: "2nFeP7taii",
},
output: {
status: "success",
message: "Withdrawal successful",
signature:
"2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBDadwunHw8reXFxRWT7khbFsQ9JT3zK4RYDLNDFDRYvM3wJk",
},
explanation: "Withdraw funds from a drift vault",
},
],
],
schema: z.object({
vaultAddress: z.string().describe("Vault's address"),
}),
handler: async (agent: SolanaAgentKit, input) => {
try {
const tx = await withdrawFromDriftVault(
agent,
input.vaultAddress as string,
);
return {
status: "success",
message: "Withdrawal successful",
signature: tx,
};
} catch (e) {
return {
status: "error",
// @ts-expect-error - error message
message: `Failed to withdraw funds: ${e.message}`,
};
}
},
};
export default withdrawFromVaultAction;

View File

@@ -1,3 +1,4 @@
import tokenBalancesAction from "./tokenBalances";
import deployTokenAction from "./metaplex/deployToken"; import deployTokenAction from "./metaplex/deployToken";
import balanceAction from "./solana/balance"; import balanceAction from "./solana/balance";
import transferAction from "./solana/transfer"; import transferAction from "./solana/transfer";
@@ -13,6 +14,8 @@ import stakeWithJupAction from "./jupiter/stakeWithJup";
import stakeWithSolayerAction from "./solayer/stakeWithSolayer"; import stakeWithSolayerAction from "./solayer/stakeWithSolayer";
import registerDomainAction from "./sns/registerDomain"; import registerDomainAction from "./sns/registerDomain";
import lendAssetAction from "./lulo/lendAsset"; import lendAssetAction from "./lulo/lendAsset";
import luloLendAction from "./lulo/luloLend";
import luloWithdrawAction from "./lulo/luloWithdraw";
import createGibworkTaskAction from "./gibwork/createGibworkTask"; import createGibworkTaskAction from "./gibwork/createGibworkTask";
import resolveSolDomainAction from "./sns/resolveSolDomain"; import resolveSolDomainAction from "./sns/resolveSolDomain";
import pythFetchPriceAction from "./pyth/pythFetchPrice"; import pythFetchPriceAction from "./pyth/pythFetchPrice";
@@ -43,9 +46,36 @@ import getAssetsByOwnerAction from "./helius/getAssetsbyOwner";
import getWebhookAction from "./helius/getWebhook"; import getWebhookAction from "./helius/getWebhook";
import parseSolanaTransactionAction from "./helius/parseTransaction"; import parseSolanaTransactionAction from "./helius/parseTransaction";
import sendTransactionWithPriorityFeeAction from "./helius/sendTransactionWithPriority"; import sendTransactionWithPriorityFeeAction from "./helius/sendTransactionWithPriority";
import createDriftVaultAction from "./drift/createVault";
import updateDriftVaultAction from "./drift/updateVault";
import depositIntoDriftVaultAction from "./drift/depositIntoVault";
import requestWithdrawalFromVaultAction from "./drift/requestWithdrawalFromVault";
import withdrawFromVaultAction from "./drift/withdrawFromVault";
import tradeDelegatedDriftVaultAction from "./drift/tradeDelegatedDriftVault";
import vaultInfoAction from "./drift/vaultInfo";
import createDriftUserAccountAction from "./drift/createDriftUserAccount";
import tradeDriftPerpAccountAction from "./drift/tradePerpAccount";
import doesUserHaveDriftAccountAction from "./drift/doesUserHaveDriftAccount";
import depositToDriftUserAccountAction from "./drift/depositToDriftUserAccount";
import withdrawFromDriftAccountAction from "./drift/withdrawFromDriftAccount";
import driftUserAccountInfoAction from "./drift/driftUserAccountInfo";
import deriveDriftVaultAddressAction from "./drift/deriveVaultAddress";
import updateDriftVaultDelegateAction from "./drift/updateDriftVaultDelegate";
import availableDriftMarketsAction from "./drift/availableMarkets";
import stakeToDriftInsuranceFundAction from "./drift/stakeToDriftInsuranceFund";
import requestUnstakeFromDriftInsuranceFundAction from "./drift/requestUnstakeFromDriftInsuranceFund";
import unstakeFromDriftInsuranceFundAction from "./drift/unstakeFromDriftInsuranceFund";
import driftSpotTokenSwapAction from "./drift/swapSpotToken";
import perpMarktetFundingRateAction from "./drift/perpMarketFundingRate";
import entryQuoteOfPerpTradeAction from "./drift/entryQuoteOfPerpTrade";
import lendAndBorrowAPYAction from "./drift/getLendAndBorrowAPY";
import getVoltrPositionValuesAction from "./voltr/getPositionValues";
import depositVoltrStrategyAction from "./voltr/depositStrategy";
import withdrawVoltrStrategyAction from "./voltr/withdrawStrategy";
export const ACTIONS = { export const ACTIONS = {
WALLET_ADDRESS_ACTION: getWalletAddressAction, WALLET_ADDRESS_ACTION: getWalletAddressAction,
TOKEN_BALANCES_ACTION: tokenBalancesAction,
DEPLOY_TOKEN_ACTION: deployTokenAction, DEPLOY_TOKEN_ACTION: deployTokenAction,
BALANCE_ACTION: balanceAction, BALANCE_ACTION: balanceAction,
TRANSFER_ACTION: transferAction, TRANSFER_ACTION: transferAction,
@@ -61,6 +91,8 @@ export const ACTIONS = {
STAKE_WITH_SOLAYER_ACTION: stakeWithSolayerAction, STAKE_WITH_SOLAYER_ACTION: stakeWithSolayerAction,
REGISTER_DOMAIN_ACTION: registerDomainAction, REGISTER_DOMAIN_ACTION: registerDomainAction,
LEND_ASSET_ACTION: lendAssetAction, LEND_ASSET_ACTION: lendAssetAction,
LULO_LEND_ACTION: luloLendAction,
LULO_WITHDRAW_ACTION: luloWithdrawAction,
CREATE_GIBWORK_TASK_ACTION: createGibworkTaskAction, CREATE_GIBWORK_TASK_ACTION: createGibworkTaskAction,
RESOLVE_SOL_DOMAIN_ACTION: resolveSolDomainAction, RESOLVE_SOL_DOMAIN_ACTION: resolveSolDomainAction,
PYTH_FETCH_PRICE_ACTION: pythFetchPriceAction, PYTH_FETCH_PRICE_ACTION: pythFetchPriceAction,
@@ -91,6 +123,33 @@ export const ACTIONS = {
GET_WEBHOOK_ACTION: getWebhookAction, GET_WEBHOOK_ACTION: getWebhookAction,
PARSE_TRANSACTION_ACTION: parseSolanaTransactionAction, PARSE_TRANSACTION_ACTION: parseSolanaTransactionAction,
SEND_TRANSACTION_WITH_PRIORITY_ACTION: sendTransactionWithPriorityFeeAction, SEND_TRANSACTION_WITH_PRIORITY_ACTION: sendTransactionWithPriorityFeeAction,
CREATE_DRIFT_VAULT_ACTION: createDriftVaultAction,
UPDATE_DRIFT_VAULT_ACTION: updateDriftVaultAction,
DEPOSIT_INTO_DRIFT_VAULT_ACTION: depositIntoDriftVaultAction,
REQUEST_WITHDRAWAL_FROM_DRIFT_VAULT_ACTION: requestWithdrawalFromVaultAction,
WITHDRAW_FROM_DRIFT_VAULT_ACTION: withdrawFromVaultAction,
TRADE_DELEGATED_DRIFT_VAULT_ACTION: tradeDelegatedDriftVaultAction,
DRIFT_VAULT_INFO_ACTION: vaultInfoAction,
CREATE_DRIFT_USER_ACCOUNT_ACTION: createDriftUserAccountAction,
TRADE_DRIFT_PERP_ACCOUNT_ACTION: tradeDriftPerpAccountAction,
DOES_USER_HAVE_DRIFT_ACCOUNT_ACTION: doesUserHaveDriftAccountAction,
DEPOSIT_TO_DRIFT_USER_ACCOUNT_ACTION: depositToDriftUserAccountAction,
WITHDRAW_OR_BORROW_FROM_DRIFT_ACCOUNT_ACTION: withdrawFromDriftAccountAction,
DRIFT_USER_ACCOUNT_INFO_ACTION: driftUserAccountInfoAction,
DERIVE_DRIFT_VAULT_ADDRESS_ACTION: deriveDriftVaultAddressAction,
UPDATE_DRIFT_VAULT_DELEGATE_ACTION: updateDriftVaultDelegateAction,
AVAILABLE_DRIFT_MARKETS_ACTION: availableDriftMarketsAction,
STAKE_TO_DRIFT_INSURANCE_FUND_ACTION: stakeToDriftInsuranceFundAction,
REQUEST_UNSTAKE_FROM_DRIFT_INSURANCE_FUND_ACTION:
requestUnstakeFromDriftInsuranceFundAction,
UNSTAKE_FROM_DRIFT_INSURANCE_FUND_ACTION: unstakeFromDriftInsuranceFundAction,
DRIFT_SPOT_TOKEN_SWAP_ACTION: driftSpotTokenSwapAction,
DRIFT_PERP_MARKET_FUNDING_RATE_ACTION: perpMarktetFundingRateAction,
DRIFT_GET_ENTRY_QUOTE_OF_PERP_TRADE_ACTION: entryQuoteOfPerpTradeAction,
DRIFT_GET_LEND_AND_BORROW_APY_ACTION: lendAndBorrowAPYAction,
GET_VOLTR_POSITION_VALUES_ACTION: getVoltrPositionValuesAction,
DEPOSIT_VOLTR_STRATEGY_ACTION: depositVoltrStrategyAction,
WITHDRAW_VOLTR_STRATEGY_ACTION: withdrawVoltrStrategyAction,
}; };
export type { Action, ActionExample, Handler } from "../types/action"; export type { Action, ActionExample, Handler } from "../types/action";

View File

@@ -0,0 +1,62 @@
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { luloLend } from "../../tools/lulo";
const luloLendAction: Action = {
name: "LULO_LEND",
similes: [
"lend USDC with lulo",
"lend PYUSD with lulo",
"lend USDS with lulo",
"lend USDT with lulo",
"lend SQL with lulo",
"lend jitoSQL with lulo",
"lend bSQL with lulo",
"lend mSQL with lulo",
"lend BONK with lulo",
"lend JUP with lulo",
],
description: "Lend SPL tokens using Lulo protocol",
examples: [
[
{
input: {
mintAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
amount: 100,
},
output: {
status: "success",
signature: "4xKpN2...",
message: "Successfully lend 100 USDC",
},
explanation: "Lend 100 USDC on Lulo",
},
],
],
schema: z.object({
mintAddress: z.string().describe("SPL Mint address"),
amount: z.number().positive().describe("Amount to lend"),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
try {
const mintAddress = input.mintAddress as string;
const amount = input.amount as number;
const response = await luloLend(agent, mintAddress, amount);
return {
status: "success",
signature: response,
message: `Successfully lend ${amount} of token ${mintAddress}`,
};
} catch (error: any) {
return {
status: "error",
message: `Lend failed: ${error.message}`,
};
}
},
};
export default luloLendAction;

View File

@@ -0,0 +1,62 @@
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { luloWithdraw } from "../../tools/lulo";
const luloWithdrawAction: Action = {
name: "LULO_WITHDRAW",
similes: [
"withdraw USDC with lulo",
"withdraw PYUSD with lulo",
"withdraw USDS with lulo",
"withdraw USDT with lulo",
"withdraw SQL with lulo",
"withdraw jitoSQL with lulo",
"withdraw bSQL with lulo",
"withdraw mSQL with lulo",
"withdraw BONK with lulo",
"withdraw JUP with lulo",
],
description: "Withdraw SPL tokens using Lulo protocol",
examples: [
[
{
input: {
mintAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
amount: 100,
},
output: {
status: "success",
signature: "4xKpN2...",
message: "Successfully withdraw 100 USDC",
},
explanation: "Withdraw 100 USDC on Lulo",
},
],
],
schema: z.object({
mintAddress: z.string().describe("SPL Mint address"),
amount: z.number().positive().describe("Amount to lend"),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
try {
const mintAddress = input.mintAddress as string;
const amount = input.amount as number;
const response = await luloWithdraw(agent, mintAddress, amount);
return {
status: "success",
signature: response,
message: `Successfully withdraw ${amount} of token ${mintAddress}`,
};
} catch (error: any) {
return {
status: "error",
message: `Withdraw failed: ${error.message}`,
};
}
},
};
export default luloWithdrawAction;

View File

@@ -13,7 +13,7 @@ const mintNFTAction: Action = {
"create token", "create token",
"add nft to collection", "add nft to collection",
], ],
description: `Mint a new NFT in a collection on Solana blockchain.`, description: "Mint a new NFT in a collection on Solana blockchain.",
examples: [ examples: [
[ [
{ {

View File

@@ -1,6 +1,6 @@
import { PublicKey } from "@solana/web3.js"; import { PublicKey } from "@solana/web3.js";
import { Action } from "../../types/action"; import type { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent"; import type { SolanaAgentKit } from "../../agent";
import { z } from "zod"; import { z } from "zod";
import { get_balance } from "../../tools"; import { get_balance } from "../../tools";

View File

@@ -0,0 +1,80 @@
import { PublicKey } from "@solana/web3.js";
import type { Action } from "../types/action";
import type { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { get_token_balance } from "../tools";
const tokenBalancesAction: Action = {
name: "TOKEN_BALANCE_ACTION",
similes: [
"check token balances",
"get wallet token balances",
"view token balances",
"show token balances",
"check token balance",
],
description: `Get the token balances of a Solana wallet.
If you want to get the balance of your wallet, you don't need to provide the wallet address.`,
examples: [
[
{
input: {},
output: {
status: "success",
balance: {
sol: 100,
tokens: [
{
tokenAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
name: "USD Coin",
symbol: "USDC",
balance: 100,
decimals: 9,
},
],
},
},
explanation: "Get token balances of the wallet",
},
],
[
{
input: {
walletAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
},
output: {
status: "success",
balance: {
sol: 100,
tokens: [
{
tokenAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
name: "USD Coin",
symbol: "USDC",
balance: 100,
decimals: 9,
},
],
},
},
explanation: "Get address token balance",
},
],
],
schema: z.object({
walletAddress: z.string().optional(),
}),
handler: async (agent: SolanaAgentKit, input) => {
const balance = await get_token_balance(
agent,
input.tokenAddress && new PublicKey(input.tokenAddress),
);
return {
status: "success",
balance: balance,
};
},
};
export default tokenBalancesAction;

View File

@@ -0,0 +1,83 @@
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { BN } from "bn.js";
const depositVoltrStrategyAction: Action = {
name: "DEPOSIT_VOLTR_STRATEGY",
similes: [
"deposit to voltr strategy",
"add funds to voltr vault strategy",
"invest in voltr strategy",
"deposit assets to voltr",
"contribute to voltr vault",
"fund voltr strategy",
],
description: "Deposit assets into a specific strategy within a Voltr vault",
examples: [
[
{
input: {
depositAmount: "1000000000", // 1 USDC with 6 decimals
vault: "7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K",
strategy: "9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk",
},
output: {
status: "success",
vault: "7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K",
strategy: "9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk",
signature: "2ZE7Rz...",
message: "Successfully deposited 1000000000 into strategy",
},
explanation: "Deposit 1 USDC into a Voltr vault strategy",
},
],
],
schema: z.object({
depositAmount: z
.string()
.min(1)
.describe("The amount to deposit (in base units including decimals)"),
vault: z
.string()
.min(1)
.describe(
"The public key of the Voltr source vault to take assets from, e.g., 'Ga27...'",
),
strategy: z
.string()
.min(1)
.describe(
"The public key of the initialized target strategy to deposit into, e.g., 'Jheh...'",
),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
try {
const depositAmount = new BN(input.depositAmount);
const vault = new PublicKey(input.vault);
const strategy = new PublicKey(input.strategy);
const signature = await agent.voltrDepositStrategy(
depositAmount,
vault,
strategy,
);
return {
status: "success",
vault: vault.toBase58(),
strategy: strategy.toBase58(),
signature,
message: `Successfully deposited ${input.depositAmount} into strategy`,
};
} catch (error: any) {
return {
status: "error",
message: `Failed to deposit into strategy: ${error.message}`,
};
}
},
};
export default depositVoltrStrategyAction;

View File

@@ -0,0 +1,74 @@
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
const getVoltrPositionValuesAction: Action = {
name: "GET_VOLTR_POSITION_VALUES",
similes: [
"get voltr vault value",
"check voltr position",
"get voltr vault assets",
"view voltr holdings",
"check voltr portfolio",
"get voltr vault breakdown",
],
description:
"Get the current position values and total assets for a Voltr vault",
examples: [
[
{
input: {
vault: "7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K",
},
output: {
status: "success",
data: {
totalValue: 1000000,
positions: [
{
strategy: "4JHtgXyMb9gFJ1hGd2sh645jrZcxurSG3QP7Le3aTMTx",
value: 600000,
},
{
strategy: "4i9kzGr1UkxBCCUkQUQ4vsF51fjdt2knKxrwM1h1NW4g",
value: 400000,
},
],
},
message: "Successfully retrieved Voltr vault position values",
},
explanation:
"Get position values for a Voltr vault showing total value and value per strategy",
},
],
],
schema: z.object({
vault: z
.string()
.min(1)
.describe("The public key of the Voltr vault to query, e.g., 'Ga27...'"),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
try {
const vault = new PublicKey(input.vault);
const result = await agent.voltrGetPositionValues(vault);
const positionData = JSON.parse(result);
return {
status: "success",
vault: vault.toBase58(),
data: positionData,
message: "Successfully retrieved Voltr vault position values",
};
} catch (error: any) {
return {
status: "error",
message: `Failed to get vault position values: ${error.message}`,
};
}
},
};
export default getVoltrPositionValuesAction;

View File

@@ -0,0 +1,83 @@
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { BN } from "bn.js";
const withdrawVoltrStrategyAction: Action = {
name: "WITHDRAW_VOLTR_STRATEGY",
similes: [
"withdraw from voltr strategy",
"remove funds from voltr vault strategy",
"take out from voltr strategy",
"withdraw assets from voltr",
"pull from voltr vault",
"redeem from voltr strategy",
],
description: "Withdraw assets from a specific strategy within a Voltr vault",
examples: [
[
{
input: {
withdrawAmount: "1000000000", // 1 USDC with 6 decimals
vault: "7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K",
strategy: "9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk",
},
output: {
status: "success",
vault: "7opUkqYtxmQRriZvwZkPcg6LqmGjAh1RSEsVrdsGDx5K",
strategy: "9ZQQYvr4x7AMqd6abVa1f5duGjti5wk1MHsX6hogPsLk",
signature: "2ZE7Rz...",
message: "Successfully withdrew 1000000000 from strategy",
},
explanation: "Withdraw 1 USDC from a Voltr vault strategy",
},
],
],
schema: z.object({
withdrawAmount: z
.string()
.min(1)
.describe("The amount to withdraw (in base units including decimals)"),
vault: z
.string()
.min(1)
.describe(
"The public key of the Voltr source vault to deposit assets into, e.g., 'Ga27...'",
),
strategy: z
.string()
.min(1)
.describe(
"The public key of the initialized target strategy to withdraw from, e.g., 'Jheh...'",
),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
try {
const withdrawAmount = new BN(input.withdrawAmount);
const vault = new PublicKey(input.vault);
const strategy = new PublicKey(input.strategy);
const signature = await agent.voltrWithdrawStrategy(
withdrawAmount,
vault,
strategy,
);
return {
status: "success",
vault: vault.toBase58(),
strategy: strategy.toBase58(),
signature,
message: `Successfully withdrew ${input.withdrawAmount} from strategy`,
};
} catch (error: any) {
return {
status: "error",
message: `Failed to withdraw from strategy: ${error.message}`,
};
}
},
};
export default withdrawVoltrStrategyAction;

View File

@@ -18,6 +18,8 @@ import {
getPrimaryDomain, getPrimaryDomain,
launchPumpFunToken, launchPumpFunToken,
lendAsset, lendAsset,
luloLend,
luloWithdraw,
mintCollectionNFT, mintCollectionNFT,
openbookCreateMarket, openbookCreateMarket,
manifestCreateMarket, manifestCreateMarket,
@@ -84,6 +86,34 @@ import {
getHeliusWebhook, getHeliusWebhook,
create_HeliusWebhook, create_HeliusWebhook,
deleteHeliusWebhook, deleteHeliusWebhook,
createDriftUserAccount,
createVault,
depositIntoVault,
depositToDriftUserAccount,
getVaultAddress,
doesUserHaveDriftAccount,
driftUserAccountInfo,
requestWithdrawalFromVault,
tradeDriftVault,
driftPerpTrade,
updateVault,
getVaultInfo,
withdrawFromDriftUserAccount,
withdrawFromDriftVault,
updateVaultDelegate,
get_token_balance,
getAvailableDriftSpotMarkets,
getAvailableDriftPerpMarkets,
stakeToDriftInsuranceFund,
requestUnstakeFromDriftInsuranceFund,
unstakeFromDriftInsuranceFund,
swapSpotToken,
calculatePerpMarketFundingRate,
getEntryQuoteOfPerpTrade,
getLendingAndBorrowAPY,
voltrGetPositionValues,
voltrDepositStrategy,
voltrWithdrawStrategy,
} from "../tools"; } from "../tools";
import { import {
Config, Config,
@@ -176,6 +206,19 @@ export class SolanaAgentKit {
return get_balance(this, token_address); return get_balance(this, token_address);
} }
async getTokenBalances(wallet_address?: PublicKey): Promise<{
sol: number;
tokens: Array<{
tokenAddress: string;
name: string;
symbol: string;
balance: number;
decimals: number;
}>;
}> {
return get_token_balance(this, wallet_address);
}
async getBalanceOther( async getBalanceOther(
walletAddress: PublicKey, walletAddress: PublicKey,
tokenAddress?: PublicKey, tokenAddress?: PublicKey,
@@ -284,6 +327,14 @@ export class SolanaAgentKit {
return lendAsset(this, amount); return lendAsset(this, amount);
} }
async luloLend(mintAddress: string, amount: number): Promise<string> {
return luloLend(this, mintAddress, amount);
}
async luloWithdraw(mintAddress: string, amount: number): Promise<string> {
return luloWithdraw(this, mintAddress, amount);
}
async getTPS(): Promise<number> { async getTPS(): Promise<number> {
return getTPS(this); return getTPS(this);
} }
@@ -655,24 +706,43 @@ export class SolanaAgentKit {
} }
async create3LandCollection( async create3LandCollection(
optionsWithBase58: StoreInitOptions,
collectionOpts: CreateCollectionOptions, collectionOpts: CreateCollectionOptions,
isDevnet: boolean = false,
): Promise<string> { ): Promise<string> {
const optionsWithBase58: StoreInitOptions = {
privateKey: this.wallet.secretKey,
};
if (isDevnet) {
optionsWithBase58.isMainnet = false;
} else {
optionsWithBase58.isMainnet = true;
}
const tx = await createCollection(optionsWithBase58, collectionOpts); const tx = await createCollection(optionsWithBase58, collectionOpts);
return `Transaction: ${tx}`; return `Transaction: ${tx}`;
} }
async create3LandNft( async create3LandNft(
optionsWithBase58: StoreInitOptions,
collectionAccount: string, collectionAccount: string,
createItemOptions: CreateSingleOptions, createItemOptions: CreateSingleOptions,
isMainnet: boolean, isDevnet: boolean = false,
withPool: boolean = false,
): Promise<string> { ): Promise<string> {
const optionsWithBase58: StoreInitOptions = {
privateKey: this.wallet.secretKey,
};
if (isDevnet) {
optionsWithBase58.isMainnet = false;
} else {
optionsWithBase58.isMainnet = true;
}
const tx = await createSingle( const tx = await createSingle(
optionsWithBase58, optionsWithBase58,
collectionAccount, collectionAccount,
createItemOptions, createItemOptions,
isMainnet, !isDevnet,
withPool,
); );
return `Transaction: ${tx}`; return `Transaction: ${tx}`;
} }
@@ -747,4 +817,185 @@ export class SolanaAgentKit {
async deleteWebhook(webhookID: string): Promise<any> { async deleteWebhook(webhookID: string): Promise<any> {
return deleteHeliusWebhook(this, webhookID); return deleteHeliusWebhook(this, webhookID);
} }
async createDriftUserAccount(depositAmount: number, depositSymbol: string) {
return await createDriftUserAccount(this, depositAmount, depositSymbol);
}
async createDriftVault(params: {
name: string;
marketName: `${string}-${string}`;
redeemPeriod: number;
maxTokens: number;
minDepositAmount: number;
managementFee: number;
profitShare: number;
hurdleRate?: number;
permissioned?: boolean;
}) {
return await createVault(this, params);
}
async depositIntoDriftVault(amount: number, vault: string) {
return await depositIntoVault(this, amount, vault);
}
async depositToDriftUserAccount(
amount: number,
symbol: string,
isRepayment?: boolean,
) {
return await depositToDriftUserAccount(this, amount, symbol, isRepayment);
}
async deriveDriftVaultAddress(name: string) {
return await getVaultAddress(this, name);
}
async doesUserHaveDriftAccount() {
return await doesUserHaveDriftAccount(this);
}
async driftUserAccountInfo() {
return await driftUserAccountInfo(this);
}
async requestWithdrawalFromDriftVault(amount: number, vault: string) {
return await requestWithdrawalFromVault(this, amount, vault);
}
async tradeUsingDelegatedDriftVault(
vault: string,
amount: number,
symbol: string,
action: "long" | "short",
type: "market" | "limit",
price?: number,
) {
return await tradeDriftVault(
this,
vault,
amount,
symbol,
action,
type,
price,
);
}
async tradeUsingDriftPerpAccount(
amount: number,
symbol: string,
action: "long" | "short",
type: "market" | "limit",
price?: number,
) {
return await driftPerpTrade(this, { action, amount, symbol, type, price });
}
async updateDriftVault(
vaultAddress: string,
params: {
name: string;
marketName: `${string}-${string}`;
redeemPeriod: number;
maxTokens: number;
minDepositAmount: number;
managementFee: number;
profitShare: number;
hurdleRate?: number;
permissioned?: boolean;
},
) {
return await updateVault(this, vaultAddress, params);
}
async getDriftVaultInfo(vaultName: string) {
return await getVaultInfo(this, vaultName);
}
async withdrawFromDriftAccount(
amount: number,
symbol: string,
isBorrow?: boolean,
) {
return await withdrawFromDriftUserAccount(this, amount, symbol, isBorrow);
}
async withdrawFromDriftVault(vault: string) {
return await withdrawFromDriftVault(this, vault);
}
async updateDriftVaultDelegate(vaultAddress: string, delegate: string) {
return await updateVaultDelegate(this, vaultAddress, delegate);
}
getAvailableDriftMarkets(type?: "spot" | "perp") {
switch (type) {
case "spot":
return getAvailableDriftSpotMarkets();
case "perp":
return getAvailableDriftPerpMarkets();
default:
return {
spot: getAvailableDriftSpotMarkets(),
perp: getAvailableDriftPerpMarkets(),
};
}
}
async stakeToDriftInsuranceFund(amount: number, symbol: string) {
return await stakeToDriftInsuranceFund(this, amount, symbol);
}
async requestUnstakeFromDriftInsuranceFund(amount: number, symbol: string) {
return await requestUnstakeFromDriftInsuranceFund(this, amount, symbol);
}
async unstakeFromDriftInsuranceFund(symbol: string) {
return await unstakeFromDriftInsuranceFund(this, symbol);
}
async driftSpotTokenSwap(
params: {
fromSymbol: string;
toSymbol: string;
slippage?: number;
} & (
| {
toAmount: number;
}
| { fromAmount: number }
),
) {
return await swapSpotToken(this, {
fromSymbol: params.fromSymbol,
toSymbol: params.toSymbol,
// @ts-expect-error - fromAmount and toAmount are mutually exclusive
fromAmount: params.fromAmount,
// @ts-expect-error - fromAmount and toAmount are mutually exclusive
toAmount: params.toAmount,
slippage: params.slippage,
});
}
async getPerpMarketFundingRate(
symbol: `${string}-PERP`,
period: "year" | "hour" = "year",
) {
return calculatePerpMarketFundingRate(this, symbol, period);
}
async getEntryQuoteOfPerpTrade(
amount: number,
symbol: `${string}-PERP`,
action: "short" | "long",
) {
return getEntryQuoteOfPerpTrade(symbol, amount, action);
}
async getLendAndBorrowAPY(symbol: string) {
return getLendingAndBorrowAPY(this, symbol);
}
async voltrDepositStrategy(
depositAmount: BN,
vault: PublicKey,
strategy: PublicKey,
): Promise<string> {
return voltrDepositStrategy(this, depositAmount, vault, strategy);
}
async voltrWithdrawStrategy(
withdrawAmount: BN,
vault: PublicKey,
strategy: PublicKey,
): Promise<string> {
return voltrWithdrawStrategy(this, withdrawAmount, vault, strategy);
}
async voltrGetPositionValues(vault: PublicKey): Promise<string> {
return voltrGetPositionValues(this, vault);
}
} }

View File

@@ -42,3 +42,8 @@ export const METEORA_DYNAMIC_AMM_PROGRAM_ID = new PublicKey(
export const METEORA_DLMM_PROGRAM_ID = new PublicKey( export const METEORA_DLMM_PROGRAM_ID = new PublicKey(
"LbVRzDTvBDEcrthxfZ4RL6yiq3uZw8bS6MwtdY6UhFQ", "LbVRzDTvBDEcrthxfZ4RL6yiq3uZw8bS6MwtdY6UhFQ",
); );
/**
* Minimum compute price required to carry out complex transactions on the Drift protocol
*/
export const MINIMUM_COMPUTE_PRICE_FOR_COMPLEX_ACTIONS =
0.000003 * 1000000 * 1000000;

View File

@@ -10,7 +10,6 @@ export class Solana3LandCreateCollection extends Tool {
description = `Creates an NFT Collection that you can visit on 3.land's website (3.land/collection/{collectionAccount}) description = `Creates an NFT Collection that you can visit on 3.land's website (3.land/collection/{collectionAccount})
Inputs: Inputs:
privateKey (required): represents the privateKey of the wallet - can be an array of numbers, Uint8Array or base58 string
isMainnet (required): defines is the tx takes places in mainnet isMainnet (required): defines is the tx takes places in mainnet
collectionSymbol (required): the symbol of the collection collectionSymbol (required): the symbol of the collection
collectionName (required): the name of the collection collectionName (required): the name of the collection
@@ -26,14 +25,8 @@ export class Solana3LandCreateCollection extends Tool {
protected async _call(input: string): Promise<string> { protected async _call(input: string): Promise<string> {
try { try {
const inputFormat = JSON.parse(input); const inputFormat = JSON.parse(input);
const privateKey = inputFormat.privateKey;
const isMainnet = inputFormat.isMainnet; const isMainnet = inputFormat.isMainnet;
const optionsWithBase58: StoreInitOptions = {
...(privateKey && { privateKey }),
...(isMainnet && { isMainnet }),
};
const collectionSymbol = inputFormat?.collectionSymbol; const collectionSymbol = inputFormat?.collectionSymbol;
const collectionName = inputFormat?.collectionName; const collectionName = inputFormat?.collectionName;
const collectionDescription = inputFormat?.collectionDescription; const collectionDescription = inputFormat?.collectionDescription;
@@ -49,8 +42,8 @@ export class Solana3LandCreateCollection extends Tool {
}; };
const tx = await this.solanaKit.create3LandCollection( const tx = await this.solanaKit.create3LandCollection(
optionsWithBase58,
collectionOpts, collectionOpts,
!isMainnet,
); );
return JSON.stringify({ return JSON.stringify({
status: "success", status: "success",

View File

@@ -10,7 +10,6 @@ export class Solana3LandCreateSingle extends Tool {
description = `Creates an NFT and lists it on 3.land's website description = `Creates an NFT and lists it on 3.land's website
Inputs: Inputs:
privateKey (required): represents the privateKey of the wallet - can be an array of numbers, Uint8Array or base58 string
collectionAccount (optional): represents the account for the nft collection collectionAccount (optional): represents the account for the nft collection
itemName (required): the name of the NFT itemName (required): the name of the NFT
sellerFee (required): the fee of the seller sellerFee (required): the fee of the seller
@@ -21,7 +20,9 @@ export class Solana3LandCreateSingle extends Tool {
mainImageUrl (required): the main image of the NFT mainImageUrl (required): the main image of the NFT
coverImageUrl (optional): the cover image of the NFT coverImageUrl (optional): the cover image of the NFT
splHash (optional): the hash of the spl token, if not provided listing will be in $SOL splHash (optional): the hash of the spl token, if not provided listing will be in $SOL
isMainnet (required): defines is the tx takes places in mainnet poolName (optional): the name of the pool
isMainnet (required): defines if the tx takes places in mainnet
withPool (optional): defines if minted edition will be tied to a liquidity pool
`; `;
constructor(private solanaKit: SolanaAgentKit) { constructor(private solanaKit: SolanaAgentKit) {
@@ -31,13 +32,9 @@ export class Solana3LandCreateSingle extends Tool {
protected async _call(input: string): Promise<string> { protected async _call(input: string): Promise<string> {
try { try {
const inputFormat = JSON.parse(input); const inputFormat = JSON.parse(input);
const privateKey = inputFormat.privateKey;
const isMainnet = inputFormat.isMainnet; const isMainnet = inputFormat.isMainnet;
const withPool = inputFormat.withPool;
const optionsWithBase58: StoreInitOptions = { const poolName = inputFormat.poolName;
...(privateKey && { privateKey }),
...(isMainnet && { isMainnet }),
};
const collectionAccount = inputFormat.collectionAccount; const collectionAccount = inputFormat.collectionAccount;
@@ -52,6 +49,15 @@ export class Solana3LandCreateSingle extends Tool {
const coverImageUrl = inputFormat?.coverImageUrl; const coverImageUrl = inputFormat?.coverImageUrl;
const splHash = inputFormat?.splHash; const splHash = inputFormat?.splHash;
if (withPool) {
if (!poolName) {
throw new Error("poolName is required when withPool is true");
}
if (!splHash) {
throw new Error("splHash is required when withPool is true");
}
}
const createItemOptions: CreateSingleOptions = { const createItemOptions: CreateSingleOptions = {
...(itemName && { itemName }), ...(itemName && { itemName }),
...(sellerFee && { sellerFee }), ...(sellerFee && { sellerFee }),
@@ -63,6 +69,7 @@ export class Solana3LandCreateSingle extends Tool {
...(mainImageUrl && { mainImageUrl }), ...(mainImageUrl && { mainImageUrl }),
...(coverImageUrl && { coverImageUrl }), ...(coverImageUrl && { coverImageUrl }),
...(splHash && { splHash }), ...(splHash && { splHash }),
...(poolName && { poolName }),
}; };
if (!collectionAccount) { if (!collectionAccount) {
@@ -70,10 +77,10 @@ export class Solana3LandCreateSingle extends Tool {
} }
const tx = await this.solanaKit.create3LandNft( const tx = await this.solanaKit.create3LandNft(
optionsWithBase58,
collectionAccount, collectionAccount,
createItemOptions, createItemOptions,
isMainnet, !isMainnet,
withPool,
); );
return JSON.stringify({ return JSON.stringify({
status: "success", status: "success",

View File

@@ -0,0 +1,38 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaCreateDriftUserAccountTool extends Tool {
name = "create_drift_user_account";
description = `Create a new user account with a deposit on Drift protocol.
Inputs (JSON string):
- amount: number, amount of the token to deposit (required)
- symbol: string, symbol of the token to deposit (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const res = await this.solanaKit.createDriftUserAccount(
parsedInput.amount,
parsedInput.symbol,
);
return JSON.stringify({
status: "success",
message: `User account created with ${parsedInput.amount} ${parsedInput.symbol} successfully deposited`,
account: res.account,
signature: res.txSignature,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "CREATE_DRIFT_USER_ACCOUNT_ERROR",
});
}
}
}

View File

@@ -0,0 +1,42 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaCreateDriftVaultTool extends Tool {
name = "create_drift_vault";
description = `Create a new drift vault delegating the agents address as the owner.
Inputs (JSON string):
- name: string, unique vault name (min 5 chars)
- marketName: string, market name in TOKEN-SPOT format
- redeemPeriod: number, days to wait before funds can be redeemed (min 1)
- maxTokens: number, maximum tokens vault can accommodate (min 100)
- minDepositAmount: number, minimum deposit amount
- managementFee: number, fee percentage for managing funds (max 20)
- profitShare: number, profit sharing percentage (max 90, default 5)
- hurdleRate: number, optional hurdle rate
- permissioned: boolean, whether vault has whitelist`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx = await this.solanaKit.createDriftVault(parsedInput);
return JSON.stringify({
status: "success",
message: "Drift vault created successfully",
vaultName: parsedInput.name,
signature: tx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "CREATE_DRIFT_VAULT_ERROR",
});
}
}
}

View File

@@ -0,0 +1,37 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaDepositIntoDriftVaultTool extends Tool {
name = "deposit_into_drift_vault";
description = `Deposit funds into an existing drift vault.
Inputs (JSON string):
- vaultAddress: string, address of the vault (required)
- amount: number, amount to deposit (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx = await this.solanaKit.depositIntoDriftVault(
parsedInput.amount,
parsedInput.vaultAddress,
);
return JSON.stringify({
status: "success",
message: "Funds deposited successfully",
signature: tx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "DEPOSIT_INTO_VAULT_ERROR",
});
}
}
}

View File

@@ -0,0 +1,39 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaDepositToDriftUserAccountTool extends Tool {
name = "deposit_to_drift_user_account";
description = `Deposit funds into your drift user account.
Inputs (JSON string):
- amount: number, amount to deposit (required)
- symbol: string, token symbol (required)
- repay: boolean, whether to repay borrowed funds (optional, default: false)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx = await this.solanaKit.depositToDriftUserAccount(
parsedInput.amount,
parsedInput.symbol,
parsedInput.repay,
);
return JSON.stringify({
status: "success",
message: "Funds deposited successfully",
signature: tx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "DEPOSIT_TO_DRIFT_ACCOUNT_ERROR",
});
}
}
}

View File

@@ -0,0 +1,32 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaDeriveVaultAddressTool extends Tool {
name = "derive_drift_vault_address";
description = `Derive a drift vault address from the vault's name.
Inputs (JSON string):
- name: string, name of the vault to derive the address of (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const address = await this.solanaKit.deriveDriftVaultAddress(input);
return JSON.stringify({
status: "success",
message: "Vault address derived successfully",
address,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "DERIVE_VAULT_ADDRESS_ERROR",
});
}
}
}

View File

@@ -0,0 +1,38 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaCheckDriftAccountTool extends Tool {
name = "does_user_have_drift_account";
description = `Check if a user has a Drift account.
Inputs: No inputs required - checks the current user's account`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(_input: string): Promise<string> {
try {
const res = await this.solanaKit.doesUserHaveDriftAccount();
if (!res.hasAccount) {
return JSON.stringify({
status: "error",
message: "You do not have a Drift account",
});
}
return JSON.stringify({
status: "success",
message: "Nice! You have a Drift account",
account: res.account,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "CHECK_DRIFT_ACCOUNT_ERROR",
});
}
}
}

View File

@@ -0,0 +1,29 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaDriftUserAccountInfoTool extends Tool {
name = "drift_user_account_info";
description = `Get information about your drift account.
Inputs: No inputs required - retrieves current user's account info`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(_input: string): Promise<string> {
try {
const accountInfo = await this.solanaKit.driftUserAccountInfo();
return JSON.stringify({
status: "success",
data: accountInfo,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "DRIFT_ACCOUNT_INFO_ERROR",
});
}
}
}

View File

@@ -0,0 +1,39 @@
import { Tool } from "langchain/tools";
import type { SolanaAgentKit } from "../../agent";
export class SolanaDriftEntryQuoteOfPerpTradeTool extends Tool {
name = "drift_entry_quote_of_perp_trade";
description = `Get an entry quote for a perpetual trade on Drift protocol.
Inputs (JSON string):
- amount: number, amount to trade (required)
- symbol: string, market symbol (required)
- action: "long" | "short", trade direction (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const quote = await this.solanaKit.getEntryQuoteOfPerpTrade(
parsedInput.amount,
parsedInput.symbol,
parsedInput.action,
);
return JSON.stringify({
status: "success",
message: `Entry quote retrieved for ${parsedInput.action} ${parsedInput.amount} ${parsedInput.symbol}`,
data: quote,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "ENTRY_QUOTE_OF_PERP_TRADE_ERROR",
});
}
}
}

View File

@@ -0,0 +1,22 @@
export * from "./create_user_account";
export * from "./create_vault";
export * from "./deposit_into_vault";
export * from "./deposit_to_user_account";
export * from "./derive_vault_address";
export * from "./does_user_have_drift_account";
export * from "./drift_user_account_info";
export * from "./request_withdrawal";
export * from "./trade_delegated_vault";
export * from "./trade_perp_account";
export * from "./update_drift_vault_delegate";
export * from "./update_vault";
export * from "./vault_info";
export * from "./withdraw_from_account";
export * from "./withdraw_from_vault";
export * from "./perp_market_funding_rate";
export * from "./entry_quote_of_perp_trade";
export * from "./lend_and_borrow_apy";
export * from "./stake_to_insurance_fund";
export * from "./swap_spot_token";
export * from "./unstake_from_insurance_fund";
export * from "./request_unstake_from_insurance_fund";

View File

@@ -0,0 +1,32 @@
import { Tool } from "langchain/tools";
import type { SolanaAgentKit } from "../../agent";
export class SolanaDriftLendAndBorrowAPYTool extends Tool {
name = "drift_lend_and_borrow_apy";
description = `Get lending and borrowing APY for a token on Drift protocol.
Inputs (JSON string):
- symbol: string, token symbol (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const apyInfo = await this.solanaKit.getLendAndBorrowAPY(input);
return JSON.stringify({
status: "success",
message: `APY information retrieved for ${input}`,
data: apyInfo,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "LEND_AND_BORROW_APY_ERROR",
});
}
}
}

View File

@@ -0,0 +1,36 @@
import { Tool } from "langchain/tools";
import type { SolanaAgentKit } from "../../agent";
export class SolanaDriftPerpMarketFundingRateTool extends Tool {
name = "drift_perp_market_funding_rate";
description = `Get the funding rate for a perpetual market on Drift protocol.
Inputs (JSON string):
- symbol: string, market symbol (required)
- period: year or hour (default: hour)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const fundingRate = await this.solanaKit.getPerpMarketFundingRate(
parsedInput.symbol,
parsedInput.period,
);
return JSON.stringify({
status: "success",
message: `Funding rate retrieved for ${parsedInput.symbol}`,
data: fundingRate,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
});
}
}
}

View File

@@ -0,0 +1,37 @@
import { Tool } from "langchain/tools";
import type { SolanaAgentKit } from "../../agent";
export class SolanaRequestUnstakeFromDriftInsuranceFundTool extends Tool {
name = "request_unstake_from_drift_insurance_fund";
description = `Request to unstake tokens from Drift Insurance Fund.
Inputs (JSON string):
- amount: number, amount to unstake (required)
- symbol: string, token symbol (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx = await this.solanaKit.requestUnstakeFromDriftInsuranceFund(
parsedInput.amount,
parsedInput.symbol,
);
return JSON.stringify({
status: "success",
message: `Requested unstake of ${parsedInput.amount} ${parsedInput.symbol} from the Drift Insurance Fund`,
signature: tx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "REQUEST_UNSTAKE_FROM_DRIFT_INSURANCE_FUND_ERROR",
});
}
}
}

View File

@@ -0,0 +1,37 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaRequestDriftWithdrawalTool extends Tool {
name = "request_withdrawal_from_drift_vault";
description = `Request a withdrawal from an existing drift vault.
Inputs (JSON string):
- vaultAddress: string, vault address (required)
- amount: number, amount of shares to withdraw (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx = await this.solanaKit.requestWithdrawalFromDriftVault(
parsedInput.amount,
parsedInput.vaultAddress,
);
return JSON.stringify({
status: "success",
message: "Withdrawal request successful",
signature: tx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "REQUEST_DRIFT_WITHDRAWAL_ERROR",
});
}
}
}

View File

@@ -0,0 +1,37 @@
import { Tool } from "langchain/tools";
import type { SolanaAgentKit } from "../../agent";
export class SolanaStakeToDriftInsuranceFundTool extends Tool {
name = "stake_to_drift_insurance_fund";
description = `Stake a token to Drift Insurance Fund.
Inputs (JSON string):
- amount: number, amount to stake (required)
- symbol: string, token symbol (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx = await this.solanaKit.stakeToDriftInsuranceFund(
parsedInput.amount,
parsedInput.symbol,
);
return JSON.stringify({
status: "success",
message: `Staked ${parsedInput.amount} ${parsedInput.symbol} to the Drift Insurance Fund`,
signature: tx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "STAKE_TO_DRIFT_INSURANCE_FUND_ERROR",
});
}
}
}

View File

@@ -0,0 +1,37 @@
import { Tool } from "langchain/tools";
import type { SolanaAgentKit } from "../../agent";
export class SolanaDriftSpotTokenSwapTool extends Tool {
name = "drift_spot_token_swap";
description = `Swap spot tokens on Drift protocol.
Inputs (JSON string):
- fromSymbol: string, symbol of token to swap from (required)
- toSymbol: string, symbol of token to swap to (required)
- fromAmount: number, amount to swap from (optional) required if toAmount is not provided
- toAmount: number, amount to swap to (optional) required if fromAmount is not provided
- slippage: number, slippage tolerance in percentage (optional)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx = await this.solanaKit.driftSpotTokenSwap(parsedInput);
return JSON.stringify({
status: "success",
message: `Swapped ${parsedInput.fromAmount} ${parsedInput.fromSymbol} for ${parsedInput.toSymbol}`,
signature: tx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "DRIFT_SPOT_TOKEN_SWAP_ERROR",
});
}
}
}

View File

@@ -0,0 +1,49 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaTradeDelegatedDriftVaultTool extends Tool {
name = "trade_delegated_drift_vault";
description = `Carry out trades in a Drift vault.
Inputs (JSON string):
- vaultAddress: string, address of the Drift vault
- amount: number, amount to trade
- symbol: string, symbol of the token to trade
- action: "long" | "short", trade direction
- type: "market" | "limit", order type
- price: number, optional limit price`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx = await this.solanaKit.tradeUsingDelegatedDriftVault(
parsedInput.vaultAddress,
parsedInput.amount,
parsedInput.symbol,
parsedInput.action,
parsedInput.type,
parsedInput.price,
);
return JSON.stringify({
status: "success",
message:
parsedInput.type === "limit"
? "Order placed successfully"
: "Trade successful",
transactionId: tx,
...parsedInput,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "TRADE_DRIFT_VAULT_ERROR",
});
}
}
}

View File

@@ -0,0 +1,42 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaTradeDriftPerpAccountTool extends Tool {
name = "trade_drift_perp_account";
description = `Trade a perpetual account on Drift protocol.
Inputs (JSON string):
- amount: number, amount to trade (required)
- symbol: string, token symbol (required)
- action: "long" | "short", trade direction (required)
- type: "market" | "limit", order type (required)
- price: number, required for limit orders`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const signature = await this.solanaKit.tradeUsingDriftPerpAccount(
parsedInput.amount,
parsedInput.symbol,
parsedInput.action,
parsedInput.type,
parsedInput.price,
);
return JSON.stringify({
status: "success",
signature,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "TRADE_PERP_ACCOUNT_ERROR",
});
}
}
}

View File

@@ -0,0 +1,32 @@
import { Tool } from "langchain/tools";
import type { SolanaAgentKit } from "../../agent";
export class SolanaUnstakeFromDriftInsuranceFundTool extends Tool {
name = "unstake_from_drift_insurance_fund";
description = `Unstake tokens from Drift Insurance Fund after request period has elapsed.
Inputs (JSON string):
- symbol: string, token symbol (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const tx = await this.solanaKit.unstakeFromDriftInsuranceFund(input);
return JSON.stringify({
status: "success",
message: `Unstaked ${input} from the Drift Insurance Fund`,
signature: tx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNSTAKE_FROM_DRIFT_INSURANCE_FUND_ERROR",
});
}
}
}

View File

@@ -0,0 +1,37 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaUpdateDriftVaultDelegateTool extends Tool {
name = "update_drift_vault_delegate";
description = `Update the delegate of a drift vault.
Inputs (JSON string):
- vaultAddress: string, address of the vault (required)
- newDelegate: string, address of the new delegate (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx = await this.solanaKit.updateDriftVaultDelegate(
parsedInput.vaultAddress,
parsedInput.newDelegate,
);
return JSON.stringify({
status: "success",
message: "Vault delegate updated successfully",
signature: tx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UPDATE_DRIFT_VAULT_DELEGATE_ERROR",
});
}
}
}

View File

@@ -0,0 +1,52 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaUpdateDriftVaultTool extends Tool {
name = "update_drift_vault";
description = `Update an existing drift vault with new settings.
Inputs (JSON string):
- vaultAddress: string, vault address (required)
- redeemPeriod: number, days until redemption (optional)
- maxTokens: number, maximum tokens allowed (optional)
- minDepositAmount: number, minimum deposit amount (optional)
- managementFee: number, management fee percentage (optional)
- profitShare: number, profit sharing percentage (optional)
- hurdleRate: number, hurdle rate (optional)
- permissioned: boolean, whitelist requirement (optional)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx = await this.solanaKit.updateDriftVault(
parsedInput.vaultAddress,
// @ts-expect-error - type mismatch
{
hurdleRate: parsedInput.hurdleRate,
maxTokens: parsedInput.maxTokens,
minDepositAmount: parsedInput.minDepositAmount,
profitShare: parsedInput.profitShare,
managementFee: parsedInput.managementFee,
permissioned: parsedInput.permissioned,
redeemPeriod: parsedInput.redeemPeriod,
},
);
return JSON.stringify({
status: "success",
message: "Drift vault parameters updated successfully",
signature: tx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UPDATE_DRIFT_VAULT_ERROR",
});
}
}
}

View File

@@ -0,0 +1,32 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaDriftVaultInfoTool extends Tool {
name = "drift_vault_info";
description = `Get information about a drift vault.
Inputs (JSON string):
- vaultNameOrAddress: string, name or address of the vault (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const vaultInfo = await this.solanaKit.getDriftVaultInfo(input);
return JSON.stringify({
status: "success",
message: "Vault info retrieved successfully",
data: vaultInfo,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "DRIFT_VAULT_INFO_ERROR",
});
}
}
}

Some files were not shown because too many files have changed in this diff Show More