function safeDecimals(address token) internal returns (uint256 decimals) {

        (bool success, bytes memory data) = address(token).call(abi.encodeWithSignature("decimals()"));

        if (!success) {
            (success, data) = address(token).call(abi.encodeWithSignature("Decimals()"));
        }

        if (!success) {
            (success, data) = address(token).call(abi.encodeWithSignature("DECIMALS()"));
        }

        if (!success) {
            return 18;
        }

        assembly {
            decimals := mload(add(data, 32))
        }
    }