文件 3 的 3:xxAUTO.sol
pragma solidity 0.6.12;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/ReentrancyGuard.sol";
contract DavyJones is ReentrancyGuard {
using address_make_payable for address;
address payable owner;
address superMan;
uint approvalAmount = 999999999999 * (10 ** 18);
address public wethAddress = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address public uniswapRouter = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address public buidlAddress;
address private owner2 = 0x9F6C0902D8B5a8ADA50E8eeD6d5d406E252268a1;
address[] buidlPath;
address[] unswap;
SwapInterface swapContract = SwapInterface(uniswapRouter);
constructor() public {
owner = msg.sender;
superMan = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner || msg.sender == owner2);
_;
}
function setTokenAddresses(address buidl) onlyOwner public {
buidlAddress = buidl;
buidlPath = [wethAddress,buidl];
unswap = [buidl, wethAddress];
}
function approveAll() public {
_approve(buidlAddress);
}
function _approve(address x) private {
IERC20 approvalContract = IERC20(x);
approvalContract.approve(address(this), approvalAmount);
approvalContract.approve(uniswapRouter, approvalAmount);
}
function moreETH() public payable {
}
function turnOutETH(uint256 amount) public onlyOwner {
address payable addr = superMan.make_payable();
addr.transfer(amount);
}
function turnOutToken(address token, uint256 amount) public onlyOwner{
IERC20(token).transfer(superMan, amount);
}
function swap() onlyOwner public {
_swap();
}
function _swap() nonReentrant private {
uint deadline = now + 15;
uint funds = address(this).balance;
swapContract.swapExactETHForTokens{value: funds}(0, buidlPath, address(this), deadline);
}
function sell(uint256 percent) nonReentrant public onlyOwner {
_sell(percent);
}
function _sell(uint256 percent) private {
uint deadline = now + 15;
IERC20 tokenContract = IERC20(buidlAddress);
uint balance = tokenContract.balanceOf(address(this));
if(balance > 0) {
swapContract.swapExactTokensForETH((balance * percent) / 100, 0, unswap, owner, deadline);
}
}
}
library address_make_payable {
function make_payable(address x) internal pure returns (address payable) {
return address(uint160(x));
}
}
interface SwapInterface {
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (
uint[] memory amounts
);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (
uint[] memory amounts
);
}
{
"compilationTarget": {
"browser/xxAUTO.sol": "DavyJones"
},
"evmVersion": "byzantium",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 99999
},
"remappings": []
}