@defisaver/automation-sdk 3.3.14 → 3.3.15-dev-13011-morpho-repay-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 +15 -0
- package/cjs/services/strategiesService.js +31 -17
- package/cjs/services/strategySubService.d.ts +5 -11
- package/cjs/services/strategySubService.js +27 -62
- package/cjs/services/strategySubService.test.js +65 -232
- package/cjs/services/subDataService.d.ts +35 -2
- package/cjs/services/subDataService.js +84 -20
- package/cjs/services/subDataService.test.js +100 -42
- package/cjs/services/triggerService.test.js +60 -0
- package/cjs/types/enums.d.ts +6 -3
- package/cjs/types/enums.js +3 -0
- package/esm/constants/index.js +15 -0
- package/esm/services/strategiesService.js +31 -17
- package/esm/services/strategySubService.d.ts +5 -11
- package/esm/services/strategySubService.js +26 -58
- package/esm/services/strategySubService.test.js +67 -234
- package/esm/services/subDataService.d.ts +35 -2
- package/esm/services/subDataService.js +82 -19
- package/esm/services/subDataService.test.js +100 -42
- package/esm/services/triggerService.test.js +61 -1
- package/esm/types/enums.d.ts +6 -3
- package/esm/types/enums.js +3 -0
- package/package.json +1 -1
- package/src/constants/index.ts +15 -0
- package/src/services/strategiesService.ts +31 -17
- package/src/services/strategySubService.test.ts +84 -279
- package/src/services/strategySubService.ts +60 -111
- package/src/services/subDataService.test.ts +110 -48
- package/src/services/subDataService.ts +107 -28
- package/src/services/triggerService.test.ts +69 -0
- package/src/types/enums.ts +3 -0
|
@@ -161,6 +161,23 @@ export const liquityLeverageManagementSubData = {
|
|
|
161
161
|
return { targetRatio };
|
|
162
162
|
},
|
|
163
163
|
};
|
|
164
|
+
export const liquityLeverageManagementSubDataWithoutSubProxy = {
|
|
165
|
+
encode(targetRatio, ratioState) {
|
|
166
|
+
const encodedRatioState = AbiCoder.encodeParameter('uint8', ratioState);
|
|
167
|
+
const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
168
|
+
const isRepay = ratioState === RatioState.UNDER;
|
|
169
|
+
const collActionType = isRepay ? CollActionType.WITHDRAW : CollActionType.SUPPLY;
|
|
170
|
+
const debtActionType = isRepay ? DebtActionType.PAYBACK : DebtActionType.BORROW;
|
|
171
|
+
const collActionTypeEncoded = AbiCoder.encodeParameter('uint8', collActionType);
|
|
172
|
+
const debtActionTypeEncoded = AbiCoder.encodeParameter('uint8', debtActionType);
|
|
173
|
+
return [encodedRatioState, encodedTargetRatio, collActionTypeEncoded, debtActionTypeEncoded];
|
|
174
|
+
},
|
|
175
|
+
decode(subData) {
|
|
176
|
+
const ratioState = AbiCoder.decodeParameter('uint8', subData[0]);
|
|
177
|
+
const targetRatio = weiToRatioPercentage(AbiCoder.decodeParameter('uint256', subData[1]));
|
|
178
|
+
return { targetRatio, ratioState };
|
|
179
|
+
},
|
|
180
|
+
};
|
|
164
181
|
export const liquityCloseSubData = {
|
|
165
182
|
encode(closeToAssetAddr, chainId = ChainId.Ethereum, collAddr, debtAddr) {
|
|
166
183
|
const _collAddr = collAddr || getAssetInfo('WETH', chainId).address;
|
|
@@ -392,6 +409,25 @@ export const aaveV2LeverageManagementSubData = {
|
|
|
392
409
|
return { targetRatio };
|
|
393
410
|
},
|
|
394
411
|
};
|
|
412
|
+
export const aaveV2LeverageManagementSubDataWithoutSubProxy = {
|
|
413
|
+
encode(market, targetRatio, ratioState) {
|
|
414
|
+
const encodedMarket = AbiCoder.encodeParameter('address', market);
|
|
415
|
+
const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
416
|
+
const encodedRatioState = AbiCoder.encodeParameter('uint8', ratioState);
|
|
417
|
+
const isBoost = ratioState === RatioState.OVER;
|
|
418
|
+
if (isBoost) {
|
|
419
|
+
const enableAsCollEncoded = AbiCoder.encodeParameter('uint256', 1);
|
|
420
|
+
return [encodedMarket, encodedTargetRatio, encodedRatioState, enableAsCollEncoded];
|
|
421
|
+
}
|
|
422
|
+
return [encodedMarket, encodedTargetRatio, encodedRatioState];
|
|
423
|
+
},
|
|
424
|
+
decode(subData) {
|
|
425
|
+
const market = AbiCoder.decodeParameter('address', subData[0]);
|
|
426
|
+
const targetRatio = weiToRatioPercentage(AbiCoder.decodeParameter('uint256', subData[1]));
|
|
427
|
+
const ratioState = AbiCoder.decodeParameter('uint8', subData[2]);
|
|
428
|
+
return { market, targetRatio, ratioState };
|
|
429
|
+
},
|
|
430
|
+
};
|
|
395
431
|
/**
|
|
396
432
|
___ ___ ____ ____ _______ ____ ____ ____
|
|
397
433
|
/ \ / \ \ \ / / | ____| \ \ / / |___ \
|
|
@@ -746,6 +782,23 @@ export const compoundV2LeverageManagementSubData = {
|
|
|
746
782
|
return { targetRatio };
|
|
747
783
|
},
|
|
748
784
|
};
|
|
785
|
+
export const compoundV2LeverageManagementSubDataWithoutSubProxy = {
|
|
786
|
+
encode(targetRatio, ratioState) {
|
|
787
|
+
const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
788
|
+
const encodedRatioState = AbiCoder.encodeParameter('uint8', ratioState);
|
|
789
|
+
const isBoost = ratioState === RatioState.OVER;
|
|
790
|
+
if (isBoost) {
|
|
791
|
+
const enableAsCollEncoded = AbiCoder.encodeParameter('uint256', 1);
|
|
792
|
+
return [encodedTargetRatio, encodedRatioState, enableAsCollEncoded];
|
|
793
|
+
}
|
|
794
|
+
return [encodedTargetRatio, encodedRatioState];
|
|
795
|
+
},
|
|
796
|
+
decode(subData) {
|
|
797
|
+
const targetRatio = weiToRatioPercentage(AbiCoder.decodeParameter('uint256', subData[0]));
|
|
798
|
+
const ratioState = AbiCoder.decodeParameter('uint8', subData[1]);
|
|
799
|
+
return { targetRatio, ratioState };
|
|
800
|
+
},
|
|
801
|
+
};
|
|
749
802
|
/**
|
|
750
803
|
______ ______ .___ ___. .______ ____ ____ ____
|
|
751
804
|
/ | / __ \ | \/ | | _ \ \ \ / / |___ \
|
|
@@ -773,27 +826,22 @@ export const compoundV3LeverageManagementSubData = {
|
|
|
773
826
|
return { targetRatio };
|
|
774
827
|
},
|
|
775
828
|
};
|
|
776
|
-
export const
|
|
777
|
-
encode(market, baseToken,
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
subInput = subInput.concat(new Dec(triggerBoostRatio).mul(1e16).toHex().slice(2)
|
|
784
|
-
.padStart(32, '0'));
|
|
785
|
-
subInput = subInput.concat(new Dec(targetBoostRatio).mul(1e16).toHex().slice(2)
|
|
786
|
-
.padStart(32, '0'));
|
|
787
|
-
subInput = subInput.concat(new Dec(targetRepayRatio).mul(1e16).toHex().slice(2)
|
|
788
|
-
.padStart(32, '0'));
|
|
789
|
-
subInput = subInput.concat(boostEnabled ? '01' : '00');
|
|
790
|
-
subInput = subInput.concat(isEOA ? '01' : '00');
|
|
791
|
-
return subInput;
|
|
829
|
+
export const compoundV3LeverageManagementSubDataWithoutSubProxy = {
|
|
830
|
+
encode(market, baseToken, targetRatio, ratioState) {
|
|
831
|
+
const encodedMarket = AbiCoder.encodeParameter('address', market);
|
|
832
|
+
const encodedBaseToken = AbiCoder.encodeParameter('address', baseToken);
|
|
833
|
+
const encodedRatioState = AbiCoder.encodeParameter('uint8', ratioState);
|
|
834
|
+
const encodedTargetRatio = AbiCoder.encodeParameter('uint256', ratioPercentageToWei(targetRatio));
|
|
835
|
+
return [encodedMarket, encodedBaseToken, encodedRatioState, encodedTargetRatio];
|
|
792
836
|
},
|
|
793
837
|
decode(subData) {
|
|
794
|
-
const
|
|
795
|
-
const
|
|
796
|
-
|
|
838
|
+
const market = AbiCoder.decodeParameter('address', subData[0]);
|
|
839
|
+
const baseToken = AbiCoder.decodeParameter('address', subData[1]);
|
|
840
|
+
const ratioState = AbiCoder.decodeParameter('uint8', subData[2]);
|
|
841
|
+
const targetRatio = weiToRatioPercentage(AbiCoder.decodeParameter('uint256', subData[3]));
|
|
842
|
+
return {
|
|
843
|
+
market, baseToken, targetRatio, ratioState,
|
|
844
|
+
};
|
|
797
845
|
},
|
|
798
846
|
};
|
|
799
847
|
export const compoundV3LeverageManagementOnPriceSubData = {
|
|
@@ -899,6 +947,21 @@ export const exchangeLimitOrderSubData = {
|
|
|
899
947
|
return { fromToken, toToken, amount };
|
|
900
948
|
},
|
|
901
949
|
};
|
|
950
|
+
export const exchangeLimitOrderSubDataWithoutSubProxy = {
|
|
951
|
+
encode(fromToken, toToken, amount) {
|
|
952
|
+
return [
|
|
953
|
+
AbiCoder.encodeParameter('address', fromToken),
|
|
954
|
+
AbiCoder.encodeParameter('address', toToken),
|
|
955
|
+
AbiCoder.encodeParameter('uint256', amount),
|
|
956
|
+
];
|
|
957
|
+
},
|
|
958
|
+
decode: (subData, chainId) => {
|
|
959
|
+
const fromToken = AbiCoder.decodeParameter('address', subData[0]).toString();
|
|
960
|
+
const toToken = AbiCoder.decodeParameter('address', subData[1]).toString();
|
|
961
|
+
const amount = assetAmountInEth(AbiCoder.decodeParameter('uint256', subData[2]).toString(), getAssetInfoByAddress(fromToken, chainId).symbol);
|
|
962
|
+
return { fromToken, toToken, amount };
|
|
963
|
+
},
|
|
964
|
+
};
|
|
902
965
|
/**
|
|
903
966
|
_______..______ ___ .______ __ ___
|
|
904
967
|
/ || _ \ / \ | _ \ | |/ /
|
|
@@ -1309,48 +1309,6 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1309
1309
|
});
|
|
1310
1310
|
});
|
|
1311
1311
|
});
|
|
1312
|
-
describe('When testing subDataService.compoundV3L2LeverageManagementSubData', () => {
|
|
1313
|
-
describe('encode()', () => {
|
|
1314
|
-
const examples = [
|
|
1315
|
-
[
|
|
1316
|
-
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e00000100',
|
|
1317
|
-
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 190, true, false]
|
|
1318
|
-
],
|
|
1319
|
-
[
|
|
1320
|
-
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee00000000',
|
|
1321
|
-
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 110, false, false]
|
|
1322
|
-
],
|
|
1323
|
-
];
|
|
1324
|
-
examples.forEach(([expected, actual]) => {
|
|
1325
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1326
|
-
expect(subDataService.compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1327
|
-
});
|
|
1328
|
-
});
|
|
1329
|
-
});
|
|
1330
|
-
describe('decode()', () => {
|
|
1331
|
-
const examples = [
|
|
1332
|
-
[
|
|
1333
|
-
{ targetRatio: 200 },
|
|
1334
|
-
[
|
|
1335
|
-
'0x0000000000000000000000000313d212133AFaB8F2B829B1066c7E43cAd94E2c', '0x0000000000000000000000000213d212133AFaB8F2B829B1066c7E43cAd94E2c',
|
|
1336
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1337
|
-
],
|
|
1338
|
-
],
|
|
1339
|
-
[
|
|
1340
|
-
{ targetRatio: 123 },
|
|
1341
|
-
[
|
|
1342
|
-
'0x0000000000000000000000000313d212133AFaB8F2B829B1066c7E43cAd94E2c', '0x0000000000000000000000000413d212133AFaB8F2B829B1066c7E43cAd94E2c',
|
|
1343
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
1344
|
-
],
|
|
1345
|
-
],
|
|
1346
|
-
];
|
|
1347
|
-
examples.forEach(([expected, actual]) => {
|
|
1348
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1349
|
-
expect(subDataService.compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1350
|
-
});
|
|
1351
|
-
});
|
|
1352
|
-
});
|
|
1353
|
-
});
|
|
1354
1312
|
describe('When testing subDataService.morphoBlueLeverageManagementSubData', () => {
|
|
1355
1313
|
describe('encode()', () => {
|
|
1356
1314
|
const examples = [
|
|
@@ -1493,6 +1451,106 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1493
1451
|
});
|
|
1494
1452
|
});
|
|
1495
1453
|
});
|
|
1454
|
+
describe('When testing subDataService.morphoBlueLeverageManagementOnPriceSubData', () => {
|
|
1455
|
+
describe('encode()', () => {
|
|
1456
|
+
const examples = [
|
|
1457
|
+
[
|
|
1458
|
+
[
|
|
1459
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1460
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1461
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1462
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1463
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1464
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1465
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1466
|
+
],
|
|
1467
|
+
[
|
|
1468
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1469
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1470
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1471
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1472
|
+
'945000000000000000',
|
|
1473
|
+
200,
|
|
1474
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1475
|
+
],
|
|
1476
|
+
],
|
|
1477
|
+
[
|
|
1478
|
+
[
|
|
1479
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1480
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1481
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1482
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1483
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1484
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1485
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1486
|
+
],
|
|
1487
|
+
[
|
|
1488
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1489
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1490
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1491
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1492
|
+
'945000000000000000',
|
|
1493
|
+
160,
|
|
1494
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1495
|
+
],
|
|
1496
|
+
],
|
|
1497
|
+
];
|
|
1498
|
+
examples.forEach(([expected, actual]) => {
|
|
1499
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1500
|
+
expect(subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1501
|
+
});
|
|
1502
|
+
});
|
|
1503
|
+
});
|
|
1504
|
+
describe('decode()', () => {
|
|
1505
|
+
const examples = [
|
|
1506
|
+
[
|
|
1507
|
+
{
|
|
1508
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1509
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1510
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1511
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1512
|
+
lltv: '945000000000000000',
|
|
1513
|
+
targetRatio: 200,
|
|
1514
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1515
|
+
},
|
|
1516
|
+
[
|
|
1517
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1518
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1519
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1520
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1521
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1522
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1523
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1524
|
+
],
|
|
1525
|
+
],
|
|
1526
|
+
[
|
|
1527
|
+
{
|
|
1528
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1529
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1530
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1531
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1532
|
+
lltv: '945000000000000000',
|
|
1533
|
+
targetRatio: 160,
|
|
1534
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1535
|
+
},
|
|
1536
|
+
[
|
|
1537
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1538
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1539
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1540
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1541
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1542
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1543
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1544
|
+
],
|
|
1545
|
+
],
|
|
1546
|
+
];
|
|
1547
|
+
examples.forEach(([expected, actual]) => {
|
|
1548
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1549
|
+
expect(subDataService.morphoBlueLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1550
|
+
});
|
|
1551
|
+
});
|
|
1552
|
+
});
|
|
1553
|
+
});
|
|
1496
1554
|
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1497
1555
|
describe('encode()', () => {
|
|
1498
1556
|
const examples = [
|
|
@@ -3,7 +3,7 @@ import { getAssetInfo, MAXUINT } from '@defisaver/tokens';
|
|
|
3
3
|
import * as web3Utils from 'web3-utils';
|
|
4
4
|
import { ChainId, OrderType, RatioState } from '../types/enums';
|
|
5
5
|
import '../configuration';
|
|
6
|
-
import { aaveV2RatioTrigger, aaveV3QuotePriceTrigger, aaveV3QuotePriceWithMaximumGasPriceTrigger, aaveV3RatioTrigger, cBondsRebondTrigger, chainlinkPriceTrigger, compoundV2RatioTrigger, compoundV3RatioTrigger, compoundV3PriceTrigger, curveUsdBorrowRateTrigger, curveUsdSoftLiquidationTrigger, exchangeOffchainPriceTrigger, exchangeTimestampTrigger, liquityDebtInFrontTrigger, makerRatioTrigger, morphoAaveV2RatioTrigger, sparkRatioTrigger, trailingStopTrigger, liquityDebtInFrontWithLimitTrigger, crvUSDRatioTrigger, morphoBlueRatioTrigger, crvUsdHealthRatioTrigger, liquityV2DebtInFrontTrigger, liquityV2AdjustTimeTrigger, compoundV3PriceRangeTrigger, aaveV3QuotePriceRangeTrigger, morphoBluePriceRangeTrigger, sparkQuotePriceTrigger, aaveV4RatioTrigger, aaveV4QuotePriceTrigger, aaveV4QuotePriceRangeTrigger, } from './triggerService';
|
|
6
|
+
import { aaveV2RatioTrigger, aaveV3QuotePriceTrigger, aaveV3QuotePriceWithMaximumGasPriceTrigger, aaveV3RatioTrigger, cBondsRebondTrigger, chainlinkPriceTrigger, compoundV2RatioTrigger, compoundV3RatioTrigger, compoundV3PriceTrigger, curveUsdBorrowRateTrigger, curveUsdSoftLiquidationTrigger, exchangeOffchainPriceTrigger, exchangeTimestampTrigger, liquityDebtInFrontTrigger, makerRatioTrigger, morphoAaveV2RatioTrigger, sparkRatioTrigger, trailingStopTrigger, liquityDebtInFrontWithLimitTrigger, crvUSDRatioTrigger, morphoBlueRatioTrigger, crvUsdHealthRatioTrigger, liquityV2DebtInFrontTrigger, liquityV2AdjustTimeTrigger, compoundV3PriceRangeTrigger, aaveV3QuotePriceRangeTrigger, morphoBluePriceRangeTrigger, morphoBluePriceTrigger, sparkQuotePriceTrigger, aaveV4RatioTrigger, aaveV4QuotePriceTrigger, aaveV4QuotePriceRangeTrigger, } from './triggerService';
|
|
7
7
|
describe('Feature: triggerService.ts', () => {
|
|
8
8
|
describe('When testing triggerService.chainlinkPriceTrigger', () => {
|
|
9
9
|
describe('encode()', () => {
|
|
@@ -1159,6 +1159,66 @@ describe('Feature: triggerService.ts', () => {
|
|
|
1159
1159
|
});
|
|
1160
1160
|
});
|
|
1161
1161
|
});
|
|
1162
|
+
describe('When testing triggerService.morphoBluePriceTrigger', () => {
|
|
1163
|
+
describe('encode()', () => {
|
|
1164
|
+
const examples = [
|
|
1165
|
+
[
|
|
1166
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1167
|
+
[
|
|
1168
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1169
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1170
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1171
|
+
2500,
|
|
1172
|
+
RatioState.UNDER,
|
|
1173
|
+
],
|
|
1174
|
+
],
|
|
1175
|
+
[
|
|
1176
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1177
|
+
[
|
|
1178
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1179
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1180
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1181
|
+
4000,
|
|
1182
|
+
RatioState.OVER,
|
|
1183
|
+
],
|
|
1184
|
+
],
|
|
1185
|
+
];
|
|
1186
|
+
examples.forEach(([expected, actual]) => {
|
|
1187
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1188
|
+
expect(morphoBluePriceTrigger.encode(...actual)).to.eql(expected);
|
|
1189
|
+
});
|
|
1190
|
+
});
|
|
1191
|
+
});
|
|
1192
|
+
describe('decode()', () => {
|
|
1193
|
+
const examples = [
|
|
1194
|
+
[
|
|
1195
|
+
{
|
|
1196
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1197
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1198
|
+
loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1199
|
+
price: '2500',
|
|
1200
|
+
priceState: RatioState.UNDER,
|
|
1201
|
+
},
|
|
1202
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1203
|
+
],
|
|
1204
|
+
[
|
|
1205
|
+
{
|
|
1206
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1207
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1208
|
+
loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1209
|
+
price: '4000',
|
|
1210
|
+
priceState: RatioState.OVER,
|
|
1211
|
+
},
|
|
1212
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1213
|
+
],
|
|
1214
|
+
];
|
|
1215
|
+
examples.forEach(([expected, actual]) => {
|
|
1216
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1217
|
+
expect(morphoBluePriceTrigger.decode(actual)).to.eql(expected);
|
|
1218
|
+
});
|
|
1219
|
+
});
|
|
1220
|
+
});
|
|
1221
|
+
});
|
|
1162
1222
|
describe('When testing triggerService.aaveV4RatioTrigger', () => {
|
|
1163
1223
|
describe('encode()', () => {
|
|
1164
1224
|
const examples = [
|
package/esm/types/enums.d.ts
CHANGED
|
@@ -224,7 +224,8 @@ export declare namespace Bundles {
|
|
|
224
224
|
AAVE_V4_EOA_BOOST = 67,
|
|
225
225
|
AAVE_V4_EOA_REPAY_ON_PRICE = 68,
|
|
226
226
|
AAVE_V4_EOA_BOOST_ON_PRICE = 69,
|
|
227
|
-
AAVE_V4_EOA_CLOSE = 70
|
|
227
|
+
AAVE_V4_EOA_CLOSE = 70,
|
|
228
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 84
|
|
228
229
|
}
|
|
229
230
|
enum OptimismIds {
|
|
230
231
|
AAVE_V3_REPAY = 0,
|
|
@@ -266,7 +267,8 @@ export declare namespace Bundles {
|
|
|
266
267
|
AAVE_V3_EOA_REPAY_ON_PRICE = 25,
|
|
267
268
|
AAVE_V3_EOA_BOOST_ON_PRICE = 26,
|
|
268
269
|
AAVE_V3_EOA_CLOSE = 27,
|
|
269
|
-
MORPHO_BLUE_CLOSE = 28
|
|
270
|
+
MORPHO_BLUE_CLOSE = 28,
|
|
271
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 36
|
|
270
272
|
}
|
|
271
273
|
enum ArbitrumIds {
|
|
272
274
|
AAVE_V3_REPAY = 0,
|
|
@@ -297,6 +299,7 @@ export declare namespace Bundles {
|
|
|
297
299
|
MORPHO_BLUE_BOOST_ON_PRICE = 25,
|
|
298
300
|
MORPHO_BLUE_EOA_REPAY = 26,
|
|
299
301
|
MORPHO_BLUE_EOA_BOOST = 27,
|
|
300
|
-
MORPHO_BLUE_CLOSE = 28
|
|
302
|
+
MORPHO_BLUE_CLOSE = 28,
|
|
303
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 36
|
|
301
304
|
}
|
|
302
305
|
}
|
package/esm/types/enums.js
CHANGED
|
@@ -245,6 +245,7 @@ export var Bundles;
|
|
|
245
245
|
MainnetIds[MainnetIds["AAVE_V4_EOA_REPAY_ON_PRICE"] = 68] = "AAVE_V4_EOA_REPAY_ON_PRICE";
|
|
246
246
|
MainnetIds[MainnetIds["AAVE_V4_EOA_BOOST_ON_PRICE"] = 69] = "AAVE_V4_EOA_BOOST_ON_PRICE";
|
|
247
247
|
MainnetIds[MainnetIds["AAVE_V4_EOA_CLOSE"] = 70] = "AAVE_V4_EOA_CLOSE";
|
|
248
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 84] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
248
249
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
249
250
|
let OptimismIds;
|
|
250
251
|
(function (OptimismIds) {
|
|
@@ -289,6 +290,7 @@ export var Bundles;
|
|
|
289
290
|
BaseIds[BaseIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 26] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
290
291
|
BaseIds[BaseIds["AAVE_V3_EOA_CLOSE"] = 27] = "AAVE_V3_EOA_CLOSE";
|
|
291
292
|
BaseIds[BaseIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
293
|
+
BaseIds[BaseIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 36] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
292
294
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
293
295
|
let ArbitrumIds;
|
|
294
296
|
(function (ArbitrumIds) {
|
|
@@ -321,5 +323,6 @@ export var Bundles;
|
|
|
321
323
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_REPAY"] = 26] = "MORPHO_BLUE_EOA_REPAY";
|
|
322
324
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_BOOST"] = 27] = "MORPHO_BLUE_EOA_BOOST";
|
|
323
325
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
326
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 36] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
324
327
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
325
328
|
})(Bundles || (Bundles = {}));
|
package/package.json
CHANGED
package/src/constants/index.ts
CHANGED
|
@@ -573,6 +573,11 @@ export const MAINNET_BUNDLES_INFO: MainnetBundleInfo = {
|
|
|
573
573
|
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
574
574
|
protocol: PROTOCOLS.AaveV4,
|
|
575
575
|
},
|
|
576
|
+
[Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
|
|
577
|
+
strategyOrBundleId: Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
578
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
579
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
580
|
+
},
|
|
576
581
|
};
|
|
577
582
|
|
|
578
583
|
export const OPTIMISM_BUNDLES_INFO: OptimismBundleInfo = {
|
|
@@ -770,6 +775,11 @@ export const BASE_BUNDLES_INFO: BaseBundleInfo = {
|
|
|
770
775
|
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
771
776
|
protocol: PROTOCOLS.MorphoBlue,
|
|
772
777
|
},
|
|
778
|
+
[Bundles.BaseIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
|
|
779
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
780
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
781
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
782
|
+
},
|
|
773
783
|
};
|
|
774
784
|
|
|
775
785
|
export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
|
|
@@ -918,6 +928,11 @@ export const ARBITRUM_BUNDLES_INFO: ArbitrumBundleInfo = {
|
|
|
918
928
|
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
919
929
|
protocol: PROTOCOLS.MorphoBlue,
|
|
920
930
|
},
|
|
931
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
|
|
932
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
933
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
934
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
935
|
+
},
|
|
921
936
|
};
|
|
922
937
|
|
|
923
938
|
export const BUNDLES_INFO: BundlesInfo = {
|