@indigo-labs/indigo-sdk 0.3.0 → 0.3.2
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.
- package/README.md +88 -15
- package/dist/index.d.mts +15 -5
- package/dist/index.d.ts +15 -5
- package/dist/index.js +40 -16
- package/dist/index.mjs +34 -13
- package/package.json +1 -1
- package/src/contracts/cdp/transactions.ts +10 -1
- package/src/contracts/stability-pool/transactions.ts +3 -3
- package/src/contracts/stability-pool/types-new.ts +11 -1
- package/src/index.ts +3 -0
- package/src/validators/cdp-creator-validator.ts +1 -1
- package/src/validators/cdp-redeem-validator.ts +1 -1
- package/src/validators/cdp-validator.ts +1 -1
- package/src/validators/stability-pool-validator.ts +1 -1
- package/src/validators/stableswap-validator.ts +1 -1
- package/tests/cdp/actions.ts +0 -1
- package/tests/cdp/cdp.test.ts +3 -3
- package/tests/interest-collection/interest-collection.test.ts +1 -1
- package/tests/stability-pool/actions.ts +16 -6
- package/tests/stability-pool.test.ts +803 -152
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
addrDetails,
|
|
10
10
|
annulRequest,
|
|
11
11
|
createProposal,
|
|
12
|
-
|
|
12
|
+
requestSpAccountCreation,
|
|
13
13
|
fromSystemParamsAsset,
|
|
14
14
|
MAX_E2S2S_ENTRIES_COUNT,
|
|
15
15
|
} from '../src';
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
runOpenCdpAndCreateSPAccount,
|
|
66
66
|
runProcessSpRequest,
|
|
67
67
|
} from './stability-pool/actions';
|
|
68
|
-
import { getValueChangeAtAddressAfterAction } from './utils';
|
|
68
|
+
import { getValueChangeAtAddressAfterAction, sendValueTo } from './utils';
|
|
69
69
|
import { calculateFeeFromRatio } from '../src/utils/indigo-helpers';
|
|
70
70
|
import {
|
|
71
71
|
refreshPriceOracle,
|
|
@@ -91,19 +91,20 @@ type MyContext = LucidContext<{
|
|
|
91
91
|
user1: EmulatorAccount;
|
|
92
92
|
user2: EmulatorAccount;
|
|
93
93
|
user3: EmulatorAccount;
|
|
94
|
+
user4: EmulatorAccount;
|
|
94
95
|
}>;
|
|
95
96
|
|
|
96
97
|
const collateralAssetA: AssetClass = {
|
|
97
98
|
currencySymbol: fromHex(
|
|
98
99
|
// random generated
|
|
99
|
-
'
|
|
100
|
+
'cc072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8daa',
|
|
100
101
|
),
|
|
101
102
|
tokenName: fromHex(fromText('A')),
|
|
102
103
|
};
|
|
103
104
|
const collateralAssetB: AssetClass = {
|
|
104
105
|
currencySymbol: fromHex(
|
|
105
106
|
// random generated
|
|
106
|
-
'
|
|
107
|
+
'cc072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8dab',
|
|
107
108
|
),
|
|
108
109
|
tokenName: fromHex(fromText('B')),
|
|
109
110
|
};
|
|
@@ -111,7 +112,7 @@ const collateralAssetB: AssetClass = {
|
|
|
111
112
|
const collateralAssetC: AssetClass = {
|
|
112
113
|
currencySymbol: fromHex(
|
|
113
114
|
// random generated
|
|
114
|
-
'
|
|
115
|
+
'aa072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8dac',
|
|
115
116
|
),
|
|
116
117
|
tokenName: fromHex(fromText('C')),
|
|
117
118
|
};
|
|
@@ -119,7 +120,7 @@ const collateralAssetC: AssetClass = {
|
|
|
119
120
|
const collateralAssetD: AssetClass = {
|
|
120
121
|
currencySymbol: fromHex(
|
|
121
122
|
// random generated
|
|
122
|
-
'
|
|
123
|
+
'cc072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8dad',
|
|
123
124
|
),
|
|
124
125
|
tokenName: fromHex(fromText('D')),
|
|
125
126
|
};
|
|
@@ -127,7 +128,7 @@ const collateralAssetD: AssetClass = {
|
|
|
127
128
|
const collateralAssetE: AssetClass = {
|
|
128
129
|
currencySymbol: fromHex(
|
|
129
130
|
// random generated
|
|
130
|
-
'
|
|
131
|
+
'aa072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8dae',
|
|
131
132
|
),
|
|
132
133
|
tokenName: fromHex(fromText('E')),
|
|
133
134
|
};
|
|
@@ -135,7 +136,7 @@ const collateralAssetE: AssetClass = {
|
|
|
135
136
|
const collateralAssetF: AssetClass = {
|
|
136
137
|
currencySymbol: fromHex(
|
|
137
138
|
// random generated
|
|
138
|
-
'
|
|
139
|
+
'cc072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8daf',
|
|
139
140
|
),
|
|
140
141
|
tokenName: fromHex(fromText('F')),
|
|
141
142
|
};
|
|
@@ -143,7 +144,7 @@ const collateralAssetF: AssetClass = {
|
|
|
143
144
|
const collateralAssetG: AssetClass = {
|
|
144
145
|
currencySymbol: fromHex(
|
|
145
146
|
// random generated
|
|
146
|
-
'
|
|
147
|
+
'aa072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8dba',
|
|
147
148
|
),
|
|
148
149
|
tokenName: fromHex(fromText('G')),
|
|
149
150
|
};
|
|
@@ -151,7 +152,7 @@ const collateralAssetG: AssetClass = {
|
|
|
151
152
|
const collateralAssetH: AssetClass = {
|
|
152
153
|
currencySymbol: fromHex(
|
|
153
154
|
// random generated
|
|
154
|
-
'
|
|
155
|
+
'aa072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8dbb',
|
|
155
156
|
),
|
|
156
157
|
tokenName: fromHex(fromText('H')),
|
|
157
158
|
};
|
|
@@ -159,11 +160,51 @@ const collateralAssetH: AssetClass = {
|
|
|
159
160
|
const collateralAssetI: AssetClass = {
|
|
160
161
|
currencySymbol: fromHex(
|
|
161
162
|
// random generated
|
|
162
|
-
'
|
|
163
|
+
'aa072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8dbc',
|
|
163
164
|
),
|
|
164
165
|
tokenName: fromHex(fromText('I')),
|
|
165
166
|
};
|
|
166
167
|
|
|
168
|
+
const collateralAssetJ: AssetClass = {
|
|
169
|
+
currencySymbol: fromHex(
|
|
170
|
+
// random generated
|
|
171
|
+
'aa072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8dbd',
|
|
172
|
+
),
|
|
173
|
+
tokenName: fromHex(fromText('J')),
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const collateralAssetK: AssetClass = {
|
|
177
|
+
currencySymbol: fromHex(
|
|
178
|
+
// random generated
|
|
179
|
+
'aa072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8dbe',
|
|
180
|
+
),
|
|
181
|
+
tokenName: fromHex(fromText('K')),
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const collateralAssetL: AssetClass = {
|
|
185
|
+
currencySymbol: fromHex(
|
|
186
|
+
// random generated
|
|
187
|
+
'aa072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8dbf',
|
|
188
|
+
),
|
|
189
|
+
tokenName: fromHex(fromText('L')),
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const collateralAssetM: AssetClass = {
|
|
193
|
+
currencySymbol: fromHex(
|
|
194
|
+
// random generated
|
|
195
|
+
'aa072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8dca',
|
|
196
|
+
),
|
|
197
|
+
tokenName: fromHex(fromText('M')),
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const collateralAssetN: AssetClass = {
|
|
201
|
+
currencySymbol: fromHex(
|
|
202
|
+
// random generated
|
|
203
|
+
'aa072059ae741791b7b9c23d9baea6a0b0d764dec617ce7e027a8dcb',
|
|
204
|
+
),
|
|
205
|
+
tokenName: fromHex(fromText('N')),
|
|
206
|
+
};
|
|
207
|
+
|
|
167
208
|
describe('Stability pool', () => {
|
|
168
209
|
beforeEach<MyContext>(async (context: MyContext) => {
|
|
169
210
|
context.users = {
|
|
@@ -197,8 +238,16 @@ describe('Stability pool', () => {
|
|
|
197
238
|
mkAssetsOf(collateralAssetG, 1_000_000_000_000n),
|
|
198
239
|
mkAssetsOf(collateralAssetH, 1_000_000_000_000n),
|
|
199
240
|
mkAssetsOf(collateralAssetI, 1_000_000_000_000n),
|
|
241
|
+
mkAssetsOf(collateralAssetJ, 1_000_000_000_000n),
|
|
242
|
+
mkAssetsOf(collateralAssetK, 1_000_000_000_000n),
|
|
243
|
+
mkAssetsOf(collateralAssetL, 1_000_000_000_000n),
|
|
244
|
+
mkAssetsOf(collateralAssetM, 1_000_000_000_000n),
|
|
245
|
+
mkAssetsOf(collateralAssetN, 1_000_000_000_000n),
|
|
200
246
|
),
|
|
201
247
|
),
|
|
248
|
+
user4: generateEmulatorAccount(
|
|
249
|
+
addAssets(mkLovelacesOf(100_000_000_000_000n)),
|
|
250
|
+
),
|
|
202
251
|
};
|
|
203
252
|
|
|
204
253
|
context.emulator = new Emulator(
|
|
@@ -232,7 +281,7 @@ describe('Stability pool', () => {
|
|
|
232
281
|
|
|
233
282
|
await benchmarkAndAwaitTx(
|
|
234
283
|
'Stability Pool - Create Account - Request',
|
|
235
|
-
await
|
|
284
|
+
await requestSpAccountCreation(
|
|
236
285
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
237
286
|
10n,
|
|
238
287
|
sysParams,
|
|
@@ -281,7 +330,7 @@ describe('Stability pool', () => {
|
|
|
281
330
|
|
|
282
331
|
await runAndAwaitTx(
|
|
283
332
|
context.lucid,
|
|
284
|
-
|
|
333
|
+
requestSpAccountCreation(
|
|
285
334
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
286
335
|
10n,
|
|
287
336
|
sysParams,
|
|
@@ -330,7 +379,7 @@ describe('Stability pool', () => {
|
|
|
330
379
|
|
|
331
380
|
await runAndAwaitTx(
|
|
332
381
|
context.lucid,
|
|
333
|
-
|
|
382
|
+
requestSpAccountCreation(
|
|
334
383
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
335
384
|
10n,
|
|
336
385
|
sysParams,
|
|
@@ -399,7 +448,7 @@ describe('Stability pool', () => {
|
|
|
399
448
|
|
|
400
449
|
await runAndAwaitTx(
|
|
401
450
|
context.lucid,
|
|
402
|
-
|
|
451
|
+
requestSpAccountCreation(
|
|
403
452
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
404
453
|
10n,
|
|
405
454
|
sysParams,
|
|
@@ -467,7 +516,7 @@ describe('Stability pool', () => {
|
|
|
467
516
|
|
|
468
517
|
await runAndAwaitTx(
|
|
469
518
|
context.lucid,
|
|
470
|
-
|
|
519
|
+
requestSpAccountCreation(
|
|
471
520
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
472
521
|
1_000n,
|
|
473
522
|
sysParams,
|
|
@@ -553,7 +602,7 @@ describe('Stability pool', () => {
|
|
|
553
602
|
|
|
554
603
|
await runAndAwaitTx(
|
|
555
604
|
context.lucid,
|
|
556
|
-
|
|
605
|
+
requestSpAccountCreation(
|
|
557
606
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
558
607
|
ACCOUNT_DEPOSIT,
|
|
559
608
|
sysParams,
|
|
@@ -574,12 +623,12 @@ describe('Stability pool', () => {
|
|
|
574
623
|
);
|
|
575
624
|
}
|
|
576
625
|
|
|
577
|
-
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
578
|
-
|
|
579
626
|
// After price doubles the collateral ratio will be 110%
|
|
580
627
|
const LIQUIDATED_DEBT = 5_000_000n;
|
|
581
628
|
const LIQUIDATED_COLLATERAL = 11_000_000n;
|
|
582
629
|
|
|
630
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
631
|
+
|
|
583
632
|
await executeLiquidation(
|
|
584
633
|
context,
|
|
585
634
|
sysParams,
|
|
@@ -678,7 +727,7 @@ describe('Stability pool', () => {
|
|
|
678
727
|
|
|
679
728
|
await runAndAwaitTx(
|
|
680
729
|
context.lucid,
|
|
681
|
-
|
|
730
|
+
requestSpAccountCreation(
|
|
682
731
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
683
732
|
ACCOUNT_DEPOSIT,
|
|
684
733
|
sysParams,
|
|
@@ -699,12 +748,30 @@ describe('Stability pool', () => {
|
|
|
699
748
|
);
|
|
700
749
|
}
|
|
701
750
|
|
|
702
|
-
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
703
|
-
|
|
704
751
|
// After price doubles the collateral ratio will be 110%
|
|
705
752
|
const LIQUIDATED_DEBT = 5_000_000n;
|
|
706
753
|
const LIQUIDATED_COLLATERAL = 11_000_000n;
|
|
707
754
|
|
|
755
|
+
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
756
|
+
|
|
757
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
758
|
+
await sendValueTo(
|
|
759
|
+
context.users.user4.address,
|
|
760
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
761
|
+
context.lucid,
|
|
762
|
+
);
|
|
763
|
+
|
|
764
|
+
context.emulator.awaitSlot(1000);
|
|
765
|
+
|
|
766
|
+
await refreshPriceOracle(
|
|
767
|
+
context,
|
|
768
|
+
sysParams,
|
|
769
|
+
iusdAssetInfo,
|
|
770
|
+
collateralAssetA,
|
|
771
|
+
);
|
|
772
|
+
|
|
773
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
774
|
+
|
|
708
775
|
await executeLiquidation(
|
|
709
776
|
context,
|
|
710
777
|
sysParams,
|
|
@@ -799,7 +866,7 @@ describe('Stability pool', () => {
|
|
|
799
866
|
|
|
800
867
|
await runAndAwaitTx(
|
|
801
868
|
context.lucid,
|
|
802
|
-
|
|
869
|
+
requestSpAccountCreation(
|
|
803
870
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
804
871
|
10_000n,
|
|
805
872
|
sysParams,
|
|
@@ -920,11 +987,12 @@ describe('Stability pool', () => {
|
|
|
920
987
|
);
|
|
921
988
|
}
|
|
922
989
|
|
|
923
|
-
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
924
|
-
|
|
925
990
|
// After price doubles the collateral ratio will be 110%
|
|
926
991
|
const LIQUIDATED_DEBT = 5_000_000n;
|
|
927
992
|
const LIQUIDATED_COLLATERAL = 11_000_000n;
|
|
993
|
+
|
|
994
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
995
|
+
|
|
928
996
|
await executeLiquidation(
|
|
929
997
|
context,
|
|
930
998
|
sysParams,
|
|
@@ -1053,12 +1121,30 @@ describe('Stability pool', () => {
|
|
|
1053
1121
|
);
|
|
1054
1122
|
}
|
|
1055
1123
|
|
|
1056
|
-
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
1057
|
-
|
|
1058
1124
|
// After price doubles the collateral ratio will be 110%
|
|
1059
1125
|
const LIQUIDATED_DEBT = 5_000_000n;
|
|
1060
1126
|
const LIQUIDATED_COLLATERAL = 11_000_000n;
|
|
1061
1127
|
|
|
1128
|
+
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
1129
|
+
|
|
1130
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
1131
|
+
await sendValueTo(
|
|
1132
|
+
context.users.user4.address,
|
|
1133
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
1134
|
+
context.lucid,
|
|
1135
|
+
);
|
|
1136
|
+
|
|
1137
|
+
context.emulator.awaitSlot(1000);
|
|
1138
|
+
|
|
1139
|
+
await refreshPriceOracle(
|
|
1140
|
+
context,
|
|
1141
|
+
sysParams,
|
|
1142
|
+
iusdAssetInfo,
|
|
1143
|
+
collateralAssetA,
|
|
1144
|
+
);
|
|
1145
|
+
|
|
1146
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
1147
|
+
|
|
1062
1148
|
await executeLiquidation(
|
|
1063
1149
|
context,
|
|
1064
1150
|
sysParams,
|
|
@@ -1174,7 +1260,7 @@ describe('Stability pool', () => {
|
|
|
1174
1260
|
|
|
1175
1261
|
await runAndAwaitTx(
|
|
1176
1262
|
context.lucid,
|
|
1177
|
-
|
|
1263
|
+
requestSpAccountCreation(
|
|
1178
1264
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
1179
1265
|
10n,
|
|
1180
1266
|
sysParams,
|
|
@@ -1268,7 +1354,7 @@ describe('Stability pool', () => {
|
|
|
1268
1354
|
|
|
1269
1355
|
await runAndAwaitTx(
|
|
1270
1356
|
context.lucid,
|
|
1271
|
-
|
|
1357
|
+
requestSpAccountCreation(
|
|
1272
1358
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
1273
1359
|
10n,
|
|
1274
1360
|
sysParams,
|
|
@@ -1523,11 +1609,12 @@ describe('Stability pool', () => {
|
|
|
1523
1609
|
);
|
|
1524
1610
|
}
|
|
1525
1611
|
|
|
1526
|
-
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
1527
|
-
|
|
1528
1612
|
// After price doubles the collateral ratio will be 110%
|
|
1529
1613
|
const LIQUIDATED_DEBT = 5_000_000n;
|
|
1530
1614
|
const LIQUIDATED_COLLATERAL = 11_000_000n;
|
|
1615
|
+
|
|
1616
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
1617
|
+
|
|
1531
1618
|
await executeLiquidation(
|
|
1532
1619
|
context,
|
|
1533
1620
|
sysParams,
|
|
@@ -1688,12 +1775,30 @@ describe('Stability pool', () => {
|
|
|
1688
1775
|
);
|
|
1689
1776
|
}
|
|
1690
1777
|
|
|
1691
|
-
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
1692
|
-
|
|
1693
1778
|
// After price doubles the collateral ratio will be 110%
|
|
1694
1779
|
const LIQUIDATED_DEBT = 5_000_000n;
|
|
1695
1780
|
const LIQUIDATED_COLLATERAL = 11_000_000n;
|
|
1696
1781
|
|
|
1782
|
+
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
1783
|
+
|
|
1784
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
1785
|
+
await sendValueTo(
|
|
1786
|
+
context.users.user4.address,
|
|
1787
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
1788
|
+
context.lucid,
|
|
1789
|
+
);
|
|
1790
|
+
|
|
1791
|
+
context.emulator.awaitSlot(1000);
|
|
1792
|
+
|
|
1793
|
+
await refreshPriceOracle(
|
|
1794
|
+
context,
|
|
1795
|
+
sysParams,
|
|
1796
|
+
iusdAssetInfo,
|
|
1797
|
+
collateralAssetA,
|
|
1798
|
+
);
|
|
1799
|
+
|
|
1800
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
1801
|
+
|
|
1697
1802
|
await executeLiquidation(
|
|
1698
1803
|
context,
|
|
1699
1804
|
sysParams,
|
|
@@ -1816,7 +1921,7 @@ describe('Stability pool', () => {
|
|
|
1816
1921
|
});
|
|
1817
1922
|
|
|
1818
1923
|
describe('Liquidate', () => {
|
|
1819
|
-
test<MyContext>('Liquidate adding
|
|
1924
|
+
test<MyContext>('Liquidate adding 9th reward asset', async (context: MyContext) => {
|
|
1820
1925
|
context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
|
|
1821
1926
|
|
|
1822
1927
|
const initialAssets = [
|
|
@@ -1828,9 +1933,10 @@ describe('Stability pool', () => {
|
|
|
1828
1933
|
collateralAssetE,
|
|
1829
1934
|
collateralAssetF,
|
|
1830
1935
|
collateralAssetG,
|
|
1936
|
+
collateralAssetH,
|
|
1831
1937
|
];
|
|
1832
1938
|
|
|
1833
|
-
expect(initialAssets.length, 'Unexpected reward assets count').toEqual(
|
|
1939
|
+
expect(initialAssets.length, 'Unexpected reward assets count').toEqual(9);
|
|
1834
1940
|
|
|
1835
1941
|
const [sysParams, [iusdAssetInfo]] = await init(
|
|
1836
1942
|
context.lucid,
|
|
@@ -1862,6 +1968,13 @@ describe('Stability pool', () => {
|
|
|
1862
1968
|
{
|
|
1863
1969
|
context.lucid.selectWallet.fromSeed(context.users.user2.seedPhrase);
|
|
1864
1970
|
|
|
1971
|
+
await refreshPriceOracle(
|
|
1972
|
+
context,
|
|
1973
|
+
sysParams,
|
|
1974
|
+
iusdAssetInfo,
|
|
1975
|
+
collateralAssetA,
|
|
1976
|
+
);
|
|
1977
|
+
|
|
1865
1978
|
await runAndAwaitTx(
|
|
1866
1979
|
context.lucid,
|
|
1867
1980
|
runOpenCdp(
|
|
@@ -1876,7 +1989,7 @@ describe('Stability pool', () => {
|
|
|
1876
1989
|
|
|
1877
1990
|
await runAndAwaitTx(
|
|
1878
1991
|
context.lucid,
|
|
1879
|
-
|
|
1992
|
+
requestSpAccountCreation(
|
|
1880
1993
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
1881
1994
|
BigInt(initialAssets.length + 1) * LIQUIDATED_DEBT,
|
|
1882
1995
|
sysParams,
|
|
@@ -1905,6 +2018,17 @@ describe('Stability pool', () => {
|
|
|
1905
2018
|
|
|
1906
2019
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
1907
2020
|
|
|
2021
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
2022
|
+
await sendValueTo(
|
|
2023
|
+
context.users.user4.address,
|
|
2024
|
+
mkAssetsOf(collateral, LIQUIDATED_COLLATERAL),
|
|
2025
|
+
context.lucid,
|
|
2026
|
+
);
|
|
2027
|
+
|
|
2028
|
+
context.emulator.awaitSlot(1000);
|
|
2029
|
+
|
|
2030
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
2031
|
+
|
|
1908
2032
|
await refreshPriceOracle(context, sysParams, iusdAssetInfo, collateral);
|
|
1909
2033
|
|
|
1910
2034
|
await executeLiquidation(
|
|
@@ -1938,6 +2062,20 @@ describe('Stability pool', () => {
|
|
|
1938
2062
|
}
|
|
1939
2063
|
|
|
1940
2064
|
const collateral = initialAssets[initialAssets.length - 1];
|
|
2065
|
+
|
|
2066
|
+
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
2067
|
+
|
|
2068
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
2069
|
+
await sendValueTo(
|
|
2070
|
+
context.users.user4.address,
|
|
2071
|
+
mkAssetsOf(collateral, LIQUIDATED_COLLATERAL),
|
|
2072
|
+
context.lucid,
|
|
2073
|
+
);
|
|
2074
|
+
|
|
2075
|
+
context.emulator.awaitSlot(1000);
|
|
2076
|
+
|
|
2077
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
2078
|
+
|
|
1941
2079
|
await refreshPriceOracle(context, sysParams, iusdAssetInfo, collateral);
|
|
1942
2080
|
|
|
1943
2081
|
await executeLiquidation(
|
|
@@ -1949,7 +2087,7 @@ describe('Stability pool', () => {
|
|
|
1949
2087
|
iusdAssetInfo,
|
|
1950
2088
|
(tx) =>
|
|
1951
2089
|
benchmarkAndAwaitTx(
|
|
1952
|
-
'Stability Pool - Liquidate adding
|
|
2090
|
+
'Stability Pool - Liquidate adding 9th reward asset',
|
|
1953
2091
|
tx,
|
|
1954
2092
|
context.lucid,
|
|
1955
2093
|
context.emulator,
|
|
@@ -1972,7 +2110,7 @@ describe('Stability pool', () => {
|
|
|
1972
2110
|
}
|
|
1973
2111
|
});
|
|
1974
2112
|
|
|
1975
|
-
test<MyContext>('Liquidate adding
|
|
2113
|
+
test<MyContext>('Liquidate adding 9th reward asset and increasing epoch', async (context: MyContext) => {
|
|
1976
2114
|
context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
|
|
1977
2115
|
|
|
1978
2116
|
const initialAssets = [
|
|
@@ -1984,9 +2122,10 @@ describe('Stability pool', () => {
|
|
|
1984
2122
|
collateralAssetE,
|
|
1985
2123
|
collateralAssetF,
|
|
1986
2124
|
collateralAssetG,
|
|
2125
|
+
collateralAssetH,
|
|
1987
2126
|
];
|
|
1988
2127
|
|
|
1989
|
-
expect(initialAssets.length, 'Unexpected reward assets count').toEqual(
|
|
2128
|
+
expect(initialAssets.length, 'Unexpected reward assets count').toEqual(9);
|
|
1990
2129
|
|
|
1991
2130
|
const [sysParams, [iusdAssetInfo]] = await init(
|
|
1992
2131
|
context.lucid,
|
|
@@ -2003,7 +2142,7 @@ describe('Stability pool', () => {
|
|
|
2003
2142
|
|
|
2004
2143
|
await createMultipleUtxosAtTreasury(
|
|
2005
2144
|
mkLovelacesOf(2n),
|
|
2006
|
-
|
|
2145
|
+
27n,
|
|
2007
2146
|
sysParams,
|
|
2008
2147
|
context,
|
|
2009
2148
|
);
|
|
@@ -2018,6 +2157,13 @@ describe('Stability pool', () => {
|
|
|
2018
2157
|
{
|
|
2019
2158
|
context.lucid.selectWallet.fromSeed(context.users.user2.seedPhrase);
|
|
2020
2159
|
|
|
2160
|
+
await refreshPriceOracle(
|
|
2161
|
+
context,
|
|
2162
|
+
sysParams,
|
|
2163
|
+
iusdAssetInfo,
|
|
2164
|
+
collateralAssetA,
|
|
2165
|
+
);
|
|
2166
|
+
|
|
2021
2167
|
await runAndAwaitTx(
|
|
2022
2168
|
context.lucid,
|
|
2023
2169
|
runOpenCdp(
|
|
@@ -2032,7 +2178,7 @@ describe('Stability pool', () => {
|
|
|
2032
2178
|
|
|
2033
2179
|
await runAndAwaitTx(
|
|
2034
2180
|
context.lucid,
|
|
2035
|
-
|
|
2181
|
+
requestSpAccountCreation(
|
|
2036
2182
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
2037
2183
|
BigInt(initialAssets.length) * LIQUIDATED_DEBT,
|
|
2038
2184
|
sysParams,
|
|
@@ -2061,6 +2207,15 @@ describe('Stability pool', () => {
|
|
|
2061
2207
|
|
|
2062
2208
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
2063
2209
|
|
|
2210
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
2211
|
+
await sendValueTo(
|
|
2212
|
+
context.users.user4.address,
|
|
2213
|
+
mkAssetsOf(collateral, LIQUIDATED_COLLATERAL),
|
|
2214
|
+
context.lucid,
|
|
2215
|
+
);
|
|
2216
|
+
|
|
2217
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
2218
|
+
|
|
2064
2219
|
await refreshPriceOracle(context, sysParams, iusdAssetInfo, collateral);
|
|
2065
2220
|
|
|
2066
2221
|
await executeLiquidation(
|
|
@@ -2095,6 +2250,17 @@ describe('Stability pool', () => {
|
|
|
2095
2250
|
|
|
2096
2251
|
const collateral = initialAssets[initialAssets.length - 1];
|
|
2097
2252
|
|
|
2253
|
+
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
2254
|
+
|
|
2255
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
2256
|
+
await sendValueTo(
|
|
2257
|
+
context.users.user4.address,
|
|
2258
|
+
mkAssetsOf(collateral, LIQUIDATED_COLLATERAL),
|
|
2259
|
+
context.lucid,
|
|
2260
|
+
);
|
|
2261
|
+
|
|
2262
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
2263
|
+
|
|
2098
2264
|
await refreshPriceOracle(context, sysParams, iusdAssetInfo, collateral);
|
|
2099
2265
|
|
|
2100
2266
|
await executeLiquidation(
|
|
@@ -2104,9 +2270,9 @@ describe('Stability pool', () => {
|
|
|
2104
2270
|
LIQUIDATED_COLLATERAL,
|
|
2105
2271
|
collateral,
|
|
2106
2272
|
iusdAssetInfo,
|
|
2107
|
-
(tx) =>
|
|
2273
|
+
async (tx) =>
|
|
2108
2274
|
benchmarkAndAwaitTx(
|
|
2109
|
-
'Stability Pool - Liquidate adding
|
|
2275
|
+
'Stability Pool - Liquidate adding 9th reward asset and increasing epoch',
|
|
2110
2276
|
tx,
|
|
2111
2277
|
context.lucid,
|
|
2112
2278
|
context.emulator,
|
|
@@ -2128,7 +2294,7 @@ describe('Stability pool', () => {
|
|
|
2128
2294
|
}
|
|
2129
2295
|
});
|
|
2130
2296
|
|
|
2131
|
-
test<MyContext>('Liquidate adding
|
|
2297
|
+
test<MyContext>('Liquidate adding 9th reward asset and increasing scale', async (context: MyContext) => {
|
|
2132
2298
|
context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
|
|
2133
2299
|
|
|
2134
2300
|
const initialAssets = [
|
|
@@ -2140,9 +2306,10 @@ describe('Stability pool', () => {
|
|
|
2140
2306
|
collateralAssetE,
|
|
2141
2307
|
collateralAssetF,
|
|
2142
2308
|
collateralAssetG,
|
|
2309
|
+
collateralAssetH,
|
|
2143
2310
|
];
|
|
2144
2311
|
|
|
2145
|
-
expect(initialAssets.length, 'Unexpected reward assets count').toEqual(
|
|
2312
|
+
expect(initialAssets.length, 'Unexpected reward assets count').toEqual(9);
|
|
2146
2313
|
|
|
2147
2314
|
const [sysParams, [iusdAssetInfo]] = await init(
|
|
2148
2315
|
context.lucid,
|
|
@@ -2174,6 +2341,13 @@ describe('Stability pool', () => {
|
|
|
2174
2341
|
{
|
|
2175
2342
|
context.lucid.selectWallet.fromSeed(context.users.user2.seedPhrase);
|
|
2176
2343
|
|
|
2344
|
+
await refreshPriceOracle(
|
|
2345
|
+
context,
|
|
2346
|
+
sysParams,
|
|
2347
|
+
iusdAssetInfo,
|
|
2348
|
+
collateralAssetA,
|
|
2349
|
+
);
|
|
2350
|
+
|
|
2177
2351
|
await runAndAwaitTx(
|
|
2178
2352
|
context.lucid,
|
|
2179
2353
|
runOpenCdp(
|
|
@@ -2188,7 +2362,7 @@ describe('Stability pool', () => {
|
|
|
2188
2362
|
|
|
2189
2363
|
await runAndAwaitTx(
|
|
2190
2364
|
context.lucid,
|
|
2191
|
-
|
|
2365
|
+
requestSpAccountCreation(
|
|
2192
2366
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
2193
2367
|
BigInt(initialAssets.length - 1) * LIQUIDATED_DEBT +
|
|
2194
2368
|
LIQUIDATED_DEBT +
|
|
@@ -2219,6 +2393,15 @@ describe('Stability pool', () => {
|
|
|
2219
2393
|
|
|
2220
2394
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
2221
2395
|
|
|
2396
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
2397
|
+
await sendValueTo(
|
|
2398
|
+
context.users.user4.address,
|
|
2399
|
+
mkAssetsOf(collateral, LIQUIDATED_COLLATERAL),
|
|
2400
|
+
context.lucid,
|
|
2401
|
+
);
|
|
2402
|
+
|
|
2403
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
2404
|
+
|
|
2222
2405
|
await refreshPriceOracle(context, sysParams, iusdAssetInfo, collateral);
|
|
2223
2406
|
|
|
2224
2407
|
await executeLiquidation(
|
|
@@ -2236,7 +2419,7 @@ describe('Stability pool', () => {
|
|
|
2236
2419
|
***********/
|
|
2237
2420
|
|
|
2238
2421
|
await repeat(1, async () => {
|
|
2239
|
-
context.lucid.selectWallet.fromSeed(context.users.
|
|
2422
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
2240
2423
|
|
|
2241
2424
|
await executeLiquidation(
|
|
2242
2425
|
context,
|
|
@@ -2292,9 +2475,18 @@ describe('Stability pool', () => {
|
|
|
2292
2475
|
).toEqual(initialAssets.length - 1);
|
|
2293
2476
|
}
|
|
2294
2477
|
|
|
2478
|
+
const collateral = initialAssets[initialAssets.length - 1];
|
|
2479
|
+
|
|
2295
2480
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
2296
2481
|
|
|
2297
|
-
|
|
2482
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
2483
|
+
await sendValueTo(
|
|
2484
|
+
context.users.user4.address,
|
|
2485
|
+
mkAssetsOf(collateral, LIQUIDATED_COLLATERAL),
|
|
2486
|
+
context.lucid,
|
|
2487
|
+
);
|
|
2488
|
+
|
|
2489
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
2298
2490
|
|
|
2299
2491
|
await refreshPriceOracle(context, sysParams, iusdAssetInfo, collateral);
|
|
2300
2492
|
|
|
@@ -2307,7 +2499,7 @@ describe('Stability pool', () => {
|
|
|
2307
2499
|
iusdAssetInfo,
|
|
2308
2500
|
(tx) =>
|
|
2309
2501
|
benchmarkAndAwaitTx(
|
|
2310
|
-
'Stability Pool - Liquidate adding
|
|
2502
|
+
'Stability Pool - Liquidate adding 9th reward asset and increasing scale',
|
|
2311
2503
|
tx,
|
|
2312
2504
|
context.lucid,
|
|
2313
2505
|
context.emulator,
|
|
@@ -2333,7 +2525,7 @@ describe('Stability pool', () => {
|
|
|
2333
2525
|
|
|
2334
2526
|
// We're skipping these tests, because they take really looong to execute... It must be some Lucid evolution issue.
|
|
2335
2527
|
describe.todo('Snapshot e2s2s', () => {
|
|
2336
|
-
test<MyContext>('Record snapshots for
|
|
2528
|
+
test<MyContext>('Record snapshots for 15 assets at once', async (context: MyContext) => {
|
|
2337
2529
|
context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
|
|
2338
2530
|
|
|
2339
2531
|
const initialAssets = [
|
|
@@ -2347,10 +2539,14 @@ describe('Stability pool', () => {
|
|
|
2347
2539
|
collateralAssetG,
|
|
2348
2540
|
collateralAssetH,
|
|
2349
2541
|
collateralAssetI,
|
|
2542
|
+
collateralAssetJ,
|
|
2543
|
+
collateralAssetK,
|
|
2544
|
+
collateralAssetL,
|
|
2545
|
+
collateralAssetM,
|
|
2350
2546
|
];
|
|
2351
2547
|
|
|
2352
2548
|
expect(initialAssets.length, 'Unexpected reward assets count').toEqual(
|
|
2353
|
-
|
|
2549
|
+
14,
|
|
2354
2550
|
);
|
|
2355
2551
|
|
|
2356
2552
|
const [sysParams, [iusdAssetInfo]] = await init(
|
|
@@ -2368,7 +2564,7 @@ describe('Stability pool', () => {
|
|
|
2368
2564
|
|
|
2369
2565
|
await createMultipleUtxosAtTreasury(
|
|
2370
2566
|
mkLovelacesOf(2n),
|
|
2371
|
-
|
|
2567
|
+
34n,
|
|
2372
2568
|
sysParams,
|
|
2373
2569
|
context,
|
|
2374
2570
|
);
|
|
@@ -2383,6 +2579,13 @@ describe('Stability pool', () => {
|
|
|
2383
2579
|
{
|
|
2384
2580
|
context.lucid.selectWallet.fromSeed(context.users.user2.seedPhrase);
|
|
2385
2581
|
|
|
2582
|
+
await refreshPriceOracle(
|
|
2583
|
+
context,
|
|
2584
|
+
sysParams,
|
|
2585
|
+
iusdAssetInfo,
|
|
2586
|
+
collateralAssetA,
|
|
2587
|
+
);
|
|
2588
|
+
|
|
2386
2589
|
await runAndAwaitTx(
|
|
2387
2590
|
context.lucid,
|
|
2388
2591
|
runOpenCdp(
|
|
@@ -2397,7 +2600,7 @@ describe('Stability pool', () => {
|
|
|
2397
2600
|
|
|
2398
2601
|
await runAndAwaitTx(
|
|
2399
2602
|
context.lucid,
|
|
2400
|
-
|
|
2603
|
+
requestSpAccountCreation(
|
|
2401
2604
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
2402
2605
|
BigInt(initialAssets.length) * LIQUIDATED_DEBT + LIQUIDATED_DEBT,
|
|
2403
2606
|
sysParams,
|
|
@@ -2424,6 +2627,15 @@ describe('Stability pool', () => {
|
|
|
2424
2627
|
for (const collateral of initialAssets) {
|
|
2425
2628
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
2426
2629
|
|
|
2630
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
2631
|
+
await sendValueTo(
|
|
2632
|
+
context.users.user4.address,
|
|
2633
|
+
mkAssetsOf(collateral, LIQUIDATED_COLLATERAL),
|
|
2634
|
+
context.lucid,
|
|
2635
|
+
);
|
|
2636
|
+
|
|
2637
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
2638
|
+
|
|
2427
2639
|
await refreshPriceOracle(context, sysParams, iusdAssetInfo, collateral);
|
|
2428
2640
|
await executeLiquidation(
|
|
2429
2641
|
context,
|
|
@@ -2440,7 +2652,7 @@ describe('Stability pool', () => {
|
|
|
2440
2652
|
***********/
|
|
2441
2653
|
|
|
2442
2654
|
await repeat(4, async () => {
|
|
2443
|
-
context.lucid.selectWallet.fromSeed(context.users.
|
|
2655
|
+
context.lucid.selectWallet.fromSeed(context.users.user1.seedPhrase);
|
|
2444
2656
|
|
|
2445
2657
|
await executeLiquidation(
|
|
2446
2658
|
context,
|
|
@@ -2499,7 +2711,7 @@ describe('Stability pool', () => {
|
|
|
2499
2711
|
}
|
|
2500
2712
|
|
|
2501
2713
|
await benchmarkAndAwaitTx(
|
|
2502
|
-
'Stability Pool - Record snapshots for
|
|
2714
|
+
'Stability Pool - Record snapshots for 15 assets at once',
|
|
2503
2715
|
await runCreateE2s2sSnapshots(
|
|
2504
2716
|
context,
|
|
2505
2717
|
sysParams,
|
|
@@ -2530,19 +2742,30 @@ describe('Stability pool', () => {
|
|
|
2530
2742
|
|
|
2531
2743
|
// We're skipping these tests, because they take really looong to execute... It must be some Lucid evolution issue.
|
|
2532
2744
|
describe.todo('Complex cases', () => {
|
|
2533
|
-
test<MyContext>('Deposit Account multiple rewards (
|
|
2745
|
+
test<MyContext>('Deposit Account multiple rewards (9 assets)', async (context: MyContext) => {
|
|
2534
2746
|
context.lucid.selectWallet.fromSeed(context.users.admin.seedPhrase);
|
|
2747
|
+
const initialAssets = [
|
|
2748
|
+
adaAssetClass,
|
|
2749
|
+
collateralAssetA,
|
|
2750
|
+
collateralAssetB,
|
|
2751
|
+
collateralAssetC,
|
|
2752
|
+
collateralAssetD,
|
|
2753
|
+
collateralAssetE,
|
|
2754
|
+
collateralAssetF,
|
|
2755
|
+
collateralAssetG,
|
|
2756
|
+
collateralAssetH,
|
|
2757
|
+
];
|
|
2758
|
+
|
|
2759
|
+
expect(initialAssets.length, 'Unexpected reward assets count').toEqual(9);
|
|
2760
|
+
|
|
2535
2761
|
const [sysParams, [iusdAssetInfo]] = await init(
|
|
2536
2762
|
context.lucid,
|
|
2537
2763
|
[
|
|
2538
2764
|
{
|
|
2539
2765
|
...iusdInitialAssetCfg(),
|
|
2540
|
-
collateralAssets: mkCollateralAssetsChain(
|
|
2541
|
-
mkBaseCollateralAsset(
|
|
2542
|
-
|
|
2543
|
-
mkBaseCollateralAsset(collateralAssetC, 0n),
|
|
2544
|
-
mkBaseCollateralAsset(adaAssetClass, 0n),
|
|
2545
|
-
]),
|
|
2766
|
+
collateralAssets: mkCollateralAssetsChain(
|
|
2767
|
+
initialAssets.map((a) => mkBaseCollateralAsset(a, 0n)),
|
|
2768
|
+
),
|
|
2546
2769
|
},
|
|
2547
2770
|
],
|
|
2548
2771
|
context.emulator.slot,
|
|
@@ -2550,12 +2773,16 @@ describe('Stability pool', () => {
|
|
|
2550
2773
|
|
|
2551
2774
|
await createMultipleUtxosAtTreasury(
|
|
2552
2775
|
mkLovelacesOf(2n),
|
|
2553
|
-
|
|
2776
|
+
14n,
|
|
2554
2777
|
sysParams,
|
|
2555
2778
|
context,
|
|
2556
2779
|
);
|
|
2557
2780
|
|
|
2558
|
-
|
|
2781
|
+
// After price doubles the collateral ratio will be 110%
|
|
2782
|
+
const LIQUIDATED_DEBT = 5_000_000n;
|
|
2783
|
+
const LIQUIDATED_COLLATERAL = 11_000_000n;
|
|
2784
|
+
const ACCOUNT_DEPOSIT = LIQUIDATED_DEBT * BigInt(initialAssets.length);
|
|
2785
|
+
|
|
2559
2786
|
for (const u of [context.users.user1, context.users.user2]) {
|
|
2560
2787
|
context.lucid.selectWallet.fromSeed(u.seedPhrase);
|
|
2561
2788
|
|
|
@@ -2566,14 +2793,14 @@ describe('Stability pool', () => {
|
|
|
2566
2793
|
sysParams,
|
|
2567
2794
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
2568
2795
|
collateralAssetA,
|
|
2569
|
-
|
|
2570
|
-
|
|
2796
|
+
ACCOUNT_DEPOSIT * 3n,
|
|
2797
|
+
ACCOUNT_DEPOSIT + LIQUIDATED_DEBT,
|
|
2571
2798
|
),
|
|
2572
2799
|
);
|
|
2573
2800
|
|
|
2574
2801
|
await runAndAwaitTx(
|
|
2575
2802
|
context.lucid,
|
|
2576
|
-
|
|
2803
|
+
requestSpAccountCreation(
|
|
2577
2804
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
2578
2805
|
ACCOUNT_DEPOSIT,
|
|
2579
2806
|
sysParams,
|
|
@@ -2594,43 +2821,33 @@ describe('Stability pool', () => {
|
|
|
2594
2821
|
);
|
|
2595
2822
|
}
|
|
2596
2823
|
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
const LIQUIDATED_DEBT = 5_000_000n;
|
|
2600
|
-
const LIQUIDATED_COLLATERAL = 11_000_000n;
|
|
2824
|
+
for (let idx = 0; idx < initialAssets.length; idx++) {
|
|
2825
|
+
const collateral = initialAssets[idx];
|
|
2601
2826
|
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
context
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
await executeLiquidation(
|
|
2627
|
-
context,
|
|
2628
|
-
sysParams,
|
|
2629
|
-
LIQUIDATED_DEBT,
|
|
2630
|
-
LIQUIDATED_COLLATERAL,
|
|
2631
|
-
adaAssetClass,
|
|
2632
|
-
iusdAssetInfo,
|
|
2633
|
-
);
|
|
2827
|
+
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
2828
|
+
|
|
2829
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
2830
|
+
await sendValueTo(
|
|
2831
|
+
context.users.user4.address,
|
|
2832
|
+
mkAssetsOf(collateral, LIQUIDATED_COLLATERAL),
|
|
2833
|
+
context.lucid,
|
|
2834
|
+
);
|
|
2835
|
+
|
|
2836
|
+
context.emulator.awaitSlot(1000);
|
|
2837
|
+
|
|
2838
|
+
await refreshPriceOracle(context, sysParams, iusdAssetInfo, collateral);
|
|
2839
|
+
|
|
2840
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
2841
|
+
|
|
2842
|
+
await executeLiquidation(
|
|
2843
|
+
context,
|
|
2844
|
+
sysParams,
|
|
2845
|
+
LIQUIDATED_DEBT,
|
|
2846
|
+
LIQUIDATED_COLLATERAL,
|
|
2847
|
+
collateral,
|
|
2848
|
+
iusdAssetInfo,
|
|
2849
|
+
);
|
|
2850
|
+
}
|
|
2634
2851
|
|
|
2635
2852
|
context.lucid.selectWallet.fromSeed(context.users.user1.seedPhrase);
|
|
2636
2853
|
|
|
@@ -2651,7 +2868,7 @@ describe('Stability pool', () => {
|
|
|
2651
2868
|
context.users.user1.address,
|
|
2652
2869
|
async () =>
|
|
2653
2870
|
benchmarkAndAwaitTx(
|
|
2654
|
-
'Stability Pool - Deposit Account multiple rewards (
|
|
2871
|
+
'Stability Pool - Deposit Account multiple rewards (9 assets) - Process',
|
|
2655
2872
|
await runProcessSpRequest(
|
|
2656
2873
|
context,
|
|
2657
2874
|
sysParams,
|
|
@@ -2676,12 +2893,18 @@ describe('Stability pool', () => {
|
|
|
2676
2893
|
iasset.datum.liquidationProcessingFeeRatio,
|
|
2677
2894
|
LIQUIDATED_COLLATERAL,
|
|
2678
2895
|
)) /
|
|
2679
|
-
|
|
2896
|
+
2n -
|
|
2897
|
+
1n; // The -1n is to compensate for rounding errors.
|
|
2680
2898
|
|
|
2681
2899
|
const expectedReceived = addAssets(
|
|
2682
2900
|
mkAssetsOf(collateralAssetA, expectedRewardPerAsset),
|
|
2683
2901
|
mkAssetsOf(collateralAssetB, expectedRewardPerAsset),
|
|
2684
2902
|
mkAssetsOf(collateralAssetC, expectedRewardPerAsset),
|
|
2903
|
+
mkAssetsOf(collateralAssetD, expectedRewardPerAsset),
|
|
2904
|
+
mkAssetsOf(collateralAssetE, expectedRewardPerAsset),
|
|
2905
|
+
mkAssetsOf(collateralAssetF, expectedRewardPerAsset),
|
|
2906
|
+
mkAssetsOf(collateralAssetG, expectedRewardPerAsset),
|
|
2907
|
+
mkAssetsOf(collateralAssetH, expectedRewardPerAsset),
|
|
2685
2908
|
mkAssetsOf(
|
|
2686
2909
|
adaAssetClass,
|
|
2687
2910
|
expectedRewardPerAsset +
|
|
@@ -2741,7 +2964,7 @@ describe('Stability pool', () => {
|
|
|
2741
2964
|
|
|
2742
2965
|
await runAndAwaitTx(
|
|
2743
2966
|
context.lucid,
|
|
2744
|
-
|
|
2967
|
+
requestSpAccountCreation(
|
|
2745
2968
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
2746
2969
|
SINGLE_ACCOUNT_DEPOSIT,
|
|
2747
2970
|
sysParams,
|
|
@@ -2776,6 +2999,24 @@ describe('Stability pool', () => {
|
|
|
2776
2999
|
collateralAssetB,
|
|
2777
3000
|
);
|
|
2778
3001
|
|
|
3002
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
3003
|
+
await sendValueTo(
|
|
3004
|
+
context.users.user4.address,
|
|
3005
|
+
mkAssetsOf(collateralAssetB, LIQUIDATED_COLLATERAL),
|
|
3006
|
+
context.lucid,
|
|
3007
|
+
);
|
|
3008
|
+
|
|
3009
|
+
context.emulator.awaitSlot(1000);
|
|
3010
|
+
|
|
3011
|
+
await refreshPriceOracle(
|
|
3012
|
+
context,
|
|
3013
|
+
sysParams,
|
|
3014
|
+
iusdAssetInfo,
|
|
3015
|
+
collateralAssetB,
|
|
3016
|
+
);
|
|
3017
|
+
|
|
3018
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
3019
|
+
|
|
2779
3020
|
// Make an additional liquidation with collateral Asset B
|
|
2780
3021
|
await executeLiquidation(
|
|
2781
3022
|
context,
|
|
@@ -2786,6 +3027,23 @@ describe('Stability pool', () => {
|
|
|
2786
3027
|
iusdAssetInfo,
|
|
2787
3028
|
);
|
|
2788
3029
|
} else {
|
|
3030
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
3031
|
+
await sendValueTo(
|
|
3032
|
+
context.users.user4.address,
|
|
3033
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
3034
|
+
context.lucid,
|
|
3035
|
+
);
|
|
3036
|
+
|
|
3037
|
+
context.emulator.awaitSlot(1000);
|
|
3038
|
+
|
|
3039
|
+
await refreshPriceOracle(
|
|
3040
|
+
context,
|
|
3041
|
+
sysParams,
|
|
3042
|
+
iusdAssetInfo,
|
|
3043
|
+
collateralAssetA,
|
|
3044
|
+
);
|
|
3045
|
+
|
|
3046
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
2789
3047
|
await executeLiquidation(
|
|
2790
3048
|
context,
|
|
2791
3049
|
sysParams,
|
|
@@ -2956,7 +3214,7 @@ describe('Stability pool', () => {
|
|
|
2956
3214
|
|
|
2957
3215
|
await runAndAwaitTx(
|
|
2958
3216
|
context.lucid,
|
|
2959
|
-
|
|
3217
|
+
requestSpAccountCreation(
|
|
2960
3218
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
2961
3219
|
5_000_010n,
|
|
2962
3220
|
sysParams,
|
|
@@ -2988,6 +3246,24 @@ describe('Stability pool', () => {
|
|
|
2988
3246
|
await repeat(6, async (isLast) => {
|
|
2989
3247
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
2990
3248
|
|
|
3249
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
3250
|
+
await sendValueTo(
|
|
3251
|
+
context.users.user4.address,
|
|
3252
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
3253
|
+
context.lucid,
|
|
3254
|
+
);
|
|
3255
|
+
|
|
3256
|
+
context.emulator.awaitSlot(1000);
|
|
3257
|
+
|
|
3258
|
+
await refreshPriceOracle(
|
|
3259
|
+
context,
|
|
3260
|
+
sysParams,
|
|
3261
|
+
iusdAssetInfo,
|
|
3262
|
+
collateralAssetA,
|
|
3263
|
+
);
|
|
3264
|
+
|
|
3265
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
3266
|
+
|
|
2991
3267
|
await executeLiquidation(
|
|
2992
3268
|
context,
|
|
2993
3269
|
sysParams,
|
|
@@ -3044,7 +3320,7 @@ describe('Stability pool', () => {
|
|
|
3044
3320
|
|
|
3045
3321
|
await runAndAwaitTx(
|
|
3046
3322
|
context.lucid,
|
|
3047
|
-
|
|
3323
|
+
requestSpAccountCreation(
|
|
3048
3324
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
3049
3325
|
LIQUIDATED_DEBT,
|
|
3050
3326
|
sysParams,
|
|
@@ -3071,6 +3347,24 @@ describe('Stability pool', () => {
|
|
|
3071
3347
|
await repeat(2, async () => {
|
|
3072
3348
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
3073
3349
|
|
|
3350
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
3351
|
+
await sendValueTo(
|
|
3352
|
+
context.users.user4.address,
|
|
3353
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
3354
|
+
context.lucid,
|
|
3355
|
+
);
|
|
3356
|
+
|
|
3357
|
+
context.emulator.awaitSlot(1000);
|
|
3358
|
+
|
|
3359
|
+
await refreshPriceOracle(
|
|
3360
|
+
context,
|
|
3361
|
+
sysParams,
|
|
3362
|
+
iusdAssetInfo,
|
|
3363
|
+
collateralAssetA,
|
|
3364
|
+
);
|
|
3365
|
+
|
|
3366
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
3367
|
+
|
|
3074
3368
|
await executeLiquidation(
|
|
3075
3369
|
context,
|
|
3076
3370
|
sysParams,
|
|
@@ -3269,6 +3563,24 @@ describe('Stability pool', () => {
|
|
|
3269
3563
|
|
|
3270
3564
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
3271
3565
|
|
|
3566
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
3567
|
+
await sendValueTo(
|
|
3568
|
+
context.users.user4.address,
|
|
3569
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
3570
|
+
context.lucid,
|
|
3571
|
+
);
|
|
3572
|
+
|
|
3573
|
+
context.emulator.awaitSlot(1000);
|
|
3574
|
+
|
|
3575
|
+
await refreshPriceOracle(
|
|
3576
|
+
context,
|
|
3577
|
+
sysParams,
|
|
3578
|
+
iusdAssetInfo,
|
|
3579
|
+
collateralAssetA,
|
|
3580
|
+
);
|
|
3581
|
+
|
|
3582
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
3583
|
+
|
|
3272
3584
|
await executeLiquidation(
|
|
3273
3585
|
context,
|
|
3274
3586
|
sysParams,
|
|
@@ -3436,7 +3748,7 @@ describe('Stability pool', () => {
|
|
|
3436
3748
|
|
|
3437
3749
|
await runAndAwaitTx(
|
|
3438
3750
|
context.lucid,
|
|
3439
|
-
|
|
3751
|
+
requestSpAccountCreation(
|
|
3440
3752
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
3441
3753
|
5_000_010n,
|
|
3442
3754
|
sysParams,
|
|
@@ -3468,6 +3780,24 @@ describe('Stability pool', () => {
|
|
|
3468
3780
|
await repeat(6, async (isLast) => {
|
|
3469
3781
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
3470
3782
|
|
|
3783
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
3784
|
+
await sendValueTo(
|
|
3785
|
+
context.users.user4.address,
|
|
3786
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
3787
|
+
context.lucid,
|
|
3788
|
+
);
|
|
3789
|
+
|
|
3790
|
+
context.emulator.awaitSlot(1000);
|
|
3791
|
+
|
|
3792
|
+
await refreshPriceOracle(
|
|
3793
|
+
context,
|
|
3794
|
+
sysParams,
|
|
3795
|
+
iusdAssetInfo,
|
|
3796
|
+
collateralAssetA,
|
|
3797
|
+
);
|
|
3798
|
+
|
|
3799
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
3800
|
+
|
|
3471
3801
|
await executeLiquidation(
|
|
3472
3802
|
context,
|
|
3473
3803
|
sysParams,
|
|
@@ -3524,7 +3854,7 @@ describe('Stability pool', () => {
|
|
|
3524
3854
|
|
|
3525
3855
|
await runAndAwaitTx(
|
|
3526
3856
|
context.lucid,
|
|
3527
|
-
|
|
3857
|
+
requestSpAccountCreation(
|
|
3528
3858
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
3529
3859
|
LIQUIDATED_DEBT,
|
|
3530
3860
|
sysParams,
|
|
@@ -3551,6 +3881,24 @@ describe('Stability pool', () => {
|
|
|
3551
3881
|
await repeat(2, async (isLast) => {
|
|
3552
3882
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
3553
3883
|
|
|
3884
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
3885
|
+
await sendValueTo(
|
|
3886
|
+
context.users.user4.address,
|
|
3887
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
3888
|
+
context.lucid,
|
|
3889
|
+
);
|
|
3890
|
+
|
|
3891
|
+
context.emulator.awaitSlot(1000);
|
|
3892
|
+
|
|
3893
|
+
await refreshPriceOracle(
|
|
3894
|
+
context,
|
|
3895
|
+
sysParams,
|
|
3896
|
+
iusdAssetInfo,
|
|
3897
|
+
collateralAssetA,
|
|
3898
|
+
);
|
|
3899
|
+
|
|
3900
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
3901
|
+
|
|
3554
3902
|
await executeLiquidation(
|
|
3555
3903
|
context,
|
|
3556
3904
|
sysParams,
|
|
@@ -3662,6 +4010,24 @@ describe('Stability pool', () => {
|
|
|
3662
4010
|
|
|
3663
4011
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
3664
4012
|
|
|
4013
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
4014
|
+
await sendValueTo(
|
|
4015
|
+
context.users.user4.address,
|
|
4016
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
4017
|
+
context.lucid,
|
|
4018
|
+
);
|
|
4019
|
+
|
|
4020
|
+
context.emulator.awaitSlot(1000);
|
|
4021
|
+
|
|
4022
|
+
await refreshPriceOracle(
|
|
4023
|
+
context,
|
|
4024
|
+
sysParams,
|
|
4025
|
+
iusdAssetInfo,
|
|
4026
|
+
collateralAssetA,
|
|
4027
|
+
);
|
|
4028
|
+
|
|
4029
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
4030
|
+
|
|
3665
4031
|
await executeLiquidation(
|
|
3666
4032
|
context,
|
|
3667
4033
|
sysParams,
|
|
@@ -3758,6 +4124,24 @@ describe('Stability pool', () => {
|
|
|
3758
4124
|
|
|
3759
4125
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
3760
4126
|
|
|
4127
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
4128
|
+
await sendValueTo(
|
|
4129
|
+
context.users.user4.address,
|
|
4130
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
4131
|
+
context.lucid,
|
|
4132
|
+
);
|
|
4133
|
+
|
|
4134
|
+
context.emulator.awaitSlot(1000);
|
|
4135
|
+
|
|
4136
|
+
await refreshPriceOracle(
|
|
4137
|
+
context,
|
|
4138
|
+
sysParams,
|
|
4139
|
+
iusdAssetInfo,
|
|
4140
|
+
collateralAssetA,
|
|
4141
|
+
);
|
|
4142
|
+
|
|
4143
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
4144
|
+
|
|
3761
4145
|
await executeLiquidation(
|
|
3762
4146
|
context,
|
|
3763
4147
|
sysParams,
|
|
@@ -3947,7 +4331,7 @@ describe('Stability pool', () => {
|
|
|
3947
4331
|
|
|
3948
4332
|
await runAndAwaitTx(
|
|
3949
4333
|
context.lucid,
|
|
3950
|
-
|
|
4334
|
+
requestSpAccountCreation(
|
|
3951
4335
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
3952
4336
|
BigInt(initialAssets.length) * LIQUIDATED_DEBT +
|
|
3953
4337
|
LIQUIDATED_DEBT +
|
|
@@ -3976,7 +4360,19 @@ describe('Stability pool', () => {
|
|
|
3976
4360
|
for (const collateral of initialAssets) {
|
|
3977
4361
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
3978
4362
|
|
|
4363
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
4364
|
+
await sendValueTo(
|
|
4365
|
+
context.users.user4.address,
|
|
4366
|
+
mkAssetsOf(collateral, LIQUIDATED_COLLATERAL),
|
|
4367
|
+
context.lucid,
|
|
4368
|
+
);
|
|
4369
|
+
|
|
4370
|
+
context.emulator.awaitSlot(1000);
|
|
4371
|
+
|
|
3979
4372
|
await refreshPriceOracle(context, sysParams, iusdAssetInfo, collateral);
|
|
4373
|
+
|
|
4374
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
4375
|
+
|
|
3980
4376
|
await executeLiquidation(
|
|
3981
4377
|
context,
|
|
3982
4378
|
sysParams,
|
|
@@ -3994,6 +4390,24 @@ describe('Stability pool', () => {
|
|
|
3994
4390
|
await repeat(6, async (isLast) => {
|
|
3995
4391
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
3996
4392
|
|
|
4393
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
4394
|
+
await sendValueTo(
|
|
4395
|
+
context.users.user4.address,
|
|
4396
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
4397
|
+
context.lucid,
|
|
4398
|
+
);
|
|
4399
|
+
|
|
4400
|
+
context.emulator.awaitSlot(1000);
|
|
4401
|
+
|
|
4402
|
+
await refreshPriceOracle(
|
|
4403
|
+
context,
|
|
4404
|
+
sysParams,
|
|
4405
|
+
iusdAssetInfo,
|
|
4406
|
+
collateralAssetA,
|
|
4407
|
+
);
|
|
4408
|
+
|
|
4409
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
4410
|
+
|
|
3997
4411
|
await executeLiquidation(
|
|
3998
4412
|
context,
|
|
3999
4413
|
sysParams,
|
|
@@ -4050,7 +4464,7 @@ describe('Stability pool', () => {
|
|
|
4050
4464
|
|
|
4051
4465
|
await runAndAwaitTx(
|
|
4052
4466
|
context.lucid,
|
|
4053
|
-
|
|
4467
|
+
requestSpAccountCreation(
|
|
4054
4468
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
4055
4469
|
LIQUIDATED_DEBT,
|
|
4056
4470
|
sysParams,
|
|
@@ -4077,6 +4491,24 @@ describe('Stability pool', () => {
|
|
|
4077
4491
|
await repeat(2, async (isLast) => {
|
|
4078
4492
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
4079
4493
|
|
|
4494
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
4495
|
+
await sendValueTo(
|
|
4496
|
+
context.users.user4.address,
|
|
4497
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
4498
|
+
context.lucid,
|
|
4499
|
+
);
|
|
4500
|
+
|
|
4501
|
+
context.emulator.awaitSlot(1000);
|
|
4502
|
+
|
|
4503
|
+
await refreshPriceOracle(
|
|
4504
|
+
context,
|
|
4505
|
+
sysParams,
|
|
4506
|
+
iusdAssetInfo,
|
|
4507
|
+
collateralAssetA,
|
|
4508
|
+
);
|
|
4509
|
+
|
|
4510
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
4511
|
+
|
|
4080
4512
|
await executeLiquidation(
|
|
4081
4513
|
context,
|
|
4082
4514
|
sysParams,
|
|
@@ -4195,6 +4627,24 @@ describe('Stability pool', () => {
|
|
|
4195
4627
|
|
|
4196
4628
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
4197
4629
|
|
|
4630
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
4631
|
+
await sendValueTo(
|
|
4632
|
+
context.users.user4.address,
|
|
4633
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
4634
|
+
context.lucid,
|
|
4635
|
+
);
|
|
4636
|
+
|
|
4637
|
+
context.emulator.awaitSlot(1000);
|
|
4638
|
+
|
|
4639
|
+
await refreshPriceOracle(
|
|
4640
|
+
context,
|
|
4641
|
+
sysParams,
|
|
4642
|
+
iusdAssetInfo,
|
|
4643
|
+
collateralAssetA,
|
|
4644
|
+
);
|
|
4645
|
+
|
|
4646
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
4647
|
+
|
|
4198
4648
|
await executeLiquidation(
|
|
4199
4649
|
context,
|
|
4200
4650
|
sysParams,
|
|
@@ -4291,6 +4741,24 @@ describe('Stability pool', () => {
|
|
|
4291
4741
|
|
|
4292
4742
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
4293
4743
|
|
|
4744
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
4745
|
+
await sendValueTo(
|
|
4746
|
+
context.users.user4.address,
|
|
4747
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
4748
|
+
context.lucid,
|
|
4749
|
+
);
|
|
4750
|
+
|
|
4751
|
+
context.emulator.awaitSlot(1000);
|
|
4752
|
+
|
|
4753
|
+
await refreshPriceOracle(
|
|
4754
|
+
context,
|
|
4755
|
+
sysParams,
|
|
4756
|
+
iusdAssetInfo,
|
|
4757
|
+
collateralAssetA,
|
|
4758
|
+
);
|
|
4759
|
+
|
|
4760
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
4761
|
+
|
|
4294
4762
|
await executeLiquidation(
|
|
4295
4763
|
context,
|
|
4296
4764
|
sysParams,
|
|
@@ -4444,6 +4912,13 @@ describe('Stability pool', () => {
|
|
|
4444
4912
|
{
|
|
4445
4913
|
context.lucid.selectWallet.fromSeed(context.users.user1.seedPhrase);
|
|
4446
4914
|
|
|
4915
|
+
await refreshPriceOracle(
|
|
4916
|
+
context,
|
|
4917
|
+
sysParams,
|
|
4918
|
+
iusdAssetInfo,
|
|
4919
|
+
collateralAssetA,
|
|
4920
|
+
);
|
|
4921
|
+
|
|
4447
4922
|
await runAndAwaitTx(
|
|
4448
4923
|
context.lucid,
|
|
4449
4924
|
runOpenCdp(
|
|
@@ -4477,7 +4952,7 @@ describe('Stability pool', () => {
|
|
|
4477
4952
|
|
|
4478
4953
|
await runAndAwaitTx(
|
|
4479
4954
|
context.lucid,
|
|
4480
|
-
|
|
4955
|
+
requestSpAccountCreation(
|
|
4481
4956
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
4482
4957
|
5_000_010n,
|
|
4483
4958
|
sysParams,
|
|
@@ -4509,6 +4984,24 @@ describe('Stability pool', () => {
|
|
|
4509
4984
|
await repeat(6, async (isLast) => {
|
|
4510
4985
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
4511
4986
|
|
|
4987
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
4988
|
+
await sendValueTo(
|
|
4989
|
+
context.users.user4.address,
|
|
4990
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
4991
|
+
context.lucid,
|
|
4992
|
+
);
|
|
4993
|
+
|
|
4994
|
+
context.emulator.awaitSlot(1000);
|
|
4995
|
+
|
|
4996
|
+
await refreshPriceOracle(
|
|
4997
|
+
context,
|
|
4998
|
+
sysParams,
|
|
4999
|
+
iusdAssetInfo,
|
|
5000
|
+
collateralAssetA,
|
|
5001
|
+
);
|
|
5002
|
+
|
|
5003
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
5004
|
+
|
|
4512
5005
|
await executeLiquidation(
|
|
4513
5006
|
context,
|
|
4514
5007
|
sysParams,
|
|
@@ -4565,7 +5058,7 @@ describe('Stability pool', () => {
|
|
|
4565
5058
|
|
|
4566
5059
|
await runAndAwaitTx(
|
|
4567
5060
|
context.lucid,
|
|
4568
|
-
|
|
5061
|
+
requestSpAccountCreation(
|
|
4569
5062
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
4570
5063
|
LIQUIDATED_DEBT,
|
|
4571
5064
|
sysParams,
|
|
@@ -4617,6 +5110,15 @@ describe('Stability pool', () => {
|
|
|
4617
5110
|
for (const collateral of initialAssets) {
|
|
4618
5111
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
4619
5112
|
|
|
5113
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
5114
|
+
await sendValueTo(
|
|
5115
|
+
context.users.user4.address,
|
|
5116
|
+
mkAssetsOf(collateral, LIQUIDATED_COLLATERAL),
|
|
5117
|
+
context.lucid,
|
|
5118
|
+
);
|
|
5119
|
+
|
|
5120
|
+
context.emulator.awaitSlot(1000);
|
|
5121
|
+
|
|
4620
5122
|
await refreshPriceOracle(
|
|
4621
5123
|
context,
|
|
4622
5124
|
sysParams,
|
|
@@ -4624,6 +5126,8 @@ describe('Stability pool', () => {
|
|
|
4624
5126
|
collateral,
|
|
4625
5127
|
);
|
|
4626
5128
|
|
|
5129
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
5130
|
+
|
|
4627
5131
|
await executeLiquidation(
|
|
4628
5132
|
context,
|
|
4629
5133
|
sysParams,
|
|
@@ -4642,6 +5146,24 @@ describe('Stability pool', () => {
|
|
|
4642
5146
|
await repeat(2, async (isLast) => {
|
|
4643
5147
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
4644
5148
|
|
|
5149
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
5150
|
+
await sendValueTo(
|
|
5151
|
+
context.users.user4.address,
|
|
5152
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
5153
|
+
context.lucid,
|
|
5154
|
+
);
|
|
5155
|
+
|
|
5156
|
+
context.emulator.awaitSlot(1000);
|
|
5157
|
+
|
|
5158
|
+
await refreshPriceOracle(
|
|
5159
|
+
context,
|
|
5160
|
+
sysParams,
|
|
5161
|
+
iusdAssetInfo,
|
|
5162
|
+
collateralAssetA,
|
|
5163
|
+
);
|
|
5164
|
+
|
|
5165
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
5166
|
+
|
|
4645
5167
|
await executeLiquidation(
|
|
4646
5168
|
context,
|
|
4647
5169
|
sysParams,
|
|
@@ -4773,6 +5295,24 @@ describe('Stability pool', () => {
|
|
|
4773
5295
|
|
|
4774
5296
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
4775
5297
|
|
|
5298
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
5299
|
+
await sendValueTo(
|
|
5300
|
+
context.users.user4.address,
|
|
5301
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
5302
|
+
context.lucid,
|
|
5303
|
+
);
|
|
5304
|
+
|
|
5305
|
+
context.emulator.awaitSlot(1000);
|
|
5306
|
+
|
|
5307
|
+
await refreshPriceOracle(
|
|
5308
|
+
context,
|
|
5309
|
+
sysParams,
|
|
5310
|
+
iusdAssetInfo,
|
|
5311
|
+
collateralAssetA,
|
|
5312
|
+
);
|
|
5313
|
+
|
|
5314
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
5315
|
+
|
|
4776
5316
|
await executeLiquidation(
|
|
4777
5317
|
context,
|
|
4778
5318
|
sysParams,
|
|
@@ -4865,6 +5405,24 @@ describe('Stability pool', () => {
|
|
|
4865
5405
|
|
|
4866
5406
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
4867
5407
|
|
|
5408
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
5409
|
+
await sendValueTo(
|
|
5410
|
+
context.users.user4.address,
|
|
5411
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
5412
|
+
context.lucid,
|
|
5413
|
+
);
|
|
5414
|
+
|
|
5415
|
+
context.emulator.awaitSlot(1000);
|
|
5416
|
+
|
|
5417
|
+
await refreshPriceOracle(
|
|
5418
|
+
context,
|
|
5419
|
+
sysParams,
|
|
5420
|
+
iusdAssetInfo,
|
|
5421
|
+
collateralAssetA,
|
|
5422
|
+
);
|
|
5423
|
+
|
|
5424
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
5425
|
+
|
|
4868
5426
|
await executeLiquidation(
|
|
4869
5427
|
context,
|
|
4870
5428
|
sysParams,
|
|
@@ -5027,7 +5585,7 @@ describe('Stability pool', () => {
|
|
|
5027
5585
|
|
|
5028
5586
|
await runAndAwaitTx(
|
|
5029
5587
|
context.lucid,
|
|
5030
|
-
|
|
5588
|
+
requestSpAccountCreation(
|
|
5031
5589
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
5032
5590
|
SINGLE_ACCOUNT_DEPOSIT,
|
|
5033
5591
|
sysParams,
|
|
@@ -5058,6 +5616,24 @@ describe('Stability pool', () => {
|
|
|
5058
5616
|
const LIQUIDATED_DEBT = 5_000_000n;
|
|
5059
5617
|
const LIQUIDATED_COLLATERAL = 11_000_000n;
|
|
5060
5618
|
|
|
5619
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
5620
|
+
await sendValueTo(
|
|
5621
|
+
context.users.user4.address,
|
|
5622
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
5623
|
+
context.lucid,
|
|
5624
|
+
);
|
|
5625
|
+
|
|
5626
|
+
context.emulator.awaitSlot(1000);
|
|
5627
|
+
|
|
5628
|
+
await refreshPriceOracle(
|
|
5629
|
+
context,
|
|
5630
|
+
sysParams,
|
|
5631
|
+
iusdAssetInfo,
|
|
5632
|
+
collateralAssetA,
|
|
5633
|
+
);
|
|
5634
|
+
|
|
5635
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
5636
|
+
|
|
5061
5637
|
await executeLiquidation(
|
|
5062
5638
|
context,
|
|
5063
5639
|
sysParams,
|
|
@@ -5099,47 +5675,83 @@ describe('Stability pool', () => {
|
|
|
5099
5675
|
* Liquidate CDP with collateral asset D (the new whitelisted one)
|
|
5100
5676
|
***********/
|
|
5101
5677
|
|
|
5102
|
-
|
|
5678
|
+
{
|
|
5679
|
+
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
5103
5680
|
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
{
|
|
5111
|
-
iassetTokenNameAscii: iusdAssetInfo.iassetTokenNameAscii,
|
|
5112
|
-
collateralAssets: [newCollateralAssetDInfo],
|
|
5113
|
-
},
|
|
5114
|
-
);
|
|
5681
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
5682
|
+
await sendValueTo(
|
|
5683
|
+
context.users.user4.address,
|
|
5684
|
+
mkAssetsOf(collateralAssetD, LIQUIDATED_COLLATERAL),
|
|
5685
|
+
context.lucid,
|
|
5686
|
+
);
|
|
5115
5687
|
|
|
5116
|
-
|
|
5117
|
-
* Liquidate CDP with collateral asset C (the new whitelisted one)
|
|
5118
|
-
***********/
|
|
5688
|
+
context.emulator.awaitSlot(1000);
|
|
5119
5689
|
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5690
|
+
await refreshPriceOracle(
|
|
5691
|
+
context,
|
|
5692
|
+
sysParams,
|
|
5693
|
+
{
|
|
5694
|
+
iassetTokenNameAscii: iusdAssetInfo.iassetTokenNameAscii,
|
|
5695
|
+
collateralAssets: [newCollateralAssetDInfo],
|
|
5696
|
+
},
|
|
5697
|
+
collateralAssetD,
|
|
5698
|
+
);
|
|
5129
5699
|
|
|
5130
|
-
|
|
5700
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
5131
5701
|
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5702
|
+
await executeLiquidation(
|
|
5703
|
+
context,
|
|
5704
|
+
sysParams,
|
|
5705
|
+
LIQUIDATED_DEBT,
|
|
5706
|
+
LIQUIDATED_COLLATERAL,
|
|
5707
|
+
collateralAssetD,
|
|
5708
|
+
{
|
|
5709
|
+
iassetTokenNameAscii: iusdAssetInfo.iassetTokenNameAscii,
|
|
5710
|
+
collateralAssets: [newCollateralAssetDInfo],
|
|
5711
|
+
},
|
|
5712
|
+
);
|
|
5713
|
+
}
|
|
5714
|
+
|
|
5715
|
+
{
|
|
5716
|
+
/**********
|
|
5717
|
+
* Liquidate CDP with collateral asset C (the new whitelisted one)
|
|
5718
|
+
***********/
|
|
5719
|
+
|
|
5720
|
+
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
5721
|
+
|
|
5722
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
5723
|
+
await sendValueTo(
|
|
5724
|
+
context.users.user4.address,
|
|
5725
|
+
mkAssetsOf(collateralAssetC, LIQUIDATED_COLLATERAL),
|
|
5726
|
+
context.lucid,
|
|
5727
|
+
);
|
|
5728
|
+
|
|
5729
|
+
context.emulator.awaitSlot(1000);
|
|
5730
|
+
|
|
5731
|
+
await refreshPriceOracle(
|
|
5732
|
+
context,
|
|
5733
|
+
sysParams,
|
|
5734
|
+
{
|
|
5735
|
+
iassetTokenNameAscii: iusdAssetInfo.iassetTokenNameAscii,
|
|
5736
|
+
collateralAssets: [newCollateralAssetCInfo],
|
|
5737
|
+
},
|
|
5738
|
+
collateralAssetC,
|
|
5739
|
+
);
|
|
5740
|
+
|
|
5741
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
5742
|
+
|
|
5743
|
+
await executeLiquidation(
|
|
5744
|
+
context,
|
|
5745
|
+
sysParams,
|
|
5746
|
+
LIQUIDATED_DEBT,
|
|
5747
|
+
LIQUIDATED_COLLATERAL,
|
|
5748
|
+
collateralAssetC,
|
|
5749
|
+
{
|
|
5750
|
+
iassetTokenNameAscii: iusdAssetInfo.iassetTokenNameAscii,
|
|
5751
|
+
collateralAssets: [newCollateralAssetCInfo],
|
|
5752
|
+
},
|
|
5753
|
+
);
|
|
5754
|
+
}
|
|
5143
5755
|
|
|
5144
5756
|
/**********
|
|
5145
5757
|
* Deposit to user1 account and withdraw rewards
|
|
@@ -5300,7 +5912,7 @@ describe('Stability pool', () => {
|
|
|
5300
5912
|
|
|
5301
5913
|
await runAndAwaitTx(
|
|
5302
5914
|
context.lucid,
|
|
5303
|
-
|
|
5915
|
+
requestSpAccountCreation(
|
|
5304
5916
|
iusdAssetInfo.iassetTokenNameAscii,
|
|
5305
5917
|
SINGLE_ACCOUNT_DEPOSIT,
|
|
5306
5918
|
sysParams,
|
|
@@ -5332,6 +5944,24 @@ describe('Stability pool', () => {
|
|
|
5332
5944
|
await repeat(2, async () => {
|
|
5333
5945
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
5334
5946
|
|
|
5947
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
5948
|
+
await sendValueTo(
|
|
5949
|
+
context.users.user4.address,
|
|
5950
|
+
mkAssetsOf(collateralAssetA, LIQUIDATED_COLLATERAL),
|
|
5951
|
+
context.lucid,
|
|
5952
|
+
);
|
|
5953
|
+
|
|
5954
|
+
context.emulator.awaitSlot(1000);
|
|
5955
|
+
|
|
5956
|
+
await refreshPriceOracle(
|
|
5957
|
+
context,
|
|
5958
|
+
sysParams,
|
|
5959
|
+
iusdAssetInfo,
|
|
5960
|
+
collateralAssetA,
|
|
5961
|
+
);
|
|
5962
|
+
|
|
5963
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
5964
|
+
|
|
5335
5965
|
await executeLiquidation(
|
|
5336
5966
|
context,
|
|
5337
5967
|
sysParams,
|
|
@@ -5400,6 +6030,27 @@ describe('Stability pool', () => {
|
|
|
5400
6030
|
|
|
5401
6031
|
context.lucid.selectWallet.fromSeed(context.users.user3.seedPhrase);
|
|
5402
6032
|
|
|
6033
|
+
// Send funds to user4 so liquidation is performed from a clean address.
|
|
6034
|
+
await sendValueTo(
|
|
6035
|
+
context.users.user4.address,
|
|
6036
|
+
mkAssetsOf(collateralAssetC, LIQUIDATED_COLLATERAL),
|
|
6037
|
+
context.lucid,
|
|
6038
|
+
);
|
|
6039
|
+
|
|
6040
|
+
context.emulator.awaitSlot(1000);
|
|
6041
|
+
|
|
6042
|
+
await refreshPriceOracle(
|
|
6043
|
+
context,
|
|
6044
|
+
sysParams,
|
|
6045
|
+
{
|
|
6046
|
+
iassetTokenNameAscii: iusdAssetInfo.iassetTokenNameAscii,
|
|
6047
|
+
collateralAssets: [newCollateralAssetCInfo],
|
|
6048
|
+
},
|
|
6049
|
+
collateralAssetC,
|
|
6050
|
+
);
|
|
6051
|
+
|
|
6052
|
+
context.lucid.selectWallet.fromSeed(context.users.user4.seedPhrase);
|
|
6053
|
+
|
|
5403
6054
|
await executeLiquidation(
|
|
5404
6055
|
context,
|
|
5405
6056
|
sysParams,
|