@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
|
@@ -22,7 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
26
30
|
const chai_1 = require("chai");
|
|
27
31
|
const tokens_1 = require("@defisaver/tokens");
|
|
28
32
|
const web3Utils = __importStar(require("web3-utils"));
|
|
@@ -142,7 +146,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
142
146
|
});
|
|
143
147
|
});
|
|
144
148
|
});
|
|
145
|
-
describe('When testing subDataService.
|
|
149
|
+
describe('When testing subDataService.makerLeverageManagementSubData', () => {
|
|
146
150
|
describe('decode()', () => {
|
|
147
151
|
const examples = [
|
|
148
152
|
[
|
|
@@ -155,12 +159,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
155
159
|
];
|
|
156
160
|
examples.forEach(([expected, actual]) => {
|
|
157
161
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
158
|
-
(0, chai_1.expect)(subDataService.
|
|
162
|
+
(0, chai_1.expect)(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
159
163
|
});
|
|
160
164
|
});
|
|
161
165
|
});
|
|
162
166
|
});
|
|
163
|
-
describe('When testing subDataService.
|
|
167
|
+
describe('When testing subDataService.makerLeverageManagementWithoutSubProxy', () => {
|
|
164
168
|
describe('encode()', () => {
|
|
165
169
|
const examples = [
|
|
166
170
|
[
|
|
@@ -180,7 +184,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
180
184
|
];
|
|
181
185
|
examples.forEach(([expected, actual]) => {
|
|
182
186
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
183
|
-
(0, chai_1.expect)(subDataService.
|
|
187
|
+
(0, chai_1.expect)(subDataService.makerLeverageManagementWithoutSubProxy.encode(...actual)).to.eql(expected);
|
|
184
188
|
});
|
|
185
189
|
});
|
|
186
190
|
});
|
|
@@ -211,12 +215,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
211
215
|
];
|
|
212
216
|
examples.forEach(([expected, actual]) => {
|
|
213
217
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
214
|
-
(0, chai_1.expect)(subDataService.
|
|
218
|
+
(0, chai_1.expect)(subDataService.makerLeverageManagementWithoutSubProxy.decode(actual)).to.eql(expected);
|
|
215
219
|
});
|
|
216
220
|
});
|
|
217
221
|
});
|
|
218
222
|
});
|
|
219
|
-
describe('When testing subDataService.
|
|
223
|
+
describe('When testing subDataService.liquityLeverageManagementSubData', () => {
|
|
220
224
|
describe('decode()', () => {
|
|
221
225
|
const examples = [
|
|
222
226
|
[
|
|
@@ -229,7 +233,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
229
233
|
];
|
|
230
234
|
examples.forEach(([expected, actual]) => {
|
|
231
235
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
232
|
-
(0, chai_1.expect)(subDataService.
|
|
236
|
+
(0, chai_1.expect)(subDataService.liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
233
237
|
});
|
|
234
238
|
});
|
|
235
239
|
});
|
|
@@ -284,7 +288,24 @@ describe('Feature: subDataService.ts', () => {
|
|
|
284
288
|
});
|
|
285
289
|
});
|
|
286
290
|
});
|
|
287
|
-
describe('When testing subDataService.
|
|
291
|
+
describe('When testing subDataService.aaveV2LeverageManagementSubData', () => {
|
|
292
|
+
describe('encode()', () => {
|
|
293
|
+
const examples = [
|
|
294
|
+
[
|
|
295
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
296
|
+
[160, 220, 180, 190, true]
|
|
297
|
+
],
|
|
298
|
+
[
|
|
299
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
300
|
+
[160, 200, 180, 190, false]
|
|
301
|
+
],
|
|
302
|
+
];
|
|
303
|
+
examples.forEach(([expected, actual]) => {
|
|
304
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
305
|
+
(0, chai_1.expect)(subDataService.aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
});
|
|
288
309
|
describe('decode()', () => {
|
|
289
310
|
const examples = [
|
|
290
311
|
[
|
|
@@ -298,12 +319,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
298
319
|
];
|
|
299
320
|
examples.forEach(([expected, actual]) => {
|
|
300
321
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
301
|
-
(0, chai_1.expect)(subDataService.
|
|
322
|
+
(0, chai_1.expect)(subDataService.aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
302
323
|
});
|
|
303
324
|
});
|
|
304
325
|
});
|
|
305
326
|
});
|
|
306
|
-
describe('When testing subDataService.
|
|
327
|
+
describe('When testing subDataService.aaveV3LeverageManagementSubData', () => {
|
|
307
328
|
describe('decode()', () => {
|
|
308
329
|
const examples = [
|
|
309
330
|
[
|
|
@@ -317,7 +338,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
317
338
|
];
|
|
318
339
|
examples.forEach(([expected, actual]) => {
|
|
319
340
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
320
|
-
(0, chai_1.expect)(subDataService.
|
|
341
|
+
(0, chai_1.expect)(subDataService.aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
321
342
|
});
|
|
322
343
|
});
|
|
323
344
|
});
|
|
@@ -656,7 +677,24 @@ describe('Feature: subDataService.ts', () => {
|
|
|
656
677
|
});
|
|
657
678
|
});
|
|
658
679
|
});
|
|
659
|
-
describe('When testing subDataService.
|
|
680
|
+
describe('When testing subDataService.compoundV2LeverageManagementSubData', () => {
|
|
681
|
+
describe('encode()', () => {
|
|
682
|
+
const examples = [
|
|
683
|
+
[
|
|
684
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
685
|
+
[160, 220, 180, 190, true]
|
|
686
|
+
],
|
|
687
|
+
[
|
|
688
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
689
|
+
[160, 200, 180, 190, false]
|
|
690
|
+
],
|
|
691
|
+
];
|
|
692
|
+
examples.forEach(([expected, actual]) => {
|
|
693
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
694
|
+
(0, chai_1.expect)(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
695
|
+
});
|
|
696
|
+
});
|
|
697
|
+
});
|
|
660
698
|
describe('decode()', () => {
|
|
661
699
|
const examples = [
|
|
662
700
|
[
|
|
@@ -670,12 +708,97 @@ describe('Feature: subDataService.ts', () => {
|
|
|
670
708
|
];
|
|
671
709
|
examples.forEach(([expected, actual]) => {
|
|
672
710
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
673
|
-
(0, chai_1.expect)(subDataService.
|
|
711
|
+
(0, chai_1.expect)(subDataService.compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
712
|
+
});
|
|
713
|
+
});
|
|
714
|
+
});
|
|
715
|
+
});
|
|
716
|
+
describe('When testing subDataService.compoundV3LeverageManagementSubData', () => {
|
|
717
|
+
describe('encode()', () => {
|
|
718
|
+
const examples = [
|
|
719
|
+
[
|
|
720
|
+
[
|
|
721
|
+
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
722
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
723
|
+
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
724
|
+
new decimal_js_1.default(220).mul(1e16).toString(),
|
|
725
|
+
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
726
|
+
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
727
|
+
true, false,
|
|
728
|
+
],
|
|
729
|
+
[
|
|
730
|
+
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
731
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
732
|
+
160, 220, 180, 190,
|
|
733
|
+
true, false,
|
|
734
|
+
]
|
|
735
|
+
],
|
|
736
|
+
[
|
|
737
|
+
[
|
|
738
|
+
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
739
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
740
|
+
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
741
|
+
new decimal_js_1.default(210).mul(1e16).toString(),
|
|
742
|
+
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
743
|
+
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
744
|
+
false, true,
|
|
745
|
+
],
|
|
746
|
+
[
|
|
747
|
+
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
748
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
749
|
+
160, 210, 180, 190,
|
|
750
|
+
false, true,
|
|
751
|
+
]
|
|
752
|
+
],
|
|
753
|
+
];
|
|
754
|
+
examples.forEach(([expected, actual]) => {
|
|
755
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
756
|
+
(0, chai_1.expect)(subDataService.compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
757
|
+
});
|
|
758
|
+
});
|
|
759
|
+
});
|
|
760
|
+
describe('decode()', () => {
|
|
761
|
+
const examples = [
|
|
762
|
+
[
|
|
763
|
+
{ targetRatio: 123 },
|
|
764
|
+
[
|
|
765
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
766
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
767
|
+
],
|
|
768
|
+
],
|
|
769
|
+
[
|
|
770
|
+
{ targetRatio: 200 },
|
|
771
|
+
[
|
|
772
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
773
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
774
|
+
],
|
|
775
|
+
],
|
|
776
|
+
];
|
|
777
|
+
examples.forEach(([expected, actual]) => {
|
|
778
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
779
|
+
(0, chai_1.expect)(subDataService.compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
674
780
|
});
|
|
675
781
|
});
|
|
676
782
|
});
|
|
677
783
|
});
|
|
678
784
|
describe('When testing subDataService.morphoAaveV2LeverageManagementSubData', () => {
|
|
785
|
+
describe('encode()', () => {
|
|
786
|
+
const examples = [
|
|
787
|
+
[
|
|
788
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
789
|
+
[160, 220, 180, 190, true]
|
|
790
|
+
],
|
|
791
|
+
[
|
|
792
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
793
|
+
[160, 200, 180, 190, false]
|
|
794
|
+
],
|
|
795
|
+
];
|
|
796
|
+
examples.forEach(([expected, actual]) => {
|
|
797
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
798
|
+
(0, chai_1.expect)(subDataService.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
799
|
+
});
|
|
800
|
+
});
|
|
801
|
+
});
|
|
679
802
|
describe('decode()', () => {
|
|
680
803
|
const examples = [
|
|
681
804
|
[
|
|
@@ -695,6 +818,23 @@ describe('Feature: subDataService.ts', () => {
|
|
|
695
818
|
});
|
|
696
819
|
});
|
|
697
820
|
describe('When testing subDataService.cBondsRebondSubData', () => {
|
|
821
|
+
describe('encode()', () => {
|
|
822
|
+
const examples = [
|
|
823
|
+
[
|
|
824
|
+
['0x00000000000000000000000000000000000000000000000000000000000000c8'],
|
|
825
|
+
[200]
|
|
826
|
+
],
|
|
827
|
+
[
|
|
828
|
+
['0x000000000000000000000000000000000000000000000000000000000000a119'],
|
|
829
|
+
[41241]
|
|
830
|
+
],
|
|
831
|
+
];
|
|
832
|
+
examples.forEach(([expected, actual]) => {
|
|
833
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
834
|
+
(0, chai_1.expect)(subDataService.cBondsRebondSubData.encode(...actual)).to.eql(expected);
|
|
835
|
+
});
|
|
836
|
+
});
|
|
837
|
+
});
|
|
698
838
|
describe('decode()', () => {
|
|
699
839
|
const examples = [
|
|
700
840
|
[
|
|
@@ -835,7 +975,52 @@ describe('Feature: subDataService.ts', () => {
|
|
|
835
975
|
});
|
|
836
976
|
});
|
|
837
977
|
});
|
|
838
|
-
describe('When testing subDataService.
|
|
978
|
+
describe('When testing subDataService.exchangeLimitOrderSubData', () => {
|
|
979
|
+
describe('encode()', () => {
|
|
980
|
+
const examples = [
|
|
981
|
+
[
|
|
982
|
+
[
|
|
983
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
984
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
985
|
+
'2131',
|
|
986
|
+
'0.53123',
|
|
987
|
+
'1696590921159',
|
|
988
|
+
`${enums_1.OrderType.STOP_LOSS}`
|
|
989
|
+
],
|
|
990
|
+
[
|
|
991
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
992
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
993
|
+
'2131',
|
|
994
|
+
'0.53123',
|
|
995
|
+
1696590921159,
|
|
996
|
+
enums_1.OrderType.STOP_LOSS
|
|
997
|
+
]
|
|
998
|
+
],
|
|
999
|
+
[
|
|
1000
|
+
[
|
|
1001
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
1002
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
1003
|
+
'2131',
|
|
1004
|
+
'0.43123',
|
|
1005
|
+
'1646590921159',
|
|
1006
|
+
`${enums_1.OrderType.TAKE_PROFIT}`
|
|
1007
|
+
],
|
|
1008
|
+
[
|
|
1009
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
1010
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
1011
|
+
'2131',
|
|
1012
|
+
'0.43123',
|
|
1013
|
+
1646590921159,
|
|
1014
|
+
enums_1.OrderType.TAKE_PROFIT
|
|
1015
|
+
]
|
|
1016
|
+
],
|
|
1017
|
+
];
|
|
1018
|
+
examples.forEach(([expected, actual]) => {
|
|
1019
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1020
|
+
(0, chai_1.expect)(subDataService.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
|
|
1021
|
+
});
|
|
1022
|
+
});
|
|
1023
|
+
});
|
|
839
1024
|
describe('decode()', () => {
|
|
840
1025
|
const examples = [
|
|
841
1026
|
[
|
|
@@ -869,12 +1054,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
869
1054
|
];
|
|
870
1055
|
examples.forEach(([expected, actual]) => {
|
|
871
1056
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
872
|
-
(0, chai_1.expect)(subDataService.
|
|
1057
|
+
(0, chai_1.expect)(subDataService.exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
|
|
873
1058
|
});
|
|
874
1059
|
});
|
|
875
1060
|
});
|
|
876
1061
|
});
|
|
877
|
-
describe('When testing subDataService.
|
|
1062
|
+
describe('When testing subDataService.sparkLeverageManagementSubData', () => {
|
|
878
1063
|
describe('decode()', () => {
|
|
879
1064
|
const examples = [
|
|
880
1065
|
[
|
|
@@ -888,7 +1073,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
888
1073
|
];
|
|
889
1074
|
examples.forEach(([expected, actual]) => {
|
|
890
1075
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
891
|
-
(0, chai_1.expect)(subDataService.
|
|
1076
|
+
(0, chai_1.expect)(subDataService.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
892
1077
|
});
|
|
893
1078
|
});
|
|
894
1079
|
});
|
|
@@ -1294,6 +1479,106 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1294
1479
|
});
|
|
1295
1480
|
});
|
|
1296
1481
|
});
|
|
1482
|
+
describe('When testing subDataService.morphoBlueLeverageManagementOnPriceSubData', () => {
|
|
1483
|
+
describe('encode()', () => {
|
|
1484
|
+
const examples = [
|
|
1485
|
+
[
|
|
1486
|
+
[
|
|
1487
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1488
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1489
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1490
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1491
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1492
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1493
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1494
|
+
],
|
|
1495
|
+
[
|
|
1496
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1497
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1498
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1499
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1500
|
+
'945000000000000000',
|
|
1501
|
+
200,
|
|
1502
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1503
|
+
],
|
|
1504
|
+
],
|
|
1505
|
+
[
|
|
1506
|
+
[
|
|
1507
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1508
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1509
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1510
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1511
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1512
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1513
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1514
|
+
],
|
|
1515
|
+
[
|
|
1516
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1517
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1518
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1519
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1520
|
+
'945000000000000000',
|
|
1521
|
+
160,
|
|
1522
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1523
|
+
],
|
|
1524
|
+
],
|
|
1525
|
+
];
|
|
1526
|
+
examples.forEach(([expected, actual]) => {
|
|
1527
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1528
|
+
(0, chai_1.expect)(subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1529
|
+
});
|
|
1530
|
+
});
|
|
1531
|
+
});
|
|
1532
|
+
describe('decode()', () => {
|
|
1533
|
+
const examples = [
|
|
1534
|
+
[
|
|
1535
|
+
{
|
|
1536
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1537
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1538
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1539
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1540
|
+
lltv: '945000000000000000',
|
|
1541
|
+
targetRatio: 200,
|
|
1542
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1543
|
+
},
|
|
1544
|
+
[
|
|
1545
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1546
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1547
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1548
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1549
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1550
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1551
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1552
|
+
],
|
|
1553
|
+
],
|
|
1554
|
+
[
|
|
1555
|
+
{
|
|
1556
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1557
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1558
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1559
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1560
|
+
lltv: '945000000000000000',
|
|
1561
|
+
targetRatio: 160,
|
|
1562
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1563
|
+
},
|
|
1564
|
+
[
|
|
1565
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1566
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1567
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1568
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1569
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1570
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1571
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1572
|
+
],
|
|
1573
|
+
],
|
|
1574
|
+
];
|
|
1575
|
+
examples.forEach(([expected, actual]) => {
|
|
1576
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1577
|
+
(0, chai_1.expect)(subDataService.morphoBlueLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1578
|
+
});
|
|
1579
|
+
});
|
|
1580
|
+
});
|
|
1581
|
+
});
|
|
1297
1582
|
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1298
1583
|
describe('encode()', () => {
|
|
1299
1584
|
const examples = [
|
|
@@ -1184,6 +1184,66 @@ describe('Feature: triggerService.ts', () => {
|
|
|
1184
1184
|
});
|
|
1185
1185
|
});
|
|
1186
1186
|
});
|
|
1187
|
+
describe('When testing triggerService.morphoBluePriceTrigger', () => {
|
|
1188
|
+
describe('encode()', () => {
|
|
1189
|
+
const examples = [
|
|
1190
|
+
[
|
|
1191
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1192
|
+
[
|
|
1193
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1194
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1195
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1196
|
+
2500,
|
|
1197
|
+
enums_1.RatioState.UNDER,
|
|
1198
|
+
],
|
|
1199
|
+
],
|
|
1200
|
+
[
|
|
1201
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1202
|
+
[
|
|
1203
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1204
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1205
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1206
|
+
4000,
|
|
1207
|
+
enums_1.RatioState.OVER,
|
|
1208
|
+
],
|
|
1209
|
+
],
|
|
1210
|
+
];
|
|
1211
|
+
examples.forEach(([expected, actual]) => {
|
|
1212
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1213
|
+
(0, chai_1.expect)(triggerService_1.morphoBluePriceTrigger.encode(...actual)).to.eql(expected);
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
});
|
|
1217
|
+
describe('decode()', () => {
|
|
1218
|
+
const examples = [
|
|
1219
|
+
[
|
|
1220
|
+
{
|
|
1221
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1222
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1223
|
+
loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1224
|
+
price: '2500',
|
|
1225
|
+
priceState: enums_1.RatioState.UNDER,
|
|
1226
|
+
},
|
|
1227
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1228
|
+
],
|
|
1229
|
+
[
|
|
1230
|
+
{
|
|
1231
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1232
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1233
|
+
loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1234
|
+
price: '4000',
|
|
1235
|
+
priceState: enums_1.RatioState.OVER,
|
|
1236
|
+
},
|
|
1237
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1238
|
+
],
|
|
1239
|
+
];
|
|
1240
|
+
examples.forEach(([expected, actual]) => {
|
|
1241
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1242
|
+
(0, chai_1.expect)(triggerService_1.morphoBluePriceTrigger.decode(actual)).to.eql(expected);
|
|
1243
|
+
});
|
|
1244
|
+
});
|
|
1245
|
+
});
|
|
1246
|
+
});
|
|
1187
1247
|
describe('When testing triggerService.aaveV4RatioTrigger', () => {
|
|
1188
1248
|
describe('encode()', () => {
|
|
1189
1249
|
const examples = [
|
package/cjs/services/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EthereumAddress } from '../types';
|
|
2
|
-
import {
|
|
2
|
+
import { ChainId, CloseStrategyType, CloseToAssetType, RatioState } from '../types/enums';
|
|
3
3
|
export declare function isDefined<T>(value: T): value is NonNullable<T>;
|
|
4
4
|
export declare function isUndefined(value: unknown): boolean;
|
|
5
5
|
export declare function compareAddresses(firstAddress: EthereumAddress, secondAddress: EthereumAddress): boolean;
|
|
@@ -28,4 +28,3 @@ export declare function getStopLossAndTakeProfitTypeByCloseStrategyType(closeStr
|
|
|
28
28
|
stopLossType: CloseToAssetType | undefined;
|
|
29
29
|
takeProfitType: CloseToAssetType | undefined;
|
|
30
30
|
};
|
|
31
|
-
export declare function getBundleIdsByNetwork(network: ChainId): typeof Bundles.MainnetIds | typeof Bundles.ArbitrumIds | typeof Bundles.BaseIds;
|
package/cjs/services/utils.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.getStopLossAndTakeProfitTypeByCloseStrategyType = exports.getCloseStrategyType = exports.getPositionId = exports.getRatioStateInfoForAaveCloseStrategy = exports.requireAddresses = exports.requireAddress = exports.isEmptyBytes = exports.isRatioStateUnder = exports.isRatioStateOver = exports.weiToRatioPercentage = exports.ratioPercentageToWei = exports.encodeSubId = exports.compareSubHashes = exports.wethToEthByAddress = exports.wethToEth = exports.ethToWeth = exports.addToObjectIf = exports.addToArrayIf = exports.isAddress = exports.compareAddresses = exports.isUndefined = exports.isDefined = void 0;
|
|
30
30
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
31
31
|
const web3Utils = __importStar(require("web3-utils"));
|
|
32
32
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
@@ -188,16 +188,3 @@ function getStopLossAndTakeProfitTypeByCloseStrategyType(closeStrategyType) {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
exports.getStopLossAndTakeProfitTypeByCloseStrategyType = getStopLossAndTakeProfitTypeByCloseStrategyType;
|
|
191
|
-
function getBundleIdsByNetwork(network) {
|
|
192
|
-
switch (Number(network)) {
|
|
193
|
-
case enums_1.ChainId.Ethereum:
|
|
194
|
-
return enums_1.Bundles.MainnetIds;
|
|
195
|
-
case enums_1.ChainId.Arbitrum:
|
|
196
|
-
return enums_1.Bundles.ArbitrumIds;
|
|
197
|
-
case enums_1.ChainId.Base:
|
|
198
|
-
return enums_1.Bundles.BaseIds;
|
|
199
|
-
default:
|
|
200
|
-
throw new Error(`Unsupported network ${network}`);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
exports.getBundleIdsByNetwork = getBundleIdsByNetwork;
|
package/cjs/types/enums.d.ts
CHANGED
|
@@ -138,9 +138,7 @@ export declare namespace Strategies {
|
|
|
138
138
|
EoaBoostOnPrice = "eoa-boost-on-price",
|
|
139
139
|
EoaRepayOnPrice = "eoa-repay-on-price",
|
|
140
140
|
CollateralSwitch = "collateral-switch",
|
|
141
|
-
EoaCollateralSwitch = "eoa-collateral-switch"
|
|
142
|
-
LiquidationProtection = "liquidation-protection",
|
|
143
|
-
EoaLiquidationProtection = "liquidation-protection-eoa"
|
|
141
|
+
EoaCollateralSwitch = "eoa-collateral-switch"
|
|
144
142
|
}
|
|
145
143
|
enum IdOverrides {
|
|
146
144
|
TakeProfit = "take-profit",
|
|
@@ -151,9 +149,7 @@ export declare namespace Strategies {
|
|
|
151
149
|
LeverageManagement = "leverage-management",
|
|
152
150
|
EoaLeverageManagement = "leverage-management-eoa",
|
|
153
151
|
LeverageManagementOnPrice = "leverage-management-on-price",
|
|
154
|
-
EoaLeverageManagementOnPrice = "leverage-management-on-price-eoa"
|
|
155
|
-
LiquidationProtection = "liquidation-protection",
|
|
156
|
-
EoaLiquidationProtection = "liquidation-protection-eoa"
|
|
152
|
+
EoaLeverageManagementOnPrice = "leverage-management-on-price-eoa"
|
|
157
153
|
}
|
|
158
154
|
}
|
|
159
155
|
export declare namespace Bundles {
|
|
@@ -229,17 +225,10 @@ export declare namespace Bundles {
|
|
|
229
225
|
AAVE_V4_EOA_REPAY_ON_PRICE = 68,
|
|
230
226
|
AAVE_V4_EOA_BOOST_ON_PRICE = 69,
|
|
231
227
|
AAVE_V4_EOA_CLOSE = 70,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
AAVE_V4_SW_LIQUIDATION_PROTECTION = 77,
|
|
237
|
-
MORPHO_BLUE_SW_LIQUIDATION_PROTECTION = 78,
|
|
238
|
-
AAVE_V3_EOA_LIQUIDATION_PROTECTION = 79,
|
|
239
|
-
AAVE_V4_EOA_LIQUIDATION_PROTECTION = 80,
|
|
240
|
-
MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION = 81,
|
|
241
|
-
COMP_V3_SW_LIQUIDATION_PROTECTION = 82,
|
|
242
|
-
COMP_V3_EOA_LIQUIDATION_PROTECTION = 83
|
|
228
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 84,
|
|
229
|
+
MORPHO_BLUE_EOA_BOOST_ON_PRICE = 85,
|
|
230
|
+
MORPHO_BLUE_EOA_REPAY_ON_PRICE = 86,
|
|
231
|
+
MORPHO_BLUE_EOA_CLOSE = 87
|
|
243
232
|
}
|
|
244
233
|
enum OptimismIds {
|
|
245
234
|
AAVE_V3_REPAY = 0,
|
|
@@ -252,9 +241,7 @@ export declare namespace Bundles {
|
|
|
252
241
|
AAVE_V3_EOA_BOOST = 7,
|
|
253
242
|
AAVE_V3_EOA_REPAY_ON_PRICE = 8,
|
|
254
243
|
AAVE_V3_EOA_BOOST_ON_PRICE = 9,
|
|
255
|
-
AAVE_V3_EOA_CLOSE = 10
|
|
256
|
-
AAVE_V3_SW_LIQUIDATION_PROTECTION = 11,
|
|
257
|
-
AAVE_V3_EOA_LIQUIDATION_PROTECTION = 12
|
|
244
|
+
AAVE_V3_EOA_CLOSE = 10
|
|
258
245
|
}
|
|
259
246
|
enum BaseIds {
|
|
260
247
|
AAVE_V3_REPAY = 0,
|
|
@@ -284,12 +271,12 @@ export declare namespace Bundles {
|
|
|
284
271
|
AAVE_V3_EOA_BOOST_ON_PRICE = 26,
|
|
285
272
|
AAVE_V3_EOA_CLOSE = 27,
|
|
286
273
|
MORPHO_BLUE_CLOSE = 28,
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
274
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 36,
|
|
275
|
+
MORPHO_BLUE_EOA_REPAY = 37,
|
|
276
|
+
MORPHO_BLUE_EOA_BOOST = 38,
|
|
277
|
+
MORPHO_BLUE_EOA_BOOST_ON_PRICE = 39,
|
|
278
|
+
MORPHO_BLUE_EOA_REPAY_ON_PRICE = 40,
|
|
279
|
+
MORPHO_BLUE_EOA_CLOSE = 41
|
|
293
280
|
}
|
|
294
281
|
enum ArbitrumIds {
|
|
295
282
|
AAVE_V3_REPAY = 0,
|
|
@@ -321,12 +308,9 @@ export declare namespace Bundles {
|
|
|
321
308
|
MORPHO_BLUE_EOA_REPAY = 26,
|
|
322
309
|
MORPHO_BLUE_EOA_BOOST = 27,
|
|
323
310
|
MORPHO_BLUE_CLOSE = 28,
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
COMP_V3_EOA_LIQUIDATION_PROTECTION = 33,
|
|
329
|
-
AAVE_V3_EOA_LIQUIDATION_PROTECTION = 34,
|
|
330
|
-
MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION = 35
|
|
311
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 36,
|
|
312
|
+
MORPHO_BLUE_EOA_BOOST_ON_PRICE = 37,
|
|
313
|
+
MORPHO_BLUE_EOA_REPAY_ON_PRICE = 38,
|
|
314
|
+
MORPHO_BLUE_EOA_CLOSE = 39
|
|
331
315
|
}
|
|
332
316
|
}
|