@indigo-labs/indigo-sdk 0.1.8 → 0.1.9

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.
@@ -7,6 +7,8 @@ import {
7
7
  OutRef,
8
8
  UTxO,
9
9
  addAssets,
10
+ unixTimeToSlot,
11
+ slotToUnixTime,
10
12
  } from '@lucid-evolution/lucid';
11
13
  import {
12
14
  addrDetails,
@@ -23,10 +25,7 @@ import {
23
25
  serialiseLrpDatum,
24
26
  serialiseLrpRedeemer,
25
27
  } from '../types/indigo/lrp';
26
- import {
27
- parsePriceOracleDatum,
28
- PriceOracleParams,
29
- } from '../types/indigo/price-oracle';
28
+ import { parsePriceOracleDatum } from '../types/indigo/price-oracle';
30
29
  import { ocdMul, OnChainDecimal } from '../types/on-chain-decimal';
31
30
  import { parseIAssetDatum } from '../types/indigo/cdp';
32
31
  import {
@@ -34,7 +33,6 @@ import {
34
33
  mkAssetsOf,
35
34
  mkLovelacesOf,
36
35
  } from '../helpers/value-helpers';
37
- import { oracleExpirationAwareValidity } from '../helpers/price-oracle-helpers';
38
36
  import { calculateFeeFromPercentage } from '../helpers/indigo-helpers';
39
37
  import { matchSingle } from '../helpers/helpers';
40
38
  import { AssetClass } from '../types/generic';
@@ -101,9 +99,7 @@ export async function redeemLrp(
101
99
  iassetOutRef: OutRef,
102
100
  lucid: LucidEvolution,
103
101
  lrpParams: LRPParams,
104
- priceOracleParams: PriceOracleParams,
105
102
  network: Network,
106
- currentSlot: number,
107
103
  ): Promise<TxBuilder> {
108
104
  const lrpScriptRefUtxo = matchSingle(
109
105
  await lucid.utxosByOutRef([lrpRefScriptOutRef]),
@@ -209,18 +205,15 @@ export async function redeemLrp(
209
205
  },
210
206
  )(redemptionLrps);
211
207
 
212
- const txValidity = oracleExpirationAwareValidity(
213
- currentSlot,
214
- Number(priceOracleParams.biasTime),
215
- Number(priceOracleDatum.expiration),
216
- network,
217
- );
218
-
219
208
  return (
220
209
  lucid
221
210
  .newTx()
222
- .validFrom(txValidity.validFrom)
223
- .validTo(txValidity.validTo)
211
+ .validTo(
212
+ slotToUnixTime(
213
+ network,
214
+ unixTimeToSlot(network, Number(priceOracleDatum.expiration)) - 1,
215
+ ),
216
+ )
224
217
  // Ref script
225
218
  .readFrom([lrpScriptRefUtxo])
226
219
  // Ref inputs
package/tests/lrp.test.ts CHANGED
@@ -337,9 +337,7 @@ describe('LRP', () => {
337
337
  ),
338
338
  lucid,
339
339
  lrpParams,
340
- testCtx.oracleParams,
341
340
  network,
342
- emulator.slot,
343
341
  ),
344
342
  );
345
343
 
@@ -465,9 +463,7 @@ describe('LRP', () => {
465
463
  ),
466
464
  lucid,
467
465
  lrpParams,
468
- testCtx.oracleParams,
469
466
  network,
470
- emulator.slot,
471
467
  ),
472
468
  );
473
469
 
@@ -599,9 +595,7 @@ describe('LRP', () => {
599
595
  ),
600
596
  lucid,
601
597
  lrpParams,
602
- testCtx.oracleParams,
603
598
  network,
604
- emulator.slot,
605
599
  ),
606
600
  );
607
601
 
@@ -732,9 +726,7 @@ describe('LRP', () => {
732
726
  ),
733
727
  lucid,
734
728
  lrpParams,
735
- testCtx.oracleParams,
736
729
  network,
737
- emulator.slot,
738
730
  ),
739
731
  );
740
732
 
@@ -39,6 +39,7 @@ afterEach(() => {
39
39
  test<LucidContext>('Stability Pool - Create Account', async ({
40
40
  lucid,
41
41
  users,
42
+ emulator,
42
43
  }: LucidContext) => {
43
44
  lucid.selectWallet.fromSeed(users.admin.seedPhrase);
44
45
  const systemParams = await init(lucid);
@@ -47,7 +48,14 @@ test<LucidContext>('Stability Pool - Create Account', async ({
47
48
 
48
49
  await runAndAwaitTx(
49
50
  lucid,
50
- CDPContract.openPosition('iUSD', 1_000_000_000n, 20n, systemParams, lucid),
51
+ CDPContract.openPosition(
52
+ 'iUSD',
53
+ 1_000_000_000n,
54
+ 20n,
55
+ systemParams,
56
+ lucid,
57
+ emulator.slot,
58
+ ),
51
59
  );
52
60
 
53
61
  await runAndAwaitTx(
@@ -113,6 +121,7 @@ test<LucidContext>('Stability Pool - Create Account', async ({
113
121
  test<LucidContext>('Stability Pool - Adjust Account', async ({
114
122
  lucid,
115
123
  users,
124
+ emulator,
116
125
  }: LucidContext) => {
117
126
  lucid.selectWallet.fromSeed(users.admin.seedPhrase);
118
127
  const systemParams = await init(lucid);
@@ -121,7 +130,14 @@ test<LucidContext>('Stability Pool - Adjust Account', async ({
121
130
 
122
131
  await runAndAwaitTx(
123
132
  lucid,
124
- CDPContract.openPosition('iUSD', 1_000_000_000n, 20n, systemParams, lucid),
133
+ CDPContract.openPosition(
134
+ 'iUSD',
135
+ 1_000_000_000n,
136
+ 20n,
137
+ systemParams,
138
+ lucid,
139
+ emulator.slot,
140
+ ),
125
141
  );
126
142
 
127
143
  await runAndAwaitTx(
@@ -251,7 +267,14 @@ test<LucidContext>('Stability Pool - Close Account', async ({
251
267
 
252
268
  await runAndAwaitTx(
253
269
  lucid,
254
- CDPContract.openPosition('iUSD', 1_000_000_000n, 20n, systemParams, lucid),
270
+ CDPContract.openPosition(
271
+ 'iUSD',
272
+ 1_000_000_000n,
273
+ 20n,
274
+ systemParams,
275
+ lucid,
276
+ emulator.slot,
277
+ ),
255
278
  );
256
279
 
257
280
  await runAndAwaitTx(