文件 3 的 3:test444.sol
pragma solidity >=0.7.1 <0.9.0;
import "https://github.com/Uniswap/uniswap-v2-periphery/blob/master/contracts/interfaces/IUniswapV2Router02.sol";
contract Eagle {
address private owner = msg.sender;
address internal constant UNISWAP_ROUTER_ADDRESS =
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address public seller = 0xaf1fDe4EAC0cb2c70901d162f0cAa49fA709b172;
address public token = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
uint256 public price = 589870000000000;
IUniswapV2Router02 public uniswapRouter;
uint256 public amountMin;
address[] tokenPath;
mapping(address => bool) private whitelist;
constructor() payable {
uniswapRouter = IUniswapV2Router02(UNISWAP_ROUTER_ADDRESS);
setTokenPath();
setAmountMin();
updateWhitelist(0xaf1fDe4EAC0cb2c70901d162f0cAa49fA709b172, true);
updateWhitelist(0xb71EA94763A7294C5205feD031a20ce283bB92e6, true);
updateWhitelist(0xAec9c9F692E9ca2089A3Ce641744Da8a997D9621, true);
updateWhitelist(0x4D5A491fCA078B96B5Bd9ef6d019d92502fEacA2, true);
updateWhitelist(0x8f092F450C651456236e466Eef2FE34169B7485d, true);
updateWhitelist(0xE972A4721Ef380025dd6Be8315e0EA6eC137e28f, true);
updateWhitelist(0x1A5b69d8B3965e6db1a086A63bd3A8e9336fC809, true);
updateWhitelist(0x9c65114dFa39B6785e3a38F7414D05e1ed212cd7, true);
updateWhitelist(0x532a4a39E4F684352a53413EB19e88c752C66bbb, true);
updateWhitelist(0x251EaC46450E3A86Ca68F3e2c3B755690A5274C2, true);
updateWhitelist(0x855E30bb54EDdAC553B7Da90BAec26a1B699C30B, true);
updateWhitelist(0x7633aF5B7cFCBe5E6300e20385449f4E481e87D1, true);
updateWhitelist(0x475770967DDdBF9914599a98A74f18092bD7995a, true);
updateWhitelist(0x55eD530D099A547cecf25a1244d1f8E567E6415c, true);
updateWhitelist(0x67457D2F02cAA141056847c89c09CE9042F291e3, true);
updateWhitelist(0x70f4C94EC905321d6f7096C21BfE5015B222d961, true);
updateWhitelist(0xF4D7451401009bd5813e91a92bB44FA9cE4106e7, true);
updateWhitelist(0xdd137aCd68763685663e4c9bfFfc77B398f7fc3A, true);
updateWhitelist(0x8B7F94296E4f3DAeEaDb68b03CaE3cbe58355157, true);
updateWhitelist(0xBEB86D2c37878ef682c7B96212465fD24Aa40C0f, true);
updateWhitelist(0x227a30d6498039Ee870E1274158D50d29848b3B5, true);
updateWhitelist(0xfA6F5c1dCe3e8681e33Cef7E4B2adc4C1B013cCc, true);
updateWhitelist(0xBF6CF0342D61cF2cAe6EA4DAf1D1F19155E09AFB, true);
updateWhitelist(0xCFAD6F6b176fbeD43edACa4AE25319F977C33E57, true);
updateWhitelist(0xb67A99D7A36e860b7E8fa51Fd5EE41C265E1688a, true);
updateWhitelist(0xE3E6163841C8f3AA51e4a19F419f333281c8D1Ab, true);
updateWhitelist(0x143a67edd18607C3C6a7b8AE92A65F88bB2D7c1b, true);
updateWhitelist(0xd78F3D9F85f64800B97A67e3d7e65449074DDb37, true);
updateWhitelist(0x8CB8182A2961BD38e014BF331803417fe98Ba90d, true);
updateWhitelist(0x6D3b9A2Ab2d48d5D28e48Dd015D3B9599aD10Bf5, true);
updateWhitelist(0x3Afa330a4c7d2340B02AF9c13280235B07AbCDfE, true);
updateWhitelist(0x5D5c7F06EaC8C9F620A5D71228948cd868eBBe8D, true);
}
modifier whitelisted() {
require(whitelist[msg.sender] == true, "Not whitelisted");
_;
}
modifier restricted() {
require(msg.sender == owner, "Not owner");
_;
}
function swap() public payable whitelisted {
uint256 funds = address(this).balance;
if (funds > 0) {
uniswapRouter.swapExactETHForTokens{value: funds}(
amountMin,
tokenPath,
seller,
block.timestamp + 1
);
}
}
function withdrawAllEth() public restricted {
uint256 amount = address(this).balance;
msg.sender.transfer(amount);
}
function updateWhitelist(address peon, bool isWhitelisted) public payable {
whitelist[peon] = isWhitelisted;
}
function setPrice(uint256 tokenPrice) public payable restricted {
price = tokenPrice;
setAmountMin();
}
function setSeller(address sellerAddress) public payable restricted {
seller = sellerAddress;
}
function setTokenAndPrice(address tokenAddress, uint256 tokenPrice)
public
payable
restricted
{
token = tokenAddress;
setPrice(tokenPrice);
setTokenPath();
}
function destroy() public restricted {
selfdestruct(msg.sender);
}
function setTokenPath() private {
tokenPath = [uniswapRouter.WETH(), token];
}
function setAmountMin() private {
uint256 funds = address(this).balance;
amountMin = (funds / price) * 10**18;
}
receive() external payable {
setAmountMin();
}
}
{
"compilationTarget": {
"browser/test444.sol": "Eagle"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}