@defisaver/automation-sdk 3.3.15 → 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 +15 -0
- package/cjs/services/strategiesService.js +1 -0
- package/cjs/services/strategySubService.test.js +67 -0
- package/cjs/services/subDataService.test.js +100 -0
- 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 +1 -0
- package/esm/services/strategySubService.test.js +67 -0
- package/esm/services/subDataService.test.js +100 -0
- 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 +1 -0
- package/src/services/strategySubService.test.ts +84 -0
- package/src/services/subDataService.test.ts +110 -0
- package/src/services/triggerService.test.ts +69 -0
- package/src/types/enums.ts +3 -0
package/cjs/constants/index.js
CHANGED
|
@@ -549,6 +549,11 @@ exports.MAINNET_BUNDLES_INFO = {
|
|
|
549
549
|
strategyId: enums_1.Strategies.Identifiers.EoaCloseOnPrice,
|
|
550
550
|
protocol: exports.PROTOCOLS.AaveV4,
|
|
551
551
|
},
|
|
552
|
+
[enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
|
|
553
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
554
|
+
strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
|
|
555
|
+
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
556
|
+
},
|
|
552
557
|
};
|
|
553
558
|
exports.OPTIMISM_BUNDLES_INFO = {
|
|
554
559
|
[enums_1.Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -743,6 +748,11 @@ exports.BASE_BUNDLES_INFO = {
|
|
|
743
748
|
strategyId: enums_1.Strategies.Identifiers.CloseOnPrice,
|
|
744
749
|
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
745
750
|
},
|
|
751
|
+
[enums_1.Bundles.BaseIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
|
|
752
|
+
strategyOrBundleId: enums_1.Bundles.BaseIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
753
|
+
strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
|
|
754
|
+
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
755
|
+
},
|
|
746
756
|
};
|
|
747
757
|
exports.ARBITRUM_BUNDLES_INFO = {
|
|
748
758
|
[enums_1.Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -890,6 +900,11 @@ exports.ARBITRUM_BUNDLES_INFO = {
|
|
|
890
900
|
strategyId: enums_1.Strategies.Identifiers.CloseOnPrice,
|
|
891
901
|
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
892
902
|
},
|
|
903
|
+
[enums_1.Bundles.ArbitrumIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
|
|
904
|
+
strategyOrBundleId: enums_1.Bundles.ArbitrumIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
905
|
+
strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
|
|
906
|
+
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
907
|
+
},
|
|
893
908
|
};
|
|
894
909
|
exports.BUNDLES_INFO = {
|
|
895
910
|
[enums_1.ChainId.Ethereum]: exports.MAINNET_BUNDLES_INFO,
|
|
@@ -1139,6 +1139,7 @@ const parsingMethodsMapping = {
|
|
|
1139
1139
|
[enums_1.Strategies.Identifiers.EoaRepay]: parseMorphoBlueLeverageManagement,
|
|
1140
1140
|
[enums_1.Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
1141
1141
|
[enums_1.Strategies.Identifiers.BoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1142
|
+
[enums_1.Strategies.Identifiers.RepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1142
1143
|
[enums_1.Strategies.Identifiers.CloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1143
1144
|
},
|
|
1144
1145
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.FluidT1]: {
|
|
@@ -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
|
[
|
|
@@ -1479,6 +1479,106 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1479
1479
|
});
|
|
1480
1480
|
});
|
|
1481
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
|
+
});
|
|
1482
1582
|
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1483
1583
|
describe('encode()', () => {
|
|
1484
1584
|
const examples = [
|
|
@@ -1184,6 +1184,66 @@ describe('Feature: triggerService.ts', () => {
|
|
|
1184
1184
|
});
|
|
1185
1185
|
});
|
|
1186
1186
|
});
|
|
1187
|
+
describe('When testing triggerService.morphoBluePriceTrigger', () => {
|
|
1188
|
+
describe('encode()', () => {
|
|
1189
|
+
const examples = [
|
|
1190
|
+
[
|
|
1191
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1192
|
+
[
|
|
1193
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1194
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1195
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1196
|
+
2500,
|
|
1197
|
+
enums_1.RatioState.UNDER,
|
|
1198
|
+
],
|
|
1199
|
+
],
|
|
1200
|
+
[
|
|
1201
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1202
|
+
[
|
|
1203
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1204
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1205
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1206
|
+
4000,
|
|
1207
|
+
enums_1.RatioState.OVER,
|
|
1208
|
+
],
|
|
1209
|
+
],
|
|
1210
|
+
];
|
|
1211
|
+
examples.forEach(([expected, actual]) => {
|
|
1212
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1213
|
+
(0, chai_1.expect)(triggerService_1.morphoBluePriceTrigger.encode(...actual)).to.eql(expected);
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
});
|
|
1217
|
+
describe('decode()', () => {
|
|
1218
|
+
const examples = [
|
|
1219
|
+
[
|
|
1220
|
+
{
|
|
1221
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1222
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1223
|
+
loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1224
|
+
price: '2500',
|
|
1225
|
+
priceState: enums_1.RatioState.UNDER,
|
|
1226
|
+
},
|
|
1227
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1228
|
+
],
|
|
1229
|
+
[
|
|
1230
|
+
{
|
|
1231
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1232
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1233
|
+
loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1234
|
+
price: '4000',
|
|
1235
|
+
priceState: enums_1.RatioState.OVER,
|
|
1236
|
+
},
|
|
1237
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1238
|
+
],
|
|
1239
|
+
];
|
|
1240
|
+
examples.forEach(([expected, actual]) => {
|
|
1241
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1242
|
+
(0, chai_1.expect)(triggerService_1.morphoBluePriceTrigger.decode(actual)).to.eql(expected);
|
|
1243
|
+
});
|
|
1244
|
+
});
|
|
1245
|
+
});
|
|
1246
|
+
});
|
|
1187
1247
|
describe('When testing triggerService.aaveV4RatioTrigger', () => {
|
|
1188
1248
|
describe('encode()', () => {
|
|
1189
1249
|
const examples = [
|
package/cjs/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/cjs/types/enums.js
CHANGED
|
@@ -248,6 +248,7 @@ var Bundles;
|
|
|
248
248
|
MainnetIds[MainnetIds["AAVE_V4_EOA_REPAY_ON_PRICE"] = 68] = "AAVE_V4_EOA_REPAY_ON_PRICE";
|
|
249
249
|
MainnetIds[MainnetIds["AAVE_V4_EOA_BOOST_ON_PRICE"] = 69] = "AAVE_V4_EOA_BOOST_ON_PRICE";
|
|
250
250
|
MainnetIds[MainnetIds["AAVE_V4_EOA_CLOSE"] = 70] = "AAVE_V4_EOA_CLOSE";
|
|
251
|
+
MainnetIds[MainnetIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 84] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
251
252
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
252
253
|
let OptimismIds;
|
|
253
254
|
(function (OptimismIds) {
|
|
@@ -292,6 +293,7 @@ var Bundles;
|
|
|
292
293
|
BaseIds[BaseIds["AAVE_V3_EOA_BOOST_ON_PRICE"] = 26] = "AAVE_V3_EOA_BOOST_ON_PRICE";
|
|
293
294
|
BaseIds[BaseIds["AAVE_V3_EOA_CLOSE"] = 27] = "AAVE_V3_EOA_CLOSE";
|
|
294
295
|
BaseIds[BaseIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
296
|
+
BaseIds[BaseIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 36] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
295
297
|
})(BaseIds = Bundles.BaseIds || (Bundles.BaseIds = {}));
|
|
296
298
|
let ArbitrumIds;
|
|
297
299
|
(function (ArbitrumIds) {
|
|
@@ -324,5 +326,6 @@ var Bundles;
|
|
|
324
326
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_REPAY"] = 26] = "MORPHO_BLUE_EOA_REPAY";
|
|
325
327
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_EOA_BOOST"] = 27] = "MORPHO_BLUE_EOA_BOOST";
|
|
326
328
|
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_CLOSE"] = 28] = "MORPHO_BLUE_CLOSE";
|
|
329
|
+
ArbitrumIds[ArbitrumIds["MORPHO_BLUE_REPAY_ON_PRICE"] = 36] = "MORPHO_BLUE_REPAY_ON_PRICE";
|
|
327
330
|
})(ArbitrumIds = Bundles.ArbitrumIds || (Bundles.ArbitrumIds = {}));
|
|
328
331
|
})(Bundles = exports.Bundles || (exports.Bundles = {}));
|
package/esm/constants/index.js
CHANGED
|
@@ -543,6 +543,11 @@ export const MAINNET_BUNDLES_INFO = {
|
|
|
543
543
|
strategyId: Strategies.Identifiers.EoaCloseOnPrice,
|
|
544
544
|
protocol: PROTOCOLS.AaveV4,
|
|
545
545
|
},
|
|
546
|
+
[Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
|
|
547
|
+
strategyOrBundleId: Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
548
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
549
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
550
|
+
},
|
|
546
551
|
};
|
|
547
552
|
export const OPTIMISM_BUNDLES_INFO = {
|
|
548
553
|
[Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -737,6 +742,11 @@ export const BASE_BUNDLES_INFO = {
|
|
|
737
742
|
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
738
743
|
protocol: PROTOCOLS.MorphoBlue,
|
|
739
744
|
},
|
|
745
|
+
[Bundles.BaseIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
|
|
746
|
+
strategyOrBundleId: Bundles.BaseIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
747
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
748
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
749
|
+
},
|
|
740
750
|
};
|
|
741
751
|
export const ARBITRUM_BUNDLES_INFO = {
|
|
742
752
|
[Bundles.ArbitrumIds.AAVE_V3_REPAY]: {
|
|
@@ -884,6 +894,11 @@ export const ARBITRUM_BUNDLES_INFO = {
|
|
|
884
894
|
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
885
895
|
protocol: PROTOCOLS.MorphoBlue,
|
|
886
896
|
},
|
|
897
|
+
[Bundles.ArbitrumIds.MORPHO_BLUE_REPAY_ON_PRICE]: {
|
|
898
|
+
strategyOrBundleId: Bundles.ArbitrumIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
899
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
900
|
+
protocol: PROTOCOLS.MorphoBlue,
|
|
901
|
+
},
|
|
887
902
|
};
|
|
888
903
|
export const BUNDLES_INFO = {
|
|
889
904
|
[ChainId.Ethereum]: MAINNET_BUNDLES_INFO,
|
|
@@ -1110,6 +1110,7 @@ const parsingMethodsMapping = {
|
|
|
1110
1110
|
[Strategies.Identifiers.EoaRepay]: parseMorphoBlueLeverageManagement,
|
|
1111
1111
|
[Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
1112
1112
|
[Strategies.Identifiers.BoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1113
|
+
[Strategies.Identifiers.RepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1113
1114
|
[Strategies.Identifiers.CloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1114
1115
|
},
|
|
1115
1116
|
[ProtocolIdentifiers.StrategiesAutomation.FluidT1]: {
|
|
@@ -1197,6 +1197,73 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1197
1197
|
});
|
|
1198
1198
|
});
|
|
1199
1199
|
});
|
|
1200
|
+
describe('leverageManagementOnPrice()', () => {
|
|
1201
|
+
const examples = [
|
|
1202
|
+
[
|
|
1203
|
+
[
|
|
1204
|
+
Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
1205
|
+
true,
|
|
1206
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1207
|
+
[
|
|
1208
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1209
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1210
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1211
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1212
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1213
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1214
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1215
|
+
],
|
|
1216
|
+
],
|
|
1217
|
+
[
|
|
1218
|
+
Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
1219
|
+
true,
|
|
1220
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1221
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1222
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1223
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1224
|
+
'945000000000000000',
|
|
1225
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1226
|
+
200,
|
|
1227
|
+
2500,
|
|
1228
|
+
RatioState.UNDER,
|
|
1229
|
+
],
|
|
1230
|
+
],
|
|
1231
|
+
[
|
|
1232
|
+
[
|
|
1233
|
+
Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
|
|
1234
|
+
true,
|
|
1235
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1236
|
+
[
|
|
1237
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1238
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1239
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1240
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1241
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1242
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1243
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1244
|
+
],
|
|
1245
|
+
],
|
|
1246
|
+
[
|
|
1247
|
+
Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
|
|
1248
|
+
true,
|
|
1249
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1250
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1251
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1252
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1253
|
+
'945000000000000000',
|
|
1254
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1255
|
+
160,
|
|
1256
|
+
4000,
|
|
1257
|
+
RatioState.OVER,
|
|
1258
|
+
],
|
|
1259
|
+
],
|
|
1260
|
+
];
|
|
1261
|
+
examples.forEach(([expected, actual]) => {
|
|
1262
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1263
|
+
expect(morphoBlueEncode.leverageManagementOnPrice(...actual)).to.eql(expected);
|
|
1264
|
+
});
|
|
1265
|
+
});
|
|
1266
|
+
});
|
|
1200
1267
|
describe('closeOnPrice()', () => {
|
|
1201
1268
|
const examples = [
|
|
1202
1269
|
[
|
|
@@ -1451,6 +1451,106 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1451
1451
|
});
|
|
1452
1452
|
});
|
|
1453
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
|
+
});
|
|
1454
1554
|
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1455
1555
|
describe('encode()', () => {
|
|
1456
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 = {
|
|
@@ -1423,6 +1423,7 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
1423
1423
|
[Strategies.Identifiers.EoaRepay]: parseMorphoBlueLeverageManagement,
|
|
1424
1424
|
[Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
1425
1425
|
[Strategies.Identifiers.BoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1426
|
+
[Strategies.Identifiers.RepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1426
1427
|
[Strategies.Identifiers.CloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1427
1428
|
},
|
|
1428
1429
|
[ProtocolIdentifiers.StrategiesAutomation.FluidT1]: {
|
|
@@ -1417,6 +1417,90 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1417
1417
|
});
|
|
1418
1418
|
});
|
|
1419
1419
|
|
|
1420
|
+
describe('leverageManagementOnPrice()', () => {
|
|
1421
|
+
const examples: Array<[
|
|
1422
|
+
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
1423
|
+
[
|
|
1424
|
+
strategyOrBundleId: number,
|
|
1425
|
+
isBundle: boolean,
|
|
1426
|
+
loanToken: EthereumAddress,
|
|
1427
|
+
collToken: EthereumAddress,
|
|
1428
|
+
oracle: EthereumAddress,
|
|
1429
|
+
irm: EthereumAddress,
|
|
1430
|
+
lltv: string,
|
|
1431
|
+
user: EthereumAddress,
|
|
1432
|
+
targetRatio: number,
|
|
1433
|
+
price: number,
|
|
1434
|
+
priceState: RatioState,
|
|
1435
|
+
]
|
|
1436
|
+
]> = [
|
|
1437
|
+
[
|
|
1438
|
+
[
|
|
1439
|
+
Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
1440
|
+
true,
|
|
1441
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1442
|
+
[
|
|
1443
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1444
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1445
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1446
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1447
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1448
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1449
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1450
|
+
],
|
|
1451
|
+
],
|
|
1452
|
+
[
|
|
1453
|
+
Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
1454
|
+
true,
|
|
1455
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1456
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1457
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1458
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1459
|
+
'945000000000000000',
|
|
1460
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1461
|
+
200,
|
|
1462
|
+
2500,
|
|
1463
|
+
RatioState.UNDER,
|
|
1464
|
+
],
|
|
1465
|
+
],
|
|
1466
|
+
[
|
|
1467
|
+
[
|
|
1468
|
+
Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
|
|
1469
|
+
true,
|
|
1470
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1471
|
+
[
|
|
1472
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1473
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1474
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1475
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1476
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1477
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1478
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1479
|
+
],
|
|
1480
|
+
],
|
|
1481
|
+
[
|
|
1482
|
+
Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
|
|
1483
|
+
true,
|
|
1484
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1485
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1486
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1487
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1488
|
+
'945000000000000000',
|
|
1489
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1490
|
+
160,
|
|
1491
|
+
4000,
|
|
1492
|
+
RatioState.OVER,
|
|
1493
|
+
],
|
|
1494
|
+
],
|
|
1495
|
+
];
|
|
1496
|
+
|
|
1497
|
+
examples.forEach(([expected, actual]) => {
|
|
1498
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1499
|
+
expect(morphoBlueEncode.leverageManagementOnPrice(...actual)).to.eql(expected);
|
|
1500
|
+
});
|
|
1501
|
+
});
|
|
1502
|
+
});
|
|
1503
|
+
|
|
1420
1504
|
describe('closeOnPrice()', () => {
|
|
1421
1505
|
const examples: Array<[
|
|
1422
1506
|
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
@@ -1564,6 +1564,116 @@ describe('Feature: subDataService.ts', () => {
|
|
|
1564
1564
|
});
|
|
1565
1565
|
});
|
|
1566
1566
|
|
|
1567
|
+
describe('When testing subDataService.morphoBlueLeverageManagementOnPriceSubData', () => {
|
|
1568
|
+
describe('encode()', () => {
|
|
1569
|
+
const examples: Array<[
|
|
1570
|
+
SubData,
|
|
1571
|
+
[loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, targetRatio: number, user: EthereumAddress],
|
|
1572
|
+
]> = [
|
|
1573
|
+
[
|
|
1574
|
+
[
|
|
1575
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1576
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1577
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1578
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1579
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1580
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1581
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1582
|
+
],
|
|
1583
|
+
[
|
|
1584
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1585
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1586
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1587
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1588
|
+
'945000000000000000',
|
|
1589
|
+
200,
|
|
1590
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1591
|
+
],
|
|
1592
|
+
],
|
|
1593
|
+
[
|
|
1594
|
+
[
|
|
1595
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1596
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1597
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1598
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1599
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1600
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1601
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1602
|
+
],
|
|
1603
|
+
[
|
|
1604
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1605
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1606
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1607
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1608
|
+
'945000000000000000',
|
|
1609
|
+
160,
|
|
1610
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1611
|
+
],
|
|
1612
|
+
],
|
|
1613
|
+
];
|
|
1614
|
+
|
|
1615
|
+
examples.forEach(([expected, actual]) => {
|
|
1616
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1617
|
+
expect(subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1618
|
+
});
|
|
1619
|
+
});
|
|
1620
|
+
});
|
|
1621
|
+
|
|
1622
|
+
describe('decode()', () => {
|
|
1623
|
+
const examples: Array<[
|
|
1624
|
+
{ loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, targetRatio: number, user: EthereumAddress },
|
|
1625
|
+
SubData,
|
|
1626
|
+
]> = [
|
|
1627
|
+
[
|
|
1628
|
+
{
|
|
1629
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1630
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1631
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1632
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1633
|
+
lltv: '945000000000000000',
|
|
1634
|
+
targetRatio: 200,
|
|
1635
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1636
|
+
},
|
|
1637
|
+
[
|
|
1638
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1639
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1640
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1641
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1642
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1643
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1644
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1645
|
+
],
|
|
1646
|
+
],
|
|
1647
|
+
[
|
|
1648
|
+
{
|
|
1649
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1650
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1651
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1652
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1653
|
+
lltv: '945000000000000000',
|
|
1654
|
+
targetRatio: 160,
|
|
1655
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1656
|
+
},
|
|
1657
|
+
[
|
|
1658
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1659
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1660
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1661
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1662
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1663
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1664
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1665
|
+
],
|
|
1666
|
+
],
|
|
1667
|
+
];
|
|
1668
|
+
|
|
1669
|
+
examples.forEach(([expected, actual]) => {
|
|
1670
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1671
|
+
expect(subDataService.morphoBlueLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1672
|
+
});
|
|
1673
|
+
});
|
|
1674
|
+
});
|
|
1675
|
+
});
|
|
1676
|
+
|
|
1567
1677
|
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1568
1678
|
describe('encode()', () => {
|
|
1569
1679
|
const examples: Array<[SubData, [collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number]]> = [
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
compoundV3PriceRangeTrigger,
|
|
33
33
|
aaveV3QuotePriceRangeTrigger,
|
|
34
34
|
morphoBluePriceRangeTrigger,
|
|
35
|
+
morphoBluePriceTrigger,
|
|
35
36
|
sparkQuotePriceTrigger,
|
|
36
37
|
aaveV4RatioTrigger,
|
|
37
38
|
aaveV4QuotePriceTrigger,
|
|
@@ -1287,6 +1288,74 @@ describe('Feature: triggerService.ts', () => {
|
|
|
1287
1288
|
});
|
|
1288
1289
|
});
|
|
1289
1290
|
});
|
|
1291
|
+
|
|
1292
|
+
describe('When testing triggerService.morphoBluePriceTrigger', () => {
|
|
1293
|
+
describe('encode()', () => {
|
|
1294
|
+
const examples: Array<[[string], [oracle: EthereumAddress, collateralToken: EthereumAddress, loanToken: EthereumAddress, price: number, priceState: RatioState]]> = [
|
|
1295
|
+
[
|
|
1296
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1297
|
+
[
|
|
1298
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1299
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1300
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1301
|
+
2500,
|
|
1302
|
+
RatioState.UNDER,
|
|
1303
|
+
],
|
|
1304
|
+
],
|
|
1305
|
+
[
|
|
1306
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1307
|
+
[
|
|
1308
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1309
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1310
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1311
|
+
4000,
|
|
1312
|
+
RatioState.OVER,
|
|
1313
|
+
],
|
|
1314
|
+
],
|
|
1315
|
+
];
|
|
1316
|
+
|
|
1317
|
+
examples.forEach(([expected, actual]) => {
|
|
1318
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1319
|
+
expect(morphoBluePriceTrigger.encode(...actual)).to.eql(expected);
|
|
1320
|
+
});
|
|
1321
|
+
});
|
|
1322
|
+
});
|
|
1323
|
+
|
|
1324
|
+
describe('decode()', () => {
|
|
1325
|
+
const examples: Array<[
|
|
1326
|
+
{ oracle: EthereumAddress, collateralToken: EthereumAddress, loanToken: EthereumAddress, price: string, priceState: RatioState },
|
|
1327
|
+
TriggerData,
|
|
1328
|
+
]> = [
|
|
1329
|
+
[
|
|
1330
|
+
{
|
|
1331
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1332
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1333
|
+
loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1334
|
+
price: '2500',
|
|
1335
|
+
priceState: RatioState.UNDER,
|
|
1336
|
+
},
|
|
1337
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1338
|
+
],
|
|
1339
|
+
[
|
|
1340
|
+
{
|
|
1341
|
+
oracle: web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1342
|
+
collateralToken: web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1343
|
+
loanToken: web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1344
|
+
price: '4000',
|
|
1345
|
+
priceState: RatioState.OVER,
|
|
1346
|
+
},
|
|
1347
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1348
|
+
],
|
|
1349
|
+
];
|
|
1350
|
+
|
|
1351
|
+
examples.forEach(([expected, actual]) => {
|
|
1352
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1353
|
+
expect(morphoBluePriceTrigger.decode(actual)).to.eql(expected);
|
|
1354
|
+
});
|
|
1355
|
+
});
|
|
1356
|
+
});
|
|
1357
|
+
});
|
|
1358
|
+
|
|
1290
1359
|
describe('When testing triggerService.aaveV4RatioTrigger', () => {
|
|
1291
1360
|
describe('encode()', () => {
|
|
1292
1361
|
const examples: Array<[[string], [owner: EthereumAddress, spoke: EthereumAddress, ratioPercentage: number, ratioState: RatioState]]> = [
|
package/src/types/enums.ts
CHANGED
|
@@ -240,6 +240,7 @@ export namespace Bundles {
|
|
|
240
240
|
AAVE_V4_EOA_REPAY_ON_PRICE = 68,
|
|
241
241
|
AAVE_V4_EOA_BOOST_ON_PRICE = 69,
|
|
242
242
|
AAVE_V4_EOA_CLOSE = 70,
|
|
243
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 84,
|
|
243
244
|
}
|
|
244
245
|
|
|
245
246
|
export enum OptimismIds {
|
|
@@ -284,6 +285,7 @@ export namespace Bundles {
|
|
|
284
285
|
AAVE_V3_EOA_BOOST_ON_PRICE = 26,
|
|
285
286
|
AAVE_V3_EOA_CLOSE = 27,
|
|
286
287
|
MORPHO_BLUE_CLOSE = 28,
|
|
288
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 36,
|
|
287
289
|
}
|
|
288
290
|
|
|
289
291
|
export enum ArbitrumIds {
|
|
@@ -316,6 +318,7 @@ export namespace Bundles {
|
|
|
316
318
|
MORPHO_BLUE_EOA_REPAY = 26,
|
|
317
319
|
MORPHO_BLUE_EOA_BOOST = 27,
|
|
318
320
|
MORPHO_BLUE_CLOSE = 28,
|
|
321
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 36,
|
|
319
322
|
}
|
|
320
323
|
}
|
|
321
324
|
|