@indigo-labs/indigo-sdk 0.2.35 → 0.2.37

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.
package/dist/index.js CHANGED
@@ -30,6 +30,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ ACCOUNT_TOKEN_NAME: () => ACCOUNT_TOKEN_NAME,
34
+ ALWAYS_FAIL_VALIDATOR_HASH: () => ALWAYS_FAIL_VALIDATOR_HASH,
33
35
  AccountContentSchema: () => AccountContentSchema,
34
36
  ActionReturnDatum: () => ActionReturnDatum,
35
37
  ActionReturnDatumSchema: () => ActionReturnDatumSchema,
@@ -41,16 +43,22 @@ __export(index_exports, {
41
43
  CDPCreatorRedeemer: () => CDPCreatorRedeemer,
42
44
  CDPDatumSchema: () => CDPDatumSchema,
43
45
  CDPFeesSchema: () => CDPFeesSchema,
46
+ CDP_CREATOR_TOKEN_NAME: () => CDP_CREATOR_TOKEN_NAME,
47
+ CDP_TOKEN_NAME: () => CDP_TOKEN_NAME,
44
48
  CredentialD: () => CredentialD,
45
49
  CredentialSchema: () => CredentialSchema,
50
+ DAO_TOKEN_NAME: () => DAO_TOKEN_NAME,
46
51
  EpochToScaleToSumSchema: () => EpochToScaleToSumSchema,
47
52
  ExecuteDatum: () => ExecuteDatum,
48
53
  ExecuteParams: () => ExecuteParams,
49
54
  FeedInterestOracleRedeemerSchema: () => FeedInterestOracleRedeemerSchema,
55
+ GOV_NFT_TOKEN_NAME: () => GOV_NFT_TOKEN_NAME,
50
56
  GovParams: () => GovParams,
51
57
  GovRedeemer: () => GovRedeemer,
58
+ IASSET_TOKEN_NAME: () => IASSET_TOKEN_NAME,
52
59
  IAssetContentSchema: () => IAssetContentSchema,
53
60
  IAssetPriceInfoSchema: () => IAssetPriceInfoSchema,
61
+ INDY_TOKEN_NAME: () => INDY_TOKEN_NAME,
54
62
  InterestOracleDatumSchema: () => InterestOracleDatumSchema,
55
63
  InterestOracleParamsSchema: () => InterestOracleParamsSchema,
56
64
  LRPDatumSchema: () => LRPDatumSchema,
@@ -58,26 +66,44 @@ __export(index_exports, {
58
66
  LRPRedeemerSchema: () => LRPRedeemerSchema,
59
67
  MAX_REDEMPTIONS_WITH_CDP_OPEN: () => MAX_REDEMPTIONS_WITH_CDP_OPEN,
60
68
  MIN_LRP_COLLATERAL_AMT: () => MIN_LRP_COLLATERAL_AMT,
69
+ NUM_CDP_CREATORS: () => NUM_CDP_CREATORS,
70
+ NUM_COLLECTORS: () => NUM_COLLECTORS,
61
71
  ONE_DAY: () => ONE_DAY,
62
72
  ONE_HOUR: () => ONE_HOUR,
63
73
  ONE_SECOND: () => ONE_SECOND,
64
74
  ONE_YEAR: () => ONE_YEAR,
65
75
  OracleAssetNftSchema: () => OracleAssetNftSchema,
66
76
  OutputReferenceSchema: () => OutputReferenceSchema,
77
+ POLL_MANAGER_TOKEN_NAME: () => POLL_MANAGER_TOKEN_NAME,
78
+ PollDatum: () => PollDatum,
67
79
  PollManagerParams: () => PollManagerParams,
68
80
  PollManagerRedeemer: () => PollManagerRedeemer,
69
81
  PollShardParams: () => PollShardParams,
70
82
  PollShardRedeemer: () => PollShardRedeemer,
71
83
  PriceOracleDatumSchema: () => PriceOracleDatumSchema,
72
84
  PriceOracleParamsSchema: () => PriceOracleParamsSchema,
85
+ ProposalContent: () => ProposalContent,
86
+ ProposalContentSchema: () => ProposalContentSchema,
87
+ ProtocolParams: () => ProtocolParams,
88
+ ProtocolParamsSchema: () => ProtocolParamsSchema,
89
+ SNAPSHOT_EPOCH_TO_SCALE_TO_SUM_TOKEN_NAME: () => SNAPSHOT_EPOCH_TO_SCALE_TO_SUM_TOKEN_NAME,
73
90
  SPIntegerSchema: () => SPIntegerSchema,
91
+ STABILITY_POOL_TOKEN_NAME: () => STABILITY_POOL_TOKEN_NAME,
92
+ STAKING_MANAGER_TOKEN_NAME: () => STAKING_MANAGER_TOKEN_NAME,
93
+ STAKING_TOKEN_NAME: () => STAKING_TOKEN_NAME,
74
94
  SnapshotEpochToScaleToSumContentSchema: () => SnapshotEpochToScaleToSumContentSchema,
75
95
  StabilityPoolContentSchema: () => StabilityPoolContentSchema,
76
96
  StabilityPoolDatumSchema: () => StabilityPoolDatumSchema,
77
97
  StabilityPoolParams: () => StabilityPoolParams,
78
98
  StabilityPoolRedeemerSchema: () => StabilityPoolRedeemerSchema,
79
99
  StakeCredentialSchema: () => StakeCredentialSchema,
100
+ TOTAL_INDY_SUPPLY: () => TOTAL_INDY_SUPPLY,
101
+ TREASURY_INDY_AMOUNT: () => TREASURY_INDY_AMOUNT,
102
+ TreasuryParams: () => TreasuryParams,
103
+ TreasuryParamsSchema: () => TreasuryParamsSchema,
80
104
  TreasuryWithdrawalSchema: () => TreasuryWithdrawalSchema,
105
+ UPGRADE_TOKEN_NAME: () => UPGRADE_TOKEN_NAME,
106
+ VERSION_RECORD_TOKEN_NAME: () => VERSION_RECORD_TOKEN_NAME,
81
107
  VerificationKeyHashSchema: () => VerificationKeyHashSchema,
82
108
  VersionRecordTokenParams: () => VersionRecordTokenParams,
83
109
  addrDetails: () => addrDetails,
@@ -116,6 +142,7 @@ __export(index_exports, {
116
142
  castPriceOracleParams: () => castPriceOracleParams,
117
143
  castStabilityPoolParams: () => castStabilityPoolParams,
118
144
  castStakingParams: () => castStakingParams,
145
+ castTreasuryParams: () => castTreasuryParams,
119
146
  castVersionRecordTokenParams: () => castVersionRecordTokenParams,
120
147
  cdpCollateralRatioPercentage: () => cdpCollateralRatioPercentage,
121
148
  claimLrp: () => claimLrp,
@@ -147,6 +174,7 @@ __export(index_exports, {
147
174
  getInlineDatumOrThrow: () => getInlineDatumOrThrow,
148
175
  getRandomElement: () => getRandomElement,
149
176
  getSumFromEpochToScaleToSum: () => getSumFromEpochToScaleToSum,
177
+ init: () => init,
150
178
  initEpochToScaleToSumMap: () => initEpochToScaleToSumMap,
151
179
  initSpSnapshot: () => initSpSnapshot,
152
180
  insertSorted: () => insertSorted,
@@ -198,16 +226,22 @@ __export(index_exports, {
198
226
  parseInterestOracleDatum: () => parseInterestOracleDatum,
199
227
  parseLrpDatum: () => parseLrpDatum,
200
228
  parseLrpDatumOrThrow: () => parseLrpDatumOrThrow,
229
+ parsePollManager: () => parsePollManager,
230
+ parsePollManagerOrThrow: () => parsePollManagerOrThrow,
231
+ parsePollShard: () => parsePollShard,
232
+ parsePollShardOrThrow: () => parsePollShardOrThrow,
201
233
  parsePriceOracleDatum: () => parsePriceOracleDatum,
202
234
  parseSnapshotEpochToScaleToSumDatum: () => parseSnapshotEpochToScaleToSumDatum,
203
235
  parseStabilityPoolDatum: () => parseStabilityPoolDatum,
204
236
  parseStakingManagerDatum: () => parseStakingManagerDatum,
205
237
  parseStakingPosition: () => parseStakingPosition,
206
238
  parseStakingPositionOrThrow: () => parseStakingPositionOrThrow,
239
+ parseUpgradePaths: () => parseUpgradePaths,
207
240
  processSpRequest: () => processSpRequest,
208
241
  randomLrpsSubsetSatisfyingTargetLovelaces: () => randomLrpsSubsetSatisfyingTargetLovelaces,
209
242
  redeemCdp: () => redeemCdp,
210
243
  redeemLrp: () => redeemLrp,
244
+ resolveUtxo: () => resolveUtxo,
211
245
  rewardSnapshotPrecision: () => rewardSnapshotPrecision,
212
246
  runCreateScriptRefTx: () => runCreateScriptRefTx,
213
247
  runOneShotMintTx: () => runOneShotMintTx,
@@ -216,6 +250,7 @@ __export(index_exports, {
216
250
  serialiseCDPCreatorRedeemer: () => serialiseCDPCreatorRedeemer,
217
251
  serialiseCdpDatum: () => serialiseCdpDatum,
218
252
  serialiseCdpRedeemer: () => serialiseCdpRedeemer,
253
+ serialiseCollectorRedeemer: () => serialiseCollectorRedeemer,
219
254
  serialiseExecuteDatum: () => serialiseExecuteDatum,
220
255
  serialiseFeedInterestOracleRedeemer: () => serialiseFeedInterestOracleRedeemer,
221
256
  serialiseGovDatum: () => serialiseGovDatum,
@@ -224,6 +259,7 @@ __export(index_exports, {
224
259
  serialiseInterestOracleDatum: () => serialiseInterestOracleDatum,
225
260
  serialiseLrpDatum: () => serialiseLrpDatum,
226
261
  serialiseLrpRedeemer: () => serialiseLrpRedeemer,
262
+ serialisePollDatum: () => serialisePollDatum,
227
263
  serialisePollManagerRedeemer: () => serialisePollManagerRedeemer,
228
264
  serialisePollShardRedeemer: () => serialisePollShardRedeemer,
229
265
  serialisePriceOracleDatum: () => serialisePriceOracleDatum,
@@ -232,6 +268,10 @@ __export(index_exports, {
232
268
  serialiseStabilityPoolRedeemer: () => serialiseStabilityPoolRedeemer,
233
269
  serialiseStakingDatum: () => serialiseStakingDatum,
234
270
  serialiseStakingRedeemer: () => serialiseStakingRedeemer,
271
+ serialiseTreasuryDatum: () => serialiseTreasuryDatum,
272
+ serialiseTreasuryRedeemer: () => serialiseTreasuryRedeemer,
273
+ serialiseUpgradePaths: () => serialiseUpgradePaths,
274
+ serialiseWithdrawalOutputDatum: () => serialiseWithdrawalOutputDatum,
235
275
  setSumInEpochToScaleToSum: () => setSumInEpochToScaleToSum,
236
276
  shuffle: () => shuffle,
237
277
  spAdd: () => spAdd,
@@ -239,10 +279,12 @@ __export(index_exports, {
239
279
  spMul: () => spMul,
240
280
  spSub: () => spSub,
241
281
  startInterestOracle: () => startInterestOracle,
282
+ submitAndAwaitTx: () => submitAndAwaitTx,
242
283
  summarizeActualLeverageRedemptions: () => summarizeActualLeverageRedemptions,
243
284
  toSystemParamsAsset: () => toSystemParamsAsset,
244
285
  treasuryFeeTx: () => treasuryFeeTx,
245
286
  updatePoolSnapshotWithdrawalFee: () => updatePoolSnapshotWithdrawalFee,
287
+ updateSlotConfigNetwork: () => updateSlotConfigNetwork,
246
288
  updateStakingLockedAmount: () => updateStakingLockedAmount,
247
289
  vote: () => vote,
248
290
  withdrawCdp: () => withdrawCdp
@@ -275,6 +317,33 @@ function fromSysParamsScriptCredential(cred) {
275
317
 
276
318
  // src/utils/lucid-utils.ts
277
319
  var import_lucid2 = require("@lucid-evolution/lucid");
320
+
321
+ // src/utils/utils.ts
322
+ var fs = __toESM(require("fs"));
323
+ var import_ts_pattern = require("ts-pattern");
324
+ function matchSingle(xs, mkErr) {
325
+ return (0, import_ts_pattern.match)(xs).with([import_ts_pattern.P.select()], (res) => res).otherwise(() => {
326
+ throw mkErr(xs);
327
+ });
328
+ }
329
+ function loadSystemParamsFromFile(file) {
330
+ return JSON.parse(fs.readFileSync(file, "utf-8"));
331
+ }
332
+ function loadSystemParamsFromUrl(url) {
333
+ return fetch(url).then((res) => res.json()).then((data) => data);
334
+ }
335
+ var getRandomElement = (arr) => arr.length ? arr[Math.floor(Math.random() * arr.length)] : void 0;
336
+
337
+ // src/utils/lucid-utils.ts
338
+ async function resolveUtxo(input, lucid, errorMsg = "Expected a single UTXO") {
339
+ if ("address" in input) {
340
+ return input;
341
+ }
342
+ return matchSingle(
343
+ await lucid.utxosByOutRef([input]),
344
+ (_) => new Error(errorMsg)
345
+ );
346
+ }
278
347
  function getInlineDatumOrThrow(utxo) {
279
348
  if (utxo.datum != null) {
280
349
  return utxo.datum;
@@ -312,22 +381,11 @@ async function scriptRef(ref, lucid) {
312
381
  function balance(utxos) {
313
382
  return utxos.reduce((acc, utxo) => (0, import_lucid2.addAssets)(acc, utxo.assets), {});
314
383
  }
315
-
316
- // src/utils/utils.ts
317
- var fs = __toESM(require("fs"));
318
- var import_ts_pattern = require("ts-pattern");
319
- function matchSingle(xs, mkErr) {
320
- return (0, import_ts_pattern.match)(xs).with([import_ts_pattern.P.select()], (res) => res).otherwise(() => {
321
- throw mkErr(xs);
322
- });
323
- }
324
- function loadSystemParamsFromFile(file) {
325
- return JSON.parse(fs.readFileSync(file, "utf-8"));
326
- }
327
- function loadSystemParamsFromUrl(url) {
328
- return fetch(url).then((res) => res.json()).then((data) => data);
384
+ function updateSlotConfigNetwork(slotConfigNetwork) {
385
+ for (const [key, value] of Object.entries(slotConfigNetwork)) {
386
+ import_lucid2.SLOT_CONFIG_NETWORK[key] = value;
387
+ }
329
388
  }
330
- var getRandomElement = (arr) => arr.length ? arr[Math.floor(Math.random() * arr.length)] : void 0;
331
389
 
332
390
  // src/contracts/cdp/types.ts
333
391
  var import_lucid6 = require("@lucid-evolution/lucid");
@@ -680,6 +738,7 @@ var ProtocolParamsSchema = import_lucid8.Data.Object({
680
738
  /// Maximum amount of INDY that can be spent at once from the treasury.
681
739
  maxTreasuryIndySpend: import_lucid8.Data.Integer()
682
740
  });
741
+ var ProtocolParams = ProtocolParamsSchema;
683
742
  var ProposeAssetContentSchema = import_lucid8.Data.Object({
684
743
  asset: import_lucid8.Data.Bytes(),
685
744
  priceOracleNft: OracleAssetNftSchema,
@@ -733,6 +792,7 @@ var ProposalContentSchema = import_lucid8.Data.Enum([
733
792
  })
734
793
  })
735
794
  ]);
795
+ var ProposalContent = ProposalContentSchema;
736
796
  var UpgradePathSchema = import_evolution.Core.TSchema.Struct({
737
797
  upgradeSymbol: import_evolution.Core.TSchema.ByteArray
738
798
  });
@@ -744,6 +804,14 @@ var UpgradePathsSchema = import_evolution.Core.TSchema.Struct({
744
804
  UpgradePathSchema
745
805
  )
746
806
  });
807
+ function serialiseUpgradePaths(d) {
808
+ return import_lucid8.Data.from(
809
+ import_evolution.Core.Data.withSchema(
810
+ UpgradePathsSchema,
811
+ DEFAULT_SCHEMA_OPTIONS
812
+ ).toCBORHex(d)
813
+ );
814
+ }
747
815
  function parseUpgradePaths(d) {
748
816
  return import_evolution.Core.Data.withSchema(
749
817
  UpgradePathsSchema,
@@ -1440,10 +1508,11 @@ function serialiseCollectorRedeemer(redeemer) {
1440
1508
  }
1441
1509
 
1442
1510
  // src/contracts/collector/transactions.ts
1443
- async function collectorFeeTx(fee, lucid, params, tx, collectorOref) {
1444
- const collectorUtxo = matchSingle(
1445
- await lucid.utxosByOutRef([collectorOref]),
1446
- (_) => new Error("Expected a single collector UTXO")
1511
+ async function collectorFeeTx(fee, lucid, params, tx, collector) {
1512
+ const collectorUtxo = await resolveUtxo(
1513
+ collector,
1514
+ lucid,
1515
+ "Expected a single collector UTXO"
1447
1516
  );
1448
1517
  const collectorRefScriptUtxo = matchSingle(
1449
1518
  await lucid.utxosByOutRef([
@@ -1471,6 +1540,7 @@ var TreasuryParamsSchema = import_lucid16.Data.Object({
1471
1540
  versionRecordToken: AssetClassSchema,
1472
1541
  treasuryUtxosStakeCredential: import_lucid16.Data.Nullable(StakeCredentialSchema)
1473
1542
  });
1543
+ var TreasuryParams = TreasuryParamsSchema;
1474
1544
  var TreasuryRedeemerSchema = import_lucid16.Data.Enum([
1475
1545
  import_lucid16.Data.Literal("Withdraw"),
1476
1546
  import_lucid16.Data.Literal("PrepareWithdraw"),
@@ -1491,13 +1561,20 @@ function serialiseWithdrawalOutputDatum(d) {
1491
1561
  function serialiseTreasuryRedeemer(redeemer) {
1492
1562
  return import_lucid16.Data.to(redeemer, TreasuryRedeemer);
1493
1563
  }
1564
+ function serialiseTreasuryDatum() {
1565
+ return import_lucid16.Data.void();
1566
+ }
1567
+ function castTreasuryParams(params) {
1568
+ return import_lucid16.Data.castTo(params, TreasuryParams);
1569
+ }
1494
1570
 
1495
1571
  // src/contracts/treasury/transactions.ts
1496
- async function treasuryFeeTx(fee, lucid, sysParams, tx, treasuryOref) {
1572
+ async function treasuryFeeTx(fee, lucid, sysParams, tx, treasury) {
1497
1573
  if (fee <= 0n) return;
1498
- const treasuryUtxo = matchSingle(
1499
- await lucid.utxosByOutRef([treasuryOref]),
1500
- (_) => new Error("Expected a single treasury UTXO")
1574
+ const treasuryUtxo = await resolveUtxo(
1575
+ treasury,
1576
+ lucid,
1577
+ "Expected a single treasury UTXO"
1501
1578
  );
1502
1579
  const treasuryRefScriptUtxo = matchSingle(
1503
1580
  await lucid.utxosByOutRef([
@@ -1522,7 +1599,7 @@ async function treasuryFeeTx(fee, lucid, sysParams, tx, treasuryOref) {
1522
1599
  }
1523
1600
 
1524
1601
  // src/contracts/cdp/transactions.ts
1525
- async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreatorOref, iassetOref, priceOracleOref, interestOracleOref, collectorOref, lucid, currentSlot) {
1602
+ async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreator, iasset, priceOracle, interestOracle, collector, lucid, currentSlot) {
1526
1603
  const network = lucid.config().network;
1527
1604
  const currentTime = BigInt((0, import_lucid18.slotToUnixTime)(network, currentSlot));
1528
1605
  const [pkh, skh] = await addrDetails(lucid);
@@ -1550,30 +1627,34 @@ async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreatorOref
1550
1627
  ]),
1551
1628
  (_) => new Error("Expected a single iasset token policy Ref Script UTXO")
1552
1629
  );
1553
- const iassetUtxo = matchSingle(
1554
- await lucid.utxosByOutRef([iassetOref]),
1555
- (_) => new Error("Expected a single iasset UTXO")
1630
+ const iassetUtxo = await resolveUtxo(
1631
+ iasset,
1632
+ lucid,
1633
+ "Expected a single iasset UTXO"
1556
1634
  );
1557
1635
  const iassetDatum = parseIAssetDatumOrThrow(
1558
1636
  getInlineDatumOrThrow(iassetUtxo)
1559
1637
  );
1560
- const priceOracleUtxo = matchSingle(
1561
- await lucid.utxosByOutRef([priceOracleOref]),
1562
- (_) => new Error("Expected a single price oracle UTXO")
1638
+ const priceOracleUtxo = await resolveUtxo(
1639
+ priceOracle,
1640
+ lucid,
1641
+ "Expected a single price oracle UTXO"
1563
1642
  );
1564
1643
  const priceOracleDatum = parsePriceOracleDatum(
1565
1644
  getInlineDatumOrThrow(priceOracleUtxo)
1566
1645
  );
1567
- const interestOracleUtxo = matchSingle(
1568
- await lucid.utxosByOutRef([interestOracleOref]),
1569
- (_) => new Error("Expected a single interest oracle UTXO")
1646
+ const interestOracleUtxo = await resolveUtxo(
1647
+ interestOracle,
1648
+ lucid,
1649
+ "Expected a single interest oracle UTXO"
1570
1650
  );
1571
1651
  const interestOracleDatum = parseInterestOracleDatum(
1572
1652
  getInlineDatumOrThrow(interestOracleUtxo)
1573
1653
  );
1574
- const cdpCreatorUtxo = matchSingle(
1575
- await lucid.utxosByOutRef([cdpCreatorOref]),
1576
- (_) => new Error("Expected a single CDP creator UTXO")
1654
+ const cdpCreatorUtxo = await resolveUtxo(
1655
+ cdpCreator,
1656
+ lucid,
1657
+ "Expected a single CDP creator UTXO"
1577
1658
  );
1578
1659
  (0, import_ts_pattern7.match)(iassetDatum.price).with({ Delisted: import_ts_pattern7.P.any }, () => {
1579
1660
  throw new Error("Can't open CDP of delisted asset");
@@ -1640,11 +1721,11 @@ async function openCdp(collateralAmount, mintedAmount, sysParams, cdpCreatorOref
1640
1721
  mintedAmount * priceOracleDatum.price.getOnChainInt / 1000000n
1641
1722
  );
1642
1723
  if (debtMintingFee > 0) {
1643
- await collectorFeeTx(debtMintingFee, lucid, sysParams, tx, collectorOref);
1724
+ await collectorFeeTx(debtMintingFee, lucid, sysParams, tx, collector);
1644
1725
  }
1645
1726
  return tx;
1646
1727
  }
1647
- async function adjustCdp(collateralAmount, mintAmount, cdpOref, iassetOref, priceOracleOref, interestOracleOref, collectorOref, govOref, treasuryOref, sysParams, lucid, currentSlot) {
1728
+ async function adjustCdp(collateralAmount, mintAmount, cdp, iasset, priceOracle, interestOracle, collector, gov, treasury, sysParams, lucid, currentSlot) {
1648
1729
  const network = lucid.config().network;
1649
1730
  const currentTime = BigInt((0, import_lucid18.slotToUnixTime)(network, currentSlot));
1650
1731
  const cdpRefScriptUtxo = matchSingle(
@@ -1653,33 +1734,30 @@ async function adjustCdp(collateralAmount, mintAmount, cdpOref, iassetOref, pric
1653
1734
  ]),
1654
1735
  (_) => new Error("Expected a single cdp Ref Script UTXO")
1655
1736
  );
1656
- const cdpUtxo = matchSingle(
1657
- await lucid.utxosByOutRef([cdpOref]),
1658
- (_) => new Error("Expected a single cdp UTXO")
1659
- );
1737
+ const cdpUtxo = await resolveUtxo(cdp, lucid, "Expected a single cdp UTXO");
1660
1738
  const cdpDatum = parseCdpDatumOrThrow(getInlineDatumOrThrow(cdpUtxo));
1661
- const iassetUtxo = matchSingle(
1662
- await lucid.utxosByOutRef([iassetOref]),
1663
- (_) => new Error("Expected a single iasset UTXO")
1739
+ const iassetUtxo = await resolveUtxo(
1740
+ iasset,
1741
+ lucid,
1742
+ "Expected a single iasset UTXO"
1664
1743
  );
1665
1744
  const iassetDatum = parseIAssetDatumOrThrow(
1666
1745
  getInlineDatumOrThrow(iassetUtxo)
1667
1746
  );
1668
- const govUtxo = matchSingle(
1669
- await lucid.utxosByOutRef([govOref]),
1670
- (_) => new Error("Expected a single gov UTXO")
1671
- );
1747
+ const govUtxo = await resolveUtxo(gov, lucid, "Expected a single gov UTXO");
1672
1748
  const govDatum = parseGovDatumOrThrow(getInlineDatumOrThrow(govUtxo));
1673
- const priceOracleUtxo = matchSingle(
1674
- await lucid.utxosByOutRef([priceOracleOref]),
1675
- (_) => new Error("Expected a single price oracle UTXO")
1749
+ const priceOracleUtxo = await resolveUtxo(
1750
+ priceOracle,
1751
+ lucid,
1752
+ "Expected a single price oracle UTXO"
1676
1753
  );
1677
1754
  const priceOracleDatum = parsePriceOracleDatum(
1678
1755
  getInlineDatumOrThrow(priceOracleUtxo)
1679
1756
  );
1680
- const interestOracleUtxo = matchSingle(
1681
- await lucid.utxosByOutRef([interestOracleOref]),
1682
- (_) => new Error("Expected a single interest oracle UTXO")
1757
+ const interestOracleUtxo = await resolveUtxo(
1758
+ interestOracle,
1759
+ lucid,
1760
+ "Expected a single interest oracle UTXO"
1683
1761
  );
1684
1762
  const interestOracleDatum = parseInterestOracleDatum(
1685
1763
  getInlineDatumOrThrow(interestOracleUtxo)
@@ -1767,13 +1845,7 @@ async function adjustCdp(collateralAmount, mintAmount, cdpOref, iassetOref, pric
1767
1845
  );
1768
1846
  const interestTreasuryAdaAmt = interestAdaAmt - interestCollectorAdaAmt;
1769
1847
  if (interestTreasuryAdaAmt > 0) {
1770
- await treasuryFeeTx(
1771
- interestTreasuryAdaAmt,
1772
- lucid,
1773
- sysParams,
1774
- tx,
1775
- treasuryOref
1776
- );
1848
+ await treasuryFeeTx(interestTreasuryAdaAmt, lucid, sysParams, tx, treasury);
1777
1849
  }
1778
1850
  let collectorFee = interestCollectorAdaAmt;
1779
1851
  if (mintAmount > 0n) {
@@ -1789,75 +1861,75 @@ async function adjustCdp(collateralAmount, mintAmount, cdpOref, iassetOref, pric
1789
1861
  );
1790
1862
  }
1791
1863
  if (collectorFee > 0n) {
1792
- await collectorFeeTx(collectorFee, lucid, sysParams, tx, collectorOref);
1864
+ await collectorFeeTx(collectorFee, lucid, sysParams, tx, collector);
1793
1865
  }
1794
1866
  return tx;
1795
1867
  }
1796
- async function depositCdp(amount, cdpOref, iassetOref, priceOracleOref, interestOracleOref, collectorOref, govOref, treasuryOref, params, lucid, currentSlot) {
1868
+ async function depositCdp(amount, cdp, iasset, priceOracle, interestOracle, collector, gov, treasury, params, lucid, currentSlot) {
1797
1869
  return adjustCdp(
1798
1870
  amount,
1799
1871
  0n,
1800
- cdpOref,
1801
- iassetOref,
1802
- priceOracleOref,
1803
- interestOracleOref,
1804
- collectorOref,
1805
- govOref,
1806
- treasuryOref,
1872
+ cdp,
1873
+ iasset,
1874
+ priceOracle,
1875
+ interestOracle,
1876
+ collector,
1877
+ gov,
1878
+ treasury,
1807
1879
  params,
1808
1880
  lucid,
1809
1881
  currentSlot
1810
1882
  );
1811
1883
  }
1812
- async function withdrawCdp(amount, cdpOref, iassetOref, priceOracleOref, interestOracleOref, collectorOref, govOref, treasuryOref, params, lucid, currentSlot) {
1884
+ async function withdrawCdp(amount, cdp, iasset, priceOracle, interestOracle, collector, gov, treasury, params, lucid, currentSlot) {
1813
1885
  return adjustCdp(
1814
1886
  -amount,
1815
1887
  0n,
1816
- cdpOref,
1817
- iassetOref,
1818
- priceOracleOref,
1819
- interestOracleOref,
1820
- collectorOref,
1821
- govOref,
1822
- treasuryOref,
1888
+ cdp,
1889
+ iasset,
1890
+ priceOracle,
1891
+ interestOracle,
1892
+ collector,
1893
+ gov,
1894
+ treasury,
1823
1895
  params,
1824
1896
  lucid,
1825
1897
  currentSlot
1826
1898
  );
1827
1899
  }
1828
- async function mintCdp(amount, cdpOref, iassetOref, priceOracleOref, interestOracleOref, collectorOref, govOref, treasuryOref, params, lucid, currentSlot) {
1900
+ async function mintCdp(amount, cdp, iasset, priceOracle, interestOracle, collector, gov, treasury, params, lucid, currentSlot) {
1829
1901
  return adjustCdp(
1830
1902
  0n,
1831
1903
  amount,
1832
- cdpOref,
1833
- iassetOref,
1834
- priceOracleOref,
1835
- interestOracleOref,
1836
- collectorOref,
1837
- govOref,
1838
- treasuryOref,
1904
+ cdp,
1905
+ iasset,
1906
+ priceOracle,
1907
+ interestOracle,
1908
+ collector,
1909
+ gov,
1910
+ treasury,
1839
1911
  params,
1840
1912
  lucid,
1841
1913
  currentSlot
1842
1914
  );
1843
1915
  }
1844
- async function burnCdp(amount, cdpOref, iassetOref, priceOracleOref, interestOracleOref, collectorOref, govOref, treasuryOref, params, lucid, currentSlot) {
1916
+ async function burnCdp(amount, cdp, iasset, priceOracle, interestOracle, collector, gov, treasury, params, lucid, currentSlot) {
1845
1917
  return adjustCdp(
1846
1918
  0n,
1847
1919
  -amount,
1848
- cdpOref,
1849
- iassetOref,
1850
- priceOracleOref,
1851
- interestOracleOref,
1852
- collectorOref,
1853
- govOref,
1854
- treasuryOref,
1920
+ cdp,
1921
+ iasset,
1922
+ priceOracle,
1923
+ interestOracle,
1924
+ collector,
1925
+ gov,
1926
+ treasury,
1855
1927
  params,
1856
1928
  lucid,
1857
1929
  currentSlot
1858
1930
  );
1859
1931
  }
1860
- async function closeCdp(cdpOref, iassetOref, priceOracleOref, interestOracleOref, collectorOref, govOref, treasuryOref, sysParams, lucid, currentSlot) {
1932
+ async function closeCdp(cdp, iasset, priceOracle, interestOracle, collector, gov, treasury, sysParams, lucid, currentSlot) {
1861
1933
  const network = lucid.config().network;
1862
1934
  const currentTime = BigInt((0, import_lucid18.slotToUnixTime)(network, currentSlot));
1863
1935
  const cdpRefScriptUtxo = matchSingle(
@@ -1882,33 +1954,30 @@ async function closeCdp(cdpOref, iassetOref, priceOracleOref, interestOracleOref
1882
1954
  ]),
1883
1955
  (_) => new Error("Expected a single iasset token policy Ref Script UTXO")
1884
1956
  );
1885
- const cdpUtxo = matchSingle(
1886
- await lucid.utxosByOutRef([cdpOref]),
1887
- (_) => new Error("Expected a single cdp UTXO")
1888
- );
1957
+ const cdpUtxo = await resolveUtxo(cdp, lucid, "Expected a single cdp UTXO");
1889
1958
  const cdpDatum = parseCdpDatumOrThrow(getInlineDatumOrThrow(cdpUtxo));
1890
- const iassetUtxo = matchSingle(
1891
- await lucid.utxosByOutRef([iassetOref]),
1892
- (_) => new Error("Expected a single iasset UTXO")
1959
+ const iassetUtxo = await resolveUtxo(
1960
+ iasset,
1961
+ lucid,
1962
+ "Expected a single iasset UTXO"
1893
1963
  );
1894
1964
  const iassetDatum = parseIAssetDatumOrThrow(
1895
1965
  getInlineDatumOrThrow(iassetUtxo)
1896
1966
  );
1897
- const govUtxo = matchSingle(
1898
- await lucid.utxosByOutRef([govOref]),
1899
- (_) => new Error("Expected a single gov UTXO")
1900
- );
1967
+ const govUtxo = await resolveUtxo(gov, lucid, "Expected a single gov UTXO");
1901
1968
  const govDatum = parseGovDatumOrThrow(getInlineDatumOrThrow(govUtxo));
1902
- const priceOracleUtxo = matchSingle(
1903
- await lucid.utxosByOutRef([priceOracleOref]),
1904
- (_) => new Error("Expected a single price oracle UTXO")
1969
+ const priceOracleUtxo = await resolveUtxo(
1970
+ priceOracle,
1971
+ lucid,
1972
+ "Expected a single price oracle UTXO"
1905
1973
  );
1906
1974
  const priceOracleDatum = parsePriceOracleDatum(
1907
1975
  getInlineDatumOrThrow(priceOracleUtxo)
1908
1976
  );
1909
- const interestOracleUtxo = matchSingle(
1910
- await lucid.utxosByOutRef([interestOracleOref]),
1911
- (_) => new Error("Expected a single interest oracle UTXO")
1977
+ const interestOracleUtxo = await resolveUtxo(
1978
+ interestOracle,
1979
+ lucid,
1980
+ "Expected a single interest oracle UTXO"
1912
1981
  );
1913
1982
  const interestOracleDatum = parseInterestOracleDatum(
1914
1983
  getInlineDatumOrThrow(interestOracleUtxo)
@@ -1961,24 +2030,18 @@ async function closeCdp(cdpOref, iassetOref, priceOracleOref, interestOracleOref
1961
2030
  );
1962
2031
  const interestTreasuryAdaAmt = interestAdaAmt - interestCollectorAdaAmt;
1963
2032
  if (interestTreasuryAdaAmt > 0) {
1964
- await treasuryFeeTx(
1965
- interestTreasuryAdaAmt,
1966
- lucid,
1967
- sysParams,
1968
- tx,
1969
- treasuryOref
1970
- );
2033
+ await treasuryFeeTx(interestTreasuryAdaAmt, lucid, sysParams, tx, treasury);
1971
2034
  }
1972
2035
  const collectorFee = interestCollectorAdaAmt + calculateFeeFromPercentage(
1973
2036
  govDatum.protocolParams.collateralFeePercentage,
1974
2037
  lovelacesAmt(cdpUtxo.assets) - interestAdaAmt
1975
2038
  );
1976
2039
  if (collectorFee > 0n) {
1977
- await collectorFeeTx(collectorFee, lucid, sysParams, tx, collectorOref);
2040
+ await collectorFeeTx(collectorFee, lucid, sysParams, tx, collector);
1978
2041
  }
1979
2042
  return tx;
1980
2043
  }
1981
- async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, priceOracleOref, interestOracleOref, collectorOref, treasuryOref, sysParams, lucid, currentSlot) {
2044
+ async function redeemCdp(attemptedRedemptionIAssetAmt, cdp, iasset, priceOracle, interestOracle, collector, treasury, sysParams, lucid, currentSlot) {
1982
2045
  const network = lucid.config().network;
1983
2046
  const currentTime = BigInt((0, import_lucid18.slotToUnixTime)(network, currentSlot));
1984
2047
  const cdpRefScriptUtxo = matchSingle(
@@ -1995,28 +2058,28 @@ async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, pric
1995
2058
  ]),
1996
2059
  (_) => new Error("Expected a single iasset token policy Ref Script UTXO")
1997
2060
  );
1998
- const cdpUtxo = matchSingle(
1999
- await lucid.utxosByOutRef([cdpOref]),
2000
- (_) => new Error("Expected a single cdp UTXO")
2001
- );
2061
+ const cdpUtxo = await resolveUtxo(cdp, lucid, "Expected a single cdp UTXO");
2002
2062
  const cdpDatum = parseCdpDatumOrThrow(getInlineDatumOrThrow(cdpUtxo));
2003
- const iassetUtxo = matchSingle(
2004
- await lucid.utxosByOutRef([iassetOref]),
2005
- (_) => new Error("Expected a single iasset UTXO")
2063
+ const iassetUtxo = await resolveUtxo(
2064
+ iasset,
2065
+ lucid,
2066
+ "Expected a single iasset UTXO"
2006
2067
  );
2007
2068
  const iassetDatum = parseIAssetDatumOrThrow(
2008
2069
  getInlineDatumOrThrow(iassetUtxo)
2009
2070
  );
2010
- const priceOracleUtxo = matchSingle(
2011
- await lucid.utxosByOutRef([priceOracleOref]),
2012
- (_) => new Error("Expected a single price oracle UTXO")
2071
+ const priceOracleUtxo = await resolveUtxo(
2072
+ priceOracle,
2073
+ lucid,
2074
+ "Expected a single price oracle UTXO"
2013
2075
  );
2014
2076
  const priceOracleDatum = parsePriceOracleDatum(
2015
2077
  getInlineDatumOrThrow(priceOracleUtxo)
2016
2078
  );
2017
- const interestOracleUtxo = matchSingle(
2018
- await lucid.utxosByOutRef([interestOracleOref]),
2019
- (_) => new Error("Expected a single interest oracle UTXO")
2079
+ const interestOracleUtxo = await resolveUtxo(
2080
+ interestOracle,
2081
+ lucid,
2082
+ "Expected a single interest oracle UTXO"
2020
2083
  );
2021
2084
  const interestOracleDatum = parseInterestOracleDatum(
2022
2085
  getInlineDatumOrThrow(interestOracleUtxo)
@@ -2120,18 +2183,12 @@ async function redeemCdp(attemptedRedemptionIAssetAmt, cdpOref, iassetOref, pric
2120
2183
  lucid,
2121
2184
  sysParams,
2122
2185
  tx,
2123
- collectorOref
2124
- );
2125
- await treasuryFeeTx(
2126
- interestTreasuryAdaAmt,
2127
- lucid,
2128
- sysParams,
2129
- tx,
2130
- treasuryOref
2186
+ collector
2131
2187
  );
2188
+ await treasuryFeeTx(interestTreasuryAdaAmt, lucid, sysParams, tx, treasury);
2132
2189
  return tx;
2133
2190
  }
2134
- async function freezeCdp(cdpOref, iassetOref, priceOracleOref, interestOracleOref, sysParams, lucid, currentSlot) {
2191
+ async function freezeCdp(cdp, iasset, priceOracle, interestOracle, sysParams, lucid, currentSlot) {
2135
2192
  const network = lucid.config().network;
2136
2193
  const currentTime = BigInt((0, import_lucid18.slotToUnixTime)(network, currentSlot));
2137
2194
  const cdpRefScriptUtxo = matchSingle(
@@ -2140,28 +2197,28 @@ async function freezeCdp(cdpOref, iassetOref, priceOracleOref, interestOracleOre
2140
2197
  ]),
2141
2198
  (_) => new Error("Expected a single cdp Ref Script UTXO")
2142
2199
  );
2143
- const cdpUtxo = matchSingle(
2144
- await lucid.utxosByOutRef([cdpOref]),
2145
- (_) => new Error("Expected a single cdp UTXO")
2146
- );
2200
+ const cdpUtxo = await resolveUtxo(cdp, lucid, "Expected a single cdp UTXO");
2147
2201
  const cdpDatum = parseCdpDatumOrThrow(getInlineDatumOrThrow(cdpUtxo));
2148
- const iassetUtxo = matchSingle(
2149
- await lucid.utxosByOutRef([iassetOref]),
2150
- (_) => new Error("Expected a single iasset UTXO")
2202
+ const iassetUtxo = await resolveUtxo(
2203
+ iasset,
2204
+ lucid,
2205
+ "Expected a single iasset UTXO"
2151
2206
  );
2152
2207
  const iassetDatum = parseIAssetDatumOrThrow(
2153
2208
  getInlineDatumOrThrow(iassetUtxo)
2154
2209
  );
2155
- const priceOracleUtxo = matchSingle(
2156
- await lucid.utxosByOutRef([priceOracleOref]),
2157
- (_) => new Error("Expected a single price oracle UTXO")
2210
+ const priceOracleUtxo = await resolveUtxo(
2211
+ priceOracle,
2212
+ lucid,
2213
+ "Expected a single price oracle UTXO"
2158
2214
  );
2159
2215
  const priceOracleDatum = parsePriceOracleDatum(
2160
2216
  getInlineDatumOrThrow(priceOracleUtxo)
2161
2217
  );
2162
- const interestOracleUtxo = matchSingle(
2163
- await lucid.utxosByOutRef([interestOracleOref]),
2164
- (_) => new Error("Expected a single interest oracle UTXO")
2218
+ const interestOracleUtxo = await resolveUtxo(
2219
+ interestOracle,
2220
+ lucid,
2221
+ "Expected a single interest oracle UTXO"
2165
2222
  );
2166
2223
  const interestOracleDatum = parseInterestOracleDatum(
2167
2224
  getInlineDatumOrThrow(interestOracleUtxo)
@@ -2236,7 +2293,7 @@ async function freezeCdp(cdpOref, iassetOref, priceOracleOref, interestOracleOre
2236
2293
  cdpUtxo.assets
2237
2294
  );
2238
2295
  }
2239
- async function liquidateCdp(cdpOref, stabilityPoolOref, collectorOref, treasuryOref, sysParams, lucid) {
2296
+ async function liquidateCdp(cdp, stabilityPool, collector, treasury, sysParams, lucid) {
2240
2297
  const cdpRefScriptUtxo = matchSingle(
2241
2298
  await lucid.utxosByOutRef([
2242
2299
  fromSystemParamsScriptRef(sysParams.scriptReferences.cdpValidatorRef)
@@ -2267,14 +2324,12 @@ async function liquidateCdp(cdpOref, stabilityPoolOref, collectorOref, treasuryO
2267
2324
  ]),
2268
2325
  (_) => new Error("Expected a single cdp auth token policy Ref Script UTXO")
2269
2326
  );
2270
- const cdpUtxo = matchSingle(
2271
- await lucid.utxosByOutRef([cdpOref]),
2272
- (_) => new Error("Expected a single cdp UTXO")
2273
- );
2327
+ const cdpUtxo = await resolveUtxo(cdp, lucid, "Expected a single cdp UTXO");
2274
2328
  const cdpDatum = parseCdpDatumOrThrow(getInlineDatumOrThrow(cdpUtxo));
2275
- const spUtxo = matchSingle(
2276
- await lucid.utxosByOutRef([stabilityPoolOref]),
2277
- (_) => new Error("Expected a single stability pool UTXO")
2329
+ const spUtxo = await resolveUtxo(
2330
+ stabilityPool,
2331
+ lucid,
2332
+ "Expected a single stability pool UTXO"
2278
2333
  );
2279
2334
  const spDatum = parseStabilityPoolDatum(getInlineDatumOrThrow(spUtxo));
2280
2335
  const [lovelacesForTreasury, lovelacesForCollector] = (0, import_ts_pattern7.match)(cdpDatum.cdpFees).returnType().with({ FrozenCDPAccumulatedFees: import_ts_pattern7.P.select() }, (fees) => [
@@ -2344,14 +2399,8 @@ async function liquidateCdp(cdpOref, stabilityPoolOref, collectorOref, treasuryO
2344
2399
  import_lucid18.Data.void()
2345
2400
  );
2346
2401
  }
2347
- await collectorFeeTx(
2348
- lovelacesForCollector,
2349
- lucid,
2350
- sysParams,
2351
- tx,
2352
- collectorOref
2353
- );
2354
- await treasuryFeeTx(lovelacesForTreasury, lucid, sysParams, tx, treasuryOref);
2402
+ await collectorFeeTx(lovelacesForCollector, lucid, sysParams, tx, collector);
2403
+ await treasuryFeeTx(lovelacesForTreasury, lucid, sysParams, tx, treasury);
2355
2404
  return tx;
2356
2405
  }
2357
2406
  async function mergeCdps(cdpsToMergeUtxos, sysParams, lucid) {
@@ -2858,20 +2907,17 @@ function updateStakingLockedAmount(stakingPosLockedAmt, currentTime) {
2858
2907
  stakingPosLockedAmt.entries().filter(([_, { votingEnd }]) => votingEnd > currentTime)
2859
2908
  );
2860
2909
  }
2861
- function findStakingManagerByOutRef(stakingManagerRef, lucid) {
2862
- return lucid.utxosByOutRef([stakingManagerRef]).then(
2863
- (utxos) => utxos.map((utxo) => {
2864
- if (!utxo.datum) return void 0;
2865
- const datum = parseStakingManagerDatum(utxo.datum);
2866
- return { utxo, datum };
2867
- }).find((utxo) => utxo !== void 0)
2868
- ).then((result) => {
2869
- if (!result)
2870
- throw new Error(
2871
- "Unable to locate Staking Manager by output reference."
2872
- );
2873
- return result;
2874
- });
2910
+ async function findStakingManagerByOutRef(stakingManager, lucid) {
2911
+ const utxo = await resolveUtxo(
2912
+ stakingManager,
2913
+ lucid,
2914
+ "Unable to locate Staking Manager by output reference."
2915
+ );
2916
+ if (!utxo.datum) {
2917
+ throw new Error("Staking Manager UTxO has no datum.");
2918
+ }
2919
+ const datum = parseStakingManagerDatum(utxo.datum);
2920
+ return { utxo, datum };
2875
2921
  }
2876
2922
  function findStakingManager(params, lucid) {
2877
2923
  return lucid.utxosAtWithUnit(
@@ -2894,20 +2940,17 @@ function findStakingManager(params, lucid) {
2894
2940
  return result;
2895
2941
  });
2896
2942
  }
2897
- function findStakingPositionByOutRef(stakingPositionRef, lucid) {
2898
- return lucid.utxosByOutRef([stakingPositionRef]).then(
2899
- (utxos) => utxos.map((utxo) => {
2900
- if (!utxo.datum) return void 0;
2901
- const datum = parseStakingPositionOrThrow(utxo.datum);
2902
- return { utxo, datum };
2903
- }).find((utxo) => utxo !== void 0)
2904
- ).then((result) => {
2905
- if (!result)
2906
- throw new Error(
2907
- "Unable to locate Staking Position by output reference."
2908
- );
2909
- return result;
2910
- });
2943
+ async function findStakingPositionByOutRef(stakingPosition, lucid) {
2944
+ const utxo = await resolveUtxo(
2945
+ stakingPosition,
2946
+ lucid,
2947
+ "Unable to locate Staking Position by output reference."
2948
+ );
2949
+ if (!utxo.datum) {
2950
+ throw new Error("Staking Position UTxO has no datum.");
2951
+ }
2952
+ const datum = parseStakingPositionOrThrow(utxo.datum);
2953
+ return { utxo, datum };
2911
2954
  }
2912
2955
  var rewardSnapshotPrecision = OCD_DECIMAL_UNIT * OCD_DECIMAL_UNIT;
2913
2956
  function distributeReward(snapshotAda, adaReward, totalStake) {
@@ -3019,89 +3062,38 @@ var teamVestingSchedule = [
3019
3062
  }
3020
3063
  ];
3021
3064
  var spDistributionSchedule = {
3022
- maxUnlockable: 14000000n * OCD_DECIMAL_UNIT,
3065
+ maxUnlockable: 2013760n * OCD_DECIMAL_UNIT,
3023
3066
  schedule: [
3024
3067
  {
3025
3068
  vestedAtTime: 1669931100000n,
3026
3069
  unlockAmt: 28768n * OCD_DECIMAL_UNIT
3027
- },
3028
- {
3029
- vestedAtTime: 1701467100000n,
3030
- unlockAmt: 33562n * OCD_DECIMAL_UNIT
3031
- },
3032
- {
3033
- vestedAtTime: 1727387100000n,
3034
- unlockAmt: 33561n * OCD_DECIMAL_UNIT
3035
- },
3036
- {
3037
- vestedAtTime: 1733003100000n,
3038
- unlockAmt: 38356n * OCD_DECIMAL_UNIT
3039
- },
3040
- {
3041
- vestedAtTime: 1764539100000n,
3042
- unlockAmt: 43150n * OCD_DECIMAL_UNIT
3043
- },
3044
- {
3045
- vestedAtTime: 1796075100000n,
3046
- unlockAmt: 47945n * OCD_DECIMAL_UNIT
3047
3070
  }
3048
3071
  ]
3049
3072
  };
3050
3073
  var liqDistributionSchedule = {
3051
- maxUnlockable: 5250000n * OCD_DECIMAL_UNIT,
3074
+ maxUnlockable: 316470n * OCD_DECIMAL_UNIT,
3052
3075
  schedule: [
3053
3076
  {
3054
3077
  vestedAtTime: 1671659100000n,
3055
3078
  unlockAmt: 4795n * OCD_DECIMAL_UNIT
3056
- },
3057
- {
3058
- vestedAtTime: 1703195100000n,
3059
- unlockAmt: 9590n * OCD_DECIMAL_UNIT
3060
- },
3061
- {
3062
- vestedAtTime: 1728683100000n,
3063
- unlockAmt: 9589n * OCD_DECIMAL_UNIT
3064
- },
3065
- {
3066
- vestedAtTime: 1734731100000n,
3067
- unlockAmt: 14383n * OCD_DECIMAL_UNIT
3068
- },
3069
- {
3070
- vestedAtTime: 1766267100000n,
3071
- unlockAmt: 19178n * OCD_DECIMAL_UNIT
3072
- },
3079
+ }
3080
+ ]
3081
+ };
3082
+ var spLpDistributionSchedule = {
3083
+ maxUnlockable: 17016441n * OCD_DECIMAL_UNIT,
3084
+ schedule: [
3073
3085
  {
3074
- vestedAtTime: 1797803100000n,
3075
- unlockAmt: 23972n * OCD_DECIMAL_UNIT
3086
+ vestedAtTime: 1700171100000n,
3087
+ unlockAmt: 33563n * OCD_DECIMAL_UNIT
3076
3088
  }
3077
3089
  ]
3078
3090
  };
3079
3091
  var govDistributionSchedule = {
3080
- maxUnlockable: 1750000n * OCD_DECIMAL_UNIT,
3092
+ maxUnlockable: 1381248n * OCD_DECIMAL_UNIT,
3081
3093
  schedule: [
3082
3094
  {
3083
3095
  vestedAtTime: 1670363100000n,
3084
3096
  unlockAmt: 2398n * OCD_DECIMAL_UNIT
3085
- },
3086
- {
3087
- vestedAtTime: 1701899100000n,
3088
- unlockAmt: 3596n * OCD_DECIMAL_UNIT
3089
- },
3090
- {
3091
- vestedAtTime: 1733435100000n,
3092
- unlockAmt: 4795n * OCD_DECIMAL_UNIT
3093
- },
3094
- {
3095
- vestedAtTime: 1752443100000n,
3096
- unlockAmt: 4794n * OCD_DECIMAL_UNIT
3097
- },
3098
- {
3099
- vestedAtTime: 1764971100000n,
3100
- unlockAmt: 5993n * OCD_DECIMAL_UNIT
3101
- },
3102
- {
3103
- vestedAtTime: 1796507100000n,
3104
- unlockAmt: 7191n * OCD_DECIMAL_UNIT
3105
3097
  }
3106
3098
  ]
3107
3099
  };
@@ -3134,7 +3126,7 @@ function calculateVestedPerEpoch(schedule, currentTime) {
3134
3126
  return bigintMin(schedule.maxUnlockable, go(schedule.schedule));
3135
3127
  }
3136
3128
  function calculateTotalVestedRewards(currentTime) {
3137
- return calculateVestedPerEpoch(spDistributionSchedule, currentTime) + calculateVestedPerEpoch(govDistributionSchedule, currentTime) + calculateVestedPerEpoch(liqDistributionSchedule, currentTime);
3129
+ return calculateVestedPerEpoch(spDistributionSchedule, currentTime) + calculateVestedPerEpoch(govDistributionSchedule, currentTime) + calculateVestedPerEpoch(liqDistributionSchedule, currentTime) + calculateVestedPerEpoch(spLpDistributionSchedule, currentTime);
3138
3130
  }
3139
3131
 
3140
3132
  // src/contracts/poll/helpers.ts
@@ -3156,7 +3148,7 @@ function q(initialIndyDist, pollStatus, currentTime, treasuryIndyWithdrawnAmt) {
3156
3148
  )
3157
3149
  }
3158
3150
  ).getOnChainInt;
3159
- return { getOnChainInt: BigInt(q2) };
3151
+ return { getOnChainInt: BigInt(q2) / 1000n };
3160
3152
  }
3161
3153
  }
3162
3154
  function pollPassQuorum(initialIndyDist, pollStatus, currentTime, minQuorum, treasuryIndyWithdrawnAmt) {
@@ -3332,7 +3324,7 @@ function serialiseVersionRecordDatum(d) {
3332
3324
  }
3333
3325
 
3334
3326
  // src/contracts/gov/transactions.ts
3335
- async function createProposal(proposalContent, treasuryWithdrawal, sysParams, lucid, currentSlot, govOref, allIAssetOrefs) {
3327
+ async function createProposal(proposalContent, treasuryWithdrawal, sysParams, lucid, currentSlot, gov, allIAssetOrefs) {
3336
3328
  const network = lucid.config().network;
3337
3329
  const currentTime = BigInt((0, import_lucid30.slotToUnixTime)(network, currentSlot));
3338
3330
  const ownAddr = await lucid.wallet().address();
@@ -3353,10 +3345,7 @@ async function createProposal(proposalContent, treasuryWithdrawal, sysParams, lu
3353
3345
  ]),
3354
3346
  (_) => new Error("Expected a single poll auth token policy ref Script UTXO")
3355
3347
  );
3356
- const govUtxo = matchSingle(
3357
- await lucid.utxosByOutRef([govOref]),
3358
- (_) => new Error("Expected a single Gov UTXO")
3359
- );
3348
+ const govUtxo = await resolveUtxo(gov, lucid, "Expected a single Gov UTXO");
3360
3349
  const govDatum = parseGovDatumOrThrow(getInlineDatumOrThrow(govUtxo));
3361
3350
  const votingEndTime = currentTime + govDatum.protocolParams.votingPeriod;
3362
3351
  const expirationTime = votingEndTime + govDatum.protocolParams.expirationPeriod;
@@ -3450,18 +3439,19 @@ async function createProposal(proposalContent, treasuryWithdrawal, sysParams, lu
3450
3439
  newPollId
3451
3440
  ];
3452
3441
  }
3453
- async function createShardsChunks(chunkSize, pollManagerOref, sysParams, currentSlot, lucid) {
3442
+ async function createShardsChunks(chunkSize, pollManager, sysParams, currentSlot, lucid) {
3454
3443
  const network = lucid.config().network;
3455
3444
  const currentTime = BigInt((0, import_lucid30.slotToUnixTime)(network, currentSlot));
3456
3445
  const ownAddr = await lucid.wallet().address();
3457
- const pollManagerUtxo = matchSingle(
3458
- await lucid.utxosByOutRef([pollManagerOref]),
3459
- (_) => new Error("Expected a single Poll manager UTXO")
3446
+ const pollManagerUtxo = await resolveUtxo(
3447
+ pollManager,
3448
+ lucid,
3449
+ "Expected a single Poll manager UTXO"
3460
3450
  );
3461
- const pollManager = parsePollManagerOrThrow(
3451
+ const pollManagerDatum = parsePollManagerOrThrow(
3462
3452
  getInlineDatumOrThrow(pollManagerUtxo)
3463
3453
  );
3464
- if (pollManager.createdShardsCount >= pollManager.totalShardsCount) {
3454
+ if (pollManagerDatum.createdShardsCount >= pollManagerDatum.totalShardsCount) {
3465
3455
  throw new Error("All shards already created.");
3466
3456
  }
3467
3457
  const pollAuthTokenPolicyRefScriptUtxo = matchSingle(
@@ -3483,7 +3473,9 @@ async function createShardsChunks(chunkSize, pollManagerOref, sysParams, current
3483
3473
  const shardsCount = BigInt(
3484
3474
  Math.min(
3485
3475
  Number(chunkSize),
3486
- Number(pollManager.totalShardsCount - pollManager.createdShardsCount)
3476
+ Number(
3477
+ pollManagerDatum.totalShardsCount - pollManagerDatum.createdShardsCount
3478
+ )
3487
3479
  )
3488
3480
  );
3489
3481
  const pollNft = fromSystemParamsAsset(sysParams.govParams.pollToken);
@@ -3499,8 +3491,8 @@ async function createShardsChunks(chunkSize, pollManagerOref, sysParams, current
3499
3491
  value: serialisePollDatum({
3500
3492
  PollManager: {
3501
3493
  content: {
3502
- ...pollManager,
3503
- createdShardsCount: pollManager.createdShardsCount + shardsCount
3494
+ ...pollManagerDatum,
3495
+ createdShardsCount: pollManagerDatum.createdShardsCount + shardsCount
3504
3496
  }
3505
3497
  }
3506
3498
  })
@@ -3515,9 +3507,9 @@ async function createShardsChunks(chunkSize, pollManagerOref, sysParams, current
3515
3507
  value: serialisePollDatum({
3516
3508
  PollShard: {
3517
3509
  content: {
3518
- pollId: pollManager.pollId,
3510
+ pollId: pollManagerDatum.pollId,
3519
3511
  status: { yesVotes: 0n, noVotes: 0n },
3520
- votingEndTime: pollManager.votingEndTime,
3512
+ votingEndTime: pollManagerDatum.votingEndTime,
3521
3513
  managerAddress: addressFromBech32(pollManagerUtxo.address)
3522
3514
  }
3523
3515
  }
@@ -3545,7 +3537,7 @@ function voteHelper(stakingPosLockedAmt, pollShard, voteOption, currentTime, ind
3545
3537
  ];
3546
3538
  return [new Map(newLockedAmt), newPollStatus];
3547
3539
  }
3548
- async function vote(voteOption, pollShardOref, stakingPositionOref, sysParams, lucid, currentSlot) {
3540
+ async function vote(voteOption, pollShard, stakingPosition, sysParams, lucid, currentSlot) {
3549
3541
  const network = lucid.config().network;
3550
3542
  const currentTime = BigInt((0, import_lucid30.slotToUnixTime)(network, currentSlot));
3551
3543
  const ownAddr = await lucid.wallet().address();
@@ -3563,16 +3555,18 @@ async function vote(voteOption, pollShardOref, stakingPositionOref, sysParams, l
3563
3555
  ]),
3564
3556
  (_) => new Error("Expected a single staking ref Script UTXO")
3565
3557
  );
3566
- const pollShardUtxo = matchSingle(
3567
- await lucid.utxosByOutRef([pollShardOref]),
3568
- (_) => new Error("Expected a single Poll shard UTXO")
3558
+ const pollShardUtxo = await resolveUtxo(
3559
+ pollShard,
3560
+ lucid,
3561
+ "Expected a single Poll shard UTXO"
3569
3562
  );
3570
3563
  const pollShardDatum = parsePollShardOrThrow(
3571
3564
  getInlineDatumOrThrow(pollShardUtxo)
3572
3565
  );
3573
- const stakingPosUtxo = matchSingle(
3574
- await lucid.utxosByOutRef([stakingPositionOref]),
3575
- (_) => new Error("Expected a single staking position UTXO")
3566
+ const stakingPosUtxo = await resolveUtxo(
3567
+ stakingPosition,
3568
+ lucid,
3569
+ "Expected a single staking position UTXO"
3576
3570
  );
3577
3571
  const stakingPosDatum = parseStakingPositionOrThrow(
3578
3572
  getInlineDatumOrThrow(stakingPosUtxo)
@@ -3626,7 +3620,7 @@ async function vote(voteOption, pollShardOref, stakingPositionOref, sysParams, l
3626
3620
  stakingPosUtxo.assets
3627
3621
  ).addSigner(ownAddr);
3628
3622
  }
3629
- async function mergeShards(pollManagerOref, shardsOutRefs, sysParams, lucid, currentSlot) {
3623
+ async function mergeShards(pollManager, shardsOutRefs, sysParams, lucid, currentSlot) {
3630
3624
  const network = lucid.config().network;
3631
3625
  const currentTime = BigInt((0, import_lucid30.slotToUnixTime)(network, currentSlot));
3632
3626
  const ownAddr = await lucid.wallet().address();
@@ -3654,9 +3648,10 @@ async function mergeShards(pollManagerOref, shardsOutRefs, sysParams, lucid, cur
3654
3648
  ]),
3655
3649
  (_) => new Error("Expected a single poll auth token policy ref Script UTXO")
3656
3650
  );
3657
- const pollManagerUtxo = matchSingle(
3658
- await lucid.utxosByOutRef([pollManagerOref]),
3659
- (_) => new Error("Expected a single Poll manager UTXO")
3651
+ const pollManagerUtxo = await resolveUtxo(
3652
+ pollManager,
3653
+ lucid,
3654
+ "Expected a single Poll manager UTXO"
3660
3655
  );
3661
3656
  const pollManagerDatum = parsePollManagerOrThrow(
3662
3657
  getInlineDatumOrThrow(pollManagerUtxo)
@@ -3717,7 +3712,7 @@ async function mergeShards(pollManagerOref, shardsOutRefs, sysParams, lucid, cur
3717
3712
  (0, import_lucid30.addAssets)(pollManagerUtxo.assets, shardsAggregatedAda)
3718
3713
  ).addSigner(ownAddr);
3719
3714
  }
3720
- async function endProposal(pollManagerOref, govOref, sysParams, lucid, currentSlot) {
3715
+ async function endProposal(pollManager, gov, sysParams, lucid, currentSlot) {
3721
3716
  const network = lucid.config().network;
3722
3717
  const currentTime = BigInt((0, import_lucid30.slotToUnixTime)(network, currentSlot));
3723
3718
  const ownAddr = await lucid.wallet().address();
@@ -3753,28 +3748,26 @@ async function endProposal(pollManagerOref, govOref, sysParams, lucid, currentSl
3753
3748
  ]),
3754
3749
  (_) => new Error("Expected a single upgrade auth token policy ref Script UTXO")
3755
3750
  );
3756
- const pollManagerUtxo = matchSingle(
3757
- await lucid.utxosByOutRef([pollManagerOref]),
3758
- (_) => new Error("Expected a single Poll manager UTXO")
3751
+ const pollManagerUtxo = await resolveUtxo(
3752
+ pollManager,
3753
+ lucid,
3754
+ "Expected a single Poll manager UTXO"
3759
3755
  );
3760
- const pollManager = parsePollManagerOrThrow(
3756
+ const pollManagerDatum = parsePollManagerOrThrow(
3761
3757
  getInlineDatumOrThrow(pollManagerUtxo)
3762
3758
  );
3763
- const govUtxo = matchSingle(
3764
- await lucid.utxosByOutRef([govOref]),
3765
- (_) => new Error("Expected a single Gov UTXO")
3766
- );
3759
+ const govUtxo = await resolveUtxo(gov, lucid, "Expected a single Gov UTXO");
3767
3760
  const govDatum = parseGovDatumOrThrow(getInlineDatumOrThrow(govUtxo));
3768
3761
  const pollNft = fromSystemParamsAsset(sysParams.govParams.pollToken);
3769
3762
  const indyAsset = fromSystemParamsAsset(
3770
3763
  sysParams.pollManagerParams.indyAsset
3771
3764
  );
3772
- const proposalExpired = currentTime > pollManager.expirationTime;
3765
+ const proposalExpired = currentTime > pollManagerDatum.expirationTime;
3773
3766
  const proposalPassed = !proposalExpired && pollPassQuorum(
3774
3767
  sysParams.pollManagerParams.initialIndyDistribution,
3775
- pollManager.status,
3768
+ pollManagerDatum.status,
3776
3769
  currentTime,
3777
- pollManager.minimumQuorum,
3770
+ pollManagerDatum.minimumQuorum,
3778
3771
  govDatum.treasuryIndyWithdrawnAmt
3779
3772
  );
3780
3773
  const upgradeTokenVal = mkAssetsOf(
@@ -3811,12 +3804,12 @@ async function endProposal(pollManagerOref, govOref, sysParams, lucid, currentSl
3811
3804
  {
3812
3805
  kind: "inline",
3813
3806
  value: serialiseExecuteDatum({
3814
- id: pollManager.pollId,
3815
- content: pollManager.content,
3807
+ id: pollManagerDatum.pollId,
3808
+ content: pollManagerDatum.content,
3816
3809
  passedTime: currentTime,
3817
- votingEndTime: pollManager.votingEndTime,
3818
- protocolVersion: pollManager.protocolVersion,
3819
- treasuryWithdrawal: pollManager.treasuryWithdrawal
3810
+ votingEndTime: pollManagerDatum.votingEndTime,
3811
+ protocolVersion: pollManagerDatum.protocolVersion,
3812
+ treasuryWithdrawal: pollManagerDatum.treasuryWithdrawal
3820
3813
  })
3821
3814
  },
3822
3815
  upgradeTokenVal
@@ -3833,14 +3826,11 @@ async function endProposal(pollManagerOref, govOref, sysParams, lucid, currentSl
3833
3826
  }
3834
3827
  return tx;
3835
3828
  }
3836
- async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, allIAssetOrefs, modifyIAssetOref, sysParams, lucid, currentSlot) {
3829
+ async function executeProposal(execute, gov, treasuryWithdrawal, allIAssetOrefs, modifyIAsset, sysParams, lucid, currentSlot) {
3837
3830
  const network = lucid.config().network;
3838
3831
  const currentTime = BigInt((0, import_lucid30.slotToUnixTime)(network, currentSlot));
3839
3832
  const ownAddr = await lucid.wallet().address();
3840
- const govUtxo = matchSingle(
3841
- await lucid.utxosByOutRef([govOref]),
3842
- (_) => new Error("Expected a single gov UTXO")
3843
- );
3833
+ const govUtxo = await resolveUtxo(gov, lucid, "Expected a single gov UTXO");
3844
3834
  const govDatum = parseGovDatumOrThrow(getInlineDatumOrThrow(govUtxo));
3845
3835
  const govRefScriptUtxo = matchSingle(
3846
3836
  await lucid.utxosByOutRef([
@@ -3864,9 +3854,10 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
3864
3854
  ]),
3865
3855
  (_) => new Error("Expected a single upgrade auth token policy ref Script UTXO")
3866
3856
  );
3867
- const executeUtxo = matchSingle(
3868
- await lucid.utxosByOutRef([executeOref]),
3869
- (_) => new Error("Expected a single execute UTXO")
3857
+ const executeUtxo = await resolveUtxo(
3858
+ execute,
3859
+ lucid,
3860
+ "Expected a single execute UTXO"
3870
3861
  );
3871
3862
  const executeDatum = parseExecuteDatumOrThrow(
3872
3863
  getInlineDatumOrThrow(executeUtxo)
@@ -3884,13 +3875,13 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
3884
3875
  import_fp_ts10.option.fromNullable(executeDatum.treasuryWithdrawal),
3885
3876
  import_fp_ts10.option.match(
3886
3877
  () => {
3887
- if (treasuryWithdrawalOref) {
3878
+ if (treasuryWithdrawal) {
3888
3879
  throw new Error("Cannot provide withdrawal oref when no withdrawal.");
3889
3880
  }
3890
3881
  return Promise.resolve();
3891
3882
  },
3892
3883
  async (withdrawal) => {
3893
- if (!treasuryWithdrawalOref) {
3884
+ if (!treasuryWithdrawal) {
3894
3885
  throw new Error("Have to provide withdrawal oref when withdrawal.");
3895
3886
  }
3896
3887
  const treasuryRefScriptUtxo = matchSingle(
@@ -3901,9 +3892,10 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
3901
3892
  ]),
3902
3893
  (_) => new Error("Expected a single Treasury Ref Script UTXO")
3903
3894
  );
3904
- const treasuryWithdrawalUtxo = matchSingle(
3905
- await lucid.utxosByOutRef([treasuryWithdrawalOref]),
3906
- (_) => new Error("Expected a single withdrawal UTXO")
3895
+ const treasuryWithdrawalUtxo = await resolveUtxo(
3896
+ treasuryWithdrawal,
3897
+ lucid,
3898
+ "Expected a single withdrawal UTXO"
3907
3899
  );
3908
3900
  const withdrawalVal = createValueFromWithdrawal(withdrawal);
3909
3901
  const withdrawalChangeVal = (0, import_lucid30.addAssets)(
@@ -4066,12 +4058,13 @@ async function executeProposal(executeOref, govOref, treasuryWithdrawalOref, all
4066
4058
  ]),
4067
4059
  (_) => new Error("Expected a single CDP Ref Script UTXO")
4068
4060
  );
4069
- if (!modifyIAssetOref) {
4061
+ if (!modifyIAsset) {
4070
4062
  throw new Error("Have to provide iasset oref when modify asset.");
4071
4063
  }
4072
- const iassetUtxo = matchSingle(
4073
- await lucid.utxosByOutRef([modifyIAssetOref]),
4074
- (_) => new Error("Expected a single iasset UTXO")
4064
+ const iassetUtxo = await resolveUtxo(
4065
+ modifyIAsset,
4066
+ lucid,
4067
+ "Expected a single iasset UTXO"
4075
4068
  );
4076
4069
  const iassetDatum = parseIAssetDatumOrThrow(
4077
4070
  getInlineDatumOrThrow(iassetUtxo)
@@ -4400,7 +4393,7 @@ async function closeSpAccount(accountUtxo, params, lucid) {
4400
4393
  }
4401
4394
  ).addSignerKey((0, import_lucid34.toHex)(oldAccountDatum.owner));
4402
4395
  }
4403
- async function processSpRequest(asset, stabilityPoolUtxo, accountUtxo, govUtxo, iAssetUtxo, newSnapshotUtxo, params, lucid, collectorOref) {
4396
+ async function processSpRequest(asset, stabilityPoolUtxo, accountUtxo, govUtxo, iAssetUtxo, newSnapshotUtxo, params, lucid, collector) {
4404
4397
  const redeemer = {
4405
4398
  ProcessRequest: {
4406
4399
  txHash: { hash: (0, import_lucid34.fromHex)(accountUtxo.txHash) },
@@ -4583,13 +4576,7 @@ async function processSpRequest(asset, stabilityPoolUtxo, accountUtxo, govUtxo,
4583
4576
  newPoolSum
4584
4577
  );
4585
4578
  if (rewardLovelacesFee > 0n) {
4586
- await collectorFeeTx(
4587
- rewardLovelacesFee,
4588
- lucid,
4589
- params,
4590
- tx,
4591
- collectorOref
4592
- );
4579
+ await collectorFeeTx(rewardLovelacesFee, lucid, params, tx, collector);
4593
4580
  }
4594
4581
  tx.readFrom([govUtxo, iAssetUtxo, ...refInputs]);
4595
4582
  tx.pay.ToContract(
@@ -4700,7 +4687,7 @@ async function processSpRequest(asset, stabilityPoolUtxo, accountUtxo, govUtxo,
4700
4687
  params.scriptReferences.authTokenPolicies.accountTokenRef,
4701
4688
  lucid
4702
4689
  );
4703
- await collectorFeeTx(rewardLovelacesFee, lucid, params, tx, collectorOref);
4690
+ await collectorFeeTx(rewardLovelacesFee, lucid, params, tx, collector);
4704
4691
  tx.readFrom([govUtxo, iAssetUtxo, accountTokenRef, ...refInputs]);
4705
4692
  tx.mintAssets(
4706
4693
  {
@@ -4791,9 +4778,16 @@ async function annulRequest(accountUtxo, params, lucid) {
4791
4778
 
4792
4779
  // src/contracts/staking/transactions.ts
4793
4780
  var import_lucid35 = require("@lucid-evolution/lucid");
4794
- async function openStakingPosition(amount, params, lucid, stakingManagerRef) {
4781
+ async function openStakingPosition(amount, params, lucid, stakingManager) {
4795
4782
  const [pkh, _] = await addrDetails(lucid);
4796
- const stakingManagerOut = stakingManagerRef ? await findStakingManagerByOutRef(stakingManagerRef, lucid) : await findStakingManager(params, lucid);
4783
+ const stakingManagerUtxo = await resolveUtxo(
4784
+ stakingManager,
4785
+ lucid,
4786
+ "Expected a single staking manager UTXO"
4787
+ );
4788
+ const stakingManagerDatum = parseStakingManagerDatum(
4789
+ getInlineDatumOrThrow(stakingManagerUtxo)
4790
+ );
4797
4791
  const stakingRefScriptUtxo = matchSingle(
4798
4792
  await lucid.utxosByOutRef([
4799
4793
  fromSystemParamsScriptRef(params.scriptReferences.stakingValidatorRef)
@@ -4809,39 +4803,39 @@ async function openStakingPosition(amount, params, lucid, stakingManagerRef) {
4809
4803
  (_2) => new Error("Expected a single staking token policy Ref Script UTXO")
4810
4804
  );
4811
4805
  const newStakingManagerDatum = {
4812
- totalStake: stakingManagerOut.datum.totalStake + amount,
4806
+ totalStake: stakingManagerDatum.totalStake + amount,
4813
4807
  managerSnapshot: {
4814
- snapshotAda: stakingManagerOut.datum.managerSnapshot.snapshotAda
4808
+ snapshotAda: stakingManagerDatum.managerSnapshot.snapshotAda
4815
4809
  }
4816
4810
  };
4817
4811
  const stakingPositionDatum = {
4818
4812
  owner: (0, import_lucid35.fromHex)(pkh.hash),
4819
4813
  lockedAmount: /* @__PURE__ */ new Map([]),
4820
4814
  positionSnapshot: {
4821
- snapshotAda: stakingManagerOut.datum.managerSnapshot.snapshotAda
4815
+ snapshotAda: stakingManagerDatum.managerSnapshot.snapshotAda
4822
4816
  }
4823
4817
  };
4824
4818
  const stakingToken = params.stakingParams.stakingToken[0].unCurrencySymbol + (0, import_lucid35.fromText)(params.stakingParams.stakingToken[1].unTokenName);
4825
4819
  const indyToken = params.stakingParams.indyToken[0].unCurrencySymbol + (0, import_lucid35.fromText)(params.stakingParams.indyToken[1].unTokenName);
4826
4820
  return lucid.newTx().collectFrom(
4827
- [stakingManagerOut.utxo],
4821
+ [stakingManagerUtxo],
4828
4822
  serialiseStakingRedeemer({
4829
4823
  CreateStakingPosition: { creatorPkh: pkh.hash }
4830
4824
  })
4831
4825
  ).readFrom([stakingRefScriptUtxo]).pay.ToContract(
4832
- stakingManagerOut.utxo.address,
4826
+ stakingManagerUtxo.address,
4833
4827
  {
4834
4828
  kind: "inline",
4835
4829
  value: serialiseStakingDatum(newStakingManagerDatum)
4836
4830
  },
4837
- stakingManagerOut.utxo.assets
4831
+ stakingManagerUtxo.assets
4838
4832
  ).readFrom([stakingTokenPolicyRefScriptUtxo]).mintAssets(
4839
4833
  {
4840
4834
  [stakingToken]: 1n
4841
4835
  },
4842
4836
  import_lucid35.Data.void()
4843
4837
  ).pay.ToContract(
4844
- stakingManagerOut.utxo.address,
4838
+ stakingManagerUtxo.address,
4845
4839
  {
4846
4840
  kind: "inline",
4847
4841
  value: serialiseStakingDatum(stakingPositionDatum)
@@ -4852,14 +4846,25 @@ async function openStakingPosition(amount, params, lucid, stakingManagerRef) {
4852
4846
  }
4853
4847
  ).addSignerKey(pkh.hash);
4854
4848
  }
4855
- async function adjustStakingPosition(stakingPositionRef, amount, params, lucid, currentSlot, stakingManagerRef) {
4849
+ async function adjustStakingPosition(stakingPosition, amount, params, lucid, currentSlot, stakingManager) {
4856
4850
  const network = lucid.config().network;
4857
4851
  const currentTime = (0, import_lucid35.slotToUnixTime)(network, currentSlot) - 120 * ONE_SECOND;
4858
- const stakingPositionOut = await findStakingPositionByOutRef(
4859
- stakingPositionRef,
4860
- lucid
4852
+ const stakingPositionUtxo = await resolveUtxo(
4853
+ stakingPosition,
4854
+ lucid,
4855
+ "Expected a single staking position UTXO"
4856
+ );
4857
+ const stakingPositionDatum = parseStakingPositionOrThrow(
4858
+ getInlineDatumOrThrow(stakingPositionUtxo)
4859
+ );
4860
+ const stakingManagerUtxo = await resolveUtxo(
4861
+ stakingManager,
4862
+ lucid,
4863
+ "Expected a single staking manager UTXO"
4864
+ );
4865
+ const stakingManagerDatum = parseStakingManagerDatum(
4866
+ getInlineDatumOrThrow(stakingManagerUtxo)
4861
4867
  );
4862
- const stakingManagerOut = stakingManagerRef ? await findStakingManagerByOutRef(stakingManagerRef, lucid) : await findStakingManager(params, lucid);
4863
4868
  const stakingRefScriptUtxo = matchSingle(
4864
4869
  await lucid.utxosByOutRef([
4865
4870
  fromSystemParamsScriptRef(params.scriptReferences.stakingValidatorRef)
@@ -4867,44 +4872,44 @@ async function adjustStakingPosition(stakingPositionRef, amount, params, lucid,
4867
4872
  (_) => new Error("Expected a single staking Ref Script UTXO")
4868
4873
  );
4869
4874
  const indyToken = params.stakingParams.indyToken[0].unCurrencySymbol + (0, import_lucid35.fromText)(params.stakingParams.indyToken[1].unTokenName);
4870
- const existingIndyAmount = stakingPositionOut.utxo.assets[indyToken] ?? 0n;
4871
- const currentSnapshotAda = stakingManagerOut.datum.managerSnapshot.snapshotAda;
4872
- const oldSnapshotAda = stakingPositionOut.datum.positionSnapshot.snapshotAda;
4875
+ const existingIndyAmount = stakingPositionUtxo.assets[indyToken] ?? 0n;
4876
+ const currentSnapshotAda = stakingManagerDatum.managerSnapshot.snapshotAda;
4877
+ const oldSnapshotAda = stakingPositionDatum.positionSnapshot.snapshotAda;
4873
4878
  const adaReward = (currentSnapshotAda - oldSnapshotAda) * existingIndyAmount / rewardSnapshotPrecision;
4874
4879
  const newLockedAmount = updateStakingLockedAmount(
4875
- stakingPositionOut.datum.lockedAmount,
4880
+ stakingPositionDatum.lockedAmount,
4876
4881
  BigInt(currentTime)
4877
4882
  );
4878
4883
  return lucid.newTx().validFrom(currentTime).readFrom([stakingRefScriptUtxo]).collectFrom(
4879
- [stakingPositionOut.utxo],
4884
+ [stakingPositionUtxo],
4880
4885
  serialiseStakingRedeemer({
4881
4886
  AdjustStakedAmount: { adjustAmount: amount }
4882
4887
  })
4883
4888
  ).collectFrom(
4884
- [stakingManagerOut.utxo],
4889
+ [stakingManagerUtxo],
4885
4890
  serialiseStakingRedeemer("UpdateTotalStake")
4886
4891
  ).pay.ToContract(
4887
- stakingManagerOut.utxo.address,
4892
+ stakingManagerUtxo.address,
4888
4893
  {
4889
4894
  kind: "inline",
4890
4895
  value: serialiseStakingDatum({
4891
- ...stakingManagerOut.datum,
4892
- totalStake: stakingManagerOut.datum.totalStake + amount
4896
+ ...stakingManagerDatum,
4897
+ totalStake: stakingManagerDatum.totalStake + amount
4893
4898
  })
4894
4899
  },
4895
- (0, import_lucid35.addAssets)(stakingManagerOut.utxo.assets, mkLovelacesOf(-adaReward))
4900
+ (0, import_lucid35.addAssets)(stakingManagerUtxo.assets, mkLovelacesOf(-adaReward))
4896
4901
  ).pay.ToContract(
4897
- stakingPositionOut.utxo.address,
4902
+ stakingPositionUtxo.address,
4898
4903
  {
4899
4904
  kind: "inline",
4900
4905
  value: serialiseStakingDatum({
4901
- ...stakingPositionOut.datum,
4906
+ ...stakingPositionDatum,
4902
4907
  lockedAmount: newLockedAmount,
4903
- positionSnapshot: stakingManagerOut.datum.managerSnapshot
4908
+ positionSnapshot: stakingManagerDatum.managerSnapshot
4904
4909
  })
4905
4910
  },
4906
4911
  (0, import_lucid35.addAssets)(
4907
- stakingPositionOut.utxo.assets,
4912
+ stakingPositionUtxo.assets,
4908
4913
  mkAssetsOf(
4909
4914
  {
4910
4915
  currencySymbol: params.stakingParams.indyToken[0].unCurrencySymbol,
@@ -4913,16 +4918,27 @@ async function adjustStakingPosition(stakingPositionRef, amount, params, lucid,
4913
4918
  amount
4914
4919
  )
4915
4920
  )
4916
- ).addSignerKey((0, import_lucid35.toHex)(stakingPositionOut.datum.owner));
4921
+ ).addSignerKey((0, import_lucid35.toHex)(stakingPositionDatum.owner));
4917
4922
  }
4918
- async function closeStakingPosition(stakingPositionRef, params, lucid, currentSlot, stakingManagerRef) {
4923
+ async function closeStakingPosition(stakingPosition, params, lucid, currentSlot, stakingManager) {
4919
4924
  const network = lucid.config().network;
4920
4925
  const currentTime = (0, import_lucid35.slotToUnixTime)(network, currentSlot) - ONE_SECOND;
4921
- const stakingPositionOut = await findStakingPositionByOutRef(
4922
- stakingPositionRef,
4923
- lucid
4926
+ const stakingPositionUtxo = await resolveUtxo(
4927
+ stakingPosition,
4928
+ lucid,
4929
+ "Expected a single staking position UTXO"
4930
+ );
4931
+ const stakingPositionDatum = parseStakingPositionOrThrow(
4932
+ getInlineDatumOrThrow(stakingPositionUtxo)
4933
+ );
4934
+ const stakingManagerUtxo = await resolveUtxo(
4935
+ stakingManager,
4936
+ lucid,
4937
+ "Expected a single staking manager UTXO"
4938
+ );
4939
+ const stakingManagerDatum = parseStakingManagerDatum(
4940
+ getInlineDatumOrThrow(stakingManagerUtxo)
4924
4941
  );
4925
- const stakingManagerOut = stakingManagerRef ? await findStakingManagerByOutRef(stakingManagerRef, lucid) : await findStakingManager(params, lucid);
4926
4942
  const stakingRefScriptUtxo = matchSingle(
4927
4943
  await lucid.utxosByOutRef([
4928
4944
  fromSystemParamsScriptRef(params.scriptReferences.stakingValidatorRef)
@@ -4939,33 +4955,37 @@ async function closeStakingPosition(stakingPositionRef, params, lucid, currentSl
4939
4955
  );
4940
4956
  const stakingToken = params.stakingParams.stakingToken[0].unCurrencySymbol + (0, import_lucid35.fromText)(params.stakingParams.stakingToken[1].unTokenName);
4941
4957
  const indyToken = params.stakingParams.indyToken[0].unCurrencySymbol + (0, import_lucid35.fromText)(params.stakingParams.indyToken[1].unTokenName);
4942
- const existingIndyAmount = stakingPositionOut.utxo.assets[indyToken] ?? 0n;
4943
- const currentSnapshotAda = stakingManagerOut.datum.managerSnapshot.snapshotAda;
4944
- const oldSnapshotAda = stakingPositionOut.datum.positionSnapshot.snapshotAda;
4958
+ const existingIndyAmount = stakingPositionUtxo.assets[indyToken] ?? 0n;
4959
+ const currentSnapshotAda = stakingManagerDatum.managerSnapshot.snapshotAda;
4960
+ const oldSnapshotAda = stakingPositionDatum.positionSnapshot.snapshotAda;
4945
4961
  const adaReward = (currentSnapshotAda - oldSnapshotAda) * existingIndyAmount / (1000000n * 1000000n);
4946
- return lucid.newTx().validFrom(currentTime).readFrom([stakingRefScriptUtxo, stakingTokenPolicyRefScriptUtxo]).collectFrom([stakingPositionOut.utxo], serialiseStakingRedeemer("Unstake")).collectFrom(
4947
- [stakingManagerOut.utxo],
4962
+ return lucid.newTx().validFrom(currentTime).readFrom([stakingRefScriptUtxo, stakingTokenPolicyRefScriptUtxo]).collectFrom([stakingPositionUtxo], serialiseStakingRedeemer("Unstake")).collectFrom(
4963
+ [stakingManagerUtxo],
4948
4964
  serialiseStakingRedeemer("UpdateTotalStake")
4949
4965
  ).pay.ToContract(
4950
- stakingManagerOut.utxo.address,
4966
+ stakingManagerUtxo.address,
4951
4967
  {
4952
4968
  kind: "inline",
4953
4969
  value: serialiseStakingDatum({
4954
- ...stakingManagerOut.datum,
4955
- totalStake: stakingManagerOut.datum.totalStake - existingIndyAmount
4970
+ ...stakingManagerDatum,
4971
+ totalStake: stakingManagerDatum.totalStake - existingIndyAmount
4956
4972
  })
4957
4973
  },
4958
- (0, import_lucid35.addAssets)(stakingManagerOut.utxo.assets, mkLovelacesOf(-adaReward))
4974
+ (0, import_lucid35.addAssets)(stakingManagerUtxo.assets, mkLovelacesOf(-adaReward))
4959
4975
  ).mintAssets(
4960
4976
  {
4961
4977
  [stakingToken]: -1n
4962
4978
  },
4963
4979
  import_lucid35.Data.void()
4964
- ).addSignerKey((0, import_lucid35.toHex)(stakingPositionOut.datum.owner));
4980
+ ).addSignerKey((0, import_lucid35.toHex)(stakingPositionDatum.owner));
4965
4981
  }
4966
4982
  var MIN_UTXO_AMOUNT = 2000000n;
4967
- async function distributeAda(stakingManagerRef, collectorRefs, params, lucid) {
4968
- const [stakingManagerUtxo] = await lucid.utxosByOutRef([stakingManagerRef]);
4983
+ async function distributeAda(stakingManager, collectorRefs, params, lucid) {
4984
+ const stakingManagerUtxo = await resolveUtxo(
4985
+ stakingManager,
4986
+ lucid,
4987
+ "Expected a single staking manager UTXO"
4988
+ );
4969
4989
  const stakingManagerDatum = parseStakingManagerDatum(
4970
4990
  getInlineDatumOrThrow(stakingManagerUtxo)
4971
4991
  );
@@ -5123,16 +5143,16 @@ async function findInterestOracle(lucid, interestNft) {
5123
5143
  }
5124
5144
 
5125
5145
  // src/contracts/interest-oracle/transactions.ts
5126
- async function startInterestOracle(initialUnitaryInterest, initialInterestRate, initialLastInterestUpdate, oracleParams, lucid, interestTokenName, withScriptRef = false, refOutRef) {
5146
+ async function startInterestOracle(initialUnitaryInterest, initialInterestRate, initialLastInterestUpdate, oracleParams, lucid, interestTokenName, withScriptRef = false, refUtxo) {
5127
5147
  const network = lucid.config().network;
5128
5148
  const tokenName = interestTokenName ?? "INTEREST_ORACLE";
5129
- if (!refOutRef) {
5130
- refOutRef = (await lucid.wallet().getUtxos())[0];
5149
+ if (!refUtxo) {
5150
+ refUtxo = (await lucid.wallet().getUtxos())[0];
5131
5151
  }
5132
5152
  const [tx, policyId] = await oneShotMintTx(lucid, {
5133
5153
  referenceOutRef: {
5134
- txHash: refOutRef.txHash,
5135
- outputIdx: BigInt(refOutRef.outputIndex)
5154
+ txHash: refUtxo.txHash,
5155
+ outputIdx: BigInt(refUtxo.outputIndex)
5136
5156
  },
5137
5157
  mintAmounts: [
5138
5158
  {
@@ -5696,21 +5716,18 @@ async function openLrp(assetTokenName, lovelacesAmt2, maxPrice, lucid, sysParams
5696
5716
  { lovelace: lovelacesAmt2 + MIN_LRP_COLLATERAL_AMT }
5697
5717
  );
5698
5718
  }
5699
- async function cancelLrp(lrpOutRef, sysParams, lucid) {
5719
+ async function cancelLrp(lrp, sysParams, lucid) {
5700
5720
  const lrpScriptRefUtxo = matchSingle(
5701
5721
  await lucid.utxosByOutRef([
5702
5722
  fromSystemParamsScriptRef(sysParams.scriptReferences.lrpValidatorRef)
5703
5723
  ]),
5704
5724
  (_) => new Error("Expected a single LRP Ref Script UTXO")
5705
5725
  );
5706
- const lrpUtxo = matchSingle(
5707
- await lucid.utxosByOutRef([lrpOutRef]),
5708
- (_) => new Error("Expected a single LRP UTXO.")
5709
- );
5726
+ const lrpUtxo = await resolveUtxo(lrp, lucid, "Expected a single LRP UTXO.");
5710
5727
  const lrpDatum = parseLrpDatumOrThrow(getInlineDatumOrThrow(lrpUtxo));
5711
5728
  return lucid.newTx().readFrom([lrpScriptRefUtxo]).collectFrom([lrpUtxo], serialiseLrpRedeemer("Cancel")).addSignerKey(lrpDatum.owner);
5712
5729
  }
5713
- async function redeemLrp(redemptionLrpsData, priceOracleOutRef, iassetOutRef, lucid, sysParams) {
5730
+ async function redeemLrp(redemptionLrpsData, priceOracle, iasset, lucid, sysParams) {
5714
5731
  const network = lucid.config().network;
5715
5732
  const lrpScriptRefUtxo = matchSingle(
5716
5733
  await lucid.utxosByOutRef([
@@ -5718,13 +5735,15 @@ async function redeemLrp(redemptionLrpsData, priceOracleOutRef, iassetOutRef, lu
5718
5735
  ]),
5719
5736
  (_) => new Error("Expected a single LRP Ref Script UTXO")
5720
5737
  );
5721
- const priceOracleUtxo = matchSingle(
5722
- await lucid.utxosByOutRef([priceOracleOutRef]),
5723
- (_) => new Error("Expected a single price oracle UTXO")
5738
+ const priceOracleUtxo = await resolveUtxo(
5739
+ priceOracle,
5740
+ lucid,
5741
+ "Expected a single price oracle UTXO"
5724
5742
  );
5725
- const iassetUtxo = matchSingle(
5726
- await lucid.utxosByOutRef([iassetOutRef]),
5727
- (_) => new Error("Expected a single IAsset UTXO")
5743
+ const iassetUtxo = await resolveUtxo(
5744
+ iasset,
5745
+ lucid,
5746
+ "Expected a single IAsset UTXO"
5728
5747
  );
5729
5748
  const iassetDatum = parseIAssetDatumOrThrow(
5730
5749
  getInlineDatumOrThrow(iassetUtxo)
@@ -5749,17 +5768,14 @@ async function redeemLrp(redemptionLrpsData, priceOracleOutRef, iassetOutRef, lu
5749
5768
  )
5750
5769
  ).readFrom([lrpScriptRefUtxo]).readFrom([iassetUtxo, priceOracleUtxo]).compose(tx);
5751
5770
  }
5752
- async function adjustLrp(lucid, lrpOutRef, lovelacesAdjustAmt, newMaxPrice, sysParams) {
5771
+ async function adjustLrp(lucid, lrp, lovelacesAdjustAmt, newMaxPrice, sysParams) {
5753
5772
  const lrpScriptRefUtxo = matchSingle(
5754
5773
  await lucid.utxosByOutRef([
5755
5774
  fromSystemParamsScriptRef(sysParams.scriptReferences.lrpValidatorRef)
5756
5775
  ]),
5757
5776
  (_) => new Error("Expected a single LRP Ref Script UTXO")
5758
5777
  );
5759
- const lrpUtxo = matchSingle(
5760
- await lucid.utxosByOutRef([lrpOutRef]),
5761
- (_) => new Error("Expected a single LRP UTXO.")
5762
- );
5778
+ const lrpUtxo = await resolveUtxo(lrp, lucid, "Expected a single LRP UTXO.");
5763
5779
  const lrpDatum = parseLrpDatumOrThrow(getInlineDatumOrThrow(lrpUtxo));
5764
5780
  const rewardAssetClass = {
5765
5781
  currencySymbol: sysParams.lrpParams.iassetPolicyId.unCurrencySymbol,
@@ -5796,8 +5812,8 @@ async function adjustLrp(lucid, lrpOutRef, lovelacesAdjustAmt, newMaxPrice, sysP
5796
5812
  )
5797
5813
  ).addSignerKey(lrpDatum.owner);
5798
5814
  }
5799
- async function claimLrp(lucid, lrpOutRef, sysParams) {
5800
- return adjustLrp(lucid, lrpOutRef, 0n, void 0, sysParams);
5815
+ async function claimLrp(lucid, lrp, sysParams) {
5816
+ return adjustLrp(lucid, lrp, 0n, void 0, sysParams);
5801
5817
  }
5802
5818
 
5803
5819
  // src/contracts/lrp/scripts.ts
@@ -6024,7 +6040,7 @@ function calculateLeverageFromCollateralRatio(iasset, collateralRatioPercentage,
6024
6040
  }
6025
6041
 
6026
6042
  // src/contracts/leverage/transactions.ts
6027
- async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, iassetOutRef, cdpCreatorOref, interestOracleOref, collectorOref, sysParams, lucid, allLrps, currentSlot) {
6043
+ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracle, iasset, cdpCreator, interestOracle, collector, sysParams, lucid, allLrps, currentSlot) {
6028
6044
  const network = lucid.config().network;
6029
6045
  const currentTime = BigInt((0, import_lucid51.slotToUnixTime)(network, currentSlot));
6030
6046
  const [pkh, skh] = await addrDetails(lucid);
@@ -6058,27 +6074,31 @@ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, i
6058
6074
  ]),
6059
6075
  (_) => new Error("Expected a single iasset token policy Ref Script UTXO")
6060
6076
  );
6061
- const cdpCreatorUtxo = matchSingle(
6062
- await lucid.utxosByOutRef([cdpCreatorOref]),
6063
- (_) => new Error("Expected a single CDP creator UTXO")
6077
+ const cdpCreatorUtxo = await resolveUtxo(
6078
+ cdpCreator,
6079
+ lucid,
6080
+ "Expected a single CDP creator UTXO"
6064
6081
  );
6065
- const interestOracleUtxo = matchSingle(
6066
- await lucid.utxosByOutRef([interestOracleOref]),
6067
- (_) => new Error("Expected a single interest oracle UTXO")
6082
+ const interestOracleUtxo = await resolveUtxo(
6083
+ interestOracle,
6084
+ lucid,
6085
+ "Expected a single interest oracle UTXO"
6068
6086
  );
6069
6087
  const interestOracleDatum = parseInterestOracleDatum(
6070
6088
  getInlineDatumOrThrow(interestOracleUtxo)
6071
6089
  );
6072
- const priceOracleUtxo = matchSingle(
6073
- await lucid.utxosByOutRef([priceOracleOutRef]),
6074
- (_) => new Error("Expected a single price oracle UTXO")
6090
+ const priceOracleUtxo = await resolveUtxo(
6091
+ priceOracle,
6092
+ lucid,
6093
+ "Expected a single price oracle UTXO"
6075
6094
  );
6076
6095
  const priceOracleDatum = parsePriceOracleDatum(
6077
6096
  getInlineDatumOrThrow(priceOracleUtxo)
6078
6097
  );
6079
- const iassetUtxo = matchSingle(
6080
- await lucid.utxosByOutRef([iassetOutRef]),
6081
- (_) => new Error("Expected a single IAsset UTXO")
6098
+ const iassetUtxo = await resolveUtxo(
6099
+ iasset,
6100
+ lucid,
6101
+ "Expected a single IAsset UTXO"
6082
6102
  );
6083
6103
  const iassetDatum = parseIAssetDatumOrThrow(
6084
6104
  getInlineDatumOrThrow(iassetUtxo)
@@ -6199,12 +6219,825 @@ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, i
6199
6219
  2n
6200
6220
  );
6201
6221
  if (debtMintingFee > 0) {
6202
- await collectorFeeTx(debtMintingFee, lucid, sysParams, tx, collectorOref);
6222
+ await collectorFeeTx(debtMintingFee, lucid, sysParams, tx, collector);
6203
6223
  }
6204
6224
  return tx;
6205
6225
  }
6226
+
6227
+ // src/contracts/initialize/helpers.ts
6228
+ var INDY_TOKEN_NAME = "INDY";
6229
+ var DAO_TOKEN_NAME = "DAO";
6230
+ var GOV_NFT_TOKEN_NAME = "GOV_NFT";
6231
+ var POLL_MANAGER_TOKEN_NAME = "POLL_MANAGER";
6232
+ var UPGRADE_TOKEN_NAME = "UPGRADE";
6233
+ var IASSET_TOKEN_NAME = "IASSET";
6234
+ var STABILITY_POOL_TOKEN_NAME = "STABILITY_POOL";
6235
+ var VERSION_RECORD_TOKEN_NAME = "VERSION_RECORD";
6236
+ var CDP_CREATOR_TOKEN_NAME = "CDP_CREATOR";
6237
+ var CDP_TOKEN_NAME = "CDP";
6238
+ var STAKING_MANAGER_TOKEN_NAME = "STAKING_MANAGER";
6239
+ var STAKING_TOKEN_NAME = "STAKING_POSITION";
6240
+ var SNAPSHOT_EPOCH_TO_SCALE_TO_SUM_TOKEN_NAME = "SNAPSHOT_EPOCH_TO_SCALE_TO_SUM";
6241
+ var ACCOUNT_TOKEN_NAME = "SP_ACCOUNT";
6242
+ var TOTAL_INDY_SUPPLY = 35000000000000n;
6243
+ var TREASURY_INDY_AMOUNT = 100000n;
6244
+ var NUM_CDP_CREATORS = 2n;
6245
+ var NUM_COLLECTORS = 2n;
6246
+ var ALWAYS_FAIL_VALIDATOR_HASH = "ea84d625650d066e1645e3e81d9c70a73f9ed837bd96dc49850ae744";
6247
+ async function submitAndAwaitTx(lucid, tx) {
6248
+ const txHash = await tx.complete().then((t) => t.sign.withWallet().complete()).then((t) => t.submit());
6249
+ await lucid.awaitTx(txHash);
6250
+ return txHash;
6251
+ }
6252
+
6253
+ // src/contracts/initialize/transactions.ts
6254
+ var import_lucid57 = require("@lucid-evolution/lucid");
6255
+
6256
+ // src/contracts/price-oracle/transactions.ts
6257
+ var import_lucid53 = require("@lucid-evolution/lucid");
6258
+
6259
+ // src/contracts/price-oracle/scripts.ts
6260
+ var import_lucid52 = require("@lucid-evolution/lucid");
6261
+ var priceOracleValidatorData = {
6262
+ type: "PlutusV2",
6263
+ cborHex: "590ba5590ba20100003232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323233027222232325335333006533357346074607e0022646605a60586ae84004dd69aba135744002607c00206e64a666ae68c0ecc1000044c8c8c848cc00400c008c0b8d5d09aba2002375a6ae84004c0fc0040e0dd50022999ab9a303a303f002132321233001003002357426ae88c0fc00cd5d0981f00101b8890008a99ab9c49103505435001637540086ea8004cc09c8888c8d4014888d40188c88c94cd54cd4ccd54c0d40e0c0a80a4c0ac01ccc0b08004d40048888888888880100e44cd5ce24812d546865207472616e73616374696f6e206973206e6f74207369676e6564206279206f7261636c65206f776e657200030132533553355335333553036039302b02a253335302135001202103e215333573466ebcc118cd5d0182319aba0375000a6ec4080cd5d01ba835500b03937620400022a66a666036446a0044466603e446a00444a666ae68c12c004400c4cc11848ccc00401c00c00800c00c0040c0cd54c0e80ec8d400488cc0e0008cd54c0f40f88d400488cc0ec008ccd4004dc0a4000e048cdc0800a400000266aa607407646a0024466070004666a002466aa607c07e46a0024466078004604600200244666038066004002466aa607c07e46a0024466078004604000200266602e05c666050400204e6a004404e0060784426a004444a66a0082a666ae68cdd78018238a999ab9a3375e00408e2a666ae68cdc4000a400006e2666ae68cdc4800a410125e80206a07006e06e44072064407e6044014074266ae712401024c310003103a1335738921156f757470757420646f6573206e6f74206d6174636800031153355333573466e2400d20001335738921165072696365206d75737420626520706f7369746976650003103a15335533535353301275a6a00407e06e44a666a00442a666ae68cdc419b8000100935500c03a0331333573466e24004d540300e80c40d00c80c84d4cc049d69a80101f911a801112999a99980980a980f19b8100900b0021533500113330120150030081333012015003008034133301201500300803003a13357389212345787069726174696f6e2074696d65206973206e6f742070726f7065726c792073657400031030030333025200102435302635533530270092100116036202402f302d350080393302f3016337000020060542a666a602e6aa66a60320022602602a442a66a0022004442602e032402e02842a66a6666666ae900048c94ccd5cd181d98200008991999aab9f001202d23233335573e002405e46666aae7cd5d1001119299a9999999aba400123253335734608660900022646666aae7c00480d48cccd55cf9aba20022533530203574200642605e00206a406c07a078608e0020646ea800880c880c880c880c80e4854cd4c070d5d08029098159981a8010008188181aba1005203003703635744004068607e0020546ea800880a880a880a880a80c48400405480548c94ccd5cd181b181d800899191919091998008028018011bad357426ae88008dd69aba10013574460760046ae84c0e80040ccdd50009111a801111a801912999a9998040038020010a99a8018800819814819911192999a80190a999a80190a999a80290980200b0980180a8a999a80210980200b0980180a80c0060a999a80210980180a8980100a0a999a80190980180a8980100a00b8a999a801100700b0068a999a80110a999a80210980180a8980100a0a999a80190980180a8980100a00b8058a999a80190980100a098008098a999a80110980100a0980080980b12999a80110a999a80210a999a802109998040038010008b0b0b0060a999a80190a999a801909998038030010008b0b0b00580691a80091111111003891999999980091199ab9a3370e00400204004644a666ae68cdc38010008098a999ab9a3371200400201401044666ae68cdc400100081001191199ab9a3371200400204004644666ae68cdc480100081181011199ab9a3371000400204604044a666ae68cdc480100088008801112999ab9a33712004002200420024464a666ae68c0c8c0dc0044c8c8cc0994ccd5cd181a181c801099813198038029aba130380023006357426ae88c0e00080c54ccd5cd181a181c800899813198038029aba130380013006357426ae88c0e00040c4dd51aba135744606e0046ea8d5d0981b0008179baa0012325333573460620020522a666ae68c0c000407c0b4c0d0dd50009119192999ab9a303300100815333573460640022601460086ae84c0d400854ccd5cd1818800803017181a8009baa00122233355302302702a335530260272350012233024002300b001333553023027223500222533533355302802b301d01c235001223300a002005006100313302e00400301c001335530260272350012233024002330382253350011300a003221350022253353300c002008112223300200a0041300600300400211009212223001004112220012230302253350011003221330060023004001212223003004233333335748002403040304030460206eb4008806007c94cd5ce2481286578706563746564206f6e6c7920612073696e676c6520636f6e74696e75696e67206f7574707574001615335738920117496e76616c696420646174756d20696e206f757470757400164988880088c8c94ccd5cd1813000899091118010021aba13028002153335734604a002264244460020086ae84c0a000854ccd5cd181200080201098140009baa00111003253353007001213335530150192235300535300935003019222200422353007350042222004225333573466ebc01000854ccd5cd19baf0030011330220060051005100500e3300d00735300f3500201b22222222222200a15335738921024c660016232533357346040604a0022646424660020060046ae84d5d118128011aba1302400101d3754002444006660024002eb4888cc09088cccd55cf80090071191980e9980a180398138009803181300098021aba2003357420040306eac0048c94ccd5cd180e181080089919191919190919998008038028018011aba1357440046ae84004d5d10011aba10013574460420046ae84c080004064dd5000919191999aa999ab9a3370e90030008990911118020029aba13020002153335734603c00226424444600400a6ae84c08000854ccd5cd180e8008990911118008029aba13020002153335734603800226424444600600a6ae84c0800080648034803480348ccd54c048054cc03c894cd40088400c400403494ccd5cd19baf002350010181300600100d3300923253335734603e60480022646424660020060046ae84d5d118120011aba1302300101c37540026a60166a00802e44444444444401860400026ea8d40040408488c00800c48cc004894cd400804c40040208cc02488ccd400c04c008004d400403488ccd5cd19baf002001004007223301c2233335573e002400c466028600a6ae84008c00cd5d10010081bac001100d23253335734602860320022646464646464646464646464646464646464646464642466666666666600202e02a02602201e01a01601200e00a0060046ae84d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d1180c8011aba1301800101137540022002200c464a666ae68c044c0580044dd69aba1301500100e37540024424660020060044446006600400260244422444a66a00220044426600a004666aa600e01600a00800260224422444a66a00226a00600c442666a00a0186008004666aa600e01400a00800244002601e442244a66a00200c44266014600800466aa600c00e00800224002220024400444244660020080062a66ae712411f496e76616c696420646174756d20746f20636865636b4f776e4f757470757400161533573892010350543100162222222222220054c1014000370e90001b8748008dc3a40086e9520005573caae748c8c00400488cc00cc008008005"
6264
+ };
6265
+ function mkPriceOracleValidator(params) {
6266
+ return {
6267
+ type: priceOracleValidatorData.type,
6268
+ script: (0, import_lucid52.applyParamsToScript)(priceOracleValidatorData.cborHex, [
6269
+ castPriceOracleParams(params)
6270
+ ])
6271
+ };
6272
+ }
6273
+
6274
+ // src/contracts/price-oracle/transactions.ts
6275
+ async function startPriceOracleTx(lucid, assetName, startPrice, oracleParams, now = Date.now(), refOutRef) {
6276
+ if (!refOutRef) {
6277
+ refOutRef = (await lucid.wallet().getUtxos())[0];
6278
+ }
6279
+ const [tx, oracleNftPolicyId] = await oneShotMintTx(lucid, {
6280
+ referenceOutRef: {
6281
+ txHash: refOutRef.txHash,
6282
+ outputIdx: BigInt(refOutRef.outputIndex)
6283
+ },
6284
+ mintAmounts: [
6285
+ {
6286
+ tokenName: (0, import_lucid53.fromText)(assetName),
6287
+ amount: 1n
6288
+ }
6289
+ ]
6290
+ });
6291
+ const priceOracleNft = {
6292
+ currencySymbol: oracleNftPolicyId,
6293
+ tokenName: (0, import_lucid53.fromText)(assetName)
6294
+ };
6295
+ const oracleValidator = mkPriceOracleValidator(oracleParams);
6296
+ const oracleDatum = {
6297
+ price: startPrice,
6298
+ expiration: BigInt(now) + oracleParams.expiration
6299
+ };
6300
+ tx.pay.ToContract(
6301
+ (0, import_lucid53.validatorToAddress)(lucid.config().network, oracleValidator),
6302
+ { kind: "inline", value: serialisePriceOracleDatum(oracleDatum) },
6303
+ (0, import_lucid53.addAssets)(mkLovelacesOf(5000000n), mkAssetsOf(priceOracleNft, 1n))
6304
+ );
6305
+ return [tx, { oracleNft: priceOracleNft }];
6306
+ }
6307
+
6308
+ // src/scripts/auth-token-policy.ts
6309
+ var import_lucid54 = require("@lucid-evolution/lucid");
6310
+ var authPolicyData = {
6311
+ type: "PlutusV2",
6312
+ cborHex: "5904d95904d60100003232323232323232323232323232323232323232323232323232223232223232323253355335533357346042660166018a00200e03026464666ae68cdc419806980728019980b9999aa999ab9a3370e90030008990911118020029aba1302400215333573466e1d20040011321222230020053574260480042a666ae68c08c0044c848888c004014d5d098120010a999ab9a30220011321222230030053574260480040424c40024c4c016900100a80d98120009baa3500201d01813357389213d4d75737420636f6e73756d65204e4654206f7220746f6b656e2070726576696f75736c79206d696e746564207573696e67207468697320706f6c6963790001301415335738920103505435001613253335734604060460022646464646464646464646464646464646464646464642466666666666600202e02a02602201e01a01601200e00a0060046ae84d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d118118011aba1302200101f37546a002036a666ae68c078c0840084c8c848cc00400c008d5d09aba2302100335742604000403aa666ae68c074c080dd500180880e1baa00153335734603260380022646601e6ae84004d5d09aba2001301b00101837540044464646603a4466a0029000111a801112999ab9a3375e0040102660464466a0029000111a801112999ab9a3375e00401a20022600c0060022600c0060086a00402a6a0020264666aa6020026660144466aa601c02a46a002446601e00466aa602203046a0024466024004666a0026e012000700466e0000520000013355300e015235001223300f00233350012335530120192350012233013002300e0010012233300a0090020012335530120192350012233013002301000100133300500400200100e232333008200133008200175a6aa666ae68c05cc0680044c8c8c8c8c8c848cccc00401c01400c008d5d09aba2002357420026ae88008d5d08009aba2301a00235742603200202c44440066ea8d400404ccc06488cccd55cf800900891919809a999ab9a3019301c001132321233001003002357426ae88c070008d5d0980d80080c18021aba200337546ae84008054dd61a80091111111111100611199ab9a3375e00400201c010444666aa601602601e66aa601802646a002446601a0046010002666aa6016026446a00444a66a666aa602802e6601c4466601402e004002601002c46a002446601400400a00c200626602600800601c00266aa601802646a002446601a0046603844a66a002260180064426a00444a66a6601800401022444660040140082600c00600800446600244a66a004018200200a4244460060084446602c446666aae7c00480388c8cc040cc02cc01cc064004c018c060004c010d5d10019aba1002012375600242444600200820142014442466002006004601c4422444a66a00220044426600a004666aa600e01e00a008002601a442244a66a00200a44266012600800466aa600c01a00800220022006442446600200800660124422444a66a00226a00600e442666a00a0106008004666aa600e01400a0080024400444002240022a66ae71241035054310016370e90001b874800955cf2ab9d2323001001223300330020020011"
6313
+ };
6314
+ function mkAuthTokenPolicy(ac, tn) {
6315
+ return {
6316
+ type: authPolicyData.type,
6317
+ script: (0, import_lucid54.applyParamsToScript)(authPolicyData.cborHex, [
6318
+ new import_lucid54.Constr(0, [ac.currencySymbol, ac.tokenName]),
6319
+ tn
6320
+ ])
6321
+ };
6322
+ }
6323
+
6324
+ // src/scripts/iasset-policy.ts
6325
+ var import_lucid55 = require("@lucid-evolution/lucid");
6326
+ var iassetPolicyData = {
6327
+ type: "PlutusV2",
6328
+ cborHex: "59047b590478010000323232323232323232323232323232323232323232323232323232323232330102223253353300453335734603e60426ea800c04c0794ccd5cd180f98108008991909198008018011aba13574460420046ae84c08000407804c54cd5ce248103505435001637540026602044464a66aa666ae68cdc419803199aa980d00e803919980810008079a98071a80080e9003998089192999ab9a30213023001132321233001003002357426ae88c08c008d5d098110008101baa00135500122222222222200c004480084ccd5cd19b8748008cc018ccd54c06807401c8ccc040800403cd4004801ccc044034d5400488888888888802801006004805c05c4cd5ce24910434450546f6b656e206d697373696e670001213253335734603e60420022646464646464646464646464646464646464646464642466666666666600202e02a02602201e01a01601200e00a0060046ae84d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d118108011aba1302000101e37546a002034464a666ae68c074c07c0044c8c848cc00400c008d5d09aba2301f00235742603c0020386ea800488800c88c8c8cc08088cd400520002235002225333573466ebc0080204cc09888cd400520002235002225333573466ebc00803440044c01800c0044c01800c010d4008064d400405ccc02488cd54c0440608d400488cc038008cd54c05006c8d400488cc044008ccd4004dc024000e008cdc0000a400000266aa602203046a002446601c004666a002466aa602a03846a0024466024004601a00200244666012010004002466aa602a03846a0024466024004601c00200266600800600400202244666ae68cdd7801000809006111199aa980780b80999aa980800b91a80091198068011804000999aa980780b911a80111299a999aa980c00d998071119980500d801000980400d11a8009119805001002803080189980b80200180900099aa980800b91a80091198068011980f91299a800898058019109a80111299a9980600100408911198010050020980300180200111980091299a80100808008049091118018021091118008021192999ab9a301430160011323232323232123333001007005003002357426ae88008d5d08009aba2002357420026ae88c058008d5d0980a8008099baa00133001200175a4446602c446666aae7c004803c8c8cc044cc020c01cc064004c018c060004c010d5d10019aba100201337560024424660020060044466026446666aae7c00480308cc034c014d5d080118019aba200201037580022014201444460066004002601a4422444a66a00220044426600a004666aa600e01e00a0080026018442244a66a00200a44266012600800466aa600c01a00800220022006442446600200800660104422444a66a00226a00600e442666a00a0106008004666aa600e01400a0080024400444002240022a66ae71241035054310016370e90002ab9e5573a4646002002446600660040040021"
6329
+ };
6330
+ function mkIAssetTokenPolicy(ac) {
6331
+ return {
6332
+ type: iassetPolicyData.type,
6333
+ script: (0, import_lucid55.applyParamsToScript)(iassetPolicyData.cborHex, [
6334
+ new import_lucid55.Constr(0, [ac.currencySymbol, ac.tokenName])
6335
+ ])
6336
+ };
6337
+ }
6338
+
6339
+ // src/contracts/gov/scripts.ts
6340
+ var import_lucid56 = require("@lucid-evolution/lucid");
6341
+
6342
+ // src/validators/governance-validator.ts
6343
+ var _governanceValidator = {
6344
+ type: "PlutusScriptV2",
6345
+ description: "Generated by Aiken",
6346
+ cborHex: "592a2c592a290100003232323232323232223232323223232323232323232253330113232325333014300a3016375400226464646464a666032602c60366ea80044c8c8c8c8c8c94ccc07ccc00d24113496e636f727265637420476f7620696e70757400330013756600a60446ea8c014c088dd5003180518111baa01e132323232323232323232323232323232323232323232325323233303830350191323232333332323232323232323232323232323232222232323232533305333225333055304b3057375400e29444c8c94ccc15ccc0ed2401415472656173757279207769746864726177616c2063616e6e6f742062652061626f7665207769746864726177616c206c696d697420666f72206c6f76656c6163650033712666074002910100488100004153330573303b49013d5472656173757279207769746864726177616c2063616e6e6f742062652061626f7665207769746864726177616c206c696d697420666f7220494e4459003371266050002602c60b46ea815800c54ccc15ccc0ed2401295472656173757279207769746864726177616c2076616c75652063616e6e6f7420626520656d707479003330573375e6e98005300101a0004a094454ccc15ccc0ed241355472656173757279207769746864726177616c2063616e6e6f7420726571756573742044414f206964656e7469747920746f6b656e003054330280013015305a37540ac2a6660ae6607692012f5472656173757279207769746864726177616c2063616e20636f6e7461696e206d6178206f66203820617373657473003371260346eb0c0f4c168dd5001240202660769201355472656173757279207769746864726177616c2063616e20636f6e7461696e206f6e6c7920706f73697469766520616d6f756e74730032330010013758607c60b66ea800c894ccc174004528899299982d19b8848000dd6983018309830982e9baa306000213300300300114a060c000229405280a5014a02940c8cc004004c8cc004004dd6181f182d9baa00322533305d00114bd7009982f1ba7323233060306100233060306100133060306130620014bd701830800982e1baa305f00133002002306000122533305c00114bd6f7b6300999119199911299982f182d800880289999981d002801991900119198008008011129998328008a4c264a6660cc002293099192999832183098331baa3303e375c60cc60d40086eb8c1980084cc014014cc1a400800454cc195241326b65797320696e206173736f63696174697665206c697374206172656e277420696e20617363656e64696e67206f726465720016306a0023068001306800133063337606ea4008dd4000a5eb7bdb180888c94ccc188c0f4004530103d87a80001304c33067374c00297ae03333303e001005004222325333065306200114c103d87a80001304f3306a375000297ae0337000020040760706eb8c18400cdd718308009bad306130620013061002375860bc0026600400460be00260b660b06ea801cdd69808182b1baa3039305637540a26eb4c078c158dd5181c982b1baa051153330533303749011b496e636f727265637420476f7665726e616e6365206f75747075740033333027004301d330580384bd70180e1982c19191918201982d9ba8301b375a608260b26ea8150cc16cc17000ccc16cc170008cc16cc170004cc16cdd4180d9bad3023305937540a860ba60ba00260b800260b600260b460ac6ea81452f5c0604a607c60ac6ea8149300103d87a8000153330533303749127546865207472616e73616374696f6e206d757374206265207369676e6564206279206f776e657200330233758602060ac6ea810402054ccc14ccc0dd24012850726f706f73616c20696e636f6d70617469626c6520776974682063757272656e7420737461746500533305330453055375400e266e1cdd6981f182b1baa30593056375400e60306eb4c0a8c158dd50288a5115333053330374910d496e76616c6964207054696d650032325333055325333056304900114a22a6660ac60980022944528182b9baa33017304030583754004608060b06ea80044c94ccc158c14c0045288a99982b18260008a5114a060ae6ea8cc05cc0ecc160dd5001181d982c1baa00114a0602a607c660b2607c660b2603c660b26ea0cdc08039bad3014305737540a697ae0330593330544a298103d87a80004c0103d87980004bd701982c981f1982c980f1982c9ba83004375a602860ae6ea814d2f5c0660b26660a8945300103d87a80004c0103d87980004bd7025eb80c050c044c158dd50208a9998299981ba481245472616e73616374696f6e206d696e742065786163746c79203120706f6c6c546f6b656e003375e6e98c0c8dd59810182b1baa041374c604a607260ac6ea814854ccc14ccc0dd24113496e76616c696420506f6c6c206f75747075740033333027004301d33058303d33058301d33058301f305637540a497ae0330584c103d87a80004bd7025eb80c070cc1600052f5c066056604a607260ac6ea8148c8ccc09cdd7181f982b9baa001375c607460ae6ea8004cdc11bad303f30573754607460ae6ea8148c03cdd69810982b9baa0523012305637540a498103d87a800013253330543051001132323232323232323232533305e3333333330163064008306400730640063064005306400430640033064002306400130643065001132533305f305c375a603c60c46ea817452889919299983298340010992999831182c18321baa001132325333068306b002132330494912469417373657420776974682073616d65206e616d6520616c726561647920657869737473005333065533306532533306a306900115333066305c306800114a22a6660cc60c660d000229405858dd5183598361836183618361836183618361836183618361836183618341baa002130433303f010375c60a060d06ea80085280a51153330653375e6607e0206eb8c140c1a0dd5001260103d87b8000132533306630633068375400226088660800226eb8c1b0c1a4dd50008a51306b306c306c306c306c306c306c306c306c306c306c306c306c306c3068375400429414ccc190c184c198dd5000899191919191919191919191919191919191919191919191919191919299984200984380801099191919191919191919191924c64a6661180261120200226464a66612402612a020042930b1bae309301001308f01375401a2a666118026104020022a66612002611e026ea80345261616308d013754018610c0201e610a0202061080202261060202461040202661020202861000202a60fe02c60fc02e60f203060ea0322c610a02002610a0200464a666104026102020022a6660fc60e8610002002294454ccc1f8c1ecc200040045280b0b1baa308301001308301002308101001308101002307f001307f002307d001307d002307b001307b0023079001307900230770013077002307500130750023073001307300230710013071002306f001306f002306d001306d002375c60d600260ce6ea80045858c1a4004c194dd50008b1817981c18321baa3047306437540022c60cc00266605c002603860c46ea8179300103d87980003758608860c26ea813052818320009831800983100098308009830000982f800982f000982e982e982e8011bae305b001305737540102a6660a860940022646464646464646466666666602860c401060c400e60c400c60c400a60c400860c400660c400460c400260c460c600260c400260c200260c000260be00260bc00260ba00260b800260b660b660b660ae6ea802054ccc150c11c0044c94ccc154cc0e52412a50726f706f73616c206465706f73697420696e2072616e6765205b302c2031305f30303020494e44595d005333055302a375a608060b06ea80044cdc49bad30403058375400201e294054cc8cc158cc0e9240128566f74696e6720706572696f6420696e2072616e6765205b3120686f75722c2031206d6f6e74685d0053330563371290405d5b819bad303c30593754004266e24dd6981e182c9baa00200114a02a6660ac66074921264566666563746976652064656c617920696e2072616e6765205b302c20313220686f7572735d005333056302b375a605a60b26ea80084cdc49bad302d3059375400466e092080bab703480605280a99982b1981d24812b45787069726174696f6e20706572696f6420696e2072616e6765205b31206461792c2031206d6f6e74685d0053330563371290407859291bad301530593754004266e24dd6980a982c9baa00200114a02a6660ac660749212d436f6c6c61746572616c206665652070657263656e7461676520696e2072616e6765205b30252c20313030255d005333056302b375a608260b26ea8c08cc164dd5001099b89375a608260b26ea8c08cc164dd50010078a50153330563303a4912b50726f706f73696e6720706572696f6420696e2072616e6765205b3120686f75722c2031206d6f6e74685d0053330563371290405d5b819bad302230593754004266e24dd69811182c9baa00200114a02a6660ac660749212950726f706f73696e6720706572696f64203c20566f74696e6720706572696f64202d203120686f757200337106eb4c088c164dd500119b80375a607860b26ea800920ffb9b703153330563303a49011f546f74616c2073686172647320696e2072616e6765205b312c20313030305d0053330563371290011bad301630593754004266e24dd6980b182c9baa002483403c5280a99982b1981d2481234d696e2071756f72756d20696e2072616e6765205b302c2031306d696c20494e44595d005333056302b375a602860b26ea80084cdc49bad30143059375400466e092080dac4094820225e85280a99982b1981d2481384d6178207472656173757279206c6f76656c616365207370656e6420696e2072616e6765205b302c2034352062696c6c696f6e204144415d005333056302b375a602660b26ea80084cdc49bad30133059375400466e09208088aca3cf024820225e852809981d249354d617820747265617375727920494e4459207370656e6420696e2072616e6765205b302c203335206d696c6c696f6e20494e44595d005333056302b375a604260b26ea80084cdc49bad30213059375400466e092080bbb0214820225e85280a5014a029405280a5014a0294052819b8248203c2c949203c14a02940c168c15cdd50040a99982a18230008991981ca4811d43616e6e6f7420636f6e7461696e206475706c6963617465206b657973003375e6e9cc02c004dd380099198008009bab305b305c3058375460b660b06ea8024894ccc16800452f5c02660b66ea4dd7182c182e00099801001182e80089981c24811e5465787450726f706f73616c2773206c656e677468206973203c3d20363400337126e34dd7182d182b9baa0084820004c154dd50038a5014a029405280a5014a02940c0f0cc15cc0f0cc15cdd4180b9bad303d305537540a0660ae6ea401ccc15c018cc15c010cc15d300106d8799f0000ff00330573750002660ae981010000330574c101000033057301230553754607060aa6ea8140cc15cdd418011bad301e30553754607060aa6ea8140cc15cdd419b80001375a602260aa6ea8c0e0c154dd50281982b9814982a9baa05033057301030553754607060aa6ea81412f5c097ae03001375a606e60a86ea8c0dcc150dd50279b80003375860aa60ac60ac60a46ea80f4c004004894ccc13c00452f5c0264660a26ea4004cc00c00cc8cc004004c15000c894ccc14800452f5c026464a6660a06660a066e3c0080152825113305537520046600800800226600800800260ac0046eb8c150004dd718288009111111112999198291981b2491d4d52206973206265747765656e205b313030252c2031305f303030255d0053330523001375a607a60aa6ea80244cdc49bad303d30553754012018294054ccc148cc0d924011e524d52206973206265747765656e205b313030252c2031305f303030255d0053330523001375a607a60aa6ea80284cdc49bad303d30553754014018294054ccc148cc0d924011f4d61696e74656e616e636520726174696f206d757374206265203e3d204c5200337126eb4c0f4c154dd50041bad303d305537540122a6660a46606c921214c69717569646174696f6e20726174696f206d757374206265203e3d2031303025003001375a607a60aa6ea802054ccc148cc0d924013144656274206d696e74696e67206665652070657263656e74616765206973206265747765656e205b30252c20313030255d0053330523027375a607a60aa6ea801c4cdc49bad303d3055375400e016294054ccc148cc0d92401394c69717569646174696f6e2070726f63657373696e67206665652070657263656e74616765206973206265747765656e205b30252c2035255d0053330523027375a607a60aa6ea80184cdc49bad303d3055375400c66e09200a4820225e85280a9998291981b24813e53746162696c69747920706f6f6c207769746864726177616c206665652070657263656e74616765206973206265747765656e205b30252c20313030255d0053330523027375a607a60aa6ea80144cdc49bad303d3055375400a016294054ccc148cc0d9240138526564656d7074696f6e207265696d62757273656d656e742070657263656e7461676520696e206265747765656e205b30252c203235255d0053330523027375a607a60aa6ea80104cdc49bad303d3055375400866e0920324820225e85280a9998291981b248139526564656d7074696f6e2070726f63657373696e67206665652070657263656e7461676520696e206265747765656e205b30252c203130255d0053330523027375a607a60aa6ea800c4cdc49bad303d3055375400666e0920144820225e852809981b2493b496e74657265737420636f6c6c6563746f7220706f7274696f6e2070657263656e7461676520696e206265747765656e205b30252c20313030255d0053330523027375a607a60aa6ea80084cdc49bad303d3055375400401629405280a5014a029405280a5014a02940dc48050a5033704906400a410112f466e0920a09c014820225e8c004004894c8ccc11cc0052010153330473001480005200013371c91108010204081020408000002153330473001481004cdc124100086600600666e00009200f1337049040404040101980180199b80002480fcdc4000918251825982598259825982598259825982580091824982518251825182518251825182500091824182498249824800918239824182418241824182418240009181519822992999820981b98219baa00113253330423253330473046001153330433039304500114a22a6660866080608a00229405858dd5181418229baa302d30453754006260186608e6ea00052f5c0260186608e6ea0c01c0052f5c06eb4c11cc110dd50008800981598219baa302b304337540026608a64a666082606e60866ea80044c94ccc108c94ccc11cc11800454ccc10cc0e4c1140045288a999821982018228008a50161637546050608a6ea8c0a0c114dd500189806198239ba80014bd7009806198239ba8337000029000a5eb80dd6982398221baa0011001302b30433754604c60866ea80052f5c04464a666082607c0022a666082607c60866ea80085300103d87a800014c103d879800015333041303400115333041303430433754004298103d87a800014c103d87b80001323253330433039001132533304433710006002298103d879800015333044337100020062980103d87b800014c103d87a8000375a6092608c6ea801054ccc10cc100004530103d87b800014c103d8798000304437540066eb4c11cc110dd500198211baa00230010012253330420011480004c00ccc008008c114004dc0240046eb8c104008c104004dd698208019820982100098208009820000981d9baa03115333038302e0191323232533303f30420021533303b3301f49010e4d697865642076657273696f6e73003375e604c607c6ea8c098c0f8dd51810981f1baa0013005330403007303e375407497ae01533303b3301f4912e706f6c6c206d616e6167657220696e707574206d75737420757365207468652072696768742072656465656d65720032323375e004604e660846ea00152f5c064a66607a607400226464a666086608c0042930b1bad3044001304037540042a66607a606600226464a666086608c0042930b1bad3044001304037540042a66607a606000226464a666086608c0042930b1bad3044001304037540042c607c6ea8004c94ccc0f0c0e4c0f8dd500089821181f9baa001153303d490117436f756c64206e6f742066696e642072656465656d657200163232330010013756601060806ea80ac894ccc1080045300103d87a8000132323253330413375e00c6086006260566608c00297ae01330050050023043002304600230440013005330403026303e375400297ae01533303b3301f490114496e636f727265637420676f76206f7574707574003333300f37586024607c6ea80a4c014cc1000812f5c060086608064646464605266088608a00866088608a00666088608a00466088608a002660886ea0cdc01bad300c3042375407a900098231823000982280098220009821800981f1baa0394bd7018069813181f1baa03a4c0103d87a800013301f49013b4d757374206275726e203120706f6c6c20746f6b656e20616e64206f7074696f6e616c6c79206d696e7420616e207570677261646520746f6b656e0032533303c3375e6e98004dd31980a180a98071811181f9baa03b300e3013303f375407629444cdd79ba6001374c602a601c6044607e6ea80ecc068dd59804181f1baa02914a029405280b18200009998041bac3024303c375404e603e60786ea80e1300103d8798000375a607c60766ea80c454ccc0e0c0ac0644cc07124011d5370656e642065786163746c792031205570677261646520546f6b656e00302e332232330010010032253330400011480004cdc0198010011821800998069bab3022303f37546044607e6ea8c10800400cdd61811981d9baa026300f303b375406e266646464446464646464a666084607e60886ea80044c94ccc10cc0e4c114dd500089919192999825182680109919192999824982318259baa00113302d3300f3304e37526e612401084d697373696e6720003304e37526e60038cc138dd49b984901172075706772616465206d696e74696e6720706f6c696379004bd70249003301930103028009375c609e60986ea800454cc128cc03ccc138dd49b98491084d697373696e6720003304e37526e60038cc138dd49b9849010d20757067726164652070617468004bd702490016325333049303f304b3754002298103d87a8000130333304e37526eb8c130c8cdd81828000982818288009bac304f304c375400297ae032330010013756605e60986ea800c894ccc1380045300103d87a800013232533304c3371e6eb8c1380080244c0d8cc144dd399828982700119828982780125eb812f5c026600800800260a400460a0002a66608e608860926ea80044c8c8c8c94ccc13cc1480084c9263303f001232375c60a00046eb8c13800458dd5982800098280011bad304e001304a37540022c6028603a60926ea8c0b0c124dd50008b1825800999809802804260103d8798000375c6092608c6ea800458c0b4c114dd5181698229baa3028304537546090608a6ea800458cc0a8dd618238020169bab30463047304730470023758608a002608a00260806ea80ac88dcc99191998008008022441002225333044002100113233300400430480035333041303e371a00426e600044cdc500119b8a00537300026e64dd718230011b98001300100122533303e00114bd7009981f981e1820000998010011820800a4903476f76003005303b375406e6e952004374a90011181e181e981e981e981e981e981e981e981e981e8009181d981e181e181e181e181e0009181d181d981d981d981d800929998199813181a9baa00113039303637540022a66068921134e6f7420616e20696e6c696e6520646174756d0016222323300b00423002301c30393754002a6660686062606c6ea800448cc05cdd5980d981c1baa0010031233710900019980c1bab301b303837540026eb8c080c0e0dd50019bae301b3038375400644646600200200644a66607000229404c94ccc0d4cdc79bae303b00200414a22660060060026076002446660280046eb8c070c0d0dd50009bae30173034375400246660046eb8c068c0c8dd50009bae3015303237540029001111299981818168008a5eb7bdb1804c8c8cc0040052f5bded8c044a66606e00226607066ec0dd48031ba60034bd6f7b630099191919299981b980a9980880500109981e19bb037520146e9801c01454ccc0dccdc780500109981e19bb037520146e9801c00c4cc0f0cdd81ba9002374c0026600c00c0066eacc0e400cdd7181b801181d801181c8009919800800a5eb7bdb180894ccc0d80044cc0dccdd81ba9004375000697adef6c60132323232533303630143301000800213303b337606ea4020dd40038028a99981b19b8f00800213303b337606ea4020dd400380189981d99bb037520046ea0004cc01801800cdd6981c0019bae3036002303a0023038001222223233001001330080065333032302f3034375400a264466ebcc07cc0dcdd5180f981b9baa00100230383035375400a264466ebcc07cc0dcdd5000801181c181a9baa00522533303700114a0264a66606864a66606a66ebcc030c0e0dd5000803899299981d0008a511533303a303d001132323253330393019375c607e0062a66607260320022a666072606c60766ea802454ccc0e4c0380084cdc48012410137dc0429404c0380085280a50375c607c607e0046eb4c0f4c0f8c0f8004dd6181e0008a5032330010013300e3756603860726ea8008c03c01c894ccc0ec00452f5c0264666444646600200200644a6660820022006264660866e9ccc10cdd4803198219ba9375c6080002660866ea0dd69820800a5eb80cc00c00cc114008c10c004dd7181d0009bab303b00133003003303f002303d00114a0607400429444cc00c00c004c0e8004dc4a400044646600200200644a666064002297ae013232533303030050021330350023300400400113300400400130360023034001230303031303100122323330010010030022225333031002100113233300400430350033333300a002375c60600026eacc0c4004888c94ccc0c8c034004530103d87a80001301c33037374c00297ae03233300100100300222253330380021001132333004004303c00333333012002375c606e0026eb4c0e0004888c94ccc0e4c0d80045300103d87a8000130233303e375000297ae03370000400201e607400401060660044646600200200444a66605c002297adef6c6013233030337606ea4dd718168009ba632330010013756605e00444a666062002297adef6c6013233033337606ea4dd718180009ba83370290001bad30310013300300330350023033001330030033032002303000122533302833720004002298103d8798000153330283371e0040022980103d87a800014c103d87b80002533302a00114a2294088888c8cc004004018894ccc0bc0044cc0c0cdd81ba9006374c00a97adef6c60132323232533302f300d3300700a002133034337606ea4028dd30048028a99981799b8f00a0021325333030302d3032375400226606a66ec0dd4805981b18199baa001004100433300800a009001133034337606ea4008dd3000998030030019bab3031003375c605e0046066004606200244444646600200200c44a66605c00226605e66ec0dd48031ba80054bd6f7b630099191919299981718061980380500109981999bb037520146ea002401454ccc0b8cdc78050010992999817981618189baa001133034337606ea402cc0d4c0c8dd5000802080219980400500480089981999bb037520046ea0004cc01801800cdd698180019bae302e00230320023030001375e98103d87980002323300100100222533302800114bd6f7b63009919191929998141804001080189981699bb037520046e98004cc01801800cdd598150019bae3028002302c002302a001371e9110030213754030294088c058ccc00c008dd7180598119baa001375c600c60466ea8004888c94ccc084c05cc08cdd50008a400026eb4c09cc090dd5000992999810980b98119baa00114c103d87a80001323300100137566050604a6ea8008894ccc09c004530103d87a8000132323253330263371e00e6eb8c0a000c4c040cc0acdd4000a5eb804cc014014008dd698140011815801181480099198008008021129998130008a6103d87a8000132323253330253371e00e6eb8c09c00c4c03ccc0a8dd3000a5eb804cc014014008dd598138011815001181400091299980f19980f000a504a22a6603e00420022002600c603c6ea8c004c078dd5001118109811000980f980e1baa00116330013758600660366ea801801088c8cc00400400c894ccc07c004530103d87a800013232533301d3375e601060406ea80080144c01ccc0880092f5c0266008008002604600460420026e9520002301c001301a301737540022c60326034004603000260286ea80045261365632325333011300e00113232323232323232533301d302000213232498c94ccc06cc0600044c8c94ccc084c0900084c926533301d301a301f3754002264646464a66604a605000426464931980b00112999811981018129baa0011323232323232533302d3030002149858dd6981700098170011bae302c001302c002375c6054002604c6ea8004594ccc084c078c08cdd5001899191919299981498160010991924c64a66604e604800226464a66605a6060004264931929998151813800899192999818181980109924c603a0022c6062002605a6ea800854ccc0a8c0800044c8c8c8c8c8c94ccc0d0c0dc00852616375a606a002606a0046eb4c0cc004c0cc008dd6981880098169baa00216302b37540022c605c00260546ea800c54ccc09cc07400454ccc0acc0a8dd50018a4c2c2c60506ea8008c05800c58c0a8004c0a8008c0a0004c090dd50018b0b1bac302600130260023024001302037540022c2c6044002603c6ea800c54ccc06cc04400454ccc07cc078dd50018a4c2c2c60386ea8008c94ccc068c05c0044c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc0d8c0e40084c8c8c8c8c8c8c8c8c8c8c926303800b303700c303600d303500e303400f3033010303201130310123030013302b01430290151630370013037002303500130350023033001303300230310013031002302f001302f002302d001302d002302b001302b00230290013029002302700130270023025001302500230230013023002375c6042002603a6ea801054ccc068c0400044c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc0d8c0e40084c8c8c8c8c8c8c8c8c8c8c926303800b303700c303600d303500e303400f3033010303201130310123030013302b01430270151630370013037002303500130350023033001303300230310013031002302f001302f002302d001302d002302b001302b00230290013029002302700130270023025001302500230230013023002375c6042002603a6ea801054ccc068c0340044c8c94ccc080c08c0084c9263017001163021001301d37540082a666034601800226464a666040604600426493299980e180c980f1baa00113232323253330243027002132498cc0500048c8c94ccc08cc080c094dd500089919299981498160010a4c2c6eb8c0a8004c098dd50008b18128011bae3023001163756604a002604a0046eb4c08c004c07cdd50008b0b1810800980e9baa0041533301a3370e900400089919299981018118010a4c2c6eb8c084004c074dd50020b180d9baa00316301e001301e002301c001301c002375c603400260340046eb4c060004c050dd50050a999808980380089919299980b980d0010a4c2c6eb4c060004c050dd50050a99980898020008a99980a980a1baa00a14985854ccc044c00c00454ccc054c050dd50050a4c2c2c60246ea80248c94ccc044c0380044c8c94ccc05cc06800852616375c603000260286ea800854ccc044c01c0044c8c94ccc05cc06800852616375c603000260286ea800858c048dd50009b8748018dc3a400844646600200200644a66602800229309919801801980c0011801980b00091929998069805000899192999809980b00109924c60160022c602800260206ea800854ccc034c00c0044c8c94ccc04cc0580084c9263006001163014001301037540042c601c6ea8004dc3a40044a666014600e60186ea80044c8c94ccc040c04c0084c9263004001163011001300d37540022c4a666012600c60166ea80044c8c8c8c94ccc044c05000852616375c602400260240046eb8c040004c030dd50008b2999803180198041baa004132323232323232323232323253330163019002132498c03402458dd6980b800980b8011bad30150013015002375a602600260260046eb4c044004c044008c03c004c03c008dd6980680098049baa004162533300630033008375400226464646464646464646464646464646464646464a66603c604200426493180b0058b1bad301f001301f002375a603a002603a0046eb4c06c004c06c008dd6980c800980c8011bad3017001301700230150013015002375a602600260260046eb4c044004c044008dd6980780098078011bad300d001300937540022c4a66600a6004600e6ea80044c8c94ccc02cc03800852616375a601800260106ea800458dc3a4000ae695ce2ab9d5573caae7d5d02ba157441"
6347
+ };
6348
+
6349
+ // src/contracts/gov/scripts.ts
6350
+ var mkGovValidatorFromSP = (params) => {
6351
+ return {
6352
+ type: "PlutusV2",
6353
+ script: (0, import_lucid56.applyParamsToScript)(_governanceValidator.cborHex, [
6354
+ castGovParams({
6355
+ gBiasTime: BigInt(params.gBiasTime),
6356
+ govNFT: fromSystemParamsAsset(params.govNFT),
6357
+ pollToken: fromSystemParamsAsset(params.pollToken),
6358
+ upgradeToken: fromSystemParamsAsset(params.upgradeToken),
6359
+ indyAsset: fromSystemParamsAsset(params.indyAsset),
6360
+ versionRecordToken: fromSystemParamsAsset(params.versionRecordToken),
6361
+ pollManagerValHash: params.pollManagerValHash,
6362
+ daoIdentityToken: fromSystemParamsAsset(params.daoIdentityToken),
6363
+ iAssetAuthToken: fromSystemParamsAsset(params.iAssetAuthToken)
6364
+ })
6365
+ ])
6366
+ };
6367
+ };
6368
+
6369
+ // src/contracts/initialize/transactions.ts
6370
+ async function mintOneTimeToken(lucid, tokenName, amount) {
6371
+ const utxos = await lucid.wallet().getUtxos();
6372
+ return await runOneShotMintTx(lucid, {
6373
+ referenceOutRef: {
6374
+ txHash: utxos[0].txHash,
6375
+ outputIdx: BigInt(utxos[0].outputIndex)
6376
+ },
6377
+ mintAmounts: [{ tokenName, amount }]
6378
+ });
6379
+ }
6380
+ async function initScriptRef(lucid, validator) {
6381
+ const tx = lucid.newTx().pay.ToContract(
6382
+ (0, import_lucid57.credentialToAddress)(lucid.config().network, {
6383
+ hash: ALWAYS_FAIL_VALIDATOR_HASH,
6384
+ type: "Script"
6385
+ }),
6386
+ void 0,
6387
+ void 0,
6388
+ validator
6389
+ );
6390
+ const txHash = await submitAndAwaitTx(lucid, tx);
6391
+ return { transactionId: txHash, index: 0 };
6392
+ }
6393
+ async function initCollector(lucid, collectorParams) {
6394
+ const tx = lucid.newTx();
6395
+ for (let i = 0; i < Number(NUM_COLLECTORS); i++) {
6396
+ tx.pay.ToContract(
6397
+ createScriptAddress(
6398
+ lucid.config().network,
6399
+ (0, import_lucid57.validatorToScriptHash)(mkCollectorValidatorFromSP(collectorParams))
6400
+ ),
6401
+ {
6402
+ kind: "inline",
6403
+ value: import_lucid57.Data.to(new import_lucid57.Constr(0, []))
6404
+ }
6405
+ );
6406
+ }
6407
+ await submitAndAwaitTx(lucid, tx);
6408
+ }
6409
+ async function initCDPCreator(lucid, cdpCreatorParams) {
6410
+ const tx = lucid.newTx();
6411
+ for (let i = 0; i < Number(NUM_CDP_CREATORS); i++) {
6412
+ tx.pay.ToContract(
6413
+ (0, import_lucid57.credentialToAddress)(lucid.config().network, {
6414
+ hash: (0, import_lucid57.validatorToScriptHash)(
6415
+ mkCDPCreatorValidatorFromSP(cdpCreatorParams)
6416
+ ),
6417
+ type: "Script"
6418
+ }),
6419
+ { kind: "inline", value: import_lucid57.Data.to(new import_lucid57.Constr(0, [])) },
6420
+ {
6421
+ [cdpCreatorParams.cdpCreatorNft[0].unCurrencySymbol + (0, import_lucid57.fromText)(cdpCreatorParams.cdpCreatorNft[1].unTokenName)]: 1n
6422
+ }
6423
+ );
6424
+ }
6425
+ await submitAndAwaitTx(lucid, tx);
6426
+ }
6427
+ async function initTreasury(lucid, treasuryParams, daoAsset, indyAsset, treasuryIndyAmount) {
6428
+ const tx = lucid.newTx().pay.ToContract(
6429
+ (0, import_lucid57.credentialToAddress)(lucid.config().network, {
6430
+ hash: (0, import_lucid57.validatorToScriptHash)(mkTreasuryValidatorFromSP(treasuryParams)),
6431
+ type: "Script"
6432
+ }),
6433
+ { kind: "inline", value: import_lucid57.Data.to(new import_lucid57.Constr(0, [])) },
6434
+ {
6435
+ [daoAsset.currencySymbol + daoAsset.tokenName]: 1n,
6436
+ [indyAsset.currencySymbol + indyAsset.tokenName]: treasuryIndyAmount
6437
+ }
6438
+ );
6439
+ await submitAndAwaitTx(lucid, tx);
6440
+ }
6441
+ async function initStakingManager(lucid, stakingParams) {
6442
+ const tx = lucid.newTx().pay.ToContract(
6443
+ createScriptAddress(
6444
+ lucid.config().network,
6445
+ (0, import_lucid57.validatorToScriptHash)(mkStakingValidatorFromSP(stakingParams))
6446
+ ),
6447
+ {
6448
+ kind: "inline",
6449
+ value: serialiseStakingDatum({
6450
+ totalStake: 0n,
6451
+ managerSnapshot: { snapshotAda: 0n }
6452
+ })
6453
+ },
6454
+ {
6455
+ lovelace: 5000000n,
6456
+ [stakingParams.stakingManagerNFT[0].unCurrencySymbol + (0, import_lucid57.fromText)(stakingParams.stakingManagerNFT[1].unTokenName)]: 1n
6457
+ }
6458
+ );
6459
+ await submitAndAwaitTx(lucid, tx);
6460
+ }
6461
+ async function initializeAsset(lucid, cdpParams, iassetToken, stabilityPoolParams, stabilityPoolToken, asset, now = Date.now()) {
6462
+ const [pkh] = await addrDetails(lucid);
6463
+ const priceOracleParams = {
6464
+ owner: pkh.hash,
6465
+ biasTime: asset.priceOracle.params.biasTime,
6466
+ expiration: asset.priceOracle.params.expirationTime
6467
+ };
6468
+ const [priceOracleStartTx, priceOracleNft] = await startPriceOracleTx(
6469
+ lucid,
6470
+ asset.name + "_ORACLE",
6471
+ {
6472
+ getOnChainInt: asset.priceOracle.startPrice
6473
+ },
6474
+ priceOracleParams,
6475
+ now
6476
+ );
6477
+ await submitAndAwaitTx(lucid, priceOracleStartTx);
6478
+ const interestOracleTokenName = asset.name + "_ORACLE";
6479
+ const [startInterestOracleTx, interestOracleNft] = await startInterestOracle(
6480
+ 0n,
6481
+ asset.interestOracle.initialInterestRate,
6482
+ 0n,
6483
+ {
6484
+ owner: pkh.hash,
6485
+ biasTime: asset.priceOracle.params.biasTime
6486
+ },
6487
+ lucid,
6488
+ interestOracleTokenName
6489
+ );
6490
+ await submitAndAwaitTx(lucid, startInterestOracleTx);
6491
+ const iassetDatum = {
6492
+ assetName: (0, import_lucid57.fromText)(asset.name),
6493
+ price: {
6494
+ Oracle: {
6495
+ content: priceOracleNft
6496
+ }
6497
+ },
6498
+ interestOracleNft,
6499
+ redemptionRatio: { getOnChainInt: asset.redemptionRatioPercentage },
6500
+ maintenanceRatio: { getOnChainInt: asset.maintenanceRatioPercentage },
6501
+ liquidationRatio: { getOnChainInt: asset.liquidationRatioPercentage },
6502
+ debtMintingFeePercentage: { getOnChainInt: asset.debtMintingFeePercentage },
6503
+ liquidationProcessingFeePercentage: {
6504
+ getOnChainInt: asset.liquidationProcessingFeePercentage
6505
+ },
6506
+ stabilityPoolWithdrawalFeePercentage: {
6507
+ getOnChainInt: asset.stabilityPoolWithdrawalFeePercentage
6508
+ },
6509
+ redemptionReimbursementPercentage: {
6510
+ getOnChainInt: asset.redemptionReimbursementPercentage
6511
+ },
6512
+ redemptionProcessingFeePercentage: {
6513
+ getOnChainInt: asset.redemptionProcessingFeePercentage
6514
+ },
6515
+ interestCollectorPortionPercentage: {
6516
+ getOnChainInt: asset.interestCollectorPortionPercentage
6517
+ },
6518
+ firstIAsset: true,
6519
+ nextIAsset: asset.nextAsset ? (0, import_lucid57.fromText)(asset.nextAsset) : null
6520
+ };
6521
+ const assetTx = lucid.newTx().pay.ToContract(
6522
+ createScriptAddress(
6523
+ lucid.config().network,
6524
+ (0, import_lucid57.validatorToScriptHash)(mkCdpValidatorFromSP(cdpParams))
6525
+ ),
6526
+ { kind: "inline", value: serialiseIAssetDatum(iassetDatum) },
6527
+ { [iassetToken.currencySymbol + iassetToken.tokenName]: 1n }
6528
+ );
6529
+ await submitAndAwaitTx(lucid, assetTx);
6530
+ const stabilityPoolDatum = {
6531
+ asset: (0, import_lucid57.fromHex)((0, import_lucid57.fromText)(asset.name)),
6532
+ poolSnapshot: initSpSnapshot,
6533
+ epochToScaleToSum: initEpochToScaleToSumMap()
6534
+ };
6535
+ const spTx = lucid.newTx().pay.ToContract(
6536
+ (0, import_lucid57.credentialToAddress)(lucid.config().network, {
6537
+ hash: (0, import_lucid57.validatorToScriptHash)(
6538
+ mkStabilityPoolValidatorFromSP(stabilityPoolParams)
6539
+ ),
6540
+ type: "Script"
6541
+ }),
6542
+ {
6543
+ kind: "inline",
6544
+ value: serialiseStabilityPoolDatum({ StabilityPool: stabilityPoolDatum })
6545
+ },
6546
+ {
6547
+ [stabilityPoolToken.currencySymbol + stabilityPoolToken.tokenName]: 1n
6548
+ }
6549
+ );
6550
+ await submitAndAwaitTx(lucid, spTx);
6551
+ return { iassetTokenNameAscii: asset.name, oracleParams: priceOracleParams };
6552
+ }
6553
+ async function initGovernance(lucid, governanceParams, govToken, initialAssets) {
6554
+ const datum = {
6555
+ currentProposal: 0n,
6556
+ currentVersion: 0n,
6557
+ protocolParams: {
6558
+ effectiveDelay: 1000n,
6559
+ expirationPeriod: 180000n,
6560
+ proposalDeposit: 1000n,
6561
+ proposingPeriod: 100000n,
6562
+ collateralFeePercentage: {
6563
+ getOnChainInt: 1500000n
6564
+ },
6565
+ votingPeriod: 1000000n,
6566
+ totalShards: 4n,
6567
+ minimumQuorum: 100000n,
6568
+ maxTreasuryLovelaceSpend: 10000000n,
6569
+ maxTreasuryIndySpend: 10000000n
6570
+ },
6571
+ activeProposals: 0n,
6572
+ treasuryIndyWithdrawnAmt: 0n,
6573
+ iassetsCount: BigInt(initialAssets.length)
6574
+ };
6575
+ const tx = lucid.newTx().pay.ToContract(
6576
+ (0, import_lucid57.credentialToAddress)(lucid.config().network, {
6577
+ hash: (0, import_lucid57.validatorToScriptHash)(mkGovValidatorFromSP(governanceParams)),
6578
+ type: "Script"
6579
+ }),
6580
+ { kind: "inline", value: serialiseGovDatum(datum) },
6581
+ {
6582
+ [govToken.currencySymbol + govToken.tokenName]: 1n
6583
+ }
6584
+ );
6585
+ await submitAndAwaitTx(lucid, tx);
6586
+ }
6587
+ async function mintAuthTokenDirect(lucid, asset, tokenName, amount) {
6588
+ const script = mkAuthTokenPolicy(asset, (0, import_lucid57.fromText)(tokenName));
6589
+ const policyId = (0, import_lucid57.mintingPolicyToId)(script);
6590
+ const address = await lucid.wallet().address();
6591
+ const utxos = await lucid.utxosAtWithUnit(
6592
+ address,
6593
+ asset.currencySymbol + asset.tokenName
6594
+ );
6595
+ if (utxos.length === 0) {
6596
+ throw new Error("No utxos found");
6597
+ }
6598
+ const tx = lucid.newTx().attach.MintingPolicy(script).collectFrom(utxos).mintAssets(
6599
+ {
6600
+ [policyId + (0, import_lucid57.fromText)(tokenName)]: amount
6601
+ },
6602
+ import_lucid57.Data.to(new import_lucid57.Constr(0, []))
6603
+ );
6604
+ await submitAndAwaitTx(lucid, tx);
6605
+ }
6606
+ async function init(lucid, initialAssets, now = Date.now()) {
6607
+ const indyAsset = {
6608
+ currencySymbol: await mintOneTimeToken(
6609
+ lucid,
6610
+ (0, import_lucid57.fromText)(INDY_TOKEN_NAME),
6611
+ TOTAL_INDY_SUPPLY
6612
+ ),
6613
+ tokenName: (0, import_lucid57.fromText)(INDY_TOKEN_NAME)
6614
+ };
6615
+ const daoAsset = {
6616
+ currencySymbol: await mintOneTimeToken(lucid, (0, import_lucid57.fromText)(DAO_TOKEN_NAME), 1n),
6617
+ tokenName: (0, import_lucid57.fromText)(DAO_TOKEN_NAME)
6618
+ };
6619
+ const govNftAsset = {
6620
+ currencySymbol: await mintOneTimeToken(
6621
+ lucid,
6622
+ (0, import_lucid57.fromText)(GOV_NFT_TOKEN_NAME),
6623
+ 1n
6624
+ ),
6625
+ tokenName: (0, import_lucid57.fromText)(GOV_NFT_TOKEN_NAME)
6626
+ };
6627
+ const pollTokenPolicy = mkAuthTokenPolicy(
6628
+ govNftAsset,
6629
+ (0, import_lucid57.fromText)(POLL_MANAGER_TOKEN_NAME)
6630
+ );
6631
+ const pollToken = {
6632
+ currencySymbol: (0, import_lucid57.mintingPolicyToId)(pollTokenPolicy),
6633
+ tokenName: (0, import_lucid57.fromText)(POLL_MANAGER_TOKEN_NAME)
6634
+ };
6635
+ const upgradeTokenPolicy = mkAuthTokenPolicy(
6636
+ pollToken,
6637
+ (0, import_lucid57.fromText)(UPGRADE_TOKEN_NAME)
6638
+ );
6639
+ const upgradeToken = {
6640
+ currencySymbol: (0, import_lucid57.mintingPolicyToId)(upgradeTokenPolicy),
6641
+ tokenName: (0, import_lucid57.fromText)(UPGRADE_TOKEN_NAME)
6642
+ };
6643
+ const iassetTokenPolicy = mkAuthTokenPolicy(
6644
+ upgradeToken,
6645
+ (0, import_lucid57.fromText)(IASSET_TOKEN_NAME)
6646
+ );
6647
+ const iassetToken = {
6648
+ currencySymbol: (0, import_lucid57.mintingPolicyToId)(iassetTokenPolicy),
6649
+ tokenName: (0, import_lucid57.fromText)(IASSET_TOKEN_NAME)
6650
+ };
6651
+ const stabilityPoolTokenPolicy = mkAuthTokenPolicy(
6652
+ upgradeToken,
6653
+ (0, import_lucid57.fromText)(STABILITY_POOL_TOKEN_NAME)
6654
+ );
6655
+ const stabilityPoolToken = {
6656
+ currencySymbol: (0, import_lucid57.mintingPolicyToId)(stabilityPoolTokenPolicy),
6657
+ tokenName: (0, import_lucid57.fromText)(STABILITY_POOL_TOKEN_NAME)
6658
+ };
6659
+ const versionRecordParams = {
6660
+ upgradeToken: toSystemParamsAsset(upgradeToken)
6661
+ };
6662
+ const versionRecordTokenPolicy = mkVersionRecordTokenPolicy({
6663
+ upgradeToken
6664
+ });
6665
+ const versionRecordToken = {
6666
+ currencySymbol: (0, import_lucid57.mintingPolicyToId)(versionRecordTokenPolicy),
6667
+ tokenName: (0, import_lucid57.fromText)(VERSION_RECORD_TOKEN_NAME)
6668
+ };
6669
+ const versionRegistryValidator = mkVersionRegistryValidator();
6670
+ const versionRegistryValHash = (0, import_lucid57.validatorToScriptHash)(
6671
+ versionRegistryValidator
6672
+ );
6673
+ const cdpCreatorAsset = {
6674
+ currencySymbol: await mintOneTimeToken(
6675
+ lucid,
6676
+ (0, import_lucid57.fromText)(CDP_CREATOR_TOKEN_NAME),
6677
+ NUM_CDP_CREATORS
6678
+ ),
6679
+ tokenName: (0, import_lucid57.fromText)(CDP_CREATOR_TOKEN_NAME)
6680
+ };
6681
+ const cdpTokenPolicy = mkAuthTokenPolicy(
6682
+ cdpCreatorAsset,
6683
+ (0, import_lucid57.fromText)(CDP_TOKEN_NAME)
6684
+ );
6685
+ const cdpToken = {
6686
+ currencySymbol: (0, import_lucid57.mintingPolicyToId)(cdpTokenPolicy),
6687
+ tokenName: (0, import_lucid57.fromText)(CDP_TOKEN_NAME)
6688
+ };
6689
+ const stakingManagerAsset = {
6690
+ currencySymbol: await mintOneTimeToken(
6691
+ lucid,
6692
+ (0, import_lucid57.fromText)(STAKING_MANAGER_TOKEN_NAME),
6693
+ 1n
6694
+ ),
6695
+ tokenName: (0, import_lucid57.fromText)(STAKING_MANAGER_TOKEN_NAME)
6696
+ };
6697
+ const stakingTokenPolicy = mkAuthTokenPolicy(
6698
+ stakingManagerAsset,
6699
+ (0, import_lucid57.fromText)(STAKING_TOKEN_NAME)
6700
+ );
6701
+ const stakingToken = {
6702
+ currencySymbol: (0, import_lucid57.mintingPolicyToId)(stakingTokenPolicy),
6703
+ tokenName: (0, import_lucid57.fromText)(STAKING_TOKEN_NAME)
6704
+ };
6705
+ const collectorParams = {
6706
+ stakingManagerNFT: toSystemParamsAsset(stakingManagerAsset),
6707
+ stakingToken: toSystemParamsAsset(stakingToken),
6708
+ versionRecordToken: toSystemParamsAsset(versionRecordToken)
6709
+ };
6710
+ const collectorValidator = mkCollectorValidatorFromSP(collectorParams);
6711
+ const collectorValHash = (0, import_lucid57.validatorToScriptHash)(collectorValidator);
6712
+ const stakingParams = {
6713
+ stakingManagerNFT: toSystemParamsAsset(stakingManagerAsset),
6714
+ stakingToken: toSystemParamsAsset(stakingToken),
6715
+ versionRecordToken: toSystemParamsAsset(versionRecordToken),
6716
+ pollToken: toSystemParamsAsset(pollToken),
6717
+ indyToken: toSystemParamsAsset(indyAsset),
6718
+ collectorValHash
6719
+ };
6720
+ const stakingValHash = (0, import_lucid57.validatorToScriptHash)(
6721
+ mkStakingValidatorFromSP(stakingParams)
6722
+ );
6723
+ await initStakingManager(lucid, stakingParams);
6724
+ const assetSymbolPolicy = mkIAssetTokenPolicy(cdpToken);
6725
+ const assetSymbol = (0, import_lucid57.mintingPolicyToId)(assetSymbolPolicy);
6726
+ const snapshotEpochToScaleToSumTokenPolicy = mkAuthTokenPolicy(
6727
+ stabilityPoolToken,
6728
+ (0, import_lucid57.fromText)(SNAPSHOT_EPOCH_TO_SCALE_TO_SUM_TOKEN_NAME)
6729
+ );
6730
+ const snapshotEpochToScaleToSumToken = {
6731
+ currencySymbol: (0, import_lucid57.mintingPolicyToId)(snapshotEpochToScaleToSumTokenPolicy),
6732
+ tokenName: (0, import_lucid57.fromText)(SNAPSHOT_EPOCH_TO_SCALE_TO_SUM_TOKEN_NAME)
6733
+ };
6734
+ const accountTokenPolicy = mkAuthTokenPolicy(
6735
+ stabilityPoolToken,
6736
+ (0, import_lucid57.fromText)(ACCOUNT_TOKEN_NAME)
6737
+ );
6738
+ const accountToken = {
6739
+ currencySymbol: (0, import_lucid57.mintingPolicyToId)(accountTokenPolicy),
6740
+ tokenName: (0, import_lucid57.fromText)(ACCOUNT_TOKEN_NAME)
6741
+ };
6742
+ const stabilityPoolParams = {
6743
+ assetSymbol: { unCurrencySymbol: assetSymbol },
6744
+ stabilityPoolToken: toSystemParamsAsset(stabilityPoolToken),
6745
+ snapshotEpochToScaleToSumToken: toSystemParamsAsset(
6746
+ snapshotEpochToScaleToSumToken
6747
+ ),
6748
+ accountToken: toSystemParamsAsset(accountToken),
6749
+ cdpToken: toSystemParamsAsset(cdpToken),
6750
+ iAssetAuthToken: toSystemParamsAsset(iassetToken),
6751
+ versionRecordToken: toSystemParamsAsset(versionRecordToken),
6752
+ collectorValHash,
6753
+ govNFT: toSystemParamsAsset(govNftAsset),
6754
+ accountCreateFeeLovelaces: 5e6,
6755
+ accountAdjustmentFeeLovelaces: 5e6,
6756
+ requestCollateralLovelaces: 5e6
6757
+ };
6758
+ const stabilityPoolValidator = mkStabilityPoolValidatorFromSP(stabilityPoolParams);
6759
+ const stabilityPoolValHash = (0, import_lucid57.validatorToScriptHash)(stabilityPoolValidator);
6760
+ const treasuryParams = {
6761
+ upgradeToken: toSystemParamsAsset(upgradeToken),
6762
+ versionRecordToken: toSystemParamsAsset(versionRecordToken),
6763
+ treasuryUtxosStakeCredential: void 0
6764
+ };
6765
+ const treasuryValidator = mkTreasuryValidatorFromSP(treasuryParams);
6766
+ const treasuryValHash = (0, import_lucid57.validatorToScriptHash)(treasuryValidator);
6767
+ await initTreasury(
6768
+ lucid,
6769
+ treasuryParams,
6770
+ daoAsset,
6771
+ indyAsset,
6772
+ TREASURY_INDY_AMOUNT
6773
+ );
6774
+ const cdpParams = {
6775
+ cdpAuthToken: toSystemParamsAsset(cdpToken),
6776
+ cdpAssetSymbol: { unCurrencySymbol: assetSymbol },
6777
+ iAssetAuthToken: toSystemParamsAsset(iassetToken),
6778
+ stabilityPoolAuthToken: toSystemParamsAsset(stabilityPoolToken),
6779
+ versionRecordToken: toSystemParamsAsset(versionRecordToken),
6780
+ upgradeToken: toSystemParamsAsset(upgradeToken),
6781
+ collectorValHash,
6782
+ spValHash: stabilityPoolValHash,
6783
+ govNFT: toSystemParamsAsset(govNftAsset),
6784
+ minCollateralInLovelace: 1e7,
6785
+ partialRedemptionExtraFeeLovelace: 1e7,
6786
+ biasTime: 18e4,
6787
+ treasuryValHash
6788
+ };
6789
+ const cdpValHash = (0, import_lucid57.validatorToScriptHash)(mkCdpValidatorFromSP(cdpParams));
6790
+ const cdpCreatorParams = {
6791
+ cdpCreatorNft: toSystemParamsAsset(cdpCreatorAsset),
6792
+ cdpAssetCs: { unCurrencySymbol: assetSymbol },
6793
+ cdpAuthTk: toSystemParamsAsset(cdpToken),
6794
+ iAssetAuthTk: toSystemParamsAsset(iassetToken),
6795
+ versionRecordToken: toSystemParamsAsset(versionRecordToken),
6796
+ cdpScriptHash: cdpValHash,
6797
+ collectorValHash,
6798
+ minCollateralInLovelace: 1e7,
6799
+ biasTime: 180000n
6800
+ };
6801
+ const cdpCreatorValidator = mkCDPCreatorValidatorFromSP(cdpCreatorParams);
6802
+ const cdpCreatorValHash = (0, import_lucid57.validatorToScriptHash)(cdpCreatorValidator);
6803
+ await initCDPCreator(lucid, cdpCreatorParams);
6804
+ await initCollector(lucid, collectorParams);
6805
+ const assetInfos = [];
6806
+ if (initialAssets.length > 0) {
6807
+ await mintAuthTokenDirect(lucid, govNftAsset, POLL_MANAGER_TOKEN_NAME, 1n);
6808
+ await mintAuthTokenDirect(lucid, pollToken, UPGRADE_TOKEN_NAME, 1n);
6809
+ for (const asset of initialAssets) {
6810
+ await mintAuthTokenDirect(lucid, upgradeToken, IASSET_TOKEN_NAME, 1n);
6811
+ await mintAuthTokenDirect(
6812
+ lucid,
6813
+ upgradeToken,
6814
+ STABILITY_POOL_TOKEN_NAME,
6815
+ 1n
6816
+ );
6817
+ const assetInfo = await initializeAsset(
6818
+ lucid,
6819
+ cdpParams,
6820
+ iassetToken,
6821
+ stabilityPoolParams,
6822
+ stabilityPoolToken,
6823
+ asset,
6824
+ now
6825
+ );
6826
+ assetInfos.push(assetInfo);
6827
+ }
6828
+ await mintAuthTokenDirect(lucid, pollToken, UPGRADE_TOKEN_NAME, -1n);
6829
+ await mintAuthTokenDirect(lucid, govNftAsset, POLL_MANAGER_TOKEN_NAME, -1n);
6830
+ }
6831
+ const executeParams = {
6832
+ govNFT: toSystemParamsAsset(govNftAsset),
6833
+ upgradeToken: toSystemParamsAsset(upgradeToken),
6834
+ iAssetToken: toSystemParamsAsset(iassetToken),
6835
+ stabilityPoolToken: toSystemParamsAsset(stabilityPoolToken),
6836
+ versionRecordToken: toSystemParamsAsset(versionRecordToken),
6837
+ cdpValHash,
6838
+ sPoolValHash: stabilityPoolValHash,
6839
+ versionRegistryValHash,
6840
+ treasuryValHash,
6841
+ indyAsset: toSystemParamsAsset(indyAsset)
6842
+ };
6843
+ const executeValidator = mkExecuteValidatorFromSP(executeParams);
6844
+ const executeValHash = (0, import_lucid57.validatorToScriptHash)(executeValidator);
6845
+ const pollShardParams = {
6846
+ pollToken: toSystemParamsAsset(pollToken),
6847
+ stakingToken: toSystemParamsAsset(stakingToken),
6848
+ indyAsset: toSystemParamsAsset(indyAsset),
6849
+ stakingValHash
6850
+ };
6851
+ const pollShardValidator = mkPollShardValidatorFromSP(pollShardParams);
6852
+ const pollShardValHash = (0, import_lucid57.validatorToScriptHash)(pollShardValidator);
6853
+ const pollManagerParams = {
6854
+ govNFT: toSystemParamsAsset(govNftAsset),
6855
+ pollToken: toSystemParamsAsset(pollToken),
6856
+ upgradeToken: toSystemParamsAsset(upgradeToken),
6857
+ indyAsset: toSystemParamsAsset(indyAsset),
6858
+ govExecuteValHash: executeValHash,
6859
+ pBiasTime: 120000n,
6860
+ shardsValHash: pollShardValHash,
6861
+ treasuryValHash,
6862
+ initialIndyDistribution: 1575000000000n
6863
+ };
6864
+ const pollManagerValidator = mkPollManagerValidatorFromSP(pollManagerParams);
6865
+ const pollManagerValHash = (0, import_lucid57.validatorToScriptHash)(pollManagerValidator);
6866
+ const govParams = {
6867
+ gBiasTime: 120000n,
6868
+ govNFT: toSystemParamsAsset(govNftAsset),
6869
+ pollToken: toSystemParamsAsset(pollToken),
6870
+ upgradeToken: toSystemParamsAsset(upgradeToken),
6871
+ indyAsset: toSystemParamsAsset(indyAsset),
6872
+ versionRecordToken: toSystemParamsAsset(versionRecordToken),
6873
+ pollManagerValHash,
6874
+ daoIdentityToken: toSystemParamsAsset(daoAsset),
6875
+ iAssetAuthToken: toSystemParamsAsset(iassetToken)
6876
+ };
6877
+ const govValidator = mkGovValidatorFromSP(govParams);
6878
+ const govValHash = (0, import_lucid57.validatorToScriptHash)(govValidator);
6879
+ await initGovernance(lucid, govParams, govNftAsset, initialAssets);
6880
+ const lrpParams = {
6881
+ iassetNft: cdpParams.iAssetAuthToken,
6882
+ iassetPolicyId: cdpParams.cdpAssetSymbol,
6883
+ minRedemptionLovelacesAmt: 10000000n,
6884
+ versionRecordToken: cdpParams.versionRecordToken
6885
+ };
6886
+ const lrpValidator = mkLrpValidatorFromSP(lrpParams);
6887
+ const lrpValHash = (0, import_lucid57.validatorToScriptHash)(lrpValidator);
6888
+ const scriptRefCalls = [
6889
+ () => initScriptRef(lucid, lrpValidator),
6890
+ () => initScriptRef(lucid, cdpCreatorValidator),
6891
+ () => initScriptRef(lucid, mkCdpValidatorFromSP(cdpParams)),
6892
+ () => initScriptRef(lucid, collectorValidator),
6893
+ () => initScriptRef(lucid, executeValidator),
6894
+ () => initScriptRef(lucid, govValidator),
6895
+ () => initScriptRef(lucid, pollShardValidator),
6896
+ () => initScriptRef(lucid, pollManagerValidator),
6897
+ () => initScriptRef(lucid, assetSymbolPolicy),
6898
+ () => initScriptRef(lucid, mkStakingValidatorFromSP(stakingParams)),
6899
+ () => initScriptRef(lucid, stabilityPoolValidator),
6900
+ () => initScriptRef(lucid, treasuryValidator),
6901
+ () => initScriptRef(lucid, govValidator),
6902
+ () => initScriptRef(lucid, versionRegistryValidator),
6903
+ () => initScriptRef(
6904
+ lucid,
6905
+ versionRecordTokenPolicy
6906
+ ),
6907
+ () => initScriptRef(lucid, cdpTokenPolicy),
6908
+ () => initScriptRef(lucid, iassetTokenPolicy),
6909
+ () => initScriptRef(lucid, accountTokenPolicy),
6910
+ () => initScriptRef(
6911
+ lucid,
6912
+ stabilityPoolTokenPolicy
6913
+ ),
6914
+ () => initScriptRef(lucid, pollTokenPolicy),
6915
+ () => initScriptRef(lucid, stakingTokenPolicy),
6916
+ () => initScriptRef(
6917
+ lucid,
6918
+ versionRecordTokenPolicy
6919
+ ),
6920
+ () => initScriptRef(lucid, assetSymbolPolicy),
6921
+ () => initScriptRef(lucid, upgradeTokenPolicy),
6922
+ () => initScriptRef(
6923
+ lucid,
6924
+ stabilityPoolTokenPolicy
6925
+ ),
6926
+ () => initScriptRef(
6927
+ lucid,
6928
+ snapshotEpochToScaleToSumTokenPolicy
6929
+ )
6930
+ ];
6931
+ const scriptRefInputs = [];
6932
+ for (const fn of scriptRefCalls) {
6933
+ scriptRefInputs.push(await fn());
6934
+ }
6935
+ const [
6936
+ lrpValidatorRef,
6937
+ cdpCreatorValidatorRef,
6938
+ cdpValidatorRef,
6939
+ collectorValidatorRef,
6940
+ executeValidatorRef,
6941
+ govValidatorRef,
6942
+ pollShardValidatorRef,
6943
+ pollManagerValidatorRef,
6944
+ iAssetTokenPolicyRef,
6945
+ stakingValidatorRef,
6946
+ stabilityPoolValidatorRef,
6947
+ treasuryValidatorRef,
6948
+ governanceValidatorRef,
6949
+ versionRegistryValidatorRef,
6950
+ versionRecordTokenPolicyRef,
6951
+ cdpAuthTokenRef,
6952
+ iAssetAuthTokenRef,
6953
+ accountTokenRef,
6954
+ stabilityPoolAuthTokenRef,
6955
+ pollManagerTokenRef,
6956
+ stakingTokenRef,
6957
+ versionRecordTokenRef,
6958
+ iAssetTokenRef,
6959
+ upgradeTokenRef,
6960
+ stabilityPoolTokenRef,
6961
+ snapshotEpochToScaleToSumTokenRef
6962
+ ] = scriptRefInputs;
6963
+ return [
6964
+ {
6965
+ cdpParams,
6966
+ cdpCreatorParams,
6967
+ collectorParams,
6968
+ executeParams,
6969
+ govParams,
6970
+ stakingParams,
6971
+ stabilityPoolParams,
6972
+ treasuryParams,
6973
+ pollShardParams,
6974
+ pollManagerParams,
6975
+ indyToken: toSystemParamsAsset(indyAsset),
6976
+ distributionParams: {
6977
+ treasuryIndyAmount: 1575e9,
6978
+ totalINDYSupply: 35e12,
6979
+ initialIndyDistribution: 1575e9
6980
+ },
6981
+ lrpParams,
6982
+ versionRecordParams,
6983
+ startTime: {
6984
+ slot: 0,
6985
+ blockHeader: ""
6986
+ },
6987
+ scriptReferences: {
6988
+ lrpValidatorRef: { input: lrpValidatorRef },
6989
+ cdpCreatorValidatorRef: { input: cdpCreatorValidatorRef },
6990
+ cdpValidatorRef: { input: cdpValidatorRef },
6991
+ collectorValidatorRef: { input: collectorValidatorRef },
6992
+ executeValidatorRef: { input: executeValidatorRef },
6993
+ govValidatorRef: { input: govValidatorRef },
6994
+ pollShardValidatorRef: { input: pollShardValidatorRef },
6995
+ pollManagerValidatorRef: { input: pollManagerValidatorRef },
6996
+ iAssetTokenPolicyRef: { input: iAssetTokenPolicyRef },
6997
+ stakingValidatorRef: { input: stakingValidatorRef },
6998
+ stabilityPoolValidatorRef: { input: stabilityPoolValidatorRef },
6999
+ treasuryValidatorRef: { input: treasuryValidatorRef },
7000
+ governanceValidatorRef: { input: governanceValidatorRef },
7001
+ versionRegistryValidatorRef: { input: versionRegistryValidatorRef },
7002
+ versionRecordTokenPolicyRef: { input: versionRecordTokenPolicyRef },
7003
+ authTokenPolicies: {
7004
+ cdpAuthTokenRef: { input: cdpAuthTokenRef },
7005
+ iAssetAuthTokenRef: { input: iAssetAuthTokenRef },
7006
+ accountTokenRef: { input: accountTokenRef },
7007
+ stabilityPoolAuthTokenRef: { input: stabilityPoolAuthTokenRef },
7008
+ pollManagerTokenRef: { input: pollManagerTokenRef },
7009
+ stakingTokenRef: { input: stakingTokenRef },
7010
+ versionRecordTokenRef: { input: versionRecordTokenRef },
7011
+ iAssetTokenRef: { input: iAssetTokenRef },
7012
+ upgradeTokenRef: { input: upgradeTokenRef },
7013
+ stabilityPoolTokenRef: { input: stabilityPoolTokenRef },
7014
+ snapshotEpochToScaleToSumTokenRef: {
7015
+ input: snapshotEpochToScaleToSumTokenRef
7016
+ }
7017
+ }
7018
+ },
7019
+ validatorHashes: {
7020
+ cdpCreatorHash: cdpCreatorValHash,
7021
+ cdpHash: cdpValHash,
7022
+ executeHash: executeValHash,
7023
+ govHash: govValHash,
7024
+ pollShardHash: pollShardValHash,
7025
+ pollManagerHash: pollManagerValHash,
7026
+ treasuryHash: treasuryValHash,
7027
+ stabilityPoolHash: stabilityPoolValHash,
7028
+ stakingHash: stakingValHash,
7029
+ collectorHash: collectorValHash,
7030
+ versionRegistryHash: versionRegistryValHash,
7031
+ lrpHash: lrpValHash
7032
+ }
7033
+ },
7034
+ assetInfos
7035
+ ];
7036
+ }
6206
7037
  // Annotate the CommonJS export names for ESM import in node:
6207
7038
  0 && (module.exports = {
7039
+ ACCOUNT_TOKEN_NAME,
7040
+ ALWAYS_FAIL_VALIDATOR_HASH,
6208
7041
  AccountContentSchema,
6209
7042
  ActionReturnDatum,
6210
7043
  ActionReturnDatumSchema,
@@ -6216,16 +7049,22 @@ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, i
6216
7049
  CDPCreatorRedeemer,
6217
7050
  CDPDatumSchema,
6218
7051
  CDPFeesSchema,
7052
+ CDP_CREATOR_TOKEN_NAME,
7053
+ CDP_TOKEN_NAME,
6219
7054
  CredentialD,
6220
7055
  CredentialSchema,
7056
+ DAO_TOKEN_NAME,
6221
7057
  EpochToScaleToSumSchema,
6222
7058
  ExecuteDatum,
6223
7059
  ExecuteParams,
6224
7060
  FeedInterestOracleRedeemerSchema,
7061
+ GOV_NFT_TOKEN_NAME,
6225
7062
  GovParams,
6226
7063
  GovRedeemer,
7064
+ IASSET_TOKEN_NAME,
6227
7065
  IAssetContentSchema,
6228
7066
  IAssetPriceInfoSchema,
7067
+ INDY_TOKEN_NAME,
6229
7068
  InterestOracleDatumSchema,
6230
7069
  InterestOracleParamsSchema,
6231
7070
  LRPDatumSchema,
@@ -6233,26 +7072,44 @@ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, i
6233
7072
  LRPRedeemerSchema,
6234
7073
  MAX_REDEMPTIONS_WITH_CDP_OPEN,
6235
7074
  MIN_LRP_COLLATERAL_AMT,
7075
+ NUM_CDP_CREATORS,
7076
+ NUM_COLLECTORS,
6236
7077
  ONE_DAY,
6237
7078
  ONE_HOUR,
6238
7079
  ONE_SECOND,
6239
7080
  ONE_YEAR,
6240
7081
  OracleAssetNftSchema,
6241
7082
  OutputReferenceSchema,
7083
+ POLL_MANAGER_TOKEN_NAME,
7084
+ PollDatum,
6242
7085
  PollManagerParams,
6243
7086
  PollManagerRedeemer,
6244
7087
  PollShardParams,
6245
7088
  PollShardRedeemer,
6246
7089
  PriceOracleDatumSchema,
6247
7090
  PriceOracleParamsSchema,
7091
+ ProposalContent,
7092
+ ProposalContentSchema,
7093
+ ProtocolParams,
7094
+ ProtocolParamsSchema,
7095
+ SNAPSHOT_EPOCH_TO_SCALE_TO_SUM_TOKEN_NAME,
6248
7096
  SPIntegerSchema,
7097
+ STABILITY_POOL_TOKEN_NAME,
7098
+ STAKING_MANAGER_TOKEN_NAME,
7099
+ STAKING_TOKEN_NAME,
6249
7100
  SnapshotEpochToScaleToSumContentSchema,
6250
7101
  StabilityPoolContentSchema,
6251
7102
  StabilityPoolDatumSchema,
6252
7103
  StabilityPoolParams,
6253
7104
  StabilityPoolRedeemerSchema,
6254
7105
  StakeCredentialSchema,
7106
+ TOTAL_INDY_SUPPLY,
7107
+ TREASURY_INDY_AMOUNT,
7108
+ TreasuryParams,
7109
+ TreasuryParamsSchema,
6255
7110
  TreasuryWithdrawalSchema,
7111
+ UPGRADE_TOKEN_NAME,
7112
+ VERSION_RECORD_TOKEN_NAME,
6256
7113
  VerificationKeyHashSchema,
6257
7114
  VersionRecordTokenParams,
6258
7115
  addrDetails,
@@ -6291,6 +7148,7 @@ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, i
6291
7148
  castPriceOracleParams,
6292
7149
  castStabilityPoolParams,
6293
7150
  castStakingParams,
7151
+ castTreasuryParams,
6294
7152
  castVersionRecordTokenParams,
6295
7153
  cdpCollateralRatioPercentage,
6296
7154
  claimLrp,
@@ -6322,6 +7180,7 @@ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, i
6322
7180
  getInlineDatumOrThrow,
6323
7181
  getRandomElement,
6324
7182
  getSumFromEpochToScaleToSum,
7183
+ init,
6325
7184
  initEpochToScaleToSumMap,
6326
7185
  initSpSnapshot,
6327
7186
  insertSorted,
@@ -6373,16 +7232,22 @@ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, i
6373
7232
  parseInterestOracleDatum,
6374
7233
  parseLrpDatum,
6375
7234
  parseLrpDatumOrThrow,
7235
+ parsePollManager,
7236
+ parsePollManagerOrThrow,
7237
+ parsePollShard,
7238
+ parsePollShardOrThrow,
6376
7239
  parsePriceOracleDatum,
6377
7240
  parseSnapshotEpochToScaleToSumDatum,
6378
7241
  parseStabilityPoolDatum,
6379
7242
  parseStakingManagerDatum,
6380
7243
  parseStakingPosition,
6381
7244
  parseStakingPositionOrThrow,
7245
+ parseUpgradePaths,
6382
7246
  processSpRequest,
6383
7247
  randomLrpsSubsetSatisfyingTargetLovelaces,
6384
7248
  redeemCdp,
6385
7249
  redeemLrp,
7250
+ resolveUtxo,
6386
7251
  rewardSnapshotPrecision,
6387
7252
  runCreateScriptRefTx,
6388
7253
  runOneShotMintTx,
@@ -6391,6 +7256,7 @@ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, i
6391
7256
  serialiseCDPCreatorRedeemer,
6392
7257
  serialiseCdpDatum,
6393
7258
  serialiseCdpRedeemer,
7259
+ serialiseCollectorRedeemer,
6394
7260
  serialiseExecuteDatum,
6395
7261
  serialiseFeedInterestOracleRedeemer,
6396
7262
  serialiseGovDatum,
@@ -6399,6 +7265,7 @@ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, i
6399
7265
  serialiseInterestOracleDatum,
6400
7266
  serialiseLrpDatum,
6401
7267
  serialiseLrpRedeemer,
7268
+ serialisePollDatum,
6402
7269
  serialisePollManagerRedeemer,
6403
7270
  serialisePollShardRedeemer,
6404
7271
  serialisePriceOracleDatum,
@@ -6407,6 +7274,10 @@ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, i
6407
7274
  serialiseStabilityPoolRedeemer,
6408
7275
  serialiseStakingDatum,
6409
7276
  serialiseStakingRedeemer,
7277
+ serialiseTreasuryDatum,
7278
+ serialiseTreasuryRedeemer,
7279
+ serialiseUpgradePaths,
7280
+ serialiseWithdrawalOutputDatum,
6410
7281
  setSumInEpochToScaleToSum,
6411
7282
  shuffle,
6412
7283
  spAdd,
@@ -6414,10 +7285,12 @@ async function leverageCdpWithLrp(leverage, baseCollateral, priceOracleOutRef, i
6414
7285
  spMul,
6415
7286
  spSub,
6416
7287
  startInterestOracle,
7288
+ submitAndAwaitTx,
6417
7289
  summarizeActualLeverageRedemptions,
6418
7290
  toSystemParamsAsset,
6419
7291
  treasuryFeeTx,
6420
7292
  updatePoolSnapshotWithdrawalFee,
7293
+ updateSlotConfigNetwork,
6421
7294
  updateStakingLockedAmount,
6422
7295
  vote,
6423
7296
  withdrawCdp