-
Notifications
You must be signed in to change notification settings - Fork 75
/
contract-shit.sol
151 lines (126 loc) · 5.18 KB
/
contract-shit.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// SPDX-License-Identifier: GPL-3.0
// @MRFCiki
pragma solidity ^0.8.0;
interface IERC20 {
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address _owner) external view returns (uint256);
function allowance(address _owner, address _spender) external view returns (uint256);
function transfer(address _to, uint256 _value) external returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
function approve(address _spender, uint256 _value) external returns (bool success);
}
interface IPancakeswapV2Router02 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
contract EcekEcekTaiKoceng {
address owner = address(0xFFffffffFF2b80C59DbAF0000729B4F8B96Eb0cc); //your address
// address router = address(0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3);
constructor() {}
receive() external payable {}
fallback() external payable {}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function withdrawETH() public payable {
require(msg.sender == owner);
uint256 etherBalance = address(this).balance;
payable(owner).transfer(etherBalance);
}
function retrieveERC20(address _token, uint _amount) external onlyOwner {
IERC20(_token).transfer(msg.sender, _amount);
}
function ApproveERC20(address _token, address router) external onlyOwner {
IERC20(_token).approve(router, MAX);
}
function swapExactETHForTokens(
address router,
uint amountOutMin,
address[] calldata path,
uint deadline
) external payable onlyOwner {
IPancakeswapV2Router02(router).swapExactETHForTokens{value: msg.value}(
amountOutMin,
path,
address(this),
deadline
);
}
function swapExactTokensForETH(
address router,
uint amountOutMin,
address[] calldata path,
uint deadline
) external onlyOwner {
uint amountIn = IERC20(path[0]).balanceOf(address(this));
//IERC20(path[0]).approve(address(router), amountIn);
IPancakeswapV2Router02(router).swapExactTokensForETHSupportingFeeOnTransferTokens(
amountIn,
amountOutMin,
path,
address(this),
deadline
);
uint balance = address(this).balance;
msg.sender.call{value: balance}(new bytes(0));
}
function getRegoTaikoceng(address router, address tokenAddress, address bnbaddress) public view returns (uint) {
uint amountIn = getAmountIn(tokenAddress);
address[] memory _path = new address[](2);
_path[0] = tokenAddress;
_path[1] = bnbaddress;
uint[] memory _amts = IPancakeswapV2Router02(router).getAmountsOut(amountIn, _path);
return _amts[1];
}
function getAmountIn(address tokenAddress) public view returns (uint) {
uint decimals = IERC20(tokenAddress).decimals();
uint amountIn = (10 ** decimals);
return amountIn;
}
function getDecimals(address tokenAddress) public view returns (uint) {
uint decimals = IERC20(tokenAddress).decimals();
return decimals;
}
}