```\nfunction \_convert(address token, uint256 amount, uint8 resolution, bool to) private view returns (uint256 converted) {\n    uint8 decimals = IERC20(token).decimals();\n    uint256 diff = 0;\n    uint256 factor = 0;\n    converted = 0;\n    if (decimals > resolution) {\n        diff = uint256(decimals.sub(resolution));\n        factor = 10 \*\* diff;\n        if (to && amount >= factor) {\n            converted = amount.div(factor);\n        } else if (!to) {\n            converted = amount.mul(factor);\n        }\n    } else if (decimals < resolution) {\n        diff = uint256(resolution.sub(decimals));\n        factor = 10 \*\* diff;\n        if (to) {\n            converted = amount.mul(factor);\n        } else if (!to && amount >= factor) {\n            converted = amount.div(factor);\n        }\n    }\n}\n```\n