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

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