@defisaver/automation-sdk 3.3.15 → 3.3.16-dev-13082-morpho-eoa-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 +70 -0
- package/cjs/services/strategiesService.js +4 -0
- package/cjs/services/strategySubService.d.ts +5 -1
- package/cjs/services/strategySubService.js +48 -11
- package/cjs/services/strategySubService.test.js +176 -1
- package/cjs/services/subDataService.test.js +100 -0
- package/cjs/services/triggerService.test.js +60 -0
- package/cjs/types/enums.d.ts +17 -3
- package/cjs/types/enums.js +14 -0
- package/esm/constants/index.js +70 -0
- package/esm/services/strategiesService.js +4 -0
- package/esm/services/strategySubService.d.ts +5 -1
- package/esm/services/strategySubService.js +46 -10
- package/esm/services/strategySubService.test.js +176 -1
- package/esm/services/subDataService.test.js +100 -0
- package/esm/services/triggerService.test.js +61 -1
- package/esm/types/enums.d.ts +17 -3
- package/esm/types/enums.js +14 -0
- package/package.json +1 -1
- package/src/constants/index.ts +70 -0
- package/src/services/strategiesService.ts +4 -0
- package/src/services/strategySubService.test.ts +229 -1
- package/src/services/strategySubService.ts +86 -11
- package/src/services/subDataService.test.ts +110 -0
- package/src/services/triggerService.test.ts +69 -0
- package/src/types/enums.ts +14 -0
|
@@ -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,10 @@ 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,
|
|
244
|
+
MORPHO_BLUE_EOA_BOOST_ON_PRICE = 85,
|
|
245
|
+
MORPHO_BLUE_EOA_REPAY_ON_PRICE = 86,
|
|
246
|
+
MORPHO_BLUE_EOA_CLOSE = 87,
|
|
243
247
|
}
|
|
244
248
|
|
|
245
249
|
export enum OptimismIds {
|
|
@@ -284,6 +288,12 @@ export namespace Bundles {
|
|
|
284
288
|
AAVE_V3_EOA_BOOST_ON_PRICE = 26,
|
|
285
289
|
AAVE_V3_EOA_CLOSE = 27,
|
|
286
290
|
MORPHO_BLUE_CLOSE = 28,
|
|
291
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 36,
|
|
292
|
+
MORPHO_BLUE_EOA_REPAY = 37,
|
|
293
|
+
MORPHO_BLUE_EOA_BOOST = 38,
|
|
294
|
+
MORPHO_BLUE_EOA_BOOST_ON_PRICE = 39,
|
|
295
|
+
MORPHO_BLUE_EOA_REPAY_ON_PRICE = 40,
|
|
296
|
+
MORPHO_BLUE_EOA_CLOSE = 41,
|
|
287
297
|
}
|
|
288
298
|
|
|
289
299
|
export enum ArbitrumIds {
|
|
@@ -316,6 +326,10 @@ export namespace Bundles {
|
|
|
316
326
|
MORPHO_BLUE_EOA_REPAY = 26,
|
|
317
327
|
MORPHO_BLUE_EOA_BOOST = 27,
|
|
318
328
|
MORPHO_BLUE_CLOSE = 28,
|
|
329
|
+
MORPHO_BLUE_REPAY_ON_PRICE = 36,
|
|
330
|
+
MORPHO_BLUE_EOA_BOOST_ON_PRICE = 37,
|
|
331
|
+
MORPHO_BLUE_EOA_REPAY_ON_PRICE = 38,
|
|
332
|
+
MORPHO_BLUE_EOA_CLOSE = 39,
|
|
319
333
|
}
|
|
320
334
|
}
|
|
321
335
|
|