@defisaver/automation-sdk 3.0.9 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (242) 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 +474 -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 +723 -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 +100 -0
  65. package/cjs/services/strategySubService.js +264 -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 +192 -0
  69. package/cjs/services/subDataService.js +475 -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 +191 -0
  73. package/cjs/services/triggerService.js +367 -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 +181 -0
  99. package/cjs/types/enums.js +203 -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 -17
  104. package/esm/abis/UniMulticall.json +17 -14
  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 -0
  130. package/esm/automation/public/BaseStrategies.js +7 -0
  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 -24
  144. package/esm/constants/index.js +468 -426
  145. package/esm/index.d.ts +23 -22
  146. package/esm/index.js +23 -63
  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 +696 -722
  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 +100 -100
  158. package/esm/services/strategySubService.js +235 -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 +192 -192
  162. package/esm/services/subDataService.js +469 -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 +191 -191
  166. package/esm/services/triggerService.js +338 -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 +181 -168
  192. package/esm/types/enums.js +200 -188
  193. package/esm/types/index.d.ts +224 -220
  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 -17
  199. package/src/abis/UniMulticall.json +17 -14
  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 -0
  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 +492 -441
  222. package/src/index.ts +39 -38
  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 +934 -932
  228. package/src/services/strategySubService.test.ts +1119 -1119
  229. package/src/services/strategySubService.ts +518 -518
  230. package/src/services/subDataService.test.ts +1387 -1387
  231. package/src/services/subDataService.ts +644 -644
  232. package/src/services/triggerService.test.ts +1004 -1004
  233. package/src/services/triggerService.ts +449 -449
  234. package/src/services/utils.test.ts +430 -430
  235. package/src/services/utils.ts +103 -103
  236. package/src/types/enums.ts +197 -182
  237. package/src/types/index.ts +279 -273
  238. package/tsconfig.esm.json +8 -0
  239. package/tsconfig.json +22 -79
  240. package/umd/index.js +17 -133
  241. package/.tests.sh +0 -3
  242. package/webpack.umd.js +0 -52
@@ -0,0 +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
+ });