@defisaver/automation-sdk 3.3.10-aave-v4-1-dev → 3.3.10-aave-v4-3-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 +25 -0
- package/cjs/services/strategySubService.d.ts +13 -0
- package/cjs/services/strategySubService.js +7 -0
- package/cjs/services/strategySubService.test.js +133 -0
- package/cjs/services/subDataService.d.ts +11 -0
- package/cjs/services/subDataService.js +25 -1
- package/cjs/services/subDataService.test.js +57 -0
- package/cjs/services/triggerService.d.ts +9 -0
- package/cjs/services/triggerService.js +16 -1
- package/cjs/services/triggerService.test.js +46 -0
- package/cjs/types/enums.d.ts +16 -12
- package/cjs/types/enums.js +15 -11
- package/cjs/types/index.d.ts +12 -1
- package/esm/constants/index.js +15 -0
- package/esm/services/strategiesService.js +25 -0
- package/esm/services/strategySubService.d.ts +13 -0
- package/esm/services/strategySubService.js +7 -0
- package/esm/services/strategySubService.test.js +134 -1
- package/esm/services/subDataService.d.ts +11 -0
- package/esm/services/subDataService.js +24 -0
- package/esm/services/subDataService.test.js +57 -0
- package/esm/services/triggerService.d.ts +9 -0
- package/esm/services/triggerService.js +15 -0
- package/esm/services/triggerService.test.js +47 -1
- package/esm/types/enums.d.ts +16 -12
- package/esm/types/enums.js +15 -11
- package/esm/types/index.d.ts +12 -1
- package/package.json +2 -2
- package/src/constants/index.ts +15 -0
- package/src/services/strategiesService.ts +31 -1
- package/src/services/strategySubService.test.ts +161 -0
- package/src/services/strategySubService.ts +22 -0
- package/src/services/subDataService.test.ts +66 -0
- package/src/services/subDataService.ts +38 -1
- package/src/services/triggerService.test.ts +50 -1
- package/src/services/triggerService.ts +23 -0
- package/src/types/enums.ts +15 -11
- package/src/types/index.ts +14 -1
package/cjs/constants/index.js
CHANGED
|
@@ -111,6 +111,11 @@ exports.MAINNET_STRATEGIES_INFO = {
|
|
|
111
111
|
strategyId: enums_1.Strategies.Identifiers.CollateralSwitch,
|
|
112
112
|
protocol: exports.PROTOCOLS.AaveV4,
|
|
113
113
|
},
|
|
114
|
+
[enums_1.Strategies.MainnetIds.AAVE_V4_COLLATERAL_SWITCH_EOA]: {
|
|
115
|
+
strategyOrBundleId: enums_1.Strategies.MainnetIds.AAVE_V4_COLLATERAL_SWITCH_EOA,
|
|
116
|
+
strategyId: enums_1.Strategies.Identifiers.EoaCollateralSwitch,
|
|
117
|
+
protocol: exports.PROTOCOLS.AaveV4,
|
|
118
|
+
},
|
|
114
119
|
};
|
|
115
120
|
exports.OPTIMISM_STRATEGIES_INFO = {
|
|
116
121
|
[enums_1.Strategies.OptimismIds.EXCHANGE_DCA]: {
|
|
@@ -478,6 +483,16 @@ exports.MAINNET_BUNDLES_INFO = {
|
|
|
478
483
|
strategyId: enums_1.Strategies.Identifiers.CloseOnPrice,
|
|
479
484
|
protocol: exports.PROTOCOLS.MorphoBlue,
|
|
480
485
|
},
|
|
486
|
+
[enums_1.Bundles.MainnetIds.SPARK_REPAY_ON_PRICE]: {
|
|
487
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.SPARK_REPAY_ON_PRICE,
|
|
488
|
+
strategyId: enums_1.Strategies.Identifiers.RepayOnPrice,
|
|
489
|
+
protocol: exports.PROTOCOLS.Spark,
|
|
490
|
+
},
|
|
491
|
+
[enums_1.Bundles.MainnetIds.SPARK_BOOST_ON_PRICE]: {
|
|
492
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.SPARK_BOOST_ON_PRICE,
|
|
493
|
+
strategyId: enums_1.Strategies.Identifiers.BoostOnPrice,
|
|
494
|
+
protocol: exports.PROTOCOLS.Spark,
|
|
495
|
+
},
|
|
481
496
|
[enums_1.Bundles.MainnetIds.AAVE_V4_REPAY]: {
|
|
482
497
|
strategyOrBundleId: enums_1.Bundles.MainnetIds.AAVE_V4_REPAY,
|
|
483
498
|
strategyId: enums_1.Strategies.Identifiers.Repay,
|
|
@@ -701,6 +701,29 @@ function parseSparkLeverageManagement(position, parseData) {
|
|
|
701
701
|
_position.strategy.strategyId = enums_1.Strategies.IdOverrides.LeverageManagement;
|
|
702
702
|
return _position;
|
|
703
703
|
}
|
|
704
|
+
function parseSparkLeverageManagementOnPrice(position, parseData) {
|
|
705
|
+
const _position = (0, lodash_1.cloneDeep)(position);
|
|
706
|
+
const { subStruct } = parseData.subscriptionEventData;
|
|
707
|
+
const triggerData = triggerService.sparkQuotePriceTrigger.decode(subStruct.triggerData);
|
|
708
|
+
const subData = subDataService.sparkLeverageManagementOnPriceSubData.decode(subStruct.subData);
|
|
709
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
710
|
+
_position.strategyData.decoded.subData = subData;
|
|
711
|
+
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, subData.marketAddr);
|
|
712
|
+
_position.specific = {
|
|
713
|
+
// subData
|
|
714
|
+
collAsset: subData.collAsset,
|
|
715
|
+
collAssetId: subData.collAssetId,
|
|
716
|
+
debtAsset: subData.debtAsset,
|
|
717
|
+
debtAssetId: subData.debtAssetId,
|
|
718
|
+
ratio: subData.targetRatio,
|
|
719
|
+
// triggerData
|
|
720
|
+
baseToken: triggerData.baseTokenAddr,
|
|
721
|
+
quoteToken: triggerData.quoteTokenAddr,
|
|
722
|
+
price: triggerData.price,
|
|
723
|
+
ratioState: triggerData.ratioState,
|
|
724
|
+
};
|
|
725
|
+
return _position;
|
|
726
|
+
}
|
|
704
727
|
function parseSparkCloseOnPrice(position, parseData) {
|
|
705
728
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
706
729
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -1074,6 +1097,8 @@ const parsingMethodsMapping = {
|
|
|
1074
1097
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.Spark]: {
|
|
1075
1098
|
[enums_1.Strategies.Identifiers.Repay]: parseSparkLeverageManagement,
|
|
1076
1099
|
[enums_1.Strategies.Identifiers.Boost]: parseSparkLeverageManagement,
|
|
1100
|
+
[enums_1.Strategies.Identifiers.RepayOnPrice]: parseSparkLeverageManagementOnPrice,
|
|
1101
|
+
[enums_1.Strategies.Identifiers.BoostOnPrice]: parseSparkLeverageManagementOnPrice,
|
|
1077
1102
|
[enums_1.Strategies.Identifiers.CloseOnPrice]: parseSparkCloseOnPrice,
|
|
1078
1103
|
},
|
|
1079
1104
|
[enums_1.ProtocolIdentifiers.StrategiesAutomation.CrvUSD]: {
|
|
@@ -86,6 +86,19 @@ export declare const exchangeEncode: {
|
|
|
86
86
|
};
|
|
87
87
|
export declare const sparkEncode: {
|
|
88
88
|
leverageManagement(triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean): string;
|
|
89
|
+
leverageManagementOnPrice(strategyOrBundleId: number, isBundle: boolean | undefined, triggerData: {
|
|
90
|
+
baseTokenAddr: EthereumAddress;
|
|
91
|
+
quoteTokenAddr: EthereumAddress;
|
|
92
|
+
price: number;
|
|
93
|
+
ratioState: RatioState;
|
|
94
|
+
}, subData: {
|
|
95
|
+
collAsset: EthereumAddress;
|
|
96
|
+
collAssetId: number;
|
|
97
|
+
debtAsset: EthereumAddress;
|
|
98
|
+
debtAssetId: number;
|
|
99
|
+
marketAddr: EthereumAddress;
|
|
100
|
+
targetRatio: number;
|
|
101
|
+
}): (number | boolean | string[])[];
|
|
89
102
|
closeOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
90
103
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
91
104
|
};
|
|
@@ -272,6 +272,13 @@ exports.sparkEncode = {
|
|
|
272
272
|
subInput = subInput.concat(boostEnabled ? '01' : '00');
|
|
273
273
|
return subInput;
|
|
274
274
|
},
|
|
275
|
+
leverageManagementOnPrice(strategyOrBundleId, isBundle = true, triggerData, subData) {
|
|
276
|
+
const { collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, } = subData;
|
|
277
|
+
const subDataEncoded = subDataService.sparkLeverageManagementOnPriceSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio);
|
|
278
|
+
const { baseTokenAddr, quoteTokenAddr, price, ratioState, } = triggerData;
|
|
279
|
+
const triggerDataEncoded = triggerService.sparkQuotePriceTrigger.encode(baseTokenAddr, quoteTokenAddr, price, ratioState);
|
|
280
|
+
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
281
|
+
},
|
|
275
282
|
closeOnPriceGeneric(strategyOrBundleId, collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, user, stopLossPrice = 0, stopLossType = enums_1.CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = enums_1.CloseToAssetType.COLLATERAL) {
|
|
276
283
|
const isBundle = true;
|
|
277
284
|
const closeType = (0, utils_1.getCloseStrategyType)(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
@@ -1481,6 +1481,139 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1481
1481
|
});
|
|
1482
1482
|
});
|
|
1483
1483
|
});
|
|
1484
|
+
describe('When testing strategySubService.sparkEncode', () => {
|
|
1485
|
+
describe('leverageManagement()', () => {
|
|
1486
|
+
const examples = [
|
|
1487
|
+
[
|
|
1488
|
+
'0x0000000000000000136dcc951d8c00000000000000000000214e8348c4f0000000000000000000001d24b2dfac52000000000000000000001a5e27eef13e000001',
|
|
1489
|
+
[140, 240, 210, 190, true]
|
|
1490
|
+
],
|
|
1491
|
+
[
|
|
1492
|
+
'0x0000000000000000130337bdce49000000000000000000001988fe4052b800000000000000000000281b57b028e1000000000000000000002223acf76376000000',
|
|
1493
|
+
[137, 184, 289, 246, false]
|
|
1494
|
+
]
|
|
1495
|
+
];
|
|
1496
|
+
examples.forEach(([expected, actual]) => {
|
|
1497
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1498
|
+
(0, chai_1.expect)(strategySubService_1.sparkEncode.leverageManagement(...actual)).to.eql(expected);
|
|
1499
|
+
});
|
|
1500
|
+
});
|
|
1501
|
+
});
|
|
1502
|
+
describe('leverageManagementOnPrice()', () => {
|
|
1503
|
+
const examples = [
|
|
1504
|
+
[
|
|
1505
|
+
[
|
|
1506
|
+
enums_1.Bundles.MainnetIds.SPARK_REPAY_ON_PRICE,
|
|
1507
|
+
true,
|
|
1508
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1509
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1510
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1511
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1512
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1513
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1514
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1515
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1516
|
+
],
|
|
1517
|
+
],
|
|
1518
|
+
[
|
|
1519
|
+
59,
|
|
1520
|
+
true,
|
|
1521
|
+
{
|
|
1522
|
+
baseTokenAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1523
|
+
quoteTokenAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1524
|
+
price: 2500,
|
|
1525
|
+
ratioState: enums_1.RatioState.UNDER,
|
|
1526
|
+
},
|
|
1527
|
+
{
|
|
1528
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1529
|
+
collAssetId: 0,
|
|
1530
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1531
|
+
debtAssetId: 1,
|
|
1532
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1533
|
+
targetRatio: 200,
|
|
1534
|
+
},
|
|
1535
|
+
]
|
|
1536
|
+
],
|
|
1537
|
+
[
|
|
1538
|
+
[
|
|
1539
|
+
enums_1.Bundles.MainnetIds.SPARK_BOOST_ON_PRICE,
|
|
1540
|
+
true,
|
|
1541
|
+
['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000417bce6c8000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1542
|
+
[
|
|
1543
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1544
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1545
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1546
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1547
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1548
|
+
'0x00000000000000000000000000000000000000000000000022b1c8c1227a0000',
|
|
1549
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1550
|
+
]
|
|
1551
|
+
],
|
|
1552
|
+
[
|
|
1553
|
+
60,
|
|
1554
|
+
true,
|
|
1555
|
+
{
|
|
1556
|
+
baseTokenAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1557
|
+
quoteTokenAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1558
|
+
price: 45000,
|
|
1559
|
+
ratioState: enums_1.RatioState.OVER,
|
|
1560
|
+
},
|
|
1561
|
+
{
|
|
1562
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1563
|
+
collAssetId: 2,
|
|
1564
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1565
|
+
debtAssetId: 4,
|
|
1566
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1567
|
+
targetRatio: 250,
|
|
1568
|
+
},
|
|
1569
|
+
]
|
|
1570
|
+
]
|
|
1571
|
+
];
|
|
1572
|
+
examples.forEach(([expected, actual]) => {
|
|
1573
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1574
|
+
(0, chai_1.expect)(strategySubService_1.sparkEncode.leverageManagementOnPrice(...actual)).to.eql(expected);
|
|
1575
|
+
});
|
|
1576
|
+
});
|
|
1577
|
+
});
|
|
1578
|
+
describe('closeOnPrice()', () => {
|
|
1579
|
+
const examples = [
|
|
1580
|
+
[
|
|
1581
|
+
[
|
|
1582
|
+
enums_1.Bundles.MainnetIds.SPARK_CLOSE,
|
|
1583
|
+
true,
|
|
1584
|
+
['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000003a35294400000000000000000000000000000000000000000000000000000000574fbde6000'],
|
|
1585
|
+
[
|
|
1586
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1587
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1588
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1589
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1590
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
1591
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
1592
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1593
|
+
]
|
|
1594
|
+
],
|
|
1595
|
+
[
|
|
1596
|
+
57,
|
|
1597
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1598
|
+
2,
|
|
1599
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1600
|
+
4,
|
|
1601
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
1602
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1603
|
+
40000,
|
|
1604
|
+
enums_1.CloseToAssetType.DEBT,
|
|
1605
|
+
60000,
|
|
1606
|
+
enums_1.CloseToAssetType.COLLATERAL,
|
|
1607
|
+
]
|
|
1608
|
+
],
|
|
1609
|
+
];
|
|
1610
|
+
examples.forEach(([expected, actual]) => {
|
|
1611
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1612
|
+
(0, chai_1.expect)(strategySubService_1.sparkEncode.closeOnPriceGeneric(...actual)).to.eql(expected);
|
|
1613
|
+
});
|
|
1614
|
+
});
|
|
1615
|
+
});
|
|
1616
|
+
});
|
|
1484
1617
|
describe('When testing strategySubService.aaveV4Encode', () => {
|
|
1485
1618
|
describe('leverageManagement()', () => {
|
|
1486
1619
|
const examples = [
|
|
@@ -418,6 +418,17 @@ export declare const sparkCloseGenericSubData: {
|
|
|
418
418
|
owner: EthereumAddress;
|
|
419
419
|
};
|
|
420
420
|
};
|
|
421
|
+
export declare const sparkLeverageManagementOnPriceSubData: {
|
|
422
|
+
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number): string[];
|
|
423
|
+
decode(subData: string[]): {
|
|
424
|
+
collAsset: EthereumAddress;
|
|
425
|
+
collAssetId: number;
|
|
426
|
+
debtAsset: EthereumAddress;
|
|
427
|
+
debtAssetId: number;
|
|
428
|
+
marketAddr: EthereumAddress;
|
|
429
|
+
targetRatio: number;
|
|
430
|
+
};
|
|
431
|
+
};
|
|
421
432
|
/**
|
|
422
433
|
______ .______ ____ ____ __ __ _______. _______
|
|
423
434
|
/ || _ \ \ \ / / | | | | / || \
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.fluidLeverageManagementSubData = exports.morphoBlueCloseOnPriceSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.sparkCloseGenericSubData = exports.sparkLeverageManagementSubDataWithoutSubProxy = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.compoundV3L2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV4CollateralSwitchSubData = exports.aaveV4CloseSubData = exports.aaveV4LeverageManagementOnPriceSubData = exports.aaveV4LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3CollateralSwitchSubData = exports.aaveV3CloseGenericSubData = exports.aaveV3LeverageManagementOnPriceGeneric = exports.aaveV3LeverageManagementSubDataWithoutSubProxy = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityV2PaybackSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.liquityRepayFromSavingsSubData = exports.makerLeverageManagementWithoutSubProxy = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.makerRepayFromSavingsSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = void 0;
|
|
6
|
+
exports.fluidLeverageManagementSubData = exports.morphoBlueCloseOnPriceSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.sparkLeverageManagementOnPriceSubData = exports.sparkCloseGenericSubData = exports.sparkLeverageManagementSubDataWithoutSubProxy = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.compoundV3L2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV4CollateralSwitchSubData = exports.aaveV4CloseSubData = exports.aaveV4LeverageManagementOnPriceSubData = exports.aaveV4LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3CollateralSwitchSubData = exports.aaveV3CloseGenericSubData = exports.aaveV3LeverageManagementOnPriceGeneric = exports.aaveV3LeverageManagementSubDataWithoutSubProxy = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityV2PaybackSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.liquityRepayFromSavingsSubData = exports.makerLeverageManagementWithoutSubProxy = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.makerRepayFromSavingsSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
9
9
|
const web3_utils_1 = require("web3-utils");
|
|
@@ -949,6 +949,30 @@ exports.sparkCloseGenericSubData = {
|
|
|
949
949
|
};
|
|
950
950
|
},
|
|
951
951
|
};
|
|
952
|
+
exports.sparkLeverageManagementOnPriceSubData = {
|
|
953
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio) {
|
|
954
|
+
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
955
|
+
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint16', collAssetId);
|
|
956
|
+
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
957
|
+
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint16', debtAssetId);
|
|
958
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
959
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
960
|
+
const useOnBehalfEncoded = web3_eth_abi_1.default.encodeParameter('bool', false);
|
|
961
|
+
return [encodedColl, encodedCollId, encodedDebt, encodedDebtId, encodedMarket, encodedTargetRatio, useOnBehalfEncoded];
|
|
962
|
+
},
|
|
963
|
+
decode(subData) {
|
|
964
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
965
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint16', subData[1]));
|
|
966
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
967
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint16', subData[3]));
|
|
968
|
+
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
969
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
970
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
971
|
+
return {
|
|
972
|
+
collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio,
|
|
973
|
+
};
|
|
974
|
+
},
|
|
975
|
+
};
|
|
952
976
|
/**
|
|
953
977
|
______ .______ ____ ____ __ __ _______. _______
|
|
954
978
|
/ || _ \ \ \ / / | | | | / || \
|
|
@@ -2089,6 +2089,63 @@ describe('Feature: subDataService.ts', () => {
|
|
|
2089
2089
|
});
|
|
2090
2090
|
});
|
|
2091
2091
|
});
|
|
2092
|
+
describe('When testing subDataService.sparkLeverageManagementOnPriceSubData', () => {
|
|
2093
|
+
describe('encode()', () => {
|
|
2094
|
+
const examples = [
|
|
2095
|
+
[
|
|
2096
|
+
[
|
|
2097
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2098
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2099
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2100
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2101
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2102
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
2103
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2104
|
+
],
|
|
2105
|
+
[
|
|
2106
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
2107
|
+
0,
|
|
2108
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2109
|
+
1,
|
|
2110
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2111
|
+
200,
|
|
2112
|
+
]
|
|
2113
|
+
]
|
|
2114
|
+
];
|
|
2115
|
+
examples.forEach(([expected, actual]) => {
|
|
2116
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2117
|
+
(0, chai_1.expect)(subDataService.sparkLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
2118
|
+
});
|
|
2119
|
+
});
|
|
2120
|
+
});
|
|
2121
|
+
describe('decode()', () => {
|
|
2122
|
+
const examples = [
|
|
2123
|
+
[
|
|
2124
|
+
{
|
|
2125
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
2126
|
+
collAssetId: 2,
|
|
2127
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
2128
|
+
debtAssetId: 4,
|
|
2129
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2130
|
+
targetRatio: 175
|
|
2131
|
+
},
|
|
2132
|
+
[
|
|
2133
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2134
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2135
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
2136
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2137
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2138
|
+
'0x00000000000000000000000000000000000000000000000018493fba64ef0000'
|
|
2139
|
+
]
|
|
2140
|
+
]
|
|
2141
|
+
];
|
|
2142
|
+
examples.forEach(([expected, actual]) => {
|
|
2143
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2144
|
+
(0, chai_1.expect)(subDataService.sparkLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
2145
|
+
});
|
|
2146
|
+
});
|
|
2147
|
+
});
|
|
2148
|
+
});
|
|
2092
2149
|
describe('When testing subDataService.aaveV4LeverageManagementSubData', () => {
|
|
2093
2150
|
describe('encode()', () => {
|
|
2094
2151
|
const examples = [
|
|
@@ -285,6 +285,15 @@ export declare const morphoBluePriceRangeTrigger: {
|
|
|
285
285
|
upperPrice: string;
|
|
286
286
|
};
|
|
287
287
|
};
|
|
288
|
+
export declare const sparkQuotePriceTrigger: {
|
|
289
|
+
encode(baseTokenAddr: EthereumAddress, quoteTokenAddr: EthereumAddress, price: number, ratioState: RatioState): string[];
|
|
290
|
+
decode(triggerData: string[]): {
|
|
291
|
+
baseTokenAddr: string;
|
|
292
|
+
quoteTokenAddr: string;
|
|
293
|
+
price: string;
|
|
294
|
+
ratioState: number;
|
|
295
|
+
};
|
|
296
|
+
};
|
|
288
297
|
export declare const aaveV4RatioTrigger: {
|
|
289
298
|
encode(owner: EthereumAddress, spoke: EthereumAddress, ratioPercentage: number, ratioState: RatioState): string[];
|
|
290
299
|
decode(triggerData: string[]): {
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.aaveV4QuotePriceRangeTrigger = exports.aaveV4QuotePriceTrigger = exports.aaveV4RatioTrigger = exports.morphoBluePriceRangeTrigger = exports.sparkQuotePriceRangeTrigger = exports.aaveV3QuotePriceRangeTrigger = exports.compoundV3PriceRangeTrigger = exports.compoundV3PriceTrigger = exports.fluidRatioTrigger = exports.morphoBluePriceTrigger = exports.closePriceTrigger = exports.liquityV2QuotePriceTrigger = exports.liquityV2RatioTrigger = exports.morphoBlueRatioTrigger = exports.crvUsdHealthRatioTrigger = exports.crvUSDRatioTrigger = exports.curveUsdSoftLiquidationTrigger = exports.curveUsdBorrowRateTrigger = exports.sparkRatioTrigger = exports.exchangeOffchainPriceTrigger = exports.exchangeTimestampTrigger = exports.compoundV3RatioTrigger = exports.cBondsRebondTrigger = exports.aaveV2RatioTrigger = exports.liquityV2AdjustTimeTrigger = exports.liquityV2DebtInFrontTrigger = exports.liquityDebtInFrontWithLimitTrigger = exports.liquityDebtInFrontTrigger = exports.liquityRatioTrigger = exports.compoundV2RatioTrigger = exports.aaveV3QuotePriceWithMaximumGasPriceTrigger = exports.aaveV3QuotePriceTrigger = exports.morphoAaveV2RatioTrigger = exports.aaveV3RatioTrigger = exports.makerRatioTrigger = exports.trailingStopTrigger = exports.chainlinkPriceTrigger = void 0;
|
|
29
|
+
exports.aaveV4QuotePriceRangeTrigger = exports.aaveV4QuotePriceTrigger = exports.aaveV4RatioTrigger = exports.sparkQuotePriceTrigger = exports.morphoBluePriceRangeTrigger = exports.sparkQuotePriceRangeTrigger = exports.aaveV3QuotePriceRangeTrigger = exports.compoundV3PriceRangeTrigger = exports.compoundV3PriceTrigger = exports.fluidRatioTrigger = exports.morphoBluePriceTrigger = exports.closePriceTrigger = exports.liquityV2QuotePriceTrigger = exports.liquityV2RatioTrigger = exports.morphoBlueRatioTrigger = exports.crvUsdHealthRatioTrigger = exports.crvUSDRatioTrigger = exports.curveUsdSoftLiquidationTrigger = exports.curveUsdBorrowRateTrigger = exports.sparkRatioTrigger = exports.exchangeOffchainPriceTrigger = exports.exchangeTimestampTrigger = exports.compoundV3RatioTrigger = exports.cBondsRebondTrigger = exports.aaveV2RatioTrigger = exports.liquityV2AdjustTimeTrigger = exports.liquityV2DebtInFrontTrigger = exports.liquityDebtInFrontWithLimitTrigger = exports.liquityDebtInFrontTrigger = exports.liquityRatioTrigger = exports.compoundV2RatioTrigger = exports.aaveV3QuotePriceWithMaximumGasPriceTrigger = exports.aaveV3QuotePriceTrigger = exports.morphoAaveV2RatioTrigger = exports.aaveV3RatioTrigger = exports.makerRatioTrigger = exports.trailingStopTrigger = exports.chainlinkPriceTrigger = void 0;
|
|
30
30
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
31
31
|
const tokens_1 = require("@defisaver/tokens");
|
|
32
32
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
@@ -547,6 +547,21 @@ exports.morphoBluePriceRangeTrigger = {
|
|
|
547
547
|
};
|
|
548
548
|
},
|
|
549
549
|
};
|
|
550
|
+
exports.sparkQuotePriceTrigger = {
|
|
551
|
+
encode(baseTokenAddr, quoteTokenAddr, price, ratioState) {
|
|
552
|
+
const _price = new decimal_js_1.default(price.toString()).mul(1e8).floor().toString();
|
|
553
|
+
return [web3_eth_abi_1.default.encodeParameters(['address', 'address', 'uint256', 'uint8'], [baseTokenAddr, quoteTokenAddr, _price, ratioState])];
|
|
554
|
+
},
|
|
555
|
+
decode(triggerData) {
|
|
556
|
+
const decodedData = web3_eth_abi_1.default.decodeParameters(['address', 'address', 'uint256', 'uint8'], triggerData[0]);
|
|
557
|
+
return {
|
|
558
|
+
baseTokenAddr: decodedData[0],
|
|
559
|
+
quoteTokenAddr: decodedData[1],
|
|
560
|
+
price: new decimal_js_1.default(decodedData[2]).div(1e8).toString(),
|
|
561
|
+
ratioState: Number(decodedData[3]),
|
|
562
|
+
};
|
|
563
|
+
},
|
|
564
|
+
};
|
|
550
565
|
exports.aaveV4RatioTrigger = {
|
|
551
566
|
encode(owner, spoke, ratioPercentage, ratioState) {
|
|
552
567
|
const ratioWei = (0, utils_1.ratioPercentageToWei)(ratioPercentage);
|
|
@@ -1268,4 +1268,50 @@ describe('Feature: triggerService.ts', () => {
|
|
|
1268
1268
|
});
|
|
1269
1269
|
});
|
|
1270
1270
|
});
|
|
1271
|
+
describe('When testing triggerService.sparkQuotePriceTrigger', () => {
|
|
1272
|
+
describe('encode()', () => {
|
|
1273
|
+
const examples = [
|
|
1274
|
+
[
|
|
1275
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1276
|
+
[web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address), web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address), 2500, enums_1.RatioState.UNDER]
|
|
1277
|
+
],
|
|
1278
|
+
[
|
|
1279
|
+
['0x000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000000000c1c0000000000000000000000000000000000000000000000000000000000000000'],
|
|
1280
|
+
[web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDT', enums_1.ChainId.Ethereum).address), web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address), 0.000031, enums_1.RatioState.OVER]
|
|
1281
|
+
],
|
|
1282
|
+
];
|
|
1283
|
+
examples.forEach(([expected, actual]) => {
|
|
1284
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1285
|
+
(0, chai_1.expect)(triggerService_1.sparkQuotePriceTrigger.encode(...actual)).to.eql(expected);
|
|
1286
|
+
});
|
|
1287
|
+
});
|
|
1288
|
+
});
|
|
1289
|
+
describe('decode()', () => {
|
|
1290
|
+
const examples = [
|
|
1291
|
+
[
|
|
1292
|
+
{
|
|
1293
|
+
baseTokenAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1294
|
+
quoteTokenAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1295
|
+
price: '2500',
|
|
1296
|
+
ratioState: enums_1.RatioState.UNDER
|
|
1297
|
+
},
|
|
1298
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001']
|
|
1299
|
+
],
|
|
1300
|
+
[
|
|
1301
|
+
{
|
|
1302
|
+
baseTokenAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDT', enums_1.ChainId.Ethereum).address),
|
|
1303
|
+
quoteTokenAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1304
|
+
price: '0.000031',
|
|
1305
|
+
ratioState: enums_1.RatioState.OVER
|
|
1306
|
+
},
|
|
1307
|
+
['0x000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec70000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000000000c1c0000000000000000000000000000000000000000000000000000000000000000']
|
|
1308
|
+
]
|
|
1309
|
+
];
|
|
1310
|
+
examples.forEach(([expected, actual]) => {
|
|
1311
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1312
|
+
(0, chai_1.expect)(triggerService_1.sparkQuotePriceTrigger.decode(actual)).to.eql(expected);
|
|
1313
|
+
});
|
|
1314
|
+
});
|
|
1315
|
+
});
|
|
1316
|
+
});
|
|
1271
1317
|
});
|
package/cjs/types/enums.d.ts
CHANGED
|
@@ -88,7 +88,8 @@ export declare namespace Strategies {
|
|
|
88
88
|
CURVEUSD_PAYBACK = 92,
|
|
89
89
|
LIQUITY_V2_PAYBACK = 113,
|
|
90
90
|
AAVE_V3_COLLATERAL_SWITCH = 135,
|
|
91
|
-
AAVE_V4_COLLATERAL_SWITCH =
|
|
91
|
+
AAVE_V4_COLLATERAL_SWITCH = 154,
|
|
92
|
+
AAVE_V4_COLLATERAL_SWITCH_EOA = 165
|
|
92
93
|
}
|
|
93
94
|
enum OptimismIds {
|
|
94
95
|
EXCHANGE_DCA = 8,
|
|
@@ -135,7 +136,8 @@ export declare namespace Strategies {
|
|
|
135
136
|
RepayOnPrice = "repay-on-price",
|
|
136
137
|
EoaBoostOnPrice = "eoa-boost-on-price",
|
|
137
138
|
EoaRepayOnPrice = "eoa-repay-on-price",
|
|
138
|
-
CollateralSwitch = "collateral-switch"
|
|
139
|
+
CollateralSwitch = "collateral-switch",
|
|
140
|
+
EoaCollateralSwitch = "eoa-collateral-switch"
|
|
139
141
|
}
|
|
140
142
|
enum IdOverrides {
|
|
141
143
|
TakeProfit = "take-profit",
|
|
@@ -210,16 +212,18 @@ export declare namespace Bundles {
|
|
|
210
212
|
AAVE_V3_EOA_CLOSE = 56,
|
|
211
213
|
SPARK_CLOSE = 57,
|
|
212
214
|
MORPHO_BLUE_CLOSE = 58,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
215
|
+
SPARK_REPAY_ON_PRICE = 59,
|
|
216
|
+
SPARK_BOOST_ON_PRICE = 60,
|
|
217
|
+
AAVE_V4_REPAY = 61,
|
|
218
|
+
AAVE_V4_BOOST = 62,
|
|
219
|
+
AAVE_V4_REPAY_ON_PRICE = 63,
|
|
220
|
+
AAVE_V4_BOOST_ON_PRICE = 64,
|
|
221
|
+
AAVE_V4_CLOSE = 65,
|
|
222
|
+
AAVE_V4_EOA_REPAY = 66,
|
|
223
|
+
AAVE_V4_EOA_BOOST = 67,
|
|
224
|
+
AAVE_V4_EOA_REPAY_ON_PRICE = 68,
|
|
225
|
+
AAVE_V4_EOA_BOOST_ON_PRICE = 69,
|
|
226
|
+
AAVE_V4_EOA_CLOSE = 70
|
|
223
227
|
}
|
|
224
228
|
enum OptimismIds {
|
|
225
229
|
AAVE_V3_REPAY = 0,
|
package/cjs/types/enums.js
CHANGED
|
@@ -104,7 +104,8 @@ var Strategies;
|
|
|
104
104
|
MainnetIds[MainnetIds["CURVEUSD_PAYBACK"] = 92] = "CURVEUSD_PAYBACK";
|
|
105
105
|
MainnetIds[MainnetIds["LIQUITY_V2_PAYBACK"] = 113] = "LIQUITY_V2_PAYBACK";
|
|
106
106
|
MainnetIds[MainnetIds["AAVE_V3_COLLATERAL_SWITCH"] = 135] = "AAVE_V3_COLLATERAL_SWITCH";
|
|
107
|
-
MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH"] =
|
|
107
|
+
MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH"] = 154] = "AAVE_V4_COLLATERAL_SWITCH";
|
|
108
|
+
MainnetIds[MainnetIds["AAVE_V4_COLLATERAL_SWITCH_EOA"] = 165] = "AAVE_V4_COLLATERAL_SWITCH_EOA";
|
|
108
109
|
})(MainnetIds = Strategies.MainnetIds || (Strategies.MainnetIds = {}));
|
|
109
110
|
let OptimismIds;
|
|
110
111
|
(function (OptimismIds) {
|
|
@@ -156,6 +157,7 @@ var Strategies;
|
|
|
156
157
|
Identifiers["EoaBoostOnPrice"] = "eoa-boost-on-price";
|
|
157
158
|
Identifiers["EoaRepayOnPrice"] = "eoa-repay-on-price";
|
|
158
159
|
Identifiers["CollateralSwitch"] = "collateral-switch";
|
|
160
|
+
Identifiers["EoaCollateralSwitch"] = "eoa-collateral-switch";
|
|
159
161
|
})(Identifiers = Strategies.Identifiers || (Strategies.Identifiers = {}));
|
|
160
162
|
let IdOverrides;
|
|
161
163
|
(function (IdOverrides) {
|
|
@@ -233,16 +235,18 @@ var Bundles;
|
|
|
233
235
|
MainnetIds[MainnetIds["AAVE_V3_EOA_CLOSE"] = 56] = "AAVE_V3_EOA_CLOSE";
|
|
234
236
|
MainnetIds[MainnetIds["SPARK_CLOSE"] = 57] = "SPARK_CLOSE";
|
|
235
237
|
MainnetIds[MainnetIds["MORPHO_BLUE_CLOSE"] = 58] = "MORPHO_BLUE_CLOSE";
|
|
236
|
-
MainnetIds[MainnetIds["
|
|
237
|
-
MainnetIds[MainnetIds["
|
|
238
|
-
MainnetIds[MainnetIds["
|
|
239
|
-
MainnetIds[MainnetIds["
|
|
240
|
-
MainnetIds[MainnetIds["
|
|
241
|
-
MainnetIds[MainnetIds["
|
|
242
|
-
MainnetIds[MainnetIds["
|
|
243
|
-
MainnetIds[MainnetIds["
|
|
244
|
-
MainnetIds[MainnetIds["
|
|
245
|
-
MainnetIds[MainnetIds["
|
|
238
|
+
MainnetIds[MainnetIds["SPARK_REPAY_ON_PRICE"] = 59] = "SPARK_REPAY_ON_PRICE";
|
|
239
|
+
MainnetIds[MainnetIds["SPARK_BOOST_ON_PRICE"] = 60] = "SPARK_BOOST_ON_PRICE";
|
|
240
|
+
MainnetIds[MainnetIds["AAVE_V4_REPAY"] = 61] = "AAVE_V4_REPAY";
|
|
241
|
+
MainnetIds[MainnetIds["AAVE_V4_BOOST"] = 62] = "AAVE_V4_BOOST";
|
|
242
|
+
MainnetIds[MainnetIds["AAVE_V4_REPAY_ON_PRICE"] = 63] = "AAVE_V4_REPAY_ON_PRICE";
|
|
243
|
+
MainnetIds[MainnetIds["AAVE_V4_BOOST_ON_PRICE"] = 64] = "AAVE_V4_BOOST_ON_PRICE";
|
|
244
|
+
MainnetIds[MainnetIds["AAVE_V4_CLOSE"] = 65] = "AAVE_V4_CLOSE";
|
|
245
|
+
MainnetIds[MainnetIds["AAVE_V4_EOA_REPAY"] = 66] = "AAVE_V4_EOA_REPAY";
|
|
246
|
+
MainnetIds[MainnetIds["AAVE_V4_EOA_BOOST"] = 67] = "AAVE_V4_EOA_BOOST";
|
|
247
|
+
MainnetIds[MainnetIds["AAVE_V4_EOA_REPAY_ON_PRICE"] = 68] = "AAVE_V4_EOA_REPAY_ON_PRICE";
|
|
248
|
+
MainnetIds[MainnetIds["AAVE_V4_EOA_BOOST_ON_PRICE"] = 69] = "AAVE_V4_EOA_BOOST_ON_PRICE";
|
|
249
|
+
MainnetIds[MainnetIds["AAVE_V4_EOA_CLOSE"] = 70] = "AAVE_V4_EOA_CLOSE";
|
|
246
250
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
247
251
|
let OptimismIds;
|
|
248
252
|
(function (OptimismIds) {
|
package/cjs/types/index.d.ts
CHANGED
|
@@ -197,6 +197,17 @@ export declare namespace Position {
|
|
|
197
197
|
stopLossType: CloseToAssetType | undefined;
|
|
198
198
|
takeProfitType: CloseToAssetType | undefined;
|
|
199
199
|
}
|
|
200
|
+
interface SparkOnPrice extends Base {
|
|
201
|
+
collAsset: EthereumAddress;
|
|
202
|
+
collAssetId: number;
|
|
203
|
+
debtAsset: EthereumAddress;
|
|
204
|
+
debtAssetId: number;
|
|
205
|
+
baseToken: EthereumAddress;
|
|
206
|
+
quoteToken: EthereumAddress;
|
|
207
|
+
price: string;
|
|
208
|
+
ratioState: RatioState;
|
|
209
|
+
ratio: number;
|
|
210
|
+
}
|
|
200
211
|
interface CloseBase extends Base {
|
|
201
212
|
stopLossPrice: string;
|
|
202
213
|
takeProfitPrice: string;
|
|
@@ -219,7 +230,7 @@ export declare namespace Position {
|
|
|
219
230
|
debtAssetId: number;
|
|
220
231
|
}
|
|
221
232
|
}
|
|
222
|
-
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD | Specific.CloseOnPriceLiquityV2 | Specific.BoostOnPriceMorpho | Specific.BoostOnPriceLiquityV2 | Specific.PaybackLiquityV2 | Specific.CompoundV3LeverageManagementOnPrice | Specific.CompoundV3CloseOnPrice | Specific.AaveV3CloseOnPriceGeneric | Specific.AaveV4LeverageManagementOnPrice | Specific.AaveV4CloseOnPrice;
|
|
233
|
+
type SpecificAny = Specific.CloseOnPrice | Specific.TrailingStop | Specific.RatioProtection | Specific.CloseOnPriceAave | Specific.BoostOnPriceAave | Specific.CloseOnPriceWithMaximumGasPriceAave | Specific.DebtInFrontRepay | Specific.LeverageManagementCrvUSD | Specific.CloseOnPriceLiquityV2 | Specific.BoostOnPriceMorpho | Specific.BoostOnPriceLiquityV2 | Specific.PaybackLiquityV2 | Specific.CompoundV3LeverageManagementOnPrice | Specific.CompoundV3CloseOnPrice | Specific.AaveV3CloseOnPriceGeneric | Specific.AaveV4LeverageManagementOnPrice | Specific.AaveV4CloseOnPrice | Specific.SparkOnPrice;
|
|
223
234
|
interface Automated {
|
|
224
235
|
chainId: ChainId;
|
|
225
236
|
positionId: string;
|
package/esm/constants/index.js
CHANGED
|
@@ -105,6 +105,11 @@ export const MAINNET_STRATEGIES_INFO = {
|
|
|
105
105
|
strategyId: Strategies.Identifiers.CollateralSwitch,
|
|
106
106
|
protocol: PROTOCOLS.AaveV4,
|
|
107
107
|
},
|
|
108
|
+
[Strategies.MainnetIds.AAVE_V4_COLLATERAL_SWITCH_EOA]: {
|
|
109
|
+
strategyOrBundleId: Strategies.MainnetIds.AAVE_V4_COLLATERAL_SWITCH_EOA,
|
|
110
|
+
strategyId: Strategies.Identifiers.EoaCollateralSwitch,
|
|
111
|
+
protocol: PROTOCOLS.AaveV4,
|
|
112
|
+
},
|
|
108
113
|
};
|
|
109
114
|
export const OPTIMISM_STRATEGIES_INFO = {
|
|
110
115
|
[Strategies.OptimismIds.EXCHANGE_DCA]: {
|
|
@@ -472,6 +477,16 @@ export const MAINNET_BUNDLES_INFO = {
|
|
|
472
477
|
strategyId: Strategies.Identifiers.CloseOnPrice,
|
|
473
478
|
protocol: PROTOCOLS.MorphoBlue,
|
|
474
479
|
},
|
|
480
|
+
[Bundles.MainnetIds.SPARK_REPAY_ON_PRICE]: {
|
|
481
|
+
strategyOrBundleId: Bundles.MainnetIds.SPARK_REPAY_ON_PRICE,
|
|
482
|
+
strategyId: Strategies.Identifiers.RepayOnPrice,
|
|
483
|
+
protocol: PROTOCOLS.Spark,
|
|
484
|
+
},
|
|
485
|
+
[Bundles.MainnetIds.SPARK_BOOST_ON_PRICE]: {
|
|
486
|
+
strategyOrBundleId: Bundles.MainnetIds.SPARK_BOOST_ON_PRICE,
|
|
487
|
+
strategyId: Strategies.Identifiers.BoostOnPrice,
|
|
488
|
+
protocol: PROTOCOLS.Spark,
|
|
489
|
+
},
|
|
475
490
|
[Bundles.MainnetIds.AAVE_V4_REPAY]: {
|
|
476
491
|
strategyOrBundleId: Bundles.MainnetIds.AAVE_V4_REPAY,
|
|
477
492
|
strategyId: Strategies.Identifiers.Repay,
|