@keep-network/tbtc-v2 0.1.1-dev.81 → 0.1.1-dev.82
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 +3 -3
- package/artifacts/Bridge.json +5 -5
- package/artifacts/Deposit.json +2 -2
- package/artifacts/DepositSweep.json +2 -2
- package/artifacts/EcdsaDkgValidator.json +1 -1
- package/artifacts/EcdsaInactivity.json +1 -1
- package/artifacts/EcdsaSortitionPool.json +2 -2
- package/artifacts/Fraud.json +2 -2
- 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 +2 -2
- package/artifacts/NuCypherStakingEscrow.json +1 -1
- package/artifacts/NuCypherToken.json +2 -2
- package/artifacts/RandomBeaconStub.json +1 -1
- package/artifacts/Redemption.json +2 -2
- package/artifacts/ReimbursementPool.json +2 -2
- package/artifacts/Relay.json +2 -2
- package/artifacts/T.json +2 -2
- package/artifacts/TBTC.json +3 -3
- package/artifacts/TBTCToken.json +3 -3
- package/artifacts/TBTCVault.json +34 -34
- package/artifacts/TokenStaking.json +1 -1
- package/artifacts/TokenholderGovernor.json +9 -9
- package/artifacts/TokenholderTimelock.json +8 -8
- package/artifacts/VendingMachine.json +3 -3
- 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 +2 -2
- package/artifacts/solcInputs/{3f679eb4591b969794b6013bc0d8da70.json → 5cd0a97e230d515eacf46fb60ea8963a.json} +1 -1
- 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/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.dbg.json +1 -1
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
- package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
- package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
- 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/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/Redemption.sol/OutboundTx.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
- 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/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +1 -1
- 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 +16 -16
- package/contracts/vault/TBTCVault.sol +14 -14
- package/export.json +14 -14
- package/package.json +1 -1
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
|
|
18
18
|
},
|
|
19
19
|
"contracts/vault/TBTCVault.sol": {
|
|
20
|
-
"content": "// SPDX-License-Identifier: MIT\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity ^0.8.9;\n\nimport \"@keep-network/random-beacon/contracts/Governable.sol\";\n\nimport \"./IVault.sol\";\nimport \"../bank/Bank.sol\";\nimport \"../token/TBTC.sol\";\n\n/// @title TBTC application vault\n/// @notice TBTC is a fully Bitcoin-backed ERC-20 token pegged to the price of\n/// Bitcoin. It facilitates Bitcoin holders to act on the Ethereum\n/// blockchain and access the decentralized finance (DeFi) ecosystem.\n/// TBTC Vault mints and
|
|
20
|
+
"content": "// SPDX-License-Identifier: MIT\n\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ██████████████ ▐████▌ ██████████████\n// ██████████████ ▐████▌ ██████████████\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n// ▐████▌ ▐████▌\n\npragma solidity ^0.8.9;\n\nimport \"@keep-network/random-beacon/contracts/Governable.sol\";\n\nimport \"./IVault.sol\";\nimport \"../bank/Bank.sol\";\nimport \"../token/TBTC.sol\";\n\n/// @title TBTC application vault\n/// @notice TBTC is a fully Bitcoin-backed ERC-20 token pegged to the price of\n/// Bitcoin. It facilitates Bitcoin holders to act on the Ethereum\n/// blockchain and access the decentralized finance (DeFi) ecosystem.\n/// TBTC Vault mints and unmints TBTC based on Bitcoin balances in the\n/// Bank.\n/// @dev TBTC Vault is the owner of TBTC token contract and is the only contract\n/// minting the token.\ncontract TBTCVault is IVault, Governable {\n Bank public bank;\n TBTC public tbtcToken;\n\n event Minted(address indexed to, uint256 amount);\n\n event Unminted(address indexed from, uint256 amount);\n\n modifier onlyBank() {\n require(msg.sender == address(bank), \"Caller is not the Bank\");\n _;\n }\n\n constructor(Bank _bank, TBTC _tbtcToken) {\n require(\n address(_bank) != address(0),\n \"Bank can not be the zero address\"\n );\n\n require(\n address(_tbtcToken) != address(0),\n \"TBTC token can not be the zero address\"\n );\n\n bank = _bank;\n tbtcToken = _tbtcToken;\n\n _transferGovernance(msg.sender);\n }\n\n /// @notice Allows the governance of the TBTCVault to recover any ERC20\n /// token sent mistakenly to the TBTC token contract address.\n /// @param token Address of the recovered ERC20 token contract.\n /// @param recipient Address the recovered token should be sent to.\n /// @param amount Recovered amount.\n function recoverERC20(\n IERC20 token,\n address recipient,\n uint256 amount\n ) external onlyGovernance {\n tbtcToken.recoverERC20(token, recipient, amount);\n }\n\n /// @notice Allows the governance of the TBTCVault to recover any ERC721\n /// token sent mistakenly to the TBTC token contract address.\n /// @param token Address of the recovered ERC721 token contract.\n /// @param recipient Address the recovered token should be sent to.\n /// @param tokenId Identifier of the recovered token.\n /// @param data Additional data.\n function recoverERC721(\n IERC721 token,\n address recipient,\n uint256 tokenId,\n bytes calldata data\n ) external onlyGovernance {\n tbtcToken.recoverERC721(token, recipient, tokenId, data);\n }\n\n /// @notice Transfers the given `amount` of the Bank balance from caller\n /// to TBTC Vault, and mints `amount` of TBTC to the caller.\n /// @dev TBTC Vault must have an allowance for caller's balance in the Bank\n /// for at least `amount`.\n /// @param amount Amount of TBTC to mint.\n function mint(uint256 amount) external {\n address minter = msg.sender;\n require(\n bank.balanceOf(minter) >= amount,\n \"Amount exceeds balance in the bank\"\n );\n _mint(minter, amount);\n bank.transferBalanceFrom(minter, address(this), amount);\n }\n\n /// @notice Transfers the given `amount` of the Bank balance from the caller\n /// to TBTC Vault and mints `amount` of TBTC to the caller.\n /// @dev Can only be called by the Bank via `approveBalanceAndCall`.\n /// @param owner The owner who approved their Bank balance.\n /// @param amount Amount of TBTC to mint.\n function receiveBalanceApproval(\n address owner,\n uint256 amount,\n bytes memory\n ) external override onlyBank {\n require(\n bank.balanceOf(owner) >= amount,\n \"Amount exceeds balance in the bank\"\n );\n _mint(owner, amount);\n bank.transferBalanceFrom(owner, address(this), amount);\n }\n\n /// @notice Mints the same amount of TBTC as the deposited amount for each\n /// depositor in the array. Can only be called by the Bank after the\n /// Bridge swept deposits and Bank increased balance for the\n /// vault.\n /// @dev Fails if `depositors` array is empty. Expects the length of\n /// `depositors` and `depositedAmounts` is the same.\n function receiveBalanceIncrease(\n address[] calldata depositors,\n uint256[] calldata depositedAmounts\n ) external override onlyBank {\n require(depositors.length != 0, \"No depositors specified\");\n for (uint256 i = 0; i < depositors.length; i++) {\n _mint(depositors[i], depositedAmounts[i]);\n }\n }\n\n /// @notice Burns `amount` of TBTC from the caller's account and transfers\n /// `amount` back to the caller's balance in the Bank.\n /// @dev Caller must have at least `amount` of TBTC approved to\n /// TBTC Vault.\n /// @param amount Amount of TBTC to unmint.\n function unmint(uint256 amount) external {\n _unmint(msg.sender, amount);\n }\n\n /// @notice Burns `amount` of TBTC from the caller's account and transfers\n /// `amount` back to the caller's balance in the Bank.\n /// @dev This function is doing the same as `unmint` but it allows to\n /// execute unminting without an additional approval transaction.\n /// The function can be called only via `approveAndCall` of TBTC token.\n /// @param from TBTC token holder executing unminting.\n /// @param amount Amount of TBTC to unmint.\n /// @param token TBTC token address.\n function receiveApproval(\n address from,\n uint256 amount,\n address token,\n bytes calldata\n ) external {\n require(token == address(tbtcToken), \"Token is not TBTC\");\n require(msg.sender == token, \"Only TBTC caller allowed\");\n _unmint(from, amount);\n }\n\n // slither-disable-next-line calls-loop\n function _mint(address minter, uint256 amount) internal {\n emit Minted(minter, amount);\n tbtcToken.mint(minter, amount);\n }\n\n function _unmint(address unminter, uint256 amount) internal {\n emit Unminted(unminter, amount);\n tbtcToken.burnFrom(unminter, amount);\n bank.transferBalance(unminter, amount);\n }\n}\n"
|
|
21
21
|
},
|
|
22
22
|
"@keep-network/random-beacon/contracts/Governable.sol": {
|
|
23
23
|
"content": "// SPDX-License-Identifier: MIT\n//\n// ▓▓▌ ▓▓ ▐▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▄\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▌▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓ ▐▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▄▄▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▄▄▄▄ ▓▓▓▓▓▓▄▄▄▄ ▐▓▓▓▓▓▌ ▐▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓▓▓▓▀ ▐▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▀▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓▀▀▀▀ ▓▓▓▓▓▓▀▀▀▀ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀\n// ▓▓▓▓▓▓ ▀▓▓▓▓▓▓▄ ▐▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓▓▓▓▓ ▓▓▓▓▓ ▐▓▓▓▓▓▌\n// ▓▓▓▓▓▓▓▓▓▓ █▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n// ▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓ ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓\n//\n// Trust math, not hardware.\n\npragma solidity ^0.8.9;\n\n/// @notice Governable contract.\n/// @dev A constructor is not defined, which makes the contract compatible with\n/// upgradable proxies. This requires calling explicitly `_transferGovernance`\n/// function in a child contract.\nabstract contract Governable {\n // Governance of the contract\n // The variable should be initialized by the implementing contract.\n // slither-disable-next-line uninitialized-state\n address public governance;\n\n // Reserved storage space in case we need to add more variables,\n // since there are upgradeable contracts that inherit from this one.\n // See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n // slither-disable-next-line unused-state\n uint256[49] private __gap;\n\n event GovernanceTransferred(address oldGovernance, address newGovernance);\n\n modifier onlyGovernance() virtual {\n require(governance == msg.sender, \"Caller is not the governance\");\n _;\n }\n\n /// @notice Transfers governance of the contract to `newGovernance`.\n function transferGovernance(address newGovernance)\n external\n virtual\n onlyGovernance\n {\n require(\n newGovernance != address(0),\n \"New governance is the zero address\"\n );\n _transferGovernance(newGovernance);\n }\n\n function _transferGovernance(address newGovernance) internal virtual {\n address oldGovernance = governance;\n governance = newGovernance;\n emit GovernanceTransferred(oldGovernance, newGovernance);\n }\n}\n"
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"type": "uint256"
|
|
74
74
|
}
|
|
75
75
|
],
|
|
76
|
-
"name": "
|
|
76
|
+
"name": "Unminted",
|
|
77
77
|
"type": "event"
|
|
78
78
|
},
|
|
79
79
|
{
|
|
@@ -235,19 +235,6 @@
|
|
|
235
235
|
"stateMutability": "nonpayable",
|
|
236
236
|
"type": "function"
|
|
237
237
|
},
|
|
238
|
-
{
|
|
239
|
-
"inputs": [
|
|
240
|
-
{
|
|
241
|
-
"internalType": "uint256",
|
|
242
|
-
"name": "amount",
|
|
243
|
-
"type": "uint256"
|
|
244
|
-
}
|
|
245
|
-
],
|
|
246
|
-
"name": "redeem",
|
|
247
|
-
"outputs": [],
|
|
248
|
-
"stateMutability": "nonpayable",
|
|
249
|
-
"type": "function"
|
|
250
|
-
},
|
|
251
238
|
{
|
|
252
239
|
"inputs": [],
|
|
253
240
|
"name": "tbtcToken",
|
|
@@ -273,10 +260,23 @@
|
|
|
273
260
|
"outputs": [],
|
|
274
261
|
"stateMutability": "nonpayable",
|
|
275
262
|
"type": "function"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"inputs": [
|
|
266
|
+
{
|
|
267
|
+
"internalType": "uint256",
|
|
268
|
+
"name": "amount",
|
|
269
|
+
"type": "uint256"
|
|
270
|
+
}
|
|
271
|
+
],
|
|
272
|
+
"name": "unmint",
|
|
273
|
+
"outputs": [],
|
|
274
|
+
"stateMutability": "nonpayable",
|
|
275
|
+
"type": "function"
|
|
276
276
|
}
|
|
277
277
|
],
|
|
278
|
-
"bytecode": "
|
|
279
|
-
"deployedBytecode": "
|
|
278
|
+
"bytecode": "0x608060405234801561001057600080fd5b5060405161114638038061114683398101604081905261002f916101a8565b6001600160a01b03821661008a5760405162461bcd60e51b815260206004820181905260248201527f42616e6b2063616e206e6f7420626520746865207a65726f206164647265737360448201526064015b60405180910390fd5b6001600160a01b0381166100ef5760405162461bcd60e51b815260206004820152602660248201527f5442544320746f6b656e2063616e206e6f7420626520746865207a65726f206160448201526564647265737360d01b6064820152608401610081565b603280546001600160a01b038085166001600160a01b03199283161790925560338054928416929091169190911790556101283361012f565b50506101e2565b600080546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80910160405180910390a15050565b6001600160a01b03811681146101a557600080fd5b50565b600080604083850312156101bb57600080fd5b82516101c681610190565b60208401519092506101d781610190565b809150509250929050565b610f55806101f16000396000f3fe608060405234801561001057600080fd5b50600436106100c95760003560e01c806376cdb03b11610081578063d38bfff41161005b578063d38bfff414610184578063e5d3d71414610197578063fc4e51f6146101aa57600080fd5b806376cdb03b1461014b5780638f4ffcb11461015e578063a0712d681461017157600080fd5b8063475d0570116100b2578063475d0570146100f65780635aa6e6751461010957806364e779b11461013857600080fd5b80631171bda9146100ce578063461c6373146100e3575b600080fd5b6100e16100dc366004610b4f565b6101bd565b005b6100e16100f1366004610bdc565b6102a9565b6100e1610104366004610c5e565b6103bc565b60005461011c906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6100e1610146366004610d2b565b610535565b60325461011c906001600160a01b031681565b6100e161016c366004610d86565b610542565b6100e161017f366004610d2b565b610601565b6100e1610192366004610df9565b610755565b60335461011c906001600160a01b031681565b6100e16101b8366004610e1d565b610834565b6000546001600160a01b0316331461021c5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e63650000000060448201526064015b60405180910390fd5b6033546040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015284811660248301526044820184905290911690631171bda9906064015b600060405180830381600087803b15801561028c57600080fd5b505af11580156102a0573d6000803e3d6000fd5b50505050505050565b6032546001600160a01b031633146103035760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610213565b826103505760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f7273207370656369666965640000000000000000006044820152606401610213565b60005b838110156103b5576103a385858381811061037057610370610e73565b90506020020160208101906103859190610df9565b84848481811061039757610397610e73565b90506020020135610918565b806103ad81610e89565b915050610353565b5050505050565b6032546001600160a01b031633146104165760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610213565b6032546040516370a0823160e01b81526001600160a01b038581166004830152849216906370a082319060240160206040518083038186803b15801561045b57600080fd5b505afa15801561046f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104939190610eb2565b10156104ec5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610213565b6104f68383610918565b603254604051631f1b6d2760e21b81526001600160a01b0385811660048301523060248301526044820185905290911690637c6db49c90606401610272565b61053f33826109ad565b50565b6033546001600160a01b0384811691161461059f5760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f7420544254430000000000000000000000000000006044820152606401610213565b336001600160a01b038416146105f75760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f77656400000000000000006044820152606401610213565b6103b585856109ad565b6032546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b15801561064957600080fd5b505afa15801561065d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106819190610eb2565b10156106da5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610213565b6106e48183610918565b603254604051631f1b6d2760e21b81526001600160a01b0383811660048301523060248301526044820185905290911690637c6db49c906064015b600060405180830381600087803b15801561073957600080fd5b505af115801561074d573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146107af5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610213565b6001600160a01b03811661082b5760405162461bcd60e51b815260206004820152602260248201527f4e657720676f7665726e616e636520697320746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610213565b61053f81610ac1565b6000546001600160a01b0316331461088e5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610213565b6033546040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063fc4e51f6906108df9088908890889088908890600401610ecb565b600060405180830381600087803b1580156108f957600080fd5b505af115801561090d573d6000803e3d6000fd5b505050505050505050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe8260405161095391815260200190565b60405180910390a26033546040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906340c10f199060440161071f565b816001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b8826040516109e891815260200190565b60405180910390a26033546040517f79cc67900000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906379cc679090604401600060405180830381600087803b158015610a5757600080fd5b505af1158015610a6b573d6000803e3d6000fd5b50506032546040517f56a6d9ef0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301526024820186905290911692506356a6d9ef915060440161071f565b600080546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117909355604080519190921680825260208201939093527f5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80910160405180910390a15050565b6001600160a01b038116811461053f57600080fd5b600080600060608486031215610b6457600080fd5b8335610b6f81610b3a565b92506020840135610b7f81610b3a565b929592945050506040919091013590565b60008083601f840112610ba257600080fd5b50813567ffffffffffffffff811115610bba57600080fd5b6020830191508360208260051b8501011115610bd557600080fd5b9250929050565b60008060008060408587031215610bf257600080fd5b843567ffffffffffffffff80821115610c0a57600080fd5b610c1688838901610b90565b90965094506020870135915080821115610c2f57600080fd5b50610c3c87828801610b90565b95989497509550505050565b634e487b7160e01b600052604160045260246000fd5b600080600060608486031215610c7357600080fd5b8335610c7e81610b3a565b925060208401359150604084013567ffffffffffffffff80821115610ca257600080fd5b818601915086601f830112610cb657600080fd5b813581811115610cc857610cc8610c48565b604051601f8201601f19908116603f01168101908382118183101715610cf057610cf0610c48565b81604052828152896020848701011115610d0957600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600060208284031215610d3d57600080fd5b5035919050565b60008083601f840112610d5657600080fd5b50813567ffffffffffffffff811115610d6e57600080fd5b602083019150836020828501011115610bd557600080fd5b600080600080600060808688031215610d9e57600080fd5b8535610da981610b3a565b9450602086013593506040860135610dc081610b3a565b9250606086013567ffffffffffffffff811115610ddc57600080fd5b610de888828901610d44565b969995985093965092949392505050565b600060208284031215610e0b57600080fd5b8135610e1681610b3a565b9392505050565b600080600080600060808688031215610e3557600080fd5b8535610e4081610b3a565b94506020860135610e5081610b3a565b935060408601359250606086013567ffffffffffffffff811115610ddc57600080fd5b634e487b7160e01b600052603260045260246000fd5b6000600019821415610eab57634e487b7160e01b600052601160045260246000fd5b5060010190565b600060208284031215610ec457600080fd5b5051919050565b60006001600160a01b03808816835280871660208401525084604083015260806060830152826080830152828460a0840137600060a0848401015260a0601f19601f8501168301019050969550505050505056fea26469706673582212209e4975796006d1db5a7262daa7434fa2dbff97aad3fb5e7c0afab1d02413c3fa64736f6c63430008090033",
|
|
279
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100c95760003560e01c806376cdb03b11610081578063d38bfff41161005b578063d38bfff414610184578063e5d3d71414610197578063fc4e51f6146101aa57600080fd5b806376cdb03b1461014b5780638f4ffcb11461015e578063a0712d681461017157600080fd5b8063475d0570116100b2578063475d0570146100f65780635aa6e6751461010957806364e779b11461013857600080fd5b80631171bda9146100ce578063461c6373146100e3575b600080fd5b6100e16100dc366004610b4f565b6101bd565b005b6100e16100f1366004610bdc565b6102a9565b6100e1610104366004610c5e565b6103bc565b60005461011c906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6100e1610146366004610d2b565b610535565b60325461011c906001600160a01b031681565b6100e161016c366004610d86565b610542565b6100e161017f366004610d2b565b610601565b6100e1610192366004610df9565b610755565b60335461011c906001600160a01b031681565b6100e16101b8366004610e1d565b610834565b6000546001600160a01b0316331461021c5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e63650000000060448201526064015b60405180910390fd5b6033546040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015284811660248301526044820184905290911690631171bda9906064015b600060405180830381600087803b15801561028c57600080fd5b505af11580156102a0573d6000803e3d6000fd5b50505050505050565b6032546001600160a01b031633146103035760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610213565b826103505760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f7273207370656369666965640000000000000000006044820152606401610213565b60005b838110156103b5576103a385858381811061037057610370610e73565b90506020020160208101906103859190610df9565b84848481811061039757610397610e73565b90506020020135610918565b806103ad81610e89565b915050610353565b5050505050565b6032546001600160a01b031633146104165760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610213565b6032546040516370a0823160e01b81526001600160a01b038581166004830152849216906370a082319060240160206040518083038186803b15801561045b57600080fd5b505afa15801561046f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104939190610eb2565b10156104ec5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610213565b6104f68383610918565b603254604051631f1b6d2760e21b81526001600160a01b0385811660048301523060248301526044820185905290911690637c6db49c90606401610272565b61053f33826109ad565b50565b6033546001600160a01b0384811691161461059f5760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f7420544254430000000000000000000000000000006044820152606401610213565b336001600160a01b038416146105f75760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f77656400000000000000006044820152606401610213565b6103b585856109ad565b6032546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b15801561064957600080fd5b505afa15801561065d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106819190610eb2565b10156106da5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610213565b6106e48183610918565b603254604051631f1b6d2760e21b81526001600160a01b0383811660048301523060248301526044820185905290911690637c6db49c906064015b600060405180830381600087803b15801561073957600080fd5b505af115801561074d573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146107af5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610213565b6001600160a01b03811661082b5760405162461bcd60e51b815260206004820152602260248201527f4e657720676f7665726e616e636520697320746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610213565b61053f81610ac1565b6000546001600160a01b0316331461088e5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610213565b6033546040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063fc4e51f6906108df9088908890889088908890600401610ecb565b600060405180830381600087803b1580156108f957600080fd5b505af115801561090d573d6000803e3d6000fd5b505050505050505050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe8260405161095391815260200190565b60405180910390a26033546040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906340c10f199060440161071f565b816001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b8826040516109e891815260200190565b60405180910390a26033546040517f79cc67900000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906379cc679090604401600060405180830381600087803b158015610a5757600080fd5b505af1158015610a6b573d6000803e3d6000fd5b50506032546040517f56a6d9ef0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301526024820186905290911692506356a6d9ef915060440161071f565b600080546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117909355604080519190921680825260208201939093527f5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80910160405180910390a15050565b6001600160a01b038116811461053f57600080fd5b600080600060608486031215610b6457600080fd5b8335610b6f81610b3a565b92506020840135610b7f81610b3a565b929592945050506040919091013590565b60008083601f840112610ba257600080fd5b50813567ffffffffffffffff811115610bba57600080fd5b6020830191508360208260051b8501011115610bd557600080fd5b9250929050565b60008060008060408587031215610bf257600080fd5b843567ffffffffffffffff80821115610c0a57600080fd5b610c1688838901610b90565b90965094506020870135915080821115610c2f57600080fd5b50610c3c87828801610b90565b95989497509550505050565b634e487b7160e01b600052604160045260246000fd5b600080600060608486031215610c7357600080fd5b8335610c7e81610b3a565b925060208401359150604084013567ffffffffffffffff80821115610ca257600080fd5b818601915086601f830112610cb657600080fd5b813581811115610cc857610cc8610c48565b604051601f8201601f19908116603f01168101908382118183101715610cf057610cf0610c48565b81604052828152896020848701011115610d0957600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600060208284031215610d3d57600080fd5b5035919050565b60008083601f840112610d5657600080fd5b50813567ffffffffffffffff811115610d6e57600080fd5b602083019150836020828501011115610bd557600080fd5b600080600080600060808688031215610d9e57600080fd5b8535610da981610b3a565b9450602086013593506040860135610dc081610b3a565b9250606086013567ffffffffffffffff811115610ddc57600080fd5b610de888828901610d44565b969995985093965092949392505050565b600060208284031215610e0b57600080fd5b8135610e1681610b3a565b9392505050565b600080600080600060808688031215610e3557600080fd5b8535610e4081610b3a565b94506020860135610e5081610b3a565b935060408601359250606086013567ffffffffffffffff811115610ddc57600080fd5b634e487b7160e01b600052603260045260246000fd5b6000600019821415610eab57634e487b7160e01b600052601160045260246000fd5b5060010190565b600060208284031215610ec457600080fd5b5051919050565b60006001600160a01b03808816835280871660208401525084604083015260806060830152826080830152828460a0840137600060a0848401015260a0601f19601f8501168301019050969550505050505056fea26469706673582212209e4975796006d1db5a7262daa7434fa2dbff97aad3fb5e7c0afab1d02413c3fa64736f6c63430008090033",
|
|
280
280
|
"linkReferences": {},
|
|
281
281
|
"deployedLinkReferences": {}
|
|
282
282
|
}
|
|
@@ -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");
|
|
@@ -140,18 +140,18 @@ contract TBTCVault is IVault, Governable {
|
|
|
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
148
|
/// @notice Burns `amount` of TBTC from the caller's account and transfers
|
|
149
149
|
/// `amount` back to the caller's balance in the Bank.
|
|
150
|
-
/// @dev This function is doing the same as `
|
|
151
|
-
/// execute
|
|
150
|
+
/// @dev This function is doing the same as `unmint` but it allows to
|
|
151
|
+
/// execute unminting without an additional approval transaction.
|
|
152
152
|
/// The function can be called only via `approveAndCall` of TBTC token.
|
|
153
|
-
/// @param from TBTC token holder executing
|
|
154
|
-
/// @param amount Amount of TBTC to
|
|
153
|
+
/// @param from TBTC token holder executing unminting.
|
|
154
|
+
/// @param amount Amount of TBTC to unmint.
|
|
155
155
|
/// @param token TBTC token address.
|
|
156
156
|
function receiveApproval(
|
|
157
157
|
address from,
|
|
@@ -161,7 +161,7 @@ contract TBTCVault is IVault, Governable {
|
|
|
161
161
|
) external {
|
|
162
162
|
require(token == address(tbtcToken), "Token is not TBTC");
|
|
163
163
|
require(msg.sender == token, "Only TBTC caller allowed");
|
|
164
|
-
|
|
164
|
+
_unmint(from, amount);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
// slither-disable-next-line calls-loop
|
|
@@ -170,9 +170,9 @@ contract TBTCVault is IVault, Governable {
|
|
|
170
170
|
tbtcToken.mint(minter, amount);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
function
|
|
174
|
-
emit
|
|
175
|
-
tbtcToken.burnFrom(
|
|
176
|
-
bank.transferBalance(
|
|
173
|
+
function _unmint(address unminter, uint256 amount) internal {
|
|
174
|
+
emit Unminted(unminter, amount);
|
|
175
|
+
tbtcToken.burnFrom(unminter, amount);
|
|
176
|
+
bank.transferBalance(unminter, amount);
|
|
177
177
|
}
|
|
178
178
|
}
|
package/export.json
CHANGED
|
@@ -16858,7 +16858,7 @@
|
|
|
16858
16858
|
"type": "uint256"
|
|
16859
16859
|
}
|
|
16860
16860
|
],
|
|
16861
|
-
"name": "
|
|
16861
|
+
"name": "Unminted",
|
|
16862
16862
|
"type": "event"
|
|
16863
16863
|
},
|
|
16864
16864
|
{
|
|
@@ -17020,19 +17020,6 @@
|
|
|
17020
17020
|
"stateMutability": "nonpayable",
|
|
17021
17021
|
"type": "function"
|
|
17022
17022
|
},
|
|
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
17023
|
{
|
|
17037
17024
|
"inputs": [],
|
|
17038
17025
|
"name": "tbtcToken",
|
|
@@ -17058,6 +17045,19 @@
|
|
|
17058
17045
|
"outputs": [],
|
|
17059
17046
|
"stateMutability": "nonpayable",
|
|
17060
17047
|
"type": "function"
|
|
17048
|
+
},
|
|
17049
|
+
{
|
|
17050
|
+
"inputs": [
|
|
17051
|
+
{
|
|
17052
|
+
"internalType": "uint256",
|
|
17053
|
+
"name": "amount",
|
|
17054
|
+
"type": "uint256"
|
|
17055
|
+
}
|
|
17056
|
+
],
|
|
17057
|
+
"name": "unmint",
|
|
17058
|
+
"outputs": [],
|
|
17059
|
+
"stateMutability": "nonpayable",
|
|
17060
|
+
"type": "function"
|
|
17061
17061
|
}
|
|
17062
17062
|
]
|
|
17063
17063
|
}
|