@defisaver/automation-sdk 3.2.5 → 3.3.0

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