@defisaver/automation-sdk 3.3.16-dev-13082-morpho-eoa-dev → 3.3.16-liq-prot-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/constants/index.js +117 -42
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +5 -2
- package/cjs/services/strategiesService.js +157 -12
- package/cjs/services/strategySubService.d.ts +18 -21
- package/cjs/services/strategySubService.js +78 -74
- package/cjs/services/strategySubService.test.js +3 -149
- package/cjs/services/subDataService.d.ts +70 -20
- package/cjs/services/subDataService.js +23 -79
- package/cjs/services/subDataService.test.js +17 -202
- package/cjs/services/utils.d.ts +2 -1
- package/cjs/services/utils.js +14 -1
- package/cjs/types/enums.d.ts +36 -17
- package/cjs/types/enums.js +30 -11
- package/esm/constants/index.js +117 -42
- package/esm/index.d.ts +2 -2
- package/esm/index.js +5 -2
- package/esm/services/strategiesService.js +157 -12
- package/esm/services/strategySubService.d.ts +18 -21
- package/esm/services/strategySubService.js +78 -73
- package/esm/services/strategySubService.test.js +4 -147
- package/esm/services/subDataService.d.ts +70 -20
- package/esm/services/subDataService.js +21 -77
- package/esm/services/subDataService.test.js +18 -200
- package/esm/services/utils.d.ts +2 -1
- package/esm/services/utils.js +13 -1
- package/esm/types/enums.d.ts +36 -17
- package/esm/types/enums.js +30 -11
- package/package.json +1 -1
- package/src/constants/index.ts +119 -43
- package/src/index.ts +22 -6
- package/src/services/strategiesService.ts +221 -12
- package/src/services/strategySubService.test.ts +3 -191
- package/src/services/strategySubService.ts +173 -121
- package/src/services/subDataService.test.ts +18 -214
- package/src/services/subDataService.ts +42 -106
- package/src/services/utils.test.ts +1 -1
- package/src/services/utils.ts +15 -1
- package/src/types/enums.ts +30 -13
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
|
-
import Dec from 'decimal.js';
|
|
3
2
|
import { otherAddresses } from '@defisaver/sdk';
|
|
4
3
|
import { getAssetInfo, MAXUINT } from '@defisaver/tokens';
|
|
5
4
|
import * as web3Utils from 'web3-utils';
|
|
@@ -9,12 +8,10 @@ import type { EthereumAddress, StrategyOrBundleIds, SubData, TriggerData } from
|
|
|
9
8
|
|
|
10
9
|
import '../configuration';
|
|
11
10
|
import {
|
|
12
|
-
chickenBondsEncode,
|
|
13
11
|
liquityEncode,
|
|
14
12
|
makerEncode,
|
|
15
13
|
aaveV3Encode,
|
|
16
14
|
compoundV3Encode,
|
|
17
|
-
morphoAaveV2Encode,
|
|
18
15
|
exchangeEncode,
|
|
19
16
|
crvUSDEncode,
|
|
20
17
|
morphoBlueEncode,
|
|
@@ -137,7 +134,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
137
134
|
});
|
|
138
135
|
});
|
|
139
136
|
|
|
140
|
-
describe('
|
|
137
|
+
describe('leverageManagement()', () => {
|
|
141
138
|
const examples: Array<[
|
|
142
139
|
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
143
140
|
[
|
|
@@ -187,7 +184,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
187
184
|
|
|
188
185
|
examples.forEach(([expected, actual]) => {
|
|
189
186
|
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
190
|
-
expect(makerEncode.
|
|
187
|
+
expect(makerEncode.leverageManagement(...actual)).to.eql(expected);
|
|
191
188
|
});
|
|
192
189
|
});
|
|
193
190
|
});
|
|
@@ -348,26 +345,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
348
345
|
});
|
|
349
346
|
});
|
|
350
347
|
|
|
351
|
-
describe('When testing strategySubService.chickenBondsEncode', () => {
|
|
352
|
-
describe('rebond()', () => {
|
|
353
|
-
const examples: Array<[
|
|
354
|
-
SubData,
|
|
355
|
-
[bondId: number],
|
|
356
|
-
]> = [
|
|
357
|
-
[
|
|
358
|
-
['0x00000000000000000000000000000000000000000000000000000000000005e3'],
|
|
359
|
-
[1507]
|
|
360
|
-
]
|
|
361
|
-
];
|
|
362
|
-
|
|
363
|
-
examples.forEach(([expected, actual]) => {
|
|
364
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
365
|
-
expect(chickenBondsEncode.rebond(...actual)).to.eql(expected);
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
});
|
|
369
|
-
});
|
|
370
|
-
|
|
371
348
|
describe('When testing strategySubService.aaveV3Encode', () => {
|
|
372
349
|
describe('closeToAsset()', () => {
|
|
373
350
|
const examples: Array<[
|
|
@@ -1156,27 +1133,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1156
1133
|
});
|
|
1157
1134
|
});
|
|
1158
1135
|
|
|
1159
|
-
describe('When testing strategySubService.morphoAaveV2Encode', () => {
|
|
1160
|
-
describe('leverageManagement()', () => {
|
|
1161
|
-
const examples: Array<[[string, string, string, string, boolean], [triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean]]> = [
|
|
1162
|
-
[
|
|
1163
|
-
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
1164
|
-
[160, 220, 180, 190, true]
|
|
1165
|
-
],
|
|
1166
|
-
[
|
|
1167
|
-
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
1168
|
-
[160, 200, 180, 190, false]
|
|
1169
|
-
],
|
|
1170
|
-
];
|
|
1171
|
-
|
|
1172
|
-
examples.forEach(([expected, actual]) => {
|
|
1173
|
-
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1174
|
-
expect(morphoAaveV2Encode.leverageManagement(...actual)).to.eql(expected);
|
|
1175
|
-
});
|
|
1176
|
-
});
|
|
1177
|
-
});
|
|
1178
|
-
});
|
|
1179
|
-
|
|
1180
1136
|
describe('When testing strategySubService.exchangeEncode', () => {
|
|
1181
1137
|
describe('dca()', () => {
|
|
1182
1138
|
const examples: Array<[
|
|
@@ -1501,93 +1457,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1501
1457
|
});
|
|
1502
1458
|
});
|
|
1503
1459
|
|
|
1504
|
-
describe('leverageManagementOnPriceGeneric()', () => {
|
|
1505
|
-
const examples: Array<[
|
|
1506
|
-
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
1507
|
-
[
|
|
1508
|
-
loanToken: EthereumAddress,
|
|
1509
|
-
collToken: EthereumAddress,
|
|
1510
|
-
oracle: EthereumAddress,
|
|
1511
|
-
irm: EthereumAddress,
|
|
1512
|
-
lltv: string,
|
|
1513
|
-
user: EthereumAddress,
|
|
1514
|
-
targetRatio: number,
|
|
1515
|
-
price: number,
|
|
1516
|
-
priceState: RatioState,
|
|
1517
|
-
isBoost: boolean,
|
|
1518
|
-
isEOA: boolean,
|
|
1519
|
-
network: ChainId,
|
|
1520
|
-
]
|
|
1521
|
-
]> = [
|
|
1522
|
-
[
|
|
1523
|
-
[
|
|
1524
|
-
Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
1525
|
-
true,
|
|
1526
|
-
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1527
|
-
[
|
|
1528
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1529
|
-
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1530
|
-
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1531
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1532
|
-
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1533
|
-
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1534
|
-
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1535
|
-
],
|
|
1536
|
-
],
|
|
1537
|
-
[
|
|
1538
|
-
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1539
|
-
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1540
|
-
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1541
|
-
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1542
|
-
'945000000000000000',
|
|
1543
|
-
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1544
|
-
200,
|
|
1545
|
-
2500,
|
|
1546
|
-
RatioState.UNDER,
|
|
1547
|
-
false,
|
|
1548
|
-
false,
|
|
1549
|
-
ChainId.Ethereum,
|
|
1550
|
-
],
|
|
1551
|
-
],
|
|
1552
|
-
[
|
|
1553
|
-
[
|
|
1554
|
-
Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
|
|
1555
|
-
true,
|
|
1556
|
-
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1557
|
-
[
|
|
1558
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1559
|
-
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1560
|
-
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1561
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1562
|
-
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1563
|
-
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1564
|
-
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1565
|
-
],
|
|
1566
|
-
],
|
|
1567
|
-
[
|
|
1568
|
-
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1569
|
-
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1570
|
-
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1571
|
-
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1572
|
-
'945000000000000000',
|
|
1573
|
-
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1574
|
-
160,
|
|
1575
|
-
4000,
|
|
1576
|
-
RatioState.OVER,
|
|
1577
|
-
true,
|
|
1578
|
-
false,
|
|
1579
|
-
ChainId.Ethereum,
|
|
1580
|
-
],
|
|
1581
|
-
],
|
|
1582
|
-
];
|
|
1583
|
-
|
|
1584
|
-
examples.forEach(([expected, actual]) => {
|
|
1585
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1586
|
-
expect(morphoBlueEncode.leverageManagementOnPriceGeneric(...actual)).to.eql(expected);
|
|
1587
|
-
});
|
|
1588
|
-
});
|
|
1589
|
-
});
|
|
1590
|
-
|
|
1591
1460
|
describe('closeOnPrice()', () => {
|
|
1592
1461
|
const examples: Array<[
|
|
1593
1462
|
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
@@ -1631,7 +1500,7 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1631
1500
|
1500,
|
|
1632
1501
|
CloseToAssetType.DEBT,
|
|
1633
1502
|
4000,
|
|
1634
|
-
CloseToAssetType.COLLATERAL
|
|
1503
|
+
CloseToAssetType.COLLATERAL
|
|
1635
1504
|
]
|
|
1636
1505
|
],
|
|
1637
1506
|
];
|
|
@@ -1642,63 +1511,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1642
1511
|
});
|
|
1643
1512
|
});
|
|
1644
1513
|
});
|
|
1645
|
-
|
|
1646
|
-
describe('closeOnPriceGeneric()', () => {
|
|
1647
|
-
const examples: Array<[
|
|
1648
|
-
[StrategyOrBundleIds, boolean, TriggerData, SubData],
|
|
1649
|
-
[
|
|
1650
|
-
loanToken: EthereumAddress,
|
|
1651
|
-
collToken: EthereumAddress,
|
|
1652
|
-
oracle: EthereumAddress,
|
|
1653
|
-
irm: EthereumAddress,
|
|
1654
|
-
lltv: string,
|
|
1655
|
-
user: EthereumAddress,
|
|
1656
|
-
stopLossPrice: number,
|
|
1657
|
-
stopLossType: CloseToAssetType,
|
|
1658
|
-
takeProfitPrice: number,
|
|
1659
|
-
takeProfitType: CloseToAssetType,
|
|
1660
|
-
isEOA: boolean,
|
|
1661
|
-
network: ChainId,
|
|
1662
|
-
]
|
|
1663
|
-
]> = [
|
|
1664
|
-
[
|
|
1665
|
-
[
|
|
1666
|
-
Bundles.MainnetIds.MORPHO_BLUE_CLOSE,
|
|
1667
|
-
true,
|
|
1668
|
-
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
1669
|
-
[
|
|
1670
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1671
|
-
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1672
|
-
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1673
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1674
|
-
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1675
|
-
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1676
|
-
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
1677
|
-
],
|
|
1678
|
-
],
|
|
1679
|
-
[
|
|
1680
|
-
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1681
|
-
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1682
|
-
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1683
|
-
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1684
|
-
'945000000000000000',
|
|
1685
|
-
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1686
|
-
1500,
|
|
1687
|
-
CloseToAssetType.DEBT,
|
|
1688
|
-
4000,
|
|
1689
|
-
CloseToAssetType.COLLATERAL,
|
|
1690
|
-
false,
|
|
1691
|
-
ChainId.Ethereum,
|
|
1692
|
-
]
|
|
1693
|
-
],
|
|
1694
|
-
];
|
|
1695
|
-
|
|
1696
|
-
examples.forEach(([expected, actual]) => {
|
|
1697
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1698
|
-
expect(morphoBlueEncode.closeOnPriceGeneric(...actual)).to.eql(expected);
|
|
1699
|
-
});
|
|
1700
|
-
});
|
|
1701
|
-
});
|
|
1702
1514
|
});
|
|
1703
1515
|
|
|
1704
1516
|
describe('When testing strategySubService.sparkEncode', () => {
|