@@ -30,12 +30,14 @@ import { expectError } from "./utils/utils";
3030
3131import { AutocratV0 } from "../target/types/autocrat_v0" ;
3232import { ConditionalVault } from "../target/types/conditional_vault" ;
33+ import { AutocratMigrator } from "../target/types/autocrat_migrator" ;
3334import { OpenbookTwap } from "./fixtures/openbook_twap" ;
3435
3536const OpenbookTwapIDL : OpenbookTwap = require ( "./fixtures/openbook_twap.json" ) ;
3637
3738const AutocratIDL : AutocratV0 = require ( "../target/idl/autocrat_v0.json" ) ;
3839const ConditionalVaultIDL : ConditionalVault = require ( "../target/idl/conditional_vault.json" ) ;
40+ const AutocratMigratorIDL : AutocratMigrator = require ( "../target/idl/autocrat_migrator.json" ) ;
3941
4042export type PublicKey = anchor . web3 . PublicKey ;
4143export type Signer = anchor . web3 . Signer ;
@@ -81,6 +83,11 @@ const OPENBOOK_PROGRAM_ID = new PublicKey(
8183 "opnb2LAfJYbRMAHHvqjCwQxanZn7ReEHp1k81EohpZb"
8284) ;
8385
86+ const AUTOCRAT_MIGRATOR_PROGRAM_ID = new PublicKey (
87+ "8C4WEdr54tBPdtmeTPUBuZX5bgUMZw4XdvpNoNaQ6NwR"
88+ ) ;
89+
90+
8491describe ( "autocrat_v0" , async function ( ) {
8592 let provider ,
8693 connection ,
@@ -94,7 +101,10 @@ describe("autocrat_v0", async function () {
94101 USDC ,
95102 vaultProgram ,
96103 openbook ,
97- openbookTwap ;
104+ openbookTwap ,
105+ migrator ,
106+ treasuryMetaAccount ,
107+ treasuryUsdcAccount ;
98108
99109 before ( async function ( ) {
100110 context = await startAnchor (
@@ -133,6 +143,12 @@ describe("autocrat_v0", async function () {
133143 provider
134144 ) ;
135145
146+ migrator = new anchor . Program < AutocratMigrator > (
147+ AutocratMigratorIDL ,
148+ AUTOCRAT_MIGRATOR_PROGRAM_ID ,
149+ provider
150+ ) ;
151+
136152 payer = autocrat . provider . wallet . payer ;
137153
138154 USDC = await createMint (
@@ -142,6 +158,8 @@ describe("autocrat_v0", async function () {
142158 payer . publicKey ,
143159 6
144160 ) ;
161+
162+ META = await createMint ( banksClient , payer , dao , dao , 9 ) ;
145163 } ) ;
146164
147165 describe ( "#initialize_dao" , async function ( ) {
@@ -155,7 +173,6 @@ describe("autocrat_v0", async function () {
155173 autocrat . programId
156174 ) ;
157175
158- META = await createMint ( banksClient , payer , dao , dao , 9 ) ;
159176
160177 await autocrat . methods
161178 . initializeDao ( )
@@ -179,6 +196,9 @@ describe("autocrat_v0", async function () {
179196 assert . equal ( daoAcc . passThresholdBps , 500 ) ;
180197 assert . ok ( daoAcc . baseBurnLamports . eq ( new BN ( 1_000_000_000 ) . muln ( 50 ) ) ) ;
181198 assert . ok ( daoAcc . burnDecayPerSlotLamports . eq ( new BN ( 46_300 ) ) ) ;
199+
200+ treasuryMetaAccount = await createAssociatedTokenAccount ( banksClient , payer , META , daoTreasury ) ;
201+ treasuryUsdcAccount = await createAssociatedTokenAccount ( banksClient , payer , USDC , daoTreasury ) ;
182202 } ) ;
183203 } ) ;
184204
@@ -256,30 +276,55 @@ describe("autocrat_v0", async function () {
256276 aliceBaseFailConditionalTokenAccount ,
257277 aliceQuotePassConditionalTokenAccount ,
258278 aliceQuoteFailConditionalTokenAccount ,
259- newPassThresholdBps ;
279+ newPassThresholdBps ,
280+ instruction ;
281+
260282
261283 beforeEach ( async function ( ) {
262- const accounts = [
263- {
264- pubkey : dao ,
265- isSigner : false ,
266- isWritable : true ,
267- } ,
268- {
269- pubkey : daoTreasury ,
270- isSigner : true ,
271- isWritable : false ,
272- } ,
273- ] ;
274- newPassThresholdBps = Math . floor ( Math . random ( ) * 1000 ) ;
275- const data = autocrat . coder . instruction . encode ( "set_pass_threshold_bps" , {
276- passThresholdBps : newPassThresholdBps ,
277- } ) ;
278- const instruction = {
279- programId : autocrat . programId ,
280- accounts,
281- data,
282- } ;
284+ // const accounts = [
285+ // {
286+ // pubkey: dao,
287+ // isSigner: false,
288+ // isWritable: true,
289+ // },
290+ // {
291+ // pubkey: daoTreasury,
292+ // isSigner: true,
293+ // isWritable: false,
294+ // },
295+ // ];
296+ // newPassThresholdBps = Math.floor(Math.random() * 1000);
297+ // const data = autocrat.coder.instruction.encode("set_pass_threshold_bps", {
298+ // passThresholdBps: newPassThresholdBps,
299+ // });
300+ // const instruction = {
301+ // programId: autocrat.programId,
302+ // accounts,
303+ // data,
304+ // };
305+
306+ await mintToOverride ( context , treasuryMetaAccount , 1_000_000_000n ) ;
307+ await mintToOverride ( context , treasuryUsdcAccount , 1_000_000n ) ;
308+
309+ let receiver = Keypair . generate ( ) ;
310+ let to0 = await createAccount ( banksClient , payer , META , receiver . publicKey ) ;
311+ let to1 = await createAccount ( banksClient , payer , USDC , receiver . publicKey ) ;
312+
313+ const ix = await migrator . methods . multiTransfer2 ( )
314+ . accounts ( {
315+ authority : daoTreasury ,
316+ from0 : treasuryMetaAccount ,
317+ to0,
318+ from1 : treasuryUsdcAccount ,
319+ to1,
320+ } )
321+ . instruction ( ) ;
322+
323+ instruction = {
324+ programId : ix . programId ,
325+ accounts : ix . keys ,
326+ data : ix . data ,
327+ }
283328
284329 proposal = await initializeProposal (
285330 autocrat ,
@@ -700,7 +745,7 @@ describe("autocrat_v0", async function () {
700745 . signers ( [ mm0 . keypair ] )
701746 . rpc ( ) ;
702747
703- await autocrat . methods
748+ let tx = await autocrat . methods
704749 . finalizeProposal ( )
705750 . accounts ( {
706751 proposal,
@@ -713,13 +758,19 @@ describe("autocrat_v0", async function () {
713758 daoTreasury,
714759 } )
715760 . remainingAccounts (
716- autocrat . instruction . setPassThresholdBps
717- . accounts ( {
718- dao,
719- daoTreasury,
720- } )
761+ // autocrat.instruction.setPassThresholdBps
762+ // .accounts({
763+ // dao,
764+ // daoTreasury,
765+ // })
766+ // .concat({
767+ // pubkey: autocrat.programId,
768+ // isWritable: false,
769+ // isSigner: false,
770+ // })
771+ instruction . accounts
721772 . concat ( {
722- pubkey : autocrat . programId ,
773+ pubkey : migrator . programId ,
723774 isWritable : false ,
724775 isSigner : false ,
725776 } )
@@ -729,6 +780,7 @@ describe("autocrat_v0", async function () {
729780 : meta
730781 )
731782 )
783+ // .transaction();
732784 . rpc ( ) ;
733785
734786 let storedBaseVault = await vaultProgram . account . conditionalVault . fetch (
@@ -744,8 +796,11 @@ describe("autocrat_v0", async function () {
744796 storedProposal = await autocrat . account . proposal . fetch ( proposal ) ;
745797 assert . exists ( storedProposal . state . passed ) ;
746798
747- const storedDao = await autocrat . account . dao . fetch ( dao ) ;
748- assert . equal ( storedDao . passThresholdBps , newPassThresholdBps ) ;
799+ assert ( ( await getAccount ( banksClient , treasuryMetaAccount ) ) . amount == 0n ) ;
800+ assert ( ( await getAccount ( banksClient , treasuryUsdcAccount ) ) . amount == 0n ) ;
801+
802+ // const storedDao = await autocrat.account.dao.fetch(dao);
803+ // assert.equal(storedDao.passThresholdBps, newPassThresholdBps);
749804
750805 await redeemConditionalTokens (
751806 vaultProgram ,
0 commit comments