@defisaver/automation-sdk 3.3.15-liq-prot-2-dev → 3.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/constants/index.js +9 -124
- package/cjs/index.d.ts +3 -4
- package/cjs/index.js +2 -6
- package/cjs/services/strategiesService.js +1 -148
- package/cjs/services/strategySubService.d.ts +2 -9
- package/cjs/services/strategySubService.js +1 -52
- package/cjs/services/strategySubService.test.js +67 -0
- package/cjs/services/subDataService.d.ts +3 -58
- package/cjs/services/subDataService.js +18 -164
- package/cjs/services/subDataService.test.js +168 -0
- package/cjs/services/triggerService.test.js +60 -0
- package/cjs/services/utils.d.ts +1 -3
- package/cjs/services/utils.js +1 -34
- package/cjs/services/utils.test.js +0 -25
- package/cjs/types/enums.d.ts +6 -33
- package/cjs/types/enums.js +3 -30
- package/esm/constants/index.js +9 -124
- package/esm/index.d.ts +3 -4
- package/esm/index.js +3 -7
- package/esm/services/strategiesService.js +1 -148
- package/esm/services/strategySubService.d.ts +2 -9
- package/esm/services/strategySubService.js +2 -53
- package/esm/services/strategySubService.test.js +67 -0
- package/esm/services/subDataService.d.ts +3 -58
- package/esm/services/subDataService.js +16 -162
- package/esm/services/subDataService.test.js +168 -0
- package/esm/services/triggerService.test.js +61 -1
- package/esm/services/utils.d.ts +1 -3
- package/esm/services/utils.js +1 -32
- package/esm/services/utils.test.js +2 -27
- package/esm/types/enums.d.ts +6 -33
- package/esm/types/enums.js +3 -30
- package/package.json +1 -1
- package/src/constants/index.ts +10 -126
- package/src/index.ts +6 -24
- package/src/services/strategiesService.ts +1 -212
- package/src/services/strategySubService.test.ts +84 -0
- package/src/services/strategySubService.ts +5 -149
- package/src/services/subDataService.test.ts +182 -0
- package/src/services/subDataService.ts +22 -229
- package/src/services/triggerService.test.ts +69 -0
- package/src/services/utils.test.ts +1 -32
- package/src/services/utils.ts +1 -32
- package/src/types/enums.ts +5 -30
|
@@ -94,24 +94,6 @@ function parseMakerLeverageManagement(position, parseData) {
|
|
|
94
94
|
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
95
95
|
return _position;
|
|
96
96
|
}
|
|
97
|
-
function parseMakerLiquidationProtection(position, parseData) {
|
|
98
|
-
const _position = cloneDeep(position);
|
|
99
|
-
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
100
|
-
const { isEnabled } = parseData.strategiesSubsData;
|
|
101
|
-
const triggerData = triggerService.makerRatioTrigger.decode(subStruct.triggerData);
|
|
102
|
-
const subData = subDataService.makerLiquidationProtectionSubData.decode(subStruct.subData);
|
|
103
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
104
|
-
_position.strategyData.decoded.subData = subData;
|
|
105
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, subData.vaultId);
|
|
106
|
-
_position.specific = {
|
|
107
|
-
triggerRepayRatio: triggerData.ratio,
|
|
108
|
-
targetRepayRatio: subData.targetRatio,
|
|
109
|
-
repayEnabled: isEnabled,
|
|
110
|
-
subId1: Number(subId),
|
|
111
|
-
};
|
|
112
|
-
_position.strategy.strategyId = Strategies.IdOverrides.LiquidationProtection;
|
|
113
|
-
return _position;
|
|
114
|
-
}
|
|
115
97
|
function parseLiquityCloseOnPrice(position, parseData) {
|
|
116
98
|
const _position = cloneDeep(position);
|
|
117
99
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -222,26 +204,6 @@ function parseAaveV3LeverageManagement(position, parseData) {
|
|
|
222
204
|
}
|
|
223
205
|
return _position;
|
|
224
206
|
}
|
|
225
|
-
function parseAaveV3LiquidationProtection(position, parseData) {
|
|
226
|
-
const _position = cloneDeep(position);
|
|
227
|
-
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
228
|
-
const { isEnabled } = parseData.strategiesSubsData;
|
|
229
|
-
const triggerData = triggerService.aaveV3RatioTrigger.decode(subStruct.triggerData);
|
|
230
|
-
const subData = subDataService.aaveV3LiquidationProtectionSubData.decode(subStruct.subData);
|
|
231
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
232
|
-
_position.strategyData.decoded.subData = subData;
|
|
233
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.market);
|
|
234
|
-
_position.specific = {
|
|
235
|
-
triggerRepayRatio: triggerData.ratio,
|
|
236
|
-
targetRepayRatio: subData.targetRatio,
|
|
237
|
-
repayEnabled: isEnabled,
|
|
238
|
-
subId1: Number(subId),
|
|
239
|
-
subHashRepay: subHash,
|
|
240
|
-
};
|
|
241
|
-
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
242
|
-
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLiquidationProtection : Strategies.IdOverrides.LiquidationProtection;
|
|
243
|
-
return _position;
|
|
244
|
-
}
|
|
245
207
|
function parseAaveV3LeverageManagementOnPrice(position, parseData) {
|
|
246
208
|
const _position = cloneDeep(position);
|
|
247
209
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -371,26 +333,6 @@ function parseAaveV4LeverageManagement(position, parseData) {
|
|
|
371
333
|
}
|
|
372
334
|
return _position;
|
|
373
335
|
}
|
|
374
|
-
function parseAaveV4LiquidationProtection(position, parseData) {
|
|
375
|
-
const _position = cloneDeep(position);
|
|
376
|
-
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
377
|
-
const { isEnabled } = parseData.strategiesSubsData;
|
|
378
|
-
const triggerData = triggerService.aaveV4RatioTrigger.decode(subStruct.triggerData);
|
|
379
|
-
const subData = subDataService.aaveV4LiquidationProtectionSubData.decode(subStruct.subData);
|
|
380
|
-
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
381
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
382
|
-
_position.strategyData.decoded.subData = subData;
|
|
383
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.spoke);
|
|
384
|
-
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLiquidationProtection : Strategies.IdOverrides.LiquidationProtection;
|
|
385
|
-
_position.specific = {
|
|
386
|
-
triggerRepayRatio: triggerData.ratio,
|
|
387
|
-
targetRepayRatio: subData.targetRatio,
|
|
388
|
-
repayEnabled: isEnabled,
|
|
389
|
-
subId1: Number(subId),
|
|
390
|
-
subHashRepay: subHash,
|
|
391
|
-
};
|
|
392
|
-
return _position;
|
|
393
|
-
}
|
|
394
336
|
function parseAaveV4LeverageManagementOnPrice(position, parseData) {
|
|
395
337
|
const _position = cloneDeep(position);
|
|
396
338
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -575,27 +517,6 @@ function parseCompoundV3LeverageManagement(position, parseData) {
|
|
|
575
517
|
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
576
518
|
return _position;
|
|
577
519
|
}
|
|
578
|
-
function parseCompoundV3LiquidationProtection(position, parseData) {
|
|
579
|
-
const _position = cloneDeep(position);
|
|
580
|
-
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
581
|
-
const { isEnabled } = parseData.strategiesSubsData;
|
|
582
|
-
const subDataDecoder = subDataService.compoundV3LiquidationProtectionSubDataWithoutSubProxy;
|
|
583
|
-
const triggerData = triggerService.compoundV3RatioTrigger.decode(subStruct.triggerData);
|
|
584
|
-
const subData = subDataDecoder.decode(subStruct.subData);
|
|
585
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
586
|
-
_position.strategyData.decoded.subData = subData;
|
|
587
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, triggerData.owner.toLowerCase(), triggerData.market);
|
|
588
|
-
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
589
|
-
_position.specific = {
|
|
590
|
-
triggerRepayRatio: triggerData.ratio,
|
|
591
|
-
targetRepayRatio: subData.targetRatio,
|
|
592
|
-
repayEnabled: isEnabled,
|
|
593
|
-
subId1: Number(subId),
|
|
594
|
-
subHashRepay: subHash,
|
|
595
|
-
};
|
|
596
|
-
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLiquidationProtection : Strategies.IdOverrides.LiquidationProtection;
|
|
597
|
-
return _position;
|
|
598
|
-
}
|
|
599
520
|
function parseCompoundV3LeverageManagementOnPrice(position, parseData) {
|
|
600
521
|
const _position = cloneDeep(position);
|
|
601
522
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -775,25 +696,6 @@ function parseSparkLeverageManagement(position, parseData) {
|
|
|
775
696
|
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
776
697
|
return _position;
|
|
777
698
|
}
|
|
778
|
-
function parseSparkLiquidationProtection(position, parseData) {
|
|
779
|
-
const _position = cloneDeep(position);
|
|
780
|
-
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
781
|
-
const { isEnabled } = parseData.strategiesSubsData;
|
|
782
|
-
const triggerData = triggerService.sparkRatioTrigger.decode(subStruct.triggerData);
|
|
783
|
-
const subData = subDataService.sparkLiquidationProtectionSubData.decode(subStruct.subData);
|
|
784
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
785
|
-
_position.strategyData.decoded.subData = subData;
|
|
786
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.market);
|
|
787
|
-
_position.specific = {
|
|
788
|
-
triggerRepayRatio: triggerData.ratio,
|
|
789
|
-
targetRepayRatio: subData.targetRatio,
|
|
790
|
-
repayEnabled: isEnabled,
|
|
791
|
-
subId1: Number(subId),
|
|
792
|
-
subHashRepay: subHash,
|
|
793
|
-
};
|
|
794
|
-
_position.strategy.strategyId = Strategies.IdOverrides.LiquidationProtection;
|
|
795
|
-
return _position;
|
|
796
|
-
}
|
|
797
699
|
function parseSparkLeverageManagementOnPrice(position, parseData) {
|
|
798
700
|
const _position = cloneDeep(position);
|
|
799
701
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -948,26 +850,6 @@ function parseMorphoBlueLeverageManagement(position, parseData) {
|
|
|
948
850
|
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLeverageManagement : Strategies.IdOverrides.LeverageManagement;
|
|
949
851
|
return _position;
|
|
950
852
|
}
|
|
951
|
-
function parseMorphoBlueLiquidationProtection(position, parseData) {
|
|
952
|
-
const _position = cloneDeep(position);
|
|
953
|
-
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
954
|
-
const { isEnabled } = parseData.strategiesSubsData;
|
|
955
|
-
const triggerData = triggerService.morphoBlueRatioTrigger.decode(subStruct.triggerData);
|
|
956
|
-
const subData = subDataService.morphoBlueLiquidationProtectionSubData.decode(subStruct.subData);
|
|
957
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
958
|
-
_position.strategyData.decoded.subData = subData;
|
|
959
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, triggerData.owner.toLowerCase(), triggerData.marketId);
|
|
960
|
-
_position.specific = {
|
|
961
|
-
triggerRepayRatio: triggerData.ratio,
|
|
962
|
-
targetRepayRatio: subData.targetRatio,
|
|
963
|
-
repayEnabled: isEnabled,
|
|
964
|
-
subId1: Number(subId),
|
|
965
|
-
subHashRepay: subHash,
|
|
966
|
-
};
|
|
967
|
-
const isEOA = _position.strategy.strategyId.includes('eoa');
|
|
968
|
-
_position.strategy.strategyId = isEOA ? Strategies.IdOverrides.EoaLiquidationProtection : Strategies.IdOverrides.LiquidationProtection;
|
|
969
|
-
return _position;
|
|
970
|
-
}
|
|
971
853
|
function parseMorphoBlueLeverageManagementOnPrice(position, parseData) {
|
|
972
854
|
const _position = cloneDeep(position);
|
|
973
855
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -1120,25 +1002,6 @@ function parseFluidT1LeverageManagement(position, parseData) {
|
|
|
1120
1002
|
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
1121
1003
|
return _position;
|
|
1122
1004
|
}
|
|
1123
|
-
function parseFluidT1LiquidationProtection(position, parseData) {
|
|
1124
|
-
const _position = cloneDeep(position);
|
|
1125
|
-
const { subStruct, subId, subHash } = parseData.subscriptionEventData;
|
|
1126
|
-
const { isEnabled } = parseData.strategiesSubsData;
|
|
1127
|
-
const triggerData = triggerService.fluidRatioTrigger.decode(subStruct.triggerData);
|
|
1128
|
-
const subData = subDataService.fluidLiquidationProtectionSubData.decode(subStruct.subData);
|
|
1129
|
-
_position.strategyData.decoded.triggerData = triggerData;
|
|
1130
|
-
_position.strategyData.decoded.subData = subData;
|
|
1131
|
-
_position.positionId = getPositionId(_position.chainId, _position.protocol.id, _position.owner, triggerData.nftId, subData.vault);
|
|
1132
|
-
_position.specific = {
|
|
1133
|
-
triggerRepayRatio: triggerData.ratio,
|
|
1134
|
-
targetRepayRatio: subData.targetRatio,
|
|
1135
|
-
repayEnabled: isEnabled,
|
|
1136
|
-
subId1: Number(subId),
|
|
1137
|
-
subHashRepay: subHash,
|
|
1138
|
-
};
|
|
1139
|
-
_position.strategy.strategyId = Strategies.IdOverrides.LiquidationProtection;
|
|
1140
|
-
return _position;
|
|
1141
|
-
}
|
|
1142
1005
|
const parsingMethodsMapping = {
|
|
1143
1006
|
[ProtocolIdentifiers.StrategiesAutomation.MakerDAO]: {
|
|
1144
1007
|
[Strategies.Identifiers.SavingsLiqProtection]: parseMakerSavingsLiqProtection,
|
|
@@ -1148,7 +1011,6 @@ const parsingMethodsMapping = {
|
|
|
1148
1011
|
[Strategies.Identifiers.TrailingStopToDebt]: parseMakerTrailingStop,
|
|
1149
1012
|
[Strategies.Identifiers.Repay]: parseMakerLeverageManagement,
|
|
1150
1013
|
[Strategies.Identifiers.Boost]: parseMakerLeverageManagement,
|
|
1151
|
-
[Strategies.Identifiers.LiquidationProtection]: parseMakerLiquidationProtection,
|
|
1152
1014
|
},
|
|
1153
1015
|
[ProtocolIdentifiers.StrategiesAutomation.Liquity]: {
|
|
1154
1016
|
[Strategies.Identifiers.CloseOnPriceToColl]: parseLiquityCloseOnPrice,
|
|
@@ -1187,8 +1049,6 @@ const parsingMethodsMapping = {
|
|
|
1187
1049
|
[Strategies.Identifiers.EoaBoostOnPrice]: parseAaveV3LeverageManagementOnPrice,
|
|
1188
1050
|
[Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV3CloseOnPrice,
|
|
1189
1051
|
[Strategies.Identifiers.CollateralSwitch]: parseAaveV3CollateralSwitch,
|
|
1190
|
-
[Strategies.Identifiers.LiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1191
|
-
[Strategies.Identifiers.EoaLiquidationProtection]: parseAaveV3LiquidationProtection,
|
|
1192
1052
|
},
|
|
1193
1053
|
[ProtocolIdentifiers.StrategiesAutomation.AaveV4]: {
|
|
1194
1054
|
[Strategies.Identifiers.Repay]: parseAaveV4LeverageManagement,
|
|
@@ -1203,8 +1063,6 @@ const parsingMethodsMapping = {
|
|
|
1203
1063
|
[Strategies.Identifiers.EoaCloseOnPrice]: parseAaveV4CloseOnPrice,
|
|
1204
1064
|
[Strategies.Identifiers.CollateralSwitch]: parseAaveV4CollateralSwitch,
|
|
1205
1065
|
[Strategies.Identifiers.EoaCollateralSwitch]: parseAaveV4CollateralSwitch,
|
|
1206
|
-
[Strategies.Identifiers.LiquidationProtection]: parseAaveV4LiquidationProtection,
|
|
1207
|
-
[Strategies.Identifiers.EoaLiquidationProtection]: parseAaveV4LiquidationProtection,
|
|
1208
1066
|
},
|
|
1209
1067
|
[ProtocolIdentifiers.StrategiesAutomation.CompoundV2]: {
|
|
1210
1068
|
[Strategies.Identifiers.Repay]: parseCompoundV2LeverageManagement,
|
|
@@ -1221,8 +1079,6 @@ const parsingMethodsMapping = {
|
|
|
1221
1079
|
[Strategies.Identifiers.EoaBoostOnPrice]: parseCompoundV3LeverageManagementOnPrice,
|
|
1222
1080
|
[Strategies.Identifiers.CloseOnPrice]: parseCompoundV3CloseOnPrice,
|
|
1223
1081
|
[Strategies.Identifiers.EoaCloseOnPrice]: parseCompoundV3CloseOnPrice,
|
|
1224
|
-
[Strategies.Identifiers.LiquidationProtection]: parseCompoundV3LiquidationProtection,
|
|
1225
|
-
[Strategies.Identifiers.EoaLiquidationProtection]: parseCompoundV3LiquidationProtection,
|
|
1226
1082
|
},
|
|
1227
1083
|
[ProtocolIdentifiers.StrategiesAutomation.ChickenBonds]: {
|
|
1228
1084
|
[Strategies.Identifiers.Rebond]: parseChickenBondsRebond,
|
|
@@ -1242,7 +1098,6 @@ const parsingMethodsMapping = {
|
|
|
1242
1098
|
[Strategies.Identifiers.BoostOnPrice]: parseSparkLeverageManagementOnPrice,
|
|
1243
1099
|
[Strategies.Identifiers.CloseOnPrice]: parseSparkCloseOnPrice,
|
|
1244
1100
|
[Strategies.Identifiers.CollateralSwitch]: parseSparkCollateralSwitch,
|
|
1245
|
-
[Strategies.Identifiers.LiquidationProtection]: parseSparkLiquidationProtection,
|
|
1246
1101
|
},
|
|
1247
1102
|
[ProtocolIdentifiers.StrategiesAutomation.CrvUSD]: {
|
|
1248
1103
|
[Strategies.Identifiers.Repay]: parseCrvUSDLeverageManagement,
|
|
@@ -1255,14 +1110,12 @@ const parsingMethodsMapping = {
|
|
|
1255
1110
|
[Strategies.Identifiers.EoaRepay]: parseMorphoBlueLeverageManagement,
|
|
1256
1111
|
[Strategies.Identifiers.EoaBoost]: parseMorphoBlueLeverageManagement,
|
|
1257
1112
|
[Strategies.Identifiers.BoostOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1113
|
+
[Strategies.Identifiers.RepayOnPrice]: parseMorphoBlueLeverageManagementOnPrice,
|
|
1258
1114
|
[Strategies.Identifiers.CloseOnPrice]: parseMorphoBlueCloseOnPrice,
|
|
1259
|
-
[Strategies.Identifiers.LiquidationProtection]: parseMorphoBlueLiquidationProtection,
|
|
1260
|
-
[Strategies.Identifiers.EoaLiquidationProtection]: parseMorphoBlueLiquidationProtection,
|
|
1261
1115
|
},
|
|
1262
1116
|
[ProtocolIdentifiers.StrategiesAutomation.FluidT1]: {
|
|
1263
1117
|
[Strategies.Identifiers.Repay]: parseFluidT1LeverageManagement,
|
|
1264
1118
|
[Strategies.Identifiers.Boost]: parseFluidT1LeverageManagement,
|
|
1265
|
-
[Strategies.Identifiers.LiquidationProtection]: parseFluidT1LiquidationProtection,
|
|
1266
1119
|
},
|
|
1267
1120
|
};
|
|
1268
1121
|
function getParsingMethod(id, strategy) {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { Bundles, ChainId, CloseToAssetType, RatioState, Strategies } from '../types/enums';
|
|
2
|
-
import type { EthereumAddress, StrategyOrBundleIds } from '../types';
|
|
3
1
|
import type { OrderType } from '../types/enums';
|
|
2
|
+
import { CloseToAssetType, Bundles, ChainId, RatioState, Strategies } from '../types/enums';
|
|
3
|
+
import type { EthereumAddress, StrategyOrBundleIds } from '../types';
|
|
4
4
|
export declare const makerEncode: {
|
|
5
5
|
repayFromSavings(bundleId: StrategyOrBundleIds, vaultId: number, triggerRepayRatio: number, targetRepayRatio: number, isBundle?: boolean, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds | Strategies.OptimismIds | Strategies.ArbitrumIds | Strategies.BaseIds | Bundles.MainnetIds | Bundles.OptimismIds | Bundles.ArbitrumIds | Bundles.BaseIds)[];
|
|
6
6
|
closeOnPrice(vaultId: number, ratioState: RatioState, price: string, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
7
7
|
trailingStop(vaultId: number, triggerPercentage: number, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, roundId: number, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
8
8
|
leverageManagementWithoutSubProxy(vaultId: number, triggerRatio: number, targetRatio: number, ratioState: RatioState, isBoost: boolean, daiAddr?: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
|
|
9
|
-
liquidationProtection(vaultId: number, triggerRatio: number, targetRatio: number, ratioState: RatioState, daiAddr?: EthereumAddress): (boolean | string[] | Bundles.MainnetIds)[];
|
|
10
9
|
};
|
|
11
10
|
export declare const liquityEncode: {
|
|
12
11
|
closeOnPrice(priceOverOrUnder: RatioState, price: string, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
@@ -61,7 +60,6 @@ export declare const aaveV3Encode: {
|
|
|
61
60
|
targetRatio: number;
|
|
62
61
|
}): (number | boolean | string[])[];
|
|
63
62
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, isGeneric?: boolean): (number | boolean | string[])[];
|
|
64
|
-
liquidationProtection(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
65
63
|
leverageManagementOnPriceGeneric(strategyOrBundleId: number, price: number, ratioState: RatioState, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): (number | boolean | string[])[];
|
|
66
64
|
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[])[];
|
|
67
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[])[];
|
|
@@ -71,7 +69,6 @@ export declare const compoundV2Encode: {
|
|
|
71
69
|
};
|
|
72
70
|
export declare const compoundV3Encode: {
|
|
73
71
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, baseToken: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
74
|
-
liquidationProtectionWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, baseToken: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
75
72
|
leverageManagementOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, price: number, priceState: RatioState, ratioState: RatioState, user: EthereumAddress): (number | boolean | string[])[];
|
|
76
73
|
closeOnPrice(strategyOrBundleId: number, market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, stopLossPrice: number | undefined, stopLossType: CloseToAssetType | undefined, takeProfitPrice: number | undefined, takeProfitType: CloseToAssetType | undefined, user: EthereumAddress): (number | boolean | string[])[];
|
|
77
74
|
};
|
|
@@ -98,7 +95,6 @@ export declare const sparkEncode: {
|
|
|
98
95
|
}): (number | boolean | string[])[];
|
|
99
96
|
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[])[];
|
|
100
97
|
leverageManagementWithoutSubProxy(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
101
|
-
liquidationProtection(strategyOrBundleId: number, market: EthereumAddress, user: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
102
98
|
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[])[];
|
|
103
99
|
};
|
|
104
100
|
export declare const crvUSDEncode: {
|
|
@@ -107,7 +103,6 @@ export declare const crvUSDEncode: {
|
|
|
107
103
|
};
|
|
108
104
|
export declare const morphoBlueEncode: {
|
|
109
105
|
leverageManagement(marketId: string, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, triggerRatio: number, user: EthereumAddress, isEOA: boolean, network: ChainId): (boolean | string[] | Bundles.BaseIds)[] | (boolean | string[] | Bundles.MainnetIds | Bundles.ArbitrumIds)[];
|
|
110
|
-
liquidationProtection(marketId: string, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, triggerRatio: number, user: EthereumAddress, isEOA: boolean, network: ChainId): (boolean | string[] | Bundles.MainnetIds)[];
|
|
111
106
|
leverageManagementOnPrice(strategyOrBundleId: number, isBundle: boolean | undefined, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, targetRatio: number, price: number, priceState: RatioState): (number | boolean | string[])[];
|
|
112
107
|
closeOnPrice(strategyOrBundleId: number, loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, user: EthereumAddress, stopLossPrice?: number, stopLossType?: CloseToAssetType, takeProfitPrice?: number, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
113
108
|
};
|
|
@@ -119,11 +114,9 @@ export declare const liquityV2Encode: {
|
|
|
119
114
|
};
|
|
120
115
|
export declare const fluidEncode: {
|
|
121
116
|
leverageManagement(nftId: string, vault: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, strategyOrBundleId: number): (number | boolean | string[])[];
|
|
122
|
-
liquidationProtection(nftId: string, vault: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number, strategyOrBundleId: number): (number | boolean | string[])[];
|
|
123
117
|
};
|
|
124
118
|
export declare const aaveV4Encode: {
|
|
125
119
|
leverageManagement(strategyOrBundleId: number, owner: EthereumAddress, spoke: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
126
|
-
liquidationProtection(strategyOrBundleId: number, owner: EthereumAddress, spoke: EthereumAddress, ratioState: RatioState, targetRatio: number, triggerRatio: number): (number | boolean | string[])[];
|
|
127
120
|
leverageManagementOnPrice(strategyOrBundleId: number, owner: EthereumAddress, spoke: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, targetRatio: number, price: string, priceState: RatioState, ratioState: RatioState): (number | boolean | string[])[];
|
|
128
121
|
closeOnPrice(strategyOrBundleId: number, owner: EthereumAddress, spoke: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, stopLossPrice?: string, stopLossType?: CloseToAssetType, takeProfitPrice?: string, takeProfitType?: CloseToAssetType): (number | boolean | string[])[];
|
|
129
122
|
collateralSwitch(strategyOrBundleId: number, owner: EthereumAddress, spoke: EthereumAddress, fromAsset: EthereumAddress, fromAssetId: number, toAsset: EthereumAddress, toAssetId: number, amountToSwitch: string, price: string, ratioState: RatioState): (number | boolean | string[])[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getAssetInfo } from '@defisaver/tokens';
|
|
2
|
+
import { CloseToAssetType, Bundles, ChainId, RatioState, Strategies, } from '../types/enums';
|
|
2
3
|
import { STRATEGY_IDS } from '../constants';
|
|
3
|
-
import { Bundles, ChainId, CloseToAssetType, RatioState, Strategies, } from '../types/enums';
|
|
4
4
|
import * as subDataService from './subDataService';
|
|
5
5
|
import * as triggerService from './triggerService';
|
|
6
|
-
import { compareAddresses,
|
|
6
|
+
import { compareAddresses, getCloseStrategyType, requireAddress, requireAddresses, } from './utils';
|
|
7
7
|
export const makerEncode = {
|
|
8
8
|
repayFromSavings(bundleId, vaultId, triggerRepayRatio, targetRepayRatio, isBundle = true, chainId = ChainId.Ethereum, daiAddr, mcdCdpManagerAddr) {
|
|
9
9
|
const subData = subDataService.makerRepayFromSavingsSubData.encode(vaultId, targetRepayRatio, chainId, daiAddr, mcdCdpManagerAddr);
|
|
@@ -41,17 +41,6 @@ export const makerEncode = {
|
|
|
41
41
|
subData,
|
|
42
42
|
];
|
|
43
43
|
},
|
|
44
|
-
liquidationProtection(vaultId, triggerRatio, targetRatio, ratioState, daiAddr) {
|
|
45
|
-
const bundleId = Bundles.MainnetIds.MAKER_SW_LIQUIDATION_PROTECTION;
|
|
46
|
-
const triggerData = triggerService.makerRatioTrigger.encode(vaultId, triggerRatio, ratioState);
|
|
47
|
-
const subData = subDataService.makerLiquidationProtectionSubData.encode(vaultId, targetRatio, daiAddr);
|
|
48
|
-
return [
|
|
49
|
-
bundleId,
|
|
50
|
-
true,
|
|
51
|
-
triggerData,
|
|
52
|
-
subData,
|
|
53
|
-
];
|
|
54
|
-
},
|
|
55
44
|
};
|
|
56
45
|
export const liquityEncode = {
|
|
57
46
|
closeOnPrice(priceOverOrUnder, price, closeToAssetAddr, chainlinkCollAddress, chainId = ChainId.Ethereum, collAddr, debtAddr) {
|
|
@@ -150,12 +139,6 @@ export const aaveV3Encode = {
|
|
|
150
139
|
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
151
140
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
152
141
|
},
|
|
153
|
-
liquidationProtection(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
154
|
-
const isBundle = true;
|
|
155
|
-
const subData = subDataService.aaveV3LiquidationProtectionSubData.encode(targetRatio, ratioState, market, user);
|
|
156
|
-
const triggerData = triggerService.aaveV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
157
|
-
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
158
|
-
},
|
|
159
142
|
leverageManagementOnPriceGeneric(strategyOrBundleId, price, ratioState, collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user) {
|
|
160
143
|
const isBundle = true;
|
|
161
144
|
const subDataEncoded = subDataService.aaveV3LeverageManagementOnPriceGeneric.encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio, user);
|
|
@@ -191,12 +174,6 @@ export const compoundV3Encode = {
|
|
|
191
174
|
const triggerData = triggerService.compoundV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
192
175
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
193
176
|
},
|
|
194
|
-
liquidationProtectionWithoutSubProxy(strategyOrBundleId, market, baseToken, user, ratioState, targetRatio, triggerRatio) {
|
|
195
|
-
const isBundle = true;
|
|
196
|
-
const subData = subDataService.compoundV3LiquidationProtectionSubDataWithoutSubProxy.encode(market, baseToken, targetRatio, ratioState);
|
|
197
|
-
const triggerData = triggerService.compoundV3RatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
198
|
-
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
199
|
-
},
|
|
200
177
|
leverageManagementOnPrice(strategyOrBundleId, market, collToken, baseToken, targetRatio, price, priceState, ratioState, // REPAY for repay on price, BOOST for boost on price
|
|
201
178
|
user) {
|
|
202
179
|
const isBundle = true;
|
|
@@ -254,12 +231,6 @@ export const sparkEncode = {
|
|
|
254
231
|
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
255
232
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
256
233
|
},
|
|
257
|
-
liquidationProtection(strategyOrBundleId, market, user, ratioState, targetRatio, triggerRatio) {
|
|
258
|
-
const isBundle = true;
|
|
259
|
-
const subData = subDataService.sparkLiquidationProtectionSubData.encode(targetRatio, ratioState);
|
|
260
|
-
const triggerData = triggerService.sparkRatioTrigger.encode(user, market, triggerRatio, ratioState);
|
|
261
|
-
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
262
|
-
},
|
|
263
234
|
collateralSwitch(strategyOrBundleId, fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch, baseTokenAddress, quoteTokenAddress, price, state) {
|
|
264
235
|
const isBundle = false;
|
|
265
236
|
const subDataEncoded = subDataService.sparkCollateralSwitchSubData.encode(fromAsset, fromAssetId, toAsset, toAssetId, marketAddr, amountToSwitch);
|
|
@@ -302,16 +273,6 @@ export const morphoBlueEncode = {
|
|
|
302
273
|
const isBundle = true;
|
|
303
274
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
304
275
|
},
|
|
305
|
-
liquidationProtection(marketId, loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, triggerRatio, user, isEOA, network) {
|
|
306
|
-
const subData = subDataService.morphoBlueLiquidationProtectionSubData.encode(loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA);
|
|
307
|
-
const triggerData = triggerService.morphoBlueRatioTrigger.encode(marketId, user, triggerRatio, ratioState);
|
|
308
|
-
// Type casting because there is no MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION for Base chain.
|
|
309
|
-
// That is fine because we will just always send isEOA == false for Base chain.
|
|
310
|
-
const bundleNetwork = getBundleIdsByNetwork(network);
|
|
311
|
-
const bundleId = isEOA ? bundleNetwork.MORPHO_BLUE_EOA_LIQUIDATION_PROTECTION : bundleNetwork.MORPHO_BLUE_SW_LIQUIDATION_PROTECTION;
|
|
312
|
-
const isBundle = true;
|
|
313
|
-
return [bundleId, isBundle, triggerData, subData];
|
|
314
|
-
},
|
|
315
276
|
leverageManagementOnPrice(strategyOrBundleId, isBundle = true, loanToken, collToken, oracle, irm, lltv, user, targetRatio, price, priceState) {
|
|
316
277
|
const subData = subDataService.morphoBlueLeverageManagementOnPriceSubData.encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user);
|
|
317
278
|
const triggerData = triggerService.morphoBluePriceTrigger.encode(oracle, collToken, loanToken, price, priceState);
|
|
@@ -360,12 +321,6 @@ export const fluidEncode = {
|
|
|
360
321
|
const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
|
|
361
322
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
362
323
|
},
|
|
363
|
-
liquidationProtection(nftId, vault, ratioState, targetRatio, triggerRatio, strategyOrBundleId) {
|
|
364
|
-
const isBundle = true;
|
|
365
|
-
const subData = subDataService.fluidLiquidationProtectionSubData.encode(nftId, vault, ratioState, targetRatio);
|
|
366
|
-
const triggerData = triggerService.fluidRatioTrigger.encode(nftId, triggerRatio, ratioState);
|
|
367
|
-
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
368
|
-
},
|
|
369
324
|
};
|
|
370
325
|
export const aaveV4Encode = {
|
|
371
326
|
leverageManagement(strategyOrBundleId, owner, spoke, ratioState, targetRatio, triggerRatio) {
|
|
@@ -374,12 +329,6 @@ export const aaveV4Encode = {
|
|
|
374
329
|
const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
|
|
375
330
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
376
331
|
},
|
|
377
|
-
liquidationProtection(strategyOrBundleId, owner, spoke, ratioState, targetRatio, triggerRatio) {
|
|
378
|
-
const isBundle = true;
|
|
379
|
-
const subData = subDataService.aaveV4LiquidationProtectionSubData.encode(spoke, owner, ratioState, targetRatio);
|
|
380
|
-
const triggerData = triggerService.aaveV4RatioTrigger.encode(owner, spoke, triggerRatio, ratioState);
|
|
381
|
-
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
382
|
-
},
|
|
383
332
|
leverageManagementOnPrice(strategyOrBundleId, owner, spoke, collAsset, collAssetId, debtAsset, debtAssetId, targetRatio, price, priceState, ratioState) {
|
|
384
333
|
const isBundle = true;
|
|
385
334
|
const subData = subDataService.aaveV4LeverageManagementOnPriceSubData.encode(spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, ratioState, targetRatio);
|
|
@@ -1197,6 +1197,73 @@ describe('Feature: strategySubService.ts', () => {
|
|
|
1197
1197
|
});
|
|
1198
1198
|
});
|
|
1199
1199
|
});
|
|
1200
|
+
describe('leverageManagementOnPrice()', () => {
|
|
1201
|
+
const examples = [
|
|
1202
|
+
[
|
|
1203
|
+
[
|
|
1204
|
+
Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
1205
|
+
true,
|
|
1206
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000003a352944000000000000000000000000000000000000000000000000000000000000000001'],
|
|
1207
|
+
[
|
|
1208
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1209
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1210
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1211
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1212
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1213
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1214
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1215
|
+
],
|
|
1216
|
+
],
|
|
1217
|
+
[
|
|
1218
|
+
Bundles.MainnetIds.MORPHO_BLUE_REPAY_ON_PRICE,
|
|
1219
|
+
true,
|
|
1220
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1221
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1222
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1223
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1224
|
+
'945000000000000000',
|
|
1225
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1226
|
+
200,
|
|
1227
|
+
2500,
|
|
1228
|
+
RatioState.UNDER,
|
|
1229
|
+
],
|
|
1230
|
+
],
|
|
1231
|
+
[
|
|
1232
|
+
[
|
|
1233
|
+
Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
|
|
1234
|
+
true,
|
|
1235
|
+
['0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000005d21dba0000000000000000000000000000000000000000000000000000000000000000000'],
|
|
1236
|
+
[
|
|
1237
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1238
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1239
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1240
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1241
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1242
|
+
'0x00000000000000000000000000000000000000000000000016345785d8a00000',
|
|
1243
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1244
|
+
],
|
|
1245
|
+
],
|
|
1246
|
+
[
|
|
1247
|
+
Bundles.MainnetIds.MORPHO_BLUE_BOOST_ON_PRICE,
|
|
1248
|
+
true,
|
|
1249
|
+
web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
1250
|
+
web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
|
|
1251
|
+
web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
|
|
1252
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1253
|
+
'945000000000000000',
|
|
1254
|
+
web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
1255
|
+
160,
|
|
1256
|
+
4000,
|
|
1257
|
+
RatioState.OVER,
|
|
1258
|
+
],
|
|
1259
|
+
],
|
|
1260
|
+
];
|
|
1261
|
+
examples.forEach(([expected, actual]) => {
|
|
1262
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1263
|
+
expect(morphoBlueEncode.leverageManagementOnPrice(...actual)).to.eql(expected);
|
|
1264
|
+
});
|
|
1265
|
+
});
|
|
1266
|
+
});
|
|
1200
1267
|
describe('closeOnPrice()', () => {
|
|
1201
1268
|
const examples = [
|
|
1202
1269
|
[
|
|
@@ -71,14 +71,6 @@ export declare const makerLeverageManagementWithoutSubProxy: {
|
|
|
71
71
|
daiAddr: string;
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
|
-
export declare const makerLiquidationProtectionSubData: {
|
|
75
|
-
encode(vaultId: number, targetRatio: number, daiAddr?: EthereumAddress): string[];
|
|
76
|
-
decode(subData: string[]): {
|
|
77
|
-
vaultId: number;
|
|
78
|
-
targetRatio: number;
|
|
79
|
-
daiAddr: string;
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
74
|
/**
|
|
83
75
|
__ __ ______ __ __ __ .___________.____ ____ ____ ____ __
|
|
84
76
|
| | | | / __ \ | | | | | | | |\ \ / / \ \ / / /_ |
|
|
@@ -220,13 +212,6 @@ export declare const aaveV3LeverageManagementSubDataWithoutSubProxy: {
|
|
|
220
212
|
ratioState: RatioState;
|
|
221
213
|
};
|
|
222
214
|
};
|
|
223
|
-
export declare const aaveV3LiquidationProtectionSubData: {
|
|
224
|
-
encode(targetRatio: number, ratioState: RatioState, market: EthereumAddress, user: EthereumAddress): string[];
|
|
225
|
-
decode(subData: string[]): {
|
|
226
|
-
targetRatio: number;
|
|
227
|
-
ratioState: RatioState;
|
|
228
|
-
};
|
|
229
|
-
};
|
|
230
215
|
export declare const aaveV3LeverageManagementOnPriceGeneric: {
|
|
231
216
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number, user: EthereumAddress): string[];
|
|
232
217
|
decode(subData: string[]): {
|
|
@@ -299,15 +284,6 @@ export declare const aaveV4LeverageManagementSubData: {
|
|
|
299
284
|
targetRatio: number;
|
|
300
285
|
};
|
|
301
286
|
};
|
|
302
|
-
export declare const aaveV4LiquidationProtectionSubData: {
|
|
303
|
-
encode: (spoke: EthereumAddress, owner: EthereumAddress, ratioState: RatioState, targetRatio: number) => string[];
|
|
304
|
-
decode: (subData: string[]) => {
|
|
305
|
-
spoke: string;
|
|
306
|
-
owner: string;
|
|
307
|
-
ratioState: RatioState;
|
|
308
|
-
targetRatio: number;
|
|
309
|
-
};
|
|
310
|
-
};
|
|
311
287
|
export declare const aaveV4LeverageManagementOnPriceSubData: {
|
|
312
288
|
encode: (spoke: EthereumAddress, owner: EthereumAddress, collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, ratioState: RatioState, targetRatio: number) => string[];
|
|
313
289
|
decode: (subData: string[]) => {
|
|
@@ -374,16 +350,13 @@ export declare const compoundV2LeverageManagementSubDataWithoutSubProxy: {
|
|
|
374
350
|
| `----.| `--' | | | | | | | \ / ___) |
|
|
375
351
|
\______| \______/ |__| |__| | _| \__/ |____/
|
|
376
352
|
*/
|
|
377
|
-
export declare const
|
|
378
|
-
encode(market: EthereumAddress, baseToken: EthereumAddress,
|
|
353
|
+
export declare const compoundV3LeverageManagementSubData: {
|
|
354
|
+
encode(market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean): string[];
|
|
379
355
|
decode(subData: string[]): {
|
|
380
|
-
market: EthereumAddress;
|
|
381
|
-
baseToken: EthereumAddress;
|
|
382
356
|
targetRatio: number;
|
|
383
|
-
ratioState: RatioState;
|
|
384
357
|
};
|
|
385
358
|
};
|
|
386
|
-
export declare const
|
|
359
|
+
export declare const compoundV3LeverageManagementSubDataWithoutSubProxy: {
|
|
387
360
|
encode(market: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, ratioState: RatioState): string[];
|
|
388
361
|
decode(subData: string[]): {
|
|
389
362
|
market: EthereumAddress;
|
|
@@ -466,13 +439,6 @@ export declare const sparkLeverageManagementSubDataWithoutSubProxy: {
|
|
|
466
439
|
ratioState: RatioState;
|
|
467
440
|
};
|
|
468
441
|
};
|
|
469
|
-
export declare const sparkLiquidationProtectionSubData: {
|
|
470
|
-
encode(targetRatio: number, ratioState: RatioState): string[];
|
|
471
|
-
decode(subData: string[]): {
|
|
472
|
-
targetRatio: number;
|
|
473
|
-
ratioState: RatioState;
|
|
474
|
-
};
|
|
475
|
-
};
|
|
476
442
|
export declare const sparkCloseGenericSubData: {
|
|
477
443
|
encode(collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, closeType: CloseStrategyType, marketAddr: EthereumAddress, user: EthereumAddress): string[];
|
|
478
444
|
decode(subData: string[]): {
|
|
@@ -551,18 +517,6 @@ export declare const morphoBlueLeverageManagementSubData: {
|
|
|
551
517
|
targetRatio: number;
|
|
552
518
|
};
|
|
553
519
|
};
|
|
554
|
-
export declare const morphoBlueLiquidationProtectionSubData: {
|
|
555
|
-
encode: (loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, user: EthereumAddress, isEOA: boolean) => string[];
|
|
556
|
-
decode: (subData: string[]) => {
|
|
557
|
-
loanToken: string;
|
|
558
|
-
collToken: string;
|
|
559
|
-
oracle: string;
|
|
560
|
-
irm: string;
|
|
561
|
-
lltv: string;
|
|
562
|
-
user: string;
|
|
563
|
-
targetRatio: number;
|
|
564
|
-
};
|
|
565
|
-
};
|
|
566
520
|
export declare const morphoBlueLeverageManagementOnPriceSubData: {
|
|
567
521
|
encode(loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, targetRatio: number, user: EthereumAddress): string[];
|
|
568
522
|
decode(subData: string[]): {
|
|
@@ -604,12 +558,3 @@ export declare const fluidLeverageManagementSubData: {
|
|
|
604
558
|
targetRatio: number;
|
|
605
559
|
};
|
|
606
560
|
};
|
|
607
|
-
export declare const fluidLiquidationProtectionSubData: {
|
|
608
|
-
encode: (nftId: string, vault: EthereumAddress, ratioState: RatioState, targetRatio: number) => string[];
|
|
609
|
-
decode: (subData: string[]) => {
|
|
610
|
-
nftId: string;
|
|
611
|
-
vault: string;
|
|
612
|
-
ratioState: RatioState;
|
|
613
|
-
targetRatio: number;
|
|
614
|
-
};
|
|
615
|
-
};
|