@defisaver/automation-sdk 1.1.2 → 1.2.0
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/esm/constants/index.js +10 -0
- package/esm/services/strategiesService.js +31 -0
- package/esm/services/strategySubService.d.ts +1 -0
- package/esm/services/strategySubService.js +10 -0
- package/esm/services/subDataService.d.ts +6 -0
- package/esm/services/subDataService.js +16 -0
- package/esm/services/triggerService.d.ts +0 -2
- package/esm/services/triggerService.js +0 -5
- package/esm/types/enums.d.ts +3 -1
- package/esm/types/enums.js +2 -0
- package/package.json +1 -1
- package/src/constants/index.ts +11 -1
- package/src/services/strategiesService.ts +37 -1
- package/src/services/strategySubService.ts +18 -1
- package/src/services/subDataService.ts +17 -1
- package/src/types/enums.ts +2 -0
- package/umd/index.js +71 -6
package/esm/constants/index.js
CHANGED
|
@@ -130,6 +130,16 @@ export const MAINNET_BUNDLES_INFO = {
|
|
|
130
130
|
strategyId: Strategies.Identifiers.Boost,
|
|
131
131
|
protocol: PROTOCOLS.AaveV3,
|
|
132
132
|
},
|
|
133
|
+
[Bundles.MainnetIds.MAKER_REPAY]: {
|
|
134
|
+
strategyOrBundleId: Bundles.MainnetIds.MAKER_REPAY,
|
|
135
|
+
strategyId: Strategies.Identifiers.Repay,
|
|
136
|
+
protocol: PROTOCOLS.MakerDAO,
|
|
137
|
+
},
|
|
138
|
+
[Bundles.MainnetIds.MAKER_BOOST]: {
|
|
139
|
+
strategyOrBundleId: Bundles.MainnetIds.MAKER_BOOST,
|
|
140
|
+
strategyId: Strategies.Identifiers.Boost,
|
|
141
|
+
protocol: PROTOCOLS.MakerDAO,
|
|
142
|
+
},
|
|
133
143
|
};
|
|
134
144
|
export const OPTIMISM_BUNDLES_INFO = {
|
|
135
145
|
[Bundles.OptimismIds.AAVE_V3_REPAY]: {
|
|
@@ -49,6 +49,35 @@ function parseMakerTrailingStop(position, parseData) {
|
|
|
49
49
|
};
|
|
50
50
|
return _position;
|
|
51
51
|
}
|
|
52
|
+
function parseMakerLeverageManagement(position, parseData) {
|
|
53
|
+
const _position = cloneDeep(position);
|
|
54
|
+
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
55
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
56
|
+
const triggerData = triggerService.makerRatioTrigger.decode(subStruct.triggerData);
|
|
57
|
+
const subData = subDataService.makerLeverageManagementSubData.decode(subStruct.subData);
|
|
58
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
59
|
+
_position.strategyData.decoded.subData = subData;
|
|
60
|
+
const isRepay = _position.strategy.strategyId === Strategies.Identifiers.Repay;
|
|
61
|
+
if (isRepay) {
|
|
62
|
+
_position.specific = {
|
|
63
|
+
minRatio: triggerData.ratio,
|
|
64
|
+
minOptimalRatio: subData.targetRatio,
|
|
65
|
+
repayEnabled: true,
|
|
66
|
+
subId1: Number(subId),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
_position.specific = {
|
|
71
|
+
maxRatio: triggerData.ratio,
|
|
72
|
+
maxOptimalRatio: subData.targetRatio,
|
|
73
|
+
boostEnabled: isEnabled,
|
|
74
|
+
subId2: Number(subId),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
78
|
+
_position.specific.mergeWithSameId = true;
|
|
79
|
+
return _position;
|
|
80
|
+
}
|
|
52
81
|
function parseLiquityCloseOnPrice(position, parseData) {
|
|
53
82
|
const _position = cloneDeep(position);
|
|
54
83
|
const { subStruct } = parseData.subscriptionEventData;
|
|
@@ -186,6 +215,8 @@ const parsingMethodsMapping = {
|
|
|
186
215
|
[Strategies.Identifiers.CloseOnPriceToColl]: parseMakerCloseOnPrice,
|
|
187
216
|
[Strategies.Identifiers.TrailingStopToColl]: parseMakerTrailingStop,
|
|
188
217
|
[Strategies.Identifiers.TrailingStopToDebt]: parseMakerTrailingStop,
|
|
218
|
+
[Strategies.Identifiers.Repay]: parseMakerLeverageManagement,
|
|
219
|
+
[Strategies.Identifiers.Boost]: parseMakerLeverageManagement,
|
|
189
220
|
},
|
|
190
221
|
[ProtocolIdentifiers.StrategiesAutomation.Liquity]: {
|
|
191
222
|
[Strategies.Identifiers.CloseOnPriceToColl]: parseLiquityCloseOnPrice,
|
|
@@ -4,6 +4,7 @@ export declare const makerEncode: {
|
|
|
4
4
|
repayFromSavings(bundleId: StrategyOrBundleIds, vaultId: number, priceOverOrUnder: RatioState, targetRatio: number, isBundle?: boolean, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[])[];
|
|
5
5
|
closeOnPrice(vaultId: number, ratioState: RatioState, price: string, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
6
6
|
trailingStop(vaultId: number, triggerPercentage: number, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, roundId: number, chainId?: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
7
|
+
leverageManagement(vaultId: number, minRatio: string, maxRatio: string, maxOptimalRatio: string, minOptimalRatio: string, boostEnabled: boolean): (string | number | boolean)[];
|
|
7
8
|
};
|
|
8
9
|
export declare const liquityEncode: {
|
|
9
10
|
closeOnPrice(priceOverOrUnder: RatioState, price: string, closeToAssetAddr: EthereumAddress, chainlinkCollAddress: EthereumAddress, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): (boolean | string[] | Strategies.MainnetIds)[];
|
|
@@ -30,6 +30,16 @@ export const makerEncode = {
|
|
|
30
30
|
const isBundle = false;
|
|
31
31
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
32
32
|
},
|
|
33
|
+
leverageManagement(vaultId, minRatio, maxRatio, maxOptimalRatio, minOptimalRatio, boostEnabled) {
|
|
34
|
+
return [
|
|
35
|
+
vaultId,
|
|
36
|
+
new Dec(minRatio).mul(1e16).toString(),
|
|
37
|
+
new Dec(maxRatio).mul(1e16).toString(),
|
|
38
|
+
new Dec(maxOptimalRatio).mul(1e16).toString(),
|
|
39
|
+
new Dec(minOptimalRatio).mul(1e16).toString(),
|
|
40
|
+
boostEnabled,
|
|
41
|
+
];
|
|
42
|
+
},
|
|
33
43
|
};
|
|
34
44
|
export const liquityEncode = {
|
|
35
45
|
closeOnPrice(priceOverOrUnder, price, closeToAssetAddr, chainlinkCollAddress, chainId = ChainId.Ethereum, collAddr, debtAddr) {
|
|
@@ -16,6 +16,12 @@ export declare const makerCloseSubData: {
|
|
|
16
16
|
closeToAssetAddr: EthereumAddress;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
+
export declare const makerLeverageManagementSubData: {
|
|
20
|
+
decode: (subData: string[]) => {
|
|
21
|
+
vaultId: number;
|
|
22
|
+
targetRatio: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
19
25
|
export declare const liquityCloseSubData: {
|
|
20
26
|
encode(closeToAssetAddr: EthereumAddress, chainId?: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress): string[];
|
|
21
27
|
decode(subData: string[]): {
|
|
@@ -54,6 +54,22 @@ export const makerCloseSubData = {
|
|
|
54
54
|
};
|
|
55
55
|
},
|
|
56
56
|
};
|
|
57
|
+
export const makerLeverageManagementSubData = {
|
|
58
|
+
// encode: (vaultId:number, repayFrom, boostFrom, boostTo, repayTo, boostEnabled) => [
|
|
59
|
+
// vaultId,
|
|
60
|
+
// new Dec(repayFrom).mul(1e16).toString(),
|
|
61
|
+
// new Dec(boostFrom).mul(1e16).toString(),
|
|
62
|
+
// new Dec(boostTo).mul(1e16).toString(),
|
|
63
|
+
// new Dec(repayTo).mul(1e16).toString(),
|
|
64
|
+
// boostEnabled,
|
|
65
|
+
// ],
|
|
66
|
+
decode: (subData) => {
|
|
67
|
+
const vaultId = +mockedWeb3.eth.abi.decodeParameter('uint256', subData[0]).toString();
|
|
68
|
+
const weiRatio = mockedWeb3.eth.abi.decodeParameter('uint256', subData[1]);
|
|
69
|
+
const targetRatio = weiToRatioPercentage(weiRatio);
|
|
70
|
+
return { vaultId, targetRatio };
|
|
71
|
+
},
|
|
72
|
+
};
|
|
57
73
|
export const liquityCloseSubData = {
|
|
58
74
|
encode(closeToAssetAddr, chainId = ChainId.Ethereum, collAddr, debtAddr) {
|
|
59
75
|
const _collAddr = collAddr || getAssetInfo('WETH', chainId).address;
|
|
@@ -25,9 +25,7 @@ export declare const makerRatioTrigger: {
|
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
export declare const aaveV3RatioTrigger: {
|
|
28
|
-
encode(owner: EthereumAddress, market: EthereumAddress, ratioPercentage: number, ratioState: RatioState): string[];
|
|
29
28
|
decode(triggerData: string[]): {
|
|
30
|
-
owner: string;
|
|
31
29
|
market: string;
|
|
32
30
|
ratio: number;
|
|
33
31
|
ratioState: number;
|
|
@@ -33,14 +33,9 @@ export const makerRatioTrigger = {
|
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
35
|
export const aaveV3RatioTrigger = {
|
|
36
|
-
encode(owner, market, ratioPercentage, ratioState) {
|
|
37
|
-
const ratioWei = ratioPercentageToWei(ratioPercentage);
|
|
38
|
-
return [mockedWeb3.eth.abi.encodeParameters(['address', 'address', 'uint256', 'uint8'], [owner, market, ratioWei, ratioState])];
|
|
39
|
-
},
|
|
40
36
|
decode(triggerData) {
|
|
41
37
|
const decodedData = mockedWeb3.eth.abi.decodeParameters(['address', 'address', 'uint256', 'uint8'], triggerData[0]);
|
|
42
38
|
return {
|
|
43
|
-
owner: decodedData[0],
|
|
44
39
|
market: decodedData[1],
|
|
45
40
|
ratio: new Dec(mockedWeb3.utils.fromWei(decodedData[2])).mul(100).toNumber(),
|
|
46
41
|
ratioState: Number(decodedData[3]),
|
package/esm/types/enums.d.ts
CHANGED
|
@@ -82,7 +82,9 @@ export declare namespace Bundles {
|
|
|
82
82
|
COMP_V3_EOA_BOOST_BUNDLE = 6,
|
|
83
83
|
LIQUITY_PAYBACK_USING_CHICKEN_BOND = 7,
|
|
84
84
|
AAVE_V3_REPAY = 8,
|
|
85
|
-
AAVE_V3_BOOST = 9
|
|
85
|
+
AAVE_V3_BOOST = 9,
|
|
86
|
+
MAKER_REPAY = 10,
|
|
87
|
+
MAKER_BOOST = 11
|
|
86
88
|
}
|
|
87
89
|
enum OptimismIds {
|
|
88
90
|
AAVE_V3_REPAY = 0,
|
package/esm/types/enums.js
CHANGED
|
@@ -97,6 +97,8 @@ export var Bundles;
|
|
|
97
97
|
MainnetIds[MainnetIds["LIQUITY_PAYBACK_USING_CHICKEN_BOND"] = 7] = "LIQUITY_PAYBACK_USING_CHICKEN_BOND";
|
|
98
98
|
MainnetIds[MainnetIds["AAVE_V3_REPAY"] = 8] = "AAVE_V3_REPAY";
|
|
99
99
|
MainnetIds[MainnetIds["AAVE_V3_BOOST"] = 9] = "AAVE_V3_BOOST";
|
|
100
|
+
MainnetIds[MainnetIds["MAKER_REPAY"] = 10] = "MAKER_REPAY";
|
|
101
|
+
MainnetIds[MainnetIds["MAKER_BOOST"] = 11] = "MAKER_BOOST";
|
|
100
102
|
})(MainnetIds = Bundles.MainnetIds || (Bundles.MainnetIds = {}));
|
|
101
103
|
let OptimismIds;
|
|
102
104
|
(function (OptimismIds) {
|
package/package.json
CHANGED
package/src/constants/index.ts
CHANGED
|
@@ -146,6 +146,16 @@ export const MAINNET_BUNDLES_INFO: MainnetBundleInfo = {
|
|
|
146
146
|
strategyId: Strategies.Identifiers.Boost,
|
|
147
147
|
protocol: PROTOCOLS.AaveV3,
|
|
148
148
|
},
|
|
149
|
+
[Bundles.MainnetIds.MAKER_REPAY]: {
|
|
150
|
+
strategyOrBundleId: Bundles.MainnetIds.MAKER_REPAY,
|
|
151
|
+
strategyId: Strategies.Identifiers.Repay,
|
|
152
|
+
protocol: PROTOCOLS.MakerDAO,
|
|
153
|
+
},
|
|
154
|
+
[Bundles.MainnetIds.MAKER_BOOST]: {
|
|
155
|
+
strategyOrBundleId: Bundles.MainnetIds.MAKER_BOOST,
|
|
156
|
+
strategyId: Strategies.Identifiers.Boost,
|
|
157
|
+
protocol: PROTOCOLS.MakerDAO,
|
|
158
|
+
},
|
|
149
159
|
};
|
|
150
160
|
|
|
151
161
|
export const OPTIMISM_BUNDLES_INFO: OptimismBundleInfo = {
|
|
@@ -204,4 +214,4 @@ export const BUNDLE_IDS = {
|
|
|
204
214
|
[ChainId.Ethereum]: Bundles.MainnetIds,
|
|
205
215
|
[ChainId.Optimism]: Bundles.OptimismIds,
|
|
206
216
|
[ChainId.Arbitrum]: Bundles.ArbitrumIds,
|
|
207
|
-
};
|
|
217
|
+
};
|
|
@@ -75,7 +75,41 @@ function parseMakerTrailingStop(position: Position.Automated, parseData: ParseDa
|
|
|
75
75
|
|
|
76
76
|
return _position;
|
|
77
77
|
}
|
|
78
|
+
function parseMakerLeverageManagement(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
79
|
+
const _position = cloneDeep(position);
|
|
80
|
+
|
|
81
|
+
const { subStruct, subId } = parseData.subscriptionEventData;
|
|
82
|
+
const { isEnabled } = parseData.strategiesSubsData;
|
|
83
|
+
|
|
84
|
+
const triggerData = triggerService.makerRatioTrigger.decode(subStruct.triggerData);
|
|
85
|
+
const subData = subDataService.makerLeverageManagementSubData.decode(subStruct.subData);
|
|
86
|
+
|
|
87
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
88
|
+
_position.strategyData.decoded.subData = subData;
|
|
78
89
|
|
|
90
|
+
const isRepay = _position.strategy.strategyId === Strategies.Identifiers.Repay;
|
|
91
|
+
|
|
92
|
+
if (isRepay) {
|
|
93
|
+
_position.specific = {
|
|
94
|
+
minRatio: triggerData.ratio,
|
|
95
|
+
minOptimalRatio: subData.targetRatio,
|
|
96
|
+
repayEnabled: true,
|
|
97
|
+
subId1: Number(subId),
|
|
98
|
+
};
|
|
99
|
+
} else {
|
|
100
|
+
_position.specific = {
|
|
101
|
+
maxRatio: triggerData.ratio,
|
|
102
|
+
maxOptimalRatio: subData.targetRatio,
|
|
103
|
+
boostEnabled: isEnabled,
|
|
104
|
+
subId2: Number(subId),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
_position.strategy.strategyId = Strategies.IdOverrides.LeverageManagement;
|
|
109
|
+
_position.specific.mergeWithSameId = true;
|
|
110
|
+
|
|
111
|
+
return _position;
|
|
112
|
+
}
|
|
79
113
|
function parseLiquityCloseOnPrice(position: Position.Automated, parseData: ParseData): Position.Automated {
|
|
80
114
|
const _position = cloneDeep(position);
|
|
81
115
|
|
|
@@ -265,6 +299,8 @@ const parsingMethodsMapping: StrategiesToProtocolVersionMapping = {
|
|
|
265
299
|
[Strategies.Identifiers.CloseOnPriceToColl]: parseMakerCloseOnPrice,
|
|
266
300
|
[Strategies.Identifiers.TrailingStopToColl]: parseMakerTrailingStop,
|
|
267
301
|
[Strategies.Identifiers.TrailingStopToDebt]: parseMakerTrailingStop,
|
|
302
|
+
[Strategies.Identifiers.Repay]: parseMakerLeverageManagement,
|
|
303
|
+
[Strategies.Identifiers.Boost]: parseMakerLeverageManagement,
|
|
268
304
|
},
|
|
269
305
|
[ProtocolIdentifiers.StrategiesAutomation.Liquity]: {
|
|
270
306
|
[Strategies.Identifiers.CloseOnPriceToColl]: parseLiquityCloseOnPrice,
|
|
@@ -339,4 +375,4 @@ export function parseStrategiesAutomatedPosition(parseData: ParseData): Position
|
|
|
339
375
|
};
|
|
340
376
|
|
|
341
377
|
return getParsingMethod(position.protocol.id, position.strategy)(position, parseData);
|
|
342
|
-
}
|
|
378
|
+
}
|
|
@@ -72,6 +72,23 @@ export const makerEncode = {
|
|
|
72
72
|
|
|
73
73
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
74
74
|
},
|
|
75
|
+
leverageManagement(
|
|
76
|
+
vaultId:number,
|
|
77
|
+
minRatio:string,
|
|
78
|
+
maxRatio:string,
|
|
79
|
+
maxOptimalRatio:string,
|
|
80
|
+
minOptimalRatio:string,
|
|
81
|
+
boostEnabled:boolean,
|
|
82
|
+
) {
|
|
83
|
+
return [
|
|
84
|
+
vaultId,
|
|
85
|
+
new Dec(minRatio).mul(1e16).toString(),
|
|
86
|
+
new Dec(maxRatio).mul(1e16).toString(),
|
|
87
|
+
new Dec(maxOptimalRatio).mul(1e16).toString(),
|
|
88
|
+
new Dec(minOptimalRatio).mul(1e16).toString(),
|
|
89
|
+
boostEnabled,
|
|
90
|
+
];
|
|
91
|
+
},
|
|
75
92
|
};
|
|
76
93
|
|
|
77
94
|
export const liquityEncode = {
|
|
@@ -199,4 +216,4 @@ export const compoundV3Encode = {
|
|
|
199
216
|
) {
|
|
200
217
|
return subDataService.compoundV3LeverageManagementSubData.encode(market, baseToken, minRatio, maxRatio, maxOptimalRatio, minOptimalRatio, boostEnabled, isEOA);
|
|
201
218
|
},
|
|
202
|
-
};
|
|
219
|
+
};
|
|
@@ -82,6 +82,22 @@ export const makerCloseSubData = {
|
|
|
82
82
|
},
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
+
export const makerLeverageManagementSubData = {
|
|
86
|
+
// encode: (vaultId:number, repayFrom, boostFrom, boostTo, repayTo, boostEnabled) => [
|
|
87
|
+
// vaultId,
|
|
88
|
+
// new Dec(repayFrom).mul(1e16).toString(),
|
|
89
|
+
// new Dec(boostFrom).mul(1e16).toString(),
|
|
90
|
+
// new Dec(boostTo).mul(1e16).toString(),
|
|
91
|
+
// new Dec(repayTo).mul(1e16).toString(),
|
|
92
|
+
// boostEnabled,
|
|
93
|
+
// ],
|
|
94
|
+
decode: (subData:SubData) => {
|
|
95
|
+
const vaultId = +mockedWeb3.eth.abi.decodeParameter('uint256', subData[0]).toString();
|
|
96
|
+
const weiRatio = mockedWeb3.eth.abi.decodeParameter('uint256', subData[1]) as any as string;
|
|
97
|
+
const targetRatio = weiToRatioPercentage(weiRatio);
|
|
98
|
+
return { vaultId, targetRatio };
|
|
99
|
+
},
|
|
100
|
+
};
|
|
85
101
|
export const liquityCloseSubData = {
|
|
86
102
|
encode(
|
|
87
103
|
closeToAssetAddr: EthereumAddress,
|
|
@@ -210,4 +226,4 @@ export const liquityPaybackUsingChickenBondSubData = {
|
|
|
210
226
|
|
|
211
227
|
return { sourceId, sourceType };
|
|
212
228
|
},
|
|
213
|
-
};
|
|
229
|
+
};
|
package/src/types/enums.ts
CHANGED
package/umd/index.js
CHANGED
|
@@ -236,6 +236,16 @@ var MAINNET_BUNDLES_INFO = {
|
|
|
236
236
|
strategyOrBundleId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Bundles.MainnetIds.AAVE_V3_BOOST,
|
|
237
237
|
strategyId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.Identifiers.Boost,
|
|
238
238
|
protocol: PROTOCOLS.AaveV3
|
|
239
|
+
},
|
|
240
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_0__.Bundles.MainnetIds.MAKER_REPAY]: {
|
|
241
|
+
strategyOrBundleId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Bundles.MainnetIds.MAKER_REPAY,
|
|
242
|
+
strategyId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.Identifiers.Repay,
|
|
243
|
+
protocol: PROTOCOLS.MakerDAO
|
|
244
|
+
},
|
|
245
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_0__.Bundles.MainnetIds.MAKER_BOOST]: {
|
|
246
|
+
strategyOrBundleId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Bundles.MainnetIds.MAKER_BOOST,
|
|
247
|
+
strategyId: _types_enums__WEBPACK_IMPORTED_MODULE_0__.Strategies.Identifiers.Boost,
|
|
248
|
+
protocol: PROTOCOLS.MakerDAO
|
|
239
249
|
}
|
|
240
250
|
};
|
|
241
251
|
var OPTIMISM_BUNDLES_INFO = {
|
|
@@ -412,6 +422,8 @@ var Bundles;
|
|
|
412
422
|
MainnetIds[MainnetIds["LIQUITY_PAYBACK_USING_CHICKEN_BOND"] = 7] = "LIQUITY_PAYBACK_USING_CHICKEN_BOND";
|
|
413
423
|
MainnetIds[MainnetIds["AAVE_V3_REPAY"] = 8] = "AAVE_V3_REPAY";
|
|
414
424
|
MainnetIds[MainnetIds["AAVE_V3_BOOST"] = 9] = "AAVE_V3_BOOST";
|
|
425
|
+
MainnetIds[MainnetIds["MAKER_REPAY"] = 10] = "MAKER_REPAY";
|
|
426
|
+
MainnetIds[MainnetIds["MAKER_BOOST"] = 11] = "MAKER_BOOST";
|
|
415
427
|
})(MainnetIds || (MainnetIds = {}));
|
|
416
428
|
_Bundles.MainnetIds = MainnetIds;
|
|
417
429
|
var OptimismIds;
|
|
@@ -1387,6 +1399,39 @@ function parseMakerTrailingStop(position, parseData) {
|
|
|
1387
1399
|
};
|
|
1388
1400
|
return _position;
|
|
1389
1401
|
}
|
|
1402
|
+
function parseMakerLeverageManagement(position, parseData) {
|
|
1403
|
+
var _position = (0,lodash__WEBPACK_IMPORTED_MODULE_0__.cloneDeep)(position);
|
|
1404
|
+
var {
|
|
1405
|
+
subStruct,
|
|
1406
|
+
subId
|
|
1407
|
+
} = parseData.subscriptionEventData;
|
|
1408
|
+
var {
|
|
1409
|
+
isEnabled
|
|
1410
|
+
} = parseData.strategiesSubsData;
|
|
1411
|
+
var triggerData = _triggerService__WEBPACK_IMPORTED_MODULE_5__.makerRatioTrigger.decode(subStruct.triggerData);
|
|
1412
|
+
var subData = _subDataService__WEBPACK_IMPORTED_MODULE_4__.makerLeverageManagementSubData.decode(subStruct.subData);
|
|
1413
|
+
_position.strategyData.decoded.triggerData = triggerData;
|
|
1414
|
+
_position.strategyData.decoded.subData = subData;
|
|
1415
|
+
var isRepay = _position.strategy.strategyId === _types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.Identifiers.Repay;
|
|
1416
|
+
if (isRepay) {
|
|
1417
|
+
_position.specific = {
|
|
1418
|
+
minRatio: triggerData.ratio,
|
|
1419
|
+
minOptimalRatio: subData.targetRatio,
|
|
1420
|
+
repayEnabled: true,
|
|
1421
|
+
subId1: Number(subId)
|
|
1422
|
+
};
|
|
1423
|
+
} else {
|
|
1424
|
+
_position.specific = {
|
|
1425
|
+
maxRatio: triggerData.ratio,
|
|
1426
|
+
maxOptimalRatio: subData.targetRatio,
|
|
1427
|
+
boostEnabled: isEnabled,
|
|
1428
|
+
subId2: Number(subId)
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
_position.strategy.strategyId = _types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.IdOverrides.LeverageManagement;
|
|
1432
|
+
_position.specific.mergeWithSameId = true;
|
|
1433
|
+
return _position;
|
|
1434
|
+
}
|
|
1390
1435
|
function parseLiquityCloseOnPrice(position, parseData) {
|
|
1391
1436
|
var _position = (0,lodash__WEBPACK_IMPORTED_MODULE_0__.cloneDeep)(position);
|
|
1392
1437
|
var {
|
|
@@ -1545,7 +1590,9 @@ var parsingMethodsMapping = {
|
|
|
1545
1590
|
[_types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.Identifiers.CloseOnPriceToDebt]: parseMakerCloseOnPrice,
|
|
1546
1591
|
[_types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.Identifiers.CloseOnPriceToColl]: parseMakerCloseOnPrice,
|
|
1547
1592
|
[_types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.Identifiers.TrailingStopToColl]: parseMakerTrailingStop,
|
|
1548
|
-
[_types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.Identifiers.TrailingStopToDebt]: parseMakerTrailingStop
|
|
1593
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.Identifiers.TrailingStopToDebt]: parseMakerTrailingStop,
|
|
1594
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.Identifiers.Repay]: parseMakerLeverageManagement,
|
|
1595
|
+
[_types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.Identifiers.Boost]: parseMakerLeverageManagement
|
|
1549
1596
|
},
|
|
1550
1597
|
[_types_enums__WEBPACK_IMPORTED_MODULE_2__.ProtocolIdentifiers.StrategiesAutomation.Liquity]: {
|
|
1551
1598
|
[_types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.Identifiers.CloseOnPriceToColl]: parseLiquityCloseOnPrice,
|
|
@@ -18838,6 +18885,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
18838
18885
|
/* harmony export */ "liquityCloseSubData": () => (/* binding */ liquityCloseSubData),
|
|
18839
18886
|
/* harmony export */ "liquityPaybackUsingChickenBondSubData": () => (/* binding */ liquityPaybackUsingChickenBondSubData),
|
|
18840
18887
|
/* harmony export */ "makerCloseSubData": () => (/* binding */ makerCloseSubData),
|
|
18888
|
+
/* harmony export */ "makerLeverageManagementSubData": () => (/* binding */ makerLeverageManagementSubData),
|
|
18841
18889
|
/* harmony export */ "makerRepayFromSavingsSubData": () => (/* binding */ makerRepayFromSavingsSubData)
|
|
18842
18890
|
/* harmony export */ });
|
|
18843
18891
|
/* harmony import */ var decimal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
|
|
@@ -18910,6 +18958,25 @@ var makerCloseSubData = {
|
|
|
18910
18958
|
};
|
|
18911
18959
|
}
|
|
18912
18960
|
};
|
|
18961
|
+
var makerLeverageManagementSubData = {
|
|
18962
|
+
// encode: (vaultId:number, repayFrom, boostFrom, boostTo, repayTo, boostEnabled) => [
|
|
18963
|
+
// vaultId,
|
|
18964
|
+
// new Dec(repayFrom).mul(1e16).toString(),
|
|
18965
|
+
// new Dec(boostFrom).mul(1e16).toString(),
|
|
18966
|
+
// new Dec(boostTo).mul(1e16).toString(),
|
|
18967
|
+
// new Dec(repayTo).mul(1e16).toString(),
|
|
18968
|
+
// boostEnabled,
|
|
18969
|
+
// ],
|
|
18970
|
+
decode: subData => {
|
|
18971
|
+
var vaultId = +mockedWeb3.eth.abi.decodeParameter('uint256', subData[0]).toString();
|
|
18972
|
+
var weiRatio = mockedWeb3.eth.abi.decodeParameter('uint256', subData[1]);
|
|
18973
|
+
var targetRatio = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.weiToRatioPercentage)(weiRatio);
|
|
18974
|
+
return {
|
|
18975
|
+
vaultId,
|
|
18976
|
+
targetRatio
|
|
18977
|
+
};
|
|
18978
|
+
}
|
|
18979
|
+
};
|
|
18913
18980
|
var liquityCloseSubData = {
|
|
18914
18981
|
encode(closeToAssetAddr) {
|
|
18915
18982
|
var chainId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _types_enums__WEBPACK_IMPORTED_MODULE_3__.ChainId.Ethereum;
|
|
@@ -28585,14 +28652,9 @@ var makerRatioTrigger = {
|
|
|
28585
28652
|
}
|
|
28586
28653
|
};
|
|
28587
28654
|
var aaveV3RatioTrigger = {
|
|
28588
|
-
encode(owner, market, ratioPercentage, ratioState) {
|
|
28589
|
-
var ratioWei = (0,_utils__WEBPACK_IMPORTED_MODULE_1__.ratioPercentageToWei)(ratioPercentage);
|
|
28590
|
-
return [mockedWeb3.eth.abi.encodeParameters(['address', 'address', 'uint256', 'uint8'], [owner, market, ratioWei, ratioState])];
|
|
28591
|
-
},
|
|
28592
28655
|
decode(triggerData) {
|
|
28593
28656
|
var decodedData = mockedWeb3.eth.abi.decodeParameters(['address', 'address', 'uint256', 'uint8'], triggerData[0]);
|
|
28594
28657
|
return {
|
|
28595
|
-
owner: decodedData[0],
|
|
28596
28658
|
market: decodedData[1],
|
|
28597
28659
|
ratio: new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(mockedWeb3.utils.fromWei(decodedData[2])).mul(100).toNumber(),
|
|
28598
28660
|
ratioState: Number(decodedData[3])
|
|
@@ -28809,6 +28871,9 @@ var makerEncode = {
|
|
|
28809
28871
|
var strategyOrBundleId = (0,_utils__WEBPACK_IMPORTED_MODULE_5__.compareAddresses)(closeToAssetAddr, (0,_defisaver_tokens__WEBPACK_IMPORTED_MODULE_1__.getAssetInfo)('DAI', chainId).address) ? _types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.MainnetIds.MAKER_TRAILING_STOP_LOSS_TO_DAI : _types_enums__WEBPACK_IMPORTED_MODULE_2__.Strategies.MainnetIds.MAKER_TRAILING_STOP_LOSS_TO_COLL;
|
|
28810
28872
|
var isBundle = false;
|
|
28811
28873
|
return [strategyOrBundleId, isBundle, triggerData, subData];
|
|
28874
|
+
},
|
|
28875
|
+
leverageManagement(vaultId, minRatio, maxRatio, maxOptimalRatio, minOptimalRatio, boostEnabled) {
|
|
28876
|
+
return [vaultId, new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(minRatio).mul(1e16).toString(), new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(maxRatio).mul(1e16).toString(), new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(maxOptimalRatio).mul(1e16).toString(), new (decimal_js__WEBPACK_IMPORTED_MODULE_0___default())(minOptimalRatio).mul(1e16).toString(), boostEnabled];
|
|
28812
28877
|
}
|
|
28813
28878
|
};
|
|
28814
28879
|
var liquityEncode = {
|