Skip to content

Commit f1419c8

Browse files
committed
feat: swap dao
1 parent 559e267 commit f1419c8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { Connection, Keypair, PublicKey, Transaction } from "@solana/web3.js";
88
import { getQuote } from "./swapUtils.ts";
99
import { getWalletKey } from "../keypairUtils.ts";
10+
import { getSAK } from "../utils";
1011

1112
async function invokeSwapDao(
1213
connection: Connection,
@@ -61,25 +62,24 @@ export const executeSwapForDAO: Action = {
6162
runtime: IAgentRuntime,
6263
message: Memory
6364
): Promise<boolean> => {
65+
const sak = await getSAK(runtime);
6466
const { inputToken, outputToken, amount } = message.content;
6567

6668
try {
6769
const connection = new Connection(
6870
runtime.getSetting("RPC_URL") as string
6971
);
7072

71-
const { keypair: authority } = await getWalletKey(runtime, true);
72-
7373
const daoMint = new PublicKey(runtime.getSetting("DAO_MINT")); // DAO mint address
7474

7575
// Derive PDAs
7676
const [statePDA] = await PublicKey.findProgramAddress(
7777
[Buffer.from("state"), daoMint.toBuffer()],
78-
authority.publicKey
78+
sak.wallet_address
7979
);
8080
const [walletPDA] = await PublicKey.findProgramAddress(
8181
[Buffer.from("wallet"), daoMint.toBuffer()],
82-
authority.publicKey
82+
sak.wallet_address
8383
);
8484

8585
const quoteData = await getQuote(
@@ -100,14 +100,14 @@ export const executeSwapForDAO: Action = {
100100
const instructionData = Buffer.from(
101101
JSON.stringify({
102102
quote: quoteData.data,
103-
userPublicKey: authority.publicKey.toString(),
103+
userPublicKey: sak.wallet_address.toString(),
104104
wrapAndUnwrapSol: true,
105105
})
106106
);
107107

108108
const txid = await invokeSwapDao(
109109
connection,
110-
authority,
110+
sak.wallet,
111111
statePDA,
112112
walletPDA,
113113
instructionData

0 commit comments

Comments
 (0)