@@ -237,7 +237,7 @@ describe("autocrat_v0", async function () {
237237 assert ( balanceAfter < balanceBefore - 1_000_000_000n * 30n ) ;
238238 console . log ( balanceAfter ) ;
239239
240- assert ( balanceAfter > balanceBefore - 1_000_000_000n * 31n ) ;
240+ assert ( balanceAfter > balanceBefore - 1_000_000_000n * 35n ) ;
241241 } ) ;
242242 } ) ;
243243
@@ -1132,125 +1132,34 @@ async function initializeProposal(
11321132
11331133 let baseNonce = new BN ( storedDAO . proposalCount ) ;
11341134
1135- const basePassVault = await initializeVault (
1135+ const baseVault = await initializeVault (
11361136 vaultProgram ,
11371137 storedDAO . treasury ,
11381138 storedDAO . metaMint ,
11391139 baseNonce ,
11401140 payer
11411141 ) ;
11421142
1143- const quotePassVault = await initializeVault (
1143+ const quoteVault = await initializeVault (
11441144 vaultProgram ,
11451145 storedDAO . treasury ,
11461146 storedDAO . usdcMint ,
11471147 baseNonce . or ( new BN ( 1 ) . shln ( 63 ) ) ,
11481148 payer
11491149 ) ;
11501150
1151- const baseFailVault = await initializeVault (
1152- vaultProgram ,
1153- storedDAO . treasury ,
1154- storedDAO . metaMint ,
1155- baseNonce . or ( new BN ( 1 ) . shln ( 62 ) ) ,
1156- payer
1157- ) ;
1158-
1159- const quoteFailVault = await initializeVault (
1160- vaultProgram ,
1161- storedDAO . treasury ,
1162- storedDAO . usdcMint ,
1163- baseNonce . or ( new BN ( 3 ) . shln ( 62 ) ) ,
1164- payer
1165- ) ;
1166-
11671151 const passBaseMint = (
1168- await vaultProgram . account . conditionalVault . fetch ( basePassVault )
1169- ) . conditionalTokenMint ;
1152+ await vaultProgram . account . conditionalVault . fetch ( baseVault )
1153+ ) . conditionalOnFinalizeTokenMint ;
11701154 const passQuoteMint = (
1171- await vaultProgram . account . conditionalVault . fetch ( quotePassVault )
1172- ) . conditionalTokenMint ;
1155+ await vaultProgram . account . conditionalVault . fetch ( quoteVault )
1156+ ) . conditionalOnFinalizeTokenMint ;
11731157 const failBaseMint = (
1174- await vaultProgram . account . conditionalVault . fetch ( baseFailVault )
1175- ) . conditionalTokenMint ;
1158+ await vaultProgram . account . conditionalVault . fetch ( baseVault )
1159+ ) . conditionalOnRevertTokenMint ;
11761160 const failQuoteMint = (
1177- await vaultProgram . account . conditionalVault . fetch ( quoteFailVault )
1178- ) . conditionalTokenMint ;
1179-
1180- const [ passMarket ] = anchor . web3 . PublicKey . findProgramAddressSync (
1181- [
1182- anchor . utils . bytes . utf8 . encode ( "order_book" ) ,
1183- passBaseMint . toBuffer ( ) ,
1184- passQuoteMint . toBuffer ( ) ,
1185- ] ,
1186- clobProgram . programId
1187- ) ;
1188-
1189- const [ failMarket ] = anchor . web3 . PublicKey . findProgramAddressSync (
1190- [
1191- anchor . utils . bytes . utf8 . encode ( "order_book" ) ,
1192- failBaseMint . toBuffer ( ) ,
1193- failQuoteMint . toBuffer ( ) ,
1194- ] ,
1195- clobProgram . programId
1196- ) ;
1197-
1198- const passBaseVault = await token . getAssociatedTokenAddress (
1199- passBaseMint ,
1200- passMarket ,
1201- true
1202- ) ;
1203-
1204- const passQuoteVault = await token . getAssociatedTokenAddress (
1205- passQuoteMint ,
1206- passMarket ,
1207- true
1208- ) ;
1209-
1210- const failBaseVault = await token . getAssociatedTokenAddress (
1211- failBaseMint ,
1212- failMarket ,
1213- true
1214- ) ;
1215-
1216- const failQuoteVault = await token . getAssociatedTokenAddress (
1217- failQuoteMint ,
1218- failMarket ,
1219- true
1220- ) ;
1221-
1222- const [ globalState ] = anchor . web3 . PublicKey . findProgramAddressSync (
1223- [ anchor . utils . bytes . utf8 . encode ( "WWCACOTMICMIBMHAFTTWYGHMB" ) ] ,
1224- clobProgram . programId
1225- ) ;
1226-
1227- await clobProgram . methods
1228- . initializeOrderBook ( )
1229- . accounts ( {
1230- orderBook : passMarket ,
1231- globalState,
1232- payer : payer . publicKey ,
1233- systemProgram : anchor . web3 . SystemProgram . programId ,
1234- base : passBaseMint ,
1235- quote : passQuoteMint ,
1236- baseVault : passBaseVault ,
1237- quoteVault : passQuoteVault ,
1238- } )
1239- . rpc ( ) ;
1240-
1241- await clobProgram . methods
1242- . initializeOrderBook ( )
1243- . accounts ( {
1244- orderBook : failMarket ,
1245- globalState,
1246- payer : payer . publicKey ,
1247- systemProgram : anchor . web3 . SystemProgram . programId ,
1248- base : failBaseMint ,
1249- quote : failQuoteMint ,
1250- baseVault : failBaseVault ,
1251- quoteVault : failQuoteVault ,
1252- } )
1253- . rpc ( ) ;
1161+ await vaultProgram . account . conditionalVault . fetch ( quoteVault )
1162+ ) . conditionalOnRevertTokenMint ;
12541163
12551164 const [ daoTreasury ] = PublicKey . findProgramAddressSync (
12561165 [ dao . toBuffer ( ) ] ,
@@ -1270,7 +1179,7 @@ async function initializeProposal(
12701179
12711180 let openbookPassMarket = await openbook . createMarket (
12721181 payer ,
1273- "fMETA/fUSDC " ,
1182+ "pMETA/pUSDC " ,
12741183 passQuoteMint ,
12751184 passBaseMint ,
12761185 new BN ( 100 ) ,
@@ -1335,10 +1244,8 @@ async function initializeProposal(
13351244 proposal : proposalKeypair . publicKey ,
13361245 dao,
13371246 daoTreasury,
1338- quotePassVault,
1339- quoteFailVault,
1340- basePassVault,
1341- baseFailVault,
1247+ baseVault,
1248+ quoteVault,
13421249 openbookTwapPassMarket,
13431250 openbookTwapFailMarket,
13441251 openbookPassMarket,
@@ -1393,28 +1300,29 @@ async function initializeVault(
13931300 ] ,
13941301 vaultProgram . programId
13951302 ) ;
1396- const conditionalTokenMintKeypair = Keypair . generate ( ) ;
1303+ const conditionalOnFinalizeTokenMintKeypair = Keypair . generate ( ) ;
1304+ const conditionalOnRevertTokenMintKeypair = Keypair . generate ( ) ;
13971305
13981306 const vaultUnderlyingTokenAccount = await token . getAssociatedTokenAddress (
13991307 underlyingTokenMint ,
14001308 vault ,
14011309 true
14021310 ) ;
1403-
1404- await vaultProgram . methods
1405- . initializeConditionalVault ( settlementAuthority , nonce )
1406- . accounts ( {
1407- vault ,
1408- underlyingTokenMint ,
1409- vaultUnderlyingTokenAccount ,
1410- conditionalTokenMint : conditionalTokenMintKeypair . publicKey ,
1411- payer : payer . publicKey ,
1412- tokenProgram : token . TOKEN_PROGRAM_ID ,
1413- associatedTokenProgram : token . ASSOCIATED_TOKEN_PROGRAM_ID ,
1414- systemProgram : anchor . web3 . SystemProgram . programId ,
1415- } )
1416- . signers ( [ conditionalTokenMintKeypair ] )
1417- . rpc ( ) ;
1311+ await vaultProgram . methods
1312+ . initializeConditionalVault ( settlementAuthority , nonce )
1313+ . accounts ( {
1314+ vault ,
1315+ underlyingTokenMint ,
1316+ vaultUnderlyingTokenAccount ,
1317+ conditionalOnFinalizeTokenMint : conditionalOnFinalizeTokenMintKeypair . publicKey ,
1318+ conditionalOnRevertTokenMint : conditionalOnRevertTokenMintKeypair . publicKey ,
1319+ payer : payer . publicKey ,
1320+ tokenProgram : token . TOKEN_PROGRAM_ID ,
1321+ associatedTokenProgram : token . ASSOCIATED_TOKEN_PROGRAM_ID ,
1322+ systemProgram : anchor . web3 . SystemProgram . programId ,
1323+ } )
1324+ . signers ( [ conditionalOnFinalizeTokenMintKeypair , conditionalOnRevertTokenMintKeypair ] )
1325+ . rpc ( ) ;
14181326
14191327 return vault ;
14201328}
0 commit comments