@defisaver/automation-sdk 3.3.8 → 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 +8 -0
- package/cjs/services/strategySubService.js +47 -1
- package/cjs/services/strategySubService.test.js +143 -0
- package/cjs/services/subDataService.d.ts +302 -129
- package/cjs/services/subDataService.js +629 -372
- package/cjs/services/subDataService.test.js +213 -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 +8 -0
- package/esm/services/strategySubService.js +46 -0
- package/esm/services/strategySubService.test.js +144 -1
- package/esm/services/subDataService.d.ts +302 -129
- package/esm/services/subDataService.js +628 -371
- package/esm/services/subDataService.test.js +213 -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 +180 -0
- package/src/services/strategySubService.ts +162 -2
- package/src/services/subDataService.test.ts +233 -0
- package/src/services/subDataService.ts +977 -703
- 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;
|
|
@@ -76,6 +131,35 @@ exports.makerLeverageManagementSubData = {
|
|
|
76
131
|
return { vaultId, targetRatio };
|
|
77
132
|
},
|
|
78
133
|
};
|
|
134
|
+
exports.makerLeverageManagementWithoutSubProxy = {
|
|
135
|
+
encode(vaultId, targetRatio, daiAddr) {
|
|
136
|
+
const encodedVaultId = web3_eth_abi_1.default.encodeParameter('uint256', vaultId);
|
|
137
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
138
|
+
const encodedDaiAddr = web3_eth_abi_1.default.encodeParameter('address', daiAddr || (0, tokens_1.getAssetInfo)('DAI', 1).address);
|
|
139
|
+
return [encodedVaultId, encodedTargetRatio, encodedDaiAddr];
|
|
140
|
+
},
|
|
141
|
+
decode(subData) {
|
|
142
|
+
const vaultId = +web3_eth_abi_1.default.decodeParameter('uint256', subData[0]).toString();
|
|
143
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[1]));
|
|
144
|
+
const daiAddr = web3_eth_abi_1.default.decodeParameter('address', subData[2]).toString();
|
|
145
|
+
return { vaultId, targetRatio, daiAddr };
|
|
146
|
+
},
|
|
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
|
+
};
|
|
79
163
|
exports.liquityLeverageManagementSubData = {
|
|
80
164
|
decode: (subData) => {
|
|
81
165
|
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
@@ -102,6 +186,201 @@ exports.liquityCloseSubData = {
|
|
|
102
186
|
return { closeToAssetAddr, debtAddr };
|
|
103
187
|
},
|
|
104
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
|
+
*/
|
|
105
384
|
exports.aaveV2LeverageManagementSubData = {
|
|
106
385
|
encode(triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled) {
|
|
107
386
|
return [
|
|
@@ -119,6 +398,14 @@ exports.aaveV2LeverageManagementSubData = {
|
|
|
119
398
|
return { targetRatio };
|
|
120
399
|
},
|
|
121
400
|
};
|
|
401
|
+
/**
|
|
402
|
+
___ ___ ____ ____ _______ ____ ____ ____
|
|
403
|
+
/ \ / \ \ \ / / | ____| \ \ / / |___ \
|
|
404
|
+
/ ^ \ / ^ \ \ \/ / | |__ \ \/ / __) |
|
|
405
|
+
/ /_\ \ / /_\ \ \ / | __| \ / |__ <
|
|
406
|
+
/ _____ \ / _____ \ \ / | |____ \ / ___) |
|
|
407
|
+
/__/ \__\ /__/ \__\ \__/ |_______| \__/ |____/
|
|
408
|
+
*/
|
|
122
409
|
exports.aaveV3LeverageManagementSubData = {
|
|
123
410
|
decode(subData) {
|
|
124
411
|
const ratioWei = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]);
|
|
@@ -266,16 +553,181 @@ exports.aaveV3QuotePriceSubData = {
|
|
|
266
553
|
};
|
|
267
554
|
},
|
|
268
555
|
};
|
|
269
|
-
exports.
|
|
270
|
-
encode(
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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);
|
|
565
|
+
return [
|
|
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,
|
|
730
|
+
];
|
|
279
731
|
},
|
|
280
732
|
decode(subData) {
|
|
281
733
|
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]);
|
|
@@ -283,6 +735,14 @@ exports.compoundV2LeverageManagementSubData = {
|
|
|
283
735
|
return { targetRatio };
|
|
284
736
|
},
|
|
285
737
|
};
|
|
738
|
+
/**
|
|
739
|
+
______ ______ .___ ___. .______ ____ ____ ____
|
|
740
|
+
/ | / __ \ | \/ | | _ \ \ \ / / |___ \
|
|
741
|
+
| ,----'| | | | | \ / | | |_) | \ \/ / __) |
|
|
742
|
+
| | | | | | | |\/| | | ___/ \ / |__ <
|
|
743
|
+
| `----.| `--' | | | | | | | \ / ___) |
|
|
744
|
+
\______| \______/ |__| |__| | _| \__/ |____/
|
|
745
|
+
*/
|
|
286
746
|
exports.compoundV3LeverageManagementSubData = {
|
|
287
747
|
encode(market, baseToken, triggerRepayRatio, triggerBoostRatio, targetBoostRatio, targetRepayRatio, boostEnabled, isEOA) {
|
|
288
748
|
return [
|
|
@@ -325,52 +785,70 @@ exports.compoundV3L2LeverageManagementSubData = {
|
|
|
325
785
|
return { targetRatio };
|
|
326
786
|
},
|
|
327
787
|
};
|
|
328
|
-
exports.
|
|
329
|
-
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);
|
|
330
796
|
return [
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
797
|
+
marketEncoded,
|
|
798
|
+
collTokenEncoded,
|
|
799
|
+
baseTokenEncoded,
|
|
800
|
+
targetRatioEncoded,
|
|
801
|
+
ratioStateEncoded,
|
|
802
|
+
userEncoded,
|
|
337
803
|
];
|
|
338
804
|
},
|
|
339
805
|
decode(subData) {
|
|
340
|
-
const
|
|
341
|
-
const
|
|
342
|
-
|
|
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
|
+
};
|
|
343
816
|
},
|
|
344
817
|
};
|
|
345
|
-
exports.
|
|
346
|
-
encode(
|
|
347
|
-
const
|
|
348
|
-
|
|
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
|
+
];
|
|
349
832
|
},
|
|
350
833
|
decode(subData) {
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
* @param chainId
|
|
360
|
-
*/
|
|
361
|
-
encode: (sourceId, sourceType, chainId = enums_1.ChainId.Ethereum) => {
|
|
362
|
-
const sourceIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', sourceId);
|
|
363
|
-
const sourceTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint256', sourceType);
|
|
364
|
-
const lusdAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', (0, tokens_1.getAssetInfo)('LUSD', chainId).address);
|
|
365
|
-
const bLusdAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', (0, tokens_1.getAssetInfo)('bLUSD', chainId).address);
|
|
366
|
-
return [sourceIdEncoded, sourceTypeEncoded, lusdAddressEncoded, bLusdAddressEncoded];
|
|
367
|
-
},
|
|
368
|
-
decode: (subData) => {
|
|
369
|
-
const sourceId = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]).toString();
|
|
370
|
-
const sourceType = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]).toString();
|
|
371
|
-
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
|
+
};
|
|
372
842
|
},
|
|
373
843
|
};
|
|
844
|
+
/**
|
|
845
|
+
__________ ___ ______ __ __ ___ .__ __. _______ _______
|
|
846
|
+
| ____\ \ / / / || | | | / \ | \ | | / _____|| ____|
|
|
847
|
+
| |__ \ V / | ,----'| |__| | / ^ \ | \| | | | __ | |__
|
|
848
|
+
| __| > < | | | __ | / /_\ \ | . ` | | | |_ | | __|
|
|
849
|
+
| |____ / . \ | `----.| | | | / _____ \ | |\ | | |__| | | |____
|
|
850
|
+
|_______/__/ \__\ \______||__| |__| /__/ \__\ |__| \__| \______| |_______|
|
|
851
|
+
*/
|
|
374
852
|
exports.exchangeDcaSubData = {
|
|
375
853
|
encode: (fromToken, toToken, amount, interval) => {
|
|
376
854
|
const sellTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', fromToken);
|
|
@@ -410,6 +888,14 @@ exports.exchangeLimitOrderSubData = {
|
|
|
410
888
|
return { fromToken, toToken, amount };
|
|
411
889
|
},
|
|
412
890
|
};
|
|
891
|
+
/**
|
|
892
|
+
_______..______ ___ .______ __ ___
|
|
893
|
+
/ || _ \ / \ | _ \ | |/ /
|
|
894
|
+
| (----`| |_) | / ^ \ | |_) | | ' /
|
|
895
|
+
\ \ | ___/ / /_\ \ | / | <
|
|
896
|
+
.----) | | | / _____ \ | |\ \----.| . \
|
|
897
|
+
|_______/ | _| /__/ \__\ | _| `._____||__|\__\
|
|
898
|
+
*/
|
|
413
899
|
exports.sparkLeverageManagementSubData = {
|
|
414
900
|
decode(subData) {
|
|
415
901
|
const ratioWei = web3_eth_abi_1.default.decodeParameter('uint256', subData[0]);
|
|
@@ -417,55 +903,60 @@ exports.sparkLeverageManagementSubData = {
|
|
|
417
903
|
return { targetRatio };
|
|
418
904
|
},
|
|
419
905
|
};
|
|
420
|
-
exports.
|
|
421
|
-
encode
|
|
422
|
-
const
|
|
423
|
-
const
|
|
424
|
-
const
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
const lusdAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', lusdAddress);
|
|
428
|
-
return [ratioStateEncoded, targetRatioEncoded, daiAddressEncoded, lusdAddressEncoded];
|
|
429
|
-
},
|
|
430
|
-
decode: (subData) => {
|
|
431
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
432
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
433
|
-
return { targetRatio };
|
|
434
|
-
},
|
|
435
|
-
};
|
|
436
|
-
exports.liquityDsrSupplySubData = {
|
|
437
|
-
encode: (targetRatio) => {
|
|
438
|
-
const daiAddress = (0, tokens_1.getAssetInfo)('DAI').address;
|
|
439
|
-
const wethAddress = (0, tokens_1.getAssetInfo)('WETH').address;
|
|
440
|
-
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', enums_1.RatioState.UNDER);
|
|
441
|
-
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
442
|
-
const daiAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', daiAddress);
|
|
443
|
-
const wethAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', wethAddress);
|
|
444
|
-
return [ratioStateEncoded, targetRatioEncoded, daiAddressEncoded, wethAddressEncoded];
|
|
906
|
+
exports.sparkLeverageManagementSubDataWithoutSubProxy = {
|
|
907
|
+
encode(targetRatio, ratioState) {
|
|
908
|
+
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
909
|
+
const encodedRatioState = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
910
|
+
const encodedUseDefaultMarket = web3_eth_abi_1.default.encodeParameter('bool', true);
|
|
911
|
+
const encodedUseOnBehalf = web3_eth_abi_1.default.encodeParameter('bool', false);
|
|
912
|
+
return [encodedTargetRatio, encodedRatioState, encodedUseDefaultMarket, encodedUseOnBehalf];
|
|
445
913
|
},
|
|
446
|
-
decode
|
|
447
|
-
const
|
|
448
|
-
const
|
|
449
|
-
return { targetRatio };
|
|
914
|
+
decode(subData) {
|
|
915
|
+
const targetRatio = (0, utils_1.weiToRatioPercentage)(web3_eth_abi_1.default.decodeParameter('uint256', subData[0]));
|
|
916
|
+
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[1]);
|
|
917
|
+
return { targetRatio, ratioState };
|
|
450
918
|
},
|
|
451
919
|
};
|
|
452
|
-
exports.
|
|
453
|
-
encode
|
|
454
|
-
const
|
|
455
|
-
const
|
|
456
|
-
const
|
|
457
|
-
const
|
|
458
|
-
const
|
|
459
|
-
const
|
|
460
|
-
const
|
|
461
|
-
return [
|
|
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
|
+
];
|
|
462
938
|
},
|
|
463
|
-
decode
|
|
464
|
-
const
|
|
465
|
-
const
|
|
466
|
-
|
|
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
|
+
};
|
|
467
950
|
},
|
|
468
951
|
};
|
|
952
|
+
/**
|
|
953
|
+
______ .______ ____ ____ __ __ _______. _______
|
|
954
|
+
/ || _ \ \ \ / / | | | | / || \
|
|
955
|
+
| ,----'| |_) | \ \/ / | | | | | (----`| .--. |
|
|
956
|
+
| | | / \ / | | | | \ \ | | | |
|
|
957
|
+
| `----.| |\ \----. \ / | `--' | .----) | | '--' |
|
|
958
|
+
\______|| _| `._____| \__/ \______/ |_______/ |_______/
|
|
959
|
+
*/
|
|
469
960
|
exports.crvUSDLeverageManagementSubData = {
|
|
470
961
|
encode: (controllerAddr, ratioState, targetRatio, collTokenAddr, crvUSDAddr) => {
|
|
471
962
|
const controllerAddrEncoded = web3_eth_abi_1.default.encodeParameter('address', controllerAddr);
|
|
@@ -511,6 +1002,14 @@ exports.crvUSDPaybackSubData = {
|
|
|
511
1002
|
};
|
|
512
1003
|
},
|
|
513
1004
|
};
|
|
1005
|
+
/**
|
|
1006
|
+
.___ ___. ______ .______ .______ __ __ ______
|
|
1007
|
+
| \/ | / __ \ | _ \ | _ \ | | | | / __ \
|
|
1008
|
+
| \ / | | | | | | |_) | | |_) | | |__| | | | | |
|
|
1009
|
+
| |\/| | | | | | | / | ___/ | __ | | | | |
|
|
1010
|
+
| | | | | `--' | | |\ \----.| | | | | | | `--' |
|
|
1011
|
+
|__| |__| \______/ | _| `._____|| _| |__| |__| \______/
|
|
1012
|
+
*/
|
|
514
1013
|
exports.morphoBlueLeverageManagementSubData = {
|
|
515
1014
|
encode: (loanToken, collToken, oracle, irm, lltv, ratioState, targetRatio, user, isEOA) => {
|
|
516
1015
|
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
@@ -544,141 +1043,6 @@ exports.morphoBlueLeverageManagementSubData = {
|
|
|
544
1043
|
};
|
|
545
1044
|
},
|
|
546
1045
|
};
|
|
547
|
-
exports.aaveV3LeverageManagementOnPriceSubData = {
|
|
548
|
-
encode(collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio) {
|
|
549
|
-
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
550
|
-
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint8', collAssetId);
|
|
551
|
-
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
552
|
-
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint8', debtAssetId);
|
|
553
|
-
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
554
|
-
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
555
|
-
const useOnBehalfEncoded = web3_eth_abi_1.default.encodeParameter('bool', false);
|
|
556
|
-
return [
|
|
557
|
-
encodedColl,
|
|
558
|
-
encodedCollId,
|
|
559
|
-
encodedDebt,
|
|
560
|
-
encodedDebtId,
|
|
561
|
-
encodedMarket,
|
|
562
|
-
encodedTargetRatio,
|
|
563
|
-
useOnBehalfEncoded,
|
|
564
|
-
];
|
|
565
|
-
},
|
|
566
|
-
decode(subData) {
|
|
567
|
-
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
568
|
-
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
569
|
-
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
570
|
-
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
571
|
-
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
572
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
573
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
574
|
-
return {
|
|
575
|
-
collAsset, collAssetId, debtAsset, debtAssetId, marketAddr, targetRatio,
|
|
576
|
-
};
|
|
577
|
-
},
|
|
578
|
-
};
|
|
579
|
-
exports.liquityV2LeverageManagementSubData = {
|
|
580
|
-
encode: (market, troveId, collToken, boldToken, ratioState, targetRatio) => {
|
|
581
|
-
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
582
|
-
const troveIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', troveId);
|
|
583
|
-
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
584
|
-
const boldTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', boldToken);
|
|
585
|
-
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
586
|
-
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
587
|
-
const isRepay = ratioState === enums_1.RatioState.UNDER;
|
|
588
|
-
const collActionType = isRepay ? enums_1.CollActionType.WITHDRAW : enums_1.CollActionType.SUPPLY;
|
|
589
|
-
const debtActionType = isRepay ? enums_1.DebtActionType.PAYBACK : enums_1.DebtActionType.BORROW;
|
|
590
|
-
const collActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
591
|
-
const debtActionTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
592
|
-
return [
|
|
593
|
-
marketEncoded,
|
|
594
|
-
troveIdEncoded,
|
|
595
|
-
collTokenEncoded,
|
|
596
|
-
boldTokenEncoded,
|
|
597
|
-
ratioStateEncoded,
|
|
598
|
-
targetRatioEncoded,
|
|
599
|
-
collActionTypeEncoded,
|
|
600
|
-
debtActionTypeEncoded,
|
|
601
|
-
];
|
|
602
|
-
},
|
|
603
|
-
decode: (subData) => {
|
|
604
|
-
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
605
|
-
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
606
|
-
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
607
|
-
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
608
|
-
const ratioState = web3_eth_abi_1.default.decodeParameter('uint8', subData[4]);
|
|
609
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[5]);
|
|
610
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
611
|
-
return {
|
|
612
|
-
market, troveId, collToken, boldToken, ratioState, targetRatio,
|
|
613
|
-
};
|
|
614
|
-
},
|
|
615
|
-
};
|
|
616
|
-
exports.liquityV2CloseSubData = {
|
|
617
|
-
encode(market, troveId, collToken, boldToken, closeType) {
|
|
618
|
-
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
619
|
-
const troveIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', troveId);
|
|
620
|
-
const collAddrEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
621
|
-
const boldTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', boldToken);
|
|
622
|
-
const wethAddress = (0, tokens_1.getAssetInfo)('WETH').address;
|
|
623
|
-
const wethAddressEncoded = web3_eth_abi_1.default.encodeParameter('address', wethAddress);
|
|
624
|
-
const gasCompensation = new decimal_js_1.default('0.0375').mul(1e18).toString();
|
|
625
|
-
const gasCompensationEncoded = web3_eth_abi_1.default.encodeParameter('uint256', gasCompensation);
|
|
626
|
-
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
627
|
-
return [
|
|
628
|
-
marketEncoded,
|
|
629
|
-
troveIdEncoded,
|
|
630
|
-
collAddrEncoded,
|
|
631
|
-
boldTokenEncoded,
|
|
632
|
-
wethAddressEncoded,
|
|
633
|
-
gasCompensationEncoded,
|
|
634
|
-
closeTypeEncoded,
|
|
635
|
-
];
|
|
636
|
-
},
|
|
637
|
-
decode(subData) {
|
|
638
|
-
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
639
|
-
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
640
|
-
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
641
|
-
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
642
|
-
// skip wethAddress and gasCompensation
|
|
643
|
-
const closeType = web3_eth_abi_1.default.decodeParameter('uint8', subData[6]);
|
|
644
|
-
return {
|
|
645
|
-
market, troveId, collToken, boldToken, closeType,
|
|
646
|
-
};
|
|
647
|
-
},
|
|
648
|
-
};
|
|
649
|
-
exports.liquityV2LeverageManagementOnPriceSubData = {
|
|
650
|
-
encode(market, troveId, collToken, boldToken, targetRatio, isRepayOnPrice) {
|
|
651
|
-
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
652
|
-
const encodedTroveId = web3_eth_abi_1.default.encodeParameter('uint256', troveId);
|
|
653
|
-
const encodedCollToken = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
654
|
-
const encodedBoldToken = web3_eth_abi_1.default.encodeParameter('address', boldToken);
|
|
655
|
-
const encodedTargetRatio = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
656
|
-
const collActionType = isRepayOnPrice ? enums_1.CollActionType.WITHDRAW : enums_1.CollActionType.SUPPLY;
|
|
657
|
-
const debtActionType = isRepayOnPrice ? enums_1.DebtActionType.PAYBACK : enums_1.DebtActionType.BORROW;
|
|
658
|
-
const encodedCollActionType = web3_eth_abi_1.default.encodeParameter('uint8', collActionType);
|
|
659
|
-
const encodedDebtActionType = web3_eth_abi_1.default.encodeParameter('uint8', debtActionType);
|
|
660
|
-
return [
|
|
661
|
-
encodedMarket,
|
|
662
|
-
encodedTroveId,
|
|
663
|
-
encodedCollToken,
|
|
664
|
-
encodedBoldToken,
|
|
665
|
-
encodedTargetRatio,
|
|
666
|
-
encodedCollActionType,
|
|
667
|
-
encodedDebtActionType,
|
|
668
|
-
];
|
|
669
|
-
},
|
|
670
|
-
decode(subData) {
|
|
671
|
-
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
672
|
-
const troveId = web3_eth_abi_1.default.decodeParameter('uint256', subData[1]);
|
|
673
|
-
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
674
|
-
const boldToken = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
675
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
676
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
677
|
-
return {
|
|
678
|
-
market, troveId, collToken, boldToken, targetRatio,
|
|
679
|
-
};
|
|
680
|
-
},
|
|
681
|
-
};
|
|
682
1046
|
exports.morphoBlueLeverageManagementOnPriceSubData = {
|
|
683
1047
|
encode(loanToken, collToken, oracle, irm, lltv, targetRatio, user) {
|
|
684
1048
|
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
@@ -710,33 +1074,44 @@ exports.morphoBlueLeverageManagementOnPriceSubData = {
|
|
|
710
1074
|
};
|
|
711
1075
|
},
|
|
712
1076
|
};
|
|
713
|
-
exports.
|
|
714
|
-
encode
|
|
715
|
-
const
|
|
716
|
-
const
|
|
717
|
-
const
|
|
718
|
-
const
|
|
719
|
-
const
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
boldTokenEncoded,
|
|
724
|
-
targetRatioEncoded,
|
|
725
|
-
ratioStateEncoded,
|
|
726
|
-
];
|
|
1077
|
+
exports.morphoBlueCloseOnPriceSubData = {
|
|
1078
|
+
encode(loanToken, collToken, oracle, irm, lltv, user, closeType) {
|
|
1079
|
+
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
1080
|
+
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
1081
|
+
const oracleEncoded = web3_eth_abi_1.default.encodeParameter('address', oracle);
|
|
1082
|
+
const irmEncoded = web3_eth_abi_1.default.encodeParameter('address', irm);
|
|
1083
|
+
const lltvEncoded = web3_eth_abi_1.default.encodeParameter('uint256', lltv);
|
|
1084
|
+
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
1085
|
+
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
1086
|
+
return [loanTokenEncoded, collTokenEncoded, oracleEncoded, irmEncoded, lltvEncoded, userEncoded, closeTypeEncoded];
|
|
727
1087
|
},
|
|
728
|
-
decode
|
|
729
|
-
const
|
|
730
|
-
const
|
|
731
|
-
const
|
|
732
|
-
const
|
|
733
|
-
const
|
|
734
|
-
const
|
|
1088
|
+
decode(subData) {
|
|
1089
|
+
const loanToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
1090
|
+
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
1091
|
+
const oracle = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
1092
|
+
const irm = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
1093
|
+
const lltv = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
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]));
|
|
735
1096
|
return {
|
|
736
|
-
|
|
1097
|
+
loanToken,
|
|
1098
|
+
collToken,
|
|
1099
|
+
oracle,
|
|
1100
|
+
irm,
|
|
1101
|
+
lltv,
|
|
1102
|
+
user,
|
|
1103
|
+
closeType,
|
|
737
1104
|
};
|
|
738
1105
|
},
|
|
739
1106
|
};
|
|
1107
|
+
/**
|
|
1108
|
+
_______ __ __ __ __ _______
|
|
1109
|
+
| ____|| | | | | | | | | \
|
|
1110
|
+
| |__ | | | | | | | | | .--. |
|
|
1111
|
+
| __| | | | | | | | | | | | |
|
|
1112
|
+
| | | `----.| `--' | | | | '--' |
|
|
1113
|
+
|__| |_______| \______/ |__| |_______/
|
|
1114
|
+
*/
|
|
740
1115
|
exports.fluidLeverageManagementSubData = {
|
|
741
1116
|
encode: (nftId, vault, ratioState, targetRatio) => {
|
|
742
1117
|
const nftIdEncoded = web3_eth_abi_1.default.encodeParameter('uint256', nftId);
|
|
@@ -770,121 +1145,3 @@ exports.fluidLeverageManagementSubData = {
|
|
|
770
1145
|
};
|
|
771
1146
|
},
|
|
772
1147
|
};
|
|
773
|
-
exports.compoundV3LeverageManagementOnPriceSubData = {
|
|
774
|
-
encode(market, collToken, baseToken, targetRatio, ratioState, user) {
|
|
775
|
-
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
776
|
-
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
777
|
-
const baseTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', baseToken);
|
|
778
|
-
const targetRatioEncoded = web3_eth_abi_1.default.encodeParameter('uint256', (0, utils_1.ratioPercentageToWei)(targetRatio));
|
|
779
|
-
const ratioStateEncoded = web3_eth_abi_1.default.encodeParameter('uint8', ratioState);
|
|
780
|
-
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
781
|
-
return [
|
|
782
|
-
marketEncoded,
|
|
783
|
-
collTokenEncoded,
|
|
784
|
-
baseTokenEncoded,
|
|
785
|
-
targetRatioEncoded,
|
|
786
|
-
ratioStateEncoded,
|
|
787
|
-
userEncoded,
|
|
788
|
-
];
|
|
789
|
-
},
|
|
790
|
-
decode(subData) {
|
|
791
|
-
const market = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
792
|
-
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
793
|
-
const baseToken = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
794
|
-
const weiRatio = web3_eth_abi_1.default.decodeParameter('uint256', subData[3]);
|
|
795
|
-
const targetRatio = (0, utils_1.weiToRatioPercentage)(weiRatio);
|
|
796
|
-
const ratioState = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[4]));
|
|
797
|
-
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
798
|
-
return {
|
|
799
|
-
market, collToken, baseToken, targetRatio, ratioState, owner,
|
|
800
|
-
};
|
|
801
|
-
},
|
|
802
|
-
};
|
|
803
|
-
exports.compoundV3CloseSubData = {
|
|
804
|
-
encode(market, collToken, baseToken, closeType, user) {
|
|
805
|
-
const marketEncoded = web3_eth_abi_1.default.encodeParameter('address', market);
|
|
806
|
-
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
807
|
-
const baseTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', baseToken);
|
|
808
|
-
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
809
|
-
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
810
|
-
return [
|
|
811
|
-
marketEncoded,
|
|
812
|
-
collTokenEncoded,
|
|
813
|
-
baseTokenEncoded,
|
|
814
|
-
closeTypeEncoded,
|
|
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 closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
823
|
-
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[4]);
|
|
824
|
-
return {
|
|
825
|
-
market, collToken, baseToken, closeType, owner,
|
|
826
|
-
};
|
|
827
|
-
},
|
|
828
|
-
};
|
|
829
|
-
exports.sparkCloseGenericSubData = {
|
|
830
|
-
encode(collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, user) {
|
|
831
|
-
const encodedColl = web3_eth_abi_1.default.encodeParameter('address', collAsset);
|
|
832
|
-
const encodedCollId = web3_eth_abi_1.default.encodeParameter('uint8', collAssetId);
|
|
833
|
-
const encodedDebt = web3_eth_abi_1.default.encodeParameter('address', debtAsset);
|
|
834
|
-
const encodedDebtId = web3_eth_abi_1.default.encodeParameter('uint8', debtAssetId);
|
|
835
|
-
const encodedCloseType = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
836
|
-
const encodedMarket = web3_eth_abi_1.default.encodeParameter('address', marketAddr);
|
|
837
|
-
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
838
|
-
return [
|
|
839
|
-
encodedColl,
|
|
840
|
-
encodedCollId,
|
|
841
|
-
encodedDebt,
|
|
842
|
-
encodedDebtId,
|
|
843
|
-
encodedCloseType,
|
|
844
|
-
encodedMarket,
|
|
845
|
-
userEncoded,
|
|
846
|
-
];
|
|
847
|
-
},
|
|
848
|
-
decode(subData) {
|
|
849
|
-
const collAsset = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
850
|
-
const collAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[1]));
|
|
851
|
-
const debtAsset = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
852
|
-
const debtAssetId = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[3]));
|
|
853
|
-
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[4]));
|
|
854
|
-
const marketAddr = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
855
|
-
const owner = web3_eth_abi_1.default.decodeParameter('address', subData[6]);
|
|
856
|
-
return {
|
|
857
|
-
collAsset, collAssetId, debtAsset, debtAssetId, closeType, marketAddr, owner,
|
|
858
|
-
};
|
|
859
|
-
},
|
|
860
|
-
};
|
|
861
|
-
exports.morphoBlueCloseOnPriceSubData = {
|
|
862
|
-
encode(loanToken, collToken, oracle, irm, lltv, user, closeType) {
|
|
863
|
-
const loanTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', loanToken);
|
|
864
|
-
const collTokenEncoded = web3_eth_abi_1.default.encodeParameter('address', collToken);
|
|
865
|
-
const oracleEncoded = web3_eth_abi_1.default.encodeParameter('address', oracle);
|
|
866
|
-
const irmEncoded = web3_eth_abi_1.default.encodeParameter('address', irm);
|
|
867
|
-
const lltvEncoded = web3_eth_abi_1.default.encodeParameter('uint256', lltv);
|
|
868
|
-
const userEncoded = web3_eth_abi_1.default.encodeParameter('address', user);
|
|
869
|
-
const closeTypeEncoded = web3_eth_abi_1.default.encodeParameter('uint8', closeType);
|
|
870
|
-
return [loanTokenEncoded, collTokenEncoded, oracleEncoded, irmEncoded, lltvEncoded, userEncoded, closeTypeEncoded];
|
|
871
|
-
},
|
|
872
|
-
decode(subData) {
|
|
873
|
-
const loanToken = web3_eth_abi_1.default.decodeParameter('address', subData[0]);
|
|
874
|
-
const collToken = web3_eth_abi_1.default.decodeParameter('address', subData[1]);
|
|
875
|
-
const oracle = web3_eth_abi_1.default.decodeParameter('address', subData[2]);
|
|
876
|
-
const irm = web3_eth_abi_1.default.decodeParameter('address', subData[3]);
|
|
877
|
-
const lltv = web3_eth_abi_1.default.decodeParameter('uint256', subData[4]);
|
|
878
|
-
const user = web3_eth_abi_1.default.decodeParameter('address', subData[5]);
|
|
879
|
-
const closeType = Number(web3_eth_abi_1.default.decodeParameter('uint8', subData[6]));
|
|
880
|
-
return {
|
|
881
|
-
loanToken,
|
|
882
|
-
collToken,
|
|
883
|
-
oracle,
|
|
884
|
-
irm,
|
|
885
|
-
lltv,
|
|
886
|
-
user,
|
|
887
|
-
closeType,
|
|
888
|
-
};
|
|
889
|
-
},
|
|
890
|
-
};
|