@defisaver/automation-sdk 3.0.9-dev → 3.1.1-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/.babelrc +3 -3
  2. package/.editorconfig +9 -9
  3. package/.env.dev +4 -4
  4. package/.eslintignore +6 -7
  5. package/.eslintrc.js +39 -41
  6. package/.mocharc.json +5 -0
  7. package/.nvmrc +1 -0
  8. package/README.md +47 -41
  9. package/cjs/abis/Erc20.json +223 -0
  10. package/cjs/abis/SubStorage.json +21 -0
  11. package/cjs/abis/UniMulticall.json +17 -0
  12. package/cjs/abis/index.d.ts +9 -0
  13. package/cjs/abis/index.js +30 -0
  14. package/cjs/abis/legacy_AaveV2Subscriptions.json +8 -0
  15. package/cjs/abis/legacy_AuthCheck.json +8 -0
  16. package/cjs/abis/legacy_CompoundV2Subscriptions.json +9 -0
  17. package/cjs/abis/legacy_MakerSubscriptions.json +9 -0
  18. package/cjs/automation/private/Automation.d.ts +12 -0
  19. package/cjs/automation/private/Automation.js +42 -0
  20. package/cjs/automation/private/LegacyAutomation.d.ts +25 -0
  21. package/cjs/automation/private/LegacyAutomation.js +118 -0
  22. package/cjs/automation/private/LegacyProtocol.d.ts +22 -0
  23. package/cjs/automation/private/LegacyProtocol.js +41 -0
  24. package/cjs/automation/private/LegacyProtocol.test.d.ts +1 -0
  25. package/cjs/automation/private/LegacyProtocol.test.js +25 -0
  26. package/cjs/automation/private/Protocol.d.ts +22 -0
  27. package/cjs/automation/private/Protocol.js +41 -0
  28. package/cjs/automation/private/Protocol.test.d.ts +1 -0
  29. package/cjs/automation/private/Protocol.test.js +25 -0
  30. package/cjs/automation/private/StrategiesAutomation.d.ts +33 -0
  31. package/cjs/automation/private/StrategiesAutomation.js +181 -0
  32. package/cjs/automation/private/StrategiesAutomation.test.d.ts +1 -0
  33. package/cjs/automation/private/StrategiesAutomation.test.js +671 -0
  34. package/cjs/automation/public/ArbitrumStrategies.d.ts +5 -0
  35. package/cjs/automation/public/ArbitrumStrategies.js +13 -0
  36. package/cjs/automation/public/BaseStrategies.d.ts +5 -0
  37. package/cjs/automation/public/BaseStrategies.js +13 -0
  38. package/cjs/automation/public/EthereumStrategies.d.ts +5 -0
  39. package/cjs/automation/public/EthereumStrategies.js +13 -0
  40. package/cjs/automation/public/OptimismStrategies.d.ts +5 -0
  41. package/cjs/automation/public/OptimismStrategies.js +13 -0
  42. package/cjs/automation/public/legacy/LegacyAaveAutomation.d.ts +6 -0
  43. package/cjs/automation/public/legacy/LegacyAaveAutomation.js +20 -0
  44. package/cjs/automation/public/legacy/LegacyCompoundAutomation.d.ts +6 -0
  45. package/cjs/automation/public/legacy/LegacyCompoundAutomation.js +20 -0
  46. package/cjs/automation/public/legacy/LegacyMakerAutomation.d.ts +6 -0
  47. package/cjs/automation/public/legacy/LegacyMakerAutomation.js +20 -0
  48. package/cjs/configuration.d.ts +1 -0
  49. package/cjs/configuration.js +12 -0
  50. package/cjs/constants/index.d.ts +28 -0
  51. package/cjs/constants/index.js +484 -0
  52. package/cjs/index.d.ts +23 -0
  53. package/cjs/index.js +65 -0
  54. package/cjs/services/contractService.d.ts +12 -0
  55. package/cjs/services/contractService.js +54 -0
  56. package/cjs/services/ethereumService.d.ts +7 -0
  57. package/cjs/services/ethereumService.js +49 -0
  58. package/cjs/services/ethereumService.test.d.ts +1 -0
  59. package/cjs/services/ethereumService.test.js +242 -0
  60. package/cjs/services/strategiesService.d.ts +2 -0
  61. package/cjs/services/strategiesService.js +758 -0
  62. package/cjs/services/strategiesService.test.d.ts +1 -0
  63. package/cjs/services/strategiesService.test.js +110 -0
  64. package/cjs/services/strategySubService.d.ts +103 -0
  65. package/cjs/services/strategySubService.js +277 -0
  66. package/cjs/services/strategySubService.test.d.ts +1 -0
  67. package/cjs/services/strategySubService.test.js +934 -0
  68. package/cjs/services/subDataService.d.ts +201 -0
  69. package/cjs/services/subDataService.js +499 -0
  70. package/cjs/services/subDataService.test.d.ts +1 -0
  71. package/cjs/services/subDataService.test.js +1282 -0
  72. package/cjs/services/triggerService.d.ts +200 -0
  73. package/cjs/services/triggerService.js +382 -0
  74. package/cjs/services/triggerService.test.d.ts +1 -0
  75. package/cjs/services/triggerService.test.js +926 -0
  76. package/cjs/services/utils.d.ts +25 -0
  77. package/cjs/services/utils.js +131 -0
  78. package/cjs/services/utils.test.d.ts +1 -0
  79. package/cjs/services/utils.test.js +376 -0
  80. package/cjs/types/contracts/generated/Erc20.d.ts +53 -0
  81. package/cjs/types/contracts/generated/Erc20.js +5 -0
  82. package/cjs/types/contracts/generated/Legacy_AaveV2Subscriptions.d.ts +129 -0
  83. package/cjs/types/contracts/generated/Legacy_AaveV2Subscriptions.js +5 -0
  84. package/cjs/types/contracts/generated/Legacy_AuthCheck.d.ts +20 -0
  85. package/cjs/types/contracts/generated/Legacy_AuthCheck.js +5 -0
  86. package/cjs/types/contracts/generated/Legacy_CompoundV2Subscriptions.d.ts +128 -0
  87. package/cjs/types/contracts/generated/Legacy_CompoundV2Subscriptions.js +5 -0
  88. package/cjs/types/contracts/generated/Legacy_MakerSubscriptions.d.ts +246 -0
  89. package/cjs/types/contracts/generated/Legacy_MakerSubscriptions.js +5 -0
  90. package/cjs/types/contracts/generated/SubStorage.d.ts +114 -0
  91. package/cjs/types/contracts/generated/SubStorage.js +5 -0
  92. package/cjs/types/contracts/generated/UniMulticall.d.ts +55 -0
  93. package/cjs/types/contracts/generated/UniMulticall.js +5 -0
  94. package/cjs/types/contracts/generated/index.d.ts +7 -0
  95. package/cjs/types/contracts/generated/index.js +2 -0
  96. package/cjs/types/contracts/generated/types.d.ts +54 -0
  97. package/cjs/types/contracts/generated/types.js +2 -0
  98. package/cjs/types/enums.d.ts +192 -0
  99. package/cjs/types/enums.js +216 -0
  100. package/cjs/types/index.d.ts +224 -0
  101. package/cjs/types/index.js +2 -0
  102. package/esm/abis/Erc20.json +223 -223
  103. package/esm/abis/SubStorage.json +21 -21
  104. package/esm/abis/UniMulticall.json +17 -17
  105. package/esm/abis/index.d.ts +9 -9
  106. package/esm/abis/index.js +18 -30
  107. package/esm/abis/legacy_AaveV2Subscriptions.json +8 -8
  108. package/esm/abis/legacy_AuthCheck.json +8 -8
  109. package/esm/abis/legacy_CompoundV2Subscriptions.json +9 -9
  110. package/esm/abis/legacy_MakerSubscriptions.json +9 -9
  111. package/esm/automation/private/Automation.d.ts +12 -12
  112. package/esm/automation/private/Automation.js +39 -42
  113. package/esm/automation/private/LegacyAutomation.d.ts +25 -25
  114. package/esm/automation/private/LegacyAutomation.js +112 -118
  115. package/esm/automation/private/LegacyProtocol.d.ts +22 -22
  116. package/esm/automation/private/LegacyProtocol.js +38 -41
  117. package/esm/automation/private/LegacyProtocol.test.d.ts +1 -1
  118. package/esm/automation/private/LegacyProtocol.test.js +20 -25
  119. package/esm/automation/private/Protocol.d.ts +22 -22
  120. package/esm/automation/private/Protocol.js +38 -41
  121. package/esm/automation/private/Protocol.test.d.ts +1 -1
  122. package/esm/automation/private/Protocol.test.js +20 -25
  123. package/esm/automation/private/StrategiesAutomation.d.ts +33 -33
  124. package/esm/automation/private/StrategiesAutomation.js +175 -181
  125. package/esm/automation/private/StrategiesAutomation.test.d.ts +1 -1
  126. package/esm/automation/private/StrategiesAutomation.test.js +666 -671
  127. package/esm/automation/public/ArbitrumStrategies.d.ts +5 -5
  128. package/esm/automation/public/ArbitrumStrategies.js +7 -13
  129. package/esm/automation/public/BaseStrategies.d.ts +5 -5
  130. package/esm/automation/public/BaseStrategies.js +7 -13
  131. package/esm/automation/public/EthereumStrategies.d.ts +5 -5
  132. package/esm/automation/public/EthereumStrategies.js +7 -13
  133. package/esm/automation/public/OptimismStrategies.d.ts +5 -5
  134. package/esm/automation/public/OptimismStrategies.js +7 -13
  135. package/esm/automation/public/legacy/LegacyAaveAutomation.d.ts +6 -6
  136. package/esm/automation/public/legacy/LegacyAaveAutomation.js +14 -20
  137. package/esm/automation/public/legacy/LegacyCompoundAutomation.d.ts +6 -6
  138. package/esm/automation/public/legacy/LegacyCompoundAutomation.js +14 -20
  139. package/esm/automation/public/legacy/LegacyMakerAutomation.d.ts +6 -6
  140. package/esm/automation/public/legacy/LegacyMakerAutomation.js +14 -20
  141. package/esm/configuration.d.ts +1 -1
  142. package/esm/configuration.js +7 -12
  143. package/esm/constants/index.d.ts +28 -28
  144. package/esm/constants/index.js +478 -474
  145. package/esm/index.d.ts +23 -23
  146. package/esm/index.js +23 -65
  147. package/esm/services/contractService.d.ts +12 -12
  148. package/esm/services/contractService.js +45 -54
  149. package/esm/services/ethereumService.d.ts +7 -7
  150. package/esm/services/ethereumService.js +41 -49
  151. package/esm/services/ethereumService.test.d.ts +1 -1
  152. package/esm/services/ethereumService.test.js +237 -242
  153. package/esm/services/strategiesService.d.ts +2 -2
  154. package/esm/services/strategiesService.js +731 -723
  155. package/esm/services/strategiesService.test.d.ts +1 -1
  156. package/esm/services/strategiesService.test.js +108 -110
  157. package/esm/services/strategySubService.d.ts +103 -100
  158. package/esm/services/strategySubService.js +248 -264
  159. package/esm/services/strategySubService.test.d.ts +1 -1
  160. package/esm/services/strategySubService.test.js +906 -934
  161. package/esm/services/subDataService.d.ts +201 -192
  162. package/esm/services/subDataService.js +493 -475
  163. package/esm/services/subDataService.test.d.ts +1 -1
  164. package/esm/services/subDataService.test.js +1254 -1282
  165. package/esm/services/triggerService.d.ts +200 -191
  166. package/esm/services/triggerService.js +353 -367
  167. package/esm/services/triggerService.test.d.ts +1 -1
  168. package/esm/services/triggerService.test.js +901 -926
  169. package/esm/services/utils.d.ts +25 -25
  170. package/esm/services/utils.js +82 -131
  171. package/esm/services/utils.test.d.ts +1 -1
  172. package/esm/services/utils.test.js +348 -376
  173. package/esm/types/contracts/generated/Erc20.d.ts +53 -53
  174. package/esm/types/contracts/generated/Erc20.js +4 -5
  175. package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.d.ts +129 -129
  176. package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.js +4 -5
  177. package/esm/types/contracts/generated/Legacy_AuthCheck.d.ts +20 -20
  178. package/esm/types/contracts/generated/Legacy_AuthCheck.js +4 -5
  179. package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.d.ts +128 -128
  180. package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.js +4 -5
  181. package/esm/types/contracts/generated/Legacy_MakerSubscriptions.d.ts +246 -246
  182. package/esm/types/contracts/generated/Legacy_MakerSubscriptions.js +4 -5
  183. package/esm/types/contracts/generated/SubStorage.d.ts +114 -114
  184. package/esm/types/contracts/generated/SubStorage.js +4 -5
  185. package/esm/types/contracts/generated/UniMulticall.d.ts +55 -55
  186. package/esm/types/contracts/generated/UniMulticall.js +4 -5
  187. package/esm/types/contracts/generated/index.d.ts +7 -7
  188. package/esm/types/contracts/generated/index.js +1 -2
  189. package/esm/types/contracts/generated/types.d.ts +54 -54
  190. package/esm/types/contracts/generated/types.js +1 -2
  191. package/esm/types/enums.d.ts +192 -181
  192. package/esm/types/enums.js +213 -203
  193. package/esm/types/index.d.ts +224 -224
  194. package/esm/types/index.js +1 -2
  195. package/package.json +61 -71
  196. package/scripts/generateContractTypes.js +39 -39
  197. package/src/abis/Erc20.json +222 -222
  198. package/src/abis/SubStorage.json +21 -21
  199. package/src/abis/UniMulticall.json +17 -17
  200. package/src/abis/index.ts +28 -28
  201. package/src/abis/legacy_AaveV2Subscriptions.json +7 -7
  202. package/src/abis/legacy_AuthCheck.json +7 -7
  203. package/src/abis/legacy_CompoundV2Subscriptions.json +8 -8
  204. package/src/abis/legacy_MakerSubscriptions.json +8 -8
  205. package/src/automation/private/Automation.ts +44 -44
  206. package/src/automation/private/LegacyAutomation.ts +135 -135
  207. package/src/automation/private/LegacyProtocol.test.ts +23 -23
  208. package/src/automation/private/LegacyProtocol.ts +51 -51
  209. package/src/automation/private/Protocol.test.ts +23 -23
  210. package/src/automation/private/Protocol.ts +51 -51
  211. package/src/automation/private/StrategiesAutomation.test.ts +663 -663
  212. package/src/automation/private/StrategiesAutomation.ts +242 -242
  213. package/src/automation/public/ArbitrumStrategies.ts +10 -10
  214. package/src/automation/public/BaseStrategies.ts +10 -10
  215. package/src/automation/public/EthereumStrategies.ts +10 -10
  216. package/src/automation/public/OptimismStrategies.ts +10 -10
  217. package/src/automation/public/legacy/LegacyAaveAutomation.ts +20 -20
  218. package/src/automation/public/legacy/LegacyCompoundAutomation.ts +20 -20
  219. package/src/automation/public/legacy/LegacyMakerAutomation.ts +20 -20
  220. package/src/configuration.ts +8 -8
  221. package/src/constants/index.ts +502 -492
  222. package/src/index.ts +39 -39
  223. package/src/services/contractService.ts +77 -77
  224. package/src/services/ethereumService.test.ts +257 -257
  225. package/src/services/ethereumService.ts +69 -69
  226. package/src/services/strategiesService.test.ts +105 -105
  227. package/src/services/strategiesService.ts +979 -934
  228. package/src/services/strategySubService.test.ts +1119 -1119
  229. package/src/services/strategySubService.ts +542 -518
  230. package/src/services/subDataService.test.ts +1387 -1387
  231. package/src/services/subDataService.ts +681 -645
  232. package/src/services/triggerService.test.ts +1004 -1004
  233. package/src/services/triggerService.ts +472 -449
  234. package/src/services/utils.test.ts +430 -430
  235. package/src/services/utils.ts +103 -103
  236. package/src/types/enums.ts +210 -197
  237. package/src/types/index.ts +279 -279
  238. package/tsconfig.esm.json +8 -0
  239. package/tsconfig.json +22 -79
  240. package/umd/index.js +40 -253
  241. package/.tests.sh +0 -3
  242. package/all_comits.txt +0 -2134
  243. package/webpack.umd.js +0 -52
@@ -1,671 +1,666 @@
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
+ 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
+ });