@defisaver/automation-sdk 3.0.9 → 3.1.1-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +484 -0
  52. package/cjs/index.d.ts +23 -0
  53. package/cjs/index.js +65 -0
  54. package/cjs/services/contractService.d.ts +12 -0
  55. package/cjs/services/contractService.js +54 -0
  56. package/cjs/services/ethereumService.d.ts +7 -0
  57. package/cjs/services/ethereumService.js +49 -0
  58. package/cjs/services/ethereumService.test.d.ts +1 -0
  59. package/cjs/services/ethereumService.test.js +242 -0
  60. package/cjs/services/strategiesService.d.ts +2 -0
  61. package/cjs/services/strategiesService.js +758 -0
  62. package/cjs/services/strategiesService.test.d.ts +1 -0
  63. package/cjs/services/strategiesService.test.js +110 -0
  64. package/cjs/services/strategySubService.d.ts +103 -0
  65. package/cjs/services/strategySubService.js +277 -0
  66. package/cjs/services/strategySubService.test.d.ts +1 -0
  67. package/cjs/services/strategySubService.test.js +934 -0
  68. package/cjs/services/subDataService.d.ts +201 -0
  69. package/cjs/services/subDataService.js +499 -0
  70. package/cjs/services/subDataService.test.d.ts +1 -0
  71. package/cjs/services/subDataService.test.js +1282 -0
  72. package/cjs/services/triggerService.d.ts +200 -0
  73. package/cjs/services/triggerService.js +382 -0
  74. package/cjs/services/triggerService.test.d.ts +1 -0
  75. package/cjs/services/triggerService.test.js +926 -0
  76. package/cjs/services/utils.d.ts +25 -0
  77. package/cjs/services/utils.js +131 -0
  78. package/cjs/services/utils.test.d.ts +1 -0
  79. package/cjs/services/utils.test.js +376 -0
  80. package/cjs/types/contracts/generated/Erc20.d.ts +53 -0
  81. package/cjs/types/contracts/generated/Erc20.js +5 -0
  82. package/cjs/types/contracts/generated/Legacy_AaveV2Subscriptions.d.ts +129 -0
  83. package/cjs/types/contracts/generated/Legacy_AaveV2Subscriptions.js +5 -0
  84. package/cjs/types/contracts/generated/Legacy_AuthCheck.d.ts +20 -0
  85. package/cjs/types/contracts/generated/Legacy_AuthCheck.js +5 -0
  86. package/cjs/types/contracts/generated/Legacy_CompoundV2Subscriptions.d.ts +128 -0
  87. package/cjs/types/contracts/generated/Legacy_CompoundV2Subscriptions.js +5 -0
  88. package/cjs/types/contracts/generated/Legacy_MakerSubscriptions.d.ts +246 -0
  89. package/cjs/types/contracts/generated/Legacy_MakerSubscriptions.js +5 -0
  90. package/cjs/types/contracts/generated/SubStorage.d.ts +114 -0
  91. package/cjs/types/contracts/generated/SubStorage.js +5 -0
  92. package/cjs/types/contracts/generated/UniMulticall.d.ts +55 -0
  93. package/cjs/types/contracts/generated/UniMulticall.js +5 -0
  94. package/cjs/types/contracts/generated/index.d.ts +7 -0
  95. package/cjs/types/contracts/generated/index.js +2 -0
  96. package/cjs/types/contracts/generated/types.d.ts +54 -0
  97. package/cjs/types/contracts/generated/types.js +2 -0
  98. package/cjs/types/enums.d.ts +192 -0
  99. package/cjs/types/enums.js +216 -0
  100. package/cjs/types/index.d.ts +224 -0
  101. package/cjs/types/index.js +2 -0
  102. package/esm/abis/Erc20.json +223 -223
  103. package/esm/abis/SubStorage.json +21 -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 +478 -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 +731 -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 +103 -100
  158. package/esm/services/strategySubService.js +248 -264
  159. package/esm/services/strategySubService.test.d.ts +1 -1
  160. package/esm/services/strategySubService.test.js +906 -934
  161. package/esm/services/subDataService.d.ts +201 -192
  162. package/esm/services/subDataService.js +493 -475
  163. package/esm/services/subDataService.test.d.ts +1 -1
  164. package/esm/services/subDataService.test.js +1254 -1282
  165. package/esm/services/triggerService.d.ts +200 -191
  166. package/esm/services/triggerService.js +353 -367
  167. package/esm/services/triggerService.test.d.ts +1 -1
  168. package/esm/services/triggerService.test.js +901 -926
  169. package/esm/services/utils.d.ts +25 -25
  170. package/esm/services/utils.js +82 -131
  171. package/esm/services/utils.test.d.ts +1 -1
  172. package/esm/services/utils.test.js +348 -376
  173. package/esm/types/contracts/generated/Erc20.d.ts +53 -53
  174. package/esm/types/contracts/generated/Erc20.js +4 -5
  175. package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.d.ts +129 -129
  176. package/esm/types/contracts/generated/Legacy_AaveV2Subscriptions.js +4 -5
  177. package/esm/types/contracts/generated/Legacy_AuthCheck.d.ts +20 -20
  178. package/esm/types/contracts/generated/Legacy_AuthCheck.js +4 -5
  179. package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.d.ts +128 -128
  180. package/esm/types/contracts/generated/Legacy_CompoundV2Subscriptions.js +4 -5
  181. package/esm/types/contracts/generated/Legacy_MakerSubscriptions.d.ts +246 -246
  182. package/esm/types/contracts/generated/Legacy_MakerSubscriptions.js +4 -5
  183. package/esm/types/contracts/generated/SubStorage.d.ts +114 -114
  184. package/esm/types/contracts/generated/SubStorage.js +4 -5
  185. package/esm/types/contracts/generated/UniMulticall.d.ts +55 -55
  186. package/esm/types/contracts/generated/UniMulticall.js +4 -5
  187. package/esm/types/contracts/generated/index.d.ts +7 -7
  188. package/esm/types/contracts/generated/index.js +1 -2
  189. package/esm/types/contracts/generated/types.d.ts +54 -54
  190. package/esm/types/contracts/generated/types.js +1 -2
  191. package/esm/types/enums.d.ts +192 -168
  192. package/esm/types/enums.js +213 -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 +502 -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 +979 -932
  228. package/src/services/strategySubService.test.ts +1119 -1119
  229. package/src/services/strategySubService.ts +542 -518
  230. package/src/services/subDataService.test.ts +1387 -1387
  231. package/src/services/subDataService.ts +681 -645
  232. package/src/services/triggerService.test.ts +1004 -1004
  233. package/src/services/triggerService.ts +472 -449
  234. package/src/services/utils.test.ts +430 -430
  235. package/src/services/utils.ts +103 -103
  236. package/src/types/enums.ts +210 -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,926 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const chai_1 = require("chai");
27
+ const tokens_1 = require("@defisaver/tokens");
28
+ const web3Utils = __importStar(require("web3-utils"));
29
+ const enums_1 = require("../types/enums");
30
+ require("../configuration");
31
+ const triggerService_1 = require("./triggerService");
32
+ describe('Feature: triggerService.ts', () => {
33
+ describe('When testing triggerService.chainlinkPriceTrigger', () => {
34
+ describe('encode()', () => {
35
+ const examples = [
36
+ [
37
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000002794ca24000000000000000000000000000000000000000000000000000000000000000000'],
38
+ [(0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address, '1700', enums_1.RatioState.OVER]
39
+ ],
40
+ [
41
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000002c3ce1ec000000000000000000000000000000000000000000000000000000000000000001'],
42
+ [(0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address, '1900', enums_1.RatioState.UNDER]
43
+ ],
44
+ ];
45
+ examples.forEach(([expected, actual]) => {
46
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
47
+ (0, chai_1.expect)(triggerService_1.chainlinkPriceTrigger.encode(...actual)).to.eql(expected);
48
+ });
49
+ });
50
+ });
51
+ describe('decode()', () => {
52
+ const examples = [
53
+ [
54
+ { tokenAddr: (0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address, price: '1700', state: enums_1.RatioState.OVER },
55
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000002794ca24000000000000000000000000000000000000000000000000000000000000000000'],
56
+ ],
57
+ [
58
+ { tokenAddr: (0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address, price: '1900', state: enums_1.RatioState.UNDER },
59
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000002c3ce1ec000000000000000000000000000000000000000000000000000000000000000001'],
60
+ ],
61
+ ];
62
+ examples.forEach(([expected, actual]) => {
63
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
64
+ (0, chai_1.expect)(triggerService_1.chainlinkPriceTrigger.decode(actual)).to.eql(expected);
65
+ });
66
+ });
67
+ });
68
+ });
69
+ describe('When testing triggerService.trailingStopTrigger', () => {
70
+ describe('encode()', () => {
71
+ const examples = [
72
+ [
73
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000002cb417800000000000000000000000000000000000000000000000000000000000000000a'],
74
+ [(0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address, 120, 10]
75
+ ],
76
+ [
77
+ ['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000002cb417800000000000000000000000000000000000000000000000000000000000000000c'],
78
+ [(0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address, 120, 12]
79
+ ],
80
+ ];
81
+ examples.forEach(([expected, actual]) => {
82
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
83
+ (0, chai_1.expect)(triggerService_1.trailingStopTrigger.encode(...actual)).to.eql(expected);
84
+ });
85
+ });
86
+ });
87
+ describe('decode()', () => {
88
+ const examples = [
89
+ [
90
+ { tokenAddr: (0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address, triggerPercentage: 120, roundId: '10' },
91
+ ['0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000002cb417800000000000000000000000000000000000000000000000000000000000000000a'],
92
+ ],
93
+ [
94
+ { tokenAddr: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address), triggerPercentage: 120, roundId: '12' },
95
+ ['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000000000000000000000000000000000002cb417800000000000000000000000000000000000000000000000000000000000000000c'],
96
+ ],
97
+ ];
98
+ examples.forEach(([expected, actual]) => {
99
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
100
+ (0, chai_1.expect)(triggerService_1.trailingStopTrigger.decode(actual)).to.eql(expected);
101
+ });
102
+ });
103
+ });
104
+ });
105
+ describe('When testing triggerService.makerRatioTrigger', () => {
106
+ describe('encode()', () => {
107
+ const examples = [
108
+ [
109
+ ['0x0000000000000000000000000000000000000000000000000000000000000520000000000000000000000000000000000000000000000000122e0e0f2fc300000000000000000000000000000000000000000000000000000000000000000001'],
110
+ [1312, 131, enums_1.RatioState.UNDER]
111
+ ],
112
+ [
113
+ ['0x000000000000000000000000000000000000000000000000000000000000a455000000000000000000000000000000000000000000000000200ec4c2d72700000000000000000000000000000000000000000000000000000000000000000000'],
114
+ [42069, 231, enums_1.RatioState.OVER]
115
+ ],
116
+ ];
117
+ examples.forEach(([expected, actual]) => {
118
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
119
+ (0, chai_1.expect)(triggerService_1.makerRatioTrigger.encode(...actual)).to.eql(expected);
120
+ });
121
+ });
122
+ });
123
+ describe('decode()', () => {
124
+ const examples = [
125
+ [
126
+ { vaultId: 1312, ratioState: enums_1.RatioState.UNDER, ratio: 131 },
127
+ ['0x0000000000000000000000000000000000000000000000000000000000000520000000000000000000000000000000000000000000000000122e0e0f2fc300000000000000000000000000000000000000000000000000000000000000000001'],
128
+ ],
129
+ [
130
+ { vaultId: 42069, ratioState: enums_1.RatioState.OVER, ratio: 231 },
131
+ ['0x000000000000000000000000000000000000000000000000000000000000a455000000000000000000000000000000000000000000000000200ec4c2d72700000000000000000000000000000000000000000000000000000000000000000000'],
132
+ ],
133
+ ];
134
+ examples.forEach(([expected, actual]) => {
135
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
136
+ (0, chai_1.expect)(triggerService_1.makerRatioTrigger.decode(actual)).to.eql(expected);
137
+ });
138
+ });
139
+ });
140
+ });
141
+ describe('When testing triggerService.aaveV3RatioTrigger', () => {
142
+ describe('encode()', () => {
143
+ const examples = [
144
+ [
145
+ ['0x0000000000000000000000000039d218133afab8f2b819b1066c7e434ad94e9c0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000000'],
146
+ [web3Utils.toChecksumAddress('0x0039d218133AFaB8F2B819B1066c7E434Ad94E9c'), '0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e', 120, enums_1.RatioState.OVER]
147
+ ],
148
+ [
149
+ ['0x0000000000000000000000000039d218ff3afab8f2b819b1066c7e434ad94e9f000000000000000000000000a97684ead0e402dc232d5a977953df7ecbab3cdb0000000000000000000000000000000000000000000000002c8c35fe210100000000000000000000000000000000000000000000000000000000000000000001'],
150
+ [web3Utils.toChecksumAddress('0x0039d218ff3AFaB8F2B819B1066c7E434Ad94E9f'), '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb', 321, enums_1.RatioState.UNDER]
151
+ ],
152
+ ];
153
+ examples.forEach(([expected, actual]) => {
154
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
155
+ (0, chai_1.expect)(triggerService_1.aaveV3RatioTrigger.encode(...actual)).to.eql(expected);
156
+ });
157
+ });
158
+ });
159
+ describe('decode()', () => {
160
+ const examples = [
161
+ [
162
+ { owner: web3Utils.toChecksumAddress('0x0039d218133AFaB8F2B819B1066c7E434Ad94E9c'), market: '0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e', ratio: 120, ratioState: enums_1.RatioState.OVER },
163
+ ['0x0000000000000000000000000039d218133afab8f2b819b1066c7e434ad94e9c0000000000000000000000002f39d218133afab8f2b819b1066c7e434ad94e9e00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000000'],
164
+ ],
165
+ [
166
+ { owner: web3Utils.toChecksumAddress('0x0039d218ff3AFaB8F2B819B1066c7E434Ad94E9f'), market: '0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb', ratio: 321, ratioState: enums_1.RatioState.UNDER },
167
+ ['0x0000000000000000000000000039d218ff3afab8f2b819b1066c7e434ad94e9f000000000000000000000000a97684ead0e402dc232d5a977953df7ecbab3cdb0000000000000000000000000000000000000000000000002c8c35fe210100000000000000000000000000000000000000000000000000000000000000000001'],
168
+ ],
169
+ ];
170
+ examples.forEach(([expected, actual]) => {
171
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
172
+ (0, chai_1.expect)(triggerService_1.aaveV3RatioTrigger.decode(actual)).to.eql(expected);
173
+ });
174
+ });
175
+ });
176
+ });
177
+ describe('When testing triggerService.morphoAaveV2RatioTrigger', () => {
178
+ describe('encode()', () => {
179
+ const examples = [
180
+ [
181
+ ['0x0000000000000000000000000039d218133afab8f2b819b1066c7e434ad94e2c0000000000000000000000000000000000000000000000001eab7f4a799d00000000000000000000000000000000000000000000000000000000000000000001'],
182
+ [web3Utils.toChecksumAddress('0x0039d218133AFaB8F2B819B1066c7E434Ad94E2c'), 221, enums_1.RatioState.UNDER]
183
+ ],
184
+ [
185
+ ['0x0000000000000000000000000032d218133afab8f2b819b1066c7e434ad94e2c0000000000000000000000000000000000000000000000003d3377a2837900000000000000000000000000000000000000000000000000000000000000000000'],
186
+ [web3Utils.toChecksumAddress('0x0032d218133AFaB8F2B819B1066c7E434Ad94E2c'), 441, enums_1.RatioState.OVER]
187
+ ],
188
+ ];
189
+ examples.forEach(([expected, actual]) => {
190
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
191
+ (0, chai_1.expect)(triggerService_1.morphoAaveV2RatioTrigger.encode(...actual)).to.eql(expected);
192
+ });
193
+ });
194
+ });
195
+ describe('decode()', () => {
196
+ const examples = [
197
+ [
198
+ { owner: web3Utils.toChecksumAddress('0x0039d218133AFaB8F2B819B1066c7E434Ad94E2c'), ratio: 221, ratioState: enums_1.RatioState.UNDER },
199
+ ['0x0000000000000000000000000039d218133afab8f2b819b1066c7e434ad94e2c0000000000000000000000000000000000000000000000001eab7f4a799d00000000000000000000000000000000000000000000000000000000000000000001'],
200
+ ],
201
+ [
202
+ { owner: web3Utils.toChecksumAddress('0x0032d218133AFaB8F2B819B1066c7E434Ad94E2c'), ratio: 441, ratioState: enums_1.RatioState.OVER },
203
+ ['0x0000000000000000000000000032d218133afab8f2b819b1066c7e434ad94e2c0000000000000000000000000000000000000000000000003d3377a2837900000000000000000000000000000000000000000000000000000000000000000000'],
204
+ ],
205
+ ];
206
+ examples.forEach(([expected, actual]) => {
207
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
208
+ (0, chai_1.expect)(triggerService_1.morphoAaveV2RatioTrigger.decode(actual)).to.eql(expected);
209
+ });
210
+ });
211
+ });
212
+ });
213
+ describe('When testing triggerService.aaveV3QuotePriceTrigger', () => {
214
+ describe('encode()', () => {
215
+ const examples = [
216
+ [
217
+ ['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000009c400000000000000000000000000000000000000000000000000000000000000001'],
218
+ [(0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address, (0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address, 0.0004, enums_1.RatioState.UNDER]
219
+ ],
220
+ [
221
+ ['0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f000000000000000000000000fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000000'],
222
+ [(0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Arbitrum).address, (0, tokens_1.getAssetInfo)('USDT', enums_1.ChainId.Arbitrum).address, 0.00000023, enums_1.RatioState.OVER]
223
+ ],
224
+ ];
225
+ examples.forEach(([expected, actual]) => {
226
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
227
+ (0, chai_1.expect)(triggerService_1.aaveV3QuotePriceTrigger.encode(...actual)).to.eql(expected);
228
+ });
229
+ });
230
+ });
231
+ describe('decode()', () => {
232
+ const examples = [
233
+ [
234
+ {
235
+ baseTokenAddress: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
236
+ quoteTokenAddress: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
237
+ price: '0.0004',
238
+ ratioState: enums_1.RatioState.UNDER,
239
+ },
240
+ ['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000009c400000000000000000000000000000000000000000000000000000000000000001'],
241
+ ],
242
+ [
243
+ {
244
+ baseTokenAddress: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Arbitrum).address),
245
+ quoteTokenAddress: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDT', enums_1.ChainId.Arbitrum).address),
246
+ price: '0.00000023',
247
+ ratioState: enums_1.RatioState.OVER,
248
+ },
249
+ ['0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f000000000000000000000000fd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb900000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000000'],
250
+ ]
251
+ ];
252
+ examples.forEach(([expected, actual]) => {
253
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
254
+ (0, chai_1.expect)(triggerService_1.aaveV3QuotePriceTrigger.decode(actual)).to.eql(expected);
255
+ });
256
+ });
257
+ });
258
+ });
259
+ describe('When testing triggerService.aaveV3QuotePriceWithMaximumGasPriceTrigger', () => {
260
+ describe('encode()', () => {
261
+ const examples = [
262
+ [
263
+ [
264
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000009c400000000000000000000000000000000000000000000000000000000000000001',
265
+ '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
266
+ ],
267
+ [(0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address, (0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address, 0.0004, enums_1.RatioState.UNDER]
268
+ ],
269
+ [
270
+ [
271
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000000',
272
+ '0x00000000000000000000000000000000000000000000000000000002cb417800',
273
+ ],
274
+ [(0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address, (0, tokens_1.getAssetInfo)('USDT', enums_1.ChainId.Ethereum).address, 0.00000023, enums_1.RatioState.OVER, 12]
275
+ ],
276
+ ];
277
+ examples.forEach(([expected, actual]) => {
278
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
279
+ (0, chai_1.expect)(triggerService_1.aaveV3QuotePriceWithMaximumGasPriceTrigger.encode(...actual)).to.eql(expected);
280
+ });
281
+ });
282
+ });
283
+ describe('decode()', () => {
284
+ const examples = [
285
+ [
286
+ {
287
+ baseTokenAddress: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
288
+ quoteTokenAddress: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WETH', enums_1.ChainId.Ethereum).address),
289
+ price: '0.0004',
290
+ ratioState: enums_1.RatioState.UNDER,
291
+ maximumGasPrice: web3Utils.fromWei(tokens_1.MAXUINT, 'gwei')
292
+ },
293
+ [
294
+ '0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000009c400000000000000000000000000000000000000000000000000000000000000001',
295
+ '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
296
+ ],
297
+ ],
298
+ [
299
+ {
300
+ baseTokenAddress: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Ethereum).address),
301
+ quoteTokenAddress: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDT', enums_1.ChainId.Ethereum).address),
302
+ price: '0.00000023',
303
+ ratioState: enums_1.RatioState.OVER,
304
+ maximumGasPrice: '12',
305
+ },
306
+ [
307
+ '0x0000000000000000000000002260fac5e5542a773aa44fbcfedf7c193bc2c599000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec700000000000000000000000000000000000000000000000000000000000000170000000000000000000000000000000000000000000000000000000000000000',
308
+ '0x00000000000000000000000000000000000000000000000000000002cb417800',
309
+ ],
310
+ ]
311
+ ];
312
+ examples.forEach(([expected, actual]) => {
313
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
314
+ (0, chai_1.expect)(triggerService_1.aaveV3QuotePriceWithMaximumGasPriceTrigger.decode(actual)).to.eql(expected);
315
+ });
316
+ });
317
+ });
318
+ });
319
+ describe('When testing triggerService.liquityRatioTrigger', () => {
320
+ describe('encode()', () => {
321
+ const examples = [
322
+ [
323
+ ['0x0000000000000000000000000039d218133afab8f2b819b1066c7e434ad94e2c00000000000000000000000000000000000000000000000029c5ab0d65ed00000000000000000000000000000000000000000000000000000000000000000001'],
324
+ [web3Utils.toChecksumAddress('0x0039d218133AFaB8F2B819B1066c7E434Ad94E2c'), 301, enums_1.RatioState.UNDER]
325
+ ],
326
+ [
327
+ ['0x0000000000000000000000000039d218133afab832b819b1066c7e434ad94e2c000000000000000000000000000000000000000000000000122e0e0f2fc300000000000000000000000000000000000000000000000000000000000000000000'],
328
+ [web3Utils.toChecksumAddress('0x0039d218133AFaB832B819B1066c7E434Ad94E2c'), 131, enums_1.RatioState.OVER]
329
+ ],
330
+ ];
331
+ examples.forEach(([expected, actual]) => {
332
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
333
+ (0, chai_1.expect)(triggerService_1.compoundV2RatioTrigger.encode(...actual)).to.eql(expected);
334
+ });
335
+ });
336
+ });
337
+ describe('decode()', () => {
338
+ const examples = [
339
+ [
340
+ {
341
+ owner: web3Utils.toChecksumAddress('0x0039d218133AFaB8F2B819B1066c7E434Ad94E2c'),
342
+ ratio: 301,
343
+ ratioState: enums_1.RatioState.UNDER,
344
+ },
345
+ ['0x0000000000000000000000000039d218133afab8f2b819b1066c7e434ad94e2c00000000000000000000000000000000000000000000000029c5ab0d65ed00000000000000000000000000000000000000000000000000000000000000000001'],
346
+ ],
347
+ [
348
+ {
349
+ owner: web3Utils.toChecksumAddress('0x0039d218133AFaB832B819B1066c7E434Ad94E2c'),
350
+ ratio: 131,
351
+ ratioState: enums_1.RatioState.OVER,
352
+ },
353
+ ['0x0000000000000000000000000039d218133afab832b819b1066c7e434ad94e2c000000000000000000000000000000000000000000000000122e0e0f2fc300000000000000000000000000000000000000000000000000000000000000000000'],
354
+ ],
355
+ ];
356
+ examples.forEach(([expected, actual]) => {
357
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
358
+ (0, chai_1.expect)(triggerService_1.compoundV2RatioTrigger.decode(actual)).to.eql(expected);
359
+ });
360
+ });
361
+ });
362
+ });
363
+ describe('When testing triggerService.liquityDebtInFrontTrigger', () => {
364
+ describe('encode()', () => {
365
+ const examples = [
366
+ [
367
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000006e0be8c4995af80000'],
368
+ [web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'), '2030']
369
+ ],
370
+ [
371
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000004697f83e6356dd440000'],
372
+ [web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'), '333369']
373
+ ],
374
+ [
375
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf000000000000000000000000000000000000000000084595161401484a000000'],
376
+ [web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'), '10000000']
377
+ ],
378
+ [
379
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf0000000000000000000000000000000000000000000000000000000000989680'],
380
+ [web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'), '0.00000000001']
381
+ ],
382
+ [
383
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a0000000000000000000000000000000000000000019d971e4fe8401e74000000'],
384
+ [web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '500000000']
385
+ ],
386
+ [
387
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a00000000000000000000000000000000000000000001a784379d99db42000000'],
388
+ [web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'), '2000000']
389
+ ],
390
+ ];
391
+ examples.forEach(([expected, actual]) => {
392
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
393
+ (0, chai_1.expect)(triggerService_1.liquityDebtInFrontTrigger.encode(...actual)).to.eql(expected);
394
+ (0, chai_1.expect)(triggerService_1.liquityDebtInFrontWithLimitTrigger.encode(...actual)).to.eql(expected);
395
+ });
396
+ });
397
+ });
398
+ describe('decode()', () => {
399
+ const examples = [
400
+ [
401
+ {
402
+ owner: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'),
403
+ debtInFrontMin: '2030',
404
+ },
405
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000006e0be8c4995af80000'],
406
+ ],
407
+ [
408
+ {
409
+ owner: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434A192E2c'),
410
+ debtInFrontMin: '333369',
411
+ },
412
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434a192e2c000000000000000000000000000000000000000000004697f83e6356dd440000'],
413
+ ],
414
+ [
415
+ {
416
+ owner: web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'),
417
+ debtInFrontMin: '10000000',
418
+ },
419
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf000000000000000000000000000000000000000000084595161401484a000000'],
420
+ ],
421
+ [
422
+ {
423
+ owner: web3Utils.toChecksumAddress('0x30462AD9D8F01A20A2EC7E7F1A8F1B303662AEBF'),
424
+ debtInFrontMin: '0.00000000001',
425
+ },
426
+ ['0x00000000000000000000000030462ad9d8f01a20a2ec7e7f1a8f1b303662aebf0000000000000000000000000000000000000000000000000000000000989680'],
427
+ ],
428
+ [
429
+ {
430
+ owner: web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'),
431
+ debtInFrontMin: '500000000',
432
+ },
433
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a0000000000000000000000000000000000000000019d971e4fe8401e74000000'],
434
+ ],
435
+ [
436
+ {
437
+ owner: web3Utils.toChecksumAddress('0x235d6A8DB3C57c3f7b4ebA749E1738Db6093732a'),
438
+ debtInFrontMin: '2000000',
439
+ },
440
+ ['0x000000000000000000000000235d6a8db3c57c3f7b4eba749e1738db6093732a00000000000000000000000000000000000000000001a784379d99db42000000'],
441
+ ],
442
+ ];
443
+ examples.forEach(([expected, actual]) => {
444
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
445
+ (0, chai_1.expect)(triggerService_1.liquityDebtInFrontTrigger.decode(actual)).to.eql(expected);
446
+ (0, chai_1.expect)(triggerService_1.liquityDebtInFrontWithLimitTrigger.decode(actual)).to.eql(expected);
447
+ });
448
+ });
449
+ });
450
+ });
451
+ describe('When testing triggerService.aaveV2RatioTrigger', () => {
452
+ describe('encode()', () => {
453
+ const examples = [
454
+ [
455
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c0000000000000000000000000249d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000000'],
456
+ [web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'), web3Utils.toChecksumAddress('0x0249d218133AFaB8F2B829B1066c7E434Ad94E2c'), 120, enums_1.RatioState.OVER]
457
+ ],
458
+ ];
459
+ examples.forEach(([expected, actual]) => {
460
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
461
+ (0, chai_1.expect)(triggerService_1.aaveV2RatioTrigger.encode(...actual)).to.eql(expected);
462
+ });
463
+ });
464
+ });
465
+ describe('decode()', () => {
466
+ const examples = [
467
+ [
468
+ {
469
+ owner: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B1066c7E434Ad94E2c'),
470
+ market: web3Utils.toChecksumAddress('0x0249d218133AFaB8F2B829B1066c7E434Ad94E2c'),
471
+ ratio: 120,
472
+ ratioState: enums_1.RatioState.OVER,
473
+ },
474
+ ['0x0000000000000000000000000049d218133afab8f2b829b1066c7e434ad94e2c0000000000000000000000000249d218133afab8f2b829b1066c7e434ad94e2c00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000000'],
475
+ ],
476
+ ];
477
+ examples.forEach(([expected, actual]) => {
478
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
479
+ (0, chai_1.expect)(triggerService_1.aaveV2RatioTrigger.decode(actual)).to.eql(expected);
480
+ });
481
+ });
482
+ });
483
+ });
484
+ describe('When testing triggerService.cBondsRebondTrigger', () => {
485
+ describe('encode()', () => {
486
+ const examples = [
487
+ [
488
+ ['0x0000000000000000000000000000000000000000000000000000000000000141'],
489
+ [321]
490
+ ],
491
+ [
492
+ ['0x000000000000000000000000000000000000000000000000000000000000002c'],
493
+ [44]
494
+ ],
495
+ ];
496
+ examples.forEach(([expected, actual]) => {
497
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
498
+ (0, chai_1.expect)(triggerService_1.cBondsRebondTrigger.encode(...actual)).to.eql(expected);
499
+ });
500
+ });
501
+ });
502
+ describe('decode()', () => {
503
+ const examples = [
504
+ [
505
+ { bondId: '321' },
506
+ ['0x0000000000000000000000000000000000000000000000000000000000000141'],
507
+ ],
508
+ [
509
+ { bondId: '44' },
510
+ ['0x000000000000000000000000000000000000000000000000000000000000002c'],
511
+ ],
512
+ ];
513
+ examples.forEach(([expected, actual]) => {
514
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
515
+ (0, chai_1.expect)(triggerService_1.cBondsRebondTrigger.decode(actual)).to.eql(expected);
516
+ });
517
+ });
518
+ });
519
+ });
520
+ describe('When testing triggerService.compoundV3RatioTrigger', () => {
521
+ describe('encode()', () => {
522
+ const examples = [
523
+ [
524
+ ['0x0000000000000000000000000049d218133afab8f2b829b106633e434ad94e2c0000000000000000000000000213d218133afab8f2b829b1066c7e43cad94e2c000000000000000000000000000000000000000000000000245c1c1e5f8600000000000000000000000000000000000000000000000000000000000000000000'],
525
+ [web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B106633E434Ad94E2c'), web3Utils.toChecksumAddress('0x0213d218133AFaB8F2B829B1066c7E43cAd94E2c'), 262, enums_1.RatioState.OVER]
526
+ ],
527
+ [
528
+ ['0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c0000000000000000000000000213d212133afab8f2b829b1066c7e43cad94e2c0000000000000000000000000000000000000000000000002def7b767e8b00000000000000000000000000000000000000000000000000000000000000000001'],
529
+ [web3Utils.toChecksumAddress('0x0043d218133AFaB8F2B829B106633E434Ad94E2c'), web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'), 331, enums_1.RatioState.UNDER]
530
+ ],
531
+ ];
532
+ examples.forEach(([expected, actual]) => {
533
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
534
+ (0, chai_1.expect)(triggerService_1.compoundV3RatioTrigger.encode(...actual)).to.eql(expected);
535
+ });
536
+ });
537
+ });
538
+ describe('decode()', () => {
539
+ const examples = [
540
+ [
541
+ {
542
+ owner: web3Utils.toChecksumAddress('0x0049d218133AFaB8F2B829B106633E434Ad94E2c'),
543
+ market: web3Utils.toChecksumAddress('0x0213d218133AFaB8F2B829B1066c7E43cAd94E2c'),
544
+ ratio: 262,
545
+ ratioState: enums_1.RatioState.OVER,
546
+ },
547
+ ['0x0000000000000000000000000049d218133afab8f2b829b106633e434ad94e2c0000000000000000000000000213d218133afab8f2b829b1066c7e43cad94e2c000000000000000000000000000000000000000000000000245c1c1e5f8600000000000000000000000000000000000000000000000000000000000000000000'],
548
+ ],
549
+ [
550
+ {
551
+ owner: web3Utils.toChecksumAddress('0x0043d218133AFaB8F2B829B106633E434Ad94E2c'),
552
+ market: web3Utils.toChecksumAddress('0x0213d212133AFaB8F2B829B1066c7E43cAd94E2c'),
553
+ ratio: 331,
554
+ ratioState: enums_1.RatioState.UNDER,
555
+ },
556
+ ['0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c0000000000000000000000000213d212133afab8f2b829b1066c7e43cad94e2c0000000000000000000000000000000000000000000000002def7b767e8b00000000000000000000000000000000000000000000000000000000000000000001'],
557
+ ],
558
+ ];
559
+ examples.forEach(([expected, actual]) => {
560
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
561
+ (0, chai_1.expect)(triggerService_1.compoundV3RatioTrigger.decode(actual)).to.eql(expected);
562
+ });
563
+ });
564
+ });
565
+ });
566
+ describe('When testing triggerService.exchangeTimestampTrigger', () => {
567
+ describe('encode()', () => {
568
+ const examples = [
569
+ [
570
+ ['0x0000000000000000000000000000000000000000000000000000018adbcdf3c10000000000000000000000000000000000000000000000000000000077359fb8'],
571
+ [1695904822209, 2000003000]
572
+ ],
573
+ [
574
+ ['0x00000000000000000000000000000000000000000000000000000189ed59a4010000000000000000000000000000000000000000000000000000000011e378b8'],
575
+ [1691904222209, 300120248]
576
+ ],
577
+ ];
578
+ examples.forEach(([expected, actual]) => {
579
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
580
+ (0, chai_1.expect)(triggerService_1.exchangeTimestampTrigger.encode(...actual)).to.eql(expected);
581
+ });
582
+ });
583
+ });
584
+ describe('decode()', () => {
585
+ const examples = [
586
+ [
587
+ {
588
+ timestamp: 1695904822209, interval: 2000003000,
589
+ },
590
+ ['0x0000000000000000000000000000000000000000000000000000018adbcdf3c10000000000000000000000000000000000000000000000000000000077359fb8'],
591
+ ],
592
+ [
593
+ {
594
+ timestamp: 1691904222209, interval: 300120248,
595
+ },
596
+ ['0x00000000000000000000000000000000000000000000000000000189ed59a4010000000000000000000000000000000000000000000000000000000011e378b8'],
597
+ ],
598
+ ];
599
+ examples.forEach(([expected, actual]) => {
600
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
601
+ (0, chai_1.expect)(triggerService_1.exchangeTimestampTrigger.decode(actual)).to.eql(expected);
602
+ });
603
+ });
604
+ });
605
+ });
606
+ describe('When testing triggerService.exchangeOffchainPriceTrigger', () => {
607
+ describe('encode()', () => {
608
+ const examples = [
609
+ [
610
+ ['0x00000000000000000000000000000000000000000000000001b4fbd92b5f80000000000000000000000000000000000000000000000000000000018adbcdf3c10000000000000000000000000000000000000000000000000000000000000000'],
611
+ ['0.123', 1695904822209, enums_1.OrderType.TAKE_PROFIT, 12, 12]
612
+ ],
613
+ [
614
+ ['0x00000000000000000000000000000000000000000000000000000000003432120000000000000000000000000000000000000000000000000000018adbbead990000000000000000000000000000000000000000000000000000000000000001'],
615
+ ['3.42069', 1695903821209, enums_1.OrderType.STOP_LOSS, 18, 6]
616
+ ],
617
+ ];
618
+ examples.forEach(([expected, actual]) => {
619
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
620
+ (0, chai_1.expect)(triggerService_1.exchangeOffchainPriceTrigger.encode(...actual)).to.eql(expected);
621
+ });
622
+ });
623
+ });
624
+ describe('decode()', () => {
625
+ const examples = [
626
+ [
627
+ {
628
+ orderType: enums_1.OrderType.TAKE_PROFIT, targetPrice: '0.123', goodUntil: 1695904822209,
629
+ },
630
+ [
631
+ ['0x00000000000000000000000000000000000000000000000001b4fbd92b5f80000000000000000000000000000000000000000000000000000000018adbcdf3c10000000000000000000000000000000000000000000000000000000000000000'],
632
+ 12,
633
+ 12,
634
+ ],
635
+ ],
636
+ [
637
+ {
638
+ orderType: enums_1.OrderType.STOP_LOSS, targetPrice: '3.42069', goodUntil: 1695903821209,
639
+ },
640
+ [
641
+ ['0x00000000000000000000000000000000000000000000000000000000003432120000000000000000000000000000000000000000000000000000018adbbead990000000000000000000000000000000000000000000000000000000000000001'],
642
+ 18,
643
+ 6,
644
+ ],
645
+ ],
646
+ ];
647
+ examples.forEach(([expected, actual]) => {
648
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
649
+ (0, chai_1.expect)(triggerService_1.exchangeOffchainPriceTrigger.decode(...actual)).to.eql(expected);
650
+ });
651
+ });
652
+ });
653
+ });
654
+ describe('When testing triggerService.sparkRatioTrigger', () => {
655
+ describe('encode()', () => {
656
+ const examples = [
657
+ [
658
+ ['0x0000000000000000000000000031d218133afab8f2b819b1066c7e434ad94e9c0000000000000000000000001131d218133afab8f2b819b1066c7e434ad94e9c00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001'],
659
+ [web3Utils.toChecksumAddress('0x0031d218133AFaB8F2B819B1066c7E434Ad94E9c'), web3Utils.toChecksumAddress('0x1131d218133AFaB8F2B819B1066c7E434Ad94E9c'), 120, enums_1.RatioState.UNDER]
660
+ ],
661
+ [
662
+ ['0x0000000000000000000000000231d218133afab8f2b819b1066c7e434ad94e9c0000000000000000000000000131d218133afab8f2b819b1066c7e434ad94e9c000000000000000000000000000000000000000000000000200ec4c2d72700000000000000000000000000000000000000000000000000000000000000000000'],
663
+ [web3Utils.toChecksumAddress('0x0231d218133AFaB8F2B819B1066c7E434Ad94E9c'), web3Utils.toChecksumAddress('0x0131d218133AFaB8F2B819B1066c7E434Ad94E9c'), 231, enums_1.RatioState.OVER]
664
+ ],
665
+ ];
666
+ examples.forEach(([expected, actual]) => {
667
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
668
+ (0, chai_1.expect)(triggerService_1.sparkRatioTrigger.encode(...actual)).to.eql(expected);
669
+ });
670
+ });
671
+ });
672
+ describe('decode()', () => {
673
+ const examples = [
674
+ [
675
+ { owner: web3Utils.toChecksumAddress('0x0031d218133AFaB8F2B819B1066c7E434Ad94E9c'), market: web3Utils.toChecksumAddress('0x1131d218133AFaB8F2B819B1066c7E434Ad94E9c'), ratio: 120, ratioState: enums_1.RatioState.UNDER },
676
+ ['0x0000000000000000000000000031d218133afab8f2b819b1066c7e434ad94e9c0000000000000000000000001131d218133afab8f2b819b1066c7e434ad94e9c00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001'],
677
+ ],
678
+ [
679
+ { owner: web3Utils.toChecksumAddress('0x0231d218133AFaB8F2B819B1066c7E434Ad94E9c'), market: web3Utils.toChecksumAddress('0x0131d218133AFaB8F2B819B1066c7E434Ad94E9c'), ratio: 231, ratioState: enums_1.RatioState.OVER },
680
+ ['0x0000000000000000000000000231d218133afab8f2b819b1066c7e434ad94e9c0000000000000000000000000131d218133afab8f2b819b1066c7e434ad94e9c000000000000000000000000000000000000000000000000200ec4c2d72700000000000000000000000000000000000000000000000000000000000000000000'],
681
+ ],
682
+ ];
683
+ examples.forEach(([expected, actual]) => {
684
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
685
+ (0, chai_1.expect)(triggerService_1.sparkRatioTrigger.decode(actual)).to.eql(expected);
686
+ });
687
+ });
688
+ });
689
+ });
690
+ describe('When testing triggerService.sparkQuotePriceTrigger', () => {
691
+ describe('encode()', () => {
692
+ const examples = [
693
+ [
694
+ ['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000000000000000000000000000000000000000a8ca0000000000000000000000000000000000000000000000000000000000000001'],
695
+ [(0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address, (0, tokens_1.getAssetInfo)('wstETH', enums_1.ChainId.Ethereum).address, 0.0004321, enums_1.RatioState.UNDER]
696
+ ],
697
+ [
698
+ ['0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000186b70000000000000000000000000000000000000000000000000000000000000000'],
699
+ [(0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Arbitrum).address, (0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address, 0.00100023, enums_1.RatioState.OVER]
700
+ ],
701
+ ];
702
+ examples.forEach(([expected, actual]) => {
703
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
704
+ (0, chai_1.expect)(triggerService_1.sparkQuotePriceTrigger.encode(...actual)).to.eql(expected);
705
+ });
706
+ });
707
+ });
708
+ describe('decode()', () => {
709
+ const examples = [
710
+ [
711
+ {
712
+ baseTokenAddress: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('DAI', enums_1.ChainId.Ethereum).address),
713
+ quoteTokenAddress: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('wstETH', enums_1.ChainId.Ethereum).address),
714
+ price: '0.0004321',
715
+ ratioState: enums_1.RatioState.UNDER,
716
+ },
717
+ ['0x0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0000000000000000000000000000000000000000000000000000000000000a8ca0000000000000000000000000000000000000000000000000000000000000001'],
718
+ ],
719
+ [
720
+ {
721
+ baseTokenAddress: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('WBTC', enums_1.ChainId.Arbitrum).address),
722
+ quoteTokenAddress: web3Utils.toChecksumAddress((0, tokens_1.getAssetInfo)('USDC', enums_1.ChainId.Arbitrum).address),
723
+ price: '0.00100023',
724
+ ratioState: enums_1.RatioState.OVER,
725
+ },
726
+ ['0x0000000000000000000000002f2a2543b76a4166549f7aab2e75bef0aefc5b0f000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e583100000000000000000000000000000000000000000000000000000000000186b70000000000000000000000000000000000000000000000000000000000000000'],
727
+ ]
728
+ ];
729
+ examples.forEach(([expected, actual]) => {
730
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
731
+ (0, chai_1.expect)(triggerService_1.sparkQuotePriceTrigger.decode(actual)).to.eql(expected);
732
+ });
733
+ });
734
+ });
735
+ });
736
+ describe('When testing triggerService.curveUsdBorrowRateTrigger', () => {
737
+ describe('encode()', () => {
738
+ const examples = [
739
+ [
740
+ ['0x0000000000000000000000000031d218133afab8c2b819b1066c7e434ad91e9c000000000000000000000000000000000000000000000000000000005c3744c40000000000000000000000000000000000000000000000000000000000000001'],
741
+ [web3Utils.toChecksumAddress('0x0031d218133AFaB8c2B819B1066c7E434Ad91E9c'), '5', enums_1.RatioState.UNDER]
742
+ ],
743
+ [
744
+ ['0x0000000000000000000000000031d318133afab8c2b819b1066c7e434ad91e9c0000000000000000000000000000000000000000000000000000000037de1dae0000000000000000000000000000000000000000000000000000000000000000'],
745
+ [web3Utils.toChecksumAddress('0x0031d318133AFaB8c2B819B1066c7E434Ad91E9c'), '3', enums_1.RatioState.OVER]
746
+ ],
747
+ ];
748
+ examples.forEach(([expected, actual]) => {
749
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
750
+ (0, chai_1.expect)(triggerService_1.curveUsdBorrowRateTrigger.encode(...actual)).to.eql(expected);
751
+ });
752
+ });
753
+ });
754
+ describe('decode()', () => {
755
+ const examples = [
756
+ [
757
+ {
758
+ market: web3Utils.toChecksumAddress('0x0031d218133AFaB8c2B819B1066c7E434Ad91E9c'),
759
+ // Because of precision of reverse engineered rate we can't get exact number
760
+ targetRate: '4.9999999977932344260462314517997495470601974794180145018256513213117735079327887085499910715825462',
761
+ rateState: enums_1.RatioState.UNDER,
762
+ },
763
+ ['0x0000000000000000000000000031d218133afab8c2b819b1066c7e434ad91e9c000000000000000000000000000000000000000000000000000000005c3744c40000000000000000000000000000000000000000000000000000000000000001'],
764
+ ],
765
+ [
766
+ {
767
+ market: web3Utils.toChecksumAddress('0x0031d318133AFaB8c2B819B1066c7E434Ad91E9c'),
768
+ // Because of precision of reverse engineered rate we can't get exact number
769
+ targetRate: '2.999999998802635853596007720123861222767915626254160712723033189270277420764438661596057080730334',
770
+ rateState: enums_1.RatioState.OVER,
771
+ },
772
+ ['0x0000000000000000000000000031d318133afab8c2b819b1066c7e434ad91e9c0000000000000000000000000000000000000000000000000000000037de1dae0000000000000000000000000000000000000000000000000000000000000000'],
773
+ ],
774
+ ];
775
+ examples.forEach(([expected, actual]) => {
776
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
777
+ (0, chai_1.expect)(triggerService_1.curveUsdBorrowRateTrigger.decode(actual)).to.eql(expected);
778
+ });
779
+ });
780
+ });
781
+ });
782
+ describe('When testing triggerService.curveUsdSoftLiquidationTrigger', () => {
783
+ describe('encode()', () => {
784
+ const examples = [
785
+ [
786
+ ['0x0000000000000000000000000031d218133afab8c2a819b1066c7e434ad91e9c0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c00000000000000000000000000000000000000000000000000b1a2bc2ec50000'],
787
+ [web3Utils.toChecksumAddress('0x0031d218133AFaB8c2a819B1066c7E434Ad91E9c'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), '5']
788
+ ],
789
+ [
790
+ ['0x0000000000000000000000000031d218233afab8c2a819b1066c7e434ad91e9c0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000000000000000000000000000001298a2e67f060000'],
791
+ [web3Utils.toChecksumAddress('0x0031d218233AFaB8c2a819B1066c7E434Ad91E9c'), web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), '134']
792
+ ],
793
+ ];
794
+ examples.forEach(([expected, actual]) => {
795
+ it(`Given ${actual} should return expected value: ${expected}`, () => {
796
+ (0, chai_1.expect)(triggerService_1.curveUsdSoftLiquidationTrigger.encode(...actual)).to.eql(expected);
797
+ });
798
+ });
799
+ });
800
+ describe('decode()', () => {
801
+ const examples = [
802
+ [
803
+ {
804
+ market: web3Utils.toChecksumAddress('0x0031d218133AFaB8c2a819B1066c7E434Ad91E9c'),
805
+ owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
806
+ percentage: '5',
807
+ },
808
+ ['0x0000000000000000000000000031d218133afab8c2a819b1066c7e434ad91e9c0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c00000000000000000000000000000000000000000000000000b1a2bc2ec50000'],
809
+ ],
810
+ [
811
+ {
812
+ market: web3Utils.toChecksumAddress('0x0031d218233AFaB8c2a819B1066c7E434Ad91E9c'),
813
+ owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'),
814
+ percentage: '134',
815
+ },
816
+ ['0x0000000000000000000000000031d218233afab8c2a819b1066c7e434ad91e9c0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c0000000000000000000000000000000000000000000000001298a2e67f060000'],
817
+ ],
818
+ ];
819
+ examples.forEach(([expected, actual]) => {
820
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
821
+ (0, chai_1.expect)(triggerService_1.curveUsdSoftLiquidationTrigger.decode(actual)).to.eql(expected);
822
+ });
823
+ });
824
+ });
825
+ });
826
+ describe('When testing triggerService.crvUSDRatioTrigger', () => {
827
+ describe('encode()', () => {
828
+ const examples = [
829
+ [
830
+ ['0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d421963500000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001'],
831
+ [web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), web3Utils.toChecksumAddress('0xa920de414ea4ab66b97da1bfe9e6eca7d4219635'), 120, enums_1.RatioState.UNDER]
832
+ ],
833
+ [
834
+ ['0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d42196350000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
835
+ [web3Utils.toChecksumAddress('0x0043d218133AFaB8F2B829B106633E434Ad94E2c'), web3Utils.toChecksumAddress('0xa920de414ea4ab66b97da1bfe9e6eca7d4219635'), 200, enums_1.RatioState.OVER]
836
+ ],
837
+ ];
838
+ examples.forEach(([expected, actual]) => {
839
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
840
+ (0, chai_1.expect)(triggerService_1.crvUSDRatioTrigger.encode(...actual)).to.eql(expected);
841
+ });
842
+ });
843
+ });
844
+ describe('decode()', () => {
845
+ const examples = [
846
+ [
847
+ { owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), controller: web3Utils.toChecksumAddress('0xa920de414ea4ab66b97da1bfe9e6eca7d4219635'), ratio: 120, ratioState: enums_1.RatioState.UNDER },
848
+ ['0x0000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d421963500000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001'],
849
+ ],
850
+ [
851
+ { owner: web3Utils.toChecksumAddress('0x0043d218133AFaB8F2B829B106633E434Ad94E2c'), controller: web3Utils.toChecksumAddress('0xa920de414ea4ab66b97da1bfe9e6eca7d4219635'), ratio: 200, ratioState: enums_1.RatioState.OVER },
852
+ ['0x0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d42196350000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
853
+ ],
854
+ ];
855
+ examples.forEach(([expected, actual]) => {
856
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
857
+ (0, chai_1.expect)(triggerService_1.crvUSDRatioTrigger.decode(actual)).to.eql(expected);
858
+ });
859
+ });
860
+ });
861
+ });
862
+ describe('When testing triggerService.crvUsdHealthRatioTrigger', () => {
863
+ describe('encode()', () => {
864
+ const examples = [
865
+ [
866
+ ['0x0000000000000000000000007a2af22ba3276108cd331c8985ef9528e10a871a000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d421963500000000000000000000000000000000000000000000000002c68af0bb140000'],
867
+ [web3Utils.toChecksumAddress('0x7a2af22ba3276108cd331c8985ef9528e10a871a'), web3Utils.toChecksumAddress('0xa920de414ea4ab66b97da1bfe9e6eca7d4219635'), 20]
868
+ ]
869
+ ];
870
+ examples.forEach(([expected, actual]) => {
871
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
872
+ (0, chai_1.expect)(triggerService_1.crvUsdHealthRatioTrigger.encode(...actual)).to.eql(expected);
873
+ });
874
+ });
875
+ });
876
+ describe('decode()', () => {
877
+ const examples = [
878
+ [
879
+ { owner: web3Utils.toChecksumAddress('0x7a2af22ba3276108cd331c8985ef9528e10a871a'), controller: web3Utils.toChecksumAddress('0xa920de414ea4ab66b97da1bfe9e6eca7d4219635'), ratio: 20 },
880
+ ['0x0000000000000000000000007a2af22ba3276108cd331c8985ef9528e10a871a000000000000000000000000a920de414ea4ab66b97da1bfe9e6eca7d421963500000000000000000000000000000000000000000000000002c68af0bb140000'],
881
+ ],
882
+ ];
883
+ examples.forEach(([expected, actual]) => {
884
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
885
+ (0, chai_1.expect)(triggerService_1.crvUsdHealthRatioTrigger.decode(actual)).to.eql(expected);
886
+ });
887
+ });
888
+ });
889
+ });
890
+ describe('When testing triggerService.morphoBlueRatioTrigger', () => {
891
+ describe('encode()', () => {
892
+ const examples = [
893
+ [
894
+ ['0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec410000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001'],
895
+ ['0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec41', web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), 120, enums_1.RatioState.UNDER]
896
+ ],
897
+ [
898
+ ['0xb323495f7e4148be5643a4ea4a8221eef163e4bccfdedc2a6f4696baacbc86cc0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
899
+ ['0xb323495f7e4148be5643a4ea4a8221eef163e4bccfdedc2a6f4696baacbc86cc', web3Utils.toChecksumAddress('0x0043d218133AFaB8F2B829B106633E434Ad94E2c'), 200, enums_1.RatioState.OVER]
900
+ ],
901
+ ];
902
+ examples.forEach(([expected, actual]) => {
903
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
904
+ (0, chai_1.expect)(triggerService_1.morphoBlueRatioTrigger.encode(...actual)).to.eql(expected);
905
+ });
906
+ });
907
+ });
908
+ describe('decode()', () => {
909
+ const examples = [
910
+ [
911
+ { marketId: '0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec41', owner: web3Utils.toChecksumAddress('0x1031d218133AFaB8c2B819B1366c7E434Ad91E9c'), ratio: 120, ratioState: enums_1.RatioState.UNDER },
912
+ ['0xc54d7acf14de29e0e5527cabd7a576506870346a78a11a6762e2cca66322ec410000000000000000000000001031d218133afab8c2b819b1366c7e434ad91e9c00000000000000000000000000000000000000000000000010a741a4627800000000000000000000000000000000000000000000000000000000000000000001'],
913
+ ],
914
+ [
915
+ { marketId: '0xb323495f7e4148be5643a4ea4a8221eef163e4bccfdedc2a6f4696baacbc86cc', owner: web3Utils.toChecksumAddress('0x0043d218133AFaB8F2B829B106633E434Ad94E2c'), ratio: 200, ratioState: enums_1.RatioState.OVER },
916
+ ['0xb323495f7e4148be5643a4ea4a8221eef163e4bccfdedc2a6f4696baacbc86cc0000000000000000000000000043d218133afab8f2b829b106633e434ad94e2c0000000000000000000000000000000000000000000000001bc16d674ec800000000000000000000000000000000000000000000000000000000000000000000'],
917
+ ],
918
+ ];
919
+ examples.forEach(([expected, actual]) => {
920
+ it(`Given ${actual} should return expected value: ${JSON.stringify(expected)}`, () => {
921
+ (0, chai_1.expect)(triggerService_1.morphoBlueRatioTrigger.decode(actual)).to.eql(expected);
922
+ });
923
+ });
924
+ });
925
+ });
926
+ });