@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigo-labs/indigo-sdk",
3
- "version": "0.2.35",
3
+ "version": "0.2.37",
4
4
  "description": "Indigo SDK for interacting with Indigo endpoints via lucid-evolution",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -43,7 +43,6 @@
43
43
  "@3rd-eye-labs/cardano-offchain-common": "^1.1.8",
44
44
  "@evolution-sdk/evolution": "^0.2.5",
45
45
  "@harmoniclabs/crypto": "^0.3.0",
46
- "@lucid-evolution/lucid": "^0.4.29",
47
46
  "decimal.js": "^10.6.0",
48
47
  "dotenv": "^16.5.0",
49
48
  "fp-ts": "^2.16.10",
@@ -63,6 +62,10 @@
63
62
  "tsup": "^8.3.6",
64
63
  "typescript": "^5.9.2",
65
64
  "typescript-eslint": "^8.39.0",
66
- "vitest": "^4.0.14"
65
+ "vitest": "^4.0.14",
66
+ "@lucid-evolution/lucid": "^0.4.29"
67
+ },
68
+ "peerDependencies": {
69
+ "@lucid-evolution/lucid": ">=0.4.29"
67
70
  }
68
71
  }
@@ -17,6 +17,8 @@ import {
17
17
  addrDetails,
18
18
  createScriptAddress,
19
19
  getInlineDatumOrThrow,
20
+ resolveUtxo,
21
+ UtxoOrOutRef,
20
22
  } from '../../utils/lucid-utils';
21
23
  import { matchSingle } from '../../utils/utils';
22
24
  import {
@@ -61,11 +63,11 @@ export async function openCdp(
61
63
  collateralAmount: bigint,
62
64
  mintedAmount: bigint,
63
65
  sysParams: SystemParams,
64
- cdpCreatorOref: OutRef,
65
- iassetOref: OutRef,
66
- priceOracleOref: OutRef,
67
- interestOracleOref: OutRef,
68
- collectorOref: OutRef,
66
+ cdpCreator: UtxoOrOutRef,
67
+ iasset: UtxoOrOutRef,
68
+ priceOracle: UtxoOrOutRef,
69
+ interestOracle: UtxoOrOutRef,
70
+ collector: UtxoOrOutRef,
69
71
  lucid: LucidEvolution,
70
72
  currentSlot: number,
71
73
  ): Promise<TxBuilder> {
@@ -99,33 +101,37 @@ export async function openCdp(
99
101
  (_) => new Error('Expected a single iasset token policy Ref Script UTXO'),
100
102
  );
101
103
 
102
- const iassetUtxo = matchSingle(
103
- await lucid.utxosByOutRef([iassetOref]),
104
- (_) => new Error('Expected a single iasset UTXO'),
104
+ const iassetUtxo = await resolveUtxo(
105
+ iasset,
106
+ lucid,
107
+ 'Expected a single iasset UTXO',
105
108
  );
106
109
  const iassetDatum = parseIAssetDatumOrThrow(
107
110
  getInlineDatumOrThrow(iassetUtxo),
108
111
  );
109
112
 
110
- const priceOracleUtxo = matchSingle(
111
- await lucid.utxosByOutRef([priceOracleOref]),
112
- (_) => new Error('Expected a single price oracle UTXO'),
113
+ const priceOracleUtxo = await resolveUtxo(
114
+ priceOracle,
115
+ lucid,
116
+ 'Expected a single price oracle UTXO',
113
117
  );
114
118
  const priceOracleDatum = parsePriceOracleDatum(
115
119
  getInlineDatumOrThrow(priceOracleUtxo),
116
120
  );
117
121
 
118
- const interestOracleUtxo = matchSingle(
119
- await lucid.utxosByOutRef([interestOracleOref]),
120
- (_) => new Error('Expected a single interest oracle UTXO'),
122
+ const interestOracleUtxo = await resolveUtxo(
123
+ interestOracle,
124
+ lucid,
125
+ 'Expected a single interest oracle UTXO',
121
126
  );
122
127
  const interestOracleDatum = parseInterestOracleDatum(
123
128
  getInlineDatumOrThrow(interestOracleUtxo),
124
129
  );
125
130
 
126
- const cdpCreatorUtxo = matchSingle(
127
- await lucid.utxosByOutRef([cdpCreatorOref]),
128
- (_) => new Error('Expected a single CDP creator UTXO'),
131
+ const cdpCreatorUtxo = await resolveUtxo(
132
+ cdpCreator,
133
+ lucid,
134
+ 'Expected a single CDP creator UTXO',
129
135
  );
130
136
 
131
137
  match(iassetDatum.price)
@@ -212,7 +218,7 @@ export async function openCdp(
212
218
  );
213
219
 
214
220
  if (debtMintingFee > 0) {
215
- await collectorFeeTx(debtMintingFee, lucid, sysParams, tx, collectorOref);
221
+ await collectorFeeTx(debtMintingFee, lucid, sysParams, tx, collector);
216
222
  }
217
223
 
218
224
  return tx;
@@ -221,13 +227,13 @@ export async function openCdp(
221
227
  async function adjustCdp(
222
228
  collateralAmount: bigint,
223
229
  mintAmount: bigint,
224
- cdpOref: OutRef,
225
- iassetOref: OutRef,
226
- priceOracleOref: OutRef,
227
- interestOracleOref: OutRef,
228
- collectorOref: OutRef,
229
- govOref: OutRef,
230
- treasuryOref: OutRef,
230
+ cdp: UtxoOrOutRef,
231
+ iasset: UtxoOrOutRef,
232
+ priceOracle: UtxoOrOutRef,
233
+ interestOracle: UtxoOrOutRef,
234
+ collector: UtxoOrOutRef,
235
+ gov: UtxoOrOutRef,
236
+ treasury: UtxoOrOutRef,
231
237
  sysParams: SystemParams,
232
238
  lucid: LucidEvolution,
233
239
  currentSlot: number,
@@ -242,37 +248,34 @@ async function adjustCdp(
242
248
  (_) => new Error('Expected a single cdp Ref Script UTXO'),
243
249
  );
244
250
 
245
- const cdpUtxo = matchSingle(
246
- await lucid.utxosByOutRef([cdpOref]),
247
- (_) => new Error('Expected a single cdp UTXO'),
248
- );
251
+ const cdpUtxo = await resolveUtxo(cdp, lucid, 'Expected a single cdp UTXO');
249
252
  const cdpDatum = parseCdpDatumOrThrow(getInlineDatumOrThrow(cdpUtxo));
250
253
 
251
- const iassetUtxo = matchSingle(
252
- await lucid.utxosByOutRef([iassetOref]),
253
- (_) => new Error('Expected a single iasset UTXO'),
254
+ const iassetUtxo = await resolveUtxo(
255
+ iasset,
256
+ lucid,
257
+ 'Expected a single iasset UTXO',
254
258
  );
255
259
  const iassetDatum = parseIAssetDatumOrThrow(
256
260
  getInlineDatumOrThrow(iassetUtxo),
257
261
  );
258
262
 
259
- const govUtxo = matchSingle(
260
- await lucid.utxosByOutRef([govOref]),
261
- (_) => new Error('Expected a single gov UTXO'),
262
- );
263
+ const govUtxo = await resolveUtxo(gov, lucid, 'Expected a single gov UTXO');
263
264
  const govDatum = parseGovDatumOrThrow(getInlineDatumOrThrow(govUtxo));
264
265
 
265
- const priceOracleUtxo = matchSingle(
266
- await lucid.utxosByOutRef([priceOracleOref]),
267
- (_) => new Error('Expected a single price oracle UTXO'),
266
+ const priceOracleUtxo = await resolveUtxo(
267
+ priceOracle,
268
+ lucid,
269
+ 'Expected a single price oracle UTXO',
268
270
  );
269
271
  const priceOracleDatum = parsePriceOracleDatum(
270
272
  getInlineDatumOrThrow(priceOracleUtxo),
271
273
  );
272
274
 
273
- const interestOracleUtxo = matchSingle(
274
- await lucid.utxosByOutRef([interestOracleOref]),
275
- (_) => new Error('Expected a single interest oracle UTXO'),
275
+ const interestOracleUtxo = await resolveUtxo(
276
+ interestOracle,
277
+ lucid,
278
+ 'Expected a single interest oracle UTXO',
276
279
  );
277
280
  const interestOracleDatum = parseInterestOracleDatum(
278
281
  getInlineDatumOrThrow(interestOracleUtxo),
@@ -388,13 +391,7 @@ async function adjustCdp(
388
391
  const interestTreasuryAdaAmt = interestAdaAmt - interestCollectorAdaAmt;
389
392
 
390
393
  if (interestTreasuryAdaAmt > 0) {
391
- await treasuryFeeTx(
392
- interestTreasuryAdaAmt,
393
- lucid,
394
- sysParams,
395
- tx,
396
- treasuryOref,
397
- );
394
+ await treasuryFeeTx(interestTreasuryAdaAmt, lucid, sysParams, tx, treasury);
398
395
  }
399
396
 
400
397
  let collectorFee = interestCollectorAdaAmt;
@@ -416,7 +413,7 @@ async function adjustCdp(
416
413
  }
417
414
 
418
415
  if (collectorFee > 0n) {
419
- await collectorFeeTx(collectorFee, lucid, sysParams, tx, collectorOref);
416
+ await collectorFeeTx(collectorFee, lucid, sysParams, tx, collector);
420
417
  }
421
418
 
422
419
  return tx;
@@ -424,13 +421,13 @@ async function adjustCdp(
424
421
 
425
422
  export async function depositCdp(
426
423
  amount: bigint,
427
- cdpOref: OutRef,
428
- iassetOref: OutRef,
429
- priceOracleOref: OutRef,
430
- interestOracleOref: OutRef,
431
- collectorOref: OutRef,
432
- govOref: OutRef,
433
- treasuryOref: OutRef,
424
+ cdp: UtxoOrOutRef,
425
+ iasset: UtxoOrOutRef,
426
+ priceOracle: UtxoOrOutRef,
427
+ interestOracle: UtxoOrOutRef,
428
+ collector: UtxoOrOutRef,
429
+ gov: UtxoOrOutRef,
430
+ treasury: UtxoOrOutRef,
434
431
  params: SystemParams,
435
432
  lucid: LucidEvolution,
436
433
  currentSlot: number,
@@ -438,13 +435,13 @@ export async function depositCdp(
438
435
  return adjustCdp(
439
436
  amount,
440
437
  0n,
441
- cdpOref,
442
- iassetOref,
443
- priceOracleOref,
444
- interestOracleOref,
445
- collectorOref,
446
- govOref,
447
- treasuryOref,
438
+ cdp,
439
+ iasset,
440
+ priceOracle,
441
+ interestOracle,
442
+ collector,
443
+ gov,
444
+ treasury,
448
445
  params,
449
446
  lucid,
450
447
  currentSlot,
@@ -453,13 +450,13 @@ export async function depositCdp(
453
450
 
454
451
  export async function withdrawCdp(
455
452
  amount: bigint,
456
- cdpOref: OutRef,
457
- iassetOref: OutRef,
458
- priceOracleOref: OutRef,
459
- interestOracleOref: OutRef,
460
- collectorOref: OutRef,
461
- govOref: OutRef,
462
- treasuryOref: OutRef,
453
+ cdp: UtxoOrOutRef,
454
+ iasset: UtxoOrOutRef,
455
+ priceOracle: UtxoOrOutRef,
456
+ interestOracle: UtxoOrOutRef,
457
+ collector: UtxoOrOutRef,
458
+ gov: UtxoOrOutRef,
459
+ treasury: UtxoOrOutRef,
463
460
  params: SystemParams,
464
461
  lucid: LucidEvolution,
465
462
  currentSlot: number,
@@ -467,13 +464,13 @@ export async function withdrawCdp(
467
464
  return adjustCdp(
468
465
  -amount,
469
466
  0n,
470
- cdpOref,
471
- iassetOref,
472
- priceOracleOref,
473
- interestOracleOref,
474
- collectorOref,
475
- govOref,
476
- treasuryOref,
467
+ cdp,
468
+ iasset,
469
+ priceOracle,
470
+ interestOracle,
471
+ collector,
472
+ gov,
473
+ treasury,
477
474
  params,
478
475
  lucid,
479
476
  currentSlot,
@@ -482,13 +479,13 @@ export async function withdrawCdp(
482
479
 
483
480
  export async function mintCdp(
484
481
  amount: bigint,
485
- cdpOref: OutRef,
486
- iassetOref: OutRef,
487
- priceOracleOref: OutRef,
488
- interestOracleOref: OutRef,
489
- collectorOref: OutRef,
490
- govOref: OutRef,
491
- treasuryOref: OutRef,
482
+ cdp: UtxoOrOutRef,
483
+ iasset: UtxoOrOutRef,
484
+ priceOracle: UtxoOrOutRef,
485
+ interestOracle: UtxoOrOutRef,
486
+ collector: UtxoOrOutRef,
487
+ gov: UtxoOrOutRef,
488
+ treasury: UtxoOrOutRef,
492
489
  params: SystemParams,
493
490
  lucid: LucidEvolution,
494
491
  currentSlot: number,
@@ -496,13 +493,13 @@ export async function mintCdp(
496
493
  return adjustCdp(
497
494
  0n,
498
495
  amount,
499
- cdpOref,
500
- iassetOref,
501
- priceOracleOref,
502
- interestOracleOref,
503
- collectorOref,
504
- govOref,
505
- treasuryOref,
496
+ cdp,
497
+ iasset,
498
+ priceOracle,
499
+ interestOracle,
500
+ collector,
501
+ gov,
502
+ treasury,
506
503
  params,
507
504
  lucid,
508
505
  currentSlot,
@@ -511,13 +508,13 @@ export async function mintCdp(
511
508
 
512
509
  export async function burnCdp(
513
510
  amount: bigint,
514
- cdpOref: OutRef,
515
- iassetOref: OutRef,
516
- priceOracleOref: OutRef,
517
- interestOracleOref: OutRef,
518
- collectorOref: OutRef,
519
- govOref: OutRef,
520
- treasuryOref: OutRef,
511
+ cdp: UtxoOrOutRef,
512
+ iasset: UtxoOrOutRef,
513
+ priceOracle: UtxoOrOutRef,
514
+ interestOracle: UtxoOrOutRef,
515
+ collector: UtxoOrOutRef,
516
+ gov: UtxoOrOutRef,
517
+ treasury: UtxoOrOutRef,
521
518
  params: SystemParams,
522
519
  lucid: LucidEvolution,
523
520
  currentSlot: number,
@@ -525,13 +522,13 @@ export async function burnCdp(
525
522
  return adjustCdp(
526
523
  0n,
527
524
  -amount,
528
- cdpOref,
529
- iassetOref,
530
- priceOracleOref,
531
- interestOracleOref,
532
- collectorOref,
533
- govOref,
534
- treasuryOref,
525
+ cdp,
526
+ iasset,
527
+ priceOracle,
528
+ interestOracle,
529
+ collector,
530
+ gov,
531
+ treasury,
535
532
  params,
536
533
  lucid,
537
534
  currentSlot,
@@ -539,13 +536,13 @@ export async function burnCdp(
539
536
  }
540
537
 
541
538
  export async function closeCdp(
542
- cdpOref: OutRef,
543
- iassetOref: OutRef,
544
- priceOracleOref: OutRef,
545
- interestOracleOref: OutRef,
546
- collectorOref: OutRef,
547
- govOref: OutRef,
548
- treasuryOref: OutRef,
539
+ cdp: UtxoOrOutRef,
540
+ iasset: UtxoOrOutRef,
541
+ priceOracle: UtxoOrOutRef,
542
+ interestOracle: UtxoOrOutRef,
543
+ collector: UtxoOrOutRef,
544
+ gov: UtxoOrOutRef,
545
+ treasury: UtxoOrOutRef,
549
546
  sysParams: SystemParams,
550
547
  lucid: LucidEvolution,
551
548
  currentSlot: number,
@@ -578,37 +575,34 @@ export async function closeCdp(
578
575
  (_) => new Error('Expected a single iasset token policy Ref Script UTXO'),
579
576
  );
580
577
 
581
- const cdpUtxo = matchSingle(
582
- await lucid.utxosByOutRef([cdpOref]),
583
- (_) => new Error('Expected a single cdp UTXO'),
584
- );
578
+ const cdpUtxo = await resolveUtxo(cdp, lucid, 'Expected a single cdp UTXO');
585
579
  const cdpDatum = parseCdpDatumOrThrow(getInlineDatumOrThrow(cdpUtxo));
586
580
 
587
- const iassetUtxo = matchSingle(
588
- await lucid.utxosByOutRef([iassetOref]),
589
- (_) => new Error('Expected a single iasset UTXO'),
581
+ const iassetUtxo = await resolveUtxo(
582
+ iasset,
583
+ lucid,
584
+ 'Expected a single iasset UTXO',
590
585
  );
591
586
  const iassetDatum = parseIAssetDatumOrThrow(
592
587
  getInlineDatumOrThrow(iassetUtxo),
593
588
  );
594
589
 
595
- const govUtxo = matchSingle(
596
- await lucid.utxosByOutRef([govOref]),
597
- (_) => new Error('Expected a single gov UTXO'),
598
- );
590
+ const govUtxo = await resolveUtxo(gov, lucid, 'Expected a single gov UTXO');
599
591
  const govDatum = parseGovDatumOrThrow(getInlineDatumOrThrow(govUtxo));
600
592
 
601
- const priceOracleUtxo = matchSingle(
602
- await lucid.utxosByOutRef([priceOracleOref]),
603
- (_) => new Error('Expected a single price oracle UTXO'),
593
+ const priceOracleUtxo = await resolveUtxo(
594
+ priceOracle,
595
+ lucid,
596
+ 'Expected a single price oracle UTXO',
604
597
  );
605
598
  const priceOracleDatum = parsePriceOracleDatum(
606
599
  getInlineDatumOrThrow(priceOracleUtxo),
607
600
  );
608
601
 
609
- const interestOracleUtxo = matchSingle(
610
- await lucid.utxosByOutRef([interestOracleOref]),
611
- (_) => new Error('Expected a single interest oracle UTXO'),
602
+ const interestOracleUtxo = await resolveUtxo(
603
+ interestOracle,
604
+ lucid,
605
+ 'Expected a single interest oracle UTXO',
612
606
  );
613
607
  const interestOracleDatum = parseInterestOracleDatum(
614
608
  getInlineDatumOrThrow(interestOracleUtxo),
@@ -683,13 +677,7 @@ export async function closeCdp(
683
677
  const interestTreasuryAdaAmt = interestAdaAmt - interestCollectorAdaAmt;
684
678
 
685
679
  if (interestTreasuryAdaAmt > 0) {
686
- await treasuryFeeTx(
687
- interestTreasuryAdaAmt,
688
- lucid,
689
- sysParams,
690
- tx,
691
- treasuryOref,
692
- );
680
+ await treasuryFeeTx(interestTreasuryAdaAmt, lucid, sysParams, tx, treasury);
693
681
  }
694
682
 
695
683
  const collectorFee =
@@ -700,7 +688,7 @@ export async function closeCdp(
700
688
  );
701
689
 
702
690
  if (collectorFee > 0n) {
703
- await collectorFeeTx(collectorFee, lucid, sysParams, tx, collectorOref);
691
+ await collectorFeeTx(collectorFee, lucid, sysParams, tx, collector);
704
692
  }
705
693
 
706
694
  return tx;
@@ -712,12 +700,12 @@ export async function redeemCdp(
712
700
  * The logic will automatically cap the amount to the max.
713
701
  */
714
702
  attemptedRedemptionIAssetAmt: bigint,
715
- cdpOref: OutRef,
716
- iassetOref: OutRef,
717
- priceOracleOref: OutRef,
718
- interestOracleOref: OutRef,
719
- collectorOref: OutRef,
720
- treasuryOref: OutRef,
703
+ cdp: UtxoOrOutRef,
704
+ iasset: UtxoOrOutRef,
705
+ priceOracle: UtxoOrOutRef,
706
+ interestOracle: UtxoOrOutRef,
707
+ collector: UtxoOrOutRef,
708
+ treasury: UtxoOrOutRef,
721
709
  sysParams: SystemParams,
722
710
  lucid: LucidEvolution,
723
711
  currentSlot: number,
@@ -741,31 +729,31 @@ export async function redeemCdp(
741
729
  (_) => new Error('Expected a single iasset token policy Ref Script UTXO'),
742
730
  );
743
731
 
744
- const cdpUtxo = matchSingle(
745
- await lucid.utxosByOutRef([cdpOref]),
746
- (_) => new Error('Expected a single cdp UTXO'),
747
- );
732
+ const cdpUtxo = await resolveUtxo(cdp, lucid, 'Expected a single cdp UTXO');
748
733
  const cdpDatum = parseCdpDatumOrThrow(getInlineDatumOrThrow(cdpUtxo));
749
734
 
750
- const iassetUtxo = matchSingle(
751
- await lucid.utxosByOutRef([iassetOref]),
752
- (_) => new Error('Expected a single iasset UTXO'),
735
+ const iassetUtxo = await resolveUtxo(
736
+ iasset,
737
+ lucid,
738
+ 'Expected a single iasset UTXO',
753
739
  );
754
740
  const iassetDatum = parseIAssetDatumOrThrow(
755
741
  getInlineDatumOrThrow(iassetUtxo),
756
742
  );
757
743
 
758
- const priceOracleUtxo = matchSingle(
759
- await lucid.utxosByOutRef([priceOracleOref]),
760
- (_) => new Error('Expected a single price oracle UTXO'),
744
+ const priceOracleUtxo = await resolveUtxo(
745
+ priceOracle,
746
+ lucid,
747
+ 'Expected a single price oracle UTXO',
761
748
  );
762
749
  const priceOracleDatum = parsePriceOracleDatum(
763
750
  getInlineDatumOrThrow(priceOracleUtxo),
764
751
  );
765
752
 
766
- const interestOracleUtxo = matchSingle(
767
- await lucid.utxosByOutRef([interestOracleOref]),
768
- (_) => new Error('Expected a single interest oracle UTXO'),
753
+ const interestOracleUtxo = await resolveUtxo(
754
+ interestOracle,
755
+ lucid,
756
+ 'Expected a single interest oracle UTXO',
769
757
  );
770
758
  const interestOracleDatum = parseInterestOracleDatum(
771
759
  getInlineDatumOrThrow(interestOracleUtxo),
@@ -902,25 +890,19 @@ export async function redeemCdp(
902
890
  lucid,
903
891
  sysParams,
904
892
  tx,
905
- collectorOref,
893
+ collector,
906
894
  );
907
895
 
908
- await treasuryFeeTx(
909
- interestTreasuryAdaAmt,
910
- lucid,
911
- sysParams,
912
- tx,
913
- treasuryOref,
914
- );
896
+ await treasuryFeeTx(interestTreasuryAdaAmt, lucid, sysParams, tx, treasury);
915
897
 
916
898
  return tx;
917
899
  }
918
900
 
919
901
  export async function freezeCdp(
920
- cdpOref: OutRef,
921
- iassetOref: OutRef,
922
- priceOracleOref: OutRef,
923
- interestOracleOref: OutRef,
902
+ cdp: UtxoOrOutRef,
903
+ iasset: UtxoOrOutRef,
904
+ priceOracle: UtxoOrOutRef,
905
+ interestOracle: UtxoOrOutRef,
924
906
  sysParams: SystemParams,
925
907
  lucid: LucidEvolution,
926
908
  currentSlot: number,
@@ -934,31 +916,31 @@ export async function freezeCdp(
934
916
  ]),
935
917
  (_) => new Error('Expected a single cdp Ref Script UTXO'),
936
918
  );
937
- const cdpUtxo = matchSingle(
938
- await lucid.utxosByOutRef([cdpOref]),
939
- (_) => new Error('Expected a single cdp UTXO'),
940
- );
919
+ const cdpUtxo = await resolveUtxo(cdp, lucid, 'Expected a single cdp UTXO');
941
920
  const cdpDatum = parseCdpDatumOrThrow(getInlineDatumOrThrow(cdpUtxo));
942
921
 
943
- const iassetUtxo = matchSingle(
944
- await lucid.utxosByOutRef([iassetOref]),
945
- (_) => new Error('Expected a single iasset UTXO'),
922
+ const iassetUtxo = await resolveUtxo(
923
+ iasset,
924
+ lucid,
925
+ 'Expected a single iasset UTXO',
946
926
  );
947
927
  const iassetDatum = parseIAssetDatumOrThrow(
948
928
  getInlineDatumOrThrow(iassetUtxo),
949
929
  );
950
930
 
951
- const priceOracleUtxo = matchSingle(
952
- await lucid.utxosByOutRef([priceOracleOref]),
953
- (_) => new Error('Expected a single price oracle UTXO'),
931
+ const priceOracleUtxo = await resolveUtxo(
932
+ priceOracle,
933
+ lucid,
934
+ 'Expected a single price oracle UTXO',
954
935
  );
955
936
  const priceOracleDatum = parsePriceOracleDatum(
956
937
  getInlineDatumOrThrow(priceOracleUtxo),
957
938
  );
958
939
 
959
- const interestOracleUtxo = matchSingle(
960
- await lucid.utxosByOutRef([interestOracleOref]),
961
- (_) => new Error('Expected a single interest oracle UTXO'),
940
+ const interestOracleUtxo = await resolveUtxo(
941
+ interestOracle,
942
+ lucid,
943
+ 'Expected a single interest oracle UTXO',
962
944
  );
963
945
  const interestOracleDatum = parseInterestOracleDatum(
964
946
  getInlineDatumOrThrow(interestOracleUtxo),
@@ -1061,10 +1043,10 @@ export async function freezeCdp(
1061
1043
  }
1062
1044
 
1063
1045
  export async function liquidateCdp(
1064
- cdpOref: OutRef,
1065
- stabilityPoolOref: OutRef,
1066
- collectorOref: OutRef,
1067
- treasuryOref: OutRef,
1046
+ cdp: UtxoOrOutRef,
1047
+ stabilityPool: UtxoOrOutRef,
1048
+ collector: UtxoOrOutRef,
1049
+ treasury: UtxoOrOutRef,
1068
1050
  sysParams: SystemParams,
1069
1051
  lucid: LucidEvolution,
1070
1052
  ): Promise<TxBuilder> {
@@ -1099,15 +1081,13 @@ export async function liquidateCdp(
1099
1081
  (_) => new Error('Expected a single cdp auth token policy Ref Script UTXO'),
1100
1082
  );
1101
1083
 
1102
- const cdpUtxo = matchSingle(
1103
- await lucid.utxosByOutRef([cdpOref]),
1104
- (_) => new Error('Expected a single cdp UTXO'),
1105
- );
1084
+ const cdpUtxo = await resolveUtxo(cdp, lucid, 'Expected a single cdp UTXO');
1106
1085
  const cdpDatum = parseCdpDatumOrThrow(getInlineDatumOrThrow(cdpUtxo));
1107
1086
 
1108
- const spUtxo = matchSingle(
1109
- await lucid.utxosByOutRef([stabilityPoolOref]),
1110
- (_) => new Error('Expected a single stability pool UTXO'),
1087
+ const spUtxo = await resolveUtxo(
1088
+ stabilityPool,
1089
+ lucid,
1090
+ 'Expected a single stability pool UTXO',
1111
1091
  );
1112
1092
  const spDatum = parseStabilityPoolDatum(getInlineDatumOrThrow(spUtxo));
1113
1093
 
@@ -1198,15 +1178,9 @@ export async function liquidateCdp(
1198
1178
  );
1199
1179
  }
1200
1180
 
1201
- await collectorFeeTx(
1202
- lovelacesForCollector,
1203
- lucid,
1204
- sysParams,
1205
- tx,
1206
- collectorOref,
1207
- );
1181
+ await collectorFeeTx(lovelacesForCollector, lucid, sysParams, tx, collector);
1208
1182
 
1209
- await treasuryFeeTx(lovelacesForTreasury, lucid, sysParams, tx, treasuryOref);
1183
+ await treasuryFeeTx(lovelacesForTreasury, lucid, sysParams, tx, treasury);
1210
1184
 
1211
1185
  return tx;
1212
1186
  }