@keep-network/tbtc-v2 0.1.1-dev.81 → 0.1.1-dev.84
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/artifacts/Bank.json +16 -16
- package/artifacts/Bridge.json +33 -11
- package/artifacts/Deposit.json +7 -7
- package/artifacts/DepositSweep.json +7 -7
- package/artifacts/EcdsaDkgValidator.json +1 -1
- package/artifacts/EcdsaInactivity.json +1 -1
- package/artifacts/EcdsaSortitionPool.json +2 -2
- package/artifacts/Fraud.json +7 -7
- package/artifacts/KeepRegistry.json +1 -1
- package/artifacts/KeepStake.json +2 -2
- package/artifacts/KeepToken.json +2 -2
- package/artifacts/KeepTokenStaking.json +1 -1
- package/artifacts/MovingFunds.json +7 -7
- package/artifacts/NuCypherStakingEscrow.json +1 -1
- package/artifacts/NuCypherToken.json +2 -2
- package/artifacts/RandomBeaconStub.json +1 -1
- package/artifacts/Redemption.json +26 -14
- package/artifacts/ReimbursementPool.json +2 -2
- package/artifacts/Relay.json +11 -11
- package/artifacts/T.json +2 -2
- package/artifacts/TBTC.json +13 -13
- package/artifacts/TBTCToken.json +13 -13
- package/artifacts/TBTCVault.json +71 -42
- package/artifacts/TokenStaking.json +1 -1
- package/artifacts/TokenholderGovernor.json +9 -9
- package/artifacts/TokenholderTimelock.json +8 -8
- package/artifacts/VendingMachine.json +11 -11
- package/artifacts/VendingMachineKeep.json +1 -1
- package/artifacts/VendingMachineNuCypher.json +1 -1
- package/artifacts/WalletRegistry.json +5 -5
- package/artifacts/WalletRegistryGovernance.json +2 -2
- package/artifacts/Wallets.json +9 -9
- package/artifacts/solcInputs/{3f679eb4591b969794b6013bc0d8da70.json → 0f79d51f4c2e0d6bf7d919933c677b91.json} +12 -9
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.json +2 -2
- package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.dbg.json +1 -1
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +2 -2
- package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
- package/build/contracts/bridge/Bridge.sol/Bridge.json +73 -42
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
- package/build/contracts/bridge/BridgeState.sol/BridgeState.json +2 -2
- package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
- package/build/contracts/bridge/Deposit.sol/Deposit.json +2 -2
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.json +2 -2
- package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
- package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
- package/build/contracts/bridge/Fraud.sol/Fraud.json +2 -2
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +1 -1
- package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +2 -2
- package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/OutboundTx.json +2 -2
- package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/Redemption.json +2 -2
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
- package/build/contracts/bridge/Wallets.sol/Wallets.json +2 -2
- package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +1 -1
- package/build/contracts/vault/DonationVault.sol/DonationVault.json +2 -2
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +35 -17
- package/contracts/bank/Bank.sol +1 -1
- package/contracts/bank/IReceiveBalanceApproval.sol +2 -2
- package/contracts/bridge/BitcoinTx.sol +1 -1
- package/contracts/bridge/Bridge.sol +85 -6
- package/contracts/bridge/Redemption.sol +160 -6
- package/contracts/vault/TBTCVault.sol +57 -19
- package/export.json +55 -15
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ import "../token/TBTC.sol";
|
|
|
25
25
|
/// @notice TBTC is a fully Bitcoin-backed ERC-20 token pegged to the price of
|
|
26
26
|
/// Bitcoin. It facilitates Bitcoin holders to act on the Ethereum
|
|
27
27
|
/// blockchain and access the decentralized finance (DeFi) ecosystem.
|
|
28
|
-
/// TBTC Vault mints and
|
|
28
|
+
/// TBTC Vault mints and unmints TBTC based on Bitcoin balances in the
|
|
29
29
|
/// Bank.
|
|
30
30
|
/// @dev TBTC Vault is the owner of TBTC token contract and is the only contract
|
|
31
31
|
/// minting the token.
|
|
@@ -35,7 +35,7 @@ contract TBTCVault is IVault, Governable {
|
|
|
35
35
|
|
|
36
36
|
event Minted(address indexed to, uint256 amount);
|
|
37
37
|
|
|
38
|
-
event
|
|
38
|
+
event Unminted(address indexed from, uint256 amount);
|
|
39
39
|
|
|
40
40
|
modifier onlyBank() {
|
|
41
41
|
require(msg.sender == address(bank), "Caller is not the Bank");
|
|
@@ -110,7 +110,7 @@ contract TBTCVault is IVault, Governable {
|
|
|
110
110
|
function receiveBalanceApproval(
|
|
111
111
|
address owner,
|
|
112
112
|
uint256 amount,
|
|
113
|
-
bytes
|
|
113
|
+
bytes calldata
|
|
114
114
|
) external override onlyBank {
|
|
115
115
|
require(
|
|
116
116
|
bank.balanceOf(owner) >= amount,
|
|
@@ -136,32 +136,60 @@ contract TBTCVault is IVault, Governable {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
/// @notice Burns `amount` of TBTC from the caller's
|
|
139
|
+
/// @notice Burns `amount` of TBTC from the caller's balance and transfers
|
|
140
140
|
/// `amount` back to the caller's balance in the Bank.
|
|
141
141
|
/// @dev Caller must have at least `amount` of TBTC approved to
|
|
142
142
|
/// TBTC Vault.
|
|
143
|
-
/// @param amount Amount of TBTC to
|
|
144
|
-
function
|
|
145
|
-
|
|
143
|
+
/// @param amount Amount of TBTC to unmint.
|
|
144
|
+
function unmint(uint256 amount) external {
|
|
145
|
+
_unmint(msg.sender, amount);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
/// @notice Burns `amount` of TBTC from the caller's
|
|
149
|
-
/// `amount`
|
|
150
|
-
///
|
|
151
|
-
///
|
|
152
|
-
///
|
|
153
|
-
/// @param
|
|
154
|
-
/// @param
|
|
148
|
+
/// @notice Burns `amount` of TBTC from the caller's balance and transfers
|
|
149
|
+
/// `amount` of Bank balance to the Bridge requesting redemption
|
|
150
|
+
/// based on the provided `redemptionData`.
|
|
151
|
+
/// @dev Caller must have at least `amount` of TBTC approved to
|
|
152
|
+
/// TBTC Vault.
|
|
153
|
+
/// @param amount Amount of TBTC to unmint and request to redeem in Bridge.
|
|
154
|
+
/// @param redemptionData Redemption data in a format expected from
|
|
155
|
+
/// `redemptionData` parameter of Bridge's `receiveBalanceApproval`
|
|
156
|
+
/// function.
|
|
157
|
+
function unmintAndRedeem(uint256 amount, bytes calldata redemptionData)
|
|
158
|
+
external
|
|
159
|
+
{
|
|
160
|
+
_unmintAndRedeem(msg.sender, amount, redemptionData);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/// @notice Burns `amount` of TBTC from the caller's balance. If `extraData`
|
|
164
|
+
/// is empty, transfers `amount` back to the caller's balance in the
|
|
165
|
+
/// Bank. If `extraData` is not empty, requests redemption in the
|
|
166
|
+
/// Bridge using the `extraData` as a `redemptionData` parameter to
|
|
167
|
+
/// Bridge's `receiveBalanceApproval` function.
|
|
168
|
+
/// @dev This function is doing the same as `unmint` or `unmintAndRedeem`
|
|
169
|
+
/// (depending on `extraData` parameter) but it allows to execute
|
|
170
|
+
/// unminting without a separate approval transaction. The function can
|
|
171
|
+
/// be called only via `approveAndCall` of TBTC token.
|
|
172
|
+
/// @param from TBTC token holder executing unminting.
|
|
173
|
+
/// @param amount Amount of TBTC to unmint.
|
|
155
174
|
/// @param token TBTC token address.
|
|
175
|
+
/// @param extraData Redemption data in a format expected from
|
|
176
|
+
/// `redemptionData` parameter of Bridge's `receiveBalanceApproval`
|
|
177
|
+
/// function. If empty, `receiveApproval` is not requesting a
|
|
178
|
+
/// redemption of Bank balance but is instead performing just TBTC
|
|
179
|
+
/// unminting to a Bank balance.
|
|
156
180
|
function receiveApproval(
|
|
157
181
|
address from,
|
|
158
182
|
uint256 amount,
|
|
159
183
|
address token,
|
|
160
|
-
bytes calldata
|
|
184
|
+
bytes calldata extraData
|
|
161
185
|
) external {
|
|
162
186
|
require(token == address(tbtcToken), "Token is not TBTC");
|
|
163
187
|
require(msg.sender == token, "Only TBTC caller allowed");
|
|
164
|
-
|
|
188
|
+
if (extraData.length == 0) {
|
|
189
|
+
_unmint(from, amount);
|
|
190
|
+
} else {
|
|
191
|
+
_unmintAndRedeem(from, amount, extraData);
|
|
192
|
+
}
|
|
165
193
|
}
|
|
166
194
|
|
|
167
195
|
// slither-disable-next-line calls-loop
|
|
@@ -170,9 +198,19 @@ contract TBTCVault is IVault, Governable {
|
|
|
170
198
|
tbtcToken.mint(minter, amount);
|
|
171
199
|
}
|
|
172
200
|
|
|
173
|
-
function
|
|
174
|
-
emit
|
|
201
|
+
function _unmint(address unminter, uint256 amount) internal {
|
|
202
|
+
emit Unminted(unminter, amount);
|
|
203
|
+
tbtcToken.burnFrom(unminter, amount);
|
|
204
|
+
bank.transferBalance(unminter, amount);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function _unmintAndRedeem(
|
|
208
|
+
address redeemer,
|
|
209
|
+
uint256 amount,
|
|
210
|
+
bytes calldata redemptionData
|
|
211
|
+
) internal {
|
|
212
|
+
emit Unminted(redeemer, amount);
|
|
175
213
|
tbtcToken.burnFrom(redeemer, amount);
|
|
176
|
-
bank.
|
|
214
|
+
bank.approveBalanceAndCall(bank.bridge(), amount, redemptionData);
|
|
177
215
|
}
|
|
178
216
|
}
|
package/export.json
CHANGED
|
@@ -15515,6 +15515,28 @@
|
|
|
15515
15515
|
],
|
|
15516
15516
|
"outputs": []
|
|
15517
15517
|
},
|
|
15518
|
+
{
|
|
15519
|
+
"type": "function",
|
|
15520
|
+
"name": "receiveBalanceApproval",
|
|
15521
|
+
"constant": false,
|
|
15522
|
+
"payable": false,
|
|
15523
|
+
"gas": 29000000,
|
|
15524
|
+
"inputs": [
|
|
15525
|
+
{
|
|
15526
|
+
"type": "address",
|
|
15527
|
+
"name": "balanceOwner"
|
|
15528
|
+
},
|
|
15529
|
+
{
|
|
15530
|
+
"type": "uint256",
|
|
15531
|
+
"name": "amount"
|
|
15532
|
+
},
|
|
15533
|
+
{
|
|
15534
|
+
"type": "bytes",
|
|
15535
|
+
"name": "redemptionData"
|
|
15536
|
+
}
|
|
15537
|
+
],
|
|
15538
|
+
"outputs": []
|
|
15539
|
+
},
|
|
15518
15540
|
{
|
|
15519
15541
|
"type": "function",
|
|
15520
15542
|
"name": "redemptionParameters",
|
|
@@ -16858,7 +16880,7 @@
|
|
|
16858
16880
|
"type": "uint256"
|
|
16859
16881
|
}
|
|
16860
16882
|
],
|
|
16861
|
-
"name": "
|
|
16883
|
+
"name": "Unminted",
|
|
16862
16884
|
"type": "event"
|
|
16863
16885
|
},
|
|
16864
16886
|
{
|
|
@@ -16919,7 +16941,7 @@
|
|
|
16919
16941
|
},
|
|
16920
16942
|
{
|
|
16921
16943
|
"internalType": "bytes",
|
|
16922
|
-
"name": "",
|
|
16944
|
+
"name": "extraData",
|
|
16923
16945
|
"type": "bytes"
|
|
16924
16946
|
}
|
|
16925
16947
|
],
|
|
@@ -17020,19 +17042,6 @@
|
|
|
17020
17042
|
"stateMutability": "nonpayable",
|
|
17021
17043
|
"type": "function"
|
|
17022
17044
|
},
|
|
17023
|
-
{
|
|
17024
|
-
"inputs": [
|
|
17025
|
-
{
|
|
17026
|
-
"internalType": "uint256",
|
|
17027
|
-
"name": "amount",
|
|
17028
|
-
"type": "uint256"
|
|
17029
|
-
}
|
|
17030
|
-
],
|
|
17031
|
-
"name": "redeem",
|
|
17032
|
-
"outputs": [],
|
|
17033
|
-
"stateMutability": "nonpayable",
|
|
17034
|
-
"type": "function"
|
|
17035
|
-
},
|
|
17036
17045
|
{
|
|
17037
17046
|
"inputs": [],
|
|
17038
17047
|
"name": "tbtcToken",
|
|
@@ -17058,6 +17067,37 @@
|
|
|
17058
17067
|
"outputs": [],
|
|
17059
17068
|
"stateMutability": "nonpayable",
|
|
17060
17069
|
"type": "function"
|
|
17070
|
+
},
|
|
17071
|
+
{
|
|
17072
|
+
"inputs": [
|
|
17073
|
+
{
|
|
17074
|
+
"internalType": "uint256",
|
|
17075
|
+
"name": "amount",
|
|
17076
|
+
"type": "uint256"
|
|
17077
|
+
}
|
|
17078
|
+
],
|
|
17079
|
+
"name": "unmint",
|
|
17080
|
+
"outputs": [],
|
|
17081
|
+
"stateMutability": "nonpayable",
|
|
17082
|
+
"type": "function"
|
|
17083
|
+
},
|
|
17084
|
+
{
|
|
17085
|
+
"inputs": [
|
|
17086
|
+
{
|
|
17087
|
+
"internalType": "uint256",
|
|
17088
|
+
"name": "amount",
|
|
17089
|
+
"type": "uint256"
|
|
17090
|
+
},
|
|
17091
|
+
{
|
|
17092
|
+
"internalType": "bytes",
|
|
17093
|
+
"name": "redemptionData",
|
|
17094
|
+
"type": "bytes"
|
|
17095
|
+
}
|
|
17096
|
+
],
|
|
17097
|
+
"name": "unmintAndRedeem",
|
|
17098
|
+
"outputs": [],
|
|
17099
|
+
"stateMutability": "nonpayable",
|
|
17100
|
+
"type": "function"
|
|
17061
17101
|
}
|
|
17062
17102
|
]
|
|
17063
17103
|
}
|