@keep-network/tbtc-v2 0.1.1-dev.36 → 0.1.1-dev.37

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 (32) hide show
  1. package/artifacts/TBTC.json +3 -3
  2. package/artifacts/TBTCToken.json +3 -3
  3. package/artifacts/VendingMachine.json +10 -10
  4. package/artifacts/solcInputs/{4718d6e944ad9d1fc247efda870cf51a.json → e22260bedca047fea8676977de0ef137.json} +6 -3
  5. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
  6. package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
  7. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
  8. package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
  9. package/build/contracts/bridge/Bridge.sol/Bridge.json +147 -131
  10. package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
  11. package/build/contracts/bridge/BridgeState.sol/BridgeState.json +2 -2
  12. package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
  13. package/build/contracts/bridge/Deposit.sol/Deposit.json +2 -2
  14. package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
  15. package/build/contracts/bridge/Frauds.sol/Frauds.dbg.json +1 -1
  16. package/build/contracts/bridge/Frauds.sol/Frauds.json +2 -2
  17. package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
  18. package/build/contracts/bridge/Redeem.sol/OutboundTx.dbg.json +4 -0
  19. package/build/contracts/bridge/Redeem.sol/OutboundTx.json +10 -0
  20. package/build/contracts/bridge/Redeem.sol/Redeem.dbg.json +4 -0
  21. package/build/contracts/bridge/Redeem.sol/Redeem.json +126 -0
  22. package/build/contracts/bridge/Sweep.sol/Sweep.dbg.json +1 -1
  23. package/build/contracts/bridge/Sweep.sol/Sweep.json +2 -2
  24. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
  25. package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
  26. package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
  27. package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
  28. package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
  29. package/contracts/bridge/Bridge.sol +114 -719
  30. package/contracts/bridge/BridgeState.sol +60 -0
  31. package/contracts/bridge/Redeem.sol +849 -0
  32. package/package.json +1 -1
@@ -17,6 +17,7 @@ pragma solidity ^0.8.9;
17
17
 
18
18
  import "./IRelay.sol";
19
19
  import "./Deposit.sol";
20
+ import "./Redeem.sol";
20
21
 
21
22
  import "../bank/Bank.sol";
22
23
 
@@ -75,6 +76,65 @@ library BridgeState {
75
76
  /// responsibility - anyone can approve their Bank balance to any
76
77
  /// address.
77
78
  mapping(address => bool) isVaultTrusted;
79
+ /// TODO: Make it governable.
80
+ /// @notice The minimal amount that can be requested for redemption.
81
+ /// Value of this parameter must take into account the value of
82
+ /// `redemptionTreasuryFeeDivisor` and `redemptionTxMaxFee`
83
+ /// parameters in order to make requests that can incur the
84
+ /// treasury and transaction fee and still satisfy the redeemer.
85
+ uint64 redemptionDustThreshold;
86
+ /// TODO: Make it governable.
87
+ /// @notice Divisor used to compute the treasury fee taken from each
88
+ /// redemption request and transferred to the treasury upon
89
+ /// successful request finalization. That fee is computed as follows:
90
+ /// `treasuryFee = requestedAmount / redemptionTreasuryFeeDivisor`
91
+ /// For example, if the treasury fee needs to be 2% of each
92
+ /// redemption request, the `redemptionTreasuryFeeDivisor` should
93
+ /// be set to `50` because `1/50 = 0.02 = 2%`.
94
+ uint64 redemptionTreasuryFeeDivisor;
95
+ /// TODO: Make it governable.
96
+ /// @notice Maximum amount of BTC transaction fee that can be incurred by
97
+ /// each redemption request being part of the given redemption
98
+ /// transaction. If the maximum BTC transaction fee is exceeded, such
99
+ /// transaction is considered a fraud.
100
+ /// @dev This is a per-redemption output max fee for the redemption transaction.
101
+ uint64 redemptionTxMaxFee;
102
+ /// TODO: Make it governable.
103
+ /// @notice Time after which the redemption request can be reported as
104
+ /// timed out. It is counted from the moment when the redemption
105
+ /// request was created via `requestRedemption` call. Reported
106
+ /// timed out requests are cancelled and locked TBTC is returned
107
+ /// to the redeemer in full amount.
108
+ uint256 redemptionTimeout;
109
+ /// @notice Collection of all pending redemption requests indexed by
110
+ /// redemption key built as
111
+ /// keccak256(walletPubKeyHash | redeemerOutputScript). The
112
+ /// walletPubKeyHash is the 20-byte wallet's public key hash
113
+ /// (computed using Bitcoin HASH160 over the compressed ECDSA
114
+ /// public key) and redeemerOutputScript is a Bitcoin script
115
+ /// (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock
116
+ /// redeemed BTC as requested by the redeemer. Requests are added
117
+ /// to this mapping by the `requestRedemption` method (duplicates
118
+ /// not allowed) and are removed by one of the following methods:
119
+ /// - `submitRedemptionProof` in case the request was handled
120
+ /// successfully
121
+ /// - `notifyRedemptionTimeout` in case the request was reported
122
+ /// to be timed out
123
+ mapping(uint256 => Redeem.RedemptionRequest) pendingRedemptions;
124
+ /// @notice Collection of all timed out redemptions requests indexed by
125
+ /// redemption key built as
126
+ /// keccak256(walletPubKeyHash | redeemerOutputScript). The
127
+ /// walletPubKeyHash is the 20-byte wallet's public key hash
128
+ /// (computed using Bitcoin HASH160 over the compressed ECDSA
129
+ /// public key) and redeemerOutputScript is the Bitcoin script
130
+ /// (P2PKH, P2WPKH, P2SH or P2WSH) that is involved in the timed
131
+ /// out request. Timed out requests are stored in this mapping to
132
+ /// avoid slashing the wallets multiple times for the same timeout.
133
+ /// Only one method can add to this mapping:
134
+ /// - `notifyRedemptionTimeout` which puts the redemption key
135
+ /// to this mapping basing on a timed out request stored
136
+ /// previously in `pendingRedemptions` mapping.
137
+ mapping(uint256 => Redeem.RedemptionRequest) timedOutRedemptions;
78
138
  /// @notice Collection of main UTXOs that are honestly spent indexed by
79
139
  /// keccak256(fundingTxHash | fundingOutputIndex). The fundingTxHash
80
140
  /// is bytes32 (ordered as in Bitcoin internally) and