mirror of
https://github.com/d0zingcat/solana-agent-kit.git
synced 2026-05-19 07:36:46 +00:00
feat: add squads actions
This commit is contained in:
52
src/actions/createMultisig.ts
Normal file
52
src/actions/createMultisig.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { Action } from "../types/action";
|
||||
import { SolanaAgentKit } from "../agent";
|
||||
import { z } from "zod";
|
||||
import { create_squads_multisig } from "../tools";
|
||||
import { PublicKey } from "@solana/web3.js";
|
||||
|
||||
const createMultisigAction: Action = {
|
||||
name: "CREATE_MULTISIG_ACTION",
|
||||
similes: [
|
||||
"create multisig",
|
||||
"create squads multisig",
|
||||
"create 2-by-2 multisig",
|
||||
"create 2-of-2 multisig",
|
||||
"create 2-of-2 multisig account",
|
||||
"create 2-of-2 multisig account on Solana",
|
||||
],
|
||||
description: `Create a 2-of-2 multisig account on Solana using Squads with the user and the agent, where both approvals will be required to run the transactions.
|
||||
|
||||
Note: For one AI agent, only one 2-by-2 multisig can be created as it is pair-wise.`,
|
||||
examples: [
|
||||
[
|
||||
{
|
||||
input: {
|
||||
creator: "7nE9GvcwsqzYxmJLSrYmSB1V1YoJWVK1KWzAcWAzjXkN",
|
||||
},
|
||||
output: {
|
||||
status: "success",
|
||||
message: "2-by-2 multisig account created successfully",
|
||||
signature: "4xKpN2...",
|
||||
},
|
||||
explanation: "Create a 2-of-2 multisig account on Solana",
|
||||
},
|
||||
],
|
||||
],
|
||||
schema: z.object({
|
||||
creator: z.string(),
|
||||
}),
|
||||
handler: async (agent: SolanaAgentKit, input: Record<string, any>) => {
|
||||
const multisig = await create_squads_multisig(
|
||||
agent,
|
||||
new PublicKey(input.creator as string),
|
||||
);
|
||||
|
||||
return {
|
||||
status: "success",
|
||||
message: "2-by-2 multisig account created successfully",
|
||||
signature: multisig,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export default createMultisigAction;
|
||||
49
src/actions/depositToMultisigTreasury.ts
Normal file
49
src/actions/depositToMultisigTreasury.ts
Normal 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;
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user