@defisaver/automation-sdk 3.2.5 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.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 +33 -33
- package/cjs/automation/private/StrategiesAutomation.js +189 -189
- package/cjs/automation/private/StrategiesAutomation.test.d.ts +1 -1
- package/cjs/automation/private/StrategiesAutomation.test.js +671 -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 +28 -28
- package/cjs/constants/index.js +674 -564
- package/cjs/index.d.ts +23 -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 +49 -49
- package/cjs/services/ethereumService.test.d.ts +1 -1
- package/cjs/services/ethereumService.test.js +242 -242
- package/cjs/services/strategiesService.d.ts +2 -2
- package/cjs/services/strategiesService.js +946 -898
- package/cjs/services/strategiesService.test.d.ts +1 -1
- package/cjs/services/strategiesService.test.js +110 -110
- package/cjs/services/strategySubService.d.ts +113 -111
- package/cjs/services/strategySubService.js +328 -314
- package/cjs/services/strategySubService.test.d.ts +1 -1
- package/cjs/services/strategySubService.test.js +1058 -936
- package/cjs/services/subDataService.d.ts +282 -261
- package/cjs/services/subDataService.js +740 -683
- package/cjs/services/subDataService.test.d.ts +1 -1
- package/cjs/services/subDataService.test.js +1458 -1282
- package/cjs/services/triggerService.d.ts +268 -249
- package/cjs/services/triggerService.js +509 -473
- package/cjs/services/triggerService.test.d.ts +1 -1
- package/cjs/services/triggerService.test.js +1139 -1045
- package/cjs/services/utils.d.ts +30 -30
- package/cjs/services/utils.js +182 -182
- package/cjs/services/utils.test.d.ts +1 -1
- package/cjs/services/utils.test.js +376 -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 +253 -226
- package/cjs/types/enums.js +279 -252
- package/cjs/types/index.d.ts +264 -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 +33 -33
- package/esm/automation/private/StrategiesAutomation.js +183 -183
- package/esm/automation/private/StrategiesAutomation.test.d.ts +1 -1
- package/esm/automation/private/StrategiesAutomation.test.js +666 -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 +28 -28
- package/esm/constants/index.js +668 -558
- package/esm/index.d.ts +23 -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 +41 -41
- package/esm/services/ethereumService.test.d.ts +1 -1
- package/esm/services/ethereumService.test.js +237 -237
- package/esm/services/strategiesService.d.ts +2 -2
- package/esm/services/strategiesService.js +916 -868
- package/esm/services/strategiesService.test.d.ts +1 -1
- package/esm/services/strategiesService.test.js +108 -108
- package/esm/services/strategySubService.d.ts +113 -111
- package/esm/services/strategySubService.js +299 -285
- package/esm/services/strategySubService.test.d.ts +1 -1
- package/esm/services/strategySubService.test.js +1030 -908
- package/esm/services/subDataService.d.ts +282 -261
- package/esm/services/subDataService.js +734 -677
- package/esm/services/subDataService.test.d.ts +1 -1
- package/esm/services/subDataService.test.js +1430 -1254
- package/esm/services/triggerService.d.ts +268 -249
- package/esm/services/triggerService.js +480 -444
- package/esm/services/triggerService.test.d.ts +1 -1
- package/esm/services/triggerService.test.js +1114 -1020
- package/esm/services/utils.d.ts +30 -30
- package/esm/services/utils.js +131 -131
- package/esm/services/utils.test.d.ts +1 -1
- package/esm/services/utils.test.js +348 -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 +253 -226
- package/esm/types/enums.js +276 -249
- package/esm/types/index.d.ts +264 -248
- package/esm/types/index.js +1 -1
- package/package.json +60 -60
- 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 +663 -663
- package/src/automation/private/StrategiesAutomation.ts +254 -254
- 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 +702 -593
- package/src/index.ts +39 -39
- package/src/services/contractService.ts +77 -77
- package/src/services/ethereumService.test.ts +257 -257
- package/src/services/ethereumService.ts +69 -69
- package/src/services/strategiesService.test.ts +105 -105
- package/src/services/strategiesService.ts +1219 -1158
- package/src/services/strategySubService.test.ts +1250 -1122
- package/src/services/strategySubService.ts +685 -648
- package/src/services/subDataService.test.ts +1546 -1387
- package/src/services/subDataService.ts +1024 -934
- package/src/services/triggerService.test.ts +1234 -1130
- package/src/services/triggerService.ts +659 -602
- package/src/services/utils.test.ts +430 -430
- package/src/services/utils.ts +162 -162
- package/src/types/enums.ts +273 -246
- package/src/types/index.ts +333 -312
- package/tsconfig.esm.json +8 -8
- package/tsconfig.json +22 -22
|
@@ -1,1387 +1,1546 @@
|
|
|
1
|
-
import Dec from 'decimal.js';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
import { getAssetInfo } from '@defisaver/tokens';
|
|
4
|
-
import * as web3Utils from 'web3-utils';
|
|
5
|
-
|
|
6
|
-
import { ChainId, OrderType, RatioState } from '../types/enums';
|
|
7
|
-
import type { EthereumAddress, SubData } from '../types';
|
|
8
|
-
|
|
9
|
-
import '../configuration';
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
describe('decode()', () => {
|
|
60
|
-
const examples: Array<[{
|
|
61
|
-
[
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
'
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
describe('
|
|
105
|
-
const examples: Array<[
|
|
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
|
-
examples.forEach(([expected, actual]) => {
|
|
194
|
-
it(`Given ${actual} should return expected value: ${
|
|
195
|
-
expect(
|
|
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
|
-
|
|
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
|
-
{ targetRatio:
|
|
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
|
-
web3Utils.toChecksumAddress(
|
|
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
|
-
examples.forEach(([expected, actual]) => {
|
|
472
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
473
|
-
expect(compoundV3LeverageManagementSubData.
|
|
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
|
-
describe('
|
|
586
|
-
const examples: Array<[
|
|
587
|
-
[
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
'
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
],
|
|
594
|
-
[
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
'
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
],
|
|
601
|
-
];
|
|
602
|
-
|
|
603
|
-
examples.forEach(([expected, actual]) => {
|
|
604
|
-
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
605
|
-
expect(liquityPaybackUsingChickenBondSubData.
|
|
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
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
web3Utils.toChecksumAddress(getAssetInfo('
|
|
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
|
-
describe('
|
|
901
|
-
const examples: Array<[
|
|
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
|
-
describe('
|
|
957
|
-
const examples: Array<[
|
|
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
|
-
|
|
1019
|
-
|
|
1020
|
-
[
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
'
|
|
1283
|
-
'
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
'
|
|
1287
|
-
'
|
|
1288
|
-
'
|
|
1289
|
-
'
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
[
|
|
1307
|
-
'
|
|
1308
|
-
'
|
|
1309
|
-
'
|
|
1310
|
-
'
|
|
1311
|
-
'
|
|
1312
|
-
'
|
|
1313
|
-
'
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
'
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
web3Utils.toChecksumAddress(
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
'
|
|
1371
|
-
'
|
|
1372
|
-
'
|
|
1373
|
-
'
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1
|
+
import Dec from 'decimal.js';
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import { getAssetInfo } from '@defisaver/tokens';
|
|
4
|
+
import * as web3Utils from 'web3-utils';
|
|
5
|
+
|
|
6
|
+
import { ChainId, CloseStrategyType, CloseToAssetType, OrderType, RatioState } from '../types/enums';
|
|
7
|
+
import type { EthereumAddress, SubData } from '../types';
|
|
8
|
+
|
|
9
|
+
import '../configuration';
|
|
10
|
+
import * as subDataService from './subDataService';
|
|
11
|
+
import { AAVE_V3_VARIABLE_BORROW_RATE } from '../constants';
|
|
12
|
+
|
|
13
|
+
describe('Feature: subDataService.ts', () => {
|
|
14
|
+
|
|
15
|
+
describe('When testing subDataService.makerRepayFromSavingsSubData', () => {
|
|
16
|
+
describe('encode()', () => {
|
|
17
|
+
const examples: Array<[SubData, [vaultId: number, targetRatioPercentage: number, chainId: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress]]> = [
|
|
18
|
+
[
|
|
19
|
+
[
|
|
20
|
+
'0x000000000000000000000000000000000000000000000000000000000000007b', '0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
21
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
22
|
+
],
|
|
23
|
+
[123, 120, ChainId.Ethereum, web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address), web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e')]
|
|
24
|
+
],
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
examples.forEach(([expected, actual]) => {
|
|
28
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
29
|
+
expect(subDataService.makerRepayFromSavingsSubData.encode(...actual)).to.eql(expected);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('decode()', () => {
|
|
35
|
+
const examples: Array<[{ vaultId: number, daiAddr: string, mcdManagerAddr: string, targetRatio: number }, SubData]> = [
|
|
36
|
+
[
|
|
37
|
+
{
|
|
38
|
+
vaultId: 123,
|
|
39
|
+
daiAddr: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
40
|
+
mcdManagerAddr: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
|
|
41
|
+
targetRatio: 120,
|
|
42
|
+
},
|
|
43
|
+
[
|
|
44
|
+
'0x000000000000000000000000000000000000000000000000000000000000007b', '0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
45
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
46
|
+
],
|
|
47
|
+
],
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
examples.forEach(([expected, actual]) => {
|
|
51
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
52
|
+
expect(subDataService.makerRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('When testing subDataService.liquityRepayFromSavingsSubData', () => {
|
|
59
|
+
describe('decode()', () => {
|
|
60
|
+
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
61
|
+
[
|
|
62
|
+
{ targetRatio: 120 },
|
|
63
|
+
[
|
|
64
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
65
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
66
|
+
],
|
|
67
|
+
],
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
examples.forEach(([expected, actual]) => {
|
|
71
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
72
|
+
expect(subDataService.liquityRepayFromSavingsSubData.decode(actual)).to.eql(expected);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('When testing subDataService.makerCloseSubData', () => {
|
|
79
|
+
describe('encode()', () => {
|
|
80
|
+
const examples: Array<[SubData, [vaultId: number, closeToAssetAddr: EthereumAddress, chainId: ChainId, daiAddr?: EthereumAddress, mcdCdpManagerAddr?: EthereumAddress]]> = [
|
|
81
|
+
[
|
|
82
|
+
[
|
|
83
|
+
'0x0000000000000000000000000000000000000000000000000000000000000141', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
84
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
85
|
+
],
|
|
86
|
+
[321, web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address), ChainId.Ethereum, web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address), web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e')]
|
|
87
|
+
],
|
|
88
|
+
[
|
|
89
|
+
[
|
|
90
|
+
'0x00000000000000000000000000000000000000000000000000000000000001a4', '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
91
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002439d218133afab8f2b819b1066c7e434ad94e9e',
|
|
92
|
+
],
|
|
93
|
+
[420, web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address), ChainId.Ethereum, web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address), web3Utils.toChecksumAddress('0x2439d218133AFaB8F2B819B1066c7E434Ad94E9e')]
|
|
94
|
+
],
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
examples.forEach(([expected, actual]) => {
|
|
98
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
99
|
+
expect(subDataService.makerCloseSubData.encode(...actual)).to.eql(expected);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe('decode()', () => {
|
|
105
|
+
const examples: Array<[{ vaultId: number, closeToAssetAddr: EthereumAddress }, SubData]> = [
|
|
106
|
+
[
|
|
107
|
+
{
|
|
108
|
+
vaultId: 321,
|
|
109
|
+
closeToAssetAddr: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
110
|
+
},
|
|
111
|
+
[
|
|
112
|
+
'0x0000000000000000000000000000000000000000000000000000000000000141', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
113
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
114
|
+
],
|
|
115
|
+
],
|
|
116
|
+
[
|
|
117
|
+
{
|
|
118
|
+
vaultId: 420,
|
|
119
|
+
closeToAssetAddr: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Ethereum).address),
|
|
120
|
+
},
|
|
121
|
+
[
|
|
122
|
+
'0x00000000000000000000000000000000000000000000000000000000000001a4', '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
123
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000002439d218133afab8f2b819b1066c7e434ad94e9e',
|
|
124
|
+
],
|
|
125
|
+
],
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
examples.forEach(([expected, actual]) => {
|
|
129
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
130
|
+
expect(subDataService.makerCloseSubData.decode(actual)).to.eql(expected);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('When testing subDataService.makerLeverageManagementSubData', () => {
|
|
137
|
+
describe('decode()', () => {
|
|
138
|
+
const examples: Array<[{ vaultId: number, targetRatio: number }, SubData]> = [
|
|
139
|
+
[
|
|
140
|
+
{ vaultId: 321, targetRatio: 200 },
|
|
141
|
+
[
|
|
142
|
+
'0x0000000000000000000000000000000000000000000000000000000000000141', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
143
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
144
|
+
],
|
|
145
|
+
],
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
examples.forEach(([expected, actual]) => {
|
|
149
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
150
|
+
expect(subDataService.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
describe('When testing subDataService.liquityLeverageManagementSubData', () => {
|
|
157
|
+
describe('decode()', () => {
|
|
158
|
+
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
159
|
+
[
|
|
160
|
+
{ targetRatio: 200 },
|
|
161
|
+
[
|
|
162
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
163
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
164
|
+
],
|
|
165
|
+
],
|
|
166
|
+
];
|
|
167
|
+
|
|
168
|
+
examples.forEach(([expected, actual]) => {
|
|
169
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
170
|
+
expect(subDataService.liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
describe('When testing subDataService.liquityCloseSubData', () => {
|
|
177
|
+
describe('encode()', () => {
|
|
178
|
+
const examples: Array<[SubData, [closeToAssetAddr: EthereumAddress, chainId: ChainId, collAddr?: EthereumAddress, debtAddr?: EthereumAddress]]> = [
|
|
179
|
+
[
|
|
180
|
+
[
|
|
181
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
182
|
+
],
|
|
183
|
+
[web3Utils.toChecksumAddress(getAssetInfo('LUSD', ChainId.Ethereum).address), ChainId.Ethereum, web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address), web3Utils.toChecksumAddress(getAssetInfo('LUSD', ChainId.Ethereum).address)]
|
|
184
|
+
],
|
|
185
|
+
[
|
|
186
|
+
[
|
|
187
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
188
|
+
],
|
|
189
|
+
[web3Utils.toChecksumAddress(getAssetInfo('LUSD', ChainId.Ethereum).address), ChainId.Ethereum]
|
|
190
|
+
],
|
|
191
|
+
];
|
|
192
|
+
|
|
193
|
+
examples.forEach(([expected, actual]) => {
|
|
194
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
195
|
+
expect(subDataService.liquityCloseSubData.encode(...actual)).to.eql(expected);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
describe('decode()', () => {
|
|
201
|
+
const examples: Array<[{ closeToAssetAddr: EthereumAddress, debtAddr: string }, SubData]> = [
|
|
202
|
+
[
|
|
203
|
+
{
|
|
204
|
+
closeToAssetAddr: web3Utils.toChecksumAddress(getAssetInfo('LUSD', ChainId.Ethereum).address),
|
|
205
|
+
debtAddr: web3Utils.toChecksumAddress(getAssetInfo('LUSD', ChainId.Ethereum).address),
|
|
206
|
+
},
|
|
207
|
+
[
|
|
208
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
209
|
+
],
|
|
210
|
+
],
|
|
211
|
+
[
|
|
212
|
+
{
|
|
213
|
+
closeToAssetAddr: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
214
|
+
debtAddr: web3Utils.toChecksumAddress(getAssetInfo('LUSD', ChainId.Ethereum).address),
|
|
215
|
+
},
|
|
216
|
+
[
|
|
217
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
218
|
+
],
|
|
219
|
+
],
|
|
220
|
+
];
|
|
221
|
+
|
|
222
|
+
examples.forEach(([expected, actual]) => {
|
|
223
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
224
|
+
expect(subDataService.liquityCloseSubData.decode(actual)).to.eql(expected);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe('When testing subDataService.aaveV2LeverageManagementSubData', () => {
|
|
231
|
+
describe('encode()', () => {
|
|
232
|
+
const examples: Array<[[string, string, string, string, boolean], [triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean]]> = [
|
|
233
|
+
[
|
|
234
|
+
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
235
|
+
[160, 220, 180, 190, true]
|
|
236
|
+
],
|
|
237
|
+
[
|
|
238
|
+
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
239
|
+
[160, 200, 180, 190, false]
|
|
240
|
+
],
|
|
241
|
+
];
|
|
242
|
+
|
|
243
|
+
examples.forEach(([expected, actual]) => {
|
|
244
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
245
|
+
expect(subDataService.aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
describe('decode()', () => {
|
|
251
|
+
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
252
|
+
[
|
|
253
|
+
{ targetRatio: 200 },
|
|
254
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
255
|
+
],
|
|
256
|
+
[
|
|
257
|
+
{ targetRatio: 123 },
|
|
258
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
259
|
+
],
|
|
260
|
+
];
|
|
261
|
+
|
|
262
|
+
examples.forEach(([expected, actual]) => {
|
|
263
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
264
|
+
expect(subDataService.aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
describe('When testing subDataService.aaveV3LeverageManagementSubData', () => {
|
|
271
|
+
describe('decode()', () => {
|
|
272
|
+
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
273
|
+
[
|
|
274
|
+
{ targetRatio: 200 },
|
|
275
|
+
['0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
276
|
+
],
|
|
277
|
+
[
|
|
278
|
+
{ targetRatio: 123 },
|
|
279
|
+
['0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
280
|
+
],
|
|
281
|
+
];
|
|
282
|
+
|
|
283
|
+
examples.forEach(([expected, actual]) => {
|
|
284
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
285
|
+
expect(subDataService.aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
describe('When testing subDataService.aaveV3QuotePriceSubData', () => {
|
|
292
|
+
describe('encode()', () => {
|
|
293
|
+
const examples: Array<[SubData, [collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, nullAddress?: EthereumAddress]]> = [
|
|
294
|
+
[
|
|
295
|
+
[
|
|
296
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
297
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
298
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
299
|
+
],
|
|
300
|
+
[
|
|
301
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
302
|
+
2,
|
|
303
|
+
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
304
|
+
4,
|
|
305
|
+
]
|
|
306
|
+
],
|
|
307
|
+
[
|
|
308
|
+
[
|
|
309
|
+
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
310
|
+
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
311
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
312
|
+
],
|
|
313
|
+
[
|
|
314
|
+
web3Utils.toChecksumAddress(getAssetInfo('wstETH', ChainId.Arbitrum).address),
|
|
315
|
+
6,
|
|
316
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
317
|
+
2,
|
|
318
|
+
]
|
|
319
|
+
],
|
|
320
|
+
];
|
|
321
|
+
|
|
322
|
+
examples.forEach(([expected, actual]) => {
|
|
323
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
324
|
+
expect(subDataService.aaveV3QuotePriceSubData.encode(...actual)).to.eql(expected);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
describe('decode()', () => {
|
|
330
|
+
const examples: Array<[{ collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number }, SubData]> = [
|
|
331
|
+
[
|
|
332
|
+
{
|
|
333
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
334
|
+
collAssetId: 2,
|
|
335
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
336
|
+
debtAssetId: 4,
|
|
337
|
+
},
|
|
338
|
+
[
|
|
339
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
340
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
341
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
342
|
+
],
|
|
343
|
+
],
|
|
344
|
+
[
|
|
345
|
+
{
|
|
346
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('wstETH', ChainId.Arbitrum).address),
|
|
347
|
+
collAssetId: 6,
|
|
348
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
349
|
+
debtAssetId: 2,
|
|
350
|
+
},
|
|
351
|
+
[
|
|
352
|
+
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
353
|
+
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
354
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
355
|
+
],
|
|
356
|
+
],
|
|
357
|
+
];
|
|
358
|
+
|
|
359
|
+
examples.forEach(([expected, actual]) => {
|
|
360
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
361
|
+
expect(subDataService.aaveV3QuotePriceSubData.decode(actual)).to.eql(expected);
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
describe('When testing subDataService.compoundV2LeverageManagementSubData', () => {
|
|
368
|
+
describe('encode()', () => {
|
|
369
|
+
const examples: Array<[[string, string, string, string, boolean], [triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean]]> = [
|
|
370
|
+
[
|
|
371
|
+
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
372
|
+
[160, 220, 180, 190, true]
|
|
373
|
+
],
|
|
374
|
+
[
|
|
375
|
+
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
376
|
+
[160, 200, 180, 190, false]
|
|
377
|
+
],
|
|
378
|
+
];
|
|
379
|
+
|
|
380
|
+
examples.forEach(([expected, actual]) => {
|
|
381
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
382
|
+
expect(subDataService.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
describe('decode()', () => {
|
|
388
|
+
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
389
|
+
[
|
|
390
|
+
{ targetRatio: 200 },
|
|
391
|
+
['0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
392
|
+
],
|
|
393
|
+
[
|
|
394
|
+
{ targetRatio: 123 },
|
|
395
|
+
['0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
396
|
+
],
|
|
397
|
+
];
|
|
398
|
+
|
|
399
|
+
examples.forEach(([expected, actual]) => {
|
|
400
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
401
|
+
expect(subDataService.compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
describe('When testing subDataService.compoundV3LeverageManagementSubData', () => {
|
|
408
|
+
describe('encode()', () => {
|
|
409
|
+
const examples: Array<[[EthereumAddress, EthereumAddress, string, string, string, string, boolean, boolean], [market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean]]> = [
|
|
410
|
+
[
|
|
411
|
+
[
|
|
412
|
+
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
413
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
414
|
+
new Dec(160).mul(1e16).toString(),
|
|
415
|
+
new Dec(220).mul(1e16).toString(),
|
|
416
|
+
new Dec(180).mul(1e16).toString(),
|
|
417
|
+
new Dec(190).mul(1e16).toString(),
|
|
418
|
+
true, false,
|
|
419
|
+
],
|
|
420
|
+
[
|
|
421
|
+
web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
422
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
423
|
+
160, 220, 180, 190,
|
|
424
|
+
true, false,
|
|
425
|
+
]
|
|
426
|
+
],
|
|
427
|
+
[
|
|
428
|
+
[
|
|
429
|
+
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
430
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
431
|
+
new Dec(160).mul(1e16).toString(),
|
|
432
|
+
new Dec(210).mul(1e16).toString(),
|
|
433
|
+
new Dec(180).mul(1e16).toString(),
|
|
434
|
+
new Dec(190).mul(1e16).toString(),
|
|
435
|
+
false, true,
|
|
436
|
+
],
|
|
437
|
+
[
|
|
438
|
+
web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
|
|
439
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
440
|
+
160, 210, 180, 190,
|
|
441
|
+
false, true,
|
|
442
|
+
]
|
|
443
|
+
],
|
|
444
|
+
];
|
|
445
|
+
|
|
446
|
+
examples.forEach(([expected, actual]) => {
|
|
447
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
448
|
+
expect(subDataService.compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
describe('decode()', () => {
|
|
454
|
+
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
455
|
+
[
|
|
456
|
+
{ targetRatio: 123 },
|
|
457
|
+
[
|
|
458
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
459
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
460
|
+
],
|
|
461
|
+
],
|
|
462
|
+
[
|
|
463
|
+
{ targetRatio: 200 },
|
|
464
|
+
[
|
|
465
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
466
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
467
|
+
],
|
|
468
|
+
],
|
|
469
|
+
];
|
|
470
|
+
|
|
471
|
+
examples.forEach(([expected, actual]) => {
|
|
472
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
473
|
+
expect(subDataService.compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
describe('When testing subDataService.morphoAaveV2LeverageManagementSubData', () => {
|
|
480
|
+
describe('encode()', () => {
|
|
481
|
+
const examples: Array<[[string, string, string, string, boolean], [triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean]]> = [
|
|
482
|
+
[
|
|
483
|
+
[new Dec(160).mul(1e16).toString(), new Dec(220).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), true],
|
|
484
|
+
[160, 220, 180, 190, true]
|
|
485
|
+
],
|
|
486
|
+
[
|
|
487
|
+
[new Dec(160).mul(1e16).toString(), new Dec(200).mul(1e16).toString(), new Dec(180).mul(1e16).toString(), new Dec(190).mul(1e16).toString(), false],
|
|
488
|
+
[160, 200, 180, 190, false]
|
|
489
|
+
],
|
|
490
|
+
];
|
|
491
|
+
|
|
492
|
+
examples.forEach(([expected, actual]) => {
|
|
493
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
494
|
+
expect(subDataService.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
495
|
+
});
|
|
496
|
+
});
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
describe('decode()', () => {
|
|
500
|
+
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
501
|
+
[
|
|
502
|
+
{ targetRatio: 200 },
|
|
503
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
504
|
+
],
|
|
505
|
+
[
|
|
506
|
+
{ targetRatio: 123 },
|
|
507
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
508
|
+
],
|
|
509
|
+
];
|
|
510
|
+
|
|
511
|
+
examples.forEach(([expected, actual]) => {
|
|
512
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
513
|
+
expect(subDataService.morphoAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
514
|
+
});
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
describe('When testing subDataService.cBondsRebondSubData', () => {
|
|
520
|
+
describe('encode()', () => {
|
|
521
|
+
const examples: Array<[SubData, [bondId: number | string]]> = [
|
|
522
|
+
[
|
|
523
|
+
['0x00000000000000000000000000000000000000000000000000000000000000c8'],
|
|
524
|
+
[200]
|
|
525
|
+
],
|
|
526
|
+
[
|
|
527
|
+
['0x000000000000000000000000000000000000000000000000000000000000a119'],
|
|
528
|
+
[41241]
|
|
529
|
+
],
|
|
530
|
+
];
|
|
531
|
+
|
|
532
|
+
examples.forEach(([expected, actual]) => {
|
|
533
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
534
|
+
expect(subDataService.cBondsRebondSubData.encode(...actual)).to.eql(expected);
|
|
535
|
+
});
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
describe('decode()', () => {
|
|
540
|
+
const examples: Array<[{ bondId: string }, SubData]> = [
|
|
541
|
+
[
|
|
542
|
+
{ bondId: '200' },
|
|
543
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x00000000000000000000000000000000000000000000000000000000000000c8'],
|
|
544
|
+
],
|
|
545
|
+
[
|
|
546
|
+
{ bondId: '41241' },
|
|
547
|
+
['0x0000000000000000000000000000000000000000000000000000000000000000', '0x000000000000000000000000000000000000000000000000000000000000a119'],
|
|
548
|
+
],
|
|
549
|
+
];
|
|
550
|
+
|
|
551
|
+
examples.forEach(([expected, actual]) => {
|
|
552
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
553
|
+
expect(subDataService.cBondsRebondSubData.decode(actual)).to.eql(expected);
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
describe('When testing subDataService.liquityPaybackUsingChickenBondSubData', () => {
|
|
560
|
+
describe('encode()', () => {
|
|
561
|
+
const examples: Array<[SubData, [sourceId: string, sourceType: number, chainId?: ChainId]]> = [
|
|
562
|
+
[
|
|
563
|
+
[
|
|
564
|
+
'0x0000000000000000000000000000000000000000000000000000000000001076', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
565
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
|
|
566
|
+
],
|
|
567
|
+
['4214', 0, ChainId.Ethereum]
|
|
568
|
+
],
|
|
569
|
+
[
|
|
570
|
+
[
|
|
571
|
+
'0x00000000000000000000000000000000000000000000000000000000000002b8', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
572
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
|
|
573
|
+
],
|
|
574
|
+
['696', 1]
|
|
575
|
+
],
|
|
576
|
+
];
|
|
577
|
+
|
|
578
|
+
examples.forEach(([expected, actual]) => {
|
|
579
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
580
|
+
expect(subDataService.liquityPaybackUsingChickenBondSubData.encode(...actual)).to.eql(expected);
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
describe('decode()', () => {
|
|
586
|
+
const examples: Array<[{ sourceId: string, sourceType: string }, SubData]> = [
|
|
587
|
+
[
|
|
588
|
+
{ sourceId: '4214', sourceType: '0' },
|
|
589
|
+
[
|
|
590
|
+
'0x0000000000000000000000000000000000000000000000000000000000001076', '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
591
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
|
|
592
|
+
],
|
|
593
|
+
],
|
|
594
|
+
[
|
|
595
|
+
{ sourceId: '696', sourceType: '1' },
|
|
596
|
+
[
|
|
597
|
+
'0x00000000000000000000000000000000000000000000000000000000000002b8', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
598
|
+
'0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
|
|
599
|
+
],
|
|
600
|
+
],
|
|
601
|
+
];
|
|
602
|
+
|
|
603
|
+
examples.forEach(([expected, actual]) => {
|
|
604
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
605
|
+
expect(subDataService.liquityPaybackUsingChickenBondSubData.decode(actual)).to.eql(expected);
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
});
|
|
609
|
+
});
|
|
610
|
+
|
|
611
|
+
describe('When testing subDataService.exchangeDcaSubData', () => {
|
|
612
|
+
describe('encode()', () => {
|
|
613
|
+
const examples: Array<[SubData, [fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, interval: number]]> = [
|
|
614
|
+
[
|
|
615
|
+
[
|
|
616
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
617
|
+
'0x0000000000000000000000000000000000000000000000000000000000000853', '0x0000000000000000000000000000000000000000000000000000000000231860'
|
|
618
|
+
],
|
|
619
|
+
[
|
|
620
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
621
|
+
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
622
|
+
'2131',
|
|
623
|
+
2300000,
|
|
624
|
+
]
|
|
625
|
+
],
|
|
626
|
+
[
|
|
627
|
+
[
|
|
628
|
+
'0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f', '0x000000000000000000000000f97f4df75117a78c1a5a0dbb814af92458539fb4',
|
|
629
|
+
'0x00000000000000000000000000000000000000000000000000000000003eddd7', '0x0000000000000000000000000000000000000000000000000000000008f57500'
|
|
630
|
+
],
|
|
631
|
+
[
|
|
632
|
+
web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Arbitrum).address),
|
|
633
|
+
web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
|
|
634
|
+
'4120023',
|
|
635
|
+
150304000,
|
|
636
|
+
]
|
|
637
|
+
],
|
|
638
|
+
];
|
|
639
|
+
|
|
640
|
+
examples.forEach(([expected, actual]) => {
|
|
641
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
642
|
+
expect(subDataService.exchangeDcaSubData.encode(...actual)).to.eql(expected);
|
|
643
|
+
});
|
|
644
|
+
});
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
describe('decode()', () => {
|
|
648
|
+
const examples: Array<[{ fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, interval: string }, [SubData, ChainId]]> = [
|
|
649
|
+
[
|
|
650
|
+
{
|
|
651
|
+
fromToken: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
652
|
+
toToken: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
653
|
+
amount: '0.000000000000002131',
|
|
654
|
+
interval: '2300000',
|
|
655
|
+
},
|
|
656
|
+
[
|
|
657
|
+
[
|
|
658
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
659
|
+
'0x0000000000000000000000000000000000000000000000000000000000000853', '0x0000000000000000000000000000000000000000000000000000000000231860'
|
|
660
|
+
],
|
|
661
|
+
ChainId.Ethereum
|
|
662
|
+
],
|
|
663
|
+
],
|
|
664
|
+
[
|
|
665
|
+
{
|
|
666
|
+
fromToken: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Arbitrum).address),
|
|
667
|
+
toToken: web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
|
|
668
|
+
amount: '0.04120023',
|
|
669
|
+
interval: '150304000',
|
|
670
|
+
},
|
|
671
|
+
[
|
|
672
|
+
[
|
|
673
|
+
'0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f', '0x000000000000000000000000f97f4df75117a78c1a5a0dbb814af92458539fb4',
|
|
674
|
+
'0x00000000000000000000000000000000000000000000000000000000003eddd7', '0x0000000000000000000000000000000000000000000000000000000008f57500'
|
|
675
|
+
],
|
|
676
|
+
ChainId.Arbitrum
|
|
677
|
+
]
|
|
678
|
+
],
|
|
679
|
+
];
|
|
680
|
+
|
|
681
|
+
examples.forEach(([expected, actual]) => {
|
|
682
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
683
|
+
expect(subDataService.exchangeDcaSubData.decode(...actual)).to.eql(expected);
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
});
|
|
687
|
+
});
|
|
688
|
+
|
|
689
|
+
describe('When testing subDataService.exchangeLimitOrderSubData', () => {
|
|
690
|
+
describe('encode()', () => {
|
|
691
|
+
const examples: Array<[[EthereumAddress, EthereumAddress, string, string, string, string], [fromToken: EthereumAddress, toToken: EthereumAddress, amount: string, targetPrice: string, goodUntil: string | number, orderType: OrderType]]> = [
|
|
692
|
+
[
|
|
693
|
+
[
|
|
694
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
695
|
+
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
696
|
+
'2131',
|
|
697
|
+
'0.53123',
|
|
698
|
+
'1696590921159',
|
|
699
|
+
`${OrderType.STOP_LOSS}`
|
|
700
|
+
],
|
|
701
|
+
[
|
|
702
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
703
|
+
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
704
|
+
'2131',
|
|
705
|
+
'0.53123',
|
|
706
|
+
1696590921159,
|
|
707
|
+
OrderType.STOP_LOSS
|
|
708
|
+
]
|
|
709
|
+
],
|
|
710
|
+
[
|
|
711
|
+
[
|
|
712
|
+
web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
|
|
713
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
714
|
+
'2131',
|
|
715
|
+
'0.43123',
|
|
716
|
+
'1646590921159',
|
|
717
|
+
`${OrderType.TAKE_PROFIT}`
|
|
718
|
+
],
|
|
719
|
+
[
|
|
720
|
+
web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
|
|
721
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
722
|
+
'2131',
|
|
723
|
+
'0.43123',
|
|
724
|
+
1646590921159,
|
|
725
|
+
OrderType.TAKE_PROFIT
|
|
726
|
+
]
|
|
727
|
+
],
|
|
728
|
+
];
|
|
729
|
+
|
|
730
|
+
examples.forEach(([expected, actual]) => {
|
|
731
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
732
|
+
expect(subDataService.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
|
|
733
|
+
});
|
|
734
|
+
});
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
describe('decode()', () => {
|
|
738
|
+
const examples: Array<[{ fromToken: EthereumAddress, toToken: EthereumAddress, amount: string }, [SubData, ChainId]]> = [
|
|
739
|
+
[
|
|
740
|
+
{
|
|
741
|
+
fromToken: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
742
|
+
toToken: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
743
|
+
amount: '0.000000000000002131',
|
|
744
|
+
},
|
|
745
|
+
[
|
|
746
|
+
[
|
|
747
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
748
|
+
'0x0000000000000000000000000000000000000000000000000000000000000853', '0x0000000000000000000000000000000000000000000000000000000000231860'
|
|
749
|
+
],
|
|
750
|
+
ChainId.Ethereum
|
|
751
|
+
],
|
|
752
|
+
],
|
|
753
|
+
[
|
|
754
|
+
{
|
|
755
|
+
fromToken: web3Utils.toChecksumAddress(getAssetInfo('WBTC', ChainId.Arbitrum).address),
|
|
756
|
+
toToken: web3Utils.toChecksumAddress(getAssetInfo('LINK', ChainId.Arbitrum).address),
|
|
757
|
+
amount: '0.04120023',
|
|
758
|
+
},
|
|
759
|
+
[
|
|
760
|
+
[
|
|
761
|
+
'0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f', '0x000000000000000000000000f97f4df75117a78c1a5a0dbb814af92458539fb4',
|
|
762
|
+
'0x00000000000000000000000000000000000000000000000000000000003eddd7', '0x0000000000000000000000000000000000000000000000000000000008f57500'
|
|
763
|
+
],
|
|
764
|
+
ChainId.Arbitrum
|
|
765
|
+
]
|
|
766
|
+
],
|
|
767
|
+
];
|
|
768
|
+
|
|
769
|
+
examples.forEach(([expected, actual]) => {
|
|
770
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
771
|
+
expect(subDataService.exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
|
|
772
|
+
});
|
|
773
|
+
});
|
|
774
|
+
});
|
|
775
|
+
});
|
|
776
|
+
|
|
777
|
+
describe('When testing subDataService.sparkLeverageManagementSubData', () => {
|
|
778
|
+
describe('decode()', () => {
|
|
779
|
+
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
780
|
+
[
|
|
781
|
+
{ targetRatio: 200 },
|
|
782
|
+
['0x0000000000000000000000000000000000000000000000001bc16d674ec80000'],
|
|
783
|
+
],
|
|
784
|
+
[
|
|
785
|
+
{ targetRatio: 123 },
|
|
786
|
+
['0x0000000000000000000000000000000000000000000000001111d67bb1bb0000'],
|
|
787
|
+
],
|
|
788
|
+
];
|
|
789
|
+
|
|
790
|
+
examples.forEach(([expected, actual]) => {
|
|
791
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
792
|
+
expect(subDataService.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
793
|
+
});
|
|
794
|
+
});
|
|
795
|
+
});
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
describe('When testing subDataService.sparkQuotePriceSubData', () => {
|
|
799
|
+
describe('encode()', () => {
|
|
800
|
+
const examples: Array<[SubData, [collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, nullAddress?: EthereumAddress]]> = [
|
|
801
|
+
[
|
|
802
|
+
[
|
|
803
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
804
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
805
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
806
|
+
],
|
|
807
|
+
[
|
|
808
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
809
|
+
2,
|
|
810
|
+
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
811
|
+
4,
|
|
812
|
+
]
|
|
813
|
+
],
|
|
814
|
+
[
|
|
815
|
+
[
|
|
816
|
+
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
817
|
+
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
818
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
819
|
+
],
|
|
820
|
+
[
|
|
821
|
+
web3Utils.toChecksumAddress(getAssetInfo('wstETH', ChainId.Arbitrum).address),
|
|
822
|
+
6,
|
|
823
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
824
|
+
2,
|
|
825
|
+
]
|
|
826
|
+
],
|
|
827
|
+
];
|
|
828
|
+
|
|
829
|
+
examples.forEach(([expected, actual]) => {
|
|
830
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
831
|
+
expect(subDataService.sparkQuotePriceSubData.encode(...actual)).to.eql(expected);
|
|
832
|
+
});
|
|
833
|
+
});
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
describe('decode()', () => {
|
|
837
|
+
const examples: Array<[{ collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number }, SubData]> = [
|
|
838
|
+
[
|
|
839
|
+
{
|
|
840
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
841
|
+
collAssetId: 2,
|
|
842
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
843
|
+
debtAssetId: 4,
|
|
844
|
+
},
|
|
845
|
+
[
|
|
846
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
847
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
848
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
849
|
+
],
|
|
850
|
+
],
|
|
851
|
+
[
|
|
852
|
+
{
|
|
853
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('wstETH', ChainId.Arbitrum).address),
|
|
854
|
+
collAssetId: 6,
|
|
855
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Arbitrum).address),
|
|
856
|
+
debtAssetId: 2,
|
|
857
|
+
},
|
|
858
|
+
[
|
|
859
|
+
'0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529', '0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
860
|
+
'0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831', '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
861
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
862
|
+
],
|
|
863
|
+
],
|
|
864
|
+
];
|
|
865
|
+
|
|
866
|
+
examples.forEach(([expected, actual]) => {
|
|
867
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
868
|
+
expect(subDataService.sparkQuotePriceSubData.decode(actual)).to.eql(expected);
|
|
869
|
+
});
|
|
870
|
+
});
|
|
871
|
+
});
|
|
872
|
+
});
|
|
873
|
+
|
|
874
|
+
describe('When testing subDataService.liquityDsrPaybackSubData', () => {
|
|
875
|
+
describe('encode()', () => {
|
|
876
|
+
const examples: Array<[SubData, [targetRatio: number]]> = [
|
|
877
|
+
[
|
|
878
|
+
[
|
|
879
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
880
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
881
|
+
],
|
|
882
|
+
[123]
|
|
883
|
+
],
|
|
884
|
+
[
|
|
885
|
+
[
|
|
886
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
|
|
887
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
888
|
+
],
|
|
889
|
+
[420]
|
|
890
|
+
],
|
|
891
|
+
];
|
|
892
|
+
|
|
893
|
+
examples.forEach(([expected, actual]) => {
|
|
894
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
895
|
+
expect(subDataService.liquityDsrPaybackSubData.encode(...actual)).to.eql(expected);
|
|
896
|
+
});
|
|
897
|
+
});
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
describe('decode()', () => {
|
|
901
|
+
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
902
|
+
[
|
|
903
|
+
{
|
|
904
|
+
targetRatio: 123,
|
|
905
|
+
},
|
|
906
|
+
[
|
|
907
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
908
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
909
|
+
],
|
|
910
|
+
],
|
|
911
|
+
[
|
|
912
|
+
{
|
|
913
|
+
targetRatio: 420,
|
|
914
|
+
},
|
|
915
|
+
[
|
|
916
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000003a4965bf58a40000',
|
|
917
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
918
|
+
],
|
|
919
|
+
],
|
|
920
|
+
];
|
|
921
|
+
|
|
922
|
+
examples.forEach(([expected, actual]) => {
|
|
923
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
924
|
+
expect(subDataService.liquityDsrPaybackSubData.decode(actual)).to.eql(expected);
|
|
925
|
+
});
|
|
926
|
+
});
|
|
927
|
+
});
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
describe('When testing subDataService.liquityDsrSupplySubData', () => {
|
|
931
|
+
describe('encode()', () => {
|
|
932
|
+
const examples: Array<[SubData, [targetRatio: number]]> = [
|
|
933
|
+
[
|
|
934
|
+
[
|
|
935
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000002c68af0bb1400000',
|
|
936
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
937
|
+
],
|
|
938
|
+
[320]
|
|
939
|
+
],
|
|
940
|
+
[
|
|
941
|
+
[
|
|
942
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001eab7f4a799d0000',
|
|
943
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
944
|
+
],
|
|
945
|
+
[221]
|
|
946
|
+
],
|
|
947
|
+
];
|
|
948
|
+
|
|
949
|
+
examples.forEach(([expected, actual]) => {
|
|
950
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
951
|
+
expect(subDataService.liquityDsrSupplySubData.encode(...actual)).to.eql(expected);
|
|
952
|
+
});
|
|
953
|
+
});
|
|
954
|
+
});
|
|
955
|
+
|
|
956
|
+
describe('decode()', () => {
|
|
957
|
+
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
958
|
+
[
|
|
959
|
+
{
|
|
960
|
+
targetRatio: 320,
|
|
961
|
+
},
|
|
962
|
+
[
|
|
963
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000002c68af0bb1400000',
|
|
964
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
965
|
+
],
|
|
966
|
+
],
|
|
967
|
+
[
|
|
968
|
+
{
|
|
969
|
+
targetRatio: 221,
|
|
970
|
+
},
|
|
971
|
+
[
|
|
972
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001eab7f4a799d0000',
|
|
973
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
974
|
+
],
|
|
975
|
+
],
|
|
976
|
+
];
|
|
977
|
+
|
|
978
|
+
examples.forEach(([expected, actual]) => {
|
|
979
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
980
|
+
expect(subDataService.liquityDsrSupplySubData.decode(actual)).to.eql(expected);
|
|
981
|
+
});
|
|
982
|
+
});
|
|
983
|
+
});
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
describe('When testing subDataService.liquityDebtInFrontRepaySubData', () => {
|
|
987
|
+
describe('encode()', () => {
|
|
988
|
+
const examples: Array<[SubData, [targetRatioIncrease: number]]> = [
|
|
989
|
+
[
|
|
990
|
+
[
|
|
991
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
992
|
+
'0x000000000000000000000000000000000000000000000000016345785d8a0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
993
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
994
|
+
],
|
|
995
|
+
[10]
|
|
996
|
+
],
|
|
997
|
+
[
|
|
998
|
+
[
|
|
999
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1000
|
+
'0x000000000000000000000000000000000000000000000000063eb89da4ed0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1001
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1002
|
+
],
|
|
1003
|
+
[45]
|
|
1004
|
+
],
|
|
1005
|
+
];
|
|
1006
|
+
|
|
1007
|
+
examples.forEach(([expected, actual]) => {
|
|
1008
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1009
|
+
expect(subDataService.liquityDebtInFrontRepaySubData.encode(...actual)).to.eql(expected);
|
|
1010
|
+
});
|
|
1011
|
+
});
|
|
1012
|
+
});
|
|
1013
|
+
|
|
1014
|
+
describe('decode()', () => {
|
|
1015
|
+
const examples: Array<[{ targetRatioIncrease: number }, SubData]> = [
|
|
1016
|
+
[
|
|
1017
|
+
{
|
|
1018
|
+
targetRatioIncrease: 10,
|
|
1019
|
+
},
|
|
1020
|
+
[
|
|
1021
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1022
|
+
'0x000000000000000000000000000000000000000000000000016345785d8a0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1023
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1024
|
+
],
|
|
1025
|
+
],
|
|
1026
|
+
[
|
|
1027
|
+
{
|
|
1028
|
+
targetRatioIncrease: 45,
|
|
1029
|
+
},
|
|
1030
|
+
[
|
|
1031
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
|
|
1032
|
+
'0x000000000000000000000000000000000000000000000000063eb89da4ed0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1033
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1034
|
+
],
|
|
1035
|
+
],
|
|
1036
|
+
];
|
|
1037
|
+
|
|
1038
|
+
examples.forEach(([expected, actual]) => {
|
|
1039
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1040
|
+
expect(subDataService.liquityDebtInFrontRepaySubData.decode(actual)).to.eql(expected);
|
|
1041
|
+
});
|
|
1042
|
+
});
|
|
1043
|
+
});
|
|
1044
|
+
});
|
|
1045
|
+
|
|
1046
|
+
describe('When testing subDataService.crvUSDLeverageManagementSubData', () => {
|
|
1047
|
+
describe('encode()', () => {
|
|
1048
|
+
const examples: Array<[SubData, [controller: EthereumAddress, ratioState: RatioState, targetRatio: number, collToken: EthereumAddress, crvUSD: EthereumAddress]]> = [
|
|
1049
|
+
[
|
|
1050
|
+
[
|
|
1051
|
+
'0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
|
|
1052
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1053
|
+
'0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
1054
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1055
|
+
'0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
|
|
1056
|
+
],
|
|
1057
|
+
['0xa920de414ea4ab66b97da1bfe9e6eca7d4219635', RatioState.UNDER, 120, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E'],
|
|
1058
|
+
],
|
|
1059
|
+
[
|
|
1060
|
+
[
|
|
1061
|
+
'0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
|
|
1062
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1063
|
+
'0x00000000000000000000000000000000000000000000000018fae27693b40000',
|
|
1064
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1065
|
+
'0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
|
|
1066
|
+
],
|
|
1067
|
+
['0xa920de414ea4ab66b97da1bfe9e6eca7d4219635', RatioState.OVER, 180, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E']
|
|
1068
|
+
],
|
|
1069
|
+
];
|
|
1070
|
+
examples.forEach(([expected, actual]) => {
|
|
1071
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1072
|
+
expect(subDataService.crvUSDLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1073
|
+
});
|
|
1074
|
+
});
|
|
1075
|
+
});
|
|
1076
|
+
describe('decode()', () => {
|
|
1077
|
+
const examples: Array<[{
|
|
1078
|
+
controller: EthereumAddress,
|
|
1079
|
+
targetRatio: number,
|
|
1080
|
+
}, SubData]> = [
|
|
1081
|
+
[
|
|
1082
|
+
{
|
|
1083
|
+
controller: '0xA920De414eA4Ab66b97dA1bFE9e6EcA7d4219635',
|
|
1084
|
+
targetRatio: 120,
|
|
1085
|
+
},
|
|
1086
|
+
['0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635', '0x0000000000000000000000000000000000000000000000000000000000000001', '0x00000000000000000000000000000000000000000000000010a741a462780000', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',],
|
|
1087
|
+
],
|
|
1088
|
+
[
|
|
1089
|
+
{
|
|
1090
|
+
controller: '0xA920De414eA4Ab66b97dA1bFE9e6EcA7d4219635',
|
|
1091
|
+
targetRatio: 180,
|
|
1092
|
+
},
|
|
1093
|
+
['0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635', '0x0000000000000000000000000000000000000000000000000000000000000000', '0x00000000000000000000000000000000000000000000000018fae27693b40000', '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',],
|
|
1094
|
+
],
|
|
1095
|
+
];
|
|
1096
|
+
|
|
1097
|
+
examples.forEach(([expected, actual]) => {
|
|
1098
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1099
|
+
expect(subDataService.crvUSDLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1100
|
+
});
|
|
1101
|
+
});
|
|
1102
|
+
});
|
|
1103
|
+
});
|
|
1104
|
+
|
|
1105
|
+
describe('When testing subDataService.crvUSDPaybackSubData', () => {
|
|
1106
|
+
describe('encode()', () => {
|
|
1107
|
+
const examples: Array<[SubData, [controller: EthereumAddress, addressToPullTokensFrom: EthereumAddress, positionOwner: EthereumAddress, paybackAmount: string, crvUSDAddr: EthereumAddress]]> = [
|
|
1108
|
+
[
|
|
1109
|
+
[
|
|
1110
|
+
'0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
|
|
1111
|
+
'0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
|
|
1112
|
+
'0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
|
|
1113
|
+
'0x00000000000000000000000000000000000000000000043c33c1937564800000',
|
|
1114
|
+
'0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
|
|
1115
|
+
],
|
|
1116
|
+
['0xa920de414ea4ab66b97da1bfe9e6eca7d4219635', '0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280', '0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280', '20000', '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E'],
|
|
1117
|
+
]
|
|
1118
|
+
];
|
|
1119
|
+
examples.forEach(([expected, actual]) => {
|
|
1120
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1121
|
+
expect(subDataService.crvUSDPaybackSubData.encode(...actual)).to.eql(expected);
|
|
1122
|
+
});
|
|
1123
|
+
});
|
|
1124
|
+
});
|
|
1125
|
+
describe('decode()', () => {
|
|
1126
|
+
const examples: Array<[{
|
|
1127
|
+
controller: EthereumAddress,
|
|
1128
|
+
addressToPullTokensFrom: EthereumAddress,
|
|
1129
|
+
positionOwner: EthereumAddress,
|
|
1130
|
+
paybackAmount: string,
|
|
1131
|
+
}, SubData]> = [
|
|
1132
|
+
[
|
|
1133
|
+
{
|
|
1134
|
+
controller: '0xA920De414eA4Ab66b97dA1bFE9e6EcA7d4219635',
|
|
1135
|
+
addressToPullTokensFrom: '0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280',
|
|
1136
|
+
positionOwner: '0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280',
|
|
1137
|
+
paybackAmount: '20000'
|
|
1138
|
+
},
|
|
1139
|
+
[
|
|
1140
|
+
'0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
|
|
1141
|
+
'0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
|
|
1142
|
+
'0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
|
|
1143
|
+
'0x00000000000000000000000000000000000000000000043c33c1937564800000',
|
|
1144
|
+
'0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
|
|
1145
|
+
]
|
|
1146
|
+
]
|
|
1147
|
+
];
|
|
1148
|
+
|
|
1149
|
+
examples.forEach(([expected, actual]) => {
|
|
1150
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1151
|
+
expect(subDataService.crvUSDPaybackSubData.decode(actual)).to.eql(expected);
|
|
1152
|
+
});
|
|
1153
|
+
});
|
|
1154
|
+
});
|
|
1155
|
+
});
|
|
1156
|
+
|
|
1157
|
+
describe('When testing subDataService.compoundV3L2LeverageManagementSubData', () => {
|
|
1158
|
+
describe('encode()', () => {
|
|
1159
|
+
const examples: Array<[
|
|
1160
|
+
string,
|
|
1161
|
+
[market: EthereumAddress, baseToken: EthereumAddress, triggerRepayRatio: number, triggerBoostRatio: number, targetBoostRatio: number, targetRepayRatio: number, boostEnabled: boolean, isEOA: boolean],
|
|
1162
|
+
]> = [
|
|
1163
|
+
[
|
|
1164
|
+
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e00000100',
|
|
1165
|
+
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 190, true, false]
|
|
1166
|
+
],
|
|
1167
|
+
[
|
|
1168
|
+
'0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee00000000',
|
|
1169
|
+
[web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'), web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'), 160, 220, 180, 110, false, false]
|
|
1170
|
+
],
|
|
1171
|
+
];
|
|
1172
|
+
|
|
1173
|
+
examples.forEach(([expected, actual]) => {
|
|
1174
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1175
|
+
expect(subDataService.compoundV3L2LeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1176
|
+
});
|
|
1177
|
+
});
|
|
1178
|
+
});
|
|
1179
|
+
describe('decode()', () => {
|
|
1180
|
+
const examples: Array<[{ targetRatio: number }, SubData]> = [
|
|
1181
|
+
[
|
|
1182
|
+
{ targetRatio: 200 },
|
|
1183
|
+
[
|
|
1184
|
+
'0x0000000000000000000000000313d212133AFaB8F2B829B1066c7E43cAd94E2c', '0x0000000000000000000000000213d212133AFaB8F2B829B1066c7E43cAd94E2c',
|
|
1185
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1186
|
+
],
|
|
1187
|
+
],
|
|
1188
|
+
[
|
|
1189
|
+
{ targetRatio: 123 },
|
|
1190
|
+
[
|
|
1191
|
+
'0x0000000000000000000000000313d212133AFaB8F2B829B1066c7E43cAd94E2c', '0x0000000000000000000000000413d212133AFaB8F2B829B1066c7E43cAd94E2c',
|
|
1192
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001111d67bb1bb0000',
|
|
1193
|
+
],
|
|
1194
|
+
],
|
|
1195
|
+
];
|
|
1196
|
+
|
|
1197
|
+
examples.forEach(([expected, actual]) => {
|
|
1198
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1199
|
+
expect(subDataService.compoundV3L2LeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1200
|
+
});
|
|
1201
|
+
});
|
|
1202
|
+
});
|
|
1203
|
+
});
|
|
1204
|
+
|
|
1205
|
+
describe('When testing subDataService.morphoBlueLeverageManagementSubData', () => {
|
|
1206
|
+
describe('encode()', () => {
|
|
1207
|
+
const examples: Array<[
|
|
1208
|
+
SubData,
|
|
1209
|
+
[loanToken: EthereumAddress, collToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, ratioState: RatioState, targetRatio: number, user: EthereumAddress, isEOA: boolean],
|
|
1210
|
+
]> = [
|
|
1211
|
+
[
|
|
1212
|
+
[
|
|
1213
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1214
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1215
|
+
'0x0000000000000000000000002a01eb9496094da03c4e364def50f5ad1280ad72',
|
|
1216
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1217
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1218
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1219
|
+
'0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
1220
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1221
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1222
|
+
],
|
|
1223
|
+
[web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0x2a01eb9496094da03c4e364def50f5ad1280ad72'), web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), '945000000000000000', RatioState.UNDER, 120, web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), false]
|
|
1224
|
+
],
|
|
1225
|
+
[
|
|
1226
|
+
[
|
|
1227
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1228
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1229
|
+
'0x00000000000000000000000048f7e36eb6b826b2df4b2e630b62cd25e89e40e2',
|
|
1230
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1231
|
+
'0x0000000000000000000000000000000000000000000000000bef55718ad60000',
|
|
1232
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1233
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1234
|
+
'0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c',
|
|
1235
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1236
|
+
],
|
|
1237
|
+
[web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'), web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'), web3Utils.toChecksumAddress('0x48F7E36EB6B826B2dF4B2E630B62Cd25e89E40e2'), web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'), '860000000000000000', RatioState.OVER, 200, web3Utils.toChecksumAddress('0x0043d218133AFaB8F2B829B106633E434Ad94E2c'), false]
|
|
1238
|
+
],
|
|
1239
|
+
];
|
|
1240
|
+
|
|
1241
|
+
examples.forEach(([expected, actual]) => {
|
|
1242
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1243
|
+
expect(subDataService.morphoBlueLeverageManagementSubData.encode(...actual)).to.eql(expected);
|
|
1244
|
+
});
|
|
1245
|
+
});
|
|
1246
|
+
});
|
|
1247
|
+
|
|
1248
|
+
describe('decode()', () => {
|
|
1249
|
+
const examples: Array<[{ collToken: EthereumAddress, loanToken: EthereumAddress, oracle: EthereumAddress, irm: EthereumAddress, lltv: string, targetRatio: number, user: EthereumAddress }, SubData]> = [
|
|
1250
|
+
[
|
|
1251
|
+
{
|
|
1252
|
+
'collToken': '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1253
|
+
'irm': '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1254
|
+
'lltv': '945000000000000000',
|
|
1255
|
+
'loanToken': '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1256
|
+
'oracle': '0x2a01EB9496094dA03c4E364Def50f5aD1280AD72',
|
|
1257
|
+
'targetRatio': 120,
|
|
1258
|
+
'user': '0x1031d218133AFaB8C2B819B1366c7e434Ad91e9c',
|
|
1259
|
+
},
|
|
1260
|
+
[
|
|
1261
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1262
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1263
|
+
'0x0000000000000000000000002a01eb9496094da03c4e364def50f5ad1280ad72',
|
|
1264
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1265
|
+
'0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
|
|
1266
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1267
|
+
'0x00000000000000000000000000000000000000000000000010a741a462780000',
|
|
1268
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1269
|
+
],
|
|
1270
|
+
],
|
|
1271
|
+
[
|
|
1272
|
+
{
|
|
1273
|
+
'collToken': '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
|
|
1274
|
+
'irm': '0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC',
|
|
1275
|
+
'lltv': '860000000000000000',
|
|
1276
|
+
'loanToken': '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
1277
|
+
'oracle': '0x48F7E36EB6B826B2dF4B2E630B62Cd25e89E40e2',
|
|
1278
|
+
'targetRatio': 200,
|
|
1279
|
+
'user': '0x0043d218133aFaB8F2b829B106633E434aD94e2C',
|
|
1280
|
+
},
|
|
1281
|
+
[
|
|
1282
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1283
|
+
'0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
1284
|
+
'0x00000000000000000000000048f7e36eb6b826b2df4b2e630b62cd25e89e40e2',
|
|
1285
|
+
'0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
|
|
1286
|
+
'0x0000000000000000000000000000000000000000000000000bef55718ad60000',
|
|
1287
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1288
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1289
|
+
'0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c',
|
|
1290
|
+
],
|
|
1291
|
+
],
|
|
1292
|
+
];
|
|
1293
|
+
|
|
1294
|
+
examples.forEach(([expected, actual]) => {
|
|
1295
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1296
|
+
expect(subDataService.morphoBlueLeverageManagementSubData.decode(actual)).to.eql(expected);
|
|
1297
|
+
});
|
|
1298
|
+
});
|
|
1299
|
+
});
|
|
1300
|
+
});
|
|
1301
|
+
|
|
1302
|
+
describe('When testing subDataService.aaveV3LeverageManagementOnPriceSubData', () => {
|
|
1303
|
+
describe('encode()', () => {
|
|
1304
|
+
const examples: Array<[SubData, [collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number]]> = [
|
|
1305
|
+
[
|
|
1306
|
+
[
|
|
1307
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1308
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1309
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1310
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1311
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
1312
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1313
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1314
|
+
],
|
|
1315
|
+
[
|
|
1316
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1317
|
+
0,
|
|
1318
|
+
web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1319
|
+
4,
|
|
1320
|
+
web3Utils.toChecksumAddress('0x2f39d218133afab8f2b819b1066c7e434ad94e9e'),
|
|
1321
|
+
200,
|
|
1322
|
+
]
|
|
1323
|
+
],
|
|
1324
|
+
];
|
|
1325
|
+
|
|
1326
|
+
examples.forEach(([expected, actual]) => {
|
|
1327
|
+
it(`Given ${actual} should return expected value: ${expected}`, () => {
|
|
1328
|
+
expect(subDataService.aaveV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1329
|
+
});
|
|
1330
|
+
});
|
|
1331
|
+
});
|
|
1332
|
+
|
|
1333
|
+
describe('decode()', () => {
|
|
1334
|
+
const examples: Array<[{ collAsset: EthereumAddress, collAssetId: number, debtAsset: EthereumAddress, debtAssetId: number, marketAddr: EthereumAddress, targetRatio: number}, SubData]> = [
|
|
1335
|
+
[
|
|
1336
|
+
{
|
|
1337
|
+
collAsset: web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1338
|
+
collAssetId: 0,
|
|
1339
|
+
debtAsset: web3Utils.toChecksumAddress(getAssetInfo('DAI', ChainId.Ethereum).address),
|
|
1340
|
+
debtAssetId: 4,
|
|
1341
|
+
marketAddr: web3Utils.toChecksumAddress('0x2f39d218133afab8f2b819b1066c7e434ad94e9e'),
|
|
1342
|
+
targetRatio: 200,
|
|
1343
|
+
},
|
|
1344
|
+
[
|
|
1345
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1346
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1347
|
+
'0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
|
|
1348
|
+
'0x0000000000000000000000000000000000000000000000000000000000000004',
|
|
1349
|
+
'0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e',
|
|
1350
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1351
|
+
],
|
|
1352
|
+
],
|
|
1353
|
+
];
|
|
1354
|
+
|
|
1355
|
+
examples.forEach(([expected, actual]) => {
|
|
1356
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1357
|
+
expect(subDataService.aaveV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1358
|
+
});
|
|
1359
|
+
});
|
|
1360
|
+
});
|
|
1361
|
+
});
|
|
1362
|
+
|
|
1363
|
+
describe('When testing subDataService.compoundV3LeverageManagementOnPriceSubData', () => {
|
|
1364
|
+
describe('encode()', () => {
|
|
1365
|
+
const examples: Array<[string[], [market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, ratioState: RatioState, user: EthereumAddress]]> = [
|
|
1366
|
+
[
|
|
1367
|
+
[
|
|
1368
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1369
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1370
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1371
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1372
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1373
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
|
|
1374
|
+
],
|
|
1375
|
+
[
|
|
1376
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1377
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1378
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1379
|
+
200,
|
|
1380
|
+
RatioState.UNDER,
|
|
1381
|
+
web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
|
|
1382
|
+
]
|
|
1383
|
+
],
|
|
1384
|
+
[
|
|
1385
|
+
[
|
|
1386
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1387
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1388
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1389
|
+
'0x0000000000000000000000000000000000000000000000001a5e27eef13e0000',
|
|
1390
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1391
|
+
'0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c'
|
|
1392
|
+
],
|
|
1393
|
+
[
|
|
1394
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1395
|
+
web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1396
|
+
web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1397
|
+
190,
|
|
1398
|
+
RatioState.OVER,
|
|
1399
|
+
web3Utils.toChecksumAddress('0x0043d218133afab8f2b829b106633e434ad94e2c')
|
|
1400
|
+
]
|
|
1401
|
+
],
|
|
1402
|
+
];
|
|
1403
|
+
|
|
1404
|
+
examples.forEach(([expected, actual]) => {
|
|
1405
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1406
|
+
expect(subDataService.compoundV3LeverageManagementOnPriceSubData.encode(...actual)).to.eql(expected);
|
|
1407
|
+
});
|
|
1408
|
+
});
|
|
1409
|
+
});
|
|
1410
|
+
|
|
1411
|
+
describe('decode()', () => {
|
|
1412
|
+
const examples: Array<[{ market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, targetRatio: number, ratioState: RatioState, owner: EthereumAddress }, string[]]> = [
|
|
1413
|
+
[
|
|
1414
|
+
{
|
|
1415
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1416
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1417
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1418
|
+
targetRatio: 200,
|
|
1419
|
+
ratioState: RatioState.UNDER,
|
|
1420
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
|
|
1421
|
+
},
|
|
1422
|
+
[
|
|
1423
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1424
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1425
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1426
|
+
'0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
|
|
1427
|
+
'0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
1428
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
|
|
1429
|
+
]
|
|
1430
|
+
],
|
|
1431
|
+
[
|
|
1432
|
+
{
|
|
1433
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1434
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1435
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1436
|
+
targetRatio: 190,
|
|
1437
|
+
ratioState: RatioState.OVER,
|
|
1438
|
+
owner: web3Utils.toChecksumAddress('0x0043d218133afab8f2b829b106633e434ad94e2c')
|
|
1439
|
+
},
|
|
1440
|
+
[
|
|
1441
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1442
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1443
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1444
|
+
'0x0000000000000000000000000000000000000000000000001a5e27eef13e0000',
|
|
1445
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1446
|
+
'0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c'
|
|
1447
|
+
]
|
|
1448
|
+
],
|
|
1449
|
+
];
|
|
1450
|
+
|
|
1451
|
+
examples.forEach(([expected, actual]) => {
|
|
1452
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1453
|
+
expect(subDataService.compoundV3LeverageManagementOnPriceSubData.decode(actual)).to.eql(expected);
|
|
1454
|
+
});
|
|
1455
|
+
});
|
|
1456
|
+
});
|
|
1457
|
+
});
|
|
1458
|
+
|
|
1459
|
+
describe('When testing subDataService.compoundV3CloseSubData', () => {
|
|
1460
|
+
describe('encode()', () => {
|
|
1461
|
+
const examples: Array<[string[], [market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, closeType: CloseStrategyType, user: EthereumAddress]]> = [
|
|
1462
|
+
[
|
|
1463
|
+
[
|
|
1464
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1465
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1466
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1467
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1468
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1469
|
+
],
|
|
1470
|
+
[
|
|
1471
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1472
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1473
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1474
|
+
CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
1475
|
+
web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c'),
|
|
1476
|
+
]
|
|
1477
|
+
],
|
|
1478
|
+
[
|
|
1479
|
+
[
|
|
1480
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1481
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1482
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1483
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1484
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
|
|
1485
|
+
],
|
|
1486
|
+
[
|
|
1487
|
+
web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1488
|
+
web3Utils.toChecksumAddress(getAssetInfo('WETH', ChainId.Ethereum).address),
|
|
1489
|
+
web3Utils.toChecksumAddress(getAssetInfo('USDC', ChainId.Ethereum).address),
|
|
1490
|
+
CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
|
|
1491
|
+
web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c'),
|
|
1492
|
+
]
|
|
1493
|
+
],
|
|
1494
|
+
];
|
|
1495
|
+
|
|
1496
|
+
examples.forEach(([expected, actual]) => {
|
|
1497
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1498
|
+
expect(subDataService.compoundV3CloseSubData.encode(...actual)).to.eql(expected);
|
|
1499
|
+
});
|
|
1500
|
+
});
|
|
1501
|
+
});
|
|
1502
|
+
|
|
1503
|
+
describe('decode()', () => {
|
|
1504
|
+
const examples: Array<[{ market: EthereumAddress, collToken: EthereumAddress, baseToken: EthereumAddress, closeType: CloseStrategyType, owner: EthereumAddress }, string[]]> = [
|
|
1505
|
+
[
|
|
1506
|
+
{
|
|
1507
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1508
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1509
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1510
|
+
closeType: CloseStrategyType.TAKE_PROFIT_AND_STOP_LOSS_IN_DEBT,
|
|
1511
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
|
|
1512
|
+
},
|
|
1513
|
+
[
|
|
1514
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1515
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1516
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1517
|
+
'0x0000000000000000000000000000000000000000000000000000000000000006',
|
|
1518
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
|
|
1519
|
+
]
|
|
1520
|
+
],
|
|
1521
|
+
[
|
|
1522
|
+
{
|
|
1523
|
+
market: web3Utils.toChecksumAddress('0xc3d688B66703497DAA19211EEdff47f25384cdc3'),
|
|
1524
|
+
collToken: web3Utils.toChecksumAddress('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),
|
|
1525
|
+
baseToken: web3Utils.toChecksumAddress('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'),
|
|
1526
|
+
closeType: CloseStrategyType.TAKE_PROFIT_IN_COLLATERAL,
|
|
1527
|
+
owner: web3Utils.toChecksumAddress('0x1031d218133afab8c2b819b1366c7e434ad91e9c')
|
|
1528
|
+
},
|
|
1529
|
+
[
|
|
1530
|
+
'0x000000000000000000000000c3d688b66703497daa19211eedff47f25384cdc3',
|
|
1531
|
+
'0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
1532
|
+
'0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
1533
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
1534
|
+
'0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c'
|
|
1535
|
+
]
|
|
1536
|
+
],
|
|
1537
|
+
];
|
|
1538
|
+
|
|
1539
|
+
examples.forEach(([expected, actual]) => {
|
|
1540
|
+
it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
|
|
1541
|
+
expect(subDataService.compoundV3CloseSubData.decode(actual)).to.eql(expected);
|
|
1542
|
+
});
|
|
1543
|
+
});
|
|
1544
|
+
});
|
|
1545
|
+
});
|
|
1546
|
+
});
|