@defisaver/automation-sdk 3.3.15-liq-prot-2-dev → 3.3.16
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 +9 -124
- package/cjs/index.d.ts +3 -4
- package/cjs/index.js +2 -6
- package/cjs/services/strategiesService.js +1 -148
- package/cjs/services/strategySubService.d.ts +2 -9
- package/cjs/services/strategySubService.js +1 -52
- package/cjs/services/strategySubService.test.js +67 -0
- package/cjs/services/subDataService.d.ts +3 -58
- package/cjs/services/subDataService.js +18 -164
- package/cjs/services/subDataService.test.js +168 -0
- package/cjs/services/triggerService.test.js +60 -0
- package/cjs/services/utils.d.ts +1 -3
- package/cjs/services/utils.js +1 -34
- package/cjs/services/utils.test.js +0 -25
- package/cjs/types/enums.d.ts +6 -33
- package/cjs/types/enums.js +3 -30
- package/esm/constants/index.js +9 -124
- package/esm/index.d.ts +3 -4
- package/esm/index.js +3 -7
- package/esm/services/strategiesService.js +1 -148
- package/esm/services/strategySubService.d.ts +2 -9
- package/esm/services/strategySubService.js +2 -53
- package/esm/services/strategySubService.test.js +67 -0
- package/esm/services/subDataService.d.ts +3 -58
- package/esm/services/subDataService.js +16 -162
- package/esm/services/subDataService.test.js +168 -0
- package/esm/services/triggerService.test.js +61 -1
- package/esm/services/utils.d.ts +1 -3
- package/esm/services/utils.js +1 -32
- package/esm/services/utils.test.js +2 -27
- package/esm/types/enums.d.ts +6 -33
- package/esm/types/enums.js +3 -30
- package/package.json +1 -1
- package/src/constants/index.ts +10 -126
- package/src/index.ts +6 -24
- package/src/services/strategiesService.ts +1 -212
- package/src/services/strategySubService.test.ts +84 -0
- package/src/services/strategySubService.ts +5 -149
- package/src/services/subDataService.test.ts +182 -0
- package/src/services/subDataService.ts +22 -229
- package/src/services/triggerService.test.ts +69 -0
- package/src/services/utils.test.ts +1 -32
- package/src/services/utils.ts +1 -32
- package/src/types/enums.ts +5 -30
|
@@ -1225,6 +1225,73 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1225
1225
|
});
|
|
1226
1226
|
});
|
|
1227
1227
|
});
|
|
1228
|
+
describe('leverageManagementOnPrice()', () => {
|
|
1229
|
+
const examples = [
|
|
1230
|
+
[
|
|
1231
|
+
[
|
|
1232
|
+
enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
1233
|
+
true,
|
|
1234
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1235
|
+
[
|
|
1236
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1237
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1238
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1239
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1240
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1241
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1242
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1243
|
+
],
|
|
1244
|
+
],
|
|
1245
|
+
[
|
|
1246
|
+
enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
1247
|
+
true,
|
|
1248
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1249
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1250
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1251
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1252
|
+
'945000000000000000',
|
|
1253
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1254
|
+
200,
|
|
1255
|
+
2500,
|
|
1256
|
+
enums_1.RatioState.UNDER,
|
|
1257
|
+
],
|
|
1258
|
+
],
|
|
1259
|
+
[
|
|
1260
|
+
[
|
|
1261
|
+
enums_1.Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
|
|
1262
|
+
true,
|
|
1263
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1264
|
+
[
|
|
1265
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1266
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1267
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1268
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1269
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1270
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1271
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1272
|
+
],
|
|
1273
|
+
],
|
|
1274
|
+
[
|
|
1275
|
+
enums_1.Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
|
|
1276
|
+
true,
|
|
1277
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1278
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1279
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1280
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1281
|
+
'945000000000000000',
|
|
1282
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1283
|
+
160,
|
|
1284
|
+
4000,
|
|
1285
|
+
enums_1.RatioState.OVER,
|
|
1286
|
+
],
|
|
1287
|
+
],
|
|
1288
|
+
];
|
|
1289
|
+
examples.forEach(([expected, actual]) => {
|
|
1290
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1291
|
+
(0, chai_1.expect)(strategySubService_1.morphoBlueEncode.leverageManagementOnPrice(...actual)).to.eql(expected);
|
|
1292
|
+
});
|
|
1293
|
+
});
|
|
1294
|
+
});
|
|
1228
1295
|
describe('closeOnPrice()', () => {
|
|
1229
1296
|
const examples = [
|
|
1230
1297
|
[
|
|
@@ -71,14 +71,6 @@ 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
|
-
};
|
|
82
74
|
/**
|
|
83
75
|
__ __ ______ __ __ __ .___________.____ ____ ____ ____ __
|
|
84
76
|
| | | | / __ \ | | | | | | | |\ \ / / \ \ / / /_ |
|
|
@@ -220,13 +212,6 @@ export declare const aaveV3LeverageManagementSubDataWithoutSubProxy: {
|
|
|
220
212
|
ratioState: RatioState;
|
|
221
213
|
};
|
|
222
214
|
};
|
|
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
|
-
};
|
|
230
215
|
export declare const aaveV3LeverageManagementOnPriceGeneric: {
|
|
231
216
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): string[];
|
|
232
217
|
decode(subData: string[]): {
|
|
@@ -299,15 +284,6 @@ export declare const aaveV4LeverageManagementSubData: {
|
|
|
299
284
|
targetRatio: number;
|
|
300
285
|
};
|
|
301
286
|
};
|
|
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
|
-
};
|
|
311
287
|
export declare const aaveV4LeverageManagementOnPriceSubData: {
|
|
312
288
|
encode: (spoke: EthereumAddress, owner: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, ratioState: RatioState, targetRatio: number) => string[];
|
|
313
289
|
decode: (subData: string[]) => {
|
|
@@ -374,16 +350,13 @@ export declare const compoundV2LeverageManagementSubDataWithoutSubProxy: {
|
|
|
374
350
|
| `----.| `--' | | | | | | | \ / ___) |
|
|
375
351
|
\______| \______/ |__| |__| | _| \__/ |____/
|
|
376
352
|
*/
|
|
377
|
-
export declare const
|
|
378
|
-
encode(market: EthereumAddress, baseToken: EthereumAddress,
|
|
353
|
+
export declare const compoundV3LeverageManagementSubData: {
|
|
354
|
+
encode(market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean): string[];
|
|
379
355
|
decode(subData: string[]): {
|
|
380
|
-
market: EthereumAddress;
|
|
381
|
-
baseToken: EthereumAddress;
|
|
382
356
|
targetRatio: number;
|
|
383
|
-
ratioState: RatioState;
|
|
384
357
|
};
|
|
385
358
|
};
|
|
386
|
-
export declare const
|
|
359
|
+
export declare const compoundV3LeverageManagementSubDataWithoutSubProxy: {
|
|
387
360
|
encode(market: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, ratioState: RatioState): string[];
|
|
388
361
|
decode(subData: string[]): {
|
|
389
362
|
market: EthereumAddress;
|
|
@@ -466,13 +439,6 @@ export declare const sparkLeverageManagementSubDataWithoutSubProxy: {
|
|
|
466
439
|
ratioState: RatioState;
|
|
467
440
|
};
|
|
468
441
|
};
|
|
469
|
-
export declare const sparkLiquidationProtectionSubData: {
|
|
470
|
-
encode(targetRatio: number, ratioState: RatioState): string[];
|
|
471
|
-
decode(subData: string[]): {
|
|
472
|
-
targetRatio: number;
|
|
473
|
-
ratioState: RatioState;
|
|
474
|
-
};
|
|
475
|
-
};
|
|
476
442
|
export declare const sparkCloseGenericSubData: {
|
|
477
443
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType, marketAddr: EthereumAddress, user: EthereumAddress): string[];
|
|
478
444
|
decode(subData: string[]): {
|
|
@@ -551,18 +517,6 @@ export declare const morphoBlueLeverageManagementSubData: {
|
|
|
551
517
|
targetRatio: number;
|
|
552
518
|
};
|
|
553
519
|
};
|
|
554
|
-
export declare const morphoBlueLiquidationProtectionSubData: {
|
|
555
|
-
encode: (loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, user: EthereumAddress, isEOA: boolean) => string[];
|
|
556
|
-
decode: (subData: string[]) => {
|
|
557
|
-
loanToken: string;
|
|
558
|
-
collToken: string;
|
|
559
|
-
oracle: string;
|
|
560
|
-
irm: string;
|
|
561
|
-
lltv: string;
|
|
562
|
-
user: string;
|
|
563
|
-
targetRatio: number;
|
|
564
|
-
};
|
|
565
|
-
};
|
|
566
520
|
export declare const morphoBlueLeverageManagementOnPriceSubData: {
|
|
567
521
|
encode(loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, targetRatio: number, user: EthereumAddress): string[];
|
|
568
522
|
decode(subData: string[]): {
|
|
@@ -604,12 +558,3 @@ export declare const fluidLeverageManagementSubData: {
|
|
|
604
558
|
targetRatio: number;
|
|
605
559
|
};
|
|
606
560
|
};
|
|
607
|
-
export declare const fluidLiquidationProtectionSubData: {
|
|
608
|
-
encode: (nftId: string, vault: EthereumAddress, ratioState: RatioState, targetRatio: number) => string[];
|
|
609
|
-
decode: (subData: string[]) => {
|
|
610
|
-
nftId: string;
|
|
611
|
-
vault: string;
|
|
612
|
-
ratioState: RatioState;
|
|
613
|
-
targetRatio: number;
|
|
614
|
-
};
|
|
615
|
-
};
|
|
@@ -3,8 +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.
|
|
7
|
-
exports.
|
|
6
|
+
exports.morphoBlueCloseOnPriceSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.sparkCollateralSwitchSubData = exports.sparkLeverageManagementOnPriceSubData = exports.sparkCloseGenericSubData = exports.sparkLeverageManagementSubDataWithoutSubProxy = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubDataWithoutSubProxy = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.compoundV3LeverageManagementSubDataWithoutSubProxy = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubDataWithoutSubProxy = exports.compoundV2LeverageManagementSubData = exports.aaveV4CollateralSwitchSubData = exports.aaveV4CloseSubData = exports.aaveV4LeverageManagementOnPriceSubData = exports.aaveV4LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3CollateralSwitchSubData = exports.aaveV3CloseGenericSubData = exports.aaveV3LeverageManagementOnPriceGeneric = 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.makerLeverageManagementWithoutSubProxy = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.makerRepayFromSavingsSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = void 0;
|
|
7
|
+
exports.fluidLeverageManagementSubData = void 0;
|
|
8
8
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
9
9
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
10
10
|
const web3_utils_1 = require("web3-utils");
|
|
@@ -132,8 +132,6 @@ exports.makerLeverageManagementSubData = {
|
|
|
132
132
|
return { vaultId, targetRatio };
|
|
133
133
|
},
|
|
134
134
|
};
|
|
135
|
-
// ! Any change here will PROBABLY require a change in makerLiquidationProtectionSubData as well, since it is copy paste
|
|
136
|
-
// ! Double check before changing
|
|
137
135
|
exports.makerLeverageManagementWithoutSubProxy = {
|
|
138
136
|
encode(vaultId, targetRatio, daiAddr) {
|
|
139
137
|
const encodedVaultId = web3_eth_abi_1.default.encodeParameter('uint256', vaultId);
|
|
@@ -148,20 +146,6 @@ exports.makerLeverageManagementWithoutSubProxy = {
|
|
|
148
146
|
return { vaultId, targetRatio, daiAddr };
|
|
149
147
|
},
|
|
150
148
|
};
|
|
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
|
-
};
|
|
165
149
|
/**
|
|
166
150
|
__ __ ______ __ __ __ .___________.____ ____ ____ ____ __
|
|
167
151
|
| | | | / __ \ | | | | | | | |\ \ / / \ \ / / /_ |
|
|
@@ -466,8 +450,6 @@ exports.aaveV3LeverageManagementSubData = {
|
|
|
466
450
|
return { targetRatio };
|
|
467
451
|
},
|
|
468
452
|
};
|
|
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
|
|
471
453
|
exports.aaveV3LeverageManagementSubDataWithoutSubProxy = {
|
|
472
454
|
encode(targetRatio, ratioState, market, user, isGeneric) {
|
|
473
455
|
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
@@ -487,20 +469,6 @@ exports.aaveV3LeverageManagementSubDataWithoutSubProxy = {
|
|
|
487
469
|
return { targetRatio, ratioState };
|
|
488
470
|
},
|
|
489
471
|
};
|
|
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
|
-
};
|
|
504
472
|
exports.aaveV3LeverageManagementOnPriceGeneric = {
|
|
505
473
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user) {
|
|
506
474
|
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
@@ -662,8 +630,6 @@ exports.aaveV3LeverageManagementOnPriceSubData = {
|
|
|
662
630
|
/ _____ \ / _____ \ \ / | |____ \ / | |
|
|
663
631
|
/__/ \__\ /__/ \__\ \__/ |_______| \__/ |_|
|
|
664
632
|
*/
|
|
665
|
-
// ! Any change here will PROBABLY require a change in aaveV4LiquidationProtectionSubData as well, since it is copy paste
|
|
666
|
-
// ! Double check before changing
|
|
667
633
|
exports.aaveV4LeverageManagementSubData = {
|
|
668
634
|
encode: (spoke, owner, ratioState, targetRatio) => {
|
|
669
635
|
const spokeEncoded = web3_eth_abi_1.default.encodeParameter('address', spoke);
|
|
@@ -690,32 +656,6 @@ exports.aaveV4LeverageManagementSubData = {
|
|
|
690
656
|
};
|
|
691
657
|
},
|
|
692
658
|
};
|
|
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
|
-
};
|
|
719
659
|
exports.aaveV4LeverageManagementOnPriceSubData = {
|
|
720
660
|
encode: (spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, ratioState, targetRatio) => {
|
|
721
661
|
const spokeEncoded = web3_eth_abi_1.default.encodeParameter('address', spoke);
|
|
@@ -874,27 +814,26 @@ exports.compoundV2LeverageManagementSubDataWithoutSubProxy = {
|
|
|
874
814
|
| `----.| `--' | | | | | | | \ / ___) |
|
|
875
815
|
\______| \______/ |__| |__| | _| \__/ |____/
|
|
876
816
|
*/
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
817
|
+
exports.compoundV3LeverageManagementSubData = {
|
|
818
|
+
encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA) {
|
|
819
|
+
return [
|
|
820
|
+
market,
|
|
821
|
+
baseToken,
|
|
822
|
+
new decimal_js_1.default(triggerRepayRatio).mul(1e16).toString(),
|
|
823
|
+
new decimal_js_1.default(triggerBoostRatio).mul(1e16).toString(),
|
|
824
|
+
new decimal_js_1.default(targetBoostRatio).mul(1e16).toString(),
|
|
825
|
+
new decimal_js_1.default(targetRepayRatio).mul(1e16).toString(),
|
|
826
|
+
// @ts-ignore // TODO
|
|
827
|
+
boostEnabled, isEOA,
|
|
828
|
+
];
|
|
886
829
|
},
|
|
887
830
|
decode(subData) {
|
|
888
|
-
const
|
|
889
|
-
const
|
|
890
|
-
|
|
891
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[3]));
|
|
892
|
-
return {
|
|
893
|
-
market, baseToken, targetRatio, ratioState,
|
|
894
|
-
};
|
|
831
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[3]);
|
|
832
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
833
|
+
return { targetRatio };
|
|
895
834
|
},
|
|
896
835
|
};
|
|
897
|
-
exports.
|
|
836
|
+
exports.compoundV3LeverageManagementSubDataWithoutSubProxy = {
|
|
898
837
|
encode(market, baseToken, targetRatio, ratioState) {
|
|
899
838
|
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
900
839
|
const encodedBaseToken = web3_eth_abi_1.default.encodeParameter('address', baseToken);
|
|
@@ -1045,8 +984,6 @@ exports.sparkLeverageManagementSubData = {
|
|
|
1045
984
|
return { targetRatio };
|
|
1046
985
|
},
|
|
1047
986
|
};
|
|
1048
|
-
// ! Any change here will PROBABLY require a change in sparkLiquidationProtectionSubData as well, since it is copy paste
|
|
1049
|
-
// ! Double check before changing
|
|
1050
987
|
exports.sparkLeverageManagementSubDataWithoutSubProxy = {
|
|
1051
988
|
encode(targetRatio, ratioState) {
|
|
1052
989
|
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
@@ -1061,20 +998,6 @@ exports.sparkLeverageManagementSubDataWithoutSubProxy = {
|
|
|
1061
998
|
return { targetRatio, ratioState };
|
|
1062
999
|
},
|
|
1063
1000
|
};
|
|
1064
|
-
exports.sparkLiquidationProtectionSubData = {
|
|
1065
|
-
encode(targetRatio, ratioState) {
|
|
1066
|
-
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
1067
|
-
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
1068
|
-
const encodedUseDefaultMarket = web3_eth_abi_1.default.encodeParameter('bool', true);
|
|
1069
|
-
const encodedUseOnBehalf = web3_eth_abi_1.default.encodeParameter('bool', false);
|
|
1070
|
-
return [encodedTargetRatio, encodedRatioState, encodedUseDefaultMarket, encodedUseOnBehalf];
|
|
1071
|
-
},
|
|
1072
|
-
decode(subData) {
|
|
1073
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[0]));
|
|
1074
|
-
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[1]);
|
|
1075
|
-
return { targetRatio, ratioState };
|
|
1076
|
-
},
|
|
1077
|
-
};
|
|
1078
1001
|
exports.sparkCloseGenericSubData = {
|
|
1079
1002
|
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user) {
|
|
1080
1003
|
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
@@ -1223,8 +1146,6 @@ exports.crvUSDPaybackSubData = {
|
|
|
1223
1146
|
| | | | | `--' | | |\ \----.| | | | | | | `--' |
|
|
1224
1147
|
|__| |__| \______/ | _| `._____|| _| |__| |__| \______/
|
|
1225
1148
|
*/
|
|
1226
|
-
// ! Any change here will PROBABLY require a change in morphoBlueLiquidationProtectionSubData as well, since it is copy paste
|
|
1227
|
-
// ! Double check before changing
|
|
1228
1149
|
exports.morphoBlueLeverageManagementSubData = {
|
|
1229
1150
|
encode: (loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA) => {
|
|
1230
1151
|
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
@@ -1258,39 +1179,6 @@ exports.morphoBlueLeverageManagementSubData = {
|
|
|
1258
1179
|
};
|
|
1259
1180
|
},
|
|
1260
1181
|
};
|
|
1261
|
-
exports.morphoBlueLiquidationProtectionSubData = {
|
|
1262
|
-
encode: (loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA) => {
|
|
1263
|
-
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
1264
|
-
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
1265
|
-
const oracleEncoded = web3_eth_abi_1.default.encodeParameter('address', oracle);
|
|
1266
|
-
const irmEncoded = web3_eth_abi_1.default.encodeParameter('address', irm);
|
|
1267
|
-
const lltvEncoded = web3_eth_abi_1.default.encodeParameter('uint256', lltv);
|
|
1268
|
-
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
1269
|
-
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
1270
|
-
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
1271
|
-
const isEOAEncoded = web3_eth_abi_1.default.encodeParameter('bool', isEOA);
|
|
1272
|
-
return [loanTokenEncoded, collTokenEncoded, oracleEncoded, irmEncoded, lltvEncoded, ratioStateEncoded, targetRatioEncoded, userEncoded, isEOAEncoded];
|
|
1273
|
-
},
|
|
1274
|
-
decode: (subData) => {
|
|
1275
|
-
const loanToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
1276
|
-
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
1277
|
-
const oracle = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
1278
|
-
const irm = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
1279
|
-
const lltv = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
1280
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[6]);
|
|
1281
|
-
const user = web3_eth_abi_1.default.decodeParameter('address', subData[7]);
|
|
1282
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
1283
|
-
return {
|
|
1284
|
-
loanToken,
|
|
1285
|
-
collToken,
|
|
1286
|
-
oracle,
|
|
1287
|
-
irm,
|
|
1288
|
-
lltv,
|
|
1289
|
-
user,
|
|
1290
|
-
targetRatio,
|
|
1291
|
-
};
|
|
1292
|
-
},
|
|
1293
|
-
};
|
|
1294
1182
|
exports.morphoBlueLeverageManagementOnPriceSubData = {
|
|
1295
1183
|
encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user) {
|
|
1296
1184
|
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
@@ -1360,8 +1248,6 @@ _______ __ __ __ __ _______
|
|
|
1360
1248
|
| | | `----.| `--' | | | | '--' |
|
|
1361
1249
|
|__| |_______| \______/ |__| |_______/
|
|
1362
1250
|
*/
|
|
1363
|
-
// ! Any change here will PROBABLY require a change in fluidLeverageManagementSubData as well, since it is copy paste
|
|
1364
|
-
// ! Double check before changing
|
|
1365
1251
|
exports.fluidLeverageManagementSubData = {
|
|
1366
1252
|
encode: (nftId, vault, ratioState, targetRatio) => {
|
|
1367
1253
|
const nftIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', nftId);
|
|
@@ -1395,35 +1281,3 @@ exports.fluidLeverageManagementSubData = {
|
|
|
1395
1281
|
};
|
|
1396
1282
|
},
|
|
1397
1283
|
};
|
|
1398
|
-
exports.fluidLiquidationProtectionSubData = {
|
|
1399
|
-
encode: (nftId, vault, ratioState, targetRatio) => {
|
|
1400
|
-
const nftIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', nftId);
|
|
1401
|
-
const vaultEncoded = web3_eth_abi_1.default.encodeParameter('address', vault);
|
|
1402
|
-
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
1403
|
-
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
1404
|
-
const wrapEthEncoded = web3_eth_abi_1.default.encodeParameter('bool', true);
|
|
1405
|
-
const collActionType = enums_1.CollActionType.WITHDRAW;
|
|
1406
|
-
const debtActionType = enums_1.DebtActionType.PAYBACK;
|
|
1407
|
-
const collActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
1408
|
-
const debtActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
1409
|
-
return [
|
|
1410
|
-
nftIdEncoded,
|
|
1411
|
-
vaultEncoded,
|
|
1412
|
-
ratioStateEncoded,
|
|
1413
|
-
targetRatioEncoded,
|
|
1414
|
-
wrapEthEncoded,
|
|
1415
|
-
collActionTypeEncoded,
|
|
1416
|
-
debtActionTypeEncoded,
|
|
1417
|
-
];
|
|
1418
|
-
},
|
|
1419
|
-
decode: (subData) => {
|
|
1420
|
-
const nftId = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]);
|
|
1421
|
-
const vault = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
1422
|
-
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[2]);
|
|
1423
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[3]);
|
|
1424
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
1425
|
-
return {
|
|
1426
|
-
nftId, vault, ratioState, targetRatio,
|
|
1427
|
-
};
|
|
1428
|
-
},
|
|
1429
|
-
};
|
|
@@ -713,6 +713,74 @@ describe('Feature: subDataService.ts', () => {
|
|
|
713
713
|
});
|
|
714
714
|
});
|
|
715
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);
|
|
780
|
+
});
|
|
781
|
+
});
|
|
782
|
+
});
|
|
783
|
+
});
|
|
716
784
|
describe('When testing subDataService.morphoAaveV2LeverageManagementSubData', () => {
|
|
717
785
|
describe('encode()', () => {
|
|
718
786
|
const examples = [
|
|
@@ -1411,6 +1479,106 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1411
1479
|
});
|
|
1412
1480
|
});
|
|
1413
1481
|
});
|
|
1482
|
+
describe('When testing subDataService.morphoBlueLeverageManagementOnPriceSubData', () => {
|
|
1483
|
+
describe('encode()', () => {
|
|
1484
|
+
const examples = [
|
|
1485
|
+
[
|
|
1486
|
+
[
|
|
1487
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1488
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1489
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1490
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1491
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1492
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1493
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1494
|
+
],
|
|
1495
|
+
[
|
|
1496
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1497
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1498
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1499
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1500
|
+
'945000000000000000',
|
|
1501
|
+
200,
|
|
1502
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1503
|
+
],
|
|
1504
|
+
],
|
|
1505
|
+
[
|
|
1506
|
+
[
|
|
1507
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1508
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1509
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1510
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1511
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1512
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1513
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1514
|
+
],
|
|
1515
|
+
[
|
|
1516
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1517
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1518
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1519
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1520
|
+
'945000000000000000',
|
|
1521
|
+
160,
|
|
1522
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1523
|
+
],
|
|
1524
|
+
],
|
|
1525
|
+
];
|
|
1526
|
+
examples.forEach(([expected, actual]) => {
|
|
1527
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1528
|
+
(0, chai_1.expect)(subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1529
|
+
});
|
|
1530
|
+
});
|
|
1531
|
+
});
|
|
1532
|
+
describe('decode()', () => {
|
|
1533
|
+
const examples = [
|
|
1534
|
+
[
|
|
1535
|
+
{
|
|
1536
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1537
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1538
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1539
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1540
|
+
lltv: '945000000000000000',
|
|
1541
|
+
targetRatio: 200,
|
|
1542
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1543
|
+
},
|
|
1544
|
+
[
|
|
1545
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1546
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1547
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1548
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1549
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1550
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1551
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1552
|
+
],
|
|
1553
|
+
],
|
|
1554
|
+
[
|
|
1555
|
+
{
|
|
1556
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1557
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1558
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1559
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1560
|
+
lltv: '945000000000000000',
|
|
1561
|
+
targetRatio: 160,
|
|
1562
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1563
|
+
},
|
|
1564
|
+
[
|
|
1565
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1566
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1567
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1568
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1569
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1570
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1571
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1572
|
+
],
|
|
1573
|
+
],
|
|
1574
|
+
];
|
|
1575
|
+
examples.forEach(([expected, actual]) => {
|
|
1576
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1577
|
+
(0, chai_1.expect)(subDataService.morphoBlueLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1578
|
+
});
|
|
1579
|
+
});
|
|
1580
|
+
});
|
|
1581
|
+
});
|
|
1414
1582
|
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1415
1583
|
describe('encode()', () => {
|
|
1416
1584
|
const examples = [
|