@defisaver/automation-sdk 3.3.15-liq-prot-2-dev → 3.3.15-liq-prot-3-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/index.d.ts +1 -2
- package/cjs/index.js +0 -1
- package/cjs/services/strategiesService.js +10 -10
- package/cjs/services/strategySubService.d.ts +9 -15
- package/cjs/services/strategySubService.js +20 -30
- package/cjs/services/strategySubService.test.js +2 -40
- package/cjs/services/subDataService.d.ts +18 -23
- package/cjs/services/subDataService.js +23 -225
- package/cjs/services/subDataService.test.js +17 -134
- package/cjs/services/utils.d.ts +0 -1
- package/cjs/services/utils.js +1 -21
- package/cjs/services/utils.test.js +0 -25
- package/esm/index.d.ts +1 -2
- package/esm/index.js +1 -2
- package/esm/services/strategiesService.js +10 -10
- package/esm/services/strategySubService.d.ts +9 -15
- package/esm/services/strategySubService.js +19 -29
- package/esm/services/strategySubService.test.js +3 -38
- package/esm/services/subDataService.d.ts +18 -23
- package/esm/services/subDataService.js +22 -224
- package/esm/services/subDataService.test.js +18 -132
- package/esm/services/utils.d.ts +0 -1
- package/esm/services/utils.js +0 -19
- package/esm/services/utils.test.js +2 -27
- package/package.json +1 -1
- package/src/index.ts +0 -2
- package/src/services/strategiesService.ts +10 -10
- package/src/services/strategySubService.test.ts +2 -46
- package/src/services/strategySubService.ts +19 -36
- package/src/services/subDataService.test.ts +18 -142
- package/src/services/subDataService.ts +23 -294
- package/src/services/utils.test.ts +0 -31
- package/src/services/utils.ts +0 -17
|
@@ -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,29 +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.
|
|
673
|
+
(0, chai_1.expect)(subDataService.legacyCompoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
712
674
|
});
|
|
713
675
|
});
|
|
714
676
|
});
|
|
715
677
|
});
|
|
716
678
|
describe('When testing subDataService.morphoAaveV2LeverageManagementSubData', () => {
|
|
717
|
-
describe('encode()', () => {
|
|
718
|
-
const examples = [
|
|
719
|
-
[
|
|
720
|
-
[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],
|
|
721
|
-
[160, 220, 180, 190, true]
|
|
722
|
-
],
|
|
723
|
-
[
|
|
724
|
-
[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],
|
|
725
|
-
[160, 200, 180, 190, false]
|
|
726
|
-
],
|
|
727
|
-
];
|
|
728
|
-
examples.forEach(([expected, actual]) => {
|
|
729
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
730
|
-
(0, chai_1.expect)(subDataService.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
731
|
-
});
|
|
732
|
-
});
|
|
733
|
-
});
|
|
734
679
|
describe('decode()', () => {
|
|
735
680
|
const examples = [
|
|
736
681
|
[
|
|
@@ -750,23 +695,6 @@ describe('Feature: subDataService.ts', () => {
|
|
|
750
695
|
});
|
|
751
696
|
});
|
|
752
697
|
describe('When testing subDataService.cBondsRebondSubData', () => {
|
|
753
|
-
describe('encode()', () => {
|
|
754
|
-
const examples = [
|
|
755
|
-
[
|
|
756
|
-
['0x00000000000000000000000000000000000000000000000000000000000000c8'],
|
|
757
|
-
[200]
|
|
758
|
-
],
|
|
759
|
-
[
|
|
760
|
-
['0x000000000000000000000000000000000000000000000000000000000000a119'],
|
|
761
|
-
[41241]
|
|
762
|
-
],
|
|
763
|
-
];
|
|
764
|
-
examples.forEach(([expected, actual]) => {
|
|
765
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
766
|
-
(0, chai_1.expect)(subDataService.cBondsRebondSubData.encode(...actual)).to.eql(expected);
|
|
767
|
-
});
|
|
768
|
-
});
|
|
769
|
-
});
|
|
770
698
|
describe('decode()', () => {
|
|
771
699
|
const examples = [
|
|
772
700
|
[
|
|
@@ -907,52 +835,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
907
835
|
});
|
|
908
836
|
});
|
|
909
837
|
});
|
|
910
|
-
describe('When testing subDataService.
|
|
911
|
-
describe('encode()', () => {
|
|
912
|
-
const examples = [
|
|
913
|
-
[
|
|
914
|
-
[
|
|
915
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
916
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
917
|
-
'2131',
|
|
918
|
-
'0.53123',
|
|
919
|
-
'1696590921159',
|
|
920
|
-
`${enums_1.OrderType.STOP_LOSS}`
|
|
921
|
-
],
|
|
922
|
-
[
|
|
923
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
924
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
925
|
-
'2131',
|
|
926
|
-
'0.53123',
|
|
927
|
-
1696590921159,
|
|
928
|
-
enums_1.OrderType.STOP_LOSS
|
|
929
|
-
]
|
|
930
|
-
],
|
|
931
|
-
[
|
|
932
|
-
[
|
|
933
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
934
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
935
|
-
'2131',
|
|
936
|
-
'0.43123',
|
|
937
|
-
'1646590921159',
|
|
938
|
-
`${enums_1.OrderType.TAKE_PROFIT}`
|
|
939
|
-
],
|
|
940
|
-
[
|
|
941
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
942
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
943
|
-
'2131',
|
|
944
|
-
'0.43123',
|
|
945
|
-
1646590921159,
|
|
946
|
-
enums_1.OrderType.TAKE_PROFIT
|
|
947
|
-
]
|
|
948
|
-
],
|
|
949
|
-
];
|
|
950
|
-
examples.forEach(([expected, actual]) => {
|
|
951
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
952
|
-
(0, chai_1.expect)(subDataService.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
|
|
953
|
-
});
|
|
954
|
-
});
|
|
955
|
-
});
|
|
838
|
+
describe('When testing subDataService.legacyExchangeLimitOrderSubData', () => {
|
|
956
839
|
describe('decode()', () => {
|
|
957
840
|
const examples = [
|
|
958
841
|
[
|
|
@@ -986,12 +869,12 @@ describe('Feature: subDataService.ts', () => {
|
|
|
986
869
|
];
|
|
987
870
|
examples.forEach(([expected, actual]) => {
|
|
988
871
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
989
|
-
(0, chai_1.expect)(subDataService.
|
|
872
|
+
(0, chai_1.expect)(subDataService.legacyExchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
|
|
990
873
|
});
|
|
991
874
|
});
|
|
992
875
|
});
|
|
993
876
|
});
|
|
994
|
-
describe('When testing subDataService.
|
|
877
|
+
describe('When testing subDataService.legacySparkLeverageManagementSubData', () => {
|
|
995
878
|
describe('decode()', () => {
|
|
996
879
|
const examples = [
|
|
997
880
|
[
|
|
@@ -1005,7 +888,7 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1005
888
|
];
|
|
1006
889
|
examples.forEach(([expected, actual]) => {
|
|
1007
890
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1008
|
-
(0, chai_1.expect)(subDataService.
|
|
891
|
+
(0, chai_1.expect)(subDataService.legacySparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1009
892
|
});
|
|
1010
893
|
});
|
|
1011
894
|
});
|
package/cjs/services/utils.d.ts
CHANGED
|
@@ -29,4 +29,3 @@ export declare function getStopLossAndTakeProfitTypeByCloseStrategyType(closeStr
|
|
|
29
29
|
takeProfitType: CloseToAssetType | undefined;
|
|
30
30
|
};
|
|
31
31
|
export declare function getBundleIdsByNetwork(network: ChainId): typeof Bundles.MainnetIds | typeof Bundles.ArbitrumIds | typeof Bundles.BaseIds;
|
|
32
|
-
export declare function getCompoundV3LeverageManagementBundleId(network: ChainId, isEOA: boolean, isBoost: boolean): number;
|
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.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"));
|
|
@@ -201,23 +201,3 @@ function getBundleIdsByNetwork(network) {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
exports.getBundleIdsByNetwork = getBundleIdsByNetwork;
|
|
204
|
-
// Mainnet uses the V2 bundle ids; L2s use the original bundle ids.
|
|
205
|
-
function getCompoundV3LeverageManagementBundleId(network, isEOA, isBoost) {
|
|
206
|
-
switch (Number(network)) {
|
|
207
|
-
case enums_1.ChainId.Ethereum:
|
|
208
|
-
if (isEOA)
|
|
209
|
-
return isBoost ? enums_1.Bundles.MainnetIds.COMP_V3_EOA_BOOST_V2_BUNDLE : enums_1.Bundles.MainnetIds.COMP_V3_EOA_REPAY_V2_BUNDLE;
|
|
210
|
-
return isBoost ? enums_1.Bundles.MainnetIds.COMP_V3_SW_BOOST_V2_BUNDLE : enums_1.Bundles.MainnetIds.COMP_V3_SW_REPAY_V2_BUNDLE;
|
|
211
|
-
case enums_1.ChainId.Base:
|
|
212
|
-
if (isEOA)
|
|
213
|
-
return isBoost ? enums_1.Bundles.BaseIds.COMP_V3_EOA_BOOST : enums_1.Bundles.BaseIds.COMP_V3_EOA_REPAY;
|
|
214
|
-
return isBoost ? enums_1.Bundles.BaseIds.COMP_V3_SW_BOOST_BUNDLE : enums_1.Bundles.BaseIds.COMP_V3_SW_REPAY_BUNDLE;
|
|
215
|
-
case enums_1.ChainId.Arbitrum:
|
|
216
|
-
if (isEOA)
|
|
217
|
-
return isBoost ? enums_1.Bundles.ArbitrumIds.COMP_V3_EOA_BOOST : enums_1.Bundles.ArbitrumIds.COMP_V3_EOA_REPAY;
|
|
218
|
-
return isBoost ? enums_1.Bundles.ArbitrumIds.COMP_V3_SW_BOOST_BUNDLE : enums_1.Bundles.ArbitrumIds.COMP_V3_SW_REPAY_BUNDLE;
|
|
219
|
-
default:
|
|
220
|
-
throw new Error(`Compound V3 leverage management is not supported on network ${network}`);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
exports.getCompoundV3LeverageManagementBundleId = getCompoundV3LeverageManagementBundleId;
|
|
@@ -296,29 +296,4 @@ describe('Feature: utils.ts', () => {
|
|
|
296
296
|
});
|
|
297
297
|
});
|
|
298
298
|
});
|
|
299
|
-
describe('When testing utils.getCompoundV3LeverageManagementBundleId()', () => {
|
|
300
|
-
// Mainnet uses the V2 bundle ids; L2s use the original bundle ids.
|
|
301
|
-
const examples = [
|
|
302
|
-
[enums_1.Bundles.MainnetIds.COMP_V3_SW_REPAY_V2_BUNDLE, [enums_1.ChainId.Ethereum, false, false]],
|
|
303
|
-
[enums_1.Bundles.MainnetIds.COMP_V3_SW_BOOST_V2_BUNDLE, [enums_1.ChainId.Ethereum, false, true]],
|
|
304
|
-
[enums_1.Bundles.MainnetIds.COMP_V3_EOA_REPAY_V2_BUNDLE, [enums_1.ChainId.Ethereum, true, false]],
|
|
305
|
-
[enums_1.Bundles.MainnetIds.COMP_V3_EOA_BOOST_V2_BUNDLE, [enums_1.ChainId.Ethereum, true, true]],
|
|
306
|
-
[enums_1.Bundles.BaseIds.COMP_V3_SW_REPAY_BUNDLE, [enums_1.ChainId.Base, false, false]],
|
|
307
|
-
[enums_1.Bundles.BaseIds.COMP_V3_SW_BOOST_BUNDLE, [enums_1.ChainId.Base, false, true]],
|
|
308
|
-
[enums_1.Bundles.BaseIds.COMP_V3_EOA_REPAY, [enums_1.ChainId.Base, true, false]],
|
|
309
|
-
[enums_1.Bundles.BaseIds.COMP_V3_EOA_BOOST, [enums_1.ChainId.Base, true, true]],
|
|
310
|
-
[enums_1.Bundles.ArbitrumIds.COMP_V3_SW_REPAY_BUNDLE, [enums_1.ChainId.Arbitrum, false, false]],
|
|
311
|
-
[enums_1.Bundles.ArbitrumIds.COMP_V3_SW_BOOST_BUNDLE, [enums_1.ChainId.Arbitrum, false, true]],
|
|
312
|
-
[enums_1.Bundles.ArbitrumIds.COMP_V3_EOA_REPAY, [enums_1.ChainId.Arbitrum, true, false]],
|
|
313
|
-
[enums_1.Bundles.ArbitrumIds.COMP_V3_EOA_BOOST, [enums_1.ChainId.Arbitrum, true, true]],
|
|
314
|
-
];
|
|
315
|
-
examples.forEach(([expected, actual]) => {
|
|
316
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
317
|
-
(0, chai_1.expect)((0, utils_1.getCompoundV3LeverageManagementBundleId)(...actual)).to.equal(expected);
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
it(`Given ${enums_1.ChainId.Optimism} (unsupported) should throw an error`, () => {
|
|
321
|
-
(0, chai_1.expect)(() => (0, utils_1.getCompoundV3LeverageManagementBundleId)(enums_1.ChainId.Optimism, false, false)).to.throw(Error);
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
299
|
});
|
package/esm/index.d.ts
CHANGED
|
@@ -13,12 +13,11 @@ import * as strategiesService from './services/strategiesService';
|
|
|
13
13
|
import * as constants from './constants';
|
|
14
14
|
import * as enums from './types/enums';
|
|
15
15
|
import type * as types from './types';
|
|
16
|
-
import { getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId, getCloseStrategyType
|
|
16
|
+
import { getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId, getCloseStrategyType } from './services/utils';
|
|
17
17
|
declare const utils: {
|
|
18
18
|
compareSubHashes: typeof compareSubHashes;
|
|
19
19
|
encodeSubId: typeof encodeSubId;
|
|
20
20
|
getCloseStrategyType: typeof getCloseStrategyType;
|
|
21
|
-
getCompoundV3LeverageManagementBundleId: typeof getCompoundV3LeverageManagementBundleId;
|
|
22
21
|
getRatioStateInfoForAaveCloseStrategy: typeof getRatioStateInfoForAaveCloseStrategy;
|
|
23
22
|
};
|
|
24
23
|
export { ArbitrumStrategies, BaseStrategies, EthereumStrategies, LegacyAaveAutomation, LegacyCompoundAutomation, LegacyMakerAutomation, OptimismStrategies, constants, enums, strategiesService, strategySubService, subDataService, triggerService, utils, };
|
package/esm/index.js
CHANGED
|
@@ -16,12 +16,11 @@ import * as strategySubService from './services/strategySubService';
|
|
|
16
16
|
import * as strategiesService from './services/strategiesService';
|
|
17
17
|
import * as constants from './constants';
|
|
18
18
|
import * as enums from './types/enums';
|
|
19
|
-
import { getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId, getCloseStrategyType,
|
|
19
|
+
import { getRatioStateInfoForAaveCloseStrategy, compareSubHashes, encodeSubId, getCloseStrategyType, } from './services/utils';
|
|
20
20
|
const utils = {
|
|
21
21
|
compareSubHashes,
|
|
22
22
|
encodeSubId,
|
|
23
23
|
getCloseStrategyType,
|
|
24
|
-
getCompoundV3LeverageManagementBundleId,
|
|
25
24
|
getRatioStateInfoForAaveCloseStrategy,
|
|
26
25
|
};
|
|
27
26
|
export { ArbitrumStrategies, BaseStrategies, EthereumStrategies, LegacyAaveAutomation, LegacyCompoundAutomation, LegacyMakerAutomation, OptimismStrategies, constants, enums, strategiesService, strategySubService, subDataService, triggerService, utils, };
|
|
@@ -66,7 +66,7 @@ function parseMakerLeverageManagement(position, parseData) {
|
|
|
66
66
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
67
67
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
68
68
|
const triggerData = triggerService.makerRatioTrigger.decode(subStruct.triggerData);
|
|
69
|
-
const subData = subDataService.
|
|
69
|
+
const subData = subDataService.legacyMakerLeverageManagementSubData.decode(subStruct.subData);
|
|
70
70
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
71
71
|
_position.strategyData.decoded.subData = subData;
|
|
72
72
|
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, subData.vaultId);
|
|
@@ -149,7 +149,7 @@ function parseAaveV2LeverageManagement(position, parseData) {
|
|
|
149
149
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
150
150
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
151
151
|
const triggerData = triggerService.aaveV2RatioTrigger.decode(subStruct.triggerData);
|
|
152
|
-
const subData = subDataService.
|
|
152
|
+
const subData = subDataService.legacyAaveV2LeverageManagementSubData.decode(subStruct.subData);
|
|
153
153
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
154
154
|
_position.strategyData.decoded.subData = subData;
|
|
155
155
|
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.market);
|
|
@@ -185,10 +185,10 @@ function parseAaveV3LeverageManagement(position, parseData) {
|
|
|
185
185
|
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
186
186
|
let subData;
|
|
187
187
|
if (isEOA) {
|
|
188
|
-
subData = subDataService.
|
|
188
|
+
subData = subDataService.aaveV3LeverageManagementSubData.decode(subStruct.subData);
|
|
189
189
|
}
|
|
190
190
|
else {
|
|
191
|
-
subData = subDataService.
|
|
191
|
+
subData = subDataService.legacyAaveV3LeverageManagementSubData.decode(subStruct.subData);
|
|
192
192
|
}
|
|
193
193
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
194
194
|
_position.strategyData.decoded.subData = subData;
|
|
@@ -510,7 +510,7 @@ function parseCompoundV2LeverageManagement(position, parseData) {
|
|
|
510
510
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
511
511
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
512
512
|
const triggerData = triggerService.compoundV2RatioTrigger.decode(subStruct.triggerData);
|
|
513
|
-
const subData = subDataService.
|
|
513
|
+
const subData = subDataService.legacyCompoundV2LeverageManagementSubData.decode(subStruct.subData);
|
|
514
514
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
515
515
|
_position.strategyData.decoded.subData = subData;
|
|
516
516
|
_position.owner = triggerData.owner.toLowerCase();
|
|
@@ -544,7 +544,7 @@ function parseCompoundV3LeverageManagement(position, parseData) {
|
|
|
544
544
|
const _position = cloneDeep(position);
|
|
545
545
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
546
546
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
547
|
-
const subDataDecoder = subDataService.
|
|
547
|
+
const subDataDecoder = subDataService.compoundV3LeverageManagementSubData;
|
|
548
548
|
const triggerData = triggerService.compoundV3RatioTrigger.decode(subStruct.triggerData);
|
|
549
549
|
const subData = subDataDecoder.decode(subStruct.subData);
|
|
550
550
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
@@ -579,7 +579,7 @@ function parseCompoundV3LiquidationProtection(position, parseData) {
|
|
|
579
579
|
const _position = cloneDeep(position);
|
|
580
580
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
581
581
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
582
|
-
const subDataDecoder = subDataService.
|
|
582
|
+
const subDataDecoder = subDataService.compoundV3LiquidationProtectionSubData;
|
|
583
583
|
const triggerData = triggerService.compoundV3RatioTrigger.decode(subStruct.triggerData);
|
|
584
584
|
const subData = subDataDecoder.decode(subStruct.subData);
|
|
585
585
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
@@ -669,7 +669,7 @@ function parseExchangeDca(position, parseData, chainId) {
|
|
|
669
669
|
function parseExchangeLimitOrder(position, parseData, chainId) {
|
|
670
670
|
const _position = cloneDeep(position);
|
|
671
671
|
const { subStruct } = parseData.subscriptionEventData;
|
|
672
|
-
_position.strategyData.decoded.subData = subDataService.
|
|
672
|
+
_position.strategyData.decoded.subData = subDataService.legacyExchangeLimitOrderSubData.decode(subStruct.subData, chainId);
|
|
673
673
|
const fromTokenDecimals = getAssetInfoByAddress(_position.strategyData.decoded.subData.fromToken, chainId).decimals;
|
|
674
674
|
const toTokenDecimals = getAssetInfoByAddress(_position.strategyData.decoded.subData.toToken, chainId).decimals;
|
|
675
675
|
_position.strategyData.decoded.triggerData = triggerService.exchangeOffchainPriceTrigger.decode(subStruct.triggerData, fromTokenDecimals, toTokenDecimals);
|
|
@@ -681,7 +681,7 @@ function parseLiquityLeverageManagement(position, parseData) {
|
|
|
681
681
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
682
682
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
683
683
|
const triggerData = triggerService.liquityRatioTrigger.decode(subStruct.triggerData);
|
|
684
|
-
const subData = subDataService.
|
|
684
|
+
const subData = subDataService.legacyLiquityLeverageManagementSubData.decode(subStruct.subData);
|
|
685
685
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
686
686
|
_position.strategyData.decoded.subData = subData;
|
|
687
687
|
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner);
|
|
@@ -747,7 +747,7 @@ function parseSparkLeverageManagement(position, parseData) {
|
|
|
747
747
|
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
748
748
|
const { isEnabled } = parseData.strategiesSubsData;
|
|
749
749
|
const triggerData = triggerService.sparkRatioTrigger.decode(subStruct.triggerData);
|
|
750
|
-
const subData = subDataService.
|
|
750
|
+
const subData = subDataService.legacySparkLeverageManagementSubData.decode(subStruct.subData);
|
|
751
751
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
752
752
|
_position.strategyData.decoded.subData = subData;
|
|
753
753
|
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.market);
|
|
@@ -5,23 +5,20 @@ export declare const makerEncode: {
|
|
|
5
5
|
repayFromSavings(bundleId: StrategyOrBundleIds, vaultId: number, triggerRepayRatio: number, targetRepayRatio: number, isBundle?: boolean, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds | Strategies.OptimismIds | Strategies.ArbitrumIds | Strategies.BaseIds | Bundles.MainnetIds | Bundles.OptimismIds | Bundles.ArbitrumIds | Bundles.BaseIds)[];
|
|
6
6
|
closeOnPrice(vaultId: number, ratioState: RatioState, price: string, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
7
7
|
trailingStop(vaultId: number, triggerPercentage: number, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, roundId: number, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
8
|
-
|
|
8
|
+
leverageManagement(vaultId: number, triggerRatio: number, targetRatio: number, ratioState: RatioState, isBoost: boolean, daiAddr?: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
|
|
9
9
|
liquidationProtection(vaultId: number, triggerRatio: number, targetRatio: number, ratioState: RatioState, daiAddr?: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
|
|
10
10
|
};
|
|
11
11
|
export declare const liquityEncode: {
|
|
12
12
|
closeOnPrice(priceOverOrUnder: RatioState, price: string, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
13
13
|
trailingStop(triggerPercentage: number, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, roundId: number, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
14
14
|
paybackFromChickenBondStrategySub(proxyAddress: EthereumAddress, ratio: number, sourceId: string, sourceType: number, ratioState?: RatioState): (boolean | string[] | Bundles.MainnetIds)[];
|
|
15
|
-
|
|
15
|
+
leverageManagement(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
16
16
|
dsrPayback(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
17
17
|
dsrSupply(proxyAddress: EthereumAddress, triggerRatio: number, targetRatio: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
18
18
|
debtInFrontRepay(proxyAddress: EthereumAddress, debtInFrontMin: string, targetRatioIncrease: number): (boolean | string[] | Strategies.MainnetIds)[];
|
|
19
19
|
};
|
|
20
|
-
export declare const chickenBondsEncode: {
|
|
21
|
-
rebond(bondId: number): string[];
|
|
22
|
-
};
|
|
23
20
|
export declare const aaveV2Encode: {
|
|
24
|
-
|
|
21
|
+
leverageManagement(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
25
22
|
};
|
|
26
23
|
export declare const aaveV3Encode: {
|
|
27
24
|
closeToAsset(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
@@ -60,27 +57,24 @@ export declare const aaveV3Encode: {
|
|
|
60
57
|
marketAddr: EthereumAddress;
|
|
61
58
|
targetRatio: number;
|
|
62
59
|
}): (number | boolean | string[])[];
|
|
63
|
-
|
|
60
|
+
leverageManagement(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, isGeneric?: boolean): (number | boolean | string[])[];
|
|
64
61
|
liquidationProtection(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
65
62
|
leverageManagementOnPriceGeneric(strategyOrBundleId: number, price: number, ratioState: RatioState, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): (number | boolean | string[])[];
|
|
66
63
|
closeOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
67
64
|
collateralSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
|
|
68
65
|
};
|
|
69
66
|
export declare const compoundV2Encode: {
|
|
70
|
-
|
|
67
|
+
leverageManagement(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
71
68
|
};
|
|
72
69
|
export declare const compoundV3Encode: {
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
leverageManagement(strategyOrBundleId: number, market: EthereumAddress, baseToken: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
71
|
+
liquidationProtection(strategyOrBundleId: number, market: EthereumAddress, baseToken: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
75
72
|
leverageManagementOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, price: number, priceState: RatioState, ratioState: RatioState, user: EthereumAddress): (number | boolean | string[])[];
|
|
76
73
|
closeOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, stopLossPrice: number | undefined, stopLossType: CloseToAssetType | undefined, takeProfitPrice: number | undefined, takeProfitType: CloseToAssetType | undefined, user: EthereumAddress): (number | boolean | string[])[];
|
|
77
74
|
};
|
|
78
|
-
export declare const morphoAaveV2Encode: {
|
|
79
|
-
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string[];
|
|
80
|
-
};
|
|
81
75
|
export declare const exchangeEncode: {
|
|
82
76
|
dca(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, timestamp: number, interval: number, network: ChainId): (boolean | string[] | Strategies.MainnetIds | Strategies.OptimismIds | Strategies.ArbitrumIds | Strategies.BaseIds)[];
|
|
83
|
-
|
|
77
|
+
limitOrder(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, targetPrice: string, goodUntil: string | number, orderType: OrderType, fromTokenDecimals: number, toTokenDecimals: number, network: ChainId): (boolean | string[] | Strategies.MainnetIds | Strategies.OptimismIds | Strategies.ArbitrumIds | Strategies.BaseIds)[];
|
|
84
78
|
};
|
|
85
79
|
export declare const sparkEncode: {
|
|
86
80
|
leverageManagementOnPrice(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
@@ -97,7 +91,7 @@ export declare const sparkEncode: {
|
|
|
97
91
|
targetRatio: number;
|
|
98
92
|
}): (number | boolean | string[])[];
|
|
99
93
|
closeOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
100
|
-
|
|
94
|
+
leverageManagement(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
101
95
|
liquidationProtection(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
102
96
|
collateralSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
|
|
103
97
|
};
|