@defisaver/automation-sdk 3.3.21-coll-switch-generic-dev → 3.3.21-instant-twap-close-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 +10 -40
- package/cjs/services/strategiesService.js +21 -16
- package/cjs/services/strategiesService.test.js +62 -94
- package/cjs/services/strategySubService.d.ts +1 -2
- package/cjs/services/strategySubService.js +7 -12
- package/cjs/services/strategySubService.test.js +111 -107
- package/cjs/services/subDataService.d.ts +12 -22
- package/cjs/services/subDataService.js +35 -61
- package/cjs/services/subDataService.test.js +70 -139
- package/cjs/types/enums.d.ts +9 -15
- package/cjs/types/enums.js +4 -10
- package/esm/constants/index.js +10 -40
- package/esm/services/strategiesService.js +21 -16
- package/esm/services/strategiesService.test.js +63 -95
- package/esm/services/strategySubService.d.ts +1 -2
- package/esm/services/strategySubService.js +7 -12
- package/esm/services/strategySubService.test.js +111 -107
- package/esm/services/subDataService.d.ts +12 -22
- package/esm/services/subDataService.js +33 -59
- package/esm/services/subDataService.test.js +70 -139
- package/esm/types/enums.d.ts +9 -15
- package/esm/types/enums.js +4 -10
- package/package.json +1 -1
- package/src/constants/index.ts +10 -40
- package/src/services/strategiesService.test.ts +78 -106
- package/src/services/strategiesService.ts +27 -16
- package/src/services/strategySubService.test.ts +125 -126
- package/src/services/strategySubService.ts +18 -38
- package/src/services/subDataService.test.ts +98 -149
- package/src/services/subDataService.ts +48 -88
- package/src/types/enums.ts +4 -10
package/cjs/constants/index.js
CHANGED
|
@@ -127,16 +127,6 @@ exports.MAINNET_STRATEGIES_INFO = {
|
|
|
127
127
|
strategyId: enums_1.Strategies.Identifiers.EoaCollateralSwitch,
|
|
128
128
|
protocol: exports.PROTOCOLS.Spark,
|
|
129
129
|
},
|
|
130
|
-
[enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH]: {
|
|
131
|
-
strategyOrBundleId: enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
132
|
-
strategyId: enums_1.Strategies.Identifiers.DebtSwitch,
|
|
133
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
134
|
-
},
|
|
135
|
-
[enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
136
|
-
strategyOrBundleId: enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
137
|
-
strategyId: enums_1.Strategies.Identifiers.EoaDebtSwitch,
|
|
138
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
139
|
-
},
|
|
140
130
|
};
|
|
141
131
|
exports.OPTIMISM_STRATEGIES_INFO = {
|
|
142
132
|
[enums_1.Strategies.OptimismIds.EXCHANGE_DCA]: {
|
|
@@ -154,16 +144,6 @@ exports.OPTIMISM_STRATEGIES_INFO = {
|
|
|
154
144
|
strategyId: enums_1.Strategies.Identifiers.CollateralSwitch,
|
|
155
145
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
156
146
|
},
|
|
157
|
-
[enums_1.Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH]: {
|
|
158
|
-
strategyOrBundleId: enums_1.Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH,
|
|
159
|
-
strategyId: enums_1.Strategies.Identifiers.DebtSwitch,
|
|
160
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
161
|
-
},
|
|
162
|
-
[enums_1.Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
163
|
-
strategyOrBundleId: enums_1.Strategies.OptimismIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
164
|
-
strategyId: enums_1.Strategies.Identifiers.EoaDebtSwitch,
|
|
165
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
166
|
-
},
|
|
167
147
|
};
|
|
168
148
|
exports.BASE_STRATEGIES_INFO = {
|
|
169
149
|
[enums_1.Strategies.BaseIds.EXCHANGE_DCA]: {
|
|
@@ -181,16 +161,6 @@ exports.BASE_STRATEGIES_INFO = {
|
|
|
181
161
|
strategyId: enums_1.Strategies.Identifiers.CollateralSwitch,
|
|
182
162
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
183
163
|
},
|
|
184
|
-
[enums_1.Strategies.BaseIds.AAVE_V3_DEBT_SWITCH]: {
|
|
185
|
-
strategyOrBundleId: enums_1.Strategies.BaseIds.AAVE_V3_DEBT_SWITCH,
|
|
186
|
-
strategyId: enums_1.Strategies.Identifiers.DebtSwitch,
|
|
187
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
188
|
-
},
|
|
189
|
-
[enums_1.Strategies.BaseIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
190
|
-
strategyOrBundleId: enums_1.Strategies.BaseIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
191
|
-
strategyId: enums_1.Strategies.Identifiers.EoaDebtSwitch,
|
|
192
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
193
|
-
},
|
|
194
164
|
};
|
|
195
165
|
exports.ARBITRUM_STRATEGIES_INFO = {
|
|
196
166
|
[enums_1.Strategies.ArbitrumIds.EXCHANGE_DCA]: {
|
|
@@ -208,16 +178,6 @@ exports.ARBITRUM_STRATEGIES_INFO = {
|
|
|
208
178
|
strategyId: enums_1.Strategies.Identifiers.CollateralSwitch,
|
|
209
179
|
protocol: exports.PROTOCOLS.AaveV3,
|
|
210
180
|
},
|
|
211
|
-
[enums_1.Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH]: {
|
|
212
|
-
strategyOrBundleId: enums_1.Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH,
|
|
213
|
-
strategyId: enums_1.Strategies.Identifiers.DebtSwitch,
|
|
214
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
215
|
-
},
|
|
216
|
-
[enums_1.Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH_EOA]: {
|
|
217
|
-
strategyOrBundleId: enums_1.Strategies.ArbitrumIds.AAVE_V3_DEBT_SWITCH_EOA,
|
|
218
|
-
strategyId: enums_1.Strategies.Identifiers.EoaDebtSwitch,
|
|
219
|
-
protocol: exports.PROTOCOLS.AaveV3,
|
|
220
|
-
},
|
|
221
181
|
};
|
|
222
182
|
exports.STRATEGIES_INFO = {
|
|
223
183
|
[enums_1.ChainId.Ethereum]: exports.MAINNET_STRATEGIES_INFO,
|
|
@@ -699,6 +659,16 @@ exports.MAINNET_BUNDLES_INFO = {
|
|
|
699
659
|
strategyId: enums_1.Strategies.Identifiers.EoaLiquidationProtection,
|
|
700
660
|
protocol: exports.PROTOCOLS.Spark,
|
|
701
661
|
},
|
|
662
|
+
[enums_1.Bundles.MainnetIds.AAVE_V3_SW_INSTANT_CLOSE]: {
|
|
663
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.AAVE_V3_SW_INSTANT_CLOSE,
|
|
664
|
+
strategyId: enums_1.Strategies.Identifiers.InstantCloseOnPrice,
|
|
665
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
666
|
+
},
|
|
667
|
+
[enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE]: {
|
|
668
|
+
strategyOrBundleId: enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
669
|
+
strategyId: enums_1.Strategies.Identifiers.EoaInstantCloseOnPrice,
|
|
670
|
+
protocol: exports.PROTOCOLS.AaveV3,
|
|
671
|
+
},
|
|
702
672
|
};
|
|
703
673
|
exports.OPTIMISM_BUNDLES_INFO = {
|
|
704
674
|
[enums_1.Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -346,30 +346,36 @@ function parseAaveV3CloseOnPrice(position, parseData) {
|
|
|
346
346
|
}
|
|
347
347
|
return _position;
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function parseAaveV3InstantCloseOnPrice(position, parseData) {
|
|
350
350
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
351
351
|
const { subStruct } = parseData.subscriptionEventData;
|
|
352
|
-
const
|
|
353
|
-
const
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
: subDataService.aaveV3CollateralSwitchSubData.decode(subStruct.subData);
|
|
352
|
+
const triggerData = triggerService.aaveV3QuotePriceRangeTrigger.decode(subStruct.triggerData);
|
|
353
|
+
const subData = subDataService.aaveV3InstantCloseGenericSubData.decode(subStruct.subData);
|
|
354
|
+
const { takeProfitType, stopLossType } = (0, utils_1.getStopLossAndTakeProfitTypeByCloseStrategyType)(+subData.closeType);
|
|
355
|
+
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, AAVE_V3_MARKET_ADDRESSES[_position.chainId]);
|
|
357
356
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
358
357
|
_position.strategyData.decoded.subData = subData;
|
|
359
|
-
_position.
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
:
|
|
358
|
+
_position.specific = {
|
|
359
|
+
collAsset: subData.collAsset,
|
|
360
|
+
collAssetId: subData.collAssetId,
|
|
361
|
+
debtAsset: subData.debtAsset,
|
|
362
|
+
debtAssetId: subData.debtAssetId,
|
|
363
|
+
baseToken: triggerData.collToken,
|
|
364
|
+
quoteToken: triggerData.debtToken,
|
|
365
|
+
stopLossPrice: triggerData.lowerPrice,
|
|
366
|
+
takeProfitPrice: triggerData.upperPrice,
|
|
367
|
+
stopLossType,
|
|
368
|
+
takeProfitType,
|
|
369
|
+
};
|
|
363
370
|
return _position;
|
|
364
371
|
}
|
|
365
|
-
function
|
|
372
|
+
function parseAaveV3CollateralSwitch(position, parseData) {
|
|
366
373
|
const _position = (0, lodash_1.cloneDeep)(position);
|
|
367
374
|
const { subStruct } = parseData.subscriptionEventData;
|
|
368
375
|
const triggerData = triggerService.aaveV3QuotePriceTrigger.decode(subStruct.triggerData);
|
|
369
|
-
const subData = subDataService.
|
|
376
|
+
const subData = subDataService.aaveV3CollateralSwitchSubData.decode(subStruct.subData);
|
|
370
377
|
_position.strategyData.decoded.triggerData = triggerData;
|
|
371
378
|
_position.strategyData.decoded.subData = subData;
|
|
372
|
-
// TODO -> This isn't enough for ID
|
|
373
379
|
_position.positionId = (0, utils_1.getPositionId)(_position.chainId, _position.protocol.id, _position.owner, subData.marketAddr);
|
|
374
380
|
return _position;
|
|
375
381
|
}
|
|
@@ -1262,10 +1268,9 @@ const parsingMethodsMapping = {
|
|
|
1262
1268
|
[enums_1.Strategies.Identifiers.EoaRepayOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1263
1269
|
[enums_1.Strategies.Identifiers.EoaBoostOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1264
1270
|
[enums_1.Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV3CloseOnPrice,
|
|
1271
|
+
[enums_1.Strategies.Identifiers.InstantCloseOnPrice]: parseAaveV3InstantCloseOnPrice,
|
|
1272
|
+
[enums_1.Strategies.Identifiers.EoaInstantCloseOnPrice]: parseAaveV3InstantCloseOnPrice,
|
|
1265
1273
|
[enums_1.Strategies.Identifiers.CollateralSwitch]: parseAaveV3CollateralSwitch,
|
|
1266
|
-
[enums_1.Strategies.Identifiers.EoaCollateralSwitch]: parseAaveV3CollateralSwitch,
|
|
1267
|
-
[enums_1.Strategies.Identifiers.DebtSwitch]: parseAaveV3DebtSwitch,
|
|
1268
|
-
[enums_1.Strategies.Identifiers.EoaDebtSwitch]: parseAaveV3DebtSwitch,
|
|
1269
1274
|
[enums_1.Strategies.Identifiers.LiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1270
1275
|
[enums_1.Strategies.Identifiers.EoaLiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1271
1276
|
},
|
|
@@ -11,103 +11,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const chai_1 = require("chai");
|
|
13
13
|
const enums_1 = require("../types/enums");
|
|
14
|
-
const constants_1 = require("../constants");
|
|
15
14
|
require("../configuration");
|
|
16
15
|
const strategiesService_1 = require("./strategiesService");
|
|
16
|
+
const strategySubService_1 = require("./strategySubService");
|
|
17
17
|
describe('Feature: strategiesService.ts', () => {
|
|
18
|
-
describe('When parsing Aave V3 collateral switch subscriptions', () => {
|
|
19
|
-
const proxy = '0x9cB7E19861665366011899d74E75d4F2A419aEeD';
|
|
20
|
-
const user = '0x1234567890123456789012345678901234567890';
|
|
21
|
-
const fromAsset = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
22
|
-
const toAsset = '0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf';
|
|
23
|
-
const marketAddr = '0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e';
|
|
24
|
-
const amountToSwitch = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
|
25
|
-
const subHash = `0x${'ab'.repeat(32)}`;
|
|
26
|
-
const triggerData = [
|
|
27
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
|
|
28
|
-
+ '000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf'
|
|
29
|
-
+ '0000000000000000000000000000000000000000000000000000000000989680'
|
|
30
|
-
+ '0000000000000000000000000000000000000000000000000000000000000001',
|
|
31
|
-
];
|
|
32
|
-
function getParseData(strategyId, isGeneric, chainId = enums_1.ChainId.Ethereum) {
|
|
33
|
-
const subData = [
|
|
34
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
35
|
-
isGeneric
|
|
36
|
-
? '0x0000000000000000000000000000000000000000000000000000000000000100'
|
|
37
|
-
: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
38
|
-
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
39
|
-
isGeneric
|
|
40
|
-
? '0x000000000000000000000000000000000000000000000000000000000000ffff'
|
|
41
|
-
: '0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
42
|
-
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
43
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
44
|
-
isGeneric
|
|
45
|
-
? '0x0000000000000000000000001234567890123456789012345678901234567890'
|
|
46
|
-
: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
47
|
-
];
|
|
48
|
-
const subStruct = Object.assign([String(strategyId), false, triggerData, subData], { strategyOrBundleId: String(strategyId), isBundle: false, triggerData, subData });
|
|
49
|
-
return {
|
|
50
|
-
chainId,
|
|
51
|
-
blockNumber: 18015756,
|
|
52
|
-
subscriptionEventData: {
|
|
53
|
-
subId: '379', proxy, subHash, subStruct,
|
|
54
|
-
0: '379', 1: proxy, 2: subHash, 3: subStruct,
|
|
55
|
-
},
|
|
56
|
-
strategiesSubsData: {
|
|
57
|
-
userProxy: proxy, isEnabled: true, strategySubHash: subHash,
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
it('decodes generic collateral switches with the user and uint16 reserve IDs', () => {
|
|
62
|
-
const strategyId = enums_1.Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH;
|
|
63
|
-
const originalInfo = constants_1.MAINNET_STRATEGIES_INFO[strategyId];
|
|
64
|
-
const parseData = getParseData(strategyId, true);
|
|
65
|
-
let position;
|
|
66
|
-
constants_1.MAINNET_STRATEGIES_INFO[strategyId] = Object.assign(Object.assign({}, originalInfo), { strategyId: enums_1.Strategies.Identifiers.EoaCollateralSwitch });
|
|
67
|
-
try {
|
|
68
|
-
position = (0, strategiesService_1.parseStrategiesAutomatedPosition)(parseData);
|
|
69
|
-
}
|
|
70
|
-
finally {
|
|
71
|
-
constants_1.MAINNET_STRATEGIES_INFO[strategyId] = originalInfo;
|
|
72
|
-
}
|
|
73
|
-
(0, chai_1.expect)(position).not.to.equal(null);
|
|
74
|
-
(0, chai_1.expect)(position.protocol.id).to.equal(enums_1.ProtocolIdentifiers.StrategiesAutomation.AaveV3);
|
|
75
|
-
(0, chai_1.expect)(position.strategy.strategyId).to.equal(enums_1.Strategies.Identifiers.EoaCollateralSwitch);
|
|
76
|
-
(0, chai_1.expect)(position.strategy.isBundle).to.equal(false);
|
|
77
|
-
(0, chai_1.expect)(position.strategyData.encoded).to.eql({
|
|
78
|
-
triggerData,
|
|
79
|
-
subData: parseData.subscriptionEventData.subStruct.subData,
|
|
80
|
-
});
|
|
81
|
-
(0, chai_1.expect)(position.strategyData.decoded.triggerData).to.eql({
|
|
82
|
-
baseTokenAddress: fromAsset,
|
|
83
|
-
quoteTokenAddress: toAsset,
|
|
84
|
-
price: '0.1',
|
|
85
|
-
ratioState: enums_1.RatioState.UNDER,
|
|
86
|
-
});
|
|
87
|
-
(0, chai_1.expect)(position.strategyData.decoded.subData).to.eql({
|
|
88
|
-
fromAsset, fromAssetId: 256, toAsset, toAssetId: 65535, marketAddr, amountToSwitch, user,
|
|
89
|
-
});
|
|
90
|
-
(0, chai_1.expect)(position.owner).to.equal(proxy.toLowerCase());
|
|
91
|
-
(0, chai_1.expect)(position.positionId).to.equal(`1-aave__v3-${proxy.toLowerCase()}-${marketAddr.toLowerCase()}`);
|
|
92
|
-
});
|
|
93
|
-
const legacyStrategies = [
|
|
94
|
-
[enums_1.ChainId.Ethereum, enums_1.Strategies.MainnetIds.AAVE_V3_COLLATERAL_SWITCH],
|
|
95
|
-
[enums_1.ChainId.Optimism, enums_1.Strategies.OptimismIds.AAVE_V3_COLLATERAL_SWITCH],
|
|
96
|
-
[enums_1.ChainId.Arbitrum, enums_1.Strategies.ArbitrumIds.AAVE_V3_COLLATERAL_SWITCH],
|
|
97
|
-
[enums_1.ChainId.Base, enums_1.Strategies.BaseIds.AAVE_V3_COLLATERAL_SWITCH],
|
|
98
|
-
];
|
|
99
|
-
legacyStrategies.forEach(([chainId, strategyId]) => {
|
|
100
|
-
it(`continues to decode legacy collateral switches on chain ${chainId}`, () => {
|
|
101
|
-
const position = (0, strategiesService_1.parseStrategiesAutomatedPosition)(getParseData(strategyId, false, chainId));
|
|
102
|
-
(0, chai_1.expect)(position).not.to.equal(null);
|
|
103
|
-
(0, chai_1.expect)(position.strategy.strategyId).to.equal(enums_1.Strategies.Identifiers.CollateralSwitch);
|
|
104
|
-
(0, chai_1.expect)(position.strategyData.decoded.subData).to.eql({
|
|
105
|
-
fromAsset, fromAssetId: 0, toAsset, toAssetId: 7, marketAddr, amountToSwitch,
|
|
106
|
-
});
|
|
107
|
-
(0, chai_1.expect)(position.positionId).to.equal(`${chainId}-aave__v3-${proxy.toLowerCase()}-${marketAddr.toLowerCase()}`);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
18
|
describe('When testing strategiesService.parseStrategiesAutomatedPosition', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
19
|
// TODO: we should probably write this for every strategy?
|
|
113
20
|
const examples = [
|
|
@@ -202,4 +109,65 @@ describe('Feature: strategiesService.ts', () => {
|
|
|
202
109
|
}));
|
|
203
110
|
});
|
|
204
111
|
}));
|
|
112
|
+
describe('When parsing Aave V3 instant close bundles', () => {
|
|
113
|
+
const owner = '0x1234567890123456789012345678901234567890';
|
|
114
|
+
const market = '0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e';
|
|
115
|
+
const weth = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
116
|
+
const usdc = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
117
|
+
const bundles = [
|
|
118
|
+
['SW', enums_1.Bundles.MainnetIds.AAVE_V3_SW_INSTANT_CLOSE, enums_1.Strategies.Identifiers.InstantCloseOnPrice],
|
|
119
|
+
['EOA', enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE, enums_1.Strategies.Identifiers.EoaInstantCloseOnPrice],
|
|
120
|
+
];
|
|
121
|
+
bundles.forEach(([walletType, expectedBundleId, expectedStrategyId]) => {
|
|
122
|
+
describe(`${walletType} bundle`, () => {
|
|
123
|
+
const [bundleId, isBundle, triggerData, subData] = strategySubService_1.aaveV3Encode.instantCloseOnPriceGeneric(expectedBundleId, weth, 0, usdc, 1, market, owner, '1000000000000000000', '10000000000000000', 1500, enums_1.CloseToAssetType.DEBT, 5000, enums_1.CloseToAssetType.COLLATERAL);
|
|
124
|
+
const parseData = {
|
|
125
|
+
chainId: 1,
|
|
126
|
+
blockNumber: 1,
|
|
127
|
+
subscriptionEventData: {
|
|
128
|
+
subId: '1',
|
|
129
|
+
proxy: owner,
|
|
130
|
+
subHash: '0xhash',
|
|
131
|
+
subStruct: {
|
|
132
|
+
strategyOrBundleId: String(bundleId), isBundle, triggerData, subData,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
strategiesSubsData: { userProxy: owner, isEnabled: true, strategySubHash: '0xhash' },
|
|
136
|
+
};
|
|
137
|
+
const result = (0, strategiesService_1.parseStrategiesAutomatedPosition)(parseData);
|
|
138
|
+
it('should identify the strategy as instant close on price', () => {
|
|
139
|
+
(0, chai_1.expect)(result.strategy.strategyOrBundleId).to.equal(expectedBundleId);
|
|
140
|
+
(0, chai_1.expect)(result.strategy.strategyId).to.equal(expectedStrategyId);
|
|
141
|
+
(0, chai_1.expect)(result.protocol.id).to.equal(enums_1.ProtocolIdentifiers.StrategiesAutomation.AaveV3);
|
|
142
|
+
});
|
|
143
|
+
it('should decode sub data including tsi and slippage', () => {
|
|
144
|
+
(0, chai_1.expect)(result.strategyData.decoded.subData).to.eql({
|
|
145
|
+
collAsset: weth,
|
|
146
|
+
collAssetId: 0,
|
|
147
|
+
debtAsset: usdc,
|
|
148
|
+
debtAssetId: 1,
|
|
149
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
150
|
+
marketAddr: market,
|
|
151
|
+
owner,
|
|
152
|
+
tsi: '1000000000000000000',
|
|
153
|
+
slippage: '10000000000000000',
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
it('should fill specific with prices and close types', () => {
|
|
157
|
+
(0, chai_1.expect)(result.specific).to.eql({
|
|
158
|
+
collAsset: weth,
|
|
159
|
+
collAssetId: 0,
|
|
160
|
+
debtAsset: usdc,
|
|
161
|
+
debtAssetId: 1,
|
|
162
|
+
baseToken: weth,
|
|
163
|
+
quoteToken: usdc,
|
|
164
|
+
stopLossPrice: '1500',
|
|
165
|
+
takeProfitPrice: '5000',
|
|
166
|
+
stopLossType: enums_1.CloseToAssetType.DEBT,
|
|
167
|
+
takeProfitType: enums_1.CloseToAssetType.COLLATERAL,
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
});
|
|
205
173
|
});
|
|
@@ -61,9 +61,8 @@ export declare const aaveV3Encode: {
|
|
|
61
61
|
liquidationProtection(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
62
62
|
leverageManagementOnPriceGeneric(strategyOrBundleId: number, price: number, ratioState: RatioState, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): (number | boolean | string[])[];
|
|
63
63
|
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[])[];
|
|
64
|
+
instantCloseOnPriceGeneric(strategyOrBundleId: number, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, user: EthereumAddress, tsi: string, slippage: string, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
64
65
|
collateralSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
|
|
65
|
-
collateralSwitchGeneric(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, user: EthereumAddress, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
|
|
66
|
-
debtSwitch(strategyOrBundleId: number, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, marketAddr: EthereumAddress, amountToSwitch: string, user: EthereumAddress, baseTokenAddress: EthereumAddress, quoteTokenAddress: EthereumAddress, price: number, state: RatioState): (number | boolean | string[])[];
|
|
67
66
|
};
|
|
68
67
|
export declare const compoundV2Encode: {
|
|
69
68
|
leverageManagement(strategyOrBundleId: number, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
@@ -190,21 +190,16 @@ exports.aaveV3Encode = {
|
|
|
190
190
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceRangeTrigger.encode(collAsset, debtAsset, stopLossPrice, takeProfitPrice);
|
|
191
191
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
192
192
|
},
|
|
193
|
-
|
|
194
|
-
const isBundle =
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
},
|
|
199
|
-
collateralSwitchGeneric(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
200
|
-
const isBundle = false;
|
|
201
|
-
const subDataEncoded = subDataService.aaveV3GenericFLCollateralSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, user);
|
|
202
|
-
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
193
|
+
instantCloseOnPriceGeneric(strategyOrBundleId, collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, user, tsi, slippage, stopLossPrice = 0, stopLossType = enums_1.CloseToAssetType.DEBT, takeProfitPrice = 0, takeProfitType = enums_1.CloseToAssetType.COLLATERAL) {
|
|
194
|
+
const isBundle = true;
|
|
195
|
+
const closeType = (0, utils_1.getCloseStrategyType)(stopLossPrice, stopLossType, takeProfitPrice, takeProfitType);
|
|
196
|
+
const subDataEncoded = subDataService.aaveV3InstantCloseGenericSubData.encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user, tsi, slippage);
|
|
197
|
+
const triggerDataEncoded = triggerService.aaveV3QuotePriceRangeTrigger.encode(collAsset, debtAsset, stopLossPrice, takeProfitPrice);
|
|
203
198
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
204
199
|
},
|
|
205
|
-
|
|
200
|
+
collateralSwitch(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
206
201
|
const isBundle = false;
|
|
207
|
-
const subDataEncoded = subDataService.
|
|
202
|
+
const subDataEncoded = subDataService.aaveV3CollateralSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch);
|
|
208
203
|
const triggerDataEncoded = triggerService.aaveV3QuotePriceTrigger.encode(baseTokenAddress, quoteTokenAddress, price, state);
|
|
209
204
|
return [strategyOrBundleId, isBundle, triggerDataEncoded, subDataEncoded];
|
|
210
205
|
},
|
|
@@ -757,6 +757,117 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
757
757
|
});
|
|
758
758
|
});
|
|
759
759
|
});
|
|
760
|
+
describe('instantCloseOnPriceGeneric()', () => {
|
|
761
|
+
const examples = [
|
|
762
|
+
// Stop loss only (to debt)
|
|
763
|
+
[
|
|
764
|
+
[
|
|
765
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
766
|
+
true,
|
|
767
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000000000000000'],
|
|
768
|
+
[
|
|
769
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
770
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
771
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
772
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
773
|
+
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
774
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
775
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
776
|
+
'0x0000000000000000000000000000000000000000000000000de0b6b3a7640000',
|
|
777
|
+
'0x000000000000000000000000000000000000000000000000002386f26fc10000',
|
|
778
|
+
],
|
|
779
|
+
],
|
|
780
|
+
[
|
|
781
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
782
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
783
|
+
0,
|
|
784
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
785
|
+
1,
|
|
786
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
787
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
788
|
+
'1000000000000000000',
|
|
789
|
+
'10000000000000000',
|
|
790
|
+
1500,
|
|
791
|
+
enums_1.CloseToAssetType.DEBT,
|
|
792
|
+
0,
|
|
793
|
+
enums_1.CloseToAssetType.COLLATERAL, // takeProfitType (not used since price is 0)
|
|
794
|
+
]
|
|
795
|
+
],
|
|
796
|
+
// Take profit only (to collateral), zero tsi and slippage
|
|
797
|
+
[
|
|
798
|
+
[
|
|
799
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
800
|
+
true,
|
|
801
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000746a528800'],
|
|
802
|
+
[
|
|
803
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
804
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
805
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
806
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
807
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
808
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
809
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
810
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
811
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
812
|
+
],
|
|
813
|
+
],
|
|
814
|
+
[
|
|
815
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
816
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
817
|
+
0,
|
|
818
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
819
|
+
1,
|
|
820
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
821
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
822
|
+
'0',
|
|
823
|
+
'0',
|
|
824
|
+
0,
|
|
825
|
+
enums_1.CloseToAssetType.DEBT,
|
|
826
|
+
5000,
|
|
827
|
+
enums_1.CloseToAssetType.COLLATERAL, // takeProfitType
|
|
828
|
+
]
|
|
829
|
+
],
|
|
830
|
+
// Take profit (to debt) and stop loss (to collateral)
|
|
831
|
+
[
|
|
832
|
+
[
|
|
833
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
834
|
+
true,
|
|
835
|
+
['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000022ecb25c000000000000000000000000000000000000000000000000000000005d21dba000'],
|
|
836
|
+
[
|
|
837
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
838
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
839
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
840
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
841
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
842
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
843
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
844
|
+
'0x00000000000000000000000000000000000000000000000000b1a2bc2ec50000',
|
|
845
|
+
'0x0000000000000000000000000000000000000000000000000011c37937e08000',
|
|
846
|
+
],
|
|
847
|
+
],
|
|
848
|
+
[
|
|
849
|
+
enums_1.Bundles.MainnetIds.AAVE_V3_EOA_INSTANT_CLOSE,
|
|
850
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
851
|
+
0,
|
|
852
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
853
|
+
1,
|
|
854
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
855
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
856
|
+
'50000000000000000',
|
|
857
|
+
'5000000000000000',
|
|
858
|
+
1500,
|
|
859
|
+
enums_1.CloseToAssetType.COLLATERAL,
|
|
860
|
+
4000,
|
|
861
|
+
enums_1.CloseToAssetType.DEBT, // takeProfitType
|
|
862
|
+
]
|
|
863
|
+
],
|
|
864
|
+
];
|
|
865
|
+
examples.forEach(([expected, actual]) => {
|
|
866
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
867
|
+
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.instantCloseOnPriceGeneric(...actual)).to.eql(expected);
|
|
868
|
+
});
|
|
869
|
+
});
|
|
870
|
+
});
|
|
760
871
|
describe('collateralSwitch()', () => {
|
|
761
872
|
const examples = [
|
|
762
873
|
// WETH -> USDC, price 100000, state UNDER
|
|
@@ -856,113 +967,6 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
856
967
|
});
|
|
857
968
|
});
|
|
858
969
|
});
|
|
859
|
-
describe('collateralSwitchGeneric()', () => {
|
|
860
|
-
const strategyId = 12345;
|
|
861
|
-
const fromAsset = web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address);
|
|
862
|
-
const toAsset = web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address);
|
|
863
|
-
const marketAddr = web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39');
|
|
864
|
-
const user = web3Utils.toChecksumAddress('0x1234567890abcdef1234567890abcdef12345678');
|
|
865
|
-
const examples = [
|
|
866
|
-
[
|
|
867
|
-
enums_1.RatioState.UNDER,
|
|
868
|
-
'10000000000000000000',
|
|
869
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
870
|
-
'0000000000000000000000000000000000000000000000000000000000000001',
|
|
871
|
-
],
|
|
872
|
-
[
|
|
873
|
-
enums_1.RatioState.OVER,
|
|
874
|
-
tokens_1.MAXUINT,
|
|
875
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
876
|
-
'0000000000000000000000000000000000000000000000000000000000000000',
|
|
877
|
-
],
|
|
878
|
-
];
|
|
879
|
-
examples.forEach(([state, amountToSwitch, encodedAmount, encodedState]) => {
|
|
880
|
-
it(`encodes a generic collateral switch with the supplied quote pair and state ${state}`, () => {
|
|
881
|
-
const expectedTrigger = `0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000003e8${encodedState}`;
|
|
882
|
-
const expectedSubData = [
|
|
883
|
-
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
884
|
-
'0x0000000000000000000000000000000000000000000000000000000000000100',
|
|
885
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
886
|
-
'0x000000000000000000000000000000000000000000000000000000000000ffff',
|
|
887
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
888
|
-
encodedAmount,
|
|
889
|
-
'0x0000000000000000000000001234567890abcdef1234567890abcdef12345678',
|
|
890
|
-
];
|
|
891
|
-
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.collateralSwitchGeneric(strategyId, fromAsset, 256, toAsset, 65535, marketAddr, amountToSwitch, user, toAsset, fromAsset, 0.00001, state)).to.eql([strategyId, false, [expectedTrigger], expectedSubData]);
|
|
892
|
-
});
|
|
893
|
-
});
|
|
894
|
-
});
|
|
895
|
-
describe('debtSwitch()', () => {
|
|
896
|
-
const examples = [
|
|
897
|
-
// USDC -> DAI, price 100000, state UNDER
|
|
898
|
-
[
|
|
899
|
-
[
|
|
900
|
-
enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
901
|
-
false,
|
|
902
|
-
['0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000000000000000000000000000000009184e72a0000000000000000000000000000000000000000000000000000000000000000001'],
|
|
903
|
-
[
|
|
904
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
905
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
906
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
907
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
908
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
909
|
-
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
910
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
911
|
-
],
|
|
912
|
-
],
|
|
913
|
-
[
|
|
914
|
-
enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
915
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
916
|
-
1,
|
|
917
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
918
|
-
3,
|
|
919
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
920
|
-
'10000000000000000000',
|
|
921
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
922
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
923
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
924
|
-
100000,
|
|
925
|
-
enums_1.RatioState.UNDER,
|
|
926
|
-
]
|
|
927
|
-
],
|
|
928
|
-
// DAI -> USDC (MaxUint256), price 1, state OVER
|
|
929
|
-
[
|
|
930
|
-
[
|
|
931
|
-
enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
932
|
-
false,
|
|
933
|
-
['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000005f5e1000000000000000000000000000000000000000000000000000000000000000000'],
|
|
934
|
-
[
|
|
935
|
-
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
936
|
-
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
937
|
-
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
938
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
939
|
-
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
940
|
-
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
941
|
-
'0x000000000000000000000000dd6ecd6c9b9f7e29e0f14bb9d5f0d0a3c6cb6c6a',
|
|
942
|
-
],
|
|
943
|
-
],
|
|
944
|
-
[
|
|
945
|
-
enums_1.Strategies.MainnetIds.AAVE_V3_DEBT_SWITCH,
|
|
946
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
947
|
-
3,
|
|
948
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
949
|
-
1,
|
|
950
|
-
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
951
|
-
tokens_1.MAXUINT,
|
|
952
|
-
web3Utils.toChecksumAddress('0xDd6ecD6c9b9F7e29E0f14bb9D5F0D0A3C6cB6c6A'),
|
|
953
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
954
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
955
|
-
1,
|
|
956
|
-
enums_1.RatioState.OVER,
|
|
957
|
-
]
|
|
958
|
-
],
|
|
959
|
-
];
|
|
960
|
-
examples.forEach(([expected, actual]) => {
|
|
961
|
-
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
962
|
-
(0, chai_1.expect)(strategySubService_1.aaveV3Encode.debtSwitch(...actual)).to.eql(expected);
|
|
963
|
-
});
|
|
964
|
-
});
|
|
965
|
-
});
|
|
966
970
|
});
|
|
967
971
|
describe('When testing strategySubService.compoundV3Encode', () => {
|
|
968
972
|
describe('leverageManagementOnPrice()', () => {
|