File size: 68,262 Bytes
f998fcd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{
  "language": "Solidity",
  "sources": {
    "Izanagi.sol": {
      "content": "/**\r\n *Submitted for verification at Etherscan.io\r\n\r\nhttps://medium.com/@IzanagiProtocol\r\n\r\n*/\r\n\r\n\r\n\r\n/**\r\n\r\n*/\r\n\r\npragma solidity 0.8.13;\r\n\r\nabstract contract Context {\r\n    function _msgSender() internal view virtual returns (address) {\r\n        return msg.sender;\r\n    }\r\n\r\n    function _msgData() internal view virtual returns (bytes calldata) {\r\n        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\r\n        return msg.data;\r\n    }\r\n}\r\n\r\ninterface IUniswapV2Factory {\r\n    function createPair(address tokenA, address tokenB) external returns (address pair);\r\n}\r\n\r\ninterface IERC20 {\r\n    /**\r\n     * @dev Returns the amount of tokens in existence.\r\n     */\r\n    function totalSupply() external view returns (uint256);\r\n\r\n    /**\r\n     * @dev Returns the amount of tokens owned by `account`.\r\n     */\r\n    function balanceOf(address account) external view returns (uint256);\r\n\r\n    /**\r\n     * @dev Moves `amount` tokens from the caller's account to `recipient`.\r\n     *\r\n     * Returns a boolean value indicating whether the operation succeeded.\r\n     *\r\n     * Emits a {Transfer} event.\r\n     */\r\n    function transfer(address recipient, uint256 amount) external returns (bool);\r\n\r\n    /**\r\n     * @dev Returns the remaining number of tokens that `spender` will be\r\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\r\n     * zero by default.\r\n     *\r\n     * This value changes when {approve} or {transferFrom} are called.\r\n     */\r\n    function allowance(address owner, address spender) external view returns (uint256);\r\n\r\n    /**\r\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\r\n     *\r\n     * Returns a boolean value indicating whether the operation succeeded.\r\n     *\r\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\r\n     * that someone may use both the old and the new allowance by unfortunate\r\n     * transaction ordering. One possible solution to mitigate this race\r\n     * condition is to first reduce the spender's allowance to 0 and set the\r\n     * desired value afterwards:\r\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\r\n     *\r\n     * Emits an {Approval} event.\r\n     */\r\n    function approve(address spender, uint256 amount) external returns (bool);\r\n\r\n    /**\r\n     * @dev Moves `amount` tokens from `sender` to `recipient` using the\r\n     * allowance mechanism. `amount` is then deducted from the caller's\r\n     * allowance.\r\n     *\r\n     * Returns a boolean value indicating whether the operation succeeded.\r\n     *\r\n     * Emits a {Transfer} event.\r\n     */\r\n    function transferFrom(\r\n        address sender,\r\n        address recipient,\r\n        uint256 amount\r\n    ) external returns (bool);\r\n\r\n    /**\r\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\r\n     * another (`to`).\r\n     *\r\n     * Note that `value` may be zero.\r\n     */\r\n    event Transfer(address indexed from, address indexed to, uint256 value);\r\n\r\n    /**\r\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\r\n     * a call to {approve}. `value` is the new allowance.\r\n     */\r\n    event Approval(address indexed owner, address indexed spender, uint256 value);\r\n}\r\n\r\ninterface IERC20Metadata is IERC20 {\r\n    /**\r\n     * @dev Returns the name of the token.\r\n     */\r\n    function name() external view returns (string memory);\r\n\r\n    /**\r\n     * @dev Returns the symbol of the token.\r\n     */\r\n    function symbol() external view returns (string memory);\r\n\r\n    /**\r\n     * @dev Returns the decimals places of the token.\r\n     */\r\n    function decimals() external view returns (uint8);\r\n}\r\n\r\n\r\ncontract ERC20 is Context, IERC20, IERC20Metadata {\r\n    mapping(address => uint256) private _balances;\r\n\r\n    mapping(address => mapping(address => uint256)) private _allowances;\r\n\r\n    uint256 private _totalSupply;\r\n\r\n    string private _name;\r\n    string private _symbol;\r\n\r\n    constructor(string memory name_, string memory symbol_) {\r\n        _name = name_;\r\n        _symbol = symbol_;\r\n    }\r\n\r\n    function name() public view virtual override returns (string memory) {\r\n        return _name;\r\n    }\r\n\r\n    function symbol() public view virtual override returns (string memory) {\r\n        return _symbol;\r\n    }\r\n\r\n    function decimals() public view virtual override returns (uint8) {\r\n        return 18;\r\n    }\r\n\r\n    function totalSupply() public view virtual override returns (uint256) {\r\n        return _totalSupply;\r\n    }\r\n\r\n    function balanceOf(address account) public view virtual override returns (uint256) {\r\n        return _balances[account];\r\n    }\r\n\r\n    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\r\n        _transfer(_msgSender(), recipient, amount);\r\n        return true;\r\n    }\r\n\r\n    function allowance(address owner, address spender) public view virtual override returns (uint256) {\r\n        return _allowances[owner][spender];\r\n    }\r\n\r\n    function approve(address spender, uint256 amount) public virtual override returns (bool) {\r\n        _approve(_msgSender(), spender, amount);\r\n        return true;\r\n    }\r\n\r\n    function transferFrom(\r\n        address sender,\r\n        address recipient,\r\n        uint256 amount\r\n    ) public virtual override returns (bool) {\r\n        _transfer(sender, recipient, amount);\r\n\r\n        uint256 currentAllowance = _allowances[sender][_msgSender()];\r\n        require(currentAllowance >= amount, \"ERC20: transfer amount exceeds allowance\");\r\n        unchecked {\r\n            _approve(sender, _msgSender(), currentAllowance - amount);\r\n        }\r\n\r\n        return true;\r\n    }\r\n\r\n    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\r\n        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);\r\n        return true;\r\n    }\r\n\r\n    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\r\n        uint256 currentAllowance = _allowances[_msgSender()][spender];\r\n        require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\r\n        unchecked {\r\n            _approve(_msgSender(), spender, currentAllowance - subtractedValue);\r\n        }\r\n\r\n        return true;\r\n    }\r\n\r\n    function _transfer(\r\n        address sender,\r\n        address recipient,\r\n        uint256 amount\r\n    ) internal virtual {\r\n        require(sender != address(0), \"ERC20: transfer from the zero address\");\r\n        require(recipient != address(0), \"ERC20: transfer to the zero address\");\r\n\r\n        uint256 senderBalance = _balances[sender];\r\n        require(senderBalance >= amount, \"ERC20: transfer amount exceeds balance\");\r\n        unchecked {\r\n            _balances[sender] = senderBalance - amount;\r\n        }\r\n        _balances[recipient] += amount;\r\n\r\n        emit Transfer(sender, recipient, amount);\r\n    }\r\n\r\n    function _createInitialSupply(address account, uint256 amount) internal virtual {\r\n        require(account != address(0), \"ERC20: mint to the zero address\");\r\n        _totalSupply += amount;\r\n        _balances[account] += amount;\r\n        emit Transfer(address(0), account, amount);\r\n    }\r\n\r\n    function _approve(\r\n        address owner,\r\n        address spender,\r\n        uint256 amount\r\n    ) internal virtual {\r\n        require(owner != address(0), \"ERC20: approve from the zero address\");\r\n        require(spender != address(0), \"ERC20: approve to the zero address\");\r\n\r\n        _allowances[owner][spender] = amount;\r\n        emit Approval(owner, spender, amount);\r\n    }\r\n}\r\n\r\ninterface DividendPayingTokenOptionalInterface {\r\n  /// @notice View the amount of dividend in wei that an address can withdraw.\r\n  /// @param _owner The address of a token holder.\r\n  /// @return The amount of dividend in wei that `_owner` can withdraw.\r\n  function withdrawableDividendOf(address _owner, address _rewardToken) external view returns(uint256);\r\n\r\n  /// @notice View the amount of dividend in wei that an address has withdrawn.\r\n  /// @param _owner The address of a token holder.\r\n  /// @return The amount of dividend in wei that `_owner` has withdrawn.\r\n  function withdrawnDividendOf(address _owner, address _rewardToken) external view returns(uint256);\r\n\r\n  /// @notice View the amount of dividend in wei that an address has earned in total.\r\n  /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner)\r\n  /// @param _owner The address of a token holder.\r\n  /// @return The amount of dividend in wei that `_owner` has earned in total.\r\n  function accumulativeDividendOf(address _owner, address _rewardToken) external view returns(uint256);\r\n}\r\n\r\ninterface DividendPayingTokenInterface {\r\n  /// @notice View the amount of dividend in wei that an address can withdraw.\r\n  /// @param _owner The address of a token holder.\r\n  /// @return The amount of dividend in wei that `_owner` can withdraw.\r\n  function dividendOf(address _owner, address _rewardToken) external view returns(uint256);\r\n\r\n  /// @notice Distributes ether to token holders as dividends.\r\n  /// @dev SHOULD distribute the paid ether to token holders as dividends.\r\n  ///  SHOULD NOT directly transfer ether to token holders in this function.\r\n  ///  MUST emit a `DividendsDistributed` event when the amount of distributed ether is greater than 0.\r\n  function distributeDividends() external payable;\r\n\r\n  /// @notice Withdraws the ether distributed to the sender.\r\n  /// @dev SHOULD transfer `dividendOf(msg.sender)` wei to `msg.sender`, and `dividendOf(msg.sender)` SHOULD be 0 after the transfer.\r\n  ///  MUST emit a `DividendWithdrawn` event if the amount of ether transferred is greater than 0.\r\n  function withdrawDividend(address _rewardToken) external;\r\n\r\n  /// @dev This event MUST emit when ether is distributed to token holders.\r\n  /// @param from The address which sends ether to this contract.\r\n  /// @param weiAmount The amount of distributed ether in wei.\r\n  event DividendsDistributed(\r\n    address indexed from,\r\n    uint256 weiAmount\r\n  );\r\n\r\n  /// @dev This event MUST emit when an address withdraws their dividend.\r\n  /// @param to The address which withdraws ether from this contract.\r\n  /// @param weiAmount The amount of withdrawn ether in wei.\r\n  event DividendWithdrawn(\r\n    address indexed to,\r\n    uint256 weiAmount\r\n  );\r\n}\r\n\r\nlibrary SafeMath {\r\n    /**\r\n     * @dev Returns the addition of two unsigned integers, reverting on\r\n     * overflow.\r\n     *\r\n     * Counterpart to Solidity's `+` operator.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - Addition cannot overflow.\r\n     */\r\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\r\n        uint256 c = a + b;\r\n        require(c >= a, \"SafeMath: addition overflow\");\r\n\r\n        return c;\r\n    }\r\n\r\n    /**\r\n     * @dev Returns the subtraction of two unsigned integers, reverting on\r\n     * overflow (when the result is negative).\r\n     *\r\n     * Counterpart to Solidity's `-` operator.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - Subtraction cannot overflow.\r\n     */\r\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\r\n        return sub(a, b, \"SafeMath: subtraction overflow\");\r\n    }\r\n\r\n    /**\r\n     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\r\n     * overflow (when the result is negative).\r\n     *\r\n     * Counterpart to Solidity's `-` operator.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - Subtraction cannot overflow.\r\n     */\r\n    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\r\n        require(b <= a, errorMessage);\r\n        uint256 c = a - b;\r\n\r\n        return c;\r\n    }\r\n\r\n    /**\r\n     * @dev Returns the multiplication of two unsigned integers, reverting on\r\n     * overflow.\r\n     *\r\n     * Counterpart to Solidity's `*` operator.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - Multiplication cannot overflow.\r\n     */\r\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\r\n        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\r\n        // benefit is lost if 'b' is also tested.\r\n        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\r\n        if (a == 0) {\r\n            return 0;\r\n        }\r\n\r\n        uint256 c = a * b;\r\n        require(c / a == b, \"SafeMath: multiplication overflow\");\r\n\r\n        return c;\r\n    }\r\n\r\n    /**\r\n     * @dev Returns the integer division of two unsigned integers. Reverts on\r\n     * division by zero. The result is rounded towards zero.\r\n     *\r\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\r\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\r\n     * uses an invalid opcode to revert (consuming all remaining gas).\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - The divisor cannot be zero.\r\n     */\r\n    function div(uint256 a, uint256 b) internal pure returns (uint256) {\r\n        return div(a, b, \"SafeMath: division by zero\");\r\n    }\r\n\r\n    /**\r\n     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on\r\n     * division by zero. The result is rounded towards zero.\r\n     *\r\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\r\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\r\n     * uses an invalid opcode to revert (consuming all remaining gas).\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - The divisor cannot be zero.\r\n     */\r\n    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\r\n        require(b > 0, errorMessage);\r\n        uint256 c = a / b;\r\n        // assert(a == b * c + a % b); // There is no case in which this doesn't hold\r\n\r\n        return c;\r\n    }\r\n\r\n    /**\r\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r\n     * Reverts when dividing by zero.\r\n     *\r\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\r\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\r\n     * invalid opcode to revert (consuming all remaining gas).\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - The divisor cannot be zero.\r\n     */\r\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\r\n        return mod(a, b, \"SafeMath: modulo by zero\");\r\n    }\r\n\r\n    /**\r\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r\n     * Reverts with custom message when dividing by zero.\r\n     *\r\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\r\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\r\n     * invalid opcode to revert (consuming all remaining gas).\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - The divisor cannot be zero.\r\n     */\r\n    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\r\n        require(b != 0, errorMessage);\r\n        return a % b;\r\n    }\r\n}\r\n\r\ncontract Ownable is Context {\r\n    address private _owner;\r\n\r\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\r\n    \r\n    /**\r\n     * @dev Initializes the contract setting the deployer as the initial owner.\r\n     */\r\n    constructor () {\r\n        address msgSender = _msgSender();\r\n        _owner = msgSender;\r\n        emit OwnershipTransferred(address(0), msgSender);\r\n    }\r\n\r\n    /**\r\n     * @dev Returns the address of the current owner.\r\n     */\r\n    function owner() public view returns (address) {\r\n        return _owner;\r\n    }\r\n\r\n    /**\r\n     * @dev Throws if called by any account other than the owner.\r\n     */\r\n    modifier onlyOwner() {\r\n        require(_owner == _msgSender(), \"Ownable: caller is not the owner\");\r\n        _;\r\n    }\r\n\r\n    /**\r\n     * @dev Leaves the contract without owner. It will not be possible to call\r\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\r\n     *\r\n     * NOTE: Renouncing ownership will leave the contract without an owner,\r\n     * thereby removing any functionality that is only available to the owner.\r\n     */\r\n    function renounceOwnership() public virtual onlyOwner {\r\n        emit OwnershipTransferred(_owner, address(0));\r\n        _owner = address(0);\r\n    }\r\n\r\n    /**\r\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\r\n     * Can only be called by the current owner.\r\n     */\r\n    function transferOwnership(address newOwner) public virtual onlyOwner {\r\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\r\n        emit OwnershipTransferred(_owner, newOwner);\r\n        _owner = newOwner;\r\n    }\r\n}\r\n\r\n\r\n\r\nlibrary SafeMathInt {\r\n    int256 private constant MIN_INT256 = int256(1) << 255;\r\n    int256 private constant MAX_INT256 = ~(int256(1) << 255);\r\n\r\n    /**\r\n     * @dev Multiplies two int256 variables and fails on overflow.\r\n     */\r\n    function mul(int256 a, int256 b) internal pure returns (int256) {\r\n        int256 c = a * b;\r\n\r\n        // Detect overflow when multiplying MIN_INT256 with -1\r\n        require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));\r\n        require((b == 0) || (c / b == a));\r\n        return c;\r\n    }\r\n\r\n    /**\r\n     * @dev Division of two int256 variables and fails on overflow.\r\n     */\r\n    function div(int256 a, int256 b) internal pure returns (int256) {\r\n        // Prevent overflow when dividing MIN_INT256 by -1\r\n        require(b != -1 || a != MIN_INT256);\r\n\r\n        // Solidity already throws when dividing by 0.\r\n        return a / b;\r\n    }\r\n\r\n    /**\r\n     * @dev Subtracts two int256 variables and fails on overflow.\r\n     */\r\n    function sub(int256 a, int256 b) internal pure returns (int256) {\r\n        int256 c = a - b;\r\n        require((b >= 0 && c <= a) || (b < 0 && c > a));\r\n        return c;\r\n    }\r\n\r\n    /**\r\n     * @dev Adds two int256 variables and fails on overflow.\r\n     */\r\n    function add(int256 a, int256 b) internal pure returns (int256) {\r\n        int256 c = a + b;\r\n        require((b >= 0 && c >= a) || (b < 0 && c < a));\r\n        return c;\r\n    }\r\n\r\n    /**\r\n     * @dev Converts to absolute value, and fails on overflow.\r\n     */\r\n    function abs(int256 a) internal pure returns (int256) {\r\n        require(a != MIN_INT256);\r\n        return a < 0 ? -a : a;\r\n    }\r\n\r\n\r\n    function toUint256Safe(int256 a) internal pure returns (uint256) {\r\n        require(a >= 0);\r\n        return uint256(a);\r\n    }\r\n}\r\n\r\nlibrary SafeMathUint {\r\n  function toInt256Safe(uint256 a) internal pure returns (int256) {\r\n    int256 b = int256(a);\r\n    require(b >= 0);\r\n    return b;\r\n  }\r\n}\r\n\r\n\r\ninterface IUniswapV2Router01 {\r\n    function factory() external pure returns (address);\r\n    function WETH() external pure returns (address);\r\n\r\n    function addLiquidity(\r\n        address tokenA,\r\n        address tokenB,\r\n        uint amountADesired,\r\n        uint amountBDesired,\r\n        uint amountAMin,\r\n        uint amountBMin,\r\n        address to,\r\n        uint deadline\r\n    ) external returns (uint amountA, uint amountB, uint liquidity);\r\n    function addLiquidityETH(\r\n        address token,\r\n        uint amountTokenDesired,\r\n        uint amountTokenMin,\r\n        uint amountETHMin,\r\n        address to,\r\n        uint deadline\r\n    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\r\n    function removeLiquidity(\r\n        address tokenA,\r\n        address tokenB,\r\n        uint liquidity,\r\n        uint amountAMin,\r\n        uint amountBMin,\r\n        address to,\r\n        uint deadline\r\n    ) external returns (uint amountA, uint amountB);\r\n    function removeLiquidityETH(\r\n        address token,\r\n        uint liquidity,\r\n        uint amountTokenMin,\r\n        uint amountETHMin,\r\n        address to,\r\n        uint deadline\r\n    ) external returns (uint amountToken, uint amountETH);\r\n    function removeLiquidityWithPermit(\r\n        address tokenA,\r\n        address tokenB,\r\n        uint liquidity,\r\n        uint amountAMin,\r\n        uint amountBMin,\r\n        address to,\r\n        uint deadline,\r\n        bool approveMax, uint8 v, bytes32 r, bytes32 s\r\n    ) external returns (uint amountA, uint amountB);\r\n    function removeLiquidityETHWithPermit(\r\n        address token,\r\n        uint liquidity,\r\n        uint amountTokenMin,\r\n        uint amountETHMin,\r\n        address to,\r\n        uint deadline,\r\n        bool approveMax, uint8 v, bytes32 r, bytes32 s\r\n    ) external returns (uint amountToken, uint amountETH);\r\n    function swapExactTokensForTokens(\r\n        uint amountIn,\r\n        uint amountOutMin,\r\n        address[] calldata path,\r\n        address to,\r\n        uint deadline\r\n    ) external returns (uint[] memory amounts);\r\n    function swapTokensForExactTokens(\r\n        uint amountOut,\r\n        uint amountInMax,\r\n        address[] calldata path,\r\n        address to,\r\n        uint deadline\r\n    ) external returns (uint[] memory amounts);\r\n    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\r\n        external\r\n        payable\r\n        returns (uint[] memory amounts);\r\n    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\r\n        external\r\n        returns (uint[] memory amounts);\r\n    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\r\n        external\r\n        returns (uint[] memory amounts);\r\n    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\r\n        external\r\n        payable\r\n        returns (uint[] memory amounts);\r\n\r\n    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\r\n    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\r\n    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\r\n    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\r\n    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\r\n}\r\n\r\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\r\n    function removeLiquidityETHSupportingFeeOnTransferTokens(\r\n        address token,\r\n        uint liquidity,\r\n        uint amountTokenMin,\r\n        uint amountETHMin,\r\n        address to,\r\n        uint deadline\r\n    ) external returns (uint amountETH);\r\n    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\r\n        address token,\r\n        uint liquidity,\r\n        uint amountTokenMin,\r\n        uint amountETHMin,\r\n        address to,\r\n        uint deadline,\r\n        bool approveMax, uint8 v, bytes32 r, bytes32 s\r\n    ) external returns (uint amountETH);\r\n\r\n    function swapExactTokensForTokensSupportingFeeOnTransferTokens(\r\n        uint amountIn,\r\n        uint amountOutMin,\r\n        address[] calldata path,\r\n        address to,\r\n        uint deadline\r\n    ) external;\r\n    function swapExactETHForTokensSupportingFeeOnTransferTokens(\r\n        uint amountOutMin,\r\n        address[] calldata path,\r\n        address to,\r\n        uint deadline\r\n    ) external payable;\r\n    function swapExactTokensForETHSupportingFeeOnTransferTokens(\r\n        uint amountIn,\r\n        uint amountOutMin,\r\n        address[] calldata path,\r\n        address to,\r\n        uint deadline\r\n    ) external;\r\n}\r\n\r\ncontract DividendPayingToken is DividendPayingTokenInterface, DividendPayingTokenOptionalInterface, Ownable {\r\n  using SafeMath for uint256;\r\n  using SafeMathUint for uint256;\r\n  using SafeMathInt for int256;\r\n\r\n  // With `magnitude`, we can properly distribute dividends even if the amount of received ether is small.\r\n  // For more discussion about choosing the value of `magnitude`,\r\n  //  see https://github.com/ethereum/EIPs/issues/1726#issuecomment-472352728\r\n  uint256 constant internal magnitude = 2**128;\r\n\r\n  mapping(address => uint256) internal magnifiedDividendPerShare;\r\n  address[] public rewardTokens;\r\n  address public nextRewardToken;\r\n  uint256 public rewardTokenCounter;\r\n  \r\n  IUniswapV2Router02 public immutable uniswapV2Router;\r\n  \r\n  \r\n  // About dividendCorrection:\r\n  // If the token balance of a `_user` is never changed, the dividend of `_user` can be computed with:\r\n  //   `dividendOf(_user) = dividendPerShare * balanceOf(_user)`.\r\n  // When `balanceOf(_user)` is changed (via minting/burning/transferring tokens),\r\n  //   `dividendOf(_user)` should not be changed,\r\n  //   but the computed value of `dividendPerShare * balanceOf(_user)` is changed.\r\n  // To keep the `dividendOf(_user)` unchanged, we add a correction term:\r\n  //   `dividendOf(_user) = dividendPerShare * balanceOf(_user) + dividendCorrectionOf(_user)`,\r\n  //   where `dividendCorrectionOf(_user)` is updated whenever `balanceOf(_user)` is changed:\r\n  //   `dividendCorrectionOf(_user) = dividendPerShare * (old balanceOf(_user)) - (new balanceOf(_user))`.\r\n  // So now `dividendOf(_user)` returns the same value before and after `balanceOf(_user)` is changed.\r\n  mapping(address => mapping(address => int256)) internal magnifiedDividendCorrections;\r\n  mapping(address => mapping(address => uint256)) internal withdrawnDividends;\r\n  \r\n  mapping (address => uint256) public holderBalance;\r\n  uint256 public totalBalance;\r\n\r\n  mapping(address => uint256) public totalDividendsDistributed;\r\n  \r\n  constructor(){\r\n      IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); // router 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\r\n      uniswapV2Router = _uniswapV2Router; \r\n      \r\n      // Mainnet\r\n\r\n      rewardTokens.push(address(0xae78736Cd615f374D3085123A210448E74Fc6393)); // rETH - 0xae78736Cd615f374D3085123A210448E74Fc6393\r\n      \r\n      nextRewardToken = rewardTokens[0];\r\n  }\r\n\r\n  \r\n\r\n  /// @dev Distributes dividends whenever ether is paid to this contract.\r\n  receive() external payable {\r\n    distributeDividends();\r\n  }\r\n\r\n  /// @notice Distributes ether to token holders as dividends.\r\n  /// @dev It reverts if the total supply of tokens is 0.\r\n  /// It emits the `DividendsDistributed` event if the amount of received ether is greater than 0.\r\n  /// About undistributed ether:\r\n  ///   In each distribution, there is a small amount of ether not distributed,\r\n  ///     the magnified amount of which is\r\n  ///     `(msg.value * magnitude) % totalSupply()`.\r\n  ///   With a well-chosen `magnitude`, the amount of undistributed ether\r\n  ///     (de-magnified) in a distribution can be less than 1 wei.\r\n  ///   We can actually keep track of the undistributed ether in a distribution\r\n  ///     and try to distribute it in the next distribution,\r\n  ///     but keeping track of such data on-chain costs much more than\r\n  ///     the saved ether, so we don't do that.\r\n    \r\n  function distributeDividends() public override payable { \r\n    require(totalBalance > 0);\r\n    uint256 initialBalance = IERC20(nextRewardToken).balanceOf(address(this));\r\n    buyTokens(msg.value, nextRewardToken);\r\n    uint256 newBalance = IERC20(nextRewardToken).balanceOf(address(this)).sub(initialBalance);\r\n    if (newBalance > 0) {\r\n      magnifiedDividendPerShare[nextRewardToken] = magnifiedDividendPerShare[nextRewardToken].add(\r\n        (newBalance).mul(magnitude) / totalBalance\r\n      );\r\n      emit DividendsDistributed(msg.sender, newBalance);\r\n\r\n      totalDividendsDistributed[nextRewardToken] = totalDividendsDistributed[nextRewardToken].add(newBalance);\r\n    }\r\n    rewardTokenCounter = rewardTokenCounter == rewardTokens.length - 1 ? 0 : rewardTokenCounter + 1;\r\n    nextRewardToken = rewardTokens[rewardTokenCounter];\r\n  }\r\n  \r\n  // useful for buybacks or to reclaim any BNB on the contract in a way that helps holders.\r\n    function buyTokens(uint256 bnbAmountInWei, address rewardToken) internal {\r\n        // generate the uniswap pair path of weth -> eth\r\n        address[] memory path = new address[](2);\r\n        path[0] = uniswapV2Router.WETH();\r\n        path[1] = rewardToken;\r\n\r\n        // make the swap\r\n        uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: bnbAmountInWei}(\r\n            0, // accept any amount of Ethereum\r\n            path,\r\n            address(this),\r\n            block.timestamp\r\n        );\r\n    }\r\n  \r\n  /// @notice Withdraws the ether distributed to the sender.\r\n  /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0.\r\n  function withdrawDividend(address _rewardToken) external virtual override {\r\n    _withdrawDividendOfUser(payable(msg.sender), _rewardToken);\r\n  }\r\n\r\n  /// @notice Withdraws the ether distributed to the sender.\r\n  /// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0.\r\n  function _withdrawDividendOfUser(address payable user, address _rewardToken) internal returns (uint256) {\r\n    uint256 _withdrawableDividend = withdrawableDividendOf(user, _rewardToken);\r\n    if (_withdrawableDividend > 0) {\r\n      withdrawnDividends[user][_rewardToken] = withdrawnDividends[user][_rewardToken].add(_withdrawableDividend);\r\n      emit DividendWithdrawn(user, _withdrawableDividend);\r\n      IERC20(_rewardToken).transfer(user, _withdrawableDividend);\r\n      return _withdrawableDividend;\r\n    }\r\n\r\n    return 0;\r\n  }\r\n\r\n\r\n  /// @notice View the amount of dividend in wei that an address can withdraw.\r\n  /// @param _owner The address of a token holder.\r\n  /// @return The amount of dividend in wei that `_owner` can withdraw.\r\n  function dividendOf(address _owner, address _rewardToken) external view override returns(uint256) {\r\n    return withdrawableDividendOf(_owner, _rewardToken);\r\n  }\r\n\r\n  /// @notice View the amount of dividend in wei that an address can withdraw.\r\n  /// @param _owner The address of a token holder.\r\n  /// @return The amount of dividend in wei that `_owner` can withdraw.\r\n  function withdrawableDividendOf(address _owner, address _rewardToken) public view override returns(uint256) {\r\n    return accumulativeDividendOf(_owner,_rewardToken).sub(withdrawnDividends[_owner][_rewardToken]);\r\n  }\r\n\r\n  /// @notice View the amount of dividend in wei that an address has withdrawn.\r\n  /// @param _owner The address of a token holder.\r\n  /// @return The amount of dividend in wei that `_owner` has withdrawn.\r\n  function withdrawnDividendOf(address _owner, address _rewardToken) external view override returns(uint256) {\r\n    return withdrawnDividends[_owner][_rewardToken];\r\n  }\r\n\r\n\r\n  /// @notice View the amount of dividend in wei that an address has earned in total.\r\n  /// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner)\r\n  /// = (magnifiedDividendPerShare * balanceOf(_owner) + magnifiedDividendCorrections[_owner]) / magnitude\r\n  /// @param _owner The address of a token holder.\r\n  /// @return The amount of dividend in wei that `_owner` has earned in total.\r\n  function accumulativeDividendOf(address _owner, address _rewardToken) public view override returns(uint256) {\r\n    return magnifiedDividendPerShare[_rewardToken].mul(holderBalance[_owner]).toInt256Safe()\r\n      .add(magnifiedDividendCorrections[_rewardToken][_owner]).toUint256Safe() / magnitude;\r\n  }\r\n\r\n  /// @dev Internal function that increases tokens to an account.\r\n  /// Update magnifiedDividendCorrections to keep dividends unchanged.\r\n  /// @param account The account that will receive the created tokens.\r\n  /// @param value The amount that will be created.\r\n  function _increase(address account, uint256 value) internal {\r\n    for (uint256 i; i < rewardTokens.length; i++){\r\n        magnifiedDividendCorrections[rewardTokens[i]][account] = magnifiedDividendCorrections[rewardTokens[i]][account]\r\n          .sub((magnifiedDividendPerShare[rewardTokens[i]].mul(value)).toInt256Safe());\r\n    }\r\n  }\r\n\r\n  /// @dev Internal function that reduces an amount of the token of a given account.\r\n  /// Update magnifiedDividendCorrections to keep dividends unchanged.\r\n  /// @param account The account whose tokens will be burnt.\r\n  /// @param value The amount that will be burnt.\r\n  function _reduce(address account, uint256 value) internal {\r\n      for (uint256 i; i < rewardTokens.length; i++){\r\n        magnifiedDividendCorrections[rewardTokens[i]][account] = magnifiedDividendCorrections[rewardTokens[i]][account]\r\n          .add( (magnifiedDividendPerShare[rewardTokens[i]].mul(value)).toInt256Safe() );\r\n      }\r\n  }\r\n\r\n  function _setBalance(address account, uint256 newBalance) internal {\r\n    uint256 currentBalance = holderBalance[account];\r\n    holderBalance[account] = newBalance;\r\n    if(newBalance > currentBalance) {\r\n      uint256 increaseAmount = newBalance.sub(currentBalance);\r\n      _increase(account, increaseAmount);\r\n      totalBalance += increaseAmount;\r\n    } else if(newBalance < currentBalance) {\r\n      uint256 reduceAmount = currentBalance.sub(newBalance);\r\n      _reduce(account, reduceAmount);\r\n      totalBalance -= reduceAmount;\r\n    }\r\n  }\r\n}\r\n\r\ncontract DividendTracker is DividendPayingToken {\r\n    using SafeMath for uint256;\r\n    using SafeMathInt for int256;\r\n\r\n    struct Map {\r\n        address[] keys;\r\n        mapping(address => uint) values;\r\n        mapping(address => uint) indexOf;\r\n        mapping(address => bool) inserted;\r\n    }\r\n\r\n    function get(address key) private view returns (uint) {\r\n        return tokenHoldersMap.values[key];\r\n    }\r\n\r\n    function getIndexOfKey(address key) private view returns (int) {\r\n        if(!tokenHoldersMap.inserted[key]) {\r\n            return -1;\r\n        }\r\n        return int(tokenHoldersMap.indexOf[key]);\r\n    }\r\n\r\n    function getKeyAtIndex(uint index) private view returns (address) {\r\n        return tokenHoldersMap.keys[index];\r\n    }\r\n\r\n\r\n\r\n    function size() private view returns (uint) {\r\n        return tokenHoldersMap.keys.length;\r\n    }\r\n\r\n    function set(address key, uint val) private {\r\n        if (tokenHoldersMap.inserted[key]) {\r\n            tokenHoldersMap.values[key] = val;\r\n        } else {\r\n            tokenHoldersMap.inserted[key] = true;\r\n            tokenHoldersMap.values[key] = val;\r\n            tokenHoldersMap.indexOf[key] = tokenHoldersMap.keys.length;\r\n            tokenHoldersMap.keys.push(key);\r\n        }\r\n    }\r\n\r\n    function remove(address key) private {\r\n        if (!tokenHoldersMap.inserted[key]) {\r\n            return;\r\n        }\r\n\r\n        delete tokenHoldersMap.inserted[key];\r\n        delete tokenHoldersMap.values[key];\r\n\r\n        uint index = tokenHoldersMap.indexOf[key];\r\n        uint lastIndex = tokenHoldersMap.keys.length - 1;\r\n        address lastKey = tokenHoldersMap.keys[lastIndex];\r\n\r\n        tokenHoldersMap.indexOf[lastKey] = index;\r\n        delete tokenHoldersMap.indexOf[key];\r\n\r\n        tokenHoldersMap.keys[index] = lastKey;\r\n        tokenHoldersMap.keys.pop();\r\n    }\r\n\r\n    Map private tokenHoldersMap;\r\n    uint256 public lastProcessedIndex;\r\n\r\n    mapping (address => bool) public excludedFromDividends;\r\n\r\n    mapping (address => uint256) public lastClaimTimes;\r\n\r\n    uint256 public claimWait;\r\n    uint256 public immutable minimumTokenBalanceForDividends;\r\n\r\n    event ExcludeFromDividends(address indexed account);\r\n    event IncludeInDividends(address indexed account);\r\n    event ClaimWaitUpdated(uint256 indexed newValue, uint256 indexed oldValue);\r\n\r\n    event Claim(address indexed account, uint256 amount, bool indexed automatic);\r\n\r\n    constructor() {\r\n    \tclaimWait = 1200;\r\n        minimumTokenBalanceForDividends = 1000 * (10**18);\r\n    }\r\n\r\n    function excludeFromDividends(address account) external onlyOwner {\r\n    \texcludedFromDividends[account] = true;\r\n\r\n    \t_setBalance(account, 0);\r\n    \tremove(account);\r\n\r\n    \temit ExcludeFromDividends(account);\r\n    }\r\n    \r\n    function includeInDividends(address account) external onlyOwner {\r\n    \trequire(excludedFromDividends[account]);\r\n    \texcludedFromDividends[account] = false;\r\n\r\n    \temit IncludeInDividends(account);\r\n    }\r\n\r\n    function updateClaimWait(uint256 newClaimWait) external onlyOwner {\r\n        require(newClaimWait >= 1200 && newClaimWait <= 86400, \"Dividend_Tracker: claimWait must be updated to between 1 and 24 hours\");\r\n        require(newClaimWait != claimWait, \"Dividend_Tracker: Cannot update claimWait to same value\");\r\n        emit ClaimWaitUpdated(newClaimWait, claimWait);\r\n        claimWait = newClaimWait;\r\n    }\r\n\r\n    function getLastProcessedIndex() external view returns(uint256) {\r\n    \treturn lastProcessedIndex;\r\n    }\r\n\r\n    function getNumberOfTokenHolders() external view returns(uint256) {\r\n        return tokenHoldersMap.keys.length;\r\n    }\r\n\r\n    // Check to see if I really made this contract or if it is a clone!\r\n\r\n    function getAccount(address _account, address _rewardToken)\r\n        public view returns (\r\n            address account,\r\n            int256 index,\r\n            int256 iterationsUntilProcessed,\r\n            uint256 withdrawableDividends,\r\n            uint256 totalDividends,\r\n            uint256 lastClaimTime,\r\n            uint256 nextClaimTime,\r\n            uint256 secondsUntilAutoClaimAvailable) {\r\n        account = _account;\r\n\r\n        index = getIndexOfKey(account);\r\n\r\n        iterationsUntilProcessed = -1;\r\n\r\n        if(index >= 0) {\r\n            if(uint256(index) > lastProcessedIndex) {\r\n                iterationsUntilProcessed = index.sub(int256(lastProcessedIndex));\r\n            }\r\n            else {\r\n                uint256 processesUntilEndOfArray = tokenHoldersMap.keys.length > lastProcessedIndex ?\r\n                                                        tokenHoldersMap.keys.length.sub(lastProcessedIndex) :\r\n                                                        0;\r\n\r\n\r\n                iterationsUntilProcessed = index.add(int256(processesUntilEndOfArray));\r\n            }\r\n        }\r\n\r\n\r\n        withdrawableDividends = withdrawableDividendOf(account, _rewardToken);\r\n        totalDividends = accumulativeDividendOf(account, _rewardToken);\r\n\r\n        lastClaimTime = lastClaimTimes[account];\r\n\r\n        nextClaimTime = lastClaimTime > 0 ?\r\n                                    lastClaimTime.add(claimWait) :\r\n                                    0;\r\n\r\n        secondsUntilAutoClaimAvailable = nextClaimTime > block.timestamp ?\r\n                                                    nextClaimTime.sub(block.timestamp) :\r\n                                                    0;\r\n    }\r\n\r\n    function getAccountAtIndex(uint256 index, address _rewardToken)\r\n        external view returns (\r\n            address,\r\n            int256,\r\n            int256,\r\n            uint256,\r\n            uint256,\r\n            uint256,\r\n            uint256,\r\n            uint256) {\r\n    \tif(index >= size()) {\r\n            return (0x0000000000000000000000000000000000000000, -1, -1, 0, 0, 0, 0, 0);\r\n        }\r\n\r\n        address account = getKeyAtIndex(index);\r\n\r\n        return getAccount(account, _rewardToken);\r\n    }\r\n\r\n    function canAutoClaim(uint256 lastClaimTime) private view returns (bool) {\r\n    \tif(lastClaimTime > block.timestamp)  {\r\n    \t\treturn false;\r\n    \t}\r\n\r\n    \treturn block.timestamp.sub(lastClaimTime) >= claimWait;\r\n    }\r\n\r\n    function setBalance(address payable account, uint256 newBalance) external onlyOwner {\r\n    \tif(excludedFromDividends[account]) {\r\n    \t\treturn;\r\n    \t}\r\n\r\n    \tif(newBalance >= minimumTokenBalanceForDividends) {\r\n            _setBalance(account, newBalance);\r\n    \t\tset(account, newBalance);\r\n    \t}\r\n    \telse {\r\n            _setBalance(account, 0);\r\n    \t\tremove(account);\r\n    \t}\r\n\r\n    \tprocessAccount(account, true);\r\n    }\r\n    \r\n    function process(uint256 gas) external returns (uint256, uint256, uint256) {\r\n    \tuint256 numberOfTokenHolders = tokenHoldersMap.keys.length;\r\n\r\n    \tif(numberOfTokenHolders == 0) {\r\n    \t\treturn (0, 0, lastProcessedIndex);\r\n    \t}\r\n\r\n    \tuint256 _lastProcessedIndex = lastProcessedIndex;\r\n\r\n    \tuint256 gasUsed = 0;\r\n\r\n    \tuint256 gasLeft = gasleft();\r\n\r\n    \tuint256 iterations = 0;\r\n    \tuint256 claims = 0;\r\n\r\n    \twhile(gasUsed < gas && iterations < numberOfTokenHolders) {\r\n    \t\t_lastProcessedIndex++;\r\n\r\n    \t\tif(_lastProcessedIndex >= tokenHoldersMap.keys.length) {\r\n    \t\t\t_lastProcessedIndex = 0;\r\n    \t\t}\r\n\r\n    \t\taddress account = tokenHoldersMap.keys[_lastProcessedIndex];\r\n\r\n    \t\tif(canAutoClaim(lastClaimTimes[account])) {\r\n    \t\t\tif(processAccount(payable(account), true)) {\r\n    \t\t\t\tclaims++;\r\n    \t\t\t}\r\n    \t\t}\r\n\r\n    \t\titerations++;\r\n\r\n    \t\tuint256 newGasLeft = gasleft();\r\n\r\n    \t\tif(gasLeft > newGasLeft) {\r\n    \t\t\tgasUsed = gasUsed.add(gasLeft.sub(newGasLeft));\r\n    \t\t}\r\n    \t\tgasLeft = newGasLeft;\r\n    \t}\r\n\r\n    \tlastProcessedIndex = _lastProcessedIndex;\r\n\r\n    \treturn (iterations, claims, lastProcessedIndex);\r\n    }\r\n\r\n    function processAccount(address payable account, bool automatic) public onlyOwner returns (bool) {\r\n        uint256 amount;\r\n        bool paid;\r\n        for (uint256 i; i < rewardTokens.length; i++){\r\n            amount = _withdrawDividendOfUser(account, rewardTokens[i]);\r\n            if(amount > 0) {\r\n        \t\tlastClaimTimes[account] = block.timestamp;\r\n                emit Claim(account, amount, automatic);\r\n                paid = true;\r\n    \t    }\r\n        }\r\n        return paid;\r\n    }\r\n}\r\n\r\ncontract IZANAGI is ERC20, Ownable {\r\n    using SafeMath for uint256;\r\n\r\n    IUniswapV2Router02 public immutable uniswapV2Router;\r\n    address public immutable uniswapV2Pair;\r\n\r\n    bool private swapping;\r\n\r\n    DividendTracker public dividendTracker;\r\n\r\n    address public operationsWallet;\r\n    \r\n    uint256 public maxTransactionAmount;\r\n    uint256 public swapTokensAtAmount;\r\n    uint256 public maxWallet;\r\n    \r\n    uint256 public liquidityActiveBlock = 0; // 0 means liquidity is not active yet\r\n    uint256 public tradingActiveBlock = 0; // 0 means trading is not active\r\n    uint256 public earlyBuyPenaltyEnd; // determines when snipers/bots can sell without extra penalty\r\n    \r\n    bool public limitsInEffect = true;\r\n    bool public tradingActive = false;\r\n    bool public swapEnabled = false;\r\n    \r\n     // Anti-bot and anti-whale mappings and variables\r\n    mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch\r\n    bool public transferDelayEnabled = true;\r\n    \r\n    uint256 public constant feeDivisor = 1000;\r\n\r\n    uint256 public totalSellFees;\r\n    uint256 public rewardsSellFee;\r\n    uint256 public operationsSellFee;\r\n    uint256 public liquiditySellFee;\r\n    \r\n    uint256 public totalBuyFees;\r\n    uint256 public rewardsBuyFee;\r\n    uint256 public operationsBuyFee;\r\n    uint256 public liquidityBuyFee;\r\n    \r\n    uint256 public tokensForRewards;\r\n    uint256 public tokensForOperations;\r\n    uint256 public tokensForLiquidity;\r\n    \r\n    uint256 public gasForProcessing = 0;\r\n\r\n    uint256 public lpWithdrawRequestTimestamp;\r\n    uint256 public lpWithdrawRequestDuration = 3 days;\r\n    bool public lpWithdrawRequestPending;\r\n    uint256 public lpPercToWithDraw;\r\n\r\n    /******************/\r\n\r\n    // exlcude from fees and max transaction amount\r\n    mapping (address => bool) private _isExcludedFromFees;\r\n\r\n    mapping (address => bool) public _isExcludedMaxTransactionAmount;\r\n\r\n    // store addresses that a automatic market maker pairs. Any transfer *to* these addresses\r\n    // could be subject to a maximum transfer amount\r\n    mapping (address => bool) public automatedMarketMakerPairs;\r\n\r\n    event ExcludeFromFees(address indexed account, bool isExcluded);\r\n    event ExcludeMultipleAccountsFromFees(address[] accounts, bool isExcluded);\r\n    event ExcludedMaxTransactionAmount(address indexed account, bool isExcluded);\r\n\r\n    event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);\r\n\r\n    event OperationsWalletUpdated(address indexed newWallet, address indexed oldWallet);\r\n\r\n    event DevWalletUpdated(address indexed newWallet, address indexed oldWallet);\r\n\r\n    event GasForProcessingUpdated(uint256 indexed newValue, uint256 indexed oldValue);\r\n    \r\n    event SwapAndLiquify(\r\n        uint256 tokensSwapped,\r\n        uint256 ethReceived,\r\n        uint256 tokensIntoLiqudity\r\n    );\r\n\r\n    event SendDividends(\r\n    \tuint256 tokensSwapped,\r\n    \tuint256 amount\r\n    );\r\n\r\n    event ProcessedDividendTracker(\r\n    \tuint256 iterations,\r\n    \tuint256 claims,\r\n        uint256 lastProcessedIndex,\r\n    \tbool indexed automatic,\r\n    \tuint256 gas,\r\n    \taddress indexed processor\r\n    );\r\n\r\n    event RequestedLPWithdraw();\r\n    \r\n    event WithdrewLPForMigration();\r\n\r\n    event CanceledLpWithdrawRequest();\r\n\r\n    constructor() ERC20(\"Izanagi Protcol\", \"Izanagi\") {\r\n\r\n        uint256 totalSupply = 100 * 1e6 * 1e18;\r\n        \r\n        maxTransactionAmount = totalSupply * 5 / 1000; // 0.5% maxTransactionAmountTxn\r\n        swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swap tokens amount\r\n        maxWallet = totalSupply * 5 / 1000; // 0.5% Max wallet\r\n\r\n        rewardsBuyFee = 20;\r\n        operationsBuyFee = 20;\r\n        liquidityBuyFee = 0;\r\n        totalBuyFees = rewardsBuyFee + operationsBuyFee + liquidityBuyFee;\r\n        \r\n        rewardsSellFee = 20;\r\n        operationsSellFee = 20;\r\n        liquiditySellFee = 0;\r\n        totalSellFees = rewardsSellFee + operationsSellFee + liquiditySellFee;\r\n\r\n    \tdividendTracker = new DividendTracker();\r\n    \t\r\n    \toperationsWallet = address(msg.sender); // set as operations wallet\r\n\r\n    \tIUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);//0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\r\n    \t\r\n         // Create a uniswap pair for this new token\r\n        address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())\r\n            .createPair(address(this), _uniswapV2Router.WETH());\r\n\r\n        uniswapV2Router = _uniswapV2Router;\r\n        uniswapV2Pair = _uniswapV2Pair;\r\n\r\n        _setAutomatedMarketMakerPair(_uniswapV2Pair, true);\r\n\r\n        // exclude from receiving dividends\r\n        dividendTracker.excludeFromDividends(address(dividendTracker));\r\n        dividendTracker.excludeFromDividends(address(this));\r\n        dividendTracker.excludeFromDividends(owner());\r\n        dividendTracker.excludeFromDividends(address(_uniswapV2Router));\r\n        dividendTracker.excludeFromDividends(address(0xdead));\r\n        \r\n        // exclude from paying fees or having max transaction amount\r\n        excludeFromFees(owner(), true);\r\n        excludeFromFees(address(this), true);\r\n        excludeFromFees(address(0xdead), true);\r\n        excludeFromMaxTransaction(owner(), true);\r\n        excludeFromMaxTransaction(address(this), true);\r\n        excludeFromMaxTransaction(address(dividendTracker), true);\r\n        excludeFromMaxTransaction(address(_uniswapV2Router), true);\r\n        excludeFromMaxTransaction(address(0xdead), true);\r\n\r\n        _createInitialSupply(address(owner()), totalSupply);\r\n    }\r\n\r\n    receive() external payable {\r\n\r\n  \t}\r\n\r\n    // only use if conducting a presale\r\n    function addPresaleAddressForExclusions(address _presaleAddress) external onlyOwner {\r\n        excludeFromFees(_presaleAddress, true);\r\n        dividendTracker.excludeFromDividends(_presaleAddress);\r\n        excludeFromMaxTransaction(_presaleAddress, true);\r\n    }\r\n\r\n     // disable Transfer delay - cannot be reenabled\r\n    function disableTransferDelay() external onlyOwner returns (bool){\r\n        transferDelayEnabled = false;\r\n        return true;\r\n    }\r\n\r\n    // excludes wallets and contracts from dividends (such as CEX hotwallets, etc.)\r\n    function excludeFromDividends(address account) external onlyOwner {\r\n        dividendTracker.excludeFromDividends(account);\r\n    }\r\n\r\n    // removes exclusion on wallets and contracts from dividends (such as CEX hotwallets, etc.)\r\n    function includeInDividends(address account) external onlyOwner {\r\n        dividendTracker.includeInDividends(account);\r\n    }\r\n    \r\n    // once enabled, can never be turned off\r\n    function enableTrading() external onlyOwner {\r\n        require(!tradingActive, \"Cannot re-enable trading\");\r\n        tradingActive = true;\r\n        swapEnabled = true;\r\n        tradingActiveBlock = block.number;\r\n    }\r\n    \r\n    // only use to disable contract sales if absolutely necessary (emergency use only)\r\n    function updateSwapEnabled(bool enabled) external onlyOwner(){\r\n        swapEnabled = enabled;\r\n    }\r\n\r\n    function updateMaxAmount(uint256 newNum) external onlyOwner {\r\n        require(newNum > (totalSupply() * 1 / 1000)/1e18, \"Cannot set maxTransactionAmount lower than 0.1%\");\r\n        maxTransactionAmount = newNum * (10**18);\r\n    }\r\n    \r\n    function updateMaxWalletAmount(uint256 newNum) external onlyOwner {\r\n        require(newNum > (totalSupply() * 1 / 100)/1e18, \"Cannot set maxWallet lower than 1%\");\r\n        maxWallet = newNum * (10**18);\r\n    }\r\n    \r\n    function updateBuyFees(uint256 _operationsFee, uint256 _rewardsFee, uint256 _liquidityFee) external onlyOwner {\r\n        operationsBuyFee = _operationsFee;\r\n        rewardsBuyFee = _rewardsFee;\r\n        liquidityBuyFee = _liquidityFee;\r\n        totalBuyFees = operationsBuyFee + rewardsBuyFee + liquidityBuyFee;\r\n        require(totalBuyFees <= 100, \"Must keep fees at 10% or less\");\r\n    }\r\n    \r\n    function updateSellFees(uint256 _operationsFee, uint256 _rewardsFee, uint256 _liquidityFee) external onlyOwner {\r\n        operationsSellFee = _operationsFee;\r\n        rewardsSellFee = _rewardsFee;\r\n        liquiditySellFee = _liquidityFee;\r\n        totalSellFees = operationsSellFee + rewardsSellFee + liquiditySellFee;\r\n        require(totalSellFees <= 100, \"Must keep fees at 10% or less\");\r\n    }\r\n\r\n    function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner {\r\n        _isExcludedMaxTransactionAmount[updAds] = isEx;\r\n        emit ExcludedMaxTransactionAmount(updAds, isEx);\r\n    }\r\n\r\n    function excludeFromFees(address account, bool excluded) public onlyOwner {\r\n        _isExcludedFromFees[account] = excluded;\r\n\r\n        emit ExcludeFromFees(account, excluded);\r\n    }\r\n\r\n    function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) external onlyOwner {\r\n        for(uint256 i = 0; i < accounts.length; i++) {\r\n            _isExcludedFromFees[accounts[i]] = excluded;\r\n        }\r\n\r\n        emit ExcludeMultipleAccountsFromFees(accounts, excluded);\r\n    }\r\n\r\n    function setAutomatedMarketMakerPair(address pair, bool value) external onlyOwner {\r\n        require(pair != uniswapV2Pair, \"The PancakeSwap pair cannot be removed from automatedMarketMakerPairs\");\r\n\r\n        _setAutomatedMarketMakerPair(pair, value);\r\n    }\r\n\r\n    function _setAutomatedMarketMakerPair(address pair, bool value) private {\r\n        automatedMarketMakerPairs[pair] = value;\r\n\r\n        excludeFromMaxTransaction(pair, value);\r\n        \r\n        if(value) {\r\n            dividendTracker.excludeFromDividends(pair);\r\n        }\r\n\r\n        emit SetAutomatedMarketMakerPair(pair, value);\r\n    }\r\n\r\n    function updateOperationsWallet(address newOperationsWallet) external onlyOwner {\r\n        require(newOperationsWallet != address(0), \"may not set to 0 address\");\r\n        excludeFromFees(newOperationsWallet, true);\r\n        emit OperationsWalletUpdated(newOperationsWallet, operationsWallet);\r\n        operationsWallet = newOperationsWallet;\r\n    }\r\n\r\n    function updateGasForProcessing(uint256 newValue) external onlyOwner {\r\n        require(newValue >= 200000 && newValue <= 500000, \" gasForProcessing must be between 200,000 and 500,000\");\r\n        require(newValue != gasForProcessing, \"Cannot update gasForProcessing to same value\");\r\n        emit GasForProcessingUpdated(newValue, gasForProcessing);\r\n        gasForProcessing = newValue;\r\n    }\r\n\r\n    function updateClaimWait(uint256 claimWait) external onlyOwner {\r\n        dividendTracker.updateClaimWait(claimWait);\r\n    }\r\n\r\n    function getClaimWait() external view returns(uint256) {\r\n        return dividendTracker.claimWait();\r\n    }\r\n\r\n    function getTotalDividendsDistributed(address rewardToken) external view returns (uint256) {\r\n        return dividendTracker.totalDividendsDistributed(rewardToken);\r\n    }\r\n\r\n    function isExcludedFromFees(address account) external view returns(bool) {\r\n        return _isExcludedFromFees[account];\r\n    }\r\n\r\n    function withdrawableDividendOf(address account, address rewardToken) external view returns(uint256) {\r\n    \treturn dividendTracker.withdrawableDividendOf(account, rewardToken);\r\n  \t}\r\n\r\n\tfunction dividendTokenBalanceOf(address account) external view returns (uint256) {\r\n\t\treturn dividendTracker.holderBalance(account);\r\n\t}\r\n\r\n    function getAccountDividendsInfo(address account, address rewardToken)\r\n        external view returns (\r\n            address,\r\n            int256,\r\n            int256,\r\n            uint256,\r\n            uint256,\r\n            uint256,\r\n            uint256,\r\n            uint256) {\r\n        return dividendTracker.getAccount(account, rewardToken);\r\n    }\r\n\r\n\tfunction getAccountDividendsInfoAtIndex(uint256 index, address rewardToken)\r\n        external view returns (\r\n            address,\r\n            int256,\r\n            int256,\r\n            uint256,\r\n            uint256,\r\n            uint256,\r\n            uint256,\r\n            uint256) {\r\n    \treturn dividendTracker.getAccountAtIndex(index, rewardToken);\r\n    }\r\n\r\n\tfunction processDividendTracker(uint256 gas) external {\r\n\t\t(uint256 iterations, uint256 claims, uint256 lastProcessedIndex) = dividendTracker.process(gas);\r\n\t\temit ProcessedDividendTracker(iterations, claims, lastProcessedIndex, false, gas, tx.origin);\r\n    }\r\n\r\n    function claim() external {\r\n\t\tdividendTracker.processAccount(payable(msg.sender), false);\r\n    }\r\n\r\n    function getLastProcessedIndex() external view returns(uint256) {\r\n    \treturn dividendTracker.getLastProcessedIndex();\r\n    }\r\n\r\n    function getNumberOfDividendTokenHolders() external view returns(uint256) {\r\n        return dividendTracker.getNumberOfTokenHolders();\r\n    }\r\n    \r\n    function getNumberOfDividends() external view returns(uint256) {\r\n        return dividendTracker.totalBalance();\r\n    }\r\n    \r\n    // remove limits after token is stable\r\n    function removeLimits() external onlyOwner returns (bool){\r\n        limitsInEffect = false;\r\n        transferDelayEnabled = false;\r\n        return true;\r\n    }\r\n    \r\n    function _transfer(\r\n        address from,\r\n        address to,\r\n        uint256 amount\r\n    ) internal override {\r\n        require(from != address(0), \"ERC20: transfer from the zero address\");\r\n        require(to != address(0), \"ERC20: transfer to the zero address\");\r\n        \r\n         if(amount == 0) {\r\n            super._transfer(from, to, 0);\r\n            return;\r\n        }\r\n        \r\n        if(!tradingActive){\r\n            require(_isExcludedFromFees[from] || _isExcludedFromFees[to], \"Trading is not active yet.\");\r\n        }\r\n        \r\n        if(limitsInEffect){\r\n            if (\r\n                from != owner() &&\r\n                to != owner() &&\r\n                to != address(0) &&\r\n                to != address(0xdead) &&\r\n                !swapping\r\n            ){\r\n\r\n                // at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.  \r\n                if (transferDelayEnabled){\r\n                    if (to != address(uniswapV2Router) && to != address(uniswapV2Pair)){\r\n                        require(_holderLastTransferTimestamp[tx.origin] < block.number, \"_transfer:: Transfer Delay enabled.  Only one purchase per block allowed.\");\r\n                        _holderLastTransferTimestamp[tx.origin] = block.number;\r\n                    }\r\n                }\r\n                \r\n                //when buy\r\n                if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {\r\n                    require(amount <= maxTransactionAmount, \"Buy transfer amount exceeds the maxTransactionAmount.\");\r\n                    require(amount + balanceOf(to) <= maxWallet, \"Unable to exceed Max Wallet\");\r\n                } \r\n                //when sell\r\n                else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) {\r\n                    require(amount <= maxTransactionAmount, \"Sell transfer amount exceeds the maxTransactionAmount.\");\r\n                }\r\n                else if(!_isExcludedMaxTransactionAmount[to]) {\r\n                    require(amount + balanceOf(to) <= maxWallet, \"Unable to exceed Max Wallet\");\r\n                }\r\n            }\r\n        }\r\n\r\n\t\tuint256 contractTokenBalance = balanceOf(address(this));\r\n        \r\n        bool canSwap = contractTokenBalance >= swapTokensAtAmount;\r\n\r\n        if( \r\n            canSwap &&\r\n            swapEnabled &&\r\n            !swapping &&\r\n            !automatedMarketMakerPairs[from] &&\r\n            !_isExcludedFromFees[from] &&\r\n            !_isExcludedFromFees[to]\r\n        ) {\r\n            swapping = true;\r\n            swapBack();\r\n            swapping = false;\r\n        }\r\n\r\n        bool takeFee = !swapping;\r\n\r\n        // if any account belongs to _isExcludedFromFee account then remove the fee\r\n        if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) {\r\n            takeFee = false;\r\n        }\r\n        \r\n        uint256 fees = 0;\r\n        \r\n        // no taxes on transfers (non buys/sells)\r\n        if(takeFee){\r\n            if(tradingActiveBlock + 1 >= block.number && (automatedMarketMakerPairs[to] || automatedMarketMakerPairs[from])){\r\n                fees = amount.mul(99).div(100);\r\n                tokensForLiquidity += fees * 33 / 99;\r\n                tokensForRewards += fees * 33 / 99;\r\n                tokensForOperations += fees * 33 / 99;\r\n            }\r\n\r\n            // on sell\r\n            else if (automatedMarketMakerPairs[to] && totalSellFees > 0){\r\n                fees = amount.mul(totalSellFees).div(feeDivisor);\r\n                tokensForRewards += fees * rewardsSellFee / totalSellFees;\r\n                tokensForLiquidity += fees * liquiditySellFee / totalSellFees;\r\n                tokensForOperations += fees * operationsSellFee / totalSellFees;\r\n            }\r\n            \r\n            // on buy\r\n            else if(automatedMarketMakerPairs[from] && totalBuyFees > 0) {\r\n        \t    fees = amount.mul(totalBuyFees).div(feeDivisor);\r\n        \t    tokensForRewards += fees * rewardsBuyFee / totalBuyFees;\r\n                tokensForLiquidity += fees * liquidityBuyFee / totalBuyFees;\r\n                tokensForOperations += fees * operationsBuyFee / totalBuyFees;\r\n            }\r\n\r\n            if(fees > 0){    \r\n                super._transfer(from, address(this), fees);\r\n            }\r\n        \t\r\n        \tamount -= fees;\r\n        }\r\n\r\n        super._transfer(from, to, amount);\r\n\r\n        dividendTracker.setBalance(payable(from), balanceOf(from));\r\n        dividendTracker.setBalance(payable(to), balanceOf(to));\r\n\r\n        if(!swapping && gasForProcessing > 0) {\r\n\t    \tuint256 gas = gasForProcessing;\r\n\r\n\t    \ttry dividendTracker.process(gas) returns (uint256 iterations, uint256 claims, uint256 lastProcessedIndex) {\r\n\t    \t\temit ProcessedDividendTracker(iterations, claims, lastProcessedIndex, true, gas, tx.origin);\r\n\t    \t}\r\n\t    \tcatch {}\r\n        }\r\n    }\r\n    \r\n    function swapTokensForEth(uint256 tokenAmount) private {\r\n\r\n        // generate the uniswap pair path of token -> weth\r\n        address[] memory path = new address[](2);\r\n        path[0] = address(this);\r\n        path[1] = uniswapV2Router.WETH();\r\n\r\n        _approve(address(this), address(uniswapV2Router), tokenAmount);\r\n\r\n        // make the swap\r\n        uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\r\n            tokenAmount,\r\n            0, // accept any amount of ETH\r\n            path,\r\n            address(this),\r\n            block.timestamp\r\n        );\r\n        \r\n    }\r\n    \r\n    function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {\r\n        // approve token transfer to cover all possible scenarios\r\n        _approve(address(this), address(uniswapV2Router), tokenAmount);\r\n\r\n        // add the liquidity\r\n        uniswapV2Router.addLiquidityETH{value: ethAmount}(\r\n            address(this),\r\n            tokenAmount,\r\n            0, // slippage is unavoidable\r\n            0, // slippage is unavoidable\r\n            address(0xdead),\r\n            block.timestamp\r\n        );\r\n\r\n    }\r\n    \r\n    function swapBack() private {\r\n        uint256 contractBalance = balanceOf(address(this));\r\n        uint256 totalTokensToSwap = tokensForLiquidity + tokensForOperations + tokensForRewards;\r\n        \r\n        if(contractBalance == 0 || totalTokensToSwap == 0) {return;}\r\n        \r\n        // Halve the amount of liquidity tokens\r\n        uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2;\r\n        uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);\r\n        \r\n        uint256 initialETHBalance = address(this).balance;\r\n\r\n        swapTokensForEth(amountToSwapForETH); \r\n        \r\n        uint256 ethBalance = address(this).balance.sub(initialETHBalance);\r\n        \r\n        uint256 ethForOperations = ethBalance.mul(tokensForOperations).div(totalTokensToSwap - (tokensForLiquidity/2));\r\n        uint256 ethForRewards = ethBalance.mul(tokensForRewards).div(totalTokensToSwap - (tokensForLiquidity/2));\r\n        \r\n        uint256 ethForLiquidity = ethBalance - ethForOperations - ethForRewards;\r\n        \r\n        tokensForLiquidity = 0;\r\n        tokensForOperations = 0;\r\n        tokensForRewards = 0;\r\n        \r\n        \r\n        \r\n        if(liquidityTokens > 0 && ethForLiquidity > 0){\r\n            addLiquidity(liquidityTokens, ethForLiquidity);\r\n            emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity);\r\n        }\r\n        \r\n        // call twice to force buy of both reward tokens.\r\n        (bool success,) = address(dividendTracker).call{value: ethForRewards}(\"\");\r\n\r\n        (success,) = address(operationsWallet).call{value: address(this).balance}(\"\");\r\n    }\r\n\r\n    function withdrawStuckEth() external onlyOwner {\r\n        (bool success,) = address(msg.sender).call{value: address(this).balance}(\"\");\r\n        require(success, \"failed to withdraw\");\r\n    }\r\n\r\n    function requestToWithdrawLP(uint256 percToWithdraw) external onlyOwner {\r\n        require(!lpWithdrawRequestPending, \"Cannot request again until first request is over.\");\r\n        require(percToWithdraw <= 100 && percToWithdraw > 0, \"Need to set between 1-100%\");\r\n        lpWithdrawRequestTimestamp = block.timestamp;\r\n        lpWithdrawRequestPending = true;\r\n        lpPercToWithDraw = percToWithdraw;\r\n        emit RequestedLPWithdraw();\r\n    }\r\n\r\n    function nextAvailableLpWithdrawDate() public view returns (uint256){\r\n        if(lpWithdrawRequestPending){\r\n            return lpWithdrawRequestTimestamp + lpWithdrawRequestDuration;\r\n        }\r\n        else {\r\n            return 0;  // 0 means no open requests\r\n        }\r\n    }\r\n\r\n    function withdrawRequestedLP() external onlyOwner {\r\n        require(block.timestamp >= nextAvailableLpWithdrawDate() && nextAvailableLpWithdrawDate() > 0, \"Must request and wait.\");\r\n        lpWithdrawRequestTimestamp = 0;\r\n        lpWithdrawRequestPending = false;\r\n\r\n        uint256 amtToWithdraw = IERC20(address(uniswapV2Pair)).balanceOf(address(this)) * lpPercToWithDraw / 100;\r\n        \r\n        lpPercToWithDraw = 0;\r\n\r\n        IERC20(uniswapV2Pair).transfer(msg.sender, amtToWithdraw);\r\n    }\r\n\r\n    function cancelLPWithdrawRequest() external onlyOwner {\r\n        lpWithdrawRequestPending = false;\r\n        lpPercToWithDraw = 0;\r\n        lpWithdrawRequestTimestamp = 0;\r\n        emit CanceledLpWithdrawRequest();\r\n    }\r\n}"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode",
          "evm.deployedBytecode",
          "devdoc",
          "userdoc",
          "metadata",
          "abi"
        ]
      }
    }
  }
}