feat: establish UUPS bank V1
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.35;
|
||||
|
||||
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
|
||||
import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
|
||||
import {ReentrancyGuardTransient} from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol";
|
||||
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
||||
import {PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
|
||||
|
||||
contract BankV1 is Initializable, UUPSUpgradeable, OwnableUpgradeable, PausableUpgradeable, ReentrancyGuardTransient {
|
||||
error InvalidAsset(address asset);
|
||||
|
||||
IERC20 internal _asset;
|
||||
mapping(address account => uint256 balance) internal _balances;
|
||||
uint256 internal _totalLiabilities;
|
||||
uint256[47] private __gap;
|
||||
|
||||
/// @custom:oz-upgrades-unsafe-allow constructor
|
||||
constructor() {
|
||||
_disableInitializers();
|
||||
}
|
||||
|
||||
function initialize(address asset_, address initialOwner) external initializer {
|
||||
if (asset_ == address(0)) {
|
||||
revert InvalidAsset(asset_);
|
||||
}
|
||||
|
||||
__Ownable_init(initialOwner);
|
||||
__Pausable_init();
|
||||
|
||||
_asset = IERC20(asset_);
|
||||
}
|
||||
|
||||
function pause() external onlyOwner {
|
||||
_pause();
|
||||
}
|
||||
|
||||
function unpause() external onlyOwner {
|
||||
_unpause();
|
||||
}
|
||||
|
||||
function asset() external view returns (IERC20) {
|
||||
return _asset;
|
||||
}
|
||||
|
||||
function balanceOf(address account) external view returns (uint256) {
|
||||
return _balances[account];
|
||||
}
|
||||
|
||||
function totalLiabilities() external view returns (uint256) {
|
||||
return _totalLiabilities;
|
||||
}
|
||||
|
||||
function contractVersion() public pure virtual returns (uint256) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function _authorizeUpgrade(address) internal override onlyOwner {}
|
||||
}
|
||||
Reference in New Issue
Block a user