@indigo-labs/indigo-sdk 0.4.4 → 0.5.0

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 (49) hide show
  1. package/dist/index.d.mts +102 -40
  2. package/dist/index.d.ts +102 -40
  3. package/dist/index.js +900 -801
  4. package/dist/index.mjs +339 -256
  5. package/package.json +2 -2
  6. package/src/contracts/cdp/helpers.ts +7 -6
  7. package/src/contracts/cdp/transactions.ts +8 -29
  8. package/src/contracts/gov/transactions.ts +12 -16
  9. package/src/contracts/iasset/helpers.ts +2 -7
  10. package/src/contracts/initialize/actions.ts +0 -2
  11. package/src/contracts/initialize/helpers.ts +0 -4
  12. package/src/contracts/interest-collection/transactions.ts +2 -5
  13. package/src/contracts/interest-oracle/helpers.ts +4 -0
  14. package/src/contracts/interest-oracle/transactions.ts +1 -4
  15. package/src/contracts/price-oracle/helpers.ts +5 -11
  16. package/src/contracts/price-oracle/transactions.ts +2 -7
  17. package/src/contracts/rob/transactions.ts +0 -2
  18. package/src/contracts/rob-leverage/transactions.ts +1 -4
  19. package/src/contracts/stability-pool/transactions.ts +2 -8
  20. package/src/contracts/stableswap/helpers.ts +369 -1
  21. package/src/contracts/stableswap/transactions.ts +43 -191
  22. package/src/contracts/staking/transactions.ts +2 -7
  23. package/tests/cdp/actions.ts +0 -11
  24. package/tests/cdp/cdp-helpers.ts +2 -2
  25. package/tests/cdp/cdp-queries.ts +1 -3
  26. package/tests/cdp/cdp.test.ts +409 -620
  27. package/tests/cdp/transactions-mutated.ts +30 -25
  28. package/tests/endpoints/initialize.ts +0 -2
  29. package/tests/gov/actions.ts +7 -32
  30. package/tests/gov/gov.test.ts +169 -401
  31. package/tests/indigo-test-helpers.ts +0 -1
  32. package/tests/initialize.test.ts +15 -20
  33. package/tests/interest-collection/interest-collection.test.ts +0 -4
  34. package/tests/interest-oracle.test.ts +1 -8
  35. package/tests/price-oracle/actions.ts +6 -8
  36. package/tests/price-oracle/price-oracle.test.ts +1 -13
  37. package/tests/price-oracle/transactions-mutated.ts +1 -4
  38. package/tests/pyth/pyth-indigo.test.ts +8 -12
  39. package/tests/pyth/pyth.test.ts +1 -2
  40. package/tests/rob/actions.ts +0 -2
  41. package/tests/rob/rob-leverage.test.ts +164 -220
  42. package/tests/rob/rob.test.ts +158 -263
  43. package/tests/rob/transactions-mutated.ts +7 -18
  44. package/tests/stability-pool/actions.ts +4 -8
  45. package/tests/stability-pool.test.ts +164 -255
  46. package/tests/stableswap/stableswap-actions.ts +0 -1
  47. package/tests/stableswap/stableswap.test.ts +226 -4
  48. package/tests/staking.test.ts +2 -13
  49. package/tests/treasury/treasury.test.ts +6 -30
@@ -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
  }