@indigo-labs/indigo-sdk 0.1.2 → 0.1.3

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 (93) hide show
  1. package/.github/workflows/ci.yml +62 -0
  2. package/.github/workflows/test.yml +44 -0
  3. package/.husky/pre-commit +1 -0
  4. package/.prettierrc +1 -1
  5. package/README.md +52 -7
  6. package/dist/index.d.mts +1064 -182
  7. package/dist/index.d.ts +1064 -182
  8. package/dist/index.js +2565 -561
  9. package/dist/index.mjs +2546 -593
  10. package/eslint.config.mjs +35 -0
  11. package/package.json +61 -43
  12. package/src/contracts/cdp.ts +208 -359
  13. package/src/contracts/collector.ts +13 -6
  14. package/src/contracts/gov.ts +1 -58
  15. package/src/contracts/interest-oracle.ts +139 -39
  16. package/src/contracts/lrp.ts +223 -0
  17. package/src/contracts/one-shot.ts +67 -0
  18. package/src/contracts/stability-pool.ts +684 -0
  19. package/src/contracts/staking.ts +348 -0
  20. package/src/contracts/treasury.ts +30 -13
  21. package/src/helpers/asset-helpers.ts +51 -22
  22. package/src/helpers/helper-txs.ts +30 -0
  23. package/src/helpers/helpers.ts +29 -8
  24. package/src/helpers/indigo-helpers.ts +19 -0
  25. package/src/helpers/interest-oracle.ts +57 -0
  26. package/src/helpers/lucid-utils.ts +62 -16
  27. package/src/helpers/price-oracle-helpers.ts +36 -0
  28. package/src/helpers/stability-pool-helpers.ts +207 -0
  29. package/src/helpers/staking-helpers.ts +94 -0
  30. package/src/helpers/time-helpers.ts +4 -3
  31. package/src/helpers/value-helpers.ts +16 -0
  32. package/src/index.ts +15 -4
  33. package/src/scripts/always-fail-validator.ts +7 -0
  34. package/src/scripts/auth-token-policy.ts +23 -0
  35. package/src/scripts/cdp-creator-validator.ts +46 -2
  36. package/src/scripts/collector-validator.ts +2 -2
  37. package/src/scripts/execute-validator.ts +52 -0
  38. package/src/scripts/gov-validator.ts +44 -0
  39. package/src/scripts/iasset-policy.ts +22 -0
  40. package/src/scripts/interest-oracle-validator.ts +18 -3
  41. package/src/scripts/lrp-validator.ts +23 -0
  42. package/src/scripts/one-shot-policy.ts +62 -0
  43. package/src/scripts/poll-manager-validator.ts +52 -0
  44. package/src/scripts/poll-shard-validator.ts +47 -0
  45. package/src/scripts/price-oracle-validator.ts +26 -0
  46. package/src/scripts/stability-pool-validator.ts +60 -0
  47. package/src/scripts/staking-validator.ts +8 -0
  48. package/src/scripts/version-record-policy.ts +26 -0
  49. package/src/scripts/version-registry.ts +15 -0
  50. package/src/types/generic.ts +99 -6
  51. package/src/types/indigo/cdp-creator.ts +46 -0
  52. package/src/types/indigo/cdp.ts +86 -31
  53. package/src/types/indigo/execute.ts +21 -0
  54. package/src/types/indigo/gov.ts +50 -20
  55. package/src/types/indigo/interest-oracle.ts +55 -5
  56. package/src/types/indigo/lrp.ts +54 -0
  57. package/src/types/indigo/poll-manager.ts +21 -0
  58. package/src/types/indigo/poll-shard.ts +16 -0
  59. package/src/types/indigo/price-oracle.ts +38 -4
  60. package/src/types/indigo/stability-pool.ts +233 -0
  61. package/src/types/indigo/staking.ts +99 -0
  62. package/src/types/indigo/version-record.ts +17 -0
  63. package/src/types/on-chain-decimal.ts +23 -0
  64. package/src/types/one-shot.ts +22 -0
  65. package/src/types/system-params.ts +95 -77
  66. package/tests/data/system-params.json +972 -972
  67. package/tests/datums.test.ts +279 -44
  68. package/tests/endpoints/initialize.ts +1013 -0
  69. package/tests/hash-checks.test.ts +71 -15
  70. package/tests/indigo-test-helpers.ts +115 -0
  71. package/tests/initialize.test.ts +27 -0
  72. package/tests/interest-calculations.test.ts +110 -133
  73. package/tests/interest-oracle.test.ts +90 -0
  74. package/tests/lrp.test.ts +149 -0
  75. package/tests/queries/governance-queries.ts +31 -0
  76. package/tests/queries/iasset-queries.ts +39 -0
  77. package/tests/queries/interest-oracle-queries.ts +13 -0
  78. package/tests/queries/lrp-queries.ts +39 -0
  79. package/tests/queries/price-oracle-queries.ts +27 -0
  80. package/tests/queries/stability-pool-queries.ts +75 -0
  81. package/tests/queries/staking-queries.ts +43 -0
  82. package/tests/stability-pool.test.ts +364 -0
  83. package/tests/staking.test.ts +105 -0
  84. package/tests/test-helpers.ts +38 -0
  85. package/tsconfig.build.json +4 -0
  86. package/tsconfig.json +8 -27
  87. package/vitest.config.ts +9 -0
  88. package/babel.config.cjs +0 -13
  89. package/examples/sample-cdp.ts +0 -43
  90. package/jest.config.js +0 -13
  91. package/src/contracts/cdp-creator.ts +0 -86
  92. package/src/contracts/price-oracle.ts +0 -24
  93. package/src/helpers/cdp-helpers.ts +0 -9
@@ -0,0 +1,364 @@
1
+ import { beforeEach, test, afterEach } from 'vitest';
2
+ import { LucidContext, runAndAwaitTx } from './test-helpers';
3
+ import { fromText, Lucid } from '@lucid-evolution/lucid';
4
+ import { Emulator } from '@lucid-evolution/lucid';
5
+ import { generateEmulatorAccount } from '@lucid-evolution/lucid';
6
+ import { init } from './endpoints/initialize';
7
+ import { addrDetails, CDPContract, StabilityPoolContract } from '../src';
8
+ import {
9
+ findStabilityPool,
10
+ findStabilityPoolAccount,
11
+ } from './queries/stability-pool-queries';
12
+ import { findIAsset } from './queries/iasset-queries';
13
+ import { findGov } from './queries/governance-queries';
14
+
15
+ let originalDateNow: () => number;
16
+
17
+ beforeEach<LucidContext>(async (context: LucidContext) => {
18
+ context.users = {
19
+ admin: generateEmulatorAccount({
20
+ lovelace: BigInt(100_000_000_000_000),
21
+ }),
22
+ user: generateEmulatorAccount({
23
+ lovelace: BigInt(100_000_000_000_000),
24
+ }),
25
+ };
26
+
27
+ context.emulator = new Emulator([context.users.admin, context.users.user]);
28
+
29
+ context.lucid = await Lucid(context.emulator, 'Custom');
30
+
31
+ originalDateNow = Date.now;
32
+ Date.now = () => context.emulator.now();
33
+ });
34
+
35
+ afterEach(() => {
36
+ Date.now = originalDateNow;
37
+ });
38
+
39
+ test<LucidContext>('Stability Pool - Create Account', async ({
40
+ lucid,
41
+ users,
42
+ }: LucidContext) => {
43
+ lucid.selectWallet.fromSeed(users.admin.seedPhrase);
44
+ const systemParams = await init(lucid);
45
+ lucid.selectWallet.fromSeed(users.user.seedPhrase);
46
+ const [pkh, _] = await addrDetails(lucid);
47
+
48
+ await runAndAwaitTx(
49
+ lucid,
50
+ CDPContract.openPosition('iUSD', 1_000_000_000n, 20n, systemParams, lucid),
51
+ );
52
+
53
+ await runAndAwaitTx(
54
+ lucid,
55
+ StabilityPoolContract.createAccount('iUSD', 10n, systemParams, lucid),
56
+ );
57
+
58
+ const stabilityPoolUtxo = await findStabilityPool(
59
+ lucid,
60
+ systemParams.validatorHashes.stabilityPoolHash,
61
+ {
62
+ currencySymbol:
63
+ systemParams.stabilityPoolParams.stabilityPoolToken[0].unCurrencySymbol,
64
+ tokenName: fromText(
65
+ systemParams.stabilityPoolParams.stabilityPoolToken[1].unTokenName,
66
+ ),
67
+ },
68
+ 'iUSD',
69
+ );
70
+
71
+ const accountUtxo = await findStabilityPoolAccount(
72
+ lucid,
73
+ systemParams.validatorHashes.stabilityPoolHash,
74
+ pkh.hash,
75
+ 'iUSD',
76
+ );
77
+
78
+ const assetUtxo = await findIAsset(
79
+ lucid,
80
+ systemParams.validatorHashes.cdpHash,
81
+ {
82
+ currencySymbol:
83
+ systemParams.cdpParams.iAssetAuthToken[0].unCurrencySymbol,
84
+ tokenName: fromText(
85
+ systemParams.cdpParams.iAssetAuthToken[1].unTokenName,
86
+ ),
87
+ },
88
+ 'iUSD',
89
+ );
90
+
91
+ const govUtxo = await findGov(lucid, systemParams.validatorHashes.govHash, {
92
+ currencySymbol: systemParams.govParams.govNFT[0].unCurrencySymbol,
93
+ tokenName: fromText(systemParams.govParams.govNFT[1].unTokenName),
94
+ });
95
+
96
+ lucid.selectWallet.fromSeed(users.admin.seedPhrase);
97
+
98
+ await runAndAwaitTx(
99
+ lucid,
100
+ StabilityPoolContract.processRequest(
101
+ 'iUSD',
102
+ stabilityPoolUtxo,
103
+ accountUtxo,
104
+ govUtxo,
105
+ assetUtxo,
106
+ undefined,
107
+ systemParams,
108
+ lucid,
109
+ ),
110
+ );
111
+ });
112
+
113
+ test<LucidContext>('Stability Pool - Adjust Account', async ({
114
+ lucid,
115
+ users,
116
+ }: LucidContext) => {
117
+ lucid.selectWallet.fromSeed(users.admin.seedPhrase);
118
+ const systemParams = await init(lucid);
119
+ lucid.selectWallet.fromSeed(users.user.seedPhrase);
120
+ const [pkh, _] = await addrDetails(lucid);
121
+
122
+ await runAndAwaitTx(
123
+ lucid,
124
+ CDPContract.openPosition('iUSD', 1_000_000_000n, 20n, systemParams, lucid),
125
+ );
126
+
127
+ await runAndAwaitTx(
128
+ lucid,
129
+ StabilityPoolContract.createAccount('iUSD', 10n, systemParams, lucid),
130
+ );
131
+
132
+ lucid.selectWallet.fromSeed(users.admin.seedPhrase);
133
+
134
+ let stabilityPoolUtxo = await findStabilityPool(
135
+ lucid,
136
+ systemParams.validatorHashes.stabilityPoolHash,
137
+ {
138
+ currencySymbol:
139
+ systemParams.stabilityPoolParams.stabilityPoolToken[0].unCurrencySymbol,
140
+ tokenName: fromText(
141
+ systemParams.stabilityPoolParams.stabilityPoolToken[1].unTokenName,
142
+ ),
143
+ },
144
+ 'iUSD',
145
+ );
146
+
147
+ let accountUtxo = await findStabilityPoolAccount(
148
+ lucid,
149
+ systemParams.validatorHashes.stabilityPoolHash,
150
+ pkh.hash,
151
+ 'iUSD',
152
+ );
153
+
154
+ const assetUtxo = await findIAsset(
155
+ lucid,
156
+ systemParams.validatorHashes.cdpHash,
157
+ {
158
+ currencySymbol:
159
+ systemParams.cdpParams.iAssetAuthToken[0].unCurrencySymbol,
160
+ tokenName: fromText(
161
+ systemParams.cdpParams.iAssetAuthToken[1].unTokenName,
162
+ ),
163
+ },
164
+ 'iUSD',
165
+ );
166
+
167
+ const govUtxo = await findGov(lucid, systemParams.validatorHashes.govHash, {
168
+ currencySymbol: systemParams.govParams.govNFT[0].unCurrencySymbol,
169
+ tokenName: fromText(systemParams.govParams.govNFT[1].unTokenName),
170
+ });
171
+
172
+ await runAndAwaitTx(
173
+ lucid,
174
+ StabilityPoolContract.processRequest(
175
+ 'iUSD',
176
+ stabilityPoolUtxo,
177
+ accountUtxo,
178
+ govUtxo,
179
+ assetUtxo,
180
+ undefined,
181
+ systemParams,
182
+ lucid,
183
+ ),
184
+ );
185
+
186
+ lucid.selectWallet.fromSeed(users.user.seedPhrase);
187
+
188
+ stabilityPoolUtxo = await findStabilityPool(
189
+ lucid,
190
+ systemParams.validatorHashes.stabilityPoolHash,
191
+ {
192
+ currencySymbol:
193
+ systemParams.stabilityPoolParams.stabilityPoolToken[0].unCurrencySymbol,
194
+ tokenName: fromText(
195
+ systemParams.stabilityPoolParams.stabilityPoolToken[1].unTokenName,
196
+ ),
197
+ },
198
+ 'iUSD',
199
+ );
200
+
201
+ accountUtxo = await findStabilityPoolAccount(
202
+ lucid,
203
+ systemParams.validatorHashes.stabilityPoolHash,
204
+ pkh.hash,
205
+ 'iUSD',
206
+ );
207
+
208
+ await runAndAwaitTx(
209
+ lucid,
210
+ StabilityPoolContract.adjustAccount(
211
+ 'iUSD',
212
+ 10n,
213
+ accountUtxo,
214
+ systemParams,
215
+ lucid,
216
+ ),
217
+ );
218
+ lucid.selectWallet.fromSeed(users.admin.seedPhrase);
219
+
220
+ accountUtxo = await findStabilityPoolAccount(
221
+ lucid,
222
+ systemParams.validatorHashes.stabilityPoolHash,
223
+ pkh.hash,
224
+ 'iUSD',
225
+ );
226
+
227
+ await runAndAwaitTx(
228
+ lucid,
229
+ StabilityPoolContract.processRequest(
230
+ 'iUSD',
231
+ stabilityPoolUtxo,
232
+ accountUtxo,
233
+ govUtxo,
234
+ assetUtxo,
235
+ undefined,
236
+ systemParams,
237
+ lucid,
238
+ ),
239
+ );
240
+ });
241
+
242
+ test<LucidContext>('Stability Pool - Close Account', async ({
243
+ lucid,
244
+ users,
245
+ emulator,
246
+ }: LucidContext) => {
247
+ lucid.selectWallet.fromSeed(users.admin.seedPhrase);
248
+ const systemParams = await init(lucid, emulator.now());
249
+ lucid.selectWallet.fromSeed(users.user.seedPhrase);
250
+ const [pkh, _] = await addrDetails(lucid);
251
+
252
+ await runAndAwaitTx(
253
+ lucid,
254
+ CDPContract.openPosition('iUSD', 1_000_000_000n, 20n, systemParams, lucid),
255
+ );
256
+
257
+ await runAndAwaitTx(
258
+ lucid,
259
+ StabilityPoolContract.createAccount('iUSD', 10n, systemParams, lucid),
260
+ );
261
+
262
+ lucid.selectWallet.fromSeed(users.admin.seedPhrase);
263
+
264
+ let stabilityPoolUtxo = await findStabilityPool(
265
+ lucid,
266
+ systemParams.validatorHashes.stabilityPoolHash,
267
+ {
268
+ currencySymbol:
269
+ systemParams.stabilityPoolParams.stabilityPoolToken[0].unCurrencySymbol,
270
+ tokenName: fromText(
271
+ systemParams.stabilityPoolParams.stabilityPoolToken[1].unTokenName,
272
+ ),
273
+ },
274
+ 'iUSD',
275
+ );
276
+
277
+ let accountUtxo = await findStabilityPoolAccount(
278
+ lucid,
279
+ systemParams.validatorHashes.stabilityPoolHash,
280
+ pkh.hash,
281
+ 'iUSD',
282
+ );
283
+
284
+ const assetUtxo = await findIAsset(
285
+ lucid,
286
+ systemParams.validatorHashes.cdpHash,
287
+ {
288
+ currencySymbol:
289
+ systemParams.cdpParams.iAssetAuthToken[0].unCurrencySymbol,
290
+ tokenName: fromText(
291
+ systemParams.cdpParams.iAssetAuthToken[1].unTokenName,
292
+ ),
293
+ },
294
+ 'iUSD',
295
+ );
296
+
297
+ const govUtxo = await findGov(lucid, systemParams.validatorHashes.govHash, {
298
+ currencySymbol: systemParams.govParams.govNFT[0].unCurrencySymbol,
299
+ tokenName: fromText(systemParams.govParams.govNFT[1].unTokenName),
300
+ });
301
+
302
+ await runAndAwaitTx(
303
+ lucid,
304
+ StabilityPoolContract.processRequest(
305
+ 'iUSD',
306
+ stabilityPoolUtxo,
307
+ accountUtxo,
308
+ govUtxo,
309
+ assetUtxo,
310
+ undefined,
311
+ systemParams,
312
+ lucid,
313
+ ),
314
+ );
315
+
316
+ lucid.selectWallet.fromSeed(users.user.seedPhrase);
317
+
318
+ stabilityPoolUtxo = await findStabilityPool(
319
+ lucid,
320
+ systemParams.validatorHashes.stabilityPoolHash,
321
+ {
322
+ currencySymbol:
323
+ systemParams.stabilityPoolParams.stabilityPoolToken[0].unCurrencySymbol,
324
+ tokenName: fromText(
325
+ systemParams.stabilityPoolParams.stabilityPoolToken[1].unTokenName,
326
+ ),
327
+ },
328
+ 'iUSD',
329
+ );
330
+
331
+ accountUtxo = await findStabilityPoolAccount(
332
+ lucid,
333
+ systemParams.validatorHashes.stabilityPoolHash,
334
+ pkh.hash,
335
+ 'iUSD',
336
+ );
337
+
338
+ await runAndAwaitTx(
339
+ lucid,
340
+ StabilityPoolContract.closeAccount(accountUtxo, systemParams, lucid),
341
+ );
342
+ lucid.selectWallet.fromSeed(users.admin.seedPhrase);
343
+
344
+ accountUtxo = await findStabilityPoolAccount(
345
+ lucid,
346
+ systemParams.validatorHashes.stabilityPoolHash,
347
+ pkh.hash,
348
+ 'iUSD',
349
+ );
350
+
351
+ await runAndAwaitTx(
352
+ lucid,
353
+ StabilityPoolContract.processRequest(
354
+ 'iUSD',
355
+ stabilityPoolUtxo,
356
+ accountUtxo,
357
+ govUtxo,
358
+ assetUtxo,
359
+ undefined,
360
+ systemParams,
361
+ lucid,
362
+ ),
363
+ );
364
+ });
@@ -0,0 +1,105 @@
1
+ import { beforeEach, test } from 'vitest';
2
+ import { LucidContext, runAndAwaitTx } from './test-helpers';
3
+ import { fromText, Lucid } from '@lucid-evolution/lucid';
4
+ import { Emulator } from '@lucid-evolution/lucid';
5
+ import { generateEmulatorAccount } from '@lucid-evolution/lucid';
6
+ import { StakingContract } from '../src/contracts/staking';
7
+ import { init } from './endpoints/initialize';
8
+ import { addrDetails } from '../src/helpers/lucid-utils';
9
+ import { findStakingPosition } from './queries/staking-queries';
10
+
11
+ beforeEach<LucidContext>(async (context: LucidContext) => {
12
+ context.users = {
13
+ admin: generateEmulatorAccount({
14
+ lovelace: BigInt(100_000_000_000_000),
15
+ }),
16
+ };
17
+
18
+ context.emulator = new Emulator([context.users.admin]);
19
+
20
+ context.lucid = await Lucid(context.emulator, 'Custom');
21
+ });
22
+
23
+ test<LucidContext>('Staking - Create Position', async ({
24
+ lucid,
25
+ users,
26
+ }: LucidContext) => {
27
+ lucid.selectWallet.fromSeed(users.admin.seedPhrase);
28
+ const systemParams = await init(lucid);
29
+
30
+ await runAndAwaitTx(
31
+ lucid,
32
+ StakingContract.openPosition(1_000_000n, systemParams, lucid),
33
+ );
34
+ });
35
+
36
+ test<LucidContext>('Staking - Adjust Position', async ({
37
+ lucid,
38
+ users,
39
+ }: LucidContext) => {
40
+ lucid.selectWallet.fromSeed(users.admin.seedPhrase);
41
+ const systemParams = await init(lucid);
42
+
43
+ await runAndAwaitTx(
44
+ lucid,
45
+ StakingContract.openPosition(1_000_000n, systemParams, lucid),
46
+ );
47
+
48
+ const [pkh, _] = await addrDetails(lucid);
49
+ const myStakingPosition = await findStakingPosition(
50
+ lucid,
51
+ lucid.config().network,
52
+ systemParams.validatorHashes.stakingHash,
53
+ {
54
+ currencySymbol:
55
+ systemParams.stakingParams.stakingToken[0].unCurrencySymbol,
56
+ tokenName: fromText(
57
+ systemParams.stakingParams.stakingToken[1].unTokenName,
58
+ ),
59
+ },
60
+ pkh.hash,
61
+ );
62
+
63
+ await runAndAwaitTx(
64
+ lucid,
65
+ StakingContract.adjustPosition(
66
+ myStakingPosition,
67
+ 1_000_000n,
68
+ systemParams,
69
+ lucid,
70
+ ),
71
+ );
72
+ });
73
+
74
+ test<LucidContext>('Staking - Close Position', async ({
75
+ lucid,
76
+ users,
77
+ }: LucidContext) => {
78
+ lucid.selectWallet.fromSeed(users.admin.seedPhrase);
79
+ const systemParams = await init(lucid);
80
+
81
+ await runAndAwaitTx(
82
+ lucid,
83
+ StakingContract.openPosition(1_000_000n, systemParams, lucid),
84
+ );
85
+
86
+ const [pkh, _] = await addrDetails(lucid);
87
+ const myStakingPosition = await findStakingPosition(
88
+ lucid,
89
+ lucid.config().network,
90
+ systemParams.validatorHashes.stakingHash,
91
+ {
92
+ currencySymbol:
93
+ systemParams.stakingParams.stakingToken[0].unCurrencySymbol,
94
+ tokenName: fromText(
95
+ systemParams.stakingParams.stakingToken[1].unTokenName,
96
+ ),
97
+ },
98
+ pkh.hash,
99
+ );
100
+
101
+ await runAndAwaitTx(
102
+ lucid,
103
+ StakingContract.closePosition(myStakingPosition, systemParams, lucid),
104
+ );
105
+ });
@@ -0,0 +1,38 @@
1
+ import {
2
+ Emulator,
3
+ EmulatorAccount,
4
+ LucidEvolution,
5
+ TxBuilder,
6
+ } from '@lucid-evolution/lucid';
7
+
8
+ export type LucidContext = {
9
+ lucid: LucidEvolution;
10
+ users: { [key: string]: EmulatorAccount };
11
+ emulator: Emulator;
12
+ };
13
+
14
+ export async function runAndAwaitTx(
15
+ lucid: LucidEvolution,
16
+ transaction: Promise<TxBuilder>,
17
+ ): Promise<string> {
18
+ const txHash = await transaction
19
+ .then((tx) => tx.complete())
20
+ .then((tx) => tx.sign.withWallet().complete())
21
+ .then((tx) => tx.submit());
22
+
23
+ await lucid.awaitTx(txHash);
24
+ return txHash;
25
+ }
26
+
27
+ export async function runAndAwaitTxBuilder(
28
+ lucid: LucidEvolution,
29
+ transaction: TxBuilder,
30
+ ): Promise<string> {
31
+ const txHash = await transaction
32
+ .complete()
33
+ .then((tx) => tx.sign.withWallet().complete())
34
+ .then((tx) => tx.submit());
35
+
36
+ await lucid.awaitTx(txHash);
37
+ return txHash;
38
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "exclude": ["spec/**/*.spec.ts", "vitest.config.ts"]
4
+ }
package/tsconfig.json CHANGED
@@ -1,35 +1,16 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "outDir": "./dist",
4
- "noImplicitAny": true,
5
- "module": "es2022",
6
- "target": "es2022",
7
- "lib": ["es2022", "DOM"],
8
- "allowJs": true,
9
- "moduleResolution": "node",
10
- "declaration": true,
11
- "strict": true,
12
- "strictNullChecks": true,
13
- "strictFunctionTypes": true,
14
- "strictBindCallApply": true,
15
- "strictPropertyInitialization": false,
16
- "noImplicitThis": true,
17
- "alwaysStrict": false,
18
- "noUnusedLocals": false,
19
- "noUnusedParameters": false,
20
- "noImplicitReturns": true,
21
- "noFallthroughCasesInSwitch": true,
22
- "esModuleInterop": true,
23
- "skipLibCheck": true,
24
- "forceConsistentCasingInFileNames": true,
25
- "resolveJsonModule": true,
26
- "allowSyntheticDefaultImports": true
4
+ "sourceMap": true,
5
+ "module": "nodenext",
6
+ "target": "ESNext",
7
+ "moduleResolution": "nodenext"
27
8
  },
28
9
  "ts-node": {
29
10
  "compilerOptions": {
30
- "module": "ES2022",
11
+ "module": "ES2022"
31
12
  }
32
13
  },
33
- "include": ["src/**/*.ts"],
34
- "exclude": ["node_modules", "tests", "dist"],
35
- }
14
+ "include": ["src/**/*.ts", "tests/**/*.ts", "vitest.config.ts"],
15
+ "exclude": ["dist", "node_modules"]
16
+ }
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ testTimeout: 120000, // 2 minutes
6
+ reporters: 'verbose',
7
+ include: ['./tests/**/*.test.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
8
+ },
9
+ });
package/babel.config.cjs DELETED
@@ -1,13 +0,0 @@
1
- module.exports = {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "node": "current"
8
- }
9
- }
10
- ],
11
- "@babel/preset-typescript",
12
- ]
13
- };
@@ -1,43 +0,0 @@
1
- import { Blockfrost, Lucid, OutRef } from "@lucid-evolution/lucid";
2
- import { balance, CDPContract, loadSystemParamsFromUrl } from "../src";
3
-
4
- async function main() {
5
- const lucid = await Lucid(
6
- new Blockfrost(
7
- 'https://cardano-mainnet.blockfrost.io/api/v0',
8
- 'mainnetpb1Y1PczllObhmQKFMO6wm3la39p70k5'
9
- ),
10
- 'Mainnet'
11
- );
12
-
13
- lucid.selectWallet.fromSeed('helmet coconut robot path message library verb lobster rigid taxi recall ribbon vacuum uniform horse thumb praise sibling wise frown cattle settle century sad');
14
-
15
- const systemParams = await loadSystemParamsFromUrl('https://config.indigoprotocol.io/mainnet/mainnet-system-params-v21.json')
16
- const address = await lucid.wallet().address();
17
- const utxos = await lucid.wallet().getUtxos();
18
- const walletBalance = balance(utxos);
19
-
20
- console.log('Wallet Address', address);
21
- console.log('Wallet Balance', walletBalance);
22
-
23
- // const cdpOutRef: OutRef = {txHash: '70b09ded453b6122688d3cd51e2c75a007f2d801d1104eae734d8f5314b2b393', outputIndex: 0};
24
-
25
- const cdpTx = await CDPContract.openPosition('iUSD', 10_000_000n, 7_820_000n, systemParams, lucid);
26
- const cdpBTx = await cdpTx.complete();
27
- const cdpBsTx = await cdpBTx.sign.withWallet().complete();
28
-
29
- console.log(cdpBsTx.toCBOR());
30
- // const cdpTx = await CDPContract.openPosition(
31
- // 'iUSD',
32
- // 10_000_000n,
33
- // 1_000_000n,
34
- // systemParams,
35
- // lucid
36
- // );
37
- // const cdpBTx = await cdpTx.complete()
38
- // const cdpBsTx = await cdpBTx.sign.withWallet().complete()
39
-
40
- // console.log(cdpBsTx.toCBOR());
41
- }
42
-
43
- main();
package/jest.config.js DELETED
@@ -1,13 +0,0 @@
1
- module.exports = {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "node": "current"
8
- }
9
- }
10
- ],
11
- "@babel/preset-typescript",
12
- ]
13
- };