@keep-network/tbtc-v2 0.1.1-dev.43 → 0.1.1-dev.46

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 (75) hide show
  1. package/artifacts/Bank.json +742 -0
  2. package/artifacts/Bridge.json +2961 -0
  3. package/artifacts/Deposit.json +117 -0
  4. package/artifacts/EcdsaDkgValidator.json +532 -0
  5. package/artifacts/EcdsaInactivity.json +156 -0
  6. package/artifacts/Fraud.json +153 -0
  7. package/artifacts/KeepRegistry.json +99 -0
  8. package/artifacts/KeepStake.json +286 -0
  9. package/artifacts/KeepToken.json +711 -0
  10. package/artifacts/KeepTokenStaking.json +483 -0
  11. package/artifacts/MovingFunds.json +137 -0
  12. package/artifacts/NuCypherStakingEscrow.json +256 -0
  13. package/artifacts/NuCypherToken.json +711 -0
  14. package/artifacts/RandomBeaconStub.json +141 -0
  15. package/artifacts/Redemption.json +161 -0
  16. package/artifacts/ReimbursementPool.json +509 -0
  17. package/artifacts/Relay.json +123 -0
  18. package/artifacts/SortitionPool.json +944 -0
  19. package/artifacts/Sweep.json +76 -0
  20. package/artifacts/T.json +1148 -0
  21. package/artifacts/TBTC.json +21 -21
  22. package/artifacts/TBTCToken.json +21 -21
  23. package/artifacts/TokenStaking.json +2288 -0
  24. package/artifacts/TokenholderGovernor.json +1795 -0
  25. package/artifacts/TokenholderTimelock.json +1058 -0
  26. package/artifacts/VendingMachine.json +24 -24
  27. package/artifacts/VendingMachineKeep.json +400 -0
  28. package/artifacts/VendingMachineNuCypher.json +400 -0
  29. package/artifacts/WalletRegistry.json +2709 -0
  30. package/artifacts/WalletRegistryGovernance.json +2364 -0
  31. package/artifacts/Wallets.json +186 -0
  32. package/artifacts/solcInputs/{f2c15d3cf1bd9566483f595c5ed30ccc.json → 75d54bcf8c4f0b65acb7ec6a1fb9af9d.json} +19 -19
  33. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
  34. package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
  35. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
  36. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +2 -2
  37. package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
  38. package/build/contracts/bridge/Bridge.sol/Bridge.json +438 -31
  39. package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
  40. package/build/contracts/bridge/BridgeState.sol/BridgeState.json +120 -2
  41. package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
  42. package/build/contracts/bridge/Deposit.sol/Deposit.json +2 -2
  43. package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
  44. package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
  45. package/build/contracts/bridge/Fraud.sol/Fraud.json +5 -5
  46. package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
  47. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
  48. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +40 -2
  49. package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
  50. package/build/contracts/bridge/Redemption.sol/OutboundTx.json +2 -2
  51. package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
  52. package/build/contracts/bridge/Redemption.sol/Redemption.json +2 -2
  53. package/build/contracts/bridge/Sweep.sol/Sweep.dbg.json +1 -1
  54. package/build/contracts/bridge/Sweep.sol/Sweep.json +2 -2
  55. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
  56. package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
  57. package/build/contracts/bridge/Wallets.sol/Wallets.json +21 -2
  58. package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
  59. package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
  60. package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
  61. package/contracts/bridge/Bridge.sol +313 -18
  62. package/contracts/bridge/BridgeState.sol +288 -5
  63. package/contracts/bridge/Deposit.sol +2 -2
  64. package/contracts/bridge/Fraud.sol +47 -17
  65. package/contracts/bridge/MovingFunds.sol +181 -1
  66. package/contracts/bridge/Redemption.sol +7 -12
  67. package/contracts/bridge/Sweep.sol +0 -3
  68. package/contracts/bridge/Wallets.sol +74 -33
  69. package/deploy/00_resolve_relay.ts +28 -0
  70. package/deploy/04_deploy_bank.ts +25 -0
  71. package/deploy/05_deploy_bridge.ts +60 -0
  72. package/deploy/06_bank_update_bridge.ts +19 -0
  73. package/deploy/07_transfer_ownership.ts +17 -0
  74. package/export.json +14827 -460
  75. package/package.json +2 -2
@@ -53,6 +53,10 @@ import "../bank/Bank.sol";
53
53
  /// @dev Bridge is an upgradeable component of the Bank. The order of
54
54
  /// functionalities in this contract is: deposit, sweep, redemption,
55
55
  /// moving funds, wallet lifecycle, frauds, parameters.
56
+ ///
57
+ /// TODO: Revisit all events and look which parameters should be indexed.
58
+ /// TODO: Align the convention around `param` and `dev` endings. They should
59
+ /// not have a punctuation mark.
56
60
  contract Bridge is Ownable, EcdsaWalletOwner {
57
61
  using BridgeState for BridgeState.Storage;
58
62
  using Deposit for BridgeState.Storage;
@@ -102,11 +106,19 @@ contract Bridge is Ownable, EcdsaWalletOwner {
102
106
  bytes20 indexed walletPubKeyHash
103
107
  );
104
108
 
109
+ event MovingFundsCommitmentSubmitted(
110
+ bytes20 walletPubKeyHash,
111
+ bytes20[] targetWallets,
112
+ address submitter
113
+ );
114
+
105
115
  event MovingFundsCompleted(
106
116
  bytes20 walletPubKeyHash,
107
117
  bytes32 movingFundsTxHash
108
118
  );
109
119
 
120
+ event MovingFundsTimedOut(bytes20 walletPubKeyHash);
121
+
110
122
  event NewWalletRequested();
111
123
 
112
124
  event NewWalletRegistered(
@@ -114,6 +126,11 @@ contract Bridge is Ownable, EcdsaWalletOwner {
114
126
  bytes20 indexed walletPubKeyHash
115
127
  );
116
128
 
129
+ event WalletClosing(
130
+ bytes32 indexed ecdsaWalletID,
131
+ bytes20 indexed walletPubKeyHash
132
+ );
133
+
117
134
  event WalletClosed(
118
135
  bytes32 indexed ecdsaWalletID,
119
136
  bytes20 indexed walletPubKeyHash
@@ -125,27 +142,54 @@ contract Bridge is Ownable, EcdsaWalletOwner {
125
142
  );
126
143
 
127
144
  event FraudChallengeSubmitted(
128
- bytes20 walletPublicKeyHash,
145
+ bytes20 walletPubKeyHash,
129
146
  bytes32 sighash,
130
147
  uint8 v,
131
148
  bytes32 r,
132
149
  bytes32 s
133
150
  );
134
151
 
135
- event FraudChallengeDefeated(bytes20 walletPublicKeyHash, bytes32 sighash);
152
+ event FraudChallengeDefeated(bytes20 walletPubKeyHash, bytes32 sighash);
136
153
 
137
154
  event FraudChallengeDefeatTimedOut(
138
- bytes20 walletPublicKeyHash,
155
+ bytes20 walletPubKeyHash,
139
156
  bytes32 sighash
140
157
  );
141
158
 
142
159
  event VaultStatusUpdated(address indexed vault, bool isTrusted);
143
160
 
161
+ event DepositParametersUpdated(
162
+ uint64 depositDustThreshold,
163
+ uint64 depositTreasuryFeeDivisor,
164
+ uint64 depositTxMaxFee
165
+ );
166
+
167
+ event RedemptionParametersUpdated(
168
+ uint64 redemptionDustThreshold,
169
+ uint64 redemptionTreasuryFeeDivisor,
170
+ uint64 redemptionTxMaxFee,
171
+ uint256 redemptionTimeout
172
+ );
173
+
174
+ event MovingFundsParametersUpdated(
175
+ uint64 movingFundsTxMaxTotalFee,
176
+ uint32 movingFundsTimeout
177
+ );
178
+
144
179
  event WalletParametersUpdated(
145
180
  uint32 walletCreationPeriod,
146
181
  uint64 walletMinBtcBalance,
147
182
  uint64 walletMaxBtcBalance,
148
- uint32 walletMaxAge
183
+ uint32 walletMaxAge,
184
+ uint64 walletMaxBtcTransfer,
185
+ uint32 walletClosingPeriod
186
+ );
187
+
188
+ event FraudParametersUpdated(
189
+ uint256 fraudSlashingAmount,
190
+ uint256 fraudNotifierRewardMultiplier,
191
+ uint256 fraudChallengeDefeatTimeout,
192
+ uint256 fraudChallengeDepositAmount
149
193
  );
150
194
 
151
195
  constructor(
@@ -181,6 +225,7 @@ contract Bridge is Ownable, EcdsaWalletOwner {
181
225
  self.redemptionTxMaxFee = 10000; // 10000 satoshi
182
226
  self.redemptionTimeout = 172800; // 48 hours
183
227
  self.movingFundsTxMaxTotalFee = 10000; // 10000 satoshi
228
+ self.movingFundsTimeout = 7 days;
184
229
  self.fraudSlashingAmount = 10000 * 1e18; // 10000 T
185
230
  self.fraudNotifierRewardMultiplier = 100; // 100%
186
231
  self.fraudChallengeDefeatTimeout = 7 days;
@@ -189,6 +234,8 @@ contract Bridge is Ownable, EcdsaWalletOwner {
189
234
  self.walletMinBtcBalance = 1e8; // 1 BTC
190
235
  self.walletMaxBtcBalance = 10e8; // 10 BTC
191
236
  self.walletMaxAge = 26 weeks; // ~6 months
237
+ self.walletMaxBtcTransfer = 10e8; // 10 BTC
238
+ self.walletClosingPeriod = 40 days;
192
239
  }
193
240
 
194
241
  /// @notice Used by the depositor to reveal information about their P2(W)SH
@@ -408,6 +455,61 @@ contract Bridge is Ownable, EcdsaWalletOwner {
408
455
  self.notifyRedemptionTimeout(walletPubKeyHash, redeemerOutputScript);
409
456
  }
410
457
 
458
+ /// @notice Submits the moving funds target wallets commitment.
459
+ /// Once all requirements are met, that function registers the
460
+ /// target wallets commitment and opens the way for moving funds
461
+ /// proof submission.
462
+ /// @param walletPubKeyHash 20-byte public key hash of the source wallet
463
+ /// @param walletMainUtxo Data of the source wallet's main UTXO, as
464
+ /// currently known on the Ethereum chain
465
+ /// @param walletMembersIDs Identifiers of the source wallet signing group
466
+ /// members
467
+ /// @param walletMemberIndex Position of the caller in the source wallet
468
+ /// signing group members list
469
+ /// @param targetWallets List of 20-byte public key hashes of the target
470
+ /// wallets that the source wallet commits to move the funds to
471
+ /// @dev Requirements:
472
+ /// - The source wallet must be in the MovingFunds state
473
+ /// - The source wallet must not have pending redemption requests
474
+ /// - The source wallet must not have submitted its commitment already
475
+ /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
476
+ /// be exactly the same as the hash stored under `membersIdsHash`
477
+ /// for the given source wallet in the ECDSA registry. Those IDs are
478
+ /// not directly stored in the contract for gas efficiency purposes
479
+ /// but they can be read from appropriate `DkgResultSubmitted`
480
+ /// and `DkgResultApproved` events.
481
+ /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length]
482
+ /// - The caller must be the member of the source wallet signing group
483
+ /// at the position indicated by `walletMemberIndex` parameter
484
+ /// - The `walletMainUtxo` components must point to the recent main
485
+ /// UTXO of the source wallet, as currently known on the Ethereum
486
+ /// chain.
487
+ /// - Source wallet BTC balance must be greater than zero
488
+ /// - At least one Live wallet must exist in the system
489
+ /// - Submitted target wallets count must match the expected count
490
+ /// `N = min(liveWalletsCount, ceil(walletBtcBalance / walletMaxBtcTransfer))`
491
+ /// where `N > 0`
492
+ /// - Each target wallet must be not equal to the source wallet
493
+ /// - Each target wallet must follow the expected order i.e. all
494
+ /// target wallets 20-byte public key hashes represented as numbers
495
+ /// must form a strictly increasing sequence without duplicates.
496
+ /// - Each target wallet must be in Live state
497
+ function submitMovingFundsCommitment(
498
+ bytes20 walletPubKeyHash,
499
+ BitcoinTx.UTXO calldata walletMainUtxo,
500
+ uint32[] calldata walletMembersIDs,
501
+ uint256 walletMemberIndex,
502
+ bytes20[] calldata targetWallets
503
+ ) external {
504
+ self.submitMovingFundsCommitment(
505
+ walletPubKeyHash,
506
+ walletMainUtxo,
507
+ walletMembersIDs,
508
+ walletMemberIndex,
509
+ targetWallets
510
+ );
511
+ }
512
+
411
513
  /// @notice Used by the wallet to prove the BTC moving funds transaction
412
514
  /// and to make the necessary state changes. Moving funds is only
413
515
  /// accepted if it satisfies SPV proof.
@@ -467,6 +569,16 @@ contract Bridge is Ownable, EcdsaWalletOwner {
467
569
  );
468
570
  }
469
571
 
572
+ /// @notice Notifies about a timed out moving funds process. Terminates
573
+ /// the wallet and slashes signing group members as a result.
574
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet
575
+ /// @dev Requirements:
576
+ /// - The wallet must be in the MovingFunds state
577
+ /// - The moving funds timeout must be actually exceeded
578
+ function notifyMovingFundsTimeout(bytes20 walletPubKeyHash) external {
579
+ self.notifyMovingFundsTimeout(walletPubKeyHash);
580
+ }
581
+
470
582
  /// @notice Requests creation of a new wallet. This function just
471
583
  /// forms a request and the creation process is performed
472
584
  /// asynchronously. Once a wallet is created, the ECDSA Wallet
@@ -525,7 +637,7 @@ contract Bridge is Ownable, EcdsaWalletOwner {
525
637
  }
526
638
 
527
639
  /// @notice Notifies that the wallet is either old enough or has too few
528
- /// satoshis left and qualifies to be closed.
640
+ /// satoshi left and qualifies to be closed.
529
641
  /// @param walletPubKeyHash 20-byte public key hash of the wallet
530
642
  /// @param walletMainUtxo Data of the wallet's main UTXO, as currently
531
643
  /// known on the Ethereum chain.
@@ -546,6 +658,19 @@ contract Bridge is Ownable, EcdsaWalletOwner {
546
658
  self.notifyCloseableWallet(walletPubKeyHash, walletMainUtxo);
547
659
  }
548
660
 
661
+ /// @notice Notifies about the end of the closing period for the given wallet.
662
+ /// Closes the wallet ultimately and notifies the ECDSA registry
663
+ /// about this fact.
664
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet
665
+ /// @dev Requirements:
666
+ /// - The wallet must be in the Closing state
667
+ /// - The wallet closing period must have elapsed
668
+ function notifyWalletClosingPeriodElapsed(bytes20 walletPubKeyHash)
669
+ external
670
+ {
671
+ self.notifyWalletClosingPeriodElapsed(walletPubKeyHash);
672
+ }
673
+
549
674
  /// @notice Submits a fraud challenge indicating that a UTXO being under
550
675
  /// wallet control was unlocked by the wallet but was not used
551
676
  /// according to the protocol rules. That means the wallet signed
@@ -571,8 +696,8 @@ contract Bridge is Ownable, EcdsaWalletOwner {
571
696
  /// for reference
572
697
  /// @param signature Bitcoin signature in the R/S/V format
573
698
  /// @dev Requirements:
574
- /// - Wallet behind `walletPubKey` must be in `Live` or `MovingFunds`
575
- /// state
699
+ /// - Wallet behind `walletPublicKey` must be in Live or MovingFunds
700
+ /// or Closing state
576
701
  /// - The challenger must send appropriate amount of ETH used as
577
702
  /// fraud challenge deposit
578
703
  /// - The signature (represented by r, s and v) must be generated by
@@ -670,40 +795,187 @@ contract Bridge is Ownable, EcdsaWalletOwner {
670
795
  emit VaultStatusUpdated(vault, isTrusted);
671
796
  }
672
797
 
673
- // TODO: updateDepositParameters
674
- // TODO: updateRedemptionParameters
675
- // TODO: updateMovingFundsParameters
798
+ /// @notice Updates parameters of deposits.
799
+ /// @param depositDustThreshold New value of the deposit dust threshold in
800
+ /// satoshis. It is the minimal amount that can be requested to
801
+ //// deposit. Value of this parameter must take into account the value
802
+ /// of `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters
803
+ /// in order to make requests that can incur the treasury and
804
+ /// transaction fee and still satisfy the depositor
805
+ /// @param depositTreasuryFeeDivisor New value of the treasury fee divisor.
806
+ /// It is the divisor used to compute the treasury fee taken from
807
+ /// each deposit and transferred to the treasury upon sweep proof
808
+ /// submission. That fee is computed as follows:
809
+ /// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`
810
+ /// For example, if the treasury fee needs to be 2% of each deposit,
811
+ /// the `depositTreasuryFeeDivisor` should be set to `50`
812
+ /// because `1/50 = 0.02 = 2%`
813
+ /// @param depositTxMaxFee New value of the deposit tx max fee in satoshis.
814
+ /// It is the maximum amount of BTC transaction fee that can
815
+ /// be incurred by each swept deposit being part of the given sweep
816
+ /// transaction. If the maximum BTC transaction fee is exceeded,
817
+ /// such transaction is considered a fraud
818
+ /// @dev Requirements:
819
+ /// - Deposit dust threshold must be greater than zero
820
+ /// - Deposit treasury fee divisor must be greater than zero
821
+ /// - Deposit transaction max fee must be greater than zero
822
+ function updateDepositParameters(
823
+ uint64 depositDustThreshold,
824
+ uint64 depositTreasuryFeeDivisor,
825
+ uint64 depositTxMaxFee
826
+ ) external onlyOwner {
827
+ self.updateDepositParameters(
828
+ depositDustThreshold,
829
+ depositTreasuryFeeDivisor,
830
+ depositTxMaxFee
831
+ );
832
+ }
833
+
834
+ /// @notice Updates parameters of redemptions.
835
+ /// @param redemptionDustThreshold New value of the redemption dust
836
+ /// threshold in satoshis. It is the minimal amount that can be
837
+ /// requested for redemption. Value of this parameter must take into
838
+ /// account the value of `redemptionTreasuryFeeDivisor` and
839
+ /// `redemptionTxMaxFee` parameters in order to make requests that
840
+ /// can incur the treasury and transaction fee and still satisfy the
841
+ /// redeemer.
842
+ /// @param redemptionTreasuryFeeDivisor New value of the redemption
843
+ /// treasury fee divisor. It is the divisor used to compute the
844
+ /// treasury fee taken from each redemption request and transferred
845
+ /// to the treasury upon successful request finalization. That fee is
846
+ /// computed as follows:
847
+ /// `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`
848
+ /// For example, if the treasury fee needs to be 2% of each
849
+ /// redemption request, the `redemptionTreasuryFeeDivisor` should
850
+ /// be set to `50` because `1/50 = 0.02 = 2%`.
851
+ /// @param redemptionTxMaxFee New value of the redemption transaction max
852
+ /// fee in satoshis. It is the maximum amount of BTC transaction fee
853
+ /// that can be incurred by each redemption request being part of the
854
+ /// given redemption transaction. If the maximum BTC transaction fee
855
+ /// is exceeded, such transaction is considered a fraud.
856
+ /// This is a per-redemption output max fee for the redemption
857
+ /// transaction.
858
+ /// @param redemptionTimeout New value of the redemption timeout in seconds.
859
+ /// It is the time after which the redemption request can be reported
860
+ /// as timed out. It is counted from the moment when the redemption
861
+ /// request was created via `requestRedemption` call. Reported timed
862
+ /// out requests are cancelled and locked TBTC is returned to the
863
+ /// redeemer in full amount.
864
+ /// @dev Requirements:
865
+ /// - Redemption dust threshold must be greater than zero
866
+ /// - Redemption treasury fee divisor must be greater than zero
867
+ /// - Redemption transaction max fee must be greater than zero
868
+ /// - Redemption timeout must be greater than zero
869
+ function updateRedemptionParameters(
870
+ uint64 redemptionDustThreshold,
871
+ uint64 redemptionTreasuryFeeDivisor,
872
+ uint64 redemptionTxMaxFee,
873
+ uint256 redemptionTimeout
874
+ ) external onlyOwner {
875
+ self.updateRedemptionParameters(
876
+ redemptionDustThreshold,
877
+ redemptionTreasuryFeeDivisor,
878
+ redemptionTxMaxFee,
879
+ redemptionTimeout
880
+ );
881
+ }
882
+
883
+ /// @notice Updates parameters of moving funds.
884
+ /// @param movingFundsTxMaxTotalFee New value of the moving funds transaction
885
+ /// max total fee in satoshis. It is the maximum amount of the total
886
+ /// BTC transaction fee that is acceptable in a single moving funds
887
+ /// transaction. This is a _total_ max fee for the entire moving
888
+ /// funds transaction.
889
+ /// @param movingFundsTimeout New value of the moving funds timeout in
890
+ /// seconds. It is the time after which the moving funds process can
891
+ /// be reported as timed out. It is counted from the moment when the
892
+ /// wallet was requested to move their funds and switched to the
893
+ /// MovingFunds state.
894
+ /// @dev Requirements:
895
+ /// - Moving funds transaction max total fee must be greater than zero
896
+ /// - Moving funds timeout must be greater than zero
897
+ function updateMovingFundsParameters(
898
+ uint64 movingFundsTxMaxTotalFee,
899
+ uint32 movingFundsTimeout
900
+ ) external onlyOwner {
901
+ self.updateMovingFundsParameters(
902
+ movingFundsTxMaxTotalFee,
903
+ movingFundsTimeout
904
+ );
905
+ }
676
906
 
677
907
  /// @notice Updates parameters of wallets.
678
908
  /// @param walletCreationPeriod New value of the wallet creation period in
679
909
  /// seconds, determines how frequently a new wallet creation can be
680
910
  /// requested
681
911
  /// @param walletMinBtcBalance New value of the wallet minimum BTC balance
682
- /// in satoshis, used to decide about wallet creation or closing
912
+ /// in satoshi, used to decide about wallet creation or closing
683
913
  /// @param walletMaxBtcBalance New value of the wallet maximum BTC balance
684
- /// in satoshis, used to decide about wallet creation
914
+ /// in satoshi, used to decide about wallet creation
685
915
  /// @param walletMaxAge New value of the wallet maximum age in seconds,
686
916
  /// indicates the maximum age of a wallet in seconds, after which
687
917
  /// the wallet moving funds process can be requested
918
+ /// @param walletMaxBtcTransfer New value of the wallet maximum BTC transfer
919
+ /// in satoshi, determines the maximum amount that can be transferred
920
+ // to a single target wallet during the moving funds process
921
+ /// @param walletClosingPeriod New value of the wallet closing period in
922
+ /// seconds, determines the length of the wallet closing period,
923
+ // i.e. the period when the wallet remains in the Closing state
924
+ // and can be subject of deposit fraud challenges
688
925
  /// @dev Requirements:
689
926
  /// - Wallet minimum BTC balance must be greater than zero
690
927
  /// - Wallet maximum BTC balance must be greater than the wallet
691
928
  /// minimum BTC balance
929
+ /// - Wallet maximum BTC transfer must be greater than zero
930
+ /// - Wallet closing period must be greater than zero
692
931
  function updateWalletParameters(
693
932
  uint32 walletCreationPeriod,
694
933
  uint64 walletMinBtcBalance,
695
934
  uint64 walletMaxBtcBalance,
696
- uint32 walletMaxAge
935
+ uint32 walletMaxAge,
936
+ uint64 walletMaxBtcTransfer,
937
+ uint32 walletClosingPeriod
697
938
  ) external onlyOwner {
698
939
  self.updateWalletParameters(
699
940
  walletCreationPeriod,
700
941
  walletMinBtcBalance,
701
942
  walletMaxBtcBalance,
702
- walletMaxAge
943
+ walletMaxAge,
944
+ walletMaxBtcTransfer,
945
+ walletClosingPeriod
703
946
  );
704
947
  }
705
948
 
706
- // TODO: updateFraudParameters
949
+ /// @notice Updates parameters related to frauds.
950
+ /// @param fraudSlashingAmount New value of the fraud slashing amount in T,
951
+ /// it is the amount slashed from each wallet member for committing
952
+ /// a fraud
953
+ /// @param fraudNotifierRewardMultiplier New value of the fraud notifier
954
+ /// reward multiplier as percentage, it determines the percentage of
955
+ /// the notifier reward from the staking contact the notifier of
956
+ /// a fraud receives. The value must be in the range [0, 100]
957
+ /// @param fraudChallengeDefeatTimeout New value of the challenge defeat
958
+ /// timeout in seconds, it is the amount of time the wallet has to
959
+ /// defeat a fraud challenge. The value must be greater than zero
960
+ /// @param fraudChallengeDepositAmount New value of the fraud challenge
961
+ /// deposit amount in wei, it is the amount of ETH the party
962
+ /// challenging the wallet for fraud needs to deposit
963
+ /// @dev Requirements:
964
+ /// - Fraud notifier reward multiplier must be in the range [0, 100]
965
+ /// - Fraud challenge defeat timeout must be greater than 0
966
+ function updateFraudParameters(
967
+ uint256 fraudSlashingAmount,
968
+ uint256 fraudNotifierRewardMultiplier,
969
+ uint256 fraudChallengeDefeatTimeout,
970
+ uint256 fraudChallengeDepositAmount
971
+ ) external onlyOwner {
972
+ self.updateFraudParameters(
973
+ fraudSlashingAmount,
974
+ fraudNotifierRewardMultiplier,
975
+ fraudChallengeDefeatTimeout,
976
+ fraudChallengeDepositAmount
977
+ );
978
+ }
707
979
 
708
980
  /// @notice Collection of all revealed deposits indexed by
709
981
  /// keccak256(fundingTxHash | fundingOutputIndex).
@@ -792,6 +1064,12 @@ contract Bridge is Ownable, EcdsaWalletOwner {
792
1064
  return self.activeWalletPubKeyHash;
793
1065
  }
794
1066
 
1067
+ /// @notice Gets the live wallets count.
1068
+ /// @return The current count of wallets being in the Live state.
1069
+ function liveWalletsCount() external view returns (uint32) {
1070
+ return self.liveWalletsCount;
1071
+ }
1072
+
795
1073
  /// @notice Returns the fraud challenge identified by the given key built
796
1074
  /// as keccak256(walletPublicKey|sighash).
797
1075
  function fraudChallenges(uint256 challengeKey)
@@ -862,6 +1140,8 @@ contract Bridge is Ownable, EcdsaWalletOwner {
862
1140
  /// can be incurred by each redemption request being part of the
863
1141
  /// given redemption transaction. If the maximum BTC transaction
864
1142
  /// fee is exceeded, such transaction is considered a fraud.
1143
+ /// This is a per-redemption output max fee for the redemption
1144
+ /// transaction.
865
1145
  /// @return redemptionTimeout Time after which the redemption request can be
866
1146
  /// reported as timed out. It is counted from the moment when the
867
1147
  /// redemption request was created via `requestRedemption` call.
@@ -889,13 +1169,17 @@ contract Bridge is Ownable, EcdsaWalletOwner {
889
1169
  /// transaction fee that is acceptable in a single moving funds
890
1170
  /// transaction. This is a _total_ max fee for the entire moving
891
1171
  /// funds transaction.
1172
+ /// @return movingFundsTimeout Time after which the moving funds process
1173
+ /// can be reported as timed out. It is counted from the moment
1174
+ /// when the wallet was requested to move their funds and switched
1175
+ /// to the MovingFunds state. Value in seconds.
892
1176
  function movingFundsParameters()
893
1177
  external
894
1178
  view
895
- returns (uint64 movingFundsTxMaxTotalFee)
1179
+ returns (uint64 movingFundsTxMaxTotalFee, uint32 movingFundsTimeout)
896
1180
  {
897
- // TODO: we will have more parameters here, for example moving funds timeout
898
1181
  movingFundsTxMaxTotalFee = self.movingFundsTxMaxTotalFee;
1182
+ movingFundsTimeout = self.movingFundsTimeout;
899
1183
  }
900
1184
 
901
1185
  /// @return walletCreationPeriod Determines how frequently a new wallet
@@ -906,6 +1190,13 @@ contract Bridge is Ownable, EcdsaWalletOwner {
906
1190
  /// used to decide about wallet creation.
907
1191
  /// @return walletMaxAge The maximum age of a wallet in seconds, after which
908
1192
  /// the wallet moving funds process can be requested.
1193
+ /// @return walletMaxBtcTransfer The maximum BTC amount in satoshi than
1194
+ /// can be transferred to a single target wallet during the moving
1195
+ /// funds process.
1196
+ /// @return walletClosingPeriod Determines the length of the wallet closing
1197
+ /// period, i.e. the period when the wallet remains in the Closing
1198
+ /// state and can be subject of deposit fraud challenges. Value
1199
+ /// in seconds.
909
1200
  function walletParameters()
910
1201
  external
911
1202
  view
@@ -913,13 +1204,17 @@ contract Bridge is Ownable, EcdsaWalletOwner {
913
1204
  uint32 walletCreationPeriod,
914
1205
  uint64 walletMinBtcBalance,
915
1206
  uint64 walletMaxBtcBalance,
916
- uint32 walletMaxAge
1207
+ uint32 walletMaxAge,
1208
+ uint64 walletMaxBtcTransfer,
1209
+ uint32 walletClosingPeriod
917
1210
  )
918
1211
  {
919
1212
  walletCreationPeriod = self.walletCreationPeriod;
920
1213
  walletMinBtcBalance = self.walletMinBtcBalance;
921
1214
  walletMaxBtcBalance = self.walletMaxBtcBalance;
922
1215
  walletMaxAge = self.walletMaxAge;
1216
+ walletMaxBtcTransfer = self.walletMaxBtcTransfer;
1217
+ walletClosingPeriod = self.walletClosingPeriod;
923
1218
  }
924
1219
 
925
1220
  /// @notice Returns the current values of Bridge fraud parameters.