@keep-network/tbtc-v2 0.1.1-dev.3 → 0.1.1-dev.4
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/TBTC.json +3 -3
- package/artifacts/TBTCToken.json +3 -3
- package/artifacts/VendingMachine.json +10 -10
- package/artifacts/solcInputs/{cebfa5efa019cb9c8c5e23e38703b883.json → d71966212a658480bad5748ad85b1396.json} +6 -3
- 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 +25 -2
- package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
- package/build/contracts/bridge/Bridge.sol/Bridge.json +2 -2
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +4 -0
- package/build/contracts/vault/IVault.sol/IVault.json +29 -0
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +20 -2
- package/contracts/bank/Bank.sol +36 -1
- package/contracts/bridge/Bridge.sol +15 -0
- package/contracts/vault/IVault.sol +38 -0
- package/contracts/vault/TBTCVault.sol +31 -7
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
pragma solidity 0.8.4;
|
|
17
17
|
|
|
18
|
+
import "./IVault.sol";
|
|
18
19
|
import "../bank/Bank.sol";
|
|
19
20
|
import "../token/TBTC.sol";
|
|
20
21
|
|
|
@@ -26,7 +27,7 @@ import "../token/TBTC.sol";
|
|
|
26
27
|
/// Bank.
|
|
27
28
|
/// @dev TBTC Vault is the owner of TBTC token contract and is the only contract
|
|
28
29
|
/// minting the token.
|
|
29
|
-
contract TBTCVault {
|
|
30
|
+
contract TBTCVault is IVault {
|
|
30
31
|
Bank public bank;
|
|
31
32
|
TBTC public tbtcToken;
|
|
32
33
|
|
|
@@ -34,6 +35,11 @@ contract TBTCVault {
|
|
|
34
35
|
|
|
35
36
|
event Redeemed(address indexed from, uint256 amount);
|
|
36
37
|
|
|
38
|
+
modifier onlyBank() {
|
|
39
|
+
require(msg.sender == address(bank), "Caller is not the Bank");
|
|
40
|
+
_;
|
|
41
|
+
}
|
|
42
|
+
|
|
37
43
|
constructor(Bank _bank, TBTC _tbtcToken) {
|
|
38
44
|
require(
|
|
39
45
|
address(_bank) != address(0),
|
|
@@ -55,7 +61,29 @@ contract TBTCVault {
|
|
|
55
61
|
/// for at least `amount`.
|
|
56
62
|
/// @param amount Amount of TBTC to mint
|
|
57
63
|
function mint(uint256 amount) external {
|
|
58
|
-
|
|
64
|
+
address minter = msg.sender;
|
|
65
|
+
require(
|
|
66
|
+
bank.balanceOf(minter) >= amount,
|
|
67
|
+
"Amount exceeds balance in the bank"
|
|
68
|
+
);
|
|
69
|
+
_mint(minter, amount);
|
|
70
|
+
bank.transferBalanceFrom(minter, address(this), amount);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/// @notice Mints the same amount of TBTC as the deposited amount for each
|
|
74
|
+
/// depositor in the array. Can only be called by the Bank after the
|
|
75
|
+
/// Bridge swept deposits and Bank increased balance for the
|
|
76
|
+
/// vault.
|
|
77
|
+
/// @dev Fails if `depositors` array is empty. Expects the length of
|
|
78
|
+
/// `depositors` and `depositedAmounts` is the same.
|
|
79
|
+
function onBalanceIncreased(
|
|
80
|
+
address[] calldata depositors,
|
|
81
|
+
uint256[] calldata depositedAmounts
|
|
82
|
+
) external override onlyBank {
|
|
83
|
+
require(depositors.length != 0, "No depositors specified");
|
|
84
|
+
for (uint256 i = 0; i < depositors.length; i++) {
|
|
85
|
+
_mint(depositors[i], depositedAmounts[i]);
|
|
86
|
+
}
|
|
59
87
|
}
|
|
60
88
|
|
|
61
89
|
/// @notice Burns `amount` of TBTC from the caller's account and transfers
|
|
@@ -86,13 +114,9 @@ contract TBTCVault {
|
|
|
86
114
|
_redeem(from, amount);
|
|
87
115
|
}
|
|
88
116
|
|
|
117
|
+
// slither-disable-next-line calls-loop
|
|
89
118
|
function _mint(address minter, uint256 amount) internal {
|
|
90
|
-
require(
|
|
91
|
-
bank.balanceOf(minter) >= amount,
|
|
92
|
-
"Amount exceeds balance in the bank"
|
|
93
|
-
);
|
|
94
119
|
emit Minted(minter, amount);
|
|
95
|
-
bank.transferBalanceFrom(minter, address(this), amount);
|
|
96
120
|
tbtcToken.mint(minter, amount);
|
|
97
121
|
}
|
|
98
122
|
|