@keep-network/tbtc-v2 0.1.1-dev.8 → 0.1.1-dev.80
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 +757 -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/4f6d4f5cd1e3d835e20ed55926a445cd.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 +25 -2
- 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 +126 -7
- package/contracts/GovernanceUtils.sol +4 -4
- package/contracts/bank/Bank.sol +45 -20
- 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 +58 -8
- 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": [
|
|
@@ -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
|
{
|
|
@@ -83,6 +115,57 @@
|
|
|
83
115
|
"stateMutability": "nonpayable",
|
|
84
116
|
"type": "function"
|
|
85
117
|
},
|
|
118
|
+
{
|
|
119
|
+
"inputs": [
|
|
120
|
+
{
|
|
121
|
+
"internalType": "address",
|
|
122
|
+
"name": "from",
|
|
123
|
+
"type": "address"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
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"
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"name": "receiveApproval",
|
|
142
|
+
"outputs": [],
|
|
143
|
+
"stateMutability": "nonpayable",
|
|
144
|
+
"type": "function"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"inputs": [
|
|
148
|
+
{
|
|
149
|
+
"internalType": "address",
|
|
150
|
+
"name": "owner",
|
|
151
|
+
"type": "address"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"internalType": "uint256",
|
|
155
|
+
"name": "amount",
|
|
156
|
+
"type": "uint256"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"internalType": "bytes",
|
|
160
|
+
"name": "",
|
|
161
|
+
"type": "bytes"
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
"name": "receiveBalanceApproval",
|
|
165
|
+
"outputs": [],
|
|
166
|
+
"stateMutability": "nonpayable",
|
|
167
|
+
"type": "function"
|
|
168
|
+
},
|
|
86
169
|
{
|
|
87
170
|
"inputs": [
|
|
88
171
|
{
|
|
@@ -96,35 +179,58 @@
|
|
|
96
179
|
"type": "uint256[]"
|
|
97
180
|
}
|
|
98
181
|
],
|
|
99
|
-
"name": "
|
|
182
|
+
"name": "receiveBalanceIncrease",
|
|
100
183
|
"outputs": [],
|
|
101
184
|
"stateMutability": "nonpayable",
|
|
102
185
|
"type": "function"
|
|
103
186
|
},
|
|
104
187
|
{
|
|
105
188
|
"inputs": [
|
|
189
|
+
{
|
|
190
|
+
"internalType": "contract IERC20",
|
|
191
|
+
"name": "token",
|
|
192
|
+
"type": "address"
|
|
193
|
+
},
|
|
106
194
|
{
|
|
107
195
|
"internalType": "address",
|
|
108
|
-
"name": "
|
|
196
|
+
"name": "recipient",
|
|
109
197
|
"type": "address"
|
|
110
198
|
},
|
|
111
199
|
{
|
|
112
200
|
"internalType": "uint256",
|
|
113
201
|
"name": "amount",
|
|
114
202
|
"type": "uint256"
|
|
203
|
+
}
|
|
204
|
+
],
|
|
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"
|
|
115
216
|
},
|
|
116
217
|
{
|
|
117
218
|
"internalType": "address",
|
|
118
|
-
"name": "
|
|
219
|
+
"name": "recipient",
|
|
119
220
|
"type": "address"
|
|
120
221
|
},
|
|
222
|
+
{
|
|
223
|
+
"internalType": "uint256",
|
|
224
|
+
"name": "tokenId",
|
|
225
|
+
"type": "uint256"
|
|
226
|
+
},
|
|
121
227
|
{
|
|
122
228
|
"internalType": "bytes",
|
|
123
|
-
"name": "",
|
|
229
|
+
"name": "data",
|
|
124
230
|
"type": "bytes"
|
|
125
231
|
}
|
|
126
232
|
],
|
|
127
|
-
"name": "
|
|
233
|
+
"name": "recoverERC721",
|
|
128
234
|
"outputs": [],
|
|
129
235
|
"stateMutability": "nonpayable",
|
|
130
236
|
"type": "function"
|
|
@@ -154,10 +260,23 @@
|
|
|
154
260
|
],
|
|
155
261
|
"stateMutability": "view",
|
|
156
262
|
"type": "function"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"inputs": [
|
|
266
|
+
{
|
|
267
|
+
"internalType": "address",
|
|
268
|
+
"name": "newGovernance",
|
|
269
|
+
"type": "address"
|
|
270
|
+
}
|
|
271
|
+
],
|
|
272
|
+
"name": "transferGovernance",
|
|
273
|
+
"outputs": [],
|
|
274
|
+
"stateMutability": "nonpayable",
|
|
275
|
+
"type": "function"
|
|
157
276
|
}
|
|
158
277
|
],
|
|
159
|
-
"bytecode": "
|
|
160
|
-
"deployedBytecode": "
|
|
278
|
+
"bytecode": "0x608060405234801561001057600080fd5b5060405161114638038061114683398101604081905261002f916101a8565b6001600160a01b03821661008a5760405162461bcd60e51b815260206004820181905260248201527f42616e6b2063616e206e6f7420626520746865207a65726f206164647265737360448201526064015b60405180910390fd5b6001600160a01b0381166100ef5760405162461bcd60e51b815260206004820152602660248201527f5442544320746f6b656e2063616e206e6f7420626520746865207a65726f206160448201526564647265737360d01b6064820152608401610081565b603280546001600160a01b038085166001600160a01b03199283161790925560338054928416929091169190911790556101283361012f565b50506101e2565b600080546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80910160405180910390a15050565b6001600160a01b03811681146101a557600080fd5b50565b600080604083850312156101bb57600080fd5b82516101c681610190565b60208401519092506101d781610190565b809150509250929050565b610f55806101f16000396000f3fe608060405234801561001057600080fd5b50600436106100c95760003560e01c80638f4ffcb111610081578063db006a751161005b578063db006a7514610184578063e5d3d71414610197578063fc4e51f6146101aa57600080fd5b80638f4ffcb11461014b578063a0712d681461015e578063d38bfff41461017157600080fd5b8063475d0570116100b2578063475d0570146100f65780635aa6e6751461010957806376cdb03b1461013857600080fd5b80631171bda9146100ce578063461c6373146100e3575b600080fd5b6100e16100dc366004610b4f565b6101bd565b005b6100e16100f1366004610bdc565b6102a9565b6100e1610104366004610c5e565b6103bc565b60005461011c906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b60325461011c906001600160a01b031681565b6100e1610159366004610d6d565b610535565b6100e161016c366004610de0565b6105f4565b6100e161017f366004610df9565b610748565b6100e1610192366004610de0565b61082a565b60335461011c906001600160a01b031681565b6100e16101b8366004610e1d565b610834565b6000546001600160a01b0316331461021c5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e63650000000060448201526064015b60405180910390fd5b6033546040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015284811660248301526044820184905290911690631171bda9906064015b600060405180830381600087803b15801561028c57600080fd5b505af11580156102a0573d6000803e3d6000fd5b50505050505050565b6032546001600160a01b031633146103035760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610213565b826103505760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f7273207370656369666965640000000000000000006044820152606401610213565b60005b838110156103b5576103a385858381811061037057610370610e73565b90506020020160208101906103859190610df9565b84848481811061039757610397610e73565b90506020020135610918565b806103ad81610e89565b915050610353565b5050505050565b6032546001600160a01b031633146104165760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610213565b6032546040516370a0823160e01b81526001600160a01b038581166004830152849216906370a082319060240160206040518083038186803b15801561045b57600080fd5b505afa15801561046f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104939190610eb2565b10156104ec5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610213565b6104f68383610918565b603254604051631f1b6d2760e21b81526001600160a01b0385811660048301523060248301526044820185905290911690637c6db49c90606401610272565b6033546001600160a01b038481169116146105925760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f7420544254430000000000000000000000000000006044820152606401610213565b336001600160a01b038416146105ea5760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f77656400000000000000006044820152606401610213565b6103b585856109ad565b6032546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b15801561063c57600080fd5b505afa158015610650573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106749190610eb2565b10156106cd5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610213565b6106d78183610918565b603254604051631f1b6d2760e21b81526001600160a01b0383811660048301523060248301526044820185905290911690637c6db49c906064015b600060405180830381600087803b15801561072c57600080fd5b505af1158015610740573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146107a25760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610213565b6001600160a01b03811661081e5760405162461bcd60e51b815260206004820152602260248201527f4e657720676f7665726e616e636520697320746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610213565b61082781610ac1565b50565b61082733826109ad565b6000546001600160a01b0316331461088e5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610213565b6033546040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063fc4e51f6906108df9088908890889088908890600401610ecb565b600060405180830381600087803b1580156108f957600080fd5b505af115801561090d573d6000803e3d6000fd5b505050505050505050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe8260405161095391815260200190565b60405180910390a26033546040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906340c10f1990604401610712565b816001600160a01b03167f4896181ff8f4543cc00db9fe9b6fb7e6f032b7eb772c72ab1ec1b4d2e03b9369826040516109e891815260200190565b60405180910390a26033546040517f79cc67900000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906379cc679090604401600060405180830381600087803b158015610a5757600080fd5b505af1158015610a6b573d6000803e3d6000fd5b50506032546040517f56a6d9ef0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301526024820186905290911692506356a6d9ef9150604401610712565b600080546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117909355604080519190921680825260208201939093527f5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80910160405180910390a15050565b6001600160a01b038116811461082757600080fd5b600080600060608486031215610b6457600080fd5b8335610b6f81610b3a565b92506020840135610b7f81610b3a565b929592945050506040919091013590565b60008083601f840112610ba257600080fd5b50813567ffffffffffffffff811115610bba57600080fd5b6020830191508360208260051b8501011115610bd557600080fd5b9250929050565b60008060008060408587031215610bf257600080fd5b843567ffffffffffffffff80821115610c0a57600080fd5b610c1688838901610b90565b90965094506020870135915080821115610c2f57600080fd5b50610c3c87828801610b90565b95989497509550505050565b634e487b7160e01b600052604160045260246000fd5b600080600060608486031215610c7357600080fd5b8335610c7e81610b3a565b925060208401359150604084013567ffffffffffffffff80821115610ca257600080fd5b818601915086601f830112610cb657600080fd5b813581811115610cc857610cc8610c48565b604051601f8201601f19908116603f01168101908382118183101715610cf057610cf0610c48565b81604052828152896020848701011115610d0957600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60008083601f840112610d3d57600080fd5b50813567ffffffffffffffff811115610d5557600080fd5b602083019150836020828501011115610bd557600080fd5b600080600080600060808688031215610d8557600080fd5b8535610d9081610b3a565b9450602086013593506040860135610da781610b3a565b9250606086013567ffffffffffffffff811115610dc357600080fd5b610dcf88828901610d2b565b969995985093965092949392505050565b600060208284031215610df257600080fd5b5035919050565b600060208284031215610e0b57600080fd5b8135610e1681610b3a565b9392505050565b600080600080600060808688031215610e3557600080fd5b8535610e4081610b3a565b94506020860135610e5081610b3a565b935060408601359250606086013567ffffffffffffffff811115610dc357600080fd5b634e487b7160e01b600052603260045260246000fd5b6000600019821415610eab57634e487b7160e01b600052601160045260246000fd5b5060010190565b600060208284031215610ec457600080fd5b5051919050565b60006001600160a01b03808816835280871660208401525084604083015260806060830152826080830152828460a0840137600060a0848401015260a0601f19601f8501168301019050969550505050505056fea2646970667358221220d8d9594142b5b1b46bfc77405493179b74258f5dea06c4620d5135cc64b2be5a64736f6c63430008090033",
|
|
279
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100c95760003560e01c80638f4ffcb111610081578063db006a751161005b578063db006a7514610184578063e5d3d71414610197578063fc4e51f6146101aa57600080fd5b80638f4ffcb11461014b578063a0712d681461015e578063d38bfff41461017157600080fd5b8063475d0570116100b2578063475d0570146100f65780635aa6e6751461010957806376cdb03b1461013857600080fd5b80631171bda9146100ce578063461c6373146100e3575b600080fd5b6100e16100dc366004610b4f565b6101bd565b005b6100e16100f1366004610bdc565b6102a9565b6100e1610104366004610c5e565b6103bc565b60005461011c906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b60325461011c906001600160a01b031681565b6100e1610159366004610d6d565b610535565b6100e161016c366004610de0565b6105f4565b6100e161017f366004610df9565b610748565b6100e1610192366004610de0565b61082a565b60335461011c906001600160a01b031681565b6100e16101b8366004610e1d565b610834565b6000546001600160a01b0316331461021c5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e63650000000060448201526064015b60405180910390fd5b6033546040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015284811660248301526044820184905290911690631171bda9906064015b600060405180830381600087803b15801561028c57600080fd5b505af11580156102a0573d6000803e3d6000fd5b50505050505050565b6032546001600160a01b031633146103035760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610213565b826103505760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f7273207370656369666965640000000000000000006044820152606401610213565b60005b838110156103b5576103a385858381811061037057610370610e73565b90506020020160208101906103859190610df9565b84848481811061039757610397610e73565b90506020020135610918565b806103ad81610e89565b915050610353565b5050505050565b6032546001600160a01b031633146104165760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610213565b6032546040516370a0823160e01b81526001600160a01b038581166004830152849216906370a082319060240160206040518083038186803b15801561045b57600080fd5b505afa15801561046f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104939190610eb2565b10156104ec5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610213565b6104f68383610918565b603254604051631f1b6d2760e21b81526001600160a01b0385811660048301523060248301526044820185905290911690637c6db49c90606401610272565b6033546001600160a01b038481169116146105925760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f7420544254430000000000000000000000000000006044820152606401610213565b336001600160a01b038416146105ea5760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f77656400000000000000006044820152606401610213565b6103b585856109ad565b6032546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b15801561063c57600080fd5b505afa158015610650573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106749190610eb2565b10156106cd5760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610213565b6106d78183610918565b603254604051631f1b6d2760e21b81526001600160a01b0383811660048301523060248301526044820185905290911690637c6db49c906064015b600060405180830381600087803b15801561072c57600080fd5b505af1158015610740573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146107a25760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610213565b6001600160a01b03811661081e5760405162461bcd60e51b815260206004820152602260248201527f4e657720676f7665726e616e636520697320746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610213565b61082781610ac1565b50565b61082733826109ad565b6000546001600160a01b0316331461088e5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610213565b6033546040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063fc4e51f6906108df9088908890889088908890600401610ecb565b600060405180830381600087803b1580156108f957600080fd5b505af115801561090d573d6000803e3d6000fd5b505050505050505050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe8260405161095391815260200190565b60405180910390a26033546040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906340c10f1990604401610712565b816001600160a01b03167f4896181ff8f4543cc00db9fe9b6fb7e6f032b7eb772c72ab1ec1b4d2e03b9369826040516109e891815260200190565b60405180910390a26033546040517f79cc67900000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906379cc679090604401600060405180830381600087803b158015610a5757600080fd5b505af1158015610a6b573d6000803e3d6000fd5b50506032546040517f56a6d9ef0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301526024820186905290911692506356a6d9ef9150604401610712565b600080546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117909355604080519190921680825260208201939093527f5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80910160405180910390a15050565b6001600160a01b038116811461082757600080fd5b600080600060608486031215610b6457600080fd5b8335610b6f81610b3a565b92506020840135610b7f81610b3a565b929592945050506040919091013590565b60008083601f840112610ba257600080fd5b50813567ffffffffffffffff811115610bba57600080fd5b6020830191508360208260051b8501011115610bd557600080fd5b9250929050565b60008060008060408587031215610bf257600080fd5b843567ffffffffffffffff80821115610c0a57600080fd5b610c1688838901610b90565b90965094506020870135915080821115610c2f57600080fd5b50610c3c87828801610b90565b95989497509550505050565b634e487b7160e01b600052604160045260246000fd5b600080600060608486031215610c7357600080fd5b8335610c7e81610b3a565b925060208401359150604084013567ffffffffffffffff80821115610ca257600080fd5b818601915086601f830112610cb657600080fd5b813581811115610cc857610cc8610c48565b604051601f8201601f19908116603f01168101908382118183101715610cf057610cf0610c48565b81604052828152896020848701011115610d0957600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b60008083601f840112610d3d57600080fd5b50813567ffffffffffffffff811115610d5557600080fd5b602083019150836020828501011115610bd557600080fd5b600080600080600060808688031215610d8557600080fd5b8535610d9081610b3a565b9450602086013593506040860135610da781610b3a565b9250606086013567ffffffffffffffff811115610dc357600080fd5b610dcf88828901610d2b565b969995985093965092949392505050565b600060208284031215610df257600080fd5b5035919050565b600060208284031215610e0b57600080fd5b8135610e1681610b3a565b9392505050565b600080600080600060808688031215610e3557600080fd5b8535610e4081610b3a565b94506020860135610e5081610b3a565b935060408601359250606086013567ffffffffffffffff811115610dc357600080fd5b634e487b7160e01b600052603260045260246000fd5b6000600019821415610eab57634e487b7160e01b600052601160045260246000fd5b5060010190565b600060208284031215610ec457600080fd5b5051919050565b60006001600160a01b03808816835280871660208401525084604083015260806060830152826080830152828460a0840137600060a0848401015260a0601f19601f8501168301019050969550505050505056fea2646970667358221220d8d9594142b5b1b46bfc77405493179b74258f5dea06c4620d5135cc64b2be5a64736f6c63430008090033",
|
|
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,10 +13,11 @@
|
|
|
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
|
|
@@ -114,6 +115,29 @@ contract Bank is Ownable {
|
|
|
114
115
|
_approveBalance(msg.sender, spender, amount);
|
|
115
116
|
}
|
|
116
117
|
|
|
118
|
+
/// @notice Sets the `amount` as an allowance of a smart contract `spender`
|
|
119
|
+
/// over the caller's balance and calls the `spender` via
|
|
120
|
+
/// `receiveBalanceApproval`.
|
|
121
|
+
/// @dev If the `amount` is set to `type(uint256).max`, the potential
|
|
122
|
+
/// `transferBalanceFrom` executed in `receiveBalanceApproval` of
|
|
123
|
+
/// `spender` will not reduce an allowance. Beware that changing an
|
|
124
|
+
/// allowance with this function brings the risk that `spender` may use
|
|
125
|
+
/// both the old and the new allowance by unfortunate transaction
|
|
126
|
+
/// ordering. Please use `increaseBalanceAllowance` and
|
|
127
|
+
/// `decreaseBalanceAllowance` to eliminate the risk.
|
|
128
|
+
function approveBalanceAndCall(
|
|
129
|
+
address spender,
|
|
130
|
+
uint256 amount,
|
|
131
|
+
bytes memory extraData
|
|
132
|
+
) external {
|
|
133
|
+
_approveBalance(msg.sender, spender, amount);
|
|
134
|
+
IReceiveBalanceApproval(spender).receiveBalanceApproval(
|
|
135
|
+
msg.sender,
|
|
136
|
+
amount,
|
|
137
|
+
extraData
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
117
141
|
/// @notice Atomically increases the balance allowance granted to `spender`
|
|
118
142
|
/// by the caller by the given `addedValue`.
|
|
119
143
|
function increaseBalanceAllowance(address spender, uint256 addedValue)
|
|
@@ -207,23 +231,22 @@ contract Bank is Ownable {
|
|
|
207
231
|
);
|
|
208
232
|
require(v == 27 || v == 28, "Invalid signature 'v' value");
|
|
209
233
|
|
|
210
|
-
bytes32 digest =
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
deadline
|
|
223
|
-
)
|
|
234
|
+
bytes32 digest = keccak256(
|
|
235
|
+
abi.encodePacked(
|
|
236
|
+
"\x19\x01",
|
|
237
|
+
DOMAIN_SEPARATOR(),
|
|
238
|
+
keccak256(
|
|
239
|
+
abi.encode(
|
|
240
|
+
PERMIT_TYPEHASH,
|
|
241
|
+
owner,
|
|
242
|
+
spender,
|
|
243
|
+
amount,
|
|
244
|
+
nonce[owner]++,
|
|
245
|
+
deadline
|
|
224
246
|
)
|
|
225
247
|
)
|
|
226
|
-
)
|
|
248
|
+
)
|
|
249
|
+
);
|
|
227
250
|
address recoveredAddress = ecrecover(digest, v, r, s);
|
|
228
251
|
require(
|
|
229
252
|
recoveredAddress != address(0) && recoveredAddress == owner,
|
|
@@ -267,8 +290,8 @@ contract Bank is Ownable {
|
|
|
267
290
|
/// @dev Requirements:
|
|
268
291
|
/// - `vault` must implement `IVault` interface,
|
|
269
292
|
/// - length of `depositors` and `depositedAmounts` must be the same.
|
|
270
|
-
/// @param vault Address of `IVault` recipient contract
|
|
271
|
-
/// @param depositors Addresses of depositors whose deposits have been swept
|
|
293
|
+
/// @param vault Address of `IVault` recipient contract.
|
|
294
|
+
/// @param depositors Addresses of depositors whose deposits have been swept.
|
|
272
295
|
/// @param depositedAmounts Amounts deposited by individual depositors and
|
|
273
296
|
/// swept. The `vault`'s balance in the Bank will be increased by the
|
|
274
297
|
/// sum of all elements in this array.
|
|
@@ -286,7 +309,7 @@ contract Bank is Ownable {
|
|
|
286
309
|
totalAmount += depositedAmounts[i];
|
|
287
310
|
}
|
|
288
311
|
_increaseBalance(vault, totalAmount);
|
|
289
|
-
IVault(vault).
|
|
312
|
+
IVault(vault).receiveBalanceIncrease(depositors, depositedAmounts);
|
|
290
313
|
}
|
|
291
314
|
|
|
292
315
|
/// @notice Decreases caller's balance by the provided `amount`. There is no
|
|
@@ -342,7 +365,9 @@ contract Bank is Ownable {
|
|
|
342
365
|
|
|
343
366
|
uint256 spenderBalance = balanceOf[spender];
|
|
344
367
|
require(spenderBalance >= amount, "Transfer amount exceeds balance");
|
|
345
|
-
unchecked {
|
|
368
|
+
unchecked {
|
|
369
|
+
balanceOf[spender] = spenderBalance - amount;
|
|
370
|
+
}
|
|
346
371
|
balanceOf[recipient] += amount;
|
|
347
372
|
emit BalanceTransferred(spender, recipient, amount);
|
|
348
373
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
/// @title IReceiveBalanceApproval
|
|
19
|
+
/// @notice `IReceiveBalanceApproval` is an interface for a smart contract
|
|
20
|
+
/// consuming Bank balances approved to them in the same transaction by
|
|
21
|
+
/// other contracts or externally owned accounts (EOA).
|
|
22
|
+
interface IReceiveBalanceApproval {
|
|
23
|
+
/// @notice Called by the Bank in `approveBalanceAndCall` function after
|
|
24
|
+
/// the balance `owner` approved `amount` of their balance in the
|
|
25
|
+
/// Bank for the contract. This way, the depositor can approve
|
|
26
|
+
/// balance and call the contract to use the approved balance in
|
|
27
|
+
/// a single transaction.
|
|
28
|
+
/// @param owner Address of the Bank balance owner who approved their
|
|
29
|
+
/// balance to be used by the contract.
|
|
30
|
+
/// @param amount The amount of the Bank balance approved by the owner
|
|
31
|
+
/// to be used by the contract.
|
|
32
|
+
/// @param extraData The `extraData` passed to `Bank.approveBalanceAndCall`.
|
|
33
|
+
// @dev The implementation must ensure this function can only be called
|
|
34
|
+
/// by the Bank. The Bank does _not_ guarantee that the `amount`
|
|
35
|
+
/// approved by the `owner` currently exists on their balance. That is,
|
|
36
|
+
/// the `owner` could approve more balance than they currently have.
|
|
37
|
+
/// This works the same as `Bank.approve` function. The contract must
|
|
38
|
+
/// ensure the actual balance is checked before performing any action
|
|
39
|
+
/// based on it.
|
|
40
|
+
function receiveBalanceApproval(
|
|
41
|
+
address owner,
|
|
42
|
+
uint256 amount,
|
|
43
|
+
bytes memory extraData
|
|
44
|
+
) external;
|
|
45
|
+
}
|