7
7
import { Connection , Keypair , PublicKey , Transaction } from "@solana/web3.js" ;
8
8
import { getQuote } from "./swapUtils.ts" ;
9
9
import { getWalletKey } from "../keypairUtils.ts" ;
10
+ import { getSAK } from "../utils" ;
10
11
11
12
async function invokeSwapDao (
12
13
connection : Connection ,
@@ -61,25 +62,24 @@ export const executeSwapForDAO: Action = {
61
62
runtime : IAgentRuntime ,
62
63
message : Memory
63
64
) : Promise < boolean > => {
65
+ const sak = await getSAK ( runtime ) ;
64
66
const { inputToken, outputToken, amount } = message . content ;
65
67
66
68
try {
67
69
const connection = new Connection (
68
70
runtime . getSetting ( "RPC_URL" ) as string
69
71
) ;
70
72
71
- const { keypair : authority } = await getWalletKey ( runtime , true ) ;
72
-
73
73
const daoMint = new PublicKey ( runtime . getSetting ( "DAO_MINT" ) ) ; // DAO mint address
74
74
75
75
// Derive PDAs
76
76
const [ statePDA ] = await PublicKey . findProgramAddress (
77
77
[ Buffer . from ( "state" ) , daoMint . toBuffer ( ) ] ,
78
- authority . publicKey
78
+ sak . wallet_address
79
79
) ;
80
80
const [ walletPDA ] = await PublicKey . findProgramAddress (
81
81
[ Buffer . from ( "wallet" ) , daoMint . toBuffer ( ) ] ,
82
- authority . publicKey
82
+ sak . wallet_address
83
83
) ;
84
84
85
85
const quoteData = await getQuote (
@@ -100,14 +100,14 @@ export const executeSwapForDAO: Action = {
100
100
const instructionData = Buffer . from (
101
101
JSON . stringify ( {
102
102
quote : quoteData . data ,
103
- userPublicKey : authority . publicKey . toString ( ) ,
103
+ userPublicKey : sak . wallet_address . toString ( ) ,
104
104
wrapAndUnwrapSol : true ,
105
105
} )
106
106
) ;
107
107
108
108
const txid = await invokeSwapDao (
109
109
connection ,
110
- authority ,
110
+ sak . wallet ,
111
111
statePDA ,
112
112
walletPDA ,
113
113
instructionData
0 commit comments