编译器
0.8.17+commit.8df45f5f
文件 1 的 6:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 2 的 6:FeeWallet.sol
pragma solidity 0.8.17;
import "../interfaces/IFeeWallet.sol";
import "../interfaces/IWstETH.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract FeeWallet is IFeeWallet, Ownable {
address public wstETH;
address public stETH;
mapping(address => bool) public feeDistributors;
string public walletName;
constructor(address _wstETH, string memory _walletName) {
wstETH = _wstETH;
stETH = IWstETH(_wstETH).stETH();
walletName = _walletName;
}
function withdraw() external override onlyFeeDistributor returns (uint256) {
uint256 stETHAmount = IERC20(stETH).balanceOf(address(this));
if (stETHAmount == 0) {
return 0;
}
IERC20(stETH).approve(wstETH, stETHAmount);
uint256 wstETHAmount = IWstETH(wstETH).wrap(stETHAmount);
IWstETH(wstETH).transfer(msg.sender, wstETHAmount);
return wstETHAmount;
}
function withdrawRaw() external override onlyFeeDistributor returns (uint256) {
uint256 stETHAmountBefore = IERC20(stETH).balanceOf(address(this));
if (stETHAmountBefore == 0) {
return 0;
}
IWstETH(stETH).transfer(msg.sender, stETHAmountBefore);
uint256 stETHAmountAfter = IERC20(stETH).balanceOf(address(this));
return stETHAmountBefore - stETHAmountAfter;
}
function feeToken() external view override returns (address) {
return wstETH;
}
function feeTokenRaw() external view override returns (address) {
return stETH;
}
function setFeeDistributor(address _feeDistributor, bool _isFeeDistributor) external onlyOwner {
feeDistributors[_feeDistributor] = _isFeeDistributor;
}
modifier onlyFeeDistributor() {
require(feeDistributors[msg.sender], "!fee distributor");
_;
}
}
文件 3 的 6:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
文件 4 的 6:IFeeWallet.sol
pragma solidity 0.8.17;
interface IFeeWallet {
function withdraw() external returns (uint);
function withdrawRaw() external returns (uint);
function feeToken() external view returns (address);
function feeTokenRaw() external view returns (address);
}
文件 5 的 6:IWstETH.sol
pragma solidity 0.8.17;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IWstETH is IERC20 {
function getWstETHByStETH(uint _stETHAmount) external view returns (uint _wstETHAmount);
function getStETHByWstETH(uint _wstETHAmount) external view returns (uint _stETHAmount);
function stETH() external view returns (address);
function wrap(uint256 _stETHAmount) external returns (uint _receivedWstETHAmount);
function unwrap(uint256 _wstETHAmount) external returns (uint _receivedStETHAmount);
}
文件 6 的 6:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
{
"compilationTarget": {
"contracts/earn/FeeWallet.sol": "FeeWallet"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"_wstETH","type":"address"},{"internalType":"string","name":"_walletName","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"feeDistributors","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeTokenRaw","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeDistributor","type":"address"},{"internalType":"bool","name":"_isFeeDistributor","type":"bool"}],"name":"setFeeDistributor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"walletName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawRaw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wstETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]