@defisaver/automation-sdk 3.1.3 → 3.2.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 (246) hide show
  1. package/.babelrc +3 -3
  2. package/.editorconfig +9 -9
  3. package/.env +5 -0
  4. package/.env.dev +4 -4
  5. package/.eslintignore +6 -6
  6. package/.eslintrc.js +39 -39
  7. package/.mocharc.json +4 -4
  8. package/.nvmrc +1 -1
  9. package/README.md +46 -46
  10. package/cjs/abis/Erc20.json +223 -223
  11. package/cjs/abis/SubStorage.json +21 -21
  12. package/cjs/abis/UniMulticall.json +17 -17
  13. package/cjs/abis/index.d.ts +9 -9
  14. package/cjs/abis/index.js +30 -30
  15. package/cjs/abis/legacy_AaveV2Subscriptions.json +8 -8
  16. package/cjs/abis/legacy_AuthCheck.json +8 -8
  17. package/cjs/abis/legacy_CompoundV2Subscriptions.json +9 -9
  18. package/cjs/abis/legacy_MakerSubscriptions.json +9 -9
  19. package/cjs/automation/private/Automation.d.ts +12 -12
  20. package/cjs/automation/private/Automation.js +42 -42
  21. package/cjs/automation/private/LegacyAutomation.d.ts +25 -25
  22. package/cjs/automation/private/LegacyAutomation.js +118 -118
  23. package/cjs/automation/private/LegacyProtocol.d.ts +22 -22
  24. package/cjs/automation/private/LegacyProtocol.js +41 -41
  25. package/cjs/automation/private/LegacyProtocol.test.d.ts +1 -1
  26. package/cjs/automation/private/LegacyProtocol.test.js +25 -25
  27. package/cjs/automation/private/Protocol.d.ts +22 -22
  28. package/cjs/automation/private/Protocol.js +41 -41
  29. package/cjs/automation/private/Protocol.test.d.ts +1 -1
  30. package/cjs/automation/private/Protocol.test.js +25 -25
  31. package/cjs/automation/private/StrategiesAutomation.d.ts +33 -33
  32. package/cjs/automation/private/StrategiesAutomation.js +190 -181
  33. package/cjs/automation/private/StrategiesAutomation.test.d.ts +1 -1
  34. package/cjs/automation/private/StrategiesAutomation.test.js +671 -671
  35. package/cjs/automation/public/ArbitrumStrategies.d.ts +5 -5
  36. package/cjs/automation/public/ArbitrumStrategies.js +13 -13
  37. package/cjs/automation/public/BaseStrategies.d.ts +5 -5
  38. package/cjs/automation/public/BaseStrategies.js +13 -13
  39. package/cjs/automation/public/EthereumStrategies.d.ts +5 -5
  40. package/cjs/automation/public/EthereumStrategies.js +13 -13
  41. package/cjs/automation/public/OptimismStrategies.d.ts +5 -5
  42. package/cjs/automation/public/OptimismStrategies.js +13 -13
  43. package/cjs/automation/public/Strategies.test.d.ts +1 -0
  44. package/cjs/automation/public/Strategies.test.js +61 -0
  45. package/cjs/automation/public/legacy/LegacyAaveAutomation.d.ts +6 -6
  46. package/cjs/automation/public/legacy/LegacyAaveAutomation.js +20 -20
  47. package/cjs/automation/public/legacy/LegacyCompoundAutomation.d.ts +6 -6
  48. package/cjs/automation/public/legacy/LegacyCompoundAutomation.js +20 -20
  49. package/cjs/automation/public/legacy/LegacyMakerAutomation.d.ts +6 -6
  50. package/cjs/automation/public/legacy/LegacyMakerAutomation.js +20 -20
  51. package/cjs/configuration.d.ts +1 -1
  52. package/cjs/configuration.js +12 -12
  53. package/cjs/constants/index.d.ts +28 -28
  54. package/cjs/constants/index.js +494 -489
  55. package/cjs/index.d.ts +23 -23
  56. package/cjs/index.js +65 -65
  57. package/cjs/services/contractService.d.ts +12 -12
  58. package/cjs/services/contractService.js +54 -54
  59. package/cjs/services/ethereumService.d.ts +7 -7
  60. package/cjs/services/ethereumService.js +49 -49
  61. package/cjs/services/ethereumService.test.d.ts +1 -1
  62. package/cjs/services/ethereumService.test.js +242 -242
  63. package/cjs/services/strategiesService.d.ts +2 -2
  64. package/cjs/services/strategiesService.js +724 -723
  65. package/cjs/services/strategiesService.test.d.ts +1 -1
  66. package/cjs/services/strategiesService.test.js +110 -110
  67. package/cjs/services/strategySubService.d.ts +100 -100
  68. package/cjs/services/strategySubService.js +267 -267
  69. package/cjs/services/strategySubService.test.d.ts +1 -1
  70. package/cjs/services/strategySubService.test.js +936 -936
  71. package/cjs/services/subDataService.d.ts +192 -192
  72. package/cjs/services/subDataService.js +475 -475
  73. package/cjs/services/subDataService.test.d.ts +1 -1
  74. package/cjs/services/subDataService.test.js +1282 -1282
  75. package/cjs/services/triggerService.d.ts +191 -191
  76. package/cjs/services/triggerService.js +367 -367
  77. package/cjs/services/triggerService.test.d.ts +1 -1
  78. package/cjs/services/triggerService.test.js +926 -926
  79. package/cjs/services/utils.d.ts +25 -25
  80. package/cjs/services/utils.js +131 -131
  81. package/cjs/services/utils.test.d.ts +1 -1
  82. package/cjs/services/utils.test.js +376 -376
  83. package/cjs/types/contracts/generated/Erc20.d.ts +53 -53
  84. package/cjs/types/contracts/generated/Erc20.js +5 -5
  85. package/cjs/types/contracts/generated/Legacy_AaveV2Subscriptions.d.ts +129 -129
  86. package/cjs/types/contracts/generated/Legacy_AaveV2Subscriptions.js +5 -5
  87. package/cjs/types/contracts/generated/Legacy_AuthCheck.d.ts +20 -20
  88. package/cjs/types/contracts/generated/Legacy_AuthCheck.js +5 -5
  89. package/cjs/types/contracts/generated/Legacy_CompoundV2Subscriptions.d.ts +128 -128
  90. package/cjs/types/contracts/generated/Legacy_CompoundV2Subscriptions.js +5 -5
  91. package/cjs/types/contracts/generated/Legacy_MakerSubscriptions.d.ts +246 -246
  92. package/cjs/types/contracts/generated/Legacy_MakerSubscriptions.js +5 -5
  93. package/cjs/types/contracts/generated/SubStorage.d.ts +110 -114
  94. package/cjs/types/contracts/generated/SubStorage.js +5 -5
  95. package/cjs/types/contracts/generated/UniMulticall.d.ts +55 -55
  96. package/cjs/types/contracts/generated/UniMulticall.js +5 -5
  97. package/cjs/types/contracts/generated/index.d.ts +7 -7
  98. package/cjs/types/contracts/generated/index.js +2 -2
  99. package/cjs/types/contracts/generated/types.d.ts +54 -54
  100. package/cjs/types/contracts/generated/types.js +2 -2
  101. package/cjs/types/enums.d.ts +186 -184
  102. package/cjs/types/enums.js +208 -206
  103. package/cjs/types/index.d.ts +224 -224
  104. package/cjs/types/index.js +2 -2
  105. package/esm/abis/Erc20.json +223 -223
  106. package/esm/abis/SubStorage.json +21 -21
  107. package/esm/abis/UniMulticall.json +17 -17
  108. package/esm/abis/index.d.ts +9 -9
  109. package/esm/abis/index.js +18 -18
  110. package/esm/abis/legacy_AaveV2Subscriptions.json +8 -8
  111. package/esm/abis/legacy_AuthCheck.json +8 -8
  112. package/esm/abis/legacy_CompoundV2Subscriptions.json +9 -9
  113. package/esm/abis/legacy_MakerSubscriptions.json +9 -9
  114. package/esm/automation/private/Automation.d.ts +12 -12
  115. package/esm/automation/private/Automation.js +39 -39
  116. package/esm/automation/private/LegacyAutomation.d.ts +25 -25
  117. package/esm/automation/private/LegacyAutomation.js +112 -112
  118. package/esm/automation/private/LegacyProtocol.d.ts +22 -22
  119. package/esm/automation/private/LegacyProtocol.js +38 -38
  120. package/esm/automation/private/LegacyProtocol.test.d.ts +1 -1
  121. package/esm/automation/private/LegacyProtocol.test.js +20 -20
  122. package/esm/automation/private/Protocol.d.ts +22 -22
  123. package/esm/automation/private/Protocol.js +38 -38
  124. package/esm/automation/private/Protocol.test.d.ts +1 -1
  125. package/esm/automation/private/Protocol.test.js +20 -20
  126. package/esm/automation/private/StrategiesAutomation.d.ts +33 -33
  127. package/esm/automation/private/StrategiesAutomation.js +184 -175
  128. package/esm/automation/private/StrategiesAutomation.test.d.ts +1 -1
  129. package/esm/automation/private/StrategiesAutomation.test.js +666 -666
  130. package/esm/automation/public/ArbitrumStrategies.d.ts +5 -5
  131. package/esm/automation/public/ArbitrumStrategies.js +7 -7
  132. package/esm/automation/public/BaseStrategies.d.ts +5 -5
  133. package/esm/automation/public/BaseStrategies.js +7 -7
  134. package/esm/automation/public/EthereumStrategies.d.ts +5 -5
  135. package/esm/automation/public/EthereumStrategies.js +7 -7
  136. package/esm/automation/public/OptimismStrategies.d.ts +5 -5
  137. package/esm/automation/public/OptimismStrategies.js +7 -7
  138. package/esm/automation/public/Strategies.test.d.ts +1 -0
  139. package/esm/automation/public/Strategies.test.js +56 -0
  140. package/esm/automation/public/legacy/LegacyAaveAutomation.d.ts +6 -6
  141. package/esm/automation/public/legacy/LegacyAaveAutomation.js +14 -14
  142. package/esm/automation/public/legacy/LegacyCompoundAutomation.d.ts +6 -6
  143. package/esm/automation/public/legacy/LegacyCompoundAutomation.js +14 -14
  144. package/esm/automation/public/legacy/LegacyMakerAutomation.d.ts +6 -6
  145. package/esm/automation/public/legacy/LegacyMakerAutomation.js +14 -14
  146. package/esm/configuration.d.ts +1 -1
  147. package/esm/configuration.js +7 -7
  148. package/esm/constants/index.d.ts +28 -28
  149. package/esm/constants/index.js +488 -483
  150. package/esm/index.d.ts +23 -23
  151. package/esm/index.js +23 -23
  152. package/esm/services/contractService.d.ts +12 -12
  153. package/esm/services/contractService.js +45 -45
  154. package/esm/services/ethereumService.d.ts +7 -7
  155. package/esm/services/ethereumService.js +41 -41
  156. package/esm/services/ethereumService.test.d.ts +1 -1
  157. package/esm/services/ethereumService.test.js +237 -237
  158. package/esm/services/strategiesService.d.ts +2 -2
  159. package/esm/services/strategiesService.js +697 -696
  160. package/esm/services/strategiesService.test.d.ts +1 -1
  161. package/esm/services/strategiesService.test.js +108 -108
  162. package/esm/services/strategySubService.d.ts +100 -100
  163. package/esm/services/strategySubService.js +238 -238
  164. package/esm/services/strategySubService.test.d.ts +1 -1
  165. package/esm/services/strategySubService.test.js +908 -908
  166. package/esm/services/subDataService.d.ts +192 -192
  167. package/esm/services/subDataService.js +469 -469
  168. package/esm/services/subDataService.test.d.ts +1 -1
  169. package/esm/services/subDataService.test.js +1254 -1254
  170. package/esm/services/triggerService.d.ts +191 -191
  171. package/esm/services/triggerService.js +338 -338
  172. package/esm/services/triggerService.test.d.ts +1 -1
  173. package/esm/services/triggerService.test.js +901 -901
  174. package/esm/services/utils.d.ts +25 -25
  175. package/esm/services/utils.js +82 -82
  176. package/esm/services/utils.test.d.ts +1 -1
  177. package/esm/services/utils.test.js +348 -348
  178. package/esm/types/contracts/generated/Erc20.d.ts +53 -53
  179. package/esm/types/contracts/generated/Erc20.js +4 -4
  180. package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.d.ts +129 -129
  181. package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.js +4 -4
  182. package/esm/types/contracts/generated/Legacy_AuthCheck.d.ts +20 -20
  183. package/esm/types/contracts/generated/Legacy_AuthCheck.js +4 -4
  184. package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.d.ts +128 -128
  185. package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.js +4 -4
  186. package/esm/types/contracts/generated/Legacy_MakerSubscriptions.d.ts +246 -246
  187. package/esm/types/contracts/generated/Legacy_MakerSubscriptions.js +4 -4
  188. package/esm/types/contracts/generated/SubStorage.d.ts +110 -114
  189. package/esm/types/contracts/generated/SubStorage.js +4 -4
  190. package/esm/types/contracts/generated/UniMulticall.d.ts +55 -55
  191. package/esm/types/contracts/generated/UniMulticall.js +4 -4
  192. package/esm/types/contracts/generated/index.d.ts +7 -7
  193. package/esm/types/contracts/generated/index.js +1 -1
  194. package/esm/types/contracts/generated/types.d.ts +54 -54
  195. package/esm/types/contracts/generated/types.js +1 -1
  196. package/esm/types/enums.d.ts +186 -184
  197. package/esm/types/enums.js +205 -203
  198. package/esm/types/index.d.ts +224 -224
  199. package/esm/types/index.js +1 -1
  200. package/package.json +62 -61
  201. package/scripts/generateContractTypes.js +39 -39
  202. package/src/abis/Erc20.json +222 -222
  203. package/src/abis/SubStorage.json +21 -21
  204. package/src/abis/UniMulticall.json +17 -17
  205. package/src/abis/index.ts +28 -28
  206. package/src/abis/legacy_AaveV2Subscriptions.json +7 -7
  207. package/src/abis/legacy_AuthCheck.json +7 -7
  208. package/src/abis/legacy_CompoundV2Subscriptions.json +8 -8
  209. package/src/abis/legacy_MakerSubscriptions.json +8 -8
  210. package/src/automation/private/Automation.ts +44 -44
  211. package/src/automation/private/LegacyAutomation.ts +135 -135
  212. package/src/automation/private/LegacyProtocol.test.ts +23 -23
  213. package/src/automation/private/LegacyProtocol.ts +51 -51
  214. package/src/automation/private/Protocol.test.ts +23 -23
  215. package/src/automation/private/Protocol.ts +51 -51
  216. package/src/automation/private/StrategiesAutomation.test.ts +663 -663
  217. package/src/automation/private/StrategiesAutomation.ts +254 -242
  218. package/src/automation/public/ArbitrumStrategies.ts +10 -10
  219. package/src/automation/public/BaseStrategies.ts +10 -10
  220. package/src/automation/public/EthereumStrategies.ts +10 -10
  221. package/src/automation/public/OptimismStrategies.ts +10 -10
  222. package/src/automation/public/Strategies.test.ts +49 -0
  223. package/src/automation/public/legacy/LegacyAaveAutomation.ts +20 -20
  224. package/src/automation/public/legacy/LegacyCompoundAutomation.ts +20 -20
  225. package/src/automation/public/legacy/LegacyMakerAutomation.ts +20 -20
  226. package/src/configuration.ts +8 -8
  227. package/src/constants/index.ts +523 -507
  228. package/src/index.ts +39 -39
  229. package/src/services/contractService.ts +77 -77
  230. package/src/services/ethereumService.test.ts +257 -257
  231. package/src/services/ethereumService.ts +69 -69
  232. package/src/services/strategiesService.test.ts +105 -105
  233. package/src/services/strategiesService.ts +935 -934
  234. package/src/services/strategySubService.test.ts +1122 -1122
  235. package/src/services/strategySubService.ts +524 -524
  236. package/src/services/subDataService.test.ts +1387 -1387
  237. package/src/services/subDataService.ts +645 -645
  238. package/src/services/triggerService.test.ts +1004 -1004
  239. package/src/services/triggerService.ts +449 -449
  240. package/src/services/utils.test.ts +430 -430
  241. package/src/services/utils.ts +103 -103
  242. package/src/types/enums.ts +202 -200
  243. package/src/types/index.ts +279 -279
  244. package/tsconfig.esm.json +8 -8
  245. package/tsconfig.json +22 -22
  246. package/umd/index.js +0 -34103
@@ -1,663 +1,663 @@
1
- import Web3 from 'web3';
2
- import { expect } from 'chai';
3
-
4
- import {ChainId} from '../../types/enums';
5
-
6
- import '../../configuration';
7
- import StrategiesAutomation from './StrategiesAutomation';
8
-
9
- require('dotenv').config({ path: '.env' });
10
-
11
- const Web3_1 = new Web3(process.env.RPC_1!);
12
-
13
- describe('Feature: StrategiesAutomation.ts', () => {
14
- describe('When testing class StrategiesAutomation', async () => {
15
- const exampleStrategiesAutomation = new StrategiesAutomation({
16
- chainId:ChainId.Ethereum,
17
- provider: Web3_1,
18
- providerFork: null!,
19
- });
20
-
21
- const examples: Array<[any, any]> = [
22
- [
23
- [
24
- {
25
- 'isEnabled': true,
26
- 'chainId': 1,
27
- 'subHash': '0x7a14b187374b9ab02f6f7c95f275ef547376da010d53c715870cd053199a6aee',
28
- 'blockNumber': 0,
29
- 'positionId': '1-aave__v3',
30
- 'subId': 0,
31
- 'protocol': {
32
- 'id': 'Aave__V3',
33
- 'name': 'Aave',
34
- 'slug': 'aave',
35
- 'version': 'V3',
36
- 'fullName': 'Aave V3'
37
- },
38
- 'strategy': {
39
- 'isBundle': true,
40
- 'strategyOrBundleId': 0,
41
- 'strategyId': 'leverage-management',
42
- 'protocol': {
43
- 'id': 'Aave__V3',
44
- 'name': 'Aave',
45
- 'slug': 'aave',
46
- 'version': 'V3',
47
- 'fullName': 'Aave V3'
48
- }
49
- },
50
- 'strategyData': {
51
- 'encoded': {
52
- 'subData': [
53
- '0x000000000000000000000000000000000000000000000000120a871cc0020000',
54
- '0x0000000000000000000000000000000000000000000000000000000000000001',
55
- '0x0000000000000000000000000000000000000000000000000000000000000001',
56
- '0x0000000000000000000000000000000000000000000000000000000000000000'
57
- ]
58
- },
59
- 'decoded': {
60
- 'triggerData': {
61
- 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
62
- 'ratio': 120,
63
- 'ratioState': 1
64
- },
65
- 'subData': {
66
- 'targetRatio': 130
67
- }
68
- }
69
- },
70
- 'specific': {
71
- 'triggerRepayRatio': 120,
72
- 'targetRepayRatio': 130,
73
- 'repayEnabled': true,
74
- 'subId1': 0,
75
- 'mergeWithId': 'boost'
76
- }
77
- },
78
- {
79
- 'isEnabled': false,
80
- 'chainId': 1,
81
- 'subHash': '0x7a14b187374b9ab02f6f7c95f275ef547376da010d53c715870cd053199a6aee',
82
- 'blockNumber': 0,
83
- 'positionId': '1-aave__v3',
84
- 'subId': 1,
85
- 'protocol': {
86
- 'id': 'Aave__V3',
87
- 'name': 'Aave',
88
- 'slug': 'aave',
89
- 'version': 'V3',
90
- 'fullName': 'Aave V3'
91
- },
92
- 'strategy': {
93
- 'isBundle': true,
94
- 'strategyOrBundleId': 0,
95
- 'strategyId': 'leverage-management',
96
- 'protocol': {
97
- 'id': 'Aave__V3',
98
- 'name': 'Aave',
99
- 'slug': 'aave',
100
- 'version': 'V3',
101
- 'fullName': 'Aave V3'
102
- }
103
- },
104
- 'strategyData': {
105
- 'encoded': {
106
- 'subData': [
107
- '0x000000000000000000000000000000000000000000000000120a871cc0020000',
108
- '0x0000000000000000000000000000000000000000000000000000000000000001',
109
- '0x0000000000000000000000000000000000000000000000000000000000000001',
110
- '0x0000000000000000000000000000000000000000000000000000000000000000'
111
- ]
112
- },
113
- 'decoded': {
114
- 'triggerData': {
115
- 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
116
- 'ratio': 120,
117
- 'ratioState': 1
118
- },
119
- 'subData': {
120
- 'targetRatio': 130
121
- }
122
- }
123
- },
124
- 'specific': {
125
- 'triggerRepayRatio': 120,
126
- 'targetRepayRatio': 130,
127
- 'repayEnabled': true,
128
- 'subId1': 1,
129
- 'mergeWithId': 'boost'
130
- }
131
- },
132
- {
133
- 'isEnabled': false,
134
- 'chainId': 1,
135
- 'subHash': '0xe55917c42ac3e8f6c080e3780c5e0ea7a0a3da6c05e7ced5fe69fee48133a5eb',
136
- 'blockNumber': 0,
137
- 'positionId': '1-aave__v3',
138
- 'subId': 2,
139
- 'protocol': {
140
- 'id': 'Aave__V3',
141
- 'name': 'Aave',
142
- 'slug': 'aave',
143
- 'version': 'V3',
144
- 'fullName': 'Aave V3'
145
- },
146
- 'strategy': {
147
- 'isBundle': true,
148
- 'strategyOrBundleId': 0,
149
- 'strategyId': 'leverage-management',
150
- 'protocol': {
151
- 'id': 'Aave__V3',
152
- 'name': 'Aave',
153
- 'slug': 'aave',
154
- 'version': 'V3',
155
- 'fullName': 'Aave V3'
156
- }
157
- },
158
- 'strategyData': {
159
- 'encoded': {
160
- 'subData': [
161
- '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
162
- '0x0000000000000000000000000000000000000000000000000000000000000001',
163
- '0x0000000000000000000000000000000000000000000000000000000000000001',
164
- '0x0000000000000000000000000000000000000000000000000000000000000000'
165
- ]
166
- },
167
- 'decoded': {
168
- 'triggerData': {
169
- 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
170
- 'ratio': 135,
171
- 'ratioState': 1
172
- },
173
- 'subData': {
174
- 'targetRatio': 150
175
- }
176
- }
177
- },
178
- 'specific': {
179
- 'triggerRepayRatio': 135,
180
- 'targetRepayRatio': 150,
181
- 'repayEnabled': true,
182
- 'subId1': 2,
183
- 'mergeWithId': 'boost'
184
- }
185
- },
186
- {
187
- 'isEnabled': false,
188
- 'chainId': 1,
189
- 'subHash': '0x96d6a5fe8127765a0fa55115621495bf66ebd16029b0883bc097eda1b597ab0b',
190
- 'blockNumber': 0,
191
- 'positionId': '1-aave__v3',
192
- 'subId': 3,
193
- 'protocol': {
194
- 'id': 'Aave__V3',
195
- 'name': 'Aave',
196
- 'slug': 'aave',
197
- 'version': 'V3',
198
- 'fullName': 'Aave V3'
199
- },
200
- 'strategy': {
201
- 'isBundle': true,
202
- 'strategyOrBundleId': 1,
203
- 'strategyId': 'leverage-management',
204
- 'protocol': {
205
- 'id': 'Aave__V3',
206
- 'name': 'Aave',
207
- 'slug': 'aave',
208
- 'version': 'V3',
209
- 'fullName': 'Aave V3'
210
- }
211
- },
212
- 'strategyData': {
213
- 'encoded': {
214
- 'subData': [
215
- '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
216
- '0x0000000000000000000000000000000000000000000000000000000000000000',
217
- '0x0000000000000000000000000000000000000000000000000000000000000001',
218
- '0x0000000000000000000000000000000000000000000000000000000000000000',
219
- '0x0000000000000000000000000000000000000000000000000000000000000001'
220
- ]
221
- },
222
- 'decoded': {
223
- 'triggerData': {
224
- 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
225
- 'ratio': 165,
226
- 'ratioState': 0
227
- },
228
- 'subData': {
229
- 'targetRatio': 150
230
- }
231
- }
232
- },
233
- 'specific': {
234
- 'triggerBoostRatio': 165,
235
- 'targetBoostRatio': 150,
236
- 'boostEnabled': false,
237
- 'subId2': 3,
238
- 'mergeId': 'boost'
239
- }
240
- },
241
- {
242
- 'isEnabled': false,
243
- 'chainId': 1,
244
- 'subHash': '0x96d6a5fe8127765a0fa55115621495bf66ebd16029b0883bc097eda1b597ab0b',
245
- 'blockNumber': 1,
246
- 'positionId': '1-aave__v3',
247
- 'subId': 4,
248
- 'protocol': {
249
- 'id': 'Aave__V3',
250
- 'name': 'Aave',
251
- 'slug': 'aave',
252
- 'version': 'V3',
253
- 'fullName': 'Aave V3'
254
- },
255
- 'strategy': {
256
- 'isBundle': true,
257
- 'strategyOrBundleId': 1,
258
- 'strategyId': 'leverage-management',
259
- 'protocol': {
260
- 'id': 'Aave__V3',
261
- 'name': 'Aave',
262
- 'slug': 'aave',
263
- 'version': 'V3',
264
- 'fullName': 'Aave V3'
265
- }
266
- },
267
- 'strategyData': {
268
- 'encoded': {
269
- 'subData': [
270
- '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
271
- '0x0000000000000000000000000000000000000000000000000000000000000000',
272
- '0x0000000000000000000000000000000000000000000000000000000000000001',
273
- '0x0000000000000000000000000000000000000000000000000000000000000000',
274
- '0x0000000000000000000000000000000000000000000000000000000000000001'
275
- ]
276
- },
277
- 'decoded': {
278
- 'triggerData': {
279
- 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
280
- 'ratio': 165,
281
- 'ratioState': 0
282
- },
283
- 'subData': {
284
- 'targetRatio': 150
285
- }
286
- }
287
- },
288
- 'specific': {
289
- 'triggerBoostRatio': 165,
290
- 'targetBoostRatio': 150,
291
- 'boostEnabled': false,
292
- 'subId2': 4,
293
- 'mergeId': 'boost'
294
- }
295
- },
296
- {
297
- 'isEnabled': false,
298
- 'chainId': 1,
299
- 'subHash': '0x96d6a5fe8127765a0fa55115621495bf66ebd16029b0883bc097eda1b597ab0b',
300
- 'blockNumber': 1,
301
- 'positionId': '1-aave__v3',
302
- 'subId': 5,
303
- 'protocol': {
304
- 'id': 'Aave__V3',
305
- 'name': 'Aave',
306
- 'slug': 'aave',
307
- 'version': 'V3',
308
- 'fullName': 'Aave V3'
309
- },
310
- 'strategy': {
311
- 'isBundle': true,
312
- 'strategyOrBundleId': 1,
313
- 'strategyId': 'leverage-management',
314
- 'protocol': {
315
- 'id': 'Aave__V3',
316
- 'name': 'Aave',
317
- 'slug': 'aave',
318
- 'version': 'V3',
319
- 'fullName': 'Aave V3'
320
- }
321
- },
322
- 'strategyData': {
323
- 'encoded': {
324
- 'subData': [
325
- '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
326
- '0x0000000000000000000000000000000000000000000000000000000000000000',
327
- '0x0000000000000000000000000000000000000000000000000000000000000001',
328
- '0x0000000000000000000000000000000000000000000000000000000000000000',
329
- '0x0000000000000000000000000000000000000000000000000000000000000001'
330
- ]
331
- },
332
- 'decoded': {
333
- 'triggerData': {
334
- 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
335
- 'ratio': 165,
336
- 'ratioState': 0
337
- },
338
- 'subData': {
339
- 'targetRatio': 150
340
- }
341
- }
342
- },
343
- 'specific': {
344
- 'triggerBoostRatio': 165,
345
- 'targetBoostRatio': 150,
346
- 'boostEnabled': false,
347
- 'subId2': 5,
348
- 'mergeId': 'boost'
349
- }
350
- },
351
- {
352
- 'isEnabled': false,
353
- 'chainId': 1,
354
- 'subHash': '0x52cd11186443c2734f027a7175bccf80158c6a45906f4b33b5713b77244aa7f6',
355
- 'blockNumber': 1,
356
- 'positionId': '1-aave__v3',
357
- 'subId': 6,
358
- 'protocol': {
359
- 'id': 'Aave__V3',
360
- 'name': 'Aave',
361
- 'slug': 'aave',
362
- 'version': 'V3',
363
- 'fullName': 'Aave V3'
364
- },
365
- 'strategy': {
366
- 'isBundle': true,
367
- 'strategyOrBundleId': 0,
368
- 'strategyId': 'leverage-management',
369
- 'protocol': {
370
- 'id': 'Aave__V3',
371
- 'name': 'Aave',
372
- 'slug': 'aave',
373
- 'version': 'V3',
374
- 'fullName': 'Aave V3'
375
- }
376
- },
377
- 'strategyData': {
378
- 'encoded': {
379
- 'subData': [
380
- '0x00000000000000000000000000000000000000000000000012bc29d8eec70000',
381
- '0x0000000000000000000000000000000000000000000000000000000000000001',
382
- '0x0000000000000000000000000000000000000000000000000000000000000001',
383
- '0x0000000000000000000000000000000000000000000000000000000000000000'
384
- ]
385
- },
386
- 'decoded': {
387
- 'triggerData': {
388
- 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
389
- 'ratio': 120,
390
- 'ratioState': 1
391
- },
392
- 'subData': {
393
- 'targetRatio': 135
394
- }
395
- }
396
- },
397
- 'specific': {
398
- 'triggerRepayRatio': 120,
399
- 'targetRepayRatio': 135,
400
- 'repayEnabled': true,
401
- 'subId1': 6,
402
- 'mergeWithId': 'boost'
403
- }
404
- }
405
- ],[
406
- {
407
- 'isEnabled': true,
408
- 'chainId': 1,
409
- 'subHash': '0x7a14b187374b9ab02f6f7c95f275ef547376da010d53c715870cd053199a6aee',
410
- 'blockNumber': 0,
411
- 'positionId': '1-aave__v3',
412
- 'subId': 0,
413
- 'protocol': {
414
- 'id': 'Aave__V3',
415
- 'name': 'Aave',
416
- 'slug': 'aave',
417
- 'version': 'V3',
418
- 'fullName': 'Aave V3'
419
- },
420
- 'strategy': {
421
- 'isBundle': true,
422
- 'strategyOrBundleId': 0,
423
- 'strategyId': 'leverage-management',
424
- 'protocol': {
425
- 'id': 'Aave__V3',
426
- 'name': 'Aave',
427
- 'slug': 'aave',
428
- 'version': 'V3',
429
- 'fullName': 'Aave V3'
430
- }
431
- },
432
- 'strategyData': {
433
- 'encoded': {
434
- 'subData': [
435
- '0x000000000000000000000000000000000000000000000000120a871cc0020000',
436
- '0x0000000000000000000000000000000000000000000000000000000000000001',
437
- '0x0000000000000000000000000000000000000000000000000000000000000001',
438
- '0x0000000000000000000000000000000000000000000000000000000000000000'
439
- ]
440
- },
441
- 'decoded': {
442
- 'triggerData': {
443
- 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
444
- 'ratio': 120,
445
- 'ratioState': 1
446
- },
447
- 'subData': {
448
- 'targetRatio': 130
449
- }
450
- }
451
- },
452
- 'specific': {
453
- 'triggerBoostRatio': 165,
454
- 'targetBoostRatio': 150,
455
- 'boostEnabled': false,
456
- 'subId2': 3,
457
- 'mergeId': 'boost',
458
- 'triggerRepayRatio': 120,
459
- 'targetRepayRatio': 130,
460
- 'repayEnabled': true,
461
- 'subId1': 0,
462
- 'mergeWithId': 'boost'
463
- },
464
- 'subIds': [
465
- 0,
466
- 3
467
- ]
468
- },
469
- {
470
- 'isEnabled': false,
471
- 'chainId': 1,
472
- 'subHash': '0x7a14b187374b9ab02f6f7c95f275ef547376da010d53c715870cd053199a6aee',
473
- 'blockNumber': 1,
474
- 'positionId': '1-aave__v3',
475
- 'subId': 1,
476
- 'protocol': {
477
- 'id': 'Aave__V3',
478
- 'name': 'Aave',
479
- 'slug': 'aave',
480
- 'version': 'V3',
481
- 'fullName': 'Aave V3'
482
- },
483
- 'strategy': {
484
- 'isBundle': true,
485
- 'strategyOrBundleId': 0,
486
- 'strategyId': 'leverage-management',
487
- 'protocol': {
488
- 'id': 'Aave__V3',
489
- 'name': 'Aave',
490
- 'slug': 'aave',
491
- 'version': 'V3',
492
- 'fullName': 'Aave V3'
493
- }
494
- },
495
- 'strategyData': {
496
- 'encoded': {
497
- 'subData': [
498
- '0x000000000000000000000000000000000000000000000000120a871cc0020000',
499
- '0x0000000000000000000000000000000000000000000000000000000000000001',
500
- '0x0000000000000000000000000000000000000000000000000000000000000001',
501
- '0x0000000000000000000000000000000000000000000000000000000000000000'
502
- ]
503
- },
504
- 'decoded': {
505
- 'triggerData': {
506
- 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
507
- 'ratio': 120,
508
- 'ratioState': 1
509
- },
510
- 'subData': {
511
- 'targetRatio': 130
512
- }
513
- }
514
- },
515
- 'specific': {
516
- 'triggerBoostRatio': 165,
517
- 'targetBoostRatio': 150,
518
- 'boostEnabled': false,
519
- 'subId2': 4,
520
- 'mergeId': 'boost',
521
- 'triggerRepayRatio': 120,
522
- 'targetRepayRatio': 130,
523
- 'repayEnabled': true,
524
- 'subId1': 1,
525
- 'mergeWithId': 'boost'
526
- },
527
- 'subIds': [
528
- 1,
529
- 4
530
- ]
531
- },
532
- {
533
- 'isEnabled': false,
534
- 'chainId': 1,
535
- 'subHash': '0xe55917c42ac3e8f6c080e3780c5e0ea7a0a3da6c05e7ced5fe69fee48133a5eb',
536
- 'blockNumber': 1,
537
- 'positionId': '1-aave__v3',
538
- 'subId': 2,
539
- 'protocol': {
540
- 'id': 'Aave__V3',
541
- 'name': 'Aave',
542
- 'slug': 'aave',
543
- 'version': 'V3',
544
- 'fullName': 'Aave V3'
545
- },
546
- 'strategy': {
547
- 'isBundle': true,
548
- 'strategyOrBundleId': 0,
549
- 'strategyId': 'leverage-management',
550
- 'protocol': {
551
- 'id': 'Aave__V3',
552
- 'name': 'Aave',
553
- 'slug': 'aave',
554
- 'version': 'V3',
555
- 'fullName': 'Aave V3'
556
- }
557
- },
558
- 'strategyData': {
559
- 'encoded': {
560
- 'subData': [
561
- '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
562
- '0x0000000000000000000000000000000000000000000000000000000000000001',
563
- '0x0000000000000000000000000000000000000000000000000000000000000001',
564
- '0x0000000000000000000000000000000000000000000000000000000000000000'
565
- ]
566
- },
567
- 'decoded': {
568
- 'triggerData': {
569
- 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
570
- 'ratio': 135,
571
- 'ratioState': 1
572
- },
573
- 'subData': {
574
- 'targetRatio': 150
575
- }
576
- }
577
- },
578
- 'specific': {
579
- 'triggerBoostRatio': 165,
580
- 'targetBoostRatio': 150,
581
- 'boostEnabled': false,
582
- 'subId2': 5,
583
- 'mergeId': 'boost',
584
- 'triggerRepayRatio': 135,
585
- 'targetRepayRatio': 150,
586
- 'repayEnabled': true,
587
- 'subId1': 2,
588
- 'mergeWithId': 'boost'
589
- },
590
- 'subIds': [
591
- 2,
592
- 5
593
- ]
594
- },
595
- {
596
- 'isEnabled': false,
597
- 'chainId': 1,
598
- 'subHash': '0x52cd11186443c2734f027a7175bccf80158c6a45906f4b33b5713b77244aa7f6',
599
- 'blockNumber': 1,
600
- 'positionId': '1-aave__v3',
601
- 'subId': 6,
602
- 'protocol': {
603
- 'id': 'Aave__V3',
604
- 'name': 'Aave',
605
- 'slug': 'aave',
606
- 'version': 'V3',
607
- 'fullName': 'Aave V3'
608
- },
609
- 'strategy': {
610
- 'isBundle': true,
611
- 'strategyOrBundleId': 0,
612
- 'strategyId': 'leverage-management',
613
- 'protocol': {
614
- 'id': 'Aave__V3',
615
- 'name': 'Aave',
616
- 'slug': 'aave',
617
- 'version': 'V3',
618
- 'fullName': 'Aave V3'
619
- }
620
- },
621
- 'strategyData': {
622
- 'encoded': {
623
- 'subData': [
624
- '0x00000000000000000000000000000000000000000000000012bc29d8eec70000',
625
- '0x0000000000000000000000000000000000000000000000000000000000000001',
626
- '0x0000000000000000000000000000000000000000000000000000000000000001',
627
- '0x0000000000000000000000000000000000000000000000000000000000000000'
628
- ]
629
- },
630
- 'decoded': {
631
- 'triggerData': {
632
- 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
633
- 'ratio': 120,
634
- 'ratioState': 1
635
- },
636
- 'subData': {
637
- 'targetRatio': 135
638
- }
639
- }
640
- },
641
- 'specific': {
642
- 'triggerRepayRatio': 120,
643
- 'targetRepayRatio': 135,
644
- 'repayEnabled': true,
645
- 'subId1': 6,
646
- 'mergeWithId': 'boost'
647
- },
648
- 'subIds': [
649
- 6
650
- ]
651
- }
652
- ]
653
- ],
654
- ];
655
- examples.forEach(([input, actual]) => {
656
- it(`Given ${input} should return expected value:`, async () => {
657
- // @ts-ignore
658
- const expected = exampleStrategiesAutomation.mergeSubs(input);
659
- expect(JSON.stringify(actual)).to.equal(JSON.stringify(expected));
660
- });
661
- });
662
- });
663
- });
1
+ import Web3 from 'web3';
2
+ import { expect } from 'chai';
3
+
4
+ import {ChainId} from '../../types/enums';
5
+
6
+ import '../../configuration';
7
+ import StrategiesAutomation from './StrategiesAutomation';
8
+
9
+ require('dotenv').config({ path: '.env' });
10
+
11
+ const Web3_1 = new Web3(process.env.RPC_1!);
12
+
13
+ describe('Feature: StrategiesAutomation.ts', () => {
14
+ describe('When testing class StrategiesAutomation', async () => {
15
+ const exampleStrategiesAutomation = new StrategiesAutomation({
16
+ chainId:ChainId.Ethereum,
17
+ provider: Web3_1,
18
+ providerFork: null!,
19
+ });
20
+
21
+ const examples: Array<[any, any]> = [
22
+ [
23
+ [
24
+ {
25
+ 'isEnabled': true,
26
+ 'chainId': 1,
27
+ 'subHash': '0x7a14b187374b9ab02f6f7c95f275ef547376da010d53c715870cd053199a6aee',
28
+ 'blockNumber': 0,
29
+ 'positionId': '1-aave__v3',
30
+ 'subId': 0,
31
+ 'protocol': {
32
+ 'id': 'Aave__V3',
33
+ 'name': 'Aave',
34
+ 'slug': 'aave',
35
+ 'version': 'V3',
36
+ 'fullName': 'Aave V3'
37
+ },
38
+ 'strategy': {
39
+ 'isBundle': true,
40
+ 'strategyOrBundleId': 0,
41
+ 'strategyId': 'leverage-management',
42
+ 'protocol': {
43
+ 'id': 'Aave__V3',
44
+ 'name': 'Aave',
45
+ 'slug': 'aave',
46
+ 'version': 'V3',
47
+ 'fullName': 'Aave V3'
48
+ }
49
+ },
50
+ 'strategyData': {
51
+ 'encoded': {
52
+ 'subData': [
53
+ '0x000000000000000000000000000000000000000000000000120a871cc0020000',
54
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
55
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
56
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
57
+ ]
58
+ },
59
+ 'decoded': {
60
+ 'triggerData': {
61
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
62
+ 'ratio': 120,
63
+ 'ratioState': 1
64
+ },
65
+ 'subData': {
66
+ 'targetRatio': 130
67
+ }
68
+ }
69
+ },
70
+ 'specific': {
71
+ 'triggerRepayRatio': 120,
72
+ 'targetRepayRatio': 130,
73
+ 'repayEnabled': true,
74
+ 'subId1': 0,
75
+ 'mergeWithId': 'boost'
76
+ }
77
+ },
78
+ {
79
+ 'isEnabled': false,
80
+ 'chainId': 1,
81
+ 'subHash': '0x7a14b187374b9ab02f6f7c95f275ef547376da010d53c715870cd053199a6aee',
82
+ 'blockNumber': 0,
83
+ 'positionId': '1-aave__v3',
84
+ 'subId': 1,
85
+ 'protocol': {
86
+ 'id': 'Aave__V3',
87
+ 'name': 'Aave',
88
+ 'slug': 'aave',
89
+ 'version': 'V3',
90
+ 'fullName': 'Aave V3'
91
+ },
92
+ 'strategy': {
93
+ 'isBundle': true,
94
+ 'strategyOrBundleId': 0,
95
+ 'strategyId': 'leverage-management',
96
+ 'protocol': {
97
+ 'id': 'Aave__V3',
98
+ 'name': 'Aave',
99
+ 'slug': 'aave',
100
+ 'version': 'V3',
101
+ 'fullName': 'Aave V3'
102
+ }
103
+ },
104
+ 'strategyData': {
105
+ 'encoded': {
106
+ 'subData': [
107
+ '0x000000000000000000000000000000000000000000000000120a871cc0020000',
108
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
109
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
110
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
111
+ ]
112
+ },
113
+ 'decoded': {
114
+ 'triggerData': {
115
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
116
+ 'ratio': 120,
117
+ 'ratioState': 1
118
+ },
119
+ 'subData': {
120
+ 'targetRatio': 130
121
+ }
122
+ }
123
+ },
124
+ 'specific': {
125
+ 'triggerRepayRatio': 120,
126
+ 'targetRepayRatio': 130,
127
+ 'repayEnabled': true,
128
+ 'subId1': 1,
129
+ 'mergeWithId': 'boost'
130
+ }
131
+ },
132
+ {
133
+ 'isEnabled': false,
134
+ 'chainId': 1,
135
+ 'subHash': '0xe55917c42ac3e8f6c080e3780c5e0ea7a0a3da6c05e7ced5fe69fee48133a5eb',
136
+ 'blockNumber': 0,
137
+ 'positionId': '1-aave__v3',
138
+ 'subId': 2,
139
+ 'protocol': {
140
+ 'id': 'Aave__V3',
141
+ 'name': 'Aave',
142
+ 'slug': 'aave',
143
+ 'version': 'V3',
144
+ 'fullName': 'Aave V3'
145
+ },
146
+ 'strategy': {
147
+ 'isBundle': true,
148
+ 'strategyOrBundleId': 0,
149
+ 'strategyId': 'leverage-management',
150
+ 'protocol': {
151
+ 'id': 'Aave__V3',
152
+ 'name': 'Aave',
153
+ 'slug': 'aave',
154
+ 'version': 'V3',
155
+ 'fullName': 'Aave V3'
156
+ }
157
+ },
158
+ 'strategyData': {
159
+ 'encoded': {
160
+ 'subData': [
161
+ '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
162
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
163
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
164
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
165
+ ]
166
+ },
167
+ 'decoded': {
168
+ 'triggerData': {
169
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
170
+ 'ratio': 135,
171
+ 'ratioState': 1
172
+ },
173
+ 'subData': {
174
+ 'targetRatio': 150
175
+ }
176
+ }
177
+ },
178
+ 'specific': {
179
+ 'triggerRepayRatio': 135,
180
+ 'targetRepayRatio': 150,
181
+ 'repayEnabled': true,
182
+ 'subId1': 2,
183
+ 'mergeWithId': 'boost'
184
+ }
185
+ },
186
+ {
187
+ 'isEnabled': false,
188
+ 'chainId': 1,
189
+ 'subHash': '0x96d6a5fe8127765a0fa55115621495bf66ebd16029b0883bc097eda1b597ab0b',
190
+ 'blockNumber': 0,
191
+ 'positionId': '1-aave__v3',
192
+ 'subId': 3,
193
+ 'protocol': {
194
+ 'id': 'Aave__V3',
195
+ 'name': 'Aave',
196
+ 'slug': 'aave',
197
+ 'version': 'V3',
198
+ 'fullName': 'Aave V3'
199
+ },
200
+ 'strategy': {
201
+ 'isBundle': true,
202
+ 'strategyOrBundleId': 1,
203
+ 'strategyId': 'leverage-management',
204
+ 'protocol': {
205
+ 'id': 'Aave__V3',
206
+ 'name': 'Aave',
207
+ 'slug': 'aave',
208
+ 'version': 'V3',
209
+ 'fullName': 'Aave V3'
210
+ }
211
+ },
212
+ 'strategyData': {
213
+ 'encoded': {
214
+ 'subData': [
215
+ '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
216
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
217
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
218
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
219
+ '0x0000000000000000000000000000000000000000000000000000000000000001'
220
+ ]
221
+ },
222
+ 'decoded': {
223
+ 'triggerData': {
224
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
225
+ 'ratio': 165,
226
+ 'ratioState': 0
227
+ },
228
+ 'subData': {
229
+ 'targetRatio': 150
230
+ }
231
+ }
232
+ },
233
+ 'specific': {
234
+ 'triggerBoostRatio': 165,
235
+ 'targetBoostRatio': 150,
236
+ 'boostEnabled': false,
237
+ 'subId2': 3,
238
+ 'mergeId': 'boost'
239
+ }
240
+ },
241
+ {
242
+ 'isEnabled': false,
243
+ 'chainId': 1,
244
+ 'subHash': '0x96d6a5fe8127765a0fa55115621495bf66ebd16029b0883bc097eda1b597ab0b',
245
+ 'blockNumber': 1,
246
+ 'positionId': '1-aave__v3',
247
+ 'subId': 4,
248
+ 'protocol': {
249
+ 'id': 'Aave__V3',
250
+ 'name': 'Aave',
251
+ 'slug': 'aave',
252
+ 'version': 'V3',
253
+ 'fullName': 'Aave V3'
254
+ },
255
+ 'strategy': {
256
+ 'isBundle': true,
257
+ 'strategyOrBundleId': 1,
258
+ 'strategyId': 'leverage-management',
259
+ 'protocol': {
260
+ 'id': 'Aave__V3',
261
+ 'name': 'Aave',
262
+ 'slug': 'aave',
263
+ 'version': 'V3',
264
+ 'fullName': 'Aave V3'
265
+ }
266
+ },
267
+ 'strategyData': {
268
+ 'encoded': {
269
+ 'subData': [
270
+ '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
271
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
272
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
273
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
274
+ '0x0000000000000000000000000000000000000000000000000000000000000001'
275
+ ]
276
+ },
277
+ 'decoded': {
278
+ 'triggerData': {
279
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
280
+ 'ratio': 165,
281
+ 'ratioState': 0
282
+ },
283
+ 'subData': {
284
+ 'targetRatio': 150
285
+ }
286
+ }
287
+ },
288
+ 'specific': {
289
+ 'triggerBoostRatio': 165,
290
+ 'targetBoostRatio': 150,
291
+ 'boostEnabled': false,
292
+ 'subId2': 4,
293
+ 'mergeId': 'boost'
294
+ }
295
+ },
296
+ {
297
+ 'isEnabled': false,
298
+ 'chainId': 1,
299
+ 'subHash': '0x96d6a5fe8127765a0fa55115621495bf66ebd16029b0883bc097eda1b597ab0b',
300
+ 'blockNumber': 1,
301
+ 'positionId': '1-aave__v3',
302
+ 'subId': 5,
303
+ 'protocol': {
304
+ 'id': 'Aave__V3',
305
+ 'name': 'Aave',
306
+ 'slug': 'aave',
307
+ 'version': 'V3',
308
+ 'fullName': 'Aave V3'
309
+ },
310
+ 'strategy': {
311
+ 'isBundle': true,
312
+ 'strategyOrBundleId': 1,
313
+ 'strategyId': 'leverage-management',
314
+ 'protocol': {
315
+ 'id': 'Aave__V3',
316
+ 'name': 'Aave',
317
+ 'slug': 'aave',
318
+ 'version': 'V3',
319
+ 'fullName': 'Aave V3'
320
+ }
321
+ },
322
+ 'strategyData': {
323
+ 'encoded': {
324
+ 'subData': [
325
+ '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
326
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
327
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
328
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
329
+ '0x0000000000000000000000000000000000000000000000000000000000000001'
330
+ ]
331
+ },
332
+ 'decoded': {
333
+ 'triggerData': {
334
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
335
+ 'ratio': 165,
336
+ 'ratioState': 0
337
+ },
338
+ 'subData': {
339
+ 'targetRatio': 150
340
+ }
341
+ }
342
+ },
343
+ 'specific': {
344
+ 'triggerBoostRatio': 165,
345
+ 'targetBoostRatio': 150,
346
+ 'boostEnabled': false,
347
+ 'subId2': 5,
348
+ 'mergeId': 'boost'
349
+ }
350
+ },
351
+ {
352
+ 'isEnabled': false,
353
+ 'chainId': 1,
354
+ 'subHash': '0x52cd11186443c2734f027a7175bccf80158c6a45906f4b33b5713b77244aa7f6',
355
+ 'blockNumber': 1,
356
+ 'positionId': '1-aave__v3',
357
+ 'subId': 6,
358
+ 'protocol': {
359
+ 'id': 'Aave__V3',
360
+ 'name': 'Aave',
361
+ 'slug': 'aave',
362
+ 'version': 'V3',
363
+ 'fullName': 'Aave V3'
364
+ },
365
+ 'strategy': {
366
+ 'isBundle': true,
367
+ 'strategyOrBundleId': 0,
368
+ 'strategyId': 'leverage-management',
369
+ 'protocol': {
370
+ 'id': 'Aave__V3',
371
+ 'name': 'Aave',
372
+ 'slug': 'aave',
373
+ 'version': 'V3',
374
+ 'fullName': 'Aave V3'
375
+ }
376
+ },
377
+ 'strategyData': {
378
+ 'encoded': {
379
+ 'subData': [
380
+ '0x00000000000000000000000000000000000000000000000012bc29d8eec70000',
381
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
382
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
383
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
384
+ ]
385
+ },
386
+ 'decoded': {
387
+ 'triggerData': {
388
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
389
+ 'ratio': 120,
390
+ 'ratioState': 1
391
+ },
392
+ 'subData': {
393
+ 'targetRatio': 135
394
+ }
395
+ }
396
+ },
397
+ 'specific': {
398
+ 'triggerRepayRatio': 120,
399
+ 'targetRepayRatio': 135,
400
+ 'repayEnabled': true,
401
+ 'subId1': 6,
402
+ 'mergeWithId': 'boost'
403
+ }
404
+ }
405
+ ],[
406
+ {
407
+ 'isEnabled': true,
408
+ 'chainId': 1,
409
+ 'subHash': '0x7a14b187374b9ab02f6f7c95f275ef547376da010d53c715870cd053199a6aee',
410
+ 'blockNumber': 0,
411
+ 'positionId': '1-aave__v3',
412
+ 'subId': 0,
413
+ 'protocol': {
414
+ 'id': 'Aave__V3',
415
+ 'name': 'Aave',
416
+ 'slug': 'aave',
417
+ 'version': 'V3',
418
+ 'fullName': 'Aave V3'
419
+ },
420
+ 'strategy': {
421
+ 'isBundle': true,
422
+ 'strategyOrBundleId': 0,
423
+ 'strategyId': 'leverage-management',
424
+ 'protocol': {
425
+ 'id': 'Aave__V3',
426
+ 'name': 'Aave',
427
+ 'slug': 'aave',
428
+ 'version': 'V3',
429
+ 'fullName': 'Aave V3'
430
+ }
431
+ },
432
+ 'strategyData': {
433
+ 'encoded': {
434
+ 'subData': [
435
+ '0x000000000000000000000000000000000000000000000000120a871cc0020000',
436
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
437
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
438
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
439
+ ]
440
+ },
441
+ 'decoded': {
442
+ 'triggerData': {
443
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
444
+ 'ratio': 120,
445
+ 'ratioState': 1
446
+ },
447
+ 'subData': {
448
+ 'targetRatio': 130
449
+ }
450
+ }
451
+ },
452
+ 'specific': {
453
+ 'triggerBoostRatio': 165,
454
+ 'targetBoostRatio': 150,
455
+ 'boostEnabled': false,
456
+ 'subId2': 3,
457
+ 'mergeId': 'boost',
458
+ 'triggerRepayRatio': 120,
459
+ 'targetRepayRatio': 130,
460
+ 'repayEnabled': true,
461
+ 'subId1': 0,
462
+ 'mergeWithId': 'boost'
463
+ },
464
+ 'subIds': [
465
+ 0,
466
+ 3
467
+ ]
468
+ },
469
+ {
470
+ 'isEnabled': false,
471
+ 'chainId': 1,
472
+ 'subHash': '0x7a14b187374b9ab02f6f7c95f275ef547376da010d53c715870cd053199a6aee',
473
+ 'blockNumber': 1,
474
+ 'positionId': '1-aave__v3',
475
+ 'subId': 1,
476
+ 'protocol': {
477
+ 'id': 'Aave__V3',
478
+ 'name': 'Aave',
479
+ 'slug': 'aave',
480
+ 'version': 'V3',
481
+ 'fullName': 'Aave V3'
482
+ },
483
+ 'strategy': {
484
+ 'isBundle': true,
485
+ 'strategyOrBundleId': 0,
486
+ 'strategyId': 'leverage-management',
487
+ 'protocol': {
488
+ 'id': 'Aave__V3',
489
+ 'name': 'Aave',
490
+ 'slug': 'aave',
491
+ 'version': 'V3',
492
+ 'fullName': 'Aave V3'
493
+ }
494
+ },
495
+ 'strategyData': {
496
+ 'encoded': {
497
+ 'subData': [
498
+ '0x000000000000000000000000000000000000000000000000120a871cc0020000',
499
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
500
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
501
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
502
+ ]
503
+ },
504
+ 'decoded': {
505
+ 'triggerData': {
506
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
507
+ 'ratio': 120,
508
+ 'ratioState': 1
509
+ },
510
+ 'subData': {
511
+ 'targetRatio': 130
512
+ }
513
+ }
514
+ },
515
+ 'specific': {
516
+ 'triggerBoostRatio': 165,
517
+ 'targetBoostRatio': 150,
518
+ 'boostEnabled': false,
519
+ 'subId2': 4,
520
+ 'mergeId': 'boost',
521
+ 'triggerRepayRatio': 120,
522
+ 'targetRepayRatio': 130,
523
+ 'repayEnabled': true,
524
+ 'subId1': 1,
525
+ 'mergeWithId': 'boost'
526
+ },
527
+ 'subIds': [
528
+ 1,
529
+ 4
530
+ ]
531
+ },
532
+ {
533
+ 'isEnabled': false,
534
+ 'chainId': 1,
535
+ 'subHash': '0xe55917c42ac3e8f6c080e3780c5e0ea7a0a3da6c05e7ced5fe69fee48133a5eb',
536
+ 'blockNumber': 1,
537
+ 'positionId': '1-aave__v3',
538
+ 'subId': 2,
539
+ 'protocol': {
540
+ 'id': 'Aave__V3',
541
+ 'name': 'Aave',
542
+ 'slug': 'aave',
543
+ 'version': 'V3',
544
+ 'fullName': 'Aave V3'
545
+ },
546
+ 'strategy': {
547
+ 'isBundle': true,
548
+ 'strategyOrBundleId': 0,
549
+ 'strategyId': 'leverage-management',
550
+ 'protocol': {
551
+ 'id': 'Aave__V3',
552
+ 'name': 'Aave',
553
+ 'slug': 'aave',
554
+ 'version': 'V3',
555
+ 'fullName': 'Aave V3'
556
+ }
557
+ },
558
+ 'strategyData': {
559
+ 'encoded': {
560
+ 'subData': [
561
+ '0x00000000000000000000000000000000000000000000000014d1120d7b160000',
562
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
563
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
564
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
565
+ ]
566
+ },
567
+ 'decoded': {
568
+ 'triggerData': {
569
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
570
+ 'ratio': 135,
571
+ 'ratioState': 1
572
+ },
573
+ 'subData': {
574
+ 'targetRatio': 150
575
+ }
576
+ }
577
+ },
578
+ 'specific': {
579
+ 'triggerBoostRatio': 165,
580
+ 'targetBoostRatio': 150,
581
+ 'boostEnabled': false,
582
+ 'subId2': 5,
583
+ 'mergeId': 'boost',
584
+ 'triggerRepayRatio': 135,
585
+ 'targetRepayRatio': 150,
586
+ 'repayEnabled': true,
587
+ 'subId1': 2,
588
+ 'mergeWithId': 'boost'
589
+ },
590
+ 'subIds': [
591
+ 2,
592
+ 5
593
+ ]
594
+ },
595
+ {
596
+ 'isEnabled': false,
597
+ 'chainId': 1,
598
+ 'subHash': '0x52cd11186443c2734f027a7175bccf80158c6a45906f4b33b5713b77244aa7f6',
599
+ 'blockNumber': 1,
600
+ 'positionId': '1-aave__v3',
601
+ 'subId': 6,
602
+ 'protocol': {
603
+ 'id': 'Aave__V3',
604
+ 'name': 'Aave',
605
+ 'slug': 'aave',
606
+ 'version': 'V3',
607
+ 'fullName': 'Aave V3'
608
+ },
609
+ 'strategy': {
610
+ 'isBundle': true,
611
+ 'strategyOrBundleId': 0,
612
+ 'strategyId': 'leverage-management',
613
+ 'protocol': {
614
+ 'id': 'Aave__V3',
615
+ 'name': 'Aave',
616
+ 'slug': 'aave',
617
+ 'version': 'V3',
618
+ 'fullName': 'Aave V3'
619
+ }
620
+ },
621
+ 'strategyData': {
622
+ 'encoded': {
623
+ 'subData': [
624
+ '0x00000000000000000000000000000000000000000000000012bc29d8eec70000',
625
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
626
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
627
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
628
+ ]
629
+ },
630
+ 'decoded': {
631
+ 'triggerData': {
632
+ 'market': '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb',
633
+ 'ratio': 120,
634
+ 'ratioState': 1
635
+ },
636
+ 'subData': {
637
+ 'targetRatio': 135
638
+ }
639
+ }
640
+ },
641
+ 'specific': {
642
+ 'triggerRepayRatio': 120,
643
+ 'targetRepayRatio': 135,
644
+ 'repayEnabled': true,
645
+ 'subId1': 6,
646
+ 'mergeWithId': 'boost'
647
+ },
648
+ 'subIds': [
649
+ 6
650
+ ]
651
+ }
652
+ ]
653
+ ],
654
+ ];
655
+ examples.forEach(([input, actual]) => {
656
+ it(`Given ${input} should return expected value:`, async () => {
657
+ // @ts-ignore
658
+ const expected = exampleStrategiesAutomation.mergeSubs(input);
659
+ expect(JSON.stringify(actual)).to.equal(JSON.stringify(expected));
660
+ });
661
+ });
662
+ });
663
+ });