library RayMul {
  uint256 internal constant RAY = 1e27;
  uint256 internal constant halfRAY = RAY / 2;

  /**
   * @dev Multiplies two ray, rounding half up to the nearest ray
   * @param a Ray
   * @param b Ray
   * @return The result of a*b, in ray
   **/
  function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {
    if (a == 0 || b == 0) {
      return 0;
    }

    require(a <= (type(uint256).max - halfRAY) / b, "rayMul overflow");

    return (a * b + halfRAY) / RAY;
  }
}
function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {
  if (a == 0 || b == 0) {
    return 0;
  }

  require(a <= (type(uint256).max - halfRAY) / b, "rayMul overflow");

  return (a * b + halfRAY) / RAY;
}

/**
 * @dev Multiplies two ray, rounding half up to the nearest ray
 * @param a Ray
 * @param b Ray
 * @return The result of a*b, in ray
 **/