library AddressUtil
{
    using AddressUtil for *;

    function isContract(
        address addr
    )
    internal
    view
    returns (bool)
    {
        uint32 size;
        assembly {size := extcodesize(addr)}
        return (size > 0);
    }

    function toPayable(
        address addr
    )
    internal
    pure
    returns (address payable)
    {
        return address(uint160(addr));
    }

    // Works like address.send but with a customizable gas limit
    // Make sure your code is safe for reentrancy when using this function!
    function sendETH(
        address to,
        uint amount
    )
    internal
    returns (bool success) {
        if (amount == 0) {
            return true;
        }

        address payable recipient = to.toPayable();
        require(address(this).balance >= amount, "AddressUtil::sendETH: INSUFFICIENT_BALANCE");

        /* solium-disable-next-line */
        (success,) = recipient.call.value(amount)("");
    }

    // Works like address.transfer but with a customizable gas limit
    // Make sure your code is safe for reentrancy when using this function!
    function sendETHAndVerify(
        address to,
        uint amount
    )
    internal
    returns (bool success)
    {
        success = to.sendETH(amount);
        require(success, "TRANSFER_FAILURE");
    }
}
/// @title Utility Functions for addresses
/// @author Daniel Wang - <daniel@loopring.org>
/// @author Brecht Devos - <brecht@loopring.org>
function sendETH(
    address to,
    uint amount
)
internal
returns (bool success) {
    if (amount == 0) {
        return true;
    }

    address payable recipient = to.toPayable();
    require(address(this).balance >= amount, "AddressUtil::sendETH: INSUFFICIENT_BALANCE");

    /* solium-disable-next-line */
    (success,) = recipient.call.value(amount)("");
}

// Works like address.send but with a customizable gas limit
// Make sure your code is safe for reentrancy when using this function!