@@ -66,7 +66,7 @@ function settingsDatum(poolStakeHash: string, userPkh: string): string {
66
66
] ,
67
67
authorizedStakingKeys : [
68
68
{
69
- VKeyCredential : { bytes : poolStakeHash } ,
69
+ SCredential : { bytes : poolStakeHash } ,
70
70
}
71
71
] ,
72
72
baseFee : 1000000n ,
@@ -120,13 +120,15 @@ async function listOrder(lucid: Lucid, scripts: Scripts, userPkh: string, assets
120
120
} ,
121
121
scooperFee : scooperFee ,
122
122
destination : {
123
- address : {
124
- paymentCredential : {
125
- VKeyCredential : { bytes : userPkh } ,
123
+ Fixed : {
124
+ address : {
125
+ paymentCredential : {
126
+ VKeyCredential : { bytes : userPkh } ,
127
+ } ,
128
+ stakeCredential : null ,
126
129
} ,
127
- stakeCredential : null ,
130
+ datum : "NoDatum" ,
128
131
} ,
129
- datum : "NoDatum" ,
130
132
} ,
131
133
order : {
132
134
Swap : {
@@ -508,7 +510,9 @@ async function mintPool(scripts: Scripts, lucid: Lucid, userAddress: Address, se
508
510
identifier : toHex ( poolId ) ,
509
511
assets : assets ,
510
512
circulatingLp : liq ,
511
- feesPer10Thousand : fees ,
513
+ bidFeesPer10Thousand : fees ,
514
+ askFeesPer10Thousand : fees ,
515
+ feeManager : null ,
512
516
marketOpen : marketOpen || 0n ,
513
517
feeFinalized : marketOpen || 0n ,
514
518
protocolFees : 2_000_000n ,
@@ -536,6 +540,17 @@ async function mintPool(scripts: Scripts, lucid: Lucid, userAddress: Address, se
536
540
const poolMintRedeemerBytes = Data . to ( poolMintRedeemer , types . PoolMintRedeemer ) ;
537
541
const poolDatumBytes = Data . to ( newPoolDatum , types . PoolDatum ) ;
538
542
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
+
539
554
console . log ( "value: " ) ;
540
555
console . log ( poolValue ) ;
541
556
console . log ( "newPoolDatum: " ) ;
@@ -544,6 +559,8 @@ async function mintPool(scripts: Scripts, lucid: Lucid, userAddress: Address, se
544
559
console . log ( poolMintRedeemerBytes ) ;
545
560
console . log ( "settings datum: " ) ;
546
561
console . log ( settings . datum ) ;
562
+ console . log ( "pool address: " ) ;
563
+ console . log ( poolAddress ) ;
547
564
console . log ( "-------" ) ;
548
565
console . log ( "seed: " , seed ) ;
549
566
const tx = lucid . newTx ( )
@@ -554,15 +571,19 @@ async function mintPool(scripts: Scripts, lucid: Lucid, userAddress: Address, se
554
571
} , poolMintRedeemerBytes )
555
572
. readFrom ( [ ...references , settings ] )
556
573
. collectFrom ( [ seed ] )
557
- . payToContract ( scripts . poolAddress , { inline : poolDatumBytes } , poolValue )
574
+ . payToContract ( poolAddress , { inline : poolDatumBytes } , poolValue )
558
575
. payToAddress ( userAddress , {
559
576
"lovelace" : 2_000_000n ,
560
577
[ toUnit ( scripts . poolPolicyId , poolLqNameHex ) ] : liq ,
561
578
} )
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
+ ) ;
566
587
567
588
const str = await tx . toString ( ) ;
568
589
console . log ( "building tx: " + str ) ;
@@ -644,8 +665,8 @@ async function testMintPool(lucid: Lucid, emulator: Emulator, scripts: Scripts,
644
665
const settings = settingsUtxos [ 0 ] ;
645
666
646
667
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 ) ;
649
670
return minted ;
650
671
}
651
672
@@ -739,16 +760,16 @@ async function executeOrder(poolABL: ABL, poolDatum: types.PoolDatum, order: UTx
739
760
let res : ABL = { a : 0n , b : 0n , liq : 0n } ;
740
761
if ( "Swap" in orderDatum . order ) {
741
762
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 ) ;
743
764
console . log ( "after swapping for coinA, poolABL will be: " ) ;
744
765
console . log ( poolABL ) ;
745
766
} 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 ) ;
747
768
} else {
748
769
throw new Error ( "Order does not appear to match the pool" ) ;
749
770
}
750
771
}
751
- const dest = await fromOrderDatumAddress ( orderDatum . destination . address ) ;
772
+ const dest = await fromOrderDatumAddress ( orderDatum . destination . Fixed . address ) ;
752
773
return [ poolABL , {
753
774
abl : res ,
754
775
destination : dest ,
@@ -828,9 +849,9 @@ async function scoopPool(scripts: Scripts, lucid: Lucid, userAddress: Address, s
828
849
toSpend . push ( ...orderUtxos ) ;
829
850
toSpend . sort ( ( a , b ) => a . txHash == b . txHash ? a . outputIndex - b . outputIndex : ( a . txHash < b . txHash ? - 1 : 1 ) ) ;
830
851
for ( let e of toSpend ) {
831
- if ( e . address == scripts . poolAddress ) {
852
+ if ( getAddressDetails ( e . address ) . paymentCredential . hash == scripts . poolScriptHash ) {
832
853
tx . collectFrom ( [ e ] , redeemerData ) ;
833
- } else if ( e . address == scripts . orderAddress ) {
854
+ } else if ( getAddressDetails ( e . address ) . paymentCredential . hash == scripts . orderScriptHash ) {
834
855
tx . collectFrom ( [ e ] , Data . to ( orderScoopRedeemer , types . OrderRedeemer ) ) ;
835
856
} else {
836
857
tx . collectFrom ( [ e ] ) ;
@@ -856,7 +877,7 @@ async function scoopPool(scripts: Scripts, lucid: Lucid, userAddress: Address, s
856
877
. addSigner ( userAddress )
857
878
. withdraw ( scripts . steakAddress , 0n , "00" )
858
879
859
- . payToContract ( scripts . poolAddress , { inline : newPoolDatum } , {
880
+ . payToContract ( targetPool . address , { inline : newPoolDatum } , {
860
881
"lovelace" :
861
882
newPoolABL . a +
862
883
poolDatum . protocolFees ,
@@ -920,7 +941,18 @@ async function testScoopPool(lucid: Lucid, emulator: Emulator, scripts: Scripts,
920
941
}
921
942
const settings = settingsUtxos [ 0 ] ;
922
943
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 ) ;
924
956
925
957
let targetPool = null ;
926
958
for ( let knownPool of knownPools ) {
@@ -1060,8 +1092,8 @@ const accounts: any[] = [
1060
1092
] ;
1061
1093
let emulator = new Emulator ( accounts , {
1062
1094
...PROTOCOL_PARAMETERS_DEFAULT ,
1063
- // maxTxSize: 999999999999,
1064
- // maxTxExMem: 999999999999999n,
1095
+ maxTxSize : 999999999999 ,
1096
+ maxTxExMem : 999999999999999n ,
1065
1097
} ) ;
1066
1098
let lucid = await Lucid . new ( emulator ) ;
1067
1099
@@ -1128,7 +1160,7 @@ emulator.ledger["000000000000000000000000000000000000000000000000000000000000000
1128
1160
1129
1161
const listOrdersChange = emulator . ledger [ "00000000000000000000000000000000000000000000000000000000000000001" ] . utxo ;
1130
1162
1131
- const { listedHash, utxos : orders } =
1163
+ const { listedHash, utxos : orders } =
1132
1164
await testListOrder ( lucid , emulator , scripts , "lovelace" , rberry , listOrdersChange , poolId , 40n ) ;
1133
1165
1134
1166
const scoopPoolChange = await findChange ( emulator , userAddress ) ;
0 commit comments