@defisaver/automation-sdk 3.3.15-liq-prot-3-dev → 3.3.16-dev-13082-morpho-eoa-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 +51 -111
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +2 -5
- package/cjs/services/strategiesService.js +13 -157
- package/cjs/services/strategySubService.d.ts +21 -18
- package/cjs/services/strategySubService.js +74 -78
- package/cjs/services/strategySubService.test.js +216 -3
- package/cjs/services/subDataService.d.ts +20 -70
- package/cjs/services/subDataService.js +79 -23
- package/cjs/services/subDataService.test.js +302 -17
- package/cjs/services/triggerService.test.js +60 -0
- package/cjs/services/utils.d.ts +1 -2
- package/cjs/services/utils.js +1 -14
- package/cjs/types/enums.d.ts +17 -33
- package/cjs/types/enums.js +14 -30
- package/esm/constants/index.js +51 -111
- package/esm/index.d.ts +2 -2
- package/esm/index.js +2 -5
- package/esm/services/strategiesService.js +13 -157
- package/esm/services/strategySubService.d.ts +21 -18
- package/esm/services/strategySubService.js +73 -78
- package/esm/services/strategySubService.test.js +214 -4
- package/esm/services/subDataService.d.ts +20 -70
- package/esm/services/subDataService.js +77 -21
- package/esm/services/subDataService.test.js +300 -18
- package/esm/services/triggerService.test.js +61 -1
- package/esm/services/utils.d.ts +1 -2
- package/esm/services/utils.js +1 -13
- package/esm/types/enums.d.ts +17 -33
- package/esm/types/enums.js +14 -30
- package/package.json +1 -1
- package/src/constants/index.ts +52 -113
- package/src/index.ts +6 -22
- package/src/services/strategiesService.ts +13 -221
- package/src/services/strategySubService.test.ts +275 -3
- package/src/services/strategySubService.ts +121 -173
- package/src/services/subDataService.test.ts +324 -18
- package/src/services/subDataService.ts +106 -42
- package/src/services/triggerService.test.ts +69 -0
- package/src/services/utils.test.ts +1 -1
- package/src/services/utils.ts +1 -15
- package/src/types/enums.ts +16 -30
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import Dec from 'decimal.js';
|
|
1
2
|
import { expect } from 'chai';
|
|
2
3
|
import { getAssetInfo } from '@defisaver/tokens';
|
|
3
4
|
import * as web3Utils from 'web3-utils';
|
|
4
5
|
import { MAXUINT } from '@defisaver/tokens';
|
|
5
6
|
|
|
6
|
-
import { ChainId, CloseStrategyType, RatioState } from '../types/enums';
|
|
7
|
+
import { ChainId, CloseStrategyType, OrderType, RatioState } from '../types/enums';
|
|
7
8
|
import type { EthereumAddress, SubData } from '../types';
|
|
8
9
|
|
|
9
10
|
import '../configuration';
|
|
@@ -132,7 +133,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
132
133
|
});
|
|
133
134
|
});
|
|
134
135
|
|
|
135
|
-
describe('When testing subDataService.
|
|
136
|
+
describe('When testing subDataService.makerLeverageManagementSubData', () => {
|
|
136
137
|
describe('decode()', () => {
|
|
137
138
|
const examples: Array<[{ vaultId: number, targetRatio: number }, SubData]> = [
|
|
138
139
|
[
|
|
@@ -146,13 +147,13 @@ describe('Feature: subDataService.ts', () => {
|
|
|
146
147
|
|
|
147
148
|
examples.forEach(([expected, actual]) => {
|
|
148
149
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
149
|
-
expect(subDataService.
|
|
150
|
+
expect(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
150
151
|
});
|
|
151
152
|
});
|
|
152
153
|
});
|
|
153
154
|
});
|
|
154
155
|
|
|
155
|
-
describe('When testing subDataService.
|
|
156
|
+
describe('When testing subDataService.makerLeverageManagementWithoutSubProxy', () => {
|
|
156
157
|
describe('encode()', () => {
|
|
157
158
|
const examples: Array<[SubData, [vaultId: number, targetRatio: number, daiAddr?: EthereumAddress]]> = [
|
|
158
159
|
[
|
|
@@ -173,7 +174,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
173
174
|
|
|
174
175
|
examples.forEach(([expected, actual]) => {
|
|
175
176
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
176
|
-
expect(subDataService.
|
|
177
|
+
expect(subDataService.makerLeverageManagementWithoutSubProxy.encode(...actual)).to.eql(expected);
|
|
177
178
|
});
|
|
178
179
|
});
|
|
179
180
|
});
|
|
@@ -206,13 +207,13 @@ describe('Feature: subDataService.ts', () => {
|
|
|
206
207
|
|
|
207
208
|
examples.forEach(([expected, actual]) => {
|
|
208
209
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
209
|
-
expect(subDataService.
|
|
210
|
+
expect(subDataService.makerLeverageManagementWithoutSubProxy.decode(actual)).to.eql(expected);
|
|
210
211
|
});
|
|
211
212
|
});
|
|
212
213
|
});
|
|
213
214
|
});
|
|
214
215
|
|
|
215
|
-
describe('When testing subDataService.
|
|
216
|
+
describe('When testing subDataService.liquityLeverageManagementSubData', () => {
|
|
216
217
|
describe('decode()', () => {
|
|
217
218
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
218
219
|
[
|
|
@@ -226,7 +227,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
226
227
|
|
|
227
228
|
examples.forEach(([expected, actual]) => {
|
|
228
229
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
229
|
-
expect(subDataService.
|
|
230
|
+
expect(subDataService.liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
230
231
|
});
|
|
231
232
|
});
|
|
232
233
|
});
|
|
@@ -286,7 +287,26 @@ describe('Feature: subDataService.ts', () => {
|
|
|
286
287
|
});
|
|
287
288
|
});
|
|
288
289
|
|
|
289
|
-
describe('When testing subDataService.
|
|
290
|
+
describe('When testing subDataService.aaveV2LeverageManagementSubData', () => {
|
|
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
|
+
|
|
290
310
|
describe('decode()', () => {
|
|
291
311
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
292
312
|
[
|
|
@@ -301,13 +321,13 @@ describe('Feature: subDataService.ts', () => {
|
|
|
301
321
|
|
|
302
322
|
examples.forEach(([expected, actual]) => {
|
|
303
323
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
304
|
-
expect(subDataService.
|
|
324
|
+
expect(subDataService.aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
305
325
|
});
|
|
306
326
|
});
|
|
307
327
|
});
|
|
308
328
|
});
|
|
309
329
|
|
|
310
|
-
describe('When testing subDataService.
|
|
330
|
+
describe('When testing subDataService.aaveV3LeverageManagementSubData', () => {
|
|
311
331
|
describe('decode()', () => {
|
|
312
332
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
313
333
|
[
|
|
@@ -322,7 +342,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
322
342
|
|
|
323
343
|
examples.forEach(([expected, actual]) => {
|
|
324
344
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
325
|
-
expect(subDataService.
|
|
345
|
+
expect(subDataService.aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
326
346
|
});
|
|
327
347
|
});
|
|
328
348
|
});
|
|
@@ -674,7 +694,26 @@ describe('Feature: subDataService.ts', () => {
|
|
|
674
694
|
});
|
|
675
695
|
});
|
|
676
696
|
|
|
677
|
-
describe('When testing subDataService.
|
|
697
|
+
describe('When testing subDataService.compoundV2LeverageManagementSubData', () => {
|
|
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
|
+
|
|
678
717
|
describe('decode()', () => {
|
|
679
718
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
680
719
|
[
|
|
@@ -689,13 +728,104 @@ describe('Feature: subDataService.ts', () => {
|
|
|
689
728
|
|
|
690
729
|
examples.forEach(([expected, actual]) => {
|
|
691
730
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
692
|
-
expect(subDataService.
|
|
731
|
+
expect(subDataService.compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
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);
|
|
693
804
|
});
|
|
694
805
|
});
|
|
695
806
|
});
|
|
696
807
|
});
|
|
697
808
|
|
|
698
809
|
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
|
+
|
|
699
829
|
describe('decode()', () => {
|
|
700
830
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
701
831
|
[
|
|
@@ -717,6 +847,25 @@ describe('Feature: subDataService.ts', () => {
|
|
|
717
847
|
});
|
|
718
848
|
|
|
719
849
|
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
|
+
|
|
720
869
|
describe('decode()', () => {
|
|
721
870
|
const examples: Array<[{ bondId: string }, SubData]> = [
|
|
722
871
|
[
|
|
@@ -867,7 +1016,54 @@ describe('Feature: subDataService.ts', () => {
|
|
|
867
1016
|
});
|
|
868
1017
|
});
|
|
869
1018
|
|
|
870
|
-
describe('When testing subDataService.
|
|
1019
|
+
describe('When testing subDataService.exchangeLimitOrderSubData', () => {
|
|
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
|
+
|
|
871
1067
|
describe('decode()', () => {
|
|
872
1068
|
const examples: Array<[{ fromToken: EthereumAddress, toToken: EthereumAddress, amount: string }, [SubData, ChainId]]> = [
|
|
873
1069
|
[
|
|
@@ -902,13 +1098,13 @@ describe('Feature: subDataService.ts', () => {
|
|
|
902
1098
|
|
|
903
1099
|
examples.forEach(([expected, actual]) => {
|
|
904
1100
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
905
|
-
expect(subDataService.
|
|
1101
|
+
expect(subDataService.exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
|
|
906
1102
|
});
|
|
907
1103
|
});
|
|
908
1104
|
});
|
|
909
1105
|
});
|
|
910
1106
|
|
|
911
|
-
describe('When testing subDataService.
|
|
1107
|
+
describe('When testing subDataService.sparkLeverageManagementSubData', () => {
|
|
912
1108
|
describe('decode()', () => {
|
|
913
1109
|
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
914
1110
|
[
|
|
@@ -923,7 +1119,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
923
1119
|
|
|
924
1120
|
examples.forEach(([expected, actual]) => {
|
|
925
1121
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
926
|
-
expect(subDataService.
|
|
1122
|
+
expect(subDataService.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
927
1123
|
});
|
|
928
1124
|
});
|
|
929
1125
|
});
|
|
@@ -1368,6 +1564,116 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1368
1564
|
});
|
|
1369
1565
|
});
|
|
1370
1566
|
|
|
1567
|
+
describe('When testing subDataService.morphoBlueLeverageManagementOnPriceSubData', () => {
|
|
1568
|
+
describe('encode()', () => {
|
|
1569
|
+
const examples: Array<[
|
|
1570
|
+
SubData,
|
|
1571
|
+
[loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, targetRatio: number, user: EthereumAddress],
|
|
1572
|
+
]> = [
|
|
1573
|
+
[
|
|
1574
|
+
[
|
|
1575
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1576
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1577
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1578
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1579
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1580
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1581
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1582
|
+
],
|
|
1583
|
+
[
|
|
1584
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1585
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1586
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1587
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1588
|
+
'945000000000000000',
|
|
1589
|
+
200,
|
|
1590
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1591
|
+
],
|
|
1592
|
+
],
|
|
1593
|
+
[
|
|
1594
|
+
[
|
|
1595
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1596
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1597
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1598
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1599
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1600
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1601
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1602
|
+
],
|
|
1603
|
+
[
|
|
1604
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1605
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1606
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1607
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1608
|
+
'945000000000000000',
|
|
1609
|
+
160,
|
|
1610
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1611
|
+
],
|
|
1612
|
+
],
|
|
1613
|
+
];
|
|
1614
|
+
|
|
1615
|
+
examples.forEach(([expected, actual]) => {
|
|
1616
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1617
|
+
expect(subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1618
|
+
});
|
|
1619
|
+
});
|
|
1620
|
+
});
|
|
1621
|
+
|
|
1622
|
+
describe('decode()', () => {
|
|
1623
|
+
const examples: Array<[
|
|
1624
|
+
{ loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, targetRatio: number, user: EthereumAddress },
|
|
1625
|
+
SubData,
|
|
1626
|
+
]> = [
|
|
1627
|
+
[
|
|
1628
|
+
{
|
|
1629
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1630
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1631
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1632
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1633
|
+
lltv: '945000000000000000',
|
|
1634
|
+
targetRatio: 200,
|
|
1635
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1636
|
+
},
|
|
1637
|
+
[
|
|
1638
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1639
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1640
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1641
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1642
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1643
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1644
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1645
|
+
],
|
|
1646
|
+
],
|
|
1647
|
+
[
|
|
1648
|
+
{
|
|
1649
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1650
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1651
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1652
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1653
|
+
lltv: '945000000000000000',
|
|
1654
|
+
targetRatio: 160,
|
|
1655
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1656
|
+
},
|
|
1657
|
+
[
|
|
1658
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1659
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1660
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1661
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1662
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1663
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1664
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1665
|
+
],
|
|
1666
|
+
],
|
|
1667
|
+
];
|
|
1668
|
+
|
|
1669
|
+
examples.forEach(([expected, actual]) => {
|
|
1670
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1671
|
+
expect(subDataService.morphoBlueLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1672
|
+
});
|
|
1673
|
+
});
|
|
1674
|
+
});
|
|
1675
|
+
});
|
|
1676
|
+
|
|
1371
1677
|
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1372
1678
|
describe('encode()', () => {
|
|
1373
1679
|
const examples: Array<[SubData, [collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number]]> = [
|