@defisaver/automation-sdk 3.3.16-dev-13082-morpho-eoa-dev → 3.3.16-liq-prot-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/constants/index.js +117 -42
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +5 -2
- package/cjs/services/strategiesService.js +157 -12
- package/cjs/services/strategySubService.d.ts +18 -21
- package/cjs/services/strategySubService.js +78 -74
- package/cjs/services/strategySubService.test.js +3 -149
- package/cjs/services/subDataService.d.ts +70 -20
- package/cjs/services/subDataService.js +23 -79
- package/cjs/services/subDataService.test.js +17 -202
- package/cjs/services/utils.d.ts +2 -1
- package/cjs/services/utils.js +14 -1
- package/cjs/types/enums.d.ts +36 -17
- package/cjs/types/enums.js +30 -11
- package/esm/constants/index.js +117 -42
- package/esm/index.d.ts +2 -2
- package/esm/index.js +5 -2
- package/esm/services/strategiesService.js +157 -12
- package/esm/services/strategySubService.d.ts +18 -21
- package/esm/services/strategySubService.js +78 -73
- package/esm/services/strategySubService.test.js +4 -147
- package/esm/services/subDataService.d.ts +70 -20
- package/esm/services/subDataService.js +21 -77
- package/esm/services/subDataService.test.js +18 -200
- package/esm/services/utils.d.ts +2 -1
- package/esm/services/utils.js +13 -1
- package/esm/types/enums.d.ts +36 -17
- package/esm/types/enums.js +30 -11
- package/package.json +1 -1
- package/src/constants/index.ts +119 -43
- package/src/index.ts +22 -6
- package/src/services/strategiesService.ts +221 -12
- package/src/services/strategySubService.test.ts +3 -191
- package/src/services/strategySubService.ts +173 -121
- package/src/services/subDataService.test.ts +18 -214
- package/src/services/subDataService.ts +42 -106
- package/src/services/utils.test.ts +1 -1
- package/src/services/utils.ts +15 -1
- package/src/types/enums.ts +30 -13
|
@@ -22,11 +22,7 @@ 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
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
30
26
|
const chai_1 = require("chai");
|
|
31
27
|
const tokens_1 = require("@defisaver/tokens");
|
|
32
28
|
const web3Utils = __importStar(require("web3-utils"));
|
|
@@ -146,7 +142,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
146
142
|
});
|
|
147
143
|
});
|
|
148
144
|
});
|
|
149
|
-
describe('When testing subDataService.
|
|
145
|
+
describe('When testing subDataService.legacyMakerLeverageManagementSubData', () => {
|
|
150
146
|
describe('decode()', () => {
|
|
151
147
|
const examples = [
|
|
152
148
|
[
|
|
@@ -159,12 +155,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
159
155
|
];
|
|
160
156
|
examples.forEach(([expected, actual]) => {
|
|
161
157
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
162
|
-
(0, chai_1.expect)(subDataService.
|
|
158
|
+
(0, chai_1.expect)(subDataService.legacyMakerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
163
159
|
});
|
|
164
160
|
});
|
|
165
161
|
});
|
|
166
162
|
});
|
|
167
|
-
describe('When testing subDataService.
|
|
163
|
+
describe('When testing subDataService.makerLeverageManagementSubData', () => {
|
|
168
164
|
describe('encode()', () => {
|
|
169
165
|
const examples = [
|
|
170
166
|
[
|
|
@@ -184,7 +180,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
184
180
|
];
|
|
185
181
|
examples.forEach(([expected, actual]) => {
|
|
186
182
|
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
187
|
-
(0, chai_1.expect)(subDataService.
|
|
183
|
+
(0, chai_1.expect)(subDataService.makerLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
188
184
|
});
|
|
189
185
|
});
|
|
190
186
|
});
|
|
@@ -215,12 +211,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
215
211
|
];
|
|
216
212
|
examples.forEach(([expected, actual]) => {
|
|
217
213
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
218
|
-
(0, chai_1.expect)(subDataService.
|
|
214
|
+
(0, chai_1.expect)(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
219
215
|
});
|
|
220
216
|
});
|
|
221
217
|
});
|
|
222
218
|
});
|
|
223
|
-
describe('When testing subDataService.
|
|
219
|
+
describe('When testing subDataService.legacyLiquityLeverageManagementSubData', () => {
|
|
224
220
|
describe('decode()', () => {
|
|
225
221
|
const examples = [
|
|
226
222
|
[
|
|
@@ -233,7 +229,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
233
229
|
];
|
|
234
230
|
examples.forEach(([expected, actual]) => {
|
|
235
231
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
236
|
-
(0, chai_1.expect)(subDataService.
|
|
232
|
+
(0, chai_1.expect)(subDataService.legacyLiquityLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
237
233
|
});
|
|
238
234
|
});
|
|
239
235
|
});
|
|
@@ -288,24 +284,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
288
284
|
});
|
|
289
285
|
});
|
|
290
286
|
});
|
|
291
|
-
describe('When testing subDataService.
|
|
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
|
-
});
|
|
287
|
+
describe('When testing subDataService.legacyAaveV2LeverageManagementSubData', () => {
|
|
309
288
|
describe('decode()', () => {
|
|
310
289
|
const examples = [
|
|
311
290
|
[
|
|
@@ -319,12 +298,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
319
298
|
];
|
|
320
299
|
examples.forEach(([expected, actual]) => {
|
|
321
300
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
322
|
-
(0, chai_1.expect)(subDataService.
|
|
301
|
+
(0, chai_1.expect)(subDataService.legacyAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
323
302
|
});
|
|
324
303
|
});
|
|
325
304
|
});
|
|
326
305
|
});
|
|
327
|
-
describe('When testing subDataService.
|
|
306
|
+
describe('When testing subDataService.legacyAaveV3LeverageManagementSubData', () => {
|
|
328
307
|
describe('decode()', () => {
|
|
329
308
|
const examples = [
|
|
330
309
|
[
|
|
@@ -338,7 +317,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
338
317
|
];
|
|
339
318
|
examples.forEach(([expected, actual]) => {
|
|
340
319
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
341
|
-
(0, chai_1.expect)(subDataService.
|
|
320
|
+
(0, chai_1.expect)(subDataService.legacyAaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
342
321
|
});
|
|
343
322
|
});
|
|
344
323
|
});
|
|
@@ -677,24 +656,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
677
656
|
});
|
|
678
657
|
});
|
|
679
658
|
});
|
|
680
|
-
describe('When testing subDataService.
|
|
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
|
-
});
|
|
659
|
+
describe('When testing subDataService.legacyCompoundV2LeverageManagementSubData', () => {
|
|
698
660
|
describe('decode()', () => {
|
|
699
661
|
const examples = [
|
|
700
662
|
[
|
|
@@ -708,97 +670,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
708
670
|
];
|
|
709
671
|
examples.forEach(([expected, actual]) => {
|
|
710
672
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
711
|
-
(0, chai_1.expect)(subDataService.
|
|
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);
|
|
673
|
+
(0, chai_1.expect)(subDataService.legacyCompoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
780
674
|
});
|
|
781
675
|
});
|
|
782
676
|
});
|
|
783
677
|
});
|
|
784
678
|
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
|
-
});
|
|
802
679
|
describe('decode()', () => {
|
|
803
680
|
const examples = [
|
|
804
681
|
[
|
|
@@ -818,23 +695,6 @@ describe('Feature: subDataService.ts', () => {
|
|
|
818
695
|
});
|
|
819
696
|
});
|
|
820
697
|
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
|
-
});
|
|
838
698
|
describe('decode()', () => {
|
|
839
699
|
const examples = [
|
|
840
700
|
[
|
|
@@ -975,52 +835,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
975
835
|
});
|
|
976
836
|
});
|
|
977
837
|
});
|
|
978
|
-
describe('When testing subDataService.
|
|
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
|
-
});
|
|
838
|
+
describe('When testing subDataService.legacyExchangeLimitOrderSubData', () => {
|
|
1024
839
|
describe('decode()', () => {
|
|
1025
840
|
const examples = [
|
|
1026
841
|
[
|
|
@@ -1054,12 +869,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1054
869
|
];
|
|
1055
870
|
examples.forEach(([expected, actual]) => {
|
|
1056
871
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1057
|
-
(0, chai_1.expect)(subDataService.
|
|
872
|
+
(0, chai_1.expect)(subDataService.legacyExchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
|
|
1058
873
|
});
|
|
1059
874
|
});
|
|
1060
875
|
});
|
|
1061
876
|
});
|
|
1062
|
-
describe('When testing subDataService.
|
|
877
|
+
describe('When testing subDataService.legacySparkLeverageManagementSubData', () => {
|
|
1063
878
|
describe('decode()', () => {
|
|
1064
879
|
const examples = [
|
|
1065
880
|
[
|
|
@@ -1073,7 +888,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1073
888
|
];
|
|
1074
889
|
examples.forEach(([expected, actual]) => {
|
|
1075
890
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1076
|
-
(0, chai_1.expect)(subDataService.
|
|
891
|
+
(0, chai_1.expect)(subDataService.legacySparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1077
892
|
});
|
|
1078
893
|
});
|
|
1079
894
|
});
|
package/cjs/services/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EthereumAddress } from '../types';
|
|
2
|
-
import { ChainId, CloseStrategyType, CloseToAssetType, RatioState } from '../types/enums';
|
|
2
|
+
import { Bundles, 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,3 +28,4 @@ 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.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;
|
|
29
|
+
exports.getBundleIdsByNetwork = 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,3 +188,16 @@ 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,7 +138,9 @@ 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"
|
|
141
|
+
EoaCollateralSwitch = "eoa-collateral-switch",
|
|
142
|
+
LiquidationProtection = "liquidation-protection",
|
|
143
|
+
EoaLiquidationProtection = "liquidation-protection-eoa"
|
|
142
144
|
}
|
|
143
145
|
enum IdOverrides {
|
|
144
146
|
TakeProfit = "take-profit",
|
|
@@ -149,7 +151,9 @@ export declare namespace Strategies {
|
|
|
149
151
|
LeverageManagement = "leverage-management",
|
|
150
152
|
EoaLeverageManagement = "leverage-management-eoa",
|
|
151
153
|
LeverageManagementOnPrice = "leverage-management-on-price",
|
|
152
|
-
EoaLeverageManagementOnPrice = "leverage-management-on-price-eoa"
|
|
154
|
+
EoaLeverageManagementOnPrice = "leverage-management-on-price-eoa",
|
|
155
|
+
LiquidationProtection = "liquidation-protection",
|
|
156
|
+
EoaLiquidationProtection = "liquidation-protection-eoa"
|
|
153
157
|
}
|
|
154
158
|
}
|
|
155
159
|
export declare namespace Bundles {
|
|
@@ -225,10 +229,18 @@ export declare namespace Bundles {
|
|
|
225
229
|
AAVE_V4_EOA_REPAY_ON_PRICE = 68,
|
|
226
230
|
AAVE_V4_EOA_BOOST_ON_PRICE = 69,
|
|
227
231
|
AAVE_V4_EOA_CLOSE = 70,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
+
AAVE_V3_SW_LIQUIDATION_PROTECTION = 71,
|
|
233
|
+
SPARK_SW_LIQUIDATION_PROTECTION = 72,
|
|
234
|
+
MAKER_SW_LIQUIDATION_PROTECTION = 75,
|
|
235
|
+
FLUID_T1_SW_LIQUIDATION_PROTECTION = 76,
|
|
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
|
|
232
244
|
}
|
|
233
245
|
enum OptimismIds {
|
|
234
246
|
AAVE_V3_REPAY = 0,
|
|
@@ -241,7 +253,9 @@ export declare namespace Bundles {
|
|
|
241
253
|
AAVE_V3_EOA_BOOST = 7,
|
|
242
254
|
AAVE_V3_EOA_REPAY_ON_PRICE = 8,
|
|
243
255
|
AAVE_V3_EOA_BOOST_ON_PRICE = 9,
|
|
244
|
-
AAVE_V3_EOA_CLOSE = 10
|
|
256
|
+
AAVE_V3_EOA_CLOSE = 10,
|
|
257
|
+
AAVE_V3_SW_LIQUIDATION_PROTECTION = 11,
|
|
258
|
+
AAVE_V3_EOA_LIQUIDATION_PROTECTION = 12
|
|
245
259
|
}
|
|
246
260
|
enum BaseIds {
|
|
247
261
|
AAVE_V3_REPAY = 0,
|
|
@@ -271,12 +285,13 @@ export declare namespace Bundles {
|
|
|
271
285
|
AAVE_V3_EOA_BOOST_ON_PRICE = 26,
|
|
272
286
|
AAVE_V3_EOA_CLOSE = 27,
|
|
273
287
|
MORPHO_BLUE_CLOSE = 28,
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
288
|
+
AAVE_V3_SW_LIQUIDATION_PROTECTION = 29,
|
|
289
|
+
FLUID_T1_SW_LIQUIDATION_PROTECTION = 30,
|
|
290
|
+
COMP_V3_SW_LIQUIDATION_PROTECTION = 32,
|
|
291
|
+
COMP_V3_EOA_LIQUIDATION_PROTECTION = 33,
|
|
292
|
+
AAVE_V3_EOA_LIQUIDATION_PROTECTION = 34,
|
|
293
|
+
MORPHO_BLUE_SW_LIQUIDATION_PROTECTION = 35,
|
|
294
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 36
|
|
280
295
|
}
|
|
281
296
|
enum ArbitrumIds {
|
|
282
297
|
AAVE_V3_REPAY = 0,
|
|
@@ -308,9 +323,13 @@ export declare namespace Bundles {
|
|
|
308
323
|
MORPHO_BLUE_EOA_REPAY = 26,
|
|
309
324
|
MORPHO_BLUE_EOA_BOOST = 27,
|
|
310
325
|
MORPHO_BLUE_CLOSE = 28,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
326
|
+
AAVE_V3_SW_LIQUIDATION_PROTECTION = 29,
|
|
327
|
+
FLUID_T1_SW_LIQUIDATION_PROTECTION = 30,
|
|
328
|
+
MORPHO_BLUE_SW_LIQUIDATION_PROTECTION = 31,
|
|
329
|
+
COMP_V3_SW_LIQUIDATION_PROTECTION = 32,
|
|
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
|
|
315
334
|
}
|
|
316
335
|
}
|
package/cjs/types/enums.js
CHANGED
|
@@ -159,6 +159,8 @@ 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";
|
|
162
164
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
|
163
165
|
let IdOverrides;
|
|
164
166
|
(function (IdOverrides) {
|
|
@@ -171,6 +173,8 @@ var Strategies;
|
|
|
171
173
|
IdOverrides["EoaLeverageManagement"] = "leverage-management-eoa";
|
|
172
174
|
IdOverrides["LeverageManagementOnPrice"] = "leverage-management-on-price";
|
|
173
175
|
IdOverrides["EoaLeverageManagementOnPrice"] = "leverage-management-on-price-eoa";
|
|
176
|
+
IdOverrides["LiquidationProtection"] = "liquidation-protection";
|
|
177
|
+
IdOverrides["EoaLiquidationProtection"] = "liquidation-protection-eoa";
|
|
174
178
|
})(IdOverrides = Strategies.IdOverrides || (Strategies.IdOverrides = {}));
|
|
175
179
|
})(Strategies = exports.Strategies || (exports.Strategies = {}));
|
|
176
180
|
var Bundles;
|
|
@@ -248,10 +252,18 @@ var Bundles;
|
|
|
248
252
|
MainnetIds[MainnetIds["AAVE_V4_EOA_REPAY_ON_PRICE"] = 68] = "AAVE_V4_EOA_REPAY_ON_PRICE";
|
|
249
253
|
MainnetIds[MainnetIds["AAVE_V4_EOA_BOOST_ON_PRICE"] = 69] = "AAVE_V4_EOA_BOOST_ON_PRICE";
|
|
250
254
|
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";
|
|
251
266
|
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";
|
|
255
267
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
256
268
|
let OptimismIds;
|
|
257
269
|
(function (OptimismIds) {
|
|
@@ -266,6 +278,8 @@ var Bundles;
|
|
|
266
278
|
OptimismIds[OptimismIds["AAVE_V3_EOA_REPAY_ON_PRICE"] = 8] = "AAVE_V3_EOA_REPAY_ON_PRICE";
|
|
267
279
|
OptimismIds[OptimismIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 9] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
268
280
|
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";
|
|
269
283
|
})(OptimismIds = Bundles.OptimismIds || (Bundles.OptimismIds = {}));
|
|
270
284
|
let BaseIds;
|
|
271
285
|
(function (BaseIds) {
|
|
@@ -296,12 +310,13 @@ var Bundles;
|
|
|
296
310
|
BaseIds[BaseIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 26] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
297
311
|
BaseIds[BaseIds["AAVE_V3_EOA_CLOSE"] = 27] = "AAVE_V3_EOA_CLOSE";
|
|
298
312
|
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";
|
|
299
319
|
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";
|
|
305
320
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
306
321
|
let ArbitrumIds;
|
|
307
322
|
(function (ArbitrumIds) {
|
|
@@ -334,9 +349,13 @@ var Bundles;
|
|
|
334
349
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_REPAY"] = 26] = "MORPHO_BLUE_EOA_REPAY";
|
|
335
350
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_BOOST"] = 27] = "MORPHO_BLUE_EOA_BOOST";
|
|
336
351
|
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";
|
|
337
359
|
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";
|
|
341
360
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
342
361
|
})(Bundles = exports.Bundles || (exports.Bundles = {}));
|