merge: main

This commit is contained in:
michaelessiet
2025-01-15 13:28:58 +01:00
375 changed files with 30301 additions and 3609 deletions

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { create_image } from "../tools/create_image";
import { create_image } from "../../tools/agent";
const createImageAction: Action = {
name: "CREATE_IMAGE",

View File

@@ -1,7 +1,7 @@
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { SolanaAgentKit } from "..";
import { get_wallet_address } from "../tools";
import { Action } from "../types/action";
import { get_wallet_address } from "../../tools/agent";
const getWalletAddressAction: Action = {
name: "GET_WALLET_ADDRESS",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getAllDomainsTLDs } from "../tools";
import { getAllDomainsTLDs } from "../../tools";
const getAllDomainsTLDsAction: Action = {
name: "GET_ALL_TLDS",

View File

@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { getOwnedAllDomains } from "../tools";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getOwnedAllDomains } from "../../tools";
const getOwnedAllDomainsAction: Action = {
name: "GET_OWNED_ALL_DOMAINS",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getOwnedDomainsForTLD } from "../tools";
import { getOwnedDomainsForTLD } from "../../tools";
const getOwnedDomainsForTLDAction: Action = {
name: "GET_OWNED_DOMAINS_FOR_TLD",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { resolveAllDomains } from "../tools";
import { resolveAllDomains } from "../../tools";
const resolveDomainAction: Action = {
name: "RESOLVE_ALL_DOMAINS",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getTokenDataByTicker } from "../tools";
import { getTokenDataByTicker } from "../../tools/dexscreener";
const tokenDataByTickerAction: Action = {
name: "GET_TOKEN_DATA_BY_TICKER",

View 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;

View 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;

View 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;

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,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;

View 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;

View 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;

View File

@@ -0,0 +1,53 @@
import { z } from "zod";
import type { Action } from "../../types";
import { updateVaultDelegate } from "../../tools";
const updateDriftVaultDelegateAction: Action = {
name: "UPDATE_DRIFT_VAULT_DELEGATE_ACTION",
similes: ["update drift vault delegate", "change drift vault delegate"],
description: "Update the delegate of a drift vault",
examples: [
[
{
input: {
vaultAddress: "2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBD",
newDelegate: "2nFeP7tai",
},
output: {
status: "success",
message: "Vault delegate updated successfully",
signature:
"2nFeP7taii3wGVgrWk4YiLMPmhtu3Zg9iXCUu4zGBDadwunHw8reXFxRWT7khbFsQ9JT3zK4RYDLNDFDRYvM3wJk",
},
explanation: "Update the delegate of a drift vault to another address",
},
],
],
schema: z.object({
vaultAddress: z.string(),
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;

View 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;

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { flashCloseTrade } from "../tools";
import { flashCloseTrade } from "../../tools/flash";
const flashCloseTradeAction: Action = {
name: "FLASH_CLOSE_TRADE",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { flashOpenTrade } from "../tools";
import { flashOpenTrade } from "../../tools/flash";
const flashOpenTradeAction: Action = {
name: "FLASH_OPEN_TRADE",

View File

@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { create_gibwork_task } from "../tools";
import { create_gibwork_task } from "../../tools/gibwork";
const createGibworkTaskAction: Action = {
name: "CREATE_GIBWORK_TASK",

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View File

@@ -1,36 +1,64 @@
import deployTokenAction from "./deployToken";
import balanceAction from "./balance";
import transferAction from "./transfer";
import deployCollectionAction from "./deployCollection";
import mintNFTAction from "./mintNFT";
import tradeAction from "./trade";
import requestFundsAction from "./requestFunds";
import resolveDomainAction from "./resolveDomain";
import getTokenDataAction from "./getTokenData";
import getTPSAction from "./getTPS";
import fetchPriceAction from "./fetchPrice";
import stakeWithJupAction from "./stakeWithJup";
import stakeWithSolayerAction from "./stakeWithSolayer";
import registerDomainAction from "./registerDomain";
import lendAssetAction from "./lendAsset";
import createGibworkTaskAction from "./createGibworkTask";
import resolveSolDomainAction from "./resolveSolDomain";
import pythFetchPriceAction from "./pythFetchPrice";
import getOwnedDomainsForTLDAction from "./getOwnedDomainsForTLD";
import getPrimaryDomainAction from "./getPrimaryDomain";
import getAllDomainsTLDsAction from "./getAllDomainsTLDs";
import getOwnedAllDomainsAction from "./getOwnedAllDomains";
import createImageAction from "./createImage";
import getMainAllDomainsDomainAction from "./getMainAllDomainsDomain";
import getAllRegisteredAllDomainsAction from "./getAllRegisteredAllDomains";
import raydiumCreateCpmmAction from "./raydiumCreateCpmm";
import raydiumCreateAmmV4Action from "./raydiumCreateAmmV4";
import createOrcaSingleSidedWhirlpoolAction from "./createOrcaSingleSidedWhirlpool";
import launchPumpfunTokenAction from "./launchPumpfunToken";
import getWalletAddressAction from "./getWalletAddress";
import flashOpenTradeAction from "./flashOpenTrade";
import flashCloseTradeAction from "./flashCloseTrade";
import tokenBalancesAction from "./tokenBalances";
import deployTokenAction from "./metaplex/deployToken";
import balanceAction from "./solana/balance";
import transferAction from "./solana/transfer";
import deployCollectionAction from "./metaplex/deployCollection";
import mintNFTAction from "./metaplex/mintNFT";
import tradeAction from "./jupiter/trade";
import requestFundsAction from "./solana/requestFunds";
import resolveDomainAction from "./sns/registerDomain";
import getTokenDataAction from "./jupiter/getTokenData";
import getTPSAction from "./solana/getTPS";
import fetchPriceAction from "./jupiter/fetchPrice";
import stakeWithJupAction from "./jupiter/stakeWithJup";
import stakeWithSolayerAction from "./solayer/stakeWithSolayer";
import registerDomainAction from "./sns/registerDomain";
import lendAssetAction from "./lulo/lendAsset";
import createGibworkTaskAction from "./gibwork/createGibworkTask";
import resolveSolDomainAction from "./sns/resolveSolDomain";
import pythFetchPriceAction from "./pyth/pythFetchPrice";
import getOwnedDomainsForTLDAction from "./alldomains/getOwnedDomainsForTLD";
import getPrimaryDomainAction from "./sns/getPrimaryDomain";
import getAllDomainsTLDsAction from "./alldomains/getAllDomainsTLDs";
import getOwnedAllDomainsAction from "./alldomains/getOwnedAllDomains";
import createImageAction from "./agent/createImage";
import getMainAllDomainsDomainAction from "./sns/getMainAllDomainsDomain";
import getAllRegisteredAllDomainsAction from "./sns/getAllRegisteredAllDomains";
import raydiumCreateCpmmAction from "./raydium/raydiumCreateCpmm";
import raydiumCreateAmmV4Action from "./raydium/raydiumCreateAmmV4";
import createOrcaSingleSidedWhirlpoolAction from "./orca/createOrcaSingleSidedWhirlpool";
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";
export const ACTIONS = {
WALLET_ADDRESS_ACTION: getWalletAddressAction,
@@ -67,6 +95,34 @@ 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,
};
export type { Action, ActionExample, Handler } from "../types/action";

View File

@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { fetchPrice } from "../tools";
import { fetchPrice } from "../../tools/jupiter";
const fetchPriceAction: Action = {
name: "FETCH_PRICE",

View File

@@ -1,9 +1,9 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { JupiterTokenData } from "../types";
import { getTokenAddressFromTicker, getTokenDataByAddress } from "../tools";
import { JupiterTokenData } from "../../types";
import { getTokenAddressFromTicker, getTokenDataByAddress } from "../../tools";
const getTokenDataAction: Action = {
name: "GET_TOKEN_DATA",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { stakeWithJup } from "../tools";
import { stakeWithJup } from "../../tools";
const stakeWithJupAction: Action = {
name: "STAKE_WITH_JUPITER",

View File

@@ -1,8 +1,8 @@
import { PublicKey } from "@solana/web3.js";
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { trade } from "../tools";
import { trade } from "../../tools";
const tradeAction: Action = {
name: "TRADE",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { sendCompressedAirdrop } from "../tools";
import { sendCompressedAirdrop } from "../../tools";
const compressedAirdropAction: Action = {
name: "COMPRESSED_AIRDROP",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { lendAsset } from "../tools";
import { lendAsset } from "../../tools/lulo";
const lendAssetAction: Action = {
name: "LEND_ASSET",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { deploy_collection } from "../tools";
import { deploy_collection } from "../../tools/metaplex";
interface CollectionOptions {
name: string;

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { deploy_token } from "../tools";
import { deploy_token } from "../../tools";
const deployTokenAction: Action = {
name: "DEPLOY_TOKEN",

View File

@@ -1,8 +1,8 @@
import { PublicKey } from "@solana/web3.js";
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { mintCollectionNFT } from "../tools";
import { mintCollectionNFT } from "../../tools/metaplex";
const mintNFTAction: Action = {
name: "MINT_NFT",
@@ -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: [
[
{

View File

@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { openbookCreateMarket } from "../tools";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { openbookCreateMarket } from "../../tools/openbook";
const createOpenbookMarketAction: Action = {
name: "CREATE_OPENBOOK_MARKET",

View File

@@ -1,9 +1,9 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { Decimal } from "decimal.js";
import { orcaCreateSingleSidedLiquidityPool } from "../tools";
import { orcaCreateSingleSidedLiquidityPool } from "../../tools";
// Fee tiers mapping from the original tool
const FEE_TIERS = {

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { launchPumpFunToken } from "../tools";
import { launchPumpFunToken } from "../../tools";
const launchPumpfunTokenAction: Action = {
name: "LAUNCH_PUMPFUN_TOKEN",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { fetchPythPrice, fetchPythPriceFeedID } from "../tools";
import { fetchPythPrice, fetchPythPriceFeedID } from "../../tools";
const pythFetchPriceAction: Action = {
name: "PYTH_FETCH_PRICE",

View File

@@ -1,9 +1,9 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import { raydiumCreateAmmV4 } from "../tools";
import { raydiumCreateAmmV4 } from "../../tools";
const raydiumCreateAmmV4Action: Action = {
name: "RAYDIUM_CREATE_AMM_V4",

View File

@@ -1,10 +1,10 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { BN } from "@coral-xyz/anchor";
import Decimal from "decimal.js";
import { raydiumCreateClmm } from "../tools";
import { raydiumCreateClmm } from "../../tools";
const raydiumCreateClmmAction: Action = {
name: "RAYDIUM_CREATE_CLMM",

View File

@@ -1,9 +1,9 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import { raydiumCreateCpmm } from "../tools";
import { raydiumCreateCpmm } from "../../tools";
const raydiumCreateCpmmAction: Action = {
name: "RAYDIUM_CREATE_CPMM",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getAllRegisteredAllDomains } from "../tools";
import { getAllRegisteredAllDomains } from "../../tools";
const getAllRegisteredAllDomainsAction: Action = {
name: "GET_ALL_REGISTERED_ALL_DOMAINS",

View File

@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { getMainAllDomainsDomain } from "../tools";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getMainAllDomainsDomain } from "../../tools";
const getMainAllDomainsDomainAction: Action = {
name: "GET_MAIN_ALL_DOMAINS_DOMAIN",

View File

@@ -1,8 +1,8 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { PublicKey } from "@solana/web3.js";
import { getPrimaryDomain } from "../tools";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getPrimaryDomain } from "../../tools";
const getPrimaryDomainAction: Action = {
name: "GET_PRIMARY_DOMAIN",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { registerDomain } from "../tools";
import { registerDomain } from "../../tools";
const registerDomainAction: Action = {
name: "REGISTER_DOMAIN",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { resolveSolDomain } from "../tools";
import { resolveSolDomain } from "../../tools/";
const resolveSolDomainAction: Action = {
name: "RESOLVE_SOL_DOMAIN",

View File

@@ -1,8 +1,8 @@
import { PublicKey } from "@solana/web3.js";
import type { Action } from "../types/action";
import type { SolanaAgentKit } from "../agent";
import type { Action } from "../../types/action";
import type { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { get_balance } from "../tools";
import { get_balance } from "../../tools";
const balanceAction: Action = {
name: "BALANCE_ACTION",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { closeEmptyTokenAccounts } from "../tools";
import { closeEmptyTokenAccounts } from "../../tools";
const closeEmptyTokenAccountsAction: Action = {
name: "CLOSE_EMPTY_TOKEN_ACCOUNTS",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { getTPS } from "../tools";
import { getTPS } from "../../tools/solana";
const getTPSAction: Action = {
name: "GET_TPS",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { request_faucet_funds } from "../tools";
import { request_faucet_funds } from "../../tools/solana";
const requestFundsAction: Action = {
name: "REQUEST_FUNDS",

View File

@@ -1,8 +1,8 @@
import { PublicKey } from "@solana/web3.js";
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { transfer } from "../tools";
import { transfer } from "../../tools";
const transferAction: Action = {
name: "TRANSFER",

View File

@@ -1,7 +1,7 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { Action } from "../../types/action";
import { SolanaAgentKit } from "../../agent";
import { z } from "zod";
import { stakeWithSolayer } from "../tools";
import { stakeWithSolayer } from "../../tools";
const stakeWithSolayerAction: Action = {
name: "STAKE_WITH_SOLAYER",

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View 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;

View File

@@ -2,7 +2,7 @@ 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/get_token_balances";
import { get_token_balance } from "../tools";
const tokenBalancesAction: Action = {
name: "TOKEN_BALANCE_ACTION",
@@ -64,7 +64,7 @@ const tokenBalancesAction: Action = {
schema: z.object({
walletAddress: z.string().optional(),
}),
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
handler: async (agent: SolanaAgentKit, input) => {
const balance = await get_token_balance(
agent,
input.tokenAddress && new PublicKey(input.tokenAddress),

View File

@@ -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,
@@ -63,8 +67,41 @@ import {
fetchPythPriceFeedID,
flashOpenTrade,
flashCloseTrade,
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,
} from "../tools";
import {
Config,
TokenCheck,
CollectionDeployment,
CollectionOptions,
GibworkCreateTaskReponse,
@@ -75,24 +112,9 @@ import {
OrderParams,
FlashTradeParams,
FlashCloseTradeParams,
HeliusWebhookIdResponse,
HeliusWebhookResponse,
} from "../types";
import {
createCollection,
createSingle,
} from "../tools/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";
import { get_token_balance } from "../tools/get_token_balances";
/**
* Main class for interacting with Solana blockchain
@@ -601,6 +623,12 @@ 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,
@@ -624,6 +652,20 @@ export class SolanaAgentKit {
);
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);
@@ -634,7 +676,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(
@@ -643,30 +685,140 @@ 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);
}
}

View File

@@ -0,0 +1,68 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
import {
CreateCollectionOptions,
StoreInitOptions,
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
export class Solana3LandCreateCollection extends Tool {
name = "3land_minting_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
collectionDescription (required): the description of the collection
mainImageUrl (required): the image of the collection
coverImageUrl (optional): the cover image of the collection
`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
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;
const mainImageUrl = inputFormat?.mainImageUrl;
const coverImageUrl = inputFormat?.coverImageUrl;
const collectionOpts: CreateCollectionOptions = {
...(collectionSymbol && { collectionSymbol }),
...(collectionName && { collectionName }),
...(collectionDescription && { collectionDescription }),
...(mainImageUrl && { mainImageUrl }),
...(coverImageUrl && { coverImageUrl }),
};
const tx = await this.solanaKit.create3LandCollection(
optionsWithBase58,
collectionOpts,
);
return JSON.stringify({
status: "success",
message: `Created Collection successfully ${tx}`,
transaction: tx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,91 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
import {
CreateSingleOptions,
StoreInitOptions,
} from "@3land/listings-sdk/dist/types/implementation/implementationTypes";
export class Solana3LandCreateSingle extends Tool {
name = "3land_minting_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
itemAmount (required): the amount of the NFTs that can be minted
itemDescription (required): the description of the NFT
traits (required): the traits of the NFT [{trait_type: string, value: string}]
price (required): the price of the item, if is 0 the listing will be free
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
`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
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 collectionAccount = inputFormat.collectionAccount;
const itemName = inputFormat?.itemName;
const sellerFee = inputFormat?.sellerFee;
const itemAmount = inputFormat?.itemAmount;
const itemSymbol = inputFormat?.itemSymbol;
const itemDescription = inputFormat?.itemDescription;
const traits = inputFormat?.traits;
const price = inputFormat?.price;
const mainImageUrl = inputFormat?.mainImageUrl;
const coverImageUrl = inputFormat?.coverImageUrl;
const splHash = inputFormat?.splHash;
const createItemOptions: CreateSingleOptions = {
...(itemName && { itemName }),
...(sellerFee && { sellerFee }),
...(itemAmount && { itemAmount }),
...(itemSymbol && { itemSymbol }),
...(itemDescription && { itemDescription }),
...(traits && { traits }),
...(price && { price }),
...(mainImageUrl && { mainImageUrl }),
...(coverImageUrl && { coverImageUrl }),
...(splHash && { splHash }),
};
if (!collectionAccount) {
throw new Error("Collection account is required");
}
const tx = await this.solanaKit.create3LandNft(
optionsWithBase58,
collectionAccount,
createItemOptions,
isMainnet,
);
return JSON.stringify({
status: "success",
message: `Created listing successfully ${tx}`,
transaction: tx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,2 @@
export * from "./create_single";
export * from "./create_collection";

View File

@@ -0,0 +1,49 @@
import { PublicKey } from "@solana/web3.js";
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaPerpCloseTradeTool extends Tool {
name = "solana_close_perp_trade";
description = `This tool can be used to close perpetuals trade ( It uses Adrena Protocol ).
Inputs ( input is a JSON string ):
tradeMint: string, eg "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn", "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" etc. (optional)
price?: number, eg 100 (optional)
side: string, eg: "long" or "short"`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx =
parsedInput.side === "long"
? await this.solanaKit.closePerpTradeLong({
price: parsedInput.price,
tradeMint: new PublicKey(parsedInput.tradeMint),
})
: await this.solanaKit.closePerpTradeShort({
price: parsedInput.price,
tradeMint: new PublicKey(parsedInput.tradeMint),
});
return JSON.stringify({
status: "success",
message: "Perpetual trade closed successfully",
transaction: tx,
price: parsedInput.price,
tradeMint: new PublicKey(parsedInput.tradeMint),
side: parsedInput.side,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,2 @@
export * from "./open_trade";
export * from "./close_trade";

View File

@@ -0,0 +1,65 @@
import { PublicKey } from "@solana/web3.js";
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaPerpOpenTradeTool extends Tool {
name = "solana_open_perp_trade";
description = `This tool can be used to open perpetuals trade ( It uses Adrena Protocol ).
Inputs ( input is a JSON string ):
collateralAmount: number, eg 1 or 0.01 (required)
collateralMint: string, eg "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn" or "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" etc. (optional)
tradeMint: string, eg "J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn", "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" etc. (optional)
leverage: number, eg 50000 = x5, 100000 = x10, 1000000 = x100 (optional)
price?: number, eg 100 (optional)
slippage?: number, eg 0.3 (optional)
side: string, eg: "long" or "short"`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const tx =
parsedInput.side === "long"
? await this.solanaKit.openPerpTradeLong({
price: parsedInput.price,
collateralAmount: parsedInput.collateralAmount,
collateralMint: new PublicKey(parsedInput.collateralMint),
leverage: parsedInput.leverage,
tradeMint: new PublicKey(parsedInput.tradeMint),
slippage: parsedInput.slippage,
})
: await this.solanaKit.openPerpTradeLong({
price: parsedInput.price,
collateralAmount: parsedInput.collateralAmount,
collateralMint: new PublicKey(parsedInput.collateralMint),
leverage: parsedInput.leverage,
tradeMint: new PublicKey(parsedInput.tradeMint),
slippage: parsedInput.slippage,
});
return JSON.stringify({
status: "success",
message: "Perpetual trade opened successfully",
transaction: tx,
price: parsedInput.price,
collateralAmount: parsedInput.collateralAmount,
collateralMint: new PublicKey(parsedInput.collateralMint),
leverage: parsedInput.leverage,
tradeMint: new PublicKey(parsedInput.tradeMint),
slippage: parsedInput.slippage,
side: parsedInput.side,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,38 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
import { create_image } from "../../tools/agent";
export class SolanaCreateImageTool extends Tool {
name = "solana_create_image";
description =
"Create an image using OpenAI's DALL-E. Input should be a string prompt for the image.";
constructor(private solanaKit: SolanaAgentKit) {
super();
}
private validateInput(input: string): void {
if (typeof input !== "string" || input.trim().length === 0) {
throw new Error("Input must be a non-empty string prompt");
}
}
protected async _call(input: string): Promise<string> {
try {
this.validateInput(input);
const result = await create_image(this.solanaKit, input.trim());
return JSON.stringify({
status: "success",
message: "Image created successfully",
...result,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,2 @@
export * from "./create_image";
export * from "./wallet_address";

View File

@@ -0,0 +1,15 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaGetWalletAddressTool extends Tool {
name = "solana_get_wallet_address";
description = `Get the wallet address of the agent`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
async _call(_input: string): Promise<string> {
return this.solanaKit.wallet_address.toString();
}
}

View File

@@ -0,0 +1,29 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaGetAllTlds extends Tool {
name = "solana_get_all_tlds";
description = `Get all active top-level domains (TLDs) in the AllDomains Name Service`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
async _call(): Promise<string> {
try {
const tlds = await this.solanaKit.getAllDomainsTLDs();
return JSON.stringify({
status: "success",
message: "TLDs fetched successfully",
tlds,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "FETCH_TLDS_ERROR",
});
}
}
}

View File

@@ -0,0 +1,4 @@
export * from "./resolve_all_domains";
export * from "./owned_domains";
export * from "./tld_domains";
export * from "./get_all_tld";

View File

@@ -0,0 +1,34 @@
import { PublicKey } from "@solana/web3.js";
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaGetOwnedDomains extends Tool {
name = "solana_get_owned_domains";
description = `Get all domains owned by a specific wallet address.
Inputs:
owner: string, eg "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
async _call(input: string): Promise<string> {
try {
const ownerPubkey = new PublicKey(input.trim());
const domains = await this.solanaKit.getOwnedAllDomains(ownerPubkey);
return JSON.stringify({
status: "success",
message: "Owned domains fetched successfully",
domains,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "FETCH_OWNED_DOMAINS_ERROR",
});
}
}
}

View File

@@ -0,0 +1,42 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaResolveAllDomainsTool extends Tool {
name = "solana_resolve_all_domains";
description = `Resolve domain names to a public key for ALL domain types EXCEPT .sol domains.
Use this for domains like .blink, .bonk, etc.
DO NOT use this for .sol domains (use solana_resolve_domain instead).
Input:
domain: string, eg "mydomain.blink" or "mydomain.bonk" (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
async _call(input: string): Promise<string> {
try {
const owner = await this.solanaKit.resolveAllDomains(input);
if (!owner) {
return JSON.stringify({
status: "error",
message: "Domain not found",
code: "DOMAIN_NOT_FOUND",
});
}
return JSON.stringify({
status: "success",
message: "Domain resolved successfully",
owner: owner?.toString(),
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "DOMAIN_RESOLUTION_ERROR",
});
}
}
}

View File

@@ -0,0 +1,32 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaGetOwnedTldDomains extends Tool {
name = "solana_get_owned_tld_domains";
description = `Get all domains owned by the agent's wallet for a specific TLD.
Inputs:
tld: string, eg "bonk" (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
async _call(input: string): Promise<string> {
try {
const domains = await this.solanaKit.getOwnedDomainsForTLD(input);
return JSON.stringify({
status: "success",
message: "TLD domains fetched successfully",
domains,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "FETCH_TLD_DOMAINS_ERROR",
});
}
}
}

View File

@@ -0,0 +1 @@
export * from "./token_data_ticker";

View File

@@ -0,0 +1,31 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaTokenDataByTickerTool extends Tool {
name = "solana_token_data_by_ticker";
description = `Get the token data for a given token ticker
Inputs: ticker is required.
ticker: string, eg "USDC" (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const ticker = input.trim();
const tokenData = await this.solanaKit.getTokenDataByTicker(ticker);
return JSON.stringify({
status: "success",
tokenData,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,53 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaFlashCloseTrade extends Tool {
name = "solana_flash_close_trade";
description = `Close an existing leveraged trading position on Flash.Trade exchange.
Inputs ( input is a JSON string ):
token: string, eg "SOL", "BTC", "ETH" (required)
side: string, eg "long", "short" (required)
Example prompt is Close a 20x leveraged trade for SOL on long side`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
// Validate input parameters
if (!parsedInput.token) {
throw new Error("Token is required");
}
if (!["SOL", "BTC", "ETH"].includes(parsedInput.token)) {
throw new Error('Token must be one of ["SOL", "BTC", "ETH"]');
}
if (!["long", "short"].includes(parsedInput.side)) {
throw new Error('Side must be either "long" or "short"');
}
const tx = await this.solanaKit.flashCloseTrade({
token: parsedInput.token,
side: parsedInput.side,
});
return JSON.stringify({
status: "success",
message: "Flash trade position closed successfully",
transaction: tx,
token: parsedInput.token,
side: parsedInput.side,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,81 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
import { marketTokenMap } from "../../utils/flashUtils";
export class SolanaFlashOpenTrade extends Tool {
name = "solana_flash_open_trade";
description = `This tool can be used to open a new leveraged trading position on Flash.Trade exchange.
Inputs ( input is a JSON string ):
token: string, eg "SOL", "BTC", "ETH" (required)
type: string, eg "long", "short" (required)
collateral: number, eg 10, 100, 1000 (required)
leverage: number, eg 5, 10, 20 (required)
Example prompt is Open a 20x leveraged trade for SOL on long side using flash trade with 500 USD as collateral`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
// Validate input parameters
if (!parsedInput.token) {
throw new Error("Token is required, received: " + parsedInput.token);
}
if (!Object.keys(marketTokenMap).includes(parsedInput.token)) {
throw new Error(
"Token must be one of " +
Object.keys(marketTokenMap).join(", ") +
", received: " +
parsedInput.token +
"\n" +
"Please check https://beast.flash.trade/ for the list of supported tokens",
);
}
if (!["long", "short"].includes(parsedInput.type)) {
throw new Error(
'Type must be either "long" or "short", received: ' +
parsedInput.type,
);
}
if (!parsedInput.collateral || parsedInput.collateral <= 0) {
throw new Error(
"Collateral amount must be positive, received: " +
parsedInput.collateral,
);
}
if (!parsedInput.leverage || parsedInput.leverage <= 0) {
throw new Error(
"Leverage must be positive, received: " + parsedInput.leverage,
);
}
const tx = await this.solanaKit.flashOpenTrade({
token: parsedInput.token,
side: parsedInput.type,
collateralUsd: parsedInput.collateral,
leverage: parsedInput.leverage,
});
return JSON.stringify({
status: "success",
message: "Flash trade position opened successfully",
transaction: tx,
token: parsedInput.token,
side: parsedInput.type,
collateral: parsedInput.collateral,
leverage: parsedInput.leverage,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,2 @@
export * from "./flash_open";
export * from "./flash_close";

View File

@@ -0,0 +1,52 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
import { GibworkCreateTaskReponse } from "../../index";
export class SolanaCreateGibworkTask extends Tool {
name = "create_gibwork_task";
description = `Create a task on Gibwork.
Inputs (input is a JSON string):
title: string, title of the task (required)
content: string, description of the task (required)
requirements: string, requirements to complete the task (required)
tags: string[], list of tags associated with the task (required)
payer: string, payer address (optional, defaults to agent wallet)
tokenMintAddress: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN" (required)
amount: number, payment amount (required)
`;
constructor(private solanaSdk: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const taskData = await this.solanaSdk.createGibworkTask(
parsedInput.title,
parsedInput.content,
parsedInput.requirements,
parsedInput.tags,
parsedInput.tokenMintAddress,
parsedInput.amount,
parsedInput.payer,
);
const response: GibworkCreateTaskReponse = {
status: "success",
taskId: taskData.taskId,
signature: taskData.signature,
};
return JSON.stringify(response);
} catch (err: any) {
return JSON.stringify({
status: "error",
message: err.message,
code: err.code || "CREATE_TASK_ERROR",
});
}
}
}

View File

@@ -0,0 +1 @@
export * from "./create_task";

View File

@@ -0,0 +1,65 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaHeliusWebhookTool extends Tool {
name = "create_helius_webhook";
description = `Creates a Helius Webhook that listens to specified account addresses.
Inputs (input is a JSON string):
accountAddresses: string[] | string,
e.g. ["BVdNLvyG2DNiWAXBE9qAmc4MTQXymd5Bzfo9xrQSUzVP","Eo2ciguhMLmcTWXELuEQPdu7DWZt67LHXb2rdHZUbot7"]
or "BVdNLvyG2DNiWAXBE9qAmc4MTQXymd5Bzfo9xrQSUzVP,Eo2ciguhMLmcTWXELuEQPdu7DWZt67LHXb2rdHZUbot7"
webhookURL: string, e.g. "https://TestServer.test.repl.co/webhooks"`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
let accountAddresses: string[] = [];
if (!parsedInput.accountAddresses) {
throw new Error('Missing "accountAddresses" property in input JSON.');
}
if (Array.isArray(parsedInput.accountAddresses)) {
accountAddresses = parsedInput.accountAddresses.map((addr: string) =>
addr.trim(),
);
} else if (typeof parsedInput.accountAddresses === "string") {
accountAddresses = parsedInput.accountAddresses
.split(",")
.map((addr: string) => addr.trim());
} else {
throw new Error(
'Invalid type for "accountAddresses". Expected array or comma-separated string.',
);
}
const webhookURL = parsedInput.webhookURL;
if (!webhookURL) {
throw new Error(
'Invalid input. Expected a "webhookURL" property in the JSON.',
);
}
const result = await this.solanaKit.CreateWebhook(
accountAddresses,
webhookURL,
);
// Return success in JSON
return JSON.stringify({
status: "success",
message: "Helius Webhook created successfully",
webhookURL: result.webhookURL,
webhookID: result.webhookID,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,39 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaDeleteHeliusWebhookTool extends Tool {
name = "delete_helius_webhook";
description = `Deletes a Helius Webhook by its ID.
Inputs (input is a JSON string):
webhookID: string, e.g. "1ed4244d-a591-4854-ac31-cc28d40b8255"`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const webhookID = parsedInput.webhookID;
if (!webhookID || typeof webhookID !== "string") {
throw new Error(
'Invalid input. Expected a "webhookID" property in the JSON.',
);
}
const result = await this.solanaKit.deleteWebhook(webhookID);
return JSON.stringify({
status: "success",
message: "Helius Webhook deleted successfully",
data: result,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,38 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
import { PublicKey } from "@solana/web3.js";
export class SolanaGetAllAssetsByOwner extends Tool {
name = "solana_get_all_assets_by_owner";
description = `Get all assets owned by a specific wallet address.
Inputs:
- owner: string, the wallet address of the owner, e.g., "4Be9CvxqHW6BYiRAxW9Q3xu1ycTMWaL5z8NX4HR3ha7t" (required)
- limit: number, the maximum number of assets to retrieve (optional)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const { owner, limit } = JSON.parse(input);
const ownerPubkey = new PublicKey(owner);
const assets = await this.solanaKit.getAllAssetsbyOwner(
ownerPubkey,
limit,
);
return JSON.stringify({
status: "success",
message: "Assets retrieved successfully",
assets: assets,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,43 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaGetHeliusWebhookTool extends Tool {
name = "get_helius_webhook";
description = `Retrieves a Helius Webhook by its ID.
Inputs (input is a JSON string):
webhookID: string, e.g. "1ed4244d-a591-4854-ac31-cc28d40b8255"`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input);
const webhookID = parsedInput.webhookID;
if (!webhookID || typeof webhookID !== "string") {
throw new Error(
'Invalid input. Expected a "webhookID" property in the JSON.',
);
}
const result = await this.solanaKit.getWebhook(webhookID);
return JSON.stringify({
status: "success",
message: "Helius Webhook retrieved successfully",
wallet: result.wallet,
webhookURL: result.webhookURL,
transactionTypes: result.transactionTypes,
accountAddresses: result.accountAddresses,
webhookType: result.webhookType,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,6 @@
export * from "./create_webhook";
export * from "./delete_webhook";
export * from "./get_all_assets";
export * from "./get_webhook";
export * from "./parse_transaction";
export * from "./send_transaction_priority";

View File

@@ -0,0 +1,32 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaParseTransactionHeliusTool extends Tool {
name = "solana_parse_transaction_helius";
description = `Parse a Solana transaction using Helius API.
Inputs:
- transactionId: string, the ID of the transaction to parse, e.g., "5h3k...9d2k" (required).`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<any> {
try {
const transactionId = input.trim();
const parsedTransaction =
await this.solanaKit.heliusParseTransactions(transactionId);
return JSON.stringify({
status: "success",
message: "transaction parsed successfully",
transaction: parsedTransaction,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "NOt able to Parse transaction",
});
}
}
}

View File

@@ -0,0 +1,63 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
import { PublicKey } from "@solana/web3.js";
export class SolanaSendTransactionWithPriorityFee extends Tool {
name = "solana_send_transaction_with_priority_fee";
description = `Sends a Solana transaction with a user-defined priority fee.
**Inputs (JSON-encoded string)**:
- priorityLevel: string — the priority level ("NONE", "Min", "Low", "Medium", "High", "VeryHigh", or "UnsafeMax")
- amount: number — the amount of SOL to send
- to: string — the recipient's wallet address (public key in base58);`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const { priorityLevel, amount, to, splmintAddress } = JSON.parse(input);
const validPriorityLevels = [
"NONE",
"Min",
"Low",
"Medium",
"High",
"VeryHigh",
"UnsafeMax",
];
if (!validPriorityLevels.includes(priorityLevel)) {
throw new Error(
`Invalid priority level. Must be one of: ${validPriorityLevels.join(", ")}. Received: ${priorityLevel}`,
);
}
if (!amount || !to) {
throw new Error(
`Missing required fields. Received: priorityLevel=${priorityLevel}, amount=${amount}, to=${to}`,
);
}
const toPubkey = new PublicKey(to);
const priorityFeeTx = await this.solanaKit.sendTranctionWithPriority(
priorityLevel,
amount,
toPubkey,
splmintAddress,
);
return JSON.stringify({
status: "success",
message: "Transaction sent successfully",
priorityFeeTx,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
/**
* Tool to fetch the price of a token in USDC
*/
export class SolanaFetchPriceTool extends Tool {
name = "solana_fetch_price";
description = `Fetch the price of a given token in USDC.
Inputs:
- tokenId: string, the mint address of the token, e.g., "JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN"`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
async _call(input: string): Promise<string> {
try {
const price = await this.solanaKit.fetchTokenPrice(input.trim());
return JSON.stringify({
status: "success",
tokenId: input.trim(),
priceInUSDC: price,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

View File

@@ -0,0 +1,4 @@
export * from "./fetch_price";
export * from "./token_data";
export * from "./trade";
export * from "./stake";

View File

@@ -0,0 +1,35 @@
import { Tool } from "langchain/tools";
import { SolanaAgentKit } from "../../agent";
export class SolanaStakeTool extends Tool {
name = "solana_stake";
description = `This tool can be used to stake your SOL (Solana), also called as SOL staking or liquid staking.
Inputs ( input is a JSON string ):
amount: number, eg 1 or 0.01 (required)`;
constructor(private solanaKit: SolanaAgentKit) {
super();
}
protected async _call(input: string): Promise<string> {
try {
const parsedInput = JSON.parse(input) || Number(input);
const tx = await this.solanaKit.stake(parsedInput.amount);
return JSON.stringify({
status: "success",
message: "Staked successfully",
transaction: tx,
amount: parsedInput.amount,
});
} catch (error: any) {
return JSON.stringify({
status: "error",
message: error.message,
code: error.code || "UNKNOWN_ERROR",
});
}
}
}

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