@defisaver/automation-sdk 3.1.9 → 3.1.14-spark-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/.babelrc +3 -3
- package/.editorconfig +9 -9
- package/.env.dev +4 -4
- package/.eslintignore +6 -6
- package/.eslintrc.js +39 -39
- package/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/README.md +46 -46
- package/cjs/abis/Erc20.json +223 -223
- package/cjs/abis/SubStorage.json +21 -21
- package/cjs/abis/UniMulticall.json +17 -17
- package/cjs/abis/index.d.ts +9 -9
- package/cjs/abis/index.js +30 -30
- package/cjs/abis/legacy_AaveV2Subscriptions.json +8 -8
- package/cjs/abis/legacy_AuthCheck.json +8 -8
- package/cjs/abis/legacy_CompoundV2Subscriptions.json +9 -9
- package/cjs/abis/legacy_MakerSubscriptions.json +9 -9
- package/cjs/automation/private/Automation.d.ts +12 -12
- package/cjs/automation/private/Automation.js +42 -42
- package/cjs/automation/private/LegacyAutomation.d.ts +25 -25
- package/cjs/automation/private/LegacyAutomation.js +118 -118
- package/cjs/automation/private/LegacyProtocol.d.ts +22 -22
- package/cjs/automation/private/LegacyProtocol.js +41 -41
- package/cjs/automation/private/LegacyProtocol.test.d.ts +1 -1
- package/cjs/automation/private/LegacyProtocol.test.js +25 -25
- package/cjs/automation/private/Protocol.d.ts +22 -22
- package/cjs/automation/private/Protocol.js +41 -41
- package/cjs/automation/private/Protocol.test.d.ts +1 -1
- package/cjs/automation/private/Protocol.test.js +25 -25
- package/cjs/automation/private/StrategiesAutomation.d.ts +35 -33
- package/cjs/automation/private/StrategiesAutomation.js +198 -181
- package/cjs/automation/private/StrategiesAutomation.test.d.ts +1 -1
- package/cjs/automation/private/StrategiesAutomation.test.js +696 -671
- package/cjs/automation/public/ArbitrumStrategies.d.ts +5 -5
- package/cjs/automation/public/ArbitrumStrategies.js +13 -13
- package/cjs/automation/public/BaseStrategies.d.ts +5 -5
- package/cjs/automation/public/BaseStrategies.js +13 -13
- package/cjs/automation/public/EthereumStrategies.d.ts +5 -5
- package/cjs/automation/public/EthereumStrategies.js +13 -13
- package/cjs/automation/public/OptimismStrategies.d.ts +5 -5
- package/cjs/automation/public/OptimismStrategies.js +13 -13
- package/cjs/automation/public/Strategies.test.d.ts +1 -1
- package/cjs/automation/public/Strategies.test.js +61 -61
- package/cjs/automation/public/legacy/LegacyAaveAutomation.d.ts +6 -6
- package/cjs/automation/public/legacy/LegacyAaveAutomation.js +20 -20
- package/cjs/automation/public/legacy/LegacyCompoundAutomation.d.ts +6 -6
- package/cjs/automation/public/legacy/LegacyCompoundAutomation.js +20 -20
- package/cjs/automation/public/legacy/LegacyMakerAutomation.d.ts +6 -6
- package/cjs/automation/public/legacy/LegacyMakerAutomation.js +20 -20
- package/cjs/configuration.d.ts +1 -1
- package/cjs/configuration.js +12 -12
- package/cjs/constants/index.d.ts +29 -28
- package/cjs/constants/index.js +905 -534
- package/cjs/index.d.ts +24 -23
- package/cjs/index.js +65 -65
- package/cjs/services/contractService.d.ts +12 -12
- package/cjs/services/contractService.js +54 -54
- package/cjs/services/ethereumService.d.ts +7 -7
- package/cjs/services/ethereumService.js +56 -49
- package/cjs/services/ethereumService.test.d.ts +1 -1
- package/cjs/services/ethereumService.test.js +245 -242
- package/cjs/services/strategiesService.d.ts +2 -2
- package/cjs/services/strategiesService.js +1173 -861
- package/cjs/services/strategiesService.test.d.ts +1 -1
- package/cjs/services/strategiesService.test.js +111 -110
- package/cjs/services/strategySubService.d.ts +129 -107
- package/cjs/services/strategySubService.js +414 -300
- package/cjs/services/strategySubService.test.d.ts +1 -1
- package/cjs/services/strategySubService.test.js +1812 -936
- package/cjs/services/subDataService.d.ts +527 -245
- package/cjs/services/subDataService.js +1219 -636
- package/cjs/services/subDataService.test.d.ts +1 -1
- package/cjs/services/subDataService.test.js +2427 -1282
- package/cjs/services/triggerService.d.ts +325 -226
- package/cjs/services/triggerService.js +616 -433
- package/cjs/services/triggerService.test.d.ts +1 -1
- package/cjs/services/triggerService.test.js +1317 -926
- package/cjs/services/utils.d.ts +30 -30
- package/cjs/services/utils.js +190 -182
- package/cjs/services/utils.test.d.ts +1 -1
- package/cjs/services/utils.test.js +299 -376
- package/cjs/types/contracts/generated/Erc20.d.ts +53 -53
- package/cjs/types/contracts/generated/Erc20.js +5 -5
- package/cjs/types/contracts/generated/Legacy_AaveV2Subscriptions.d.ts +129 -129
- package/cjs/types/contracts/generated/Legacy_AaveV2Subscriptions.js +5 -5
- package/cjs/types/contracts/generated/Legacy_AuthCheck.d.ts +20 -20
- package/cjs/types/contracts/generated/Legacy_AuthCheck.js +5 -5
- package/cjs/types/contracts/generated/Legacy_CompoundV2Subscriptions.d.ts +128 -128
- package/cjs/types/contracts/generated/Legacy_CompoundV2Subscriptions.js +5 -5
- package/cjs/types/contracts/generated/Legacy_MakerSubscriptions.d.ts +246 -246
- package/cjs/types/contracts/generated/Legacy_MakerSubscriptions.js +5 -5
- package/cjs/types/contracts/generated/SubStorage.d.ts +114 -114
- package/cjs/types/contracts/generated/SubStorage.js +5 -5
- package/cjs/types/contracts/generated/UniMulticall.d.ts +55 -55
- package/cjs/types/contracts/generated/UniMulticall.js +5 -5
- package/cjs/types/contracts/generated/index.d.ts +7 -7
- package/cjs/types/contracts/generated/index.js +2 -2
- package/cjs/types/contracts/generated/types.d.ts +54 -54
- package/cjs/types/contracts/generated/types.js +2 -2
- package/cjs/types/enums.d.ts +302 -219
- package/cjs/types/enums.js +328 -245
- package/cjs/types/index.d.ts +306 -248
- package/cjs/types/index.js +2 -2
- package/esm/abis/Erc20.json +223 -223
- package/esm/abis/SubStorage.json +21 -21
- package/esm/abis/UniMulticall.json +17 -17
- package/esm/abis/index.d.ts +9 -9
- package/esm/abis/index.js +18 -18
- package/esm/abis/legacy_AaveV2Subscriptions.json +8 -8
- package/esm/abis/legacy_AuthCheck.json +8 -8
- package/esm/abis/legacy_CompoundV2Subscriptions.json +9 -9
- package/esm/abis/legacy_MakerSubscriptions.json +9 -9
- package/esm/automation/private/Automation.d.ts +12 -12
- package/esm/automation/private/Automation.js +39 -39
- package/esm/automation/private/LegacyAutomation.d.ts +25 -25
- package/esm/automation/private/LegacyAutomation.js +112 -112
- package/esm/automation/private/LegacyProtocol.d.ts +22 -22
- package/esm/automation/private/LegacyProtocol.js +38 -38
- package/esm/automation/private/LegacyProtocol.test.d.ts +1 -1
- package/esm/automation/private/LegacyProtocol.test.js +20 -20
- package/esm/automation/private/Protocol.d.ts +22 -22
- package/esm/automation/private/Protocol.js +38 -38
- package/esm/automation/private/Protocol.test.d.ts +1 -1
- package/esm/automation/private/Protocol.test.js +20 -20
- package/esm/automation/private/StrategiesAutomation.d.ts +35 -33
- package/esm/automation/private/StrategiesAutomation.js +192 -175
- package/esm/automation/private/StrategiesAutomation.test.d.ts +1 -1
- package/esm/automation/private/StrategiesAutomation.test.js +691 -666
- package/esm/automation/public/ArbitrumStrategies.d.ts +5 -5
- package/esm/automation/public/ArbitrumStrategies.js +7 -7
- package/esm/automation/public/BaseStrategies.d.ts +5 -5
- package/esm/automation/public/BaseStrategies.js +7 -7
- package/esm/automation/public/EthereumStrategies.d.ts +5 -5
- package/esm/automation/public/EthereumStrategies.js +7 -7
- package/esm/automation/public/OptimismStrategies.d.ts +5 -5
- package/esm/automation/public/OptimismStrategies.js +7 -7
- package/esm/automation/public/Strategies.test.d.ts +1 -1
- package/esm/automation/public/Strategies.test.js +56 -56
- package/esm/automation/public/legacy/LegacyAaveAutomation.d.ts +6 -6
- package/esm/automation/public/legacy/LegacyAaveAutomation.js +14 -14
- package/esm/automation/public/legacy/LegacyCompoundAutomation.d.ts +6 -6
- package/esm/automation/public/legacy/LegacyCompoundAutomation.js +14 -14
- package/esm/automation/public/legacy/LegacyMakerAutomation.d.ts +6 -6
- package/esm/automation/public/legacy/LegacyMakerAutomation.js +14 -14
- package/esm/configuration.d.ts +1 -1
- package/esm/configuration.js +7 -7
- package/esm/constants/index.d.ts +29 -28
- package/esm/constants/index.js +899 -528
- package/esm/index.d.ts +24 -23
- package/esm/index.js +23 -23
- package/esm/services/contractService.d.ts +12 -12
- package/esm/services/contractService.js +45 -45
- package/esm/services/ethereumService.d.ts +7 -7
- package/esm/services/ethereumService.js +48 -41
- package/esm/services/ethereumService.test.d.ts +1 -1
- package/esm/services/ethereumService.test.js +240 -237
- package/esm/services/strategiesService.d.ts +2 -2
- package/esm/services/strategiesService.js +1143 -831
- package/esm/services/strategiesService.test.d.ts +1 -1
- package/esm/services/strategiesService.test.js +109 -108
- package/esm/services/strategySubService.d.ts +129 -107
- package/esm/services/strategySubService.js +385 -271
- package/esm/services/strategySubService.test.d.ts +1 -1
- package/esm/services/strategySubService.test.js +1784 -908
- package/esm/services/subDataService.d.ts +527 -245
- package/esm/services/subDataService.js +1213 -630
- package/esm/services/subDataService.test.d.ts +1 -1
- package/esm/services/subDataService.test.js +2399 -1254
- package/esm/services/triggerService.d.ts +325 -226
- package/esm/services/triggerService.js +587 -404
- package/esm/services/triggerService.test.d.ts +1 -1
- package/esm/services/triggerService.test.js +1292 -901
- package/esm/services/utils.d.ts +30 -30
- package/esm/services/utils.js +139 -131
- package/esm/services/utils.test.d.ts +1 -1
- package/esm/services/utils.test.js +297 -348
- package/esm/types/contracts/generated/Erc20.d.ts +53 -53
- package/esm/types/contracts/generated/Erc20.js +4 -4
- package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.d.ts +129 -129
- package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.js +4 -4
- package/esm/types/contracts/generated/Legacy_AuthCheck.d.ts +20 -20
- package/esm/types/contracts/generated/Legacy_AuthCheck.js +4 -4
- package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.d.ts +128 -128
- package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.js +4 -4
- package/esm/types/contracts/generated/Legacy_MakerSubscriptions.d.ts +246 -246
- package/esm/types/contracts/generated/Legacy_MakerSubscriptions.js +4 -4
- package/esm/types/contracts/generated/SubStorage.d.ts +114 -114
- package/esm/types/contracts/generated/SubStorage.js +4 -4
- package/esm/types/contracts/generated/UniMulticall.d.ts +55 -55
- package/esm/types/contracts/generated/UniMulticall.js +4 -4
- package/esm/types/contracts/generated/index.d.ts +7 -7
- package/esm/types/contracts/generated/index.js +1 -1
- package/esm/types/contracts/generated/types.d.ts +54 -54
- package/esm/types/contracts/generated/types.js +1 -1
- package/esm/types/enums.d.ts +302 -219
- package/esm/types/enums.js +325 -242
- package/esm/types/index.d.ts +306 -248
- package/esm/types/index.js +1 -1
- package/package.json +60 -61
- package/scripts/generateContractTypes.js +39 -39
- package/src/abis/Erc20.json +222 -222
- package/src/abis/SubStorage.json +21 -21
- package/src/abis/UniMulticall.json +17 -17
- package/src/abis/index.ts +28 -28
- package/src/abis/legacy_AaveV2Subscriptions.json +7 -7
- package/src/abis/legacy_AuthCheck.json +7 -7
- package/src/abis/legacy_CompoundV2Subscriptions.json +8 -8
- package/src/abis/legacy_MakerSubscriptions.json +8 -8
- package/src/automation/private/Automation.ts +44 -44
- package/src/automation/private/LegacyAutomation.ts +135 -135
- package/src/automation/private/LegacyProtocol.test.ts +23 -23
- package/src/automation/private/LegacyProtocol.ts +51 -51
- package/src/automation/private/Protocol.test.ts +23 -23
- package/src/automation/private/Protocol.ts +51 -51
- package/src/automation/private/StrategiesAutomation.test.ts +703 -663
- package/src/automation/private/StrategiesAutomation.ts +265 -242
- package/src/automation/public/ArbitrumStrategies.ts +10 -10
- package/src/automation/public/BaseStrategies.ts +10 -10
- package/src/automation/public/EthereumStrategies.ts +10 -10
- package/src/automation/public/OptimismStrategies.ts +10 -10
- package/src/automation/public/Strategies.test.ts +49 -49
- package/src/automation/public/legacy/LegacyAaveAutomation.ts +20 -20
- package/src/automation/public/legacy/LegacyCompoundAutomation.ts +20 -20
- package/src/automation/public/legacy/LegacyMakerAutomation.ts +20 -20
- package/src/configuration.ts +8 -8
- package/src/constants/index.ts +935 -563
- package/src/index.ts +41 -39
- package/src/services/contractService.ts +77 -77
- package/src/services/ethereumService.test.ts +260 -257
- package/src/services/ethereumService.ts +76 -69
- package/src/services/strategiesService.test.ts +106 -105
- package/src/services/strategiesService.ts +1473 -1111
- package/src/services/strategySubService.test.ts +2136 -1122
- package/src/services/strategySubService.ts +987 -617
- package/src/services/subDataService.test.ts +2630 -1387
- package/src/services/subDataService.ts +1631 -870
- package/src/services/triggerService.test.ts +1434 -1004
- package/src/services/triggerService.ts +819 -553
- package/src/services/utils.test.ts +371 -430
- package/src/services/utils.ts +173 -162
- package/src/types/enums.ts +322 -239
- package/src/types/index.ts +385 -312
- package/tsconfig.esm.json +8 -8
- package/tsconfig.json +22 -22
- package/umd/index.js +0 -34103
|
@@ -1,1282 +1,2427 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
30
|
-
const chai_1 = require("chai");
|
|
31
|
-
const tokens_1 = require("@defisaver/tokens");
|
|
32
|
-
const web3Utils = __importStar(require("web3-utils"));
|
|
33
|
-
const
|
|
34
|
-
require("../
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
'
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
'
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
'0x0000000000000000000000000000000000000000000000000000000000000000', '
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
'
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
'
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
'
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
'
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
'
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
[
|
|
172
|
-
'
|
|
173
|
-
'
|
|
174
|
-
],
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
[
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
(0,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
[
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
})
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
[
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
'
|
|
447
|
-
'
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
[
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
[
|
|
542
|
-
'
|
|
543
|
-
'
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
[
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
'
|
|
567
|
-
'
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
'
|
|
591
|
-
'
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
[
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
'
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
'
|
|
667
|
-
'
|
|
668
|
-
'
|
|
669
|
-
|
|
670
|
-
],
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
],
|
|
689
|
-
[
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
examples
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
]
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
[
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
]
|
|
790
|
-
],
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
],
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
[
|
|
843
|
-
],
|
|
844
|
-
[
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
[
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
[
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
'
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
],
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
'
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
'
|
|
946
|
-
|
|
947
|
-
[
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
'
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
'
|
|
1002
|
-
'
|
|
1003
|
-
'
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
[
|
|
1009
|
-
'
|
|
1010
|
-
'
|
|
1011
|
-
'
|
|
1012
|
-
'
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
],
|
|
1017
|
-
];
|
|
1018
|
-
examples.forEach(([expected, actual]) => {
|
|
1019
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1020
|
-
(0, chai_1.expect)(
|
|
1021
|
-
});
|
|
1022
|
-
});
|
|
1023
|
-
});
|
|
1024
|
-
describe('decode()', () => {
|
|
1025
|
-
const examples = [
|
|
1026
|
-
[
|
|
1027
|
-
{
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
],
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1146
|
-
'
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
'
|
|
1191
|
-
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1192
|
-
'
|
|
1193
|
-
|
|
1194
|
-
]
|
|
1195
|
-
],
|
|
1196
|
-
[
|
|
1197
|
-
|
|
1198
|
-
'
|
|
1199
|
-
'
|
|
1200
|
-
'
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
'
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
30
|
+
const chai_1 = require("chai");
|
|
31
|
+
const tokens_1 = require("@defisaver/tokens");
|
|
32
|
+
const web3Utils = __importStar(require("web3-utils"));
|
|
33
|
+
const tokens_2 = require("@defisaver/tokens");
|
|
34
|
+
const enums_1 = require("../types/enums");
|
|
35
|
+
require("../configuration");
|
|
36
|
+
const subDataService = __importStar(require("./subDataService"));
|
|
37
|
+
describe('Feature: subDataService.ts', () => {
|
|
38
|
+
describe('When testing subDataService.makerRepayFromSavingsSubData', () => {
|
|
39
|
+
describe('encode()', () => {
|
|
40
|
+
const examples = [
|
|
41
|
+
[
|
|
42
|
+
[
|
|
43
|
+
'0x000000000000000000000000000000000000000000000000000000000000007b', '0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
44
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
45
|
+
],
|
|
46
|
+
[123, 120, enums_1.ChainId.Ethereum, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address), web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e')]
|
|
47
|
+
],
|
|
48
|
+
];
|
|
49
|
+
examples.forEach(([expected, actual]) => {
|
|
50
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
51
|
+
(0, chai_1.expect)(subDataService.makerRepayFromSavingsSubData.encode(...actual)).to.eql(expected);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('decode()', () => {
|
|
56
|
+
const examples = [
|
|
57
|
+
[
|
|
58
|
+
{
|
|
59
|
+
vaultId: 123,
|
|
60
|
+
daiAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
61
|
+
mcdManagerAddr: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
62
|
+
targetRatio: 120,
|
|
63
|
+
},
|
|
64
|
+
[
|
|
65
|
+
'0x000000000000000000000000000000000000000000000000000000000000007b', '0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
66
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
67
|
+
],
|
|
68
|
+
],
|
|
69
|
+
];
|
|
70
|
+
examples.forEach(([expected, actual]) => {
|
|
71
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
72
|
+
(0, chai_1.expect)(subDataService.makerRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
describe('When testing subDataService.liquityRepayFromSavingsSubData', () => {
|
|
78
|
+
describe('decode()', () => {
|
|
79
|
+
const examples = [
|
|
80
|
+
[
|
|
81
|
+
{ targetRatio: 120 },
|
|
82
|
+
[
|
|
83
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
84
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
85
|
+
],
|
|
86
|
+
],
|
|
87
|
+
];
|
|
88
|
+
examples.forEach(([expected, actual]) => {
|
|
89
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
90
|
+
(0, chai_1.expect)(subDataService.liquityRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
describe('When testing subDataService.makerCloseSubData', () => {
|
|
96
|
+
describe('encode()', () => {
|
|
97
|
+
const examples = [
|
|
98
|
+
[
|
|
99
|
+
[
|
|
100
|
+
'0x0000000000000000000000000000000000000000000000000000000000000141', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
101
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
102
|
+
],
|
|
103
|
+
[321, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address), enums_1.ChainId.Ethereum, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address), web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e')]
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
[
|
|
107
|
+
'0x00000000000000000000000000000000000000000000000000000000000001a4', '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
108
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002439d218133afab8f2b819b1066c7e434ad94e9e',
|
|
109
|
+
],
|
|
110
|
+
[420, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address), enums_1.ChainId.Ethereum, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address), web3Utils.toChecksumAddress('0x2439d218133AFaB8F2B819B1066c7E434Ad94E9e')]
|
|
111
|
+
],
|
|
112
|
+
];
|
|
113
|
+
examples.forEach(([expected, actual]) => {
|
|
114
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
115
|
+
(0, chai_1.expect)(subDataService.makerCloseSubData.encode(...actual)).to.eql(expected);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
describe('decode()', () => {
|
|
120
|
+
const examples = [
|
|
121
|
+
[
|
|
122
|
+
{
|
|
123
|
+
vaultId: 321,
|
|
124
|
+
closeToAssetAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
125
|
+
},
|
|
126
|
+
[
|
|
127
|
+
'0x0000000000000000000000000000000000000000000000000000000000000141', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
128
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
129
|
+
],
|
|
130
|
+
],
|
|
131
|
+
[
|
|
132
|
+
{
|
|
133
|
+
vaultId: 420,
|
|
134
|
+
closeToAssetAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
135
|
+
},
|
|
136
|
+
[
|
|
137
|
+
'0x00000000000000000000000000000000000000000000000000000000000001a4', '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
138
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002439d218133afab8f2b819b1066c7e434ad94e9e',
|
|
139
|
+
],
|
|
140
|
+
],
|
|
141
|
+
];
|
|
142
|
+
examples.forEach(([expected, actual]) => {
|
|
143
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
144
|
+
(0, chai_1.expect)(subDataService.makerCloseSubData.decode(actual)).to.eql(expected);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
describe('When testing subDataService.makerLeverageManagementSubData', () => {
|
|
150
|
+
describe('decode()', () => {
|
|
151
|
+
const examples = [
|
|
152
|
+
[
|
|
153
|
+
{ vaultId: 321, targetRatio: 200 },
|
|
154
|
+
[
|
|
155
|
+
'0x0000000000000000000000000000000000000000000000000000000000000141', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
156
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
157
|
+
],
|
|
158
|
+
],
|
|
159
|
+
];
|
|
160
|
+
examples.forEach(([expected, actual]) => {
|
|
161
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
162
|
+
(0, chai_1.expect)(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
describe('When testing subDataService.makerLeverageManagementWithoutSubProxy', () => {
|
|
168
|
+
describe('encode()', () => {
|
|
169
|
+
const examples = [
|
|
170
|
+
[
|
|
171
|
+
[
|
|
172
|
+
'0x00000000000000000000000000000000000000000000000000000000000000de', '0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
173
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
174
|
+
],
|
|
175
|
+
[222, 180], // Uses default DAI address
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
[
|
|
179
|
+
'0x000000000000000000000000000000000000000000000000000000000000014d', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
180
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
181
|
+
],
|
|
182
|
+
[333, 200, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address)], // Custom address
|
|
183
|
+
],
|
|
184
|
+
];
|
|
185
|
+
examples.forEach(([expected, actual]) => {
|
|
186
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
187
|
+
(0, chai_1.expect)(subDataService.makerLeverageManagementWithoutSubProxy.encode(...actual)).to.eql(expected);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
describe('decode()', () => {
|
|
192
|
+
const examples = [
|
|
193
|
+
[
|
|
194
|
+
{
|
|
195
|
+
vaultId: 222,
|
|
196
|
+
targetRatio: 180,
|
|
197
|
+
daiAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
198
|
+
},
|
|
199
|
+
[
|
|
200
|
+
'0x00000000000000000000000000000000000000000000000000000000000000de', '0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
201
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
202
|
+
],
|
|
203
|
+
],
|
|
204
|
+
[
|
|
205
|
+
{
|
|
206
|
+
vaultId: 333,
|
|
207
|
+
targetRatio: 200,
|
|
208
|
+
daiAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
209
|
+
},
|
|
210
|
+
[
|
|
211
|
+
'0x000000000000000000000000000000000000000000000000000000000000014d', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
212
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
213
|
+
],
|
|
214
|
+
],
|
|
215
|
+
];
|
|
216
|
+
examples.forEach(([expected, actual]) => {
|
|
217
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
218
|
+
(0, chai_1.expect)(subDataService.makerLeverageManagementWithoutSubProxy.decode(actual)).to.eql(expected);
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
describe('When testing subDataService.liquityLeverageManagementSubData', () => {
|
|
224
|
+
describe('decode()', () => {
|
|
225
|
+
const examples = [
|
|
226
|
+
[
|
|
227
|
+
{ targetRatio: 200 },
|
|
228
|
+
[
|
|
229
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
230
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
231
|
+
],
|
|
232
|
+
],
|
|
233
|
+
];
|
|
234
|
+
examples.forEach(([expected, actual]) => {
|
|
235
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
236
|
+
(0, chai_1.expect)(subDataService.liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
describe('When testing subDataService.liquityCloseSubData', () => {
|
|
242
|
+
describe('encode()', () => {
|
|
243
|
+
const examples = [
|
|
244
|
+
[
|
|
245
|
+
[
|
|
246
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
247
|
+
],
|
|
248
|
+
[web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LUSD', enums_1.ChainId.Ethereum).address), enums_1.ChainId.Ethereum, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address), web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LUSD', enums_1.ChainId.Ethereum).address)]
|
|
249
|
+
],
|
|
250
|
+
[
|
|
251
|
+
[
|
|
252
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
253
|
+
],
|
|
254
|
+
[web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LUSD', enums_1.ChainId.Ethereum).address), enums_1.ChainId.Ethereum]
|
|
255
|
+
],
|
|
256
|
+
];
|
|
257
|
+
examples.forEach(([expected, actual]) => {
|
|
258
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
259
|
+
(0, chai_1.expect)(subDataService.liquityCloseSubData.encode(...actual)).to.eql(expected);
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
describe('decode()', () => {
|
|
264
|
+
const examples = [
|
|
265
|
+
[
|
|
266
|
+
{
|
|
267
|
+
closeToAssetAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LUSD', enums_1.ChainId.Ethereum).address),
|
|
268
|
+
debtAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LUSD', enums_1.ChainId.Ethereum).address),
|
|
269
|
+
},
|
|
270
|
+
[
|
|
271
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
272
|
+
],
|
|
273
|
+
],
|
|
274
|
+
[
|
|
275
|
+
{
|
|
276
|
+
closeToAssetAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
277
|
+
debtAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LUSD', enums_1.ChainId.Ethereum).address),
|
|
278
|
+
},
|
|
279
|
+
[
|
|
280
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
281
|
+
],
|
|
282
|
+
],
|
|
283
|
+
];
|
|
284
|
+
examples.forEach(([expected, actual]) => {
|
|
285
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
286
|
+
(0, chai_1.expect)(subDataService.liquityCloseSubData.decode(actual)).to.eql(expected);
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
describe('When testing subDataService.aaveV2LeverageManagementSubData', () => {
|
|
292
|
+
describe('encode()', () => {
|
|
293
|
+
const examples = [
|
|
294
|
+
[
|
|
295
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
296
|
+
[160, 220, 180, 190, true]
|
|
297
|
+
],
|
|
298
|
+
[
|
|
299
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
300
|
+
[160, 200, 180, 190, false]
|
|
301
|
+
],
|
|
302
|
+
];
|
|
303
|
+
examples.forEach(([expected, actual]) => {
|
|
304
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
305
|
+
(0, chai_1.expect)(subDataService.aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
describe('decode()', () => {
|
|
310
|
+
const examples = [
|
|
311
|
+
[
|
|
312
|
+
{ targetRatio: 200 },
|
|
313
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
314
|
+
],
|
|
315
|
+
[
|
|
316
|
+
{ targetRatio: 123 },
|
|
317
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
318
|
+
],
|
|
319
|
+
];
|
|
320
|
+
examples.forEach(([expected, actual]) => {
|
|
321
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
322
|
+
(0, chai_1.expect)(subDataService.aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
describe('When testing subDataService.aaveV3LeverageManagementSubData', () => {
|
|
328
|
+
describe('decode()', () => {
|
|
329
|
+
const examples = [
|
|
330
|
+
[
|
|
331
|
+
{ targetRatio: 200 },
|
|
332
|
+
['0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
333
|
+
],
|
|
334
|
+
[
|
|
335
|
+
{ targetRatio: 123 },
|
|
336
|
+
['0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
337
|
+
],
|
|
338
|
+
];
|
|
339
|
+
examples.forEach(([expected, actual]) => {
|
|
340
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
341
|
+
(0, chai_1.expect)(subDataService.aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
describe('When testing subDataService.aaveV3QuotePriceSubData', () => {
|
|
347
|
+
describe('encode()', () => {
|
|
348
|
+
const examples = [
|
|
349
|
+
[
|
|
350
|
+
[
|
|
351
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
352
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
353
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
354
|
+
],
|
|
355
|
+
[
|
|
356
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
357
|
+
2,
|
|
358
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
359
|
+
4,
|
|
360
|
+
]
|
|
361
|
+
],
|
|
362
|
+
[
|
|
363
|
+
[
|
|
364
|
+
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
365
|
+
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
366
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
367
|
+
],
|
|
368
|
+
[
|
|
369
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('wstETH', enums_1.ChainId.Arbitrum).address),
|
|
370
|
+
6,
|
|
371
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
372
|
+
2,
|
|
373
|
+
]
|
|
374
|
+
],
|
|
375
|
+
];
|
|
376
|
+
examples.forEach(([expected, actual]) => {
|
|
377
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
378
|
+
(0, chai_1.expect)(subDataService.aaveV3QuotePriceSubData.encode(...actual)).to.eql(expected);
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
describe('decode()', () => {
|
|
383
|
+
const examples = [
|
|
384
|
+
[
|
|
385
|
+
{
|
|
386
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
387
|
+
collAssetId: 2,
|
|
388
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
389
|
+
debtAssetId: 4,
|
|
390
|
+
},
|
|
391
|
+
[
|
|
392
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
393
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
394
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
395
|
+
],
|
|
396
|
+
],
|
|
397
|
+
[
|
|
398
|
+
{
|
|
399
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('wstETH', enums_1.ChainId.Arbitrum).address),
|
|
400
|
+
collAssetId: 6,
|
|
401
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
402
|
+
debtAssetId: 2,
|
|
403
|
+
},
|
|
404
|
+
[
|
|
405
|
+
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
406
|
+
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
407
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
408
|
+
],
|
|
409
|
+
],
|
|
410
|
+
];
|
|
411
|
+
examples.forEach(([expected, actual]) => {
|
|
412
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
413
|
+
(0, chai_1.expect)(subDataService.aaveV3QuotePriceSubData.decode(actual)).to.eql(expected);
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
describe('When testing subDataService.aaveV3CollateralSwitchSubData', () => {
|
|
419
|
+
describe('encode()', () => {
|
|
420
|
+
const examples = [
|
|
421
|
+
// WETH -> USDC
|
|
422
|
+
[
|
|
423
|
+
[
|
|
424
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
425
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
426
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
427
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
428
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
429
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
430
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
431
|
+
],
|
|
432
|
+
[
|
|
433
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
434
|
+
0,
|
|
435
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
436
|
+
1,
|
|
437
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
438
|
+
'10000000000000000000',
|
|
439
|
+
false,
|
|
440
|
+
]
|
|
441
|
+
],
|
|
442
|
+
// USDC -> WETH (MaxUint256)
|
|
443
|
+
[
|
|
444
|
+
[
|
|
445
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
446
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
447
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
448
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
449
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
450
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
451
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
452
|
+
],
|
|
453
|
+
[
|
|
454
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
455
|
+
1,
|
|
456
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
457
|
+
0,
|
|
458
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
459
|
+
tokens_2.MAXUINT, // MaxUint256
|
|
460
|
+
]
|
|
461
|
+
],
|
|
462
|
+
// WETH -> WBTC
|
|
463
|
+
[
|
|
464
|
+
[
|
|
465
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
466
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
467
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
468
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
469
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
470
|
+
'0x0000000000000000000000000000000000000000000000004563918244f40000',
|
|
471
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
472
|
+
],
|
|
473
|
+
[
|
|
474
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
475
|
+
0,
|
|
476
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
477
|
+
2,
|
|
478
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
479
|
+
'5000000000000000000', // 5 WETH
|
|
480
|
+
]
|
|
481
|
+
],
|
|
482
|
+
];
|
|
483
|
+
examples.forEach(([expected, actual]) => {
|
|
484
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
485
|
+
(0, chai_1.expect)(subDataService.aaveV3CollateralSwitchSubData.encode(...actual)).to.eql(expected);
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
});
|
|
489
|
+
describe('decode()', () => {
|
|
490
|
+
const examples = [
|
|
491
|
+
// WETH -> USDC
|
|
492
|
+
[
|
|
493
|
+
{
|
|
494
|
+
fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
495
|
+
fromAssetId: 0,
|
|
496
|
+
toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
497
|
+
toAssetId: 1,
|
|
498
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
499
|
+
amountToSwitch: '10000000000000000000',
|
|
500
|
+
},
|
|
501
|
+
[
|
|
502
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
503
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
504
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
505
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
506
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
507
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
508
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
509
|
+
],
|
|
510
|
+
],
|
|
511
|
+
// USDC -> WETH (MaxUint256)
|
|
512
|
+
[
|
|
513
|
+
{
|
|
514
|
+
fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
515
|
+
fromAssetId: 1,
|
|
516
|
+
toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
517
|
+
toAssetId: 0,
|
|
518
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
519
|
+
amountToSwitch: tokens_2.MAXUINT,
|
|
520
|
+
},
|
|
521
|
+
[
|
|
522
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
523
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
524
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
525
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
526
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
527
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
528
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
529
|
+
],
|
|
530
|
+
],
|
|
531
|
+
// WETH -> WBTC
|
|
532
|
+
[
|
|
533
|
+
{
|
|
534
|
+
fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
535
|
+
fromAssetId: 0,
|
|
536
|
+
toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
537
|
+
toAssetId: 2,
|
|
538
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
539
|
+
amountToSwitch: '5000000000000000000',
|
|
540
|
+
},
|
|
541
|
+
[
|
|
542
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
543
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
544
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
545
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
546
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
547
|
+
'0x0000000000000000000000000000000000000000000000004563918244f40000',
|
|
548
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
549
|
+
],
|
|
550
|
+
],
|
|
551
|
+
];
|
|
552
|
+
examples.forEach(([expected, actual]) => {
|
|
553
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
554
|
+
(0, chai_1.expect)(subDataService.aaveV3CollateralSwitchSubData.decode(actual)).to.eql(expected);
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
});
|
|
559
|
+
describe('When testing subDataService.sparkCollateralSwitchSubData', () => {
|
|
560
|
+
describe('encode()', () => {
|
|
561
|
+
const examples = [
|
|
562
|
+
// WETH -> cbBTC
|
|
563
|
+
[
|
|
564
|
+
[
|
|
565
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
566
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
567
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
568
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
569
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
570
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
571
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
572
|
+
],
|
|
573
|
+
[
|
|
574
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
575
|
+
0,
|
|
576
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
577
|
+
7,
|
|
578
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
579
|
+
'10000000000000000000',
|
|
580
|
+
false,
|
|
581
|
+
]
|
|
582
|
+
],
|
|
583
|
+
// cbBTC -> WETH (MaxUint256)
|
|
584
|
+
[
|
|
585
|
+
[
|
|
586
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
587
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
588
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
589
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
590
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
591
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
592
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
593
|
+
],
|
|
594
|
+
[
|
|
595
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
596
|
+
7,
|
|
597
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
598
|
+
0,
|
|
599
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
600
|
+
tokens_2.MAXUINT,
|
|
601
|
+
]
|
|
602
|
+
],
|
|
603
|
+
// WETH -> cbBTC (5 WETH)
|
|
604
|
+
[
|
|
605
|
+
[
|
|
606
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
607
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
608
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
609
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
610
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
611
|
+
'0x0000000000000000000000000000000000000000000000004563918244f40000',
|
|
612
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
613
|
+
],
|
|
614
|
+
[
|
|
615
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
616
|
+
0,
|
|
617
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
618
|
+
7,
|
|
619
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
620
|
+
'5000000000000000000', // 5 WETH
|
|
621
|
+
]
|
|
622
|
+
],
|
|
623
|
+
];
|
|
624
|
+
examples.forEach(([expected, actual]) => {
|
|
625
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
626
|
+
(0, chai_1.expect)(subDataService.sparkCollateralSwitchSubData.encode(...actual)).to.eql(expected);
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
});
|
|
630
|
+
describe('decode()', () => {
|
|
631
|
+
const examples = [
|
|
632
|
+
// WETH -> cbBTC
|
|
633
|
+
[
|
|
634
|
+
{
|
|
635
|
+
fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
636
|
+
fromAssetId: 0,
|
|
637
|
+
toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
638
|
+
toAssetId: 7,
|
|
639
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
640
|
+
amountToSwitch: '10000000000000000000',
|
|
641
|
+
},
|
|
642
|
+
[
|
|
643
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
644
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
645
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
646
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
647
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
648
|
+
'0x0000000000000000000000000000000000000000000000008ac7230489e80000',
|
|
649
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
650
|
+
],
|
|
651
|
+
],
|
|
652
|
+
// cbBTC -> WETH (MaxUint256)
|
|
653
|
+
[
|
|
654
|
+
{
|
|
655
|
+
fromAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('cbBTC', enums_1.ChainId.Ethereum).address),
|
|
656
|
+
fromAssetId: 7,
|
|
657
|
+
toAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
658
|
+
toAssetId: 0,
|
|
659
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
660
|
+
amountToSwitch: tokens_2.MAXUINT,
|
|
661
|
+
},
|
|
662
|
+
[
|
|
663
|
+
'0x000000000000000000000000cbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
664
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
665
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
666
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
667
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
668
|
+
'0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
|
669
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
670
|
+
],
|
|
671
|
+
],
|
|
672
|
+
];
|
|
673
|
+
examples.forEach(([expected, actual]) => {
|
|
674
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
675
|
+
(0, chai_1.expect)(subDataService.sparkCollateralSwitchSubData.decode(actual)).to.eql(expected);
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
});
|
|
680
|
+
describe('When testing subDataService.compoundV2LeverageManagementSubData', () => {
|
|
681
|
+
describe('encode()', () => {
|
|
682
|
+
const examples = [
|
|
683
|
+
[
|
|
684
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
685
|
+
[160, 220, 180, 190, true]
|
|
686
|
+
],
|
|
687
|
+
[
|
|
688
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
689
|
+
[160, 200, 180, 190, false]
|
|
690
|
+
],
|
|
691
|
+
];
|
|
692
|
+
examples.forEach(([expected, actual]) => {
|
|
693
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
694
|
+
(0, chai_1.expect)(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
695
|
+
});
|
|
696
|
+
});
|
|
697
|
+
});
|
|
698
|
+
describe('decode()', () => {
|
|
699
|
+
const examples = [
|
|
700
|
+
[
|
|
701
|
+
{ targetRatio: 200 },
|
|
702
|
+
['0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
703
|
+
],
|
|
704
|
+
[
|
|
705
|
+
{ targetRatio: 123 },
|
|
706
|
+
['0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
707
|
+
],
|
|
708
|
+
];
|
|
709
|
+
examples.forEach(([expected, actual]) => {
|
|
710
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
711
|
+
(0, chai_1.expect)(subDataService.compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
712
|
+
});
|
|
713
|
+
});
|
|
714
|
+
});
|
|
715
|
+
});
|
|
716
|
+
describe('When testing subDataService.compoundV3LeverageManagementSubData', () => {
|
|
717
|
+
describe('encode()', () => {
|
|
718
|
+
const examples = [
|
|
719
|
+
[
|
|
720
|
+
[
|
|
721
|
+
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
722
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
723
|
+
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
724
|
+
new decimal_js_1.default(220).mul(1e16).toString(),
|
|
725
|
+
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
726
|
+
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
727
|
+
true, false,
|
|
728
|
+
],
|
|
729
|
+
[
|
|
730
|
+
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
731
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
732
|
+
160, 220, 180, 190,
|
|
733
|
+
true, false,
|
|
734
|
+
]
|
|
735
|
+
],
|
|
736
|
+
[
|
|
737
|
+
[
|
|
738
|
+
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
739
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
740
|
+
new decimal_js_1.default(160).mul(1e16).toString(),
|
|
741
|
+
new decimal_js_1.default(210).mul(1e16).toString(),
|
|
742
|
+
new decimal_js_1.default(180).mul(1e16).toString(),
|
|
743
|
+
new decimal_js_1.default(190).mul(1e16).toString(),
|
|
744
|
+
false, true,
|
|
745
|
+
],
|
|
746
|
+
[
|
|
747
|
+
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
748
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
749
|
+
160, 210, 180, 190,
|
|
750
|
+
false, true,
|
|
751
|
+
]
|
|
752
|
+
],
|
|
753
|
+
];
|
|
754
|
+
examples.forEach(([expected, actual]) => {
|
|
755
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
756
|
+
(0, chai_1.expect)(subDataService.compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
757
|
+
});
|
|
758
|
+
});
|
|
759
|
+
});
|
|
760
|
+
describe('decode()', () => {
|
|
761
|
+
const examples = [
|
|
762
|
+
[
|
|
763
|
+
{ targetRatio: 123 },
|
|
764
|
+
[
|
|
765
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
766
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
767
|
+
],
|
|
768
|
+
],
|
|
769
|
+
[
|
|
770
|
+
{ targetRatio: 200 },
|
|
771
|
+
[
|
|
772
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
773
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
774
|
+
],
|
|
775
|
+
],
|
|
776
|
+
];
|
|
777
|
+
examples.forEach(([expected, actual]) => {
|
|
778
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
779
|
+
(0, chai_1.expect)(subDataService.compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
780
|
+
});
|
|
781
|
+
});
|
|
782
|
+
});
|
|
783
|
+
});
|
|
784
|
+
describe('When testing subDataService.morphoAaveV2LeverageManagementSubData', () => {
|
|
785
|
+
describe('encode()', () => {
|
|
786
|
+
const examples = [
|
|
787
|
+
[
|
|
788
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
|
|
789
|
+
[160, 220, 180, 190, true]
|
|
790
|
+
],
|
|
791
|
+
[
|
|
792
|
+
[new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
|
|
793
|
+
[160, 200, 180, 190, false]
|
|
794
|
+
],
|
|
795
|
+
];
|
|
796
|
+
examples.forEach(([expected, actual]) => {
|
|
797
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
798
|
+
(0, chai_1.expect)(subDataService.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
799
|
+
});
|
|
800
|
+
});
|
|
801
|
+
});
|
|
802
|
+
describe('decode()', () => {
|
|
803
|
+
const examples = [
|
|
804
|
+
[
|
|
805
|
+
{ targetRatio: 200 },
|
|
806
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
807
|
+
],
|
|
808
|
+
[
|
|
809
|
+
{ targetRatio: 123 },
|
|
810
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
811
|
+
],
|
|
812
|
+
];
|
|
813
|
+
examples.forEach(([expected, actual]) => {
|
|
814
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
815
|
+
(0, chai_1.expect)(subDataService.morphoAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
816
|
+
});
|
|
817
|
+
});
|
|
818
|
+
});
|
|
819
|
+
});
|
|
820
|
+
describe('When testing subDataService.cBondsRebondSubData', () => {
|
|
821
|
+
describe('encode()', () => {
|
|
822
|
+
const examples = [
|
|
823
|
+
[
|
|
824
|
+
['0x00000000000000000000000000000000000000000000000000000000000000c8'],
|
|
825
|
+
[200]
|
|
826
|
+
],
|
|
827
|
+
[
|
|
828
|
+
['0x000000000000000000000000000000000000000000000000000000000000a119'],
|
|
829
|
+
[41241]
|
|
830
|
+
],
|
|
831
|
+
];
|
|
832
|
+
examples.forEach(([expected, actual]) => {
|
|
833
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
834
|
+
(0, chai_1.expect)(subDataService.cBondsRebondSubData.encode(...actual)).to.eql(expected);
|
|
835
|
+
});
|
|
836
|
+
});
|
|
837
|
+
});
|
|
838
|
+
describe('decode()', () => {
|
|
839
|
+
const examples = [
|
|
840
|
+
[
|
|
841
|
+
{ bondId: '200' },
|
|
842
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x00000000000000000000000000000000000000000000000000000000000000c8'],
|
|
843
|
+
],
|
|
844
|
+
[
|
|
845
|
+
{ bondId: '41241' },
|
|
846
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000000000000000000000000000000000000000a119'],
|
|
847
|
+
],
|
|
848
|
+
];
|
|
849
|
+
examples.forEach(([expected, actual]) => {
|
|
850
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
851
|
+
(0, chai_1.expect)(subDataService.cBondsRebondSubData.decode(actual)).to.eql(expected);
|
|
852
|
+
});
|
|
853
|
+
});
|
|
854
|
+
});
|
|
855
|
+
});
|
|
856
|
+
describe('When testing subDataService.liquityPaybackUsingChickenBondSubData', () => {
|
|
857
|
+
describe('encode()', () => {
|
|
858
|
+
const examples = [
|
|
859
|
+
[
|
|
860
|
+
[
|
|
861
|
+
'0x0000000000000000000000000000000000000000000000000000000000001076', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
862
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
|
|
863
|
+
],
|
|
864
|
+
['4214', 0, enums_1.ChainId.Ethereum]
|
|
865
|
+
],
|
|
866
|
+
[
|
|
867
|
+
[
|
|
868
|
+
'0x00000000000000000000000000000000000000000000000000000000000002b8', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
869
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
|
|
870
|
+
],
|
|
871
|
+
['696', 1]
|
|
872
|
+
],
|
|
873
|
+
];
|
|
874
|
+
examples.forEach(([expected, actual]) => {
|
|
875
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
876
|
+
(0, chai_1.expect)(subDataService.liquityPaybackUsingChickenBondSubData.encode(...actual)).to.eql(expected);
|
|
877
|
+
});
|
|
878
|
+
});
|
|
879
|
+
});
|
|
880
|
+
describe('decode()', () => {
|
|
881
|
+
const examples = [
|
|
882
|
+
[
|
|
883
|
+
{ sourceId: '4214', sourceType: '0' },
|
|
884
|
+
[
|
|
885
|
+
'0x0000000000000000000000000000000000000000000000000000000000001076', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
886
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
|
|
887
|
+
],
|
|
888
|
+
],
|
|
889
|
+
[
|
|
890
|
+
{ sourceId: '696', sourceType: '1' },
|
|
891
|
+
[
|
|
892
|
+
'0x00000000000000000000000000000000000000000000000000000000000002b8', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
893
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
|
|
894
|
+
],
|
|
895
|
+
],
|
|
896
|
+
];
|
|
897
|
+
examples.forEach(([expected, actual]) => {
|
|
898
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
899
|
+
(0, chai_1.expect)(subDataService.liquityPaybackUsingChickenBondSubData.decode(actual)).to.eql(expected);
|
|
900
|
+
});
|
|
901
|
+
});
|
|
902
|
+
});
|
|
903
|
+
});
|
|
904
|
+
describe('When testing subDataService.exchangeDcaSubData', () => {
|
|
905
|
+
describe('encode()', () => {
|
|
906
|
+
const examples = [
|
|
907
|
+
[
|
|
908
|
+
[
|
|
909
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
910
|
+
'0x0000000000000000000000000000000000000000000000000000000000000853', '0x0000000000000000000000000000000000000000000000000000000000231860'
|
|
911
|
+
],
|
|
912
|
+
[
|
|
913
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
914
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
915
|
+
'2131',
|
|
916
|
+
2300000,
|
|
917
|
+
]
|
|
918
|
+
],
|
|
919
|
+
[
|
|
920
|
+
[
|
|
921
|
+
'0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f', '0x000000000000000000000000f97f4df75117a78c1a5a0dbb814af92458539fb4',
|
|
922
|
+
'0x00000000000000000000000000000000000000000000000000000000003eddd7', '0x0000000000000000000000000000000000000000000000000000000008f57500'
|
|
923
|
+
],
|
|
924
|
+
[
|
|
925
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Arbitrum).address),
|
|
926
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
927
|
+
'4120023',
|
|
928
|
+
150304000,
|
|
929
|
+
]
|
|
930
|
+
],
|
|
931
|
+
];
|
|
932
|
+
examples.forEach(([expected, actual]) => {
|
|
933
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
934
|
+
(0, chai_1.expect)(subDataService.exchangeDcaSubData.encode(...actual)).to.eql(expected);
|
|
935
|
+
});
|
|
936
|
+
});
|
|
937
|
+
});
|
|
938
|
+
describe('decode()', () => {
|
|
939
|
+
const examples = [
|
|
940
|
+
[
|
|
941
|
+
{
|
|
942
|
+
fromToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
943
|
+
toToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
944
|
+
amount: '0.000000000000002131',
|
|
945
|
+
interval: '2300000',
|
|
946
|
+
},
|
|
947
|
+
[
|
|
948
|
+
[
|
|
949
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
950
|
+
'0x0000000000000000000000000000000000000000000000000000000000000853', '0x0000000000000000000000000000000000000000000000000000000000231860'
|
|
951
|
+
],
|
|
952
|
+
enums_1.ChainId.Ethereum
|
|
953
|
+
],
|
|
954
|
+
],
|
|
955
|
+
[
|
|
956
|
+
{
|
|
957
|
+
fromToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Arbitrum).address),
|
|
958
|
+
toToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
959
|
+
amount: '0.04120023',
|
|
960
|
+
interval: '150304000',
|
|
961
|
+
},
|
|
962
|
+
[
|
|
963
|
+
[
|
|
964
|
+
'0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f', '0x000000000000000000000000f97f4df75117a78c1a5a0dbb814af92458539fb4',
|
|
965
|
+
'0x00000000000000000000000000000000000000000000000000000000003eddd7', '0x0000000000000000000000000000000000000000000000000000000008f57500'
|
|
966
|
+
],
|
|
967
|
+
enums_1.ChainId.Arbitrum
|
|
968
|
+
]
|
|
969
|
+
],
|
|
970
|
+
];
|
|
971
|
+
examples.forEach(([expected, actual]) => {
|
|
972
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
973
|
+
(0, chai_1.expect)(subDataService.exchangeDcaSubData.decode(...actual)).to.eql(expected);
|
|
974
|
+
});
|
|
975
|
+
});
|
|
976
|
+
});
|
|
977
|
+
});
|
|
978
|
+
describe('When testing subDataService.exchangeLimitOrderSubData', () => {
|
|
979
|
+
describe('encode()', () => {
|
|
980
|
+
const examples = [
|
|
981
|
+
[
|
|
982
|
+
[
|
|
983
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
984
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
985
|
+
'2131',
|
|
986
|
+
'0.53123',
|
|
987
|
+
'1696590921159',
|
|
988
|
+
`${enums_1.OrderType.STOP_LOSS}`
|
|
989
|
+
],
|
|
990
|
+
[
|
|
991
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
992
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
993
|
+
'2131',
|
|
994
|
+
'0.53123',
|
|
995
|
+
1696590921159,
|
|
996
|
+
enums_1.OrderType.STOP_LOSS
|
|
997
|
+
]
|
|
998
|
+
],
|
|
999
|
+
[
|
|
1000
|
+
[
|
|
1001
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
1002
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
1003
|
+
'2131',
|
|
1004
|
+
'0.43123',
|
|
1005
|
+
'1646590921159',
|
|
1006
|
+
`${enums_1.OrderType.TAKE_PROFIT}`
|
|
1007
|
+
],
|
|
1008
|
+
[
|
|
1009
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
1010
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
|
|
1011
|
+
'2131',
|
|
1012
|
+
'0.43123',
|
|
1013
|
+
1646590921159,
|
|
1014
|
+
enums_1.OrderType.TAKE_PROFIT
|
|
1015
|
+
]
|
|
1016
|
+
],
|
|
1017
|
+
];
|
|
1018
|
+
examples.forEach(([expected, actual]) => {
|
|
1019
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1020
|
+
(0, chai_1.expect)(subDataService.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
|
|
1021
|
+
});
|
|
1022
|
+
});
|
|
1023
|
+
});
|
|
1024
|
+
describe('decode()', () => {
|
|
1025
|
+
const examples = [
|
|
1026
|
+
[
|
|
1027
|
+
{
|
|
1028
|
+
fromToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1029
|
+
toToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1030
|
+
amount: '0.000000000000002131',
|
|
1031
|
+
},
|
|
1032
|
+
[
|
|
1033
|
+
[
|
|
1034
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1035
|
+
'0x0000000000000000000000000000000000000000000000000000000000000853', '0x0000000000000000000000000000000000000000000000000000000000231860'
|
|
1036
|
+
],
|
|
1037
|
+
enums_1.ChainId.Ethereum
|
|
1038
|
+
],
|
|
1039
|
+
],
|
|
1040
|
+
[
|
|
1041
|
+
{
|
|
1042
|
+
fromToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Arbitrum).address),
|
|
1043
|
+
toToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
|
|
1044
|
+
amount: '0.04120023',
|
|
1045
|
+
},
|
|
1046
|
+
[
|
|
1047
|
+
[
|
|
1048
|
+
'0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f', '0x000000000000000000000000f97f4df75117a78c1a5a0dbb814af92458539fb4',
|
|
1049
|
+
'0x00000000000000000000000000000000000000000000000000000000003eddd7', '0x0000000000000000000000000000000000000000000000000000000008f57500'
|
|
1050
|
+
],
|
|
1051
|
+
enums_1.ChainId.Arbitrum
|
|
1052
|
+
]
|
|
1053
|
+
],
|
|
1054
|
+
];
|
|
1055
|
+
examples.forEach(([expected, actual]) => {
|
|
1056
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1057
|
+
(0, chai_1.expect)(subDataService.exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
|
|
1058
|
+
});
|
|
1059
|
+
});
|
|
1060
|
+
});
|
|
1061
|
+
});
|
|
1062
|
+
describe('When testing subDataService.sparkLeverageManagementSubData', () => {
|
|
1063
|
+
describe('decode()', () => {
|
|
1064
|
+
const examples = [
|
|
1065
|
+
[
|
|
1066
|
+
{ targetRatio: 200 },
|
|
1067
|
+
['0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
1068
|
+
],
|
|
1069
|
+
[
|
|
1070
|
+
{ targetRatio: 123 },
|
|
1071
|
+
['0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
1072
|
+
],
|
|
1073
|
+
];
|
|
1074
|
+
examples.forEach(([expected, actual]) => {
|
|
1075
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1076
|
+
(0, chai_1.expect)(subDataService.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1077
|
+
});
|
|
1078
|
+
});
|
|
1079
|
+
});
|
|
1080
|
+
});
|
|
1081
|
+
describe('When testing subDataService.liquityDsrPaybackSubData', () => {
|
|
1082
|
+
describe('encode()', () => {
|
|
1083
|
+
const examples = [
|
|
1084
|
+
[
|
|
1085
|
+
[
|
|
1086
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
1087
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1088
|
+
],
|
|
1089
|
+
[123]
|
|
1090
|
+
],
|
|
1091
|
+
[
|
|
1092
|
+
[
|
|
1093
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
|
|
1094
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1095
|
+
],
|
|
1096
|
+
[420]
|
|
1097
|
+
],
|
|
1098
|
+
];
|
|
1099
|
+
examples.forEach(([expected, actual]) => {
|
|
1100
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1101
|
+
(0, chai_1.expect)(subDataService.liquityDsrPaybackSubData.encode(...actual)).to.eql(expected);
|
|
1102
|
+
});
|
|
1103
|
+
});
|
|
1104
|
+
});
|
|
1105
|
+
describe('decode()', () => {
|
|
1106
|
+
const examples = [
|
|
1107
|
+
[
|
|
1108
|
+
{
|
|
1109
|
+
targetRatio: 123,
|
|
1110
|
+
},
|
|
1111
|
+
[
|
|
1112
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
1113
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1114
|
+
],
|
|
1115
|
+
],
|
|
1116
|
+
[
|
|
1117
|
+
{
|
|
1118
|
+
targetRatio: 420,
|
|
1119
|
+
},
|
|
1120
|
+
[
|
|
1121
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
|
|
1122
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1123
|
+
],
|
|
1124
|
+
],
|
|
1125
|
+
];
|
|
1126
|
+
examples.forEach(([expected, actual]) => {
|
|
1127
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1128
|
+
(0, chai_1.expect)(subDataService.liquityDsrPaybackSubData.decode(actual)).to.eql(expected);
|
|
1129
|
+
});
|
|
1130
|
+
});
|
|
1131
|
+
});
|
|
1132
|
+
});
|
|
1133
|
+
describe('When testing subDataService.liquityDsrSupplySubData', () => {
|
|
1134
|
+
describe('encode()', () => {
|
|
1135
|
+
const examples = [
|
|
1136
|
+
[
|
|
1137
|
+
[
|
|
1138
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000002c68af0bb1400000',
|
|
1139
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1140
|
+
],
|
|
1141
|
+
[320]
|
|
1142
|
+
],
|
|
1143
|
+
[
|
|
1144
|
+
[
|
|
1145
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001eab7f4a799d0000',
|
|
1146
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1147
|
+
],
|
|
1148
|
+
[221]
|
|
1149
|
+
],
|
|
1150
|
+
];
|
|
1151
|
+
examples.forEach(([expected, actual]) => {
|
|
1152
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1153
|
+
(0, chai_1.expect)(subDataService.liquityDsrSupplySubData.encode(...actual)).to.eql(expected);
|
|
1154
|
+
});
|
|
1155
|
+
});
|
|
1156
|
+
});
|
|
1157
|
+
describe('decode()', () => {
|
|
1158
|
+
const examples = [
|
|
1159
|
+
[
|
|
1160
|
+
{
|
|
1161
|
+
targetRatio: 320,
|
|
1162
|
+
},
|
|
1163
|
+
[
|
|
1164
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000002c68af0bb1400000',
|
|
1165
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1166
|
+
],
|
|
1167
|
+
],
|
|
1168
|
+
[
|
|
1169
|
+
{
|
|
1170
|
+
targetRatio: 221,
|
|
1171
|
+
},
|
|
1172
|
+
[
|
|
1173
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001eab7f4a799d0000',
|
|
1174
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1175
|
+
],
|
|
1176
|
+
],
|
|
1177
|
+
];
|
|
1178
|
+
examples.forEach(([expected, actual]) => {
|
|
1179
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1180
|
+
(0, chai_1.expect)(subDataService.liquityDsrSupplySubData.decode(actual)).to.eql(expected);
|
|
1181
|
+
});
|
|
1182
|
+
});
|
|
1183
|
+
});
|
|
1184
|
+
});
|
|
1185
|
+
describe('When testing subDataService.liquityDebtInFrontRepaySubData', () => {
|
|
1186
|
+
describe('encode()', () => {
|
|
1187
|
+
const examples = [
|
|
1188
|
+
[
|
|
1189
|
+
[
|
|
1190
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1191
|
+
'0x000000000000000000000000000000000000000000000000016345785d8a0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1192
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1193
|
+
],
|
|
1194
|
+
[10]
|
|
1195
|
+
],
|
|
1196
|
+
[
|
|
1197
|
+
[
|
|
1198
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1199
|
+
'0x000000000000000000000000000000000000000000000000063eb89da4ed0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1200
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1201
|
+
],
|
|
1202
|
+
[45]
|
|
1203
|
+
],
|
|
1204
|
+
];
|
|
1205
|
+
examples.forEach(([expected, actual]) => {
|
|
1206
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1207
|
+
(0, chai_1.expect)(subDataService.liquityDebtInFrontRepaySubData.encode(...actual)).to.eql(expected);
|
|
1208
|
+
});
|
|
1209
|
+
});
|
|
1210
|
+
});
|
|
1211
|
+
describe('decode()', () => {
|
|
1212
|
+
const examples = [
|
|
1213
|
+
[
|
|
1214
|
+
{
|
|
1215
|
+
targetRatioIncrease: 10,
|
|
1216
|
+
},
|
|
1217
|
+
[
|
|
1218
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1219
|
+
'0x000000000000000000000000000000000000000000000000016345785d8a0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1220
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1221
|
+
],
|
|
1222
|
+
],
|
|
1223
|
+
[
|
|
1224
|
+
{
|
|
1225
|
+
targetRatioIncrease: 45,
|
|
1226
|
+
},
|
|
1227
|
+
[
|
|
1228
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1229
|
+
'0x000000000000000000000000000000000000000000000000063eb89da4ed0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1230
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1231
|
+
],
|
|
1232
|
+
],
|
|
1233
|
+
];
|
|
1234
|
+
examples.forEach(([expected, actual]) => {
|
|
1235
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1236
|
+
(0, chai_1.expect)(subDataService.liquityDebtInFrontRepaySubData.decode(actual)).to.eql(expected);
|
|
1237
|
+
});
|
|
1238
|
+
});
|
|
1239
|
+
});
|
|
1240
|
+
});
|
|
1241
|
+
describe('When testing subDataService.crvUSDLeverageManagementSubData', () => {
|
|
1242
|
+
describe('encode()', () => {
|
|
1243
|
+
const examples = [
|
|
1244
|
+
[
|
|
1245
|
+
[
|
|
1246
|
+
'0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
|
|
1247
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1248
|
+
'0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
1249
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1250
|
+
'0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
|
|
1251
|
+
],
|
|
1252
|
+
['0xa920de414ea4ab66b97da1bfe9e6eca7d4219635', enums_1.RatioState.UNDER, 120, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E'],
|
|
1253
|
+
],
|
|
1254
|
+
[
|
|
1255
|
+
[
|
|
1256
|
+
'0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
|
|
1257
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1258
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1259
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1260
|
+
'0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
|
|
1261
|
+
],
|
|
1262
|
+
['0xa920de414ea4ab66b97da1bfe9e6eca7d4219635', enums_1.RatioState.OVER, 180, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E']
|
|
1263
|
+
],
|
|
1264
|
+
];
|
|
1265
|
+
examples.forEach(([expected, actual]) => {
|
|
1266
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1267
|
+
(0, chai_1.expect)(subDataService.crvUSDLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1268
|
+
});
|
|
1269
|
+
});
|
|
1270
|
+
});
|
|
1271
|
+
describe('decode()', () => {
|
|
1272
|
+
const examples = [
|
|
1273
|
+
[
|
|
1274
|
+
{
|
|
1275
|
+
controller: '0xA920De414eA4Ab66b97dA1bFE9e6EcA7d4219635',
|
|
1276
|
+
targetRatio: 120,
|
|
1277
|
+
},
|
|
1278
|
+
['0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635', '0x0000000000000000000000000000000000000000000000000000000000000001', '0x00000000000000000000000000000000000000000000000010a741a462780000', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',],
|
|
1279
|
+
],
|
|
1280
|
+
[
|
|
1281
|
+
{
|
|
1282
|
+
controller: '0xA920De414eA4Ab66b97dA1bFE9e6EcA7d4219635',
|
|
1283
|
+
targetRatio: 180,
|
|
1284
|
+
},
|
|
1285
|
+
['0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x00000000000000000000000000000000000000000000000018fae27693b40000', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',],
|
|
1286
|
+
],
|
|
1287
|
+
];
|
|
1288
|
+
examples.forEach(([expected, actual]) => {
|
|
1289
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1290
|
+
(0, chai_1.expect)(subDataService.crvUSDLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1291
|
+
});
|
|
1292
|
+
});
|
|
1293
|
+
});
|
|
1294
|
+
});
|
|
1295
|
+
describe('When testing subDataService.crvUSDPaybackSubData', () => {
|
|
1296
|
+
describe('encode()', () => {
|
|
1297
|
+
const examples = [
|
|
1298
|
+
[
|
|
1299
|
+
[
|
|
1300
|
+
'0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
|
|
1301
|
+
'0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
|
|
1302
|
+
'0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
|
|
1303
|
+
'0x00000000000000000000000000000000000000000000043c33c1937564800000',
|
|
1304
|
+
'0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
|
|
1305
|
+
],
|
|
1306
|
+
['0xa920de414ea4ab66b97da1bfe9e6eca7d4219635', '0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280', '0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280', '20000', '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E'],
|
|
1307
|
+
]
|
|
1308
|
+
];
|
|
1309
|
+
examples.forEach(([expected, actual]) => {
|
|
1310
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1311
|
+
(0, chai_1.expect)(subDataService.crvUSDPaybackSubData.encode(...actual)).to.eql(expected);
|
|
1312
|
+
});
|
|
1313
|
+
});
|
|
1314
|
+
});
|
|
1315
|
+
describe('decode()', () => {
|
|
1316
|
+
const examples = [
|
|
1317
|
+
[
|
|
1318
|
+
{
|
|
1319
|
+
controller: '0xA920De414eA4Ab66b97dA1bFE9e6EcA7d4219635',
|
|
1320
|
+
addressToPullTokensFrom: '0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280',
|
|
1321
|
+
positionOwner: '0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280',
|
|
1322
|
+
paybackAmount: '20000'
|
|
1323
|
+
},
|
|
1324
|
+
[
|
|
1325
|
+
'0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
|
|
1326
|
+
'0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
|
|
1327
|
+
'0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
|
|
1328
|
+
'0x00000000000000000000000000000000000000000000043c33c1937564800000',
|
|
1329
|
+
'0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
|
|
1330
|
+
]
|
|
1331
|
+
]
|
|
1332
|
+
];
|
|
1333
|
+
examples.forEach(([expected, actual]) => {
|
|
1334
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1335
|
+
(0, chai_1.expect)(subDataService.crvUSDPaybackSubData.decode(actual)).to.eql(expected);
|
|
1336
|
+
});
|
|
1337
|
+
});
|
|
1338
|
+
});
|
|
1339
|
+
});
|
|
1340
|
+
describe('When testing subDataService.compoundV3L2LeverageManagementSubData', () => {
|
|
1341
|
+
describe('encode()', () => {
|
|
1342
|
+
const examples = [
|
|
1343
|
+
[
|
|
1344
|
+
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e00000100',
|
|
1345
|
+
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 190, true, false]
|
|
1346
|
+
],
|
|
1347
|
+
[
|
|
1348
|
+
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee00000000',
|
|
1349
|
+
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 110, false, false]
|
|
1350
|
+
],
|
|
1351
|
+
];
|
|
1352
|
+
examples.forEach(([expected, actual]) => {
|
|
1353
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1354
|
+
(0, chai_1.expect)(subDataService.compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1355
|
+
});
|
|
1356
|
+
});
|
|
1357
|
+
});
|
|
1358
|
+
describe('decode()', () => {
|
|
1359
|
+
const examples = [
|
|
1360
|
+
[
|
|
1361
|
+
{ targetRatio: 200 },
|
|
1362
|
+
[
|
|
1363
|
+
'0x0000000000000000000000000313d212133AFaB8F2B829B1066c7E43cAd94E2c', '0x0000000000000000000000000213d212133AFaB8F2B829B1066c7E43cAd94E2c',
|
|
1364
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1365
|
+
],
|
|
1366
|
+
],
|
|
1367
|
+
[
|
|
1368
|
+
{ targetRatio: 123 },
|
|
1369
|
+
[
|
|
1370
|
+
'0x0000000000000000000000000313d212133AFaB8F2B829B1066c7E43cAd94E2c', '0x0000000000000000000000000413d212133AFaB8F2B829B1066c7E43cAd94E2c',
|
|
1371
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
1372
|
+
],
|
|
1373
|
+
],
|
|
1374
|
+
];
|
|
1375
|
+
examples.forEach(([expected, actual]) => {
|
|
1376
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1377
|
+
(0, chai_1.expect)(subDataService.compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1378
|
+
});
|
|
1379
|
+
});
|
|
1380
|
+
});
|
|
1381
|
+
});
|
|
1382
|
+
describe('When testing subDataService.morphoBlueLeverageManagementSubData', () => {
|
|
1383
|
+
describe('encode()', () => {
|
|
1384
|
+
const examples = [
|
|
1385
|
+
[
|
|
1386
|
+
[
|
|
1387
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1388
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1389
|
+
'0x0000000000000000000000002a01eb9496094da03c4e364def50f5ad1280ad72',
|
|
1390
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1391
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1392
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1393
|
+
'0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
1394
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1395
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1396
|
+
],
|
|
1397
|
+
[web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0x2a01eb9496094da03c4e364def50f5ad1280ad72'), web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), '945000000000000000', enums_1.RatioState.UNDER, 120, web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), false]
|
|
1398
|
+
],
|
|
1399
|
+
[
|
|
1400
|
+
[
|
|
1401
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1402
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1403
|
+
'0x00000000000000000000000048f7e36eb6b826b2df4b2e630b62cd25e89e40e2',
|
|
1404
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1405
|
+
'0x0000000000000000000000000000000000000000000000000bef55718ad60000',
|
|
1406
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1407
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1408
|
+
'0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c',
|
|
1409
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1410
|
+
],
|
|
1411
|
+
[web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0x48F7E36EB6B826B2dF4B2E630B62Cd25e89E40e2'), web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), '860000000000000000', enums_1.RatioState.OVER, 200, web3Utils.toChecksumAddress('0x0043d218133AFaB8F2B829B106633E434Ad94E2c'), false]
|
|
1412
|
+
],
|
|
1413
|
+
];
|
|
1414
|
+
examples.forEach(([expected, actual]) => {
|
|
1415
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1416
|
+
(0, chai_1.expect)(subDataService.morphoBlueLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1417
|
+
});
|
|
1418
|
+
});
|
|
1419
|
+
});
|
|
1420
|
+
describe('decode()', () => {
|
|
1421
|
+
const examples = [
|
|
1422
|
+
[
|
|
1423
|
+
{
|
|
1424
|
+
'collToken': '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1425
|
+
'irm': '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1426
|
+
'lltv': '945000000000000000',
|
|
1427
|
+
'loanToken': '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1428
|
+
'oracle': '0x2a01EB9496094dA03c4E364Def50f5aD1280AD72',
|
|
1429
|
+
'targetRatio': 120,
|
|
1430
|
+
'user': '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1431
|
+
},
|
|
1432
|
+
[
|
|
1433
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1434
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1435
|
+
'0x0000000000000000000000002a01eb9496094da03c4e364def50f5ad1280ad72',
|
|
1436
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1437
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1438
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1439
|
+
'0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
1440
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1441
|
+
],
|
|
1442
|
+
],
|
|
1443
|
+
[
|
|
1444
|
+
{
|
|
1445
|
+
'collToken': '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1446
|
+
'irm': '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1447
|
+
'lltv': '860000000000000000',
|
|
1448
|
+
'loanToken': '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
1449
|
+
'oracle': '0x48F7E36EB6B826B2dF4B2E630B62Cd25e89E40e2',
|
|
1450
|
+
'targetRatio': 200,
|
|
1451
|
+
'user': '0x0043d218133aFaB8F2b829B106633E434aD94e2C',
|
|
1452
|
+
},
|
|
1453
|
+
[
|
|
1454
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1455
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1456
|
+
'0x00000000000000000000000048f7e36eb6b826b2df4b2e630b62cd25e89e40e2',
|
|
1457
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1458
|
+
'0x0000000000000000000000000000000000000000000000000bef55718ad60000',
|
|
1459
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1460
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1461
|
+
'0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c',
|
|
1462
|
+
],
|
|
1463
|
+
],
|
|
1464
|
+
];
|
|
1465
|
+
examples.forEach(([expected, actual]) => {
|
|
1466
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1467
|
+
(0, chai_1.expect)(subDataService.morphoBlueLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1468
|
+
});
|
|
1469
|
+
});
|
|
1470
|
+
});
|
|
1471
|
+
});
|
|
1472
|
+
describe('When testing subDataService.morphoBlueCloseOnPriceSubData', () => {
|
|
1473
|
+
describe('encode()', () => {
|
|
1474
|
+
const examples = [
|
|
1475
|
+
[
|
|
1476
|
+
[
|
|
1477
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1478
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1479
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1480
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1481
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1482
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1483
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1484
|
+
],
|
|
1485
|
+
[web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'), '945000000000000000', web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT]
|
|
1486
|
+
],
|
|
1487
|
+
];
|
|
1488
|
+
examples.forEach(([expected, actual]) => {
|
|
1489
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1490
|
+
(0, chai_1.expect)(subDataService.morphoBlueCloseOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1491
|
+
});
|
|
1492
|
+
});
|
|
1493
|
+
});
|
|
1494
|
+
describe('decode()', () => {
|
|
1495
|
+
const examples = [
|
|
1496
|
+
[
|
|
1497
|
+
{
|
|
1498
|
+
loanToken: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1499
|
+
collToken: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1500
|
+
oracle: '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1501
|
+
irm: '0x0000000000000000000000000000000000000000',
|
|
1502
|
+
lltv: '945000000000000000',
|
|
1503
|
+
user: '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1504
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
1505
|
+
},
|
|
1506
|
+
[
|
|
1507
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1508
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1509
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1510
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1511
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1512
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1513
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1514
|
+
],
|
|
1515
|
+
],
|
|
1516
|
+
];
|
|
1517
|
+
examples.forEach(([expected, actual]) => {
|
|
1518
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1519
|
+
(0, chai_1.expect)(subDataService.morphoBlueCloseOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1520
|
+
});
|
|
1521
|
+
});
|
|
1522
|
+
});
|
|
1523
|
+
});
|
|
1524
|
+
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1525
|
+
describe('encode()', () => {
|
|
1526
|
+
const examples = [
|
|
1527
|
+
[
|
|
1528
|
+
[
|
|
1529
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1530
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1531
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1532
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1533
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
1534
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1535
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1536
|
+
],
|
|
1537
|
+
[
|
|
1538
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1539
|
+
0,
|
|
1540
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1541
|
+
4,
|
|
1542
|
+
web3Utils.toChecksumAddress('0x2f39d218133afab8f2b819b1066c7e434ad94e9e'),
|
|
1543
|
+
200,
|
|
1544
|
+
]
|
|
1545
|
+
],
|
|
1546
|
+
];
|
|
1547
|
+
examples.forEach(([expected, actual]) => {
|
|
1548
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1549
|
+
(0, chai_1.expect)(subDataService.aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1550
|
+
});
|
|
1551
|
+
});
|
|
1552
|
+
});
|
|
1553
|
+
describe('decode()', () => {
|
|
1554
|
+
const examples = [
|
|
1555
|
+
[
|
|
1556
|
+
{
|
|
1557
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1558
|
+
collAssetId: 0,
|
|
1559
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
1560
|
+
debtAssetId: 4,
|
|
1561
|
+
marketAddr: web3Utils.toChecksumAddress('0x2f39d218133afab8f2b819b1066c7e434ad94e9e'),
|
|
1562
|
+
targetRatio: 200,
|
|
1563
|
+
},
|
|
1564
|
+
[
|
|
1565
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1566
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1567
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1568
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1569
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
1570
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1571
|
+
],
|
|
1572
|
+
],
|
|
1573
|
+
];
|
|
1574
|
+
examples.forEach(([expected, actual]) => {
|
|
1575
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1576
|
+
(0, chai_1.expect)(subDataService.aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1577
|
+
});
|
|
1578
|
+
});
|
|
1579
|
+
});
|
|
1580
|
+
});
|
|
1581
|
+
describe('When testing subDataService.compoundV3LeverageManagementOnPriceSubData', () => {
|
|
1582
|
+
describe('encode()', () => {
|
|
1583
|
+
const examples = [
|
|
1584
|
+
[
|
|
1585
|
+
[
|
|
1586
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1587
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1588
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1589
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1590
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1591
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
|
|
1592
|
+
],
|
|
1593
|
+
[
|
|
1594
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1595
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1596
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1597
|
+
200,
|
|
1598
|
+
enums_1.RatioState.UNDER,
|
|
1599
|
+
web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
|
|
1600
|
+
]
|
|
1601
|
+
],
|
|
1602
|
+
[
|
|
1603
|
+
[
|
|
1604
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1605
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1606
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1607
|
+
'0x0000000000000000000000000000000000000000000000001a5e27eef13e0000',
|
|
1608
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1609
|
+
'0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c'
|
|
1610
|
+
],
|
|
1611
|
+
[
|
|
1612
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1613
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1614
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1615
|
+
190,
|
|
1616
|
+
enums_1.RatioState.OVER,
|
|
1617
|
+
web3Utils.toChecksumAddress('0x0043d218133afab8f2b829b106633e434ad94e2c')
|
|
1618
|
+
]
|
|
1619
|
+
],
|
|
1620
|
+
];
|
|
1621
|
+
examples.forEach(([expected, actual]) => {
|
|
1622
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1623
|
+
(0, chai_1.expect)(subDataService.compoundV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1624
|
+
});
|
|
1625
|
+
});
|
|
1626
|
+
});
|
|
1627
|
+
describe('decode()', () => {
|
|
1628
|
+
const examples = [
|
|
1629
|
+
[
|
|
1630
|
+
{
|
|
1631
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1632
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1633
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1634
|
+
targetRatio: 200,
|
|
1635
|
+
ratioState: enums_1.RatioState.UNDER,
|
|
1636
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
|
|
1637
|
+
},
|
|
1638
|
+
[
|
|
1639
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1640
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1641
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1642
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1643
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1644
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
|
|
1645
|
+
]
|
|
1646
|
+
],
|
|
1647
|
+
[
|
|
1648
|
+
{
|
|
1649
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1650
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1651
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1652
|
+
targetRatio: 190,
|
|
1653
|
+
ratioState: enums_1.RatioState.OVER,
|
|
1654
|
+
owner: web3Utils.toChecksumAddress('0x0043d218133afab8f2b829b106633e434ad94e2c')
|
|
1655
|
+
},
|
|
1656
|
+
[
|
|
1657
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1658
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1659
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1660
|
+
'0x0000000000000000000000000000000000000000000000001a5e27eef13e0000',
|
|
1661
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1662
|
+
'0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c'
|
|
1663
|
+
]
|
|
1664
|
+
],
|
|
1665
|
+
];
|
|
1666
|
+
examples.forEach(([expected, actual]) => {
|
|
1667
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1668
|
+
(0, chai_1.expect)(subDataService.compoundV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1669
|
+
});
|
|
1670
|
+
});
|
|
1671
|
+
});
|
|
1672
|
+
});
|
|
1673
|
+
describe('When testing subDataService.compoundV3CloseSubData', () => {
|
|
1674
|
+
describe('encode()', () => {
|
|
1675
|
+
const examples = [
|
|
1676
|
+
[
|
|
1677
|
+
[
|
|
1678
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1679
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1680
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1681
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1682
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1683
|
+
],
|
|
1684
|
+
[
|
|
1685
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1686
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1687
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1688
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
1689
|
+
web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c'),
|
|
1690
|
+
]
|
|
1691
|
+
],
|
|
1692
|
+
[
|
|
1693
|
+
[
|
|
1694
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1695
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1696
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1697
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1698
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1699
|
+
],
|
|
1700
|
+
[
|
|
1701
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1702
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1703
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1704
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
|
|
1705
|
+
web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c'),
|
|
1706
|
+
]
|
|
1707
|
+
],
|
|
1708
|
+
];
|
|
1709
|
+
examples.forEach(([expected, actual]) => {
|
|
1710
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1711
|
+
(0, chai_1.expect)(subDataService.compoundV3CloseSubData.encode(...actual)).to.eql(expected);
|
|
1712
|
+
});
|
|
1713
|
+
});
|
|
1714
|
+
});
|
|
1715
|
+
describe('decode()', () => {
|
|
1716
|
+
const examples = [
|
|
1717
|
+
[
|
|
1718
|
+
{
|
|
1719
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1720
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1721
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1722
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
1723
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
|
|
1724
|
+
},
|
|
1725
|
+
[
|
|
1726
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1727
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1728
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1729
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1730
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
|
|
1731
|
+
]
|
|
1732
|
+
],
|
|
1733
|
+
[
|
|
1734
|
+
{
|
|
1735
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1736
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1737
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1738
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
|
|
1739
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
|
|
1740
|
+
},
|
|
1741
|
+
[
|
|
1742
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1743
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1744
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1745
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1746
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
|
|
1747
|
+
]
|
|
1748
|
+
],
|
|
1749
|
+
];
|
|
1750
|
+
examples.forEach(([expected, actual]) => {
|
|
1751
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1752
|
+
(0, chai_1.expect)(subDataService.compoundV3CloseSubData.decode(actual)).to.eql(expected);
|
|
1753
|
+
});
|
|
1754
|
+
});
|
|
1755
|
+
});
|
|
1756
|
+
});
|
|
1757
|
+
describe("When testing subDataService.aaveV3LeverageManagementOnPriceGeneric", () => {
|
|
1758
|
+
describe("encode()", () => {
|
|
1759
|
+
const examples = [
|
|
1760
|
+
[
|
|
1761
|
+
[
|
|
1762
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1763
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1764
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1765
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1766
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1767
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1768
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1769
|
+
],
|
|
1770
|
+
[
|
|
1771
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1772
|
+
0,
|
|
1773
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1774
|
+
1,
|
|
1775
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1776
|
+
200,
|
|
1777
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1778
|
+
]
|
|
1779
|
+
],
|
|
1780
|
+
[
|
|
1781
|
+
[
|
|
1782
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1783
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1784
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1785
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1786
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1787
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1788
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1789
|
+
],
|
|
1790
|
+
[
|
|
1791
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1792
|
+
2,
|
|
1793
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1794
|
+
1,
|
|
1795
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1796
|
+
200,
|
|
1797
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1798
|
+
]
|
|
1799
|
+
],
|
|
1800
|
+
];
|
|
1801
|
+
examples.forEach(([expected, actual]) => {
|
|
1802
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1803
|
+
(0, chai_1.expect)(subDataService.aaveV3LeverageManagementOnPriceGeneric.encode(...actual)).to.eql(expected);
|
|
1804
|
+
});
|
|
1805
|
+
});
|
|
1806
|
+
});
|
|
1807
|
+
describe("decode()", () => {
|
|
1808
|
+
const examples = [
|
|
1809
|
+
[
|
|
1810
|
+
{
|
|
1811
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1812
|
+
collAssetId: 0,
|
|
1813
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1814
|
+
debtAssetId: 1,
|
|
1815
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1816
|
+
targetRatio: 200,
|
|
1817
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1818
|
+
},
|
|
1819
|
+
[
|
|
1820
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1821
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1822
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1823
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1824
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1825
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1826
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1827
|
+
]
|
|
1828
|
+
],
|
|
1829
|
+
[
|
|
1830
|
+
{
|
|
1831
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1832
|
+
collAssetId: 2,
|
|
1833
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1834
|
+
debtAssetId: 1,
|
|
1835
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1836
|
+
targetRatio: 200,
|
|
1837
|
+
owner: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1838
|
+
},
|
|
1839
|
+
[
|
|
1840
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1841
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1842
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1843
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1844
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1845
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1846
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1847
|
+
]
|
|
1848
|
+
],
|
|
1849
|
+
];
|
|
1850
|
+
examples.forEach(([expected, actual]) => {
|
|
1851
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1852
|
+
(0, chai_1.expect)(subDataService.aaveV3LeverageManagementOnPriceGeneric.decode(actual)).to.eql(expected);
|
|
1853
|
+
});
|
|
1854
|
+
});
|
|
1855
|
+
});
|
|
1856
|
+
});
|
|
1857
|
+
describe("When testing subDataService.aaveV3CloseGenericSubData", () => {
|
|
1858
|
+
describe("encode()", () => {
|
|
1859
|
+
const examples = [
|
|
1860
|
+
// TAKE_PROFIT_IN_COLLATERAL
|
|
1861
|
+
[
|
|
1862
|
+
[
|
|
1863
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1864
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1865
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1866
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1867
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1868
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1869
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1870
|
+
],
|
|
1871
|
+
[
|
|
1872
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1873
|
+
0,
|
|
1874
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1875
|
+
1,
|
|
1876
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
|
|
1877
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1878
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1879
|
+
]
|
|
1880
|
+
],
|
|
1881
|
+
// STOP_LOSS_IN_COLLATERAL
|
|
1882
|
+
[
|
|
1883
|
+
[
|
|
1884
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1885
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1886
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1887
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1888
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1889
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1890
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1891
|
+
],
|
|
1892
|
+
[
|
|
1893
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1894
|
+
0,
|
|
1895
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1896
|
+
1,
|
|
1897
|
+
enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
|
|
1898
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1899
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1900
|
+
]
|
|
1901
|
+
],
|
|
1902
|
+
// TAKE_PROFIT_IN_DEBT
|
|
1903
|
+
[
|
|
1904
|
+
[
|
|
1905
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1906
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1907
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1908
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1909
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1910
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1911
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1912
|
+
],
|
|
1913
|
+
[
|
|
1914
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1915
|
+
0,
|
|
1916
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1917
|
+
1,
|
|
1918
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT,
|
|
1919
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1920
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1921
|
+
]
|
|
1922
|
+
],
|
|
1923
|
+
// STOP_LOSS_IN_DEBT
|
|
1924
|
+
[
|
|
1925
|
+
[
|
|
1926
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1927
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1928
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1929
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1930
|
+
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
1931
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1932
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1933
|
+
],
|
|
1934
|
+
[
|
|
1935
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1936
|
+
0,
|
|
1937
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1938
|
+
1,
|
|
1939
|
+
enums_1.CloseStrategyType.STOP_LOSS_IN_DEBT,
|
|
1940
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1941
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1942
|
+
]
|
|
1943
|
+
],
|
|
1944
|
+
// TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL
|
|
1945
|
+
[
|
|
1946
|
+
[
|
|
1947
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1948
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1949
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1950
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1951
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1952
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1953
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
1954
|
+
],
|
|
1955
|
+
[
|
|
1956
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
1957
|
+
0,
|
|
1958
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1959
|
+
1,
|
|
1960
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
1961
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1962
|
+
web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
1963
|
+
]
|
|
1964
|
+
],
|
|
1965
|
+
// TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT
|
|
1966
|
+
[
|
|
1967
|
+
[
|
|
1968
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1969
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1970
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1971
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1972
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
1973
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1974
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1975
|
+
],
|
|
1976
|
+
[
|
|
1977
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1978
|
+
2,
|
|
1979
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
1980
|
+
1,
|
|
1981
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
1982
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
1983
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
1984
|
+
]
|
|
1985
|
+
],
|
|
1986
|
+
// TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT
|
|
1987
|
+
[
|
|
1988
|
+
[
|
|
1989
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
1990
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
1991
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1992
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1993
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1994
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
1995
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1996
|
+
],
|
|
1997
|
+
[
|
|
1998
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
1999
|
+
2,
|
|
2000
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2001
|
+
1,
|
|
2002
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
2003
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2004
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2005
|
+
]
|
|
2006
|
+
],
|
|
2007
|
+
// TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL
|
|
2008
|
+
[
|
|
2009
|
+
[
|
|
2010
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2011
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2012
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2013
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2014
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
2015
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2016
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2017
|
+
],
|
|
2018
|
+
[
|
|
2019
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
2020
|
+
2,
|
|
2021
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2022
|
+
1,
|
|
2023
|
+
enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
2024
|
+
web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2025
|
+
web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2026
|
+
]
|
|
2027
|
+
],
|
|
2028
|
+
];
|
|
2029
|
+
examples.forEach(([expected, actual]) => {
|
|
2030
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2031
|
+
(0, chai_1.expect)(subDataService.aaveV3CloseGenericSubData.encode(...actual)).to.eql(expected);
|
|
2032
|
+
});
|
|
2033
|
+
});
|
|
2034
|
+
});
|
|
2035
|
+
describe("decode()", () => {
|
|
2036
|
+
const examples = [
|
|
2037
|
+
// TAKE_PROFIT_IN_COLLATERAL
|
|
2038
|
+
[
|
|
2039
|
+
{
|
|
2040
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
2041
|
+
collAssetId: 0,
|
|
2042
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2043
|
+
debtAssetId: 1,
|
|
2044
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
|
|
2045
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2046
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2047
|
+
},
|
|
2048
|
+
[
|
|
2049
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2050
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2051
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2052
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2053
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2054
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2055
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2056
|
+
]
|
|
2057
|
+
],
|
|
2058
|
+
// STOP_LOSS_IN_COLLATERAL
|
|
2059
|
+
[
|
|
2060
|
+
{
|
|
2061
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
2062
|
+
collAssetId: 0,
|
|
2063
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2064
|
+
debtAssetId: 1,
|
|
2065
|
+
closeType: enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
|
|
2066
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2067
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2068
|
+
},
|
|
2069
|
+
[
|
|
2070
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2071
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2072
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2073
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2074
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2075
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2076
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2077
|
+
]
|
|
2078
|
+
],
|
|
2079
|
+
// TAKE_PROFIT_IN_DEBT
|
|
2080
|
+
[
|
|
2081
|
+
{
|
|
2082
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
2083
|
+
collAssetId: 0,
|
|
2084
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2085
|
+
debtAssetId: 1,
|
|
2086
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT,
|
|
2087
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2088
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2089
|
+
},
|
|
2090
|
+
[
|
|
2091
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2092
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2093
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2094
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2095
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2096
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2097
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2098
|
+
]
|
|
2099
|
+
],
|
|
2100
|
+
// STOP_LOSS_IN_DEBT
|
|
2101
|
+
[
|
|
2102
|
+
{
|
|
2103
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
2104
|
+
collAssetId: 0,
|
|
2105
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2106
|
+
debtAssetId: 1,
|
|
2107
|
+
closeType: enums_1.CloseStrategyType.STOP_LOSS_IN_DEBT,
|
|
2108
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2109
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2110
|
+
},
|
|
2111
|
+
[
|
|
2112
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2113
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2114
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2115
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2116
|
+
'0x0000000000000000000000000000000000000000000000000000000000000003',
|
|
2117
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2118
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2119
|
+
]
|
|
2120
|
+
],
|
|
2121
|
+
// TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL
|
|
2122
|
+
[
|
|
2123
|
+
{
|
|
2124
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
2125
|
+
collAssetId: 0,
|
|
2126
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2127
|
+
debtAssetId: 1,
|
|
2128
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
2129
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2130
|
+
owner: web3Utils.toChecksumAddress('0x1234567890123456789012345678901234567890'),
|
|
2131
|
+
},
|
|
2132
|
+
[
|
|
2133
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2134
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2135
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2136
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2137
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2138
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2139
|
+
'0x0000000000000000000000001234567890123456789012345678901234567890',
|
|
2140
|
+
]
|
|
2141
|
+
],
|
|
2142
|
+
// TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT
|
|
2143
|
+
[
|
|
2144
|
+
{
|
|
2145
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
2146
|
+
collAssetId: 2,
|
|
2147
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2148
|
+
debtAssetId: 1,
|
|
2149
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL_AND_STOP_LOSS_IN_DEBT,
|
|
2150
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2151
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2152
|
+
},
|
|
2153
|
+
[
|
|
2154
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2155
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2156
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2157
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2158
|
+
'0x0000000000000000000000000000000000000000000000000000000000000005',
|
|
2159
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2160
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2161
|
+
]
|
|
2162
|
+
],
|
|
2163
|
+
// TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT
|
|
2164
|
+
[
|
|
2165
|
+
{
|
|
2166
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
2167
|
+
collAssetId: 2,
|
|
2168
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2169
|
+
debtAssetId: 1,
|
|
2170
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
2171
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2172
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2173
|
+
},
|
|
2174
|
+
[
|
|
2175
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2176
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2177
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2178
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2179
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
2180
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2181
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2182
|
+
]
|
|
2183
|
+
],
|
|
2184
|
+
// TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL
|
|
2185
|
+
[
|
|
2186
|
+
{
|
|
2187
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
2188
|
+
collAssetId: 2,
|
|
2189
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2190
|
+
debtAssetId: 1,
|
|
2191
|
+
closeType: enums_1.CloseStrategyType.TAKE_PROFIT_IN_DEBT_AND_STOP_LOSS_IN_COLLATERAL,
|
|
2192
|
+
marketAddr: web3Utils.toChecksumAddress('0x87870Bca3F3fD6335C3F4ce8392D69d0B4161d39'),
|
|
2193
|
+
owner: web3Utils.toChecksumAddress('0x0000000000000000000000000000000000000000'),
|
|
2194
|
+
},
|
|
2195
|
+
[
|
|
2196
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2197
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2198
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2199
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2200
|
+
'0x0000000000000000000000000000000000000000000000000000000000000007',
|
|
2201
|
+
'0x00000000000000000000000087870bca3f3fd6335c3f4ce8392d69d0b4161d39',
|
|
2202
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2203
|
+
]
|
|
2204
|
+
],
|
|
2205
|
+
];
|
|
2206
|
+
examples.forEach(([expected, actual]) => {
|
|
2207
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2208
|
+
(0, chai_1.expect)(subDataService.aaveV3CloseGenericSubData.decode(actual)).to.eql(expected);
|
|
2209
|
+
});
|
|
2210
|
+
});
|
|
2211
|
+
});
|
|
2212
|
+
});
|
|
2213
|
+
describe('When testing subDataService.sparkLeverageManagementOnPriceSubData', () => {
|
|
2214
|
+
describe('encode()', () => {
|
|
2215
|
+
const examples = [
|
|
2216
|
+
[
|
|
2217
|
+
[
|
|
2218
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
2219
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2220
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
2221
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
2222
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2223
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
2224
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
2225
|
+
],
|
|
2226
|
+
[
|
|
2227
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
|
|
2228
|
+
0,
|
|
2229
|
+
web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
|
|
2230
|
+
1,
|
|
2231
|
+
web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2232
|
+
200,
|
|
2233
|
+
]
|
|
2234
|
+
]
|
|
2235
|
+
];
|
|
2236
|
+
examples.forEach(([expected, actual]) => {
|
|
2237
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2238
|
+
(0, chai_1.expect)(subDataService.sparkLeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
2239
|
+
});
|
|
2240
|
+
});
|
|
2241
|
+
});
|
|
2242
|
+
describe('decode()', () => {
|
|
2243
|
+
const examples = [
|
|
2244
|
+
[
|
|
2245
|
+
{
|
|
2246
|
+
collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
|
|
2247
|
+
collAssetId: 2,
|
|
2248
|
+
debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
|
|
2249
|
+
debtAssetId: 4,
|
|
2250
|
+
marketAddr: web3Utils.toChecksumAddress('0x02C3eA4e34C0cBd694D2adFa2c690EECbC1793eE'),
|
|
2251
|
+
targetRatio: 175
|
|
2252
|
+
},
|
|
2253
|
+
[
|
|
2254
|
+
'0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
2255
|
+
'0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
2256
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
2257
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
2258
|
+
'0x00000000000000000000000002c3ea4e34c0cbd694d2adfa2c690eecbc1793ee',
|
|
2259
|
+
'0x00000000000000000000000000000000000000000000000018493fba64ef0000'
|
|
2260
|
+
]
|
|
2261
|
+
]
|
|
2262
|
+
];
|
|
2263
|
+
examples.forEach(([expected, actual]) => {
|
|
2264
|
+
it(`Given ${JSON.stringify(actual)} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2265
|
+
(0, chai_1.expect)(subDataService.sparkLeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
2266
|
+
});
|
|
2267
|
+
});
|
|
2268
|
+
});
|
|
2269
|
+
});
|
|
2270
|
+
describe('When testing subDataService.aaveV4LeverageManagementSubData', () => {
|
|
2271
|
+
describe('encode()', () => {
|
|
2272
|
+
const examples = [
|
|
2273
|
+
[
|
|
2274
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2275
|
+
[web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), enums_1.RatioState.UNDER, 150]
|
|
2276
|
+
],
|
|
2277
|
+
];
|
|
2278
|
+
examples.forEach(([expected, actual]) => {
|
|
2279
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
2280
|
+
(0, chai_1.expect)(subDataService.aaveV4LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
2281
|
+
});
|
|
2282
|
+
});
|
|
2283
|
+
});
|
|
2284
|
+
describe('decode()', () => {
|
|
2285
|
+
const examples = [
|
|
2286
|
+
[
|
|
2287
|
+
{
|
|
2288
|
+
spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
2289
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2290
|
+
ratioState: enums_1.RatioState.UNDER,
|
|
2291
|
+
targetRatio: 150,
|
|
2292
|
+
},
|
|
2293
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x00000000000000000000000000000000000000000000000014d1120d7b160000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2294
|
+
],
|
|
2295
|
+
];
|
|
2296
|
+
examples.forEach(([expected, actual]) => {
|
|
2297
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2298
|
+
(0, chai_1.expect)(subDataService.aaveV4LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
2299
|
+
});
|
|
2300
|
+
});
|
|
2301
|
+
});
|
|
2302
|
+
});
|
|
2303
|
+
describe('When testing subDataService.aaveV4LeverageManagementOnPriceSubData', () => {
|
|
2304
|
+
describe('encode()', () => {
|
|
2305
|
+
const examples = [
|
|
2306
|
+
[
|
|
2307
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2308
|
+
[
|
|
2309
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2310
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
2311
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 20,
|
|
2312
|
+
enums_1.RatioState.OVER, 160
|
|
2313
|
+
]
|
|
2314
|
+
],
|
|
2315
|
+
];
|
|
2316
|
+
examples.forEach(([expected, actual]) => {
|
|
2317
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
2318
|
+
(0, chai_1.expect)(subDataService.aaveV4LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
2319
|
+
});
|
|
2320
|
+
});
|
|
2321
|
+
});
|
|
2322
|
+
describe('decode()', () => {
|
|
2323
|
+
const examples = [
|
|
2324
|
+
[
|
|
2325
|
+
{
|
|
2326
|
+
spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
2327
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2328
|
+
collAsset: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
2329
|
+
collAssetId: 10,
|
|
2330
|
+
debtAsset: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
2331
|
+
debtAssetId: 20,
|
|
2332
|
+
ratioState: enums_1.RatioState.OVER,
|
|
2333
|
+
targetRatio: 160,
|
|
2334
|
+
},
|
|
2335
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000016345785d8a00000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2336
|
+
],
|
|
2337
|
+
];
|
|
2338
|
+
examples.forEach(([expected, actual]) => {
|
|
2339
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2340
|
+
(0, chai_1.expect)(subDataService.aaveV4LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
2341
|
+
});
|
|
2342
|
+
});
|
|
2343
|
+
});
|
|
2344
|
+
});
|
|
2345
|
+
describe('When testing subDataService.aaveV4CloseSubData', () => {
|
|
2346
|
+
describe('encode()', () => {
|
|
2347
|
+
const examples = [
|
|
2348
|
+
[
|
|
2349
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2350
|
+
[
|
|
2351
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2352
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
2353
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 20,
|
|
2354
|
+
enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL
|
|
2355
|
+
]
|
|
2356
|
+
],
|
|
2357
|
+
];
|
|
2358
|
+
examples.forEach(([expected, actual]) => {
|
|
2359
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
2360
|
+
(0, chai_1.expect)(subDataService.aaveV4CloseSubData.encode(...actual)).to.eql(expected);
|
|
2361
|
+
});
|
|
2362
|
+
});
|
|
2363
|
+
});
|
|
2364
|
+
describe('decode()', () => {
|
|
2365
|
+
const examples = [
|
|
2366
|
+
[
|
|
2367
|
+
{
|
|
2368
|
+
spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
2369
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2370
|
+
collAsset: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
2371
|
+
collAssetId: 10,
|
|
2372
|
+
debtAsset: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
2373
|
+
debtAssetId: 20,
|
|
2374
|
+
closeType: enums_1.CloseStrategyType.STOP_LOSS_IN_COLLATERAL,
|
|
2375
|
+
},
|
|
2376
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2377
|
+
],
|
|
2378
|
+
];
|
|
2379
|
+
examples.forEach(([expected, actual]) => {
|
|
2380
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2381
|
+
(0, chai_1.expect)(subDataService.aaveV4CloseSubData.decode(actual)).to.eql(expected);
|
|
2382
|
+
});
|
|
2383
|
+
});
|
|
2384
|
+
});
|
|
2385
|
+
});
|
|
2386
|
+
describe('When testing subDataService.aaveV4CollateralSwitchSubData', () => {
|
|
2387
|
+
describe('encode()', () => {
|
|
2388
|
+
const examples = [
|
|
2389
|
+
[
|
|
2390
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2391
|
+
[
|
|
2392
|
+
web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2393
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'), 10,
|
|
2394
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), 20,
|
|
2395
|
+
'1000000000000000000'
|
|
2396
|
+
]
|
|
2397
|
+
],
|
|
2398
|
+
];
|
|
2399
|
+
examples.forEach(([expected, actual]) => {
|
|
2400
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
2401
|
+
(0, chai_1.expect)(subDataService.aaveV4CollateralSwitchSubData.encode(...actual)).to.eql(expected);
|
|
2402
|
+
});
|
|
2403
|
+
});
|
|
2404
|
+
});
|
|
2405
|
+
describe('decode()', () => {
|
|
2406
|
+
const examples = [
|
|
2407
|
+
[
|
|
2408
|
+
{
|
|
2409
|
+
spoke: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
2410
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
|
|
2411
|
+
fromAsset: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
2412
|
+
fromAssetId: 10,
|
|
2413
|
+
toAsset: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
2414
|
+
toAssetId: 20,
|
|
2415
|
+
amountToSwitch: '1000000000000000000'
|
|
2416
|
+
},
|
|
2417
|
+
["0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e", "0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "0x0000000000000000000000000000000000000000000000000000000000000014", "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"],
|
|
2418
|
+
],
|
|
2419
|
+
];
|
|
2420
|
+
examples.forEach(([expected, actual]) => {
|
|
2421
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
2422
|
+
(0, chai_1.expect)(subDataService.aaveV4CollateralSwitchSubData.decode(actual)).to.eql(expected);
|
|
2423
|
+
});
|
|
2424
|
+
});
|
|
2425
|
+
});
|
|
2426
|
+
});
|
|
2427
|
+
});
|