@defisaver/automation-sdk 2.0.5 → 2.0.8

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.
Files changed (50) hide show
  1. package/.env.dev +5 -0
  2. package/.tests.sh +3 -0
  3. package/README.md +3 -1
  4. package/esm/automation/private/LegacyProtocol.test.d.ts +1 -0
  5. package/esm/automation/private/LegacyProtocol.test.js +25 -0
  6. package/esm/automation/private/Protocol.test.d.ts +1 -0
  7. package/esm/automation/private/Protocol.test.js +25 -0
  8. package/esm/automation/private/StrategiesAutomation.js +1 -1
  9. package/esm/constants/index.js +15 -0
  10. package/esm/services/contractService.d.ts +3 -2
  11. package/esm/services/contractService.js +7 -1
  12. package/esm/services/ethereumService.test.d.ts +1 -0
  13. package/esm/services/ethereumService.test.js +241 -0
  14. package/esm/services/strategiesService.js +40 -0
  15. package/esm/services/strategiesService.test.d.ts +1 -0
  16. package/esm/services/strategiesService.test.js +108 -0
  17. package/esm/services/strategySubService.d.ts +17 -3
  18. package/esm/services/strategySubService.js +17 -6
  19. package/esm/services/strategySubService.test.d.ts +1 -0
  20. package/esm/services/strategySubService.test.js +692 -0
  21. package/esm/services/subDataService.d.ts +8 -1
  22. package/esm/services/subDataService.js +23 -14
  23. package/esm/services/subDataService.test.d.ts +1 -0
  24. package/esm/services/subDataService.test.js +993 -0
  25. package/esm/services/triggerService.d.ts +17 -0
  26. package/esm/services/triggerService.js +42 -1
  27. package/esm/services/triggerService.test.js +119 -17
  28. package/esm/types/enums.d.ts +10 -2
  29. package/esm/types/enums.js +8 -0
  30. package/esm/types/index.d.ts +19 -2
  31. package/package.json +3 -3
  32. package/src/automation/private/LegacyProtocol.test.ts +24 -0
  33. package/src/automation/private/Protocol.test.ts +24 -0
  34. package/src/automation/private/StrategiesAutomation.ts +1 -1
  35. package/src/constants/index.ts +15 -0
  36. package/src/services/contractService.ts +17 -4
  37. package/src/services/ethereumService.test.ts +256 -0
  38. package/src/services/ethereumService.ts +2 -1
  39. package/src/services/strategiesService.test.ts +103 -0
  40. package/src/services/strategiesService.ts +66 -3
  41. package/src/services/strategySubService.test.ts +835 -0
  42. package/src/services/strategySubService.ts +50 -15
  43. package/src/services/subDataService.test.ts +1063 -0
  44. package/src/services/subDataService.ts +29 -14
  45. package/src/services/triggerService.test.ts +133 -20
  46. package/src/services/triggerService.ts +55 -0
  47. package/src/services/utils.test.ts +1 -1
  48. package/src/types/enums.ts +8 -0
  49. package/src/types/index.ts +27 -3
  50. package/umd/index.js +282 -115
@@ -0,0 +1,993 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const decimal_js_1 = __importDefault(require("decimal.js"));
30
+ const chai_1 = require("chai");
31
+ const tokens_1 = require("@defisaver/tokens");
32
+ const web3Utils = __importStar(require("web3-utils"));
33
+ const enums_1 = require("../types/enums");
34
+ const subDataService_1 = require("./subDataService");
35
+ describe('Feature: subDataService.ts', () => {
36
+ describe('When testing subDataService.makerRepayFromSavingsSubData', () => {
37
+ describe('encode()', () => {
38
+ const examples = [
39
+ [
40
+ [
41
+ "0x000000000000000000000000000000000000000000000000000000000000007b", "0x00000000000000000000000000000000000000000000000010a741a462780000",
42
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e",
43
+ ],
44
+ [123, 120, enums_1.ChainId.Ethereum, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address), web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e')]
45
+ ],
46
+ ];
47
+ examples.forEach(([expected, actual]) => {
48
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
49
+ (0, chai_1.expect)(subDataService_1.makerRepayFromSavingsSubData.encode(...actual)).to.eql(expected);
50
+ });
51
+ });
52
+ });
53
+ describe('decode()', () => {
54
+ const examples = [
55
+ [
56
+ {
57
+ vaultId: 123,
58
+ daiAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
59
+ mcdManagerAddr: web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e'),
60
+ targetRatio: 120,
61
+ },
62
+ [
63
+ "0x000000000000000000000000000000000000000000000000000000000000007b", "0x00000000000000000000000000000000000000000000000010a741a462780000",
64
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e",
65
+ ],
66
+ ],
67
+ ];
68
+ examples.forEach(([expected, actual]) => {
69
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
70
+ (0, chai_1.expect)(subDataService_1.makerRepayFromSavingsSubData.decode(actual)).to.eql(expected);
71
+ });
72
+ });
73
+ });
74
+ });
75
+ describe('When testing subDataService.liquityRepayFromSavingsSubData', () => {
76
+ describe('decode()', () => {
77
+ const examples = [
78
+ [
79
+ { targetRatio: 120 },
80
+ [
81
+ "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000010a741a462780000",
82
+ "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000",
83
+ ],
84
+ ],
85
+ ];
86
+ examples.forEach(([expected, actual]) => {
87
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
88
+ (0, chai_1.expect)(subDataService_1.liquityRepayFromSavingsSubData.decode(actual)).to.eql(expected);
89
+ });
90
+ });
91
+ });
92
+ });
93
+ describe('When testing subDataService.makerCloseSubData', () => {
94
+ describe('encode()', () => {
95
+ const examples = [
96
+ [
97
+ [
98
+ "0x0000000000000000000000000000000000000000000000000000000000000141", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
99
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e",
100
+ ],
101
+ [321, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address), enums_1.ChainId.Ethereum, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address), web3Utils.toChecksumAddress('0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e')]
102
+ ],
103
+ [
104
+ [
105
+ "0x00000000000000000000000000000000000000000000000000000000000001a4", "0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599",
106
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000002439d218133afab8f2b819b1066c7e434ad94e9e",
107
+ ],
108
+ [420, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address), enums_1.ChainId.Ethereum, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address), web3Utils.toChecksumAddress('0x2439d218133AFaB8F2B819B1066c7E434Ad94E9e')]
109
+ ],
110
+ ];
111
+ examples.forEach(([expected, actual]) => {
112
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
113
+ (0, chai_1.expect)(subDataService_1.makerCloseSubData.encode(...actual)).to.eql(expected);
114
+ });
115
+ });
116
+ });
117
+ describe('decode()', () => {
118
+ const examples = [
119
+ [
120
+ {
121
+ vaultId: 321,
122
+ closeToAssetAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
123
+ },
124
+ [
125
+ "0x0000000000000000000000000000000000000000000000000000000000000141", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
126
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e",
127
+ ],
128
+ ],
129
+ [
130
+ {
131
+ vaultId: 420,
132
+ closeToAssetAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
133
+ },
134
+ [
135
+ "0x00000000000000000000000000000000000000000000000000000000000001a4", "0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599",
136
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000002439d218133afab8f2b819b1066c7e434ad94e9e",
137
+ ],
138
+ ],
139
+ ];
140
+ examples.forEach(([expected, actual]) => {
141
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
142
+ (0, chai_1.expect)(subDataService_1.makerCloseSubData.decode(actual)).to.eql(expected);
143
+ });
144
+ });
145
+ });
146
+ });
147
+ describe('When testing subDataService.makerLeverageManagementSubData', () => {
148
+ describe('decode()', () => {
149
+ const examples = [
150
+ [
151
+ { vaultId: 321, targetRatio: 200 },
152
+ [
153
+ '0x0000000000000000000000000000000000000000000000000000000000000141', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
154
+ '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
155
+ ],
156
+ ],
157
+ ];
158
+ examples.forEach(([expected, actual]) => {
159
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
160
+ (0, chai_1.expect)(subDataService_1.makerLeverageManagementSubData.decode(actual)).to.eql(expected);
161
+ });
162
+ });
163
+ });
164
+ });
165
+ describe('When testing subDataService.liquityLeverageManagementSubData', () => {
166
+ describe('decode()', () => {
167
+ const examples = [
168
+ [
169
+ { targetRatio: 200 },
170
+ [
171
+ '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000001bc16d674ec80000',
172
+ '0x0000000000000000000000000000000000000000000000000000000000000000', '0x0000000000000000000000000000000000000000000000000000000000000000',
173
+ ],
174
+ ],
175
+ ];
176
+ examples.forEach(([expected, actual]) => {
177
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
178
+ (0, chai_1.expect)(subDataService_1.liquityLeverageManagementSubData.decode(actual)).to.eql(expected);
179
+ });
180
+ });
181
+ });
182
+ });
183
+ describe('When testing subDataService.liquityCloseSubData', () => {
184
+ describe('encode()', () => {
185
+ const examples = [
186
+ [
187
+ [
188
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0",
189
+ ],
190
+ [web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LUSD', enums_1.ChainId.Ethereum).address), enums_1.ChainId.Ethereum, web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address), web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LUSD', enums_1.ChainId.Ethereum).address)]
191
+ ],
192
+ [
193
+ [
194
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0",
195
+ ],
196
+ [web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LUSD', enums_1.ChainId.Ethereum).address), enums_1.ChainId.Ethereum]
197
+ ],
198
+ ];
199
+ examples.forEach(([expected, actual]) => {
200
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
201
+ (0, chai_1.expect)(subDataService_1.liquityCloseSubData.encode(...actual)).to.eql(expected);
202
+ });
203
+ });
204
+ });
205
+ describe('decode()', () => {
206
+ const examples = [
207
+ [
208
+ {
209
+ closeToAssetAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LUSD', enums_1.ChainId.Ethereum).address),
210
+ debtAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LUSD', enums_1.ChainId.Ethereum).address),
211
+ },
212
+ [
213
+ "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0", "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0",
214
+ ],
215
+ ],
216
+ [
217
+ {
218
+ closeToAssetAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
219
+ debtAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LUSD', enums_1.ChainId.Ethereum).address),
220
+ },
221
+ [
222
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0",
223
+ ],
224
+ ],
225
+ ];
226
+ examples.forEach(([expected, actual]) => {
227
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
228
+ (0, chai_1.expect)(subDataService_1.liquityCloseSubData.decode(actual)).to.eql(expected);
229
+ });
230
+ });
231
+ });
232
+ });
233
+ describe('When testing subDataService.aaveV2LeverageManagementSubData', () => {
234
+ describe('encode()', () => {
235
+ const examples = [
236
+ [
237
+ [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
238
+ [160, 220, 180, 190, true]
239
+ ],
240
+ [
241
+ [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
242
+ [160, 200, 180, 190, false]
243
+ ],
244
+ ];
245
+ examples.forEach(([expected, actual]) => {
246
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
247
+ (0, chai_1.expect)(subDataService_1.aaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
248
+ });
249
+ });
250
+ });
251
+ describe('decode()', () => {
252
+ const examples = [
253
+ [
254
+ { targetRatio: 200 },
255
+ ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000001bc16d674ec80000"],
256
+ ],
257
+ [
258
+ { targetRatio: 123 },
259
+ ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000001111d67bb1bb0000"],
260
+ ],
261
+ ];
262
+ examples.forEach(([expected, actual]) => {
263
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
264
+ (0, chai_1.expect)(subDataService_1.aaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
265
+ });
266
+ });
267
+ });
268
+ });
269
+ describe('When testing subDataService.aaveV3LeverageManagementSubData', () => {
270
+ describe('decode()', () => {
271
+ const examples = [
272
+ [
273
+ { targetRatio: 200 },
274
+ ["0x0000000000000000000000000000000000000000000000001bc16d674ec80000"],
275
+ ],
276
+ [
277
+ { targetRatio: 123 },
278
+ ["0x0000000000000000000000000000000000000000000000001111d67bb1bb0000"],
279
+ ],
280
+ ];
281
+ examples.forEach(([expected, actual]) => {
282
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
283
+ (0, chai_1.expect)(subDataService_1.aaveV3LeverageManagementSubData.decode(actual)).to.eql(expected);
284
+ });
285
+ });
286
+ });
287
+ });
288
+ describe('When testing subDataService.aaveV3QuotePriceSubData', () => {
289
+ describe('encode()', () => {
290
+ const examples = [
291
+ [
292
+ [
293
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000000000000000000000000000000000000000000002",
294
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000000000000000000000000000000000000000000004",
295
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
296
+ ],
297
+ [
298
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
299
+ 2,
300
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
301
+ 4,
302
+ ]
303
+ ],
304
+ [
305
+ [
306
+ "0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529", "0x0000000000000000000000000000000000000000000000000000000000000006",
307
+ "0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831", "0x0000000000000000000000000000000000000000000000000000000000000002",
308
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
309
+ ],
310
+ [
311
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('wstETH', enums_1.ChainId.Arbitrum).address),
312
+ 6,
313
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
314
+ 2,
315
+ ]
316
+ ],
317
+ ];
318
+ examples.forEach(([expected, actual]) => {
319
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
320
+ (0, chai_1.expect)(subDataService_1.aaveV3QuotePriceSubData.encode(...actual)).to.eql(expected);
321
+ });
322
+ });
323
+ });
324
+ describe('decode()', () => {
325
+ const examples = [
326
+ [
327
+ {
328
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
329
+ collAssetId: 2,
330
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
331
+ debtAssetId: 4,
332
+ },
333
+ [
334
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000000000000000000000000000000000000000000002",
335
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000000000000000000000000000000000000000000004",
336
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
337
+ ],
338
+ ],
339
+ [
340
+ {
341
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('wstETH', enums_1.ChainId.Arbitrum).address),
342
+ collAssetId: 6,
343
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
344
+ debtAssetId: 2,
345
+ },
346
+ [
347
+ "0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529", "0x0000000000000000000000000000000000000000000000000000000000000006",
348
+ "0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831", "0x0000000000000000000000000000000000000000000000000000000000000002",
349
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
350
+ ],
351
+ ],
352
+ ];
353
+ examples.forEach(([expected, actual]) => {
354
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
355
+ (0, chai_1.expect)(subDataService_1.aaveV3QuotePriceSubData.decode(actual)).to.eql(expected);
356
+ });
357
+ });
358
+ });
359
+ });
360
+ describe('When testing subDataService.compoundV2LeverageManagementSubData', () => {
361
+ describe('encode()', () => {
362
+ const examples = [
363
+ [
364
+ [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
365
+ [160, 220, 180, 190, true]
366
+ ],
367
+ [
368
+ [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
369
+ [160, 200, 180, 190, false]
370
+ ],
371
+ ];
372
+ examples.forEach(([expected, actual]) => {
373
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
374
+ (0, chai_1.expect)(subDataService_1.compoundV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
375
+ });
376
+ });
377
+ });
378
+ describe('decode()', () => {
379
+ const examples = [
380
+ [
381
+ { targetRatio: 200 },
382
+ ["0x0000000000000000000000000000000000000000000000001bc16d674ec80000"],
383
+ ],
384
+ [
385
+ { targetRatio: 123 },
386
+ ["0x0000000000000000000000000000000000000000000000001111d67bb1bb0000"],
387
+ ],
388
+ ];
389
+ examples.forEach(([expected, actual]) => {
390
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
391
+ (0, chai_1.expect)(subDataService_1.compoundV2LeverageManagementSubData.decode(actual)).to.eql(expected);
392
+ });
393
+ });
394
+ });
395
+ });
396
+ describe('When testing subDataService.compoundV3LeverageManagementSubData', () => {
397
+ describe('encode()', () => {
398
+ const examples = [
399
+ [
400
+ [
401
+ web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
402
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
403
+ new decimal_js_1.default(160).mul(1e16).toString(),
404
+ new decimal_js_1.default(220).mul(1e16).toString(),
405
+ new decimal_js_1.default(180).mul(1e16).toString(),
406
+ new decimal_js_1.default(190).mul(1e16).toString(),
407
+ true, false,
408
+ ],
409
+ [
410
+ web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
411
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
412
+ 160, 220, 180, 190,
413
+ true, false,
414
+ ]
415
+ ],
416
+ [
417
+ [
418
+ web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
419
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
420
+ new decimal_js_1.default(160).mul(1e16).toString(),
421
+ new decimal_js_1.default(210).mul(1e16).toString(),
422
+ new decimal_js_1.default(180).mul(1e16).toString(),
423
+ new decimal_js_1.default(190).mul(1e16).toString(),
424
+ false, true,
425
+ ],
426
+ [
427
+ web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
428
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
429
+ 160, 210, 180, 190,
430
+ false, true,
431
+ ]
432
+ ],
433
+ ];
434
+ examples.forEach(([expected, actual]) => {
435
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
436
+ (0, chai_1.expect)(subDataService_1.compoundV3LeverageManagementSubData.encode(...actual)).to.eql(expected);
437
+ });
438
+ });
439
+ });
440
+ describe('decode()', () => {
441
+ const examples = [
442
+ [
443
+ { targetRatio: 123 },
444
+ [
445
+ "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000",
446
+ "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000001111d67bb1bb0000",
447
+ ],
448
+ ],
449
+ [
450
+ { targetRatio: 200 },
451
+ [
452
+ "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000",
453
+ "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000001bc16d674ec80000",
454
+ ],
455
+ ],
456
+ ];
457
+ examples.forEach(([expected, actual]) => {
458
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
459
+ (0, chai_1.expect)(subDataService_1.compoundV3LeverageManagementSubData.decode(actual)).to.eql(expected);
460
+ });
461
+ });
462
+ });
463
+ });
464
+ describe('When testing subDataService.morphoAaveV2LeverageManagementSubData', () => {
465
+ describe('encode()', () => {
466
+ const examples = [
467
+ [
468
+ [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
469
+ [160, 220, 180, 190, true]
470
+ ],
471
+ [
472
+ [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
473
+ [160, 200, 180, 190, false]
474
+ ],
475
+ ];
476
+ examples.forEach(([expected, actual]) => {
477
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
478
+ (0, chai_1.expect)(subDataService_1.morphoAaveV2LeverageManagementSubData.encode(...actual)).to.eql(expected);
479
+ });
480
+ });
481
+ });
482
+ describe('decode()', () => {
483
+ const examples = [
484
+ [
485
+ { targetRatio: 200 },
486
+ ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000001bc16d674ec80000"],
487
+ ],
488
+ [
489
+ { targetRatio: 123 },
490
+ ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000001111d67bb1bb0000"],
491
+ ],
492
+ ];
493
+ examples.forEach(([expected, actual]) => {
494
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
495
+ (0, chai_1.expect)(subDataService_1.morphoAaveV2LeverageManagementSubData.decode(actual)).to.eql(expected);
496
+ });
497
+ });
498
+ });
499
+ });
500
+ describe('When testing subDataService.cBondsRebondSubData', () => {
501
+ describe('encode()', () => {
502
+ const examples = [
503
+ [
504
+ ["0x00000000000000000000000000000000000000000000000000000000000000c8"],
505
+ [200]
506
+ ],
507
+ [
508
+ ["0x000000000000000000000000000000000000000000000000000000000000a119"],
509
+ [41241]
510
+ ],
511
+ ];
512
+ examples.forEach(([expected, actual]) => {
513
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
514
+ (0, chai_1.expect)(subDataService_1.cBondsRebondSubData.encode(...actual)).to.eql(expected);
515
+ });
516
+ });
517
+ });
518
+ describe('decode()', () => {
519
+ const examples = [
520
+ [
521
+ { bondId: '200' },
522
+ ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000000000000000000c8"],
523
+ ],
524
+ [
525
+ { bondId: '41241' },
526
+ ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x000000000000000000000000000000000000000000000000000000000000a119"],
527
+ ],
528
+ ];
529
+ examples.forEach(([expected, actual]) => {
530
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
531
+ (0, chai_1.expect)(subDataService_1.cBondsRebondSubData.decode(actual)).to.eql(expected);
532
+ });
533
+ });
534
+ });
535
+ });
536
+ describe('When testing subDataService.liquityPaybackUsingChickenBondSubData', () => {
537
+ describe('encode()', () => {
538
+ const examples = [
539
+ [
540
+ [
541
+ "0x0000000000000000000000000000000000000000000000000000000000001076", "0x0000000000000000000000000000000000000000000000000000000000000000",
542
+ "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0", "0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3",
543
+ ],
544
+ ['4214', 0, enums_1.ChainId.Ethereum]
545
+ ],
546
+ [
547
+ [
548
+ "0x00000000000000000000000000000000000000000000000000000000000002b8", "0x0000000000000000000000000000000000000000000000000000000000000001",
549
+ "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0", "0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3",
550
+ ],
551
+ ['696', 1]
552
+ ],
553
+ ];
554
+ examples.forEach(([expected, actual]) => {
555
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
556
+ (0, chai_1.expect)(subDataService_1.liquityPaybackUsingChickenBondSubData.encode(...actual)).to.eql(expected);
557
+ });
558
+ });
559
+ });
560
+ describe('decode()', () => {
561
+ const examples = [
562
+ [
563
+ { sourceId: '4214', sourceType: '0' },
564
+ [
565
+ "0x0000000000000000000000000000000000000000000000000000000000001076", "0x0000000000000000000000000000000000000000000000000000000000000000",
566
+ "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0", "0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3",
567
+ ],
568
+ ],
569
+ [
570
+ { sourceId: '696', sourceType: '1' },
571
+ [
572
+ "0x00000000000000000000000000000000000000000000000000000000000002b8", "0x0000000000000000000000000000000000000000000000000000000000000001",
573
+ "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0", "0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3",
574
+ ],
575
+ ],
576
+ ];
577
+ examples.forEach(([expected, actual]) => {
578
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
579
+ (0, chai_1.expect)(subDataService_1.liquityPaybackUsingChickenBondSubData.decode(actual)).to.eql(expected);
580
+ });
581
+ });
582
+ });
583
+ });
584
+ describe('When testing subDataService.exchangeDcaSubData', () => {
585
+ describe('encode()', () => {
586
+ const examples = [
587
+ [
588
+ [
589
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f",
590
+ "0x0000000000000000000000000000000000000000000000000000000000000853", "0x0000000000000000000000000000000000000000000000000000000000231860"
591
+ ],
592
+ [
593
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
594
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
595
+ '2131',
596
+ 2300000,
597
+ ]
598
+ ],
599
+ [
600
+ [
601
+ "0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f", "0x000000000000000000000000f97f4df75117a78c1a5a0dbb814af92458539fb4",
602
+ "0x00000000000000000000000000000000000000000000000000000000003eddd7", "0x0000000000000000000000000000000000000000000000000000000008f57500"
603
+ ],
604
+ [
605
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Arbitrum).address),
606
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
607
+ '4120023',
608
+ 150304000,
609
+ ]
610
+ ],
611
+ ];
612
+ examples.forEach(([expected, actual]) => {
613
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
614
+ (0, chai_1.expect)(subDataService_1.exchangeDcaSubData.encode(...actual)).to.eql(expected);
615
+ });
616
+ });
617
+ });
618
+ describe('decode()', () => {
619
+ const examples = [
620
+ [
621
+ {
622
+ fromToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
623
+ toToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
624
+ amount: '0.000000000000002131',
625
+ interval: '2300000',
626
+ },
627
+ [
628
+ [
629
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f",
630
+ "0x0000000000000000000000000000000000000000000000000000000000000853", "0x0000000000000000000000000000000000000000000000000000000000231860"
631
+ ],
632
+ enums_1.ChainId.Ethereum
633
+ ],
634
+ ],
635
+ [
636
+ {
637
+ fromToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Arbitrum).address),
638
+ toToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
639
+ amount: '0.04120023',
640
+ interval: '150304000',
641
+ },
642
+ [
643
+ [
644
+ "0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f", "0x000000000000000000000000f97f4df75117a78c1a5a0dbb814af92458539fb4",
645
+ "0x00000000000000000000000000000000000000000000000000000000003eddd7", "0x0000000000000000000000000000000000000000000000000000000008f57500"
646
+ ],
647
+ enums_1.ChainId.Arbitrum
648
+ ]
649
+ ],
650
+ ];
651
+ examples.forEach(([expected, actual]) => {
652
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
653
+ (0, chai_1.expect)(subDataService_1.exchangeDcaSubData.decode(...actual)).to.eql(expected);
654
+ });
655
+ });
656
+ });
657
+ });
658
+ describe('When testing subDataService.exchangeLimitOrderSubData', () => {
659
+ describe('encode()', () => {
660
+ const examples = [
661
+ [
662
+ [
663
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
664
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
665
+ '2131',
666
+ '0.53123',
667
+ '1696590921159',
668
+ `${enums_1.OrderType.STOP_LOSS}`
669
+ ],
670
+ [
671
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
672
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
673
+ '2131',
674
+ '0.53123',
675
+ 1696590921159,
676
+ enums_1.OrderType.STOP_LOSS
677
+ ]
678
+ ],
679
+ [
680
+ [
681
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
682
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
683
+ '2131',
684
+ '0.43123',
685
+ '1646590921159',
686
+ `${enums_1.OrderType.TAKE_PROFIT}`
687
+ ],
688
+ [
689
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
690
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
691
+ '2131',
692
+ '0.43123',
693
+ 1646590921159,
694
+ enums_1.OrderType.TAKE_PROFIT
695
+ ]
696
+ ],
697
+ ];
698
+ examples.forEach(([expected, actual]) => {
699
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
700
+ (0, chai_1.expect)(subDataService_1.exchangeLimitOrderSubData.encode(...actual)).to.eql(expected);
701
+ });
702
+ });
703
+ });
704
+ describe('decode()', () => {
705
+ const examples = [
706
+ [
707
+ {
708
+ fromToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
709
+ toToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
710
+ amount: '0.000000000000002131',
711
+ },
712
+ [
713
+ [
714
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f",
715
+ "0x0000000000000000000000000000000000000000000000000000000000000853", "0x0000000000000000000000000000000000000000000000000000000000231860"
716
+ ],
717
+ enums_1.ChainId.Ethereum
718
+ ],
719
+ ],
720
+ [
721
+ {
722
+ fromToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Arbitrum).address),
723
+ toToken: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
724
+ amount: '0.04120023',
725
+ },
726
+ [
727
+ [
728
+ "0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f", "0x000000000000000000000000f97f4df75117a78c1a5a0dbb814af92458539fb4",
729
+ "0x00000000000000000000000000000000000000000000000000000000003eddd7", "0x0000000000000000000000000000000000000000000000000000000008f57500"
730
+ ],
731
+ enums_1.ChainId.Arbitrum
732
+ ]
733
+ ],
734
+ ];
735
+ examples.forEach(([expected, actual]) => {
736
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
737
+ (0, chai_1.expect)(subDataService_1.exchangeLimitOrderSubData.decode(...actual)).to.eql(expected);
738
+ });
739
+ });
740
+ });
741
+ });
742
+ describe('When testing subDataService.sparkLeverageManagementSubData', () => {
743
+ describe('decode()', () => {
744
+ const examples = [
745
+ [
746
+ { targetRatio: 200 },
747
+ ["0x0000000000000000000000000000000000000000000000001bc16d674ec80000"],
748
+ ],
749
+ [
750
+ { targetRatio: 123 },
751
+ ["0x0000000000000000000000000000000000000000000000001111d67bb1bb0000"],
752
+ ],
753
+ ];
754
+ examples.forEach(([expected, actual]) => {
755
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
756
+ (0, chai_1.expect)(subDataService_1.sparkLeverageManagementSubData.decode(actual)).to.eql(expected);
757
+ });
758
+ });
759
+ });
760
+ });
761
+ describe('When testing subDataService.sparkQuotePriceSubData', () => {
762
+ describe('encode()', () => {
763
+ const examples = [
764
+ [
765
+ [
766
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000000000000000000000000000000000000000000002",
767
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000000000000000000000000000000000000000000004",
768
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
769
+ ],
770
+ [
771
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
772
+ 2,
773
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
774
+ 4,
775
+ ]
776
+ ],
777
+ [
778
+ [
779
+ "0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529", "0x0000000000000000000000000000000000000000000000000000000000000006",
780
+ "0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831", "0x0000000000000000000000000000000000000000000000000000000000000002",
781
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
782
+ ],
783
+ [
784
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('wstETH', enums_1.ChainId.Arbitrum).address),
785
+ 6,
786
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
787
+ 2,
788
+ ]
789
+ ],
790
+ ];
791
+ examples.forEach(([expected, actual]) => {
792
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
793
+ (0, chai_1.expect)(subDataService_1.sparkQuotePriceSubData.encode(...actual)).to.eql(expected);
794
+ });
795
+ });
796
+ });
797
+ describe('decode()', () => {
798
+ const examples = [
799
+ [
800
+ {
801
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
802
+ collAssetId: 2,
803
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
804
+ debtAssetId: 4,
805
+ },
806
+ [
807
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000000000000000000000000000000000000000000002",
808
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000000000000000000000000000000000000000000004",
809
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
810
+ ],
811
+ ],
812
+ [
813
+ {
814
+ collAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('wstETH', enums_1.ChainId.Arbitrum).address),
815
+ collAssetId: 6,
816
+ debtAsset: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
817
+ debtAssetId: 2,
818
+ },
819
+ [
820
+ "0x0000000000000000000000005979d7b546e38e414f7e9822514be443a4800529", "0x0000000000000000000000000000000000000000000000000000000000000006",
821
+ "0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831", "0x0000000000000000000000000000000000000000000000000000000000000002",
822
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
823
+ ],
824
+ ],
825
+ ];
826
+ examples.forEach(([expected, actual]) => {
827
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
828
+ (0, chai_1.expect)(subDataService_1.sparkQuotePriceSubData.decode(actual)).to.eql(expected);
829
+ });
830
+ });
831
+ });
832
+ });
833
+ describe('When testing subDataService.liquityDsrPaybackSubData', () => {
834
+ describe('encode()', () => {
835
+ const examples = [
836
+ [
837
+ [
838
+ "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000001111d67bb1bb0000",
839
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0",
840
+ ],
841
+ [123]
842
+ ],
843
+ [
844
+ [
845
+ "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000003a4965bf58a40000",
846
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0",
847
+ ],
848
+ [420]
849
+ ],
850
+ ];
851
+ examples.forEach(([expected, actual]) => {
852
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
853
+ (0, chai_1.expect)(subDataService_1.liquityDsrPaybackSubData.encode(...actual)).to.eql(expected);
854
+ });
855
+ });
856
+ });
857
+ describe('decode()', () => {
858
+ const examples = [
859
+ [
860
+ {
861
+ targetRatio: 123,
862
+ },
863
+ [
864
+ "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000001111d67bb1bb0000",
865
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0",
866
+ ],
867
+ ],
868
+ [
869
+ {
870
+ targetRatio: 420,
871
+ },
872
+ [
873
+ "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000003a4965bf58a40000",
874
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0",
875
+ ],
876
+ ],
877
+ ];
878
+ examples.forEach(([expected, actual]) => {
879
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
880
+ (0, chai_1.expect)(subDataService_1.liquityDsrPaybackSubData.decode(actual)).to.eql(expected);
881
+ });
882
+ });
883
+ });
884
+ });
885
+ describe('When testing subDataService.liquityDsrSupplySubData', () => {
886
+ describe('encode()', () => {
887
+ const examples = [
888
+ [
889
+ [
890
+ "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000002c68af0bb1400000",
891
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
892
+ ],
893
+ [320]
894
+ ],
895
+ [
896
+ [
897
+ "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000001eab7f4a799d0000",
898
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
899
+ ],
900
+ [221]
901
+ ],
902
+ ];
903
+ examples.forEach(([expected, actual]) => {
904
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
905
+ (0, chai_1.expect)(subDataService_1.liquityDsrSupplySubData.encode(...actual)).to.eql(expected);
906
+ });
907
+ });
908
+ });
909
+ describe('decode()', () => {
910
+ const examples = [
911
+ [
912
+ {
913
+ targetRatio: 320,
914
+ },
915
+ [
916
+ "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000002c68af0bb1400000",
917
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
918
+ ],
919
+ ],
920
+ [
921
+ {
922
+ targetRatio: 221,
923
+ },
924
+ [
925
+ "0x0000000000000000000000000000000000000000000000000000000000000001", "0x0000000000000000000000000000000000000000000000001eab7f4a799d0000",
926
+ "0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f", "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
927
+ ],
928
+ ],
929
+ ];
930
+ examples.forEach(([expected, actual]) => {
931
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
932
+ (0, chai_1.expect)(subDataService_1.liquityDsrSupplySubData.decode(actual)).to.eql(expected);
933
+ });
934
+ });
935
+ });
936
+ });
937
+ describe('When testing subDataService.liquityDebtInFrontRepaySubData', () => {
938
+ describe('encode()', () => {
939
+ const examples = [
940
+ [
941
+ [
942
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0",
943
+ "0x000000000000000000000000000000000000000000000000016345785d8a0000", "0x0000000000000000000000000000000000000000000000000000000000000001",
944
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
945
+ ],
946
+ [10]
947
+ ],
948
+ [
949
+ [
950
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0",
951
+ "0x000000000000000000000000000000000000000000000000063eb89da4ed0000", "0x0000000000000000000000000000000000000000000000000000000000000001",
952
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
953
+ ],
954
+ [45]
955
+ ],
956
+ ];
957
+ examples.forEach(([expected, actual]) => {
958
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
959
+ (0, chai_1.expect)(subDataService_1.liquityDebtInFrontRepaySubData.encode(...actual)).to.eql(expected);
960
+ });
961
+ });
962
+ });
963
+ describe('decode()', () => {
964
+ const examples = [
965
+ [
966
+ {
967
+ targetRatioIncrease: 10,
968
+ },
969
+ [
970
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0",
971
+ "0x000000000000000000000000000000000000000000000000016345785d8a0000", "0x0000000000000000000000000000000000000000000000000000000000000001",
972
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
973
+ ],
974
+ ],
975
+ [
976
+ {
977
+ targetRatioIncrease: 45,
978
+ },
979
+ [
980
+ "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0",
981
+ "0x000000000000000000000000000000000000000000000000063eb89da4ed0000", "0x0000000000000000000000000000000000000000000000000000000000000001",
982
+ "0x0000000000000000000000000000000000000000000000000000000000000000",
983
+ ],
984
+ ],
985
+ ];
986
+ examples.forEach(([expected, actual]) => {
987
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
988
+ (0, chai_1.expect)(subDataService_1.liquityDebtInFrontRepaySubData.decode(actual)).to.eql(expected);
989
+ });
990
+ });
991
+ });
992
+ });
993
+ });