@defisaver/automation-sdk 3.2.5 → 3.3.0

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