contract FeeApproverV2 is OwnableUpgradeSafe {
    using SafeMath for uint256;

    function initialize(
        address _KOREAddress,
        address _WKOREAddress,
        address _WETHAddress,
        address _koreVaultAddress
    ) public initializer {
        OwnableUpgradeSafe.__Ownable_init();
        koreTokenAddress = _KOREAddress;
        wKoreTokenAddress = _WKOREAddress;
        WETHAddress = _WETHAddress;
        tokenUniswapPair = IUniswapV2Factory(address(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f)).getPair(WETHAddress,koreTokenAddress);
        koreVaultAddress = _koreVaultAddress;
        feePercentX100 = 20;
        paused = false; // We start paused until sync post LGE happens.
    }

    address tokenUniswapPair;
    IUniswapV2Factory public uniswapFactory;
    address internal WETHAddress;
    address koreTokenAddress;
    address wKoreTokenAddress;
    address koreVaultAddress;
    uint8 public feePercentX100;
    uint256 public lastTotalSupplyOfLPTokens;
    bool paused;

    // Pausing transfers of the token
    function setPaused(bool _pause) public onlyOwner {
        paused = _pause;
    }

    function setFeeMultiplier(uint8 _feeMultiplier) public onlyOwner {
        feePercentX100 = _feeMultiplier;
    }

    function setKoreVaultAddress(address _koreVaultAddress) public onlyOwner {
        koreVaultAddress = _koreVaultAddress;
    }

    function setWKoreAddress(address _wKoreTokenAddress) public onlyOwner {
        wKoreTokenAddress = _wKoreTokenAddress;
    }

    function sync() public {
        uint256 _LPSupplyOfPairTotal = IERC20(tokenUniswapPair).totalSupply();
        lastTotalSupplyOfLPTokens = _LPSupplyOfPairTotal;
    }

    function calculateAmountsAfterFee(
        address sender,
        address recipient, // unusued maybe use din future
        uint256 amount
    )
        public
        returns (
          uint256 transferToAmount,
          uint256 transferToFeeDistributorAmount
        )
    {
        require(paused == false, "FEE APPROVER: Transfers Paused");
        uint256 _LPSupplyOfPairTotal = IERC20(tokenUniswapPair).totalSupply();

        if(sender == tokenUniswapPair) {
            require(lastTotalSupplyOfLPTokens <= _LPSupplyOfPairTotal, "Liquidity withdrawals forbidden");
        }

        // Dont have a fee when koreVault is sending, or infinite loop
        // And when pair is sending ( buys are happening, do not tax on it)
        // And no fee for wrapping and unwrapping wkore
        if(sender == koreVaultAddress
           || sender == tokenUniswapPair
           || recipient == wKoreTokenAddress) {
            transferToFeeDistributorAmount = 0;
            transferToAmount = amount;
        } else {
            transferToFeeDistributorAmount = amount.mul(feePercentX100).div(1000);
            transferToAmount = amount.sub(transferToFeeDistributorAmount);
        }

        lastTotalSupplyOfLPTokens = _LPSupplyOfPairTotal;
    }
}
function setPaused(bool _pause) public onlyOwner {
        paused = _pause;
    }
// Pausing transfers of the token