Skip to content

Commit 136f530

Browse files
committed
wip: solana-agent-kit
1 parent 76d4f42 commit 136f530

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

packages/plugin-solana/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"type": "module",
66
"types": "dist/index.d.ts",
77
"dependencies": {
8+
"@coral-xyz/anchor": "0.30.1",
89
"@elizaos/core": "workspace:*",
9-
"@elizaos/plugin-trustdb": "workspace:*",
1010
"@elizaos/plugin-tee": "workspace:*",
11-
"@coral-xyz/anchor": "0.30.1",
11+
"@elizaos/plugin-trustdb": "workspace:*",
1212
"@solana/spl-token": "0.4.9",
1313
"@solana/web3.js": "1.95.8",
1414
"bignumber": "1.1.0",
@@ -17,6 +17,7 @@
1717
"fomo-sdk-solana": "1.3.2",
1818
"node-cache": "5.1.2",
1919
"pumpdotfun-sdk": "1.3.2",
20+
"solana-agent-kit": "^1.3.4",
2021
"tsup": "8.3.5",
2122
"vitest": "2.1.4"
2223
},

packages/plugin-solana/src/actions/pumpfun.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Wallet } from "@coral-xyz/anchor";
33
import { generateImage } from "@elizaos/core";
44
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
55
import { CreateTokenMetadata, PriorityFee, PumpFunSDK } from "pumpdotfun-sdk";
6+
import { SolanaAgentKit} from "solana-agent-kit"
67

78
import { getAssociatedTokenAddressSync } from "@solana/spl-token";
89
import {

packages/plugin-solana/src/actions/swap.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import BigNumber from "bignumber.js";
1515
import { getWalletKey } from "../keypairUtils.ts";
1616
import { walletProvider, WalletProvider } from "../providers/wallet.ts";
1717
import { getTokenDecimals } from "./swapUtils.ts";
18+
import { SolanaAgentKit, ACTIONS } from "solana-agent-kit";
19+
20+
const TRADE_ACTION = ACTIONS.TRADE_ACTION;
1821

1922
async function swapToken(
2023
connection: Connection,
@@ -167,14 +170,14 @@ async function getTokenFromWallet(runtime: IAgentRuntime, tokenSymbol: string) {
167170
// swapToken should took CA, not symbol
168171

169172
export const executeSwap: Action = {
170-
name: "EXECUTE_SWAP",
171-
similes: ["SWAP_TOKENS", "TOKEN_SWAP", "TRADE_TOKENS", "EXCHANGE_TOKENS"],
173+
name: TRADE_ACTION.name,
174+
similes: TRADE_ACTION.similes,
172175
validate: async (runtime: IAgentRuntime, message: Memory) => {
173176
// Check if the necessary parameters are provided in the message
174177
console.log("Message:", message);
175178
return true;
176179
},
177-
description: "Perform a token swap.",
180+
description: TRADE_ACTION.description,
178181
handler: async (
179182
runtime: IAgentRuntime,
180183
message: Memory,

packages/plugin-solana/src/actions/transfer.ts

+6-9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ import {
2424
import { composeContext } from "@elizaos/core";
2525
import { getWalletKey } from "../keypairUtils";
2626
import { generateObjectDeprecated } from "@elizaos/core";
27+
import { ACTIONS } from "solana-agent-kit";
28+
29+
const TRANSFER_ACTION = ACTIONS.TRANSFER_ACTION;
2730

2831
export interface TransferContent extends Content {
2932
tokenAddress: string;
@@ -65,14 +68,8 @@ Given the recent messages, extract the following information about the requested
6568
Respond with a JSON markdown block containing only the extracted values.`;
6669

6770
export default {
68-
name: "SEND_TOKEN",
69-
similes: [
70-
"TRANSFER_TOKEN",
71-
"TRANSFER_TOKENS",
72-
"SEND_TOKENS",
73-
"SEND_SOL",
74-
"PAY",
75-
],
71+
name: TRANSFER_ACTION.name,
72+
similes: TRANSFER_ACTION.similes,
7673
validate: async (runtime: IAgentRuntime, message: Memory) => {
7774
console.log("Validating transfer from user:", message.userId);
7875
//add custom validate logic here
@@ -94,7 +91,7 @@ export default {
9491
*/
9592
return false;
9693
},
97-
description: "Transfer tokens from the agent's wallet to another address",
94+
description: TRANSFER_ACTION.description,
9895
handler: async (
9996
runtime: IAgentRuntime,
10097
message: Memory,

0 commit comments

Comments
 (0)