-
Notifications
You must be signed in to change notification settings - Fork 2
/
WithdrawHook.sol
45 lines (37 loc) · 1.13 KB
/
WithdrawHook.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// SPDX-License-Identifier: UNLICENSED
import "./interfaces/IHook.sol";
import "./interfaces/ICollateralDepositRecord.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
pragma solidity =0.8.7;
contract WithdrawHook is IHook, Ownable {
address private _vault;
ICollateralDepositRecord private _depositRecord;
constructor(address _newDepositRecord) {
_depositRecord = ICollateralDepositRecord(_newDepositRecord);
}
modifier onlyVault() {
require(msg.sender == _vault, "Caller is not the vault");
_;
}
function hook(
address _sender,
uint256 _initialAmount,
uint256 _finalAmount
) external override onlyVault {
_depositRecord.recordWithdrawal(_sender, _finalAmount);
}
function setVault(address _newVault) external override onlyOwner {
_vault = _newVault;
emit VaultChanged(_newVault);
}
function getVault() external view returns (address) {
return _vault;
}
function getDepositRecord()
external
view
returns (ICollateralDepositRecord)
{
return _depositRecord;
}
}