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