@defisaver/automation-sdk 3.0.4 → 3.0.6

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 (143) 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 +41 -41
  6. package/.tests.sh +2 -2
  7. package/README.md +41 -41
  8. package/esm/abis/Erc20.json +223 -223
  9. package/esm/abis/SubStorage.json +17 -17
  10. package/esm/abis/UniMulticall.json +14 -14
  11. package/esm/abis/index.d.ts +9 -9
  12. package/esm/abis/index.js +30 -30
  13. package/esm/abis/legacy_AaveV2Subscriptions.json +8 -8
  14. package/esm/abis/legacy_AuthCheck.json +8 -8
  15. package/esm/abis/legacy_CompoundV2Subscriptions.json +9 -9
  16. package/esm/abis/legacy_MakerSubscriptions.json +9 -9
  17. package/esm/automation/private/Automation.d.ts +12 -12
  18. package/esm/automation/private/Automation.js +42 -42
  19. package/esm/automation/private/LegacyAutomation.d.ts +25 -25
  20. package/esm/automation/private/LegacyAutomation.js +118 -118
  21. package/esm/automation/private/LegacyProtocol.d.ts +22 -22
  22. package/esm/automation/private/LegacyProtocol.js +41 -41
  23. package/esm/automation/private/LegacyProtocol.test.d.ts +1 -1
  24. package/esm/automation/private/LegacyProtocol.test.js +25 -25
  25. package/esm/automation/private/Protocol.d.ts +22 -22
  26. package/esm/automation/private/Protocol.js +41 -41
  27. package/esm/automation/private/Protocol.test.d.ts +1 -1
  28. package/esm/automation/private/Protocol.test.js +25 -25
  29. package/esm/automation/private/StrategiesAutomation.d.ts +33 -33
  30. package/esm/automation/private/StrategiesAutomation.js +181 -181
  31. package/esm/automation/private/StrategiesAutomation.test.d.ts +1 -1
  32. package/esm/automation/private/StrategiesAutomation.test.js +671 -671
  33. package/esm/automation/public/ArbitrumStrategies.d.ts +5 -5
  34. package/esm/automation/public/ArbitrumStrategies.js +13 -13
  35. package/esm/automation/public/EthereumStrategies.d.ts +5 -5
  36. package/esm/automation/public/EthereumStrategies.js +13 -13
  37. package/esm/automation/public/OptimismStrategies.d.ts +5 -5
  38. package/esm/automation/public/OptimismStrategies.js +13 -13
  39. package/esm/automation/public/legacy/LegacyAaveAutomation.d.ts +6 -6
  40. package/esm/automation/public/legacy/LegacyAaveAutomation.js +20 -20
  41. package/esm/automation/public/legacy/LegacyCompoundAutomation.d.ts +6 -6
  42. package/esm/automation/public/legacy/LegacyCompoundAutomation.js +20 -20
  43. package/esm/automation/public/legacy/LegacyMakerAutomation.d.ts +6 -6
  44. package/esm/automation/public/legacy/LegacyMakerAutomation.js +20 -20
  45. package/esm/configuration.d.ts +1 -1
  46. package/esm/configuration.js +12 -12
  47. package/esm/constants/index.d.ts +45 -45
  48. package/esm/constants/index.js +395 -385
  49. package/esm/index.d.ts +22 -22
  50. package/esm/index.js +63 -63
  51. package/esm/services/contractService.d.ts +12 -12
  52. package/esm/services/contractService.js +54 -54
  53. package/esm/services/ethereumService.d.ts +7 -7
  54. package/esm/services/ethereumService.js +49 -49
  55. package/esm/services/ethereumService.test.d.ts +1 -1
  56. package/esm/services/ethereumService.test.js +242 -242
  57. package/esm/services/strategiesService.d.ts +2 -2
  58. package/esm/services/strategiesService.js +701 -698
  59. package/esm/services/strategiesService.test.d.ts +1 -1
  60. package/esm/services/strategiesService.test.js +110 -110
  61. package/esm/services/strategySubService.d.ts +87 -87
  62. package/esm/services/strategySubService.js +257 -252
  63. package/esm/services/strategySubService.test.d.ts +1 -1
  64. package/esm/services/strategySubService.test.js +894 -890
  65. package/esm/services/subDataService.d.ts +181 -181
  66. package/esm/services/subDataService.js +443 -442
  67. package/esm/services/subDataService.test.d.ts +1 -1
  68. package/esm/services/subDataService.test.js +1225 -1223
  69. package/esm/services/triggerService.d.ts +191 -191
  70. package/esm/services/triggerService.js +367 -367
  71. package/esm/services/triggerService.test.d.ts +1 -1
  72. package/esm/services/triggerService.test.js +926 -926
  73. package/esm/services/utils.d.ts +25 -25
  74. package/esm/services/utils.js +131 -131
  75. package/esm/services/utils.test.d.ts +1 -1
  76. package/esm/services/utils.test.js +376 -376
  77. package/esm/types/contracts/generated/Erc20.d.ts +53 -53
  78. package/esm/types/contracts/generated/Erc20.js +5 -5
  79. package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.d.ts +129 -129
  80. package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.js +5 -5
  81. package/esm/types/contracts/generated/Legacy_AuthCheck.d.ts +20 -20
  82. package/esm/types/contracts/generated/Legacy_AuthCheck.js +5 -5
  83. package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.d.ts +128 -128
  84. package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.js +5 -5
  85. package/esm/types/contracts/generated/Legacy_MakerSubscriptions.d.ts +246 -246
  86. package/esm/types/contracts/generated/Legacy_MakerSubscriptions.js +5 -5
  87. package/esm/types/contracts/generated/SubStorage.d.ts +114 -114
  88. package/esm/types/contracts/generated/SubStorage.js +5 -5
  89. package/esm/types/contracts/generated/UniMulticall.d.ts +55 -55
  90. package/esm/types/contracts/generated/UniMulticall.js +5 -5
  91. package/esm/types/contracts/generated/index.d.ts +7 -7
  92. package/esm/types/contracts/generated/index.js +2 -2
  93. package/esm/types/contracts/generated/types.d.ts +54 -54
  94. package/esm/types/contracts/generated/types.js +2 -2
  95. package/esm/types/enums.d.ts +160 -158
  96. package/esm/types/enums.js +180 -178
  97. package/esm/types/index.d.ts +217 -217
  98. package/esm/types/index.js +2 -2
  99. package/package.json +71 -71
  100. package/scripts/generateContractTypes.js +39 -39
  101. package/src/abis/Erc20.json +222 -222
  102. package/src/abis/SubStorage.json +17 -17
  103. package/src/abis/UniMulticall.json +14 -14
  104. package/src/abis/index.ts +28 -28
  105. package/src/abis/legacy_AaveV2Subscriptions.json +7 -7
  106. package/src/abis/legacy_AuthCheck.json +7 -7
  107. package/src/abis/legacy_CompoundV2Subscriptions.json +8 -8
  108. package/src/abis/legacy_MakerSubscriptions.json +8 -8
  109. package/src/automation/private/Automation.ts +44 -44
  110. package/src/automation/private/LegacyAutomation.ts +135 -135
  111. package/src/automation/private/LegacyProtocol.test.ts +23 -23
  112. package/src/automation/private/LegacyProtocol.ts +51 -51
  113. package/src/automation/private/Protocol.test.ts +23 -23
  114. package/src/automation/private/Protocol.ts +51 -51
  115. package/src/automation/private/StrategiesAutomation.test.ts +663 -663
  116. package/src/automation/private/StrategiesAutomation.ts +242 -242
  117. package/src/automation/public/ArbitrumStrategies.ts +10 -10
  118. package/src/automation/public/EthereumStrategies.ts +10 -10
  119. package/src/automation/public/OptimismStrategies.ts +10 -10
  120. package/src/automation/public/legacy/LegacyAaveAutomation.ts +20 -20
  121. package/src/automation/public/legacy/LegacyCompoundAutomation.ts +20 -20
  122. package/src/automation/public/legacy/LegacyMakerAutomation.ts +20 -20
  123. package/src/configuration.ts +8 -8
  124. package/src/constants/index.ts +409 -399
  125. package/src/index.ts +38 -38
  126. package/src/services/contractService.ts +77 -77
  127. package/src/services/ethereumService.test.ts +257 -257
  128. package/src/services/ethereumService.ts +69 -69
  129. package/src/services/strategiesService.test.ts +105 -105
  130. package/src/services/strategiesService.ts +905 -901
  131. package/src/services/strategySubService.test.ts +1065 -1060
  132. package/src/services/strategySubService.ts +496 -492
  133. package/src/services/subDataService.test.ts +1326 -1324
  134. package/src/services/subDataService.ts +595 -593
  135. package/src/services/triggerService.test.ts +1004 -1004
  136. package/src/services/triggerService.ts +449 -449
  137. package/src/services/utils.test.ts +430 -430
  138. package/src/services/utils.ts +103 -103
  139. package/src/types/enums.ts +174 -172
  140. package/src/types/index.ts +262 -262
  141. package/tsconfig.json +79 -79
  142. package/umd/index.js +42 -24
  143. package/webpack.umd.js +52 -52
@@ -1,890 +1,894 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const chai_1 = require("chai");
30
- const decimal_js_1 = __importDefault(require("decimal.js"));
31
- const sdk_1 = require("@defisaver/sdk");
32
- const tokens_1 = require("@defisaver/tokens");
33
- const web3Utils = __importStar(require("web3-utils"));
34
- const enums_1 = require("../types/enums");
35
- require("../configuration");
36
- const strategySubService_1 = require("./strategySubService");
37
- describe('Feature: strategySubService.ts', () => {
38
- describe('When testing strategySubService.makerEncode', () => {
39
- // @ts-ignore // TODO - this requires change in @defisaver/tokens
40
- const mcdCdpManagerAddr = (0, sdk_1.otherAddresses)(enums_1.ChainId.Ethereum).McdCdpManager;
41
- describe('repayFromSavings()', () => {
42
- const examples = [
43
- [
44
- [
45
- enums_1.Bundles.MainnetIds.MAKER_REPAY_FROM_SMART_SAVINGS_RARI,
46
- true,
47
- ['0x00000000000000000000000000000000000000000000000000000000000000de000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
48
- [
49
- '0x00000000000000000000000000000000000000000000000000000000000000de', '0x00000000000000000000000000000000000000000000000018fae27693b40000',
50
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005ef30b9986345249bc32d8928b7ee64de9435e39',
51
- ],
52
- ],
53
- [
54
- enums_1.Bundles.MainnetIds.MAKER_REPAY_FROM_SMART_SAVINGS_RARI,
55
- 222,
56
- 140,
57
- 180,
58
- true,
59
- enums_1.ChainId.Ethereum,
60
- (0, tokens_1.getAssetInfo)('DAI').address,
61
- mcdCdpManagerAddr,
62
- ]
63
- ]
64
- ];
65
- examples.forEach(([expected, actual]) => {
66
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
67
- (0, chai_1.expect)(strategySubService_1.makerEncode.repayFromSavings(...actual)).to.eql(expected);
68
- });
69
- });
70
- });
71
- describe('closeOnPrice()', () => {
72
- const examples = [
73
- [
74
- [
75
- enums_1.Strategies.MainnetIds.MAKER_CLOSE_ON_PRICE_TO_DAI,
76
- false,
77
- ['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000002cc9e4c0000000000000000000000000000000000000000000000000000000000000000'],
78
- [
79
- '0x0000000000000000000000000000000000000000000000000000000000000078', '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
80
- '0x0000000000000000000000005ef30b9986345249bc32d8928b7ee64de9435e39',
81
- ],
82
- ],
83
- [
84
- 120,
85
- enums_1.RatioState.OVER,
86
- '0.469643',
87
- (0, tokens_1.getAssetInfo)('DAI').address,
88
- (0, tokens_1.getAssetInfo)('WBTC').address,
89
- enums_1.ChainId.Ethereum,
90
- ]
91
- ]
92
- ];
93
- examples.forEach(([expected, actual]) => {
94
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
95
- (0, chai_1.expect)(strategySubService_1.makerEncode.closeOnPrice(...actual)).to.eql(expected);
96
- });
97
- });
98
- });
99
- describe('trailingStop()', () => {
100
- const examples = [
101
- [
102
- [
103
- enums_1.Strategies.MainnetIds.MAKER_TRAILING_STOP_LOSS_TO_COLL,
104
- false,
105
- ['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000000000000000000000000000000000055ae82600000000000000000000000000000000000000000000000000000000000000007b'],
106
- [
107
- '0x000000000000000000000000000000000000000000000000000000000000096e', '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
108
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005ef30b9986345249bc32d8928b7ee64de9435e39',
109
- ],
110
- ],
111
- [
112
- 2414,
113
- 230,
114
- (0, tokens_1.getAssetInfo)('WBTC').address,
115
- (0, tokens_1.getAssetInfo)('WBTC').address,
116
- 123,
117
- enums_1.ChainId.Ethereum,
118
- ]
119
- ]
120
- ];
121
- examples.forEach(([expected, actual]) => {
122
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
123
- (0, chai_1.expect)(strategySubService_1.makerEncode.trailingStop(...actual)).to.eql(expected);
124
- });
125
- });
126
- });
127
- describe('leverageManagement()', () => {
128
- const examples = [
129
- [
130
- [
131
- 5791,
132
- new decimal_js_1.default('210').mul(1e16).toString(),
133
- new decimal_js_1.default('290').mul(1e16).toString(),
134
- new decimal_js_1.default('240').mul(1e16).toString(),
135
- new decimal_js_1.default('240').mul(1e16).toString(),
136
- true,
137
- ],
138
- [
139
- 5791, '210', '290', '240', '240', true,
140
- ]
141
- ]
142
- ];
143
- examples.forEach(([expected, actual]) => {
144
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
145
- (0, chai_1.expect)(strategySubService_1.makerEncode.leverageManagement(...actual)).to.eql(expected);
146
- });
147
- });
148
- });
149
- });
150
- describe('When testing strategySubService.liquityEncode', () => {
151
- describe('closeOnPrice()', () => {
152
- const examples = [
153
- [
154
- [
155
- enums_1.Strategies.MainnetIds.LIQUITY_CLOSE_ON_PRICE_TO_COLL,
156
- false,
157
- ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000001c027053000000000000000000000000000000000000000000000000000000000000000000'],
158
- [
159
- '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
160
- ],
161
- ],
162
- [
163
- enums_1.RatioState.OVER,
164
- '1203',
165
- (0, tokens_1.getAssetInfo)('WETH').address,
166
- (0, tokens_1.getAssetInfo)('WETH').address,
167
- ]
168
- ]
169
- ];
170
- examples.forEach(([expected, actual]) => {
171
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
172
- (0, chai_1.expect)(strategySubService_1.liquityEncode.closeOnPrice(...actual)).to.eql(expected);
173
- });
174
- });
175
- });
176
- describe('trailingStop()', () => {
177
- const examples = [
178
- [
179
- [
180
- enums_1.Strategies.MainnetIds.LIQUITY_TRAILING_STOP_LOSS_TO_COLL,
181
- false,
182
- ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000055ae826000000000000000000000000000000000000000000000000000000000000000c97'],
183
- [
184
- '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
185
- ],
186
- ],
187
- [
188
- 230,
189
- (0, tokens_1.getAssetInfo)('WETH').address,
190
- (0, tokens_1.getAssetInfo)('WETH').address,
191
- 3223,
192
- ]
193
- ]
194
- ];
195
- examples.forEach(([expected, actual]) => {
196
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
197
- (0, chai_1.expect)(strategySubService_1.liquityEncode.trailingStop(...actual)).to.eql(expected);
198
- });
199
- });
200
- });
201
- describe('leverageManagement()', () => {
202
- const examples = [
203
- [
204
- [
205
- new decimal_js_1.default('210').mul(1e16).toString(),
206
- new decimal_js_1.default('290').mul(1e16).toString(),
207
- new decimal_js_1.default('240').mul(1e16).toString(),
208
- new decimal_js_1.default('240').mul(1e16).toString(),
209
- false,
210
- ],
211
- [
212
- '210', '290', '240', '240', false,
213
- ]
214
- ]
215
- ];
216
- examples.forEach(([expected, actual]) => {
217
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
218
- (0, chai_1.expect)(strategySubService_1.liquityEncode.leverageManagement(...actual)).to.eql(expected);
219
- });
220
- });
221
- });
222
- describe('paybackFromChickenBondStrategySub()', () => {
223
- const examples = [
224
- [
225
- [
226
- enums_1.Bundles.MainnetIds.LIQUITY_PAYBACK_USING_CHICKEN_BOND,
227
- true,
228
- ['0x0000000000000000000000002439d211133afab8f2b819b1066c7e434ad94e9e0000000000000000000000000000000000000000000000002dcbf4840eca00000000000000000000000000000000000000000000000000000000000000000000'],
229
- [
230
- '0x000000000000000000000000000000000000000000000000000000000000007b', '0x0000000000000000000000000000000000000000000000000000000000000000',
231
- '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
232
- ],
233
- ],
234
- [
235
- web3Utils.toChecksumAddress('0x2439d211133AFaB8F2B819B1066c7E434Ad94E9e'),
236
- 330,
237
- '123',
238
- 0,
239
- enums_1.RatioState.OVER
240
- ]
241
- ]
242
- ];
243
- examples.forEach(([expected, actual]) => {
244
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
245
- (0, chai_1.expect)(strategySubService_1.liquityEncode.paybackFromChickenBondStrategySub(...actual)).to.eql(expected);
246
- });
247
- });
248
- });
249
- describe('dsrPayback()', () => {
250
- const examples = [
251
- [
252
- [
253
- enums_1.Strategies.MainnetIds.LIQUITY_DSR_PAYBACK,
254
- false,
255
- ['0x0000000000000000000000002439d211133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000250dbeda8e4b00000000000000000000000000000000000000000000000000000000000000000001'],
256
- [
257
- '0x0000000000000000000000000000000000000000000000000000000000000001', '0x00000000000000000000000000000000000000000000000029a2241af62c0000',
258
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
259
- ],
260
- ],
261
- [web3Utils.toChecksumAddress('0x2439d211133AFaB8F2B819B1066c7E434Ad94E9e'), 267, 300]
262
- ]
263
- ];
264
- examples.forEach(([expected, actual]) => {
265
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
266
- (0, chai_1.expect)(strategySubService_1.liquityEncode.dsrPayback(...actual)).to.eql(expected);
267
- });
268
- });
269
- });
270
- describe('debtInFrontRepay()', () => {
271
- const examples = [
272
- [
273
- [
274
- enums_1.Strategies.MainnetIds.LIQUITY_DEBT_IN_FRONT_REPAY,
275
- false,
276
- ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a0000000000000000000000000000000000000000019d971e4fe8401e74000000'],
277
- [
278
- '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
279
- '0x000000000000000000000000000000000000000000000000063eb89da4ed0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
280
- '0x0000000000000000000000000000000000000000000000000000000000000000'
281
- ],
282
- ],
283
- [web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '500000000', 45]
284
- ]
285
- ];
286
- examples.forEach(([expected, actual]) => {
287
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
288
- (0, chai_1.expect)(strategySubService_1.liquityEncode.debtInFrontRepay(...actual)).to.eql(expected);
289
- });
290
- });
291
- });
292
- });
293
- describe('When testing strategySubService.chickenBondsEncode', () => {
294
- describe('rebond()', () => {
295
- const examples = [
296
- [
297
- ['0x00000000000000000000000000000000000000000000000000000000000005e3'],
298
- [1507]
299
- ]
300
- ];
301
- examples.forEach(([expected, actual]) => {
302
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
303
- (0, chai_1.expect)(strategySubService_1.chickenBondsEncode.rebond(...actual)).to.eql(expected);
304
- });
305
- });
306
- });
307
- });
308
- describe('When testing strategySubService.aaveV2Encode', () => {
309
- describe('leverageManagement()', () => {
310
- const examples = [
311
- [
312
- [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
313
- [160, 220, 180, 190, true]
314
- ],
315
- [
316
- [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
317
- [160, 200, 180, 190, false]
318
- ],
319
- ];
320
- examples.forEach(([expected, actual]) => {
321
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
322
- (0, chai_1.expect)(strategySubService_1.aaveV2Encode.leverageManagement(...actual)).to.eql(expected);
323
- });
324
- });
325
- });
326
- });
327
- describe('When testing strategySubService.aaveV3Encode', () => {
328
- describe('leverageManagement()', () => {
329
- const examples = [
330
- [
331
- '0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
332
- [160, 220, 180, 190, true]
333
- ],
334
- [
335
- '0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
336
- [160, 200, 180, 190, false]
337
- ],
338
- ];
339
- examples.forEach(([expected, actual]) => {
340
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
341
- (0, chai_1.expect)(strategySubService_1.aaveV3Encode.leverageManagement(...actual)).to.eql(expected);
342
- });
343
- });
344
- });
345
- describe('closeToAsset()', () => {
346
- const examples = [
347
- [
348
- [
349
- enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_COLLATERAL,
350
- true,
351
- ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000026e1f9c6000000000000000000000000000000000000000000000000000000000000000000'],
352
- [
353
- '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000015',
354
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000020',
355
- '0x0000000000000000000000000000000000000000000000000000000000000000',
356
- ],
357
- ],
358
- [
359
- enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_COLLATERAL,
360
- true,
361
- {
362
- baseTokenAddress: (0, tokens_1.getAssetInfo)('WETH').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 1670, ratioState: enums_1.RatioState.OVER
363
- },
364
- {
365
- collAsset: (0, tokens_1.getAssetInfo)('WETH').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('DAI').address, debtAssetId: 32,
366
- },
367
- ]
368
- ],
369
- [
370
- [
371
- enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_DEBT,
372
- true,
373
- ['0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000084d000000000000000000000000000000000000000000000000000000000000000001'],
374
- [
375
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000015',
376
- '0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca', '0x0000000000000000000000000000000000000000000000000000000000000020',
377
- '0x0000000000000000000000000000000000000000000000000000000000000000',
378
- ],
379
- ],
380
- [
381
- enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_DEBT,
382
- true,
383
- {
384
- baseTokenAddress: (0, tokens_1.getAssetInfo)('LINK').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 0.00544, ratioState: enums_1.RatioState.UNDER
385
- },
386
- {
387
- collAsset: (0, tokens_1.getAssetInfo)('DAI').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('LINK').address, debtAssetId: 32,
388
- },
389
- ]
390
- ]
391
- ];
392
- examples.forEach(([expected, actual]) => {
393
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
394
- (0, chai_1.expect)(strategySubService_1.aaveV3Encode.closeToAsset(...actual)).to.eql(expected);
395
- });
396
- });
397
- });
398
- describe('closeToAssetWithMaximumGasPrice()', () => {
399
- const examples = [
400
- [
401
- [
402
- enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_COLLATERAL,
403
- true,
404
- [
405
- '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000026e1f9c6000000000000000000000000000000000000000000000000000000000000000000',
406
- '0x00000000000000000000000000000000000000000000000000000002cb417800',
407
- ],
408
- [
409
- '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000015',
410
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000020',
411
- '0x0000000000000000000000000000000000000000000000000000000000000000',
412
- ],
413
- ],
414
- [
415
- enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_COLLATERAL,
416
- true,
417
- {
418
- baseTokenAddress: (0, tokens_1.getAssetInfo)('WETH').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 1670, ratioState: enums_1.RatioState.OVER, maximumGasPrice: 12,
419
- },
420
- {
421
- collAsset: (0, tokens_1.getAssetInfo)('WETH').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('DAI').address, debtAssetId: 32,
422
- },
423
- ]
424
- ],
425
- [
426
- [
427
- enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_DEBT,
428
- true,
429
- [
430
- '0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000084d000000000000000000000000000000000000000000000000000000000000000001',
431
- '0x0000000000000000000000000000000000000000000000000000004a817c8000',
432
- ],
433
- [
434
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000015',
435
- '0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca', '0x0000000000000000000000000000000000000000000000000000000000000020',
436
- '0x0000000000000000000000000000000000000000000000000000000000000000',
437
- ],
438
- ],
439
- [
440
- enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_DEBT,
441
- true,
442
- {
443
- baseTokenAddress: (0, tokens_1.getAssetInfo)('LINK').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 0.00544, ratioState: enums_1.RatioState.UNDER, maximumGasPrice: 320,
444
- },
445
- {
446
- collAsset: (0, tokens_1.getAssetInfo)('DAI').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('LINK').address, debtAssetId: 32,
447
- },
448
- ]
449
- ]
450
- ];
451
- examples.forEach(([expected, actual]) => {
452
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
453
- (0, chai_1.expect)(strategySubService_1.aaveV3Encode.closeToAssetWithMaximumGasPrice(...actual)).to.eql(expected);
454
- });
455
- });
456
- });
457
- });
458
- describe('When testing strategySubService.compoundV2Encode', () => {
459
- describe('leverageManagement()', () => {
460
- const examples = [
461
- [
462
- [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
463
- [160, 220, 180, 190, true]
464
- ],
465
- [
466
- [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
467
- [160, 200, 180, 190, false]
468
- ],
469
- ];
470
- examples.forEach(([expected, actual]) => {
471
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
472
- (0, chai_1.expect)(strategySubService_1.compoundV2Encode.leverageManagement(...actual)).to.eql(expected);
473
- });
474
- });
475
- });
476
- });
477
- describe('When testing strategySubService.compoundV3Encode', () => {
478
- describe('leverageManagement()', () => {
479
- const examples = [
480
- [
481
- [
482
- web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
483
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
484
- new decimal_js_1.default(160).mul(1e16).toString(),
485
- new decimal_js_1.default(220).mul(1e16).toString(),
486
- new decimal_js_1.default(180).mul(1e16).toString(),
487
- new decimal_js_1.default(190).mul(1e16).toString(),
488
- true, false,
489
- ],
490
- [
491
- web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
492
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
493
- 160, 220, 180, 190,
494
- true, false,
495
- ]
496
- ],
497
- [
498
- [
499
- web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
500
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
501
- new decimal_js_1.default(160).mul(1e16).toString(),
502
- new decimal_js_1.default(210).mul(1e16).toString(),
503
- new decimal_js_1.default(180).mul(1e16).toString(),
504
- new decimal_js_1.default(190).mul(1e16).toString(),
505
- false, true,
506
- ],
507
- [
508
- web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
509
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
510
- 160, 210, 180, 190,
511
- false, true,
512
- ]
513
- ],
514
- ];
515
- examples.forEach(([expected, actual]) => {
516
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
517
- (0, chai_1.expect)(strategySubService_1.compoundV3Encode.leverageManagement(...actual)).to.eql(expected);
518
- });
519
- });
520
- });
521
- });
522
- describe('When testing strategySubService.morphoAaveV2Encode', () => {
523
- describe('leverageManagement()', () => {
524
- const examples = [
525
- [
526
- [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
527
- [160, 220, 180, 190, true]
528
- ],
529
- [
530
- [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
531
- [160, 200, 180, 190, false]
532
- ],
533
- ];
534
- examples.forEach(([expected, actual]) => {
535
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
536
- (0, chai_1.expect)(strategySubService_1.morphoAaveV2Encode.leverageManagement(...actual)).to.eql(expected);
537
- });
538
- });
539
- });
540
- });
541
- describe('When testing strategySubService.exchangeEncode', () => {
542
- describe('dca()', () => {
543
- const examples = [
544
- [
545
- [
546
- enums_1.Strategies.ArbitrumIds.EXCHANGE_DCA,
547
- false,
548
- ['0x0000000000000000000000000000000000000000000000000000018b23bd88cd000000000000000000000000000000000000000000000000000000000012d068'],
549
- [
550
- '0x000000000000000000000000da10009cbd5d07dd0cecc66161fc93d7c9000da1', '0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831',
551
- '0x0000000000000000000000000000000000000000000000000000000000038270', '0x000000000000000000000000000000000000000000000000000000000012d068'
552
- ],
553
- ],
554
- [(0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Arbitrum).address, (0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address, '230000', 1697111705805, 1233000, enums_1.ChainId.Arbitrum]
555
- ],
556
- [
557
- [
558
- enums_1.Strategies.MainnetIds.EXCHANGE_DCA,
559
- false,
560
- ['0x0000000000000000000000000000000000000000000000000000018b23bd88cd0000000000000000000000000000000000000000000000000000000000067458'],
561
- [
562
- '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599', '0x000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
563
- '0x0000000000000000000000000000000000000000000000000000000000000015', '0x0000000000000000000000000000000000000000000000000000000000067458',
564
- ],
565
- ],
566
- [(0, tokens_1.getAssetInfo)('WBTC').address, (0, tokens_1.getAssetInfo)('ETH').address, '21', 1697111705805, 423000, enums_1.ChainId.Ethereum]
567
- ],
568
- ];
569
- examples.forEach(([expected, actual]) => {
570
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
571
- (0, chai_1.expect)(strategySubService_1.exchangeEncode.dca(...actual)).to.eql(expected);
572
- });
573
- });
574
- });
575
- describe('limitOrder()', () => {
576
- const examples = [
577
- [
578
- [
579
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
580
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
581
- '2131',
582
- '0.53123',
583
- '1696590921159',
584
- `${enums_1.OrderType.STOP_LOSS}`
585
- ],
586
- [
587
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
588
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
589
- '2131',
590
- '0.53123',
591
- 1696590921159,
592
- enums_1.OrderType.STOP_LOSS
593
- ]
594
- ],
595
- [
596
- [
597
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
598
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
599
- '2131',
600
- '0.43123',
601
- '1646590921159',
602
- `${enums_1.OrderType.TAKE_PROFIT}`
603
- ],
604
- [
605
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
606
- web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
607
- '2131',
608
- '0.43123',
609
- 1646590921159,
610
- enums_1.OrderType.TAKE_PROFIT
611
- ]
612
- ],
613
- ];
614
- examples.forEach(([expected, actual]) => {
615
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
616
- (0, chai_1.expect)(strategySubService_1.exchangeEncode.limitOrder(...actual)).to.eql(expected);
617
- });
618
- });
619
- });
620
- });
621
- describe('When testing strategySubService.sparkEncode', () => {
622
- describe('leverageManagement()', () => {
623
- const examples = [
624
- [
625
- '0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
626
- [160, 220, 180, 190, true]
627
- ],
628
- [
629
- '0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
630
- [160, 200, 180, 190, false]
631
- ],
632
- ];
633
- examples.forEach(([expected, actual]) => {
634
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
635
- (0, chai_1.expect)(strategySubService_1.sparkEncode.leverageManagement(...actual)).to.eql(expected);
636
- });
637
- });
638
- });
639
- describe('closeToAsset()', () => {
640
- const examples = [
641
- [
642
- [
643
- enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL,
644
- true,
645
- ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000026e1f9c6000000000000000000000000000000000000000000000000000000000000000000'],
646
- [
647
- '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000015',
648
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000020',
649
- '0x0000000000000000000000000000000000000000000000000000000000000000',
650
- ],
651
- ],
652
- [
653
- enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL,
654
- true,
655
- {
656
- baseTokenAddress: (0, tokens_1.getAssetInfo)('WETH').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 1670, ratioState: enums_1.RatioState.OVER
657
- },
658
- {
659
- collAsset: (0, tokens_1.getAssetInfo)('WETH').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('DAI').address, debtAssetId: 32,
660
- },
661
- ]
662
- ],
663
- [
664
- [
665
- enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT,
666
- true,
667
- ['0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000084d000000000000000000000000000000000000000000000000000000000000000001'],
668
- [
669
- '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000015',
670
- '0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca', '0x0000000000000000000000000000000000000000000000000000000000000020',
671
- '0x0000000000000000000000000000000000000000000000000000000000000000',
672
- ],
673
- ],
674
- [
675
- enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT,
676
- true,
677
- {
678
- baseTokenAddress: (0, tokens_1.getAssetInfo)('LINK').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 0.00544, ratioState: enums_1.RatioState.UNDER
679
- },
680
- {
681
- collAsset: (0, tokens_1.getAssetInfo)('DAI').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('LINK').address, debtAssetId: 32,
682
- },
683
- ]
684
- ]
685
- ];
686
- examples.forEach(([expected, actual]) => {
687
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
688
- (0, chai_1.expect)(strategySubService_1.sparkEncode.closeToAsset(...actual)).to.eql(expected);
689
- });
690
- });
691
- });
692
- });
693
- describe('When testing strategySubService.crvUSDEncode', () => {
694
- describe('leverageManagement()', () => {
695
- const examples = [
696
- [
697
- [
698
- enums_1.Bundles.MainnetIds.CRVUSD_REPAY,
699
- true,
700
- [
701
- '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001',
702
- ],
703
- [
704
- '0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
705
- '0x0000000000000000000000000000000000000000000000000000000000000001',
706
- '0x0000000000000000000000000000000000000000000000001a5e27eef13e0000',
707
- '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
708
- '0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
709
- ],
710
- ],
711
- [
712
- web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
713
- web3Utils.toChecksumAddress('0xa920de414ea4ab66b97da1bfe9e6eca7d4219635'),
714
- enums_1.RatioState.UNDER,
715
- 190,
716
- 140,
717
- '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
718
- '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E',
719
- ]
720
- ],
721
- [
722
- [
723
- enums_1.Bundles.MainnetIds.CRVUSD_BOOST,
724
- true,
725
- [
726
- '0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d42196350000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'
727
- ],
728
- [
729
- '0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
730
- '0x0000000000000000000000000000000000000000000000000000000000000000',
731
- '0x00000000000000000000000000000000000000000000000016345785d8a00000',
732
- '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
733
- '0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
734
- ],
735
- ],
736
- [
737
- web3Utils.toChecksumAddress('0x0043d218133AFaB8F2B829B106633E434Ad94E2c'),
738
- web3Utils.toChecksumAddress('0xa920de414ea4ab66b97da1bfe9e6eca7d4219635'),
739
- enums_1.RatioState.OVER,
740
- 160,
741
- 200,
742
- '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
743
- '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E',
744
- ]
745
- ],
746
- ];
747
- examples.forEach(([expected, actual]) => {
748
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
749
- (0, chai_1.expect)(strategySubService_1.crvUSDEncode.leverageManagement(...actual)).to.eql(expected);
750
- });
751
- });
752
- });
753
- describe('payback()', () => {
754
- const examples = [
755
- [
756
- [
757
- enums_1.Strategies.MainnetIds.CURVEUSD_PAYBACK,
758
- false,
759
- [
760
- '0x0000000000000000000000007a2af22ba3276108cd331c8985ef9528e10a871a000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d421963500000000000000000000000000000000000000000000000002c68af0bb140000',
761
- ],
762
- [
763
- '0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
764
- '0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
765
- '0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
766
- '0x00000000000000000000000000000000000000000000043c33c1937564800000',
767
- '0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e'
768
- ],
769
- ],
770
- [
771
- web3Utils.toChecksumAddress('0x7a2af22ba3276108cd331c8985ef9528e10a871a'),
772
- web3Utils.toChecksumAddress('0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280'),
773
- web3Utils.toChecksumAddress('0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280'),
774
- '20000',
775
- '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E',
776
- web3Utils.toChecksumAddress('0xA920De414eA4Ab66b97dA1bFE9e6EcA7d4219635'),
777
- 20,
778
- ]
779
- ]
780
- ];
781
- examples.forEach(([expected, actual]) => {
782
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
783
- (0, chai_1.expect)(strategySubService_1.crvUSDEncode.payback(...actual)).to.eql(expected);
784
- });
785
- });
786
- });
787
- });
788
- describe('When testing strategySubService.morphoBlueEncode', () => {
789
- describe('leverageManagement()', () => {
790
- const examples = [
791
- [
792
- [
793
- enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY,
794
- true,
795
- [
796
- '0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec410000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001',
797
- ],
798
- [
799
- '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
800
- '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
801
- '0x0000000000000000000000002a01eb9496094da03c4e364def50f5ad1280ad72',
802
- '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
803
- '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
804
- '0x0000000000000000000000000000000000000000000000000000000000000001',
805
- '0x000000000000000000000000000000000000000000000000136dcc951d8c0000',
806
- '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
807
- ],
808
- ],
809
- [
810
- '0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec41',
811
- web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
812
- web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
813
- web3Utils.toChecksumAddress('0x2a01eb9496094da03c4e364def50f5ad1280ad72'),
814
- web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
815
- '945000000000000000',
816
- enums_1.RatioState.UNDER,
817
- 140,
818
- 120,
819
- web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c')
820
- ]
821
- ],
822
- [
823
- [
824
- enums_1.Bundles.MainnetIds.MORPHO_BLUE_BOOST,
825
- true,
826
- [
827
- '0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec410000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'
828
- ],
829
- [
830
- '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
831
- '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
832
- '0x0000000000000000000000002a01eb9496094da03c4e364def50f5ad1280ad72',
833
- '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
834
- '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
835
- '0x0000000000000000000000000000000000000000000000000000000000000000',
836
- '0x00000000000000000000000000000000000000000000000016345785d8a00000',
837
- '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
838
- ],
839
- ],
840
- [
841
- '0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec41',
842
- web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
843
- web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
844
- web3Utils.toChecksumAddress('0x2a01eb9496094da03c4e364def50f5ad1280ad72'),
845
- web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
846
- '945000000000000000',
847
- enums_1.RatioState.OVER,
848
- 160,
849
- 200,
850
- web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c')
851
- ]
852
- ],
853
- ];
854
- examples.forEach(([expected, actual]) => {
855
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
856
- (0, chai_1.expect)(strategySubService_1.morphoBlueEncode.leverageManagement(...actual)).to.eql(expected);
857
- });
858
- });
859
- });
860
- });
861
- describe('When testing strategySubService.compoundV3L2Encode', () => {
862
- describe('leverageManagement()', () => {
863
- const examples = [
864
- [
865
- '0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
866
- [
867
- web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'),
868
- web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'),
869
- 160, 220, 180, 190,
870
- true
871
- ],
872
- ],
873
- [
874
- '0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee000000',
875
- [
876
- web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'),
877
- web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'),
878
- 160, 220, 180, 110,
879
- false
880
- ],
881
- ],
882
- ];
883
- examples.forEach(([expected, actual]) => {
884
- it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
885
- (0, chai_1.expect)(strategySubService_1.compoundV3L2Encode.leverageManagement(...actual)).to.eql(expected);
886
- });
887
- });
888
- });
889
- });
890
- });
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const chai_1 = require("chai");
30
+ const decimal_js_1 = __importDefault(require("decimal.js"));
31
+ const sdk_1 = require("@defisaver/sdk");
32
+ const tokens_1 = require("@defisaver/tokens");
33
+ const web3Utils = __importStar(require("web3-utils"));
34
+ const enums_1 = require("../types/enums");
35
+ require("../configuration");
36
+ const strategySubService_1 = require("./strategySubService");
37
+ describe('Feature: strategySubService.ts', () => {
38
+ describe('When testing strategySubService.makerEncode', () => {
39
+ // @ts-ignore // TODO - this requires change in @defisaver/tokens
40
+ const mcdCdpManagerAddr = (0, sdk_1.otherAddresses)(enums_1.ChainId.Ethereum).McdCdpManager;
41
+ describe('repayFromSavings()', () => {
42
+ const examples = [
43
+ [
44
+ [
45
+ enums_1.Bundles.MainnetIds.MAKER_REPAY_FROM_SMART_SAVINGS_RARI,
46
+ true,
47
+ ['0x00000000000000000000000000000000000000000000000000000000000000de000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001'],
48
+ [
49
+ '0x00000000000000000000000000000000000000000000000000000000000000de', '0x00000000000000000000000000000000000000000000000018fae27693b40000',
50
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005ef30b9986345249bc32d8928b7ee64de9435e39',
51
+ ],
52
+ ],
53
+ [
54
+ enums_1.Bundles.MainnetIds.MAKER_REPAY_FROM_SMART_SAVINGS_RARI,
55
+ 222,
56
+ 140,
57
+ 180,
58
+ true,
59
+ enums_1.ChainId.Ethereum,
60
+ (0, tokens_1.getAssetInfo)('DAI').address,
61
+ mcdCdpManagerAddr,
62
+ ]
63
+ ]
64
+ ];
65
+ examples.forEach(([expected, actual]) => {
66
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
67
+ (0, chai_1.expect)(strategySubService_1.makerEncode.repayFromSavings(...actual)).to.eql(expected);
68
+ });
69
+ });
70
+ });
71
+ describe('closeOnPrice()', () => {
72
+ const examples = [
73
+ [
74
+ [
75
+ enums_1.Strategies.MainnetIds.MAKER_CLOSE_ON_PRICE_TO_DAI,
76
+ false,
77
+ ['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c5990000000000000000000000000000000000000000000000000000000002cc9e4c0000000000000000000000000000000000000000000000000000000000000000'],
78
+ [
79
+ '0x0000000000000000000000000000000000000000000000000000000000000078', '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f',
80
+ '0x0000000000000000000000005ef30b9986345249bc32d8928b7ee64de9435e39',
81
+ ],
82
+ ],
83
+ [
84
+ 120,
85
+ enums_1.RatioState.OVER,
86
+ '0.469643',
87
+ (0, tokens_1.getAssetInfo)('DAI').address,
88
+ (0, tokens_1.getAssetInfo)('WBTC').address,
89
+ enums_1.ChainId.Ethereum,
90
+ ]
91
+ ]
92
+ ];
93
+ examples.forEach(([expected, actual]) => {
94
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
95
+ (0, chai_1.expect)(strategySubService_1.makerEncode.closeOnPrice(...actual)).to.eql(expected);
96
+ });
97
+ });
98
+ });
99
+ describe('trailingStop()', () => {
100
+ const examples = [
101
+ [
102
+ [
103
+ enums_1.Strategies.MainnetIds.MAKER_TRAILING_STOP_LOSS_TO_COLL,
104
+ false,
105
+ ['0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000000000000000000000000000000000055ae82600000000000000000000000000000000000000000000000000000000000000007b'],
106
+ [
107
+ '0x000000000000000000000000000000000000000000000000000000000000096e', '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599',
108
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005ef30b9986345249bc32d8928b7ee64de9435e39',
109
+ ],
110
+ ],
111
+ [
112
+ 2414,
113
+ 230,
114
+ (0, tokens_1.getAssetInfo)('WBTC').address,
115
+ (0, tokens_1.getAssetInfo)('WBTC').address,
116
+ 123,
117
+ enums_1.ChainId.Ethereum,
118
+ ]
119
+ ]
120
+ ];
121
+ examples.forEach(([expected, actual]) => {
122
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
123
+ (0, chai_1.expect)(strategySubService_1.makerEncode.trailingStop(...actual)).to.eql(expected);
124
+ });
125
+ });
126
+ });
127
+ describe('leverageManagement()', () => {
128
+ const examples = [
129
+ [
130
+ [
131
+ 5791,
132
+ new decimal_js_1.default('210').mul(1e16).toString(),
133
+ new decimal_js_1.default('290').mul(1e16).toString(),
134
+ new decimal_js_1.default('240').mul(1e16).toString(),
135
+ new decimal_js_1.default('240').mul(1e16).toString(),
136
+ true,
137
+ ],
138
+ [
139
+ 5791, '210', '290', '240', '240', true,
140
+ ]
141
+ ]
142
+ ];
143
+ examples.forEach(([expected, actual]) => {
144
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
145
+ (0, chai_1.expect)(strategySubService_1.makerEncode.leverageManagement(...actual)).to.eql(expected);
146
+ });
147
+ });
148
+ });
149
+ });
150
+ describe('When testing strategySubService.liquityEncode', () => {
151
+ describe('closeOnPrice()', () => {
152
+ const examples = [
153
+ [
154
+ [
155
+ enums_1.Strategies.MainnetIds.LIQUITY_CLOSE_ON_PRICE_TO_COLL,
156
+ false,
157
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000001c027053000000000000000000000000000000000000000000000000000000000000000000'],
158
+ [
159
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
160
+ ],
161
+ ],
162
+ [
163
+ enums_1.RatioState.OVER,
164
+ '1203',
165
+ (0, tokens_1.getAssetInfo)('WETH').address,
166
+ (0, tokens_1.getAssetInfo)('WETH').address,
167
+ ]
168
+ ]
169
+ ];
170
+ examples.forEach(([expected, actual]) => {
171
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
172
+ (0, chai_1.expect)(strategySubService_1.liquityEncode.closeOnPrice(...actual)).to.eql(expected);
173
+ });
174
+ });
175
+ });
176
+ describe('trailingStop()', () => {
177
+ const examples = [
178
+ [
179
+ [
180
+ enums_1.Strategies.MainnetIds.LIQUITY_TRAILING_STOP_LOSS_TO_COLL,
181
+ false,
182
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000055ae826000000000000000000000000000000000000000000000000000000000000000c97'],
183
+ [
184
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
185
+ ],
186
+ ],
187
+ [
188
+ 230,
189
+ (0, tokens_1.getAssetInfo)('WETH').address,
190
+ (0, tokens_1.getAssetInfo)('WETH').address,
191
+ 3223,
192
+ ]
193
+ ]
194
+ ];
195
+ examples.forEach(([expected, actual]) => {
196
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
197
+ (0, chai_1.expect)(strategySubService_1.liquityEncode.trailingStop(...actual)).to.eql(expected);
198
+ });
199
+ });
200
+ });
201
+ describe('leverageManagement()', () => {
202
+ const examples = [
203
+ [
204
+ [
205
+ new decimal_js_1.default('210').mul(1e16).toString(),
206
+ new decimal_js_1.default('290').mul(1e16).toString(),
207
+ new decimal_js_1.default('240').mul(1e16).toString(),
208
+ new decimal_js_1.default('240').mul(1e16).toString(),
209
+ false,
210
+ ],
211
+ [
212
+ '210', '290', '240', '240', false,
213
+ ]
214
+ ]
215
+ ];
216
+ examples.forEach(([expected, actual]) => {
217
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
218
+ (0, chai_1.expect)(strategySubService_1.liquityEncode.leverageManagement(...actual)).to.eql(expected);
219
+ });
220
+ });
221
+ });
222
+ describe('paybackFromChickenBondStrategySub()', () => {
223
+ const examples = [
224
+ [
225
+ [
226
+ enums_1.Bundles.MainnetIds.LIQUITY_PAYBACK_USING_CHICKEN_BOND,
227
+ true,
228
+ ['0x0000000000000000000000002439d211133afab8f2b819b1066c7e434ad94e9e0000000000000000000000000000000000000000000000002dcbf4840eca00000000000000000000000000000000000000000000000000000000000000000000'],
229
+ [
230
+ '0x000000000000000000000000000000000000000000000000000000000000007b', '0x0000000000000000000000000000000000000000000000000000000000000000',
231
+ '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0', '0x000000000000000000000000b9d7dddca9a4ac480991865efef82e01273f79c3',
232
+ ],
233
+ ],
234
+ [
235
+ web3Utils.toChecksumAddress('0x2439d211133AFaB8F2B819B1066c7E434Ad94E9e'),
236
+ 330,
237
+ '123',
238
+ 0,
239
+ enums_1.RatioState.OVER
240
+ ]
241
+ ]
242
+ ];
243
+ examples.forEach(([expected, actual]) => {
244
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
245
+ (0, chai_1.expect)(strategySubService_1.liquityEncode.paybackFromChickenBondStrategySub(...actual)).to.eql(expected);
246
+ });
247
+ });
248
+ });
249
+ describe('dsrPayback()', () => {
250
+ const examples = [
251
+ [
252
+ [
253
+ enums_1.Strategies.MainnetIds.LIQUITY_DSR_PAYBACK,
254
+ false,
255
+ ['0x0000000000000000000000002439d211133afab8f2b819b1066c7e434ad94e9e000000000000000000000000000000000000000000000000250dbeda8e4b00000000000000000000000000000000000000000000000000000000000000000001'],
256
+ [
257
+ '0x0000000000000000000000000000000000000000000000000000000000000001', '0x00000000000000000000000000000000000000000000000029a2241af62c0000',
258
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
259
+ ],
260
+ ],
261
+ [web3Utils.toChecksumAddress('0x2439d211133AFaB8F2B819B1066c7E434Ad94E9e'), 267, 300]
262
+ ]
263
+ ];
264
+ examples.forEach(([expected, actual]) => {
265
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
266
+ (0, chai_1.expect)(strategySubService_1.liquityEncode.dsrPayback(...actual)).to.eql(expected);
267
+ });
268
+ });
269
+ });
270
+ describe('debtInFrontRepay()', () => {
271
+ const examples = [
272
+ [
273
+ [
274
+ enums_1.Strategies.MainnetIds.LIQUITY_DEBT_IN_FRONT_REPAY,
275
+ false,
276
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a0000000000000000000000000000000000000000019d971e4fe8401e74000000'],
277
+ [
278
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000005f98805a4e8be255a32880fdec7f6728c6568ba0',
279
+ '0x000000000000000000000000000000000000000000000000063eb89da4ed0000', '0x0000000000000000000000000000000000000000000000000000000000000001',
280
+ '0x0000000000000000000000000000000000000000000000000000000000000000'
281
+ ],
282
+ ],
283
+ [web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '500000000', 45]
284
+ ]
285
+ ];
286
+ examples.forEach(([expected, actual]) => {
287
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
288
+ (0, chai_1.expect)(strategySubService_1.liquityEncode.debtInFrontRepay(...actual)).to.eql(expected);
289
+ });
290
+ });
291
+ });
292
+ });
293
+ describe('When testing strategySubService.chickenBondsEncode', () => {
294
+ describe('rebond()', () => {
295
+ const examples = [
296
+ [
297
+ ['0x00000000000000000000000000000000000000000000000000000000000005e3'],
298
+ [1507]
299
+ ]
300
+ ];
301
+ examples.forEach(([expected, actual]) => {
302
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
303
+ (0, chai_1.expect)(strategySubService_1.chickenBondsEncode.rebond(...actual)).to.eql(expected);
304
+ });
305
+ });
306
+ });
307
+ });
308
+ describe('When testing strategySubService.aaveV2Encode', () => {
309
+ describe('leverageManagement()', () => {
310
+ const examples = [
311
+ [
312
+ [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
313
+ [160, 220, 180, 190, true]
314
+ ],
315
+ [
316
+ [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
317
+ [160, 200, 180, 190, false]
318
+ ],
319
+ ];
320
+ examples.forEach(([expected, actual]) => {
321
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
322
+ (0, chai_1.expect)(strategySubService_1.aaveV2Encode.leverageManagement(...actual)).to.eql(expected);
323
+ });
324
+ });
325
+ });
326
+ });
327
+ describe('When testing strategySubService.aaveV3Encode', () => {
328
+ describe('leverageManagement()', () => {
329
+ const examples = [
330
+ [
331
+ '0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
332
+ [160, 220, 180, 190, true]
333
+ ],
334
+ [
335
+ '0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
336
+ [160, 200, 180, 190, false]
337
+ ],
338
+ ];
339
+ examples.forEach(([expected, actual]) => {
340
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
341
+ (0, chai_1.expect)(strategySubService_1.aaveV3Encode.leverageManagement(...actual)).to.eql(expected);
342
+ });
343
+ });
344
+ });
345
+ describe('closeToAsset()', () => {
346
+ const examples = [
347
+ [
348
+ [
349
+ enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_COLLATERAL,
350
+ true,
351
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000026e1f9c6000000000000000000000000000000000000000000000000000000000000000000'],
352
+ [
353
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000015',
354
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000020',
355
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
356
+ ],
357
+ ],
358
+ [
359
+ enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_COLLATERAL,
360
+ true,
361
+ {
362
+ baseTokenAddress: (0, tokens_1.getAssetInfo)('WETH').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 1670, ratioState: enums_1.RatioState.OVER
363
+ },
364
+ {
365
+ collAsset: (0, tokens_1.getAssetInfo)('WETH').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('DAI').address, debtAssetId: 32,
366
+ },
367
+ ]
368
+ ],
369
+ [
370
+ [
371
+ enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_DEBT,
372
+ true,
373
+ ['0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000084d000000000000000000000000000000000000000000000000000000000000000001'],
374
+ [
375
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000015',
376
+ '0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca', '0x0000000000000000000000000000000000000000000000000000000000000020',
377
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
378
+ ],
379
+ ],
380
+ [
381
+ enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_DEBT,
382
+ true,
383
+ {
384
+ baseTokenAddress: (0, tokens_1.getAssetInfo)('LINK').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 0.00544, ratioState: enums_1.RatioState.UNDER
385
+ },
386
+ {
387
+ collAsset: (0, tokens_1.getAssetInfo)('DAI').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('LINK').address, debtAssetId: 32,
388
+ },
389
+ ]
390
+ ]
391
+ ];
392
+ examples.forEach(([expected, actual]) => {
393
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
394
+ (0, chai_1.expect)(strategySubService_1.aaveV3Encode.closeToAsset(...actual)).to.eql(expected);
395
+ });
396
+ });
397
+ });
398
+ describe('closeToAssetWithMaximumGasPrice()', () => {
399
+ const examples = [
400
+ [
401
+ [
402
+ enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_COLLATERAL,
403
+ true,
404
+ [
405
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000026e1f9c6000000000000000000000000000000000000000000000000000000000000000000',
406
+ '0x00000000000000000000000000000000000000000000000000000002cb417800',
407
+ ],
408
+ [
409
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000015',
410
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000020',
411
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
412
+ ],
413
+ ],
414
+ [
415
+ enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_COLLATERAL,
416
+ true,
417
+ {
418
+ baseTokenAddress: (0, tokens_1.getAssetInfo)('WETH').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 1670, ratioState: enums_1.RatioState.OVER, maximumGasPrice: 12,
419
+ },
420
+ {
421
+ collAsset: (0, tokens_1.getAssetInfo)('WETH').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('DAI').address, debtAssetId: 32,
422
+ },
423
+ ]
424
+ ],
425
+ [
426
+ [
427
+ enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_DEBT,
428
+ true,
429
+ [
430
+ '0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000084d000000000000000000000000000000000000000000000000000000000000000001',
431
+ '0x0000000000000000000000000000000000000000000000000000004a817c8000',
432
+ ],
433
+ [
434
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000015',
435
+ '0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca', '0x0000000000000000000000000000000000000000000000000000000000000020',
436
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
437
+ ],
438
+ ],
439
+ [
440
+ enums_1.Bundles.MainnetIds.AAVE_V3_CLOSE_TO_DEBT,
441
+ true,
442
+ {
443
+ baseTokenAddress: (0, tokens_1.getAssetInfo)('LINK').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 0.00544, ratioState: enums_1.RatioState.UNDER, maximumGasPrice: 320,
444
+ },
445
+ {
446
+ collAsset: (0, tokens_1.getAssetInfo)('DAI').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('LINK').address, debtAssetId: 32,
447
+ },
448
+ ]
449
+ ]
450
+ ];
451
+ examples.forEach(([expected, actual]) => {
452
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
453
+ (0, chai_1.expect)(strategySubService_1.aaveV3Encode.closeToAssetWithMaximumGasPrice(...actual)).to.eql(expected);
454
+ });
455
+ });
456
+ });
457
+ });
458
+ describe('When testing strategySubService.compoundV2Encode', () => {
459
+ describe('leverageManagement()', () => {
460
+ const examples = [
461
+ [
462
+ [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
463
+ [160, 220, 180, 190, true]
464
+ ],
465
+ [
466
+ [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
467
+ [160, 200, 180, 190, false]
468
+ ],
469
+ ];
470
+ examples.forEach(([expected, actual]) => {
471
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
472
+ (0, chai_1.expect)(strategySubService_1.compoundV2Encode.leverageManagement(...actual)).to.eql(expected);
473
+ });
474
+ });
475
+ });
476
+ });
477
+ describe('When testing strategySubService.compoundV3Encode', () => {
478
+ describe('leverageManagement()', () => {
479
+ const examples = [
480
+ [
481
+ [
482
+ web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
483
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
484
+ new decimal_js_1.default(160).mul(1e16).toString(),
485
+ new decimal_js_1.default(220).mul(1e16).toString(),
486
+ new decimal_js_1.default(180).mul(1e16).toString(),
487
+ new decimal_js_1.default(190).mul(1e16).toString(),
488
+ true, false,
489
+ ],
490
+ [
491
+ web3Utils.toChecksumAddress('0x1C0F620155e85491f8D35440eb17538Ca5c55212'),
492
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Ethereum).address),
493
+ 160, 220, 180, 190,
494
+ true, false,
495
+ ]
496
+ ],
497
+ [
498
+ [
499
+ web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
500
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
501
+ new decimal_js_1.default(160).mul(1e16).toString(),
502
+ new decimal_js_1.default(210).mul(1e16).toString(),
503
+ new decimal_js_1.default(180).mul(1e16).toString(),
504
+ new decimal_js_1.default(190).mul(1e16).toString(),
505
+ false, true,
506
+ ],
507
+ [
508
+ web3Utils.toChecksumAddress('0xaC0F620155e85491f8D35440eb17538Ca5c55212'),
509
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
510
+ 160, 210, 180, 190,
511
+ false, true,
512
+ ]
513
+ ],
514
+ ];
515
+ examples.forEach(([expected, actual]) => {
516
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
517
+ (0, chai_1.expect)(strategySubService_1.compoundV3Encode.leverageManagement(...actual)).to.eql(expected);
518
+ });
519
+ });
520
+ });
521
+ });
522
+ describe('When testing strategySubService.morphoAaveV2Encode', () => {
523
+ describe('leverageManagement()', () => {
524
+ const examples = [
525
+ [
526
+ [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(220).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), true],
527
+ [160, 220, 180, 190, true]
528
+ ],
529
+ [
530
+ [new decimal_js_1.default(160).mul(1e16).toString(), new decimal_js_1.default(200).mul(1e16).toString(), new decimal_js_1.default(180).mul(1e16).toString(), new decimal_js_1.default(190).mul(1e16).toString(), false],
531
+ [160, 200, 180, 190, false]
532
+ ],
533
+ ];
534
+ examples.forEach(([expected, actual]) => {
535
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
536
+ (0, chai_1.expect)(strategySubService_1.morphoAaveV2Encode.leverageManagement(...actual)).to.eql(expected);
537
+ });
538
+ });
539
+ });
540
+ });
541
+ describe('When testing strategySubService.exchangeEncode', () => {
542
+ describe('dca()', () => {
543
+ const examples = [
544
+ [
545
+ [
546
+ enums_1.Strategies.ArbitrumIds.EXCHANGE_DCA,
547
+ false,
548
+ ['0x0000000000000000000000000000000000000000000000000000018b23bd88cd000000000000000000000000000000000000000000000000000000000012d068'],
549
+ [
550
+ '0x000000000000000000000000da10009cbd5d07dd0cecc66161fc93d7c9000da1', '0x000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831',
551
+ '0x0000000000000000000000000000000000000000000000000000000000038270', '0x000000000000000000000000000000000000000000000000000000000012d068'
552
+ ],
553
+ ],
554
+ [(0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Arbitrum).address, (0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address, '230000', 1697111705805, 1233000, enums_1.ChainId.Arbitrum]
555
+ ],
556
+ [
557
+ [
558
+ enums_1.Strategies.MainnetIds.EXCHANGE_DCA,
559
+ false,
560
+ ['0x0000000000000000000000000000000000000000000000000000018b23bd88cd0000000000000000000000000000000000000000000000000000000000067458'],
561
+ [
562
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599', '0x000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
563
+ '0x0000000000000000000000000000000000000000000000000000000000000015', '0x0000000000000000000000000000000000000000000000000000000000067458',
564
+ ],
565
+ ],
566
+ [(0, tokens_1.getAssetInfo)('WBTC').address, (0, tokens_1.getAssetInfo)('ETH').address, '21', 1697111705805, 423000, enums_1.ChainId.Ethereum]
567
+ ],
568
+ ];
569
+ examples.forEach(([expected, actual]) => {
570
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
571
+ (0, chai_1.expect)(strategySubService_1.exchangeEncode.dca(...actual)).to.eql(expected);
572
+ });
573
+ });
574
+ });
575
+ describe('limitOrder()', () => {
576
+ const examples = [
577
+ [
578
+ [
579
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
580
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
581
+ '2131',
582
+ '0.53123',
583
+ '1696590921159',
584
+ `${enums_1.OrderType.STOP_LOSS}`
585
+ ],
586
+ [
587
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
588
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
589
+ '2131',
590
+ '0.53123',
591
+ 1696590921159,
592
+ enums_1.OrderType.STOP_LOSS
593
+ ]
594
+ ],
595
+ [
596
+ [
597
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
598
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
599
+ '2131',
600
+ '0.43123',
601
+ '1646590921159',
602
+ `${enums_1.OrderType.TAKE_PROFIT}`
603
+ ],
604
+ [
605
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('LINK', enums_1.ChainId.Arbitrum).address),
606
+ web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
607
+ '2131',
608
+ '0.43123',
609
+ 1646590921159,
610
+ enums_1.OrderType.TAKE_PROFIT
611
+ ]
612
+ ],
613
+ ];
614
+ examples.forEach(([expected, actual]) => {
615
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
616
+ (0, chai_1.expect)(strategySubService_1.exchangeEncode.limitOrder(...actual)).to.eql(expected);
617
+ });
618
+ });
619
+ });
620
+ });
621
+ describe('When testing strategySubService.sparkEncode', () => {
622
+ describe('leverageManagement()', () => {
623
+ const examples = [
624
+ [
625
+ '0x000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
626
+ [160, 220, 180, 190, true]
627
+ ],
628
+ [
629
+ '0x000000000000000016345785d8a0000000000000000000001bc16d674ec80000000000000000000018fae27693b4000000000000000000001a5e27eef13e000000',
630
+ [160, 200, 180, 190, false]
631
+ ],
632
+ ];
633
+ examples.forEach(([expected, actual]) => {
634
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
635
+ (0, chai_1.expect)(strategySubService_1.sparkEncode.leverageManagement(...actual)).to.eql(expected);
636
+ });
637
+ });
638
+ });
639
+ describe('closeToAsset()', () => {
640
+ const examples = [
641
+ [
642
+ [
643
+ enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL,
644
+ true,
645
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000026e1f9c6000000000000000000000000000000000000000000000000000000000000000000'],
646
+ [
647
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', '0x0000000000000000000000000000000000000000000000000000000000000015',
648
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000020',
649
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
650
+ ],
651
+ ],
652
+ [
653
+ enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_COLLATERAL,
654
+ true,
655
+ {
656
+ baseTokenAddress: (0, tokens_1.getAssetInfo)('WETH').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 1670, ratioState: enums_1.RatioState.OVER
657
+ },
658
+ {
659
+ collAsset: (0, tokens_1.getAssetInfo)('WETH').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('DAI').address, debtAssetId: 32,
660
+ },
661
+ ]
662
+ ],
663
+ [
664
+ [
665
+ enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT,
666
+ true,
667
+ ['0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000000000000000000000000000000000000000084d000000000000000000000000000000000000000000000000000000000000000001'],
668
+ [
669
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f', '0x0000000000000000000000000000000000000000000000000000000000000015',
670
+ '0x000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca', '0x0000000000000000000000000000000000000000000000000000000000000020',
671
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
672
+ ],
673
+ ],
674
+ [
675
+ enums_1.Bundles.MainnetIds.SPARK_CLOSE_TO_DEBT,
676
+ true,
677
+ {
678
+ baseTokenAddress: (0, tokens_1.getAssetInfo)('LINK').address, quoteTokenAddress: (0, tokens_1.getAssetInfo)('DAI').address, price: 0.00544, ratioState: enums_1.RatioState.UNDER
679
+ },
680
+ {
681
+ collAsset: (0, tokens_1.getAssetInfo)('DAI').address, collAssetId: 21, debtAsset: (0, tokens_1.getAssetInfo)('LINK').address, debtAssetId: 32,
682
+ },
683
+ ]
684
+ ]
685
+ ];
686
+ examples.forEach(([expected, actual]) => {
687
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
688
+ (0, chai_1.expect)(strategySubService_1.sparkEncode.closeToAsset(...actual)).to.eql(expected);
689
+ });
690
+ });
691
+ });
692
+ });
693
+ describe('When testing strategySubService.crvUSDEncode', () => {
694
+ describe('leverageManagement()', () => {
695
+ const examples = [
696
+ [
697
+ [
698
+ enums_1.Bundles.MainnetIds.CRVUSD_REPAY,
699
+ true,
700
+ [
701
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635000000000000000000000000000000000000000000000000136dcc951d8c00000000000000000000000000000000000000000000000000000000000000000001',
702
+ ],
703
+ [
704
+ '0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
705
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
706
+ '0x0000000000000000000000000000000000000000000000001a5e27eef13e0000',
707
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
708
+ '0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
709
+ ],
710
+ ],
711
+ [
712
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
713
+ web3Utils.toChecksumAddress('0xa920de414ea4ab66b97da1bfe9e6eca7d4219635'),
714
+ enums_1.RatioState.UNDER,
715
+ 190,
716
+ 140,
717
+ '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
718
+ '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E',
719
+ ]
720
+ ],
721
+ [
722
+ [
723
+ enums_1.Bundles.MainnetIds.CRVUSD_BOOST,
724
+ true,
725
+ [
726
+ '0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d42196350000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'
727
+ ],
728
+ [
729
+ '0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
730
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
731
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
732
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
733
+ '0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e',
734
+ ],
735
+ ],
736
+ [
737
+ web3Utils.toChecksumAddress('0x0043d218133AFaB8F2B829B106633E434Ad94E2c'),
738
+ web3Utils.toChecksumAddress('0xa920de414ea4ab66b97da1bfe9e6eca7d4219635'),
739
+ enums_1.RatioState.OVER,
740
+ 160,
741
+ 200,
742
+ '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
743
+ '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E',
744
+ ]
745
+ ],
746
+ ];
747
+ examples.forEach(([expected, actual]) => {
748
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
749
+ (0, chai_1.expect)(strategySubService_1.crvUSDEncode.leverageManagement(...actual)).to.eql(expected);
750
+ });
751
+ });
752
+ });
753
+ describe('payback()', () => {
754
+ const examples = [
755
+ [
756
+ [
757
+ enums_1.Strategies.MainnetIds.CURVEUSD_PAYBACK,
758
+ false,
759
+ [
760
+ '0x0000000000000000000000007a2af22ba3276108cd331c8985ef9528e10a871a000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d421963500000000000000000000000000000000000000000000000002c68af0bb140000',
761
+ ],
762
+ [
763
+ '0x000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d4219635',
764
+ '0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
765
+ '0x000000000000000000000000dc0ad7a48088f1aa55d26f8b36f7c1e827ddd280',
766
+ '0x00000000000000000000000000000000000000000000043c33c1937564800000',
767
+ '0x000000000000000000000000f939e0a03fb07f59a73314e73794be0e57ac1b4e'
768
+ ],
769
+ ],
770
+ [
771
+ web3Utils.toChecksumAddress('0x7a2af22ba3276108cd331c8985ef9528e10a871a'),
772
+ web3Utils.toChecksumAddress('0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280'),
773
+ web3Utils.toChecksumAddress('0xDc0Ad7a48088f1AA55d26f8b36F7C1E827DdD280'),
774
+ '20000',
775
+ '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E',
776
+ web3Utils.toChecksumAddress('0xA920De414eA4Ab66b97dA1bFE9e6EcA7d4219635'),
777
+ 20,
778
+ ]
779
+ ]
780
+ ];
781
+ examples.forEach(([expected, actual]) => {
782
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
783
+ (0, chai_1.expect)(strategySubService_1.crvUSDEncode.payback(...actual)).to.eql(expected);
784
+ });
785
+ });
786
+ });
787
+ });
788
+ describe('When testing strategySubService.morphoBlueEncode', () => {
789
+ describe('leverageManagement()', () => {
790
+ const examples = [
791
+ [
792
+ [
793
+ enums_1.Bundles.MainnetIds.MORPHO_BLUE_REPAY,
794
+ true,
795
+ [
796
+ '0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec410000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001',
797
+ ],
798
+ [
799
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
800
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
801
+ '0x0000000000000000000000002a01eb9496094da03c4e364def50f5ad1280ad72',
802
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
803
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
804
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
805
+ '0x000000000000000000000000000000000000000000000000136dcc951d8c0000',
806
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
807
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
808
+ ],
809
+ ],
810
+ [
811
+ '0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec41',
812
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
813
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
814
+ web3Utils.toChecksumAddress('0x2a01eb9496094da03c4e364def50f5ad1280ad72'),
815
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
816
+ '945000000000000000',
817
+ enums_1.RatioState.UNDER,
818
+ 140,
819
+ 120,
820
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
821
+ false,
822
+ ]
823
+ ],
824
+ [
825
+ [
826
+ enums_1.Bundles.MainnetIds.MORPHO_BLUE_BOOST,
827
+ true,
828
+ [
829
+ '0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec410000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'
830
+ ],
831
+ [
832
+ '0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
833
+ '0x0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
834
+ '0x0000000000000000000000002a01eb9496094da03c4e364def50f5ad1280ad72',
835
+ '0x000000000000000000000000870ac11d48b15db9a138cf899d20f13f79ba00bc',
836
+ '0x0000000000000000000000000000000000000000000000000d1d507e40be8000',
837
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
838
+ '0x00000000000000000000000000000000000000000000000016345785d8a00000',
839
+ '0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c',
840
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
841
+ ],
842
+ ],
843
+ [
844
+ '0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec41',
845
+ web3Utils.toChecksumAddress('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
846
+ web3Utils.toChecksumAddress('0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'),
847
+ web3Utils.toChecksumAddress('0x2a01eb9496094da03c4e364def50f5ad1280ad72'),
848
+ web3Utils.toChecksumAddress('0x870aC11D48B15DB9a138Cf899d20F13F79Ba00BC'),
849
+ '945000000000000000',
850
+ enums_1.RatioState.OVER,
851
+ 160,
852
+ 200,
853
+ web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
854
+ false,
855
+ ]
856
+ ],
857
+ ];
858
+ examples.forEach(([expected, actual]) => {
859
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
860
+ (0, chai_1.expect)(strategySubService_1.morphoBlueEncode.leverageManagement(...actual)).to.eql(expected);
861
+ });
862
+ });
863
+ });
864
+ });
865
+ describe('When testing strategySubService.compoundV3L2Encode', () => {
866
+ describe('leverageManagement()', () => {
867
+ const examples = [
868
+ [
869
+ '0x0313D212133AFab8F2b829B1066c7e43caD94e2c0213D212133AfaB8F2b829B1066C7E43cAD94E2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000001a5e27eef13e000001',
870
+ [
871
+ web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'),
872
+ web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'),
873
+ 160, 220, 180, 190,
874
+ true
875
+ ],
876
+ ],
877
+ [
878
+ '0x0313D212133AFab8F2b829B1066c7e43caD94e2c0413d212133afAb8F2B829b1066C7e43cAd94e2c000000000000000016345785d8a0000000000000000000001e87f85809dc0000000000000000000018fae27693b4000000000000000000000f43fc2c04ee000000',
879
+ [
880
+ web3Utils.toChecksumAddress('0x0313d212133AFaB8F2B829B1066c7E43cAd94E2c'),
881
+ web3Utils.toChecksumAddress('0x0413d212133AFaB8F2B829B1066c7E43cAd94E2c'),
882
+ 160, 220, 180, 110,
883
+ false
884
+ ],
885
+ ],
886
+ ];
887
+ examples.forEach(([expected, actual]) => {
888
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
889
+ (0, chai_1.expect)(strategySubService_1.compoundV3L2Encode.leverageManagement(...actual)).to.eql(expected);
890
+ });
891
+ });
892
+ });
893
+ });
894
+ });