|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0; |
|
|
|
import "./Context.sol"; |
|
import "./IUniswapV2Pair.sol"; |
|
import "./IUniswapV2Factory.sol"; |
|
import "./ERC20.sol"; |
|
import "./ERC20Burnable.sol"; |
|
import "./SafeMath.sol"; |
|
import "./Ownable.sol"; |
|
import "./IUniswapV2Router01.sol"; |
|
|
|
contract TheHeist is ERC20, ERC20Burnable, Ownable { |
|
|
|
using SafeMath for uint256; |
|
|
|
IUniswapV2Router02 public immutable uniswapV2Router; |
|
address public uniswapV2Pair; |
|
|
|
bool private swapping; |
|
|
|
address public marketingWallet; |
|
uint256 public swapTokensAtAmount; |
|
|
|
uint256 public maxTransactionAmount; |
|
uint256 public maxWallet; |
|
|
|
bool public limitsInEffect = true; |
|
bool public tradingActive = false; |
|
bool public swapEnabled = false; |
|
|
|
|
|
mapping(address => uint256) private _holderLastTransferTimestamp; |
|
bool public transferDelayEnabled = true; |
|
|
|
uint256 public buyFees; |
|
uint256 public sellFees; |
|
|
|
uint256 public tokensForFee; |
|
|
|
|
|
|
|
|
|
mapping (address => bool) private _isExcludedFromFees; |
|
mapping (address => bool) public _isExcludedMaxTransactionAmount; |
|
|
|
|
|
|
|
mapping (address => bool) public automatedMarketMakerPairs; |
|
|
|
event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress); |
|
event ExcludeFromFees(address indexed account, bool isExcluded); |
|
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value); |
|
event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet); |
|
event jigsawContractUpdated(address indexed newWallet, address indexed oldWallet); |
|
event BoughtEarly(address indexed sniper); |
|
event withdrawForeignTokensFromContract(address token, uint256 amount); |
|
|
|
constructor() ERC20("The Heist", "TH") { |
|
|
|
|
|
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); |
|
uniswapV2Router = _uniswapV2Router; |
|
|
|
|
|
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH()); |
|
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true); |
|
|
|
|
|
uint256 totalSupply = 1 * 1e6 * 1e18; |
|
|
|
|
|
maxTransactionAmount = totalSupply * 1 / 100; |
|
maxWallet = totalSupply * 2 / 100; |
|
swapTokensAtAmount = totalSupply * 5 / 10000; |
|
|
|
|
|
buyFees = 2; |
|
|
|
|
|
sellFees = 2; |
|
|
|
|
|
marketingWallet = address(owner()); |
|
|
|
|
|
excludeFromFees(owner(), true); |
|
excludeFromFees(address(this), true); |
|
excludeFromFees(address(0xdead), true); |
|
excludeFromMaxTransaction(owner(), true); |
|
excludeFromMaxTransaction(address(this), true); |
|
excludeFromMaxTransaction(address(0xdead), true); |
|
excludeFromMaxTransaction(address(uniswapV2Pair), true); |
|
excludeFromMaxTransaction(address(_uniswapV2Router), true); |
|
|
|
|
|
_mint(msg.sender, totalSupply); |
|
} |
|
|
|
receive() external payable { |
|
|
|
} |
|
|
|
|
|
function enableTrading() external onlyOwner { |
|
require(!tradingActive, "Trading is already active, cannot relaunch."); |
|
|
|
|
|
require(address(this).balance > 0, "Must have ETH on contract to launch"); |
|
require(balanceOf(address(this)) > 0, "Must have Tokens on contract to launch"); |
|
|
|
|
|
_approve(address(this), address(uniswapV2Router), balanceOf(address(this))); |
|
|
|
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this), balanceOf(address(this)), 0, 0, msg.sender, block.timestamp); |
|
|
|
tradingActive = true; |
|
swapEnabled = true; |
|
} |
|
|
|
|
|
function removeLimits() external onlyOwner returns (bool){ |
|
limitsInEffect = false; |
|
return true; |
|
} |
|
|
|
|
|
function disableTransferDelay() external onlyOwner returns (bool){ |
|
transferDelayEnabled = false; |
|
return true; |
|
} |
|
|
|
|
|
function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){ |
|
require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply."); |
|
require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply."); |
|
swapTokensAtAmount = newAmount; |
|
return true; |
|
} |
|
|
|
|
|
function updateMaxTxnAmount(uint256 newNum) external onlyOwner { |
|
require(newNum >= (totalSupply() * 1 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%"); |
|
maxTransactionAmount = newNum * (10**18); |
|
} |
|
|
|
|
|
function updateMaxWalletAmount(uint256 newNum) external onlyOwner { |
|
require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%"); |
|
maxWallet = newNum * (10**18); |
|
} |
|
|
|
|
|
function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner { |
|
_isExcludedMaxTransactionAmount[updAds] = isEx; |
|
} |
|
|
|
|
|
function updateBuyFees(uint256 _Fee) external onlyOwner { |
|
buyFees = _Fee; |
|
require(buyFees <= 20, "Must keep fees at 20% or less"); |
|
} |
|
|
|
|
|
function updateSellFees(uint256 _Fee) external onlyOwner { |
|
sellFees = _Fee; |
|
require(sellFees <= 25, "Must keep fees at 25% or less"); |
|
} |
|
|
|
|
|
function excludeFromFees(address account, bool excluded) public onlyOwner { |
|
_isExcludedFromFees[account] = excluded; |
|
emit ExcludeFromFees(account, excluded); |
|
} |
|
|
|
|
|
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner { |
|
require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs"); |
|
_setAutomatedMarketMakerPair(pair, value); |
|
} |
|
|
|
|
|
function _setAutomatedMarketMakerPair(address pair, bool value) private { |
|
automatedMarketMakerPairs[pair] = value; |
|
emit SetAutomatedMarketMakerPair(pair, value); |
|
} |
|
|
|
|
|
function updateMarketingWallet(address newMarketingWallet) external onlyOwner { |
|
emit marketingWalletUpdated(newMarketingWallet, marketingWallet); |
|
marketingWallet = newMarketingWallet; |
|
} |
|
|
|
|
|
function isExcludedFromFees(address account) public view returns(bool) { |
|
return _isExcludedFromFees[account]; |
|
} |
|
|
|
|
|
function _transfer(address from, address to, uint256 amount) internal override { |
|
require(from != address(0), "ERC20: transfer from the zero address"); |
|
require(to != address(0), "ERC20: transfer to the zero address"); |
|
|
|
if( amount == 0) { |
|
super._transfer(from, to, 0); |
|
return; |
|
} |
|
|
|
if(limitsInEffect){ |
|
if (from != owner() && |
|
to != owner() && |
|
to != address(0) && |
|
to != address(0xdead) && |
|
!swapping |
|
){ |
|
if(!tradingActive){ |
|
require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active."); |
|
} |
|
|
|
|
|
if (transferDelayEnabled){ |
|
if (to != owner() && |
|
to != address(uniswapV2Router) && |
|
to != address(uniswapV2Pair)){ |
|
require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed."); |
|
_holderLastTransferTimestamp[tx.origin] = block.number; |
|
} |
|
} |
|
|
|
|
|
if (automatedMarketMakerPairs[from] && |
|
!_isExcludedMaxTransactionAmount[to]) { |
|
require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount."); |
|
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); |
|
} |
|
|
|
|
|
else if (automatedMarketMakerPairs[to] && |
|
!_isExcludedMaxTransactionAmount[from]) { |
|
require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount."); |
|
} |
|
else if(!_isExcludedMaxTransactionAmount[to]){ |
|
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded"); |
|
} |
|
} |
|
} |
|
|
|
uint256 contractTokenBalance = balanceOf(address(this)); |
|
bool canSwap = contractTokenBalance >= swapTokensAtAmount; |
|
|
|
if( canSwap && |
|
swapEnabled && |
|
!swapping && |
|
!automatedMarketMakerPairs[from] && |
|
!_isExcludedFromFees[from] && |
|
!_isExcludedFromFees[to] |
|
) { |
|
swapping = true; |
|
swapBack(); |
|
swapping = false; |
|
} |
|
|
|
bool takeFee = !swapping; |
|
|
|
|
|
if( _isExcludedFromFees[from] || |
|
_isExcludedFromFees[to]) { |
|
takeFee = false; |
|
} |
|
|
|
uint256 fees = 0; |
|
|
|
|
|
if(takeFee){ |
|
|
|
if( automatedMarketMakerPairs[to] && |
|
sellFees > 0){ |
|
fees = amount.mul(sellFees).div(100); |
|
tokensForFee += fees; |
|
} |
|
|
|
else if(automatedMarketMakerPairs[from] && |
|
buyFees > 0) { |
|
fees = amount.mul(buyFees).div(100); |
|
tokensForFee += fees; |
|
} |
|
|
|
if(fees > 0){ |
|
super._transfer(from, address(this), fees); |
|
} |
|
|
|
amount -= fees; |
|
} |
|
|
|
super._transfer(from, to, amount); |
|
|
|
} |
|
|
|
|
|
function withdrawForeignTokens(address _token, address _to) external onlyOwner returns (bool _sent) { |
|
require(_token != address(0), "_token address cannot be 0"); |
|
require(_token != address(this) || !tradingActive, "Can't withdraw native tokens while trading is active"); |
|
uint256 _contractBalance = IERC20(_token).balanceOf(address(this)); |
|
_sent = IERC20(_token).transfer(_to, _contractBalance); |
|
emit withdrawForeignTokensFromContract(_token, _contractBalance); |
|
} |
|
|
|
|
|
function withdrawETH() external onlyOwner { |
|
bool success; |
|
(success,) = address(msg.sender).call{value: address(this).balance}(""); |
|
} |
|
|
|
|
|
function swapTokensForEth(uint256 tokenAmount) private { |
|
|
|
address[] memory path = new address[](2); |
|
path[0] = address(this); |
|
path[1] = uniswapV2Router.WETH(); |
|
|
|
_approve(address(this), address(uniswapV2Router), tokenAmount); |
|
|
|
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(tokenAmount, 0, path, address(this), block.timestamp); |
|
} |
|
|
|
function swapBack() private { |
|
uint256 contractBalance = balanceOf(address(this)); |
|
uint256 totalTokensToSwap = tokensForFee; |
|
|
|
bool success; |
|
|
|
if( contractBalance == 0 || |
|
totalTokensToSwap == 0) { |
|
return; |
|
} |
|
if( contractBalance > swapTokensAtAmount * 20){ |
|
contractBalance = swapTokensAtAmount * 20; |
|
} |
|
|
|
uint256 initialETHBalance = address(this).balance; |
|
|
|
|
|
swapTokensForEth(totalTokensToSwap); |
|
|
|
uint256 ethForMarketing = address(this).balance.sub(initialETHBalance); |
|
|
|
tokensForFee = 0; |
|
|
|
(success,) = address(marketingWallet).call{value: ethForMarketing}(""); |
|
} |
|
} |