@defisaver/automation-sdk 3.1.9 → 3.1.14-spark-dev

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