@@ -66,7 +66,7 @@ function settingsDatum(poolStakeHash: string, userPkh: string): string {
6666 ] ,
6767 authorizedStakingKeys : [
6868 {
69- VKeyCredential : { bytes : poolStakeHash } ,
69+ SCredential : { bytes : poolStakeHash } ,
7070 }
7171 ] ,
7272 baseFee : 1000000n ,
@@ -120,13 +120,15 @@ async function listOrder(lucid: Lucid, scripts: Scripts, userPkh: string, assets
120120 } ,
121121 scooperFee : scooperFee ,
122122 destination : {
123- address : {
124- paymentCredential : {
125- VKeyCredential : { bytes : userPkh } ,
123+ Fixed : {
124+ address : {
125+ paymentCredential : {
126+ VKeyCredential : { bytes : userPkh } ,
127+ } ,
128+ stakeCredential : null ,
126129 } ,
127- stakeCredential : null ,
130+ datum : "NoDatum" ,
128131 } ,
129- datum : "NoDatum" ,
130132 } ,
131133 order : {
132134 Swap : {
@@ -508,7 +510,9 @@ async function mintPool(scripts: Scripts, lucid: Lucid, userAddress: Address, se
508510 identifier : toHex ( poolId ) ,
509511 assets : assets ,
510512 circulatingLp : liq ,
511- feesPer10Thousand : fees ,
513+ bidFeesPer10Thousand : fees ,
514+ askFeesPer10Thousand : fees ,
515+ feeManager : null ,
512516 marketOpen : marketOpen || 0n ,
513517 feeFinalized : marketOpen || 0n ,
514518 protocolFees : 2_000_000n ,
@@ -536,6 +540,17 @@ async function mintPool(scripts: Scripts, lucid: Lucid, userAddress: Address, se
536540 const poolMintRedeemerBytes = Data . to ( poolMintRedeemer , types . PoolMintRedeemer ) ;
537541 const poolDatumBytes = Data . to ( newPoolDatum , types . PoolDatum ) ;
538542
543+ const poolAddress = ( new Utils ( lucid ) ) . credentialToAddress (
544+ {
545+ type : "Script" ,
546+ hash : scripts . poolScriptHash ,
547+ } ,
548+ {
549+ type : "Script" ,
550+ hash : scripts . poolStakeHash ,
551+ }
552+ ) ;
553+
539554 console . log ( "value: " ) ;
540555 console . log ( poolValue ) ;
541556 console . log ( "newPoolDatum: " ) ;
@@ -544,6 +559,8 @@ async function mintPool(scripts: Scripts, lucid: Lucid, userAddress: Address, se
544559 console . log ( poolMintRedeemerBytes ) ;
545560 console . log ( "settings datum: " ) ;
546561 console . log ( settings . datum ) ;
562+ console . log ( "pool address: " ) ;
563+ console . log ( poolAddress ) ;
547564 console . log ( "-------" ) ;
548565 console . log ( "seed: " , seed ) ;
549566 const tx = lucid . newTx ( )
@@ -554,15 +571,19 @@ async function mintPool(scripts: Scripts, lucid: Lucid, userAddress: Address, se
554571 } , poolMintRedeemerBytes )
555572 . readFrom ( [ ...references , settings ] )
556573 . collectFrom ( [ seed ] )
557- . payToContract ( scripts . poolAddress , { inline : poolDatumBytes } , poolValue )
574+ . payToContract ( poolAddress , { inline : poolDatumBytes } , poolValue )
558575 . payToAddress ( userAddress , {
559576 "lovelace" : 2_000_000n ,
560577 [ toUnit ( scripts . poolPolicyId , poolLqNameHex ) ] : liq ,
561578 } )
562- . payToAddress ( userAddress , {
563- "lovelace" : 2_000_000n ,
564- [ toUnit ( scripts . poolPolicyId , poolRefNameHex ) ] : 1n ,
565- } ) ;
579+ . payToAddressWithData (
580+ userAddress ,
581+ { inline : "d87980" } ,
582+ {
583+ "lovelace" : 2_000_000n ,
584+ [ toUnit ( scripts . poolPolicyId , poolRefNameHex ) ] : 1n ,
585+ }
586+ ) ;
566587
567588 const str = await tx . toString ( ) ;
568589 console . log ( "building tx: " + str ) ;
@@ -644,8 +665,8 @@ async function testMintPool(lucid: Lucid, emulator: Emulator, scripts: Scripts,
644665 const settings = settingsUtxos [ 0 ] ;
645666
646667 const minted = await mintPool ( scripts , lucid , userAddress , settings , [ refUtxo ] , assets , seed , 1_000_000_000n , 1_000_000_000n , [ 5n , 5n ] ) ;
647- await emulator . awaitTx ( minted . mintedHash ) ;
648- console . log ( "Minted a pool, hash: " + minted . mintedHash ) ;
668+ await emulator . awaitTx ( minted . poolMintedHash ) ;
669+ console . log ( "Minted a pool, hash: " + minted . poolMintedHash ) ;
649670 return minted ;
650671}
651672
@@ -739,16 +760,16 @@ async function executeOrder(poolABL: ABL, poolDatum: types.PoolDatum, order: UTx
739760 let res : ABL = { a : 0n , b : 0n , liq : 0n } ;
740761 if ( "Swap" in orderDatum . order ) {
741762 if ( orderDatum . order . Swap . offer [ 0 ] + orderDatum . order . Swap . offer [ 1 ] == poolCoinA ) {
742- [ res , poolABL ] = doSwap ( Coin . CoinA , orderDatum . order . Swap . offer [ 2 ] , poolDatum . feesPer10Thousand , poolABL ) ;
763+ [ res , poolABL ] = doSwap ( Coin . CoinA , orderDatum . order . Swap . offer [ 2 ] , poolDatum . bidFeesPer10Thousand , poolABL ) ;
743764 console . log ( "after swapping for coinA, poolABL will be: " ) ;
744765 console . log ( poolABL ) ;
745766 } else if ( orderDatum . order . Swap . offer [ 0 ] + orderDatum . order . Swap . offer [ 1 ] == poolCoinB ) {
746- [ res , poolABL ] = doSwap ( Coin . CoinB , orderDatum . order . Swap . offer [ 2 ] , poolDatum . feesPer10Thousand , poolABL ) ;
767+ [ res , poolABL ] = doSwap ( Coin . CoinB , orderDatum . order . Swap . offer [ 2 ] , poolDatum . askFeesPer10Thousand , poolABL ) ;
747768 } else {
748769 throw new Error ( "Order does not appear to match the pool" ) ;
749770 }
750771 }
751- const dest = await fromOrderDatumAddress ( orderDatum . destination . address ) ;
772+ const dest = await fromOrderDatumAddress ( orderDatum . destination . Fixed . address ) ;
752773 return [ poolABL , {
753774 abl : res ,
754775 destination : dest ,
@@ -828,9 +849,9 @@ async function scoopPool(scripts: Scripts, lucid: Lucid, userAddress: Address, s
828849 toSpend . push ( ...orderUtxos ) ;
829850 toSpend . sort ( ( a , b ) => a . txHash == b . txHash ? a . outputIndex - b . outputIndex : ( a . txHash < b . txHash ? - 1 : 1 ) ) ;
830851 for ( let e of toSpend ) {
831- if ( e . address == scripts . poolAddress ) {
852+ if ( getAddressDetails ( e . address ) . paymentCredential . hash == scripts . poolScriptHash ) {
832853 tx . collectFrom ( [ e ] , redeemerData ) ;
833- } else if ( e . address == scripts . orderAddress ) {
854+ } else if ( getAddressDetails ( e . address ) . paymentCredential . hash == scripts . orderScriptHash ) {
834855 tx . collectFrom ( [ e ] , Data . to ( orderScoopRedeemer , types . OrderRedeemer ) ) ;
835856 } else {
836857 tx . collectFrom ( [ e ] ) ;
@@ -856,7 +877,7 @@ async function scoopPool(scripts: Scripts, lucid: Lucid, userAddress: Address, s
856877 . addSigner ( userAddress )
857878 . withdraw ( scripts . steakAddress , 0n , "00" )
858879
859- . payToContract ( scripts . poolAddress , { inline : newPoolDatum } , {
880+ . payToContract ( targetPool . address , { inline : newPoolDatum } , {
860881 "lovelace" :
861882 newPoolABL . a +
862883 poolDatum . protocolFees ,
@@ -920,7 +941,18 @@ async function testScoopPool(lucid: Lucid, emulator: Emulator, scripts: Scripts,
920941 }
921942 const settings = settingsUtxos [ 0 ] ;
922943
923- let knownPools = await emulator . getUtxos ( scripts . poolAddress ) ;
944+ const poolAddress = ( new Utils ( lucid ) ) . credentialToAddress (
945+ {
946+ type : "Script" ,
947+ hash : scripts . poolScriptHash ,
948+ } ,
949+ {
950+ type : "Script" ,
951+ hash : scripts . poolStakeHash ,
952+ }
953+ ) ;
954+
955+ let knownPools = await emulator . getUtxos ( poolAddress ) ;
924956
925957 let targetPool = null ;
926958 for ( let knownPool of knownPools ) {
@@ -1060,8 +1092,8 @@ const accounts: any[] = [
10601092] ;
10611093let emulator = new Emulator ( accounts , {
10621094 ...PROTOCOL_PARAMETERS_DEFAULT ,
1063- // maxTxSize: 999999999999,
1064- // maxTxExMem: 999999999999999n,
1095+ maxTxSize : 999999999999 ,
1096+ maxTxExMem : 999999999999999n ,
10651097} ) ;
10661098let lucid = await Lucid . new ( emulator ) ;
10671099
@@ -1128,7 +1160,7 @@ emulator.ledger["000000000000000000000000000000000000000000000000000000000000000
11281160
11291161const listOrdersChange = emulator . ledger [ "00000000000000000000000000000000000000000000000000000000000000001" ] . utxo ;
11301162
1131- const { listedHash, utxos : orders } =
1163+ const { listedHash, utxos : orders } =
11321164 await testListOrder ( lucid , emulator , scripts , "lovelace" , rberry , listOrdersChange , poolId , 40n ) ;
11331165
11341166const scoopPoolChange = await findChange ( emulator , userAddress ) ;
0 commit comments