@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.
- package/README.adoc +12 -0
- package/artifacts/.chainId +1 -1
- package/artifacts/Bank.json +807 -0
- package/artifacts/Bridge.json +2300 -0
- package/artifacts/Deposit.json +117 -0
- package/artifacts/DepositSweep.json +77 -0
- package/artifacts/EcdsaDkgValidator.json +532 -0
- package/artifacts/EcdsaInactivity.json +156 -0
- package/artifacts/EcdsaSortitionPool.json +1004 -0
- package/artifacts/Fraud.json +164 -0
- package/artifacts/KeepRegistry.json +99 -0
- package/artifacts/KeepStake.json +286 -0
- package/artifacts/KeepToken.json +711 -0
- package/artifacts/KeepTokenStaking.json +483 -0
- package/artifacts/MovingFunds.json +249 -0
- package/artifacts/NuCypherStakingEscrow.json +256 -0
- package/artifacts/NuCypherToken.json +711 -0
- package/artifacts/RandomBeaconStub.json +141 -0
- package/artifacts/Redemption.json +174 -0
- package/artifacts/ReimbursementPool.json +509 -0
- package/artifacts/Relay.json +123 -0
- package/artifacts/T.json +1148 -0
- package/artifacts/TBTC.json +36 -35
- package/artifacts/TBTCToken.json +738 -0
- package/artifacts/TBTCVault.json +691 -0
- package/artifacts/TokenStaking.json +2288 -0
- package/artifacts/TokenholderGovernor.json +1795 -0
- package/artifacts/TokenholderTimelock.json +1058 -0
- package/artifacts/VendingMachine.json +34 -33
- package/artifacts/VendingMachineKeep.json +400 -0
- package/artifacts/VendingMachineNuCypher.json +400 -0
- package/artifacts/WalletRegistry.json +1843 -0
- package/artifacts/WalletRegistryGovernance.json +2754 -0
- package/artifacts/Wallets.json +186 -0
- package/artifacts/solcInputs/5e62cff1ead0900b07facca4b559e818.json +314 -0
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.json +2 -2
- package/build/contracts/bank/Bank.sol/Bank.dbg.json +4 -0
- package/build/contracts/bank/Bank.sol/Bank.json +542 -0
- package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.dbg.json +4 -0
- package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.json +34 -0
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +4 -0
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +10 -0
- package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +4 -0
- package/build/contracts/bridge/Bridge.sol/Bridge.json +2686 -0
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +4 -0
- package/build/contracts/bridge/BridgeState.sol/BridgeState.json +226 -0
- package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +4 -0
- package/build/contracts/bridge/Deposit.sol/Deposit.json +72 -0
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +4 -0
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.json +30 -0
- package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +4 -0
- package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.json +10 -0
- package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +4 -0
- package/build/contracts/bridge/Fraud.sol/Fraud.json +86 -0
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +4 -0
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.json +10 -0
- package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +4 -0
- package/build/contracts/bridge/IRelay.sol/IRelay.json +37 -0
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +4 -0
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +138 -0
- package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +4 -0
- package/build/contracts/bridge/Redemption.sol/OutboundTx.json +10 -0
- package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +4 -0
- package/build/contracts/bridge/Redemption.sol/Redemption.json +92 -0
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.json +2 -2
- package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +4 -0
- package/build/contracts/bridge/Wallets.sol/Wallets.json +112 -0
- package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/token/TBTC.sol/TBTC.json +4 -4
- package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +4 -0
- package/build/contracts/vault/DonationVault.sol/DonationVault.json +108 -0
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +4 -0
- package/build/contracts/vault/IVault.sol/IVault.json +52 -0
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +4 -0
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +449 -0
- package/contracts/GovernanceUtils.sol +4 -4
- package/contracts/bank/Bank.sol +436 -0
- package/contracts/bank/IReceiveBalanceApproval.sol +45 -0
- package/contracts/bridge/BitcoinTx.sol +326 -0
- package/contracts/bridge/Bridge.sol +1793 -0
- package/contracts/bridge/BridgeState.sol +739 -0
- package/contracts/bridge/Deposit.sol +269 -0
- package/contracts/bridge/DepositSweep.sol +574 -0
- package/contracts/bridge/EcdsaLib.sol +45 -0
- package/contracts/bridge/Fraud.sol +579 -0
- package/contracts/bridge/Heartbeat.sol +112 -0
- package/contracts/bridge/IRelay.sol +28 -0
- package/contracts/bridge/MovingFunds.sol +1077 -0
- package/contracts/bridge/Redemption.sol +1020 -0
- package/contracts/bridge/VendingMachine.sol +2 -2
- package/contracts/bridge/Wallets.sol +719 -0
- package/contracts/hardhat-dependency-compiler/.hardhat-dependency-compiler +1 -0
- package/contracts/hardhat-dependency-compiler/@keep-network/ecdsa/contracts/WalletRegistry.sol +3 -0
- package/contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol +3 -0
- package/contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +3 -0
- package/contracts/token/TBTC.sol +1 -1
- package/contracts/vault/DonationVault.sol +125 -0
- package/contracts/vault/IVault.sol +44 -0
- package/contracts/vault/TBTCVault.sol +305 -0
- package/deploy/00_resolve_relay.ts +28 -0
- package/deploy/00_resolve_tbtc_v1_token.ts +1 -1
- package/deploy/01_deploy_tbtc_v2_token.ts +8 -1
- package/deploy/02_deploy_vending_machine.ts +7 -0
- package/deploy/{03_transfer_roles.ts → 03_transfer_vending_machine_roles.ts} +1 -1
- package/deploy/04_deploy_bank.ts +27 -0
- package/deploy/05_deploy_bridge.ts +80 -0
- package/deploy/06_deploy_tbtc_vault.ts +30 -0
- package/deploy/07_bank_update_bridge.ts +19 -0
- package/deploy/08_transfer_bank_ownership.ts +15 -0
- package/deploy/09_transfer_tbtc_vault_ownership.ts +15 -0
- package/deploy/10_transfer_bridge_governance.ts +20 -0
- package/deploy/11_initialize_wallet_owner.ts +18 -0
- package/deploy/11_transfer_proxy_admin_ownership.ts +30 -0
- package/deploy/12_deploy_proxy_admin_with_deputy.ts +33 -0
- package/export/deploy/00_resolve_relay.js +24 -0
- package/export/deploy/00_resolve_tbtc_v1_token.js +24 -0
- package/export/deploy/01_deploy_tbtc_v2_token.js +19 -0
- package/export/deploy/02_deploy_vending_machine.js +25 -0
- package/export/deploy/03_transfer_vending_machine_roles.js +19 -0
- package/export/deploy/04_deploy_bank.js +21 -0
- package/export/deploy/05_deploy_bridge.js +69 -0
- package/export/deploy/06_deploy_tbtc_vault.js +24 -0
- package/export/deploy/07_bank_update_bridge.js +13 -0
- package/export/deploy/08_transfer_bank_ownership.js +11 -0
- package/export/deploy/09_transfer_tbtc_vault_ownership.js +11 -0
- package/export/deploy/10_transfer_bridge_governance.js +11 -0
- package/export/deploy/11_initialize_wallet_owner.js +14 -0
- package/export/deploy/11_transfer_proxy_admin_ownership.js +23 -0
- package/export/deploy/12_deploy_proxy_admin_with_deputy.js +22 -0
- package/export/hardhat.config.js +169 -0
- package/export/test/bank/Bank.test.js +1012 -0
- package/export/test/bridge/Bridge.Deployment.test.js +76 -0
- package/export/test/bridge/Bridge.Deposit.test.js +1834 -0
- package/export/test/bridge/Bridge.Frauds.test.js +1349 -0
- package/export/test/bridge/Bridge.MovingFunds.test.js +2437 -0
- package/export/test/bridge/Bridge.Parameters.test.js +400 -0
- package/export/test/bridge/Bridge.Redemption.test.js +2523 -0
- package/export/test/bridge/Bridge.Vaults.test.js +74 -0
- package/export/test/bridge/Bridge.Wallets.test.js +1017 -0
- package/export/test/bridge/EcdsaLib.test.js +46 -0
- package/export/test/bridge/Heartbeat.test.js +77 -0
- package/export/test/bridge/VendingMachine.Upgrade.test.js +160 -0
- package/export/test/bridge/VendingMachine.test.js +762 -0
- package/export/test/data/deposit-sweep.js +655 -0
- package/export/test/data/ecdsa.js +18 -0
- package/export/test/data/fraud.js +158 -0
- package/export/test/data/moving-funds.js +815 -0
- package/export/test/data/redemption.js +1011 -0
- package/export/test/fixtures/bridge.js +54 -0
- package/export/test/fixtures/index.js +57 -0
- package/export/test/helpers/contract-test-helpers.js +18 -0
- package/export/test/integration/Slashing.test.js +279 -0
- package/export/test/integration/WalleCreation.test.js +66 -0
- package/export/test/integration/utils/ecdsa-wallet-registry.js +137 -0
- package/export/test/integration/utils/fixture.js +77 -0
- package/export/test/integration/utils/gas.js +36 -0
- package/export/test/integration/utils/random-beacon.js +26 -0
- package/export/test/integration/utils/staking.js +19 -0
- package/export/test/vault/DonationVault.test.js +202 -0
- package/export/test/vault/TBTCVault.Redemption.test.js +357 -0
- package/export/test/vault/TBTCVault.test.js +768 -0
- package/export/typechain/BTCUtils.js +2 -0
- package/export/typechain/Bank.js +2 -0
- package/export/typechain/BankStub.js +2 -0
- package/export/typechain/Bridge.js +2 -0
- package/export/typechain/BridgeState.js +2 -0
- package/export/typechain/BridgeStub.js +2 -0
- package/export/typechain/Deposit.js +2 -0
- package/export/typechain/DepositSweep.js +2 -0
- package/export/typechain/DonationVault.js +2 -0
- package/export/typechain/ERC165.js +2 -0
- package/export/typechain/ERC1967Proxy.js +2 -0
- package/export/typechain/ERC1967Upgrade.js +2 -0
- package/export/typechain/ERC20WithPermit.js +2 -0
- package/export/typechain/ERC721.js +2 -0
- package/export/typechain/EcdsaAuthorization.js +2 -0
- package/export/typechain/EcdsaDkg.js +2 -0
- package/export/typechain/EcdsaDkgValidator.js +2 -0
- package/export/typechain/EcdsaInactivity.js +2 -0
- package/export/typechain/Fraud.js +2 -0
- package/export/typechain/Governable.js +2 -0
- package/export/typechain/HeartbeatStub.js +2 -0
- package/export/typechain/IApplication.js +2 -0
- package/export/typechain/IApproveAndCall.js +2 -0
- package/export/typechain/IBeacon.js +2 -0
- package/export/typechain/IERC165.js +2 -0
- package/export/typechain/IERC1822Proxiable.js +2 -0
- package/export/typechain/IERC20.js +2 -0
- package/export/typechain/IERC20Metadata.js +2 -0
- package/export/typechain/IERC20WithPermit.js +2 -0
- package/export/typechain/IERC721.js +2 -0
- package/export/typechain/IERC721Metadata.js +2 -0
- package/export/typechain/IERC721Receiver.js +2 -0
- package/export/typechain/IRandomBeacon.js +2 -0
- package/export/typechain/IRandomBeaconConsumer.js +2 -0
- package/export/typechain/IReceiveApproval.js +2 -0
- package/export/typechain/IReceiveBalanceApproval.js +2 -0
- package/export/typechain/IRelay.js +2 -0
- package/export/typechain/IStaking.js +2 -0
- package/export/typechain/IVault.js +2 -0
- package/export/typechain/IWalletOwner.js +2 -0
- package/export/typechain/IWalletRegistry.js +2 -0
- package/export/typechain/Initializable.js +2 -0
- package/export/typechain/MisfundRecovery.js +2 -0
- package/export/typechain/MovingFunds.js +2 -0
- package/export/typechain/Ownable.js +2 -0
- package/export/typechain/Proxy.js +2 -0
- package/export/typechain/ProxyAdmin.js +2 -0
- package/export/typechain/ReceiveApprovalStub.js +2 -0
- package/export/typechain/Redemption.js +2 -0
- package/export/typechain/Reimbursable.js +2 -0
- package/export/typechain/ReimbursementPool.js +2 -0
- package/export/typechain/Rewards.js +2 -0
- package/export/typechain/SortitionPool.js +2 -0
- package/export/typechain/SortitionTree.js +2 -0
- package/export/typechain/TBTC.js +2 -0
- package/export/typechain/TBTCVault.js +2 -0
- package/export/typechain/TestERC20.js +2 -0
- package/export/typechain/TestERC721.js +2 -0
- package/export/typechain/TestEcdsaLib.js +2 -0
- package/export/typechain/TestRelay.js +2 -0
- package/export/typechain/TransparentUpgradeableProxy.js +2 -0
- package/export/typechain/VendingMachine.js +2 -0
- package/export/typechain/WalletRegistry.js +2 -0
- package/export/typechain/Wallets.js +2 -0
- package/export/typechain/common.js +2 -0
- package/export/typechain/factories/BTCUtils__factory.js +94 -0
- package/export/typechain/factories/BankStub__factory.js +586 -0
- package/export/typechain/factories/Bank__factory.js +573 -0
- package/export/typechain/factories/BridgeState__factory.js +257 -0
- package/export/typechain/factories/BridgeStub__factory.js +2912 -0
- package/export/typechain/factories/Bridge__factory.js +2526 -0
- package/export/typechain/factories/DepositSweep__factory.js +61 -0
- package/export/typechain/factories/Deposit__factory.js +103 -0
- package/export/typechain/factories/DonationVault__factory.js +139 -0
- package/export/typechain/factories/ERC165__factory.js +38 -0
- package/export/typechain/factories/ERC1967Proxy__factory.js +111 -0
- package/export/typechain/factories/ERC1967Upgrade__factory.js +64 -0
- package/export/typechain/factories/ERC20WithPermit__factory.js +524 -0
- package/export/typechain/factories/ERC721__factory.js +388 -0
- package/export/typechain/factories/EcdsaAuthorization__factory.js +211 -0
- package/export/typechain/factories/EcdsaDkgValidator__factory.js +441 -0
- package/export/typechain/factories/EcdsaDkg__factory.js +192 -0
- package/export/typechain/factories/EcdsaInactivity__factory.js +134 -0
- package/export/typechain/factories/Fraud__factory.js +117 -0
- package/export/typechain/factories/Governable__factory.js +64 -0
- package/export/typechain/factories/HeartbeatStub__factory.js +61 -0
- package/export/typechain/factories/IApplication__factory.js +152 -0
- package/export/typechain/factories/IApproveAndCall__factory.js +48 -0
- package/export/typechain/factories/IBeacon__factory.js +32 -0
- package/export/typechain/factories/IERC165__factory.js +38 -0
- package/export/typechain/factories/IERC1822Proxiable__factory.js +32 -0
- package/export/typechain/factories/IERC20Metadata__factory.js +241 -0
- package/export/typechain/factories/IERC20WithPermit__factory.js +389 -0
- package/export/typechain/factories/IERC20__factory.js +202 -0
- package/export/typechain/factories/IERC721Metadata__factory.js +349 -0
- package/export/typechain/factories/IERC721Receiver__factory.js +53 -0
- package/export/typechain/factories/IERC721__factory.js +304 -0
- package/export/typechain/factories/IRandomBeaconConsumer__factory.js +37 -0
- package/export/typechain/factories/IRandomBeacon__factory.js +32 -0
- package/export/typechain/factories/IReceiveApproval__factory.js +47 -0
- package/export/typechain/factories/IReceiveBalanceApproval__factory.js +42 -0
- package/export/typechain/factories/IRelay__factory.js +45 -0
- package/export/typechain/factories/IStaking__factory.js +722 -0
- package/export/typechain/factories/IVault__factory.js +60 -0
- package/export/typechain/factories/IWalletOwner__factory.js +65 -0
- package/export/typechain/factories/IWalletRegistry__factory.js +138 -0
- package/export/typechain/factories/Initializable__factory.js +32 -0
- package/export/typechain/factories/MisfundRecovery__factory.js +145 -0
- package/export/typechain/factories/MovingFunds__factory.js +169 -0
- package/export/typechain/factories/Ownable__factory.js +71 -0
- package/export/typechain/factories/ProxyAdmin__factory.js +191 -0
- package/export/typechain/factories/Proxy__factory.js +27 -0
- package/export/typechain/factories/ReceiveApprovalStub__factory.js +127 -0
- package/export/typechain/factories/Redemption__factory.js +123 -0
- package/export/typechain/factories/Reimbursable__factory.js +58 -0
- package/export/typechain/factories/ReimbursementPool__factory.js +350 -0
- package/export/typechain/factories/Rewards__factory.js +117 -0
- package/export/typechain/factories/SortitionPool__factory.js +610 -0
- package/export/typechain/factories/SortitionTree__factory.js +149 -0
- package/export/typechain/factories/TBTCVault__factory.js +480 -0
- package/export/typechain/factories/TBTC__factory.js +564 -0
- package/export/typechain/factories/TestERC20__factory.js +539 -0
- package/export/typechain/factories/TestERC721__factory.js +421 -0
- package/export/typechain/factories/TestEcdsaLib__factory.js +66 -0
- package/export/typechain/factories/TestRelay__factory.js +94 -0
- package/export/typechain/factories/TransparentUpgradeableProxy__factory.js +186 -0
- package/export/typechain/factories/VendingMachine__factory.js +549 -0
- package/export/typechain/factories/WalletRegistry__factory.js +1919 -0
- package/export/typechain/factories/Wallets__factory.js +143 -0
- package/export/typechain/index.js +132 -0
- package/export.json +15932 -503
- package/package.json +47 -26
- 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
|
+
});
|