@defisaver/automation-sdk 3.2.5 → 3.3.1

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