@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
@@ -5,7 +5,6 @@ import {
5
5
  getInputIndices,
6
6
  LucidEvolution,
7
7
  OutRef,
8
- slotToUnixTime,
9
8
  toHex,
10
9
  TxBuilder,
11
10
  } from '@lucid-evolution/lucid';
@@ -55,12 +54,9 @@ export async function testRedeemRob(
55
54
  iassetOutRef: OutRef,
56
55
  collateralAssetOutRef: OutRef,
57
56
  lucid: LucidEvolution,
58
- currentSlot: number,
59
57
  sysParams: SystemParams,
60
58
  pythMessage?: string,
61
59
  ): Promise<TxBuilder> {
62
- const network = lucid.config().network!;
63
-
64
60
  const robScriptRefUtxo = matchSingle(
65
61
  await lucid.utxosByOutRef([
66
62
  fromSystemParamsScriptRef(sysParams.scriptReferences.robValidatorRef),
@@ -131,7 +127,7 @@ export async function testRedeemRob(
131
127
 
132
128
  const transaction = lucid
133
129
  .newTx()
134
- .validTo(slotToUnixTime(network, currentSlot))
130
+ .validTo(lucid.slotToUnixTime(lucid.currentSlot()))
135
131
  .readFrom(allRefInputs)
136
132
  .compose(tx);
137
133
 
@@ -154,10 +150,9 @@ export async function redeemWithCdpCreate(
154
150
  interestOracleOref: OutRef,
155
151
  treasuryOref: OutRef,
156
152
  lucid: LucidEvolution,
157
- currentSlot: number,
158
153
  ): Promise<TxBuilder> {
159
154
  const network = lucid.config().network!;
160
- const currentTime = BigInt(slotToUnixTime(network, currentSlot));
155
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
161
156
 
162
157
  const [pkh, skh] = await addrDetails(lucid);
163
158
 
@@ -301,10 +296,9 @@ export async function redeemWithCdpCreate(
301
296
  );
302
297
 
303
298
  const txValidity = oracleExpirationAwareValidity(
304
- currentSlot,
299
+ lucid,
305
300
  Number(sysParams.cdpCreatorParams.biasTime),
306
301
  Number(priceOracleDatum.expirationTime),
307
- network,
308
302
  );
309
303
 
310
304
  tx.validFrom(txValidity.validFrom)
@@ -400,10 +394,8 @@ export async function redeemWithCdpClose(
400
394
  interestCollectorOref: OutRef,
401
395
  sysParams: SystemParams,
402
396
  lucid: LucidEvolution,
403
- currentSlot: number,
404
397
  ): Promise<TxBuilder> {
405
- const network = lucid.config().network!;
406
- const currentTime = BigInt(slotToUnixTime(network, currentSlot));
398
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
407
399
 
408
400
  const robScriptRefUtxo = matchSingle(
409
401
  await lucid.utxosByOutRef([
@@ -539,7 +531,7 @@ export async function redeemWithCdpClose(
539
531
  { OracleRefInputIdx: refInputIdxs[2] },
540
532
  );
541
533
 
542
- const validateFrom = slotToUnixTime(network, currentSlot - 1);
534
+ const validateFrom = lucid.slotToUnixTime(lucid.currentSlot() - 1);
543
535
  const validateTo = Math.min(
544
536
  Number(BigInt(validateFrom) + sysParams.cdpParams.biasTime / 2n),
545
537
  Number(priceOracleDatum.expirationTime - 1n * 1000n),
@@ -610,12 +602,10 @@ export async function redeemWithCdpAdjust(
610
602
  interestOracleOref: OutRef,
611
603
  treasuryOref: OutRef,
612
604
  interestCollectorOref: OutRef,
613
- currentSlot: number,
614
605
  lucid: LucidEvolution,
615
606
  sysParams: SystemParams,
616
607
  ): Promise<TxBuilder> {
617
- const network = lucid.config().network!;
618
- const currentTime = BigInt(slotToUnixTime(network, currentSlot));
608
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
619
609
 
620
610
  const robScriptRefUtxo = matchSingle(
621
611
  await lucid.utxosByOutRef([
@@ -764,10 +754,9 @@ export async function redeemWithCdpAdjust(
764
754
  );
765
755
 
766
756
  const txValidity = oracleExpirationAwareValidity(
767
- currentSlot,
757
+ lucid,
768
758
  Number(sysParams.cdpCreatorParams.biasTime),
769
759
  Number(priceOracleDatum.expirationTime),
770
- network,
771
760
  );
772
761
 
773
762
  tx.validFrom(txValidity.validFrom)
@@ -4,7 +4,6 @@ import {
4
4
  fromText,
5
5
  LucidEvolution,
6
6
  TxBuilder,
7
- unixTimeToSlot,
8
7
  } from '@lucid-evolution/lucid';
9
8
  import {
10
9
  addrDetails,
@@ -91,7 +90,6 @@ export async function runOpenCdpAndCreateSPAccount(
91
90
  orefs.interestOracleUtxo,
92
91
  orefs.treasuryUtxo,
93
92
  context.lucid,
94
- context.emulator.slot,
95
93
  ),
96
94
  );
97
95
 
@@ -118,16 +116,15 @@ async function waitForAccountCooldown(
118
116
  );
119
117
 
120
118
  if (accountUtxo.datum.lastRequestProcessingTime !== 0n) {
121
- const targetSlot = unixTimeToSlot(
122
- context.lucid.config().network!,
119
+ const targetSlot = context.lucid.unixTimeToSlot(
123
120
  Number(accountUtxo.datum.lastRequestProcessingTime) +
124
121
  sysParams.stabilityPoolParams.accountProcessingCooldownMs,
125
122
  );
126
123
 
127
- if (targetSlot > context.emulator.slot) {
128
- expect(targetSlot).toBeGreaterThan(context.emulator.slot);
124
+ if (targetSlot > context.lucid.currentSlot()) {
125
+ expect(targetSlot).toBeGreaterThan(context.lucid.currentSlot());
129
126
 
130
- context.emulator.awaitSlot(targetSlot - context.emulator.slot + 2);
127
+ context.emulator.awaitSlot(targetSlot - context.lucid.currentSlot() + 2);
131
128
  }
132
129
  }
133
130
  }
@@ -174,7 +171,6 @@ export async function runProcessSpRequest(
174
171
  ).map((res) => res.utxo),
175
172
  sysParams,
176
173
  context.lucid,
177
- context.emulator.slot,
178
174
  );
179
175
  }
180
176