@defisaver/automation-sdk 3.3.16-liq-prot-dev → 3.3.17
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 +42 -117
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +2 -5
- package/cjs/services/strategiesService.js +21 -160
- package/cjs/services/strategySubService.d.ts +21 -18
- package/cjs/services/strategySubService.js +74 -78
- package/cjs/services/strategySubService.test.js +149 -3
- package/cjs/services/subDataService.d.ts +20 -70
- package/cjs/services/subDataService.js +79 -23
- package/cjs/services/subDataService.test.js +202 -17
- package/cjs/services/utils.d.ts +1 -2
- package/cjs/services/utils.js +1 -14
- package/cjs/types/enums.d.ts +17 -36
- package/cjs/types/enums.js +11 -30
- package/esm/constants/index.js +42 -117
- package/esm/index.d.ts +2 -2
- package/esm/index.js +2 -5
- package/esm/services/strategiesService.js +21 -160
- package/esm/services/strategySubService.d.ts +21 -18
- package/esm/services/strategySubService.js +73 -78
- package/esm/services/strategySubService.test.js +147 -4
- package/esm/services/subDataService.d.ts +20 -70
- package/esm/services/subDataService.js +77 -21
- package/esm/services/subDataService.test.js +200 -18
- package/esm/services/utils.d.ts +1 -2
- package/esm/services/utils.js +1 -13
- package/esm/types/enums.d.ts +17 -36
- package/esm/types/enums.js +11 -30
- package/package.json +1 -1
- package/src/constants/index.ts +43 -119
- package/src/index.ts +6 -22
- package/src/services/strategiesService.ts +23 -225
- package/src/services/strategySubService.test.ts +191 -3
- package/src/services/strategySubService.ts +121 -173
- package/src/services/subDataService.test.ts +214 -18
- package/src/services/subDataService.ts +106 -42
- package/src/services/utils.test.ts +1 -1
- package/src/services/utils.ts +1 -15
- package/src/types/enums.ts +13 -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
|
});
|
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,18 +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,
|
|
243
|
-
MORPHO_BLUE_REPAY_ON_PRICE = 84
|
|
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
|
|
244
232
|
}
|
|
245
233
|
enum OptimismIds {
|
|
246
234
|
AAVE_V3_REPAY = 0,
|
|
@@ -253,9 +241,7 @@ export declare namespace Bundles {
|
|
|
253
241
|
AAVE_V3_EOA_BOOST = 7,
|
|
254
242
|
AAVE_V3_EOA_REPAY_ON_PRICE = 8,
|
|
255
243
|
AAVE_V3_EOA_BOOST_ON_PRICE = 9,
|
|
256
|
-
AAVE_V3_EOA_CLOSE = 10
|
|
257
|
-
AAVE_V3_SW_LIQUIDATION_PROTECTION = 11,
|
|
258
|
-
AAVE_V3_EOA_LIQUIDATION_PROTECTION = 12
|
|
244
|
+
AAVE_V3_EOA_CLOSE = 10
|
|
259
245
|
}
|
|
260
246
|
enum BaseIds {
|
|
261
247
|
AAVE_V3_REPAY = 0,
|
|
@@ -285,13 +271,12 @@ export declare namespace Bundles {
|
|
|
285
271
|
AAVE_V3_EOA_BOOST_ON_PRICE = 26,
|
|
286
272
|
AAVE_V3_EOA_CLOSE = 27,
|
|
287
273
|
MORPHO_BLUE_CLOSE = 28,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
MORPHO_BLUE_REPAY_ON_PRICE = 36
|
|
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
|
|
295
280
|
}
|
|
296
281
|
enum ArbitrumIds {
|
|
297
282
|
AAVE_V3_REPAY = 0,
|
|
@@ -323,13 +308,9 @@ export declare namespace Bundles {
|
|
|
323
308
|
MORPHO_BLUE_EOA_REPAY = 26,
|
|
324
309
|
MORPHO_BLUE_EOA_BOOST = 27,
|
|
325
310
|
MORPHO_BLUE_CLOSE = 28,
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
COMP_V3_EOA_LIQUIDATION_PROTECTION = 33,
|
|
331
|
-
AAVE_V3_EOA_LIQUIDATION_PROTECTION = 34,
|
|
332
|
-
MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION = 35,
|
|
333
|
-
MORPHO_BLUE_REPAY_ON_PRICE = 36
|
|
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
|
|
334
315
|
}
|
|
335
316
|
}
|
package/cjs/types/enums.js
CHANGED
|
@@ -159,8 +159,6 @@ var Strategies;
|
|
|
159
159
|
Identifiers["EoaRepayOnPrice"] = "eoa-repay-on-price";
|
|
160
160
|
Identifiers["CollateralSwitch"] = "collateral-switch";
|
|
161
161
|
Identifiers["EoaCollateralSwitch"] = "eoa-collateral-switch";
|
|
162
|
-
Identifiers["LiquidationProtection"] = "liquidation-protection";
|
|
163
|
-
Identifiers["EoaLiquidationProtection"] = "liquidation-protection-eoa";
|
|
164
162
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
|
165
163
|
let IdOverrides;
|
|
166
164
|
(function (IdOverrides) {
|
|
@@ -173,8 +171,6 @@ var Strategies;
|
|
|
173
171
|
IdOverrides["EoaLeverageManagement"] = "leverage-management-eoa";
|
|
174
172
|
IdOverrides["LeverageManagementOnPrice"] = "leverage-management-on-price";
|
|
175
173
|
IdOverrides["EoaLeverageManagementOnPrice"] = "leverage-management-on-price-eoa";
|
|
176
|
-
IdOverrides["LiquidationProtection"] = "liquidation-protection";
|
|
177
|
-
IdOverrides["EoaLiquidationProtection"] = "liquidation-protection-eoa";
|
|
178
174
|
})(IdOverrides = Strategies.IdOverrides || (Strategies.IdOverrides = {}));
|
|
179
175
|
})(Strategies = exports.Strategies || (exports.Strategies = {}));
|
|
180
176
|
var Bundles;
|
|
@@ -252,18 +248,10 @@ var Bundles;
|
|
|
252
248
|
MainnetIds[MainnetIds["AAVE_V4_EOA_REPAY_ON_PRICE"] = 68] = "AAVE_V4_EOA_REPAY_ON_PRICE";
|
|
253
249
|
MainnetIds[MainnetIds["AAVE_V4_EOA_BOOST_ON_PRICE"] = 69] = "AAVE_V4_EOA_BOOST_ON_PRICE";
|
|
254
250
|
MainnetIds[MainnetIds["AAVE_V4_EOA_CLOSE"] = 70] = "AAVE_V4_EOA_CLOSE";
|
|
255
|
-
MainnetIds[MainnetIds["AAVE_V3_SW_LIQUIDATION_PROTECTION"] = 71] = "AAVE_V3_SW_LIQUIDATION_PROTECTION";
|
|
256
|
-
MainnetIds[MainnetIds["SPARK_SW_LIQUIDATION_PROTECTION"] = 72] = "SPARK_SW_LIQUIDATION_PROTECTION";
|
|
257
|
-
MainnetIds[MainnetIds["MAKER_SW_LIQUIDATION_PROTECTION"] = 75] = "MAKER_SW_LIQUIDATION_PROTECTION";
|
|
258
|
-
MainnetIds[MainnetIds["FLUID_T1_SW_LIQUIDATION_PROTECTION"] = 76] = "FLUID_T1_SW_LIQUIDATION_PROTECTION";
|
|
259
|
-
MainnetIds[MainnetIds["AAVE_V4_SW_LIQUIDATION_PROTECTION"] = 77] = "AAVE_V4_SW_LIQUIDATION_PROTECTION";
|
|
260
|
-
MainnetIds[MainnetIds["MORPHO_BLUE_SW_LIQUIDATION_PROTECTION"] = 78] = "MORPHO_BLUE_SW_LIQUIDATION_PROTECTION";
|
|
261
|
-
MainnetIds[MainnetIds["AAVE_V3_EOA_LIQUIDATION_PROTECTION"] = 79] = "AAVE_V3_EOA_LIQUIDATION_PROTECTION";
|
|
262
|
-
MainnetIds[MainnetIds["AAVE_V4_EOA_LIQUIDATION_PROTECTION"] = 80] = "AAVE_V4_EOA_LIQUIDATION_PROTECTION";
|
|
263
|
-
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION"] = 81] = "MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION";
|
|
264
|
-
MainnetIds[MainnetIds["COMP_V3_SW_LIQUIDATION_PROTECTION"] = 82] = "COMP_V3_SW_LIQUIDATION_PROTECTION";
|
|
265
|
-
MainnetIds[MainnetIds["COMP_V3_EOA_LIQUIDATION_PROTECTION"] = 83] = "COMP_V3_EOA_LIQUIDATION_PROTECTION";
|
|
266
251
|
MainnetIds[MainnetIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 84] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
252
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_BOOST_ON_PRICE"] = 85] = "MORPHO_BLUE_EOA_BOOST_ON_PRICE";
|
|
253
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_REPAY_ON_PRICE"] = 86] = "MORPHO_BLUE_EOA_REPAY_ON_PRICE";
|
|
254
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_EOA_CLOSE"] = 87] = "MORPHO_BLUE_EOA_CLOSE";
|
|
267
255
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
268
256
|
let OptimismIds;
|
|
269
257
|
(function (OptimismIds) {
|
|
@@ -278,8 +266,6 @@ var Bundles;
|
|
|
278
266
|
OptimismIds[OptimismIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 8] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
279
267
|
OptimismIds[OptimismIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 9] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
280
268
|
OptimismIds[OptimismIds["AAVE_V3_EOA_CLOSE"] = 10] = "AAVE_V3_EOA_CLOSE";
|
|
281
|
-
OptimismIds[OptimismIds["AAVE_V3_SW_LIQUIDATION_PROTECTION"] = 11] = "AAVE_V3_SW_LIQUIDATION_PROTECTION";
|
|
282
|
-
OptimismIds[OptimismIds["AAVE_V3_EOA_LIQUIDATION_PROTECTION"] = 12] = "AAVE_V3_EOA_LIQUIDATION_PROTECTION";
|
|
283
269
|
})(OptimismIds = Bundles.OptimismIds || (Bundles.OptimismIds = {}));
|
|
284
270
|
let BaseIds;
|
|
285
271
|
(function (BaseIds) {
|
|
@@ -310,13 +296,12 @@ var Bundles;
|
|
|
310
296
|
BaseIds[BaseIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 26] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
311
297
|
BaseIds[BaseIds["AAVE_V3_EOA_CLOSE"] = 27] = "AAVE_V3_EOA_CLOSE";
|
|
312
298
|
BaseIds[BaseIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
313
|
-
BaseIds[BaseIds["AAVE_V3_SW_LIQUIDATION_PROTECTION"] = 29] = "AAVE_V3_SW_LIQUIDATION_PROTECTION";
|
|
314
|
-
BaseIds[BaseIds["FLUID_T1_SW_LIQUIDATION_PROTECTION"] = 30] = "FLUID_T1_SW_LIQUIDATION_PROTECTION";
|
|
315
|
-
BaseIds[BaseIds["COMP_V3_SW_LIQUIDATION_PROTECTION"] = 32] = "COMP_V3_SW_LIQUIDATION_PROTECTION";
|
|
316
|
-
BaseIds[BaseIds["COMP_V3_EOA_LIQUIDATION_PROTECTION"] = 33] = "COMP_V3_EOA_LIQUIDATION_PROTECTION";
|
|
317
|
-
BaseIds[BaseIds["AAVE_V3_EOA_LIQUIDATION_PROTECTION"] = 34] = "AAVE_V3_EOA_LIQUIDATION_PROTECTION";
|
|
318
|
-
BaseIds[BaseIds["MORPHO_BLUE_SW_LIQUIDATION_PROTECTION"] = 35] = "MORPHO_BLUE_SW_LIQUIDATION_PROTECTION";
|
|
319
299
|
BaseIds[BaseIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 36] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
300
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_REPAY"] = 37] = "MORPHO_BLUE_EOA_REPAY";
|
|
301
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_BOOST"] = 38] = "MORPHO_BLUE_EOA_BOOST";
|
|
302
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_BOOST_ON_PRICE"] = 39] = "MORPHO_BLUE_EOA_BOOST_ON_PRICE";
|
|
303
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_REPAY_ON_PRICE"] = 40] = "MORPHO_BLUE_EOA_REPAY_ON_PRICE";
|
|
304
|
+
BaseIds[BaseIds["MORPHO_BLUE_EOA_CLOSE"] = 41] = "MORPHO_BLUE_EOA_CLOSE";
|
|
320
305
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
321
306
|
let ArbitrumIds;
|
|
322
307
|
(function (ArbitrumIds) {
|
|
@@ -349,13 +334,9 @@ var Bundles;
|
|
|
349
334
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_REPAY"] = 26] = "MORPHO_BLUE_EOA_REPAY";
|
|
350
335
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_BOOST"] = 27] = "MORPHO_BLUE_EOA_BOOST";
|
|
351
336
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
352
|
-
ArbitrumIds[ArbitrumIds["AAVE_V3_SW_LIQUIDATION_PROTECTION"] = 29] = "AAVE_V3_SW_LIQUIDATION_PROTECTION";
|
|
353
|
-
ArbitrumIds[ArbitrumIds["FLUID_T1_SW_LIQUIDATION_PROTECTION"] = 30] = "FLUID_T1_SW_LIQUIDATION_PROTECTION";
|
|
354
|
-
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_SW_LIQUIDATION_PROTECTION"] = 31] = "MORPHO_BLUE_SW_LIQUIDATION_PROTECTION";
|
|
355
|
-
ArbitrumIds[ArbitrumIds["COMP_V3_SW_LIQUIDATION_PROTECTION"] = 32] = "COMP_V3_SW_LIQUIDATION_PROTECTION";
|
|
356
|
-
ArbitrumIds[ArbitrumIds["COMP_V3_EOA_LIQUIDATION_PROTECTION"] = 33] = "COMP_V3_EOA_LIQUIDATION_PROTECTION";
|
|
357
|
-
ArbitrumIds[ArbitrumIds["AAVE_V3_EOA_LIQUIDATION_PROTECTION"] = 34] = "AAVE_V3_EOA_LIQUIDATION_PROTECTION";
|
|
358
|
-
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION"] = 35] = "MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION";
|
|
359
337
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 36] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
338
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_BOOST_ON_PRICE"] = 37] = "MORPHO_BLUE_EOA_BOOST_ON_PRICE";
|
|
339
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_REPAY_ON_PRICE"] = 38] = "MORPHO_BLUE_EOA_REPAY_ON_PRICE";
|
|
340
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_CLOSE"] = 39] = "MORPHO_BLUE_EOA_CLOSE";
|
|
360
341
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
361
342
|
})(Bundles = exports.Bundles || (exports.Bundles = {}));
|