// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title Math functions that do not check inputs or outputs /// @notice Contains methods that perform common math functions but do not do any overflow or underflow checks library UnsafeMath { /// @notice Returns ceil(x / y) /// @dev division by 0 will return 0, and should be checked externally /// @param x The dividend /// @param y The divisor /// @return z The quotient, ceil(x / y) function divRoundingUp(uint256 x, uint256 y) internal pure returns (uint256 z) { assembly ("memory-safe") { z := add(div(x, y), gt(mod(x, y), 0)) } } /// @notice Calculates floor(a×b÷denominator) /// @dev division by 0 will return 0, and should be checked externally /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result, floor(a×b÷denominator) function simpleMulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) { assembly ("memory-safe") { result := div(mul(a, b), denominator) } } }