-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
518 additions
and
699 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.26; | ||
|
||
import "@openzeppelin/contracts/utils/math/SafeMath.sol"; | ||
|
||
library Math { | ||
using SafeMath for uint256; | ||
|
||
error AdditionsOverflow(); | ||
error SubtractionsUnderflow(); | ||
error MultiplicationsOverflow(); | ||
|
||
function add(uint256 x, uint256 y) internal pure returns (uint256 z) { | ||
bool success; | ||
(success, z) = x.tryAdd(y); | ||
if (!success) revert AdditionsOverflow(); | ||
unchecked { | ||
z = x + y; | ||
if (z < x) revert AdditionsOverflow(); | ||
} | ||
} | ||
|
||
function sub(uint256 x, uint256 y) internal pure returns (uint256 z) { | ||
bool success; | ||
(success, z) = x.trySub(y); | ||
if (!success) revert SubtractionsUnderflow(); | ||
unchecked { | ||
if (y > x) revert SubtractionsUnderflow(); | ||
z = x - y; | ||
} | ||
} | ||
|
||
function mul(uint256 x, uint256 y) internal pure returns (uint256 z) { | ||
bool success; | ||
(success, z) = x.tryMul(y); | ||
if (!success) revert MultiplicationsOverflow(); | ||
unchecked { | ||
if (x == 0 || (z = x * y) / x == y) { | ||
return z; | ||
} else { | ||
revert MultiplicationsOverflow(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
/* Autogenerated file. Do not edit manually. */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import type * as interfaces from "./interfaces"; | ||
export type { interfaces }; | ||
import type * as token from "./token"; | ||
export type { token }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.