@indigo-labs/indigo-sdk 0.4.4 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/index.d.mts +102 -40
  2. package/dist/index.d.ts +102 -40
  3. package/dist/index.js +900 -801
  4. package/dist/index.mjs +339 -256
  5. package/package.json +2 -2
  6. package/src/contracts/cdp/helpers.ts +7 -6
  7. package/src/contracts/cdp/transactions.ts +8 -29
  8. package/src/contracts/gov/transactions.ts +12 -16
  9. package/src/contracts/iasset/helpers.ts +2 -7
  10. package/src/contracts/initialize/actions.ts +0 -2
  11. package/src/contracts/initialize/helpers.ts +0 -4
  12. package/src/contracts/interest-collection/transactions.ts +2 -5
  13. package/src/contracts/interest-oracle/helpers.ts +4 -0
  14. package/src/contracts/interest-oracle/transactions.ts +1 -4
  15. package/src/contracts/price-oracle/helpers.ts +5 -11
  16. package/src/contracts/price-oracle/transactions.ts +2 -7
  17. package/src/contracts/rob/transactions.ts +0 -2
  18. package/src/contracts/rob-leverage/transactions.ts +1 -4
  19. package/src/contracts/stability-pool/transactions.ts +2 -8
  20. package/src/contracts/stableswap/helpers.ts +369 -1
  21. package/src/contracts/stableswap/transactions.ts +43 -191
  22. package/src/contracts/staking/transactions.ts +2 -7
  23. package/tests/cdp/actions.ts +0 -11
  24. package/tests/cdp/cdp-helpers.ts +2 -2
  25. package/tests/cdp/cdp-queries.ts +1 -3
  26. package/tests/cdp/cdp.test.ts +409 -620
  27. package/tests/cdp/transactions-mutated.ts +30 -25
  28. package/tests/endpoints/initialize.ts +0 -2
  29. package/tests/gov/actions.ts +7 -32
  30. package/tests/gov/gov.test.ts +169 -401
  31. package/tests/indigo-test-helpers.ts +0 -1
  32. package/tests/initialize.test.ts +15 -20
  33. package/tests/interest-collection/interest-collection.test.ts +0 -4
  34. package/tests/interest-oracle.test.ts +1 -8
  35. package/tests/price-oracle/actions.ts +6 -8
  36. package/tests/price-oracle/price-oracle.test.ts +1 -13
  37. package/tests/price-oracle/transactions-mutated.ts +1 -4
  38. package/tests/pyth/pyth-indigo.test.ts +8 -12
  39. package/tests/pyth/pyth.test.ts +1 -2
  40. package/tests/rob/actions.ts +0 -2
  41. package/tests/rob/rob-leverage.test.ts +164 -220
  42. package/tests/rob/rob.test.ts +158 -263
  43. package/tests/rob/transactions-mutated.ts +7 -18
  44. package/tests/stability-pool/actions.ts +4 -8
  45. package/tests/stability-pool.test.ts +164 -255
  46. package/tests/stableswap/stableswap-actions.ts +0 -1
  47. package/tests/stableswap/stableswap.test.ts +226 -4
  48. package/tests/staking.test.ts +2 -13
  49. package/tests/treasury/treasury.test.ts +6 -30
package/dist/index.js CHANGED
@@ -147,6 +147,7 @@ __export(index_exports, {
147
147
  createStableswapOrder: () => createStableswapOrder,
148
148
  decodePriceUpdate: () => decodePriceUpdate,
149
149
  decodePythMessage: () => decodePythMessage,
150
+ defaultOrderProcessingConfig: () => defaultOrderProcessingConfig,
150
151
  depositCdp: () => depositCdp,
151
152
  deriveAuthToken: () => deriveAuthToken,
152
153
  derivePythPrice: () => derivePythPrice,
@@ -310,7 +311,9 @@ __export(index_exports, {
310
311
  parseStakingRedeemer: () => parseStakingRedeemer,
311
312
  parseStakingRedeemerOrThrow: () => parseStakingRedeemerOrThrow,
312
313
  partitionEpochToScaleToSums: () => partitionEpochToScaleToSums,
314
+ pickValidSatisfiableOrders: () => pickValidSatisfiableOrders,
313
315
  processSpRequest: () => processSpRequest,
316
+ psmOrderType: () => psmOrderType,
314
317
  randomRobsSubsetSatisfyingTargetCollateral: () => randomRobsSubsetSatisfyingTargetCollateral,
315
318
  rationalAdd: () => rationalAdd,
316
319
  rationalCeil: () => rationalCeil,
@@ -384,6 +387,7 @@ __export(index_exports, {
384
387
  startPriceOracleTx: () => startPriceOracleTx,
385
388
  submitTx: () => submitTx,
386
389
  sum: () => sum,
390
+ summariseOrder: () => summariseOrder,
387
391
  summarizeActualLeverageRedemptions: () => summarizeActualLeverageRedemptions,
388
392
  toAssetClassFromLucid: () => toAssetClassFromLucid,
389
393
  toDataDerivedPythPrice: () => toDataDerivedPythPrice,
@@ -405,7 +409,7 @@ __export(index_exports, {
405
409
  module.exports = __toCommonJS(index_exports);
406
410
 
407
411
  // src/contracts/cdp/transactions.ts
408
- var import_lucid14 = require("@lucid-evolution/lucid");
412
+ var import_lucid12 = require("@lucid-evolution/lucid");
409
413
 
410
414
  // src/types/system-params.ts
411
415
  var import_lucid = require("@lucid-evolution/lucid");
@@ -815,13 +819,11 @@ function calculateAccruedInterest(now, unitaryInterestSnapshot, mintedAmount, in
815
819
  }
816
820
 
817
821
  // src/contracts/price-oracle/helpers.ts
818
- var import_lucid3 = require("@lucid-evolution/lucid");
819
- function oracleExpirationAwareValidity(currentSlot, biasTime, oracleExpiration, network) {
820
- const validateFrom = (0, import_lucid3.slotToUnixTime)(network, currentSlot - 1);
822
+ function oracleExpirationAwareValidity(lucid, biasTime, oracleExpiration) {
823
+ const validateFrom = lucid.slotToUnixTime(lucid.currentSlot() - 1);
821
824
  const defaultValidateTo = validateFrom + biasTime;
822
- const cappedValidateTo = (0, import_lucid3.slotToUnixTime)(
823
- network,
824
- (0, import_lucid3.unixTimeToSlot)(network, oracleExpiration) - 1
825
+ const cappedValidateTo = lucid.slotToUnixTime(
826
+ lucid.unixTimeToSlot(oracleExpiration) - 1
825
827
  );
826
828
  const isOracleActuallyExpired = cappedValidateTo <= validateFrom;
827
829
  return {
@@ -834,7 +836,6 @@ function oracleExpirationAwareValidity(currentSlot, biasTime, oracleExpiration,
834
836
  var import_ts_pattern14 = require("ts-pattern");
835
837
 
836
838
  // src/contracts/cdp/helpers.ts
837
- var import_lucid4 = require("@lucid-evolution/lucid");
838
839
  var import_ts_pattern5 = require("ts-pattern");
839
840
 
840
841
  // src/utils/indigo-helpers.ts
@@ -852,11 +853,10 @@ function iassetValueOfCollateral(collateralAmt, oraclePrice) {
852
853
  rationalDiv(rationalFromInt(collateralAmt), oraclePrice)
853
854
  );
854
855
  }
855
- function cdpCollateralRatioPercentage(currentSlot, iassetPrice, cdpUtxoAssets, cdpContent, interestOracleDatum, network) {
856
- const currentTime = BigInt((0, import_lucid4.slotToUnixTime)(network, currentSlot));
856
+ function cdpCollateralRatioPercentage(now, iassetPrice, cdpUtxoAssets, cdpContent, interestOracleDatum) {
857
857
  return (0, import_ts_pattern5.match)(cdpContent.cdpFees).with({ ActiveCDPInterestTracking: import_ts_pattern5.P.select() }, (interest) => {
858
858
  const interestAmt = calculateAccruedInterest(
859
- currentTime,
859
+ now,
860
860
  interest.unitaryInterestSnapshot,
861
861
  cdpContent.mintedAmt,
862
862
  interest.lastSettled,
@@ -1214,7 +1214,7 @@ function spZeroNegatives(a) {
1214
1214
  }
1215
1215
 
1216
1216
  // src/contracts/stability-pool/helpers.ts
1217
- var import_lucid8 = require("@lucid-evolution/lucid");
1217
+ var import_lucid6 = require("@lucid-evolution/lucid");
1218
1218
  var import_fp_ts4 = require("fp-ts");
1219
1219
  var import_cardano_offchain_common3 = require("@3rd-eye-labs/cardano-offchain-common");
1220
1220
 
@@ -1296,45 +1296,45 @@ var repsertWithReadonlyArr = (predicate, replaceVal, newVal, mkKey) => (arr) =>
1296
1296
  var import_ts_pattern7 = require("ts-pattern");
1297
1297
 
1298
1298
  // src/contracts/stability-pool/scripts.ts
1299
- var import_lucid7 = require("@lucid-evolution/lucid");
1299
+ var import_lucid5 = require("@lucid-evolution/lucid");
1300
1300
 
1301
1301
  // src/contracts/stability-pool/types.ts
1302
- var import_lucid6 = require("@lucid-evolution/lucid");
1302
+ var import_lucid4 = require("@lucid-evolution/lucid");
1303
1303
 
1304
1304
  // src/types/generic.ts
1305
- var import_lucid5 = require("@lucid-evolution/lucid");
1306
- var AssetClassSchema2 = import_lucid5.Data.Object({
1307
- currencySymbol: import_lucid5.Data.Bytes(),
1305
+ var import_lucid3 = require("@lucid-evolution/lucid");
1306
+ var AssetClassSchema2 = import_lucid3.Data.Object({
1307
+ currencySymbol: import_lucid3.Data.Bytes(),
1308
1308
  /** Use the HEX encoding */
1309
- tokenName: import_lucid5.Data.Bytes()
1309
+ tokenName: import_lucid3.Data.Bytes()
1310
1310
  });
1311
1311
  function toAssetClassFromLucid(asset) {
1312
1312
  return {
1313
- currencySymbol: (0, import_lucid5.fromHex)(asset.currencySymbol),
1314
- tokenName: (0, import_lucid5.fromHex)(asset.tokenName)
1313
+ currencySymbol: (0, import_lucid3.fromHex)(asset.currencySymbol),
1314
+ tokenName: (0, import_lucid3.fromHex)(asset.tokenName)
1315
1315
  };
1316
1316
  }
1317
1317
  function getAssetClassComparisonStr(asset) {
1318
- return `${(0, import_lucid5.toHex)(asset.currencySymbol)}${(0, import_lucid5.toHex)(asset.tokenName)}`;
1318
+ return `${(0, import_lucid3.toHex)(asset.currencySymbol)}${(0, import_lucid3.toHex)(asset.tokenName)}`;
1319
1319
  }
1320
- var VerificationKeyHashSchema = import_lucid5.Data.Bytes();
1321
- var CredentialSchema = import_lucid5.Data.Enum([
1322
- import_lucid5.Data.Object({
1323
- PublicKeyCredential: import_lucid5.Data.Tuple([VerificationKeyHashSchema])
1320
+ var VerificationKeyHashSchema = import_lucid3.Data.Bytes();
1321
+ var CredentialSchema = import_lucid3.Data.Enum([
1322
+ import_lucid3.Data.Object({
1323
+ PublicKeyCredential: import_lucid3.Data.Tuple([VerificationKeyHashSchema])
1324
1324
  }),
1325
- import_lucid5.Data.Object({
1326
- ScriptCredential: import_lucid5.Data.Tuple([import_lucid5.Data.Bytes()])
1325
+ import_lucid3.Data.Object({
1326
+ ScriptCredential: import_lucid3.Data.Tuple([import_lucid3.Data.Bytes()])
1327
1327
  })
1328
1328
  ]);
1329
1329
  var CredentialD = CredentialSchema;
1330
- var StakeCredentialSchema = import_lucid5.Data.Enum([
1331
- import_lucid5.Data.Object({ Inline: import_lucid5.Data.Tuple([CredentialSchema]) }),
1332
- import_lucid5.Data.Object({
1333
- Pointer: import_lucid5.Data.Tuple([
1334
- import_lucid5.Data.Object({
1335
- slotNumber: import_lucid5.Data.Integer(),
1336
- transactionIndex: import_lucid5.Data.Integer(),
1337
- certificateIndex: import_lucid5.Data.Integer()
1330
+ var StakeCredentialSchema = import_lucid3.Data.Enum([
1331
+ import_lucid3.Data.Object({ Inline: import_lucid3.Data.Tuple([CredentialSchema]) }),
1332
+ import_lucid3.Data.Object({
1333
+ Pointer: import_lucid3.Data.Tuple([
1334
+ import_lucid3.Data.Object({
1335
+ slotNumber: import_lucid3.Data.Integer(),
1336
+ transactionIndex: import_lucid3.Data.Integer(),
1337
+ certificateIndex: import_lucid3.Data.Integer()
1338
1338
  })
1339
1339
  ])
1340
1340
  })
@@ -1342,23 +1342,23 @@ var StakeCredentialSchema = import_lucid5.Data.Enum([
1342
1342
  var StakeCredential = StakeCredentialSchema;
1343
1343
 
1344
1344
  // src/contracts/stability-pool/types.ts
1345
- var StabilityPoolParamsSchema = import_lucid6.Data.Object({
1346
- assetSymbol: import_lucid6.Data.Bytes(),
1345
+ var StabilityPoolParamsSchema = import_lucid4.Data.Object({
1346
+ assetSymbol: import_lucid4.Data.Bytes(),
1347
1347
  stabilityPoolToken: AssetClassSchema2,
1348
1348
  snapshotEpochToScaleToSumToken: AssetClassSchema2,
1349
1349
  accountToken: AssetClassSchema2,
1350
1350
  cdpToken: AssetClassSchema2,
1351
1351
  iAssetAuthToken: AssetClassSchema2,
1352
1352
  versionRecordToken: AssetClassSchema2,
1353
- iassetValHash: import_lucid6.Data.Bytes(),
1354
- accountCreateFeeLovelaces: import_lucid6.Data.Integer(),
1355
- accountProcessingCooldownMs: import_lucid6.Data.Integer(),
1356
- accountProcessingBiasMs: import_lucid6.Data.Integer(),
1357
- stakeCredential: import_lucid6.Data.Nullable(StakeCredentialSchema)
1353
+ iassetValHash: import_lucid4.Data.Bytes(),
1354
+ accountCreateFeeLovelaces: import_lucid4.Data.Integer(),
1355
+ accountProcessingCooldownMs: import_lucid4.Data.Integer(),
1356
+ accountProcessingBiasMs: import_lucid4.Data.Integer(),
1357
+ stakeCredential: import_lucid4.Data.Nullable(StakeCredentialSchema)
1358
1358
  });
1359
1359
  var StabilityPoolParams = StabilityPoolParamsSchema;
1360
1360
  function castStabilityPoolParams(params) {
1361
- return import_lucid6.Data.castTo(params, StabilityPoolParams);
1361
+ return import_lucid4.Data.castTo(params, StabilityPoolParams);
1362
1362
  }
1363
1363
 
1364
1364
  // src/validators/stability-pool-validator.ts
@@ -1372,7 +1372,7 @@ var _stabilityPoolValidator = {
1372
1372
  var mkStabilityPoolValidator = (params) => {
1373
1373
  return {
1374
1374
  type: "PlutusV3",
1375
- script: (0, import_lucid7.applyParamsToScript)(_stabilityPoolValidator.cborHex, [
1375
+ script: (0, import_lucid5.applyParamsToScript)(_stabilityPoolValidator.cborHex, [
1376
1376
  castStabilityPoolParams(params)
1377
1377
  ])
1378
1378
  };
@@ -1380,7 +1380,7 @@ var mkStabilityPoolValidator = (params) => {
1380
1380
  var mkStabilityPoolValidatorFromSP = (params) => {
1381
1381
  return {
1382
1382
  type: "PlutusV3",
1383
- script: (0, import_lucid7.applyParamsToScript)(_stabilityPoolValidator.cborHex, [
1383
+ script: (0, import_lucid5.applyParamsToScript)(_stabilityPoolValidator.cborHex, [
1384
1384
  castStabilityPoolParams({
1385
1385
  assetSymbol: params.assetSymbol.unCurrencySymbol,
1386
1386
  stabilityPoolToken: fromSystemParamsAssetLucid(
@@ -1417,10 +1417,10 @@ var initSpState = {
1417
1417
  scale: 0n
1418
1418
  };
1419
1419
  function mkStabilityPoolAddr(lucid, sysParams) {
1420
- return (0, import_lucid8.credentialToAddress)(
1420
+ return (0, import_lucid6.credentialToAddress)(
1421
1421
  lucid.config().network,
1422
1422
  {
1423
- hash: (0, import_lucid8.validatorToScriptHash)(
1423
+ hash: (0, import_lucid6.validatorToScriptHash)(
1424
1424
  mkStabilityPoolValidatorFromSP(sysParams.stabilityPoolParams)
1425
1425
  ),
1426
1426
  type: "Script"
@@ -1483,7 +1483,7 @@ async function findRelevantE2s2sIdxs(lucid, stabilityPool, accountState, allSnap
1483
1483
  utxo,
1484
1484
  parseSnapshotEpochToScaleToSumDatumOrThrow((0, import_cardano_offchain_common3.getInlineDatumOrThrow)(utxo))
1485
1485
  ];
1486
- }).filter(([_, d]) => (0, import_lucid8.toHex)(d.iasset) === (0, import_lucid8.toHex)(stabilityPool.iasset));
1486
+ }).filter(([_, d]) => (0, import_lucid6.toHex)(d.iasset) === (0, import_lucid6.toHex)(stabilityPool.iasset));
1487
1487
  const s1E2sKey = {
1488
1488
  epoch: accountState.epoch,
1489
1489
  scale: accountState.scale
@@ -1611,7 +1611,7 @@ function createProcessRequestAccountRedeemer(e2s2sIdxs, otherRefInputs, currentT
1611
1611
  return [...import_fp_ts4.function.pipe([s1RefInput], import_fp_ts4.array.compact), ...s2RefInput];
1612
1612
  })
1613
1613
  );
1614
- const e2s2sInputsIndices = (0, import_lucid8.getInputIndices)(allE2s2sSnapshotRefInputs, [
1614
+ const e2s2sInputsIndices = (0, import_lucid6.getInputIndices)(allE2s2sSnapshotRefInputs, [
1615
1615
  ...otherRefInputs,
1616
1616
  ...allE2s2sSnapshotRefInputs
1617
1617
  ]);
@@ -1755,7 +1755,7 @@ function updateAccount(pool, account, e2s2sIdxs) {
1755
1755
  rewards,
1756
1756
  import_fp_ts4.array.reduce(
1757
1757
  {},
1758
- (acc, [asset, amt]) => (0, import_lucid8.addAssets)(acc, (0, import_cardano_offchain_common3.mkAssetsOf)(asset, amt))
1758
+ (acc, [asset, amt]) => (0, import_lucid6.addAssets)(acc, (0, import_cardano_offchain_common3.mkAssetsOf)(asset, amt))
1759
1759
  )
1760
1760
  )
1761
1761
  };
@@ -1957,7 +1957,7 @@ function partitionEpochToScaleToSums(spContent) {
1957
1957
  var import_fp_ts13 = require("fp-ts");
1958
1958
 
1959
1959
  // src/contracts/interest-collection/transactions.ts
1960
- var import_lucid9 = require("@lucid-evolution/lucid");
1960
+ var import_lucid7 = require("@lucid-evolution/lucid");
1961
1961
 
1962
1962
  // src/contracts/interest-collection/types-new.ts
1963
1963
  var import_evolution6 = require("@evolution-sdk/evolution");
@@ -2439,9 +2439,8 @@ function parseCollateralAssetDatumOrThrow(datum) {
2439
2439
  }
2440
2440
 
2441
2441
  // src/contracts/interest-collection/transactions.ts
2442
- async function batchCollectInterest(collateralAssetOref, interestCollectorOutRef, interestOracleOutRef, cdpOutRefs, params, lucid, currentSlot) {
2443
- const network = lucid.config().network;
2444
- const currentTime = BigInt((0, import_lucid9.slotToUnixTime)(network, currentSlot));
2442
+ async function batchCollectInterest(collateralAssetOref, interestCollectorOutRef, interestOracleOutRef, cdpOutRefs, params, lucid) {
2443
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
2445
2444
  const interestCollectionRefScriptUtxo = matchSingle(
2446
2445
  await lucid.utxosByOutRef([
2447
2446
  fromSystemParamsScriptRef(
@@ -2489,7 +2488,7 @@ async function batchCollectInterest(collateralAssetOref, interestCollectorOutRef
2489
2488
  (0, import_cardano_offchain_common6.getInlineDatumOrThrow)(interestOracleUtxo)
2490
2489
  );
2491
2490
  const cdpUtxos = await lucid.utxosByOutRef(cdpOutRefs);
2492
- const sortedCdpUtxos = (0, import_lucid9.sortUTxOs)(cdpUtxos, "Canonical");
2491
+ const sortedCdpUtxos = (0, import_lucid7.sortUTxOs)(cdpUtxos, "Canonical");
2493
2492
  if (sortedCdpUtxos.length !== cdpOutRefs.length) {
2494
2493
  throw new Error("Expected certain number of CDPs");
2495
2494
  }
@@ -2532,12 +2531,12 @@ async function batchCollectInterest(collateralAssetOref, interestCollectorOutRef
2532
2531
  cdpRefScriptUtxo,
2533
2532
  iAssetTokenPolicyRefScriptUtxo
2534
2533
  ];
2535
- const referenceInputIndices = (0, import_lucid9.getInputIndices)(
2534
+ const referenceInputIndices = (0, import_lucid7.getInputIndices)(
2536
2535
  [collateralAssetUtxo, interestOracleUtxo],
2537
2536
  referenceInputs,
2538
2537
  false
2539
2538
  );
2540
- const validateFrom = (0, import_lucid9.slotToUnixTime)(network, currentSlot - 1);
2539
+ const validateFrom = lucid.slotToUnixTime(lucid.currentSlot() - 1);
2541
2540
  const validateTo = validateFrom + Number(params.cdpParams.biasTime);
2542
2541
  const tx = lucid.newTx().validFrom(validateFrom).validTo(validateTo).readFrom(referenceInputs).collectFrom([interestCollectorUtxo], {
2543
2542
  kind: "selected",
@@ -2555,25 +2554,25 @@ async function batchCollectInterest(collateralAssetOref, interestCollectorOutRef
2555
2554
  }).mintAssets(
2556
2555
  (0, import_cardano_offchain_common6.mkAssetsOf)(
2557
2556
  {
2558
- currencySymbol: (0, import_lucid9.fromHex)(
2557
+ currencySymbol: (0, import_lucid7.fromHex)(
2559
2558
  params.cdpParams.cdpAssetSymbol.unCurrencySymbol
2560
2559
  ),
2561
2560
  tokenName: collateralAssetDatum.iasset
2562
2561
  },
2563
2562
  accumulatedInterest
2564
2563
  ),
2565
- import_lucid9.Data.void()
2564
+ import_lucid7.Data.void()
2566
2565
  ).pay.ToContract(
2567
2566
  createScriptAddress(
2568
2567
  lucid.config().network,
2569
2568
  params.validatorHashes.interestCollectionHash
2570
2569
  ),
2571
- { kind: "inline", value: import_lucid9.Data.void() },
2572
- (0, import_lucid9.addAssets)(
2570
+ { kind: "inline", value: import_lucid7.Data.void() },
2571
+ (0, import_lucid7.addAssets)(
2573
2572
  interestCollectorUtxo.assets,
2574
2573
  (0, import_cardano_offchain_common6.mkAssetsOf)(
2575
2574
  {
2576
- currencySymbol: (0, import_lucid9.fromHex)(
2575
+ currencySymbol: (0, import_lucid7.fromHex)(
2577
2576
  params.cdpParams.cdpAssetSymbol.unCurrencySymbol
2578
2577
  ),
2579
2578
  tokenName: collateralAssetDatum.iasset
@@ -2633,8 +2632,8 @@ async function collectInterestTx(value, lucid, sysParams, tx, interestCollectorO
2633
2632
  serialiseInterestCollectionRedeemer("CollectInterest")
2634
2633
  ).pay.ToContract(
2635
2634
  interestCollectorUtxo.address,
2636
- { kind: "inline", value: import_lucid9.Data.void() },
2637
- (0, import_lucid9.addAssets)(interestCollectorUtxo.assets, value)
2635
+ { kind: "inline", value: import_lucid7.Data.void() },
2636
+ (0, import_lucid7.addAssets)(interestCollectorUtxo.assets, value)
2638
2637
  );
2639
2638
  return interestCollectorRefScriptUtxo;
2640
2639
  }
@@ -2674,7 +2673,7 @@ async function distributeInterest(interestCollectorOutRefs, interestAdminOutRef,
2674
2673
  );
2675
2674
  if ("Signature" in interestAdminDatum.admin_permissions) {
2676
2675
  tx.addSignerKey(
2677
- (0, import_lucid9.toHex)(interestAdminDatum.admin_permissions.Signature.keyHash)
2676
+ (0, import_lucid7.toHex)(interestAdminDatum.admin_permissions.Signature.keyHash)
2678
2677
  );
2679
2678
  } else {
2680
2679
  throw new Error("Unsupported admin permissions type");
@@ -3003,7 +3002,7 @@ function serialiseCDPCreatorRedeemer(r) {
3003
3002
  }
3004
3003
 
3005
3004
  // src/contracts/treasury/transactions.ts
3006
- var import_lucid11 = require("@lucid-evolution/lucid");
3005
+ var import_lucid9 = require("@lucid-evolution/lucid");
3007
3006
  var import_cardano_offchain_common11 = require("@3rd-eye-labs/cardano-offchain-common");
3008
3007
 
3009
3008
  // src/contracts/treasury/types-new.ts
@@ -3100,7 +3099,7 @@ function parseExecuteDatumOrThrow(datum) {
3100
3099
  // src/contracts/gov/helpers.ts
3101
3100
  var import_function = require("fp-ts/lib/function");
3102
3101
  var import_fp_ts10 = require("fp-ts");
3103
- var import_lucid10 = require("@lucid-evolution/lucid");
3102
+ var import_lucid8 = require("@lucid-evolution/lucid");
3104
3103
  var import_cardano_offchain_common10 = require("@3rd-eye-labs/cardano-offchain-common");
3105
3104
  function proposalDeposit(baseDeposit, activeProposals) {
3106
3105
  return baseDeposit * 2n ** activeProposals;
@@ -3108,7 +3107,7 @@ function proposalDeposit(baseDeposit, activeProposals) {
3108
3107
  function createValueFromWithdrawal(w) {
3109
3108
  return import_fp_ts10.array.reduce(
3110
3109
  {},
3111
- (acc, item) => (0, import_lucid10.addAssets)(
3110
+ (acc, item) => (0, import_lucid8.addAssets)(
3112
3111
  acc,
3113
3112
  (0, import_cardano_offchain_common10.mkAssetsOf)(
3114
3113
  {
@@ -3163,7 +3162,7 @@ async function findRelativeIAssetForInsertion(newIAssetTokenName, allIAssetOrefs
3163
3162
  newIAssetTokenName,
3164
3163
  allIAssetOrefs,
3165
3164
  lucid,
3166
- import_fp_ts10.ord.contramap((x) => (0, import_lucid10.toText)((0, import_lucid10.toHex)(x)))(
3165
+ import_fp_ts10.ord.contramap((x) => (0, import_lucid8.toText)((0, import_lucid8.toHex)(x)))(
3167
3166
  import_fp_ts10.string.Ord
3168
3167
  ),
3169
3168
  (d) => d.assetName,
@@ -3235,7 +3234,7 @@ function iassetCreationDatumHelper(proposeAssetContent, referencedIAsset) {
3235
3234
  newReferencedIAsset: import_fp_ts10.option.none
3236
3235
  }),
3237
3236
  (referencedIA) => {
3238
- if ((0, import_lucid10.toText)((0, import_lucid10.toHex)(proposeAssetContent.asset)) < (0, import_lucid10.toText)((0, import_lucid10.toHex)(referencedIA.assetName))) {
3237
+ if ((0, import_lucid8.toText)((0, import_lucid8.toHex)(proposeAssetContent.asset)) < (0, import_lucid8.toText)((0, import_lucid8.toHex)(referencedIA.assetName))) {
3239
3238
  return {
3240
3239
  newIAsset: {
3241
3240
  ...newContent,
@@ -3358,7 +3357,7 @@ async function treasuryFeeTx(assetToPay, amountToPay, extraLovelaces, lucid, sys
3358
3357
  amountToCollect: amt,
3359
3358
  extraLovelaces: extraLov,
3360
3359
  actionInputOref: {
3361
- txHash: (0, import_lucid11.fromHex)(actionOref.txHash),
3360
+ txHash: (0, import_lucid9.fromHex)(actionOref.txHash),
3362
3361
  outputIndex: BigInt(actionOref.outputIndex)
3363
3362
  }
3364
3363
  }
@@ -3369,16 +3368,16 @@ async function treasuryFeeTx(assetToPay, amountToPay, extraLovelaces, lucid, sys
3369
3368
  kind: "inline",
3370
3369
  value: serialiseTreasuryDatum({
3371
3370
  treasuryInputOref: {
3372
- txHash: (0, import_lucid11.fromHex)(treasuryOref.txHash),
3371
+ txHash: (0, import_lucid9.fromHex)(treasuryOref.txHash),
3373
3372
  outputIndex: BigInt(treasuryOref.outputIndex)
3374
3373
  },
3375
3374
  actionInputOref: {
3376
- txHash: (0, import_lucid11.fromHex)(actionOref.txHash),
3375
+ txHash: (0, import_lucid9.fromHex)(actionOref.txHash),
3377
3376
  outputIndex: BigInt(actionOref.outputIndex)
3378
3377
  }
3379
3378
  })
3380
3379
  },
3381
- (0, import_lucid11.addAssets)(
3380
+ (0, import_lucid9.addAssets)(
3382
3381
  treasuryUtxo.assets,
3383
3382
  (0, import_cardano_offchain_common11.mkAssetsOf)(asset, amt),
3384
3383
  (0, import_cardano_offchain_common11.mkLovelacesOf)(extraLov)
@@ -3392,12 +3391,12 @@ async function treasuryFeeTx(assetToPay, amountToPay, extraLovelaces, lucid, sys
3392
3391
  value: serialiseTreasuryDatum({
3393
3392
  treasuryInputOref: null,
3394
3393
  actionInputOref: {
3395
- txHash: (0, import_lucid11.fromHex)(actionOref.txHash),
3394
+ txHash: (0, import_lucid9.fromHex)(actionOref.txHash),
3396
3395
  outputIndex: BigInt(actionOref.outputIndex)
3397
3396
  }
3398
3397
  })
3399
3398
  },
3400
- (0, import_lucid11.addAssets)((0, import_cardano_offchain_common11.mkAssetsOf)(asset, amt), (0, import_cardano_offchain_common11.mkLovelacesOf)(extraLov))
3399
+ (0, import_lucid9.addAssets)((0, import_cardano_offchain_common11.mkAssetsOf)(asset, amt), (0, import_cardano_offchain_common11.mkLovelacesOf)(extraLov))
3401
3400
  );
3402
3401
  }
3403
3402
  return treasuryRefScriptUtxo;
@@ -3423,7 +3422,7 @@ async function treasuryCollect(assetToPay, amountToPay, extraLovelaces, lucid, s
3423
3422
  amountToCollect: amountToPay,
3424
3423
  extraLovelaces,
3425
3424
  actionInputOref: {
3426
- txHash: (0, import_lucid11.fromHex)(actionOref.txHash),
3425
+ txHash: (0, import_lucid9.fromHex)(actionOref.txHash),
3427
3426
  outputIndex: BigInt(actionOref.outputIndex)
3428
3427
  }
3429
3428
  }
@@ -3434,16 +3433,16 @@ async function treasuryCollect(assetToPay, amountToPay, extraLovelaces, lucid, s
3434
3433
  kind: "inline",
3435
3434
  value: serialiseTreasuryDatum({
3436
3435
  treasuryInputOref: {
3437
- txHash: (0, import_lucid11.fromHex)(treasuryOref.txHash),
3436
+ txHash: (0, import_lucid9.fromHex)(treasuryOref.txHash),
3438
3437
  outputIndex: BigInt(treasuryOref.outputIndex)
3439
3438
  },
3440
3439
  actionInputOref: {
3441
- txHash: (0, import_lucid11.fromHex)(actionOref.txHash),
3440
+ txHash: (0, import_lucid9.fromHex)(actionOref.txHash),
3442
3441
  outputIndex: BigInt(actionOref.outputIndex)
3443
3442
  }
3444
3443
  })
3445
3444
  },
3446
- (0, import_lucid11.addAssets)(
3445
+ (0, import_lucid9.addAssets)(
3447
3446
  treasuryUtxo.assets,
3448
3447
  (0, import_cardano_offchain_common11.mkAssetsOf)(assetToPay, amountToPay),
3449
3448
  (0, import_cardano_offchain_common11.mkLovelacesOf)(extraLovelaces)
@@ -3462,11 +3461,11 @@ async function treasuryMerge(treasuryOutRefs, lucid, sysParams) {
3462
3461
  const treasuryUtxos = await lucid.utxosByOutRef(treasuryOutRefs);
3463
3462
  const totalAssets = import_fp_ts11.function.pipe(
3464
3463
  treasuryUtxos,
3465
- import_fp_ts11.array.reduce({}, (acc, utxo) => (0, import_lucid11.addAssets)(acc, utxo.assets))
3464
+ import_fp_ts11.array.reduce({}, (acc, utxo) => (0, import_lucid9.addAssets)(acc, utxo.assets))
3466
3465
  );
3467
3466
  return lucid.newTx().readFrom([treasuryScriptRefUtxo]).collectFrom(treasuryUtxos, serialiseTreasuryRedeemer("Merge")).pay.ToContract(
3468
3467
  mkTreasuryAddr(lucid, sysParams),
3469
- { kind: "inline", value: import_lucid11.Data.void() },
3468
+ { kind: "inline", value: import_lucid9.Data.void() },
3470
3469
  totalAssets
3471
3470
  );
3472
3471
  }
@@ -3491,13 +3490,13 @@ async function treasurySplit(treasuryOutRef, lucid, sysParams) {
3491
3490
  lucid.config().protocolParameters,
3492
3491
  mkTreasuryAddr(lucid, sysParams),
3493
3492
  { [asset]: treasuryUtxo.assets[asset] },
3494
- { InlineDatum: { datum: import_lucid11.Data.void() } }
3493
+ { InlineDatum: { datum: import_lucid9.Data.void() } }
3495
3494
  );
3496
3495
  paidLovelaces += utxoMinLovelace;
3497
3496
  tx.pay.ToContract(
3498
3497
  mkTreasuryAddr(lucid, sysParams),
3499
- { kind: "inline", value: import_lucid11.Data.void() },
3500
- (0, import_lucid11.addAssets)(
3498
+ { kind: "inline", value: import_lucid9.Data.void() },
3499
+ (0, import_lucid9.addAssets)(
3501
3500
  { [asset]: treasuryUtxo.assets[asset] },
3502
3501
  (0, import_cardano_offchain_common11.mkLovelacesOf)(utxoMinLovelace)
3503
3502
  )
@@ -3505,7 +3504,7 @@ async function treasurySplit(treasuryOutRef, lucid, sysParams) {
3505
3504
  }
3506
3505
  tx.pay.ToContract(
3507
3506
  mkTreasuryAddr(lucid, sysParams),
3508
- { kind: "inline", value: import_lucid11.Data.void() },
3507
+ { kind: "inline", value: import_lucid9.Data.void() },
3509
3508
  { [adaAsset]: treasuryUtxo.assets[adaAsset] - paidLovelaces }
3510
3509
  );
3511
3510
  return tx;
@@ -3527,7 +3526,7 @@ async function treasuryPrepareWithdrawal(treasuryOutRefs, upgradeOutRef, lucid,
3527
3526
  const treasuryAddress = mkTreasuryAddr(lucid, sysParams);
3528
3527
  const totalAssets = import_fp_ts11.function.pipe(
3529
3528
  treasuryUtxos,
3530
- import_fp_ts11.array.reduce({}, (acc, utxo) => (0, import_lucid11.addAssets)(acc, utxo.assets))
3529
+ import_fp_ts11.array.reduce({}, (acc, utxo) => (0, import_lucid9.addAssets)(acc, utxo.assets))
3531
3530
  );
3532
3531
  const executeDatum = parseExecuteDatumOrThrow(
3533
3532
  getInlineDatumOrThrow(upgradeUtxo)
@@ -3537,21 +3536,21 @@ async function treasuryPrepareWithdrawal(treasuryOutRefs, upgradeOutRef, lucid,
3537
3536
  const withdrawalVal = createValueFromWithdrawal(
3538
3537
  executeDatum.treasuryWithdrawal
3539
3538
  );
3540
- const change = (0, import_lucid11.addAssets)(totalAssets, (0, import_cardano_offchain_common11.negateAssets)(withdrawalVal));
3539
+ const change = (0, import_lucid9.addAssets)(totalAssets, (0, import_cardano_offchain_common11.negateAssets)(withdrawalVal));
3541
3540
  const tx = lucid.newTx().collectFrom(treasuryUtxos, serialiseTreasuryRedeemer("PrepareWithdraw")).readFrom([treasuryScriptRefUtxo, upgradeUtxo]).pay.ToContract(
3542
3541
  treasuryAddress,
3543
- { kind: "inline", value: import_lucid11.Data.void() },
3542
+ { kind: "inline", value: import_lucid9.Data.void() },
3544
3543
  withdrawalVal
3545
3544
  ).pay.ToContract(
3546
3545
  treasuryAddress,
3547
- { kind: "inline", value: import_lucid11.Data.void() },
3546
+ { kind: "inline", value: import_lucid9.Data.void() },
3548
3547
  change
3549
3548
  );
3550
3549
  return tx;
3551
3550
  }
3552
3551
 
3553
3552
  // src/contracts/iasset/helpers.ts
3554
- var import_lucid13 = require("@lucid-evolution/lucid");
3553
+ var import_lucid11 = require("@lucid-evolution/lucid");
3555
3554
  var import_ts_pattern12 = require("ts-pattern");
3556
3555
 
3557
3556
  // src/contracts/pyth-feed/helpers.ts
@@ -3990,7 +3989,7 @@ async function encodeSignedPythMessage(update, secretKey) {
3990
3989
  }
3991
3990
 
3992
3991
  // src/contracts/pyth-feed/helpers.ts
3993
- var import_lucid12 = require("@lucid-evolution/lucid");
3992
+ var import_lucid10 = require("@lucid-evolution/lucid");
3994
3993
  var import_fp_ts12 = require("fp-ts");
3995
3994
  function collectPriceFeedIds(derivedPythPrice) {
3996
3995
  const ids = (0, import_ts_pattern11.match)(derivedPythPrice).with({ Value: import_ts_pattern11.P.select() }, (value) => [
@@ -4005,7 +4004,7 @@ function collectPriceFeedIds(derivedPythPrice) {
4005
4004
  return import_fp_ts12.function.pipe(ids, import_fp_ts12.array.uniq(BigIntOrd), import_fp_ts12.array.sort(BigIntOrd));
4006
4005
  }
4007
4006
  function derivePythPrice(derivedPythPrice, messageHex) {
4008
- const decodedMessage = decodePythMessage((0, import_lucid12.fromHex)(messageHex));
4007
+ const decodedMessage = decodePythMessage((0, import_lucid10.fromHex)(messageHex));
4009
4008
  const pricePayload = decodePriceUpdate(decodedMessage.payload);
4010
4009
  return (0, import_ts_pattern11.match)(derivedPythPrice).with(
4011
4010
  { Value: import_ts_pattern11.P.select() },
@@ -4046,11 +4045,9 @@ function derivePythPrice(derivedPythPrice, messageHex) {
4046
4045
  // src/contracts/iasset/helpers.ts
4047
4046
  var Core = __toESM(require("@evolution-sdk/evolution"));
4048
4047
  var MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET = 9;
4049
- function attachOracle(iasset, collateralAsset, priceInfo, priceOracleOref, pythStateOref, pythMessage, pythConfig, biasTime, currentSlot, lucid, tx) {
4048
+ function attachOracle(iasset, collateralAsset, priceInfo, priceOracleOref, pythStateOref, pythMessage, pythConfig, biasTime, lucid, tx) {
4050
4049
  return (0, import_ts_pattern12.match)(priceInfo).returnType().with({ Delisted: import_ts_pattern12.P.any }, () => {
4051
- const currentTime = BigInt(
4052
- (0, import_lucid13.slotToUnixTime)(lucid.config().network, currentSlot)
4053
- );
4050
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
4054
4051
  const validFrom = Number(currentTime - BigInt(biasTime / 2n));
4055
4052
  const validTo = Number(currentTime + BigInt(biasTime / 2n));
4056
4053
  return Promise.resolve({
@@ -4071,10 +4068,9 @@ function attachOracle(iasset, collateralAsset, priceInfo, priceOracleOref, pythS
4071
4068
  );
4072
4069
  return {
4073
4070
  interval: oracleExpirationAwareValidity(
4074
- currentSlot,
4071
+ lucid,
4075
4072
  Number(biasTime),
4076
- Number(priceOracleDatum.expirationTime),
4077
- lucid.config().network
4073
+ Number(priceOracleDatum.expirationTime)
4078
4074
  ),
4079
4075
  referenceInputs: [priceOracleUtxo]
4080
4076
  };
@@ -4106,26 +4102,26 @@ function attachOracle(iasset, collateralAsset, priceInfo, priceOracleOref, pythS
4106
4102
  pythFeedCfg.params.config
4107
4103
  );
4108
4104
  const price = derivePythPrice(derivedPythPrice, pythMessage);
4109
- const decodedMessage = decodePythMessage((0, import_lucid13.fromHex)(pythMessage));
4105
+ const decodedMessage = decodePythMessage((0, import_lucid11.fromHex)(pythMessage));
4110
4106
  const pricePayload = decodePriceUpdate(decodedMessage.payload);
4111
4107
  const pythTimestamp = Number(pricePayload.timestampUs) / 1e3;
4112
4108
  tx.withdraw(
4113
- (0, import_lucid13.credentialToRewardAddress)(
4109
+ (0, import_lucid11.credentialToRewardAddress)(
4114
4110
  lucid.config().network,
4115
- (0, import_lucid13.scriptHashToCredential)((0, import_lucid13.toHex)(pythStateDatum.withdraw_script))
4111
+ (0, import_lucid11.scriptHashToCredential)((0, import_lucid11.toHex)(pythStateDatum.withdraw_script))
4116
4112
  ),
4117
4113
  0n,
4118
- serialisePythUpdatesRedeemer([(0, import_lucid13.fromHex)(pythMessage)])
4114
+ serialisePythUpdatesRedeemer([(0, import_lucid11.fromHex)(pythMessage)])
4119
4115
  );
4120
4116
  tx.withdraw(
4121
- (0, import_lucid13.credentialToRewardAddress)(
4117
+ (0, import_lucid11.credentialToRewardAddress)(
4122
4118
  lucid.config().network,
4123
- (0, import_lucid13.scriptHashToCredential)((0, import_lucid13.toHex)(feedValHash))
4119
+ (0, import_lucid11.scriptHashToCredential)((0, import_lucid11.toHex)(feedValHash))
4124
4120
  ),
4125
4121
  0n,
4126
4122
  serialisePythFeedRedeemer({
4127
4123
  price,
4128
- auxiliaryData: Core.Data.fromCBORHex(import_lucid13.Data.void())
4124
+ auxiliaryData: Core.Data.fromCBORHex(import_lucid11.Data.void())
4129
4125
  })
4130
4126
  );
4131
4127
  const pythMaxDelay = 280 * 1e3;
@@ -4175,9 +4171,9 @@ async function retrieveAdjustedPrice(iasset, collateralAsset, priceInfo, extraDe
4175
4171
  }
4176
4172
 
4177
4173
  // src/contracts/cdp/transactions.ts
4178
- async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreatorOref, iassetOref, collateralAssetOref, priceOracleOref, interestOracleOref, treasuryOref, lucid, currentSlot, pythMessage = void 0, pythStateOref = void 0) {
4174
+ async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreatorOref, iassetOref, collateralAssetOref, priceOracleOref, interestOracleOref, treasuryOref, lucid, pythMessage = void 0, pythStateOref = void 0) {
4179
4175
  const network = lucid.config().network;
4180
- const currentTime = BigInt((0, import_lucid14.slotToUnixTime)(network, currentSlot));
4176
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
4181
4177
  const [pkh, skh] = await addrDetails(lucid);
4182
4178
  const cdpCreatorRefScriptUtxo = matchSingle(
4183
4179
  await lucid.utxosByOutRef([
@@ -4237,7 +4233,7 @@ async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreatorOref
4237
4233
  1n
4238
4234
  );
4239
4235
  const iassetClass = {
4240
- currencySymbol: (0, import_lucid14.fromHex)(
4236
+ currencySymbol: (0, import_lucid12.fromHex)(
4241
4237
  sysParams.cdpParams.cdpAssetSymbol.unCurrencySymbol
4242
4238
  ),
4243
4239
  tokenName: iassetDatum.assetName
@@ -4253,12 +4249,12 @@ async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreatorOref
4253
4249
  iassetUtxo,
4254
4250
  collateralAssetUtxo
4255
4251
  ];
4256
- const tx = lucid.newTx().readFrom(refScripts).mintAssets(cdpNftVal, import_lucid14.Data.void()).mintAssets(iassetTokensVal, import_lucid14.Data.void()).pay.ToContract(
4252
+ const tx = lucid.newTx().readFrom(refScripts).mintAssets(cdpNftVal, import_lucid12.Data.void()).mintAssets(iassetTokensVal, import_lucid12.Data.void()).pay.ToContract(
4257
4253
  createScriptAddress(network, sysParams.validatorHashes.cdpHash, skh),
4258
4254
  {
4259
4255
  kind: "inline",
4260
4256
  value: serialiseCdpDatum({
4261
- cdpOwner: (0, import_lucid14.fromHex)(pkh.hash),
4257
+ cdpOwner: (0, import_lucid12.fromHex)(pkh.hash),
4262
4258
  iasset: iassetDatum.assetName,
4263
4259
  collateralAsset: collateralAssetDatum.collateralAsset,
4264
4260
  mintedAmt: mintedAmount,
@@ -4273,7 +4269,7 @@ async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreatorOref
4273
4269
  }
4274
4270
  })
4275
4271
  },
4276
- (0, import_lucid14.addAssets)(
4272
+ (0, import_lucid12.addAssets)(
4277
4273
  cdpNftVal,
4278
4274
  (0, import_cardano_offchain_common13.mkAssetsOf)(collateralAssetDatum.collateralAsset, collateralAmount)
4279
4275
  )
@@ -4284,7 +4280,7 @@ async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreatorOref
4284
4280
  value: serialiseCDPCreatorDatum({
4285
4281
  creatorInputOref: {
4286
4282
  outputIndex: BigInt(cdpCreatorUtxo.outputIndex),
4287
- txHash: (0, import_lucid14.fromHex)(cdpCreatorUtxo.txHash)
4283
+ txHash: (0, import_lucid12.fromHex)(cdpCreatorUtxo.txHash)
4288
4284
  }
4289
4285
  })
4290
4286
  },
@@ -4299,7 +4295,6 @@ async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreatorOref
4299
4295
  pythMessage,
4300
4296
  sysParams.pythConfig,
4301
4297
  sysParams.cdpCreatorParams.biasTime,
4302
- currentSlot,
4303
4298
  lucid,
4304
4299
  tx
4305
4300
  );
@@ -4320,7 +4315,7 @@ async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreatorOref
4320
4315
  cdpCreatorUtxo,
4321
4316
  treasuryOref
4322
4317
  ) : void 0;
4323
- const refInputsIndices = (0, import_lucid14.getInputIndices)(referenceInputs, [
4318
+ const refInputsIndices = (0, import_lucid12.getInputIndices)(referenceInputs, [
4324
4319
  ...referenceInputs,
4325
4320
  ...refScripts,
4326
4321
  ...treasuryRefScriptUtxo != null ? [treasuryRefScriptUtxo] : []
@@ -4330,7 +4325,7 @@ async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreatorOref
4330
4325
  makeRedeemer: (inputIdx) => {
4331
4326
  return serialiseCDPCreatorRedeemer({
4332
4327
  CreateCDP: {
4333
- cdpOwner: (0, import_lucid14.fromHex)(pkh.hash),
4328
+ cdpOwner: (0, import_lucid12.fromHex)(pkh.hash),
4334
4329
  minted: mintedAmount,
4335
4330
  collateralAmt: collateralAmount,
4336
4331
  currentTime,
@@ -4347,9 +4342,8 @@ async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreatorOref
4347
4342
  });
4348
4343
  return tx;
4349
4344
  }
4350
- async function adjustCdp(collateralAdjustment, debtAdjustment, cdpOref, iassetOref, collateralAssetOref, priceOracleOref, interestOracleOref, treasuryOref, interestCollectorOref, sysParams, lucid, currentSlot, pythMessage = void 0, pythStateOref = void 0) {
4351
- const network = lucid.config().network;
4352
- const currentTime = BigInt((0, import_lucid14.slotToUnixTime)(network, currentSlot));
4345
+ async function adjustCdp(collateralAdjustment, debtAdjustment, cdpOref, iassetOref, collateralAssetOref, priceOracleOref, interestOracleOref, treasuryOref, interestCollectorOref, sysParams, lucid, pythMessage = void 0, pythStateOref = void 0) {
4346
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
4353
4347
  const cdpRefScriptUtxo = matchSingle(
4354
4348
  await lucid.utxosByOutRef([
4355
4349
  fromSystemParamsScriptRef(sysParams.scriptReferences.cdpValidatorRef)
@@ -4376,7 +4370,7 @@ async function adjustCdp(collateralAdjustment, debtAdjustment, cdpOref, iassetOr
4376
4370
  getInlineDatumOrThrow(collateralAssetUtxo)
4377
4371
  );
4378
4372
  const iAssetAc = {
4379
- currencySymbol: (0, import_lucid14.fromHex)(
4373
+ currencySymbol: (0, import_lucid12.fromHex)(
4380
4374
  sysParams.cdpParams.cdpAssetSymbol.unCurrencySymbol
4381
4375
  ),
4382
4376
  tokenName: iassetDatum.assetName
@@ -4415,7 +4409,6 @@ async function adjustCdp(collateralAdjustment, debtAdjustment, cdpOref, iassetOr
4415
4409
  pythMessage,
4416
4410
  sysParams.pythConfig,
4417
4411
  sysParams.cdpParams.biasTime,
4418
- currentSlot,
4419
4412
  lucid,
4420
4413
  tx
4421
4414
  );
@@ -4457,7 +4450,7 @@ async function adjustCdp(collateralAdjustment, debtAdjustment, cdpOref, iassetOr
4457
4450
  ]),
4458
4451
  (_) => new Error("Expected a single iasset token policy Ref Script UTXO")
4459
4452
  ) : void 0;
4460
- const refInputsIndices = (0, import_lucid14.getInputIndices)(referenceInputs, [
4453
+ const refInputsIndices = (0, import_lucid12.getInputIndices)(referenceInputs, [
4461
4454
  ...referenceInputs,
4462
4455
  ...referenceScripts,
4463
4456
  ...treasuryRefScriptUtxo != null ? [treasuryRefScriptUtxo] : [],
@@ -4492,7 +4485,7 @@ async function adjustCdp(collateralAdjustment, debtAdjustment, cdpOref, iassetOr
4492
4485
  }
4493
4486
  })
4494
4487
  },
4495
- (0, import_lucid14.addAssets)(
4488
+ (0, import_lucid12.addAssets)(
4496
4489
  cdpUtxo.assets,
4497
4490
  (0, import_cardano_offchain_common13.mkAssetsOf)(cdpDatum.collateralAsset, collateralAdjustment)
4498
4491
  )
@@ -4501,16 +4494,16 @@ async function adjustCdp(collateralAdjustment, debtAdjustment, cdpOref, iassetOr
4501
4494
  const iassetTokensVal = (0, import_cardano_offchain_common13.mkAssetsOf)(iAssetAc, mintedAmountChange);
4502
4495
  tx.readFrom([iAssetTokenPolicyRefScriptUtxo]).mintAssets(
4503
4496
  iassetTokensVal,
4504
- import_lucid14.Data.void()
4497
+ import_lucid12.Data.void()
4505
4498
  );
4506
4499
  }
4507
4500
  if (!cdpDatum.cdpOwner) {
4508
4501
  throw new Error("Expected active CDP");
4509
4502
  }
4510
- tx.addSignerKey((0, import_lucid14.toHex)(cdpDatum.cdpOwner));
4503
+ tx.addSignerKey((0, import_lucid12.toHex)(cdpDatum.cdpOwner));
4511
4504
  return tx;
4512
4505
  }
4513
- async function depositCdp(amount, cdpOref, iassetOref, collateralAssetOref, interestOracleOref, treasuryOref, interestCollectorOref, params, lucid, currentSlot) {
4506
+ async function depositCdp(amount, cdpOref, iassetOref, collateralAssetOref, interestOracleOref, treasuryOref, interestCollectorOref, params, lucid) {
4514
4507
  return adjustCdp(
4515
4508
  amount,
4516
4509
  0n,
@@ -4522,11 +4515,10 @@ async function depositCdp(amount, cdpOref, iassetOref, collateralAssetOref, inte
4522
4515
  treasuryOref,
4523
4516
  interestCollectorOref,
4524
4517
  params,
4525
- lucid,
4526
- currentSlot
4518
+ lucid
4527
4519
  );
4528
4520
  }
4529
- async function withdrawCdp(amount, cdpOref, iassetOref, collateralAssetOref, priceOracleOref, interestOracleOref, treasuryOref, interestCollectorOref, params, lucid, currentSlot, pythMessage = void 0, pythStateOref = void 0) {
4521
+ async function withdrawCdp(amount, cdpOref, iassetOref, collateralAssetOref, priceOracleOref, interestOracleOref, treasuryOref, interestCollectorOref, params, lucid, pythMessage = void 0, pythStateOref = void 0) {
4530
4522
  return adjustCdp(
4531
4523
  -amount,
4532
4524
  0n,
@@ -4539,12 +4531,11 @@ async function withdrawCdp(amount, cdpOref, iassetOref, collateralAssetOref, pri
4539
4531
  interestCollectorOref,
4540
4532
  params,
4541
4533
  lucid,
4542
- currentSlot,
4543
4534
  pythMessage,
4544
4535
  pythStateOref
4545
4536
  );
4546
4537
  }
4547
- async function mintCdp(amount, cdpOref, iassetOref, collateralAssetOref, priceOracleOref, interestOracleOref, treasuryOref, interestCollectorOref, params, lucid, currentSlot, pythMessage = void 0, pythStateOref = void 0) {
4538
+ async function mintCdp(amount, cdpOref, iassetOref, collateralAssetOref, priceOracleOref, interestOracleOref, treasuryOref, interestCollectorOref, params, lucid, pythMessage = void 0, pythStateOref = void 0) {
4548
4539
  return adjustCdp(
4549
4540
  0n,
4550
4541
  amount,
@@ -4557,12 +4548,11 @@ async function mintCdp(amount, cdpOref, iassetOref, collateralAssetOref, priceOr
4557
4548
  interestCollectorOref,
4558
4549
  params,
4559
4550
  lucid,
4560
- currentSlot,
4561
4551
  pythMessage,
4562
4552
  pythStateOref
4563
4553
  );
4564
4554
  }
4565
- async function burnCdp(amount, cdpOref, iassetOref, collateralAssetOref, interestOracleOref, treasuryOref, interestCollectorOref, params, lucid, currentSlot) {
4555
+ async function burnCdp(amount, cdpOref, iassetOref, collateralAssetOref, interestOracleOref, treasuryOref, interestCollectorOref, params, lucid) {
4566
4556
  return adjustCdp(
4567
4557
  0n,
4568
4558
  -amount,
@@ -4574,13 +4564,11 @@ async function burnCdp(amount, cdpOref, iassetOref, collateralAssetOref, interes
4574
4564
  treasuryOref,
4575
4565
  interestCollectorOref,
4576
4566
  params,
4577
- lucid,
4578
- currentSlot
4567
+ lucid
4579
4568
  );
4580
4569
  }
4581
- async function closeCdp(cdpOref, collateralAssetOref, interestOracleOref, interestCollectorOref, sysParams, lucid, currentSlot) {
4582
- const network = lucid.config().network;
4583
- const currentTime = BigInt((0, import_lucid14.slotToUnixTime)(network, currentSlot));
4570
+ async function closeCdp(cdpOref, collateralAssetOref, interestOracleOref, interestCollectorOref, sysParams, lucid) {
4571
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
4584
4572
  const cdpRefScriptUtxo = matchSingle(
4585
4573
  await lucid.utxosByOutRef([
4586
4574
  fromSystemParamsScriptRef(sysParams.scriptReferences.cdpValidatorRef)
@@ -4622,7 +4610,7 @@ async function closeCdp(cdpOref, collateralAssetOref, interestOracleOref, intere
4622
4610
  const interestOracleDatum = parseInterestOracleDatum(
4623
4611
  getInlineDatumOrThrow(interestOracleUtxo)
4624
4612
  );
4625
- const validateFrom = (0, import_lucid14.slotToUnixTime)(network, currentSlot - 1);
4613
+ const validateFrom = lucid.slotToUnixTime(lucid.currentSlot() - 1);
4626
4614
  const validateTo = validateFrom + Number(sysParams.cdpCreatorParams.biasTime);
4627
4615
  const tx = lucid.newTx().readFrom([
4628
4616
  cdpRefScriptUtxo,
@@ -4631,17 +4619,17 @@ async function closeCdp(cdpOref, collateralAssetOref, interestOracleOref, intere
4631
4619
  ]).readFrom([collateralAssetUtxo, interestOracleUtxo]).validFrom(validateFrom).validTo(validateTo).mintAssets(
4632
4620
  (0, import_cardano_offchain_common13.mkAssetsOf)(
4633
4621
  {
4634
- currencySymbol: (0, import_lucid14.fromHex)(
4622
+ currencySymbol: (0, import_lucid12.fromHex)(
4635
4623
  sysParams.cdpParams.cdpAssetSymbol.unCurrencySymbol
4636
4624
  ),
4637
4625
  tokenName: collateralDatum.iasset
4638
4626
  },
4639
4627
  -cdpDatum.mintedAmt
4640
4628
  ),
4641
- import_lucid14.Data.void()
4629
+ import_lucid12.Data.void()
4642
4630
  ).mintAssets(
4643
4631
  (0, import_cardano_offchain_common13.mkAssetsOf)(fromSystemParamsAsset(sysParams.cdpParams.cdpAuthToken), -1n),
4644
- import_lucid14.Data.void()
4632
+ import_lucid12.Data.void()
4645
4633
  ).collectFrom(
4646
4634
  [cdpUtxo],
4647
4635
  serialiseCdpRedeemer({ CloseCdp: { currentTime } })
@@ -4649,7 +4637,7 @@ async function closeCdp(cdpOref, collateralAssetOref, interestOracleOref, intere
4649
4637
  if (!cdpDatum.cdpOwner) {
4650
4638
  throw new Error("Expected active CDP");
4651
4639
  }
4652
- tx.addSignerKey((0, import_lucid14.toHex)(cdpDatum.cdpOwner));
4640
+ tx.addSignerKey((0, import_lucid12.toHex)(cdpDatum.cdpOwner));
4653
4641
  const interestAmt = (0, import_ts_pattern14.match)(cdpDatum.cdpFees).with({ FrozenCDPAccumulatedFees: import_ts_pattern14.P.any }, () => {
4654
4642
  throw new Error("CDP fees wrong");
4655
4643
  }).with({ ActiveCDPInterestTracking: import_ts_pattern14.P.select() }, (interest) => {
@@ -4665,7 +4653,7 @@ async function closeCdp(cdpOref, collateralAssetOref, interestOracleOref, intere
4665
4653
  await collectInterestTx(
4666
4654
  (0, import_cardano_offchain_common13.mkAssetsOf)(
4667
4655
  {
4668
- currencySymbol: (0, import_lucid14.fromHex)(
4656
+ currencySymbol: (0, import_lucid12.fromHex)(
4669
4657
  sysParams.cdpParams.cdpAssetSymbol.unCurrencySymbol
4670
4658
  ),
4671
4659
  tokenName: collateralDatum.iasset
@@ -4680,9 +4668,8 @@ async function closeCdp(cdpOref, collateralAssetOref, interestOracleOref, intere
4680
4668
  }
4681
4669
  return tx;
4682
4670
  }
4683
- async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, collateralAssetOref, priceOracleOref, interestOracleOref, interestCollectorOref, treasuryOref, govOref, sysParams, lucid, currentSlot, pythMessage = void 0, _pythStateOref = void 0) {
4684
- const network = lucid.config().network;
4685
- const currentTime = BigInt((0, import_lucid14.slotToUnixTime)(network, currentSlot));
4671
+ async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, collateralAssetOref, priceOracleOref, interestOracleOref, interestCollectorOref, treasuryOref, govOref, sysParams, lucid, pythMessage = void 0, _pythStateOref = void 0) {
4672
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
4686
4673
  const cdpRefScriptUtxo = matchSingle(
4687
4674
  await lucid.utxosByOutRef([
4688
4675
  fromSystemParamsScriptRef(sysParams.scriptReferences.cdpValidatorRef)
@@ -4812,15 +4799,14 @@ async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, coll
4812
4799
  getInlineDatumOrThrow(priceOracleUtxo)
4813
4800
  );
4814
4801
  const txValidity = oracleExpirationAwareValidity(
4815
- currentSlot,
4802
+ lucid,
4816
4803
  Number(sysParams.cdpCreatorParams.biasTime),
4817
- Number(priceOracleDatum.expirationTime),
4818
- network
4804
+ Number(priceOracleDatum.expirationTime)
4819
4805
  );
4820
4806
  referenceInputs.push(priceOracleUtxo);
4821
4807
  tx.validFrom(txValidity.validFrom).validTo(txValidity.validTo);
4822
4808
  } else {
4823
- const validateFrom = (0, import_lucid14.slotToUnixTime)(network, currentSlot - 1);
4809
+ const validateFrom = lucid.slotToUnixTime(lucid.currentSlot() - 1);
4824
4810
  const validateTo = validateFrom + Number(sysParams.cdpCreatorParams.biasTime);
4825
4811
  tx.validFrom(validateFrom).validTo(validateTo);
4826
4812
  }
@@ -4834,7 +4820,7 @@ async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, coll
4834
4820
  },
4835
4821
  // When private redemptions
4836
4822
  (requiredSignature) => {
4837
- tx.addSignerKey((0, import_lucid14.toHex)(requiredSignature));
4823
+ tx.addSignerKey((0, import_lucid12.toHex)(requiredSignature));
4838
4824
  return 0n;
4839
4825
  }
4840
4826
  )
@@ -4861,7 +4847,7 @@ async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, coll
4861
4847
  const interestCollectorRefScriptUtxo = interestAmt > 0n ? await collectInterestTx(
4862
4848
  (0, import_cardano_offchain_common13.mkAssetsOf)(
4863
4849
  {
4864
- currencySymbol: (0, import_lucid14.fromHex)(
4850
+ currencySymbol: (0, import_lucid12.fromHex)(
4865
4851
  sysParams.cdpParams.cdpAssetSymbol.unCurrencySymbol
4866
4852
  ),
4867
4853
  tokenName: iassetDatum.assetName
@@ -4873,21 +4859,21 @@ async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, coll
4873
4859
  tx,
4874
4860
  interestCollectorOref
4875
4861
  ) : void 0;
4876
- const refInputsIndices = (0, import_lucid14.getInputIndices)(referenceInputs, [
4862
+ const refInputsIndices = (0, import_lucid12.getInputIndices)(referenceInputs, [
4877
4863
  ...referenceInputs,
4878
4864
  ...referenceScripts,
4879
4865
  ...treasuryRefScriptUtxo != null ? [treasuryRefScriptUtxo] : [],
4880
4866
  ...interestCollectorRefScriptUtxo != null ? [interestCollectorRefScriptUtxo] : []
4881
4867
  ]);
4882
4868
  tx.readFrom(referenceInputs).withdraw(
4883
- (0, import_lucid14.credentialToRewardAddress)(
4869
+ (0, import_lucid12.credentialToRewardAddress)(
4884
4870
  lucid.config().network,
4885
- (0, import_lucid14.scriptHashToCredential)(sysParams.cdpParams.cdpRedeemValHash)
4871
+ (0, import_lucid12.scriptHashToCredential)(sysParams.cdpParams.cdpRedeemValHash)
4886
4872
  ),
4887
4873
  0n,
4888
4874
  serialiseRedeemCdpWithdrawalRedeemer({
4889
4875
  cdpOutReference: {
4890
- txHash: (0, import_lucid14.fromHex)(cdpUtxo.txHash),
4876
+ txHash: (0, import_lucid12.fromHex)(cdpUtxo.txHash),
4891
4877
  outputIndex: BigInt(cdpUtxo.outputIndex)
4892
4878
  },
4893
4879
  currentTime,
@@ -4896,14 +4882,14 @@ async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, coll
4896
4882
  ).collectFrom([cdpUtxo], serialiseCdpRedeemer("RedeemCdp")).mintAssets(
4897
4883
  (0, import_cardano_offchain_common13.mkAssetsOf)(
4898
4884
  {
4899
- currencySymbol: (0, import_lucid14.fromHex)(
4885
+ currencySymbol: (0, import_lucid12.fromHex)(
4900
4886
  sysParams.cdpParams.cdpAssetSymbol.unCurrencySymbol
4901
4887
  ),
4902
4888
  tokenName: iassetDatum.assetName
4903
4889
  },
4904
4890
  interestAmt - redemptionIAssetAmt
4905
4891
  ),
4906
- import_lucid14.Data.void()
4892
+ import_lucid12.Data.void()
4907
4893
  ).pay.ToContract(
4908
4894
  cdpUtxo.address,
4909
4895
  {
@@ -4922,7 +4908,7 @@ async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, coll
4922
4908
  }
4923
4909
  })
4924
4910
  },
4925
- (0, import_lucid14.addAssets)(
4911
+ (0, import_lucid12.addAssets)(
4926
4912
  cdpUtxo.assets,
4927
4913
  (0, import_cardano_offchain_common13.mkAssetsOf)(
4928
4914
  cdpDatum.collateralAsset,
@@ -4932,9 +4918,9 @@ async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, coll
4932
4918
  );
4933
4919
  return tx;
4934
4920
  }
4935
- async function freezeCdp(cdpOref, iassetOref, collateralAssetOref, priceOracleOref, interestOracleOref, sysParams, lucid, currentSlot, pythMessage = void 0, pythStateOref = void 0) {
4921
+ async function freezeCdp(cdpOref, iassetOref, collateralAssetOref, priceOracleOref, interestOracleOref, sysParams, lucid, pythMessage = void 0, pythStateOref = void 0) {
4936
4922
  const network = lucid.config().network;
4937
- const currentTime = BigInt((0, import_lucid14.slotToUnixTime)(network, currentSlot));
4923
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
4938
4924
  const cdpRefScriptUtxo = matchSingle(
4939
4925
  await lucid.utxosByOutRef([
4940
4926
  fromSystemParamsScriptRef(sysParams.scriptReferences.cdpValidatorRef)
@@ -5017,12 +5003,11 @@ async function freezeCdp(cdpOref, iassetOref, collateralAssetOref, priceOracleOr
5017
5003
  pythMessage,
5018
5004
  sysParams.pythConfig,
5019
5005
  sysParams.cdpParams.biasTime,
5020
- currentSlot,
5021
5006
  lucid,
5022
5007
  tx
5023
5008
  );
5024
5009
  referenceInputs = [...oracleRefInputs, ...referenceInputs];
5025
- const refInputsIndices = (0, import_lucid14.getInputIndices)(referenceInputs, [
5010
+ const refInputsIndices = (0, import_lucid12.getInputIndices)(referenceInputs, [
5026
5011
  ...referenceInputs,
5027
5012
  ...referenceScripts
5028
5013
  ]);
@@ -5101,7 +5086,7 @@ async function liquidateCdp(cdpOref, stabilityPoolOref, interestCollectorOref, t
5101
5086
  }).exhaustive();
5102
5087
  const cdpNftAc = fromSystemParamsAsset(sysParams.cdpParams.cdpAuthToken);
5103
5088
  const iassetsAc = {
5104
- currencySymbol: (0, import_lucid14.fromHex)(
5089
+ currencySymbol: (0, import_lucid12.fromHex)(
5105
5090
  sysParams.cdpParams.cdpAssetSymbol.unCurrencySymbol
5106
5091
  ),
5107
5092
  tokenName: cdpDatum.iasset
@@ -5132,7 +5117,7 @@ async function liquidateCdp(cdpOref, stabilityPoolOref, interestCollectorOref, t
5132
5117
  }
5133
5118
  }),
5134
5119
  inputs: [cdpUtxo]
5135
- }).collectFrom([cdpUtxo], serialiseCdpRedeemer("Liquidate")).mintAssets((0, import_cardano_offchain_common13.mkAssetsOf)(iassetsAc, -iassetBurnAmt), import_lucid14.Data.void()).pay.ToContract(
5120
+ }).collectFrom([cdpUtxo], serialiseCdpRedeemer("Liquidate")).mintAssets((0, import_cardano_offchain_common13.mkAssetsOf)(iassetsAc, -iassetBurnAmt), import_lucid12.Data.void()).pay.ToContract(
5136
5121
  spUtxo.address,
5137
5122
  {
5138
5123
  kind: "inline",
@@ -5145,7 +5130,7 @@ async function liquidateCdp(cdpOref, stabilityPoolOref, interestCollectorOref, t
5145
5130
  )
5146
5131
  })
5147
5132
  },
5148
- (0, import_lucid14.addAssets)(
5133
+ (0, import_lucid12.addAssets)(
5149
5134
  spUtxo.assets,
5150
5135
  (0, import_cardano_offchain_common13.mkAssetsOf)(cdpDatum.collateralAsset, collateralAbsorbed),
5151
5136
  (0, import_cardano_offchain_common13.mkAssetsOf)(iassetsAc, -iassetUsedAmt)
@@ -5179,7 +5164,7 @@ async function liquidateCdp(cdpOref, stabilityPoolOref, interestCollectorOref, t
5179
5164
  }
5180
5165
  })
5181
5166
  },
5182
- (0, import_lucid14.addAssets)(
5167
+ (0, import_lucid12.addAssets)(
5183
5168
  cdpUtxo.assets,
5184
5169
  (0, import_cardano_offchain_common13.negateAssets)(
5185
5170
  (0, import_cardano_offchain_common13.mkAssetsOf)(
@@ -5192,7 +5177,7 @@ async function liquidateCdp(cdpOref, stabilityPoolOref, interestCollectorOref, t
5192
5177
  } else {
5193
5178
  tx.mintAssets(
5194
5179
  (0, import_cardano_offchain_common13.mkAssetsOf)(cdpNftAc, -(0, import_cardano_offchain_common13.assetClassValueOf)(cdpUtxo.assets, cdpNftAc)),
5195
- import_lucid14.Data.void()
5180
+ import_lucid12.Data.void()
5196
5181
  );
5197
5182
  }
5198
5183
  if (payableInterest > 0) {
@@ -5222,7 +5207,7 @@ async function mergeCdps(cdpsToMergeUtxos, sysParams, lucid) {
5222
5207
  }
5223
5208
  const aggregatedVal = import_fp_ts13.function.pipe(
5224
5209
  cdpUtxos,
5225
- import_fp_ts13.array.reduce({}, (acc, utxo) => (0, import_lucid14.addAssets)(acc, utxo.assets))
5210
+ import_fp_ts13.array.reduce({}, (acc, utxo) => (0, import_lucid12.addAssets)(acc, utxo.assets))
5226
5211
  );
5227
5212
  const aggregatedMintedAmt = import_fp_ts13.function.pipe(
5228
5213
  cdpDatums,
@@ -5252,7 +5237,7 @@ async function mergeCdps(cdpsToMergeUtxos, sysParams, lucid) {
5252
5237
  MergeAuxiliary: {
5253
5238
  mainMergeUtxo: {
5254
5239
  outputIndex: BigInt(mainMergeUtxo.outputIndex),
5255
- txHash: (0, import_lucid14.fromHex)(mainMergeUtxo.txHash)
5240
+ txHash: (0, import_lucid12.fromHex)(mainMergeUtxo.txHash)
5256
5241
  }
5257
5242
  }
5258
5243
  })
@@ -5278,45 +5263,45 @@ async function mergeCdps(cdpsToMergeUtxos, sysParams, lucid) {
5278
5263
  }
5279
5264
 
5280
5265
  // src/contracts/cdp/types.ts
5281
- var import_lucid15 = require("@lucid-evolution/lucid");
5282
- var CdpParamsSchema = import_lucid15.Data.Object({
5266
+ var import_lucid13 = require("@lucid-evolution/lucid");
5267
+ var CdpParamsSchema = import_lucid13.Data.Object({
5283
5268
  cdp_auth_token: AssetClassSchema2,
5284
- cdp_asset_symbol: import_lucid15.Data.Bytes(),
5269
+ cdp_asset_symbol: import_lucid13.Data.Bytes(),
5285
5270
  iasset_auth_token: AssetClassSchema2,
5286
5271
  collateral_asset_auth_token: AssetClassSchema2,
5287
5272
  stability_pool_auth_token: AssetClassSchema2,
5288
5273
  upgrade_token: AssetClassSchema2,
5289
5274
  version_record_token: AssetClassSchema2,
5290
- interest_collector_val_hash: import_lucid15.Data.Bytes(),
5291
- sp_val_hash: import_lucid15.Data.Bytes(),
5292
- iasset_val_hash: import_lucid15.Data.Bytes(),
5293
- treasury_val_hash: import_lucid15.Data.Bytes(),
5294
- cdp_redeem_val_hash: import_lucid15.Data.Bytes(),
5295
- bias_time: import_lucid15.Data.Integer()
5275
+ interest_collector_val_hash: import_lucid13.Data.Bytes(),
5276
+ sp_val_hash: import_lucid13.Data.Bytes(),
5277
+ iasset_val_hash: import_lucid13.Data.Bytes(),
5278
+ treasury_val_hash: import_lucid13.Data.Bytes(),
5279
+ cdp_redeem_val_hash: import_lucid13.Data.Bytes(),
5280
+ bias_time: import_lucid13.Data.Integer()
5296
5281
  });
5297
5282
  var CdpParams = CdpParamsSchema;
5298
5283
  function castCdpParams(params) {
5299
- return import_lucid15.Data.castTo(params, CdpParams);
5284
+ return import_lucid13.Data.castTo(params, CdpParams);
5300
5285
  }
5301
- var CdpRedeemParamsSchema = import_lucid15.Data.Object({
5286
+ var CdpRedeemParamsSchema = import_lucid13.Data.Object({
5302
5287
  cdp_auth_token: AssetClassSchema2,
5303
- cdp_asset_symbol: import_lucid15.Data.Bytes(),
5288
+ cdp_asset_symbol: import_lucid13.Data.Bytes(),
5304
5289
  iasset_auth_token: AssetClassSchema2,
5305
5290
  collateral_asset_auth_token: AssetClassSchema2,
5306
- interest_collector_val_hash: import_lucid15.Data.Bytes(),
5307
- iasset_val_hash: import_lucid15.Data.Bytes(),
5308
- treasury_val_hash: import_lucid15.Data.Bytes(),
5291
+ interest_collector_val_hash: import_lucid13.Data.Bytes(),
5292
+ iasset_val_hash: import_lucid13.Data.Bytes(),
5293
+ treasury_val_hash: import_lucid13.Data.Bytes(),
5309
5294
  gov_nft: AssetClassSchema2,
5310
- partial_redemption_extra_fee_lovelace: import_lucid15.Data.Integer(),
5311
- bias_time: import_lucid15.Data.Integer()
5295
+ partial_redemption_extra_fee_lovelace: import_lucid13.Data.Integer(),
5296
+ bias_time: import_lucid13.Data.Integer()
5312
5297
  });
5313
5298
  var CdpRedeemParams = CdpRedeemParamsSchema;
5314
5299
  function castCdpRedeemParams(params) {
5315
- return import_lucid15.Data.castTo(params, CdpRedeemParams);
5300
+ return import_lucid13.Data.castTo(params, CdpRedeemParams);
5316
5301
  }
5317
5302
 
5318
5303
  // src/contracts/cdp/scripts.ts
5319
- var import_lucid16 = require("@lucid-evolution/lucid");
5304
+ var import_lucid14 = require("@lucid-evolution/lucid");
5320
5305
 
5321
5306
  // src/validators/cdp-validator.ts
5322
5307
  var _cdpValidator = {
@@ -5336,7 +5321,7 @@ var _cdpRedeemValidator = {
5336
5321
  var mkCdpValidatorFromSP = (params) => {
5337
5322
  return {
5338
5323
  type: "PlutusV3",
5339
- script: (0, import_lucid16.applyParamsToScript)(_cdpValidator.cborHex, [
5324
+ script: (0, import_lucid14.applyParamsToScript)(_cdpValidator.cborHex, [
5340
5325
  castCdpParams({
5341
5326
  cdp_auth_token: fromSystemParamsAssetLucid(params.cdpAuthToken),
5342
5327
  cdp_asset_symbol: params.cdpAssetSymbol.unCurrencySymbol,
@@ -5364,7 +5349,7 @@ var mkCdpValidatorFromSP = (params) => {
5364
5349
  var mkCdpRedeemValidatorFromSP = (params) => {
5365
5350
  return {
5366
5351
  type: "PlutusV3",
5367
- script: (0, import_lucid16.applyParamsToScript)(_cdpRedeemValidator.cborHex, [
5352
+ script: (0, import_lucid14.applyParamsToScript)(_cdpRedeemValidator.cborHex, [
5368
5353
  castCdpRedeemParams({
5369
5354
  cdp_auth_token: fromSystemParamsAssetLucid(params.cdpAuthToken),
5370
5355
  cdp_asset_symbol: params.cdpAssetSymbol.unCurrencySymbol,
@@ -5386,27 +5371,27 @@ var mkCdpRedeemValidatorFromSP = (params) => {
5386
5371
  };
5387
5372
 
5388
5373
  // src/contracts/cdp-creator/types.ts
5389
- var import_lucid17 = require("@lucid-evolution/lucid");
5390
- var CDPCreatorParamsSchema = import_lucid17.Data.Object({
5374
+ var import_lucid15 = require("@lucid-evolution/lucid");
5375
+ var CDPCreatorParamsSchema = import_lucid15.Data.Object({
5391
5376
  cdpCreatorNft: AssetClassSchema2,
5392
- cdpAssetCs: import_lucid17.Data.Bytes(),
5377
+ cdpAssetCs: import_lucid15.Data.Bytes(),
5393
5378
  cdpAuthTk: AssetClassSchema2,
5394
5379
  iAssetAuthTk: AssetClassSchema2,
5395
5380
  collateralAssetAuthTk: AssetClassSchema2,
5396
5381
  upgradeToken: AssetClassSchema2,
5397
5382
  versionRecordToken: AssetClassSchema2,
5398
- cdpScriptHash: import_lucid17.Data.Bytes(),
5399
- treasuryValHash: import_lucid17.Data.Bytes(),
5400
- iassetValHash: import_lucid17.Data.Bytes(),
5401
- biasTime: import_lucid17.Data.Integer()
5383
+ cdpScriptHash: import_lucid15.Data.Bytes(),
5384
+ treasuryValHash: import_lucid15.Data.Bytes(),
5385
+ iassetValHash: import_lucid15.Data.Bytes(),
5386
+ biasTime: import_lucid15.Data.Integer()
5402
5387
  });
5403
5388
  var CDPCreatorParams = CDPCreatorParamsSchema;
5404
5389
  function castCDPCreatorParams(params) {
5405
- return import_lucid17.Data.castTo(params, CDPCreatorParams);
5390
+ return import_lucid15.Data.castTo(params, CDPCreatorParams);
5406
5391
  }
5407
5392
 
5408
5393
  // src/contracts/cdp-creator/scripts.ts
5409
- var import_lucid18 = require("@lucid-evolution/lucid");
5394
+ var import_lucid16 = require("@lucid-evolution/lucid");
5410
5395
 
5411
5396
  // src/validators/cdp-creator-validator.ts
5412
5397
  var _cdpCreatorValidator = {
@@ -5419,7 +5404,7 @@ var _cdpCreatorValidator = {
5419
5404
  var mkCDPCreatorValidator = (params) => {
5420
5405
  return {
5421
5406
  type: "PlutusV3",
5422
- script: (0, import_lucid18.applyParamsToScript)(_cdpCreatorValidator.cborHex, [
5407
+ script: (0, import_lucid16.applyParamsToScript)(_cdpCreatorValidator.cborHex, [
5423
5408
  castCDPCreatorParams(params)
5424
5409
  ])
5425
5410
  };
@@ -5427,7 +5412,7 @@ var mkCDPCreatorValidator = (params) => {
5427
5412
  var mkCDPCreatorValidatorFromSP = (params) => {
5428
5413
  return {
5429
5414
  type: "PlutusV3",
5430
- script: (0, import_lucid18.applyParamsToScript)(_cdpCreatorValidator.cborHex, [
5415
+ script: (0, import_lucid16.applyParamsToScript)(_cdpCreatorValidator.cborHex, [
5431
5416
  castCDPCreatorParams({
5432
5417
  cdpCreatorNft: fromSystemParamsAssetLucid(params.cdpCreatorNft),
5433
5418
  cdpAssetCs: params.cdpAssetCs.unCurrencySymbol,
@@ -5471,36 +5456,36 @@ async function findRandomCdpCreator(lucid, sysParams) {
5471
5456
  }
5472
5457
 
5473
5458
  // src/contracts/poll/scripts.ts
5474
- var import_lucid21 = require("@lucid-evolution/lucid");
5459
+ var import_lucid19 = require("@lucid-evolution/lucid");
5475
5460
 
5476
5461
  // src/contracts/poll/types-poll-manager.ts
5477
- var import_lucid19 = require("@lucid-evolution/lucid");
5478
- var PollManagerParamsSchema = import_lucid19.Data.Object({
5462
+ var import_lucid17 = require("@lucid-evolution/lucid");
5463
+ var PollManagerParamsSchema = import_lucid17.Data.Object({
5479
5464
  govNFT: AssetClassSchema2,
5480
5465
  pollToken: AssetClassSchema2,
5481
5466
  upgradeToken: AssetClassSchema2,
5482
5467
  indyAsset: AssetClassSchema2,
5483
- govExecuteValHash: import_lucid19.Data.Bytes(),
5484
- pBiasTime: import_lucid19.Data.Integer(),
5485
- shardValHash: import_lucid19.Data.Bytes(),
5486
- treasuryValHash: import_lucid19.Data.Bytes()
5468
+ govExecuteValHash: import_lucid17.Data.Bytes(),
5469
+ pBiasTime: import_lucid17.Data.Integer(),
5470
+ shardValHash: import_lucid17.Data.Bytes(),
5471
+ treasuryValHash: import_lucid17.Data.Bytes()
5487
5472
  });
5488
5473
  var PollManagerParams = PollManagerParamsSchema;
5489
5474
  function castPollManagerParams(params) {
5490
- return import_lucid19.Data.castTo(params, PollManagerParams);
5475
+ return import_lucid17.Data.castTo(params, PollManagerParams);
5491
5476
  }
5492
5477
 
5493
5478
  // src/contracts/poll/types-poll-shard.ts
5494
- var import_lucid20 = require("@lucid-evolution/lucid");
5495
- var PollShardParamsSchema = import_lucid20.Data.Object({
5479
+ var import_lucid18 = require("@lucid-evolution/lucid");
5480
+ var PollShardParamsSchema = import_lucid18.Data.Object({
5496
5481
  pollToken: AssetClassSchema2,
5497
5482
  stakingToken: AssetClassSchema2,
5498
5483
  indyAsset: AssetClassSchema2,
5499
- stakingValHash: import_lucid20.Data.Bytes()
5484
+ stakingValHash: import_lucid18.Data.Bytes()
5500
5485
  });
5501
5486
  var PollShardParams = PollShardParamsSchema;
5502
5487
  function castPollShardParams(params) {
5503
- return import_lucid20.Data.castTo(params, PollShardParams);
5488
+ return import_lucid18.Data.castTo(params, PollShardParams);
5504
5489
  }
5505
5490
 
5506
5491
  // src/validators/poll-manager-validator.ts
@@ -5521,7 +5506,7 @@ var _pollShardValidator = {
5521
5506
  var mkPollManagerValidator = (params) => {
5522
5507
  return {
5523
5508
  type: "PlutusV3",
5524
- script: (0, import_lucid21.applyParamsToScript)(_pollManagerValidator.cborHex, [
5509
+ script: (0, import_lucid19.applyParamsToScript)(_pollManagerValidator.cborHex, [
5525
5510
  castPollManagerParams(params)
5526
5511
  ])
5527
5512
  };
@@ -5529,7 +5514,7 @@ var mkPollManagerValidator = (params) => {
5529
5514
  var mkPollManagerValidatorFromSP = (params) => {
5530
5515
  return {
5531
5516
  type: "PlutusV3",
5532
- script: (0, import_lucid21.applyParamsToScript)(_pollManagerValidator.cborHex, [
5517
+ script: (0, import_lucid19.applyParamsToScript)(_pollManagerValidator.cborHex, [
5533
5518
  castPollManagerParams({
5534
5519
  govNFT: fromSystemParamsAssetLucid(params.govNFT),
5535
5520
  pollToken: fromSystemParamsAssetLucid(params.pollToken),
@@ -5546,7 +5531,7 @@ var mkPollManagerValidatorFromSP = (params) => {
5546
5531
  var mkPollShardValidator = (params) => {
5547
5532
  return {
5548
5533
  type: "PlutusV3",
5549
- script: (0, import_lucid21.applyParamsToScript)(_pollShardValidator.cborHex, [
5534
+ script: (0, import_lucid19.applyParamsToScript)(_pollShardValidator.cborHex, [
5550
5535
  castPollShardParams(params)
5551
5536
  ])
5552
5537
  };
@@ -5554,7 +5539,7 @@ var mkPollShardValidator = (params) => {
5554
5539
  var mkPollShardValidatorFromSP = (params) => {
5555
5540
  return {
5556
5541
  type: "PlutusV3",
5557
- script: (0, import_lucid21.applyParamsToScript)(_pollShardValidator.cborHex, [
5542
+ script: (0, import_lucid19.applyParamsToScript)(_pollShardValidator.cborHex, [
5558
5543
  castPollShardParams({
5559
5544
  pollToken: fromSystemParamsAssetLucid(params.pollToken),
5560
5545
  stakingToken: fromSystemParamsAssetLucid(params.stakingToken),
@@ -5566,7 +5551,7 @@ var mkPollShardValidatorFromSP = (params) => {
5566
5551
  };
5567
5552
 
5568
5553
  // src/contracts/collector/transactions.ts
5569
- var import_lucid22 = require("@lucid-evolution/lucid");
5554
+ var import_lucid20 = require("@lucid-evolution/lucid");
5570
5555
 
5571
5556
  // src/contracts/collector/types-new.ts
5572
5557
  var import_evolution15 = require("@evolution-sdk/evolution");
@@ -5597,16 +5582,16 @@ async function collectorFeeTx(fee, lucid, params, tx, collectorOref) {
5597
5582
  );
5598
5583
  tx.collectFrom([collectorUtxo], serialiseCollectorRedeemer("Collect")).pay.ToContract(
5599
5584
  collectorUtxo.address,
5600
- { kind: "inline", value: import_lucid22.Data.void() },
5601
- (0, import_lucid22.addAssets)(collectorUtxo.assets, (0, import_cardano_offchain_common15.mkLovelacesOf)(fee))
5585
+ { kind: "inline", value: import_lucid20.Data.void() },
5586
+ (0, import_lucid20.addAssets)(collectorUtxo.assets, (0, import_cardano_offchain_common15.mkLovelacesOf)(fee))
5602
5587
  ).readFrom([collectorRefScriptUtxo]);
5603
5588
  return collectorRefScriptUtxo;
5604
5589
  }
5605
5590
 
5606
5591
  // src/contracts/gov/transactions.ts
5607
- var import_lucid25 = require("@lucid-evolution/lucid");
5592
+ var import_lucid23 = require("@lucid-evolution/lucid");
5608
5593
  var import_cardano_offchain_common17 = require("@3rd-eye-labs/cardano-offchain-common");
5609
- var import_lucid26 = require("@lucid-evolution/lucid");
5594
+ var import_lucid24 = require("@lucid-evolution/lucid");
5610
5595
  var import_function2 = require("fp-ts/lib/function");
5611
5596
  var import_fp_ts17 = require("fp-ts");
5612
5597
  var import_ts_pattern17 = require("ts-pattern");
@@ -5726,10 +5711,10 @@ function serialiseStakingDatum(d) {
5726
5711
  }
5727
5712
 
5728
5713
  // src/contracts/staking/helpers.ts
5729
- var import_lucid24 = require("@lucid-evolution/lucid");
5714
+ var import_lucid22 = require("@lucid-evolution/lucid");
5730
5715
 
5731
5716
  // src/contracts/staking/scripts.ts
5732
- var import_lucid23 = require("@lucid-evolution/lucid");
5717
+ var import_lucid21 = require("@lucid-evolution/lucid");
5733
5718
 
5734
5719
  // src/validators/staking-validator.ts
5735
5720
  var _stakingValidator = {
@@ -5742,27 +5727,27 @@ var _stakingValidator = {
5742
5727
  var mkStakingValidatorFromSP = (params) => {
5743
5728
  return {
5744
5729
  type: "PlutusV3",
5745
- script: (0, import_lucid23.applyParamsToScript)(_stakingValidator.cborHex, [
5746
- new import_lucid23.Constr(0, [
5747
- new import_lucid23.Constr(0, [
5730
+ script: (0, import_lucid21.applyParamsToScript)(_stakingValidator.cborHex, [
5731
+ new import_lucid21.Constr(0, [
5732
+ new import_lucid21.Constr(0, [
5748
5733
  params.stakingManagerNFT[0].unCurrencySymbol,
5749
- (0, import_lucid23.fromText)(params.stakingManagerNFT[1].unTokenName)
5734
+ (0, import_lucid21.fromText)(params.stakingManagerNFT[1].unTokenName)
5750
5735
  ]),
5751
- new import_lucid23.Constr(0, [
5736
+ new import_lucid21.Constr(0, [
5752
5737
  params.stakingToken[0].unCurrencySymbol,
5753
- (0, import_lucid23.fromText)(params.stakingToken[1].unTokenName)
5738
+ (0, import_lucid21.fromText)(params.stakingToken[1].unTokenName)
5754
5739
  ]),
5755
- new import_lucid23.Constr(0, [
5740
+ new import_lucid21.Constr(0, [
5756
5741
  params.indyToken[0].unCurrencySymbol,
5757
- (0, import_lucid23.fromText)(params.indyToken[1].unTokenName)
5742
+ (0, import_lucid21.fromText)(params.indyToken[1].unTokenName)
5758
5743
  ]),
5759
- new import_lucid23.Constr(0, [
5744
+ new import_lucid21.Constr(0, [
5760
5745
  params.pollToken[0].unCurrencySymbol,
5761
- (0, import_lucid23.fromText)(params.pollToken[1].unTokenName)
5746
+ (0, import_lucid21.fromText)(params.pollToken[1].unTokenName)
5762
5747
  ]),
5763
- new import_lucid23.Constr(0, [
5748
+ new import_lucid21.Constr(0, [
5764
5749
  params.versionRecordToken[0].unCurrencySymbol,
5765
- (0, import_lucid23.fromText)(params.versionRecordToken[1].unTokenName)
5750
+ (0, import_lucid21.fromText)(params.versionRecordToken[1].unTokenName)
5766
5751
  ]),
5767
5752
  params.collectorValHash
5768
5753
  ])
@@ -5795,9 +5780,9 @@ function findStakingManager(params, lucid) {
5795
5780
  return lucid.utxosAtWithUnit(
5796
5781
  createScriptAddress(
5797
5782
  lucid.config().network,
5798
- (0, import_lucid24.validatorToScriptHash)(mkStakingValidatorFromSP(params.stakingParams))
5783
+ (0, import_lucid22.validatorToScriptHash)(mkStakingValidatorFromSP(params.stakingParams))
5799
5784
  ),
5800
- params.stakingParams.stakingManagerNFT[0].unCurrencySymbol + (0, import_lucid24.fromText)(params.stakingParams.stakingManagerNFT[1].unTokenName)
5785
+ params.stakingParams.stakingManagerNFT[0].unCurrencySymbol + (0, import_lucid22.fromText)(params.stakingParams.stakingManagerNFT[1].unTokenName)
5801
5786
  ).then(
5802
5787
  (utxos) => utxos.map((utxo) => {
5803
5788
  if (!utxo.datum) return void 0;
@@ -6033,11 +6018,11 @@ function serialisePollDatum(d) {
6033
6018
 
6034
6019
  // src/contracts/gov/transactions.ts
6035
6020
  var import_cardano_offchain_common18 = require("@3rd-eye-labs/cardano-offchain-common");
6036
- async function createProposal(proposalContent, treasuryWithdrawal, sysParams, lucid, currentSlot, govOref, allIAssetOrefs) {
6021
+ async function createProposal(proposalContent, treasuryWithdrawal, sysParams, lucid, govOref, allIAssetOrefs) {
6037
6022
  const network = lucid.config().network;
6038
- const currentTime = BigInt((0, import_lucid25.slotToUnixTime)(network, currentSlot));
6023
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
6039
6024
  const ownAddr = await lucid.wallet().address();
6040
- const pkh = (0, import_lucid25.paymentCredentialOf)(ownAddr);
6025
+ const pkh = (0, import_lucid23.paymentCredentialOf)(ownAddr);
6041
6026
  const govRefScriptUtxo = matchSingle(
6042
6027
  await lucid.utxosByOutRef([
6043
6028
  fromSystemParamsScriptRef(
@@ -6095,13 +6080,13 @@ async function createProposal(proposalContent, treasuryWithdrawal, sysParams, lu
6095
6080
  }).otherwise(() => {
6096
6081
  });
6097
6082
  return [
6098
- tx.mintAssets(pollNftValue, import_lucid26.Data.void()).readFrom([govRefScriptUtxo, pollAuthTokenPolicyRefScriptUtxo]).collectFrom(
6083
+ tx.mintAssets(pollNftValue, import_lucid24.Data.void()).readFrom([govRefScriptUtxo, pollAuthTokenPolicyRefScriptUtxo]).collectFrom(
6099
6084
  [govUtxo],
6100
6085
  serialiseGovRedeemer({
6101
6086
  CreatePoll: {
6102
6087
  content: proposalContent,
6103
6088
  currentTime,
6104
- proposalOwner: (0, import_lucid25.fromHex)(pkh.hash),
6089
+ proposalOwner: (0, import_lucid23.fromHex)(pkh.hash),
6105
6090
  treasuryWithdrawal
6106
6091
  }
6107
6092
  })
@@ -6123,7 +6108,7 @@ async function createProposal(proposalContent, treasuryWithdrawal, sysParams, lu
6123
6108
  value: serialisePollDatum({
6124
6109
  PollManager: {
6125
6110
  pollId: newPollId,
6126
- pollOwner: (0, import_lucid25.fromHex)(pkh.hash),
6111
+ pollOwner: (0, import_lucid23.fromHex)(pkh.hash),
6127
6112
  content: proposalContent,
6128
6113
  treasuryWithdrawal,
6129
6114
  status: { yesVotes: 0n, noVotes: 0n },
@@ -6138,7 +6123,7 @@ async function createProposal(proposalContent, treasuryWithdrawal, sysParams, lu
6138
6123
  }
6139
6124
  })
6140
6125
  },
6141
- (0, import_lucid25.addAssets)(
6126
+ (0, import_lucid23.addAssets)(
6142
6127
  pollNftValue,
6143
6128
  (0, import_cardano_offchain_common17.mkAssetsOf)(
6144
6129
  fromSystemParamsAsset(sysParams.govParams.indyAsset),
@@ -6154,9 +6139,9 @@ async function createProposal(proposalContent, treasuryWithdrawal, sysParams, lu
6154
6139
  newPollId
6155
6140
  ];
6156
6141
  }
6157
- async function createShardsChunks(chunkSize, pollManagerOref, sysParams, currentSlot, lucid) {
6142
+ async function createShardsChunks(chunkSize, pollManagerOref, sysParams, lucid) {
6158
6143
  const network = lucid.config().network;
6159
- const currentTime = BigInt((0, import_lucid25.slotToUnixTime)(network, currentSlot));
6144
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
6160
6145
  const ownAddr = await lucid.wallet().address();
6161
6146
  const pollManagerUtxo = matchSingle(
6162
6147
  await lucid.utxosByOutRef([pollManagerOref]),
@@ -6193,7 +6178,7 @@ async function createShardsChunks(chunkSize, pollManagerOref, sysParams, current
6193
6178
  const pollNft = fromSystemParamsAsset(sysParams.govParams.pollToken);
6194
6179
  const tx = lucid.newTx().validFrom(Number(currentTime) - ONE_SECOND).validTo(
6195
6180
  Number(currentTime) + Number(sysParams.pollManagerParams.pBiasTime) - ONE_SECOND
6196
- ).mintAssets((0, import_cardano_offchain_common17.mkAssetsOf)(pollNft, shardsCount), import_lucid26.Data.void()).readFrom([pollAuthTokenPolicyRefScriptUtxo, pollManagerRefScriptUtxo]).collectFrom(
6181
+ ).mintAssets((0, import_cardano_offchain_common17.mkAssetsOf)(pollNft, shardsCount), import_lucid24.Data.void()).readFrom([pollAuthTokenPolicyRefScriptUtxo, pollManagerRefScriptUtxo]).collectFrom(
6197
6182
  [pollManagerUtxo],
6198
6183
  serialisePollManagerRedeemer({ CreateShards: { currentTime } })
6199
6184
  ).pay.ToContract(
@@ -6245,9 +6230,8 @@ function voteHelper(stakingPosLockedAmt, pollShard, voteOption, currentTime, ind
6245
6230
  ];
6246
6231
  return [newLockedAmt, newPollStatus];
6247
6232
  }
6248
- async function vote(voteOption, pollShardOref, stakingPositionOref, sysParams, lucid, currentSlot) {
6249
- const network = lucid.config().network;
6250
- const currentTime = BigInt((0, import_lucid25.slotToUnixTime)(network, currentSlot));
6233
+ async function vote(voteOption, pollShardOref, stakingPositionOref, sysParams, lucid) {
6234
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
6251
6235
  const ownAddr = await lucid.wallet().address();
6252
6236
  const pollShardRefScriptUtxo = matchSingle(
6253
6237
  await lucid.utxosByOutRef([
@@ -6293,7 +6277,10 @@ async function vote(voteOption, pollShardOref, stakingPositionOref, sysParams, l
6293
6277
  indyStakedAmt
6294
6278
  );
6295
6279
  return lucid.newTx().validFrom(validityFrom).validTo(
6296
- validityFrom + Number(sysParams.pollManagerParams.pBiasTime) - ONE_SECOND
6280
+ Math.min(
6281
+ validityFrom + Number(sysParams.pollManagerParams.pBiasTime) - ONE_SECOND,
6282
+ Number(pollShardDatum.votingEndTime) - ONE_SECOND
6283
+ )
6297
6284
  ).readFrom([stakingRefScriptUtxo, pollShardRefScriptUtxo]).collectFrom([stakingPosUtxo], serialiseStakingRedeemer("Lock")).collectFrom(
6298
6285
  [pollShardUtxo],
6299
6286
  serialisePollShardRedeemer({ Vote: voteOption })
@@ -6321,9 +6308,8 @@ async function vote(voteOption, pollShardOref, stakingPositionOref, sysParams, l
6321
6308
  stakingPosUtxo.assets
6322
6309
  ).addSigner(ownAddr);
6323
6310
  }
6324
- async function mergeShards(pollManagerOref, shardsOutRefs, sysParams, lucid, currentSlot) {
6325
- const network = lucid.config().network;
6326
- const currentTime = BigInt((0, import_lucid25.slotToUnixTime)(network, currentSlot));
6311
+ async function mergeShards(pollManagerOref, shardsOutRefs, sysParams, lucid) {
6312
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
6327
6313
  const ownAddr = await lucid.wallet().address();
6328
6314
  const pollShardRefScriptUtxo = matchSingle(
6329
6315
  await lucid.utxosByOutRef([
@@ -6370,7 +6356,7 @@ async function mergeShards(pollManagerOref, shardsOutRefs, sysParams, lucid, cur
6370
6356
  );
6371
6357
  const shardsAggregatedAda = import_fp_ts17.array.reduce(
6372
6358
  {},
6373
- (acc, utxo) => (0, import_lucid25.addAssets)(acc, (0, import_cardano_offchain_common17.mkLovelacesOf)((0, import_cardano_offchain_common17.lovelacesAmt)(utxo.assets)))
6359
+ (acc, utxo) => (0, import_lucid23.addAssets)(acc, (0, import_cardano_offchain_common17.mkLovelacesOf)((0, import_cardano_offchain_common17.lovelacesAmt)(utxo.assets)))
6374
6360
  )(shardUtxos);
6375
6361
  const pollNft = fromSystemParamsAsset(sysParams.govParams.pollToken);
6376
6362
  return lucid.newTx().validFrom(Number(currentTime) - ONE_SECOND).validTo(
@@ -6379,7 +6365,7 @@ async function mergeShards(pollManagerOref, shardsOutRefs, sysParams, lucid, cur
6379
6365
  pollShardRefScriptUtxo,
6380
6366
  pollManagerRefScriptUtxo,
6381
6367
  pollAuthTokenPolicyRefScriptUtxo
6382
- ]).mintAssets((0, import_cardano_offchain_common17.mkAssetsOf)(pollNft, -BigInt(shardsOutRefs.length)), import_lucid26.Data.void()).collectFrom(
6368
+ ]).mintAssets((0, import_cardano_offchain_common17.mkAssetsOf)(pollNft, -BigInt(shardsOutRefs.length)), import_lucid24.Data.void()).collectFrom(
6383
6369
  [pollManagerUtxo],
6384
6370
  serialisePollManagerRedeemer({
6385
6371
  MergeShardsManager: { currentTime }
@@ -6391,7 +6377,7 @@ async function mergeShards(pollManagerOref, shardsOutRefs, sysParams, lucid, cur
6391
6377
  currentTime,
6392
6378
  pollManagerRef: {
6393
6379
  outputIndex: BigInt(pollManagerUtxo.outputIndex),
6394
- txHash: (0, import_lucid25.fromHex)(pollManagerUtxo.txHash)
6380
+ txHash: (0, import_lucid23.fromHex)(pollManagerUtxo.txHash)
6395
6381
  }
6396
6382
  }
6397
6383
  })
@@ -6407,12 +6393,12 @@ async function mergeShards(pollManagerOref, shardsOutRefs, sysParams, lucid, cur
6407
6393
  }
6408
6394
  })
6409
6395
  },
6410
- (0, import_lucid25.addAssets)(pollManagerUtxo.assets, shardsAggregatedAda)
6396
+ (0, import_lucid23.addAssets)(pollManagerUtxo.assets, shardsAggregatedAda)
6411
6397
  ).addSigner(ownAddr);
6412
6398
  }
6413
- async function endProposal(pollManagerOref, govOref, sysParams, lucid, currentSlot) {
6399
+ async function endProposal(pollManagerOref, govOref, sysParams, lucid) {
6414
6400
  const network = lucid.config().network;
6415
- const currentTime = BigInt((0, import_lucid25.slotToUnixTime)(network, currentSlot));
6401
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
6416
6402
  const ownAddr = await lucid.wallet().address();
6417
6403
  const pollManagerRefScriptUtxo = matchSingle(
6418
6404
  await lucid.utxosByOutRef([
@@ -6485,7 +6471,7 @@ async function endProposal(pollManagerOref, govOref, sysParams, lucid, currentSl
6485
6471
  ).collectFrom(
6486
6472
  [govUtxo],
6487
6473
  serialiseGovRedeemer({ WitnessEndPoll: { currentTime } })
6488
- ).mintAssets((0, import_cardano_offchain_common17.mkAssetsOf)(pollNft, -1n), import_lucid26.Data.void()).pay.ToContract(
6474
+ ).mintAssets((0, import_cardano_offchain_common17.mkAssetsOf)(pollNft, -1n), import_lucid24.Data.void()).pay.ToContract(
6489
6475
  govUtxo.address,
6490
6476
  {
6491
6477
  kind: "inline",
@@ -6511,11 +6497,11 @@ async function endProposal(pollManagerOref, govOref, sysParams, lucid, currentSl
6511
6497
  })
6512
6498
  },
6513
6499
  upgradeTokenVal
6514
- ).mintAssets(upgradeTokenVal, import_lucid26.Data.void());
6500
+ ).mintAssets(upgradeTokenVal, import_lucid24.Data.void());
6515
6501
  } else {
6516
6502
  tx.pay.ToContract(
6517
6503
  createScriptAddress(network, sysParams.validatorHashes.treasuryHash),
6518
- { kind: "inline", value: import_lucid26.Data.void() },
6504
+ { kind: "inline", value: import_lucid24.Data.void() },
6519
6505
  (0, import_cardano_offchain_common17.mkAssetsOf)(
6520
6506
  indyAsset,
6521
6507
  (0, import_cardano_offchain_common17.assetClassValueOf)(pollManagerUtxo.assets, indyAsset)
@@ -6524,9 +6510,9 @@ async function endProposal(pollManagerOref, govOref, sysParams, lucid, currentSl
6524
6510
  }
6525
6511
  return tx;
6526
6512
  }
6527
- async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, allIAssetOrefs, iAssetOref, allCollateralAssetsOrefsOfIAsset, collateralAssetOref, stableswapPoolOrCdpCreatorOref, sysParams, lucid, currentSlot) {
6513
+ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, allIAssetOrefs, iAssetOref, allCollateralAssetsOrefsOfIAsset, collateralAssetOref, stableswapPoolOrCdpCreatorOref, sysParams, lucid) {
6528
6514
  const network = lucid.config().network;
6529
- const currentTime = BigInt((0, import_lucid25.slotToUnixTime)(network, currentSlot));
6515
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
6530
6516
  const ownAddr = await lucid.wallet().address();
6531
6517
  const govUtxo = matchSingle(
6532
6518
  await lucid.utxosByOutRef([govOref]),
@@ -6589,7 +6575,7 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
6589
6575
  (_) => new Error("Expected a single withdrawal UTXO")
6590
6576
  );
6591
6577
  const withdrawalVal = createValueFromWithdrawal(withdrawal);
6592
- const withdrawalChangeVal = (0, import_lucid25.addAssets)(
6578
+ const withdrawalChangeVal = (0, import_lucid23.addAssets)(
6593
6579
  treasuryWithdrawalUtxo.assets,
6594
6580
  (0, import_cardano_offchain_common17.negateAssets)(withdrawalVal)
6595
6581
  );
@@ -6602,7 +6588,7 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
6602
6588
  sysParams.treasuryParams.treasuryUtxosStakeCredential
6603
6589
  ) : void 0
6604
6590
  ),
6605
- { kind: "inline", value: import_lucid26.Data.void() },
6591
+ { kind: "inline", value: import_lucid24.Data.void() },
6606
6592
  withdrawalChangeVal
6607
6593
  );
6608
6594
  }
@@ -6614,9 +6600,9 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
6614
6600
  {
6615
6601
  kind: "inline",
6616
6602
  value: serialiseWithdrawalOutputDatum([
6617
- (0, import_lucid25.fromHex)((0, import_lucid25.fromText)("IndigoTreasuryWithdrawal")),
6603
+ (0, import_lucid23.fromHex)((0, import_lucid23.fromText)("IndigoTreasuryWithdrawal")),
6618
6604
  {
6619
- txHash: (0, import_lucid25.fromHex)(executeUtxo.txHash),
6605
+ txHash: (0, import_lucid23.fromHex)(executeUtxo.txHash),
6620
6606
  outputIndex: BigInt(executeUtxo.outputIndex)
6621
6607
  }
6622
6608
  ])
@@ -6681,7 +6667,7 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
6681
6667
  iassetRefScriptUtxo,
6682
6668
  iassetTokenPolicyRefScriptUtxo,
6683
6669
  stabilityPoolTokenPolicyRefScriptUtxo
6684
- ]).mintAssets(spAuthVal, import_lucid26.Data.void()).mintAssets(iassetAuthVal, import_lucid26.Data.void()).collectFrom([govUtxo], serialiseGovRedeemer("UpgradeGov")).pay.ToContract(
6670
+ ]).mintAssets(spAuthVal, import_lucid24.Data.void()).mintAssets(iassetAuthVal, import_lucid24.Data.void()).collectFrom([govUtxo], serialiseGovRedeemer("UpgradeGov")).pay.ToContract(
6685
6671
  govUtxo.address,
6686
6672
  {
6687
6673
  kind: "inline",
@@ -6860,7 +6846,7 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
6860
6846
  iassetRefScriptUtxo,
6861
6847
  collateralAssetTokenPolicyRefScriptUtxo
6862
6848
  ]);
6863
- tx.readFrom([govUtxo]).mintAssets(collateralAssetAuthVal, import_lucid26.Data.void()).collectFrom([iassetUtxo], {
6849
+ tx.readFrom([govUtxo]).mintAssets(collateralAssetAuthVal, import_lucid24.Data.void()).collectFrom([iassetUtxo], {
6864
6850
  kind: "selected",
6865
6851
  makeRedeemer: (inputIndices) => serialiseIAssetRedeemer({
6866
6852
  UpdateOrInsertAsset: {
@@ -6975,7 +6961,7 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
6975
6961
  if (!(0, import_cardano_offchain_common17.isSameAssetClass)(
6976
6962
  collateralAssetDatum.collateralAsset,
6977
6963
  updateCollateralContent.collateralAsset
6978
- ) || (0, import_lucid25.toHex)(collateralAssetDatum.iasset) !== (0, import_lucid25.toHex)(updateCollateralContent.correspondingIAsset)) {
6964
+ ) || (0, import_lucid23.toHex)(collateralAssetDatum.iasset) !== (0, import_lucid23.toHex)(updateCollateralContent.correspondingIAsset)) {
6979
6965
  throw new Error("Wrong collateral asset.");
6980
6966
  }
6981
6967
  tx.readFrom([iassetRefScriptUtxo]).collectFrom([collateralAssetUtxo], {
@@ -7051,7 +7037,7 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
7051
7037
  cdpTokenPolicyRefScriptUtxo,
7052
7038
  govUtxo,
7053
7039
  iassetUtxo
7054
- ]).mintAssets(cdpAuthVal, import_lucid26.Data.void()).collectFrom(
7040
+ ]).mintAssets(cdpAuthVal, import_lucid24.Data.void()).collectFrom(
7055
7041
  [cdpCreatorUtxo],
7056
7042
  serialiseCDPCreatorRedeemer("CreateStableswapPool")
7057
7043
  ).pay.ToContract(
@@ -7059,7 +7045,7 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
7059
7045
  network,
7060
7046
  sysParams.validatorHashes.cdpCreatorHash
7061
7047
  ),
7062
- { kind: "inline", value: import_lucid26.Data.void() },
7048
+ { kind: "inline", value: import_lucid24.Data.void() },
7063
7049
  cdpCreatorUtxo.assets
7064
7050
  ).pay.ToContract(
7065
7051
  createScriptAddress(network, sysParams.validatorHashes.cdpHash),
@@ -7155,7 +7141,7 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
7155
7141
  fromSystemParamsAsset(sysParams.executeParams.versionRecordToken),
7156
7142
  1n
7157
7143
  );
7158
- tx.readFrom([govRefScriptUtxo, versionRecordTokenPolicyRefScriptUtxo]).mintAssets(versionRecordNftVal, import_lucid26.Data.void()).pay.ToContract(
7144
+ tx.readFrom([govRefScriptUtxo, versionRecordTokenPolicyRefScriptUtxo]).mintAssets(versionRecordNftVal, import_lucid24.Data.void()).pay.ToContract(
7159
7145
  createScriptAddress(
7160
7146
  network,
7161
7147
  sysParams.validatorHashes.versionRegistryHash
@@ -7186,35 +7172,35 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
7186
7172
  });
7187
7173
  tx.readFrom([upgradeTokenPolicyRefScriptUtxo, executeRefScriptUtxo]).validFrom(Number(currentTime) - ONE_SECOND).validTo(
7188
7174
  Number(currentTime) + Number(sysParams.govParams.gBiasTime) - ONE_SECOND
7189
- ).collectFrom([executeUtxo], import_lucid26.Data.void()).mintAssets(
7175
+ ).collectFrom([executeUtxo], import_lucid24.Data.void()).mintAssets(
7190
7176
  (0, import_cardano_offchain_common17.mkAssetsOf)(fromSystemParamsAsset(sysParams.govParams.upgradeToken), -1n),
7191
- import_lucid26.Data.void()
7177
+ import_lucid24.Data.void()
7192
7178
  ).addSigner(ownAddr).setMinFee(922932n);
7193
7179
  return tx;
7194
7180
  }
7195
7181
 
7196
7182
  // src/contracts/gov/types.ts
7197
- var import_lucid27 = require("@lucid-evolution/lucid");
7198
- var GovParamsSchema = import_lucid27.Data.Object({
7183
+ var import_lucid25 = require("@lucid-evolution/lucid");
7184
+ var GovParamsSchema = import_lucid25.Data.Object({
7199
7185
  govNFT: AssetClassSchema2,
7200
7186
  pollToken: AssetClassSchema2,
7201
7187
  upgradeToken: AssetClassSchema2,
7202
7188
  indyAsset: AssetClassSchema2,
7203
7189
  versionRecordToken: AssetClassSchema2,
7204
- iassetSymbol: import_lucid27.Data.Bytes(),
7205
- pollManagerValHash: import_lucid27.Data.Bytes(),
7206
- iassetValHash: import_lucid27.Data.Bytes(),
7207
- gBiasTime: import_lucid27.Data.Integer(),
7190
+ iassetSymbol: import_lucid25.Data.Bytes(),
7191
+ pollManagerValHash: import_lucid25.Data.Bytes(),
7192
+ iassetValHash: import_lucid25.Data.Bytes(),
7193
+ gBiasTime: import_lucid25.Data.Integer(),
7208
7194
  daoIdentityToken: AssetClassSchema2,
7209
7195
  iAssetAuthToken: AssetClassSchema2
7210
7196
  });
7211
7197
  var GovParams = GovParamsSchema;
7212
7198
  function castGovParams(params) {
7213
- return import_lucid27.Data.castTo(params, GovParams);
7199
+ return import_lucid25.Data.castTo(params, GovParams);
7214
7200
  }
7215
7201
 
7216
7202
  // src/contracts/gov/scripts.ts
7217
- var import_lucid28 = require("@lucid-evolution/lucid");
7203
+ var import_lucid26 = require("@lucid-evolution/lucid");
7218
7204
 
7219
7205
  // src/validators/governance-validator.ts
7220
7206
  var _governanceValidator = {
@@ -7227,7 +7213,7 @@ var _governanceValidator = {
7227
7213
  var mkGovValidator = (params) => {
7228
7214
  return {
7229
7215
  type: "PlutusV3",
7230
- script: (0, import_lucid28.applyParamsToScript)(_governanceValidator.cborHex, [
7216
+ script: (0, import_lucid26.applyParamsToScript)(_governanceValidator.cborHex, [
7231
7217
  castGovParams(params)
7232
7218
  ])
7233
7219
  };
@@ -7235,7 +7221,7 @@ var mkGovValidator = (params) => {
7235
7221
  var mkGovValidatorFromSP = (params) => {
7236
7222
  return {
7237
7223
  type: "PlutusV3",
7238
- script: (0, import_lucid28.applyParamsToScript)(_governanceValidator.cborHex, [
7224
+ script: (0, import_lucid26.applyParamsToScript)(_governanceValidator.cborHex, [
7239
7225
  castGovParams({
7240
7226
  gBiasTime: BigInt(params.gBiasTime),
7241
7227
  govNFT: fromSystemParamsAssetLucid(params.govNFT),
@@ -7256,7 +7242,7 @@ var mkGovValidatorFromSP = (params) => {
7256
7242
  };
7257
7243
 
7258
7244
  // src/contracts/staking/transactions.ts
7259
- var import_lucid29 = require("@lucid-evolution/lucid");
7245
+ var import_lucid27 = require("@lucid-evolution/lucid");
7260
7246
  var import_cardano_offchain_common19 = require("@3rd-eye-labs/cardano-offchain-common");
7261
7247
  async function openStakingPosition(amount, params, lucid, stakingManagerRef) {
7262
7248
  const [pkh, _] = await addrDetails(lucid);
@@ -7282,18 +7268,18 @@ async function openStakingPosition(amount, params, lucid, stakingManagerRef) {
7282
7268
  }
7283
7269
  };
7284
7270
  const stakingPositionDatum = {
7285
- owner: (0, import_lucid29.fromHex)(pkh.hash),
7271
+ owner: (0, import_lucid27.fromHex)(pkh.hash),
7286
7272
  lockedAmount: [],
7287
7273
  positionSnapshot: {
7288
7274
  snapshotAda: stakingManagerOut.datum.managerSnapshot.snapshotAda
7289
7275
  }
7290
7276
  };
7291
- const stakingToken = params.stakingParams.stakingToken[0].unCurrencySymbol + (0, import_lucid29.fromText)(params.stakingParams.stakingToken[1].unTokenName);
7292
- const indyToken = params.stakingParams.indyToken[0].unCurrencySymbol + (0, import_lucid29.fromText)(params.stakingParams.indyToken[1].unTokenName);
7277
+ const stakingToken = params.stakingParams.stakingToken[0].unCurrencySymbol + (0, import_lucid27.fromText)(params.stakingParams.stakingToken[1].unTokenName);
7278
+ const indyToken = params.stakingParams.indyToken[0].unCurrencySymbol + (0, import_lucid27.fromText)(params.stakingParams.indyToken[1].unTokenName);
7293
7279
  return lucid.newTx().collectFrom(
7294
7280
  [stakingManagerOut.utxo],
7295
7281
  serialiseStakingRedeemer({
7296
- CreateStakingPosition: { creatorPkh: (0, import_lucid29.fromHex)(pkh.hash) }
7282
+ CreateStakingPosition: { creatorPkh: (0, import_lucid27.fromHex)(pkh.hash) }
7297
7283
  })
7298
7284
  ).readFrom([stakingRefScriptUtxo]).pay.ToContract(
7299
7285
  stakingManagerOut.utxo.address,
@@ -7306,7 +7292,7 @@ async function openStakingPosition(amount, params, lucid, stakingManagerRef) {
7306
7292
  {
7307
7293
  [stakingToken]: 1n
7308
7294
  },
7309
- import_lucid29.Data.void()
7295
+ import_lucid27.Data.void()
7310
7296
  ).pay.ToContract(
7311
7297
  stakingManagerOut.utxo.address,
7312
7298
  {
@@ -7319,9 +7305,8 @@ async function openStakingPosition(amount, params, lucid, stakingManagerRef) {
7319
7305
  }
7320
7306
  ).addSignerKey(pkh.hash);
7321
7307
  }
7322
- async function adjustStakingPosition(stakingPositionRef, amount, params, lucid, currentSlot, stakingManagerRef) {
7323
- const network = lucid.config().network;
7324
- const now = BigInt((0, import_lucid29.slotToUnixTime)(network, currentSlot));
7308
+ async function adjustStakingPosition(stakingPositionRef, amount, params, lucid, stakingManagerRef) {
7309
+ const now = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
7325
7310
  const stakingPositionOut = await findStakingPositionByOutRef(
7326
7311
  stakingPositionRef,
7327
7312
  lucid
@@ -7360,7 +7345,7 @@ async function adjustStakingPosition(stakingPositionRef, amount, params, lucid,
7360
7345
  totalStake: stakingManagerOut.datum.totalStake + amount
7361
7346
  })
7362
7347
  },
7363
- (0, import_lucid29.addAssets)(stakingManagerOut.utxo.assets, (0, import_cardano_offchain_common19.mkLovelacesOf)(-adaReward))
7348
+ (0, import_lucid27.addAssets)(stakingManagerOut.utxo.assets, (0, import_cardano_offchain_common19.mkLovelacesOf)(-adaReward))
7364
7349
  ).pay.ToContract(
7365
7350
  stakingPositionOut.utxo.address,
7366
7351
  {
@@ -7373,12 +7358,11 @@ async function adjustStakingPosition(stakingPositionRef, amount, params, lucid,
7373
7358
  lockedAmount: newLockedAmount
7374
7359
  })
7375
7360
  },
7376
- (0, import_lucid29.addAssets)(stakingPositionOut.utxo.assets, (0, import_cardano_offchain_common19.mkAssetsOf)(indyToken, amount))
7377
- ).addSignerKey((0, import_lucid29.toHex)(stakingPositionOut.datum.owner));
7361
+ (0, import_lucid27.addAssets)(stakingPositionOut.utxo.assets, (0, import_cardano_offchain_common19.mkAssetsOf)(indyToken, amount))
7362
+ ).addSignerKey((0, import_lucid27.toHex)(stakingPositionOut.datum.owner));
7378
7363
  }
7379
- async function closeStakingPosition(stakingPositionRef, params, lucid, currentSlot, stakingManagerRef) {
7380
- const network = lucid.config().network;
7381
- const now = BigInt((0, import_lucid29.slotToUnixTime)(network, currentSlot));
7364
+ async function closeStakingPosition(stakingPositionRef, params, lucid, stakingManagerRef) {
7365
+ const now = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
7382
7366
  const stakingPositionOut = await findStakingPositionByOutRef(
7383
7367
  stakingPositionRef,
7384
7368
  lucid
@@ -7420,11 +7404,11 @@ async function closeStakingPosition(stakingPositionRef, params, lucid, currentSl
7420
7404
  totalStake: stakingManagerOut.datum.totalStake - existingIndyAmount
7421
7405
  })
7422
7406
  },
7423
- (0, import_lucid29.addAssets)(stakingManagerOut.utxo.assets, (0, import_cardano_offchain_common19.mkLovelacesOf)(-adaReward))
7407
+ (0, import_lucid27.addAssets)(stakingManagerOut.utxo.assets, (0, import_cardano_offchain_common19.mkLovelacesOf)(-adaReward))
7424
7408
  ).mintAssets(
7425
7409
  (0, import_cardano_offchain_common19.mkAssetsOf)(fromSystemParamsAsset(params.stakingParams.stakingToken), -1n),
7426
- import_lucid29.Data.void()
7427
- ).addSignerKey((0, import_lucid29.toHex)(stakingPositionOut.datum.owner));
7410
+ import_lucid27.Data.void()
7411
+ ).addSignerKey((0, import_lucid27.toHex)(stakingPositionOut.datum.owner));
7428
7412
  }
7429
7413
  var MIN_UTXO_AMOUNT = 2000000n;
7430
7414
  async function distributeAda(stakingManagerRef, collectorRefs, params, lucid) {
@@ -7432,7 +7416,7 @@ async function distributeAda(stakingManagerRef, collectorRefs, params, lucid) {
7432
7416
  const stakingManagerDatum = parseStakingManagerDatum(
7433
7417
  (0, import_cardano_offchain_common19.getInlineDatumOrThrow)(stakingManagerUtxo)
7434
7418
  );
7435
- const collectorUtxos = (await lucid.utxosByOutRef(collectorRefs)).filter((utxo) => utxo.datum && utxo.datum === import_lucid29.Data.void()).filter((utxo) => utxo.assets["lovelace"] > MIN_UTXO_AMOUNT);
7419
+ const collectorUtxos = (await lucid.utxosByOutRef(collectorRefs)).filter((utxo) => utxo.datum && utxo.datum === import_lucid27.Data.void()).filter((utxo) => utxo.assets["lovelace"] > MIN_UTXO_AMOUNT);
7436
7420
  if (collectorUtxos.length === 0) {
7437
7421
  throw new Error("No available collectors found");
7438
7422
  }
@@ -7469,12 +7453,12 @@ async function distributeAda(stakingManagerRef, collectorRefs, params, lucid) {
7469
7453
  managerSnapshot: { snapshotAda: newSnapshot }
7470
7454
  })
7471
7455
  },
7472
- (0, import_lucid29.addAssets)(stakingManagerUtxo.assets, (0, import_cardano_offchain_common19.mkLovelacesOf)(adaRewardCollected))
7456
+ (0, import_lucid27.addAssets)(stakingManagerUtxo.assets, (0, import_cardano_offchain_common19.mkLovelacesOf)(adaRewardCollected))
7473
7457
  );
7474
7458
  for (const collectorUtxo of collectorUtxos) {
7475
7459
  tx.pay.ToContract(
7476
7460
  collectorUtxo.address,
7477
- { kind: "inline", value: import_lucid29.Data.void() },
7461
+ { kind: "inline", value: import_lucid27.Data.void() },
7478
7462
  (0, import_cardano_offchain_common19.mkLovelacesOf)(MIN_UTXO_AMOUNT)
7479
7463
  );
7480
7464
  }
@@ -7482,47 +7466,47 @@ async function distributeAda(stakingManagerRef, collectorRefs, params, lucid) {
7482
7466
  }
7483
7467
 
7484
7468
  // src/contracts/staking/types.ts
7485
- var import_lucid30 = require("@lucid-evolution/lucid");
7486
- var StakingParamsSchema = import_lucid30.Data.Object({
7469
+ var import_lucid28 = require("@lucid-evolution/lucid");
7470
+ var StakingParamsSchema = import_lucid28.Data.Object({
7487
7471
  stakingManagerNft: AssetClassSchema2,
7488
7472
  stakingToken: AssetClassSchema2,
7489
7473
  indyToken: AssetClassSchema2,
7490
7474
  pollToken: AssetClassSchema2,
7491
7475
  versionRecordToken: AssetClassSchema2,
7492
- collectorValHash: import_lucid30.Data.Bytes()
7476
+ collectorValHash: import_lucid28.Data.Bytes()
7493
7477
  });
7494
7478
  var StakingParams = StakingParamsSchema;
7495
7479
  function castStakingParams(params) {
7496
- return import_lucid30.Data.castTo(params, StakingParams);
7480
+ return import_lucid28.Data.castTo(params, StakingParams);
7497
7481
  }
7498
7482
 
7499
7483
  // src/contracts/interest-oracle/transactions.ts
7500
- var import_lucid36 = require("@lucid-evolution/lucid");
7484
+ var import_lucid34 = require("@lucid-evolution/lucid");
7501
7485
 
7502
7486
  // src/contracts/one-shot/transactions.ts
7503
- var import_lucid33 = require("@lucid-evolution/lucid");
7487
+ var import_lucid31 = require("@lucid-evolution/lucid");
7504
7488
 
7505
7489
  // src/contracts/one-shot/scripts.ts
7506
- var import_lucid32 = require("@lucid-evolution/lucid");
7490
+ var import_lucid30 = require("@lucid-evolution/lucid");
7507
7491
 
7508
7492
  // src/contracts/one-shot/types.ts
7509
- var import_lucid31 = require("@lucid-evolution/lucid");
7510
- var OneShotParamsSchema = import_lucid31.Data.Object({
7511
- referenceOutRef: import_lucid31.Data.Object({
7512
- txHash: import_lucid31.Data.Bytes(),
7513
- outputIdx: import_lucid31.Data.Integer()
7493
+ var import_lucid29 = require("@lucid-evolution/lucid");
7494
+ var OneShotParamsSchema = import_lucid29.Data.Object({
7495
+ referenceOutRef: import_lucid29.Data.Object({
7496
+ txHash: import_lucid29.Data.Bytes(),
7497
+ outputIdx: import_lucid29.Data.Integer()
7514
7498
  }),
7515
- mintAmounts: import_lucid31.Data.Array(
7516
- import_lucid31.Data.Object({
7499
+ mintAmounts: import_lucid29.Data.Array(
7500
+ import_lucid29.Data.Object({
7517
7501
  /// Use hex encoded string
7518
- tokenName: import_lucid31.Data.Bytes(),
7519
- amount: import_lucid31.Data.Integer()
7502
+ tokenName: import_lucid29.Data.Bytes(),
7503
+ amount: import_lucid29.Data.Integer()
7520
7504
  })
7521
7505
  )
7522
7506
  });
7523
7507
  var OneShotParams = OneShotParamsSchema;
7524
7508
  function castOneShotParams(params) {
7525
- return import_lucid31.Data.castTo(params, OneShotParams);
7509
+ return import_lucid29.Data.castTo(params, OneShotParams);
7526
7510
  }
7527
7511
 
7528
7512
  // src/validators/one-shot-policy.ts
@@ -7536,7 +7520,7 @@ var _oneShotPolicy = {
7536
7520
  function mkOneShotPolicy(params) {
7537
7521
  return {
7538
7522
  type: "PlutusV3",
7539
- script: (0, import_lucid32.applyParamsToScript)(_oneShotPolicy.cborHex, [
7523
+ script: (0, import_lucid30.applyParamsToScript)(_oneShotPolicy.cborHex, [
7540
7524
  castOneShotParams(params)
7541
7525
  ])
7542
7526
  };
@@ -7546,7 +7530,7 @@ function mkOneShotPolicy(params) {
7546
7530
  var import_Array = require("fp-ts/lib/Array");
7547
7531
  async function oneShotMintTx(lucid, params) {
7548
7532
  const oneShotPolicy = mkOneShotPolicy(params);
7549
- const policyId = (0, import_lucid33.mintingPolicyToId)(oneShotPolicy);
7533
+ const policyId = (0, import_lucid31.mintingPolicyToId)(oneShotPolicy);
7550
7534
  const refUtxo = matchSingle(
7551
7535
  await lucid.utxosByOutRef([
7552
7536
  {
@@ -7562,11 +7546,11 @@ async function oneShotMintTx(lucid, params) {
7562
7546
  lucid.newTx().collectFrom([refUtxo]).mintAssets(
7563
7547
  (0, import_Array.reduce)(
7564
7548
  {},
7565
- (acc, entry) => (0, import_lucid33.addAssets)(acc, {
7566
- [(0, import_lucid33.toUnit)(policyId, entry.tokenName)]: entry.amount
7549
+ (acc, entry) => (0, import_lucid31.addAssets)(acc, {
7550
+ [(0, import_lucid31.toUnit)(policyId, entry.tokenName)]: entry.amount
7567
7551
  })
7568
7552
  )(params.mintAmounts),
7569
- import_lucid33.Data.void()
7553
+ import_lucid31.Data.void()
7570
7554
  ).attach.MintingPolicy(oneShotPolicy),
7571
7555
  policyId
7572
7556
  ];
@@ -7579,18 +7563,18 @@ async function runOneShotMintTx(lucid, params) {
7579
7563
  }
7580
7564
 
7581
7565
  // src/contracts/interest-oracle/scripts.ts
7582
- var import_lucid35 = require("@lucid-evolution/lucid");
7566
+ var import_lucid33 = require("@lucid-evolution/lucid");
7583
7567
 
7584
7568
  // src/contracts/interest-oracle/types.ts
7585
- var import_lucid34 = require("@lucid-evolution/lucid");
7586
- var InterestOracleParamsSchema = import_lucid34.Data.Object({
7569
+ var import_lucid32 = require("@lucid-evolution/lucid");
7570
+ var InterestOracleParamsSchema = import_lucid32.Data.Object({
7587
7571
  /** Milliseconds */
7588
- biasTime: import_lucid34.Data.Integer(),
7589
- owner: import_lucid34.Data.Bytes()
7572
+ biasTime: import_lucid32.Data.Integer(),
7573
+ owner: import_lucid32.Data.Bytes()
7590
7574
  });
7591
7575
  var InterestOracleParams = InterestOracleParamsSchema;
7592
7576
  function castInterestOracleParams(params) {
7593
- return import_lucid34.Data.castTo(params, InterestOracleParams);
7577
+ return import_lucid32.Data.castTo(params, InterestOracleParams);
7594
7578
  }
7595
7579
 
7596
7580
  // src/validators/interest-oracle-validator.ts
@@ -7604,7 +7588,7 @@ var _interestOracleValidator = {
7604
7588
  function mkInterestOracleValidator(params) {
7605
7589
  return {
7606
7590
  type: "PlutusV3",
7607
- script: (0, import_lucid35.applyParamsToScript)(_interestOracleValidator.cborHex, [
7591
+ script: (0, import_lucid33.applyParamsToScript)(_interestOracleValidator.cborHex, [
7608
7592
  castInterestOracleParams(params)
7609
7593
  ])
7610
7594
  };
@@ -7630,14 +7614,14 @@ async function startInterestOracle(initialUnitaryInterest, initialInterestRate,
7630
7614
  },
7631
7615
  mintAmounts: [
7632
7616
  {
7633
- tokenName: (0, import_lucid36.fromText)(tokenName),
7617
+ tokenName: (0, import_lucid34.fromText)(tokenName),
7634
7618
  amount: 1n
7635
7619
  }
7636
7620
  ]
7637
7621
  });
7638
7622
  const validator = mkInterestOracleValidator(oracleParams);
7639
7623
  tx.pay.ToContract(
7640
- (0, import_lucid36.validatorToAddress)(network, validator),
7624
+ (0, import_lucid34.validatorToAddress)(network, validator),
7641
7625
  {
7642
7626
  kind: "inline",
7643
7627
  value: serialiseInterestOracleDatum({
@@ -7650,12 +7634,12 @@ async function startInterestOracle(initialUnitaryInterest, initialInterestRate,
7650
7634
  },
7651
7635
  {
7652
7636
  lovelace: 2500000n,
7653
- [(0, import_lucid36.toUnit)(policyId, (0, import_lucid36.fromText)(tokenName))]: 1n
7637
+ [(0, import_lucid34.toUnit)(policyId, (0, import_lucid34.fromText)(tokenName))]: 1n
7654
7638
  }
7655
7639
  );
7656
7640
  if (withScriptRef) {
7657
7641
  tx.pay.ToAddressWithData(
7658
- (0, import_lucid36.validatorToAddress)(network, validator),
7642
+ (0, import_lucid34.validatorToAddress)(network, validator),
7659
7643
  void 0,
7660
7644
  void 0,
7661
7645
  validator
@@ -7664,19 +7648,18 @@ async function startInterestOracle(initialUnitaryInterest, initialInterestRate,
7664
7648
  return [
7665
7649
  tx,
7666
7650
  {
7667
- currencySymbol: (0, import_lucid36.fromHex)(policyId),
7668
- tokenName: (0, import_lucid36.fromHex)((0, import_lucid36.fromText)(tokenName))
7651
+ currencySymbol: (0, import_lucid34.fromHex)(policyId),
7652
+ tokenName: (0, import_lucid34.fromHex)((0, import_lucid34.fromText)(tokenName))
7669
7653
  }
7670
7654
  ];
7671
7655
  }
7672
- async function feedInterestOracle(params, newInterestRate, lucid, currentSlot, assetClass, utxo, scriptRef2) {
7656
+ async function feedInterestOracle(params, newInterestRate, lucid, assetClass, utxo, scriptRef2) {
7673
7657
  if (!assetClass && !utxo)
7674
7658
  throw new Error("Either interest oracle nft or utxo must be provided");
7675
7659
  if (assetClass && !utxo) {
7676
7660
  utxo = await findInterestOracle(lucid, assetClass);
7677
7661
  }
7678
- const network = lucid.config().network;
7679
- const now = BigInt((0, import_lucid36.slotToUnixTime)(network, currentSlot));
7662
+ const now = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
7680
7663
  const tx = lucid.newTx();
7681
7664
  const datum = parseInterestOracleDatum(getInlineDatumOrThrow(utxo));
7682
7665
  if (scriptRef2) {
@@ -7714,10 +7697,10 @@ async function feedInterestOracle(params, newInterestRate, lucid, currentSlot, a
7714
7697
  }
7715
7698
 
7716
7699
  // src/contracts/interest-collection/helpers.ts
7717
- var import_lucid37 = require("@lucid-evolution/lucid");
7700
+ var import_lucid35 = require("@lucid-evolution/lucid");
7718
7701
  function signersAllOf(multisig) {
7719
7702
  if ("Signature" in multisig) {
7720
- return [(0, import_lucid37.toHex)(multisig.Signature.keyHash)];
7703
+ return [(0, import_lucid35.toHex)(multisig.Signature.keyHash)];
7721
7704
  } else {
7722
7705
  return multisig.AtLeast.authSignatories.map((signatory) => {
7723
7706
  try {
@@ -7730,24 +7713,24 @@ function signersAllOf(multisig) {
7730
7713
  }
7731
7714
 
7732
7715
  // src/contracts/interest-collection/types.ts
7733
- var import_lucid38 = require("@lucid-evolution/lucid");
7734
- var InterestCollectionParamsSchema = import_lucid38.Data.Object({
7716
+ var import_lucid36 = require("@lucid-evolution/lucid");
7717
+ var InterestCollectionParamsSchema = import_lucid36.Data.Object({
7735
7718
  versionRecordNft: AssetClassSchema2,
7736
7719
  multisigUtxoNft: AssetClassSchema2,
7737
7720
  cdpAuthTk: AssetClassSchema2,
7738
7721
  collateralAssetAuthTk: AssetClassSchema2,
7739
7722
  govAuthTk: AssetClassSchema2,
7740
- cdpAssetSymbol: import_lucid38.Data.Bytes(),
7741
- cdpBiasTime: import_lucid38.Data.Integer(),
7742
- interestSettlementCooldown: import_lucid38.Data.Integer()
7723
+ cdpAssetSymbol: import_lucid36.Data.Bytes(),
7724
+ cdpBiasTime: import_lucid36.Data.Integer(),
7725
+ interestSettlementCooldown: import_lucid36.Data.Integer()
7743
7726
  });
7744
7727
  var InterestCollectionParams = InterestCollectionParamsSchema;
7745
7728
  function castInterestCollectionParams(params) {
7746
- return import_lucid38.Data.castTo(params, InterestCollectionParams);
7729
+ return import_lucid36.Data.castTo(params, InterestCollectionParams);
7747
7730
  }
7748
7731
 
7749
7732
  // src/contracts/interest-collection/scripts.ts
7750
- var import_lucid39 = require("@lucid-evolution/lucid");
7733
+ var import_lucid37 = require("@lucid-evolution/lucid");
7751
7734
 
7752
7735
  // src/validators/interest-collection-validator.ts
7753
7736
  var _interestCollectionValidator = {
@@ -7760,7 +7743,7 @@ var _interestCollectionValidator = {
7760
7743
  function mkInterestCollectionValidator(params) {
7761
7744
  return {
7762
7745
  type: "PlutusV3",
7763
- script: (0, import_lucid39.applyParamsToScript)(_interestCollectionValidator.cborHex, [
7746
+ script: (0, import_lucid37.applyParamsToScript)(_interestCollectionValidator.cborHex, [
7764
7747
  castInterestCollectionParams(params)
7765
7748
  ])
7766
7749
  };
@@ -7768,7 +7751,7 @@ function mkInterestCollectionValidator(params) {
7768
7751
  var mkInterestCollectionValidatorFromSP = (params) => {
7769
7752
  return {
7770
7753
  type: "PlutusV3",
7771
- script: (0, import_lucid39.applyParamsToScript)(_interestCollectionValidator.cborHex, [
7754
+ script: (0, import_lucid37.applyParamsToScript)(_interestCollectionValidator.cborHex, [
7772
7755
  castInterestCollectionParams({
7773
7756
  versionRecordNft: fromSystemParamsAssetLucid(params.versionRecordNft),
7774
7757
  multisigUtxoNft: fromSystemParamsAssetLucid(params.multisigUtxoNft),
@@ -7830,17 +7813,17 @@ async function findRandomNonAdminInterestCollector(lucid, sysParams) {
7830
7813
  }
7831
7814
 
7832
7815
  // src/contracts/version-registry/types.ts
7833
- var import_lucid40 = require("@lucid-evolution/lucid");
7834
- var VersionRecordTokenParamsSchema = import_lucid40.Data.Object({
7816
+ var import_lucid38 = require("@lucid-evolution/lucid");
7817
+ var VersionRecordTokenParamsSchema = import_lucid38.Data.Object({
7835
7818
  upgradeToken: AssetClassSchema2
7836
7819
  });
7837
7820
  var VersionRecordTokenParams = VersionRecordTokenParamsSchema;
7838
7821
  function castVersionRecordTokenParams(params) {
7839
- return import_lucid40.Data.castTo(params, VersionRecordTokenParams);
7822
+ return import_lucid38.Data.castTo(params, VersionRecordTokenParams);
7840
7823
  }
7841
7824
 
7842
7825
  // src/contracts/version-registry/scripts.ts
7843
- var import_lucid41 = require("@lucid-evolution/lucid");
7826
+ var import_lucid39 = require("@lucid-evolution/lucid");
7844
7827
 
7845
7828
  // src/validators/version-record-policy.ts
7846
7829
  var _versionRecordTokenPolicy = {
@@ -7860,7 +7843,7 @@ var _versionRegistryValidator = {
7860
7843
  function mkVersionRecordTokenPolicy(params) {
7861
7844
  return {
7862
7845
  type: "PlutusV3",
7863
- script: (0, import_lucid41.applyParamsToScript)(_versionRecordTokenPolicy.cborHex, [
7846
+ script: (0, import_lucid39.applyParamsToScript)(_versionRecordTokenPolicy.cborHex, [
7864
7847
  castVersionRecordTokenParams(params)
7865
7848
  ])
7866
7849
  };
@@ -7873,7 +7856,7 @@ var mkVersionRegistryValidator = () => {
7873
7856
  };
7874
7857
 
7875
7858
  // src/contracts/treasury/scripts.ts
7876
- var import_lucid43 = require("@lucid-evolution/lucid");
7859
+ var import_lucid41 = require("@lucid-evolution/lucid");
7877
7860
 
7878
7861
  // src/validators/treasury-validator.ts
7879
7862
  var _treasuryValidator = {
@@ -7883,22 +7866,22 @@ var _treasuryValidator = {
7883
7866
  };
7884
7867
 
7885
7868
  // src/contracts/treasury/types.ts
7886
- var import_lucid42 = require("@lucid-evolution/lucid");
7887
- var TreasuryParamsSchema = import_lucid42.Data.Object({
7869
+ var import_lucid40 = require("@lucid-evolution/lucid");
7870
+ var TreasuryParamsSchema = import_lucid40.Data.Object({
7888
7871
  upgradeToken: AssetClassSchema2,
7889
7872
  versionRecordToken: AssetClassSchema2,
7890
- treasuryUtxosStakeCredential: import_lucid42.Data.Nullable(StakeCredentialSchema)
7873
+ treasuryUtxosStakeCredential: import_lucid40.Data.Nullable(StakeCredentialSchema)
7891
7874
  });
7892
7875
  var TreasuryParams = TreasuryParamsSchema;
7893
7876
  function castTreasuryParams(params) {
7894
- return import_lucid42.Data.castTo(params, TreasuryParams);
7877
+ return import_lucid40.Data.castTo(params, TreasuryParams);
7895
7878
  }
7896
7879
 
7897
7880
  // src/contracts/treasury/scripts.ts
7898
7881
  var mkTreasuryValidatorFromSP = (params) => {
7899
7882
  return {
7900
7883
  type: "PlutusV3",
7901
- script: (0, import_lucid43.applyParamsToScript)(_treasuryValidator.cborHex, [
7884
+ script: (0, import_lucid41.applyParamsToScript)(_treasuryValidator.cborHex, [
7902
7885
  castTreasuryParams({
7903
7886
  upgradeToken: fromSystemParamsAssetLucid(params.upgradeToken),
7904
7887
  versionRecordToken: fromSystemParamsAssetLucid(
@@ -7967,7 +7950,7 @@ async function findAllTreasuryUtxosWithNonAdaAsset(lucid, sysParams, includeDaoT
7967
7950
  }
7968
7951
 
7969
7952
  // src/contracts/collector/scripts.ts
7970
- var import_lucid44 = require("@lucid-evolution/lucid");
7953
+ var import_lucid42 = require("@lucid-evolution/lucid");
7971
7954
 
7972
7955
  // src/validators/collector-validator.ts
7973
7956
  var _collectorValidator = {
@@ -7980,19 +7963,19 @@ var _collectorValidator = {
7980
7963
  var mkCollectorValidatorFromSP = (params) => {
7981
7964
  return {
7982
7965
  type: "PlutusV3",
7983
- script: (0, import_lucid44.applyParamsToScript)(_collectorValidator.cborHex, [
7984
- new import_lucid44.Constr(0, [
7985
- new import_lucid44.Constr(0, [
7966
+ script: (0, import_lucid42.applyParamsToScript)(_collectorValidator.cborHex, [
7967
+ new import_lucid42.Constr(0, [
7968
+ new import_lucid42.Constr(0, [
7986
7969
  params.stakingManagerNFT[0].unCurrencySymbol,
7987
- (0, import_lucid44.fromText)(params.stakingManagerNFT[1].unTokenName)
7970
+ (0, import_lucid42.fromText)(params.stakingManagerNFT[1].unTokenName)
7988
7971
  ]),
7989
- new import_lucid44.Constr(0, [
7972
+ new import_lucid42.Constr(0, [
7990
7973
  params.stakingToken[0].unCurrencySymbol,
7991
- (0, import_lucid44.fromText)(params.stakingToken[1].unTokenName)
7974
+ (0, import_lucid42.fromText)(params.stakingToken[1].unTokenName)
7992
7975
  ]),
7993
- new import_lucid44.Constr(0, [
7976
+ new import_lucid42.Constr(0, [
7994
7977
  params.versionRecordToken[0].unCurrencySymbol,
7995
- (0, import_lucid44.fromText)(params.versionRecordToken[1].unTokenName)
7978
+ (0, import_lucid42.fromText)(params.versionRecordToken[1].unTokenName)
7996
7979
  ])
7997
7980
  ])
7998
7981
  ])
@@ -8000,8 +7983,8 @@ var mkCollectorValidatorFromSP = (params) => {
8000
7983
  };
8001
7984
 
8002
7985
  // src/contracts/execute/types.ts
8003
- var import_lucid45 = require("@lucid-evolution/lucid");
8004
- var ExecuteParamsSchema = import_lucid45.Data.Object({
7986
+ var import_lucid43 = require("@lucid-evolution/lucid");
7987
+ var ExecuteParamsSchema = import_lucid43.Data.Object({
8005
7988
  govNFT: AssetClassSchema2,
8006
7989
  upgradeToken: AssetClassSchema2,
8007
7990
  iAssetToken: AssetClassSchema2,
@@ -8010,19 +7993,19 @@ var ExecuteParamsSchema = import_lucid45.Data.Object({
8010
7993
  cdpCreatorToken: AssetClassSchema2,
8011
7994
  cdpToken: AssetClassSchema2,
8012
7995
  versionRecordToken: AssetClassSchema2,
8013
- iassetValHash: import_lucid45.Data.Bytes(),
8014
- cdpValHash: import_lucid45.Data.Bytes(),
8015
- sPoolValHash: import_lucid45.Data.Bytes(),
8016
- versionRegistryValHash: import_lucid45.Data.Bytes(),
8017
- treasuryValHash: import_lucid45.Data.Bytes()
7996
+ iassetValHash: import_lucid43.Data.Bytes(),
7997
+ cdpValHash: import_lucid43.Data.Bytes(),
7998
+ sPoolValHash: import_lucid43.Data.Bytes(),
7999
+ versionRegistryValHash: import_lucid43.Data.Bytes(),
8000
+ treasuryValHash: import_lucid43.Data.Bytes()
8018
8001
  });
8019
8002
  var ExecuteParams = ExecuteParamsSchema;
8020
8003
  function castExecuteParams(params) {
8021
- return import_lucid45.Data.castTo(params, ExecuteParams);
8004
+ return import_lucid43.Data.castTo(params, ExecuteParams);
8022
8005
  }
8023
8006
 
8024
8007
  // src/contracts/execute/scripts.ts
8025
- var import_lucid46 = require("@lucid-evolution/lucid");
8008
+ var import_lucid44 = require("@lucid-evolution/lucid");
8026
8009
 
8027
8010
  // src/validators/execute-validator.ts
8028
8011
  var _executeValidator = {
@@ -8035,8 +8018,8 @@ var _executeValidator = {
8035
8018
  var mkExecuteValidator = (params) => {
8036
8019
  return {
8037
8020
  type: "PlutusV3",
8038
- script: (0, import_lucid46.applySingleCborEncoding)(
8039
- (0, import_lucid46.applyParamsToScript)(_executeValidator.cborHex, [
8021
+ script: (0, import_lucid44.applySingleCborEncoding)(
8022
+ (0, import_lucid44.applyParamsToScript)(_executeValidator.cborHex, [
8040
8023
  castExecuteParams(params)
8041
8024
  ])
8042
8025
  )
@@ -8045,8 +8028,8 @@ var mkExecuteValidator = (params) => {
8045
8028
  var mkExecuteValidatorFromSP = (params) => {
8046
8029
  return {
8047
8030
  type: "PlutusV3",
8048
- script: (0, import_lucid46.applySingleCborEncoding)(
8049
- (0, import_lucid46.applyParamsToScript)(_executeValidator.cborHex, [
8031
+ script: (0, import_lucid44.applySingleCborEncoding)(
8032
+ (0, import_lucid44.applyParamsToScript)(_executeValidator.cborHex, [
8050
8033
  castExecuteParams({
8051
8034
  govNFT: fromSystemParamsAssetLucid(params.govNFT),
8052
8035
  upgradeToken: fromSystemParamsAssetLucid(params.upgradeToken),
@@ -8074,21 +8057,21 @@ var mkExecuteValidatorFromSP = (params) => {
8074
8057
  };
8075
8058
 
8076
8059
  // src/contracts/price-oracle/types.ts
8077
- var import_lucid47 = require("@lucid-evolution/lucid");
8078
- var PriceOracleParamsSchema = import_lucid47.Data.Object({
8079
- owner: import_lucid47.Data.Bytes(),
8060
+ var import_lucid45 = require("@lucid-evolution/lucid");
8061
+ var PriceOracleParamsSchema = import_lucid45.Data.Object({
8062
+ owner: import_lucid45.Data.Bytes(),
8080
8063
  /** Milliseconds */
8081
- biasTime: import_lucid47.Data.Integer(),
8064
+ biasTime: import_lucid45.Data.Integer(),
8082
8065
  /** Milliseconds */
8083
- expirationPeriod: import_lucid47.Data.Integer()
8066
+ expirationPeriod: import_lucid45.Data.Integer()
8084
8067
  });
8085
8068
  var PriceOracleParams = PriceOracleParamsSchema;
8086
8069
  function castPriceOracleParams(params) {
8087
- return import_lucid47.Data.castTo(params, PriceOracleParams);
8070
+ return import_lucid45.Data.castTo(params, PriceOracleParams);
8088
8071
  }
8089
8072
 
8090
8073
  // src/contracts/stability-pool/queries.ts
8091
- var import_lucid48 = require("@lucid-evolution/lucid");
8074
+ var import_lucid46 = require("@lucid-evolution/lucid");
8092
8075
  var import_cardano_offchain_common23 = require("@3rd-eye-labs/cardano-offchain-common");
8093
8076
  var import_fp_ts20 = require("fp-ts");
8094
8077
  async function findStabilityPool(lucid, sysParams, iassetName) {
@@ -8105,7 +8088,7 @@ async function findStabilityPool(lucid, sysParams, iassetName) {
8105
8088
  import_fp_ts20.option.fromNullable(utxo.datum),
8106
8089
  import_fp_ts20.option.flatMap(parseStabilityPoolDatum),
8107
8090
  import_fp_ts20.option.flatMap((datum) => {
8108
- if ((0, import_lucid48.toHex)(datum.iasset) == (0, import_lucid48.toHex)(iassetName)) {
8091
+ if ((0, import_lucid46.toHex)(datum.iasset) == (0, import_lucid46.toHex)(iassetName)) {
8109
8092
  return import_fp_ts20.option.some({ utxo, datum });
8110
8093
  } else {
8111
8094
  return import_fp_ts20.option.none;
@@ -8132,7 +8115,7 @@ async function findStabilityPoolAccount(lucid, sysParams, owner, iassetName) {
8132
8115
  import_fp_ts20.option.fromNullable(utxo.datum),
8133
8116
  import_fp_ts20.option.flatMap(parseAccountDatum),
8134
8117
  import_fp_ts20.option.flatMap((datum) => {
8135
- if ((0, import_lucid48.toHex)(datum.iasset) == (0, import_lucid48.toHex)(iassetName) && (0, import_lucid48.toHex)(datum.owner) == owner) {
8118
+ if ((0, import_lucid46.toHex)(datum.iasset) == (0, import_lucid46.toHex)(iassetName) && (0, import_lucid46.toHex)(datum.owner) == owner) {
8136
8119
  return import_fp_ts20.option.some({ utxo, datum });
8137
8120
  } else {
8138
8121
  return import_fp_ts20.option.none;
@@ -8160,7 +8143,7 @@ async function findE2s2sSnapshots(lucid, sysParams, iassetName) {
8160
8143
  import_fp_ts20.option.fromNullable(utxo.datum),
8161
8144
  import_fp_ts20.option.flatMap(parseSnapshotEpochToScaleToSumDatum),
8162
8145
  import_fp_ts20.option.flatMap((datum) => {
8163
- if ((0, import_lucid48.toHex)(datum.iasset) == (0, import_lucid48.toHex)(iassetName)) {
8146
+ if ((0, import_lucid46.toHex)(datum.iasset) == (0, import_lucid46.toHex)(iassetName)) {
8164
8147
  return import_fp_ts20.option.some({ utxo, datum });
8165
8148
  } else {
8166
8149
  return import_fp_ts20.option.none;
@@ -8173,20 +8156,20 @@ async function findE2s2sSnapshots(lucid, sysParams, iassetName) {
8173
8156
  }
8174
8157
 
8175
8158
  // src/contracts/stability-pool/transactions.ts
8176
- var import_lucid49 = require("@lucid-evolution/lucid");
8159
+ var import_lucid47 = require("@lucid-evolution/lucid");
8177
8160
  var import_cardano_offchain_common24 = require("@3rd-eye-labs/cardano-offchain-common");
8178
8161
  var import_ts_pattern18 = require("ts-pattern");
8179
8162
  async function requestSpAccountCreation(assetAscii, amount, sysParams, lucid) {
8180
8163
  const [pkh, _skh] = await addrDetails(lucid);
8181
- const iasset = (0, import_lucid49.fromHex)((0, import_lucid49.fromText)(assetAscii));
8164
+ const iasset = (0, import_lucid47.fromHex)((0, import_lucid47.fromText)(assetAscii));
8182
8165
  const iassetAssetClass = {
8183
- currencySymbol: (0, import_lucid49.fromHex)(
8166
+ currencySymbol: (0, import_lucid47.fromHex)(
8184
8167
  sysParams.stabilityPoolParams.assetSymbol.unCurrencySymbol
8185
8168
  ),
8186
8169
  tokenName: iasset
8187
8170
  };
8188
8171
  const datum = {
8189
- owner: (0, import_lucid49.fromHex)(pkh.hash),
8172
+ owner: (0, import_lucid47.fromHex)(pkh.hash),
8190
8173
  iasset,
8191
8174
  state: { ...initSpState, depositVal: mkSPInteger(amount) },
8192
8175
  assetSums: [],
@@ -8194,7 +8177,7 @@ async function requestSpAccountCreation(assetAscii, amount, sysParams, lucid) {
8194
8177
  lastRequestProcessingTime: 0n
8195
8178
  };
8196
8179
  return lucid.newTx().pay.ToContract(
8197
- (0, import_lucid49.credentialToAddress)(
8180
+ (0, import_lucid47.credentialToAddress)(
8198
8181
  lucid.config().network,
8199
8182
  {
8200
8183
  hash: sysParams.validatorHashes.stabilityPoolHash,
@@ -8208,7 +8191,7 @@ async function requestSpAccountCreation(assetAscii, amount, sysParams, lucid) {
8208
8191
  kind: "inline",
8209
8192
  value: serialiseStabilityPoolDatum({ Account: datum })
8210
8193
  },
8211
- (0, import_lucid49.addAssets)(
8194
+ (0, import_lucid47.addAssets)(
8212
8195
  (0, import_cardano_offchain_common24.mkAssetsOf)(iassetAssetClass, amount),
8213
8196
  (0, import_cardano_offchain_common24.mkLovelacesOf)(
8214
8197
  // TODO: Calculate a more accurate amount to just cover costs.
@@ -8259,7 +8242,7 @@ async function requestSpAccountAdjustment(amount, accountUtxo, sysParams, lucid)
8259
8242
  Account: newAccountDatum
8260
8243
  })
8261
8244
  },
8262
- (0, import_lucid49.addAssets)(
8245
+ (0, import_lucid47.addAssets)(
8263
8246
  (0, import_cardano_offchain_common24.mkLovelacesOf)(
8264
8247
  // TODO: Calculate a more accurate amount to just cover costs.
8265
8248
  // This should cover the minimum ADA for 2 UTxOs (account and
@@ -8272,7 +8255,7 @@ async function requestSpAccountAdjustment(amount, accountUtxo, sysParams, lucid)
8272
8255
  ),
8273
8256
  amount > 0n ? (0, import_cardano_offchain_common24.mkAssetsOf)(
8274
8257
  {
8275
- currencySymbol: (0, import_lucid49.fromHex)(
8258
+ currencySymbol: (0, import_lucid47.fromHex)(
8276
8259
  sysParams.stabilityPoolParams.assetSymbol.unCurrencySymbol
8277
8260
  ),
8278
8261
  tokenName: oldAccountDatum.iasset
@@ -8280,7 +8263,7 @@ async function requestSpAccountAdjustment(amount, accountUtxo, sysParams, lucid)
8280
8263
  amount
8281
8264
  ) : {}
8282
8265
  )
8283
- ).addSignerKey((0, import_lucid49.toHex)(oldAccountDatum.owner));
8266
+ ).addSignerKey((0, import_lucid47.toHex)(oldAccountDatum.owner));
8284
8267
  }
8285
8268
  async function requestSpAccountClosure(accountUtxo, sysParams, lucid, maxTxFee = BASE_MAX_TX_FEE) {
8286
8269
  const myAddress = await lucid.wallet().address();
@@ -8314,7 +8297,7 @@ async function requestSpAccountClosure(accountUtxo, sysParams, lucid, maxTxFee =
8314
8297
  kind: "inline",
8315
8298
  value: serialiseStabilityPoolDatum({ Account: newAccountDatum })
8316
8299
  },
8317
- (0, import_lucid49.addAssets)(
8300
+ (0, import_lucid47.addAssets)(
8318
8301
  (0, import_cardano_offchain_common24.mkLovelacesOf)(
8319
8302
  // TODO: Calculate a more accurate amount to just cover costs.
8320
8303
  // This should cover the minimum ADA for the rewards UTxO and the transaction fee.
@@ -8325,11 +8308,10 @@ async function requestSpAccountClosure(accountUtxo, sysParams, lucid, maxTxFee =
8325
8308
  1n
8326
8309
  )
8327
8310
  )
8328
- ).addSignerKey((0, import_lucid49.toHex)(oldAccountDatum.owner));
8311
+ ).addSignerKey((0, import_lucid47.toHex)(oldAccountDatum.owner));
8329
8312
  }
8330
- async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, currentSlot, txFee) {
8331
- const network = lucid.config().network;
8332
- const currentTime = BigInt((0, import_lucid49.slotToUnixTime)(network, currentSlot));
8313
+ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, txFee) {
8314
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
8333
8315
  const stabilityPoolScriptRef = (0, import_cardano_offchain_common24.matchSingle)(
8334
8316
  await lucid.utxosByOutRef([
8335
8317
  fromSystemParamsScriptRef(
@@ -8345,7 +8327,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8345
8327
  getInlineDatumOrThrow(stabilityPoolUtxo)
8346
8328
  );
8347
8329
  const baseRefInputs = [iAssetUtxo, stabilityPoolScriptRef];
8348
- const validFrom = (0, import_lucid49.slotToUnixTime)(network, currentSlot - 1);
8330
+ const validFrom = lucid.slotToUnixTime(lucid.currentSlot() - 1);
8349
8331
  const tx = lucid.newTx().validFrom(validFrom).validTo(validFrom + sysParams.stabilityPoolParams.accountProcessingBiasMs).readFrom(baseRefInputs).collectFrom([stabilityPoolUtxo], {
8350
8332
  kind: "selected",
8351
8333
  inputs: [stabilityPoolUtxo, accountUtxo],
@@ -8358,7 +8340,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8358
8340
  });
8359
8341
  if (!accountDatum.request) throw new Error("Account Request is null");
8360
8342
  const iassetAssetClass = {
8361
- currencySymbol: (0, import_lucid49.fromHex)(
8343
+ currencySymbol: (0, import_lucid47.fromHex)(
8362
8344
  sysParams.stabilityPoolParams.assetSymbol.unCurrencySymbol
8363
8345
  ),
8364
8346
  tokenName: stabilityPoolDatum.iasset
@@ -8376,7 +8358,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8376
8358
  accountUtxo.assets,
8377
8359
  iassetAssetClass
8378
8360
  );
8379
- const poolAddr = (0, import_lucid49.credentialToAddress)(
8361
+ const poolAddr = (0, import_lucid47.credentialToAddress)(
8380
8362
  lucid.config().network,
8381
8363
  {
8382
8364
  hash: sysParams.validatorHashes.stabilityPoolHash,
@@ -8427,7 +8409,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8427
8409
  currentTime
8428
8410
  }
8429
8411
  })
8430
- }).mintAssets(accountTokenVal, import_lucid49.Data.void()).pay.ToContract(
8412
+ }).mintAssets(accountTokenVal, import_lucid47.Data.void()).pay.ToContract(
8431
8413
  poolAddr,
8432
8414
  {
8433
8415
  kind: "inline",
@@ -8449,7 +8431,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8449
8431
  )
8450
8432
  })
8451
8433
  },
8452
- (0, import_lucid49.addAssets)(
8434
+ (0, import_lucid47.addAssets)(
8453
8435
  stabilityPoolUtxo.assets,
8454
8436
  (0, import_cardano_offchain_common24.mkAssetsOf)(iassetAssetClass, requestDepositAmt),
8455
8437
  (0, import_cardano_offchain_common24.mkLovelacesOf)(
@@ -8462,7 +8444,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8462
8444
  kind: "inline",
8463
8445
  value: accountOutputDatum
8464
8446
  },
8465
- (0, import_lucid49.addAssets)(accountTokenVal, (0, import_cardano_offchain_common24.mkLovelacesOf)(accountOutputAdaAmt))
8447
+ (0, import_lucid47.addAssets)(accountTokenVal, (0, import_cardano_offchain_common24.mkLovelacesOf)(accountOutputAdaAmt))
8466
8448
  ).setMinFee(txFee);
8467
8449
  }).with({ Adjust: import_ts_pattern18.P.select() }, async (adjustContent) => {
8468
8450
  const iassetDatum = parseIAssetDatumOrThrow(
@@ -8533,13 +8515,13 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8533
8515
  }
8534
8516
  })
8535
8517
  },
8536
- (0, import_lucid49.addAssets)(
8518
+ (0, import_lucid47.addAssets)(
8537
8519
  stabilityPoolUtxo.assets,
8538
8520
  (0, import_cardano_offchain_common24.negateAssets)(reward),
8539
8521
  (0, import_cardano_offchain_common24.mkAssetsOf)(iassetAssetClass, accountBalanceChange + withdrawalFeeAmt)
8540
8522
  )
8541
8523
  );
8542
- const theoreticalOwnerOutputVal = (0, import_lucid49.addAssets)(
8524
+ const theoreticalOwnerOutputVal = (0, import_lucid47.addAssets)(
8543
8525
  reward,
8544
8526
  isDepositOrRewardWithdrawal ? {} : (0, import_cardano_offchain_common24.mkAssetsOf)(
8545
8527
  iassetAssetClass,
@@ -8548,7 +8530,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8548
8530
  );
8549
8531
  const ownerOutputDat = serialiseActionReturnDatum({
8550
8532
  IndigoStabilityPoolAccountAdjustment: {
8551
- txHash: (0, import_lucid49.fromHex)(accountUtxo.txHash),
8533
+ txHash: (0, import_lucid47.fromHex)(accountUtxo.txHash),
8552
8534
  outputIndex: BigInt(accountUtxo.outputIndex)
8553
8535
  }
8554
8536
  });
@@ -8559,7 +8541,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8559
8541
  { InlineDatum: { datum: ownerOutputDat } }
8560
8542
  );
8561
8543
  const extraOwnerOutputLovelacesAmt = (0, import_cardano_offchain_common24.lovelacesAmt)(theoreticalOwnerOutputVal) >= ownerOutputMinUtxoLovelace ? 0n : ownerOutputMinUtxoLovelace - (0, import_cardano_offchain_common24.lovelacesAmt)(theoreticalOwnerOutputVal);
8562
- const actualOwnerOutputVal = (0, import_lucid49.addAssets)(
8544
+ const actualOwnerOutputVal = (0, import_lucid47.addAssets)(
8563
8545
  theoreticalOwnerOutputVal,
8564
8546
  (0, import_cardano_offchain_common24.mkLovelacesOf)(extraOwnerOutputLovelacesAmt)
8565
8547
  );
@@ -8597,7 +8579,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8597
8579
  kind: "inline",
8598
8580
  value: accountOutputDat
8599
8581
  },
8600
- (0, import_lucid49.addAssets)(
8582
+ (0, import_lucid47.addAssets)(
8601
8583
  accountOutputValWithoutAda,
8602
8584
  (0, import_cardano_offchain_common24.mkLovelacesOf)(accountOutputAdaAmt)
8603
8585
  )
@@ -8680,7 +8662,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8680
8662
  fromSystemParamsAsset(sysParams.stabilityPoolParams.accountToken),
8681
8663
  -1n
8682
8664
  ),
8683
- import_lucid49.Data.void()
8665
+ import_lucid47.Data.void()
8684
8666
  ).pay.ToContract(
8685
8667
  stabilityPoolUtxo.address,
8686
8668
  {
@@ -8692,7 +8674,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8692
8674
  }
8693
8675
  })
8694
8676
  },
8695
- (0, import_lucid49.addAssets)(
8677
+ (0, import_lucid47.addAssets)(
8696
8678
  stabilityPoolUtxo.assets,
8697
8679
  (0, import_cardano_offchain_common24.negateAssets)(reward),
8698
8680
  (0, import_cardano_offchain_common24.mkAssetsOf)(iassetAssetClass, -withdrawnAmt + withdrawalFeeAmt)
@@ -8703,12 +8685,12 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8703
8685
  kind: "inline",
8704
8686
  value: serialiseActionReturnDatum({
8705
8687
  IndigoStabilityPoolAccountClosure: {
8706
- txHash: (0, import_lucid49.fromHex)(accountUtxo.txHash),
8688
+ txHash: (0, import_lucid47.fromHex)(accountUtxo.txHash),
8707
8689
  outputIndex: BigInt(accountUtxo.outputIndex)
8708
8690
  }
8709
8691
  })
8710
8692
  },
8711
- (0, import_lucid49.addAssets)(
8693
+ (0, import_lucid47.addAssets)(
8712
8694
  (0, import_cardano_offchain_common24.mkLovelacesOf)((0, import_cardano_offchain_common24.lovelacesAmt)(accountUtxo.assets) - txFee),
8713
8695
  reward,
8714
8696
  (0, import_cardano_offchain_common24.mkAssetsOf)(iassetAssetClass, withdrawnAmt - withdrawalFeeAmt)
@@ -8717,7 +8699,7 @@ async function processSpRequestAuxiliary(stabilityPoolUtxo, accountUtxo, iAssetU
8717
8699
  }).exhaustive();
8718
8700
  return tx;
8719
8701
  }
8720
- async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid, currentSlot) {
8702
+ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE2s2sSnapshotOrefs, sysParams, lucid) {
8721
8703
  const draftTx = processSpRequestAuxiliary(
8722
8704
  stabilityPoolUtxo,
8723
8705
  accountUtxo,
@@ -8725,7 +8707,6 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
8725
8707
  allE2s2sSnapshotOrefs,
8726
8708
  sysParams,
8727
8709
  lucid,
8728
- currentSlot,
8729
8710
  // Placeholder transation fee
8730
8711
  1n
8731
8712
  );
@@ -8737,7 +8718,6 @@ async function processSpRequest(stabilityPoolUtxo, accountUtxo, iAssetUtxo, allE
8737
8718
  allE2s2sSnapshotOrefs,
8738
8719
  sysParams,
8739
8720
  lucid,
8740
- currentSlot,
8741
8721
  fee
8742
8722
  );
8743
8723
  }
@@ -8775,7 +8755,7 @@ async function createE2s2sSnapshots(stabilityPoolOref, sysParams, lucid) {
8775
8755
  serialiseStabilityPoolRedeemer("RecordEpochToScaleToSum")
8776
8756
  ).mintAssets(
8777
8757
  (0, import_cardano_offchain_common24.mkAssetsOf)(snapshotAc, BigInt(newSnapshotDatums.length)),
8778
- import_lucid49.Data.void()
8758
+ import_lucid47.Data.void()
8779
8759
  ).pay.ToContract(
8780
8760
  spUtxo.address,
8781
8761
  {
@@ -8812,7 +8792,7 @@ async function annulRequest(accountUtxo, params, lucid) {
8812
8792
  const oldAccountDatum = parseAccountDatumOrThrow(
8813
8793
  getInlineDatumOrThrow(accountUtxo)
8814
8794
  );
8815
- const tx = lucid.newTx().readFrom([stabilityPoolRefScriptUtxo]).collectFrom([accountUtxo], serialiseStabilityPoolRedeemer("AnnulRequest")).addSignerKey((0, import_lucid49.toHex)(oldAccountDatum.owner));
8795
+ const tx = lucid.newTx().readFrom([stabilityPoolRefScriptUtxo]).collectFrom([accountUtxo], serialiseStabilityPoolRedeemer("AnnulRequest")).addSignerKey((0, import_lucid47.toHex)(oldAccountDatum.owner));
8816
8796
  if (oldAccountDatum.request !== "Create") {
8817
8797
  tx.pay.ToContract(
8818
8798
  accountUtxo.address,
@@ -8835,7 +8815,7 @@ async function annulRequest(accountUtxo, params, lucid) {
8835
8815
  }
8836
8816
 
8837
8817
  // src/contracts/rob/helpers.ts
8838
- var import_lucid50 = require("@lucid-evolution/lucid");
8818
+ var import_lucid48 = require("@lucid-evolution/lucid");
8839
8819
 
8840
8820
  // src/contracts/rob/types-new.ts
8841
8821
  var import_evolution19 = require("@evolution-sdk/evolution");
@@ -9073,7 +9053,7 @@ function buildRedemptionsTx(redemptions, iasset, collateralAsset, price, redempt
9073
9053
  tx,
9074
9054
  (idx, acc, [robUtxo, payoutAmt]) => {
9075
9055
  const robDatum = parseRobDatumOrThrow(getInlineDatumOrThrow(robUtxo));
9076
- if ((0, import_lucid50.toHex)(robDatum.iasset) !== (0, import_lucid50.toHex)(iasset)) {
9056
+ if ((0, import_lucid48.toHex)(robDatum.iasset) !== (0, import_lucid48.toHex)(iasset)) {
9077
9057
  throw new Error("Only same iAsset");
9078
9058
  }
9079
9059
  const [robOutputVal, sellOrderAllowedAssetsIdx] = (0, import_ts_pattern19.match)(
@@ -9088,12 +9068,12 @@ function buildRedemptionsTx(redemptions, iasset, collateralAsset, price, redempt
9088
9068
  redemptionReimbursementRatio,
9089
9069
  price
9090
9070
  );
9091
- const resultVal = (0, import_lucid50.addAssets)(
9071
+ const resultVal = (0, import_lucid48.addAssets)(
9092
9072
  robUtxo.assets,
9093
9073
  (0, import_cardano_offchain_common26.mkAssetsOf)(collateralAsset, -collateralForRedemption),
9094
9074
  (0, import_cardano_offchain_common26.mkAssetsOf)(
9095
9075
  {
9096
- currencySymbol: (0, import_lucid50.fromHex)(
9076
+ currencySymbol: (0, import_lucid48.fromHex)(
9097
9077
  sysParams.robParams.iassetPolicyId.unCurrencySymbol
9098
9078
  ),
9099
9079
  tokenName: robDatum.iasset
@@ -9118,12 +9098,12 @@ function buildRedemptionsTx(redemptions, iasset, collateralAsset, price, redempt
9118
9098
  redemptionReimbursementRatio,
9119
9099
  price
9120
9100
  );
9121
- const resultVal = (0, import_lucid50.addAssets)(
9101
+ const resultVal = (0, import_lucid48.addAssets)(
9122
9102
  robUtxo.assets,
9123
9103
  (0, import_cardano_offchain_common26.mkAssetsOf)(collateralAsset, payoutCollateralAmt),
9124
9104
  (0, import_cardano_offchain_common26.mkAssetsOf)(
9125
9105
  {
9126
- currencySymbol: (0, import_lucid50.fromHex)(
9106
+ currencySymbol: (0, import_lucid48.fromHex)(
9127
9107
  sysParams.robParams.iassetPolicyId.unCurrencySymbol
9128
9108
  ),
9129
9109
  tokenName: robDatum.iasset
@@ -9158,7 +9138,7 @@ function buildRedemptionsTx(redemptions, iasset, collateralAsset, price, redempt
9158
9138
  ...robDatum,
9159
9139
  robRefInput: {
9160
9140
  outputIndex: BigInt(robUtxo.outputIndex),
9161
- txHash: (0, import_lucid50.fromHex)(robUtxo.txHash)
9141
+ txHash: (0, import_lucid48.fromHex)(robUtxo.txHash)
9162
9142
  }
9163
9143
  })
9164
9144
  },
@@ -9176,7 +9156,7 @@ function calculateTotalCollateralForRedemption(iasset, collateralAsset, iassetPr
9176
9156
  { BuyIAssetOrder: import_ts_pattern19.P.select() },
9177
9157
  (content) => (0, import_cardano_offchain_common26.isSameAssetClass)(content.collateralAsset, collateralAsset) && rationalToFloat(content.maxPrice) >= rationalToFloat(iassetPrice) && !isBuyOrderFullyRedeemed(utxo.assets, datum.orderType, iassetPrice)
9178
9158
  ).otherwise(() => false);
9179
- if ((0, import_lucid50.toHex)(datum.iasset) !== (0, import_lucid50.toHex)(iasset) || !isCorrectOrder) {
9159
+ if ((0, import_lucid48.toHex)(datum.iasset) !== (0, import_lucid48.toHex)(iasset) || !isCorrectOrder) {
9180
9160
  return import_fp_ts22.option.none;
9181
9161
  }
9182
9162
  const collateralToSpend = robCollateralAmtToSpend(
@@ -9200,7 +9180,7 @@ function randomRobsSubsetSatisfyingTargetCollateral(iasset, collateralAsset, tar
9200
9180
  import_fp_ts22.function.pipe(
9201
9181
  allLrps,
9202
9182
  import_fp_ts22.array.filter(
9203
- ([utxo, datum]) => (0, import_lucid50.toHex)(datum.iasset) === (0, import_lucid50.toHex)(iasset) && (0, import_ts_pattern19.match)(datum.orderType).with(
9183
+ ([utxo, datum]) => (0, import_lucid48.toHex)(datum.iasset) === (0, import_lucid48.toHex)(iasset) && (0, import_ts_pattern19.match)(datum.orderType).with(
9204
9184
  { BuyIAssetOrder: import_ts_pattern19.P.select() },
9205
9185
  (content) => (0, import_cardano_offchain_common26.isSameAssetClass)(collateralAsset, content.collateralAsset) && rationalToFloat(content.maxPrice) >= rationalToFloat(iassetPrice)
9206
9186
  ).otherwise(() => false) && !isBuyOrderFullyRedeemed(utxo.assets, datum.orderType, iassetPrice)
@@ -9262,21 +9242,21 @@ function randomRobsSubsetSatisfyingTargetCollateral(iasset, collateralAsset, tar
9262
9242
  }
9263
9243
 
9264
9244
  // src/contracts/rob/types.ts
9265
- var import_lucid51 = require("@lucid-evolution/lucid");
9266
- var RobParamsSchema = import_lucid51.Data.Object({
9245
+ var import_lucid49 = require("@lucid-evolution/lucid");
9246
+ var RobParamsSchema = import_lucid49.Data.Object({
9267
9247
  versionRecordToken: AssetClassSchema2,
9268
9248
  iassetAuthToken: AssetClassSchema2,
9269
9249
  collateralAssetAuthToken: AssetClassSchema2,
9270
- iassetPolicyId: import_lucid51.Data.Bytes(),
9271
- iassetValHash: import_lucid51.Data.Bytes()
9250
+ iassetPolicyId: import_lucid49.Data.Bytes(),
9251
+ iassetValHash: import_lucid49.Data.Bytes()
9272
9252
  });
9273
9253
  var RobParams = RobParamsSchema;
9274
9254
  function castRobParams(params) {
9275
- return import_lucid51.Data.castTo(params, RobParams);
9255
+ return import_lucid49.Data.castTo(params, RobParams);
9276
9256
  }
9277
9257
 
9278
9258
  // src/contracts/rob/transactions.ts
9279
- var import_lucid52 = require("@lucid-evolution/lucid");
9259
+ var import_lucid50 = require("@lucid-evolution/lucid");
9280
9260
  var import_fp_ts23 = require("fp-ts");
9281
9261
  var import_Array2 = require("fp-ts/lib/Array");
9282
9262
  var import_cardano_offchain_common27 = require("@3rd-eye-labs/cardano-offchain-common");
@@ -9285,11 +9265,11 @@ async function openRob(assetTokenNameAscii, depositAmt, orderType, lucid, sysPar
9285
9265
  const network = lucid.config().network;
9286
9266
  const [ownPkh, _] = await addrDetails(lucid);
9287
9267
  const newDatum = {
9288
- owner: (0, import_lucid52.fromHex)(ownPkh.hash),
9289
- iasset: (0, import_lucid52.fromHex)((0, import_lucid52.fromText)(assetTokenNameAscii)),
9268
+ owner: (0, import_lucid50.fromHex)(ownPkh.hash),
9269
+ iasset: (0, import_lucid50.fromHex)((0, import_lucid50.fromText)(assetTokenNameAscii)),
9290
9270
  orderType,
9291
9271
  robRefInput: {
9292
- txHash: (0, import_lucid52.fromHex)(
9272
+ txHash: (0, import_lucid50.fromHex)(
9293
9273
  "0000000000000000000000000000000000000000000000000000000000000000"
9294
9274
  ),
9295
9275
  outputIndex: 0n
@@ -9302,7 +9282,7 @@ async function openRob(assetTokenNameAscii, depositAmt, orderType, lucid, sysPar
9302
9282
  { SellIAssetOrder: import_ts_pattern20.P.any },
9303
9283
  (_2) => (0, import_cardano_offchain_common27.mkAssetsOf)(
9304
9284
  {
9305
- currencySymbol: (0, import_lucid52.fromHex)(
9285
+ currencySymbol: (0, import_lucid50.fromHex)(
9306
9286
  sysParams.cdpParams.cdpAssetSymbol.unCurrencySymbol
9307
9287
  ),
9308
9288
  tokenName: newDatum.iasset
@@ -9320,7 +9300,7 @@ async function openRob(assetTokenNameAscii, depositAmt, orderType, lucid, sysPar
9320
9300
  kind: "inline",
9321
9301
  value: serialiseRobDatum(newDatum)
9322
9302
  },
9323
- (0, import_lucid52.addAssets)(depositVal, (0, import_cardano_offchain_common27.mkLovelacesOf)(MIN_ROB_COLLATERAL_AMT))
9303
+ (0, import_lucid50.addAssets)(depositVal, (0, import_cardano_offchain_common27.mkLovelacesOf)(MIN_ROB_COLLATERAL_AMT))
9324
9304
  );
9325
9305
  }
9326
9306
  async function cancelRob(robOutRef, sysParams, lucid) {
@@ -9335,9 +9315,9 @@ async function cancelRob(robOutRef, sysParams, lucid) {
9335
9315
  (_) => new Error("Expected a single ROB UTXO.")
9336
9316
  );
9337
9317
  const robDatum = parseRobDatumOrThrow(getInlineDatumOrThrow(robUtxo));
9338
- return lucid.newTx().readFrom([robScriptRefUtxo]).collectFrom([robUtxo], serialiseRobRedeemer("Cancel")).addSignerKey((0, import_lucid52.toHex)(robDatum.owner));
9318
+ return lucid.newTx().readFrom([robScriptRefUtxo]).collectFrom([robUtxo], serialiseRobRedeemer("Cancel")).addSignerKey((0, import_lucid50.toHex)(robDatum.owner));
9339
9319
  }
9340
- async function redeemRob(redemptionRobsData, priceOracleOutRef, iassetOutRef, collateralAssetOutRef, lucid, sysParams, currentSlot, pythMessage = void 0, pythStateOutRef = void 0) {
9320
+ async function redeemRob(redemptionRobsData, priceOracleOutRef, iassetOutRef, collateralAssetOutRef, lucid, sysParams, pythMessage = void 0, pythStateOutRef = void 0) {
9341
9321
  const robScriptRefUtxo = matchSingle(
9342
9322
  await lucid.utxosByOutRef([
9343
9323
  fromSystemParamsScriptRef(sysParams.scriptReferences.robValidatorRef)
@@ -9381,13 +9361,12 @@ async function redeemRob(redemptionRobsData, priceOracleOutRef, iassetOutRef, co
9381
9361
  pythMessage,
9382
9362
  sysParams.pythConfig,
9383
9363
  sysParams.cdpParams.biasTime,
9384
- currentSlot,
9385
9364
  lucid,
9386
9365
  tx
9387
9366
  );
9388
9367
  tx.validFrom(interval.validFrom).validTo(interval.validTo);
9389
9368
  allRefInputs.push(...referenceInputs);
9390
- const refInputIdxs = (0, import_lucid52.getInputIndices)(allRefInputs, allRefInputs);
9369
+ const refInputIdxs = (0, import_lucid50.getInputIndices)(allRefInputs, allRefInputs);
9391
9370
  buildRedemptionsTx(
9392
9371
  redemptionRobs,
9393
9372
  iassetDatum.assetName,
@@ -9417,7 +9396,7 @@ async function adjustRob(lucid, robOutRef, adjustmentAmt, newLimitPrice, sysPara
9417
9396
  );
9418
9397
  const robDatum = parseRobDatumOrThrow(getInlineDatumOrThrow(robUtxo));
9419
9398
  if (adjustmentAmt === 0n && isFullyRedeemed(robUtxo.assets, robDatum.orderType, {
9420
- currencySymbol: (0, import_lucid52.fromHex)(
9399
+ currencySymbol: (0, import_lucid50.fromHex)(
9421
9400
  sysParams.cdpParams.cdpAssetSymbol.unCurrencySymbol
9422
9401
  ),
9423
9402
  tokenName: robDatum.iasset
@@ -9427,7 +9406,7 @@ async function adjustRob(lucid, robOutRef, adjustmentAmt, newLimitPrice, sysPara
9427
9406
  );
9428
9407
  }
9429
9408
  if (adjustmentAmt < 0 && robAmtToSpend(robUtxo.assets, robDatum.orderType, {
9430
- currencySymbol: (0, import_lucid52.fromHex)(
9409
+ currencySymbol: (0, import_lucid50.fromHex)(
9431
9410
  sysParams.cdpParams.cdpAssetSymbol.unCurrencySymbol
9432
9411
  ),
9433
9412
  tokenName: robDatum.iasset
@@ -9437,7 +9416,7 @@ async function adjustRob(lucid, robOutRef, adjustmentAmt, newLimitPrice, sysPara
9437
9416
  );
9438
9417
  }
9439
9418
  const iassetAc = {
9440
- currencySymbol: (0, import_lucid52.fromHex)(
9419
+ currencySymbol: (0, import_lucid50.fromHex)(
9441
9420
  sysParams.robParams.iassetPolicyId.unCurrencySymbol
9442
9421
  ),
9443
9422
  tokenName: robDatum.iasset
@@ -9453,7 +9432,7 @@ async function adjustRob(lucid, robOutRef, adjustmentAmt, newLimitPrice, sysPara
9453
9432
  (acc, [asset, _]) => {
9454
9433
  const amt = (0, import_cardano_offchain_common27.assetClassValueOf)(robUtxo.assets, asset) - // in case of ADA, the min has to stay.
9455
9434
  ((0, import_cardano_offchain_common27.isSameAssetClass)(asset, import_cardano_offchain_common27.adaAssetClass) ? MIN_ROB_COLLATERAL_AMT : 0n);
9456
- return (0, import_lucid52.addAssets)(acc, (0, import_cardano_offchain_common27.mkAssetsOf)(asset, amt));
9435
+ return (0, import_lucid50.addAssets)(acc, (0, import_cardano_offchain_common27.mkAssetsOf)(asset, amt));
9457
9436
  }
9458
9437
  )
9459
9438
  );
@@ -9505,19 +9484,19 @@ async function adjustRob(lucid, robOutRef, adjustmentAmt, newLimitPrice, sysPara
9505
9484
  }).exhaustive()
9506
9485
  })
9507
9486
  },
9508
- (0, import_lucid52.addAssets)(
9487
+ (0, import_lucid50.addAssets)(
9509
9488
  robUtxo.assets,
9510
9489
  (0, import_cardano_offchain_common27.mkAssetsOf)(depositAsset, adjustmentAmt),
9511
9490
  (0, import_cardano_offchain_common27.negateAssets)(rewardVal)
9512
9491
  )
9513
- ).addSignerKey((0, import_lucid52.toHex)(robDatum.owner));
9492
+ ).addSignerKey((0, import_lucid50.toHex)(robDatum.owner));
9514
9493
  }
9515
9494
  async function claimRob(lucid, robOutRef, sysParams) {
9516
9495
  return adjustRob(lucid, robOutRef, 0n, void 0, sysParams);
9517
9496
  }
9518
9497
 
9519
9498
  // src/contracts/rob/scripts.ts
9520
- var import_lucid53 = require("@lucid-evolution/lucid");
9499
+ var import_lucid51 = require("@lucid-evolution/lucid");
9521
9500
 
9522
9501
  // src/validators/rob-validator.ts
9523
9502
  var _robValidator = {
@@ -9530,13 +9509,13 @@ var _robValidator = {
9530
9509
  var mkRobValidator = (params) => {
9531
9510
  return {
9532
9511
  type: "PlutusV3",
9533
- script: (0, import_lucid53.applyParamsToScript)(_robValidator.cborHex, [castRobParams(params)])
9512
+ script: (0, import_lucid51.applyParamsToScript)(_robValidator.cborHex, [castRobParams(params)])
9534
9513
  };
9535
9514
  };
9536
9515
  var mkRobValidatorFromSP = (params) => {
9537
9516
  return {
9538
9517
  type: "PlutusV3",
9539
- script: (0, import_lucid53.applyParamsToScript)(_robValidator.cborHex, [
9518
+ script: (0, import_lucid51.applyParamsToScript)(_robValidator.cborHex, [
9540
9519
  castRobParams({
9541
9520
  versionRecordToken: fromSystemParamsAssetLucid(
9542
9521
  params.versionRecordToken
@@ -9553,7 +9532,7 @@ var mkRobValidatorFromSP = (params) => {
9553
9532
  };
9554
9533
 
9555
9534
  // src/contracts/rob-leverage/transactions.ts
9556
- var import_lucid54 = require("@lucid-evolution/lucid");
9535
+ var import_lucid52 = require("@lucid-evolution/lucid");
9557
9536
 
9558
9537
  // src/contracts/rob-leverage/helpers.ts
9559
9538
  var import_fp_ts24 = require("fp-ts");
@@ -9735,9 +9714,9 @@ function calculateLeverageFromCollateralRatio(iasset, collateralAsset, collatera
9735
9714
  // src/contracts/rob-leverage/transactions.ts
9736
9715
  var import_cardano_offchain_common28 = require("@3rd-eye-labs/cardano-offchain-common");
9737
9716
  var import_decimal3 = __toESM(require("decimal.js"));
9738
- async function leverageCdpWithRob(leverage, baseCollateral, priceOracleOutRef, iassetOutRef, collateralAssetOutRef, cdpCreatorOref, interestOracleOref, treasuryOref, sysParams, lucid, allRobs, currentSlot, pythMessage = void 0, pythStateOref = void 0) {
9717
+ async function leverageCdpWithRob(leverage, baseCollateral, priceOracleOutRef, iassetOutRef, collateralAssetOutRef, cdpCreatorOref, interestOracleOref, treasuryOref, sysParams, lucid, allRobs, pythMessage = void 0, pythStateOref = void 0) {
9739
9718
  const network = lucid.config().network;
9740
- const currentTime = BigInt((0, import_lucid54.slotToUnixTime)(network, currentSlot));
9719
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
9741
9720
  const [pkh, skh] = await addrDetails(lucid);
9742
9721
  const robScriptRefUtxo = matchSingle(
9743
9722
  await lucid.utxosByOutRef([
@@ -9863,7 +9842,7 @@ async function leverageCdpWithRob(leverage, baseCollateral, priceOracleOutRef, i
9863
9842
  1n
9864
9843
  );
9865
9844
  const iassetClass = {
9866
- currencySymbol: (0, import_lucid54.fromHex)(
9845
+ currencySymbol: (0, import_lucid52.fromHex)(
9867
9846
  sysParams.cdpParams.cdpAssetSymbol.unCurrencySymbol
9868
9847
  ),
9869
9848
  tokenName: iassetDatum.assetName
@@ -9875,12 +9854,12 @@ async function leverageCdpWithRob(leverage, baseCollateral, priceOracleOutRef, i
9875
9854
  iAssetTokenPolicyRefScriptUtxo,
9876
9855
  robScriptRefUtxo
9877
9856
  ];
9878
- const tx = lucid.newTx().readFrom(refScripts).mintAssets(cdpNftVal, import_lucid54.Data.void()).mintAssets(iassetTokensVal, import_lucid54.Data.void()).pay.ToContract(
9857
+ const tx = lucid.newTx().readFrom(refScripts).mintAssets(cdpNftVal, import_lucid52.Data.void()).mintAssets(iassetTokensVal, import_lucid52.Data.void()).pay.ToContract(
9879
9858
  createScriptAddress(network, sysParams.validatorHashes.cdpHash, skh),
9880
9859
  {
9881
9860
  kind: "inline",
9882
9861
  value: serialiseCdpDatum({
9883
- cdpOwner: (0, import_lucid54.fromHex)(pkh.hash),
9862
+ cdpOwner: (0, import_lucid52.fromHex)(pkh.hash),
9884
9863
  iasset: iassetDatum.assetName,
9885
9864
  collateralAsset: collateralAssetDatum.collateralAsset,
9886
9865
  mintedAmt,
@@ -9895,7 +9874,7 @@ async function leverageCdpWithRob(leverage, baseCollateral, priceOracleOutRef, i
9895
9874
  }
9896
9875
  })
9897
9876
  },
9898
- (0, import_lucid54.addAssets)(
9877
+ (0, import_lucid52.addAssets)(
9899
9878
  cdpNftVal,
9900
9879
  (0, import_cardano_offchain_common28.mkAssetsOf)(collateralAssetDatum.collateralAsset, collateralAmt)
9901
9880
  )
@@ -9906,7 +9885,7 @@ async function leverageCdpWithRob(leverage, baseCollateral, priceOracleOutRef, i
9906
9885
  value: serialiseCDPCreatorDatum({
9907
9886
  creatorInputOref: {
9908
9887
  outputIndex: BigInt(cdpCreatorUtxo.outputIndex),
9909
- txHash: (0, import_lucid54.fromHex)(cdpCreatorUtxo.txHash)
9888
+ txHash: (0, import_lucid52.fromHex)(cdpCreatorUtxo.txHash)
9910
9889
  }
9911
9890
  })
9912
9891
  },
@@ -9931,7 +9910,6 @@ async function leverageCdpWithRob(leverage, baseCollateral, priceOracleOutRef, i
9931
9910
  pythMessage,
9932
9911
  sysParams.pythConfig,
9933
9912
  sysParams.cdpCreatorParams.biasTime,
9934
- currentSlot,
9935
9913
  lucid,
9936
9914
  tx
9937
9915
  );
@@ -9941,7 +9919,7 @@ async function leverageCdpWithRob(leverage, baseCollateral, priceOracleOutRef, i
9941
9919
  collateralAssetUtxo,
9942
9920
  ...refInputs
9943
9921
  ];
9944
- const refInputsIndices = (0, import_lucid54.getInputIndices)(referenceInputs, [
9922
+ const refInputsIndices = (0, import_lucid52.getInputIndices)(referenceInputs, [
9945
9923
  ...referenceInputs,
9946
9924
  ...refScripts,
9947
9925
  ...treasuryRefScriptUtxo != null ? [treasuryRefScriptUtxo] : []
@@ -9952,7 +9930,7 @@ async function leverageCdpWithRob(leverage, baseCollateral, priceOracleOutRef, i
9952
9930
  makeRedeemer: (inputIdx) => {
9953
9931
  return serialiseCDPCreatorRedeemer({
9954
9932
  CreateCDP: {
9955
- cdpOwner: (0, import_lucid54.fromHex)(pkh.hash),
9933
+ cdpOwner: (0, import_lucid52.fromHex)(pkh.hash),
9956
9934
  minted: mintedAmt,
9957
9935
  collateralAmt,
9958
9936
  currentTime,
@@ -9984,10 +9962,10 @@ async function leverageCdpWithRob(leverage, baseCollateral, priceOracleOutRef, i
9984
9962
  }
9985
9963
 
9986
9964
  // src/contracts/price-oracle/transactions.ts
9987
- var import_lucid56 = require("@lucid-evolution/lucid");
9965
+ var import_lucid54 = require("@lucid-evolution/lucid");
9988
9966
 
9989
9967
  // src/contracts/price-oracle/scripts.ts
9990
- var import_lucid55 = require("@lucid-evolution/lucid");
9968
+ var import_lucid53 = require("@lucid-evolution/lucid");
9991
9969
 
9992
9970
  // src/validators/price-oracle-validator.ts
9993
9971
  var _priceOracleValidator = {
@@ -10000,7 +9978,7 @@ var _priceOracleValidator = {
10000
9978
  function mkPriceOracleValidator(params) {
10001
9979
  return {
10002
9980
  type: "PlutusV3",
10003
- script: (0, import_lucid55.applyParamsToScript)(_priceOracleValidator.cborHex, [
9981
+ script: (0, import_lucid53.applyParamsToScript)(_priceOracleValidator.cborHex, [
10004
9982
  castPriceOracleParams(params)
10005
9983
  ])
10006
9984
  };
@@ -10009,9 +9987,8 @@ function mkPriceOracleValidator(params) {
10009
9987
  // src/contracts/price-oracle/transactions.ts
10010
9988
  var import_cardano_offchain_common29 = require("@3rd-eye-labs/cardano-offchain-common");
10011
9989
  var Core2 = __toESM(require("@evolution-sdk/evolution"));
10012
- async function startPriceOracleTx(lucid, assetName, startPrice, oracleParams, currentSlot, refOutRef, auxiliaryData) {
10013
- const network = lucid.config().network;
10014
- const now = BigInt((0, import_lucid56.slotToUnixTime)(network, currentSlot));
9990
+ async function startPriceOracleTx(lucid, assetName, startPrice, oracleParams, refOutRef, auxiliaryData) {
9991
+ const now = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
10015
9992
  if (!refOutRef) {
10016
9993
  refOutRef = (await lucid.wallet().getUtxos())[0];
10017
9994
  }
@@ -10022,31 +9999,30 @@ async function startPriceOracleTx(lucid, assetName, startPrice, oracleParams, cu
10022
9999
  },
10023
10000
  mintAmounts: [
10024
10001
  {
10025
- tokenName: (0, import_lucid56.fromText)(assetName),
10002
+ tokenName: (0, import_lucid54.fromText)(assetName),
10026
10003
  amount: 1n
10027
10004
  }
10028
10005
  ]
10029
10006
  });
10030
10007
  const priceOracleNft = {
10031
- currencySymbol: (0, import_lucid56.fromHex)(oracleNftPolicyId),
10032
- tokenName: (0, import_lucid56.fromHex)((0, import_lucid56.fromText)(assetName))
10008
+ currencySymbol: (0, import_lucid54.fromHex)(oracleNftPolicyId),
10009
+ tokenName: (0, import_lucid54.fromHex)((0, import_lucid54.fromText)(assetName))
10033
10010
  };
10034
10011
  const oracleValidator = mkPriceOracleValidator(oracleParams);
10035
10012
  const oracleDatum = {
10036
10013
  price: startPrice,
10037
10014
  expirationTime: BigInt(now) + oracleParams.expirationPeriod,
10038
- auxiliaryData: auxiliaryData ?? Core2.Data.fromCBORHex(import_lucid56.Data.void())
10015
+ auxiliaryData: auxiliaryData ?? Core2.Data.fromCBORHex(import_lucid54.Data.void())
10039
10016
  };
10040
10017
  tx.pay.ToContract(
10041
- (0, import_lucid56.validatorToAddress)(lucid.config().network, oracleValidator),
10018
+ (0, import_lucid54.validatorToAddress)(lucid.config().network, oracleValidator),
10042
10019
  { kind: "inline", value: serialisePriceOracleDatum(oracleDatum) },
10043
- (0, import_lucid56.addAssets)((0, import_cardano_offchain_common29.mkAssetsOf)(priceOracleNft, 1n))
10020
+ (0, import_lucid54.addAssets)((0, import_cardano_offchain_common29.mkAssetsOf)(priceOracleNft, 1n))
10044
10021
  );
10045
10022
  return [tx, priceOracleNft];
10046
10023
  }
10047
- async function feedPriceOracleTx(lucid, oracleOref, newPrice, oracleParams, currentSlot, auxiliaryData) {
10048
- const network = lucid.config().network;
10049
- const currentTime = BigInt((0, import_lucid56.slotToUnixTime)(network, currentSlot));
10024
+ async function feedPriceOracleTx(lucid, oracleOref, newPrice, oracleParams, auxiliaryData) {
10025
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
10050
10026
  const priceOracleUtxo = matchSingle(
10051
10027
  await lucid.utxosByOutRef([oracleOref]),
10052
10028
  (_) => new Error("Expected a single price oracle UTXO")
@@ -10065,7 +10041,7 @@ async function feedPriceOracleTx(lucid, oracleOref, newPrice, oracleParams, curr
10065
10041
  value: serialisePriceOracleDatum({
10066
10042
  price: newPrice,
10067
10043
  expirationTime: currentTime + oracleParams.expirationPeriod,
10068
- auxiliaryData: auxiliaryData ?? Core2.Data.fromCBORHex(import_lucid56.Data.void())
10044
+ auxiliaryData: auxiliaryData ?? Core2.Data.fromCBORHex(import_lucid54.Data.void())
10069
10045
  })
10070
10046
  },
10071
10047
  priceOracleUtxo.assets
@@ -10073,7 +10049,7 @@ async function feedPriceOracleTx(lucid, oracleOref, newPrice, oracleParams, curr
10073
10049
  }
10074
10050
 
10075
10051
  // src/utils/helper-txs.ts
10076
- var import_lucid57 = require("@lucid-evolution/lucid");
10052
+ var import_lucid55 = require("@lucid-evolution/lucid");
10077
10053
 
10078
10054
  // src/scripts/always-fail-validator.ts
10079
10055
  var alwaysFailValidator = {
@@ -10083,18 +10059,18 @@ var alwaysFailValidator = {
10083
10059
 
10084
10060
  // src/utils/helper-txs.ts
10085
10061
  async function runCreateScriptRefTx(lucid, scriptRefValidator, network) {
10086
- const scriptAddr = (0, import_lucid57.validatorToAddress)(network, alwaysFailValidator);
10062
+ const scriptAddr = (0, import_lucid55.validatorToAddress)(network, alwaysFailValidator);
10087
10063
  const txHash = await lucid.newTx().pay.ToAddressWithData(scriptAddr, void 0, {}, scriptRefValidator).complete().then((tx) => tx.sign.withWallet().complete()).then((tx) => tx.submit());
10088
10064
  await lucid.awaitTx(txHash);
10089
10065
  return { txHash, outputIndex: 0 };
10090
10066
  }
10091
10067
 
10092
10068
  // src/contracts/initialize/helpers.ts
10093
- var import_lucid61 = require("@lucid-evolution/lucid");
10069
+ var import_lucid59 = require("@lucid-evolution/lucid");
10094
10070
  var import_cardano_offchain_common30 = require("@3rd-eye-labs/cardano-offchain-common");
10095
10071
 
10096
10072
  // src/scripts/auth-token-policy.ts
10097
- var import_lucid58 = require("@lucid-evolution/lucid");
10073
+ var import_lucid56 = require("@lucid-evolution/lucid");
10098
10074
  var authPolicyData = {
10099
10075
  type: "PlutusV2",
10100
10076
  cborHex: "5904d95904d60100003232323232323232323232323232323232323232323232323232223232223232323253355335533357346042660166018a00200e03026464666ae68cdc419806980728019980b9999aa999ab9a3370e90030008990911118020029aba1302400215333573466e1d20040011321222230020053574260480042a666ae68c08c0044c848888c004014d5d098120010a999ab9a30220011321222230030053574260480040424c40024c4c016900100a80d98120009baa3500201d01813357389213d4d75737420636f6e73756d65204e4654206f7220746f6b656e2070726576696f75736c79206d696e746564207573696e67207468697320706f6c6963790001301415335738920103505435001613253335734604060460022646464646464646464646464646464646464646464642466666666666600202e02a02602201e01a01601200e00a0060046ae84d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d118118011aba1302200101f37546a002036a666ae68c078c0840084c8c848cc00400c008d5d09aba2302100335742604000403aa666ae68c074c080dd500180880e1baa00153335734603260380022646601e6ae84004d5d09aba2001301b00101837540044464646603a4466a0029000111a801112999ab9a3375e0040102660464466a0029000111a801112999ab9a3375e00401a20022600c0060022600c0060086a00402a6a0020264666aa6020026660144466aa601c02a46a002446601e00466aa602203046a0024466024004666a0026e012000700466e0000520000013355300e015235001223300f00233350012335530120192350012233013002300e0010012233300a0090020012335530120192350012233013002301000100133300500400200100e232333008200133008200175a6aa666ae68c05cc0680044c8c8c8c8c8c848cccc00401c01400c008d5d09aba2002357420026ae88008d5d08009aba2301a00235742603200202c44440066ea8d400404ccc06488cccd55cf800900891919809a999ab9a3019301c001132321233001003002357426ae88c070008d5d0980d80080c18021aba200337546ae84008054dd61a80091111111111100611199ab9a3375e00400201c010444666aa601602601e66aa601802646a002446601a0046010002666aa6016026446a00444a66a666aa602802e6601c4466601402e004002601002c46a002446601400400a00c200626602600800601c00266aa601802646a002446601a0046603844a66a002260180064426a00444a66a6601800401022444660040140082600c00600800446600244a66a004018200200a4244460060084446602c446666aae7c00480388c8cc040cc02cc01cc064004c018c060004c010d5d10019aba1002012375600242444600200820142014442466002006004601c4422444a66a00220044426600a004666aa600e01e00a008002601a442244a66a00200a44266012600800466aa600c01a00800220022006442446600200800660124422444a66a00226a00600e442666a00a0106008004666aa600e01400a0080024400444002240022a66ae71241035054310016370e90001b874800955cf2ab9d2323001001223300330020020011"
@@ -10102,15 +10078,15 @@ var authPolicyData = {
10102
10078
  function mkAuthTokenPolicy(ac, tn) {
10103
10079
  return {
10104
10080
  type: authPolicyData.type,
10105
- script: (0, import_lucid58.applyParamsToScript)(authPolicyData.cborHex, [
10106
- new import_lucid58.Constr(0, [(0, import_lucid58.toHex)(ac.currencySymbol), (0, import_lucid58.toHex)(ac.tokenName)]),
10081
+ script: (0, import_lucid56.applyParamsToScript)(authPolicyData.cborHex, [
10082
+ new import_lucid56.Constr(0, [(0, import_lucid56.toHex)(ac.currencySymbol), (0, import_lucid56.toHex)(ac.tokenName)]),
10107
10083
  tn
10108
10084
  ])
10109
10085
  };
10110
10086
  }
10111
10087
 
10112
10088
  // src/contracts/iasset/scripts.ts
10113
- var import_lucid59 = require("@lucid-evolution/lucid");
10089
+ var import_lucid57 = require("@lucid-evolution/lucid");
10114
10090
 
10115
10091
  // src/validators/iasset-validator.ts
10116
10092
  var _iassetValidator = {
@@ -10120,8 +10096,8 @@ var _iassetValidator = {
10120
10096
  };
10121
10097
 
10122
10098
  // src/contracts/iasset/scripts.ts
10123
- var import_lucid60 = require("@lucid-evolution/lucid");
10124
- var IAssetScriptParamsSchema = import_lucid60.Data.Object({
10099
+ var import_lucid58 = require("@lucid-evolution/lucid");
10100
+ var IAssetScriptParamsSchema = import_lucid58.Data.Object({
10125
10101
  upgradeToken: AssetClassSchema2,
10126
10102
  versionRecordToken: AssetClassSchema2
10127
10103
  });
@@ -10129,8 +10105,8 @@ var IAssetScriptParams = IAssetScriptParamsSchema;
10129
10105
  var mkIAssetValidatorFromSP = (params) => {
10130
10106
  return {
10131
10107
  type: "PlutusV3",
10132
- script: (0, import_lucid59.applyParamsToScript)(_iassetValidator.cborHex, [
10133
- import_lucid60.Data.castTo(
10108
+ script: (0, import_lucid57.applyParamsToScript)(_iassetValidator.cborHex, [
10109
+ import_lucid58.Data.castTo(
10134
10110
  {
10135
10111
  upgradeToken: fromSystemParamsAssetLucid(params.upgradeToken),
10136
10112
  versionRecordToken: fromSystemParamsAssetLucid(
@@ -10208,22 +10184,22 @@ async function mintOneTimeToken(lucid, tokenName, amount) {
10208
10184
  });
10209
10185
  }
10210
10186
  async function mintOneTimeAsset(lucid, tokenName, amount) {
10211
- const policyId = await mintOneTimeToken(lucid, (0, import_lucid61.fromText)(tokenName), amount);
10187
+ const policyId = await mintOneTimeToken(lucid, (0, import_lucid59.fromText)(tokenName), amount);
10212
10188
  return {
10213
- currencySymbol: (0, import_lucid61.fromHex)(policyId),
10214
- tokenName: (0, import_lucid61.fromHex)((0, import_lucid61.fromText)(tokenName))
10189
+ currencySymbol: (0, import_lucid59.fromHex)(policyId),
10190
+ tokenName: (0, import_lucid59.fromHex)((0, import_lucid59.fromText)(tokenName))
10215
10191
  };
10216
10192
  }
10217
10193
  function deriveAuthToken(parent, tokenName) {
10218
- const policy = mkAuthTokenPolicy(parent, (0, import_lucid61.fromText)(tokenName));
10194
+ const policy = mkAuthTokenPolicy(parent, (0, import_lucid59.fromText)(tokenName));
10219
10195
  return {
10220
- currencySymbol: (0, import_lucid61.fromHex)((0, import_lucid61.mintingPolicyToId)(policy)),
10221
- tokenName: (0, import_lucid61.fromHex)((0, import_lucid61.fromText)(tokenName))
10196
+ currencySymbol: (0, import_lucid59.fromHex)((0, import_lucid59.mintingPolicyToId)(policy)),
10197
+ tokenName: (0, import_lucid59.fromHex)((0, import_lucid59.fromText)(tokenName))
10222
10198
  };
10223
10199
  }
10224
10200
  async function initScriptRef(lucid, validator) {
10225
10201
  const tx = lucid.newTx().pay.ToContract(
10226
- (0, import_lucid61.credentialToAddress)(lucid.config().network, {
10202
+ (0, import_lucid59.credentialToAddress)(lucid.config().network, {
10227
10203
  hash: alwaysFailValidatorHash,
10228
10204
  type: "Script"
10229
10205
  }),
@@ -10241,11 +10217,11 @@ async function initCollector(lucid, collectorParams, numCollectors) {
10241
10217
  tx.pay.ToContract(
10242
10218
  createScriptAddress(
10243
10219
  lucid.config().network,
10244
- (0, import_lucid61.validatorToScriptHash)(mkCollectorValidatorFromSP(collectorParams))
10220
+ (0, import_lucid59.validatorToScriptHash)(mkCollectorValidatorFromSP(collectorParams))
10245
10221
  ),
10246
10222
  {
10247
10223
  kind: "inline",
10248
- value: import_lucid61.Data.void()
10224
+ value: import_lucid59.Data.void()
10249
10225
  }
10250
10226
  );
10251
10227
  }
@@ -10256,7 +10232,7 @@ async function initInterestCollector(lucid, interestCollectionValHash, multisigU
10256
10232
  const interestCollectionAdminDatum = {
10257
10233
  admin_permissions: {
10258
10234
  Signature: {
10259
- keyHash: (0, import_lucid61.fromHex)(pkh.hash)
10235
+ keyHash: (0, import_lucid59.fromHex)(pkh.hash)
10260
10236
  }
10261
10237
  }
10262
10238
  };
@@ -10285,15 +10261,15 @@ async function initCDPCreator(lucid, cdpCreatorParams, numCdpCreators) {
10285
10261
  const tx = lucid.newTx();
10286
10262
  for (let i = 0; i < Number(numCdpCreators); i++) {
10287
10263
  tx.pay.ToContract(
10288
- (0, import_lucid61.credentialToAddress)(lucid.config().network, {
10289
- hash: (0, import_lucid61.validatorToScriptHash)(
10264
+ (0, import_lucid59.credentialToAddress)(lucid.config().network, {
10265
+ hash: (0, import_lucid59.validatorToScriptHash)(
10290
10266
  mkCDPCreatorValidatorFromSP(cdpCreatorParams)
10291
10267
  ),
10292
10268
  type: "Script"
10293
10269
  }),
10294
- { kind: "inline", value: import_lucid61.Data.void() },
10270
+ { kind: "inline", value: import_lucid59.Data.void() },
10295
10271
  {
10296
- [cdpCreatorParams.cdpCreatorNft[0].unCurrencySymbol + (0, import_lucid61.fromText)(cdpCreatorParams.cdpCreatorNft[1].unTokenName)]: 1n
10272
+ [cdpCreatorParams.cdpCreatorNft[0].unCurrencySymbol + (0, import_lucid59.fromText)(cdpCreatorParams.cdpCreatorNft[1].unTokenName)]: 1n
10297
10273
  }
10298
10274
  );
10299
10275
  }
@@ -10302,13 +10278,13 @@ async function initCDPCreator(lucid, cdpCreatorParams, numCdpCreators) {
10302
10278
  async function initTreasury(lucid, treasuryParams, daoAsset, indyAsset, treasuryIndyAmount, numTreasuryCollectors) {
10303
10279
  const treasuryAddr = createScriptAddress(
10304
10280
  lucid.config().network,
10305
- (0, import_lucid61.validatorToScriptHash)(mkTreasuryValidatorFromSP(treasuryParams)),
10281
+ (0, import_lucid59.validatorToScriptHash)(mkTreasuryValidatorFromSP(treasuryParams)),
10306
10282
  treasuryParams.treasuryUtxosStakeCredential != null ? fromSysParamsCredential(treasuryParams.treasuryUtxosStakeCredential) : void 0
10307
10283
  );
10308
10284
  const tx = lucid.newTx().pay.ToContract(
10309
10285
  treasuryAddr,
10310
- { kind: "inline", value: import_lucid61.Data.void() },
10311
- (0, import_lucid61.addAssets)(
10286
+ { kind: "inline", value: import_lucid59.Data.void() },
10287
+ (0, import_lucid59.addAssets)(
10312
10288
  (0, import_cardano_offchain_common30.mkAssetsOf)(daoAsset, 1n),
10313
10289
  (0, import_cardano_offchain_common30.mkAssetsOf)(indyAsset, treasuryIndyAmount)
10314
10290
  )
@@ -10316,7 +10292,7 @@ async function initTreasury(lucid, treasuryParams, daoAsset, indyAsset, treasury
10316
10292
  for (let i = 0; i < Number(numTreasuryCollectors); i++) {
10317
10293
  tx.pay.ToContract(treasuryAddr, {
10318
10294
  kind: "inline",
10319
- value: import_lucid61.Data.void()
10295
+ value: import_lucid59.Data.void()
10320
10296
  });
10321
10297
  }
10322
10298
  await submitTx(lucid, tx);
@@ -10325,7 +10301,7 @@ async function initStakingManager(lucid, stakingParams) {
10325
10301
  const tx = lucid.newTx().pay.ToContract(
10326
10302
  createScriptAddress(
10327
10303
  lucid.config().network,
10328
- (0, import_lucid61.validatorToScriptHash)(mkStakingValidatorFromSP(stakingParams))
10304
+ (0, import_lucid59.validatorToScriptHash)(mkStakingValidatorFromSP(stakingParams))
10329
10305
  ),
10330
10306
  {
10331
10307
  kind: "inline",
@@ -10335,12 +10311,12 @@ async function initStakingManager(lucid, stakingParams) {
10335
10311
  })
10336
10312
  },
10337
10313
  {
10338
- [stakingParams.stakingManagerNFT[0].unCurrencySymbol + (0, import_lucid61.fromText)(stakingParams.stakingManagerNFT[1].unTokenName)]: 1n
10314
+ [stakingParams.stakingManagerNFT[0].unCurrencySymbol + (0, import_lucid59.fromText)(stakingParams.stakingManagerNFT[1].unTokenName)]: 1n
10339
10315
  }
10340
10316
  );
10341
10317
  await submitTx(lucid, tx);
10342
10318
  }
10343
- async function handleOracleForCollateralAsset(lucid, iasset, collateralAsset, pythConfig, currentSlot) {
10319
+ async function handleOracleForCollateralAsset(lucid, iasset, collateralAsset, pythConfig) {
10344
10320
  return (0, import_ts_pattern21.match)(collateralAsset.priceOracle).returnType().with({ tag: "_indigo_oracle_nft" }, async (val) => {
10345
10321
  const [pkh, _] = await addrDetails(lucid);
10346
10322
  const priceOracleParams = {
@@ -10352,8 +10328,7 @@ async function handleOracleForCollateralAsset(lucid, iasset, collateralAsset, py
10352
10328
  lucid,
10353
10329
  val.tokenName,
10354
10330
  val.startPrice,
10355
- priceOracleParams,
10356
- currentSlot
10331
+ priceOracleParams
10357
10332
  );
10358
10333
  await runAndAwaitTxBuilder(lucid, priceOracleStartTx);
10359
10334
  return { info: { OracleNft: priceOracleNft }, params: priceOracleParams };
@@ -10361,10 +10336,10 @@ async function handleOracleForCollateralAsset(lucid, iasset, collateralAsset, py
10361
10336
  return Promise.resolve({
10362
10337
  info: {
10363
10338
  DeferredValidation: {
10364
- feedValHash: (0, import_lucid61.fromHex)(
10339
+ feedValHash: (0, import_lucid59.fromHex)(
10365
10340
  getPythFeedConfig(
10366
10341
  pythConfig,
10367
- (0, import_lucid61.fromHex)((0, import_lucid61.fromText)(iasset.name)),
10342
+ (0, import_lucid59.fromHex)((0, import_lucid59.fromText)(iasset.name)),
10368
10343
  collateralAsset.collateralAsset
10369
10344
  ).pythFeedValHash
10370
10345
  )
@@ -10374,8 +10349,8 @@ async function handleOracleForCollateralAsset(lucid, iasset, collateralAsset, py
10374
10349
  });
10375
10350
  }).exhaustive();
10376
10351
  }
10377
- async function initializeAsset(lucid, iassetParams, iassetToken, collateralAssetAuthToken, cdpAuthToken, cdpParams, stableswapValidatorHash, stabilityPoolParams, stabilityPoolToken, asset, pythConfig, currentSlot) {
10378
- const iassetName = (0, import_lucid61.fromHex)((0, import_lucid61.fromText)(asset.name));
10352
+ async function initializeAsset(lucid, iassetParams, iassetToken, collateralAssetAuthToken, cdpAuthToken, cdpParams, stableswapValidatorHash, stabilityPoolParams, stabilityPoolToken, asset, pythConfig) {
10353
+ const iassetName = (0, import_lucid59.fromHex)((0, import_lucid59.fromText)(asset.name));
10379
10354
  const collateralAssetInfos = [];
10380
10355
  for (const collateralAsset of asset.collateralAssets) {
10381
10356
  const [pkh, _] = await addrDetails(lucid);
@@ -10396,8 +10371,7 @@ async function initializeAsset(lucid, iassetParams, iassetToken, collateralAsset
10396
10371
  lucid,
10397
10372
  asset,
10398
10373
  collateralAsset,
10399
- pythConfig,
10400
- currentSlot
10374
+ pythConfig
10401
10375
  );
10402
10376
  const collateralAssetContent = {
10403
10377
  iasset: iassetName,
@@ -10415,7 +10389,7 @@ async function initializeAsset(lucid, iassetParams, iassetToken, collateralAsset
10415
10389
  const collateralAssetTx = lucid.newTx().pay.ToContract(
10416
10390
  createScriptAddress(
10417
10391
  lucid.config().network,
10418
- (0, import_lucid61.validatorToScriptHash)(mkIAssetValidatorFromSP(iassetParams))
10392
+ (0, import_lucid59.validatorToScriptHash)(mkIAssetValidatorFromSP(iassetParams))
10419
10393
  ),
10420
10394
  {
10421
10395
  kind: "inline",
@@ -10441,18 +10415,18 @@ async function initializeAsset(lucid, iassetParams, iassetToken, collateralAsset
10441
10415
  redemptionFeeRatio: stableswapPool.redemptionFeeRatio,
10442
10416
  mintingEnabled: stableswapPool.mintingEnabled,
10443
10417
  redemptionEnabled: stableswapPool.redemptionEnabled,
10444
- feeManager: stableswapPool.feeManager ? (0, import_lucid61.fromHex)(stableswapPool.feeManager) : null,
10418
+ feeManager: stableswapPool.feeManager ? (0, import_lucid59.fromHex)(stableswapPool.feeManager) : null,
10445
10419
  minMintOrderAmount: stableswapPool.minMintOrderAmount,
10446
10420
  minRedemptionOrderAmount: stableswapPool.minRedemptionOrderAmount,
10447
10421
  iasset: iassetName,
10448
- stableswapValHash: (0, import_lucid61.fromHex)(stableswapValidatorHash)
10422
+ stableswapValHash: (0, import_lucid59.fromHex)(stableswapValidatorHash)
10449
10423
  };
10450
10424
  await submitTx(
10451
10425
  lucid,
10452
10426
  lucid.newTx().pay.ToContract(
10453
10427
  createScriptAddress(
10454
10428
  lucid.config().network,
10455
- (0, import_lucid61.validatorToScriptHash)(mkCdpValidatorFromSP(cdpParams))
10429
+ (0, import_lucid59.validatorToScriptHash)(mkCdpValidatorFromSP(cdpParams))
10456
10430
  ),
10457
10431
  {
10458
10432
  kind: "inline",
@@ -10471,12 +10445,12 @@ async function initializeAsset(lucid, iassetParams, iassetToken, collateralAsset
10471
10445
  redemptionReimbursementRatio: asset.redemptionReimbursementRatio,
10472
10446
  redemptionProcessingFeeRatio: asset.redemptionProcessingFeeRatio,
10473
10447
  firstIAsset: asset.firstAsset,
10474
- nextIAsset: asset.nextAsset ? (0, import_lucid61.fromHex)((0, import_lucid61.fromText)(asset.nextAsset)) : null
10448
+ nextIAsset: asset.nextAsset ? (0, import_lucid59.fromHex)((0, import_lucid59.fromText)(asset.nextAsset)) : null
10475
10449
  };
10476
10450
  const assetTx = lucid.newTx().pay.ToContract(
10477
10451
  createScriptAddress(
10478
10452
  lucid.config().network,
10479
- (0, import_lucid61.validatorToScriptHash)(mkIAssetValidatorFromSP(iassetParams))
10453
+ (0, import_lucid59.validatorToScriptHash)(mkIAssetValidatorFromSP(iassetParams))
10480
10454
  ),
10481
10455
  {
10482
10456
  kind: "inline",
@@ -10486,13 +10460,13 @@ async function initializeAsset(lucid, iassetParams, iassetToken, collateralAsset
10486
10460
  );
10487
10461
  await submitTx(lucid, assetTx);
10488
10462
  const stabilityPoolDatum = {
10489
- iasset: (0, import_lucid61.fromHex)((0, import_lucid61.fromText)(asset.name)),
10463
+ iasset: (0, import_lucid59.fromHex)((0, import_lucid59.fromText)(asset.name)),
10490
10464
  state: initSpState,
10491
10465
  assetStates: []
10492
10466
  };
10493
10467
  const spTx = lucid.newTx().pay.ToContract(
10494
- (0, import_lucid61.credentialToAddress)(lucid.config().network, {
10495
- hash: (0, import_lucid61.validatorToScriptHash)(
10468
+ (0, import_lucid59.credentialToAddress)(lucid.config().network, {
10469
+ hash: (0, import_lucid59.validatorToScriptHash)(
10496
10470
  mkStabilityPoolValidatorFromSP(stabilityPoolParams)
10497
10471
  ),
10498
10472
  type: "Script"
@@ -10518,8 +10492,8 @@ async function initGovernance(lucid, governanceParams, govToken, initialAssets,
10518
10492
  iassetsCount: BigInt(initialAssets.length)
10519
10493
  };
10520
10494
  const tx = lucid.newTx().pay.ToContract(
10521
- (0, import_lucid61.credentialToAddress)(lucid.config().network, {
10522
- hash: (0, import_lucid61.validatorToScriptHash)(mkGovValidatorFromSP(governanceParams)),
10495
+ (0, import_lucid59.credentialToAddress)(lucid.config().network, {
10496
+ hash: (0, import_lucid59.validatorToScriptHash)(mkGovValidatorFromSP(governanceParams)),
10523
10497
  type: "Script"
10524
10498
  }),
10525
10499
  { kind: "inline", value: serialiseGovDatum(datum) },
@@ -10528,8 +10502,8 @@ async function initGovernance(lucid, governanceParams, govToken, initialAssets,
10528
10502
  await submitTx(lucid, tx);
10529
10503
  }
10530
10504
  async function mintAuthTokenDirect(lucid, asset, tokenName, amount) {
10531
- const script = mkAuthTokenPolicy(asset, (0, import_lucid61.fromText)(tokenName));
10532
- const policyId = (0, import_lucid61.mintingPolicyToId)(script);
10505
+ const script = mkAuthTokenPolicy(asset, (0, import_lucid59.fromText)(tokenName));
10506
+ const policyId = (0, import_lucid59.mintingPolicyToId)(script);
10533
10507
  const address = await lucid.wallet().address();
10534
10508
  const utxos = (await lucid.utxosAtWithUnit(address, (0, import_cardano_offchain_common30.assetClassToUnit)(asset))).filter((utxo2) => (0, import_cardano_offchain_common30.assetClassValueOf)(utxo2.assets, asset) === 1n).sort((a, b) => Number((0, import_cardano_offchain_common30.lovelacesAmt)(b.assets) - (0, import_cardano_offchain_common30.lovelacesAmt)(a.assets)));
10535
10509
  if (utxos.length === 0) {
@@ -10538,19 +10512,19 @@ async function mintAuthTokenDirect(lucid, asset, tokenName, amount) {
10538
10512
  const utxo = utxos[0];
10539
10513
  const tx = lucid.newTx().attach.MintingPolicy(script).collectFrom([utxo]).mintAssets(
10540
10514
  {
10541
- [policyId + (0, import_lucid61.fromText)(tokenName)]: amount
10515
+ [policyId + (0, import_lucid59.fromText)(tokenName)]: amount
10542
10516
  },
10543
- import_lucid61.Data.void()
10517
+ import_lucid59.Data.void()
10544
10518
  );
10545
10519
  await submitTx(lucid, tx);
10546
10520
  }
10547
10521
 
10548
10522
  // src/contracts/initialize/actions.ts
10549
- var import_lucid66 = require("@lucid-evolution/lucid");
10523
+ var import_lucid64 = require("@lucid-evolution/lucid");
10550
10524
  var import_cardano_offchain_common32 = require("@3rd-eye-labs/cardano-offchain-common");
10551
10525
 
10552
10526
  // src/scripts/iasset-policy.ts
10553
- var import_lucid62 = require("@lucid-evolution/lucid");
10527
+ var import_lucid60 = require("@lucid-evolution/lucid");
10554
10528
  var iassetPolicyData = {
10555
10529
  type: "PlutusV2",
10556
10530
  cborHex: "59047b590478010000323232323232323232323232323232323232323232323232323232323232330102223253353300453335734603e60426ea800c04c0794ccd5cd180f98108008991909198008018011aba13574460420046ae84c08000407804c54cd5ce248103505435001637540026602044464a66aa666ae68cdc419803199aa980d00e803919980810008079a98071a80080e9003998089192999ab9a30213023001132321233001003002357426ae88c08c008d5d098110008101baa00135500122222222222200c004480084ccd5cd19b8748008cc018ccd54c06807401c8ccc040800403cd4004801ccc044034d5400488888888888802801006004805c05c4cd5ce24910434450546f6b656e206d697373696e670001213253335734603e60420022646464646464646464646464646464646464646464642466666666666600202e02a02602201e01a01601200e00a0060046ae84d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d118108011aba1302000101e37546a002034464a666ae68c074c07c0044c8c848cc00400c008d5d09aba2301f00235742603c0020386ea800488800c88c8c8cc08088cd400520002235002225333573466ebc0080204cc09888cd400520002235002225333573466ebc00803440044c01800c0044c01800c010d4008064d400405ccc02488cd54c0440608d400488cc038008cd54c05006c8d400488cc044008ccd4004dc024000e008cdc0000a400000266aa602203046a002446601c004666a002466aa602a03846a0024466024004601a00200244666012010004002466aa602a03846a0024466024004601c00200266600800600400202244666ae68cdd7801000809006111199aa980780b80999aa980800b91a80091198068011804000999aa980780b911a80111299a999aa980c00d998071119980500d801000980400d11a8009119805001002803080189980b80200180900099aa980800b91a80091198068011980f91299a800898058019109a80111299a9980600100408911198010050020980300180200111980091299a80100808008049091118018021091118008021192999ab9a301430160011323232323232123333001007005003002357426ae88008d5d08009aba2002357420026ae88c058008d5d0980a8008099baa00133001200175a4446602c446666aae7c004803c8c8cc044cc020c01cc064004c018c060004c010d5d10019aba100201337560024424660020060044466026446666aae7c00480308cc034c014d5d080118019aba200201037580022014201444460066004002601a4422444a66a00220044426600a004666aa600e01e00a0080026018442244a66a00200a44266012600800466aa600c01a00800220022006442446600200800660104422444a66a00226a00600e442666a00a0106008004666aa600e01400a0080024400444002240022a66ae71241035054310016370e90002ab9e5573a4646002002446600660040040021"
@@ -10558,27 +10532,27 @@ var iassetPolicyData = {
10558
10532
  function mkIAssetTokenPolicy(ac) {
10559
10533
  return {
10560
10534
  type: iassetPolicyData.type,
10561
- script: (0, import_lucid62.applyParamsToScript)(iassetPolicyData.cborHex, [
10562
- new import_lucid62.Constr(0, [(0, import_lucid62.toHex)(ac.currencySymbol), (0, import_lucid62.toHex)(ac.tokenName)])
10535
+ script: (0, import_lucid60.applyParamsToScript)(iassetPolicyData.cborHex, [
10536
+ new import_lucid60.Constr(0, [(0, import_lucid60.toHex)(ac.currencySymbol), (0, import_lucid60.toHex)(ac.tokenName)])
10563
10537
  ])
10564
10538
  };
10565
10539
  }
10566
10540
 
10567
10541
  // src/contracts/stableswap/scripts.ts
10568
- var import_lucid64 = require("@lucid-evolution/lucid");
10542
+ var import_lucid62 = require("@lucid-evolution/lucid");
10569
10543
 
10570
10544
  // src/contracts/stableswap/types.ts
10571
- var import_lucid63 = require("@lucid-evolution/lucid");
10572
- var StableswapParamsSchema = import_lucid63.Data.Object({
10573
- iassetSymbol: import_lucid63.Data.Bytes(),
10545
+ var import_lucid61 = require("@lucid-evolution/lucid");
10546
+ var StableswapParamsSchema = import_lucid61.Data.Object({
10547
+ iassetSymbol: import_lucid61.Data.Bytes(),
10574
10548
  cdpToken: AssetClassSchema2,
10575
10549
  versionRecordToken: AssetClassSchema2,
10576
- cdpValHash: import_lucid63.Data.Bytes(),
10577
- treasuryValHash: import_lucid63.Data.Bytes()
10550
+ cdpValHash: import_lucid61.Data.Bytes(),
10551
+ treasuryValHash: import_lucid61.Data.Bytes()
10578
10552
  });
10579
10553
  var StableswapParams = StableswapParamsSchema;
10580
10554
  function castStableswapParams(params) {
10581
- return import_lucid63.Data.castTo(params, StableswapParams);
10555
+ return import_lucid61.Data.castTo(params, StableswapParams);
10582
10556
  }
10583
10557
 
10584
10558
  // src/validators/stableswap-validator.ts
@@ -10592,7 +10566,7 @@ var _stableswapValidator = {
10592
10566
  var mkStableswapValidator = (params) => {
10593
10567
  return {
10594
10568
  type: "PlutusV3",
10595
- script: (0, import_lucid64.applyParamsToScript)(_stableswapValidator.cborHex, [
10569
+ script: (0, import_lucid62.applyParamsToScript)(_stableswapValidator.cborHex, [
10596
10570
  castStableswapParams(params)
10597
10571
  ])
10598
10572
  };
@@ -10600,7 +10574,7 @@ var mkStableswapValidator = (params) => {
10600
10574
  var mkStableswapValidatorFromSP = (params) => {
10601
10575
  return {
10602
10576
  type: "PlutusV3",
10603
- script: (0, import_lucid64.applyParamsToScript)(_stableswapValidator.cborHex, [
10577
+ script: (0, import_lucid62.applyParamsToScript)(_stableswapValidator.cborHex, [
10604
10578
  castStableswapParams({
10605
10579
  iassetSymbol: params.iassetSymbol.unCurrencySymbol,
10606
10580
  cdpToken: fromSystemParamsAssetLucid(params.cdpToken),
@@ -10636,7 +10610,7 @@ var mkPythFeedValidator = (params) => {
10636
10610
  var import_ts_pattern22 = require("ts-pattern");
10637
10611
 
10638
10612
  // tests/pyth/endpoints.ts
10639
- var import_lucid65 = require("@lucid-evolution/lucid");
10613
+ var import_lucid63 = require("@lucid-evolution/lucid");
10640
10614
 
10641
10615
  // src/validators/always-succeed-validator.ts
10642
10616
  var _alwaysSucceedValidator = {
@@ -10655,26 +10629,26 @@ var alwaysSucceedValidator = {
10655
10629
  var import_cardano_offchain_common31 = require("@3rd-eye-labs/cardano-offchain-common");
10656
10630
  var TEST_TRUSTED_SIGNER_PUB_KEY = "4a50d7c3d16b2be5c16ba996109a455a34cce08a81b3e15b86ef407e2f72e71f";
10657
10631
  async function initPyth(lucid) {
10658
- const pythStateName = (0, import_lucid65.fromText)("Pyth State");
10632
+ const pythStateName = (0, import_lucid63.fromText)("Pyth State");
10659
10633
  const pythStatePolicyId = await mintOneTimeToken(lucid, pythStateName, 1n);
10660
10634
  const pythStateAsset = {
10661
- currencySymbol: (0, import_lucid65.fromHex)(pythStatePolicyId),
10662
- tokenName: (0, import_lucid65.fromHex)(pythStateName)
10635
+ currencySymbol: (0, import_lucid63.fromHex)(pythStatePolicyId),
10636
+ tokenName: (0, import_lucid63.fromHex)(pythStateName)
10663
10637
  };
10664
- const alwaysSucceedsValidatorHash = (0, import_lucid65.validatorToScriptHash)(
10638
+ const alwaysSucceedsValidatorHash = (0, import_lucid63.validatorToScriptHash)(
10665
10639
  alwaysSucceedValidator
10666
10640
  );
10667
10641
  const pythStateDatum = {
10668
10642
  // The governance doesn't matter for the purpose of testing, so we can use any values
10669
10643
  governance: {
10670
- wormhole: (0, import_lucid65.fromHex)(""),
10644
+ wormhole: (0, import_lucid63.fromHex)(""),
10671
10645
  emitterChain: 0n,
10672
- emitterAddress: (0, import_lucid65.fromHex)(""),
10646
+ emitterAddress: (0, import_lucid63.fromHex)(""),
10673
10647
  seenSequence: 0n
10674
10648
  },
10675
10649
  trustedSigners: /* @__PURE__ */ new Map([
10676
10650
  [
10677
- (0, import_lucid65.fromHex)(TEST_TRUSTED_SIGNER_PUB_KEY),
10651
+ (0, import_lucid63.fromHex)(TEST_TRUSTED_SIGNER_PUB_KEY),
10678
10652
  {
10679
10653
  lower_bound: {
10680
10654
  bound_type: {
@@ -10694,13 +10668,13 @@ async function initPyth(lucid) {
10694
10668
  deprecatedWithdrawScripts: /* @__PURE__ */ new Map(),
10695
10669
  // For the purpose of testing, we use the always succeeds validator to validate the Pyth Messages.
10696
10670
  // This means the message signature checking will always succeed for the purpose of emulation testing.
10697
- withdraw_script: (0, import_lucid65.fromHex)(alwaysSucceedsValidatorHash)
10671
+ withdraw_script: (0, import_lucid63.fromHex)(alwaysSucceedsValidatorHash)
10698
10672
  };
10699
10673
  await runAndAwaitTxBuilder(
10700
10674
  lucid,
10701
10675
  lucid.newTx().pay.ToContract(
10702
- (0, import_lucid65.credentialToAddress)(lucid.config().network, {
10703
- hash: (0, import_lucid65.validatorToScriptHash)(alwaysSucceedValidator),
10676
+ (0, import_lucid63.credentialToAddress)(lucid.config().network, {
10677
+ hash: (0, import_lucid63.validatorToScriptHash)(alwaysSucceedValidator),
10704
10678
  type: "Script"
10705
10679
  }),
10706
10680
  { kind: "inline", value: serialisePythStateDatum(pythStateDatum) },
@@ -10711,8 +10685,8 @@ async function initPyth(lucid) {
10711
10685
  await runAndAwaitTxBuilder(
10712
10686
  lucid,
10713
10687
  lucid.newTx().register.Stake(
10714
- (0, import_lucid65.credentialToRewardAddress)(lucid.config().network, {
10715
- hash: (0, import_lucid65.validatorToScriptHash)(alwaysSucceedValidator),
10688
+ (0, import_lucid63.credentialToRewardAddress)(lucid.config().network, {
10689
+ hash: (0, import_lucid63.validatorToScriptHash)(alwaysSucceedValidator),
10716
10690
  type: "Script"
10717
10691
  })
10718
10692
  )
@@ -10736,7 +10710,7 @@ async function initPythConfig(lucid, initialAssets, pythStateAsset) {
10736
10710
  const pythFeedValidator = mkPythFeedValidator(
10737
10711
  fromSysParamsPythFeedParams(val.pythFeedParams)
10738
10712
  );
10739
- const pythFeedValHash = (0, import_lucid66.validatorToScriptHash)(pythFeedValidator);
10713
+ const pythFeedValHash = (0, import_lucid64.validatorToScriptHash)(pythFeedValidator);
10740
10714
  const pythFeedValScriptRef = await initScriptRef(
10741
10715
  lucid,
10742
10716
  pythFeedValidator
@@ -10745,8 +10719,8 @@ async function initPythConfig(lucid, initialAssets, pythStateAsset) {
10745
10719
  await runAndAwaitTxBuilder(
10746
10720
  lucid,
10747
10721
  lucid.newTx().register.Stake(
10748
- (0, import_lucid66.credentialToRewardAddress)(lucid.config().network, {
10749
- hash: (0, import_lucid66.validatorToScriptHash)(pythFeedValidator),
10722
+ (0, import_lucid64.credentialToRewardAddress)(lucid.config().network, {
10723
+ hash: (0, import_lucid64.validatorToScriptHash)(pythFeedValidator),
10750
10724
  type: "Script"
10751
10725
  })
10752
10726
  )
@@ -10759,7 +10733,7 @@ async function initPythConfig(lucid, initialAssets, pythStateAsset) {
10759
10733
  throw error;
10760
10734
  }
10761
10735
  }
10762
- const key = `${asset.name}/${(0, import_lucid66.toHex)(collateral.collateralAsset.currencySymbol)}.${(0, import_lucid66.toHex)(collateral.collateralAsset.tokenName)}`;
10736
+ const key = `${asset.name}/${(0, import_lucid64.toHex)(collateral.collateralAsset.currencySymbol)}.${(0, import_lucid64.toHex)(collateral.collateralAsset.tokenName)}`;
10763
10737
  return {
10764
10738
  [key]: {
10765
10739
  params: val.pythFeedParams,
@@ -10776,7 +10750,7 @@ async function initPythConfig(lucid, initialAssets, pythStateAsset) {
10776
10750
  pythFeeds: allPythFeeds
10777
10751
  };
10778
10752
  }
10779
- async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets = () => [], protocolParams, initOptions, spStakingCred = DEFAULT_STAKING_CRED, treasuryStakingCred = DEFAULT_STAKING_CRED) {
10753
+ async function init(lucid, defaultInitialAssets, mkPythBasedAssets = () => [], protocolParams, initOptions, spStakingCred = DEFAULT_STAKING_CRED, treasuryStakingCred = DEFAULT_STAKING_CRED) {
10780
10754
  const startSlot = lucid.currentSlot();
10781
10755
  const {
10782
10756
  totalIndySupply,
@@ -10811,16 +10785,16 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
10811
10785
  };
10812
10786
  const versionRecordTokenPolicy = mkVersionRecordTokenPolicy({
10813
10787
  upgradeToken: {
10814
- currencySymbol: (0, import_lucid66.toHex)(upgradeToken.currencySymbol),
10815
- tokenName: (0, import_lucid66.toHex)(upgradeToken.tokenName)
10788
+ currencySymbol: (0, import_lucid64.toHex)(upgradeToken.currencySymbol),
10789
+ tokenName: (0, import_lucid64.toHex)(upgradeToken.tokenName)
10816
10790
  }
10817
10791
  });
10818
10792
  const versionRecordToken = {
10819
- currencySymbol: (0, import_lucid66.fromHex)((0, import_lucid66.mintingPolicyToId)(versionRecordTokenPolicy)),
10820
- tokenName: (0, import_lucid66.fromHex)((0, import_lucid66.fromText)(tn.versionRecord))
10793
+ currencySymbol: (0, import_lucid64.fromHex)((0, import_lucid64.mintingPolicyToId)(versionRecordTokenPolicy)),
10794
+ tokenName: (0, import_lucid64.fromHex)((0, import_lucid64.fromText)(tn.versionRecord))
10821
10795
  };
10822
10796
  const versionRegistryValidator = mkVersionRegistryValidator();
10823
- const versionRegistryValHash = (0, import_lucid66.validatorToScriptHash)(
10797
+ const versionRegistryValHash = (0, import_lucid64.validatorToScriptHash)(
10824
10798
  versionRegistryValidator
10825
10799
  );
10826
10800
  const cdpCreatorAsset = await mintOneTimeAsset(
@@ -10841,7 +10815,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
10841
10815
  versionRecordToken: toSystemParamsAsset(versionRecordToken)
10842
10816
  };
10843
10817
  const collectorValidator = mkCollectorValidatorFromSP(collectorParams);
10844
- const collectorValHash = (0, import_lucid66.validatorToScriptHash)(collectorValidator);
10818
+ const collectorValHash = (0, import_lucid64.validatorToScriptHash)(collectorValidator);
10845
10819
  const stakingParams = {
10846
10820
  stakingManagerNFT: toSystemParamsAsset(stakingManagerAsset),
10847
10821
  stakingToken: toSystemParamsAsset(stakingToken),
@@ -10850,7 +10824,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
10850
10824
  indyToken: toSystemParamsAsset(indyAsset),
10851
10825
  collectorValHash
10852
10826
  };
10853
- const stakingValHash = (0, import_lucid66.validatorToScriptHash)(
10827
+ const stakingValHash = (0, import_lucid64.validatorToScriptHash)(
10854
10828
  mkStakingValidatorFromSP(stakingParams)
10855
10829
  );
10856
10830
  await initStakingManager(lucid, stakingParams);
@@ -10859,9 +10833,9 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
10859
10833
  versionRecordToken: toSystemParamsAsset(versionRecordToken)
10860
10834
  };
10861
10835
  const iassetValidator = mkIAssetValidatorFromSP(iassetParams);
10862
- const iassetValHash = (0, import_lucid66.validatorToScriptHash)(iassetValidator);
10836
+ const iassetValHash = (0, import_lucid64.validatorToScriptHash)(iassetValidator);
10863
10837
  const assetSymbolPolicy = mkIAssetTokenPolicy(cdpToken);
10864
- const assetSymbol = (0, import_lucid66.mintingPolicyToId)(assetSymbolPolicy);
10838
+ const assetSymbol = (0, import_lucid64.mintingPolicyToId)(assetSymbolPolicy);
10865
10839
  const snapshotEpochToScaleToSumToken = deriveAuthToken(
10866
10840
  stabilityPoolToken,
10867
10841
  tn.snapshotEpochToScaleToSum
@@ -10884,14 +10858,14 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
10884
10858
  stakeCredential: spStakingCred
10885
10859
  };
10886
10860
  const stabilityPoolValidator = mkStabilityPoolValidatorFromSP(stabilityPoolParams);
10887
- const stabilityPoolValHash = (0, import_lucid66.validatorToScriptHash)(stabilityPoolValidator);
10861
+ const stabilityPoolValHash = (0, import_lucid64.validatorToScriptHash)(stabilityPoolValidator);
10888
10862
  const treasuryParams = {
10889
10863
  upgradeToken: toSystemParamsAsset(upgradeToken),
10890
10864
  versionRecordToken: toSystemParamsAsset(versionRecordToken),
10891
10865
  treasuryUtxosStakeCredential: treasuryStakingCred
10892
10866
  };
10893
10867
  const treasuryValidator = mkTreasuryValidatorFromSP(treasuryParams);
10894
- const treasuryValHash = (0, import_lucid66.validatorToScriptHash)(treasuryValidator);
10868
+ const treasuryValHash = (0, import_lucid64.validatorToScriptHash)(treasuryValidator);
10895
10869
  await initTreasury(
10896
10870
  lucid,
10897
10871
  treasuryParams,
@@ -10914,7 +10888,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
10914
10888
  const interestCollectionValidator = mkInterestCollectionValidatorFromSP(
10915
10889
  interestCollectionParams
10916
10890
  );
10917
- const interestCollectionValHash = (0, import_lucid66.validatorToScriptHash)(
10891
+ const interestCollectionValHash = (0, import_lucid64.validatorToScriptHash)(
10918
10892
  interestCollectionValidator
10919
10893
  );
10920
10894
  await initInterestCollector(
@@ -10943,10 +10917,10 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
10943
10917
  biasTime
10944
10918
  };
10945
10919
  const cdpRedeemValidator = mkCdpRedeemValidatorFromSP(cdpRedeemParams);
10946
- const cdpRedeemValHash = (0, import_lucid66.validatorToScriptHash)(cdpRedeemValidator);
10947
- const cdpRedeemRewardAddr = (0, import_lucid66.credentialToRewardAddress)(
10920
+ const cdpRedeemValHash = (0, import_lucid64.validatorToScriptHash)(cdpRedeemValidator);
10921
+ const cdpRedeemRewardAddr = (0, import_lucid64.credentialToRewardAddress)(
10948
10922
  lucid.config().network,
10949
- (0, import_lucid66.scriptHashToCredential)(cdpRedeemValHash)
10923
+ (0, import_lucid64.scriptHashToCredential)(cdpRedeemValHash)
10950
10924
  );
10951
10925
  try {
10952
10926
  await runAndAwaitTxBuilder(
@@ -10975,7 +10949,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
10975
10949
  biasTime
10976
10950
  };
10977
10951
  const cdpValidator = mkCdpValidatorFromSP(cdpParams);
10978
- const cdpValHash = (0, import_lucid66.validatorToScriptHash)(cdpValidator);
10952
+ const cdpValHash = (0, import_lucid64.validatorToScriptHash)(cdpValidator);
10979
10953
  const cdpCreatorParams = {
10980
10954
  cdpCreatorNft: toSystemParamsAsset(cdpCreatorAsset),
10981
10955
  cdpAssetCs: { unCurrencySymbol: assetSymbol },
@@ -10990,7 +10964,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
10990
10964
  biasTime: cdpParams.biasTime
10991
10965
  };
10992
10966
  const cdpCreatorValidator = mkCDPCreatorValidatorFromSP(cdpCreatorParams);
10993
- const cdpCreatorValHash = (0, import_lucid66.validatorToScriptHash)(cdpCreatorValidator);
10967
+ const cdpCreatorValHash = (0, import_lucid64.validatorToScriptHash)(cdpCreatorValidator);
10994
10968
  const stableswapParams = {
10995
10969
  iassetSymbol: { unCurrencySymbol: assetSymbol },
10996
10970
  cdpToken: toSystemParamsAsset(cdpToken),
@@ -10999,7 +10973,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
10999
10973
  treasuryValHash
11000
10974
  };
11001
10975
  const stableswapValidator = mkStableswapValidatorFromSP(stableswapParams);
11002
- const stableswapValHash = (0, import_lucid66.validatorToScriptHash)(stableswapValidator);
10976
+ const stableswapValHash = (0, import_lucid64.validatorToScriptHash)(stableswapValidator);
11003
10977
  await initCollector(lucid, collectorParams, numCollectors);
11004
10978
  const assetInfos = [];
11005
10979
  if (initialAssets.length > 0) {
@@ -11026,7 +11000,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
11026
11000
  lucid,
11027
11001
  lucid.newTx().pay.ToAddress(
11028
11002
  await lucid.wallet().address(),
11029
- (0, import_lucid66.addAssets)(
11003
+ (0, import_lucid64.addAssets)(
11030
11004
  (0, import_cardano_offchain_common32.mkAssetsOf)(iassetToken, 1n),
11031
11005
  (0, import_cardano_offchain_common32.mkLovelacesOf)(BigInt(totalCollateralAssetsCount) * 5000000n)
11032
11006
  )
@@ -11044,7 +11018,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
11044
11018
  lucid,
11045
11019
  lucid.newTx().pay.ToAddress(
11046
11020
  await lucid.wallet().address(),
11047
- (0, import_lucid66.addAssets)(
11021
+ (0, import_lucid64.addAssets)(
11048
11022
  (0, import_cardano_offchain_common32.mkAssetsOf)(cdpCreatorAsset, 1n),
11049
11023
  (0, import_cardano_offchain_common32.mkLovelacesOf)(BigInt(totalStablePoolsCount) * 5000000n)
11050
11024
  )
@@ -11076,8 +11050,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
11076
11050
  stabilityPoolParams,
11077
11051
  stabilityPoolToken,
11078
11052
  asset,
11079
- pythConfig,
11080
- currentSlot
11053
+ pythConfig
11081
11054
  );
11082
11055
  assetInfos.push(assetInfo);
11083
11056
  }
@@ -11102,7 +11075,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
11102
11075
  treasuryValHash
11103
11076
  };
11104
11077
  const executeValidator = mkExecuteValidatorFromSP(executeParams);
11105
- const executeValHash = (0, import_lucid66.validatorToScriptHash)(executeValidator);
11078
+ const executeValHash = (0, import_lucid64.validatorToScriptHash)(executeValidator);
11106
11079
  const pollShardParams = {
11107
11080
  pollToken: toSystemParamsAsset(pollToken),
11108
11081
  stakingToken: toSystemParamsAsset(stakingToken),
@@ -11110,7 +11083,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
11110
11083
  stakingValHash
11111
11084
  };
11112
11085
  const pollShardValidator = mkPollShardValidatorFromSP(pollShardParams);
11113
- const pollShardValHash = (0, import_lucid66.validatorToScriptHash)(pollShardValidator);
11086
+ const pollShardValHash = (0, import_lucid64.validatorToScriptHash)(pollShardValidator);
11114
11087
  const pollManagerParams = {
11115
11088
  govNFT: toSystemParamsAsset(govNftAsset),
11116
11089
  pollToken: toSystemParamsAsset(pollToken),
@@ -11122,7 +11095,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
11122
11095
  treasuryValHash
11123
11096
  };
11124
11097
  const pollManagerValidator = mkPollManagerValidatorFromSP(pollManagerParams);
11125
- const pollManagerValHash = (0, import_lucid66.validatorToScriptHash)(pollManagerValidator);
11098
+ const pollManagerValHash = (0, import_lucid64.validatorToScriptHash)(pollManagerValidator);
11126
11099
  const govParams = {
11127
11100
  gBiasTime: gBiasTime ? BigInt(gBiasTime) : BigInt(biasTime),
11128
11101
  govNFT: toSystemParamsAsset(govNftAsset),
@@ -11137,7 +11110,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
11137
11110
  iassetSymbol: { unCurrencySymbol: assetSymbol }
11138
11111
  };
11139
11112
  const govValidator = mkGovValidatorFromSP(govParams);
11140
- const govValHash = (0, import_lucid66.validatorToScriptHash)(govValidator);
11113
+ const govValHash = (0, import_lucid64.validatorToScriptHash)(govValidator);
11141
11114
  await initGovernance(
11142
11115
  lucid,
11143
11116
  govParams,
@@ -11153,36 +11126,36 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
11153
11126
  versionRecordToken: cdpParams.versionRecordToken
11154
11127
  };
11155
11128
  const robValidator = mkRobValidatorFromSP(robParams);
11156
- const robValHash = (0, import_lucid66.validatorToScriptHash)(robValidator);
11157
- const cdpTokenPolicy = mkAuthTokenPolicy(cdpCreatorAsset, (0, import_lucid66.fromText)(tn.cdp));
11129
+ const robValHash = (0, import_lucid64.validatorToScriptHash)(robValidator);
11130
+ const cdpTokenPolicy = mkAuthTokenPolicy(cdpCreatorAsset, (0, import_lucid64.fromText)(tn.cdp));
11158
11131
  const iassetTokenPolicy = mkAuthTokenPolicy(
11159
11132
  upgradeToken,
11160
- (0, import_lucid66.fromText)(tn.iasset)
11133
+ (0, import_lucid64.fromText)(tn.iasset)
11161
11134
  );
11162
11135
  const accountTokenPolicy = mkAuthTokenPolicy(
11163
11136
  stabilityPoolToken,
11164
- (0, import_lucid66.fromText)(tn.account)
11137
+ (0, import_lucid64.fromText)(tn.account)
11165
11138
  );
11166
11139
  const stabilityPoolTokenPolicy = mkAuthTokenPolicy(
11167
11140
  upgradeToken,
11168
- (0, import_lucid66.fromText)(tn.stabilityPool)
11141
+ (0, import_lucid64.fromText)(tn.stabilityPool)
11169
11142
  );
11170
11143
  const pollTokenPolicy = mkAuthTokenPolicy(
11171
11144
  govNftAsset,
11172
- (0, import_lucid66.fromText)(tn.pollManager)
11145
+ (0, import_lucid64.fromText)(tn.pollManager)
11173
11146
  );
11174
11147
  const stakingTokenPolicy = mkAuthTokenPolicy(
11175
11148
  stakingManagerAsset,
11176
- (0, import_lucid66.fromText)(tn.staking)
11149
+ (0, import_lucid64.fromText)(tn.staking)
11177
11150
  );
11178
11151
  const collateralAssetAuthTokenPolicy = mkAuthTokenPolicy(
11179
11152
  iassetToken,
11180
- (0, import_lucid66.fromText)(tn.collateralAsset)
11153
+ (0, import_lucid64.fromText)(tn.collateralAsset)
11181
11154
  );
11182
- const upgradeTokenPolicy = mkAuthTokenPolicy(pollToken, (0, import_lucid66.fromText)(tn.upgrade));
11155
+ const upgradeTokenPolicy = mkAuthTokenPolicy(pollToken, (0, import_lucid64.fromText)(tn.upgrade));
11183
11156
  const snapshotEpochToScaleToSumTokenPolicy = mkAuthTokenPolicy(
11184
11157
  stabilityPoolToken,
11185
- (0, import_lucid66.fromText)(tn.snapshotEpochToScaleToSum)
11158
+ (0, import_lucid64.fromText)(tn.snapshotEpochToScaleToSum)
11186
11159
  );
11187
11160
  const sysParams = {
11188
11161
  cdpParams,
@@ -11326,7 +11299,7 @@ async function init(lucid, defaultInitialAssets, currentSlot, mkPythBasedAssets
11326
11299
  }
11327
11300
 
11328
11301
  // src/contracts/iasset/queries.ts
11329
- var import_lucid67 = require("@lucid-evolution/lucid");
11302
+ var import_lucid65 = require("@lucid-evolution/lucid");
11330
11303
  var import_cardano_offchain_common33 = require("@3rd-eye-labs/cardano-offchain-common");
11331
11304
  var import_fp_ts26 = require("fp-ts");
11332
11305
  async function findIAsset(lucid, sysParams, iassetName) {
@@ -11346,7 +11319,7 @@ async function findIAsset(lucid, sysParams, iassetName) {
11346
11319
  import_fp_ts26.option.fromNullable(utxo.datum),
11347
11320
  import_fp_ts26.option.flatMap(parseIAssetDatum),
11348
11321
  import_fp_ts26.option.flatMap((datum) => {
11349
- if ((0, import_lucid67.toHex)(datum.assetName) === (0, import_lucid67.toHex)(iassetName)) {
11322
+ if ((0, import_lucid65.toHex)(datum.assetName) === (0, import_lucid65.toHex)(iassetName)) {
11350
11323
  return import_fp_ts26.option.some({ utxo, datum });
11351
11324
  } else {
11352
11325
  return import_fp_ts26.option.none;
@@ -11376,7 +11349,7 @@ async function findCollateralAsset(lucid, sysParams, iassetName, collateralAsset
11376
11349
  import_fp_ts26.option.fromNullable(utxo.datum),
11377
11350
  import_fp_ts26.option.flatMap(parseCollateralAssetDatum),
11378
11351
  import_fp_ts26.option.flatMap((datum) => {
11379
- if ((0, import_cardano_offchain_common33.isSameAssetClass)(datum.collateralAsset, collateralAsset) && (0, import_lucid67.toHex)(iassetName) === (0, import_lucid67.toHex)(datum.iasset)) {
11352
+ if ((0, import_cardano_offchain_common33.isSameAssetClass)(datum.collateralAsset, collateralAsset) && (0, import_lucid65.toHex)(iassetName) === (0, import_lucid65.toHex)(datum.iasset)) {
11380
11353
  return import_fp_ts26.option.some({ utxo, datum });
11381
11354
  } else {
11382
11355
  return import_fp_ts26.option.none;
@@ -11393,7 +11366,8 @@ async function findCollateralAsset(lucid, sysParams, iassetName, collateralAsset
11393
11366
  }
11394
11367
 
11395
11368
  // src/contracts/stableswap/helpers.ts
11396
- var import_lucid68 = require("@lucid-evolution/lucid");
11369
+ var import_lucid66 = require("@lucid-evolution/lucid");
11370
+ var import_fp_ts28 = require("fp-ts");
11397
11371
 
11398
11372
  // src/contracts/stableswap/types-new.ts
11399
11373
  var import_cardano_offchain_common34 = require("@3rd-eye-labs/cardano-offchain-common");
@@ -11493,43 +11467,270 @@ function parseStableswapOrderRedeemerOrThrow(redeemerCborHex) {
11493
11467
 
11494
11468
  // src/contracts/stableswap/helpers.ts
11495
11469
  var import_evolution21 = require("@evolution-sdk/evolution");
11470
+ var import_cardano_offchain_common35 = require("@3rd-eye-labs/cardano-offchain-common");
11496
11471
  var BASE_MAX_EXECUTION_FEE = 1620000n;
11472
+ var defaultOrderProcessingConfig = {
11473
+ ignoreMaxExecutionFeeConstraint: false
11474
+ };
11497
11475
  function createDestinationDatum(datum, outRef) {
11498
11476
  if (!datum) {
11499
11477
  return serialiseStableswapOutputDatum([
11500
- (0, import_lucid68.fromHex)((0, import_lucid68.fromText)("IndigoStableswap")),
11478
+ (0, import_lucid66.fromHex)((0, import_lucid66.fromText)("IndigoStableswap")),
11501
11479
  {
11502
- txHash: (0, import_lucid68.fromHex)(outRef.txHash),
11480
+ txHash: (0, import_lucid66.fromHex)(outRef.txHash),
11503
11481
  outputIndex: BigInt(outRef.outputIndex)
11504
11482
  }
11505
11483
  ]);
11506
11484
  }
11507
11485
  return import_evolution21.Data.toCBORHex(datum);
11508
11486
  }
11487
+ function psmOrderType(order, sysParams) {
11488
+ const iassetAc = {
11489
+ currencySymbol: (0, import_lucid66.fromHex)(
11490
+ sysParams.stableswapParams.iassetSymbol.unCurrencySymbol
11491
+ ),
11492
+ tokenName: order.datum.iasset
11493
+ };
11494
+ const suppliedIasset = (0, import_cardano_offchain_common35.assetClassValueOf)(order.utxo.assets, iassetAc);
11495
+ const suppliedCollateralAsset = (0, import_cardano_offchain_common35.assetClassValueOf)(
11496
+ order.utxo.assets,
11497
+ order.datum.collateralAsset
11498
+ );
11499
+ if (suppliedIasset != 0n && suppliedCollateralAsset != 0n || suppliedIasset == 0n && suppliedCollateralAsset == 0n) {
11500
+ return {
11501
+ type: "ERROR",
11502
+ reason: "An order must supply either iAsset or collateral asset"
11503
+ };
11504
+ }
11505
+ const isMinting = suppliedCollateralAsset > 0n;
11506
+ return isMinting ? { type: "MINTING", suppliedCollateral: suppliedCollateralAsset } : { type: "REDEEMING", suppliedIassets: suppliedIasset };
11507
+ }
11508
+ function summariseOrder(order, psmPool, sysParams, orderProcessingConfig) {
11509
+ const orderType = psmOrderType(order, sysParams);
11510
+ if (orderType.type === "ERROR") {
11511
+ return { _tag: "ERROR", reason: orderType.reason };
11512
+ }
11513
+ const isOneToOne = psmPool.datum.collateralToIassetRatio.numerator === psmPool.datum.collateralToIassetRatio.denominator;
11514
+ if (!orderProcessingConfig.ignoreMaxExecutionFeeConstraint && order.datum.maxExecutionFee < BASE_MAX_EXECUTION_FEE) {
11515
+ return {
11516
+ _tag: "ERROR",
11517
+ reason: `Max execution fee is too low. Minimum: ${BASE_MAX_EXECUTION_FEE}`
11518
+ };
11519
+ }
11520
+ if (orderType.type === "MINTING") {
11521
+ const suppliedCollateralAsset = orderType.suppliedCollateral;
11522
+ if (rationalToFloat(order.datum.maxFeeRatio) < rationalToFloat(psmPool.datum.mintingFeeRatio)) {
11523
+ return { _tag: "ERROR", reason: "Max fee ratio not satisfied" };
11524
+ }
11525
+ if (isOneToOne) {
11526
+ const fee = calculateFeeFromRatio(
11527
+ psmPool.datum.mintingFeeRatio,
11528
+ suppliedCollateralAsset
11529
+ );
11530
+ return {
11531
+ _tag: "SUCCESS",
11532
+ result: {
11533
+ order,
11534
+ orderType: "MINTING",
11535
+ swapInfo: {
11536
+ suppliedCollateralAsset,
11537
+ suppliedIasset: 0n,
11538
+ owedCollateralAsset: 0n,
11539
+ owedIasset: suppliedCollateralAsset - fee,
11540
+ mintingFee: fee,
11541
+ redemptionFee: 0n
11542
+ }
11543
+ }
11544
+ };
11545
+ } else {
11546
+ const iAssetConversion = rationalFloor(
11547
+ rationalDiv(
11548
+ rationalFromInt(suppliedCollateralAsset),
11549
+ psmPool.datum.collateralToIassetRatio
11550
+ )
11551
+ );
11552
+ const attemptedNormalizedCollateral = rationalFloor(
11553
+ rationalMul(
11554
+ rationalFromInt(iAssetConversion),
11555
+ psmPool.datum.collateralToIassetRatio
11556
+ )
11557
+ );
11558
+ const normalizedCollateralSupplied = rationalFloor(
11559
+ rationalDiv(
11560
+ rationalFromInt(attemptedNormalizedCollateral),
11561
+ psmPool.datum.collateralToIassetRatio
11562
+ )
11563
+ ) != iAssetConversion ? suppliedCollateralAsset : attemptedNormalizedCollateral;
11564
+ const fee = calculateFeeFromRatio(
11565
+ psmPool.datum.mintingFeeRatio,
11566
+ iAssetConversion
11567
+ );
11568
+ return {
11569
+ _tag: "SUCCESS",
11570
+ result: {
11571
+ order,
11572
+ orderType: "MINTING",
11573
+ swapInfo: {
11574
+ suppliedCollateralAsset: normalizedCollateralSupplied,
11575
+ suppliedIasset: 0n,
11576
+ owedIasset: iAssetConversion - fee,
11577
+ owedCollateralAsset: 0n,
11578
+ mintingFee: fee,
11579
+ redemptionFee: 0n
11580
+ }
11581
+ }
11582
+ };
11583
+ }
11584
+ } else {
11585
+ const suppliedIasset = orderType.suppliedIassets;
11586
+ if (rationalToFloat(order.datum.maxFeeRatio) < rationalToFloat(psmPool.datum.redemptionFeeRatio)) {
11587
+ return { _tag: "ERROR", reason: "Max fee ratio not satisfied" };
11588
+ }
11589
+ const fee = calculateFeeFromRatio(
11590
+ psmPool.datum.redemptionFeeRatio,
11591
+ suppliedIasset
11592
+ );
11593
+ const effectiveSuppliedIasset = suppliedIasset - fee;
11594
+ if (isOneToOne) {
11595
+ return {
11596
+ _tag: "SUCCESS",
11597
+ result: {
11598
+ order,
11599
+ orderType: "REDEEMING",
11600
+ swapInfo: {
11601
+ suppliedIasset: effectiveSuppliedIasset,
11602
+ suppliedCollateralAsset: 0n,
11603
+ owedCollateralAsset: effectiveSuppliedIasset,
11604
+ owedIasset: 0n,
11605
+ redemptionFee: fee,
11606
+ mintingFee: 0n
11607
+ }
11608
+ }
11609
+ };
11610
+ } else {
11611
+ const collateralConversion = rationalFloor(
11612
+ rationalMul(
11613
+ rationalFromInt(effectiveSuppliedIasset),
11614
+ psmPool.datum.collateralToIassetRatio
11615
+ )
11616
+ );
11617
+ const attemptedNormalizedEffectiveIasset = rationalFloor(
11618
+ rationalDiv(
11619
+ rationalFromInt(collateralConversion),
11620
+ psmPool.datum.collateralToIassetRatio
11621
+ )
11622
+ );
11623
+ const normalizedEffectiveIasset = rationalFloor(
11624
+ rationalMul(
11625
+ rationalFromInt(attemptedNormalizedEffectiveIasset),
11626
+ psmPool.datum.collateralToIassetRatio
11627
+ )
11628
+ ) != collateralConversion ? effectiveSuppliedIasset : attemptedNormalizedEffectiveIasset;
11629
+ return {
11630
+ _tag: "SUCCESS",
11631
+ result: {
11632
+ order,
11633
+ orderType: "REDEEMING",
11634
+ swapInfo: {
11635
+ suppliedIasset: normalizedEffectiveIasset,
11636
+ suppliedCollateralAsset: 0n,
11637
+ owedCollateralAsset: rationalFloor(
11638
+ rationalMul(
11639
+ rationalFromInt(effectiveSuppliedIasset),
11640
+ psmPool.datum.collateralToIassetRatio
11641
+ )
11642
+ ),
11643
+ owedIasset: 0n,
11644
+ redemptionFee: fee,
11645
+ mintingFee: 0n
11646
+ }
11647
+ }
11648
+ };
11649
+ }
11650
+ }
11651
+ }
11652
+ function pickValidSatisfiableOrders(orders, pool, sysParams, orderProcessingConfig) {
11653
+ const psmAvailableLiq = (0, import_cardano_offchain_common35.assetClassValueOf)(
11654
+ pool.utxo.assets,
11655
+ pool.datum.collateralAsset
11656
+ );
11657
+ const validOrders = orders.flatMap((order) => {
11658
+ try {
11659
+ const res = summariseOrder(order, pool, sysParams, orderProcessingConfig);
11660
+ return res._tag === "SUCCESS" ? [res.result] : [];
11661
+ } catch (_) {
11662
+ return [];
11663
+ }
11664
+ });
11665
+ const { left: mintingOrders, right: redeemingOrdersSortedDesc } = import_fp_ts28.function.pipe(
11666
+ validOrders,
11667
+ import_fp_ts28.array.partition((o) => o.orderType === "REDEEMING"),
11668
+ ({ left, right }) => ({
11669
+ left,
11670
+ // Sort the redeeming orders descending.
11671
+ right: import_fp_ts28.function.pipe(
11672
+ right,
11673
+ import_fp_ts28.array.sort(
11674
+ import_fp_ts28.ord.contramap(
11675
+ (o) => o.swapInfo.owedCollateralAsset
11676
+ )(import_fp_ts28.ord.reverse(BigIntOrd))
11677
+ )
11678
+ )
11679
+ })
11680
+ );
11681
+ const totalCollateralDiff = import_fp_ts28.function.pipe(
11682
+ validOrders,
11683
+ import_fp_ts28.array.reduce(
11684
+ 0n,
11685
+ (acc, order) => acc + order.swapInfo.suppliedCollateralAsset - order.swapInfo.owedCollateralAsset
11686
+ )
11687
+ );
11688
+ if (psmAvailableLiq + totalCollateralDiff >= 0n) {
11689
+ return validOrders.map((o) => o.order);
11690
+ }
11691
+ const collateralFromMinting = import_fp_ts28.function.pipe(
11692
+ mintingOrders,
11693
+ import_fp_ts28.array.reduce(0n, (acc, o) => acc + o.swapInfo.suppliedCollateralAsset)
11694
+ );
11695
+ const { selected } = import_fp_ts28.function.pipe(
11696
+ redeemingOrdersSortedDesc,
11697
+ import_fp_ts28.array.reduce(
11698
+ {
11699
+ intermediateCollateralAmt: psmAvailableLiq + collateralFromMinting,
11700
+ selected: []
11701
+ },
11702
+ ({ intermediateCollateralAmt, selected: selected2 }, order) => intermediateCollateralAmt >= order.swapInfo.owedCollateralAsset ? {
11703
+ intermediateCollateralAmt: intermediateCollateralAmt - order.swapInfo.owedCollateralAsset,
11704
+ selected: [...selected2, order]
11705
+ } : { intermediateCollateralAmt, selected: selected2 }
11706
+ )
11707
+ );
11708
+ return [...mintingOrders, ...selected].map((o) => o.order);
11709
+ }
11509
11710
 
11510
11711
  // src/contracts/stableswap/transactions.ts
11511
- var import_lucid69 = require("@lucid-evolution/lucid");
11512
- var import_cardano_offchain_common35 = require("@3rd-eye-labs/cardano-offchain-common");
11513
- var import_fp_ts28 = require("fp-ts");
11712
+ var import_lucid67 = require("@lucid-evolution/lucid");
11713
+ var import_cardano_offchain_common36 = require("@3rd-eye-labs/cardano-offchain-common");
11714
+ var import_fp_ts29 = require("fp-ts");
11514
11715
  var import_Array3 = require("fp-ts/lib/Array");
11515
11716
  async function createStableswapOrder(iasset, collateralAsset, amount, minting, poolDatum, params, lucid, destinationAddress, destinationInlineDatum, maxExecutionFee = BASE_MAX_EXECUTION_FEE, additionalLovelaces = 0n, maxFeeRatio) {
11516
11717
  const myAddress = await lucid.wallet().address();
11517
- const pkh = (0, import_lucid69.paymentCredentialOf)(myAddress);
11718
+ const pkh = (0, import_lucid67.paymentCredentialOf)(myAddress);
11518
11719
  const datum = {
11519
- iasset: (0, import_lucid69.fromHex)((0, import_lucid69.fromText)(iasset)),
11720
+ iasset: (0, import_lucid67.fromHex)((0, import_lucid67.fromText)(iasset)),
11520
11721
  collateralAsset,
11521
- owner: (0, import_lucid69.fromHex)(pkh.hash),
11522
- destination: (0, import_cardano_offchain_common35.addressFromBech32)(destinationAddress ?? myAddress),
11722
+ owner: (0, import_lucid67.fromHex)(pkh.hash),
11723
+ destination: (0, import_cardano_offchain_common36.addressFromBech32)(destinationAddress ?? myAddress),
11523
11724
  destinationInlineDatum: destinationInlineDatum ?? null,
11524
11725
  maxExecutionFee,
11525
11726
  maxFeeRatio: maxFeeRatio ?? (minting ? poolDatum.mintingFeeRatio : poolDatum.redemptionFeeRatio)
11526
11727
  };
11527
- const assetsToSwap = minting ? (0, import_cardano_offchain_common35.mkAssetsOf)(collateralAsset, amount) : (0, import_cardano_offchain_common35.mkAssetsOf)(
11728
+ const assetsToSwap = minting ? (0, import_cardano_offchain_common36.mkAssetsOf)(collateralAsset, amount) : (0, import_cardano_offchain_common36.mkAssetsOf)(
11528
11729
  {
11529
- currencySymbol: (0, import_lucid69.fromHex)(
11730
+ currencySymbol: (0, import_lucid67.fromHex)(
11530
11731
  params.stableswapParams.iassetSymbol.unCurrencySymbol
11531
11732
  ),
11532
- tokenName: (0, import_lucid69.fromHex)((0, import_lucid69.fromText)(iasset))
11733
+ tokenName: (0, import_lucid67.fromHex)((0, import_lucid67.fromText)(iasset))
11533
11734
  },
11534
11735
  amount
11535
11736
  );
@@ -11547,7 +11748,7 @@ async function createStableswapOrder(iasset, collateralAsset, amount, minting, p
11547
11748
  );
11548
11749
  const roundedExpectedOutputLovelaces = (expectedOutputLovelaces / 1000000n + 1n) * 1000000n;
11549
11750
  return lucid.newTx().pay.ToContract(
11550
- (0, import_lucid69.credentialToAddress)(lucid.config().network, {
11751
+ (0, import_lucid67.credentialToAddress)(lucid.config().network, {
11551
11752
  hash: params.validatorHashes.stableswapHash,
11552
11753
  type: "Script"
11553
11754
  }),
@@ -11555,16 +11756,16 @@ async function createStableswapOrder(iasset, collateralAsset, amount, minting, p
11555
11756
  kind: "inline",
11556
11757
  value: serialiseStableswapOrderDatum(datum)
11557
11758
  },
11558
- (0, import_lucid69.addAssets)(
11759
+ (0, import_lucid67.addAssets)(
11559
11760
  assetsToSwap,
11560
- (0, import_cardano_offchain_common35.mkLovelacesOf)(
11761
+ (0, import_cardano_offchain_common36.mkLovelacesOf)(
11561
11762
  roundedExpectedOutputLovelaces + maxExecutionFee + additionalLovelaces
11562
11763
  )
11563
11764
  )
11564
11765
  );
11565
11766
  }
11566
11767
  async function cancelStableswapOrder(stableswapOrderOref, sysParams, lucid) {
11567
- const stableswapScriptRefUtxo = (0, import_cardano_offchain_common35.matchSingle)(
11768
+ const stableswapScriptRefUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11568
11769
  await lucid.utxosByOutRef([
11569
11770
  fromSystemParamsScriptRef(
11570
11771
  sysParams.scriptReferences.stableswapValidatorRef
@@ -11572,20 +11773,20 @@ async function cancelStableswapOrder(stableswapOrderOref, sysParams, lucid) {
11572
11773
  ]),
11573
11774
  (_) => new Error("Expected a single Stableswap Ref Script UTXO")
11574
11775
  );
11575
- const stableswapOrderUtxo = (0, import_cardano_offchain_common35.matchSingle)(
11776
+ const stableswapOrderUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11576
11777
  await lucid.utxosByOutRef([stableswapOrderOref]),
11577
11778
  (_) => new Error("Expected a single Stableswap Order UTXO.")
11578
11779
  );
11579
11780
  const stableswapOrderDatum = parseStableswapOrderDatumOrThrow(
11580
- (0, import_cardano_offchain_common35.getInlineDatumOrThrow)(stableswapOrderUtxo)
11781
+ (0, import_cardano_offchain_common36.getInlineDatumOrThrow)(stableswapOrderUtxo)
11581
11782
  );
11582
11783
  return lucid.newTx().readFrom([stableswapScriptRefUtxo]).collectFrom(
11583
11784
  [stableswapOrderUtxo],
11584
11785
  serialiseStableswapOrderRedeemer("CancelStableswapOrder")
11585
- ).addSignerKey((0, import_lucid69.toHex)(stableswapOrderDatum.owner));
11786
+ ).addSignerKey((0, import_lucid67.toHex)(stableswapOrderDatum.owner));
11586
11787
  }
11587
- async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPoolOref, treasuryOref, sysParams, lucid) {
11588
- const stableswapScriptRefUtxo = (0, import_cardano_offchain_common35.matchSingle)(
11788
+ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPoolOref, treasuryOref, sysParams, lucid, orderProcessingConfig = defaultOrderProcessingConfig) {
11789
+ const stableswapScriptRefUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11589
11790
  await lucid.utxosByOutRef([
11590
11791
  fromSystemParamsScriptRef(
11591
11792
  sysParams.scriptReferences.stableswapValidatorRef
@@ -11593,13 +11794,13 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11593
11794
  ]),
11594
11795
  (_) => new Error("Expected a single Stableswap Ref Script UTXO")
11595
11796
  );
11596
- const cdpScriptRefUtxo = (0, import_cardano_offchain_common35.matchSingle)(
11797
+ const cdpScriptRefUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11597
11798
  await lucid.utxosByOutRef([
11598
11799
  fromSystemParamsScriptRef(sysParams.scriptReferences.cdpValidatorRef)
11599
11800
  ]),
11600
11801
  (_) => new Error("Expected a single CDP Ref Script UTXO")
11601
11802
  );
11602
- const iAssetTokenPolicyRefScriptUtxo = (0, import_cardano_offchain_common35.matchSingle)(
11803
+ const iAssetTokenPolicyRefScriptUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11603
11804
  await lucid.utxosByOutRef([
11604
11805
  fromSystemParamsScriptRef(
11605
11806
  sysParams.scriptReferences.iAssetTokenPolicyRef
@@ -11611,7 +11812,7 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11611
11812
  throw new Error("At least one order must be provided.");
11612
11813
  }
11613
11814
  const stableswapOrderUtxos = await lucid.utxosByOutRef(stableswapOrderOrefs);
11614
- const sortedStableswapOrderUtxos = (0, import_lucid69.sortUTxOs)(
11815
+ const sortedStableswapOrderUtxos = (0, import_lucid67.sortUTxOs)(
11615
11816
  stableswapOrderUtxos,
11616
11817
  "Canonical"
11617
11818
  );
@@ -11620,158 +11821,45 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11620
11821
  }
11621
11822
  const mainOrderUtxo = sortedStableswapOrderUtxos[0];
11622
11823
  const mainOrderDatum = parseStableswapOrderDatumOrThrow(
11623
- (0, import_cardano_offchain_common35.getInlineDatumOrThrow)(mainOrderUtxo)
11824
+ (0, import_cardano_offchain_common36.getInlineDatumOrThrow)(mainOrderUtxo)
11624
11825
  );
11625
11826
  const iassetAc = {
11626
- currencySymbol: (0, import_lucid69.fromHex)(
11827
+ currencySymbol: (0, import_lucid67.fromHex)(
11627
11828
  sysParams.stableswapParams.iassetSymbol.unCurrencySymbol
11628
11829
  ),
11629
11830
  tokenName: mainOrderDatum.iasset
11630
11831
  };
11631
11832
  const collateralAc = mainOrderDatum.collateralAsset;
11632
- const stableswapPoolUtxo = (0, import_cardano_offchain_common35.matchSingle)(
11833
+ const stableswapPoolUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11633
11834
  await lucid.utxosByOutRef([stableswapPoolOref]),
11634
11835
  (_) => new Error("Expected a single cdp UTXO")
11635
11836
  );
11636
11837
  const stableswapPoolDatum = parseStableswapPoolDatumOrThrow(
11637
- (0, import_cardano_offchain_common35.getInlineDatumOrThrow)(stableswapPoolUtxo)
11838
+ (0, import_cardano_offchain_common36.getInlineDatumOrThrow)(stableswapPoolUtxo)
11638
11839
  );
11639
11840
  const ordersInfo = sortedStableswapOrderUtxos.map(
11640
11841
  (orderUtxo) => {
11641
11842
  const orderDatum = parseStableswapOrderDatumOrThrow(
11642
- (0, import_cardano_offchain_common35.getInlineDatumOrThrow)(orderUtxo)
11843
+ (0, import_cardano_offchain_common36.getInlineDatumOrThrow)(orderUtxo)
11643
11844
  );
11644
- if ((0, import_lucid69.toHex)(orderDatum.iasset) != (0, import_lucid69.toHex)(mainOrderDatum.iasset) || (0, import_lucid69.toHex)(orderDatum.collateralAsset.currencySymbol) != (0, import_lucid69.toHex)(mainOrderDatum.collateralAsset.currencySymbol) || (0, import_lucid69.toHex)(orderDatum.collateralAsset.tokenName) != (0, import_lucid69.toHex)(mainOrderDatum.collateralAsset.tokenName)) {
11845
+ if ((0, import_lucid67.toHex)(orderDatum.iasset) != (0, import_lucid67.toHex)(mainOrderDatum.iasset) || (0, import_lucid67.toHex)(orderDatum.collateralAsset.currencySymbol) != (0, import_lucid67.toHex)(mainOrderDatum.collateralAsset.currencySymbol) || (0, import_lucid67.toHex)(orderDatum.collateralAsset.tokenName) != (0, import_lucid67.toHex)(mainOrderDatum.collateralAsset.tokenName)) {
11645
11846
  throw new Error("Wrong batch of orders");
11646
11847
  }
11647
- const suppliedIasset = (0, import_cardano_offchain_common35.assetClassValueOf)(orderUtxo.assets, iassetAc);
11648
- const suppliedCollateralAsset = (0, import_cardano_offchain_common35.assetClassValueOf)(
11649
- orderUtxo.assets,
11650
- collateralAc
11848
+ const res = summariseOrder(
11849
+ { utxo: orderUtxo, datum: orderDatum },
11850
+ { utxo: stableswapPoolUtxo, datum: stableswapPoolDatum },
11851
+ sysParams,
11852
+ orderProcessingConfig
11651
11853
  );
11652
- if (suppliedIasset != 0n && suppliedCollateralAsset != 0n || suppliedIasset == 0n && suppliedCollateralAsset == 0n) {
11653
- throw new Error(
11654
- "An order must supply either iAsset or collateral asset"
11655
- );
11656
- }
11657
- const isMinting = suppliedCollateralAsset > 0n;
11658
- const isOneToOne = stableswapPoolDatum.collateralToIassetRatio.numerator === stableswapPoolDatum.collateralToIassetRatio.denominator;
11659
- if (isMinting) {
11660
- if (isOneToOne) {
11661
- const fee2 = calculateFeeFromRatio(
11662
- stableswapPoolDatum.mintingFeeRatio,
11663
- suppliedCollateralAsset
11664
- );
11665
- return {
11666
- utxo: orderUtxo,
11667
- datum: orderDatum,
11668
- swapInfo: {
11669
- suppliedCollateralAsset,
11670
- suppliedIasset: 0n,
11671
- owedCollateralAsset: 0n,
11672
- owedIasset: suppliedCollateralAsset - fee2,
11673
- mintingFee: fee2,
11674
- redemptionFee: 0n
11675
- }
11676
- };
11677
- } else {
11678
- const iAssetConversion = rationalFloor(
11679
- rationalDiv(
11680
- rationalFromInt(suppliedCollateralAsset),
11681
- stableswapPoolDatum.collateralToIassetRatio
11682
- )
11683
- );
11684
- const attemptedNormalizedCollateral = rationalFloor(
11685
- rationalMul(
11686
- rationalFromInt(iAssetConversion),
11687
- stableswapPoolDatum.collateralToIassetRatio
11688
- )
11689
- );
11690
- const normalizedCollateralSupplied = rationalFloor(
11691
- rationalDiv(
11692
- rationalFromInt(attemptedNormalizedCollateral),
11693
- stableswapPoolDatum.collateralToIassetRatio
11694
- )
11695
- ) != iAssetConversion ? suppliedCollateralAsset : attemptedNormalizedCollateral;
11696
- const fee2 = calculateFeeFromRatio(
11697
- stableswapPoolDatum.mintingFeeRatio,
11698
- iAssetConversion
11699
- );
11700
- return {
11701
- utxo: orderUtxo,
11702
- datum: orderDatum,
11703
- swapInfo: {
11704
- suppliedCollateralAsset: normalizedCollateralSupplied,
11705
- suppliedIasset: 0n,
11706
- owedCollateralAsset: 0n,
11707
- owedIasset: iAssetConversion - fee2,
11708
- mintingFee: fee2,
11709
- redemptionFee: 0n
11710
- }
11711
- };
11712
- }
11713
- } else {
11714
- const fee2 = calculateFeeFromRatio(
11715
- stableswapPoolDatum.redemptionFeeRatio,
11716
- suppliedIasset
11717
- );
11718
- const effectiveSuppliedIasset = suppliedIasset - fee2;
11719
- if (isOneToOne) {
11720
- return {
11721
- utxo: orderUtxo,
11722
- datum: orderDatum,
11723
- swapInfo: {
11724
- suppliedCollateralAsset: 0n,
11725
- suppliedIasset: effectiveSuppliedIasset,
11726
- owedCollateralAsset: effectiveSuppliedIasset,
11727
- owedIasset: 0n,
11728
- mintingFee: 0n,
11729
- redemptionFee: fee2
11730
- }
11731
- };
11732
- } else {
11733
- const collateralConversion = rationalFloor(
11734
- rationalMul(
11735
- rationalFromInt(effectiveSuppliedIasset),
11736
- stableswapPoolDatum.collateralToIassetRatio
11737
- )
11738
- );
11739
- const attemptedNormalizedEffectiveIasset = rationalFloor(
11740
- rationalDiv(
11741
- rationalFromInt(collateralConversion),
11742
- stableswapPoolDatum.collateralToIassetRatio
11743
- )
11744
- );
11745
- const normalizedEffectiveIasset = rationalFloor(
11746
- rationalMul(
11747
- rationalFromInt(attemptedNormalizedEffectiveIasset),
11748
- stableswapPoolDatum.collateralToIassetRatio
11749
- )
11750
- ) != collateralConversion ? effectiveSuppliedIasset : attemptedNormalizedEffectiveIasset;
11751
- return {
11752
- utxo: orderUtxo,
11753
- datum: orderDatum,
11754
- swapInfo: {
11755
- suppliedCollateralAsset: 0n,
11756
- suppliedIasset: normalizedEffectiveIasset,
11757
- owedCollateralAsset: rationalFloor(
11758
- rationalMul(
11759
- rationalFromInt(effectiveSuppliedIasset),
11760
- stableswapPoolDatum.collateralToIassetRatio
11761
- )
11762
- ),
11763
- owedIasset: 0n,
11764
- mintingFee: 0n,
11765
- redemptionFee: fee2
11766
- }
11767
- };
11768
- }
11854
+ if (res._tag === "ERROR") {
11855
+ throw new Error(res.reason);
11769
11856
  }
11857
+ return res.result;
11770
11858
  }
11771
11859
  );
11772
- const totalSwapInfo = import_fp_ts28.function.pipe(
11860
+ const totalSwapInfo = import_fp_ts29.function.pipe(
11773
11861
  ordersInfo,
11774
- import_fp_ts28.array.reduce(
11862
+ import_fp_ts29.array.reduce(
11775
11863
  {
11776
11864
  suppliedCollateralAsset: 0n,
11777
11865
  suppliedIasset: 0n,
@@ -11793,6 +11881,13 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11793
11881
  )
11794
11882
  );
11795
11883
  const collateralAmtChangePool = totalSwapInfo.suppliedCollateralAsset - totalSwapInfo.owedCollateralAsset;
11884
+ const newPsmPoolValue = (0, import_lucid67.addAssets)(
11885
+ stableswapPoolUtxo.assets,
11886
+ (0, import_cardano_offchain_common36.mkAssetsOf)(collateralAc, collateralAmtChangePool)
11887
+ );
11888
+ if ((0, import_cardano_offchain_common36.assetClassValueOf)(newPsmPoolValue, collateralAc) < 0n) {
11889
+ throw new Error("Cannot batch more than liquidity allows");
11890
+ }
11796
11891
  const amountToMint = totalSwapInfo.owedIasset - totalSwapInfo.suppliedIasset + totalSwapInfo.mintingFee;
11797
11892
  const fee = totalSwapInfo.mintingFee + totalSwapInfo.redemptionFee;
11798
11893
  const tx = lucid.newTx().readFrom([
@@ -11813,20 +11908,17 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11813
11908
  kind: "inline",
11814
11909
  value: serialiseStableswapPoolDatum(stableswapPoolDatum)
11815
11910
  },
11816
- collateralAmtChangePool != 0n ? (0, import_lucid69.addAssets)(
11817
- stableswapPoolUtxo.assets,
11818
- (0, import_cardano_offchain_common35.mkAssetsOf)(collateralAc, collateralAmtChangePool)
11819
- ) : stableswapPoolUtxo.assets
11911
+ newPsmPoolValue
11820
11912
  ).setMinFee(stableswapOrderOrefs.length > 1 ? 1498875n : 1030000n);
11821
11913
  if (amountToMint !== 0n) {
11822
- tx.mintAssets((0, import_cardano_offchain_common35.mkAssetsOf)(iassetAc, amountToMint), import_lucid69.Data.void());
11914
+ tx.mintAssets((0, import_cardano_offchain_common36.mkAssetsOf)(iassetAc, amountToMint), import_lucid67.Data.void());
11823
11915
  }
11824
- import_fp_ts28.function.pipe(
11916
+ import_fp_ts29.function.pipe(
11825
11917
  ordersInfo,
11826
- import_fp_ts28.array.reduce(tx, (acc, orderInfo) => {
11918
+ import_fp_ts29.array.reduce(tx, (acc, orderInfo) => {
11827
11919
  return acc.collectFrom(
11828
- [orderInfo.utxo],
11829
- (0, import_cardano_offchain_common35.isSameOutRef)(orderInfo.utxo, mainOrderUtxo) ? serialiseStableswapOrderRedeemer("BatchProcessStableswapOrders") : {
11920
+ [orderInfo.order.utxo],
11921
+ (0, import_cardano_offchain_common36.isSameOutRef)(orderInfo.order.utxo, mainOrderUtxo) ? serialiseStableswapOrderRedeemer("BatchProcessStableswapOrders") : {
11830
11922
  kind: "selected",
11831
11923
  makeRedeemer: (inputIndices) => {
11832
11924
  return serialiseStableswapOrderRedeemer({
@@ -11836,24 +11928,27 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11836
11928
  }
11837
11929
  });
11838
11930
  },
11839
- inputs: [orderInfo.utxo, mainOrderUtxo]
11931
+ inputs: [orderInfo.order.utxo, mainOrderUtxo]
11840
11932
  }
11841
11933
  ).pay.ToAddressWithData(
11842
- (0, import_cardano_offchain_common35.addressToBech32)(orderInfo.datum.destination, lucid.config().network),
11934
+ (0, import_cardano_offchain_common36.addressToBech32)(
11935
+ orderInfo.order.datum.destination,
11936
+ lucid.config().network
11937
+ ),
11843
11938
  {
11844
11939
  kind: "inline",
11845
11940
  value: createDestinationDatum(
11846
- orderInfo.datum.destinationInlineDatum ?? null,
11847
- orderInfo.utxo
11941
+ orderInfo.order.datum.destinationInlineDatum ?? null,
11942
+ orderInfo.order.utxo
11848
11943
  )
11849
11944
  },
11850
- (0, import_lucid69.addAssets)(
11851
- // Currently, we always take the max execution fee from the order utxo.
11945
+ (0, import_lucid67.addAssets)(
11946
+ // NOTICE: Currently, we always take the max execution fee from the order utxo.
11852
11947
  // This can be improved so that we take the actual execution fee.
11853
- (0, import_cardano_offchain_common35.mkLovelacesOf)(
11854
- (0, import_cardano_offchain_common35.lovelacesAmt)(orderInfo.utxo.assets) - orderInfo.datum.maxExecutionFee
11948
+ (0, import_cardano_offchain_common36.mkLovelacesOf)(
11949
+ (0, import_cardano_offchain_common36.lovelacesAmt)(orderInfo.order.utxo.assets) - orderInfo.order.datum.maxExecutionFee
11855
11950
  ),
11856
- orderInfo.swapInfo.owedIasset > 0 ? (0, import_cardano_offchain_common35.mkAssetsOf)(iassetAc, orderInfo.swapInfo.owedIasset) : (0, import_cardano_offchain_common35.mkAssetsOf)(
11951
+ orderInfo.orderType === "MINTING" ? (0, import_cardano_offchain_common36.mkAssetsOf)(iassetAc, orderInfo.swapInfo.owedIasset) : (0, import_cardano_offchain_common36.mkAssetsOf)(
11857
11952
  collateralAc,
11858
11953
  orderInfo.swapInfo.owedCollateralAsset
11859
11954
  )
@@ -11876,7 +11971,7 @@ async function batchProcessStableswapOrders(stableswapOrderOrefs, stableswapPool
11876
11971
  return tx;
11877
11972
  }
11878
11973
  async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRef, newMintingFeeRatio, newRedemptionFeeRatio, sysParams, lucid) {
11879
- const stableswapScriptRefUtxo = (0, import_cardano_offchain_common35.matchSingle)(
11974
+ const stableswapScriptRefUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11880
11975
  await lucid.utxosByOutRef([
11881
11976
  fromSystemParamsScriptRef(
11882
11977
  sysParams.scriptReferences.stableswapValidatorRef
@@ -11884,22 +11979,22 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
11884
11979
  ]),
11885
11980
  (_) => new Error("Expected a single Stableswap Ref Script UTXO")
11886
11981
  );
11887
- const cdpScriptRefUtxo = (0, import_cardano_offchain_common35.matchSingle)(
11982
+ const cdpScriptRefUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11888
11983
  await lucid.utxosByOutRef([
11889
11984
  fromSystemParamsScriptRef(sysParams.scriptReferences.cdpValidatorRef)
11890
11985
  ]),
11891
11986
  (_) => new Error("Expected a single CDP Ref Script UTXO")
11892
11987
  );
11893
- const stableswapPool = (0, import_cardano_offchain_common35.matchSingle)(
11988
+ const stableswapPool = (0, import_cardano_offchain_common36.matchSingle)(
11894
11989
  await lucid.utxosByOutRef([stableswapPoolOutRef]),
11895
11990
  (_) => new Error("Expected a single Stableswap Pool UTXO.")
11896
11991
  );
11897
- const stableswapFeeUtxo = (0, import_cardano_offchain_common35.matchSingle)(
11992
+ const stableswapFeeUtxo = (0, import_cardano_offchain_common36.matchSingle)(
11898
11993
  await lucid.utxosByOutRef([stableswapFeeOutRef]),
11899
11994
  (_) => new Error("Expected a single Stableswap Fee UTXO.")
11900
11995
  );
11901
11996
  const stableswapPoolDatum = parseStableswapPoolDatumOrThrow(
11902
- (0, import_cardano_offchain_common35.getInlineDatumOrThrow)(stableswapPool)
11997
+ (0, import_cardano_offchain_common36.getInlineDatumOrThrow)(stableswapPool)
11903
11998
  );
11904
11999
  const newStableswapPoolDatum = {
11905
12000
  ...stableswapPoolDatum,
@@ -11927,7 +12022,7 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
11927
12022
  value: serialiseStableswapPoolDatum(newStableswapPoolDatum)
11928
12023
  },
11929
12024
  stableswapPool.assets
11930
- ).addSignerKey((0, import_lucid69.toHex)(stableswapPoolDatum.feeManager)).setMinFee(1038402n);
12025
+ ).addSignerKey((0, import_lucid67.toHex)(stableswapPoolDatum.feeManager)).setMinFee(1038402n);
11931
12026
  }
11932
12027
  // Annotate the CommonJS export names for ESM import in node:
11933
12028
  0 && (module.exports = {
@@ -12048,6 +12143,7 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
12048
12143
  createStableswapOrder,
12049
12144
  decodePriceUpdate,
12050
12145
  decodePythMessage,
12146
+ defaultOrderProcessingConfig,
12051
12147
  depositCdp,
12052
12148
  deriveAuthToken,
12053
12149
  derivePythPrice,
@@ -12211,7 +12307,9 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
12211
12307
  parseStakingRedeemer,
12212
12308
  parseStakingRedeemerOrThrow,
12213
12309
  partitionEpochToScaleToSums,
12310
+ pickValidSatisfiableOrders,
12214
12311
  processSpRequest,
12312
+ psmOrderType,
12215
12313
  randomRobsSubsetSatisfyingTargetCollateral,
12216
12314
  rationalAdd,
12217
12315
  rationalCeil,
@@ -12285,6 +12383,7 @@ async function updateStableswapPoolFees(stableswapPoolOutRef, stableswapFeeOutRe
12285
12383
  startPriceOracleTx,
12286
12384
  submitTx,
12287
12385
  sum,
12386
+ summariseOrder,
12288
12387
  summarizeActualLeverageRedemptions,
12289
12388
  toAssetClassFromLucid,
12290
12389
  toDataDerivedPythPrice,