@indigo-labs/indigo-sdk 0.4.4 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/index.d.mts +121 -40
  2. package/dist/index.d.ts +121 -40
  3. package/dist/index.js +962 -818
  4. package/dist/index.mjs +418 -282
  5. package/package.json +2 -2
  6. package/scripts/run-repeat.sh +22 -0
  7. package/src/contracts/cdp/helpers.ts +7 -6
  8. package/src/contracts/cdp/transactions.ts +8 -29
  9. package/src/contracts/gov/transactions.ts +12 -16
  10. package/src/contracts/iasset/helpers.ts +2 -7
  11. package/src/contracts/initialize/actions.ts +0 -2
  12. package/src/contracts/initialize/helpers.ts +0 -4
  13. package/src/contracts/interest-collection/transactions.ts +2 -5
  14. package/src/contracts/interest-oracle/helpers.ts +4 -0
  15. package/src/contracts/interest-oracle/transactions.ts +1 -4
  16. package/src/contracts/price-oracle/helpers.ts +5 -11
  17. package/src/contracts/price-oracle/transactions.ts +2 -7
  18. package/src/contracts/rob/transactions.ts +0 -2
  19. package/src/contracts/rob-leverage/transactions.ts +1 -4
  20. package/src/contracts/stability-pool/transactions.ts +2 -8
  21. package/src/contracts/stableswap/helpers.ts +487 -2
  22. package/src/contracts/stableswap/transactions.ts +53 -222
  23. package/src/contracts/staking/transactions.ts +2 -7
  24. package/tests/cdp/actions.ts +0 -11
  25. package/tests/cdp/cdp-helpers.ts +2 -2
  26. package/tests/cdp/cdp-queries.ts +1 -3
  27. package/tests/cdp/cdp.test.ts +407 -619
  28. package/tests/cdp/transactions-mutated.ts +30 -25
  29. package/tests/endpoints/initialize.ts +0 -2
  30. package/tests/gov/actions.ts +7 -32
  31. package/tests/gov/gov.test.ts +169 -401
  32. package/tests/indigo-test-helpers.ts +2 -3
  33. package/tests/initialize.test.ts +15 -20
  34. package/tests/interest-collection/interest-collection.test.ts +0 -4
  35. package/tests/interest-oracle.test.ts +1 -8
  36. package/tests/price-oracle/actions.ts +6 -8
  37. package/tests/price-oracle/price-oracle.test.ts +1 -13
  38. package/tests/price-oracle/transactions-mutated.ts +1 -4
  39. package/tests/pyth/pyth-indigo.test.ts +8 -12
  40. package/tests/pyth/pyth.test.ts +1 -2
  41. package/tests/rob/actions.ts +0 -2
  42. package/tests/rob/rob-leverage.test.ts +164 -220
  43. package/tests/rob/rob.test.ts +158 -263
  44. package/tests/rob/transactions-mutated.ts +7 -18
  45. package/tests/stability-pool/actions.ts +4 -8
  46. package/tests/stability-pool.test.ts +164 -255
  47. package/tests/stableswap/stableswap-actions.ts +0 -1
  48. package/tests/stableswap/stableswap-queries.ts +26 -17
  49. package/tests/stableswap/stableswap.test.ts +338 -4
  50. package/tests/staking.test.ts +2 -13
  51. package/tests/treasury/treasury.test.ts +6 -30
@@ -11,13 +11,11 @@ import {
11
11
  sortUTxOs,
12
12
  toHex,
13
13
  TxBuilder,
14
- UTxO,
15
14
  } from '@lucid-evolution/lucid';
16
15
  import {
17
16
  fromSystemParamsScriptRef,
18
17
  SystemParams,
19
18
  } from '../../types/system-params';
20
- import { estimateUtxoMinLovelace } from '../../utils/lucid-utils';
21
19
  import {
22
20
  parseStableswapOrderDatumOrThrow,
23
21
  serialiseStableswapOrderDatum,
@@ -42,34 +40,20 @@ import {
42
40
  serialiseStableswapPoolDatum,
43
41
  StableswapPoolContent,
44
42
  } from '../cdp/types-new';
45
- import { calculateFeeFromRatio } from '../../utils/indigo-helpers';
46
43
  import { array as A, function as F } from 'fp-ts';
47
44
  import { isEmpty } from 'fp-ts/lib/Array';
48
- import { BASE_MAX_EXECUTION_FEE, createDestinationDatum } from './helpers';
45
+ import {
46
+ BASE_MAX_EXECUTION_FEE,
47
+ createDestinationDatum,
48
+ estimateMinOrderOutputLovelaces,
49
+ PSMProcessingConfig,
50
+ StableswapInfo,
51
+ StableswapOrderInfo,
52
+ summariseOrder,
53
+ } from './helpers';
49
54
  import * as Core from '@evolution-sdk/evolution';
50
55
  import { treasuryFeeTx } from '../treasury/transactions';
51
- import {
52
- Rational,
53
- rationalDiv,
54
- rationalFloor,
55
- rationalFromInt,
56
- rationalMul,
57
- } from '../../types/rational';
58
-
59
- type StableswapInfo = {
60
- suppliedCollateralAsset: bigint;
61
- suppliedIasset: bigint;
62
- owedCollateralAsset: bigint;
63
- owedIasset: bigint;
64
- mintingFee: bigint;
65
- redemptionFee: bigint;
66
- };
67
-
68
- type StableswapOrderInfo = {
69
- utxo: UTxO;
70
- datum: StableswapOrderDatum;
71
- swapInfo: StableswapInfo;
72
- };
56
+ import { Rational } from '../../types/rational';
73
57
 
74
58
  export async function createStableswapOrder(
75
59
  iasset: string,
@@ -113,23 +97,17 @@ export async function createStableswapOrder(
113
97
  amount,
114
98
  );
115
99
 
116
- // This is an approximation of the amount of lovelace that will be needed to pay for the output.
117
- const expectedOutputLovelaces = estimateUtxoMinLovelace(
118
- lucid.config().protocolParameters!,
119
- myAddress,
100
+ const orderAssetsPlusFees = addAssets(
120
101
  assetsToSwap,
121
- {
122
- kind: 'inline',
123
- value: createDestinationDatum(destinationInlineDatum ?? null, {
124
- txHash:
125
- '0000000000000000000000000000000000000000000000000000000000000000',
126
- outputIndex: 0,
127
- }),
128
- },
102
+ mkLovelacesOf(maxExecutionFee),
103
+ mkLovelacesOf(additionalLovelaces),
129
104
  );
130
105
 
131
- const roundedExpectedOutputLovelaces =
132
- (expectedOutputLovelaces / 1_000_000n + 1n) * 1_000_000n;
106
+ const expectedMinOutputLovelaces = estimateMinOrderOutputLovelaces(
107
+ lucid,
108
+ datum,
109
+ orderAssetsPlusFees,
110
+ );
133
111
 
134
112
  return lucid.newTx().pay.ToContract(
135
113
  credentialToAddress(lucid.config().network!, {
@@ -140,12 +118,7 @@ export async function createStableswapOrder(
140
118
  kind: 'inline',
141
119
  value: serialiseStableswapOrderDatum(datum),
142
120
  },
143
- addAssets(
144
- assetsToSwap,
145
- mkLovelacesOf(
146
- roundedExpectedOutputLovelaces + maxExecutionFee + additionalLovelaces,
147
- ),
148
- ),
121
+ addAssets(orderAssetsPlusFees, mkLovelacesOf(expectedMinOutputLovelaces)),
149
122
  );
150
123
  }
151
124
 
@@ -188,6 +161,7 @@ export async function batchProcessStableswapOrders(
188
161
  treasuryOref: OutRef,
189
162
  sysParams: SystemParams,
190
163
  lucid: LucidEvolution,
164
+ psmProcessingConfig?: PSMProcessingConfig,
191
165
  ): Promise<TxBuilder> {
192
166
  const stableswapScriptRefUtxo = matchSingle(
193
167
  await lucid.utxosByOutRef([
@@ -259,169 +233,19 @@ export async function batchProcessStableswapOrders(
259
233
  getInlineDatumOrThrow(orderUtxo),
260
234
  );
261
235
 
262
- if (
263
- toHex(orderDatum.iasset) != toHex(mainOrderDatum.iasset) ||
264
- toHex(orderDatum.collateralAsset.currencySymbol) !=
265
- toHex(mainOrderDatum.collateralAsset.currencySymbol) ||
266
- toHex(orderDatum.collateralAsset.tokenName) !=
267
- toHex(mainOrderDatum.collateralAsset.tokenName)
268
- ) {
269
- throw new Error('Wrong batch of orders');
270
- }
271
-
272
- const suppliedIasset = assetClassValueOf(orderUtxo.assets, iassetAc);
273
- const suppliedCollateralAsset = assetClassValueOf(
274
- orderUtxo.assets,
275
- collateralAc,
236
+ const res = summariseOrder(
237
+ lucid,
238
+ { utxo: orderUtxo, datum: orderDatum },
239
+ { utxo: stableswapPoolUtxo, datum: stableswapPoolDatum },
240
+ sysParams,
241
+ psmProcessingConfig,
276
242
  );
277
243
 
278
- if (
279
- (suppliedIasset != 0n && suppliedCollateralAsset != 0n) ||
280
- (suppliedIasset == 0n && suppliedCollateralAsset == 0n)
281
- ) {
282
- throw new Error(
283
- 'An order must supply either iAsset or collateral asset',
284
- );
244
+ if (res._tag === 'ERROR') {
245
+ throw new Error(res.description);
285
246
  }
286
247
 
287
- const isMinting = suppliedCollateralAsset > 0n;
288
-
289
- const isOneToOne =
290
- stableswapPoolDatum.collateralToIassetRatio.numerator ===
291
- stableswapPoolDatum.collateralToIassetRatio.denominator;
292
-
293
- if (isMinting) {
294
- // Mint order with one to one ratio case.
295
- if (isOneToOne) {
296
- const fee = calculateFeeFromRatio(
297
- stableswapPoolDatum.mintingFeeRatio,
298
- suppliedCollateralAsset,
299
- );
300
-
301
- return {
302
- utxo: orderUtxo,
303
- datum: orderDatum,
304
- swapInfo: {
305
- suppliedCollateralAsset: suppliedCollateralAsset,
306
- suppliedIasset: 0n,
307
- owedCollateralAsset: 0n,
308
- owedIasset: suppliedCollateralAsset - fee,
309
- mintingFee: fee,
310
- redemptionFee: 0n,
311
- },
312
- };
313
- // Mint order with any ratio case.
314
- } else {
315
- const iAssetConversion = rationalFloor(
316
- rationalDiv(
317
- rationalFromInt(suppliedCollateralAsset),
318
- stableswapPoolDatum.collateralToIassetRatio,
319
- ),
320
- );
321
-
322
- const attemptedNormalizedCollateral = rationalFloor(
323
- rationalMul(
324
- rationalFromInt(iAssetConversion),
325
- stableswapPoolDatum.collateralToIassetRatio,
326
- ),
327
- );
328
-
329
- const normalizedCollateralSupplied =
330
- rationalFloor(
331
- rationalDiv(
332
- rationalFromInt(attemptedNormalizedCollateral),
333
- stableswapPoolDatum.collateralToIassetRatio,
334
- ),
335
- ) != iAssetConversion
336
- ? suppliedCollateralAsset
337
- : attemptedNormalizedCollateral;
338
-
339
- const fee = calculateFeeFromRatio(
340
- stableswapPoolDatum.mintingFeeRatio,
341
- iAssetConversion,
342
- );
343
-
344
- return {
345
- utxo: orderUtxo,
346
- datum: orderDatum,
347
- swapInfo: {
348
- suppliedCollateralAsset: normalizedCollateralSupplied,
349
- suppliedIasset: 0n,
350
- owedCollateralAsset: 0n,
351
- owedIasset: iAssetConversion - fee,
352
- mintingFee: fee,
353
- redemptionFee: 0n,
354
- },
355
- };
356
- }
357
- // Redeem order case
358
- } else {
359
- const fee = calculateFeeFromRatio(
360
- stableswapPoolDatum.redemptionFeeRatio,
361
- suppliedIasset,
362
- );
363
-
364
- const effectiveSuppliedIasset = suppliedIasset - fee;
365
-
366
- // Redeem order with one to one ratio case
367
- if (isOneToOne) {
368
- return {
369
- utxo: orderUtxo,
370
- datum: orderDatum,
371
- swapInfo: {
372
- suppliedCollateralAsset: 0n,
373
- suppliedIasset: effectiveSuppliedIasset,
374
- owedCollateralAsset: effectiveSuppliedIasset,
375
- owedIasset: 0n,
376
- mintingFee: 0n,
377
- redemptionFee: fee,
378
- },
379
- };
380
- // Redeem order with any ratio case
381
- } else {
382
- const collateralConversion = rationalFloor(
383
- rationalMul(
384
- rationalFromInt(effectiveSuppliedIasset),
385
- stableswapPoolDatum.collateralToIassetRatio,
386
- ),
387
- );
388
-
389
- const attemptedNormalizedEffectiveIasset = rationalFloor(
390
- rationalDiv(
391
- rationalFromInt(collateralConversion),
392
- stableswapPoolDatum.collateralToIassetRatio,
393
- ),
394
- );
395
-
396
- const normalizedEffectiveIasset =
397
- rationalFloor(
398
- rationalMul(
399
- rationalFromInt(attemptedNormalizedEffectiveIasset),
400
- stableswapPoolDatum.collateralToIassetRatio,
401
- ),
402
- ) != collateralConversion
403
- ? effectiveSuppliedIasset
404
- : attemptedNormalizedEffectiveIasset;
405
-
406
- return {
407
- utxo: orderUtxo,
408
- datum: orderDatum,
409
- swapInfo: {
410
- suppliedCollateralAsset: 0n,
411
- suppliedIasset: normalizedEffectiveIasset,
412
- owedCollateralAsset: rationalFloor(
413
- rationalMul(
414
- rationalFromInt(effectiveSuppliedIasset),
415
- stableswapPoolDatum.collateralToIassetRatio,
416
- ),
417
- ),
418
- owedIasset: 0n,
419
- mintingFee: 0n,
420
- redemptionFee: fee,
421
- },
422
- };
423
- }
424
- }
248
+ return res.result;
425
249
  },
426
250
  );
427
251
 
@@ -448,7 +272,7 @@ export async function batchProcessStableswapOrders(
448
272
  owedIasset: acc.owedIasset + orderInfo.swapInfo.owedIasset,
449
273
  mintingFee: acc.mintingFee + orderInfo.swapInfo.mintingFee,
450
274
  redemptionFee: acc.redemptionFee + orderInfo.swapInfo.redemptionFee,
451
- };
275
+ } satisfies StableswapInfo;
452
276
  },
453
277
  ),
454
278
  );
@@ -456,6 +280,15 @@ export async function batchProcessStableswapOrders(
456
280
  const collateralAmtChangePool =
457
281
  totalSwapInfo.suppliedCollateralAsset - totalSwapInfo.owedCollateralAsset;
458
282
 
283
+ const newPsmPoolValue = addAssets(
284
+ stableswapPoolUtxo.assets,
285
+ mkAssetsOf(collateralAc, collateralAmtChangePool),
286
+ );
287
+
288
+ if (assetClassValueOf(newPsmPoolValue, collateralAc) < 0n) {
289
+ throw new Error('Cannot batch more than liquidity allows');
290
+ }
291
+
459
292
  const amountToMint =
460
293
  totalSwapInfo.owedIasset -
461
294
  totalSwapInfo.suppliedIasset +
@@ -486,12 +319,7 @@ export async function batchProcessStableswapOrders(
486
319
  kind: 'inline',
487
320
  value: serialiseStableswapPoolDatum(stableswapPoolDatum),
488
321
  },
489
- collateralAmtChangePool != 0n
490
- ? addAssets(
491
- stableswapPoolUtxo.assets,
492
- mkAssetsOf(collateralAc, collateralAmtChangePool),
493
- )
494
- : stableswapPoolUtxo.assets,
322
+ newPsmPoolValue,
495
323
  )
496
324
  // This has to be added as otherwise there is the following error:
497
325
  // TxBuilderError: { Complete: RedeemerBuilder: Coin selection had to be updated
@@ -509,8 +337,8 @@ export async function batchProcessStableswapOrders(
509
337
  A.reduce<StableswapOrderInfo, TxBuilder>(tx, (acc, orderInfo) => {
510
338
  return acc
511
339
  .collectFrom(
512
- [orderInfo.utxo],
513
- isSameOutRef(orderInfo.utxo, mainOrderUtxo)
340
+ [orderInfo.order.utxo],
341
+ isSameOutRef(orderInfo.order.utxo, mainOrderUtxo)
514
342
  ? serialiseStableswapOrderRedeemer('BatchProcessStableswapOrders')
515
343
  : {
516
344
  kind: 'selected',
@@ -522,26 +350,29 @@ export async function batchProcessStableswapOrders(
522
350
  },
523
351
  });
524
352
  },
525
- inputs: [orderInfo.utxo, mainOrderUtxo],
353
+ inputs: [orderInfo.order.utxo, mainOrderUtxo],
526
354
  },
527
355
  )
528
356
  .pay.ToAddressWithData(
529
- addressToBech32(orderInfo.datum.destination, lucid.config().network!),
357
+ addressToBech32(
358
+ orderInfo.order.datum.destination,
359
+ lucid.config().network!,
360
+ ),
530
361
  {
531
362
  kind: 'inline',
532
363
  value: createDestinationDatum(
533
- orderInfo.datum.destinationInlineDatum ?? null,
534
- orderInfo.utxo,
364
+ orderInfo.order.datum.destinationInlineDatum ?? null,
365
+ orderInfo.order.utxo,
535
366
  ),
536
367
  },
537
368
  addAssets(
538
- // Currently, we always take the max execution fee from the order utxo.
369
+ // NOTICE: Currently, we always take the max execution fee from the order utxo.
539
370
  // This can be improved so that we take the actual execution fee.
540
371
  mkLovelacesOf(
541
- lovelacesAmt(orderInfo.utxo.assets) -
542
- orderInfo.datum.maxExecutionFee,
372
+ lovelacesAmt(orderInfo.order.utxo.assets) -
373
+ orderInfo.order.datum.maxExecutionFee,
543
374
  ),
544
- orderInfo.swapInfo.owedIasset > 0
375
+ orderInfo.orderType === 'MINTING'
545
376
  ? mkAssetsOf(iassetAc, orderInfo.swapInfo.owedIasset)
546
377
  : mkAssetsOf(
547
378
  collateralAc,
@@ -5,7 +5,6 @@ import {
5
5
  fromText,
6
6
  LucidEvolution,
7
7
  OutRef,
8
- slotToUnixTime,
9
8
  toHex,
10
9
  TxBuilder,
11
10
  } from '@lucid-evolution/lucid';
@@ -130,11 +129,9 @@ export async function adjustStakingPosition(
130
129
  amount: bigint,
131
130
  params: SystemParams,
132
131
  lucid: LucidEvolution,
133
- currentSlot: number,
134
132
  stakingManagerRef?: OutRef,
135
133
  ): Promise<TxBuilder> {
136
- const network = lucid.config().network!;
137
- const now = BigInt(slotToUnixTime(network, currentSlot));
134
+ const now = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
138
135
 
139
136
  const stakingPositionOut = await findStakingPositionByOutRef(
140
137
  stakingPositionRef,
@@ -210,11 +207,9 @@ export async function closeStakingPosition(
210
207
  stakingPositionRef: OutRef,
211
208
  params: SystemParams,
212
209
  lucid: LucidEvolution,
213
- currentSlot: number,
214
210
  stakingManagerRef?: OutRef,
215
211
  ): Promise<TxBuilder> {
216
- const network = lucid.config().network!;
217
- const now = BigInt(slotToUnixTime(network, currentSlot));
212
+ const now = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
218
213
 
219
214
  const stakingPositionOut = await findStakingPositionByOutRef(
220
215
  stakingPositionRef,
@@ -103,7 +103,6 @@ export async function runOpenCdp(
103
103
  orefs.interestOracleUtxo,
104
104
  directTreasuryPayment ? undefined : orefs.treasuryUtxo,
105
105
  context.lucid,
106
- context.emulator.slot,
107
106
  pythMessage,
108
107
  pythStateOref,
109
108
  );
@@ -142,7 +141,6 @@ export async function runDepositCdp(
142
141
  orefs.interestCollectorUtxo,
143
142
  sysParams,
144
143
  context.lucid,
145
- context.emulator.slot,
146
144
  );
147
145
  }
148
146
 
@@ -194,7 +192,6 @@ export async function runWithdrawCdp(
194
192
  orefs.interestCollectorUtxo,
195
193
  sysParams,
196
194
  context.lucid,
197
- context.emulator.slot,
198
195
  pythMessage,
199
196
  pythStateOref,
200
197
  );
@@ -249,7 +246,6 @@ export async function runMintCdp(
249
246
  orefs.interestCollectorUtxo,
250
247
  sysParams,
251
248
  context.lucid,
252
- context.emulator.slot,
253
249
  pythMessage,
254
250
  pythStateOref,
255
251
  );
@@ -288,7 +284,6 @@ export async function runBurnCdp(
288
284
  orefs.interestCollectorUtxo,
289
285
  sysParams,
290
286
  context.lucid,
291
- context.emulator.slot,
292
287
  );
293
288
  }
294
289
 
@@ -321,7 +316,6 @@ export async function runCloseCdp(
321
316
  orefs.interestCollectorUtxo,
322
317
  sysParams,
323
318
  context.lucid,
324
- context.emulator.slot,
325
319
  );
326
320
  }
327
321
 
@@ -367,7 +361,6 @@ export async function runRedeemCdp(
367
361
  orefs.govUtxo,
368
362
  sysParams,
369
363
  context.lucid,
370
- context.emulator.slot,
371
364
  );
372
365
  }
373
366
 
@@ -415,7 +408,6 @@ export async function runFreezeCdp(
415
408
  orefs.interestOracleUtxo,
416
409
  sysParams,
417
410
  context.lucid,
418
- context.emulator.slot,
419
411
  pythMessage,
420
412
  pythStateOref,
421
413
  );
@@ -463,7 +455,6 @@ export async function runCreateAndFreezeCdps(
463
455
  orefs.interestOracleUtxo,
464
456
  orefs.treasuryUtxo,
465
457
  context.lucid,
466
- context.emulator.slot,
467
458
  ),
468
459
  );
469
460
  });
@@ -475,7 +466,6 @@ export async function runCreateAndFreezeCdps(
475
466
  priceOracleUtxo!,
476
467
  { numerator: 18n, denominator: 10n }, // 1.8
477
468
  assetInfo.collateralAssets[0].oracleParams!,
478
- context.emulator.slot,
479
469
  ),
480
470
  );
481
471
 
@@ -515,7 +505,6 @@ export async function runCreateAndFreezeCdps(
515
505
  orefs.interestOracleUtxo,
516
506
  sysParams,
517
507
  context.lucid,
518
- context.emulator.slot,
519
508
  ),
520
509
  );
521
510
  }
@@ -2,7 +2,7 @@ import { match, P } from 'ts-pattern';
2
2
  import { CDPContent } from '../../src/contracts/cdp/types-new';
3
3
  import { calculateAccruedInterest } from '../../src/contracts/interest-oracle/helpers';
4
4
  import { LucidContext } from '../test-helpers';
5
- import { slotToUnixTime, toHex, toText } from '@lucid-evolution/lucid';
5
+ import { toHex, toText } from '@lucid-evolution/lucid';
6
6
  import { findCollateralAsset } from '../queries/iasset-queries';
7
7
  import {
8
8
  fromSystemParamsAsset,
@@ -18,7 +18,7 @@ export async function calculateCdpInterest(
18
18
  sysParams: SystemParams,
19
19
  ): Promise<bigint> {
20
20
  const currentTime = BigInt(
21
- slotToUnixTime(context.lucid.config().network!, context.emulator.slot),
21
+ context.lucid.slotToUnixTime(context.lucid.currentSlot()),
22
22
  );
23
23
 
24
24
  const collateralAsset = await findCollateralAsset(
@@ -385,7 +385,6 @@ export async function findCdpCR(
385
385
  lucid: LucidEvolution,
386
386
  sysParams: SystemParams,
387
387
  cdp: { utxo: UTxO; datum: CDPContent },
388
- slot: number,
389
388
  ): Promise<number> {
390
389
  const iassetAscii = toText(toHex(cdp.datum.iasset));
391
390
 
@@ -410,7 +409,7 @@ export async function findCdpCR(
410
409
  );
411
410
 
412
411
  return cdpCollateralRatioPercentage(
413
- slot,
412
+ BigInt(lucid.slotToUnixTime(lucid.currentSlot())),
414
413
  adjustedPrice,
415
414
  cdp.utxo.assets,
416
415
  cdp.datum,
@@ -420,6 +419,5 @@ export async function findCdpCR(
420
419
  iassetAscii,
421
420
  cdp.datum.collateralAsset,
422
421
  ),
423
- lucid.config().network!,
424
422
  );
425
423
  }