@defisaver/automation-sdk 3.3.14 → 3.3.15-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 +95 -0
- package/cjs/index.d.ts +4 -3
- package/cjs/index.js +6 -2
- package/cjs/services/strategiesService.js +181 -17
- package/cjs/services/strategySubService.d.ts +14 -13
- package/cjs/services/strategySubService.js +74 -63
- package/cjs/services/strategySubService.test.js +0 -234
- package/cjs/services/subDataService.d.ts +98 -1
- package/cjs/services/subDataService.js +264 -6
- package/cjs/services/subDataService.test.js +0 -42
- package/cjs/services/utils.d.ts +3 -1
- package/cjs/services/utils.js +34 -1
- package/cjs/services/utils.test.js +25 -0
- package/cjs/types/enums.d.ts +29 -6
- package/cjs/types/enums.js +23 -0
- package/esm/constants/index.js +95 -0
- package/esm/index.d.ts +4 -3
- package/esm/index.js +7 -3
- package/esm/services/strategiesService.js +181 -17
- package/esm/services/strategySubService.d.ts +14 -13
- package/esm/services/strategySubService.js +74 -60
- package/esm/services/strategySubService.test.js +2 -236
- package/esm/services/subDataService.d.ts +98 -1
- package/esm/services/subDataService.js +262 -5
- package/esm/services/subDataService.test.js +0 -42
- package/esm/services/utils.d.ts +3 -1
- package/esm/services/utils.js +32 -1
- package/esm/services/utils.test.js +27 -2
- package/esm/types/enums.d.ts +29 -6
- package/esm/types/enums.js +23 -0
- package/package.json +1 -1
- package/src/constants/index.ts +96 -0
- package/src/index.ts +24 -6
- package/src/services/strategiesService.ts +246 -17
- package/src/services/strategySubService.test.ts +0 -279
- package/src/services/strategySubService.ts +196 -110
- package/src/services/subDataService.test.ts +0 -48
- package/src/services/subDataService.ts +363 -4
- package/src/services/utils.test.ts +32 -1
- package/src/services/utils.ts +32 -1
- package/src/types/enums.ts +23 -0
|
@@ -71,6 +71,14 @@ export declare const makerLeverageManagementWithoutSubProxy: {
|
|
|
71
71
|
daiAddr: string;
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
|
+
export declare const makerLiquidationProtectionSubData: {
|
|
75
|
+
encode(vaultId: number, targetRatio: number, daiAddr?: EthereumAddress): string[];
|
|
76
|
+
decode(subData: string[]): {
|
|
77
|
+
vaultId: number;
|
|
78
|
+
targetRatio: number;
|
|
79
|
+
daiAddr: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
74
82
|
/**
|
|
75
83
|
__ __ ______ __ __ __ .___________.____ ____ ____ ____ __
|
|
76
84
|
| | | | / __ \ | | | | | | | |\ \ / / \ \ / / /_ |
|
|
@@ -89,6 +97,13 @@ export declare const liquityLeverageManagementSubData: {
|
|
|
89
97
|
targetRatio: number;
|
|
90
98
|
};
|
|
91
99
|
};
|
|
100
|
+
export declare const liquityLeverageManagementSubDataWithoutSubProxy: {
|
|
101
|
+
encode(targetRatio: number, ratioState: RatioState): string[];
|
|
102
|
+
decode(subData: string[]): {
|
|
103
|
+
targetRatio: number;
|
|
104
|
+
ratioState: RatioState;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
92
107
|
export declare const liquityCloseSubData: {
|
|
93
108
|
encode(closeToAssetAddr: EthereumAddress, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): string[];
|
|
94
109
|
decode(subData: string[]): {
|
|
@@ -177,6 +192,14 @@ export declare const aaveV2LeverageManagementSubData: {
|
|
|
177
192
|
targetRatio: number;
|
|
178
193
|
};
|
|
179
194
|
};
|
|
195
|
+
export declare const aaveV2LeverageManagementSubDataWithoutSubProxy: {
|
|
196
|
+
encode(market: EthereumAddress, targetRatio: number, ratioState: RatioState): string[];
|
|
197
|
+
decode(subData: string[]): {
|
|
198
|
+
market: EthereumAddress;
|
|
199
|
+
targetRatio: number;
|
|
200
|
+
ratioState: RatioState;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
180
203
|
/**
|
|
181
204
|
___ ___ ____ ____ _______ ____ ____ ____
|
|
182
205
|
/ \ / \ \ \ / / | ____| \ \ / / |___ \
|
|
@@ -197,6 +220,13 @@ export declare const aaveV3LeverageManagementSubDataWithoutSubProxy: {
|
|
|
197
220
|
ratioState: RatioState;
|
|
198
221
|
};
|
|
199
222
|
};
|
|
223
|
+
export declare const aaveV3LiquidationProtectionSubData: {
|
|
224
|
+
encode(targetRatio: number, ratioState: RatioState, market: EthereumAddress, user: EthereumAddress): string[];
|
|
225
|
+
decode(subData: string[]): {
|
|
226
|
+
targetRatio: number;
|
|
227
|
+
ratioState: RatioState;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
200
230
|
export declare const aaveV3LeverageManagementOnPriceGeneric: {
|
|
201
231
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): string[];
|
|
202
232
|
decode(subData: string[]): {
|
|
@@ -269,6 +299,15 @@ export declare const aaveV4LeverageManagementSubData: {
|
|
|
269
299
|
targetRatio: number;
|
|
270
300
|
};
|
|
271
301
|
};
|
|
302
|
+
export declare const aaveV4LiquidationProtectionSubData: {
|
|
303
|
+
encode: (spoke: EthereumAddress, owner: EthereumAddress, ratioState: RatioState, targetRatio: number) => string[];
|
|
304
|
+
decode: (subData: string[]) => {
|
|
305
|
+
spoke: string;
|
|
306
|
+
owner: string;
|
|
307
|
+
ratioState: RatioState;
|
|
308
|
+
targetRatio: number;
|
|
309
|
+
};
|
|
310
|
+
};
|
|
272
311
|
export declare const aaveV4LeverageManagementOnPriceSubData: {
|
|
273
312
|
encode: (spoke: EthereumAddress, owner: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, ratioState: RatioState, targetRatio: number) => string[];
|
|
274
313
|
decode: (subData: string[]) => {
|
|
@@ -320,6 +359,13 @@ export declare const compoundV2LeverageManagementSubData: {
|
|
|
320
359
|
targetRatio: number;
|
|
321
360
|
};
|
|
322
361
|
};
|
|
362
|
+
export declare const compoundV2LeverageManagementSubDataWithoutSubProxy: {
|
|
363
|
+
encode(targetRatio: number, ratioState: RatioState): string[];
|
|
364
|
+
decode(subData: string[]): {
|
|
365
|
+
targetRatio: number;
|
|
366
|
+
ratioState: RatioState;
|
|
367
|
+
};
|
|
368
|
+
};
|
|
323
369
|
/**
|
|
324
370
|
______ ______ .___ ___. .______ ____ ____ ____
|
|
325
371
|
/ | / __ \ | \/ | | _ \ \ \ / / |___ \
|
|
@@ -334,7 +380,22 @@ export declare const compoundV3LeverageManagementSubData: {
|
|
|
334
380
|
targetRatio: number;
|
|
335
381
|
};
|
|
336
382
|
};
|
|
337
|
-
export declare const
|
|
383
|
+
export declare const compoundV3LeverageManagementSubDataWithoutSubProxy: {
|
|
384
|
+
encode(market: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, ratioState: RatioState): string[];
|
|
385
|
+
decode(subData: string[]): {
|
|
386
|
+
market: EthereumAddress;
|
|
387
|
+
baseToken: EthereumAddress;
|
|
388
|
+
targetRatio: number;
|
|
389
|
+
ratioState: RatioState;
|
|
390
|
+
};
|
|
391
|
+
};
|
|
392
|
+
export declare const compoundV3LiquidationProtectionSubData: {
|
|
393
|
+
encode(market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean): string[];
|
|
394
|
+
decode(subData: string[]): {
|
|
395
|
+
targetRatio: number;
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
export declare const compoundV3L2LiquidationProtectionSubData: {
|
|
338
399
|
encode(market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean): string;
|
|
339
400
|
decode(subData: string[]): {
|
|
340
401
|
targetRatio: number;
|
|
@@ -386,6 +447,14 @@ export declare const exchangeLimitOrderSubData: {
|
|
|
386
447
|
amount: string;
|
|
387
448
|
};
|
|
388
449
|
};
|
|
450
|
+
export declare const exchangeLimitOrderSubDataWithoutSubProxy: {
|
|
451
|
+
encode(fromToken: EthereumAddress, toToken: EthereumAddress, amount: string): string[];
|
|
452
|
+
decode: (subData: string[], chainId: ChainId) => {
|
|
453
|
+
fromToken: string;
|
|
454
|
+
toToken: string;
|
|
455
|
+
amount: string;
|
|
456
|
+
};
|
|
457
|
+
};
|
|
389
458
|
/**
|
|
390
459
|
_______..______ ___ .______ __ ___
|
|
391
460
|
/ || _ \ / \ | _ \ | |/ /
|
|
@@ -406,6 +475,13 @@ export declare const sparkLeverageManagementSubDataWithoutSubProxy: {
|
|
|
406
475
|
ratioState: RatioState;
|
|
407
476
|
};
|
|
408
477
|
};
|
|
478
|
+
export declare const sparkLiquidationProtectionSubData: {
|
|
479
|
+
encode(targetRatio: number, ratioState: RatioState): string[];
|
|
480
|
+
decode(subData: string[]): {
|
|
481
|
+
targetRatio: number;
|
|
482
|
+
ratioState: RatioState;
|
|
483
|
+
};
|
|
484
|
+
};
|
|
409
485
|
export declare const sparkCloseGenericSubData: {
|
|
410
486
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType, marketAddr: EthereumAddress, user: EthereumAddress): string[];
|
|
411
487
|
decode(subData: string[]): {
|
|
@@ -484,6 +560,18 @@ export declare const morphoBlueLeverageManagementSubData: {
|
|
|
484
560
|
targetRatio: number;
|
|
485
561
|
};
|
|
486
562
|
};
|
|
563
|
+
export declare const morphoBlueLiquidationProtectionSubData: {
|
|
564
|
+
encode: (loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, user: EthereumAddress, isEOA: boolean) => string[];
|
|
565
|
+
decode: (subData: string[]) => {
|
|
566
|
+
loanToken: string;
|
|
567
|
+
collToken: string;
|
|
568
|
+
oracle: string;
|
|
569
|
+
irm: string;
|
|
570
|
+
lltv: string;
|
|
571
|
+
user: string;
|
|
572
|
+
targetRatio: number;
|
|
573
|
+
};
|
|
574
|
+
};
|
|
487
575
|
export declare const morphoBlueLeverageManagementOnPriceSubData: {
|
|
488
576
|
encode(loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, targetRatio: number, user: EthereumAddress): string[];
|
|
489
577
|
decode(subData: string[]): {
|
|
@@ -525,3 +613,12 @@ export declare const fluidLeverageManagementSubData: {
|
|
|
525
613
|
targetRatio: number;
|
|
526
614
|
};
|
|
527
615
|
};
|
|
616
|
+
export declare const fluidLiquidationProtectionSubData: {
|
|
617
|
+
encode: (nftId: string, vault: EthereumAddress, ratioState: RatioState, targetRatio: number) => string[];
|
|
618
|
+
decode: (subData: string[]) => {
|
|
619
|
+
nftId: string;
|
|
620
|
+
vault: string;
|
|
621
|
+
ratioState: RatioState;
|
|
622
|
+
targetRatio: number;
|
|
623
|
+
};
|
|
624
|
+
};
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.sparkLeverageManagementOnPriceSubData = exports.sparkCloseGenericSubData = exports.sparkLiquidationProtectionSubData = exports.sparkLeverageManagementSubDataWithoutSubProxy = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubDataWithoutSubProxy = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.compoundV3L2LiquidationProtectionSubData = exports.compoundV3LiquidationProtectionSubData = exports.compoundV3LeverageManagementSubDataWithoutSubProxy = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubDataWithoutSubProxy = exports.compoundV2LeverageManagementSubData = exports.aaveV4CollateralSwitchSubData = exports.aaveV4CloseSubData = exports.aaveV4LeverageManagementOnPriceSubData = exports.aaveV4LiquidationProtectionSubData = exports.aaveV4LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3CollateralSwitchSubData = exports.aaveV3CloseGenericSubData = exports.aaveV3LeverageManagementOnPriceGeneric = exports.aaveV3LiquidationProtectionSubData = exports.aaveV3LeverageManagementSubDataWithoutSubProxy = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubDataWithoutSubProxy = exports.aaveV2LeverageManagementSubData = exports.liquityV2PaybackSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubDataWithoutSubProxy = exports.liquityLeverageManagementSubData = exports.liquityRepayFromSavingsSubData = exports.makerLiquidationProtectionSubData = exports.makerLeverageManagementWithoutSubProxy = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.makerRepayFromSavingsSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = void 0;
|
|
7
|
+
exports.fluidLiquidationProtectionSubData = exports.fluidLeverageManagementSubData = exports.morphoBlueCloseOnPriceSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.morphoBlueLiquidationProtectionSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.sparkCollateralSwitchSubData = void 0;
|
|
7
8
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
9
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
9
10
|
const web3_utils_1 = require("web3-utils");
|
|
@@ -131,6 +132,8 @@ exports.makerLeverageManagementSubData = {
|
|
|
131
132
|
return { vaultId, targetRatio };
|
|
132
133
|
},
|
|
133
134
|
};
|
|
135
|
+
// ! Any change here will PROBABLY require a change in makerLiquidationProtectionSubData as well, since it is copy paste
|
|
136
|
+
// ! Double check before changing
|
|
134
137
|
exports.makerLeverageManagementWithoutSubProxy = {
|
|
135
138
|
encode(vaultId, targetRatio, daiAddr) {
|
|
136
139
|
const encodedVaultId = web3_eth_abi_1.default.encodeParameter('uint256', vaultId);
|
|
@@ -145,6 +148,20 @@ exports.makerLeverageManagementWithoutSubProxy = {
|
|
|
145
148
|
return { vaultId, targetRatio, daiAddr };
|
|
146
149
|
},
|
|
147
150
|
};
|
|
151
|
+
exports.makerLiquidationProtectionSubData = {
|
|
152
|
+
encode(vaultId, targetRatio, daiAddr) {
|
|
153
|
+
const encodedVaultId = web3_eth_abi_1.default.encodeParameter('uint256', vaultId);
|
|
154
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
155
|
+
const encodedDaiAddr = web3_eth_abi_1.default.encodeParameter('address', daiAddr || (0, tokens_1.getAssetInfo)('DAI', 1).address);
|
|
156
|
+
return [encodedVaultId, encodedTargetRatio, encodedDaiAddr];
|
|
157
|
+
},
|
|
158
|
+
decode(subData) {
|
|
159
|
+
const vaultId = +web3_eth_abi_1.default.decodeParameter('uint256', subData[0]).toString();
|
|
160
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[1]));
|
|
161
|
+
const daiAddr = web3_eth_abi_1.default.decodeParameter('address', subData[2]).toString();
|
|
162
|
+
return { vaultId, targetRatio, daiAddr };
|
|
163
|
+
},
|
|
164
|
+
};
|
|
148
165
|
/**
|
|
149
166
|
__ __ ______ __ __ __ .___________.____ ____ ____ ____ __
|
|
150
167
|
| | | | / __ \ | | | | | | | |\ \ / / \ \ / / /_ |
|
|
@@ -167,6 +184,23 @@ exports.liquityLeverageManagementSubData = {
|
|
|
167
184
|
return { targetRatio };
|
|
168
185
|
},
|
|
169
186
|
};
|
|
187
|
+
exports.liquityLeverageManagementSubDataWithoutSubProxy = {
|
|
188
|
+
encode(targetRatio, ratioState) {
|
|
189
|
+
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
190
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
191
|
+
const isRepay = ratioState === enums_1.RatioState.UNDER;
|
|
192
|
+
const collActionType = isRepay ? enums_1.CollActionType.WITHDRAW : enums_1.CollActionType.SUPPLY;
|
|
193
|
+
const debtActionType = isRepay ? enums_1.DebtActionType.PAYBACK : enums_1.DebtActionType.BORROW;
|
|
194
|
+
const collActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
195
|
+
const debtActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
196
|
+
return [encodedRatioState, encodedTargetRatio, collActionTypeEncoded, debtActionTypeEncoded];
|
|
197
|
+
},
|
|
198
|
+
decode(subData) {
|
|
199
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[0]);
|
|
200
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[1]));
|
|
201
|
+
return { targetRatio, ratioState };
|
|
202
|
+
},
|
|
203
|
+
};
|
|
170
204
|
exports.liquityCloseSubData = {
|
|
171
205
|
encode(closeToAssetAddr, chainId = enums_1.ChainId.Ethereum, collAddr, debtAddr) {
|
|
172
206
|
const _collAddr = collAddr || (0, tokens_1.getAssetInfo)('WETH', chainId).address;
|
|
@@ -398,6 +432,25 @@ exports.aaveV2LeverageManagementSubData = {
|
|
|
398
432
|
return { targetRatio };
|
|
399
433
|
},
|
|
400
434
|
};
|
|
435
|
+
exports.aaveV2LeverageManagementSubDataWithoutSubProxy = {
|
|
436
|
+
encode(market, targetRatio, ratioState) {
|
|
437
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
438
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
439
|
+
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
440
|
+
const isBoost = ratioState === enums_1.RatioState.OVER;
|
|
441
|
+
if (isBoost) {
|
|
442
|
+
const enableAsCollEncoded = web3_eth_abi_1.default.encodeParameter('uint256', 1);
|
|
443
|
+
return [encodedMarket, encodedTargetRatio, encodedRatioState, enableAsCollEncoded];
|
|
444
|
+
}
|
|
445
|
+
return [encodedMarket, encodedTargetRatio, encodedRatioState];
|
|
446
|
+
},
|
|
447
|
+
decode(subData) {
|
|
448
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
449
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[1]));
|
|
450
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[2]);
|
|
451
|
+
return { market, targetRatio, ratioState };
|
|
452
|
+
},
|
|
453
|
+
};
|
|
401
454
|
/**
|
|
402
455
|
___ ___ ____ ____ _______ ____ ____ ____
|
|
403
456
|
/ \ / \ \ \ / / | ____| \ \ / / |___ \
|
|
@@ -413,6 +466,8 @@ exports.aaveV3LeverageManagementSubData = {
|
|
|
413
466
|
return { targetRatio };
|
|
414
467
|
},
|
|
415
468
|
};
|
|
469
|
+
// ! Any change here will PROBABLY require a change in aaveV3LiquidationProtectionSubData as well
|
|
470
|
+
// ! Double check before changing. Liquidation protection is using Generic encoding for both - EOA and SW
|
|
416
471
|
exports.aaveV3LeverageManagementSubDataWithoutSubProxy = {
|
|
417
472
|
encode(targetRatio, ratioState, market, user, isGeneric) {
|
|
418
473
|
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
@@ -432,6 +487,20 @@ exports.aaveV3LeverageManagementSubDataWithoutSubProxy = {
|
|
|
432
487
|
return { targetRatio, ratioState };
|
|
433
488
|
},
|
|
434
489
|
};
|
|
490
|
+
exports.aaveV3LiquidationProtectionSubData = {
|
|
491
|
+
encode(targetRatio, ratioState, market, user) {
|
|
492
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
493
|
+
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
494
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
495
|
+
const encodedUser = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
496
|
+
return [encodedTargetRatio, encodedRatioState, encodedMarket, encodedUser];
|
|
497
|
+
},
|
|
498
|
+
decode(subData) {
|
|
499
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[0]));
|
|
500
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[1]);
|
|
501
|
+
return { targetRatio, ratioState };
|
|
502
|
+
},
|
|
503
|
+
};
|
|
435
504
|
exports.aaveV3LeverageManagementOnPriceGeneric = {
|
|
436
505
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user) {
|
|
437
506
|
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
@@ -593,6 +662,8 @@ exports.aaveV3LeverageManagementOnPriceSubData = {
|
|
|
593
662
|
/ _____ \ / _____ \ \ / | |____ \ / | |
|
|
594
663
|
/__/ \__\ /__/ \__\ \__/ |_______| \__/ |_|
|
|
595
664
|
*/
|
|
665
|
+
// ! Any change here will PROBABLY require a change in aaveV4LiquidationProtectionSubData as well, since it is copy paste
|
|
666
|
+
// ! Double check before changing
|
|
596
667
|
exports.aaveV4LeverageManagementSubData = {
|
|
597
668
|
encode: (spoke, owner, ratioState, targetRatio) => {
|
|
598
669
|
const spokeEncoded = web3_eth_abi_1.default.encodeParameter('address', spoke);
|
|
@@ -619,6 +690,32 @@ exports.aaveV4LeverageManagementSubData = {
|
|
|
619
690
|
};
|
|
620
691
|
},
|
|
621
692
|
};
|
|
693
|
+
exports.aaveV4LiquidationProtectionSubData = {
|
|
694
|
+
encode: (spoke, owner, ratioState, targetRatio) => {
|
|
695
|
+
const spokeEncoded = web3_eth_abi_1.default.encodeParameter('address', spoke);
|
|
696
|
+
const ownerEncoded = web3_eth_abi_1.default.encodeParameter('address', owner);
|
|
697
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
698
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
699
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
700
|
+
return [
|
|
701
|
+
spokeEncoded,
|
|
702
|
+
ownerEncoded,
|
|
703
|
+
ratioStateEncoded,
|
|
704
|
+
targetRatioEncoded,
|
|
705
|
+
constants_1.EMPTY_SLOT,
|
|
706
|
+
constants_1.EMPTY_SLOT,
|
|
707
|
+
];
|
|
708
|
+
},
|
|
709
|
+
decode: (subData) => {
|
|
710
|
+
const spoke = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
711
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
712
|
+
const ratioState = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[2]));
|
|
713
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[3]));
|
|
714
|
+
return {
|
|
715
|
+
spoke, owner, ratioState, targetRatio,
|
|
716
|
+
};
|
|
717
|
+
},
|
|
718
|
+
};
|
|
622
719
|
exports.aaveV4LeverageManagementOnPriceSubData = {
|
|
623
720
|
encode: (spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, ratioState, targetRatio) => {
|
|
624
721
|
const spokeEncoded = web3_eth_abi_1.default.encodeParameter('address', spoke);
|
|
@@ -752,6 +849,23 @@ exports.compoundV2LeverageManagementSubData = {
|
|
|
752
849
|
return { targetRatio };
|
|
753
850
|
},
|
|
754
851
|
};
|
|
852
|
+
exports.compoundV2LeverageManagementSubDataWithoutSubProxy = {
|
|
853
|
+
encode(targetRatio, ratioState) {
|
|
854
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
855
|
+
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
856
|
+
const isBoost = ratioState === enums_1.RatioState.OVER;
|
|
857
|
+
if (isBoost) {
|
|
858
|
+
const enableAsCollEncoded = web3_eth_abi_1.default.encodeParameter('uint256', 1);
|
|
859
|
+
return [encodedTargetRatio, encodedRatioState, enableAsCollEncoded];
|
|
860
|
+
}
|
|
861
|
+
return [encodedTargetRatio, encodedRatioState];
|
|
862
|
+
},
|
|
863
|
+
decode(subData) {
|
|
864
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[0]));
|
|
865
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[1]);
|
|
866
|
+
return { targetRatio, ratioState };
|
|
867
|
+
},
|
|
868
|
+
};
|
|
755
869
|
/**
|
|
756
870
|
______ ______ .___ ___. .______ ____ ____ ____
|
|
757
871
|
/ | / __ \ | \/ | | _ \ \ \ / / |___ \
|
|
@@ -760,6 +874,8 @@ exports.compoundV2LeverageManagementSubData = {
|
|
|
760
874
|
| `----.| `--' | | | | | | | \ / ___) |
|
|
761
875
|
\______| \______/ |__| |__| | _| \__/ |____/
|
|
762
876
|
*/
|
|
877
|
+
// ! Any change here will PROBABLY require a change in compoundV3LiquidationProtectionSubData as well, since it is copy paste
|
|
878
|
+
// ! Double check before changing
|
|
763
879
|
exports.compoundV3LeverageManagementSubData = {
|
|
764
880
|
encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA) {
|
|
765
881
|
return [
|
|
@@ -779,8 +895,51 @@ exports.compoundV3LeverageManagementSubData = {
|
|
|
779
895
|
return { targetRatio };
|
|
780
896
|
},
|
|
781
897
|
};
|
|
782
|
-
|
|
783
|
-
|
|
898
|
+
// ! Any change here will PROBABLY require a change in compoundV3L2LiquidationProtectionSubData as well, since it is copy paste
|
|
899
|
+
// ! Double check before changing
|
|
900
|
+
exports.compoundV3LeverageManagementSubDataWithoutSubProxy = {
|
|
901
|
+
encode(market, baseToken, targetRatio, ratioState) {
|
|
902
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
903
|
+
const encodedBaseToken = web3_eth_abi_1.default.encodeParameter('address', baseToken);
|
|
904
|
+
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
905
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
906
|
+
return [encodedMarket, encodedBaseToken, encodedRatioState, encodedTargetRatio];
|
|
907
|
+
},
|
|
908
|
+
decode(subData) {
|
|
909
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
910
|
+
const baseToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
911
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[2]);
|
|
912
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[3]));
|
|
913
|
+
return {
|
|
914
|
+
market, baseToken, targetRatio, ratioState,
|
|
915
|
+
};
|
|
916
|
+
},
|
|
917
|
+
};
|
|
918
|
+
exports.compoundV3LiquidationProtectionSubData = {
|
|
919
|
+
encode(market, baseToken, triggerRepayRatio,
|
|
920
|
+
// TODO -> can remove boost stuff ? Not sure if want it to be compatible or not.
|
|
921
|
+
triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA) {
|
|
922
|
+
return [
|
|
923
|
+
market,
|
|
924
|
+
baseToken,
|
|
925
|
+
new decimal_js_1.default(triggerRepayRatio).mul(1e16).toString(),
|
|
926
|
+
new decimal_js_1.default(triggerBoostRatio).mul(1e16).toString(),
|
|
927
|
+
new decimal_js_1.default(targetBoostRatio).mul(1e16).toString(),
|
|
928
|
+
new decimal_js_1.default(targetRepayRatio).mul(1e16).toString(),
|
|
929
|
+
// @ts-ignore // TODO
|
|
930
|
+
boostEnabled, isEOA,
|
|
931
|
+
];
|
|
932
|
+
},
|
|
933
|
+
decode(subData) {
|
|
934
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[3]);
|
|
935
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
936
|
+
return { targetRatio };
|
|
937
|
+
},
|
|
938
|
+
};
|
|
939
|
+
exports.compoundV3L2LiquidationProtectionSubData = {
|
|
940
|
+
encode(market, baseToken, triggerRepayRatio,
|
|
941
|
+
// TODO -> can remove boost stuff ? Not sure if want it to be compatible or not.
|
|
942
|
+
triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA) {
|
|
784
943
|
let subInput = '0x';
|
|
785
944
|
subInput = subInput.concat(market.slice(2));
|
|
786
945
|
subInput = subInput.concat(baseToken.slice(2));
|
|
@@ -905,6 +1064,21 @@ exports.exchangeLimitOrderSubData = {
|
|
|
905
1064
|
return { fromToken, toToken, amount };
|
|
906
1065
|
},
|
|
907
1066
|
};
|
|
1067
|
+
exports.exchangeLimitOrderSubDataWithoutSubProxy = {
|
|
1068
|
+
encode(fromToken, toToken, amount) {
|
|
1069
|
+
return [
|
|
1070
|
+
web3_eth_abi_1.default.encodeParameter('address', fromToken),
|
|
1071
|
+
web3_eth_abi_1.default.encodeParameter('address', toToken),
|
|
1072
|
+
web3_eth_abi_1.default.encodeParameter('uint256', amount),
|
|
1073
|
+
];
|
|
1074
|
+
},
|
|
1075
|
+
decode: (subData, chainId) => {
|
|
1076
|
+
const fromToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]).toString();
|
|
1077
|
+
const toToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]).toString();
|
|
1078
|
+
const amount = (0, tokens_1.assetAmountInEth)(web3_eth_abi_1.default.decodeParameter('uint256', subData[2]).toString(), (0, tokens_1.getAssetInfoByAddress)(fromToken, chainId).symbol);
|
|
1079
|
+
return { fromToken, toToken, amount };
|
|
1080
|
+
},
|
|
1081
|
+
};
|
|
908
1082
|
/**
|
|
909
1083
|
_______..______ ___ .______ __ ___
|
|
910
1084
|
/ || _ \ / \ | _ \ | |/ /
|
|
@@ -920,6 +1094,8 @@ exports.sparkLeverageManagementSubData = {
|
|
|
920
1094
|
return { targetRatio };
|
|
921
1095
|
},
|
|
922
1096
|
};
|
|
1097
|
+
// ! Any change here will PROBABLY require a change in sparkLiquidationProtectionSubData as well, since it is copy paste
|
|
1098
|
+
// ! Double check before changing
|
|
923
1099
|
exports.sparkLeverageManagementSubDataWithoutSubProxy = {
|
|
924
1100
|
encode(targetRatio, ratioState) {
|
|
925
1101
|
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
@@ -934,6 +1110,20 @@ exports.sparkLeverageManagementSubDataWithoutSubProxy = {
|
|
|
934
1110
|
return { targetRatio, ratioState };
|
|
935
1111
|
},
|
|
936
1112
|
};
|
|
1113
|
+
exports.sparkLiquidationProtectionSubData = {
|
|
1114
|
+
encode(targetRatio, ratioState) {
|
|
1115
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
1116
|
+
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
1117
|
+
const encodedUseDefaultMarket = web3_eth_abi_1.default.encodeParameter('bool', true);
|
|
1118
|
+
const encodedUseOnBehalf = web3_eth_abi_1.default.encodeParameter('bool', false);
|
|
1119
|
+
return [encodedTargetRatio, encodedRatioState, encodedUseDefaultMarket, encodedUseOnBehalf];
|
|
1120
|
+
},
|
|
1121
|
+
decode(subData) {
|
|
1122
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[0]));
|
|
1123
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[1]);
|
|
1124
|
+
return { targetRatio, ratioState };
|
|
1125
|
+
},
|
|
1126
|
+
};
|
|
937
1127
|
exports.sparkCloseGenericSubData = {
|
|
938
1128
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user) {
|
|
939
1129
|
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
@@ -1082,6 +1272,8 @@ exports.crvUSDPaybackSubData = {
|
|
|
1082
1272
|
| | | | | `--' | | |\ \----.| | | | | | | `--' |
|
|
1083
1273
|
|__| |__| \______/ | _| `._____|| _| |__| |__| \______/
|
|
1084
1274
|
*/
|
|
1275
|
+
// ! Any change here will PROBABLY require a change in morphoBlueLiquidationProtectionSubData as well, since it is copy paste
|
|
1276
|
+
// ! Double check before changing
|
|
1085
1277
|
exports.morphoBlueLeverageManagementSubData = {
|
|
1086
1278
|
encode: (loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA) => {
|
|
1087
1279
|
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
@@ -1115,6 +1307,39 @@ exports.morphoBlueLeverageManagementSubData = {
|
|
|
1115
1307
|
};
|
|
1116
1308
|
},
|
|
1117
1309
|
};
|
|
1310
|
+
exports.morphoBlueLiquidationProtectionSubData = {
|
|
1311
|
+
encode: (loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA) => {
|
|
1312
|
+
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
1313
|
+
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
1314
|
+
const oracleEncoded = web3_eth_abi_1.default.encodeParameter('address', oracle);
|
|
1315
|
+
const irmEncoded = web3_eth_abi_1.default.encodeParameter('address', irm);
|
|
1316
|
+
const lltvEncoded = web3_eth_abi_1.default.encodeParameter('uint256', lltv);
|
|
1317
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
1318
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
1319
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
1320
|
+
const isEOAEncoded = web3_eth_abi_1.default.encodeParameter('bool', isEOA);
|
|
1321
|
+
return [loanTokenEncoded, collTokenEncoded, oracleEncoded, irmEncoded, lltvEncoded, ratioStateEncoded, targetRatioEncoded, userEncoded, isEOAEncoded];
|
|
1322
|
+
},
|
|
1323
|
+
decode: (subData) => {
|
|
1324
|
+
const loanToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
1325
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
1326
|
+
const oracle = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
1327
|
+
const irm = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
1328
|
+
const lltv = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
1329
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[6]);
|
|
1330
|
+
const user = web3_eth_abi_1.default.decodeParameter('address', subData[7]);
|
|
1331
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
1332
|
+
return {
|
|
1333
|
+
loanToken,
|
|
1334
|
+
collToken,
|
|
1335
|
+
oracle,
|
|
1336
|
+
irm,
|
|
1337
|
+
lltv,
|
|
1338
|
+
user,
|
|
1339
|
+
targetRatio,
|
|
1340
|
+
};
|
|
1341
|
+
},
|
|
1342
|
+
};
|
|
1118
1343
|
exports.morphoBlueLeverageManagementOnPriceSubData = {
|
|
1119
1344
|
encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user) {
|
|
1120
1345
|
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
@@ -1184,6 +1409,8 @@ _______ __ __ __ __ _______
|
|
|
1184
1409
|
| | | `----.| `--' | | | | '--' |
|
|
1185
1410
|
|__| |_______| \______/ |__| |_______/
|
|
1186
1411
|
*/
|
|
1412
|
+
// ! Any change here will PROBABLY require a change in fluidLeverageManagementSubData as well, since it is copy paste
|
|
1413
|
+
// ! Double check before changing
|
|
1187
1414
|
exports.fluidLeverageManagementSubData = {
|
|
1188
1415
|
encode: (nftId, vault, ratioState, targetRatio) => {
|
|
1189
1416
|
const nftIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', nftId);
|
|
@@ -1191,9 +1418,40 @@ exports.fluidLeverageManagementSubData = {
|
|
|
1191
1418
|
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
1192
1419
|
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
1193
1420
|
const wrapEthEncoded = web3_eth_abi_1.default.encodeParameter('bool', true);
|
|
1194
|
-
const
|
|
1195
|
-
const
|
|
1196
|
-
const
|
|
1421
|
+
const collActionType = enums_1.CollActionType.WITHDRAW;
|
|
1422
|
+
const debtActionType = enums_1.DebtActionType.PAYBACK;
|
|
1423
|
+
const collActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
1424
|
+
const debtActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
1425
|
+
return [
|
|
1426
|
+
nftIdEncoded,
|
|
1427
|
+
vaultEncoded,
|
|
1428
|
+
ratioStateEncoded,
|
|
1429
|
+
targetRatioEncoded,
|
|
1430
|
+
wrapEthEncoded,
|
|
1431
|
+
collActionTypeEncoded,
|
|
1432
|
+
debtActionTypeEncoded,
|
|
1433
|
+
];
|
|
1434
|
+
},
|
|
1435
|
+
decode: (subData) => {
|
|
1436
|
+
const nftId = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]);
|
|
1437
|
+
const vault = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
1438
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[2]);
|
|
1439
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[3]);
|
|
1440
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
1441
|
+
return {
|
|
1442
|
+
nftId, vault, ratioState, targetRatio,
|
|
1443
|
+
};
|
|
1444
|
+
},
|
|
1445
|
+
};
|
|
1446
|
+
exports.fluidLiquidationProtectionSubData = {
|
|
1447
|
+
encode: (nftId, vault, ratioState, targetRatio) => {
|
|
1448
|
+
const nftIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', nftId);
|
|
1449
|
+
const vaultEncoded = web3_eth_abi_1.default.encodeParameter('address', vault);
|
|
1450
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
1451
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
1452
|
+
const wrapEthEncoded = web3_eth_abi_1.default.encodeParameter('bool', true);
|
|
1453
|
+
const collActionType = enums_1.CollActionType.WITHDRAW;
|
|
1454
|
+
const debtActionType = enums_1.DebtActionType.PAYBACK;
|
|
1197
1455
|
const collActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
1198
1456
|
const debtActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
1199
1457
|
return [
|
|
@@ -1337,48 +1337,6 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1337
1337
|
});
|
|
1338
1338
|
});
|
|
1339
1339
|
});
|
|
1340
|
-
describe('When testing subDataService.compoundV3L2LeverageManagementSubData', () => {
|
|
1341
|
-
describe('encode()', () => {
|
|
1342
|
-
const examples = [
|
|
1343
|
-
[
|
|
1344
|
-
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e00000100',
|
|
1345
|
-
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 190, true, false]
|
|
1346
|
-
],
|
|
1347
|
-
[
|
|
1348
|
-
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee00000000',
|
|
1349
|
-
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 110, false, false]
|
|
1350
|
-
],
|
|
1351
|
-
];
|
|
1352
|
-
examples.forEach(([expected, actual]) => {
|
|
1353
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1354
|
-
(0, chai_1.expect)(subDataService.compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1355
|
-
});
|
|
1356
|
-
});
|
|
1357
|
-
});
|
|
1358
|
-
describe('decode()', () => {
|
|
1359
|
-
const examples = [
|
|
1360
|
-
[
|
|
1361
|
-
{ targetRatio: 200 },
|
|
1362
|
-
[
|
|
1363
|
-
'0x0000000000000000000000000313d212133AFaB8F2B829B1066c7E43cAd94E2c', '0x0000000000000000000000000213d212133AFaB8F2B829B1066c7E43cAd94E2c',
|
|
1364
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1365
|
-
],
|
|
1366
|
-
],
|
|
1367
|
-
[
|
|
1368
|
-
{ targetRatio: 123 },
|
|
1369
|
-
[
|
|
1370
|
-
'0x0000000000000000000000000313d212133AFaB8F2B829B1066c7E43cAd94E2c', '0x0000000000000000000000000413d212133AFaB8F2B829B1066c7E43cAd94E2c',
|
|
1371
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
1372
|
-
],
|
|
1373
|
-
],
|
|
1374
|
-
];
|
|
1375
|
-
examples.forEach(([expected, actual]) => {
|
|
1376
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1377
|
-
(0, chai_1.expect)(subDataService.compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1378
|
-
});
|
|
1379
|
-
});
|
|
1380
|
-
});
|
|
1381
|
-
});
|
|
1382
1340
|
describe('When testing subDataService.morphoBlueLeverageManagementSubData', () => {
|
|
1383
1341
|
describe('encode()', () => {
|
|
1384
1342
|
const examples = [
|
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,5 @@ 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.OptimismIds | typeof Bundles.ArbitrumIds | typeof Bundles.BaseIds;
|
|
32
|
+
export declare function getCompoundV3LeverageManagementBundleId(network: ChainId, isEOA: boolean, isBoost: boolean): number;
|