@defisaver/automation-sdk 3.3.15 → 3.3.16-liq-prot-dev
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/cjs/constants/index.js +145 -0
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +5 -2
- package/cjs/services/strategiesService.js +158 -9
- package/cjs/services/strategySubService.d.ts +17 -16
- package/cjs/services/strategySubService.js +69 -28
- package/cjs/services/strategySubService.test.js +69 -40
- package/cjs/services/subDataService.d.ts +70 -20
- package/cjs/services/subDataService.js +23 -79
- package/cjs/services/subDataService.test.js +117 -202
- package/cjs/services/triggerService.test.js +60 -0
- package/cjs/services/utils.d.ts +2 -1
- package/cjs/services/utils.js +14 -1
- package/cjs/types/enums.d.ts +39 -6
- package/cjs/types/enums.js +33 -0
- package/esm/constants/index.js +145 -0
- package/esm/index.d.ts +2 -2
- package/esm/index.js +5 -2
- package/esm/services/strategiesService.js +158 -9
- package/esm/services/strategySubService.d.ts +17 -16
- package/esm/services/strategySubService.js +69 -28
- package/esm/services/strategySubService.test.js +70 -38
- package/esm/services/subDataService.d.ts +70 -20
- package/esm/services/subDataService.js +21 -77
- package/esm/services/subDataService.test.js +118 -200
- package/esm/services/triggerService.test.js +61 -1
- package/esm/services/utils.d.ts +2 -1
- package/esm/services/utils.js +13 -1
- package/esm/types/enums.d.ts +39 -6
- package/esm/types/enums.js +33 -0
- package/package.json +1 -1
- package/src/constants/index.ts +147 -1
- package/src/index.ts +22 -6
- package/src/services/strategiesService.ts +222 -9
- package/src/services/strategySubService.test.ts +86 -46
- package/src/services/strategySubService.ts +166 -39
- package/src/services/subDataService.test.ts +128 -214
- package/src/services/subDataService.ts +42 -106
- package/src/services/triggerService.test.ts +69 -0
- package/src/services/utils.test.ts +1 -1
- package/src/services/utils.ts +15 -1
- package/src/types/enums.ts +33 -2
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import Dec from 'decimal.js';
|
|
2
1
|
import { expect } from 'chai';
|
|
3
2
|
import { getAssetInfo } from '@defisaver/tokens';
|
|
4
3
|
import * as web3Utils from 'web3-utils';
|
|
5
4
|
import { MAXUINT } from '@defisaver/tokens';
|
|
6
5
|
|
|
7
|
-
import { ChainId, CloseStrategyType,
|
|
6
|
+
import { ChainId, CloseStrategyType, RatioState } from '../types/enums';
|
|
8
7
|
import type { EthereumAddress, SubData } from '../types';
|
|
9
8
|
|
|
10
9
|
import '../configuration';
|
|
@@ -133,7 +132,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
133
132
|
});
|
|
134
133
|
});
|
|
135
134
|
|
|
136
|
-
describe('When testing subDataService.
|
|
135
|
+
describe('When testing subDataService.legacyMakerLeverageManagementSubData', () => {
|
|
137
136
|
describe('decode()', () => {
|
|
138
137
|
const examples: Array<[{ vaultId: number, targetRatio: number }, SubData]> = [
|
|
139
138
|
[
|
|
@@ -147,13 +146,13 @@ describe('Feature: subDataService.ts', () => {
|
|
|
147
146
|
|
|
148
147
|
examples.forEach(([expected, actual]) => {
|
|
149
148
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
150
|
-
expect(subDataService.
|
|
149
|
+
expect(subDataService.legacyMakerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
151
150
|
});
|
|
152
151
|
});
|
|
153
152
|
});
|
|
154
153
|
});
|
|
155
154
|
|
|
156
|
-
describe('When testing subDataService.
|
|
155
|
+
describe('When testing subDataService.makerLeverageManagementSubData', () => {
|
|
157
156
|
describe('encode()', () => {
|
|
158
157
|
const examples: Array<[SubData, [vaultId: number, targetRatio: number, daiAddr?: EthereumAddress]]> = [
|
|
159
158
|
[
|
|
@@ -174,7 +173,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
174
173
|
|
|
175
174
|
examples.forEach(([expected, actual]) => {
|
|
176
175
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
177
|
-
expect(subDataService.
|
|
176
|
+
expect(subDataService.makerLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
178
177
|
});
|
|
179
178
|
});
|
|
180
179
|
});
|
|
@@ -207,13 +206,13 @@ describe('Feature: subDataService.ts', () => {
|
|
|
207
206
|
|
|
208
207
|
examples.forEach(([expected, actual]) => {
|
|
209
208
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
210
|
-
expect(subDataService.
|
|
209
|
+
expect(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
211
210
|
});
|
|
212
211
|
});
|
|
213
212
|
});
|
|
214
213
|
});
|
|
215
214
|
|
|
216
|
-
describe('When testing subDataService.
|
|
215
|
+
describe('When testing subDataService.legacyLiquityLeverageManagementSubData', () => {
|
|
217
216
|
describe('decode()', () => {
|
|
218
217
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
219
218
|
[
|
|
@@ -227,7 +226,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
227
226
|
|
|
228
227
|
examples.forEach(([expected, actual]) => {
|
|
229
228
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
230
|
-
expect(subDataService.
|
|
229
|
+
expect(subDataService.legacyLiquityLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
231
230
|
});
|
|
232
231
|
});
|
|
233
232
|
});
|
|
@@ -287,26 +286,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
287
286
|
});
|
|
288
287
|
});
|
|
289
288
|
|
|
290
|
-
describe('When testing subDataService.
|
|
291
|
-
describe('encode()', () => {
|
|
292
|
-
const examples: Array<[[string, string, string, string, boolean], [triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean]]> = [
|
|
293
|
-
[
|
|
294
|
-
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
295
|
-
[160, 220, 180, 190, true]
|
|
296
|
-
],
|
|
297
|
-
[
|
|
298
|
-
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
299
|
-
[160, 200, 180, 190, false]
|
|
300
|
-
],
|
|
301
|
-
];
|
|
302
|
-
|
|
303
|
-
examples.forEach(([expected, actual]) => {
|
|
304
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
305
|
-
expect(subDataService.aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
|
|
289
|
+
describe('When testing subDataService.legacyAaveV2LeverageManagementSubData', () => {
|
|
310
290
|
describe('decode()', () => {
|
|
311
291
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
312
292
|
[
|
|
@@ -321,13 +301,13 @@ describe('Feature: subDataService.ts', () => {
|
|
|
321
301
|
|
|
322
302
|
examples.forEach(([expected, actual]) => {
|
|
323
303
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
324
|
-
expect(subDataService.
|
|
304
|
+
expect(subDataService.legacyAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
325
305
|
});
|
|
326
306
|
});
|
|
327
307
|
});
|
|
328
308
|
});
|
|
329
309
|
|
|
330
|
-
describe('When testing subDataService.
|
|
310
|
+
describe('When testing subDataService.legacyAaveV3LeverageManagementSubData', () => {
|
|
331
311
|
describe('decode()', () => {
|
|
332
312
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
333
313
|
[
|
|
@@ -342,7 +322,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
342
322
|
|
|
343
323
|
examples.forEach(([expected, actual]) => {
|
|
344
324
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
345
|
-
expect(subDataService.
|
|
325
|
+
expect(subDataService.legacyAaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
346
326
|
});
|
|
347
327
|
});
|
|
348
328
|
});
|
|
@@ -694,26 +674,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
694
674
|
});
|
|
695
675
|
});
|
|
696
676
|
|
|
697
|
-
describe('When testing subDataService.
|
|
698
|
-
describe('encode()', () => {
|
|
699
|
-
const examples: Array<[[string, string, string, string, boolean], [triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean]]> = [
|
|
700
|
-
[
|
|
701
|
-
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
702
|
-
[160, 220, 180, 190, true]
|
|
703
|
-
],
|
|
704
|
-
[
|
|
705
|
-
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
706
|
-
[160, 200, 180, 190, false]
|
|
707
|
-
],
|
|
708
|
-
];
|
|
709
|
-
|
|
710
|
-
examples.forEach(([expected, actual]) => {
|
|
711
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
712
|
-
expect(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
713
|
-
});
|
|
714
|
-
});
|
|
715
|
-
});
|
|
716
|
-
|
|
677
|
+
describe('When testing subDataService.legacyCompoundV2LeverageManagementSubData', () => {
|
|
717
678
|
describe('decode()', () => {
|
|
718
679
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
719
680
|
[
|
|
@@ -728,104 +689,13 @@ describe('Feature: subDataService.ts', () => {
|
|
|
728
689
|
|
|
729
690
|
examples.forEach(([expected, actual]) => {
|
|
730
691
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
731
|
-
expect(subDataService.
|
|
732
|
-
});
|
|
733
|
-
});
|
|
734
|
-
});
|
|
735
|
-
});
|
|
736
|
-
|
|
737
|
-
describe('When testing subDataService.compoundV3LeverageManagementSubData', () => {
|
|
738
|
-
describe('encode()', () => {
|
|
739
|
-
const examples: Array<[[EthereumAddress, EthereumAddress, string, string, string, string, boolean, boolean], [market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean]]> = [
|
|
740
|
-
[
|
|
741
|
-
[
|
|
742
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
743
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
744
|
-
new Dec(160).mul(1e16).toString(),
|
|
745
|
-
new Dec(220).mul(1e16).toString(),
|
|
746
|
-
new Dec(180).mul(1e16).toString(),
|
|
747
|
-
new Dec(190).mul(1e16).toString(),
|
|
748
|
-
true, false,
|
|
749
|
-
],
|
|
750
|
-
[
|
|
751
|
-
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
752
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
753
|
-
160, 220, 180, 190,
|
|
754
|
-
true, false,
|
|
755
|
-
]
|
|
756
|
-
],
|
|
757
|
-
[
|
|
758
|
-
[
|
|
759
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
760
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
761
|
-
new Dec(160).mul(1e16).toString(),
|
|
762
|
-
new Dec(210).mul(1e16).toString(),
|
|
763
|
-
new Dec(180).mul(1e16).toString(),
|
|
764
|
-
new Dec(190).mul(1e16).toString(),
|
|
765
|
-
false, true,
|
|
766
|
-
],
|
|
767
|
-
[
|
|
768
|
-
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
769
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
770
|
-
160, 210, 180, 190,
|
|
771
|
-
false, true,
|
|
772
|
-
]
|
|
773
|
-
],
|
|
774
|
-
];
|
|
775
|
-
|
|
776
|
-
examples.forEach(([expected, actual]) => {
|
|
777
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
778
|
-
expect(subDataService.compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
779
|
-
});
|
|
780
|
-
});
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
describe('decode()', () => {
|
|
784
|
-
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
785
|
-
[
|
|
786
|
-
{ targetRatio: 123 },
|
|
787
|
-
[
|
|
788
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
789
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
790
|
-
],
|
|
791
|
-
],
|
|
792
|
-
[
|
|
793
|
-
{ targetRatio: 200 },
|
|
794
|
-
[
|
|
795
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
796
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
797
|
-
],
|
|
798
|
-
],
|
|
799
|
-
];
|
|
800
|
-
|
|
801
|
-
examples.forEach(([expected, actual]) => {
|
|
802
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
803
|
-
expect(subDataService.compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
692
|
+
expect(subDataService.legacyCompoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
804
693
|
});
|
|
805
694
|
});
|
|
806
695
|
});
|
|
807
696
|
});
|
|
808
697
|
|
|
809
698
|
describe('When testing subDataService.morphoAaveV2LeverageManagementSubData', () => {
|
|
810
|
-
describe('encode()', () => {
|
|
811
|
-
const examples: Array<[[string, string, string, string, boolean], [triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean]]> = [
|
|
812
|
-
[
|
|
813
|
-
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
814
|
-
[160, 220, 180, 190, true]
|
|
815
|
-
],
|
|
816
|
-
[
|
|
817
|
-
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
818
|
-
[160, 200, 180, 190, false]
|
|
819
|
-
],
|
|
820
|
-
];
|
|
821
|
-
|
|
822
|
-
examples.forEach(([expected, actual]) => {
|
|
823
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
824
|
-
expect(subDataService.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
825
|
-
});
|
|
826
|
-
});
|
|
827
|
-
});
|
|
828
|
-
|
|
829
699
|
describe('decode()', () => {
|
|
830
700
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
831
701
|
[
|
|
@@ -847,25 +717,6 @@ describe('Feature: subDataService.ts', () => {
|
|
|
847
717
|
});
|
|
848
718
|
|
|
849
719
|
describe('When testing subDataService.cBondsRebondSubData', () => {
|
|
850
|
-
describe('encode()', () => {
|
|
851
|
-
const examples: Array<[SubData, [bondId: number | string]]> = [
|
|
852
|
-
[
|
|
853
|
-
['0x00000000000000000000000000000000000000000000000000000000000000c8'],
|
|
854
|
-
[200]
|
|
855
|
-
],
|
|
856
|
-
[
|
|
857
|
-
['0x000000000000000000000000000000000000000000000000000000000000a119'],
|
|
858
|
-
[41241]
|
|
859
|
-
],
|
|
860
|
-
];
|
|
861
|
-
|
|
862
|
-
examples.forEach(([expected, actual]) => {
|
|
863
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
864
|
-
expect(subDataService.cBondsRebondSubData.encode(...actual)).to.eql(expected);
|
|
865
|
-
});
|
|
866
|
-
});
|
|
867
|
-
});
|
|
868
|
-
|
|
869
720
|
describe('decode()', () => {
|
|
870
721
|
const examples: Array<[{ bondId: string }, SubData]> = [
|
|
871
722
|
[
|
|
@@ -1016,54 +867,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1016
867
|
});
|
|
1017
868
|
});
|
|
1018
869
|
|
|
1019
|
-
describe('When testing subDataService.
|
|
1020
|
-
describe('encode()', () => {
|
|
1021
|
-
const examples: Array<[[EthereumAddress, EthereumAddress, string, string, string, string], [fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, targetPrice: string, goodUntil: string | number, orderType: OrderType]]> = [
|
|
1022
|
-
[
|
|
1023
|
-
[
|
|
1024
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1025
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1026
|
-
'2131',
|
|
1027
|
-
'0.53123',
|
|
1028
|
-
'1696590921159',
|
|
1029
|
-
`${OrderType.STOP_LOSS}`
|
|
1030
|
-
],
|
|
1031
|
-
[
|
|
1032
|
-
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1033
|
-
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1034
|
-
'2131',
|
|
1035
|
-
'0.53123',
|
|
1036
|
-
1696590921159,
|
|
1037
|
-
OrderType.STOP_LOSS
|
|
1038
|
-
]
|
|
1039
|
-
],
|
|
1040
|
-
[
|
|
1041
|
-
[
|
|
1042
|
-
web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
|
|
1043
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
1044
|
-
'2131',
|
|
1045
|
-
'0.43123',
|
|
1046
|
-
'1646590921159',
|
|
1047
|
-
`${OrderType.TAKE_PROFIT}`
|
|
1048
|
-
],
|
|
1049
|
-
[
|
|
1050
|
-
web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
|
|
1051
|
-
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
1052
|
-
'2131',
|
|
1053
|
-
'0.43123',
|
|
1054
|
-
1646590921159,
|
|
1055
|
-
OrderType.TAKE_PROFIT
|
|
1056
|
-
]
|
|
1057
|
-
],
|
|
1058
|
-
];
|
|
1059
|
-
|
|
1060
|
-
examples.forEach(([expected, actual]) => {
|
|
1061
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1062
|
-
expect(subDataService.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
|
|
1063
|
-
});
|
|
1064
|
-
});
|
|
1065
|
-
});
|
|
1066
|
-
|
|
870
|
+
describe('When testing subDataService.legacyExchangeLimitOrderSubData', () => {
|
|
1067
871
|
describe('decode()', () => {
|
|
1068
872
|
const examples: Array<[{ fromToken: EthereumAddress, toToken: EthereumAddress, amount: string }, [SubData, ChainId]]> = [
|
|
1069
873
|
[
|
|
@@ -1098,13 +902,13 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1098
902
|
|
|
1099
903
|
examples.forEach(([expected, actual]) => {
|
|
1100
904
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1101
|
-
expect(subDataService.
|
|
905
|
+
expect(subDataService.legacyExchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
|
|
1102
906
|
});
|
|
1103
907
|
});
|
|
1104
908
|
});
|
|
1105
909
|
});
|
|
1106
910
|
|
|
1107
|
-
describe('When testing subDataService.
|
|
911
|
+
describe('When testing subDataService.legacySparkLeverageManagementSubData', () => {
|
|
1108
912
|
describe('decode()', () => {
|
|
1109
913
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
1110
914
|
[
|
|
@@ -1119,7 +923,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1119
923
|
|
|
1120
924
|
examples.forEach(([expected, actual]) => {
|
|
1121
925
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1122
|
-
expect(subDataService.
|
|
926
|
+
expect(subDataService.legacySparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1123
927
|
});
|
|
1124
928
|
});
|
|
1125
929
|
});
|
|
@@ -1564,6 +1368,116 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1564
1368
|
});
|
|
1565
1369
|
});
|
|
1566
1370
|
|
|
1371
|
+
describe('When testing subDataService.morphoBlueLeverageManagementOnPriceSubData', () => {
|
|
1372
|
+
describe('encode()', () => {
|
|
1373
|
+
const examples: Array<[
|
|
1374
|
+
SubData,
|
|
1375
|
+
[loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, targetRatio: number, user: EthereumAddress],
|
|
1376
|
+
]> = [
|
|
1377
|
+
[
|
|
1378
|
+
[
|
|
1379
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1380
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1381
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1382
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1383
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1384
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1385
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1386
|
+
],
|
|
1387
|
+
[
|
|
1388
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1389
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1390
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1391
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1392
|
+
'945000000000000000',
|
|
1393
|
+
200,
|
|
1394
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1395
|
+
],
|
|
1396
|
+
],
|
|
1397
|
+
[
|
|
1398
|
+
[
|
|
1399
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1400
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1401
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1402
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1403
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1404
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1405
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1406
|
+
],
|
|
1407
|
+
[
|
|
1408
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1409
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1410
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1411
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1412
|
+
'945000000000000000',
|
|
1413
|
+
160,
|
|
1414
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1415
|
+
],
|
|
1416
|
+
],
|
|
1417
|
+
];
|
|
1418
|
+
|
|
1419
|
+
examples.forEach(([expected, actual]) => {
|
|
1420
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1421
|
+
expect(subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1422
|
+
});
|
|
1423
|
+
});
|
|
1424
|
+
});
|
|
1425
|
+
|
|
1426
|
+
describe('decode()', () => {
|
|
1427
|
+
const examples: Array<[
|
|
1428
|
+
{ loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, targetRatio: number, user: EthereumAddress },
|
|
1429
|
+
SubData,
|
|
1430
|
+
]> = [
|
|
1431
|
+
[
|
|
1432
|
+
{
|
|
1433
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1434
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1435
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1436
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1437
|
+
lltv: '945000000000000000',
|
|
1438
|
+
targetRatio: 200,
|
|
1439
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1440
|
+
},
|
|
1441
|
+
[
|
|
1442
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1443
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1444
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1445
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1446
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1447
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1448
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1449
|
+
],
|
|
1450
|
+
],
|
|
1451
|
+
[
|
|
1452
|
+
{
|
|
1453
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1454
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1455
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1456
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1457
|
+
lltv: '945000000000000000',
|
|
1458
|
+
targetRatio: 160,
|
|
1459
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1460
|
+
},
|
|
1461
|
+
[
|
|
1462
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1463
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1464
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1465
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1466
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1467
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1468
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1469
|
+
],
|
|
1470
|
+
],
|
|
1471
|
+
];
|
|
1472
|
+
|
|
1473
|
+
examples.forEach(([expected, actual]) => {
|
|
1474
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1475
|
+
expect(subDataService.morphoBlueLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1476
|
+
});
|
|
1477
|
+
});
|
|
1478
|
+
});
|
|
1479
|
+
});
|
|
1480
|
+
|
|
1567
1481
|
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1568
1482
|
describe('encode()', () => {
|
|
1569
1483
|
const examples: Array<[SubData, [collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number]]> = [
|