@keep-network/tbtc-v2 0.1.1-dev.61 → 0.1.1-dev.62

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 (55) hide show
  1. package/artifacts/Bank.json +3 -3
  2. package/artifacts/Bridge.json +3 -3
  3. package/artifacts/Deposit.json +2 -2
  4. package/artifacts/DepositSweep.json +2 -2
  5. package/artifacts/EcdsaDkgValidator.json +1 -1
  6. package/artifacts/EcdsaInactivity.json +1 -1
  7. package/artifacts/Fraud.json +2 -2
  8. package/artifacts/KeepRegistry.json +1 -1
  9. package/artifacts/KeepStake.json +2 -2
  10. package/artifacts/KeepToken.json +2 -2
  11. package/artifacts/KeepTokenStaking.json +1 -1
  12. package/artifacts/MovingFunds.json +2 -2
  13. package/artifacts/NuCypherStakingEscrow.json +1 -1
  14. package/artifacts/NuCypherToken.json +2 -2
  15. package/artifacts/RandomBeaconStub.json +1 -1
  16. package/artifacts/Redemption.json +2 -2
  17. package/artifacts/ReimbursementPool.json +2 -2
  18. package/artifacts/Relay.json +2 -2
  19. package/artifacts/SortitionPool.json +2 -2
  20. package/artifacts/T.json +2 -2
  21. package/artifacts/TBTC.json +3 -3
  22. package/artifacts/TBTCToken.json +3 -3
  23. package/artifacts/TokenStaking.json +1 -1
  24. package/artifacts/TokenholderGovernor.json +9 -9
  25. package/artifacts/TokenholderTimelock.json +8 -8
  26. package/artifacts/VendingMachine.json +3 -3
  27. package/artifacts/VendingMachineKeep.json +1 -1
  28. package/artifacts/VendingMachineNuCypher.json +1 -1
  29. package/artifacts/WalletRegistry.json +2 -2
  30. package/artifacts/WalletRegistryGovernance.json +2 -2
  31. package/artifacts/Wallets.json +2 -2
  32. package/artifacts/solcInputs/{6ff443beb223cf0c26c6b81361aa1799.json → 05c98d94f96a77da7702c7818a8cadac.json} +3 -0
  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/Bridge.sol/Bridge.dbg.json +1 -1
  37. package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
  38. package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
  39. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
  40. package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
  41. package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
  42. package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +1 -1
  43. package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
  44. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
  45. package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
  46. package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
  47. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
  48. package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
  49. package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
  50. package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +4 -0
  51. package/build/contracts/vault/DonationVault.sol/DonationVault.json +103 -0
  52. package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
  53. package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
  54. package/contracts/vault/DonationVault.sol +125 -0
  55. package/package.json +1 -1
@@ -190,6 +190,9 @@
190
190
  "contracts/test/TestERC721.sol": {
191
191
  "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\";\n\ncontract TestERC721 is ERC721 {\n string public constant NAME = \"Test ERC721 Token\";\n string public constant SYMBOL = \"TT\";\n\n constructor() ERC721(NAME, SYMBOL) {}\n\n function mint(address to, uint256 tokenId) public {\n _mint(to, tokenId);\n }\n}\n"
192
192
  },
193
+ "contracts/vault/DonationVault.sol": {
194
+ "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 \"./IVault.sol\";\nimport \"../bank/Bank.sol\";\n\n/// @title BTC donation vault\n/// @notice Vault that allows making BTC donations to the system. Upon deposit,\n/// this vault does not increase depositors' balances and always\n/// decreases its own balance in the same transaction. The vault also\n/// allows making donations using existing Bank balances.\n///\n/// BEWARE: ALL BTC DEPOSITS TARGETING THIS VAULT ARE NOT REDEEMABLE\n/// AND THERE IS NO WAY TO RESTORE THE DONATED BALANCE.\n/// USE THIS VAULT ONLY WHEN YOU REALLY KNOW WHAT YOU ARE DOING!\ncontract DonationVault is IVault {\n Bank public bank;\n\n event DonationReceived(address donor, uint256 donatedAmount);\n\n modifier onlyBank() {\n require(msg.sender == address(bank), \"Caller is not the Bank\");\n _;\n }\n\n constructor(Bank _bank) {\n require(\n address(_bank) != address(0),\n \"Bank can not be the zero address\"\n );\n\n bank = _bank;\n }\n\n /// @notice Transfers the given `amount` of the Bank balance from the\n /// caller to the Donation Vault and immediately decreases the\n /// vault's balance in the Bank by the transferred `amount`.\n /// @param amount Amount of the Bank balance to donate\n /// @dev Requirements:\n /// - The caller's balance in the Bank must be greater than or equal\n /// to the `amount`.\n /// - Donation Vault must have an allowance for caller's balance in\n /// the Bank for at least `amount`.\n function donate(uint256 amount) external {\n address donor = msg.sender;\n\n require(\n bank.balanceOf(donor) >= amount,\n \"Amount exceeds balance in the bank\"\n );\n\n emit DonationReceived(donor, amount);\n\n bank.transferBalanceFrom(donor, address(this), amount);\n bank.decreaseBalance(amount);\n }\n\n /// @notice Transfers the given `amount` of the Bank balance from the\n /// `owner` to the Donation Vault and immediately decreases the\n /// vault's balance in the Bank by the transferred `amount`.\n /// @param owner Address of the Bank balance owner who approved their\n /// balance to be used by the vault\n /// @param amount The amount of the Bank balance approved by the owner\n /// to be used by the vault\n /// @dev Requirements:\n /// - Can only be called by the Bank via `approveBalanceAndCall`.\n /// - The `owner` balance in the Bank must be greater than or equal\n /// to the `amount`.\n function receiveBalanceApproval(address owner, uint256 amount)\n external\n override\n onlyBank\n {\n require(\n bank.balanceOf(owner) >= amount,\n \"Amount exceeds balance in the bank\"\n );\n\n emit DonationReceived(owner, amount);\n\n bank.transferBalanceFrom(owner, address(this), amount);\n bank.decreaseBalance(amount);\n }\n\n /// @notice Ignores the deposited amounts and does not increase depositors'\n /// individual balances. The vault decreases its own tBTC balance\n /// in the Bank by the total deposited amount.\n /// @param depositors Addresses of depositors whose deposits have been swept\n /// @param depositedAmounts Amounts deposited by individual depositors and\n /// swept\n /// @dev Requirements:\n /// - Can only be called by the Bank after the Bridge swept deposits\n /// and Bank increased balance for the vault.\n /// - The `depositors` array must not be empty.\n /// - The `depositors` array length must be equal to the\n /// `depositedAmounts` array length.\n function receiveBalanceIncrease(\n address[] calldata depositors,\n uint256[] calldata depositedAmounts\n ) external override onlyBank {\n require(depositors.length != 0, \"No depositors specified\");\n\n uint256 totalAmount = 0;\n for (uint256 i = 0; i < depositors.length; i++) {\n totalAmount += depositedAmounts[i];\n emit DonationReceived(depositors[i], depositedAmounts[i]);\n }\n\n bank.decreaseBalance(totalAmount);\n }\n}\n"
195
+ },
193
196
  "contracts/test/BankStub.sol": {
194
197
  "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\nimport \"../bank/Bank.sol\";\n\ncontract BankStub is Bank {\n function setBalance(address addr, uint256 amount) external {\n balanceOf[addr] = amount;\n }\n}\n"
195
198
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -0,0 +1,4 @@
1
+ {
2
+ "_format": "hh-sol-dbg-1",
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
+ }
@@ -0,0 +1,103 @@
1
+ {
2
+ "_format": "hh-sol-artifact-1",
3
+ "contractName": "DonationVault",
4
+ "sourceName": "contracts/vault/DonationVault.sol",
5
+ "abi": [
6
+ {
7
+ "inputs": [
8
+ {
9
+ "internalType": "contract Bank",
10
+ "name": "_bank",
11
+ "type": "address"
12
+ }
13
+ ],
14
+ "stateMutability": "nonpayable",
15
+ "type": "constructor"
16
+ },
17
+ {
18
+ "anonymous": false,
19
+ "inputs": [
20
+ {
21
+ "indexed": false,
22
+ "internalType": "address",
23
+ "name": "donor",
24
+ "type": "address"
25
+ },
26
+ {
27
+ "indexed": false,
28
+ "internalType": "uint256",
29
+ "name": "donatedAmount",
30
+ "type": "uint256"
31
+ }
32
+ ],
33
+ "name": "DonationReceived",
34
+ "type": "event"
35
+ },
36
+ {
37
+ "inputs": [],
38
+ "name": "bank",
39
+ "outputs": [
40
+ {
41
+ "internalType": "contract Bank",
42
+ "name": "",
43
+ "type": "address"
44
+ }
45
+ ],
46
+ "stateMutability": "view",
47
+ "type": "function"
48
+ },
49
+ {
50
+ "inputs": [
51
+ {
52
+ "internalType": "uint256",
53
+ "name": "amount",
54
+ "type": "uint256"
55
+ }
56
+ ],
57
+ "name": "donate",
58
+ "outputs": [],
59
+ "stateMutability": "nonpayable",
60
+ "type": "function"
61
+ },
62
+ {
63
+ "inputs": [
64
+ {
65
+ "internalType": "address",
66
+ "name": "owner",
67
+ "type": "address"
68
+ },
69
+ {
70
+ "internalType": "uint256",
71
+ "name": "amount",
72
+ "type": "uint256"
73
+ }
74
+ ],
75
+ "name": "receiveBalanceApproval",
76
+ "outputs": [],
77
+ "stateMutability": "nonpayable",
78
+ "type": "function"
79
+ },
80
+ {
81
+ "inputs": [
82
+ {
83
+ "internalType": "address[]",
84
+ "name": "depositors",
85
+ "type": "address[]"
86
+ },
87
+ {
88
+ "internalType": "uint256[]",
89
+ "name": "depositedAmounts",
90
+ "type": "uint256[]"
91
+ }
92
+ ],
93
+ "name": "receiveBalanceIncrease",
94
+ "outputs": [],
95
+ "stateMutability": "nonpayable",
96
+ "type": "function"
97
+ }
98
+ ],
99
+ "bytecode": "0x608060405234801561001057600080fd5b5060405161096138038061096183398101604081905261002f916100ae565b6001600160a01b0381166100895760405162461bcd60e51b815260206004820181905260248201527f42616e6b2063616e206e6f7420626520746865207a65726f2061646472657373604482015260640160405180910390fd5b600080546001600160a01b0319166001600160a01b03929092169190911790556100de565b6000602082840312156100c057600080fd5b81516001600160a01b03811681146100d757600080fd5b9392505050565b610874806100ed6000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c8063461c637314610051578063537941371461006657806376cdb03b14610079578063f14faf6f146100a8575b600080fd5b61006461005f3660046106d9565b6100bb565b005b610064610074366004610761565b610294565b60005461008c906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6100646100b636600461078b565b6104d5565b6000546001600160a01b0316331461011a5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064015b60405180910390fd5b826101675760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f7273207370656369666965640000000000000000006044820152606401610111565b6000805b8481101561022e57838382818110610185576101856107a4565b905060200201358261019791906107d0565b91507f264f630d9efa0d07053a31163641d9fcc0adafc9d9e76f1c37c2ce3a558d2c528686838181106101cc576101cc6107a4565b90506020020160208101906101e191906107e8565b8585848181106101f3576101f36107a4565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a1806102268161080a565b91505061016b565b5060005460405163392aee4360e01b8152600481018390526001600160a01b039091169063392aee4390602401600060405180830381600087803b15801561027557600080fd5b505af1158015610289573d6000803e3d6000fd5b505050505050505050565b6000546001600160a01b031633146102ee5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610111565b6000546040516370a0823160e01b81526001600160a01b038481166004830152839216906370a082319060240160206040518083038186803b15801561033357600080fd5b505afa158015610347573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036b9190610825565b10156103c45760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610111565b604080516001600160a01b0384168152602081018390527f264f630d9efa0d07053a31163641d9fcc0adafc9d9e76f1c37c2ce3a558d2c52910160405180910390a1600054604051631f1b6d2760e21b81526001600160a01b0384811660048301523060248301526044820184905290911690637c6db49c90606401600060405180830381600087803b15801561045a57600080fd5b505af115801561046e573d6000803e3d6000fd5b505060005460405163392aee4360e01b8152600481018590526001600160a01b03909116925063392aee4391506024015b600060405180830381600087803b1580156104b957600080fd5b505af11580156104cd573d6000803e3d6000fd5b505050505050565b6000546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b15801561051d57600080fd5b505afa158015610531573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105559190610825565b10156105ae5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610111565b604080516001600160a01b0383168152602081018490527f264f630d9efa0d07053a31163641d9fcc0adafc9d9e76f1c37c2ce3a558d2c52910160405180910390a1600054604051631f1b6d2760e21b81526001600160a01b0383811660048301523060248301526044820185905290911690637c6db49c90606401600060405180830381600087803b15801561064457600080fd5b505af1158015610658573d6000803e3d6000fd5b505060005460405163392aee4360e01b8152600481018690526001600160a01b03909116925063392aee43915060240161049f565b60008083601f84011261069f57600080fd5b50813567ffffffffffffffff8111156106b757600080fd5b6020830191508360208260051b85010111156106d257600080fd5b9250929050565b600080600080604085870312156106ef57600080fd5b843567ffffffffffffffff8082111561070757600080fd5b6107138883890161068d565b9096509450602087013591508082111561072c57600080fd5b506107398782880161068d565b95989497509550505050565b80356001600160a01b038116811461075c57600080fd5b919050565b6000806040838503121561077457600080fd5b61077d83610745565b946020939093013593505050565b60006020828403121561079d57600080fd5b5035919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082198211156107e3576107e36107ba565b500190565b6000602082840312156107fa57600080fd5b61080382610745565b9392505050565b600060001982141561081e5761081e6107ba565b5060010190565b60006020828403121561083757600080fd5b505191905056fea2646970667358221220dc957cd9c5732cf06b6dbed9d89b94ba301340cb0f0b126392378c58fdeae32e64736f6c63430008090033",
100
+ "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c8063461c637314610051578063537941371461006657806376cdb03b14610079578063f14faf6f146100a8575b600080fd5b61006461005f3660046106d9565b6100bb565b005b610064610074366004610761565b610294565b60005461008c906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6100646100b636600461078b565b6104d5565b6000546001600160a01b0316331461011a5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b0000000000000000000060448201526064015b60405180910390fd5b826101675760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f7273207370656369666965640000000000000000006044820152606401610111565b6000805b8481101561022e57838382818110610185576101856107a4565b905060200201358261019791906107d0565b91507f264f630d9efa0d07053a31163641d9fcc0adafc9d9e76f1c37c2ce3a558d2c528686838181106101cc576101cc6107a4565b90506020020160208101906101e191906107e8565b8585848181106101f3576101f36107a4565b604080516001600160a01b0390951685526020918202939093013590840152500160405180910390a1806102268161080a565b91505061016b565b5060005460405163392aee4360e01b8152600481018390526001600160a01b039091169063392aee4390602401600060405180830381600087803b15801561027557600080fd5b505af1158015610289573d6000803e3d6000fd5b505050505050505050565b6000546001600160a01b031633146102ee5760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610111565b6000546040516370a0823160e01b81526001600160a01b038481166004830152839216906370a082319060240160206040518083038186803b15801561033357600080fd5b505afa158015610347573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061036b9190610825565b10156103c45760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610111565b604080516001600160a01b0384168152602081018390527f264f630d9efa0d07053a31163641d9fcc0adafc9d9e76f1c37c2ce3a558d2c52910160405180910390a1600054604051631f1b6d2760e21b81526001600160a01b0384811660048301523060248301526044820184905290911690637c6db49c90606401600060405180830381600087803b15801561045a57600080fd5b505af115801561046e573d6000803e3d6000fd5b505060005460405163392aee4360e01b8152600481018590526001600160a01b03909116925063392aee4391506024015b600060405180830381600087803b1580156104b957600080fd5b505af11580156104cd573d6000803e3d6000fd5b505050505050565b6000546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b15801561051d57600080fd5b505afa158015610531573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105559190610825565b10156105ae5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610111565b604080516001600160a01b0383168152602081018490527f264f630d9efa0d07053a31163641d9fcc0adafc9d9e76f1c37c2ce3a558d2c52910160405180910390a1600054604051631f1b6d2760e21b81526001600160a01b0383811660048301523060248301526044820185905290911690637c6db49c90606401600060405180830381600087803b15801561064457600080fd5b505af1158015610658573d6000803e3d6000fd5b505060005460405163392aee4360e01b8152600481018690526001600160a01b03909116925063392aee43915060240161049f565b60008083601f84011261069f57600080fd5b50813567ffffffffffffffff8111156106b757600080fd5b6020830191508360208260051b85010111156106d257600080fd5b9250929050565b600080600080604085870312156106ef57600080fd5b843567ffffffffffffffff8082111561070757600080fd5b6107138883890161068d565b9096509450602087013591508082111561072c57600080fd5b506107398782880161068d565b95989497509550505050565b80356001600160a01b038116811461075c57600080fd5b919050565b6000806040838503121561077457600080fd5b61077d83610745565b946020939093013593505050565b60006020828403121561079d57600080fd5b5035919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082198211156107e3576107e36107ba565b500190565b6000602082840312156107fa57600080fd5b61080382610745565b9392505050565b600060001982141561081e5761081e6107ba565b5060010190565b60006020828403121561083757600080fd5b505191905056fea2646970667358221220dc957cd9c5732cf06b6dbed9d89b94ba301340cb0f0b126392378c58fdeae32e64736f6c63430008090033",
101
+ "linkReferences": {},
102
+ "deployedLinkReferences": {}
103
+ }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "_format": "hh-sol-dbg-1",
3
- "buildInfo": "../../../build-info/013e70f95a1ea637f765500cfd16d8d4.json"
3
+ "buildInfo": "../../../build-info/a1155826dfa1f8a3eecfffafe048f2a9.json"
4
4
  }
@@ -0,0 +1,125 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ // ██████████████ ▐████▌ ██████████████
4
+ // ██████████████ ▐████▌ ██████████████
5
+ // ▐████▌ ▐████▌
6
+ // ▐████▌ ▐████▌
7
+ // ██████████████ ▐████▌ ██████████████
8
+ // ██████████████ ▐████▌ ██████████████
9
+ // ▐████▌ ▐████▌
10
+ // ▐████▌ ▐████▌
11
+ // ▐████▌ ▐████▌
12
+ // ▐████▌ ▐████▌
13
+ // ▐████▌ ▐████▌
14
+ // ▐████▌ ▐████▌
15
+
16
+ pragma solidity ^0.8.9;
17
+
18
+ import "./IVault.sol";
19
+ import "../bank/Bank.sol";
20
+
21
+ /// @title BTC donation vault
22
+ /// @notice Vault that allows making BTC donations to the system. Upon deposit,
23
+ /// this vault does not increase depositors' balances and always
24
+ /// decreases its own balance in the same transaction. The vault also
25
+ /// allows making donations using existing Bank balances.
26
+ ///
27
+ /// BEWARE: ALL BTC DEPOSITS TARGETING THIS VAULT ARE NOT REDEEMABLE
28
+ /// AND THERE IS NO WAY TO RESTORE THE DONATED BALANCE.
29
+ /// USE THIS VAULT ONLY WHEN YOU REALLY KNOW WHAT YOU ARE DOING!
30
+ contract DonationVault is IVault {
31
+ Bank public bank;
32
+
33
+ event DonationReceived(address donor, uint256 donatedAmount);
34
+
35
+ modifier onlyBank() {
36
+ require(msg.sender == address(bank), "Caller is not the Bank");
37
+ _;
38
+ }
39
+
40
+ constructor(Bank _bank) {
41
+ require(
42
+ address(_bank) != address(0),
43
+ "Bank can not be the zero address"
44
+ );
45
+
46
+ bank = _bank;
47
+ }
48
+
49
+ /// @notice Transfers the given `amount` of the Bank balance from the
50
+ /// caller to the Donation Vault and immediately decreases the
51
+ /// vault's balance in the Bank by the transferred `amount`.
52
+ /// @param amount Amount of the Bank balance to donate
53
+ /// @dev Requirements:
54
+ /// - The caller's balance in the Bank must be greater than or equal
55
+ /// to the `amount`.
56
+ /// - Donation Vault must have an allowance for caller's balance in
57
+ /// the Bank for at least `amount`.
58
+ function donate(uint256 amount) external {
59
+ address donor = msg.sender;
60
+
61
+ require(
62
+ bank.balanceOf(donor) >= amount,
63
+ "Amount exceeds balance in the bank"
64
+ );
65
+
66
+ emit DonationReceived(donor, amount);
67
+
68
+ bank.transferBalanceFrom(donor, address(this), amount);
69
+ bank.decreaseBalance(amount);
70
+ }
71
+
72
+ /// @notice Transfers the given `amount` of the Bank balance from the
73
+ /// `owner` to the Donation Vault and immediately decreases the
74
+ /// vault's balance in the Bank by the transferred `amount`.
75
+ /// @param owner Address of the Bank balance owner who approved their
76
+ /// balance to be used by the vault
77
+ /// @param amount The amount of the Bank balance approved by the owner
78
+ /// to be used by the vault
79
+ /// @dev Requirements:
80
+ /// - Can only be called by the Bank via `approveBalanceAndCall`.
81
+ /// - The `owner` balance in the Bank must be greater than or equal
82
+ /// to the `amount`.
83
+ function receiveBalanceApproval(address owner, uint256 amount)
84
+ external
85
+ override
86
+ onlyBank
87
+ {
88
+ require(
89
+ bank.balanceOf(owner) >= amount,
90
+ "Amount exceeds balance in the bank"
91
+ );
92
+
93
+ emit DonationReceived(owner, amount);
94
+
95
+ bank.transferBalanceFrom(owner, address(this), amount);
96
+ bank.decreaseBalance(amount);
97
+ }
98
+
99
+ /// @notice Ignores the deposited amounts and does not increase depositors'
100
+ /// individual balances. The vault decreases its own tBTC balance
101
+ /// in the Bank by the total deposited amount.
102
+ /// @param depositors Addresses of depositors whose deposits have been swept
103
+ /// @param depositedAmounts Amounts deposited by individual depositors and
104
+ /// swept
105
+ /// @dev Requirements:
106
+ /// - Can only be called by the Bank after the Bridge swept deposits
107
+ /// and Bank increased balance for the vault.
108
+ /// - The `depositors` array must not be empty.
109
+ /// - The `depositors` array length must be equal to the
110
+ /// `depositedAmounts` array length.
111
+ function receiveBalanceIncrease(
112
+ address[] calldata depositors,
113
+ uint256[] calldata depositedAmounts
114
+ ) external override onlyBank {
115
+ require(depositors.length != 0, "No depositors specified");
116
+
117
+ uint256 totalAmount = 0;
118
+ for (uint256 i = 0; i < depositors.length; i++) {
119
+ totalAmount += depositedAmounts[i];
120
+ emit DonationReceived(depositors[i], depositedAmounts[i]);
121
+ }
122
+
123
+ bank.decreaseBalance(totalAmount);
124
+ }
125
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keep-network/tbtc-v2",
3
- "version": "0.1.1-dev.61+main.7a1cd6ba871d67f537fa5b44cb36dbd2f29fb161",
3
+ "version": "0.1.1-dev.62+main.0b72875d1c74fabf79b85822aa47ac160f8b4c92",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "artifacts/",