@defisaver/automation-sdk 3.3.11 → 3.3.12
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/automation/private/StrategiesAutomation.d.ts +2 -0
- package/cjs/automation/private/StrategiesAutomation.js +10 -1
- package/cjs/automation/private/StrategiesAutomation.test.js +25 -0
- package/cjs/constants/index.d.ts +1 -0
- package/cjs/constants/index.js +62 -1
- package/cjs/services/strategiesService.js +104 -0
- package/cjs/services/strategySubService.d.ts +6 -0
- package/cjs/services/strategySubService.js +30 -1
- package/cjs/services/strategySubService.test.js +96 -0
- package/cjs/services/subDataService.d.ts +295 -137
- package/cjs/services/subDataService.js +639 -393
- package/cjs/services/subDataService.test.js +157 -0
- package/cjs/services/triggerService.d.ts +29 -0
- package/cjs/services/triggerService.js +53 -1
- package/cjs/services/triggerService.test.js +84 -0
- package/cjs/services/utils.d.ts +1 -1
- package/cjs/services/utils.js +10 -2
- package/cjs/types/enums.d.ts +17 -3
- package/cjs/types/enums.js +14 -0
- package/cjs/types/index.d.ts +22 -1
- package/esm/automation/private/StrategiesAutomation.d.ts +2 -0
- package/esm/automation/private/StrategiesAutomation.js +10 -1
- package/esm/automation/private/StrategiesAutomation.test.js +25 -0
- package/esm/constants/index.d.ts +1 -0
- package/esm/constants/index.js +61 -0
- package/esm/services/strategiesService.js +105 -1
- package/esm/services/strategySubService.d.ts +6 -0
- package/esm/services/strategySubService.js +29 -0
- package/esm/services/strategySubService.test.js +97 -1
- package/esm/services/subDataService.d.ts +295 -137
- package/esm/services/subDataService.js +639 -393
- package/esm/services/subDataService.test.js +157 -0
- package/esm/services/triggerService.d.ts +29 -0
- package/esm/services/triggerService.js +52 -0
- package/esm/services/triggerService.test.js +85 -1
- package/esm/services/utils.d.ts +1 -1
- package/esm/services/utils.js +10 -2
- package/esm/types/enums.d.ts +17 -3
- package/esm/types/enums.js +14 -0
- package/esm/types/index.d.ts +22 -1
- package/package.json +2 -2
- package/src/automation/private/StrategiesAutomation.test.ts +40 -0
- package/src/automation/private/StrategiesAutomation.ts +11 -0
- package/src/constants/index.ts +62 -0
- package/src/services/strategiesService.ts +119 -1
- package/src/services/strategySubService.test.ts +124 -0
- package/src/services/strategySubService.ts +118 -0
- package/src/services/subDataService.test.ts +172 -0
- package/src/services/subDataService.ts +1031 -782
- package/src/services/triggerService.test.ts +97 -0
- package/src/services/triggerService.ts +74 -1
- package/src/services/utils.ts +15 -4
- package/src/types/enums.ts +14 -0
- package/src/types/index.ts +26 -0
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.fluidLeverageManagementSubData = exports.morphoBlueCloseOnPriceSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.sparkLeverageManagementOnPriceSubData = exports.sparkCloseGenericSubData = exports.sparkLeverageManagementSubDataWithoutSubProxy = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.compoundV3L2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV4CollateralSwitchSubData = exports.aaveV4CloseSubData = exports.aaveV4LeverageManagementOnPriceSubData = exports.aaveV4LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3CollateralSwitchSubData = exports.aaveV3CloseGenericSubData = exports.aaveV3LeverageManagementOnPriceGeneric = exports.aaveV3LeverageManagementSubDataWithoutSubProxy = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityV2PaybackSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.liquityRepayFromSavingsSubData = exports.makerLeverageManagementWithoutSubProxy = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.makerRepayFromSavingsSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
8
|
const web3_eth_abi_1 = __importDefault(require("web3-eth-abi"));
|
|
9
9
|
const web3_utils_1 = require("web3-utils");
|
|
@@ -12,6 +12,68 @@ const sdk_1 = require("@defisaver/sdk");
|
|
|
12
12
|
const enums_1 = require("../types/enums");
|
|
13
13
|
const constants_1 = require("../constants");
|
|
14
14
|
const utils_1 = require("./utils");
|
|
15
|
+
/**
|
|
16
|
+
_______ _______ .______ .______ _______ ______ ___ .___________. _______ _______
|
|
17
|
+
| \ | ____|| _ \ | _ \ | ____| / | / \ | || ____|| \
|
|
18
|
+
| .--. || |__ | |_) | | |_) | | |__ | ,----' / ^ \ `---| |----`| |__ | .--. |
|
|
19
|
+
| | | || __| | ___/ | / | __| | | / /_\ \ | | | __| | | | |
|
|
20
|
+
| '--' || |____ | | | |\ \----.| |____ | `----./ _____ \ | | | |____ | '--' |
|
|
21
|
+
|_______/ |_______|| _| | _| `._____||_______| \______/__/ \__\ |__| |_______||_______/
|
|
22
|
+
*/
|
|
23
|
+
exports.morphoAaveV2LeverageManagementSubData = {
|
|
24
|
+
encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
25
|
+
return [
|
|
26
|
+
(0, utils_1.ratioPercentageToWei)(triggerRepayRatio),
|
|
27
|
+
(0, utils_1.ratioPercentageToWei)(triggerBoostRatio),
|
|
28
|
+
(0, utils_1.ratioPercentageToWei)(targetBoostRatio),
|
|
29
|
+
(0, utils_1.ratioPercentageToWei)(targetRepayRatio),
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
boostEnabled,
|
|
32
|
+
];
|
|
33
|
+
},
|
|
34
|
+
decode(subData) {
|
|
35
|
+
const ratioWei = web3_eth_abi_1.default.decodeParameter('uint128', subData[1]);
|
|
36
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(ratioWei);
|
|
37
|
+
return { targetRatio };
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
exports.cBondsRebondSubData = {
|
|
41
|
+
encode(bondId) {
|
|
42
|
+
const bondIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', bondId);
|
|
43
|
+
return [bondIdEncoded];
|
|
44
|
+
},
|
|
45
|
+
decode(subData) {
|
|
46
|
+
const bondId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]).toString();
|
|
47
|
+
return { bondId };
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
exports.liquityPaybackUsingChickenBondSubData = {
|
|
51
|
+
/**
|
|
52
|
+
* @param sourceId bondId or subId
|
|
53
|
+
* @param sourceType 0 for bond, 1 for subId
|
|
54
|
+
* @param chainId
|
|
55
|
+
*/
|
|
56
|
+
encode: (sourceId, sourceType, chainId = enums_1.ChainId.Ethereum) => {
|
|
57
|
+
const sourceIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', sourceId);
|
|
58
|
+
const sourceTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint256', sourceType);
|
|
59
|
+
const lusdAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', (0, tokens_1.getAssetInfo)('LUSD', chainId).address);
|
|
60
|
+
const bLusdAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', (0, tokens_1.getAssetInfo)('bLUSD', chainId).address);
|
|
61
|
+
return [sourceIdEncoded, sourceTypeEncoded, lusdAddressEncoded, bLusdAddressEncoded];
|
|
62
|
+
},
|
|
63
|
+
decode: (subData) => {
|
|
64
|
+
const sourceId = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]).toString();
|
|
65
|
+
const sourceType = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]).toString();
|
|
66
|
+
return { sourceId, sourceType };
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
.___ ___. ___ __ ___ _______ .______
|
|
71
|
+
| \/ | / \ | |/ / | ____|| _ \
|
|
72
|
+
| \ / | / ^ \ | ' / | |__ | |_) |
|
|
73
|
+
| |\/| | / /_\ \ | < | __| | /
|
|
74
|
+
| | | | / _____ \ | . \ | |____ | |\ \----.
|
|
75
|
+
|__| |__| /__/ \__\ |__|\__\ |_______|| _| `._____|
|
|
76
|
+
*/
|
|
15
77
|
exports.makerRepayFromSavingsSubData = {
|
|
16
78
|
encode(vaultId, targetRatioPercentage, chainId, daiAddr, mcdCdpManagerAddr) {
|
|
17
79
|
const _daiAddr = daiAddr || (0, tokens_1.getAssetInfo)('DAI', chainId).address;
|
|
@@ -35,13 +97,6 @@ exports.makerRepayFromSavingsSubData = {
|
|
|
35
97
|
};
|
|
36
98
|
},
|
|
37
99
|
};
|
|
38
|
-
exports.liquityRepayFromSavingsSubData = {
|
|
39
|
-
decode(subData) {
|
|
40
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
41
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
42
|
-
return { targetRatio };
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
100
|
exports.makerCloseSubData = {
|
|
46
101
|
encode(vaultId, closeToAssetAddr, chainId, daiAddr, mcdCdpManagerAddr) {
|
|
47
102
|
const _daiAddr = daiAddr || (0, tokens_1.getAssetInfo)('DAI', chainId).address;
|
|
@@ -90,6 +145,21 @@ exports.makerLeverageManagementWithoutSubProxy = {
|
|
|
90
145
|
return { vaultId, targetRatio, daiAddr };
|
|
91
146
|
},
|
|
92
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
__ __ ______ __ __ __ .___________.____ ____ ____ ____ __
|
|
150
|
+
| | | | / __ \ | | | | | | | |\ \ / / \ \ / / /_ |
|
|
151
|
+
| | | | | | | | | | | | | | `---| |----` \ \/ / \ \/ / | |
|
|
152
|
+
| | | | | | | | | | | | | | | | \_ _/ \ / | |
|
|
153
|
+
| `----.| | | `--' '--.| `--' | | | | | | | \ / | |
|
|
154
|
+
|_______||__| \_____\_____\\______/ |__| |__| |__| \__/ |_|
|
|
155
|
+
*/
|
|
156
|
+
exports.liquityRepayFromSavingsSubData = {
|
|
157
|
+
decode(subData) {
|
|
158
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
159
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
160
|
+
return { targetRatio };
|
|
161
|
+
},
|
|
162
|
+
};
|
|
93
163
|
exports.liquityLeverageManagementSubData = {
|
|
94
164
|
decode: (subData) => {
|
|
95
165
|
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
@@ -116,6 +186,201 @@ exports.liquityCloseSubData = {
|
|
|
116
186
|
return { closeToAssetAddr, debtAddr };
|
|
117
187
|
},
|
|
118
188
|
};
|
|
189
|
+
exports.liquityDsrPaybackSubData = {
|
|
190
|
+
encode: (targetRatio) => {
|
|
191
|
+
const daiAddress = (0, tokens_1.getAssetInfo)('DAI').address;
|
|
192
|
+
const lusdAddress = (0, tokens_1.getAssetInfo)('LUSD').address;
|
|
193
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', enums_1.RatioState.UNDER);
|
|
194
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
195
|
+
const daiAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', daiAddress);
|
|
196
|
+
const lusdAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', lusdAddress);
|
|
197
|
+
return [ratioStateEncoded, targetRatioEncoded, daiAddressEncoded, lusdAddressEncoded];
|
|
198
|
+
},
|
|
199
|
+
decode: (subData) => {
|
|
200
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
201
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
202
|
+
return { targetRatio };
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
exports.liquityDsrSupplySubData = {
|
|
206
|
+
encode: (targetRatio) => {
|
|
207
|
+
const daiAddress = (0, tokens_1.getAssetInfo)('DAI').address;
|
|
208
|
+
const wethAddress = (0, tokens_1.getAssetInfo)('WETH').address;
|
|
209
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', enums_1.RatioState.UNDER);
|
|
210
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
211
|
+
const daiAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', daiAddress);
|
|
212
|
+
const wethAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', wethAddress);
|
|
213
|
+
return [ratioStateEncoded, targetRatioEncoded, daiAddressEncoded, wethAddressEncoded];
|
|
214
|
+
},
|
|
215
|
+
decode: (subData) => {
|
|
216
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
217
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
218
|
+
return { targetRatio };
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
exports.liquityDebtInFrontRepaySubData = {
|
|
222
|
+
encode: (targetRatioIncrease) => {
|
|
223
|
+
const wethAddress = (0, tokens_1.getAssetInfo)('WETH').address;
|
|
224
|
+
const lusdAddress = (0, tokens_1.getAssetInfo)('LUSD').address;
|
|
225
|
+
const wethAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', wethAddress);
|
|
226
|
+
const lusdAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', lusdAddress);
|
|
227
|
+
const targetRatioIncreaseEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatioIncrease));
|
|
228
|
+
const withdrawIdEncoded = web3_eth_abi_1.default.encodeParameter('uint8', 1); // withdraw - 1
|
|
229
|
+
const paybackIdEncoded = web3_eth_abi_1.default.encodeParameter('uint8', 0); // payback - 0
|
|
230
|
+
return [wethAddressEncoded, lusdAddressEncoded, targetRatioIncreaseEncoded, withdrawIdEncoded, paybackIdEncoded];
|
|
231
|
+
},
|
|
232
|
+
decode: (subData) => {
|
|
233
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[2]);
|
|
234
|
+
const targetRatioIncrease = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
235
|
+
return { targetRatioIncrease };
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* __ __ ______ __ __ __ .___________.____ ____ ____ ____ ___
|
|
240
|
+
| | | | / __ \ | | | | | | | |\ \ / / \ \ / / |__ \
|
|
241
|
+
| | | | | | | | | | | | | | `---| |----` \ \/ / \ \/ / ) |
|
|
242
|
+
| | | | | | | | | | | | | | | | \_ _/ \ / / /
|
|
243
|
+
| `----.| | | `--' '--.| `--' | | | | | | | \ / / /_
|
|
244
|
+
|_______||__| \_____\_____\\______/ |__| |__| |__| \__/ |____|
|
|
245
|
+
*/
|
|
246
|
+
exports.liquityV2LeverageManagementSubData = {
|
|
247
|
+
encode: (market, troveId, collToken, boldToken, ratioState, targetRatio) => {
|
|
248
|
+
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
249
|
+
const troveIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', troveId);
|
|
250
|
+
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
251
|
+
const boldTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', boldToken);
|
|
252
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
253
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
254
|
+
const isRepay = ratioState === enums_1.RatioState.UNDER;
|
|
255
|
+
const collActionType = isRepay ? enums_1.CollActionType.WITHDRAW : enums_1.CollActionType.SUPPLY;
|
|
256
|
+
const debtActionType = isRepay ? enums_1.DebtActionType.PAYBACK : enums_1.DebtActionType.BORROW;
|
|
257
|
+
const collActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
258
|
+
const debtActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
259
|
+
return [
|
|
260
|
+
marketEncoded,
|
|
261
|
+
troveIdEncoded,
|
|
262
|
+
collTokenEncoded,
|
|
263
|
+
boldTokenEncoded,
|
|
264
|
+
ratioStateEncoded,
|
|
265
|
+
targetRatioEncoded,
|
|
266
|
+
collActionTypeEncoded,
|
|
267
|
+
debtActionTypeEncoded,
|
|
268
|
+
];
|
|
269
|
+
},
|
|
270
|
+
decode: (subData) => {
|
|
271
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
272
|
+
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
273
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
274
|
+
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
275
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[4]);
|
|
276
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
277
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
278
|
+
return {
|
|
279
|
+
market, troveId, collToken, boldToken, ratioState, targetRatio,
|
|
280
|
+
};
|
|
281
|
+
},
|
|
282
|
+
};
|
|
283
|
+
exports.liquityV2CloseSubData = {
|
|
284
|
+
encode(market, troveId, collToken, boldToken, closeType) {
|
|
285
|
+
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
286
|
+
const troveIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', troveId);
|
|
287
|
+
const collAddrEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
288
|
+
const boldTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', boldToken);
|
|
289
|
+
const wethAddress = (0, tokens_1.getAssetInfo)('WETH').address;
|
|
290
|
+
const wethAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', wethAddress);
|
|
291
|
+
const gasCompensation = new decimal_js_1.default('0.0375').mul(1e18).toString();
|
|
292
|
+
const gasCompensationEncoded = web3_eth_abi_1.default.encodeParameter('uint256', gasCompensation);
|
|
293
|
+
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
294
|
+
return [
|
|
295
|
+
marketEncoded,
|
|
296
|
+
troveIdEncoded,
|
|
297
|
+
collAddrEncoded,
|
|
298
|
+
boldTokenEncoded,
|
|
299
|
+
wethAddressEncoded,
|
|
300
|
+
gasCompensationEncoded,
|
|
301
|
+
closeTypeEncoded,
|
|
302
|
+
];
|
|
303
|
+
},
|
|
304
|
+
decode(subData) {
|
|
305
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
306
|
+
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
307
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
308
|
+
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
309
|
+
// skip wethAddress and gasCompensation
|
|
310
|
+
const closeType = web3_eth_abi_1.default.decodeParameter('uint8', subData[6]);
|
|
311
|
+
return {
|
|
312
|
+
market, troveId, collToken, boldToken, closeType,
|
|
313
|
+
};
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
exports.liquityV2LeverageManagementOnPriceSubData = {
|
|
317
|
+
encode(market, troveId, collToken, boldToken, targetRatio, isRepayOnPrice) {
|
|
318
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
319
|
+
const encodedTroveId = web3_eth_abi_1.default.encodeParameter('uint256', troveId);
|
|
320
|
+
const encodedCollToken = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
321
|
+
const encodedBoldToken = web3_eth_abi_1.default.encodeParameter('address', boldToken);
|
|
322
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
323
|
+
const collActionType = isRepayOnPrice ? enums_1.CollActionType.WITHDRAW : enums_1.CollActionType.SUPPLY;
|
|
324
|
+
const debtActionType = isRepayOnPrice ? enums_1.DebtActionType.PAYBACK : enums_1.DebtActionType.BORROW;
|
|
325
|
+
const encodedCollActionType = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
326
|
+
const encodedDebtActionType = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
327
|
+
return [
|
|
328
|
+
encodedMarket,
|
|
329
|
+
encodedTroveId,
|
|
330
|
+
encodedCollToken,
|
|
331
|
+
encodedBoldToken,
|
|
332
|
+
encodedTargetRatio,
|
|
333
|
+
encodedCollActionType,
|
|
334
|
+
encodedDebtActionType,
|
|
335
|
+
];
|
|
336
|
+
},
|
|
337
|
+
decode(subData) {
|
|
338
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
339
|
+
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
340
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
341
|
+
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
342
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
343
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
344
|
+
return {
|
|
345
|
+
market, troveId, collToken, boldToken, targetRatio,
|
|
346
|
+
};
|
|
347
|
+
},
|
|
348
|
+
};
|
|
349
|
+
exports.liquityV2PaybackSubData = {
|
|
350
|
+
encode: (market, troveId, boldToken, targetRatio, ratioState) => {
|
|
351
|
+
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
352
|
+
const troveIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', troveId);
|
|
353
|
+
const boldTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', boldToken);
|
|
354
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
355
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
356
|
+
return [
|
|
357
|
+
marketEncoded,
|
|
358
|
+
troveIdEncoded,
|
|
359
|
+
boldTokenEncoded,
|
|
360
|
+
targetRatioEncoded,
|
|
361
|
+
ratioStateEncoded,
|
|
362
|
+
];
|
|
363
|
+
},
|
|
364
|
+
decode: (subData) => {
|
|
365
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
366
|
+
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
367
|
+
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
368
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[3]);
|
|
369
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[4]);
|
|
370
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
371
|
+
return {
|
|
372
|
+
market, troveId, boldToken, ratioState, targetRatio,
|
|
373
|
+
};
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
/**
|
|
377
|
+
___ ___ ____ ____ _______ ____ ____ ___
|
|
378
|
+
/ \ / \ \ \ / / | ____| \ \ / / |__ \
|
|
379
|
+
/ ^ \ / ^ \ \ \/ / | |__ \ \/ / ) |
|
|
380
|
+
/ /_\ \ / /_\ \ \ / | __| \ / / /
|
|
381
|
+
/ _____ \ / _____ \ \ / | |____ \ / / /_
|
|
382
|
+
/__/ \__\ /__/ \__\ \__/ |_______| \__/ |____|
|
|
383
|
+
*/
|
|
119
384
|
exports.aaveV2LeverageManagementSubData = {
|
|
120
385
|
encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
121
386
|
return [
|
|
@@ -133,6 +398,14 @@ exports.aaveV2LeverageManagementSubData = {
|
|
|
133
398
|
return { targetRatio };
|
|
134
399
|
},
|
|
135
400
|
};
|
|
401
|
+
/**
|
|
402
|
+
___ ___ ____ ____ _______ ____ ____ ____
|
|
403
|
+
/ \ / \ \ \ / / | ____| \ \ / / |___ \
|
|
404
|
+
/ ^ \ / ^ \ \ \/ / | |__ \ \/ / __) |
|
|
405
|
+
/ /_\ \ / /_\ \ \ / | __| \ / |__ <
|
|
406
|
+
/ _____ \ / _____ \ \ / | |____ \ / ___) |
|
|
407
|
+
/__/ \__\ /__/ \__\ \__/ |_______| \__/ |____/
|
|
408
|
+
*/
|
|
136
409
|
exports.aaveV3LeverageManagementSubData = {
|
|
137
410
|
decode(subData) {
|
|
138
411
|
const ratioWei = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]);
|
|
@@ -280,15 +553,197 @@ exports.aaveV3QuotePriceSubData = {
|
|
|
280
553
|
};
|
|
281
554
|
},
|
|
282
555
|
};
|
|
283
|
-
exports.
|
|
284
|
-
encode(
|
|
556
|
+
exports.aaveV3LeverageManagementOnPriceSubData = {
|
|
557
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio) {
|
|
558
|
+
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
559
|
+
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint8', collAssetId);
|
|
560
|
+
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
561
|
+
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint8', debtAssetId);
|
|
562
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
563
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
564
|
+
const useOnBehalfEncoded = web3_eth_abi_1.default.encodeParameter('bool', false);
|
|
285
565
|
return [
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
566
|
+
encodedColl,
|
|
567
|
+
encodedCollId,
|
|
568
|
+
encodedDebt,
|
|
569
|
+
encodedDebtId,
|
|
570
|
+
encodedMarket,
|
|
571
|
+
encodedTargetRatio,
|
|
572
|
+
useOnBehalfEncoded,
|
|
573
|
+
];
|
|
574
|
+
},
|
|
575
|
+
decode(subData) {
|
|
576
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
577
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
578
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
579
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
580
|
+
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
581
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
582
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
583
|
+
return {
|
|
584
|
+
collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio,
|
|
585
|
+
};
|
|
586
|
+
},
|
|
587
|
+
};
|
|
588
|
+
/**
|
|
589
|
+
* ___ ___ ____ ____ _______ ____ ____ _ _
|
|
590
|
+
/ \ / \ \ \ / / | ____| \ \ / / | || |
|
|
591
|
+
/ ^ \ / ^ \ \ \/ / | |__ \ \/ / | || |_
|
|
592
|
+
/ /_\ \ / /_\ \ \ / | __| \ / |__ _|
|
|
593
|
+
/ _____ \ / _____ \ \ / | |____ \ / | |
|
|
594
|
+
/__/ \__\ /__/ \__\ \__/ |_______| \__/ |_|
|
|
595
|
+
*/
|
|
596
|
+
exports.aaveV4LeverageManagementSubData = {
|
|
597
|
+
encode: (spoke, owner, ratioState, targetRatio) => {
|
|
598
|
+
const spokeEncoded = web3_eth_abi_1.default.encodeParameter('address', spoke);
|
|
599
|
+
const ownerEncoded = web3_eth_abi_1.default.encodeParameter('address', owner);
|
|
600
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
601
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
602
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
603
|
+
return [
|
|
604
|
+
spokeEncoded,
|
|
605
|
+
ownerEncoded,
|
|
606
|
+
ratioStateEncoded,
|
|
607
|
+
targetRatioEncoded,
|
|
608
|
+
constants_1.EMPTY_SLOT,
|
|
609
|
+
constants_1.EMPTY_SLOT,
|
|
610
|
+
];
|
|
611
|
+
},
|
|
612
|
+
decode: (subData) => {
|
|
613
|
+
const spoke = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
614
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
615
|
+
const ratioState = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[2]));
|
|
616
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[3]));
|
|
617
|
+
return {
|
|
618
|
+
spoke, owner, ratioState, targetRatio,
|
|
619
|
+
};
|
|
620
|
+
},
|
|
621
|
+
};
|
|
622
|
+
exports.aaveV4LeverageManagementOnPriceSubData = {
|
|
623
|
+
encode: (spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, ratioState, targetRatio) => {
|
|
624
|
+
const spokeEncoded = web3_eth_abi_1.default.encodeParameter('address', spoke);
|
|
625
|
+
const ownerEncoded = web3_eth_abi_1.default.encodeParameter('address', owner);
|
|
626
|
+
const collAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
627
|
+
const collAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', collAssetId);
|
|
628
|
+
const debtAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
629
|
+
const debtAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', debtAssetId);
|
|
630
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
631
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
632
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
633
|
+
return [
|
|
634
|
+
spokeEncoded,
|
|
635
|
+
ownerEncoded,
|
|
636
|
+
collAssetEncoded,
|
|
637
|
+
collAssetIdEncoded,
|
|
638
|
+
debtAssetEncoded,
|
|
639
|
+
debtAssetIdEncoded,
|
|
640
|
+
ratioStateEncoded,
|
|
641
|
+
targetRatioEncoded,
|
|
642
|
+
constants_1.EMPTY_SLOT,
|
|
643
|
+
constants_1.EMPTY_SLOT,
|
|
644
|
+
];
|
|
645
|
+
},
|
|
646
|
+
decode: (subData) => {
|
|
647
|
+
const spoke = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
648
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
649
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
650
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint256', subData[3]));
|
|
651
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
652
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint256', subData[5]));
|
|
653
|
+
const ratioState = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[6]));
|
|
654
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[7]));
|
|
655
|
+
return {
|
|
656
|
+
spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, ratioState, targetRatio,
|
|
657
|
+
};
|
|
658
|
+
},
|
|
659
|
+
};
|
|
660
|
+
exports.aaveV4CloseSubData = {
|
|
661
|
+
encode: (spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, closeType) => {
|
|
662
|
+
const spokeEncoded = web3_eth_abi_1.default.encodeParameter('address', spoke);
|
|
663
|
+
const ownerEncoded = web3_eth_abi_1.default.encodeParameter('address', owner);
|
|
664
|
+
const collAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
665
|
+
const collAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', collAssetId);
|
|
666
|
+
const debtAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
667
|
+
const debtAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', debtAssetId);
|
|
668
|
+
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
669
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
670
|
+
return [
|
|
671
|
+
spokeEncoded,
|
|
672
|
+
ownerEncoded,
|
|
673
|
+
collAssetEncoded,
|
|
674
|
+
collAssetIdEncoded,
|
|
675
|
+
debtAssetEncoded,
|
|
676
|
+
debtAssetIdEncoded,
|
|
677
|
+
closeTypeEncoded,
|
|
678
|
+
constants_1.EMPTY_SLOT,
|
|
679
|
+
constants_1.EMPTY_SLOT,
|
|
680
|
+
];
|
|
681
|
+
},
|
|
682
|
+
decode: (subData) => {
|
|
683
|
+
const spoke = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
684
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
685
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
686
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint256', subData[3]));
|
|
687
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
688
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint256', subData[5]));
|
|
689
|
+
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[6]));
|
|
690
|
+
return {
|
|
691
|
+
spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, closeType,
|
|
692
|
+
};
|
|
693
|
+
},
|
|
694
|
+
};
|
|
695
|
+
exports.aaveV4CollateralSwitchSubData = {
|
|
696
|
+
encode: (spoke, owner, fromAsset, fromAssetId, toAsset, toAssetId, amountToSwitch) => {
|
|
697
|
+
const spokeEncoded = web3_eth_abi_1.default.encodeParameter('address', spoke);
|
|
698
|
+
const ownerEncoded = web3_eth_abi_1.default.encodeParameter('address', owner);
|
|
699
|
+
const fromAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', fromAsset);
|
|
700
|
+
const fromAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', fromAssetId);
|
|
701
|
+
const toAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', toAsset);
|
|
702
|
+
const toAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', toAssetId);
|
|
703
|
+
const amountToSwitchEncoded = web3_eth_abi_1.default.encodeParameter('uint256', amountToSwitch);
|
|
704
|
+
// Add two empty slots for future addons (e.g tsi or slippage settings)
|
|
705
|
+
return [
|
|
706
|
+
spokeEncoded,
|
|
707
|
+
ownerEncoded,
|
|
708
|
+
fromAssetEncoded,
|
|
709
|
+
fromAssetIdEncoded,
|
|
710
|
+
toAssetEncoded,
|
|
711
|
+
toAssetIdEncoded,
|
|
712
|
+
amountToSwitchEncoded,
|
|
713
|
+
constants_1.EMPTY_SLOT,
|
|
714
|
+
constants_1.EMPTY_SLOT,
|
|
715
|
+
];
|
|
716
|
+
},
|
|
717
|
+
decode: (subData) => {
|
|
718
|
+
const spoke = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
719
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
720
|
+
const fromAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
721
|
+
const fromAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint256', subData[3]));
|
|
722
|
+
const toAsset = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
723
|
+
const toAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint256', subData[5]));
|
|
724
|
+
const amountToSwitch = web3_eth_abi_1.default.decodeParameter('uint256', subData[6]);
|
|
725
|
+
return {
|
|
726
|
+
spoke, owner, fromAsset, fromAssetId, toAsset, toAssetId, amountToSwitch,
|
|
727
|
+
};
|
|
728
|
+
},
|
|
729
|
+
};
|
|
730
|
+
/**
|
|
731
|
+
______ ______ .___ ___. .______ ____ ____ ___
|
|
732
|
+
/ | / __ \ | \/ | | _ \ \ \ / / |__ \
|
|
733
|
+
| ,----'| | | | | \ / | | |_) | \ \/ / ) |
|
|
734
|
+
| | | | | | | |\/| | | ___/ \ / / /
|
|
735
|
+
| `----.| `--' | | | | | | | \ / / /_
|
|
736
|
+
\______| \______/ |__| |__| | _| \__/ |____|
|
|
737
|
+
*/
|
|
738
|
+
exports.compoundV2LeverageManagementSubData = {
|
|
739
|
+
encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
740
|
+
return [
|
|
741
|
+
new decimal_js_1.default(triggerRepayRatio).mul(1e16).toString(),
|
|
742
|
+
new decimal_js_1.default(triggerBoostRatio).mul(1e16).toString(),
|
|
743
|
+
new decimal_js_1.default(targetBoostRatio).mul(1e16).toString(),
|
|
744
|
+
new decimal_js_1.default(targetRepayRatio).mul(1e16).toString(),
|
|
745
|
+
// @ts-ignore // TODO
|
|
746
|
+
boostEnabled,
|
|
292
747
|
];
|
|
293
748
|
},
|
|
294
749
|
decode(subData) {
|
|
@@ -297,6 +752,14 @@ exports.compoundV2LeverageManagementSubData = {
|
|
|
297
752
|
return { targetRatio };
|
|
298
753
|
},
|
|
299
754
|
};
|
|
755
|
+
/**
|
|
756
|
+
______ ______ .___ ___. .______ ____ ____ ____
|
|
757
|
+
/ | / __ \ | \/ | | _ \ \ \ / / |___ \
|
|
758
|
+
| ,----'| | | | | \ / | | |_) | \ \/ / __) |
|
|
759
|
+
| | | | | | | |\/| | | ___/ \ / |__ <
|
|
760
|
+
| `----.| `--' | | | | | | | \ / ___) |
|
|
761
|
+
\______| \______/ |__| |__| | _| \__/ |____/
|
|
762
|
+
*/
|
|
300
763
|
exports.compoundV3LeverageManagementSubData = {
|
|
301
764
|
encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA) {
|
|
302
765
|
return [
|
|
@@ -339,52 +802,70 @@ exports.compoundV3L2LeverageManagementSubData = {
|
|
|
339
802
|
return { targetRatio };
|
|
340
803
|
},
|
|
341
804
|
};
|
|
342
|
-
exports.
|
|
343
|
-
encode(
|
|
805
|
+
exports.compoundV3LeverageManagementOnPriceSubData = {
|
|
806
|
+
encode(market, collToken, baseToken, targetRatio, ratioState, user) {
|
|
807
|
+
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
808
|
+
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
809
|
+
const baseTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', baseToken);
|
|
810
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
811
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
812
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
344
813
|
return [
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
814
|
+
marketEncoded,
|
|
815
|
+
collTokenEncoded,
|
|
816
|
+
baseTokenEncoded,
|
|
817
|
+
targetRatioEncoded,
|
|
818
|
+
ratioStateEncoded,
|
|
819
|
+
userEncoded,
|
|
351
820
|
];
|
|
352
821
|
},
|
|
353
822
|
decode(subData) {
|
|
354
|
-
const
|
|
355
|
-
const
|
|
356
|
-
|
|
823
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
824
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
825
|
+
const baseToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
826
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[3]);
|
|
827
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
828
|
+
const ratioState = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[4]));
|
|
829
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
830
|
+
return {
|
|
831
|
+
market, collToken, baseToken, targetRatio, ratioState, owner,
|
|
832
|
+
};
|
|
357
833
|
},
|
|
358
834
|
};
|
|
359
|
-
exports.
|
|
360
|
-
encode(
|
|
361
|
-
const
|
|
362
|
-
|
|
835
|
+
exports.compoundV3CloseSubData = {
|
|
836
|
+
encode(market, collToken, baseToken, closeType, user) {
|
|
837
|
+
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
838
|
+
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
839
|
+
const baseTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', baseToken);
|
|
840
|
+
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
841
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
842
|
+
return [
|
|
843
|
+
marketEncoded,
|
|
844
|
+
collTokenEncoded,
|
|
845
|
+
baseTokenEncoded,
|
|
846
|
+
closeTypeEncoded,
|
|
847
|
+
userEncoded,
|
|
848
|
+
];
|
|
363
849
|
},
|
|
364
850
|
decode(subData) {
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
* @param chainId
|
|
374
|
-
*/
|
|
375
|
-
encode: (sourceId, sourceType, chainId = enums_1.ChainId.Ethereum) => {
|
|
376
|
-
const sourceIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', sourceId);
|
|
377
|
-
const sourceTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint256', sourceType);
|
|
378
|
-
const lusdAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', (0, tokens_1.getAssetInfo)('LUSD', chainId).address);
|
|
379
|
-
const bLusdAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', (0, tokens_1.getAssetInfo)('bLUSD', chainId).address);
|
|
380
|
-
return [sourceIdEncoded, sourceTypeEncoded, lusdAddressEncoded, bLusdAddressEncoded];
|
|
381
|
-
},
|
|
382
|
-
decode: (subData) => {
|
|
383
|
-
const sourceId = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]).toString();
|
|
384
|
-
const sourceType = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]).toString();
|
|
385
|
-
return { sourceId, sourceType };
|
|
851
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
852
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
853
|
+
const baseToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
854
|
+
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
855
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
856
|
+
return {
|
|
857
|
+
market, collToken, baseToken, closeType, owner,
|
|
858
|
+
};
|
|
386
859
|
},
|
|
387
860
|
};
|
|
861
|
+
/**
|
|
862
|
+
__________ ___ ______ __ __ ___ .__ __. _______ _______
|
|
863
|
+
| ____\ \ / / / || | | | / \ | \ | | / _____|| ____|
|
|
864
|
+
| |__ \ V / | ,----'| |__| | / ^ \ | \| | | | __ | |__
|
|
865
|
+
| __| > < | | | __ | / /_\ \ | . ` | | | |_ | | __|
|
|
866
|
+
| |____ / . \ | `----.| | | | / _____ \ | |\ | | |__| | | |____
|
|
867
|
+
|_______/__/ \__\ \______||__| |__| /__/ \__\ |__| \__| \______| |_______|
|
|
868
|
+
*/
|
|
388
869
|
exports.exchangeDcaSubData = {
|
|
389
870
|
encode: (fromToken, toToken, amount, interval) => {
|
|
390
871
|
const sellTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', fromToken);
|
|
@@ -424,6 +905,14 @@ exports.exchangeLimitOrderSubData = {
|
|
|
424
905
|
return { fromToken, toToken, amount };
|
|
425
906
|
},
|
|
426
907
|
};
|
|
908
|
+
/**
|
|
909
|
+
_______..______ ___ .______ __ ___
|
|
910
|
+
/ || _ \ / \ | _ \ | |/ /
|
|
911
|
+
| (----`| |_) | / ^ \ | |_) | | ' /
|
|
912
|
+
\ \ | ___/ / /_\ \ | / | <
|
|
913
|
+
.----) | | | / _____ \ | |\ \----.| . \
|
|
914
|
+
|_______/ | _| /__/ \__\ | _| `._____||__|\__\
|
|
915
|
+
*/
|
|
427
916
|
exports.sparkLeverageManagementSubData = {
|
|
428
917
|
decode(subData) {
|
|
429
918
|
const ratioWei = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]);
|
|
@@ -445,55 +934,70 @@ exports.sparkLeverageManagementSubDataWithoutSubProxy = {
|
|
|
445
934
|
return { targetRatio, ratioState };
|
|
446
935
|
},
|
|
447
936
|
};
|
|
448
|
-
exports.
|
|
449
|
-
encode
|
|
450
|
-
const
|
|
451
|
-
const
|
|
452
|
-
const
|
|
453
|
-
const
|
|
454
|
-
const
|
|
455
|
-
const
|
|
456
|
-
|
|
937
|
+
exports.sparkCloseGenericSubData = {
|
|
938
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user) {
|
|
939
|
+
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
940
|
+
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint8', collAssetId);
|
|
941
|
+
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
942
|
+
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint8', debtAssetId);
|
|
943
|
+
const encodedCloseType = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
944
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
945
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
946
|
+
return [
|
|
947
|
+
encodedColl,
|
|
948
|
+
encodedCollId,
|
|
949
|
+
encodedDebt,
|
|
950
|
+
encodedDebtId,
|
|
951
|
+
encodedCloseType,
|
|
952
|
+
encodedMarket,
|
|
953
|
+
userEncoded,
|
|
954
|
+
];
|
|
457
955
|
},
|
|
458
|
-
decode
|
|
459
|
-
const
|
|
460
|
-
const
|
|
461
|
-
|
|
956
|
+
decode(subData) {
|
|
957
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
958
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
959
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
960
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
961
|
+
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[4]));
|
|
962
|
+
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
963
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[6]);
|
|
964
|
+
return {
|
|
965
|
+
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, owner,
|
|
966
|
+
};
|
|
462
967
|
},
|
|
463
968
|
};
|
|
464
|
-
exports.
|
|
465
|
-
encode
|
|
466
|
-
const
|
|
467
|
-
const
|
|
468
|
-
const
|
|
469
|
-
const
|
|
470
|
-
const
|
|
471
|
-
const
|
|
472
|
-
|
|
969
|
+
exports.sparkLeverageManagementOnPriceSubData = {
|
|
970
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio) {
|
|
971
|
+
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
972
|
+
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint16', collAssetId);
|
|
973
|
+
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
974
|
+
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint16', debtAssetId);
|
|
975
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
976
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
977
|
+
const useOnBehalfEncoded = web3_eth_abi_1.default.encodeParameter('bool', false);
|
|
978
|
+
return [encodedColl, encodedCollId, encodedDebt, encodedDebtId, encodedMarket, encodedTargetRatio, useOnBehalfEncoded];
|
|
473
979
|
},
|
|
474
|
-
decode
|
|
475
|
-
const
|
|
980
|
+
decode(subData) {
|
|
981
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
982
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint16', subData[1]));
|
|
983
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
984
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint16', subData[3]));
|
|
985
|
+
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
986
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
476
987
|
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
477
|
-
return {
|
|
478
|
-
|
|
479
|
-
};
|
|
480
|
-
exports.liquityDebtInFrontRepaySubData = {
|
|
481
|
-
encode: (targetRatioIncrease) => {
|
|
482
|
-
const wethAddress = (0, tokens_1.getAssetInfo)('WETH').address;
|
|
483
|
-
const lusdAddress = (0, tokens_1.getAssetInfo)('LUSD').address;
|
|
484
|
-
const wethAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', wethAddress);
|
|
485
|
-
const lusdAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', lusdAddress);
|
|
486
|
-
const targetRatioIncreaseEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatioIncrease));
|
|
487
|
-
const withdrawIdEncoded = web3_eth_abi_1.default.encodeParameter('uint8', 1); // withdraw - 1
|
|
488
|
-
const paybackIdEncoded = web3_eth_abi_1.default.encodeParameter('uint8', 0); // payback - 0
|
|
489
|
-
return [wethAddressEncoded, lusdAddressEncoded, targetRatioIncreaseEncoded, withdrawIdEncoded, paybackIdEncoded];
|
|
490
|
-
},
|
|
491
|
-
decode: (subData) => {
|
|
492
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[2]);
|
|
493
|
-
const targetRatioIncrease = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
494
|
-
return { targetRatioIncrease };
|
|
988
|
+
return {
|
|
989
|
+
collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio,
|
|
990
|
+
};
|
|
495
991
|
},
|
|
496
992
|
};
|
|
993
|
+
/**
|
|
994
|
+
______ .______ ____ ____ __ __ _______. _______
|
|
995
|
+
/ || _ \ \ \ / / | | | | / || \
|
|
996
|
+
| ,----'| |_) | \ \/ / | | | | | (----`| .--. |
|
|
997
|
+
| | | / \ / | | | | \ \ | | | |
|
|
998
|
+
| `----.| |\ \----. \ / | `--' | .----) | | '--' |
|
|
999
|
+
\______|| _| `._____| \__/ \______/ |_______/ |_______/
|
|
1000
|
+
*/
|
|
497
1001
|
exports.crvUSDLeverageManagementSubData = {
|
|
498
1002
|
encode: (controllerAddr, ratioState, targetRatio, collTokenAddr, crvUSDAddr) => {
|
|
499
1003
|
const controllerAddrEncoded = web3_eth_abi_1.default.encodeParameter('address', controllerAddr);
|
|
@@ -539,6 +1043,14 @@ exports.crvUSDPaybackSubData = {
|
|
|
539
1043
|
};
|
|
540
1044
|
},
|
|
541
1045
|
};
|
|
1046
|
+
/**
|
|
1047
|
+
.___ ___. ______ .______ .______ __ __ ______
|
|
1048
|
+
| \/ | / __ \ | _ \ | _ \ | | | | / __ \
|
|
1049
|
+
| \ / | | | | | | |_) | | |_) | | |__| | | | | |
|
|
1050
|
+
| |\/| | | | | | | / | ___/ | __ | | | | |
|
|
1051
|
+
| | | | | `--' | | |\ \----.| | | | | | | `--' |
|
|
1052
|
+
|__| |__| \______/ | _| `._____|| _| |__| |__| \______/
|
|
1053
|
+
*/
|
|
542
1054
|
exports.morphoBlueLeverageManagementSubData = {
|
|
543
1055
|
encode: (loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA) => {
|
|
544
1056
|
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
@@ -572,141 +1084,6 @@ exports.morphoBlueLeverageManagementSubData = {
|
|
|
572
1084
|
};
|
|
573
1085
|
},
|
|
574
1086
|
};
|
|
575
|
-
exports.aaveV3LeverageManagementOnPriceSubData = {
|
|
576
|
-
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio) {
|
|
577
|
-
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
578
|
-
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint8', collAssetId);
|
|
579
|
-
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
580
|
-
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint8', debtAssetId);
|
|
581
|
-
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
582
|
-
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
583
|
-
const useOnBehalfEncoded = web3_eth_abi_1.default.encodeParameter('bool', false);
|
|
584
|
-
return [
|
|
585
|
-
encodedColl,
|
|
586
|
-
encodedCollId,
|
|
587
|
-
encodedDebt,
|
|
588
|
-
encodedDebtId,
|
|
589
|
-
encodedMarket,
|
|
590
|
-
encodedTargetRatio,
|
|
591
|
-
useOnBehalfEncoded,
|
|
592
|
-
];
|
|
593
|
-
},
|
|
594
|
-
decode(subData) {
|
|
595
|
-
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
596
|
-
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
597
|
-
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
598
|
-
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
599
|
-
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
600
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
601
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
602
|
-
return {
|
|
603
|
-
collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio,
|
|
604
|
-
};
|
|
605
|
-
},
|
|
606
|
-
};
|
|
607
|
-
exports.liquityV2LeverageManagementSubData = {
|
|
608
|
-
encode: (market, troveId, collToken, boldToken, ratioState, targetRatio) => {
|
|
609
|
-
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
610
|
-
const troveIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', troveId);
|
|
611
|
-
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
612
|
-
const boldTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', boldToken);
|
|
613
|
-
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
614
|
-
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
615
|
-
const isRepay = ratioState === enums_1.RatioState.UNDER;
|
|
616
|
-
const collActionType = isRepay ? enums_1.CollActionType.WITHDRAW : enums_1.CollActionType.SUPPLY;
|
|
617
|
-
const debtActionType = isRepay ? enums_1.DebtActionType.PAYBACK : enums_1.DebtActionType.BORROW;
|
|
618
|
-
const collActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
619
|
-
const debtActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
620
|
-
return [
|
|
621
|
-
marketEncoded,
|
|
622
|
-
troveIdEncoded,
|
|
623
|
-
collTokenEncoded,
|
|
624
|
-
boldTokenEncoded,
|
|
625
|
-
ratioStateEncoded,
|
|
626
|
-
targetRatioEncoded,
|
|
627
|
-
collActionTypeEncoded,
|
|
628
|
-
debtActionTypeEncoded,
|
|
629
|
-
];
|
|
630
|
-
},
|
|
631
|
-
decode: (subData) => {
|
|
632
|
-
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
633
|
-
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
634
|
-
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
635
|
-
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
636
|
-
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[4]);
|
|
637
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
638
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
639
|
-
return {
|
|
640
|
-
market, troveId, collToken, boldToken, ratioState, targetRatio,
|
|
641
|
-
};
|
|
642
|
-
},
|
|
643
|
-
};
|
|
644
|
-
exports.liquityV2CloseSubData = {
|
|
645
|
-
encode(market, troveId, collToken, boldToken, closeType) {
|
|
646
|
-
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
647
|
-
const troveIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', troveId);
|
|
648
|
-
const collAddrEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
649
|
-
const boldTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', boldToken);
|
|
650
|
-
const wethAddress = (0, tokens_1.getAssetInfo)('WETH').address;
|
|
651
|
-
const wethAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', wethAddress);
|
|
652
|
-
const gasCompensation = new decimal_js_1.default('0.0375').mul(1e18).toString();
|
|
653
|
-
const gasCompensationEncoded = web3_eth_abi_1.default.encodeParameter('uint256', gasCompensation);
|
|
654
|
-
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
655
|
-
return [
|
|
656
|
-
marketEncoded,
|
|
657
|
-
troveIdEncoded,
|
|
658
|
-
collAddrEncoded,
|
|
659
|
-
boldTokenEncoded,
|
|
660
|
-
wethAddressEncoded,
|
|
661
|
-
gasCompensationEncoded,
|
|
662
|
-
closeTypeEncoded,
|
|
663
|
-
];
|
|
664
|
-
},
|
|
665
|
-
decode(subData) {
|
|
666
|
-
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
667
|
-
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
668
|
-
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
669
|
-
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
670
|
-
// skip wethAddress and gasCompensation
|
|
671
|
-
const closeType = web3_eth_abi_1.default.decodeParameter('uint8', subData[6]);
|
|
672
|
-
return {
|
|
673
|
-
market, troveId, collToken, boldToken, closeType,
|
|
674
|
-
};
|
|
675
|
-
},
|
|
676
|
-
};
|
|
677
|
-
exports.liquityV2LeverageManagementOnPriceSubData = {
|
|
678
|
-
encode(market, troveId, collToken, boldToken, targetRatio, isRepayOnPrice) {
|
|
679
|
-
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
680
|
-
const encodedTroveId = web3_eth_abi_1.default.encodeParameter('uint256', troveId);
|
|
681
|
-
const encodedCollToken = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
682
|
-
const encodedBoldToken = web3_eth_abi_1.default.encodeParameter('address', boldToken);
|
|
683
|
-
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
684
|
-
const collActionType = isRepayOnPrice ? enums_1.CollActionType.WITHDRAW : enums_1.CollActionType.SUPPLY;
|
|
685
|
-
const debtActionType = isRepayOnPrice ? enums_1.DebtActionType.PAYBACK : enums_1.DebtActionType.BORROW;
|
|
686
|
-
const encodedCollActionType = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
687
|
-
const encodedDebtActionType = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
688
|
-
return [
|
|
689
|
-
encodedMarket,
|
|
690
|
-
encodedTroveId,
|
|
691
|
-
encodedCollToken,
|
|
692
|
-
encodedBoldToken,
|
|
693
|
-
encodedTargetRatio,
|
|
694
|
-
encodedCollActionType,
|
|
695
|
-
encodedDebtActionType,
|
|
696
|
-
];
|
|
697
|
-
},
|
|
698
|
-
decode(subData) {
|
|
699
|
-
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
700
|
-
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
701
|
-
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
702
|
-
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
703
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
704
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
705
|
-
return {
|
|
706
|
-
market, troveId, collToken, boldToken, targetRatio,
|
|
707
|
-
};
|
|
708
|
-
},
|
|
709
|
-
};
|
|
710
1087
|
exports.morphoBlueLeverageManagementOnPriceSubData = {
|
|
711
1088
|
encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user) {
|
|
712
1089
|
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
@@ -738,33 +1115,44 @@ exports.morphoBlueLeverageManagementOnPriceSubData = {
|
|
|
738
1115
|
};
|
|
739
1116
|
},
|
|
740
1117
|
};
|
|
741
|
-
exports.
|
|
742
|
-
encode
|
|
743
|
-
const
|
|
744
|
-
const
|
|
745
|
-
const
|
|
746
|
-
const
|
|
747
|
-
const
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
boldTokenEncoded,
|
|
752
|
-
targetRatioEncoded,
|
|
753
|
-
ratioStateEncoded,
|
|
754
|
-
];
|
|
1118
|
+
exports.morphoBlueCloseOnPriceSubData = {
|
|
1119
|
+
encode(loanToken, collToken, oracle, irm, lltv, user, closeType) {
|
|
1120
|
+
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
1121
|
+
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
1122
|
+
const oracleEncoded = web3_eth_abi_1.default.encodeParameter('address', oracle);
|
|
1123
|
+
const irmEncoded = web3_eth_abi_1.default.encodeParameter('address', irm);
|
|
1124
|
+
const lltvEncoded = web3_eth_abi_1.default.encodeParameter('uint256', lltv);
|
|
1125
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
1126
|
+
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
1127
|
+
return [loanTokenEncoded, collTokenEncoded, oracleEncoded, irmEncoded, lltvEncoded, userEncoded, closeTypeEncoded];
|
|
755
1128
|
},
|
|
756
|
-
decode
|
|
757
|
-
const
|
|
758
|
-
const
|
|
759
|
-
const
|
|
760
|
-
const
|
|
761
|
-
const
|
|
762
|
-
const
|
|
1129
|
+
decode(subData) {
|
|
1130
|
+
const loanToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
1131
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
1132
|
+
const oracle = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
1133
|
+
const irm = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
1134
|
+
const lltv = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
1135
|
+
const user = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
1136
|
+
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[6]));
|
|
763
1137
|
return {
|
|
764
|
-
|
|
1138
|
+
loanToken,
|
|
1139
|
+
collToken,
|
|
1140
|
+
oracle,
|
|
1141
|
+
irm,
|
|
1142
|
+
lltv,
|
|
1143
|
+
user,
|
|
1144
|
+
closeType,
|
|
765
1145
|
};
|
|
766
1146
|
},
|
|
767
1147
|
};
|
|
1148
|
+
/**
|
|
1149
|
+
_______ __ __ __ __ _______
|
|
1150
|
+
| ____|| | | | | | | | | \
|
|
1151
|
+
| |__ | | | | | | | | | .--. |
|
|
1152
|
+
| __| | | | | | | | | | | | |
|
|
1153
|
+
| | | `----.| `--' | | | | '--' |
|
|
1154
|
+
|__| |_______| \______/ |__| |_______/
|
|
1155
|
+
*/
|
|
768
1156
|
exports.fluidLeverageManagementSubData = {
|
|
769
1157
|
encode: (nftId, vault, ratioState, targetRatio) => {
|
|
770
1158
|
const nftIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', nftId);
|
|
@@ -798,145 +1186,3 @@ exports.fluidLeverageManagementSubData = {
|
|
|
798
1186
|
};
|
|
799
1187
|
},
|
|
800
1188
|
};
|
|
801
|
-
exports.compoundV3LeverageManagementOnPriceSubData = {
|
|
802
|
-
encode(market, collToken, baseToken, targetRatio, ratioState, user) {
|
|
803
|
-
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
804
|
-
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
805
|
-
const baseTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', baseToken);
|
|
806
|
-
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
807
|
-
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
808
|
-
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
809
|
-
return [
|
|
810
|
-
marketEncoded,
|
|
811
|
-
collTokenEncoded,
|
|
812
|
-
baseTokenEncoded,
|
|
813
|
-
targetRatioEncoded,
|
|
814
|
-
ratioStateEncoded,
|
|
815
|
-
userEncoded,
|
|
816
|
-
];
|
|
817
|
-
},
|
|
818
|
-
decode(subData) {
|
|
819
|
-
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
820
|
-
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
821
|
-
const baseToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
822
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[3]);
|
|
823
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
824
|
-
const ratioState = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[4]));
|
|
825
|
-
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
826
|
-
return {
|
|
827
|
-
market, collToken, baseToken, targetRatio, ratioState, owner,
|
|
828
|
-
};
|
|
829
|
-
},
|
|
830
|
-
};
|
|
831
|
-
exports.compoundV3CloseSubData = {
|
|
832
|
-
encode(market, collToken, baseToken, closeType, user) {
|
|
833
|
-
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
834
|
-
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
835
|
-
const baseTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', baseToken);
|
|
836
|
-
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
837
|
-
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
838
|
-
return [
|
|
839
|
-
marketEncoded,
|
|
840
|
-
collTokenEncoded,
|
|
841
|
-
baseTokenEncoded,
|
|
842
|
-
closeTypeEncoded,
|
|
843
|
-
userEncoded,
|
|
844
|
-
];
|
|
845
|
-
},
|
|
846
|
-
decode(subData) {
|
|
847
|
-
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
848
|
-
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
849
|
-
const baseToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
850
|
-
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
851
|
-
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
852
|
-
return {
|
|
853
|
-
market, collToken, baseToken, closeType, owner,
|
|
854
|
-
};
|
|
855
|
-
},
|
|
856
|
-
};
|
|
857
|
-
exports.sparkCloseGenericSubData = {
|
|
858
|
-
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user) {
|
|
859
|
-
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
860
|
-
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint8', collAssetId);
|
|
861
|
-
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
862
|
-
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint8', debtAssetId);
|
|
863
|
-
const encodedCloseType = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
864
|
-
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
865
|
-
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
866
|
-
return [
|
|
867
|
-
encodedColl,
|
|
868
|
-
encodedCollId,
|
|
869
|
-
encodedDebt,
|
|
870
|
-
encodedDebtId,
|
|
871
|
-
encodedCloseType,
|
|
872
|
-
encodedMarket,
|
|
873
|
-
userEncoded,
|
|
874
|
-
];
|
|
875
|
-
},
|
|
876
|
-
decode(subData) {
|
|
877
|
-
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
878
|
-
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
879
|
-
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
880
|
-
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
881
|
-
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[4]));
|
|
882
|
-
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
883
|
-
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[6]);
|
|
884
|
-
return {
|
|
885
|
-
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, owner,
|
|
886
|
-
};
|
|
887
|
-
},
|
|
888
|
-
};
|
|
889
|
-
exports.morphoBlueCloseOnPriceSubData = {
|
|
890
|
-
encode(loanToken, collToken, oracle, irm, lltv, user, closeType) {
|
|
891
|
-
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
892
|
-
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
893
|
-
const oracleEncoded = web3_eth_abi_1.default.encodeParameter('address', oracle);
|
|
894
|
-
const irmEncoded = web3_eth_abi_1.default.encodeParameter('address', irm);
|
|
895
|
-
const lltvEncoded = web3_eth_abi_1.default.encodeParameter('uint256', lltv);
|
|
896
|
-
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
897
|
-
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
898
|
-
return [loanTokenEncoded, collTokenEncoded, oracleEncoded, irmEncoded, lltvEncoded, userEncoded, closeTypeEncoded];
|
|
899
|
-
},
|
|
900
|
-
decode(subData) {
|
|
901
|
-
const loanToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
902
|
-
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
903
|
-
const oracle = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
904
|
-
const irm = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
905
|
-
const lltv = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
906
|
-
const user = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
907
|
-
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[6]));
|
|
908
|
-
return {
|
|
909
|
-
loanToken,
|
|
910
|
-
collToken,
|
|
911
|
-
oracle,
|
|
912
|
-
irm,
|
|
913
|
-
lltv,
|
|
914
|
-
user,
|
|
915
|
-
closeType,
|
|
916
|
-
};
|
|
917
|
-
},
|
|
918
|
-
};
|
|
919
|
-
exports.sparkLeverageManagementOnPriceSubData = {
|
|
920
|
-
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio) {
|
|
921
|
-
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
922
|
-
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint16', collAssetId);
|
|
923
|
-
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
924
|
-
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint16', debtAssetId);
|
|
925
|
-
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
926
|
-
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
927
|
-
const useOnBehalfEncoded = web3_eth_abi_1.default.encodeParameter('bool', false);
|
|
928
|
-
return [encodedColl, encodedCollId, encodedDebt, encodedDebtId, encodedMarket, encodedTargetRatio, useOnBehalfEncoded];
|
|
929
|
-
},
|
|
930
|
-
decode(subData) {
|
|
931
|
-
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
932
|
-
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint16', subData[1]));
|
|
933
|
-
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
934
|
-
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint16', subData[3]));
|
|
935
|
-
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
936
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
937
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
938
|
-
return {
|
|
939
|
-
collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio,
|
|
940
|
-
};
|
|
941
|
-
},
|
|
942
|
-
};
|