mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-13 15:10:04 +00:00
Merge branch 'main' into deposit_and_withdraw_with_lulo
This commit is contained in:
@@ -5,3 +5,4 @@ JUPITER_REFERRAL_ACCOUNT=
|
||||
JUPITER_FEE_BPS=
|
||||
FLASH_PRIVILEGE= referral | nft | none
|
||||
FLEXLEND_API_KEY=
|
||||
HELIUS_API_KEY=
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"no-constant-condition": "off",
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"@typescript-eslint/no-empty-object-type": "off",
|
||||
"@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }],
|
||||
"no-console": ["warn", { "allow": ["warn", "error"] }],
|
||||
"curly": ["error", "all"],
|
||||
@@ -30,4 +31,4 @@
|
||||
"ecmaVersion": 2020,
|
||||
"sourceType": "module"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
@@ -14,6 +14,9 @@ jobs:
|
||||
with:
|
||||
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
|
||||
with:
|
||||
node-version: "23"
|
||||
@@ -21,7 +24,7 @@ jobs:
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install -r --no-frozen-lockfile
|
||||
|
||||
|
||||
- name: Run lint and fix
|
||||
run: pnpm run lint:fix
|
||||
|
||||
|
||||
221
README.md
221
README.md
@@ -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
|
||||
- Register/resolve Alldomains
|
||||
- Perpetuals Trading with Adrena Protocol
|
||||
- Drift Vaults, Perps, Lending and Borrowing
|
||||
|
||||
- **Solana Blinks**
|
||||
- Lending by Lulo (Best APR for USDC)
|
||||
@@ -133,10 +134,7 @@ console.log("Token Mint Address:", result.mint.toString());
|
||||
```
|
||||
### Create NFT Collection on 3Land
|
||||
```typescript
|
||||
const optionsWithBase58: StoreInitOptions = {
|
||||
privateKey: "",
|
||||
isMainnet: true, // if false, collection will be created on devnet 3.land (dev.3.land)
|
||||
};
|
||||
const isDevnet = true; // (Optional) if not present TX takes place in Mainnet
|
||||
|
||||
const collectionOpts: CreateCollectionOptions = {
|
||||
collectionName: "",
|
||||
@@ -146,18 +144,16 @@ const optionsWithBase58: StoreInitOptions = {
|
||||
};
|
||||
|
||||
const result = await agent.create3LandCollection(
|
||||
optionsWithBase58,
|
||||
collectionOpts
|
||||
collectionOpts,
|
||||
isDevnet, // (Optional) if not present TX takes place in Mainnet
|
||||
);
|
||||
```
|
||||
|
||||
### Create NFT on 3Land
|
||||
When creating an NFT using 3Land's tool, it automatically goes for sale on 3.land website
|
||||
```typescript
|
||||
const optionsWithBase58: StoreInitOptions = {
|
||||
privateKey: "",
|
||||
isMainnet: true, // if false, listing will be on devnet 3.land (dev.3.land)
|
||||
};
|
||||
const isDevnet = true; // (Optional) if not present TX takes place in Mainnet
|
||||
const withPool = true; // (Optional) only present if NFT will be created with a Liquidity Pool for a specific SPL token
|
||||
const collectionAccount = ""; //hash for the collection
|
||||
const createItemOptions: CreateSingleOptions = {
|
||||
itemName: "",
|
||||
@@ -169,15 +165,15 @@ const createItemOptions: CreateSingleOptions = {
|
||||
{ trait_type: "", value: "" },
|
||||
],
|
||||
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: "",
|
||||
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(
|
||||
optionsWithBase58,
|
||||
collectionAccount,
|
||||
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();
|
||||
```
|
||||
|
||||
### 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
|
||||
|
||||
### LangGraph Multi-Agent System
|
||||
@@ -357,7 +546,7 @@ Refer to [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines on how to co
|
||||
|
||||
Apache-2 License
|
||||
|
||||
## Funding
|
||||
## Funding
|
||||
|
||||
If you wanna give back any tokens or donations to the OSS community -- The Public Solana Agent Kit Treasury Address:
|
||||
|
||||
@@ -365,4 +554,4 @@ Solana Network : EKHTbXpsm6YDgJzMkFxNU1LNXeWcUW7Ezf8mjUNQQ4Pa
|
||||
|
||||
## Security
|
||||
|
||||
This toolkit handles private keys and transactions. Always ensure you're using it in a secure environment and never share your private keys.
|
||||
This toolkit handles private keys and transactions. Always ensure you're using it in a secure environment and never share your private keys.
|
||||
|
||||
@@ -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
@@ -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"><</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">></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"><</span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</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">></span><span class="tsd-signature-symbol">></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"><</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">></span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</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">></span><span class="tsd-signature-symbol">></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/88023dfe2d6afb3cdfc4b4be784ca3333faa6263/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"><</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">></span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</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">></span><span class="tsd-signature-symbol">></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>
|
||||
|
||||
@@ -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>
|
||||
</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/88023dfe2d6afb3cdfc4b4be784ca3333faa6263/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>
|
||||
|
||||
@@ -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>
|
||||
</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/88023dfe2d6afb3cdfc4b4be784ca3333faa6263/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
@@ -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
|
||||
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/88023dfe2d6afb3cdfc4b4be784ca3333faa6263/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#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#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>
|
||||
</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/88023dfe2d6afb3cdfc4b4be784ca3333faa6263/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>
|
||||
</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/88023dfe2d6afb3cdfc4b4be784ca3333faa6263/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/88023dfe2d6afb3cdfc4b4be784ca3333faa6263/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/88023dfe2d6afb3cdfc4b4be784ca3333faa6263/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/88023dfe2d6afb3cdfc4b4be784ca3333faa6263/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/88023dfe2d6afb3cdfc4b4be784ca3333faa6263/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#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/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/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/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/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
6
docs/interfaces/HeliusWebhookIdResponse.html
Normal file
6
docs/interfaces/HeliusWebhookIdResponse.html
Normal file
File diff suppressed because one or more lines are too long
3
docs/interfaces/HeliusWebhookResponse.html
Normal file
3
docs/interfaces/HeliusWebhookResponse.html
Normal file
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
5
docs/interfaces/PriorityFeeResponse.html
Normal file
5
docs/interfaces/PriorityFeeResponse.html
Normal file
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
4
examples/discord-bot-starter/.env.template
Normal file
4
examples/discord-bot-starter/.env.template
Normal file
@@ -0,0 +1,4 @@
|
||||
DISCORD_BOT_TOKEN=
|
||||
SOLANA_PRIVATE_KEY=
|
||||
SOLANA_RPC_URL=
|
||||
OPENAI_API_KEY=
|
||||
8
examples/discord-bot-starter/.gitignore
vendored
Normal file
8
examples/discord-bot-starter/.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
.env
|
||||
*.log
|
||||
.DS_Store
|
||||
|
||||
logs/
|
||||
node_modules/
|
||||
build/
|
||||
dist/
|
||||
10
examples/discord-bot-starter/.prettierrc
Normal file
10
examples/discord-bot-starter/.prettierrc
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"arrowParens": "always",
|
||||
"printWidth": 120,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all",
|
||||
"endOfLine": "auto",
|
||||
"bracketSpacing": true
|
||||
}
|
||||
41
examples/discord-bot-starter/README.md
Normal file
41
examples/discord-bot-starter/README.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Discord Bot Starter
|
||||
|
||||
This is a starter template for creating a Discord bot using the Solana Agent Kit by Send AI.
|
||||
|
||||
## Setup
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Node.js (v20 or higher)
|
||||
- pnpm (v9 or higher)
|
||||
- A Discord account
|
||||
- A Solana account keypair
|
||||
|
||||
### Step 1: Create a Discord Bot
|
||||
|
||||
1. Go to the [Discord Developer Portal](https://discord.com/developers/applications).
|
||||
2. Click on "New Application" and give your application a name.
|
||||
3. Navigate to the "Bot" tab on the left sidebar and click "Add Bot".
|
||||
4. Under the "Token" section, click "Copy" to copy your bot token.
|
||||
|
||||
### Step 2: Fill Out Environment Variables
|
||||
|
||||
Create a `.env` file in the root directory of the project and fill it out with the following variables:
|
||||
|
||||
- `DISCORD_BOT_TOKEN`: Paste the bot token you copied from the Discord Developer Portal.
|
||||
- `SOLANA_PRIVATE_KEY`: Enter your Solana private key. This is required for interacting with the Solana blockchain.
|
||||
- `SOLANA_RPC_URL`: Provide the RPC URL for connecting to the Solana network. You can use a public RPC URL or your own.
|
||||
- `OPENAI_API_KEY`: Input your OpenAI API key if you plan to use OpenAI services within your bot. You can obtain this key from the OpenAI platform.
|
||||
|
||||
### Step 3: Install Dependencies and Start the Bot
|
||||
|
||||
1. Open a terminal and navigate to the root directory of the project.
|
||||
2. Run the following command to install the project dependencies:
|
||||
```sh
|
||||
pnpm install
|
||||
```
|
||||
3. After the installation is complete, start the bot by running:
|
||||
```sh
|
||||
pnpm start
|
||||
```
|
||||
4. Once the bot is running, open Discord and send a direct message (DM) to your bot to ensure it is working correctly.
|
||||
39
examples/discord-bot-starter/package.json
Normal file
39
examples/discord-bot-starter/package.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "discord-bot-starter",
|
||||
"version": "1.0.0",
|
||||
"description": "Discord bot starter template using the Solana Agent Kit by Send AI",
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
"start": "nodemon ./src/index.ts",
|
||||
"lint": "eslint -c .eslintrc.js --ext .ts ./src",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\""
|
||||
},
|
||||
"author": "dimitrov-d",
|
||||
"dependencies": {
|
||||
"discord.js": "^14.17.2",
|
||||
"dotenv": "^16.4.7",
|
||||
"solana-agent-kit": "^1.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.10.5",
|
||||
"@typescript-eslint/parser": "8.19.0",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-import-resolver-typescript": "^3.7.0",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-prettier": "^5.2.1",
|
||||
"eslint-plugin-promise": "^7.2.1",
|
||||
"eslint-plugin-security": "^3.0.1",
|
||||
"eslint-plugin-sonarjs": "^3.0.1",
|
||||
"nodemon": "^3.1.9",
|
||||
"prettier": "^3.4.2",
|
||||
"tsconfig-paths": "^4.2.0",
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "^5.7.2"
|
||||
},
|
||||
"nodemonConfig": {
|
||||
"ext": "*.ts",
|
||||
"exec": "tsx",
|
||||
"delay": 1000
|
||||
}
|
||||
}
|
||||
8533
examples/discord-bot-starter/pnpm-lock.yaml
generated
Normal file
8533
examples/discord-bot-starter/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
96
examples/discord-bot-starter/src/index.ts
Normal file
96
examples/discord-bot-starter/src/index.ts
Normal file
@@ -0,0 +1,96 @@
|
||||
import 'dotenv/config';
|
||||
import { Client, GatewayIntentBits, Events, ChannelType, Partials } from 'discord.js';
|
||||
import { HumanMessage } from '@langchain/core/messages';
|
||||
import { MemorySaver } from '@langchain/langgraph';
|
||||
import { createReactAgent } from '@langchain/langgraph/prebuilt';
|
||||
import { ChatOpenAI } from '@langchain/openai';
|
||||
import { SolanaAgentKit, createSolanaTools } from 'solana-agent-kit';
|
||||
|
||||
const client = new Client({
|
||||
intents: [GatewayIntentBits.MessageContent, GatewayIntentBits.DirectMessages],
|
||||
partials: [Partials.Message, Partials.Channel],
|
||||
});
|
||||
|
||||
const chatHistory = new Map();
|
||||
|
||||
async function initializeAgent() {
|
||||
try {
|
||||
const llm = new ChatOpenAI({
|
||||
modelName: 'gpt-4o-mini',
|
||||
temperature: 0.3,
|
||||
});
|
||||
|
||||
const solanaAgent = new SolanaAgentKit(process.env.SOLANA_PRIVATE_KEY!, process.env.SOLANA_RPC_URL!, {
|
||||
OPENAI_API_KEY: process.env.OPENAI_API_KEY!,
|
||||
// other config options here
|
||||
});
|
||||
|
||||
const tools = createSolanaTools(solanaAgent);
|
||||
|
||||
const memory = new MemorySaver();
|
||||
const config = { configurable: { thread_id: 'Solana Agent Kit!' } };
|
||||
|
||||
const agent = createReactAgent({
|
||||
llm,
|
||||
tools,
|
||||
checkpointSaver: memory,
|
||||
messageModifier: `
|
||||
You are a helpful agent that can interact onchain using the Solana Agent Kit. You are
|
||||
empowered to interact onchain using your tools. If you ever need funds, you can request them from the
|
||||
faucet. If not, you can provide your wallet details and request funds from the user. If there is a 5XX
|
||||
(internal) HTTP error code, ask the user to try again later. If someone asks you to do something you
|
||||
can't do with your currently available tools, you must say so, and encourage them to implement it
|
||||
themselves using the Solana Agent Kit, recommend they go to https://www.solanaagentkit.xyz for more information. Be
|
||||
concise and helpful with your responses. Refrain from restating your tools' descriptions unless it is explicitly requested.
|
||||
`,
|
||||
});
|
||||
|
||||
return { agent, config };
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize agent:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
client.on(Events.ClientReady, async () => {
|
||||
// gets data about the bot
|
||||
await client.application?.fetch();
|
||||
|
||||
console.info(`${client.user?.username || 'Bot'} is running. Send it a message in Discord DM to get started.`);
|
||||
});
|
||||
|
||||
client.on(Events.MessageCreate, async (message) => {
|
||||
try {
|
||||
if (message.channel.type !== ChannelType.DM || message.author.bot) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.info(`Received message: ${message.content}`);
|
||||
await message.channel.sendTyping();
|
||||
|
||||
const { agent, config } = await initializeAgent();
|
||||
|
||||
const userId = message.author.id;
|
||||
if (!chatHistory.has(userId)) {
|
||||
chatHistory.set(userId, []);
|
||||
}
|
||||
const userChatHistory = chatHistory.get(userId);
|
||||
userChatHistory.push(new HumanMessage(message.content));
|
||||
|
||||
const stream = await agent.stream({ messages: userChatHistory }, config);
|
||||
|
||||
const replyIfNotEmpty = async (content: string) => content.trim() !== '' && message.reply(content);
|
||||
|
||||
for await (const chunk of stream) {
|
||||
if ('agent' in chunk) {
|
||||
const agentMessage = chunk.agent.messages[0].content;
|
||||
await replyIfNotEmpty(agentMessage);
|
||||
userChatHistory.push(new HumanMessage(agentMessage));
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error handling message:', error);
|
||||
}
|
||||
});
|
||||
|
||||
client.login(process.env.DISCORD_BOT_TOKEN);
|
||||
21
examples/discord-bot-starter/tsconfig.json
Normal file
21
examples/discord-bot-starter/tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"rootDir": "./src",
|
||||
"outDir": "./build",
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"target": "es2020",
|
||||
"typeRoots": ["node_modules/@types"],
|
||||
"lib": ["es2018", "dom", "esnext.asynciterable"],
|
||||
"plugins": [{ "transform": "typescript-transform-paths" }],
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true
|
||||
}
|
||||
}
|
||||
@@ -5,23 +5,47 @@ Extending the **Solana Agent Kit** with custom tools allows you to add specializ
|
||||
## Overview
|
||||
|
||||
1. Create a new tool file
|
||||
2. Implement the tool class
|
||||
3. Implement supporting functions in SolanaAgentKit
|
||||
4. Export the new tool
|
||||
5. Integrate the tool into the agent
|
||||
6. Use the custom tool
|
||||
2. Export the new tool
|
||||
3. Add supporting functions in SolanaAgentKit
|
||||
4. Implement the Langchain tool class
|
||||
5. Export the Langchain tool
|
||||
6. Export your protocol's langchain tools (if not already exported)
|
||||
7. Define Action class for given tool
|
||||
8. Export Action
|
||||
9. Use the custom tool
|
||||
|
||||
## Implementation Guide
|
||||
|
||||
### 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. Implement the Tool Class
|
||||
> `src/langchain/index.ts`
|
||||
```typescript:src/langchain/index.ts
|
||||
### 2. Export the Tool (if not already exported)
|
||||
> `src/tools/index.ts`
|
||||
```typescript:src/tools/index.ts
|
||||
export * from "./squads";
|
||||
export * from "./jupiter";
|
||||
export * from "./your_protocol"; // Add your protocol here if it's not already in the list
|
||||
```
|
||||
|
||||
### 3. Add Supporting Functions to SolanaAgentKit
|
||||
> `src/agent/index.ts`
|
||||
```typescript:src/agent/index.ts
|
||||
export class SolanaAgentKit {
|
||||
// ... existing code ...
|
||||
|
||||
async customFunction(input: string): Promise<string> {
|
||||
// Implement your custom functionality
|
||||
return `Processed input: ${input}`;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Implement the Langchain Tool Class
|
||||
> `src/langchain/your_protocol/custom_tool.ts`
|
||||
```typescript:src/langchain/your_protocol/custom_tool.ts
|
||||
import { Tool } from "langchain/tools";
|
||||
import { SolanaAgentKit } from "../agent";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
|
||||
export class CustomTool extends Tool {
|
||||
name = "custom_tool";
|
||||
@@ -50,41 +74,65 @@ export class CustomTool extends Tool {
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Add Supporting Functions to SolanaAgentKit
|
||||
> `src/agent/index.ts`
|
||||
```typescript:src/agent/index.ts
|
||||
export class SolanaAgentKit {
|
||||
// ... existing code ...
|
||||
|
||||
async customFunction(input: string): Promise<string> {
|
||||
// Implement your custom functionality
|
||||
return `Processed input: ${input}`;
|
||||
}
|
||||
}
|
||||
### 5. Export Langchain Tool
|
||||
> `src/langchain/your_protocol/index.ts`
|
||||
```typescript:src/langchain/your_protocol/index.ts
|
||||
export * from "./custom_tool";
|
||||
```
|
||||
|
||||
### 4. Export the Tool
|
||||
> `src/tools/index.ts`
|
||||
```typescript:src/tools/index.ts
|
||||
export * from "./request_faucet_funds";
|
||||
export * from "./deploy_token";
|
||||
export * from "./custom_tool"; // Add your new tool
|
||||
```
|
||||
|
||||
### 5. Integrate with Agent
|
||||
### 6. Export your protocol's langchain tools (if not already exported)
|
||||
> `src/langchain/index.ts`
|
||||
```typescript:src/langchain/index.ts
|
||||
import { CustomTool } from "../tools/custom_tool";
|
||||
export * from "./tiplink";
|
||||
export * from "./your_protocol"; // Add your protocol here if it's not already in the list
|
||||
```
|
||||
|
||||
export function createSolanaTools(agent: SolanaAgentKit) {
|
||||
return [
|
||||
// ... existing tools ...
|
||||
new CustomTool(agent),
|
||||
];
|
||||
### 7. Define Action class for given tool
|
||||
|
||||
> `src/actions/your_protocol/custom_action.ts`
|
||||
```typescript:src/actions/your_protocol/custom_action.ts
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { custom_tool } from "../../tools";
|
||||
|
||||
const customAction: Action = {
|
||||
name: "CUSTOM_ACTION",
|
||||
similes: ["custom tool"],
|
||||
description: "Description of what the custom tool does.",
|
||||
examples: [
|
||||
{
|
||||
input: {},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Custom tool executed successfully",
|
||||
data: result,
|
||||
},
|
||||
explanation: "Custom tool executed successfully",
|
||||
},
|
||||
],
|
||||
schema: z.object({
|
||||
input: z.string(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const result = await agent.customFunction(input);
|
||||
return result;
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
### 8. Export Action
|
||||
> `src/actions/index.ts`
|
||||
```typescript:src/actions/index.ts
|
||||
import customAction from "./your_protocol/custom_action";
|
||||
|
||||
export const ACTIONS = {
|
||||
// ... existing actions ...
|
||||
CUSTOM_ACTION: customAction,
|
||||
}
|
||||
```
|
||||
|
||||
### 6. Usage Example
|
||||
### 9. Usage Example
|
||||
|
||||
Add a code example in the `README.md` file.
|
||||
|
||||
@@ -106,7 +154,7 @@ if (customTool) {
|
||||
}
|
||||
|
||||
// or alternatively
|
||||
const result = await agent.customFunction("your-input"); // assuming you have a `customFunction` method in SolanaAgentKit
|
||||
const result = await agent.customFunction("your-input"); // assuming you have implemented `customFunction` method in SolanaAgentKit
|
||||
console.log(result);
|
||||
```
|
||||
|
||||
@@ -174,6 +222,43 @@ export class SolanaAgentKit {
|
||||
}
|
||||
```
|
||||
|
||||
Add Action for given tool:
|
||||
> `src/actions/fetch_token_price.ts`
|
||||
```typescript:src/actions/fetch_token_price.ts
|
||||
import { Action } from "../types/action";
|
||||
import { SolanaAgentKit } from "../agent";
|
||||
import { z } from "zod";
|
||||
import { fetch_token_price } from "../tools";
|
||||
|
||||
const fetchTokenPriceAction: Action = {
|
||||
name: "FETCH_TOKEN_PRICE",
|
||||
similes: ["fetch token price"],
|
||||
description: "Fetches the current price of a specified token.",
|
||||
examples: [
|
||||
{
|
||||
input: { tokenSymbol: "SOL" },
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Price fetched successfully for SOL.",
|
||||
price: 150,
|
||||
},
|
||||
explanation: "Fetch the current price of SOL token in USDC",
|
||||
},
|
||||
],
|
||||
schema: z.object({
|
||||
tokenSymbol: z.string().describe("The symbol of the token to fetch the price for"),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const price = await agent.getTokenPrice(input.tokenSymbol);
|
||||
return {
|
||||
status: "success",
|
||||
price,
|
||||
message: `Price fetched successfully for ${input.tokenSymbol}.`,
|
||||
};
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
Then it can be used as such:
|
||||
|
||||
```typescript
|
||||
|
||||
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "solana-agent-kit",
|
||||
"version": "1.3.8",
|
||||
"version": "1.4.0",
|
||||
"description": "connect any ai agents to solana protocols",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
@@ -23,11 +23,13 @@
|
||||
"author": "sendaifun",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@3land/listings-sdk": "^0.0.4",
|
||||
"@3land/listings-sdk": "^0.0.6",
|
||||
"@ai-sdk/openai": "^1.0.11",
|
||||
"@bonfida/spl-name-service": "^3.0.7",
|
||||
"@cks-systems/manifest-sdk": "0.1.59",
|
||||
"@coral-xyz/anchor": "0.29",
|
||||
"@drift-labs/sdk": "2.107.0-beta.3",
|
||||
"@drift-labs/vaults-sdk": "^0.2.49",
|
||||
"@langchain/core": "^0.3.26",
|
||||
"@langchain/groq": "^0.1.2",
|
||||
"@langchain/langgraph": "^0.2.36",
|
||||
@@ -50,6 +52,7 @@
|
||||
"@sqds/multisig": "^2.1.3",
|
||||
"@tensor-oss/tensorswap-sdk": "^4.5.0",
|
||||
"@tiplink/api": "^0.3.1",
|
||||
"@voltr/vault-sdk": "^0.1.1",
|
||||
"ai": "^4.0.22",
|
||||
"bn.js": "^5.2.1",
|
||||
"bs58": "^6.0.0",
|
||||
@@ -77,5 +80,6 @@
|
||||
"prettier": "^3.4.2",
|
||||
"tsx": "^4.19.2",
|
||||
"typescript": "^5.7.2"
|
||||
}
|
||||
},
|
||||
"packageManager": "pnpm@9.15.3"
|
||||
}
|
||||
|
||||
2869
pnpm-lock.yaml
generated
2869
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
59
src/actions/drift/createDriftUserAccount.ts
Normal file
59
src/actions/drift/createDriftUserAccount.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
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"),
|
||||
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;
|
||||
108
src/actions/drift/createVault.ts
Normal file
108
src/actions/drift/createVault.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
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",
|
||||
),
|
||||
minDepositAmount: z.number().positive().describe("Minimum deposit amount"),
|
||||
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;
|
||||
56
src/actions/drift/depositIntoVault.ts
Normal file
56
src/actions/drift/depositIntoVault.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
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"),
|
||||
}),
|
||||
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;
|
||||
73
src/actions/drift/depositToDriftUserAccount.ts
Normal file
73
src/actions/drift/depositToDriftUserAccount.ts
Normal 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",
|
||||
),
|
||||
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;
|
||||
46
src/actions/drift/deriveVaultAddress.ts
Normal file
46
src/actions/drift/deriveVaultAddress.ts
Normal 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;
|
||||
53
src/actions/drift/doesUserHaveDriftAccount.ts
Normal file
53
src/actions/drift/doesUserHaveDriftAccount.ts
Normal 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;
|
||||
39
src/actions/drift/driftUserAccountInfo.ts
Normal file
39
src/actions/drift/driftUserAccountInfo.ts
Normal 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;
|
||||
57
src/actions/drift/requestWithdrawalFromVault.ts
Normal file
57
src/actions/drift/requestWithdrawalFromVault.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
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"),
|
||||
}),
|
||||
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;
|
||||
114
src/actions/drift/tradeDelegatedDriftVault.ts
Normal file
114
src/actions/drift/tradeDelegatedDriftVault.ts
Normal file
@@ -0,0 +1,114 @@
|
||||
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"),
|
||||
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("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;
|
||||
82
src/actions/drift/tradePerpAccount.ts
Normal file
82
src/actions/drift/tradePerpAccount.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
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(),
|
||||
symbol: z
|
||||
.string()
|
||||
.toUpperCase()
|
||||
.describe("Symbol of the token to open a position on "),
|
||||
action: z.enum(["long", "short"]),
|
||||
type: z.enum(["market", "limit"]),
|
||||
price: z.number().positive().optional(),
|
||||
}),
|
||||
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;
|
||||
53
src/actions/drift/updateDriftVaultDelegate.ts
Normal file
53
src/actions/drift/updateDriftVaultDelegate.ts
Normal 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(),
|
||||
newDelegate: z.string(),
|
||||
}),
|
||||
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;
|
||||
87
src/actions/drift/updateVault.ts
Normal file
87
src/actions/drift/updateVault.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
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")
|
||||
.optional(),
|
||||
maxTokens: z
|
||||
.number()
|
||||
.int()
|
||||
.min(100, "Max tokens must be at least 100")
|
||||
.optional(),
|
||||
minDepositAmount: z.number().positive().optional(),
|
||||
managementFee: z.number().positive().max(20).optional(),
|
||||
profitShare: z.number().positive().max(90).optional(),
|
||||
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;
|
||||
57
src/actions/drift/vaultInfo.ts
Normal file
57
src/actions/drift/vaultInfo.ts
Normal 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;
|
||||
77
src/actions/drift/withdrawFromDriftAccount.ts
Normal file
77
src/actions/drift/withdrawFromDriftAccount.ts
Normal 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",
|
||||
),
|
||||
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;
|
||||
52
src/actions/drift/withdrawFromVault.ts
Normal file
52
src/actions/drift/withdrawFromVault.ts
Normal 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(),
|
||||
}),
|
||||
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;
|
||||
57
src/actions/helius/createWebhook.ts
Normal file
57
src/actions/helius/createWebhook.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { create_HeliusWebhook } from "../../tools/helius";
|
||||
|
||||
const createWebhookAction: Action = {
|
||||
name: "CREATE_HELIOUS_WEBHOOK",
|
||||
similes: ["setup webhook", "register webhook", "initiate webhook"],
|
||||
description:
|
||||
"Creates a new webhook in the Helius system to monitor transactions for specified account addresses",
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
accountAddresses: [
|
||||
"BVdNLvyG2DNiWAXBE9qAmc4MTQXymd5Bzfo9xrQSUzVP",
|
||||
"Eo2ciguhMLmcTWXELuEQPdu7DWZt67LHXb2rdHZUbot7",
|
||||
],
|
||||
webhookURL: "https://yourdomain.com/webhook",
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
webhookURL: "https://yourdomain.com/webhook",
|
||||
webhookID: "webhook_123",
|
||||
message: "Webhook created successfully.",
|
||||
},
|
||||
explanation:
|
||||
"Creates a Webhook to send live notifications on the given Url with the wallet Addresses.",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
accountAddresses: z
|
||||
.array(z.string())
|
||||
.min(1)
|
||||
.describe("List of Solana account public keys to monitor"),
|
||||
webhookURL: z
|
||||
.string()
|
||||
.url()
|
||||
.describe("The URL where Helius will send webhook notifications"),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const response = await create_HeliusWebhook(
|
||||
agent,
|
||||
input.accountAddresses,
|
||||
input.webhookURL,
|
||||
);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
...response,
|
||||
message: "Webhook created successfully.",
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default createWebhookAction;
|
||||
40
src/actions/helius/deleteWebhook.ts
Normal file
40
src/actions/helius/deleteWebhook.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { deleteHeliusWebhook } from "../../tools/helius";
|
||||
|
||||
const deleteWebhookAction: Action = {
|
||||
name: "DELETE_HELIOUS_WEBHOOK",
|
||||
similes: ["remove webhook", "unregister webhook", "delete webhook"],
|
||||
description: "Deletes a Helius webhook by its unique ID",
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
webhookID: "webhook_123",
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Webhook deleted successfully.",
|
||||
},
|
||||
explanation: "Permanently removes a Helius webhook.",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
webhookID: z
|
||||
.string()
|
||||
.min(1)
|
||||
.describe("The unique identifier of the Helius webhook to delete"),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const result = await deleteHeliusWebhook(agent, input.webhookID);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: result.message || "Webhook deleted successfully.",
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default deleteWebhookAction;
|
||||
75
src/actions/helius/getAssetsbyOwner.ts
Normal file
75
src/actions/helius/getAssetsbyOwner.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { getAssetsByOwner } from "../../tools/helius";
|
||||
|
||||
const getAssetsByOwnerAction: Action = {
|
||||
name: "FETCH_ASSETS_BY_OWNER",
|
||||
similes: [
|
||||
"fetch assets",
|
||||
"get assets",
|
||||
"retrieve assets",
|
||||
"list assets",
|
||||
"assets by owner",
|
||||
],
|
||||
description:
|
||||
"Fetch assets owned by a specific Solana wallet address using the Helius Digital Asset Standard API",
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
ownerPublicKey: "4Pf8q3mHGLdkoc1M8xWZwW5q32gYmdhwC2gJ8K9EAGDX",
|
||||
limit: 10,
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
assets: [
|
||||
{
|
||||
name: "Helius NFT #1",
|
||||
type: "NFT",
|
||||
owner: "4Pf8q3mHGLdkoc1M8xWZwW5q32gYmdhwC2gJ8K9EAGDX",
|
||||
},
|
||||
{
|
||||
name: "Helius Token #10",
|
||||
type: "Token",
|
||||
owner: "4Pf8q3mHGLdkoc1M8xWZwW5q32gYmdhwC2gJ8K9EAGDX",
|
||||
},
|
||||
],
|
||||
message: "Successfully fetched assets for the wallet address",
|
||||
},
|
||||
explanation:
|
||||
"Fetches a list of assets from the for the given wallet address with a limit of 10 items.",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
ownerPublicKey: z.string().describe("Owner's Solana wallet PublicKey"),
|
||||
limit: z
|
||||
.number()
|
||||
.positive()
|
||||
.describe("Number of assets to retrieve per request"),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
try {
|
||||
const assets = await getAssetsByOwner(
|
||||
agent,
|
||||
new PublicKey(input.ownerPublicKey),
|
||||
input.limit,
|
||||
);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
assets: assets,
|
||||
message: `Successfully fetched assets for the wallet address: ${input.ownerPublicKey}`,
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
status: "error",
|
||||
message: `Failed to fetch assets: ${error.message}`,
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default getAssetsByOwnerAction;
|
||||
47
src/actions/helius/getWebhook.ts
Normal file
47
src/actions/helius/getWebhook.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { getHeliusWebhook } from "../../tools/helius";
|
||||
|
||||
const getWebhookAction: Action = {
|
||||
name: "GET_HELIOUS_WEBHOOK",
|
||||
similes: ["fetch webhook details", "retrieve webhook", "get webhook info"],
|
||||
description: "Retrieves details of a Helius webhook by its unique ID",
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
webhookID: "webhook_123",
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
wallet: "WalletPublicKey",
|
||||
webhookURL: "https://yourdomain.com/webhook",
|
||||
transactionTypes: ["Any"],
|
||||
accountAddresses: ["SomePublicKey", "AnotherPublicKey"],
|
||||
webhookType: "enhanced",
|
||||
message: "Webhook details retrieved successfully.",
|
||||
},
|
||||
explanation:
|
||||
"Retrieves detailed information about an existing Helius webhook, including the wallet address it monitors, the types of transactions it tracks, and the specific webhook URL.",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
webhookID: z
|
||||
.string()
|
||||
.min(1)
|
||||
.describe("The unique identifier of the Helius webhook to retrieve"),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const webhookDetails = await getHeliusWebhook(agent, input.webhookID);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
...webhookDetails,
|
||||
message: "Webhook details retrieved successfully.",
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default getWebhookAction;
|
||||
65
src/actions/helius/parseTransaction.ts
Normal file
65
src/actions/helius/parseTransaction.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { parseTransaction } from "../../tools/helius";
|
||||
|
||||
const parseSolanaTransactionAction: Action = {
|
||||
name: "PARSE_SOLANA_TRANSACTION",
|
||||
similes: [
|
||||
"parse transaction",
|
||||
"analyze transaction",
|
||||
"inspect transaction",
|
||||
"decode transaction",
|
||||
],
|
||||
description:
|
||||
"Parse a Solana transaction to retrieve detailed information using the Helius Enhanced Transactions API",
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
transactionId:
|
||||
"4zZVvbgzcriyjAeEiK1w7CeDCt7gYThUCZat3ULTNerzKHF4WLfRG2YUjbRovfFJ639TAyARB4oyRDcLVUvrakq7",
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
transaction: {
|
||||
details: "Transaction details...",
|
||||
involvedAccounts: ["Account1", "Account2"],
|
||||
executedOperations: [{ operation: "Transfer", amount: "1000 SOL" }],
|
||||
},
|
||||
message:
|
||||
"Successfully parsed transaction: 4zZVvbgzcriyjAeEiK1w7CeDCt7gYThUCZat3ULTNerzKHF4WLfRG2YUjbRovfFJ639TAyARB4oyRDcLVUvrakq7",
|
||||
},
|
||||
explanation:
|
||||
"Parse a Transaction to transform it into human readable format.",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
transactionId: z
|
||||
.string()
|
||||
.min(1)
|
||||
.describe("The Solana transaction ID to parse"),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
try {
|
||||
const parsedTransactionData = await parseTransaction(
|
||||
agent,
|
||||
input.transactionId,
|
||||
);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
transaction: parsedTransactionData,
|
||||
message: `Successfully parsed transaction: ${input.transactionId}`,
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
status: "error",
|
||||
message: `Failed to parse transaction: ${error.message}`,
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default parseSolanaTransactionAction;
|
||||
76
src/actions/helius/sendTransactionWithPriority.ts
Normal file
76
src/actions/helius/sendTransactionWithPriority.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { sendTransactionWithPriorityFee } from "../../tools/helius";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
|
||||
const sendTransactionWithPriorityFeeAction: Action = {
|
||||
name: "SEND_TRANSACTION_WITH_PRIORITY_FEE",
|
||||
similes: [
|
||||
"send SOL with fee",
|
||||
"transfer tokens with priority",
|
||||
"execute priority transaction",
|
||||
],
|
||||
description:
|
||||
"Sends SOL or SPL tokens from a wallet with an estimated priority fee, ensuring faster processing on the Solana network.",
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
priorityLevel: "High",
|
||||
amount: 2,
|
||||
to: "BVdNLvyG2DNiWAXBE9qAmc4MTQXymd5Bzfo9xrQSUzVP",
|
||||
splmintAddress: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
transactionId: "5Xgq9xVABhwXpNStWpfqxS6Vm5Eau91pjfeHNwJbRgis",
|
||||
fee: 5000,
|
||||
message: "Transaction sent with priority fee successfully.",
|
||||
},
|
||||
explanation:
|
||||
"Sends 2 USDC to BVdNLvyG2DNiWAXBE9qAmc4MTQXymd5Bzfo9xrQSUzVP with High priority fee option.",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
priorityLevel: z
|
||||
.enum(["Min", "Low", "Medium", "High", "VeryHigh", "UnsafeMax"])
|
||||
.describe("Priority level to determine the urgency of the transaction."),
|
||||
amount: z
|
||||
.number()
|
||||
.positive()
|
||||
.describe("Amount of SOL or SPL tokens to send."),
|
||||
to: z.string().describe("Recipient's PublicKey."),
|
||||
splmintAddress: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
"Optional SPL token address, if transferring tokens other than SOL.",
|
||||
),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const { priorityLevel, amount, to, splmintAddress } = input;
|
||||
const toPublicKey = new PublicKey(to);
|
||||
const splmintPublicKey = splmintAddress
|
||||
? new PublicKey(splmintAddress)
|
||||
: undefined;
|
||||
|
||||
const result = await sendTransactionWithPriorityFee(
|
||||
agent,
|
||||
priorityLevel,
|
||||
amount,
|
||||
toPublicKey,
|
||||
splmintPublicKey,
|
||||
);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
transactionId: result.transactionId,
|
||||
fee: result.fee,
|
||||
message: "Transaction sent with priority fee successfully.",
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default sendTransactionWithPriorityFeeAction;
|
||||
@@ -1,3 +1,4 @@
|
||||
import tokenBalancesAction from "./tokenBalances";
|
||||
import deployTokenAction from "./metaplex/deployToken";
|
||||
import balanceAction from "./solana/balance";
|
||||
import transferAction from "./solana/transfer";
|
||||
@@ -32,9 +33,41 @@ import launchPumpfunTokenAction from "./pumpfun/launchPumpfunToken";
|
||||
import getWalletAddressAction from "./agent/getWalletAddress";
|
||||
import flashOpenTradeAction from "./flash/flashOpenTrade";
|
||||
import flashCloseTradeAction from "./flash/flashCloseTrade";
|
||||
import createMultisigAction from "./squads/createMultisig";
|
||||
import approveMultisigProposalAction from "./squads/approveMultisigProposal";
|
||||
import createMultisigProposalAction from "./squads/createMultisigProposal";
|
||||
import depositToMultisigAction from "./squads/depositToMultisigTreasury";
|
||||
import executeMultisigProposalAction from "./squads/executeMultisigProposal";
|
||||
import rejectMultisigProposalAction from "./squads/rejectMultisigProposal";
|
||||
import transferFromMultisigAction from "./squads/transferFromMultisigTreasury";
|
||||
import createWebhookAction from "./helius/createWebhook";
|
||||
import deleteWebhookAction from "./helius/deleteWebhook";
|
||||
import getAssetsByOwnerAction from "./helius/getAssetsbyOwner";
|
||||
import getWebhookAction from "./helius/getWebhook";
|
||||
import parseSolanaTransactionAction from "./helius/parseTransaction";
|
||||
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 getVoltrPositionValuesAction from "./voltr/getPositionValues";
|
||||
import depositVoltrStrategyAction from "./voltr/depositStrategy";
|
||||
import withdrawVoltrStrategyAction from "./voltr/withdrawStrategy";
|
||||
|
||||
export const ACTIONS = {
|
||||
WALLET_ADDRESS_ACTION: getWalletAddressAction,
|
||||
TOKEN_BALANCES_ACTION: tokenBalancesAction,
|
||||
DEPLOY_TOKEN_ACTION: deployTokenAction,
|
||||
BALANCE_ACTION: balanceAction,
|
||||
TRANSFER_ACTION: transferAction,
|
||||
@@ -69,6 +102,37 @@ export const ACTIONS = {
|
||||
LAUNCH_PUMPFUN_TOKEN_ACTION: launchPumpfunTokenAction,
|
||||
FLASH_OPEN_TRADE_ACTION: flashOpenTradeAction,
|
||||
FLASH_CLOSE_TRADE_ACTION: flashCloseTradeAction,
|
||||
CREATE_MULTISIG_ACTION: createMultisigAction,
|
||||
DEPOSIT_TO_MULTISIG_ACTION: depositToMultisigAction,
|
||||
TRANSFER_FROM_MULTISIG_ACTION: transferFromMultisigAction,
|
||||
CREATE_MULTISIG_PROPOSAL_ACTION: createMultisigProposalAction,
|
||||
APPROVE_MULTISIG_PROPOSAL_ACTION: approveMultisigProposalAction,
|
||||
REJECT_MULTISIG_PROPOSAL_ACTION: rejectMultisigProposalAction,
|
||||
EXECUTE_MULTISIG_PROPOSAL_ACTION: executeMultisigProposalAction,
|
||||
CREATE_WEBHOOK_ACTION: createWebhookAction,
|
||||
DELETE_WEBHOOK_ACTION: deleteWebhookAction,
|
||||
GET_ASSETS_BY_OWNER_ACTION: getAssetsByOwnerAction,
|
||||
GET_WEBHOOK_ACTION: getWebhookAction,
|
||||
PARSE_TRANSACTION_ACTION: parseSolanaTransactionAction,
|
||||
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,
|
||||
GET_VOLTR_POSITION_VALUES_ACTION: getVoltrPositionValuesAction,
|
||||
DEPOSIT_VOLTR_STRATEGY_ACTION: depositVoltrStrategyAction,
|
||||
WITHDRAW_VOLTR_STRATEGY_ACTION: withdrawVoltrStrategyAction,
|
||||
};
|
||||
|
||||
export type { Action, ActionExample, Handler } from "../types/action";
|
||||
|
||||
@@ -13,7 +13,7 @@ const mintNFTAction: Action = {
|
||||
"create token",
|
||||
"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: [
|
||||
[
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import type { Action } from "../../types/action";
|
||||
import type { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { get_balance } from "../../tools";
|
||||
|
||||
|
||||
50
src/actions/squads/approveMultisigProposal.ts
Normal file
50
src/actions/squads/approveMultisigProposal.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { multisig_approve_proposal } from "../../tools";
|
||||
|
||||
const approveMultisigProposalAction: Action = {
|
||||
name: "APPROVE_MULTISIG_PROPOSAL_ACTION",
|
||||
similes: [
|
||||
"approve proposal",
|
||||
"approve proposal to transfer funds",
|
||||
"approve proposal to transfer funds from 2-of-2 multisig",
|
||||
"approve proposal to transfer funds from 2-of-2 multisig account",
|
||||
"approve proposal to transfer funds from 2-of-2 multisig account on Solana",
|
||||
],
|
||||
description: `Approve a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions.
|
||||
|
||||
Note: For one AI agent, only one 2-by-2 multisig can be created as it is pair-wise.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
transactionIndex: 0,
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Proposal approved successfully",
|
||||
transaction: "4xKpN2...",
|
||||
transactionIndex: "0",
|
||||
},
|
||||
explanation:
|
||||
"Approve a proposal to transfer 1 SOL from 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
transactionIndex: z.number().optional(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const tx = await multisig_approve_proposal(agent, input.transactionIndex);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "Proposal approved successfully",
|
||||
transaction: tx,
|
||||
transactionIndex: input.transactionIndex.toString(),
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default approveMultisigProposalAction;
|
||||
52
src/actions/squads/createMultisig.ts
Normal file
52
src/actions/squads/createMultisig.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { create_squads_multisig } from "../../tools";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
|
||||
const createMultisigAction: Action = {
|
||||
name: "CREATE_MULTISIG_ACTION",
|
||||
similes: [
|
||||
"create multisig",
|
||||
"create squads multisig",
|
||||
"create 2-by-2 multisig",
|
||||
"create 2-of-2 multisig",
|
||||
"create 2-of-2 multisig account",
|
||||
"create 2-of-2 multisig account on Solana",
|
||||
],
|
||||
description: `Create a 2-of-2 multisig account on Solana using Squads with the user and the agent, where both approvals will be required to run the transactions.
|
||||
|
||||
Note: For one AI agent, only one 2-by-2 multisig can be created as it is pair-wise.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
creator: "7nE9GvcwsqzYxmJLSrYmSB1V1YoJWVK1KWzAcWAzjXkN",
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "2-by-2 multisig account created successfully",
|
||||
signature: "4xKpN2...",
|
||||
},
|
||||
explanation: "Create a 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
creator: z.string(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const multisig = await create_squads_multisig(
|
||||
agent,
|
||||
new PublicKey(input.creator as string),
|
||||
);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "2-by-2 multisig account created successfully",
|
||||
signature: multisig,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default createMultisigAction;
|
||||
55
src/actions/squads/createMultisigProposal.ts
Normal file
55
src/actions/squads/createMultisigProposal.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { multisig_create_proposal } from "../../tools";
|
||||
|
||||
const createMultisigProposalAction: Action = {
|
||||
name: "CREATE_MULTISIG_PROPOSAL_ACTION",
|
||||
similes: [
|
||||
"create proposal",
|
||||
"create proposal to transfer funds",
|
||||
"create proposal to transfer funds from 2-of-2 multisig",
|
||||
"create proposal to transfer funds from 2-of-2 multisig account",
|
||||
"create proposal to transfer funds from 2-of-2 multisig account on Solana",
|
||||
],
|
||||
description: `Create a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions.
|
||||
|
||||
If transactionIndex is not provided, the latest index will automatically be fetched and used.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
transactionIndex: 0,
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Proposal created successfully",
|
||||
transaction: "4xKpN2...",
|
||||
transactionIndex: "0",
|
||||
},
|
||||
explanation:
|
||||
"Create a proposal to transfer 1 SOL from 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
transactionIndex: z.number().optional(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const transactionIndex =
|
||||
input.transactionIndex !== undefined
|
||||
? Number(input.transactionIndex)
|
||||
: undefined;
|
||||
|
||||
const multisig = await multisig_create_proposal(agent, transactionIndex);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "Proposal created successfully",
|
||||
transaction: multisig,
|
||||
transactionIndex: transactionIndex,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default createMultisigProposalAction;
|
||||
49
src/actions/squads/depositToMultisigTreasury.ts
Normal file
49
src/actions/squads/depositToMultisigTreasury.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { multisig_deposit_to_treasury } from "../../tools";
|
||||
|
||||
const depositToMultisigAction: Action = {
|
||||
name: "DEPOSIT_TO_MULTISIG_ACTION",
|
||||
similes: [
|
||||
"deposit to multisig",
|
||||
"deposit to squads multisig",
|
||||
"deposit to 2-of-2 multisig account",
|
||||
"deposit to 2-of-2 multisig account on Solana",
|
||||
"deposit SOL to 2-of-2 multisig",
|
||||
"deposit SPL tokens to 2-of-2 multisig",
|
||||
],
|
||||
description: `Deposit funds to a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
amount: 1,
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Funds deposited to 2-by-2 multisig account successfully",
|
||||
signature: "4xKpN2...",
|
||||
},
|
||||
explanation: "Deposit 1 SOL to 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
amount: z.number().min(0, "Amount must be greater than 0"),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const multisig = await multisig_deposit_to_treasury(
|
||||
agent,
|
||||
input.amount as number,
|
||||
);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "Funds deposited to 2-by-2 multisig account successfully",
|
||||
signature: multisig,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default depositToMultisigAction;
|
||||
53
src/actions/squads/executeMultisigProposal.ts
Normal file
53
src/actions/squads/executeMultisigProposal.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { multisig_execute_proposal } from "../../tools";
|
||||
|
||||
const executeMultisigProposalAction: Action = {
|
||||
name: "EXECUTE_MULTISIG_PROPOSAL_ACTION",
|
||||
similes: [
|
||||
"execute proposal",
|
||||
"execute proposal to transfer funds",
|
||||
"execute proposal to transfer funds from 2-of-2 multisig",
|
||||
"execute proposal to transfer funds from 2-of-2 multisig account",
|
||||
"execute proposal to transfer funds from 2-of-2 multisig account on Solana",
|
||||
],
|
||||
description: `Execute a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
proposalIndex: 0,
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Proposal executed successfully",
|
||||
transaction: "4xKpN2...",
|
||||
proposalIndex: "0",
|
||||
},
|
||||
explanation:
|
||||
"Execute a proposal to transfer 1 SOL from 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
proposalIndex: z.number().optional(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const proposalIndex =
|
||||
input.proposalIndex !== undefined
|
||||
? Number(input.proposalIndex)
|
||||
: undefined;
|
||||
|
||||
const multisig = await multisig_execute_proposal(agent, proposalIndex);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "Proposal executed successfully",
|
||||
transaction: multisig,
|
||||
proposalIndex,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default executeMultisigProposalAction;
|
||||
53
src/actions/squads/rejectMultisigProposal.ts
Normal file
53
src/actions/squads/rejectMultisigProposal.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { multisig_reject_proposal } from "../../tools";
|
||||
|
||||
const rejectMultisigProposalAction: Action = {
|
||||
name: "REJECT_MULTISIG_PROPOSAL_ACTION",
|
||||
similes: [
|
||||
"reject proposal",
|
||||
"reject proposal to transfer funds",
|
||||
"reject proposal to transfer funds from 2-of-2 multisig",
|
||||
"reject proposal to transfer funds from 2-of-2 multisig account",
|
||||
"reject proposal to transfer funds from 2-of-2 multisig account on Solana",
|
||||
],
|
||||
description: `Reject a proposal to transfer funds from a 2-of-2 multisig account on Solana with the user and the agent, where both approvals will be required to run the transactions.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
proposalIndex: 0,
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Proposal rejected successfully",
|
||||
transaction: "4xKpN2...",
|
||||
proposalIndex: "0",
|
||||
},
|
||||
explanation:
|
||||
"Reject a proposal to transfer 1 SOL from 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
proposalIndex: z.number().optional(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const proposalIndex =
|
||||
input.proposalIndex !== undefined
|
||||
? Number(input.proposalIndex)
|
||||
: undefined;
|
||||
|
||||
const tx = await multisig_reject_proposal(agent, proposalIndex);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "Proposal rejected successfully",
|
||||
transaction: tx,
|
||||
proposalIndex,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default rejectMultisigProposalAction;
|
||||
56
src/actions/squads/transferFromMultisigTreasury.ts
Normal file
56
src/actions/squads/transferFromMultisigTreasury.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { Action } from "../../types/action";
|
||||
import { SolanaAgentKit } from "../../agent";
|
||||
import { z } from "zod";
|
||||
import { multisig_transfer_from_treasury } from "../../tools";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
|
||||
const transferFromMultisigAction: Action = {
|
||||
name: "TRANSFER_FROM_MULTISIG_ACTION",
|
||||
similes: [
|
||||
"transfer from multisig",
|
||||
"transfer from squads multisig",
|
||||
"transfer SOL from 2-by-2 multisig",
|
||||
"transfer from 2-of-2 multisig account",
|
||||
"transfer from 2-of-2 multisig account on Solana",
|
||||
],
|
||||
description: `Create a transaction to transfer funds from a 2-of-2 multisig account on Solana using Squads with the user and the agent, where both approvals will be required to run the transactions.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
amount: 1,
|
||||
recipient: "7nE9GvcwsqzYxmJLSrYmSB1V1YoJWVK1KWzAcWAzjXkN",
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "Transaction added to 2-by-2 multisig account successfully",
|
||||
transaction: "4xKpN2...",
|
||||
amount: "1",
|
||||
recipient: "7nE9GvcwsqzYxmJLSrYmSB1V1YoJWVK1KWzAcWAzjXkN",
|
||||
},
|
||||
explanation: "Transfer 1 SOL from 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
amount: z.number().min(0, "Amount must be greater than 0"),
|
||||
recipient: z.string(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const multisig = await multisig_transfer_from_treasury(
|
||||
agent,
|
||||
input.amount as number,
|
||||
new PublicKey(input.recipient as string),
|
||||
);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "Transaction added to 2-by-2 multisig account successfully",
|
||||
transaction: multisig,
|
||||
amount: input.amount,
|
||||
recipient: input.recipient,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default transferFromMultisigAction;
|
||||
80
src/actions/tokenBalances.ts
Normal file
80
src/actions/tokenBalances.ts
Normal 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;
|
||||
83
src/actions/voltr/depositStrategy.ts
Normal file
83
src/actions/voltr/depositStrategy.ts
Normal 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;
|
||||
74
src/actions/voltr/getPositionValues.ts
Normal file
74
src/actions/voltr/getPositionValues.ts
Normal 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;
|
||||
83
src/actions/voltr/withdrawStrategy.ts
Normal file
83
src/actions/voltr/withdrawStrategy.ts
Normal 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;
|
||||
@@ -2,8 +2,12 @@ import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
||||
import { BN } from "@coral-xyz/anchor";
|
||||
import bs58 from "bs58";
|
||||
import Decimal from "decimal.js";
|
||||
import {
|
||||
CreateCollectionOptions,
|
||||
CreateSingleOptions,
|
||||
StoreInitOptions,
|
||||
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
|
||||
import { DEFAULT_OPTIONS } from "../constants";
|
||||
import { Config, TokenCheck } from "../types";
|
||||
import {
|
||||
deploy_collection,
|
||||
deploy_token,
|
||||
@@ -65,8 +69,44 @@ import {
|
||||
fetchPythPriceFeedID,
|
||||
flashOpenTrade,
|
||||
flashCloseTrade,
|
||||
} from "../tools/";
|
||||
createCollection,
|
||||
createSingle,
|
||||
multisig_transfer_from_treasury,
|
||||
create_squads_multisig,
|
||||
multisig_create_proposal,
|
||||
multisig_deposit_to_treasury,
|
||||
multisig_reject_proposal,
|
||||
multisig_approve_proposal,
|
||||
multisig_execute_proposal,
|
||||
parseTransaction,
|
||||
sendTransactionWithPriorityFee,
|
||||
getAssetsByOwner,
|
||||
getHeliusWebhook,
|
||||
create_HeliusWebhook,
|
||||
deleteHeliusWebhook,
|
||||
createDriftUserAccount,
|
||||
createVault,
|
||||
depositIntoVault,
|
||||
depositToDriftUserAccount,
|
||||
getVaultAddress,
|
||||
doesUserHaveDriftAccount,
|
||||
driftUserAccountInfo,
|
||||
requestWithdrawalFromVault,
|
||||
tradeDriftVault,
|
||||
driftPerpTrade,
|
||||
updateVault,
|
||||
getVaultInfo,
|
||||
withdrawFromDriftUserAccount,
|
||||
withdrawFromDriftVault,
|
||||
updateVaultDelegate,
|
||||
get_token_balance,
|
||||
voltrGetPositionValues,
|
||||
voltrDepositStrategy,
|
||||
voltrWithdrawStrategy,
|
||||
} from "../tools";
|
||||
import {
|
||||
Config,
|
||||
TokenCheck,
|
||||
CollectionDeployment,
|
||||
CollectionOptions,
|
||||
GibworkCreateTaskReponse,
|
||||
@@ -77,23 +117,9 @@ import {
|
||||
OrderParams,
|
||||
FlashTradeParams,
|
||||
FlashCloseTradeParams,
|
||||
HeliusWebhookIdResponse,
|
||||
HeliusWebhookResponse,
|
||||
} from "../types";
|
||||
import {
|
||||
createCollection,
|
||||
createSingle,
|
||||
} from "../tools/3land/create_3land_collectible";
|
||||
import {
|
||||
CreateCollectionOptions,
|
||||
CreateSingleOptions,
|
||||
StoreInitOptions,
|
||||
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
|
||||
import { create_squads_multisig } from "../tools/squads_multisig/create_multisig";
|
||||
import { deposit_to_multisig } from "../tools/squads_multisig/deposit_to_multisig";
|
||||
import { transfer_from_multisig } from "../tools/squads_multisig/transfer_from_multisig";
|
||||
import { create_proposal } from "../tools/squads_multisig/create_proposal";
|
||||
import { approve_proposal } from "../tools/squads_multisig/approve_proposal";
|
||||
import { execute_transaction } from "../tools/squads_multisig/execute_proposal";
|
||||
import { reject_proposal } from "../tools/squads_multisig/reject_proposal";
|
||||
|
||||
/**
|
||||
* Main class for interacting with Solana blockchain
|
||||
@@ -169,6 +195,19 @@ export class SolanaAgentKit {
|
||||
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(
|
||||
walletAddress: PublicKey,
|
||||
tokenAddress?: PublicKey,
|
||||
@@ -597,29 +636,68 @@ export class SolanaAgentKit {
|
||||
async flashCloseTrade(params: FlashCloseTradeParams): Promise<string> {
|
||||
return flashCloseTrade(this, params);
|
||||
}
|
||||
async heliusParseTransactions(transactionId: string): Promise<any> {
|
||||
return parseTransaction(this, transactionId);
|
||||
}
|
||||
async getAllAssetsbyOwner(owner: PublicKey, limit: number): Promise<any> {
|
||||
return getAssetsByOwner(this, owner, limit);
|
||||
}
|
||||
|
||||
async create3LandCollection(
|
||||
optionsWithBase58: StoreInitOptions,
|
||||
collectionOpts: CreateCollectionOptions,
|
||||
isDevnet: boolean = false,
|
||||
): Promise<string> {
|
||||
let optionsWithBase58: StoreInitOptions = {
|
||||
privateKey: this.wallet.secretKey,
|
||||
};
|
||||
if (isDevnet) {
|
||||
optionsWithBase58.isMainnet = false;
|
||||
} else {
|
||||
optionsWithBase58.isMainnet = true;
|
||||
}
|
||||
|
||||
const tx = await createCollection(optionsWithBase58, collectionOpts);
|
||||
return `Transaction: ${tx}`;
|
||||
}
|
||||
|
||||
async create3LandNft(
|
||||
optionsWithBase58: StoreInitOptions,
|
||||
collectionAccount: string,
|
||||
createItemOptions: CreateSingleOptions,
|
||||
isMainnet: boolean,
|
||||
isDevnet: boolean = false,
|
||||
withPool: boolean = false,
|
||||
): Promise<string> {
|
||||
let optionsWithBase58: StoreInitOptions = {
|
||||
privateKey: this.wallet.secretKey,
|
||||
};
|
||||
if (isDevnet) {
|
||||
optionsWithBase58.isMainnet = false;
|
||||
} else {
|
||||
optionsWithBase58.isMainnet = true;
|
||||
}
|
||||
|
||||
const tx = await createSingle(
|
||||
optionsWithBase58,
|
||||
collectionAccount,
|
||||
createItemOptions,
|
||||
isMainnet,
|
||||
!isDevnet,
|
||||
withPool,
|
||||
);
|
||||
return `Transaction: ${tx}`;
|
||||
}
|
||||
async sendTranctionWithPriority(
|
||||
priorityLevel: string,
|
||||
amount: number,
|
||||
to: PublicKey,
|
||||
splmintAddress?: PublicKey,
|
||||
): Promise<{ transactionId: string; fee: number }> {
|
||||
return sendTransactionWithPriorityFee(
|
||||
this,
|
||||
priorityLevel,
|
||||
amount,
|
||||
to,
|
||||
splmintAddress,
|
||||
);
|
||||
}
|
||||
|
||||
async createSquadsMultisig(creator: PublicKey): Promise<string> {
|
||||
return create_squads_multisig(this, creator);
|
||||
@@ -630,7 +708,7 @@ export class SolanaAgentKit {
|
||||
vaultIndex: number = 0,
|
||||
mint?: PublicKey,
|
||||
): Promise<string> {
|
||||
return deposit_to_multisig(this, amount, vaultIndex, mint);
|
||||
return multisig_deposit_to_treasury(this, amount, vaultIndex, mint);
|
||||
}
|
||||
|
||||
async transferFromMultisig(
|
||||
@@ -639,30 +717,160 @@ export class SolanaAgentKit {
|
||||
vaultIndex: number = 0,
|
||||
mint?: PublicKey,
|
||||
): Promise<string> {
|
||||
return transfer_from_multisig(this, amount, to, vaultIndex, mint);
|
||||
return multisig_transfer_from_treasury(this, amount, to, vaultIndex, mint);
|
||||
}
|
||||
|
||||
async createMultisigProposal(
|
||||
transactionIndex?: number | bigint,
|
||||
): Promise<string> {
|
||||
return create_proposal(this, transactionIndex);
|
||||
return multisig_create_proposal(this, transactionIndex);
|
||||
}
|
||||
|
||||
async approveMultisigProposal(
|
||||
transactionIndex?: number | bigint,
|
||||
): Promise<string> {
|
||||
return approve_proposal(this, transactionIndex);
|
||||
return multisig_approve_proposal(this, transactionIndex);
|
||||
}
|
||||
|
||||
async rejectMultisigProposal(
|
||||
transactionIndex?: number | bigint,
|
||||
): Promise<string> {
|
||||
return reject_proposal(this, transactionIndex);
|
||||
return multisig_reject_proposal(this, transactionIndex);
|
||||
}
|
||||
|
||||
async executeMultisigTransaction(
|
||||
transactionIndex?: number | bigint,
|
||||
): Promise<string> {
|
||||
return execute_transaction(this, transactionIndex);
|
||||
return multisig_execute_proposal(this, transactionIndex);
|
||||
}
|
||||
async CreateWebhook(
|
||||
accountAddresses: string[],
|
||||
webhookURL: string,
|
||||
): Promise<HeliusWebhookResponse> {
|
||||
return create_HeliusWebhook(this, accountAddresses, webhookURL);
|
||||
}
|
||||
async getWebhook(id: string): Promise<HeliusWebhookIdResponse> {
|
||||
return getHeliusWebhook(this, id);
|
||||
}
|
||||
async deleteWebhook(webhookID: string): Promise<any> {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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})
|
||||
|
||||
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
|
||||
collectionSymbol (required): the symbol 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> {
|
||||
try {
|
||||
const inputFormat = JSON.parse(input);
|
||||
const privateKey = inputFormat.privateKey;
|
||||
const isMainnet = inputFormat.isMainnet;
|
||||
|
||||
const optionsWithBase58: StoreInitOptions = {
|
||||
...(privateKey && { privateKey }),
|
||||
...(isMainnet && { isMainnet }),
|
||||
};
|
||||
|
||||
const collectionSymbol = inputFormat?.collectionSymbol;
|
||||
const collectionName = inputFormat?.collectionName;
|
||||
const collectionDescription = inputFormat?.collectionDescription;
|
||||
@@ -49,8 +42,8 @@ export class Solana3LandCreateCollection extends Tool {
|
||||
};
|
||||
|
||||
const tx = await this.solanaKit.create3LandCollection(
|
||||
optionsWithBase58,
|
||||
collectionOpts,
|
||||
!isMainnet,
|
||||
);
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
|
||||
@@ -10,7 +10,6 @@ export class Solana3LandCreateSingle extends Tool {
|
||||
description = `Creates an NFT and lists it on 3.land's website
|
||||
|
||||
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
|
||||
itemName (required): the name of the NFT
|
||||
sellerFee (required): the fee of the seller
|
||||
@@ -21,7 +20,9 @@ export class Solana3LandCreateSingle extends Tool {
|
||||
mainImageUrl (required): the main 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
|
||||
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) {
|
||||
@@ -31,13 +32,9 @@ export class Solana3LandCreateSingle extends Tool {
|
||||
protected async _call(input: string): Promise<string> {
|
||||
try {
|
||||
const inputFormat = JSON.parse(input);
|
||||
const privateKey = inputFormat.privateKey;
|
||||
const isMainnet = inputFormat.isMainnet;
|
||||
|
||||
const optionsWithBase58: StoreInitOptions = {
|
||||
...(privateKey && { privateKey }),
|
||||
...(isMainnet && { isMainnet }),
|
||||
};
|
||||
const withPool = inputFormat.withPool;
|
||||
const poolName = inputFormat.poolName;
|
||||
|
||||
const collectionAccount = inputFormat.collectionAccount;
|
||||
|
||||
@@ -52,6 +49,15 @@ export class Solana3LandCreateSingle extends Tool {
|
||||
const coverImageUrl = inputFormat?.coverImageUrl;
|
||||
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 = {
|
||||
...(itemName && { itemName }),
|
||||
...(sellerFee && { sellerFee }),
|
||||
@@ -63,6 +69,7 @@ export class Solana3LandCreateSingle extends Tool {
|
||||
...(mainImageUrl && { mainImageUrl }),
|
||||
...(coverImageUrl && { coverImageUrl }),
|
||||
...(splHash && { splHash }),
|
||||
...(poolName && { poolName }),
|
||||
};
|
||||
|
||||
if (!collectionAccount) {
|
||||
@@ -70,10 +77,10 @@ export class Solana3LandCreateSingle extends Tool {
|
||||
}
|
||||
|
||||
const tx = await this.solanaKit.create3LandNft(
|
||||
optionsWithBase58,
|
||||
collectionAccount,
|
||||
createItemOptions,
|
||||
isMainnet,
|
||||
!isMainnet,
|
||||
withPool,
|
||||
);
|
||||
return JSON.stringify({
|
||||
status: "success",
|
||||
|
||||
38
src/langchain/drift/create_user_account.ts
Normal file
38
src/langchain/drift/create_user_account.ts
Normal 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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
42
src/langchain/drift/create_vault.ts
Normal file
42
src/langchain/drift/create_vault.ts
Normal 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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
37
src/langchain/drift/deposit_into_vault.ts
Normal file
37
src/langchain/drift/deposit_into_vault.ts
Normal 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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
39
src/langchain/drift/deposit_to_user_account.ts
Normal file
39
src/langchain/drift/deposit_to_user_account.ts
Normal 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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
32
src/langchain/drift/derive_vault_address.ts
Normal file
32
src/langchain/drift/derive_vault_address.ts
Normal 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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
38
src/langchain/drift/does_user_have_drift_account.ts
Normal file
38
src/langchain/drift/does_user_have_drift_account.ts
Normal 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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/langchain/drift/drift_user_account_info.ts
Normal file
29
src/langchain/drift/drift_user_account_info.ts
Normal 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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
15
src/langchain/drift/index.ts
Normal file
15
src/langchain/drift/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
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";
|
||||
37
src/langchain/drift/request_withdrawal.ts
Normal file
37
src/langchain/drift/request_withdrawal.ts
Normal 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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
49
src/langchain/drift/trade_delegated_vault.ts
Normal file
49
src/langchain/drift/trade_delegated_vault.ts
Normal 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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
42
src/langchain/drift/trade_perp_account.ts
Normal file
42
src/langchain/drift/trade_perp_account.ts
Normal 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",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user