contract FeeCalculator is OwnableUpgradeSafe {
    using SafeMath for uint256;

    function initialize(address _pisAddress) public initializer {
        OwnableUpgradeSafe.__Ownable_init();
        pisTokenAddress = _pisAddress;
        feePercentX100 = 20;
        paused = false; // We start paused until sync post LGE happens.
        _editNoFeeList(pisTokenAddress, true); //this is to not apply fees for transfer from the token contrat itself
        //vault
        _editNoFeeList(0xe3ABb69c22792Ba841450C61060367a539434724, true);
    }

    address pisTokenAddress;
    uint8 public feePercentX100; // max 255 = 25.5% artificial clamp
    bool paused;
    mapping(address => bool) public noFeeList;

    // PIS token is pausable
    function setPaused(bool _pause) public onlyOwner {
        paused = _pause;
    }

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

    function editNoFeeList(address _address, bool noFee) public onlyOwner {
        _editNoFeeList(_address, noFee);
    }

    function _editNoFeeList(address _address, bool noFee) internal {
        noFeeList[_address] = noFee;
    }

    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");

        if (noFeeList[sender] || noFeeList[recipient]) {
            // Dont have a fee when pisvault is sending, or infinite loop
            transferToFeeDistributorAmount = 0;
            transferToAmount = amount;
        } else {
            transferToFeeDistributorAmount = amount.mul(feePercentX100).div(
                1000
            );
            transferToAmount = amount.sub(transferToFeeDistributorAmount);
        }
    }
}
function setPaused(bool _pause) public onlyOwner {
    paused = _pause;
}

// PIS token is pausable