@keep-network/tbtc-v2 0.1.0 → 0.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 (296) hide show
  1. package/README.adoc +12 -0
  2. package/artifacts/.chainId +1 -1
  3. package/artifacts/Bank.json +807 -0
  4. package/artifacts/Bridge.json +2300 -0
  5. package/artifacts/Deposit.json +117 -0
  6. package/artifacts/DepositSweep.json +77 -0
  7. package/artifacts/EcdsaDkgValidator.json +532 -0
  8. package/artifacts/EcdsaInactivity.json +156 -0
  9. package/artifacts/EcdsaSortitionPool.json +1004 -0
  10. package/artifacts/Fraud.json +164 -0
  11. package/artifacts/KeepRegistry.json +99 -0
  12. package/artifacts/KeepStake.json +286 -0
  13. package/artifacts/KeepToken.json +711 -0
  14. package/artifacts/KeepTokenStaking.json +483 -0
  15. package/artifacts/MovingFunds.json +249 -0
  16. package/artifacts/NuCypherStakingEscrow.json +256 -0
  17. package/artifacts/NuCypherToken.json +711 -0
  18. package/artifacts/RandomBeaconStub.json +141 -0
  19. package/artifacts/Redemption.json +174 -0
  20. package/artifacts/ReimbursementPool.json +509 -0
  21. package/artifacts/Relay.json +123 -0
  22. package/artifacts/T.json +1148 -0
  23. package/artifacts/TBTC.json +36 -35
  24. package/artifacts/TBTCToken.json +738 -0
  25. package/artifacts/TBTCVault.json +691 -0
  26. package/artifacts/TokenStaking.json +2288 -0
  27. package/artifacts/TokenholderGovernor.json +1795 -0
  28. package/artifacts/TokenholderTimelock.json +1058 -0
  29. package/artifacts/VendingMachine.json +34 -33
  30. package/artifacts/VendingMachineKeep.json +400 -0
  31. package/artifacts/VendingMachineNuCypher.json +400 -0
  32. package/artifacts/WalletRegistry.json +1843 -0
  33. package/artifacts/WalletRegistryGovernance.json +2754 -0
  34. package/artifacts/Wallets.json +186 -0
  35. package/artifacts/solcInputs/5e62cff1ead0900b07facca4b559e818.json +314 -0
  36. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
  37. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.json +2 -2
  38. package/build/contracts/bank/Bank.sol/Bank.dbg.json +4 -0
  39. package/build/contracts/bank/Bank.sol/Bank.json +542 -0
  40. package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.dbg.json +4 -0
  41. package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.json +34 -0
  42. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +4 -0
  43. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +10 -0
  44. package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +4 -0
  45. package/build/contracts/bridge/Bridge.sol/Bridge.json +2686 -0
  46. package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +4 -0
  47. package/build/contracts/bridge/BridgeState.sol/BridgeState.json +226 -0
  48. package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +4 -0
  49. package/build/contracts/bridge/Deposit.sol/Deposit.json +72 -0
  50. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +4 -0
  51. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.json +30 -0
  52. package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +4 -0
  53. package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.json +10 -0
  54. package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +4 -0
  55. package/build/contracts/bridge/Fraud.sol/Fraud.json +86 -0
  56. package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +4 -0
  57. package/build/contracts/bridge/Heartbeat.sol/Heartbeat.json +10 -0
  58. package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +4 -0
  59. package/build/contracts/bridge/IRelay.sol/IRelay.json +37 -0
  60. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +4 -0
  61. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +138 -0
  62. package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +4 -0
  63. package/build/contracts/bridge/Redemption.sol/OutboundTx.json +10 -0
  64. package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +4 -0
  65. package/build/contracts/bridge/Redemption.sol/Redemption.json +92 -0
  66. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
  67. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.json +2 -2
  68. package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +4 -0
  69. package/build/contracts/bridge/Wallets.sol/Wallets.json +112 -0
  70. package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
  71. package/build/contracts/token/TBTC.sol/TBTC.json +4 -4
  72. package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +4 -0
  73. package/build/contracts/vault/DonationVault.sol/DonationVault.json +108 -0
  74. package/build/contracts/vault/IVault.sol/IVault.dbg.json +4 -0
  75. package/build/contracts/vault/IVault.sol/IVault.json +52 -0
  76. package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +4 -0
  77. package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +449 -0
  78. package/contracts/GovernanceUtils.sol +4 -4
  79. package/contracts/bank/Bank.sol +436 -0
  80. package/contracts/bank/IReceiveBalanceApproval.sol +45 -0
  81. package/contracts/bridge/BitcoinTx.sol +326 -0
  82. package/contracts/bridge/Bridge.sol +1793 -0
  83. package/contracts/bridge/BridgeState.sol +739 -0
  84. package/contracts/bridge/Deposit.sol +269 -0
  85. package/contracts/bridge/DepositSweep.sol +574 -0
  86. package/contracts/bridge/EcdsaLib.sol +45 -0
  87. package/contracts/bridge/Fraud.sol +579 -0
  88. package/contracts/bridge/Heartbeat.sol +112 -0
  89. package/contracts/bridge/IRelay.sol +28 -0
  90. package/contracts/bridge/MovingFunds.sol +1077 -0
  91. package/contracts/bridge/Redemption.sol +1020 -0
  92. package/contracts/bridge/VendingMachine.sol +2 -2
  93. package/contracts/bridge/Wallets.sol +719 -0
  94. package/contracts/hardhat-dependency-compiler/.hardhat-dependency-compiler +1 -0
  95. package/contracts/hardhat-dependency-compiler/@keep-network/ecdsa/contracts/WalletRegistry.sol +3 -0
  96. package/contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol +3 -0
  97. package/contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +3 -0
  98. package/contracts/token/TBTC.sol +1 -1
  99. package/contracts/vault/DonationVault.sol +125 -0
  100. package/contracts/vault/IVault.sol +44 -0
  101. package/contracts/vault/TBTCVault.sol +305 -0
  102. package/deploy/00_resolve_relay.ts +28 -0
  103. package/deploy/00_resolve_tbtc_v1_token.ts +1 -1
  104. package/deploy/01_deploy_tbtc_v2_token.ts +8 -1
  105. package/deploy/02_deploy_vending_machine.ts +7 -0
  106. package/deploy/{03_transfer_roles.ts → 03_transfer_vending_machine_roles.ts} +1 -1
  107. package/deploy/04_deploy_bank.ts +27 -0
  108. package/deploy/05_deploy_bridge.ts +80 -0
  109. package/deploy/06_deploy_tbtc_vault.ts +30 -0
  110. package/deploy/07_bank_update_bridge.ts +19 -0
  111. package/deploy/08_transfer_bank_ownership.ts +15 -0
  112. package/deploy/09_transfer_tbtc_vault_ownership.ts +15 -0
  113. package/deploy/10_transfer_bridge_governance.ts +20 -0
  114. package/deploy/11_initialize_wallet_owner.ts +18 -0
  115. package/deploy/11_transfer_proxy_admin_ownership.ts +30 -0
  116. package/deploy/12_deploy_proxy_admin_with_deputy.ts +33 -0
  117. package/export/deploy/00_resolve_relay.js +24 -0
  118. package/export/deploy/00_resolve_tbtc_v1_token.js +24 -0
  119. package/export/deploy/01_deploy_tbtc_v2_token.js +19 -0
  120. package/export/deploy/02_deploy_vending_machine.js +25 -0
  121. package/export/deploy/03_transfer_vending_machine_roles.js +19 -0
  122. package/export/deploy/04_deploy_bank.js +21 -0
  123. package/export/deploy/05_deploy_bridge.js +69 -0
  124. package/export/deploy/06_deploy_tbtc_vault.js +24 -0
  125. package/export/deploy/07_bank_update_bridge.js +13 -0
  126. package/export/deploy/08_transfer_bank_ownership.js +11 -0
  127. package/export/deploy/09_transfer_tbtc_vault_ownership.js +11 -0
  128. package/export/deploy/10_transfer_bridge_governance.js +11 -0
  129. package/export/deploy/11_initialize_wallet_owner.js +14 -0
  130. package/export/deploy/11_transfer_proxy_admin_ownership.js +23 -0
  131. package/export/deploy/12_deploy_proxy_admin_with_deputy.js +22 -0
  132. package/export/hardhat.config.js +169 -0
  133. package/export/test/bank/Bank.test.js +1012 -0
  134. package/export/test/bridge/Bridge.Deployment.test.js +76 -0
  135. package/export/test/bridge/Bridge.Deposit.test.js +1834 -0
  136. package/export/test/bridge/Bridge.Frauds.test.js +1349 -0
  137. package/export/test/bridge/Bridge.MovingFunds.test.js +2437 -0
  138. package/export/test/bridge/Bridge.Parameters.test.js +400 -0
  139. package/export/test/bridge/Bridge.Redemption.test.js +2523 -0
  140. package/export/test/bridge/Bridge.Vaults.test.js +74 -0
  141. package/export/test/bridge/Bridge.Wallets.test.js +1017 -0
  142. package/export/test/bridge/EcdsaLib.test.js +46 -0
  143. package/export/test/bridge/Heartbeat.test.js +77 -0
  144. package/export/test/bridge/VendingMachine.Upgrade.test.js +160 -0
  145. package/export/test/bridge/VendingMachine.test.js +762 -0
  146. package/export/test/data/deposit-sweep.js +655 -0
  147. package/export/test/data/ecdsa.js +18 -0
  148. package/export/test/data/fraud.js +158 -0
  149. package/export/test/data/moving-funds.js +815 -0
  150. package/export/test/data/redemption.js +1011 -0
  151. package/export/test/fixtures/bridge.js +54 -0
  152. package/export/test/fixtures/index.js +57 -0
  153. package/export/test/helpers/contract-test-helpers.js +18 -0
  154. package/export/test/integration/Slashing.test.js +279 -0
  155. package/export/test/integration/WalleCreation.test.js +66 -0
  156. package/export/test/integration/utils/ecdsa-wallet-registry.js +137 -0
  157. package/export/test/integration/utils/fixture.js +77 -0
  158. package/export/test/integration/utils/gas.js +36 -0
  159. package/export/test/integration/utils/random-beacon.js +26 -0
  160. package/export/test/integration/utils/staking.js +19 -0
  161. package/export/test/vault/DonationVault.test.js +202 -0
  162. package/export/test/vault/TBTCVault.Redemption.test.js +357 -0
  163. package/export/test/vault/TBTCVault.test.js +768 -0
  164. package/export/typechain/BTCUtils.js +2 -0
  165. package/export/typechain/Bank.js +2 -0
  166. package/export/typechain/BankStub.js +2 -0
  167. package/export/typechain/Bridge.js +2 -0
  168. package/export/typechain/BridgeState.js +2 -0
  169. package/export/typechain/BridgeStub.js +2 -0
  170. package/export/typechain/Deposit.js +2 -0
  171. package/export/typechain/DepositSweep.js +2 -0
  172. package/export/typechain/DonationVault.js +2 -0
  173. package/export/typechain/ERC165.js +2 -0
  174. package/export/typechain/ERC1967Proxy.js +2 -0
  175. package/export/typechain/ERC1967Upgrade.js +2 -0
  176. package/export/typechain/ERC20WithPermit.js +2 -0
  177. package/export/typechain/ERC721.js +2 -0
  178. package/export/typechain/EcdsaAuthorization.js +2 -0
  179. package/export/typechain/EcdsaDkg.js +2 -0
  180. package/export/typechain/EcdsaDkgValidator.js +2 -0
  181. package/export/typechain/EcdsaInactivity.js +2 -0
  182. package/export/typechain/Fraud.js +2 -0
  183. package/export/typechain/Governable.js +2 -0
  184. package/export/typechain/HeartbeatStub.js +2 -0
  185. package/export/typechain/IApplication.js +2 -0
  186. package/export/typechain/IApproveAndCall.js +2 -0
  187. package/export/typechain/IBeacon.js +2 -0
  188. package/export/typechain/IERC165.js +2 -0
  189. package/export/typechain/IERC1822Proxiable.js +2 -0
  190. package/export/typechain/IERC20.js +2 -0
  191. package/export/typechain/IERC20Metadata.js +2 -0
  192. package/export/typechain/IERC20WithPermit.js +2 -0
  193. package/export/typechain/IERC721.js +2 -0
  194. package/export/typechain/IERC721Metadata.js +2 -0
  195. package/export/typechain/IERC721Receiver.js +2 -0
  196. package/export/typechain/IRandomBeacon.js +2 -0
  197. package/export/typechain/IRandomBeaconConsumer.js +2 -0
  198. package/export/typechain/IReceiveApproval.js +2 -0
  199. package/export/typechain/IReceiveBalanceApproval.js +2 -0
  200. package/export/typechain/IRelay.js +2 -0
  201. package/export/typechain/IStaking.js +2 -0
  202. package/export/typechain/IVault.js +2 -0
  203. package/export/typechain/IWalletOwner.js +2 -0
  204. package/export/typechain/IWalletRegistry.js +2 -0
  205. package/export/typechain/Initializable.js +2 -0
  206. package/export/typechain/MisfundRecovery.js +2 -0
  207. package/export/typechain/MovingFunds.js +2 -0
  208. package/export/typechain/Ownable.js +2 -0
  209. package/export/typechain/Proxy.js +2 -0
  210. package/export/typechain/ProxyAdmin.js +2 -0
  211. package/export/typechain/ReceiveApprovalStub.js +2 -0
  212. package/export/typechain/Redemption.js +2 -0
  213. package/export/typechain/Reimbursable.js +2 -0
  214. package/export/typechain/ReimbursementPool.js +2 -0
  215. package/export/typechain/Rewards.js +2 -0
  216. package/export/typechain/SortitionPool.js +2 -0
  217. package/export/typechain/SortitionTree.js +2 -0
  218. package/export/typechain/TBTC.js +2 -0
  219. package/export/typechain/TBTCVault.js +2 -0
  220. package/export/typechain/TestERC20.js +2 -0
  221. package/export/typechain/TestERC721.js +2 -0
  222. package/export/typechain/TestEcdsaLib.js +2 -0
  223. package/export/typechain/TestRelay.js +2 -0
  224. package/export/typechain/TransparentUpgradeableProxy.js +2 -0
  225. package/export/typechain/VendingMachine.js +2 -0
  226. package/export/typechain/WalletRegistry.js +2 -0
  227. package/export/typechain/Wallets.js +2 -0
  228. package/export/typechain/common.js +2 -0
  229. package/export/typechain/factories/BTCUtils__factory.js +94 -0
  230. package/export/typechain/factories/BankStub__factory.js +586 -0
  231. package/export/typechain/factories/Bank__factory.js +573 -0
  232. package/export/typechain/factories/BridgeState__factory.js +257 -0
  233. package/export/typechain/factories/BridgeStub__factory.js +2912 -0
  234. package/export/typechain/factories/Bridge__factory.js +2526 -0
  235. package/export/typechain/factories/DepositSweep__factory.js +61 -0
  236. package/export/typechain/factories/Deposit__factory.js +103 -0
  237. package/export/typechain/factories/DonationVault__factory.js +139 -0
  238. package/export/typechain/factories/ERC165__factory.js +38 -0
  239. package/export/typechain/factories/ERC1967Proxy__factory.js +111 -0
  240. package/export/typechain/factories/ERC1967Upgrade__factory.js +64 -0
  241. package/export/typechain/factories/ERC20WithPermit__factory.js +524 -0
  242. package/export/typechain/factories/ERC721__factory.js +388 -0
  243. package/export/typechain/factories/EcdsaAuthorization__factory.js +211 -0
  244. package/export/typechain/factories/EcdsaDkgValidator__factory.js +441 -0
  245. package/export/typechain/factories/EcdsaDkg__factory.js +192 -0
  246. package/export/typechain/factories/EcdsaInactivity__factory.js +134 -0
  247. package/export/typechain/factories/Fraud__factory.js +117 -0
  248. package/export/typechain/factories/Governable__factory.js +64 -0
  249. package/export/typechain/factories/HeartbeatStub__factory.js +61 -0
  250. package/export/typechain/factories/IApplication__factory.js +152 -0
  251. package/export/typechain/factories/IApproveAndCall__factory.js +48 -0
  252. package/export/typechain/factories/IBeacon__factory.js +32 -0
  253. package/export/typechain/factories/IERC165__factory.js +38 -0
  254. package/export/typechain/factories/IERC1822Proxiable__factory.js +32 -0
  255. package/export/typechain/factories/IERC20Metadata__factory.js +241 -0
  256. package/export/typechain/factories/IERC20WithPermit__factory.js +389 -0
  257. package/export/typechain/factories/IERC20__factory.js +202 -0
  258. package/export/typechain/factories/IERC721Metadata__factory.js +349 -0
  259. package/export/typechain/factories/IERC721Receiver__factory.js +53 -0
  260. package/export/typechain/factories/IERC721__factory.js +304 -0
  261. package/export/typechain/factories/IRandomBeaconConsumer__factory.js +37 -0
  262. package/export/typechain/factories/IRandomBeacon__factory.js +32 -0
  263. package/export/typechain/factories/IReceiveApproval__factory.js +47 -0
  264. package/export/typechain/factories/IReceiveBalanceApproval__factory.js +42 -0
  265. package/export/typechain/factories/IRelay__factory.js +45 -0
  266. package/export/typechain/factories/IStaking__factory.js +722 -0
  267. package/export/typechain/factories/IVault__factory.js +60 -0
  268. package/export/typechain/factories/IWalletOwner__factory.js +65 -0
  269. package/export/typechain/factories/IWalletRegistry__factory.js +138 -0
  270. package/export/typechain/factories/Initializable__factory.js +32 -0
  271. package/export/typechain/factories/MisfundRecovery__factory.js +145 -0
  272. package/export/typechain/factories/MovingFunds__factory.js +169 -0
  273. package/export/typechain/factories/Ownable__factory.js +71 -0
  274. package/export/typechain/factories/ProxyAdmin__factory.js +191 -0
  275. package/export/typechain/factories/Proxy__factory.js +27 -0
  276. package/export/typechain/factories/ReceiveApprovalStub__factory.js +127 -0
  277. package/export/typechain/factories/Redemption__factory.js +123 -0
  278. package/export/typechain/factories/Reimbursable__factory.js +58 -0
  279. package/export/typechain/factories/ReimbursementPool__factory.js +350 -0
  280. package/export/typechain/factories/Rewards__factory.js +117 -0
  281. package/export/typechain/factories/SortitionPool__factory.js +610 -0
  282. package/export/typechain/factories/SortitionTree__factory.js +149 -0
  283. package/export/typechain/factories/TBTCVault__factory.js +480 -0
  284. package/export/typechain/factories/TBTC__factory.js +564 -0
  285. package/export/typechain/factories/TestERC20__factory.js +539 -0
  286. package/export/typechain/factories/TestERC721__factory.js +421 -0
  287. package/export/typechain/factories/TestEcdsaLib__factory.js +66 -0
  288. package/export/typechain/factories/TestRelay__factory.js +94 -0
  289. package/export/typechain/factories/TransparentUpgradeableProxy__factory.js +186 -0
  290. package/export/typechain/factories/VendingMachine__factory.js +549 -0
  291. package/export/typechain/factories/WalletRegistry__factory.js +1919 -0
  292. package/export/typechain/factories/Wallets__factory.js +143 -0
  293. package/export/typechain/index.js +132 -0
  294. package/export.json +15932 -503
  295. package/package.json +47 -26
  296. package/artifacts/solcInputs/7cc3eda3cb3ff2522d18b5e7b31ea228.json +0 -104
@@ -0,0 +1,400 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const hardhat_1 = require("hardhat");
7
+ const chai_1 = require("chai");
8
+ const fixtures_1 = require("../fixtures");
9
+ const bridge_1 = __importDefault(require("../fixtures/bridge"));
10
+ const { createSnapshot, restoreSnapshot } = hardhat_1.helpers.snapshot;
11
+ describe("Bridge - Parameters", () => {
12
+ let governance;
13
+ let thirdParty;
14
+ let bridge;
15
+ before(async () => {
16
+ // eslint-disable-next-line @typescript-eslint/no-extra-semi
17
+ ;
18
+ ({ governance, thirdParty, bridge } = await hardhat_1.waffle.loadFixture(bridge_1.default));
19
+ });
20
+ describe("updateDepositParameters", () => {
21
+ context("when caller is the contract guvnor", () => {
22
+ context("when all new parameter values are correct", () => {
23
+ const newDepositDustThreshold = fixtures_1.constants.depositDustThreshold * 2;
24
+ const newDepositTreasuryFeeDivisor = fixtures_1.constants.depositTreasuryFeeDivisor * 2;
25
+ const newDepositTxMaxFee = fixtures_1.constants.depositTxMaxFee * 3;
26
+ let tx;
27
+ before(async () => {
28
+ await createSnapshot();
29
+ tx = await bridge
30
+ .connect(governance)
31
+ .updateDepositParameters(newDepositDustThreshold, newDepositTreasuryFeeDivisor, newDepositTxMaxFee);
32
+ });
33
+ after(async () => {
34
+ await restoreSnapshot();
35
+ });
36
+ it("should set correct values", async () => {
37
+ const params = await bridge.depositParameters();
38
+ (0, chai_1.expect)(params.depositDustThreshold).to.be.equal(newDepositDustThreshold);
39
+ (0, chai_1.expect)(params.depositTreasuryFeeDivisor).to.be.equal(newDepositTreasuryFeeDivisor);
40
+ (0, chai_1.expect)(params.depositTxMaxFee).to.be.equal(newDepositTxMaxFee);
41
+ });
42
+ it("should emit DepositParametersUpdated event", async () => {
43
+ await (0, chai_1.expect)(tx)
44
+ .to.emit(bridge, "DepositParametersUpdated")
45
+ .withArgs(newDepositDustThreshold, newDepositTreasuryFeeDivisor, newDepositTxMaxFee);
46
+ });
47
+ });
48
+ context("when new deposit dust threshold is zero", () => {
49
+ it("should revert", async () => {
50
+ await (0, chai_1.expect)(bridge
51
+ .connect(governance)
52
+ .updateDepositParameters(0, fixtures_1.constants.depositTreasuryFeeDivisor, fixtures_1.constants.depositTxMaxFee)).to.be.revertedWith("Deposit dust threshold must be greater than zero");
53
+ });
54
+ });
55
+ context("when new deposit treasury fee divisor is zero", () => {
56
+ it("should revert", async () => {
57
+ await (0, chai_1.expect)(bridge
58
+ .connect(governance)
59
+ .updateDepositParameters(fixtures_1.constants.depositDustThreshold, 0, fixtures_1.constants.depositTxMaxFee)).to.be.revertedWith("Deposit treasury fee divisor must be greater than zero");
60
+ });
61
+ });
62
+ context("when new deposit transaction max fee is zero", () => {
63
+ it("should revert", async () => {
64
+ await (0, chai_1.expect)(bridge
65
+ .connect(governance)
66
+ .updateDepositParameters(fixtures_1.constants.depositDustThreshold, fixtures_1.constants.depositTreasuryFeeDivisor, 0)).to.be.revertedWith("Deposit transaction max fee must be greater than zero");
67
+ });
68
+ });
69
+ });
70
+ context("when caller is not the contract guvnor", () => {
71
+ it("should revert", async () => {
72
+ await (0, chai_1.expect)(bridge
73
+ .connect(thirdParty)
74
+ .updateDepositParameters(fixtures_1.constants.depositDustThreshold, fixtures_1.constants.depositTreasuryFeeDivisor, fixtures_1.constants.depositTxMaxFee)).to.be.revertedWith("Caller is not the governance");
75
+ });
76
+ });
77
+ });
78
+ describe("updateRedemptionParameters", () => {
79
+ context("when caller is the contract guvnor", () => {
80
+ context("when all new parameter values are correct", () => {
81
+ const newRedemptionDustThreshold = fixtures_1.constants.redemptionDustThreshold * 2;
82
+ const newRedemptionTreasuryFeeDivisor = fixtures_1.constants.redemptionTreasuryFeeDivisor / 2;
83
+ const newRedemptionTxMaxFee = fixtures_1.constants.redemptionTxMaxFee * 3;
84
+ const newRedemptionTimeout = fixtures_1.constants.redemptionTimeout * 4;
85
+ const newRedemptionTimeoutSlashingAmount = fixtures_1.constants.redemptionTimeoutSlashingAmount.mul(2);
86
+ const newRedemptionTimeoutNotifierRewardMultiplier = fixtures_1.constants.redemptionTimeoutNotifierRewardMultiplier / 4;
87
+ let tx;
88
+ before(async () => {
89
+ await createSnapshot();
90
+ tx = await bridge
91
+ .connect(governance)
92
+ .updateRedemptionParameters(newRedemptionDustThreshold, newRedemptionTreasuryFeeDivisor, newRedemptionTxMaxFee, newRedemptionTimeout, newRedemptionTimeoutSlashingAmount, newRedemptionTimeoutNotifierRewardMultiplier);
93
+ });
94
+ after(async () => {
95
+ await restoreSnapshot();
96
+ });
97
+ it("should set correct values", async () => {
98
+ const params = await bridge.redemptionParameters();
99
+ (0, chai_1.expect)(params.redemptionDustThreshold).to.be.equal(newRedemptionDustThreshold);
100
+ (0, chai_1.expect)(params.redemptionTreasuryFeeDivisor).to.be.equal(newRedemptionTreasuryFeeDivisor);
101
+ (0, chai_1.expect)(params.redemptionTxMaxFee).to.be.equal(newRedemptionTxMaxFee);
102
+ (0, chai_1.expect)(params.redemptionTimeout).to.be.equal(newRedemptionTimeout);
103
+ (0, chai_1.expect)(params.redemptionTimeoutSlashingAmount).to.be.equal(newRedemptionTimeoutSlashingAmount);
104
+ (0, chai_1.expect)(params.redemptionTimeoutNotifierRewardMultiplier).to.be.equal(newRedemptionTimeoutNotifierRewardMultiplier);
105
+ });
106
+ it("should emit RedemptionParametersUpdated event", async () => {
107
+ await (0, chai_1.expect)(tx)
108
+ .to.emit(bridge, "RedemptionParametersUpdated")
109
+ .withArgs(newRedemptionDustThreshold, newRedemptionTreasuryFeeDivisor, newRedemptionTxMaxFee, newRedemptionTimeout, newRedemptionTimeoutSlashingAmount, newRedemptionTimeoutNotifierRewardMultiplier);
110
+ });
111
+ });
112
+ context("when new redemption dust threshold is not greater than moving funds dust threshold", () => {
113
+ // Use the current value of `movingFundsDustThreshold` as the new value
114
+ // of `redemptionDustThreshold`.
115
+ it("should revert", async () => {
116
+ await (0, chai_1.expect)(bridge
117
+ .connect(governance)
118
+ .updateRedemptionParameters((await bridge.movingFundsParameters()).movingFundsDustThreshold, fixtures_1.constants.redemptionTreasuryFeeDivisor, fixtures_1.constants.redemptionTxMaxFee, fixtures_1.constants.redemptionTimeout, fixtures_1.constants.redemptionTimeoutSlashingAmount, fixtures_1.constants.redemptionTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Redemption dust threshold must be greater than moving funds dust threshold");
119
+ });
120
+ });
121
+ context("when new redemption treasury fee divisor is zero", () => {
122
+ it("should revert", async () => {
123
+ await (0, chai_1.expect)(bridge
124
+ .connect(governance)
125
+ .updateRedemptionParameters(fixtures_1.constants.redemptionDustThreshold, 0, fixtures_1.constants.redemptionTxMaxFee, fixtures_1.constants.redemptionTimeout, fixtures_1.constants.redemptionTimeoutSlashingAmount, fixtures_1.constants.redemptionTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Redemption treasury fee divisor must be greater than zero");
126
+ });
127
+ });
128
+ context("when new redemption transaction max fee is zero", () => {
129
+ it("should revert", async () => {
130
+ await (0, chai_1.expect)(bridge
131
+ .connect(governance)
132
+ .updateRedemptionParameters(fixtures_1.constants.redemptionDustThreshold, fixtures_1.constants.redemptionTreasuryFeeDivisor, 0, fixtures_1.constants.redemptionTimeout, fixtures_1.constants.redemptionTimeoutSlashingAmount, fixtures_1.constants.redemptionTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Redemption transaction max fee must be greater than zero");
133
+ });
134
+ });
135
+ context("when new redemption timeout is zero", () => {
136
+ it("should revert", async () => {
137
+ await (0, chai_1.expect)(bridge
138
+ .connect(governance)
139
+ .updateRedemptionParameters(fixtures_1.constants.redemptionDustThreshold, fixtures_1.constants.redemptionTreasuryFeeDivisor, fixtures_1.constants.redemptionTxMaxFee, 0, fixtures_1.constants.redemptionTimeoutSlashingAmount, fixtures_1.constants.redemptionTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Redemption timeout must be greater than zero");
140
+ });
141
+ });
142
+ context("when new redemption timeout notifier reward multiplier is greater than 100", () => {
143
+ it("should revert", async () => {
144
+ await (0, chai_1.expect)(bridge
145
+ .connect(governance)
146
+ .updateRedemptionParameters(fixtures_1.constants.redemptionDustThreshold, fixtures_1.constants.redemptionTreasuryFeeDivisor, fixtures_1.constants.redemptionTxMaxFee, fixtures_1.constants.redemptionTimeout, fixtures_1.constants.redemptionTimeoutSlashingAmount, 101)).to.be.revertedWith("Redemption timeout notifier reward multiplier must be in the range [0, 100]");
147
+ });
148
+ });
149
+ });
150
+ context("when caller is not the contract guvnor", () => {
151
+ it("should revert", async () => {
152
+ await (0, chai_1.expect)(bridge
153
+ .connect(thirdParty)
154
+ .updateRedemptionParameters(fixtures_1.constants.redemptionDustThreshold, fixtures_1.constants.redemptionTreasuryFeeDivisor, fixtures_1.constants.redemptionTxMaxFee, fixtures_1.constants.redemptionTimeout, fixtures_1.constants.redemptionTimeoutSlashingAmount, fixtures_1.constants.redemptionTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Caller is not the governance");
155
+ });
156
+ });
157
+ });
158
+ describe("updateMovingFundsParameters", () => {
159
+ context("when caller is the contract guvnor", () => {
160
+ context("when all new parameter values are correct", () => {
161
+ const newMovingFundsTxMaxTotalFee = fixtures_1.constants.movingFundsTxMaxTotalFee / 2;
162
+ const newMovingFundsDustThreshold = fixtures_1.constants.movingFundsDustThreshold * 2;
163
+ const newMovingFundsTimeoutResetDelay = fixtures_1.constants.movingFundsTimeoutResetDelay * 2;
164
+ const newMovingFundsTimeout = fixtures_1.constants.movingFundsTimeout * 2;
165
+ const newMovingFundsTimeoutSlashingAmount = fixtures_1.constants.movingFundsTimeoutSlashingAmount.mul(3);
166
+ const newMovingFundsTimeoutNotifierRewardMultiplier = fixtures_1.constants.movingFundsTimeoutNotifierRewardMultiplier / 2;
167
+ const newMovedFundsSweepTxMaxTotalFee = fixtures_1.constants.movedFundsSweepTxMaxTotalFee * 2;
168
+ const newMovedFundsSweepTimeout = fixtures_1.constants.movedFundsSweepTimeout * 4;
169
+ const newMovedFundsSweepTimeoutSlashingAmount = fixtures_1.constants.movedFundsSweepTimeoutSlashingAmount.mul(6);
170
+ const newMovedFundsSweepTimeoutNotifierRewardMultiplier = fixtures_1.constants.movedFundsSweepTimeoutNotifierRewardMultiplier / 4;
171
+ let tx;
172
+ before(async () => {
173
+ await createSnapshot();
174
+ tx = await bridge
175
+ .connect(governance)
176
+ .updateMovingFundsParameters(newMovingFundsTxMaxTotalFee, newMovingFundsDustThreshold, newMovingFundsTimeoutResetDelay, newMovingFundsTimeout, newMovingFundsTimeoutSlashingAmount, newMovingFundsTimeoutNotifierRewardMultiplier, newMovedFundsSweepTxMaxTotalFee, newMovedFundsSweepTimeout, newMovedFundsSweepTimeoutSlashingAmount, newMovedFundsSweepTimeoutNotifierRewardMultiplier);
177
+ });
178
+ after(async () => {
179
+ await restoreSnapshot();
180
+ });
181
+ it("should set correct values", async () => {
182
+ const params = await bridge.movingFundsParameters();
183
+ (0, chai_1.expect)(params.movingFundsTxMaxTotalFee).to.be.equal(newMovingFundsTxMaxTotalFee);
184
+ (0, chai_1.expect)(params.movingFundsDustThreshold).to.be.equal(newMovingFundsDustThreshold);
185
+ (0, chai_1.expect)(params.movingFundsTimeoutResetDelay).to.be.equal(newMovingFundsTimeoutResetDelay);
186
+ (0, chai_1.expect)(params.movingFundsTimeout).to.be.equal(newMovingFundsTimeout);
187
+ (0, chai_1.expect)(params.movingFundsTimeoutSlashingAmount).to.be.equal(newMovingFundsTimeoutSlashingAmount);
188
+ (0, chai_1.expect)(params.movingFundsTimeoutNotifierRewardMultiplier).to.be.equal(newMovingFundsTimeoutNotifierRewardMultiplier);
189
+ (0, chai_1.expect)(params.movedFundsSweepTxMaxTotalFee).to.be.equal(newMovedFundsSweepTxMaxTotalFee);
190
+ (0, chai_1.expect)(params.movedFundsSweepTimeout).to.be.equal(newMovedFundsSweepTimeout);
191
+ (0, chai_1.expect)(params.movedFundsSweepTimeoutSlashingAmount).to.be.equal(newMovedFundsSweepTimeoutSlashingAmount);
192
+ (0, chai_1.expect)(params.movedFundsSweepTimeoutNotifierRewardMultiplier).to.be.equal(newMovedFundsSweepTimeoutNotifierRewardMultiplier);
193
+ });
194
+ it("should emit MovingFundsParametersUpdated event", async () => {
195
+ await (0, chai_1.expect)(tx)
196
+ .to.emit(bridge, "MovingFundsParametersUpdated")
197
+ .withArgs(newMovingFundsTxMaxTotalFee, newMovingFundsDustThreshold, newMovingFundsTimeoutResetDelay, newMovingFundsTimeout, newMovingFundsTimeoutSlashingAmount, newMovingFundsTimeoutNotifierRewardMultiplier, newMovedFundsSweepTxMaxTotalFee, newMovedFundsSweepTimeout, newMovedFundsSweepTimeoutSlashingAmount, newMovedFundsSweepTimeoutNotifierRewardMultiplier);
198
+ });
199
+ });
200
+ context("when new moving funds transaction max total fee is zero", () => {
201
+ it("should revert", async () => {
202
+ await (0, chai_1.expect)(bridge
203
+ .connect(governance)
204
+ .updateMovingFundsParameters(0, fixtures_1.constants.movingFundsDustThreshold, fixtures_1.constants.movingFundsTimeoutResetDelay, fixtures_1.constants.movingFundsTimeout, fixtures_1.constants.movingFundsTimeoutSlashingAmount, fixtures_1.constants.movingFundsTimeoutNotifierRewardMultiplier, fixtures_1.constants.movedFundsSweepTxMaxTotalFee, fixtures_1.constants.movedFundsSweepTimeout, fixtures_1.constants.movedFundsSweepTimeoutSlashingAmount, fixtures_1.constants.movedFundsSweepTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Moving funds transaction max total fee must be greater than zero");
205
+ });
206
+ });
207
+ context("when new moving funds dust threshold is zero", () => {
208
+ it("should revert", async () => {
209
+ await (0, chai_1.expect)(bridge
210
+ .connect(governance)
211
+ .updateMovingFundsParameters(fixtures_1.constants.movingFundsTxMaxTotalFee, 0, fixtures_1.constants.movingFundsTimeoutResetDelay, fixtures_1.constants.movingFundsTimeout, fixtures_1.constants.movingFundsTimeoutSlashingAmount, fixtures_1.constants.movingFundsTimeoutNotifierRewardMultiplier, fixtures_1.constants.movedFundsSweepTxMaxTotalFee, fixtures_1.constants.movedFundsSweepTimeout, fixtures_1.constants.movedFundsSweepTimeoutSlashingAmount, fixtures_1.constants.movedFundsSweepTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Moving funds dust threshold must be greater than zero and lower than redemption dust threshold");
212
+ });
213
+ });
214
+ context("when new moving funds dust threshold is not lower than redemption dust threshold", () => {
215
+ // Use the current value of `redemptionDustThreshold` as the new value
216
+ // of `movingFundsDustThreshold`.
217
+ it("should revert", async () => {
218
+ await (0, chai_1.expect)(bridge
219
+ .connect(governance)
220
+ .updateMovingFundsParameters(fixtures_1.constants.movingFundsTxMaxTotalFee, (await bridge.redemptionParameters()).redemptionDustThreshold, fixtures_1.constants.movingFundsTimeoutResetDelay, fixtures_1.constants.movingFundsTimeout, fixtures_1.constants.movingFundsTimeoutSlashingAmount, fixtures_1.constants.movingFundsTimeoutNotifierRewardMultiplier, fixtures_1.constants.movedFundsSweepTxMaxTotalFee, fixtures_1.constants.movedFundsSweepTimeout, fixtures_1.constants.movedFundsSweepTimeoutSlashingAmount, fixtures_1.constants.movedFundsSweepTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Moving funds dust threshold must be greater than zero and lower than redemption dust threshold");
221
+ });
222
+ });
223
+ context("when new moving funds timeout reset delay is zero", () => {
224
+ it("should revert", async () => {
225
+ await (0, chai_1.expect)(bridge
226
+ .connect(governance)
227
+ .updateMovingFundsParameters(fixtures_1.constants.movingFundsTxMaxTotalFee, fixtures_1.constants.movingFundsDustThreshold, 0, fixtures_1.constants.movingFundsTimeout, fixtures_1.constants.movingFundsTimeoutSlashingAmount, fixtures_1.constants.movingFundsTimeoutNotifierRewardMultiplier, fixtures_1.constants.movedFundsSweepTxMaxTotalFee, fixtures_1.constants.movedFundsSweepTimeout, fixtures_1.constants.movedFundsSweepTimeoutSlashingAmount, fixtures_1.constants.movedFundsSweepTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Moving funds timeout reset delay must be greater than zero");
228
+ });
229
+ });
230
+ context("when new moving funds timeout is not greater than its reset delay", () => {
231
+ it("should revert", async () => {
232
+ await (0, chai_1.expect)(bridge
233
+ .connect(governance)
234
+ .updateMovingFundsParameters(fixtures_1.constants.movingFundsTxMaxTotalFee, fixtures_1.constants.movingFundsDustThreshold, fixtures_1.constants.movingFundsTimeoutResetDelay, fixtures_1.constants.movingFundsTimeoutResetDelay, fixtures_1.constants.movingFundsTimeoutSlashingAmount, fixtures_1.constants.movingFundsTimeoutNotifierRewardMultiplier, fixtures_1.constants.movedFundsSweepTxMaxTotalFee, fixtures_1.constants.movedFundsSweepTimeout, fixtures_1.constants.movedFundsSweepTimeoutSlashingAmount, fixtures_1.constants.movedFundsSweepTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Moving funds timeout must be greater than its reset delay");
235
+ });
236
+ });
237
+ context("when new moving funds timeout notifier reward multiplier is greater than 100", () => {
238
+ it("should revert", async () => {
239
+ await (0, chai_1.expect)(bridge
240
+ .connect(governance)
241
+ .updateMovingFundsParameters(fixtures_1.constants.movingFundsTxMaxTotalFee, fixtures_1.constants.movingFundsDustThreshold, fixtures_1.constants.movingFundsTimeoutResetDelay, fixtures_1.constants.movingFundsTimeout, fixtures_1.constants.movingFundsTimeoutSlashingAmount, 101, fixtures_1.constants.movedFundsSweepTxMaxTotalFee, fixtures_1.constants.movedFundsSweepTimeout, fixtures_1.constants.movedFundsSweepTimeoutSlashingAmount, fixtures_1.constants.movedFundsSweepTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Moving funds timeout notifier reward multiplier must be in the range [0, 100]");
242
+ });
243
+ });
244
+ context("when new moved funds sweep transaction max total fee is zero", () => {
245
+ it("should revert", async () => {
246
+ await (0, chai_1.expect)(bridge
247
+ .connect(governance)
248
+ .updateMovingFundsParameters(fixtures_1.constants.movingFundsTxMaxTotalFee, fixtures_1.constants.movingFundsDustThreshold, fixtures_1.constants.movingFundsTimeoutResetDelay, fixtures_1.constants.movingFundsTimeout, fixtures_1.constants.movingFundsTimeoutSlashingAmount, fixtures_1.constants.movingFundsTimeoutNotifierRewardMultiplier, 0, fixtures_1.constants.movedFundsSweepTimeout, fixtures_1.constants.movedFundsSweepTimeoutSlashingAmount, fixtures_1.constants.movedFundsSweepTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Moved funds sweep transaction max total fee must be greater than zero");
249
+ });
250
+ });
251
+ context("when new moved funds sweep timeout is zero", () => {
252
+ it("should revert", async () => {
253
+ await (0, chai_1.expect)(bridge
254
+ .connect(governance)
255
+ .updateMovingFundsParameters(fixtures_1.constants.movingFundsTxMaxTotalFee, fixtures_1.constants.movingFundsDustThreshold, fixtures_1.constants.movingFundsTimeoutResetDelay, fixtures_1.constants.movingFundsTimeout, fixtures_1.constants.movingFundsTimeoutSlashingAmount, fixtures_1.constants.movingFundsTimeoutNotifierRewardMultiplier, fixtures_1.constants.movedFundsSweepTxMaxTotalFee, 0, fixtures_1.constants.movedFundsSweepTimeoutSlashingAmount, fixtures_1.constants.movedFundsSweepTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Moved funds sweep timeout must be greater than zero");
256
+ });
257
+ });
258
+ context("when new moved funds sweep timeout notifier reward multiplier is greater than 100", () => {
259
+ it("should revert", async () => {
260
+ await (0, chai_1.expect)(bridge
261
+ .connect(governance)
262
+ .updateMovingFundsParameters(fixtures_1.constants.movingFundsTxMaxTotalFee, fixtures_1.constants.movingFundsDustThreshold, fixtures_1.constants.movingFundsTimeoutResetDelay, fixtures_1.constants.movingFundsTimeout, fixtures_1.constants.movingFundsTimeoutSlashingAmount, fixtures_1.constants.movingFundsTimeoutNotifierRewardMultiplier, fixtures_1.constants.movedFundsSweepTxMaxTotalFee, fixtures_1.constants.movedFundsSweepTimeout, fixtures_1.constants.movedFundsSweepTimeoutSlashingAmount, 101)).to.be.revertedWith("Moved funds sweep timeout notifier reward multiplier must be in the range [0, 100]");
263
+ });
264
+ });
265
+ });
266
+ context("when caller is not the contract guvnor", () => {
267
+ it("should revert", async () => {
268
+ await (0, chai_1.expect)(bridge
269
+ .connect(thirdParty)
270
+ .updateMovingFundsParameters(fixtures_1.constants.movingFundsTxMaxTotalFee, fixtures_1.constants.movingFundsDustThreshold, fixtures_1.constants.movingFundsTimeoutResetDelay, fixtures_1.constants.movingFundsTimeout, fixtures_1.constants.movingFundsTimeoutSlashingAmount, fixtures_1.constants.movingFundsTimeoutNotifierRewardMultiplier, fixtures_1.constants.movedFundsSweepTxMaxTotalFee, fixtures_1.constants.movedFundsSweepTimeout, fixtures_1.constants.movedFundsSweepTimeoutSlashingAmount, fixtures_1.constants.movedFundsSweepTimeoutNotifierRewardMultiplier)).to.be.revertedWith("Caller is not the governance");
271
+ });
272
+ });
273
+ });
274
+ describe("updateWalletParameters", () => {
275
+ context("when caller is the contract guvnor", () => {
276
+ context("when all new parameter values are correct", () => {
277
+ const newWalletCreationPeriod = fixtures_1.constants.walletCreationPeriod * 2;
278
+ const newWalletCreationMinBtcBalance = fixtures_1.constants.walletCreationMinBtcBalance.add(1000);
279
+ const newWalletCreationMaxBtcBalance = fixtures_1.constants.walletCreationMaxBtcBalance.add(2000);
280
+ const newWalletClosureMinBtcBalance = fixtures_1.constants.walletClosureMinBtcBalance.add(3000);
281
+ const newWalletMaxAge = fixtures_1.constants.walletMaxAge * 2;
282
+ const newWalletMaxBtcTransfer = fixtures_1.constants.walletMaxBtcTransfer.add(1000);
283
+ const newWalletClosingPeriod = fixtures_1.constants.walletClosingPeriod * 2;
284
+ let tx;
285
+ before(async () => {
286
+ await createSnapshot();
287
+ tx = await bridge
288
+ .connect(governance)
289
+ .updateWalletParameters(newWalletCreationPeriod, newWalletCreationMinBtcBalance, newWalletCreationMaxBtcBalance, newWalletClosureMinBtcBalance, newWalletMaxAge, newWalletMaxBtcTransfer, newWalletClosingPeriod);
290
+ });
291
+ after(async () => {
292
+ await restoreSnapshot();
293
+ });
294
+ it("should set correct values", async () => {
295
+ const params = await bridge.walletParameters();
296
+ (0, chai_1.expect)(params.walletCreationPeriod).to.be.equal(newWalletCreationPeriod);
297
+ (0, chai_1.expect)(params.walletCreationMinBtcBalance).to.be.equal(newWalletCreationMinBtcBalance);
298
+ (0, chai_1.expect)(params.walletCreationMaxBtcBalance).to.be.equal(newWalletCreationMaxBtcBalance);
299
+ (0, chai_1.expect)(params.walletClosureMinBtcBalance).to.be.equal(newWalletClosureMinBtcBalance);
300
+ (0, chai_1.expect)(params.walletMaxAge).to.be.equal(newWalletMaxAge);
301
+ (0, chai_1.expect)(params.walletMaxBtcTransfer).to.be.equal(newWalletMaxBtcTransfer);
302
+ (0, chai_1.expect)(params.walletClosingPeriod).to.be.equal(newWalletClosingPeriod);
303
+ });
304
+ it("should emit WalletParametersUpdated event", async () => {
305
+ await (0, chai_1.expect)(tx)
306
+ .to.emit(bridge, "WalletParametersUpdated")
307
+ .withArgs(newWalletCreationPeriod, newWalletCreationMinBtcBalance, newWalletCreationMaxBtcBalance, newWalletClosureMinBtcBalance, newWalletMaxAge, newWalletMaxBtcTransfer, newWalletClosingPeriod);
308
+ });
309
+ });
310
+ context("when new creation maximum BTC balance is not greater than the creation minimum BTC balance", () => {
311
+ it("should revert", async () => {
312
+ await (0, chai_1.expect)(bridge
313
+ .connect(governance)
314
+ .updateWalletParameters(fixtures_1.constants.walletCreationPeriod, fixtures_1.constants.walletCreationMinBtcBalance, fixtures_1.constants.walletCreationMinBtcBalance, fixtures_1.constants.walletClosureMinBtcBalance, fixtures_1.constants.walletMaxAge, fixtures_1.constants.walletMaxBtcTransfer, fixtures_1.constants.walletClosingPeriod)).to.be.revertedWith("Wallet creation maximum BTC balance must be greater than the creation minimum BTC balance");
315
+ });
316
+ });
317
+ context("when new closure minimum BTC balance is zero", () => {
318
+ it("should revert", async () => {
319
+ await (0, chai_1.expect)(bridge
320
+ .connect(governance)
321
+ .updateWalletParameters(fixtures_1.constants.walletCreationPeriod, fixtures_1.constants.walletClosureMinBtcBalance, fixtures_1.constants.walletCreationMaxBtcBalance, 0, fixtures_1.constants.walletMaxAge, fixtures_1.constants.walletMaxBtcTransfer, fixtures_1.constants.walletClosingPeriod)).to.be.revertedWith("Wallet closure minimum BTC balance must be greater than zero");
322
+ });
323
+ });
324
+ context("when new maximum BTC transfer is zero", () => {
325
+ it("should revert", async () => {
326
+ await (0, chai_1.expect)(bridge
327
+ .connect(governance)
328
+ .updateWalletParameters(fixtures_1.constants.walletCreationPeriod, fixtures_1.constants.walletCreationMinBtcBalance, fixtures_1.constants.walletCreationMaxBtcBalance, fixtures_1.constants.walletClosureMinBtcBalance, fixtures_1.constants.walletMaxAge, 0, fixtures_1.constants.walletClosingPeriod)).to.be.revertedWith("Wallet maximum BTC transfer must be greater than zero");
329
+ });
330
+ });
331
+ context("when new closing period is zero", () => {
332
+ it("should revert", async () => {
333
+ await (0, chai_1.expect)(bridge
334
+ .connect(governance)
335
+ .updateWalletParameters(fixtures_1.constants.walletCreationPeriod, fixtures_1.constants.walletCreationMinBtcBalance, fixtures_1.constants.walletCreationMaxBtcBalance, fixtures_1.constants.walletClosureMinBtcBalance, fixtures_1.constants.walletMaxAge, fixtures_1.constants.walletMaxBtcTransfer, 0)).to.be.revertedWith("Wallet closing period must be greater than zero");
336
+ });
337
+ });
338
+ });
339
+ context("when caller is not the contract guvnor", () => {
340
+ it("should revert", async () => {
341
+ await (0, chai_1.expect)(bridge
342
+ .connect(thirdParty)
343
+ .updateWalletParameters(fixtures_1.constants.walletCreationPeriod, fixtures_1.constants.walletCreationMinBtcBalance, fixtures_1.constants.walletCreationMaxBtcBalance, fixtures_1.constants.walletClosureMinBtcBalance, fixtures_1.constants.walletMaxAge, fixtures_1.constants.walletMaxBtcTransfer, fixtures_1.constants.walletClosingPeriod)).to.be.revertedWith("Caller is not the governance");
344
+ });
345
+ });
346
+ });
347
+ describe("updateFraudParameters", () => {
348
+ context("when caller is the contract guvnor", () => {
349
+ context("when all new parameter values are correct", () => {
350
+ const newFraudChallengeDepositAmount = fixtures_1.constants.fraudChallengeDepositAmount.mul(4);
351
+ const newFraudChallengeDefeatTimeout = fixtures_1.constants.fraudChallengeDefeatTimeout * 3;
352
+ const newFraudSlashingAmount = fixtures_1.constants.fraudSlashingAmount.mul(2);
353
+ const newFraudNotifierRewardMultiplier = fixtures_1.constants.fraudNotifierRewardMultiplier / 4;
354
+ let tx;
355
+ before(async () => {
356
+ await createSnapshot();
357
+ tx = await bridge
358
+ .connect(governance)
359
+ .updateFraudParameters(newFraudChallengeDepositAmount, newFraudChallengeDefeatTimeout, newFraudSlashingAmount, newFraudNotifierRewardMultiplier);
360
+ });
361
+ after(async () => {
362
+ await restoreSnapshot();
363
+ });
364
+ it("should set correct values", async () => {
365
+ const params = await bridge.fraudParameters();
366
+ (0, chai_1.expect)(params.fraudChallengeDepositAmount).to.be.equal(newFraudChallengeDepositAmount);
367
+ (0, chai_1.expect)(params.fraudChallengeDefeatTimeout).to.be.equal(newFraudChallengeDefeatTimeout);
368
+ (0, chai_1.expect)(params.fraudSlashingAmount).to.be.equal(newFraudSlashingAmount);
369
+ (0, chai_1.expect)(params.fraudNotifierRewardMultiplier).to.be.equal(newFraudNotifierRewardMultiplier);
370
+ });
371
+ it("should emit FraudParametersUpdated event", async () => {
372
+ await (0, chai_1.expect)(tx)
373
+ .to.emit(bridge, "FraudParametersUpdated")
374
+ .withArgs(newFraudChallengeDepositAmount, newFraudChallengeDefeatTimeout, newFraudSlashingAmount, newFraudNotifierRewardMultiplier);
375
+ });
376
+ });
377
+ context("when new fraud challenge defeat timeout is zero", () => {
378
+ it("should revert", async () => {
379
+ await (0, chai_1.expect)(bridge
380
+ .connect(governance)
381
+ .updateFraudParameters(fixtures_1.constants.fraudChallengeDepositAmount, 0, fixtures_1.constants.fraudSlashingAmount, fixtures_1.constants.fraudNotifierRewardMultiplier)).to.be.revertedWith("Fraud challenge defeat timeout must be greater than zero");
382
+ });
383
+ });
384
+ context("when new fraud notifier reward multiplier is greater than 100", () => {
385
+ it("should revert", async () => {
386
+ await (0, chai_1.expect)(bridge
387
+ .connect(governance)
388
+ .updateFraudParameters(fixtures_1.constants.fraudChallengeDepositAmount, fixtures_1.constants.fraudChallengeDefeatTimeout, fixtures_1.constants.fraudSlashingAmount, 101)).to.be.revertedWith("Fraud notifier reward multiplier must be in the range [0, 100]");
389
+ });
390
+ });
391
+ });
392
+ context("when caller is not the contract guvnor", () => {
393
+ it("should revert", async () => {
394
+ await (0, chai_1.expect)(bridge
395
+ .connect(thirdParty)
396
+ .updateFraudParameters(fixtures_1.constants.fraudChallengeDepositAmount, fixtures_1.constants.fraudChallengeDefeatTimeout, fixtures_1.constants.fraudSlashingAmount, fixtures_1.constants.fraudNotifierRewardMultiplier)).to.be.revertedWith("Caller is not the governance");
397
+ });
398
+ });
399
+ });
400
+ });