Skip to content

Commit

Permalink
feat: UnsafeMathUint256
Browse files Browse the repository at this point in the history
  • Loading branch information
0xhiroshi committed Oct 19, 2023
1 parent 48815b7 commit 9f90f09
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions contracts/libraries/UnsafeMathUint256.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library UnsafeMathUint256 {
function unsafeAdd(uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
return a + b;
}
}

function unsafeSubtract(uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
return a - b;
}
}

function unsafeMultiply(uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
return a * b;
}
}

function unsafeDivide(uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
return a / b;
}
}
}

0 comments on commit 9f90f09

Please sign in to comment.