编译器
0.8.13+commit.abaa5c0e
文件 1 的 5: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 的 5: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);
}
文件 3 的 5:IOFT.sol
interface IOFT {
function estimateSendFee(
uint16 _dstChainId,
bytes calldata _toAddress,
uint256 _amount,
bool _useZro,
bytes calldata _adapterParams
) external view returns (uint256 nativeFee, uint256 zroFee);
function sendFrom(
address _from,
uint16 _dstChainId,
bytes calldata _toAddress,
uint256 _amount,
address payable _refundAddress,
address _zroPaymentAddress,
bytes calldata _adapterParams
) external payable;
}
文件 4 的 5: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);
}
}
文件 5 的 5:ZooDAOProxyEth.sol
pragma solidity ^0.8.0;
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import './interfaces/IOFT.sol';
contract ZooDAOProxyEth is Ownable {
address private _commissionReceiver;
uint256 private _commissionAmountInNative;
address public token;
IOFT private proxyOft;
event CommissionAmountUpdated(uint256 oldCommissionAmount, uint256 newCommissionAmount);
event CommissionReceiverUpdated(address oldCommissionReceiver, address newCommissionReceiver);
event BridgeWithCommission(uint256 amount, uint256 amountWithoutCommission, uint256 commission);
constructor(
address token_,
address proxyOft_,
address commisionReceiver_,
uint256 commissionAmountInNative_
) {
_commissionReceiver = commisionReceiver_;
_commissionAmountInNative = commissionAmountInNative_;
token = token_;
proxyOft = IOFT(proxyOft_);
}
function estimateSendFee(
uint16 _dstChainId,
bytes calldata _toAddress,
uint256 _amount,
bool _useZro,
bytes calldata _adapterParams
) public view returns (uint256 nativeFee, uint256 zroFee) {
(nativeFee, zroFee) = proxyOft.estimateSendFee(_dstChainId, _toAddress, _amount, _useZro, _adapterParams);
nativeFee += _commissionAmountInNative;
}
function sendFrom(
address,
uint16 _dstChainId,
bytes calldata _toAddress,
uint256 _amount,
address payable _refundAddress,
address _zroPaymentAddress,
bytes calldata _adapterParams
) public payable {
require(IERC20(token).transferFrom(msg.sender, address(this), _amount));
require(IERC20(token).approve(address(proxyOft), _amount));
uint256 newValue = deductCommissionInNative();
proxyOft.sendFrom{value: newValue}(
address(this),
_dstChainId,
_toAddress,
_amount,
_refundAddress,
_zroPaymentAddress,
_adapterParams
);
}
function deductCommissionInNative() internal returns (uint256 newFeeAmount) {
(bool success, ) = _commissionReceiver.call{value: _commissionAmountInNative}('');
require(success, 'Fee is too low. Get fee amount from estimateSendFee()');
emit BridgeWithCommission(msg.value, msg.value - _commissionAmountInNative, _commissionAmountInNative);
return msg.value - _commissionAmountInNative;
}
function updateCommissionAmount(uint256 commissionAmountInNative_) external onlyOwner {
uint256 oldCommissionAmountInNative = _commissionAmountInNative;
_commissionAmountInNative = commissionAmountInNative_;
emit CommissionAmountUpdated(oldCommissionAmountInNative, _commissionAmountInNative);
}
function updateCommissionReceiver(address commisionReceiver_) external onlyOwner {
address oldCommissionReceiver = _commissionReceiver;
_commissionReceiver = commisionReceiver_;
emit CommissionReceiverUpdated(oldCommissionReceiver, _commissionReceiver);
}
}
{
"compilationTarget": {
"contracts/ZooDAOProxyEth.sol": "ZooDAOProxyEth"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"token_","type":"address"},{"internalType":"address","name":"proxyOft_","type":"address"},{"internalType":"address","name":"commisionReceiver_","type":"address"},{"internalType":"uint256","name":"commissionAmountInNative_","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountWithoutCommission","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"commission","type":"uint256"}],"name":"BridgeWithCommission","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldCommissionAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newCommissionAmount","type":"uint256"}],"name":"CommissionAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldCommissionReceiver","type":"address"},{"indexed":false,"internalType":"address","name":"newCommissionReceiver","type":"address"}],"name":"CommissionReceiverUpdated","type":"event"},{"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":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"bytes","name":"_toAddress","type":"bytes"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bool","name":"_useZro","type":"bool"},{"internalType":"bytes","name":"_adapterParams","type":"bytes"}],"name":"estimateSendFee","outputs":[{"internalType":"uint256","name":"nativeFee","type":"uint256"},{"internalType":"uint256","name":"zroFee","type":"uint256"}],"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":"","type":"address"},{"internalType":"uint16","name":"_dstChainId","type":"uint16"},{"internalType":"bytes","name":"_toAddress","type":"bytes"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address payable","name":"_refundAddress","type":"address"},{"internalType":"address","name":"_zroPaymentAddress","type":"address"},{"internalType":"bytes","name":"_adapterParams","type":"bytes"}],"name":"sendFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"token","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":[{"internalType":"uint256","name":"commissionAmountInNative_","type":"uint256"}],"name":"updateCommissionAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"commisionReceiver_","type":"address"}],"name":"updateCommissionReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"}]