@indigo-labs/indigo-sdk 0.1.3 → 0.1.4

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 (85) hide show
  1. package/package.json +4 -1
  2. package/.github/workflows/ci.yml +0 -62
  3. package/.github/workflows/test.yml +0 -44
  4. package/.husky/pre-commit +0 -1
  5. package/.nvmrc +0 -1
  6. package/.prettierrc +0 -6
  7. package/eslint.config.mjs +0 -35
  8. package/src/contracts/cdp.ts +0 -741
  9. package/src/contracts/collector.ts +0 -98
  10. package/src/contracts/gov.ts +0 -1
  11. package/src/contracts/interest-oracle.ts +0 -149
  12. package/src/contracts/lrp.ts +0 -223
  13. package/src/contracts/one-shot.ts +0 -67
  14. package/src/contracts/stability-pool.ts +0 -684
  15. package/src/contracts/staking.ts +0 -348
  16. package/src/contracts/treasury.ts +0 -112
  17. package/src/helpers/asset-helpers.ts +0 -57
  18. package/src/helpers/helper-txs.ts +0 -30
  19. package/src/helpers/helpers.ts +0 -38
  20. package/src/helpers/indigo-helpers.ts +0 -19
  21. package/src/helpers/interest-oracle.ts +0 -57
  22. package/src/helpers/lucid-utils.ts +0 -70
  23. package/src/helpers/price-oracle-helpers.ts +0 -36
  24. package/src/helpers/stability-pool-helpers.ts +0 -207
  25. package/src/helpers/staking-helpers.ts +0 -94
  26. package/src/helpers/time-helpers.ts +0 -4
  27. package/src/helpers/value-helpers.ts +0 -16
  28. package/src/index.ts +0 -34
  29. package/src/scripts/always-fail-validator.ts +0 -7
  30. package/src/scripts/auth-token-policy.ts +0 -23
  31. package/src/scripts/cdp-creator-validator.ts +0 -53
  32. package/src/scripts/cdp-validator.ts +0 -9
  33. package/src/scripts/collector-validator.ts +0 -8
  34. package/src/scripts/execute-validator.ts +0 -52
  35. package/src/scripts/gov-validator.ts +0 -44
  36. package/src/scripts/iasset-policy.ts +0 -22
  37. package/src/scripts/interest-oracle-validator.ts +0 -23
  38. package/src/scripts/lrp-validator.ts +0 -23
  39. package/src/scripts/one-shot-policy.ts +0 -62
  40. package/src/scripts/poll-manager-validator.ts +0 -52
  41. package/src/scripts/poll-shard-validator.ts +0 -47
  42. package/src/scripts/price-oracle-validator.ts +0 -26
  43. package/src/scripts/stability-pool-validator.ts +0 -60
  44. package/src/scripts/staking-validator.ts +0 -8
  45. package/src/scripts/treasury-validator.ts +0 -8
  46. package/src/scripts/version-record-policy.ts +0 -26
  47. package/src/scripts/version-registry.ts +0 -15
  48. package/src/types/generic.ts +0 -106
  49. package/src/types/indigo/cdp-creator.ts +0 -46
  50. package/src/types/indigo/cdp.ts +0 -88
  51. package/src/types/indigo/execute.ts +0 -21
  52. package/src/types/indigo/gov.ts +0 -51
  53. package/src/types/indigo/interest-oracle.ts +0 -55
  54. package/src/types/indigo/lrp.ts +0 -54
  55. package/src/types/indigo/poll-manager.ts +0 -21
  56. package/src/types/indigo/poll-shard.ts +0 -16
  57. package/src/types/indigo/price-oracle.ts +0 -38
  58. package/src/types/indigo/stability-pool.ts +0 -233
  59. package/src/types/indigo/staking.ts +0 -99
  60. package/src/types/indigo/version-record.ts +0 -17
  61. package/src/types/on-chain-decimal.ts +0 -23
  62. package/src/types/one-shot.ts +0 -22
  63. package/src/types/system-params.ts +0 -246
  64. package/tests/data/system-params.json +0 -989
  65. package/tests/datums.test.ts +0 -286
  66. package/tests/endpoints/initialize.ts +0 -1013
  67. package/tests/hash-checks.test.ts +0 -73
  68. package/tests/indigo-test-helpers.ts +0 -115
  69. package/tests/initialize.test.ts +0 -27
  70. package/tests/interest-calculations.test.ts +0 -120
  71. package/tests/interest-oracle.test.ts +0 -90
  72. package/tests/lrp.test.ts +0 -149
  73. package/tests/queries/governance-queries.ts +0 -31
  74. package/tests/queries/iasset-queries.ts +0 -39
  75. package/tests/queries/interest-oracle-queries.ts +0 -13
  76. package/tests/queries/lrp-queries.ts +0 -39
  77. package/tests/queries/price-oracle-queries.ts +0 -27
  78. package/tests/queries/stability-pool-queries.ts +0 -75
  79. package/tests/queries/staking-queries.ts +0 -43
  80. package/tests/stability-pool.test.ts +0 -364
  81. package/tests/staking.test.ts +0 -105
  82. package/tests/test-helpers.ts +0 -38
  83. package/tsconfig.build.json +0 -4
  84. package/tsconfig.json +0 -16
  85. package/vitest.config.ts +0 -9
@@ -1,27 +0,0 @@
1
- import {
2
- LucidEvolution,
3
- Network,
4
- OutRef,
5
- ScriptHash,
6
- toUnit,
7
- } from '@lucid-evolution/lucid';
8
- import { createScriptAddress, matchSingle, OracleAssetNft } from '../../src';
9
-
10
- export async function findPriceOracle(
11
- lucid: LucidEvolution,
12
- network: Network,
13
- oracleScriptHash: ScriptHash,
14
- oracleNft: OracleAssetNft,
15
- ): Promise<OutRef> {
16
- return matchSingle(
17
- await lucid.utxosAtWithUnit(
18
- createScriptAddress(network, oracleScriptHash),
19
- toUnit(
20
- oracleNft.oracleNft.asset.currencySymbol,
21
- oracleNft.oracleNft.asset.tokenName,
22
- ),
23
- ),
24
- (res) =>
25
- new Error('Expected a single Oracle UTXO.: ' + JSON.stringify(res)),
26
- );
27
- }
@@ -1,75 +0,0 @@
1
- import {
2
- fromText,
3
- LucidEvolution,
4
- ScriptHash,
5
- UTxO,
6
- } from '@lucid-evolution/lucid';
7
- import { createScriptAddress } from '../../src/helpers/lucid-utils';
8
- import { AssetClass } from '../../src/types/generic';
9
- import { assetClassToUnit } from '../../src/helpers/value-helpers';
10
- import {
11
- matchSingle,
12
- parseAccountDatum,
13
- parseStabilityPoolDatum,
14
- } from '../../src';
15
-
16
- export async function findStabilityPool(
17
- lucid: LucidEvolution,
18
- stabilityPoolHash: ScriptHash,
19
- stabilityPoolToken: AssetClass,
20
- asset: string,
21
- ): Promise<UTxO> {
22
- const stakingUtxos = await lucid.utxosAtWithUnit(
23
- createScriptAddress(lucid.config().network, stabilityPoolHash),
24
- assetClassToUnit(stabilityPoolToken),
25
- );
26
-
27
- return matchSingle(
28
- stakingUtxos.filter((utxo) => {
29
- if (utxo.datum != null) {
30
- try {
31
- const stabilityPoolDatum = parseStabilityPoolDatum(utxo.datum);
32
-
33
- return stabilityPoolDatum.asset == fromText(asset);
34
- } catch (_) {
35
- // when incompatible datum
36
- return false;
37
- }
38
- }
39
- }),
40
- (res) =>
41
- new Error(
42
- 'Expected a single Stability Pool UTXO.: ' + JSON.stringify(res),
43
- ),
44
- );
45
- }
46
-
47
- export async function findStabilityPoolAccount(
48
- lucid: LucidEvolution,
49
- stabilityPoolHash: ScriptHash,
50
- owner: string,
51
- asset: string,
52
- ): Promise<UTxO> {
53
- const accountUtxos = await lucid.utxosAt(
54
- createScriptAddress(lucid.config().network, stabilityPoolHash),
55
- );
56
-
57
- return matchSingle(
58
- accountUtxos.filter((utxo) => {
59
- if (utxo.datum != null) {
60
- try {
61
- const accountDatum = parseAccountDatum(utxo.datum);
62
-
63
- return (
64
- accountDatum.asset == fromText(asset) && accountDatum.owner == owner
65
- );
66
- } catch (_) {
67
- // when incompatible datum
68
- return false;
69
- }
70
- }
71
- }),
72
- (res) =>
73
- new Error('Expected a single Account UTXO.: ' + JSON.stringify(res)),
74
- );
75
- }
@@ -1,43 +0,0 @@
1
- import {
2
- LucidEvolution,
3
- Network,
4
- OutRef,
5
- ScriptHash,
6
- } from '@lucid-evolution/lucid';
7
- import { createScriptAddress } from '../../src/helpers/lucid-utils';
8
- import { AssetClass } from '../../src/types/generic';
9
- import { assetClassToUnit } from '../../src/helpers/value-helpers';
10
- import { matchSingle } from '../../src';
11
- import { parseStakingPositionDatum } from '../../src/types/indigo/staking';
12
-
13
- export async function findStakingPosition(
14
- lucid: LucidEvolution,
15
- network: Network,
16
- stakingScriptHash: ScriptHash,
17
- stakingPositionNft: AssetClass,
18
- owner: string,
19
- ): Promise<OutRef> {
20
- const stakingUtxos = await lucid.utxosAtWithUnit(
21
- createScriptAddress(network, stakingScriptHash),
22
- assetClassToUnit(stakingPositionNft),
23
- );
24
-
25
- return matchSingle(
26
- stakingUtxos.filter((utxo) => {
27
- if (utxo.datum != null) {
28
- try {
29
- const stakingDatum = parseStakingPositionDatum(utxo.datum);
30
-
31
- return stakingDatum.owner == owner;
32
- } catch (_) {
33
- // when incompatible datum
34
- return false;
35
- }
36
- }
37
- }),
38
- (res) =>
39
- new Error(
40
- 'Expected a single Staking Position UTXO.: ' + JSON.stringify(res),
41
- ),
42
- );
43
- }
@@ -1,364 +0,0 @@
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
- });
@@ -1,105 +0,0 @@
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
- });
@@ -1,38 +0,0 @@
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
- }
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "exclude": ["spec/**/*.spec.ts", "vitest.config.ts"]
4
- }
package/tsconfig.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "outDir": "./dist",
4
- "sourceMap": true,
5
- "module": "nodenext",
6
- "target": "ESNext",
7
- "moduleResolution": "nodenext"
8
- },
9
- "ts-node": {
10
- "compilerOptions": {
11
- "module": "ES2022"
12
- }
13
- },
14
- "include": ["src/**/*.ts", "tests/**/*.ts", "vitest.config.ts"],
15
- "exclude": ["dist", "node_modules"]
16
- }
package/vitest.config.ts DELETED
@@ -1,9 +0,0 @@
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
- });