@keep-network/tbtc-v2 0.1.1-dev.8 → 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/README.adoc +12 -0
- package/artifacts/Bank.json +817 -0
- package/artifacts/Bridge.json +2644 -0
- package/artifacts/Deposit.json +117 -0
- package/artifacts/DepositSweep.json +77 -0
- package/artifacts/EcdsaDkgValidator.json +532 -0
- package/artifacts/EcdsaInactivity.json +156 -0
- package/artifacts/EcdsaSortitionPool.json +1004 -0
- package/artifacts/Fraud.json +164 -0
- package/artifacts/KeepRegistry.json +99 -0
- package/artifacts/KeepStake.json +286 -0
- package/artifacts/KeepToken.json +711 -0
- package/artifacts/KeepTokenStaking.json +483 -0
- package/artifacts/MovingFunds.json +249 -0
- package/artifacts/NuCypherStakingEscrow.json +256 -0
- package/artifacts/NuCypherToken.json +711 -0
- package/artifacts/RandomBeaconStub.json +141 -0
- package/artifacts/Redemption.json +162 -0
- package/artifacts/ReimbursementPool.json +509 -0
- package/artifacts/Relay.json +123 -0
- package/artifacts/T.json +1148 -0
- package/artifacts/TBTC.json +27 -26
- package/artifacts/TBTCToken.json +27 -26
- package/artifacts/TBTCVault.json +462 -0
- package/artifacts/TokenStaking.json +2288 -0
- package/artifacts/TokenholderGovernor.json +1795 -0
- package/artifacts/TokenholderTimelock.json +1058 -0
- package/artifacts/VendingMachine.json +30 -29
- package/artifacts/VendingMachineKeep.json +400 -0
- package/artifacts/VendingMachineNuCypher.json +400 -0
- package/artifacts/WalletRegistry.json +1843 -0
- package/artifacts/WalletRegistryGovernance.json +2754 -0
- package/artifacts/Wallets.json +186 -0
- package/artifacts/solcInputs/5cd0a97e230d515eacf46fb60ea8963a.json +311 -0
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.json +2 -2
- package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.json +27 -4
- package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.dbg.json +4 -0
- package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.json +34 -0
- 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 +2516 -196
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +4 -0
- package/build/contracts/bridge/BridgeState.sol/BridgeState.json +226 -0
- package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +4 -0
- package/build/contracts/bridge/Deposit.sol/Deposit.json +72 -0
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +4 -0
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.json +30 -0
- package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +4 -0
- package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.json +10 -0
- package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +4 -0
- package/build/contracts/bridge/Fraud.sol/Fraud.json +86 -0
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +4 -0
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.json +10 -0
- package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +4 -0
- package/build/contracts/bridge/IRelay.sol/IRelay.json +37 -0
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +4 -0
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +138 -0
- package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +4 -0
- package/build/contracts/bridge/Redemption.sol/OutboundTx.json +10 -0
- package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +4 -0
- package/build/contracts/bridge/Redemption.sol/Redemption.json +92 -0
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.json +2 -2
- package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +4 -0
- package/build/contracts/bridge/Wallets.sol/Wallets.json +112 -0
- package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/token/TBTC.sol/TBTC.json +2 -2
- package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +4 -0
- package/build/contracts/vault/DonationVault.sol/DonationVault.json +108 -0
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
- package/build/contracts/vault/IVault.sol/IVault.json +24 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +137 -18
- package/contracts/GovernanceUtils.sol +4 -4
- package/contracts/bank/Bank.sol +119 -57
- package/contracts/bank/IReceiveBalanceApproval.sol +45 -0
- package/contracts/bridge/BitcoinTx.sol +232 -10
- package/contracts/bridge/Bridge.sol +1601 -244
- package/contracts/bridge/BridgeState.sol +739 -0
- package/contracts/bridge/Deposit.sol +269 -0
- package/contracts/bridge/DepositSweep.sol +571 -0
- package/contracts/bridge/EcdsaLib.sol +45 -0
- package/contracts/bridge/Fraud.sol +604 -0
- package/contracts/bridge/Heartbeat.sol +112 -0
- package/contracts/bridge/IRelay.sol +28 -0
- package/contracts/bridge/MovingFunds.sol +1089 -0
- package/contracts/bridge/Redemption.sol +867 -0
- package/contracts/bridge/VendingMachine.sol +1 -1
- package/contracts/bridge/Wallets.sol +553 -0
- package/contracts/hardhat-dependency-compiler/.hardhat-dependency-compiler +1 -0
- package/contracts/hardhat-dependency-compiler/@keep-network/ecdsa/contracts/WalletRegistry.sol +3 -0
- package/contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol +3 -0
- package/contracts/hardhat-dependency-compiler/@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol +3 -0
- package/contracts/token/TBTC.sol +1 -1
- package/contracts/vault/DonationVault.sol +125 -0
- package/contracts/vault/IVault.sol +19 -13
- package/contracts/vault/TBTCVault.sol +69 -19
- package/deploy/00_resolve_relay.ts +28 -0
- package/deploy/04_deploy_bank.ts +27 -0
- package/deploy/05_deploy_bridge.ts +80 -0
- package/deploy/06_deploy_tbtc_vault.ts +30 -0
- package/deploy/07_bank_update_bridge.ts +19 -0
- package/deploy/08_transfer_ownership.ts +15 -0
- package/deploy/09_transfer_governance.ts +20 -0
- package/deploy/10_transfer_proxy_admin_ownership.ts +30 -0
- package/deploy/11_deploy_proxy_admin_with_deputy.ts +33 -0
- package/export.json +15993 -475
- package/package.json +32 -25
- package/artifacts/solcInputs/4cf328e09411ac69d75a3c381680bc2c.json +0 -128
|
@@ -19,6 +19,25 @@
|
|
|
19
19
|
"stateMutability": "nonpayable",
|
|
20
20
|
"type": "constructor"
|
|
21
21
|
},
|
|
22
|
+
{
|
|
23
|
+
"anonymous": false,
|
|
24
|
+
"inputs": [
|
|
25
|
+
{
|
|
26
|
+
"indexed": false,
|
|
27
|
+
"internalType": "address",
|
|
28
|
+
"name": "oldGovernance",
|
|
29
|
+
"type": "address"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"indexed": false,
|
|
33
|
+
"internalType": "address",
|
|
34
|
+
"name": "newGovernance",
|
|
35
|
+
"type": "address"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"name": "GovernanceTransferred",
|
|
39
|
+
"type": "event"
|
|
40
|
+
},
|
|
22
41
|
{
|
|
23
42
|
"anonymous": false,
|
|
24
43
|
"inputs": [
|
|
@@ -54,7 +73,7 @@
|
|
|
54
73
|
"type": "uint256"
|
|
55
74
|
}
|
|
56
75
|
],
|
|
57
|
-
"name": "
|
|
76
|
+
"name": "Unminted",
|
|
58
77
|
"type": "event"
|
|
59
78
|
},
|
|
60
79
|
{
|
|
@@ -70,6 +89,19 @@
|
|
|
70
89
|
"stateMutability": "view",
|
|
71
90
|
"type": "function"
|
|
72
91
|
},
|
|
92
|
+
{
|
|
93
|
+
"inputs": [],
|
|
94
|
+
"name": "governance",
|
|
95
|
+
"outputs": [
|
|
96
|
+
{
|
|
97
|
+
"internalType": "address",
|
|
98
|
+
"name": "",
|
|
99
|
+
"type": "address"
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
"stateMutability": "view",
|
|
103
|
+
"type": "function"
|
|
104
|
+
},
|
|
73
105
|
{
|
|
74
106
|
"inputs": [
|
|
75
107
|
{
|
|
@@ -86,17 +118,27 @@
|
|
|
86
118
|
{
|
|
87
119
|
"inputs": [
|
|
88
120
|
{
|
|
89
|
-
"internalType": "address
|
|
90
|
-
"name": "
|
|
91
|
-
"type": "address
|
|
121
|
+
"internalType": "address",
|
|
122
|
+
"name": "from",
|
|
123
|
+
"type": "address"
|
|
92
124
|
},
|
|
93
125
|
{
|
|
94
|
-
"internalType": "uint256
|
|
95
|
-
"name": "
|
|
96
|
-
"type": "uint256
|
|
126
|
+
"internalType": "uint256",
|
|
127
|
+
"name": "amount",
|
|
128
|
+
"type": "uint256"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"internalType": "address",
|
|
132
|
+
"name": "token",
|
|
133
|
+
"type": "address"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"internalType": "bytes",
|
|
137
|
+
"name": "",
|
|
138
|
+
"type": "bytes"
|
|
97
139
|
}
|
|
98
140
|
],
|
|
99
|
-
"name": "
|
|
141
|
+
"name": "receiveApproval",
|
|
100
142
|
"outputs": [],
|
|
101
143
|
"stateMutability": "nonpayable",
|
|
102
144
|
"type": "function"
|
|
@@ -105,7 +147,7 @@
|
|
|
105
147
|
"inputs": [
|
|
106
148
|
{
|
|
107
149
|
"internalType": "address",
|
|
108
|
-
"name": "
|
|
150
|
+
"name": "owner",
|
|
109
151
|
"type": "address"
|
|
110
152
|
},
|
|
111
153
|
{
|
|
@@ -113,31 +155,82 @@
|
|
|
113
155
|
"name": "amount",
|
|
114
156
|
"type": "uint256"
|
|
115
157
|
},
|
|
116
|
-
{
|
|
117
|
-
"internalType": "address",
|
|
118
|
-
"name": "token",
|
|
119
|
-
"type": "address"
|
|
120
|
-
},
|
|
121
158
|
{
|
|
122
159
|
"internalType": "bytes",
|
|
123
160
|
"name": "",
|
|
124
161
|
"type": "bytes"
|
|
125
162
|
}
|
|
126
163
|
],
|
|
127
|
-
"name": "
|
|
164
|
+
"name": "receiveBalanceApproval",
|
|
128
165
|
"outputs": [],
|
|
129
166
|
"stateMutability": "nonpayable",
|
|
130
167
|
"type": "function"
|
|
131
168
|
},
|
|
132
169
|
{
|
|
133
170
|
"inputs": [
|
|
171
|
+
{
|
|
172
|
+
"internalType": "address[]",
|
|
173
|
+
"name": "depositors",
|
|
174
|
+
"type": "address[]"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"internalType": "uint256[]",
|
|
178
|
+
"name": "depositedAmounts",
|
|
179
|
+
"type": "uint256[]"
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"name": "receiveBalanceIncrease",
|
|
183
|
+
"outputs": [],
|
|
184
|
+
"stateMutability": "nonpayable",
|
|
185
|
+
"type": "function"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"inputs": [
|
|
189
|
+
{
|
|
190
|
+
"internalType": "contract IERC20",
|
|
191
|
+
"name": "token",
|
|
192
|
+
"type": "address"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"internalType": "address",
|
|
196
|
+
"name": "recipient",
|
|
197
|
+
"type": "address"
|
|
198
|
+
},
|
|
134
199
|
{
|
|
135
200
|
"internalType": "uint256",
|
|
136
201
|
"name": "amount",
|
|
137
202
|
"type": "uint256"
|
|
138
203
|
}
|
|
139
204
|
],
|
|
140
|
-
"name": "
|
|
205
|
+
"name": "recoverERC20",
|
|
206
|
+
"outputs": [],
|
|
207
|
+
"stateMutability": "nonpayable",
|
|
208
|
+
"type": "function"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"inputs": [
|
|
212
|
+
{
|
|
213
|
+
"internalType": "contract IERC721",
|
|
214
|
+
"name": "token",
|
|
215
|
+
"type": "address"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"internalType": "address",
|
|
219
|
+
"name": "recipient",
|
|
220
|
+
"type": "address"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"internalType": "uint256",
|
|
224
|
+
"name": "tokenId",
|
|
225
|
+
"type": "uint256"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"internalType": "bytes",
|
|
229
|
+
"name": "data",
|
|
230
|
+
"type": "bytes"
|
|
231
|
+
}
|
|
232
|
+
],
|
|
233
|
+
"name": "recoverERC721",
|
|
141
234
|
"outputs": [],
|
|
142
235
|
"stateMutability": "nonpayable",
|
|
143
236
|
"type": "function"
|
|
@@ -154,10 +247,36 @@
|
|
|
154
247
|
],
|
|
155
248
|
"stateMutability": "view",
|
|
156
249
|
"type": "function"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"inputs": [
|
|
253
|
+
{
|
|
254
|
+
"internalType": "address",
|
|
255
|
+
"name": "newGovernance",
|
|
256
|
+
"type": "address"
|
|
257
|
+
}
|
|
258
|
+
],
|
|
259
|
+
"name": "transferGovernance",
|
|
260
|
+
"outputs": [],
|
|
261
|
+
"stateMutability": "nonpayable",
|
|
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"
|
|
157
276
|
}
|
|
158
277
|
],
|
|
159
|
-
"bytecode": "
|
|
160
|
-
"deployedBytecode": "
|
|
278
|
+
"bytecode": "0x608060405234801561001057600080fd5b5060405161114638038061114683398101604081905261002f916101a8565b6001600160a01b03821661008a5760405162461bcd60e51b815260206004820181905260248201527f42616e6b2063616e206e6f7420626520746865207a65726f206164647265737360448201526064015b60405180910390fd5b6001600160a01b0381166100ef5760405162461bcd60e51b815260206004820152602660248201527f5442544320746f6b656e2063616e206e6f7420626520746865207a65726f206160448201526564647265737360d01b6064820152608401610081565b603280546001600160a01b038085166001600160a01b03199283161790925560338054928416929091169190911790556101283361012f565b50506101e2565b600080546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80910160405180910390a15050565b6001600160a01b03811681146101a557600080fd5b50565b600080604083850312156101bb57600080fd5b82516101c681610190565b60208401519092506101d781610190565b809150509250929050565b610f55806101f16000396000f3fe608060405234801561001057600080fd5b50600436106100c95760003560e01c806376cdb03b11610081578063d38bfff41161005b578063d38bfff414610184578063e5d3d71414610197578063fc4e51f6146101aa57600080fd5b806376cdb03b1461014b5780638f4ffcb11461015e578063a0712d681461017157600080fd5b8063475d0570116100b2578063475d0570146100f65780635aa6e6751461010957806364e779b11461013857600080fd5b80631171bda9146100ce578063461c6373146100e3575b600080fd5b6100e16100dc366004610b4f565b6101bd565b005b6100e16100f1366004610bdc565b6102a9565b6100e1610104366004610c5e565b6103bc565b60005461011c906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6100e1610146366004610d2b565b610535565b60325461011c906001600160a01b031681565b6100e161016c366004610d86565b610542565b6100e161017f366004610d2b565b610601565b6100e1610192366004610df9565b610755565b60335461011c906001600160a01b031681565b6100e16101b8366004610e1d565b610834565b6000546001600160a01b0316331461021c5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e63650000000060448201526064015b60405180910390fd5b6033546040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015284811660248301526044820184905290911690631171bda9906064015b600060405180830381600087803b15801561028c57600080fd5b505af11580156102a0573d6000803e3d6000fd5b50505050505050565b6032546001600160a01b031633146103035760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610213565b826103505760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f7273207370656369666965640000000000000000006044820152606401610213565b60005b838110156103b5576103a385858381811061037057610370610e73565b90506020020160208101906103859190610df9565b84848481811061039757610397610e73565b90506020020135610918565b806103ad81610e89565b915050610353565b5050505050565b6032546001600160a01b031633146104165760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610213565b6032546040516370a0823160e01b81526001600160a01b038581166004830152849216906370a082319060240160206040518083038186803b15801561045b57600080fd5b505afa15801561046f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104939190610eb2565b10156104ec5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610213565b6104f68383610918565b603254604051631f1b6d2760e21b81526001600160a01b0385811660048301523060248301526044820185905290911690637c6db49c90606401610272565b61053f33826109ad565b50565b6033546001600160a01b0384811691161461059f5760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f7420544254430000000000000000000000000000006044820152606401610213565b336001600160a01b038416146105f75760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f77656400000000000000006044820152606401610213565b6103b585856109ad565b6032546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b15801561064957600080fd5b505afa15801561065d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106819190610eb2565b10156106da5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610213565b6106e48183610918565b603254604051631f1b6d2760e21b81526001600160a01b0383811660048301523060248301526044820185905290911690637c6db49c906064015b600060405180830381600087803b15801561073957600080fd5b505af115801561074d573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146107af5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610213565b6001600160a01b03811661082b5760405162461bcd60e51b815260206004820152602260248201527f4e657720676f7665726e616e636520697320746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610213565b61053f81610ac1565b6000546001600160a01b0316331461088e5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610213565b6033546040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063fc4e51f6906108df9088908890889088908890600401610ecb565b600060405180830381600087803b1580156108f957600080fd5b505af115801561090d573d6000803e3d6000fd5b505050505050505050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe8260405161095391815260200190565b60405180910390a26033546040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906340c10f199060440161071f565b816001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b8826040516109e891815260200190565b60405180910390a26033546040517f79cc67900000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906379cc679090604401600060405180830381600087803b158015610a5757600080fd5b505af1158015610a6b573d6000803e3d6000fd5b50506032546040517f56a6d9ef0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301526024820186905290911692506356a6d9ef915060440161071f565b600080546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117909355604080519190921680825260208201939093527f5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80910160405180910390a15050565b6001600160a01b038116811461053f57600080fd5b600080600060608486031215610b6457600080fd5b8335610b6f81610b3a565b92506020840135610b7f81610b3a565b929592945050506040919091013590565b60008083601f840112610ba257600080fd5b50813567ffffffffffffffff811115610bba57600080fd5b6020830191508360208260051b8501011115610bd557600080fd5b9250929050565b60008060008060408587031215610bf257600080fd5b843567ffffffffffffffff80821115610c0a57600080fd5b610c1688838901610b90565b90965094506020870135915080821115610c2f57600080fd5b50610c3c87828801610b90565b95989497509550505050565b634e487b7160e01b600052604160045260246000fd5b600080600060608486031215610c7357600080fd5b8335610c7e81610b3a565b925060208401359150604084013567ffffffffffffffff80821115610ca257600080fd5b818601915086601f830112610cb657600080fd5b813581811115610cc857610cc8610c48565b604051601f8201601f19908116603f01168101908382118183101715610cf057610cf0610c48565b81604052828152896020848701011115610d0957600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600060208284031215610d3d57600080fd5b5035919050565b60008083601f840112610d5657600080fd5b50813567ffffffffffffffff811115610d6e57600080fd5b602083019150836020828501011115610bd557600080fd5b600080600080600060808688031215610d9e57600080fd5b8535610da981610b3a565b9450602086013593506040860135610dc081610b3a565b9250606086013567ffffffffffffffff811115610ddc57600080fd5b610de888828901610d44565b969995985093965092949392505050565b600060208284031215610e0b57600080fd5b8135610e1681610b3a565b9392505050565b600080600080600060808688031215610e3557600080fd5b8535610e4081610b3a565b94506020860135610e5081610b3a565b935060408601359250606086013567ffffffffffffffff811115610ddc57600080fd5b634e487b7160e01b600052603260045260246000fd5b6000600019821415610eab57634e487b7160e01b600052601160045260246000fd5b5060010190565b600060208284031215610ec457600080fd5b5051919050565b60006001600160a01b03808816835280871660208401525084604083015260806060830152826080830152828460a0840137600060a0848401015260a0601f19601f8501168301019050969550505050505056fea26469706673582212209e4975796006d1db5a7262daa7434fa2dbff97aad3fb5e7c0afab1d02413c3fa64736f6c63430008090033",
|
|
279
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100c95760003560e01c806376cdb03b11610081578063d38bfff41161005b578063d38bfff414610184578063e5d3d71414610197578063fc4e51f6146101aa57600080fd5b806376cdb03b1461014b5780638f4ffcb11461015e578063a0712d681461017157600080fd5b8063475d0570116100b2578063475d0570146100f65780635aa6e6751461010957806364e779b11461013857600080fd5b80631171bda9146100ce578063461c6373146100e3575b600080fd5b6100e16100dc366004610b4f565b6101bd565b005b6100e16100f1366004610bdc565b6102a9565b6100e1610104366004610c5e565b6103bc565b60005461011c906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6100e1610146366004610d2b565b610535565b60325461011c906001600160a01b031681565b6100e161016c366004610d86565b610542565b6100e161017f366004610d2b565b610601565b6100e1610192366004610df9565b610755565b60335461011c906001600160a01b031681565b6100e16101b8366004610e1d565b610834565b6000546001600160a01b0316331461021c5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e63650000000060448201526064015b60405180910390fd5b6033546040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015284811660248301526044820184905290911690631171bda9906064015b600060405180830381600087803b15801561028c57600080fd5b505af11580156102a0573d6000803e3d6000fd5b50505050505050565b6032546001600160a01b031633146103035760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610213565b826103505760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f7273207370656369666965640000000000000000006044820152606401610213565b60005b838110156103b5576103a385858381811061037057610370610e73565b90506020020160208101906103859190610df9565b84848481811061039757610397610e73565b90506020020135610918565b806103ad81610e89565b915050610353565b5050505050565b6032546001600160a01b031633146104165760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610213565b6032546040516370a0823160e01b81526001600160a01b038581166004830152849216906370a082319060240160206040518083038186803b15801561045b57600080fd5b505afa15801561046f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104939190610eb2565b10156104ec5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610213565b6104f68383610918565b603254604051631f1b6d2760e21b81526001600160a01b0385811660048301523060248301526044820185905290911690637c6db49c90606401610272565b61053f33826109ad565b50565b6033546001600160a01b0384811691161461059f5760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f7420544254430000000000000000000000000000006044820152606401610213565b336001600160a01b038416146105f75760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f77656400000000000000006044820152606401610213565b6103b585856109ad565b6032546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b15801561064957600080fd5b505afa15801561065d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106819190610eb2565b10156106da5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610213565b6106e48183610918565b603254604051631f1b6d2760e21b81526001600160a01b0383811660048301523060248301526044820185905290911690637c6db49c906064015b600060405180830381600087803b15801561073957600080fd5b505af115801561074d573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146107af5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610213565b6001600160a01b03811661082b5760405162461bcd60e51b815260206004820152602260248201527f4e657720676f7665726e616e636520697320746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610213565b61053f81610ac1565b6000546001600160a01b0316331461088e5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610213565b6033546040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063fc4e51f6906108df9088908890889088908890600401610ecb565b600060405180830381600087803b1580156108f957600080fd5b505af115801561090d573d6000803e3d6000fd5b505050505050505050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe8260405161095391815260200190565b60405180910390a26033546040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906340c10f199060440161071f565b816001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b8826040516109e891815260200190565b60405180910390a26033546040517f79cc67900000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906379cc679090604401600060405180830381600087803b158015610a5757600080fd5b505af1158015610a6b573d6000803e3d6000fd5b50506032546040517f56a6d9ef0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301526024820186905290911692506356a6d9ef915060440161071f565b600080546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117909355604080519190921680825260208201939093527f5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80910160405180910390a15050565b6001600160a01b038116811461053f57600080fd5b600080600060608486031215610b6457600080fd5b8335610b6f81610b3a565b92506020840135610b7f81610b3a565b929592945050506040919091013590565b60008083601f840112610ba257600080fd5b50813567ffffffffffffffff811115610bba57600080fd5b6020830191508360208260051b8501011115610bd557600080fd5b9250929050565b60008060008060408587031215610bf257600080fd5b843567ffffffffffffffff80821115610c0a57600080fd5b610c1688838901610b90565b90965094506020870135915080821115610c2f57600080fd5b50610c3c87828801610b90565b95989497509550505050565b634e487b7160e01b600052604160045260246000fd5b600080600060608486031215610c7357600080fd5b8335610c7e81610b3a565b925060208401359150604084013567ffffffffffffffff80821115610ca257600080fd5b818601915086601f830112610cb657600080fd5b813581811115610cc857610cc8610c48565b604051601f8201601f19908116603f01168101908382118183101715610cf057610cf0610c48565b81604052828152896020848701011115610d0957600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b600060208284031215610d3d57600080fd5b5035919050565b60008083601f840112610d5657600080fd5b50813567ffffffffffffffff811115610d6e57600080fd5b602083019150836020828501011115610bd557600080fd5b600080600080600060808688031215610d9e57600080fd5b8535610da981610b3a565b9450602086013593506040860135610dc081610b3a565b9250606086013567ffffffffffffffff811115610ddc57600080fd5b610de888828901610d44565b969995985093965092949392505050565b600060208284031215610e0b57600080fd5b8135610e1681610b3a565b9392505050565b600080600080600060808688031215610e3557600080fd5b8535610e4081610b3a565b94506020860135610e5081610b3a565b935060408601359250606086013567ffffffffffffffff811115610ddc57600080fd5b634e487b7160e01b600052603260045260246000fd5b6000600019821415610eab57634e487b7160e01b600052601160045260246000fd5b5060010190565b600060208284031215610ec457600080fd5b5051919050565b60006001600160a01b03808816835280871660208401525084604083015260806060830152826080830152828460a0840137600060a0848401015260a0601f19601f8501168301019050969550505050505056fea26469706673582212209e4975796006d1db5a7262daa7434fa2dbff97aad3fb5e7c0afab1d02413c3fa64736f6c63430008090033",
|
|
161
280
|
"linkReferences": {},
|
|
162
281
|
"deployedLinkReferences": {}
|
|
163
282
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
|
|
3
|
-
pragma solidity 0.8.
|
|
3
|
+
pragma solidity ^0.8.9;
|
|
4
4
|
|
|
5
5
|
library GovernanceUtils {
|
|
6
6
|
/// @notice Reverts if the governance delay has not passed since
|
|
@@ -24,9 +24,9 @@ library GovernanceUtils {
|
|
|
24
24
|
/// @notice Gets the time remaining until the governable parameter update
|
|
25
25
|
/// can be committed.
|
|
26
26
|
/// @param changeInitiatedTimestamp Timestamp indicating the beginning of
|
|
27
|
-
/// the change
|
|
28
|
-
/// @param delay Governance delay
|
|
29
|
-
/// @return Remaining time in seconds
|
|
27
|
+
/// the change.
|
|
28
|
+
/// @param delay Governance delay.
|
|
29
|
+
/// @return Remaining time in seconds.
|
|
30
30
|
function getRemainingGovernanceDelay(
|
|
31
31
|
uint256 changeInitiatedTimestamp,
|
|
32
32
|
uint256 delay
|
package/contracts/bank/Bank.sol
CHANGED
|
@@ -13,24 +13,25 @@
|
|
|
13
13
|
// ▐████▌ ▐████▌
|
|
14
14
|
// ▐████▌ ▐████▌
|
|
15
15
|
|
|
16
|
-
pragma solidity 0.8.
|
|
16
|
+
pragma solidity ^0.8.9;
|
|
17
17
|
|
|
18
18
|
import "@openzeppelin/contracts/access/Ownable.sol";
|
|
19
19
|
|
|
20
|
+
import "./IReceiveBalanceApproval.sol";
|
|
20
21
|
import "../vault/IVault.sol";
|
|
21
22
|
|
|
22
23
|
/// @title Bitcoin Bank
|
|
23
24
|
/// @notice Bank is a central component tracking Bitcoin balances. Balances can
|
|
24
|
-
/// be transferred between
|
|
25
|
-
/// balances to be spent by others. Balances in the Bank
|
|
26
|
-
/// depositors who
|
|
27
|
-
/// Bridge can increase balances.
|
|
25
|
+
/// be transferred between balance owners, and balance owners can
|
|
26
|
+
/// approve their balances to be spent by others. Balances in the Bank
|
|
27
|
+
/// are updated for depositors who deposited their Bitcoin into the
|
|
28
|
+
/// Bridge and only the Bridge can increase balances.
|
|
28
29
|
/// @dev Bank is a governable contract and the Governance can upgrade the Bridge
|
|
29
30
|
/// address.
|
|
30
31
|
contract Bank is Ownable {
|
|
31
32
|
address public bridge;
|
|
32
33
|
|
|
33
|
-
/// @notice The balance of
|
|
34
|
+
/// @notice The balance of the given account in the Bank. Zero by default.
|
|
34
35
|
mapping(address => uint256) public balanceOf;
|
|
35
36
|
|
|
36
37
|
/// @notice The remaining amount of balance a spender will be
|
|
@@ -38,16 +39,17 @@ contract Bank is Ownable {
|
|
|
38
39
|
/// `transferBalanceFrom`. Zero by default.
|
|
39
40
|
mapping(address => mapping(address => uint256)) public allowance;
|
|
40
41
|
|
|
41
|
-
/// @notice Returns the current nonce for EIP2612 permission for the
|
|
42
|
-
/// provided balance owner
|
|
43
|
-
/// construct EIP2612 signature provided to `permit`
|
|
42
|
+
/// @notice Returns the current nonce for an EIP2612 permission for the
|
|
43
|
+
/// provided balance owner to protect against replay attacks. Used
|
|
44
|
+
/// to construct an EIP2612 signature provided to the `permit`
|
|
45
|
+
/// function.
|
|
44
46
|
mapping(address => uint256) public nonce;
|
|
45
47
|
|
|
46
48
|
uint256 public immutable cachedChainId;
|
|
47
49
|
bytes32 public immutable cachedDomainSeparator;
|
|
48
50
|
|
|
49
|
-
/// @notice Returns EIP2612 Permit message hash. Used to construct
|
|
50
|
-
/// signature provided to `permit` function.
|
|
51
|
+
/// @notice Returns an EIP2612 Permit message hash. Used to construct
|
|
52
|
+
/// an EIP2612 signature provided to the `permit` function.
|
|
51
53
|
bytes32 public constant PERMIT_TYPEHASH =
|
|
52
54
|
keccak256(
|
|
53
55
|
"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
|
|
@@ -86,6 +88,9 @@ contract Bank is Ownable {
|
|
|
86
88
|
/// check the status of the Bridge. The Governance implementation needs
|
|
87
89
|
/// to ensure all requirements for the upgrade are satisfied before
|
|
88
90
|
/// executing this function.
|
|
91
|
+
/// Requirements:
|
|
92
|
+
/// - The new Bridge address must not be zero.
|
|
93
|
+
/// @param _bridge The new Bridge address.
|
|
89
94
|
function updateBridge(address _bridge) external onlyOwner {
|
|
90
95
|
require(_bridge != address(0), "Bridge address must not be 0x0");
|
|
91
96
|
bridge = _bridge;
|
|
@@ -97,25 +102,59 @@ contract Bank is Ownable {
|
|
|
97
102
|
/// @dev Requirements:
|
|
98
103
|
/// - `recipient` cannot be the zero address,
|
|
99
104
|
/// - the caller must have a balance of at least `amount`.
|
|
105
|
+
/// @param recipient The recipient of the balance.
|
|
106
|
+
/// @param amount The amount of the balance transferred.
|
|
100
107
|
function transferBalance(address recipient, uint256 amount) external {
|
|
101
108
|
_transferBalance(msg.sender, recipient, amount);
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
/// @notice Sets `amount` as the allowance of `spender` over the caller's
|
|
105
112
|
/// balance.
|
|
106
|
-
/// @dev If the `amount` is set to `type(uint256).max
|
|
113
|
+
/// @dev If the `amount` is set to `type(uint256).max`,
|
|
107
114
|
/// `transferBalanceFrom` will not reduce an allowance.
|
|
108
115
|
/// Beware that changing an allowance with this function brings the
|
|
109
116
|
/// risk that someone may use both the old and the new allowance by
|
|
110
117
|
/// unfortunate transaction ordering. Please use
|
|
111
118
|
/// `increaseBalanceAllowance` and `decreaseBalanceAllowance` to
|
|
112
119
|
/// eliminate the risk.
|
|
120
|
+
/// @param spender The address that will be allowed to spend the balance.
|
|
121
|
+
/// @param amount The amount the spender is allowed to spend.
|
|
113
122
|
function approveBalance(address spender, uint256 amount) external {
|
|
114
123
|
_approveBalance(msg.sender, spender, amount);
|
|
115
124
|
}
|
|
116
125
|
|
|
117
|
-
/// @notice
|
|
118
|
-
///
|
|
126
|
+
/// @notice Sets the `amount` as an allowance of a smart contract `spender`
|
|
127
|
+
/// over the caller's balance and calls the `spender` via
|
|
128
|
+
/// `receiveBalanceApproval`.
|
|
129
|
+
/// @dev If the `amount` is set to `type(uint256).max`, the potential
|
|
130
|
+
/// `transferBalanceFrom` executed in `receiveBalanceApproval` of
|
|
131
|
+
/// `spender` will not reduce an allowance. Beware that changing an
|
|
132
|
+
/// allowance with this function brings the risk that `spender` may use
|
|
133
|
+
/// both the old and the new allowance by unfortunate transaction
|
|
134
|
+
/// ordering. Please use `increaseBalanceAllowance` and
|
|
135
|
+
/// `decreaseBalanceAllowance` to eliminate the risk.
|
|
136
|
+
/// @param spender The smart contract that will be allowed to spend the
|
|
137
|
+
/// balance.
|
|
138
|
+
/// @param amount The amount the spender contract is allowed to spend.
|
|
139
|
+
/// @param extraData Extra data passed to the `spender` contract via
|
|
140
|
+
/// `receiveBalanceApproval` call.
|
|
141
|
+
function approveBalanceAndCall(
|
|
142
|
+
address spender,
|
|
143
|
+
uint256 amount,
|
|
144
|
+
bytes memory extraData
|
|
145
|
+
) external {
|
|
146
|
+
_approveBalance(msg.sender, spender, amount);
|
|
147
|
+
IReceiveBalanceApproval(spender).receiveBalanceApproval(
|
|
148
|
+
msg.sender,
|
|
149
|
+
amount,
|
|
150
|
+
extraData
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/// @notice Atomically increases the caller's balance allowance granted to
|
|
155
|
+
/// `spender` by the given `addedValue`.
|
|
156
|
+
/// @param spender The spender address for which the allowance is increased.
|
|
157
|
+
/// @param addedValue The amount by which the allowance is increased.
|
|
119
158
|
function increaseBalanceAllowance(address spender, uint256 addedValue)
|
|
120
159
|
external
|
|
121
160
|
{
|
|
@@ -126,8 +165,14 @@ contract Bank is Ownable {
|
|
|
126
165
|
);
|
|
127
166
|
}
|
|
128
167
|
|
|
129
|
-
/// @notice Atomically decreases the balance allowance granted to
|
|
130
|
-
///
|
|
168
|
+
/// @notice Atomically decreases the caller's balance allowance granted to
|
|
169
|
+
/// `spender` by the given `subtractedValue`.
|
|
170
|
+
/// @dev Requirements:
|
|
171
|
+
/// - `spender` must not be the zero address,
|
|
172
|
+
/// - the current allowance for `spender` must not be lower than
|
|
173
|
+
/// the `subtractedValue`.
|
|
174
|
+
/// @param spender The spender address for which the allowance is decreased.
|
|
175
|
+
/// @param subtractedValue The amount by which the allowance is decreased.
|
|
131
176
|
function decreaseBalanceAllowance(address spender, uint256 subtractedValue)
|
|
132
177
|
external
|
|
133
178
|
{
|
|
@@ -151,8 +196,11 @@ contract Bank is Ownable {
|
|
|
151
196
|
/// @dev Requirements:
|
|
152
197
|
/// - `recipient` cannot be the zero address,
|
|
153
198
|
/// - `spender` must have a balance of at least `amount`,
|
|
154
|
-
/// - the caller must have allowance for `spender`'s balance of at
|
|
199
|
+
/// - the caller must have an allowance for `spender`'s balance of at
|
|
155
200
|
/// least `amount`.
|
|
201
|
+
/// @param spender The address from which the balance is transferred.
|
|
202
|
+
/// @param recipient The address to which the balance is transferred.
|
|
203
|
+
/// @param amount The amount of balance that is transferred.
|
|
156
204
|
function transferBalanceFrom(
|
|
157
205
|
address spender,
|
|
158
206
|
address recipient,
|
|
@@ -171,12 +219,13 @@ contract Bank is Ownable {
|
|
|
171
219
|
_transferBalance(spender, recipient, amount);
|
|
172
220
|
}
|
|
173
221
|
|
|
174
|
-
/// @notice EIP2612 approval made with secp256k1 signature.
|
|
175
|
-
///
|
|
176
|
-
/// conforming EIP712 standard, rather than an on-chain
|
|
177
|
-
/// from their address. Anyone can submit this signature
|
|
178
|
-
/// user's behalf by calling the permit function, paying
|
|
179
|
-
/// and possibly performing other actions in the same
|
|
222
|
+
/// @notice An EIP2612 approval made with secp256k1 signature. Users can
|
|
223
|
+
/// authorize a transfer of their balance with a signature
|
|
224
|
+
/// conforming to the EIP712 standard, rather than an on-chain
|
|
225
|
+
/// transaction from their address. Anyone can submit this signature
|
|
226
|
+
/// on the user's behalf by calling the `permit` function, paying
|
|
227
|
+
/// gas fees, and possibly performing other actions in the same
|
|
228
|
+
/// transaction.
|
|
180
229
|
/// @dev The deadline argument can be set to `type(uint256).max to create
|
|
181
230
|
/// permits that effectively never expire. If the `amount` is set
|
|
182
231
|
/// to `type(uint256).max` then `transferBalanceFrom` will not
|
|
@@ -185,6 +234,13 @@ contract Bank is Ownable {
|
|
|
185
234
|
/// new allowance by unfortunate transaction ordering. Please use
|
|
186
235
|
/// `increaseBalanceAllowance` and `decreaseBalanceAllowance` to
|
|
187
236
|
/// eliminate the risk.
|
|
237
|
+
/// @param owner The balance owner who signed the permission.
|
|
238
|
+
/// @param spender The address that will be allowed to spend the balance.
|
|
239
|
+
/// @param amount The amount the spender is allowed to spend.
|
|
240
|
+
/// @param deadline The UNIX time until which the permit is valid.
|
|
241
|
+
/// @param v V part of the permit signature.
|
|
242
|
+
/// @param r R part of the permit signature.
|
|
243
|
+
/// @param s S part of the permit signature.
|
|
188
244
|
function permit(
|
|
189
245
|
address owner,
|
|
190
246
|
address spender,
|
|
@@ -207,23 +263,22 @@ contract Bank is Ownable {
|
|
|
207
263
|
);
|
|
208
264
|
require(v == 27 || v == 28, "Invalid signature 'v' value");
|
|
209
265
|
|
|
210
|
-
bytes32 digest =
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
deadline
|
|
223
|
-
)
|
|
266
|
+
bytes32 digest = keccak256(
|
|
267
|
+
abi.encodePacked(
|
|
268
|
+
"\x19\x01",
|
|
269
|
+
DOMAIN_SEPARATOR(),
|
|
270
|
+
keccak256(
|
|
271
|
+
abi.encode(
|
|
272
|
+
PERMIT_TYPEHASH,
|
|
273
|
+
owner,
|
|
274
|
+
spender,
|
|
275
|
+
amount,
|
|
276
|
+
nonce[owner]++,
|
|
277
|
+
deadline
|
|
224
278
|
)
|
|
225
279
|
)
|
|
226
|
-
)
|
|
280
|
+
)
|
|
281
|
+
);
|
|
227
282
|
address recoveredAddress = ecrecover(digest, v, r, s);
|
|
228
283
|
require(
|
|
229
284
|
recoveredAddress != address(0) && recoveredAddress == owner,
|
|
@@ -235,7 +290,10 @@ contract Bank is Ownable {
|
|
|
235
290
|
/// @notice Increases balances of the provided `recipients` by the provided
|
|
236
291
|
/// `amounts`. Can only be called by the Bridge.
|
|
237
292
|
/// @dev Requirements:
|
|
238
|
-
/// - length of `recipients` and `amounts` must be the same
|
|
293
|
+
/// - length of `recipients` and `amounts` must be the same,
|
|
294
|
+
/// - none of `recipients` addresses must point to the Bank.
|
|
295
|
+
/// @param recipients Balance increase recipients.
|
|
296
|
+
/// @param amounts Amounts by which balances are increased.
|
|
239
297
|
function increaseBalances(
|
|
240
298
|
address[] calldata recipients,
|
|
241
299
|
uint256[] calldata amounts
|
|
@@ -251,6 +309,10 @@ contract Bank is Ownable {
|
|
|
251
309
|
|
|
252
310
|
/// @notice Increases balance of the provided `recipient` by the provided
|
|
253
311
|
/// `amount`. Can only be called by the Bridge.
|
|
312
|
+
/// @dev Requirements:
|
|
313
|
+
/// - `recipient` address must not point to the Bank.
|
|
314
|
+
/// @param recipient Balance increase recipient.
|
|
315
|
+
/// @param amount Amount by which the balance is increased.
|
|
254
316
|
function increaseBalance(address recipient, uint256 amount)
|
|
255
317
|
external
|
|
256
318
|
onlyBridge
|
|
@@ -259,39 +321,37 @@ contract Bank is Ownable {
|
|
|
259
321
|
}
|
|
260
322
|
|
|
261
323
|
/// @notice Increases the given smart contract `vault`'s balance and
|
|
262
|
-
/// notifies the `vault` contract
|
|
263
|
-
/// the deposits routed by depositors to that `vault` have been
|
|
264
|
-
/// swept by the Bridge. This way, the depositor does not have to
|
|
265
|
-
/// issue a separate transaction to the `vault` contract.
|
|
324
|
+
/// notifies the `vault` contract about it.
|
|
266
325
|
/// Can be called only by the Bridge.
|
|
267
326
|
/// @dev Requirements:
|
|
268
327
|
/// - `vault` must implement `IVault` interface,
|
|
269
|
-
/// - length of `
|
|
270
|
-
/// @param vault Address of `IVault` recipient contract
|
|
271
|
-
/// @param
|
|
272
|
-
/// @param
|
|
273
|
-
/// swept. The `vault`'s balance in the Bank will be increased by the
|
|
274
|
-
/// sum of all elements in this array.
|
|
328
|
+
/// - length of `recipients` and `amounts` must be the same.
|
|
329
|
+
/// @param vault Address of `IVault` recipient contract.
|
|
330
|
+
/// @param recipients Balance increase recipients.
|
|
331
|
+
/// @param amounts Amounts by which balances are increased.
|
|
275
332
|
function increaseBalanceAndCall(
|
|
276
333
|
address vault,
|
|
277
|
-
address[] calldata
|
|
278
|
-
uint256[] calldata
|
|
334
|
+
address[] calldata recipients,
|
|
335
|
+
uint256[] calldata amounts
|
|
279
336
|
) external onlyBridge {
|
|
280
337
|
require(
|
|
281
|
-
|
|
338
|
+
recipients.length == amounts.length,
|
|
282
339
|
"Arrays must have the same length"
|
|
283
340
|
);
|
|
284
341
|
uint256 totalAmount = 0;
|
|
285
|
-
for (uint256 i = 0; i <
|
|
286
|
-
totalAmount +=
|
|
342
|
+
for (uint256 i = 0; i < amounts.length; i++) {
|
|
343
|
+
totalAmount += amounts[i];
|
|
287
344
|
}
|
|
288
345
|
_increaseBalance(vault, totalAmount);
|
|
289
|
-
IVault(vault).
|
|
346
|
+
IVault(vault).receiveBalanceIncrease(recipients, amounts);
|
|
290
347
|
}
|
|
291
348
|
|
|
292
349
|
/// @notice Decreases caller's balance by the provided `amount`. There is no
|
|
293
350
|
/// way to restore the balance so do not call this function unless
|
|
294
351
|
/// you really know what you are doing!
|
|
352
|
+
/// @dev Requirements:
|
|
353
|
+
/// - The caller must have a balance of at least `amount`.
|
|
354
|
+
/// @param amount The amount by which the balance is decreased.
|
|
295
355
|
function decreaseBalance(uint256 amount) external {
|
|
296
356
|
balanceOf[msg.sender] -= amount;
|
|
297
357
|
emit BalanceDecreased(msg.sender, amount);
|
|
@@ -299,7 +359,7 @@ contract Bank is Ownable {
|
|
|
299
359
|
|
|
300
360
|
/// @notice Returns hash of EIP712 Domain struct with `TBTC Bank` as
|
|
301
361
|
/// a signing domain and Bank contract as a verifying contract.
|
|
302
|
-
/// Used to construct EIP2612 signature provided to `permit`
|
|
362
|
+
/// Used to construct an EIP2612 signature provided to the `permit`
|
|
303
363
|
/// function.
|
|
304
364
|
/* solhint-disable-next-line func-name-mixedcase */
|
|
305
365
|
function DOMAIN_SEPARATOR() public view returns (bytes32) {
|
|
@@ -342,7 +402,9 @@ contract Bank is Ownable {
|
|
|
342
402
|
|
|
343
403
|
uint256 spenderBalance = balanceOf[spender];
|
|
344
404
|
require(spenderBalance >= amount, "Transfer amount exceeds balance");
|
|
345
|
-
unchecked {
|
|
405
|
+
unchecked {
|
|
406
|
+
balanceOf[spender] = spenderBalance - amount;
|
|
407
|
+
}
|
|
346
408
|
balanceOf[recipient] += amount;
|
|
347
409
|
emit BalanceTransferred(spender, recipient, amount);
|
|
348
410
|
}
|