|
| 1 | +// SPDX-License-Identifier: BUSL-1.1 |
| 2 | +pragma solidity ^0.8.28; |
| 3 | + |
| 4 | +import { ICapNotify } from "../interfaces/ICapNotify.sol"; |
| 5 | + |
| 6 | +import { IFeeReceiver } from "../interfaces/IFeeReceiver.sol"; |
| 7 | +import { IStakedCap } from "../interfaces/IStakedCap.sol"; |
| 8 | + |
| 9 | +import { CapNotifyStorageUtils } from "../storage/CapNotifyStorageUtils.sol"; |
| 10 | +import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; |
| 11 | +import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; |
| 12 | + |
| 13 | +/// @title Cap Notifier |
| 14 | +/// @author weso, Cap Labs |
| 15 | +/// @notice Calls distribute from the Fee Receiver contract |
| 16 | +contract CapNotify is ICapNotify, CapNotifyStorageUtils, Initializable { |
| 17 | + /// @inheritdoc ICapNotify |
| 18 | + function initialize(address _feeReceiver, address _stakedCap) external initializer { |
| 19 | + CapNotifyStorage storage $ = getCapNotifyStorage(); |
| 20 | + $.feeReceiver = _feeReceiver; |
| 21 | + $.stakedCap = _stakedCap; |
| 22 | + } |
| 23 | + |
| 24 | + /// @inheritdoc ICapNotify |
| 25 | + function notify() external { |
| 26 | + CapNotifyStorage storage $ = getCapNotifyStorage(); |
| 27 | + IFeeReceiver($.feeReceiver).distribute(); |
| 28 | + } |
| 29 | + |
| 30 | + /// @inheritdoc ICapNotify |
| 31 | + function checker() external view returns (bool canExec, bytes memory execPayload) { |
| 32 | + CapNotifyStorage storage $ = getCapNotifyStorage(); |
| 33 | + uint256 lastNotify = IStakedCap($.stakedCap).lastNotify(); |
| 34 | + uint256 duration = IStakedCap($.stakedCap).lockDuration(); |
| 35 | + if (lastNotify + duration > block.timestamp) return (false, bytes("Not time to notify")); |
| 36 | + |
| 37 | + return (true, abi.encodeCall(this.notify, ())); |
| 38 | + } |
| 39 | +} |
0 commit comments