@defisaver/automation-sdk 3.3.9 → 3.3.10-aave-v4-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/constants/index.js +55 -0
- package/cjs/services/ethereumService.js +21 -14
- package/cjs/services/strategiesService.js +101 -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 +290 -132
- package/cjs/services/subDataService.js +607 -378
- package/cjs/services/subDataService.test.js +157 -0
- package/cjs/services/triggerService.d.ts +29 -0
- package/cjs/services/triggerService.js +55 -1
- package/cjs/services/triggerService.test.js +84 -0
- package/cjs/types/enums.d.ts +14 -2
- package/cjs/types/enums.js +12 -0
- package/cjs/types/index.d.ts +22 -1
- package/esm/constants/index.js +55 -0
- package/esm/services/ethereumService.js +21 -14
- package/esm/services/strategiesService.js +102 -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 +290 -132
- package/esm/services/subDataService.js +606 -377
- package/esm/services/subDataService.test.js +157 -0
- package/esm/services/triggerService.d.ts +29 -0
- package/esm/services/triggerService.js +54 -0
- package/esm/services/triggerService.test.js +85 -1
- package/esm/types/enums.d.ts +14 -2
- package/esm/types/enums.js +12 -0
- package/esm/types/index.d.ts +22 -1
- package/package.json +1 -1
- package/src/constants/index.ts +55 -0
- package/src/services/ethereumService.ts +23 -16
- package/src/services/strategiesService.ts +116 -1
- package/src/services/strategySubService.test.ts +125 -0
- package/src/services/strategySubService.ts +118 -0
- package/src/services/subDataService.test.ts +173 -0
- package/src/services/subDataService.ts +980 -746
- package/src/services/triggerService.test.ts +99 -0
- package/src/services/triggerService.ts +76 -1
- package/src/types/enums.ts +12 -0
- package/src/types/index.ts +27 -1
|
@@ -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.morphoBlueCloseOnPriceSubData = exports.
|
|
6
|
+
exports.fluidLeverageManagementSubData = exports.morphoBlueCloseOnPriceSubData = exports.morphoBlueLeverageManagementOnPriceSubData = exports.morphoBlueLeverageManagementSubData = exports.crvUSDPaybackSubData = exports.crvUSDLeverageManagementSubData = exports.sparkCloseGenericSubData = exports.sparkLeverageManagementSubDataWithoutSubProxy = exports.sparkLeverageManagementSubData = exports.exchangeLimitOrderSubData = exports.exchangeDcaSubData = exports.compoundV3CloseSubData = exports.compoundV3LeverageManagementOnPriceSubData = exports.compoundV3L2LeverageManagementSubData = exports.compoundV3LeverageManagementSubData = exports.compoundV2LeverageManagementSubData = exports.aaveV4CollateralSwitchSubData = exports.aaveV4CloseSubData = exports.aaveV4LeverageManagementOnPriceSubData = exports.aaveV4LeverageManagementSubData = exports.aaveV3LeverageManagementOnPriceSubData = exports.aaveV3QuotePriceSubData = exports.aaveV3CollateralSwitchSubData = exports.aaveV3CloseGenericSubData = exports.aaveV3LeverageManagementOnPriceGeneric = exports.aaveV3LeverageManagementSubDataWithoutSubProxy = exports.aaveV3LeverageManagementSubData = exports.aaveV2LeverageManagementSubData = exports.liquityV2PaybackSubData = exports.liquityV2LeverageManagementOnPriceSubData = exports.liquityV2CloseSubData = exports.liquityV2LeverageManagementSubData = exports.liquityDebtInFrontRepaySubData = exports.liquityDsrSupplySubData = exports.liquityDsrPaybackSubData = exports.liquityCloseSubData = exports.liquityLeverageManagementSubData = exports.liquityRepayFromSavingsSubData = exports.makerLeverageManagementWithoutSubProxy = exports.makerLeverageManagementSubData = exports.makerCloseSubData = exports.makerRepayFromSavingsSubData = exports.liquityPaybackUsingChickenBondSubData = exports.cBondsRebondSubData = exports.morphoAaveV2LeverageManagementSubData = void 0;
|
|
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,180 @@ 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
|
+
return [spokeEncoded, ownerEncoded, ratioStateEncoded, targetRatioEncoded];
|
|
603
|
+
},
|
|
604
|
+
decode: (subData) => {
|
|
605
|
+
const spoke = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
606
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
607
|
+
const ratioState = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[2]));
|
|
608
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[3]));
|
|
609
|
+
return {
|
|
610
|
+
spoke, owner, ratioState, targetRatio,
|
|
611
|
+
};
|
|
612
|
+
},
|
|
613
|
+
};
|
|
614
|
+
exports.aaveV4LeverageManagementOnPriceSubData = {
|
|
615
|
+
encode: (spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, ratioState, targetRatio) => {
|
|
616
|
+
const spokeEncoded = web3_eth_abi_1.default.encodeParameter('address', spoke);
|
|
617
|
+
const ownerEncoded = web3_eth_abi_1.default.encodeParameter('address', owner);
|
|
618
|
+
const collAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
619
|
+
const collAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', collAssetId);
|
|
620
|
+
const debtAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
621
|
+
const debtAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', debtAssetId);
|
|
622
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
623
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
624
|
+
return [
|
|
625
|
+
spokeEncoded,
|
|
626
|
+
ownerEncoded,
|
|
627
|
+
collAssetEncoded,
|
|
628
|
+
collAssetIdEncoded,
|
|
629
|
+
debtAssetEncoded,
|
|
630
|
+
debtAssetIdEncoded,
|
|
631
|
+
ratioStateEncoded,
|
|
632
|
+
targetRatioEncoded,
|
|
633
|
+
];
|
|
634
|
+
},
|
|
635
|
+
decode: (subData) => {
|
|
636
|
+
const spoke = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
637
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
638
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
639
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint256', subData[3]));
|
|
640
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
641
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint256', subData[5]));
|
|
642
|
+
const ratioState = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[6]));
|
|
643
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[7]));
|
|
644
|
+
return {
|
|
645
|
+
spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, ratioState, targetRatio,
|
|
646
|
+
};
|
|
647
|
+
},
|
|
648
|
+
};
|
|
649
|
+
exports.aaveV4CloseSubData = {
|
|
650
|
+
encode: (spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, closeType) => {
|
|
651
|
+
const spokeEncoded = web3_eth_abi_1.default.encodeParameter('address', spoke);
|
|
652
|
+
const ownerEncoded = web3_eth_abi_1.default.encodeParameter('address', owner);
|
|
653
|
+
const collAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
654
|
+
const collAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', collAssetId);
|
|
655
|
+
const debtAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
656
|
+
const debtAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', debtAssetId);
|
|
657
|
+
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
658
|
+
return [
|
|
659
|
+
spokeEncoded,
|
|
660
|
+
ownerEncoded,
|
|
661
|
+
collAssetEncoded,
|
|
662
|
+
collAssetIdEncoded,
|
|
663
|
+
debtAssetEncoded,
|
|
664
|
+
debtAssetIdEncoded,
|
|
665
|
+
closeTypeEncoded,
|
|
666
|
+
];
|
|
667
|
+
},
|
|
668
|
+
decode: (subData) => {
|
|
669
|
+
const spoke = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
670
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
671
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
672
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint256', subData[3]));
|
|
673
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
674
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint256', subData[5]));
|
|
675
|
+
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[6]));
|
|
676
|
+
return {
|
|
677
|
+
spoke, owner, collAsset, collAssetId, debtAsset, debtAssetId, closeType,
|
|
678
|
+
};
|
|
679
|
+
},
|
|
680
|
+
};
|
|
681
|
+
exports.aaveV4CollateralSwitchSubData = {
|
|
682
|
+
encode: (spoke, owner, fromAsset, fromAssetId, toAsset, toAssetId, amountToSwitch) => {
|
|
683
|
+
const spokeEncoded = web3_eth_abi_1.default.encodeParameter('address', spoke);
|
|
684
|
+
const ownerEncoded = web3_eth_abi_1.default.encodeParameter('address', owner);
|
|
685
|
+
const fromAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', fromAsset);
|
|
686
|
+
const fromAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', fromAssetId);
|
|
687
|
+
const toAssetEncoded = web3_eth_abi_1.default.encodeParameter('address', toAsset);
|
|
688
|
+
const toAssetIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', toAssetId);
|
|
689
|
+
const amountToSwitchEncoded = web3_eth_abi_1.default.encodeParameter('uint256', amountToSwitch);
|
|
690
|
+
return [
|
|
691
|
+
spokeEncoded,
|
|
692
|
+
ownerEncoded,
|
|
693
|
+
fromAssetEncoded,
|
|
694
|
+
fromAssetIdEncoded,
|
|
695
|
+
toAssetEncoded,
|
|
696
|
+
toAssetIdEncoded,
|
|
697
|
+
amountToSwitchEncoded,
|
|
698
|
+
];
|
|
699
|
+
},
|
|
700
|
+
decode: (subData) => {
|
|
701
|
+
const spoke = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
702
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
703
|
+
const fromAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
704
|
+
const fromAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint256', subData[3]));
|
|
705
|
+
const toAsset = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
706
|
+
const toAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint256', subData[5]));
|
|
707
|
+
const amountToSwitch = web3_eth_abi_1.default.decodeParameter('uint256', subData[6]);
|
|
708
|
+
return {
|
|
709
|
+
spoke, owner, fromAsset, fromAssetId, toAsset, toAssetId, amountToSwitch,
|
|
710
|
+
};
|
|
711
|
+
},
|
|
712
|
+
};
|
|
713
|
+
/**
|
|
714
|
+
______ ______ .___ ___. .______ ____ ____ ___
|
|
715
|
+
/ | / __ \ | \/ | | _ \ \ \ / / |__ \
|
|
716
|
+
| ,----'| | | | | \ / | | |_) | \ \/ / ) |
|
|
717
|
+
| | | | | | | |\/| | | ___/ \ / / /
|
|
718
|
+
| `----.| `--' | | | | | | | \ / / /_
|
|
719
|
+
\______| \______/ |__| |__| | _| \__/ |____|
|
|
720
|
+
*/
|
|
721
|
+
exports.compoundV2LeverageManagementSubData = {
|
|
722
|
+
encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
723
|
+
return [
|
|
724
|
+
new decimal_js_1.default(triggerRepayRatio).mul(1e16).toString(),
|
|
725
|
+
new decimal_js_1.default(triggerBoostRatio).mul(1e16).toString(),
|
|
726
|
+
new decimal_js_1.default(targetBoostRatio).mul(1e16).toString(),
|
|
727
|
+
new decimal_js_1.default(targetRepayRatio).mul(1e16).toString(),
|
|
728
|
+
// @ts-ignore // TODO
|
|
729
|
+
boostEnabled,
|
|
292
730
|
];
|
|
293
731
|
},
|
|
294
732
|
decode(subData) {
|
|
@@ -297,6 +735,14 @@ exports.compoundV2LeverageManagementSubData = {
|
|
|
297
735
|
return { targetRatio };
|
|
298
736
|
},
|
|
299
737
|
};
|
|
738
|
+
/**
|
|
739
|
+
______ ______ .___ ___. .______ ____ ____ ____
|
|
740
|
+
/ | / __ \ | \/ | | _ \ \ \ / / |___ \
|
|
741
|
+
| ,----'| | | | | \ / | | |_) | \ \/ / __) |
|
|
742
|
+
| | | | | | | |\/| | | ___/ \ / |__ <
|
|
743
|
+
| `----.| `--' | | | | | | | \ / ___) |
|
|
744
|
+
\______| \______/ |__| |__| | _| \__/ |____/
|
|
745
|
+
*/
|
|
300
746
|
exports.compoundV3LeverageManagementSubData = {
|
|
301
747
|
encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA) {
|
|
302
748
|
return [
|
|
@@ -339,52 +785,70 @@ exports.compoundV3L2LeverageManagementSubData = {
|
|
|
339
785
|
return { targetRatio };
|
|
340
786
|
},
|
|
341
787
|
};
|
|
342
|
-
exports.
|
|
343
|
-
encode(
|
|
788
|
+
exports.compoundV3LeverageManagementOnPriceSubData = {
|
|
789
|
+
encode(market, collToken, baseToken, targetRatio, ratioState, user) {
|
|
790
|
+
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
791
|
+
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
792
|
+
const baseTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', baseToken);
|
|
793
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
794
|
+
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
795
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
344
796
|
return [
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
797
|
+
marketEncoded,
|
|
798
|
+
collTokenEncoded,
|
|
799
|
+
baseTokenEncoded,
|
|
800
|
+
targetRatioEncoded,
|
|
801
|
+
ratioStateEncoded,
|
|
802
|
+
userEncoded,
|
|
351
803
|
];
|
|
352
804
|
},
|
|
353
805
|
decode(subData) {
|
|
354
|
-
const
|
|
355
|
-
const
|
|
356
|
-
|
|
806
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
807
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
808
|
+
const baseToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
809
|
+
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[3]);
|
|
810
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
811
|
+
const ratioState = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[4]));
|
|
812
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
813
|
+
return {
|
|
814
|
+
market, collToken, baseToken, targetRatio, ratioState, owner,
|
|
815
|
+
};
|
|
357
816
|
},
|
|
358
817
|
};
|
|
359
|
-
exports.
|
|
360
|
-
encode(
|
|
361
|
-
const
|
|
362
|
-
|
|
818
|
+
exports.compoundV3CloseSubData = {
|
|
819
|
+
encode(market, collToken, baseToken, closeType, user) {
|
|
820
|
+
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
821
|
+
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
822
|
+
const baseTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', baseToken);
|
|
823
|
+
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
824
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
825
|
+
return [
|
|
826
|
+
marketEncoded,
|
|
827
|
+
collTokenEncoded,
|
|
828
|
+
baseTokenEncoded,
|
|
829
|
+
closeTypeEncoded,
|
|
830
|
+
userEncoded,
|
|
831
|
+
];
|
|
363
832
|
},
|
|
364
833
|
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 };
|
|
834
|
+
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
835
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
836
|
+
const baseToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
837
|
+
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
838
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
839
|
+
return {
|
|
840
|
+
market, collToken, baseToken, closeType, owner,
|
|
841
|
+
};
|
|
386
842
|
},
|
|
387
843
|
};
|
|
844
|
+
/**
|
|
845
|
+
__________ ___ ______ __ __ ___ .__ __. _______ _______
|
|
846
|
+
| ____\ \ / / / || | | | / \ | \ | | / _____|| ____|
|
|
847
|
+
| |__ \ V / | ,----'| |__| | / ^ \ | \| | | | __ | |__
|
|
848
|
+
| __| > < | | | __ | / /_\ \ | . ` | | | |_ | | __|
|
|
849
|
+
| |____ / . \ | `----.| | | | / _____ \ | |\ | | |__| | | |____
|
|
850
|
+
|_______/__/ \__\ \______||__| |__| /__/ \__\ |__| \__| \______| |_______|
|
|
851
|
+
*/
|
|
388
852
|
exports.exchangeDcaSubData = {
|
|
389
853
|
encode: (fromToken, toToken, amount, interval) => {
|
|
390
854
|
const sellTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', fromToken);
|
|
@@ -424,6 +888,14 @@ exports.exchangeLimitOrderSubData = {
|
|
|
424
888
|
return { fromToken, toToken, amount };
|
|
425
889
|
},
|
|
426
890
|
};
|
|
891
|
+
/**
|
|
892
|
+
_______..______ ___ .______ __ ___
|
|
893
|
+
/ || _ \ / \ | _ \ | |/ /
|
|
894
|
+
| (----`| |_) | / ^ \ | |_) | | ' /
|
|
895
|
+
\ \ | ___/ / /_\ \ | / | <
|
|
896
|
+
.----) | | | / _____ \ | |\ \----.| . \
|
|
897
|
+
|_______/ | _| /__/ \__\ | _| `._____||__|\__\
|
|
898
|
+
*/
|
|
427
899
|
exports.sparkLeverageManagementSubData = {
|
|
428
900
|
decode(subData) {
|
|
429
901
|
const ratioWei = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]);
|
|
@@ -445,55 +917,46 @@ exports.sparkLeverageManagementSubDataWithoutSubProxy = {
|
|
|
445
917
|
return { targetRatio, ratioState };
|
|
446
918
|
},
|
|
447
919
|
};
|
|
448
|
-
exports.
|
|
449
|
-
encode
|
|
450
|
-
const
|
|
451
|
-
const
|
|
452
|
-
const
|
|
453
|
-
const
|
|
454
|
-
const
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
const daiAddress = (0, tokens_1.getAssetInfo)('DAI').address;
|
|
467
|
-
const wethAddress = (0, tokens_1.getAssetInfo)('WETH').address;
|
|
468
|
-
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', enums_1.RatioState.UNDER);
|
|
469
|
-
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
470
|
-
const daiAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', daiAddress);
|
|
471
|
-
const wethAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', wethAddress);
|
|
472
|
-
return [ratioStateEncoded, targetRatioEncoded, daiAddressEncoded, wethAddressEncoded];
|
|
473
|
-
},
|
|
474
|
-
decode: (subData) => {
|
|
475
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
476
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
477
|
-
return { targetRatio };
|
|
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];
|
|
920
|
+
exports.sparkCloseGenericSubData = {
|
|
921
|
+
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user) {
|
|
922
|
+
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
923
|
+
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint8', collAssetId);
|
|
924
|
+
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
925
|
+
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint8', debtAssetId);
|
|
926
|
+
const encodedCloseType = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
927
|
+
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
928
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
929
|
+
return [
|
|
930
|
+
encodedColl,
|
|
931
|
+
encodedCollId,
|
|
932
|
+
encodedDebt,
|
|
933
|
+
encodedDebtId,
|
|
934
|
+
encodedCloseType,
|
|
935
|
+
encodedMarket,
|
|
936
|
+
userEncoded,
|
|
937
|
+
];
|
|
490
938
|
},
|
|
491
|
-
decode
|
|
492
|
-
const
|
|
493
|
-
const
|
|
494
|
-
|
|
939
|
+
decode(subData) {
|
|
940
|
+
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
941
|
+
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
942
|
+
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
943
|
+
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
944
|
+
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[4]));
|
|
945
|
+
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
946
|
+
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[6]);
|
|
947
|
+
return {
|
|
948
|
+
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, owner,
|
|
949
|
+
};
|
|
495
950
|
},
|
|
496
951
|
};
|
|
952
|
+
/**
|
|
953
|
+
______ .______ ____ ____ __ __ _______. _______
|
|
954
|
+
/ || _ \ \ \ / / | | | | / || \
|
|
955
|
+
| ,----'| |_) | \ \/ / | | | | | (----`| .--. |
|
|
956
|
+
| | | / \ / | | | | \ \ | | | |
|
|
957
|
+
| `----.| |\ \----. \ / | `--' | .----) | | '--' |
|
|
958
|
+
\______|| _| `._____| \__/ \______/ |_______/ |_______/
|
|
959
|
+
*/
|
|
497
960
|
exports.crvUSDLeverageManagementSubData = {
|
|
498
961
|
encode: (controllerAddr, ratioState, targetRatio, collTokenAddr, crvUSDAddr) => {
|
|
499
962
|
const controllerAddrEncoded = web3_eth_abi_1.default.encodeParameter('address', controllerAddr);
|
|
@@ -539,6 +1002,14 @@ exports.crvUSDPaybackSubData = {
|
|
|
539
1002
|
};
|
|
540
1003
|
},
|
|
541
1004
|
};
|
|
1005
|
+
/**
|
|
1006
|
+
.___ ___. ______ .______ .______ __ __ ______
|
|
1007
|
+
| \/ | / __ \ | _ \ | _ \ | | | | / __ \
|
|
1008
|
+
| \ / | | | | | | |_) | | |_) | | |__| | | | | |
|
|
1009
|
+
| |\/| | | | | | | / | ___/ | __ | | | | |
|
|
1010
|
+
| | | | | `--' | | |\ \----.| | | | | | | `--' |
|
|
1011
|
+
|__| |__| \______/ | _| `._____|| _| |__| |__| \______/
|
|
1012
|
+
*/
|
|
542
1013
|
exports.morphoBlueLeverageManagementSubData = {
|
|
543
1014
|
encode: (loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA) => {
|
|
544
1015
|
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
@@ -572,151 +1043,47 @@ exports.morphoBlueLeverageManagementSubData = {
|
|
|
572
1043
|
};
|
|
573
1044
|
},
|
|
574
1045
|
};
|
|
575
|
-
exports.
|
|
576
|
-
encode(
|
|
577
|
-
const
|
|
578
|
-
const
|
|
579
|
-
const
|
|
580
|
-
const
|
|
581
|
-
const
|
|
582
|
-
const
|
|
583
|
-
const
|
|
584
|
-
return [
|
|
585
|
-
encodedColl,
|
|
586
|
-
encodedCollId,
|
|
587
|
-
encodedDebt,
|
|
588
|
-
encodedDebtId,
|
|
589
|
-
encodedMarket,
|
|
590
|
-
encodedTargetRatio,
|
|
591
|
-
useOnBehalfEncoded,
|
|
592
|
-
];
|
|
1046
|
+
exports.morphoBlueLeverageManagementOnPriceSubData = {
|
|
1047
|
+
encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user) {
|
|
1048
|
+
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
1049
|
+
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
1050
|
+
const oracleEncoded = web3_eth_abi_1.default.encodeParameter('address', oracle);
|
|
1051
|
+
const irmEncoded = web3_eth_abi_1.default.encodeParameter('address', irm);
|
|
1052
|
+
const lltvEncoded = web3_eth_abi_1.default.encodeParameter('uint256', lltv);
|
|
1053
|
+
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
1054
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
1055
|
+
return [loanTokenEncoded, collTokenEncoded, oracleEncoded, irmEncoded, lltvEncoded, targetRatioEncoded, userEncoded];
|
|
593
1056
|
},
|
|
594
1057
|
decode(subData) {
|
|
595
|
-
const
|
|
596
|
-
const
|
|
597
|
-
const
|
|
598
|
-
const
|
|
599
|
-
const
|
|
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]);
|
|
1058
|
+
const loanToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
1059
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
1060
|
+
const oracle = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
1061
|
+
const irm = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
1062
|
+
const lltv = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
637
1063
|
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
638
1064
|
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
1065
|
+
const user = web3_eth_abi_1.default.decodeParameter('address', subData[6]);
|
|
639
1066
|
return {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
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,
|
|
1067
|
+
loanToken,
|
|
1068
|
+
collToken,
|
|
1069
|
+
oracle,
|
|
1070
|
+
irm,
|
|
1071
|
+
lltv,
|
|
1072
|
+
targetRatio,
|
|
1073
|
+
user,
|
|
707
1074
|
};
|
|
708
1075
|
},
|
|
709
1076
|
};
|
|
710
|
-
exports.
|
|
711
|
-
encode(loanToken, collToken, oracle, irm, lltv,
|
|
1077
|
+
exports.morphoBlueCloseOnPriceSubData = {
|
|
1078
|
+
encode(loanToken, collToken, oracle, irm, lltv, user, closeType) {
|
|
712
1079
|
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
713
1080
|
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
714
1081
|
const oracleEncoded = web3_eth_abi_1.default.encodeParameter('address', oracle);
|
|
715
1082
|
const irmEncoded = web3_eth_abi_1.default.encodeParameter('address', irm);
|
|
716
1083
|
const lltvEncoded = web3_eth_abi_1.default.encodeParameter('uint256', lltv);
|
|
717
|
-
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
718
1084
|
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
719
|
-
|
|
1085
|
+
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
1086
|
+
return [loanTokenEncoded, collTokenEncoded, oracleEncoded, irmEncoded, lltvEncoded, userEncoded, closeTypeEncoded];
|
|
720
1087
|
},
|
|
721
1088
|
decode(subData) {
|
|
722
1089
|
const loanToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
@@ -724,47 +1091,27 @@ exports.morphoBlueLeverageManagementOnPriceSubData = {
|
|
|
724
1091
|
const oracle = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
725
1092
|
const irm = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
726
1093
|
const lltv = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
727
|
-
const
|
|
728
|
-
const
|
|
729
|
-
const user = web3_eth_abi_1.default.decodeParameter('address', subData[6]);
|
|
1094
|
+
const user = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
1095
|
+
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[6]));
|
|
730
1096
|
return {
|
|
731
1097
|
loanToken,
|
|
732
1098
|
collToken,
|
|
733
1099
|
oracle,
|
|
734
1100
|
irm,
|
|
735
1101
|
lltv,
|
|
736
|
-
targetRatio,
|
|
737
1102
|
user,
|
|
1103
|
+
closeType,
|
|
738
1104
|
};
|
|
739
1105
|
},
|
|
740
1106
|
};
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
marketEncoded,
|
|
750
|
-
troveIdEncoded,
|
|
751
|
-
boldTokenEncoded,
|
|
752
|
-
targetRatioEncoded,
|
|
753
|
-
ratioStateEncoded,
|
|
754
|
-
];
|
|
755
|
-
},
|
|
756
|
-
decode: (subData) => {
|
|
757
|
-
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
758
|
-
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
759
|
-
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
760
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[3]);
|
|
761
|
-
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[4]);
|
|
762
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
763
|
-
return {
|
|
764
|
-
market, troveId, boldToken, ratioState, targetRatio,
|
|
765
|
-
};
|
|
766
|
-
},
|
|
767
|
-
};
|
|
1107
|
+
/**
|
|
1108
|
+
_______ __ __ __ __ _______
|
|
1109
|
+
| ____|| | | | | | | | | \
|
|
1110
|
+
| |__ | | | | | | | | | .--. |
|
|
1111
|
+
| __| | | | | | | | | | | | |
|
|
1112
|
+
| | | `----.| `--' | | | | '--' |
|
|
1113
|
+
|__| |_______| \______/ |__| |_______/
|
|
1114
|
+
*/
|
|
768
1115
|
exports.fluidLeverageManagementSubData = {
|
|
769
1116
|
encode: (nftId, vault, ratioState, targetRatio) => {
|
|
770
1117
|
const nftIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', nftId);
|
|
@@ -798,121 +1145,3 @@ exports.fluidLeverageManagementSubData = {
|
|
|
798
1145
|
};
|
|
799
1146
|
},
|
|
800
1147
|
};
|
|
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
|
-
};
|