@indigo-labs/indigo-sdk 0.4.3 → 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 (54) hide show
  1. package/.claude/settings.local.json +7 -0
  2. package/dist/index.d.mts +992 -905
  3. package/dist/index.d.ts +992 -905
  4. package/dist/index.js +2346 -2155
  5. package/dist/index.mjs +1925 -1750
  6. package/package.json +13 -21
  7. package/scripts/bench.sh +0 -0
  8. package/src/contracts/cdp/helpers.ts +7 -6
  9. package/src/contracts/cdp/transactions.ts +8 -29
  10. package/src/contracts/gov/transactions.ts +15 -17
  11. package/src/contracts/iasset/helpers.ts +2 -7
  12. package/src/contracts/initialize/actions.ts +0 -2
  13. package/src/contracts/initialize/helpers.ts +0 -4
  14. package/src/contracts/interest-collection/transactions.ts +2 -5
  15. package/src/contracts/interest-oracle/helpers.ts +4 -0
  16. package/src/contracts/interest-oracle/transactions.ts +1 -4
  17. package/src/contracts/price-oracle/helpers.ts +5 -11
  18. package/src/contracts/price-oracle/transactions.ts +2 -7
  19. package/src/contracts/rob/transactions.ts +0 -2
  20. package/src/contracts/rob-leverage/transactions.ts +1 -4
  21. package/{tests/queries/stability-pool-queries.ts → src/contracts/stability-pool/queries.ts} +22 -14
  22. package/src/contracts/stability-pool/transactions.ts +2 -8
  23. package/src/contracts/stableswap/helpers.ts +369 -1
  24. package/src/contracts/stableswap/transactions.ts +43 -191
  25. package/src/contracts/staking/transactions.ts +2 -7
  26. package/src/index.ts +4 -3
  27. package/tests/cdp/actions.ts +0 -11
  28. package/tests/cdp/cdp-helpers.ts +2 -2
  29. package/tests/cdp/cdp-queries.ts +8 -5
  30. package/tests/cdp/cdp.test.ts +409 -620
  31. package/tests/cdp/transactions-mutated.ts +30 -25
  32. package/tests/endpoints/initialize.ts +0 -2
  33. package/tests/gov/actions.ts +7 -32
  34. package/tests/gov/gov.test.ts +169 -401
  35. package/tests/indigo-test-helpers.ts +0 -1
  36. package/tests/initialize.test.ts +15 -20
  37. package/tests/interest-collection/interest-collection.test.ts +0 -4
  38. package/tests/interest-oracle.test.ts +1 -8
  39. package/tests/price-oracle/actions.ts +6 -8
  40. package/tests/price-oracle/price-oracle.test.ts +1 -13
  41. package/tests/price-oracle/transactions-mutated.ts +1 -4
  42. package/tests/pyth/pyth-feeds.test.ts +943 -0
  43. package/tests/pyth/pyth-indigo.test.ts +8 -12
  44. package/tests/pyth/pyth.test.ts +1 -2
  45. package/tests/rob/actions.ts +0 -2
  46. package/tests/rob/rob-leverage.test.ts +164 -220
  47. package/tests/rob/rob.test.ts +158 -263
  48. package/tests/rob/transactions-mutated.ts +7 -18
  49. package/tests/stability-pool/actions.ts +31 -22
  50. package/tests/stability-pool.test.ts +226 -319
  51. package/tests/stableswap/stableswap-actions.ts +0 -1
  52. package/tests/stableswap/stableswap.test.ts +226 -4
  53. package/tests/staking.test.ts +2 -13
  54. package/tests/treasury/treasury.test.ts +6 -30
@@ -82,7 +82,6 @@ export async function createIndigoTestContext(
82
82
  const [systemParams, assetConfigs] = await init(
83
83
  context.lucid,
84
84
  [iusdInitialAssetCfg()],
85
- context.emulator.slot,
86
85
  () => [],
87
86
  {
88
87
  foundationMultisig: {
@@ -40,29 +40,24 @@ beforeEach<MyContext>(async (context: MyContext) => {
40
40
  test<MyContext>('Initialize Protocol - can initialize', async ({
41
41
  lucid,
42
42
  users,
43
- emulator,
44
43
  }: MyContext) => {
45
44
  lucid.selectWallet.fromSeed(users.admin.seedPhrase);
46
45
 
47
- await init(
48
- lucid,
49
- [
50
- iusdInitialAssetCfg(DEFAULT_INTEREST, [
51
- {
52
- collateralAsset: EXAMPLE_TOKEN_1,
53
- collateralToIassetRatio: rationalFromInt(1n),
54
- feeManager: undefined,
55
- minMintOrderAmount: 0n,
56
- minRedemptionOrderAmount: 0n,
57
- mintingEnabled: true,
58
- redemptionEnabled: true,
59
- mintingFeeRatio: { numerator: 1n, denominator: 100n },
60
- redemptionFeeRatio: { numerator: 1n, denominator: 100n },
61
- },
62
- ]),
63
- ],
64
- emulator.slot,
65
- );
46
+ await init(lucid, [
47
+ iusdInitialAssetCfg(DEFAULT_INTEREST, [
48
+ {
49
+ collateralAsset: EXAMPLE_TOKEN_1,
50
+ collateralToIassetRatio: rationalFromInt(1n),
51
+ feeManager: undefined,
52
+ minMintOrderAmount: 0n,
53
+ minRedemptionOrderAmount: 0n,
54
+ mintingEnabled: true,
55
+ redemptionEnabled: true,
56
+ mintingFeeRatio: { numerator: 1n, denominator: 100n },
57
+ redemptionFeeRatio: { numerator: 1n, denominator: 100n },
58
+ },
59
+ ]),
60
+ ]);
66
61
  });
67
62
 
68
63
  test<MyContext>('Validate Lucid protocol parameters match Mainnet', ({
@@ -314,7 +314,6 @@ describe('Interest Collection', () => {
314
314
  priceOracleUtxo!,
315
315
  rationalFromInt(1n),
316
316
  iAssetConfig.collateralAssets[0].oracleParams!,
317
- context.emulator.slot,
318
317
  ),
319
318
  );
320
319
 
@@ -327,7 +326,6 @@ describe('Interest Collection', () => {
327
326
  cdpsInfo.map((cdp) => cdp.utxo),
328
327
  context.systemParams,
329
328
  context.lucid,
330
- context.emulator.slot,
331
329
  ),
332
330
  context.lucid,
333
331
  context.emulator,
@@ -406,7 +404,6 @@ describe('Interest Collection', () => {
406
404
  priceOracleUtxo!,
407
405
  rationalFromInt(1n),
408
406
  iAssetConfig.collateralAssets[0].oracleParams!,
409
- context.emulator.slot,
410
407
  ),
411
408
  );
412
409
 
@@ -419,7 +416,6 @@ describe('Interest Collection', () => {
419
416
  cdpsInfo.map((cdp) => cdp.utxo),
420
417
  context.systemParams,
421
418
  context.lucid,
422
- context.emulator.slot,
423
419
  ),
424
420
  );
425
421
  });
@@ -86,14 +86,7 @@ test<InterestOracleTestContext>('Interest Oracle - Update', async ({
86
86
 
87
87
  await benchmarkAndAwaitTx(
88
88
  'Interest Oracle - Update',
89
- await feedInterestOracle(
90
- interestParams,
91
- 500_000n,
92
- lucid,
93
- emulator.slot,
94
- undefined,
95
- utxo,
96
- ),
89
+ await feedInterestOracle(interestParams, 500_000n, lucid, undefined, utxo),
97
90
  lucid,
98
91
  emulator,
99
92
  );
@@ -16,7 +16,6 @@ import {
16
16
  } from '../cdp/cdp-queries';
17
17
  import { feedPriceOracleTx } from '../../src/contracts/price-oracle/transactions';
18
18
  import { findCollateralAsset } from '../queries/iasset-queries';
19
- import { unixTimeToSlot } from '@lucid-evolution/lucid';
20
19
  import { findPriceOracle } from './price-oracle-queries';
21
20
  import { match, P } from 'ts-pattern';
22
21
  import { parsePriceOracleDatum } from '../../src/contracts/price-oracle/types-new';
@@ -65,7 +64,6 @@ export async function runFeedPriceToOracle(
65
64
  priceOracleUtxo!,
66
65
  price,
67
66
  collateralInfo.oracleParams!,
68
- context.emulator.slot,
69
67
  ),
70
68
  );
71
69
 
@@ -120,7 +118,6 @@ export async function refreshPriceOracle(
120
118
  priceOracleUtxo!,
121
119
  price,
122
120
  collateralInfo.oracleParams!,
123
- context.emulator.slot,
124
121
  ),
125
122
  );
126
123
 
@@ -147,15 +144,16 @@ export async function waitForOracleExpiration(
147
144
 
148
145
  const oracle = parsePriceOracleDatum(getInlineDatumOrThrow(priceOracle));
149
146
 
150
- const targetSlot = unixTimeToSlot(
151
- context.lucid.config().network!,
147
+ const targetSlot = context.lucid.unixTimeToSlot(
152
148
  Number(oracle.expirationTime),
153
149
  );
154
150
 
155
- if (targetSlot > context.emulator.slot) {
156
- expect(targetSlot).toBeGreaterThan(context.emulator.slot);
151
+ if (targetSlot > context.lucid.currentSlot()) {
152
+ expect(targetSlot).toBeGreaterThan(context.lucid.currentSlot());
157
153
 
158
- context.emulator.awaitSlot(targetSlot - context.emulator.slot + 5);
154
+ context.emulator.awaitSlot(
155
+ targetSlot - context.lucid.currentSlot() + 5,
156
+ );
159
157
  }
160
158
  })
161
159
  // otherwise no need to await
@@ -52,7 +52,6 @@ describe('Rational Price Oracle', () => {
52
52
  'ORACLE_NFT',
53
53
  rationalFromInt(1n),
54
54
  params,
55
- context.emulator.slot,
56
55
  );
57
56
 
58
57
  await runAndAwaitTxBuilder(context.lucid, tx);
@@ -70,7 +69,6 @@ describe('Rational Price Oracle', () => {
70
69
  'ORACLE_NFT',
71
70
  rationalFromInt(1n),
72
71
  params,
73
- context.emulator.slot,
74
72
  );
75
73
 
76
74
  const startTxHash = await runAndAwaitTxBuilder(context.lucid, startTx);
@@ -80,7 +78,6 @@ describe('Rational Price Oracle', () => {
80
78
  { txHash: startTxHash, outputIndex: 0 },
81
79
  rationalFromInt(2n),
82
80
  params,
83
- context.emulator.slot,
84
81
  );
85
82
 
86
83
  await runAndAwaitTxBuilder(context.lucid, feedTx);
@@ -98,7 +95,6 @@ describe('Rational Price Oracle', () => {
98
95
  'ORACLE_NFT',
99
96
  rationalFromInt(1n),
100
97
  params,
101
- context.emulator.slot,
102
98
  );
103
99
 
104
100
  const startTxHash = await runAndAwaitTxBuilder(context.lucid, startTx);
@@ -110,7 +106,6 @@ describe('Rational Price Oracle', () => {
110
106
  { txHash: startTxHash, outputIndex: 0 },
111
107
  rationalFromInt(-2n),
112
108
  params,
113
- context.emulator.slot,
114
109
  ),
115
110
  );
116
111
  });
@@ -127,7 +122,6 @@ describe('Rational Price Oracle', () => {
127
122
  'ORACLE_NFT',
128
123
  rationalFromInt(1n),
129
124
  params,
130
- context.emulator.slot,
131
125
  );
132
126
 
133
127
  const startTxHash = await runAndAwaitTxBuilder(context.lucid, startTx);
@@ -139,7 +133,6 @@ describe('Rational Price Oracle', () => {
139
133
  { txHash: startTxHash, outputIndex: 0 },
140
134
  rationalFromInt(2n),
141
135
  params,
142
- context.emulator.slot,
143
136
  ),
144
137
  );
145
138
  });
@@ -156,7 +149,6 @@ describe('Rational Price Oracle', () => {
156
149
  'ORACLE_NFT',
157
150
  rationalFromInt(1n),
158
151
  params,
159
- context.emulator.slot,
160
152
  );
161
153
 
162
154
  const startTxHash = await runAndAwaitTxBuilder(context.lucid, startTx);
@@ -168,7 +160,6 @@ describe('Rational Price Oracle', () => {
168
160
  { txHash: startTxHash, outputIndex: 0 },
169
161
  { numerator: 2n, denominator: 0n },
170
162
  params,
171
- context.emulator.slot,
172
163
  ),
173
164
  );
174
165
  });
@@ -185,7 +176,6 @@ describe('Rational Price Oracle', () => {
185
176
  'ORACLE_NFT',
186
177
  rationalFromInt(1n),
187
178
  params,
188
- context.emulator.slot,
189
179
  );
190
180
 
191
181
  const startTxHash = await runAndAwaitTxBuilder(context.lucid, startTx);
@@ -201,7 +191,6 @@ describe('Rational Price Oracle', () => {
201
191
  denominator: BigInt(Number.MAX_SAFE_INTEGER),
202
192
  },
203
193
  params,
204
- context.emulator.slot,
205
194
  ),
206
195
  );
207
196
  });
@@ -218,7 +207,6 @@ describe('Rational Price Oracle', () => {
218
207
  'ORACLE_NFT',
219
208
  rationalFromInt(1n),
220
209
  params,
221
- context.emulator.slot,
222
210
  );
223
211
 
224
212
  const startTxHash = await runAndAwaitTxBuilder(context.lucid, startTx);
@@ -230,7 +218,7 @@ describe('Rational Price Oracle', () => {
230
218
  { txHash: startTxHash, outputIndex: 0 },
231
219
  rationalFromInt(1n),
232
220
  params,
233
- context.emulator.slot,
221
+
234
222
  Core.Data.fromCBORHex(
235
223
  'd8799f1b0180e51d1ae19514d8799f1a00030d40ff1b00000194ce33c598ff',
236
224
  ),
@@ -2,7 +2,6 @@ import {
2
2
  Data,
3
3
  LucidEvolution,
4
4
  OutRef,
5
- slotToUnixTime,
6
5
  TxBuilder,
7
6
  } from '@lucid-evolution/lucid';
8
7
  import {
@@ -22,10 +21,8 @@ export async function feedPriceOracleTxStealNft(
22
21
  oracleOref: OutRef,
23
22
  newPrice: Rational,
24
23
  oracleParams: PriceOracleParams,
25
- currentSlot: number,
26
24
  ): Promise<TxBuilder> {
27
- const network = lucid.config().network!;
28
- const currentTime = BigInt(slotToUnixTime(network, currentSlot));
25
+ const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
29
26
 
30
27
  const priceOracleUtxo = matchSingle(
31
28
  await lucid.utxosByOutRef([oracleOref]),