diff --git a/contracts/components/staking/GeneralFortaStakingVault.sol b/contracts/components/staking/GeneralFortaStakingVault.sol index 13f11fdf..6c96faf0 100644 --- a/contracts/components/staking/GeneralFortaStakingVault.sol +++ b/contracts/components/staking/GeneralFortaStakingVault.sol @@ -6,16 +6,18 @@ pragma solidity ^0.8.9; import "@openzeppelin/contracts/utils/Multicall.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../../errors/GeneralErrors.sol"; -import "./utils/IVersioned.sol"; +import "../utils/IVersioned.sol"; contract GeneralFortaStakingVault is ERC4626Upgradeable, AccessControlUpgradeable, UUPSUpgradeable, Multicall, IVersioned { using SafeERC20 for IERC20; - bytes32 public constant SLASHER_ROLE = keccak256("SLASHER_ROLE"); + bytes32 constant SLASHER_ROLE = keccak256("SLASHER_ROLE"); + bytes32 constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE"); // treasury for slashing address private _treasury; @@ -26,7 +28,7 @@ contract GeneralFortaStakingVault is ERC4626Upgradeable, AccessControlUpgradeabl string public constant version = "0.1.0"; /// @custom:oz-upgrades-unsafe-allow constructor - construction() initializer { + constructor() initializer { _disableInitializers(); } @@ -42,7 +44,7 @@ contract GeneralFortaStakingVault is ERC4626Upgradeable, AccessControlUpgradeabl if (__treasury == address(0)) revert ZeroAddress("__treasury"); __ERC20_init("General FORT Staking Vault", "vFORTGeneral"); - __ERC4626_init(IERC20(__asset)); + __ERC4626_init(IERC20MetadataUpgradeable(__asset)); __AccessControl_init(); __UUPSUpgradeable_init(); _grantRole(DEFAULT_ADMIN_ROLE, __admin); @@ -57,10 +59,10 @@ contract GeneralFortaStakingVault is ERC4626Upgradeable, AccessControlUpgradeabl * @param stakeValue amount of staked token to be slashed. */ function slash( - uint256 stakeValue, - ) external onlyRole(SLASHER_ROLE) returns (uint256) { + uint256 stakeValue + ) external onlyRole(SLASHER_ROLE) { if (stakeValue == 0) revert ZeroAmount("stakeValue"); - SafeERC20.safeTransfer(IERC20(asset()), address(this), _treasury, stakeValue); + SafeERC20.safeTransferFrom(IERC20(asset()), address(this), _treasury, stakeValue); emit Slashed(_msgSender(), stakeValue); } @@ -74,6 +76,10 @@ contract GeneralFortaStakingVault is ERC4626Upgradeable, AccessControlUpgradeabl emit TreasurySet(newTreasury); } + // Access control for the upgrade process + function _authorizeUpgrade(address newImplementation) internal virtual override onlyRole(UPGRADER_ROLE) { + } + /** * 50 * - 1 _treasury