feat: add squads actions

This commit is contained in:
Arihant Bansal
2025-01-11 23:15:37 +05:30
parent b93b961a9e
commit cd72af002e
3 changed files with 105 additions and 0 deletions

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,49 @@
import { Action } from "../types/action";
import { SolanaAgentKit } from "../agent";
import { z } from "zod";
import { create_squads_multisig, 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-by-2 multisig",
"deposit to 2-of-2 multisig",
"deposit SOL to 2-of-2 multisig account on Solana",
"deposit SPL tokens to 2-of-2 multisig account",
],
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

@@ -30,6 +30,8 @@ import launchPumpfunTokenAction from "./launchPumpfunToken";
import getWalletAddressAction from "./getWalletAddress";
import flashOpenTradeAction from "./flashOpenTrade";
import flashCloseTradeAction from "./flashCloseTrade";
import createMultisigAction from "./createMultisig";
import depositToMultisigAction from "./depositToMultisigTreasury";
export const ACTIONS = {
WALLET_ADDRESS_ACTION: getWalletAddressAction,
@@ -65,6 +67,8 @@ 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,
};
export type { Action, ActionExample, Handler } from "../types/action";