-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* impl: unchecked stdMath * lib: update forge-std commit to v1.5.3 * build: update unoptimized key * test: update gas snapshot
- Loading branch information
Showing
6 changed files
with
67 additions
and
45 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,6 +1,6 @@ | ||
{ | ||
"constant_product_hash": "0x331cc67f13638cfb7ba5843198a0c38a5b4eee0162ae0f20eddc07e8cbf0732e", | ||
"factory_hash": "0x282a99019ed382d1037d5d34b6bf9ca045737c0bca2642a38c4dd0a5cc7d76c3", | ||
"constant_product_hash": "0xd42c24652292f1d010c199a1902937404331f86155feb0045f7f4ccaa53288e0", | ||
"factory_hash": "0x4809cda82093eabbe5c089c6ec04d08debfff7cb44748ac3e6a417e874f7c0c1", | ||
"oracle_caller_hash": "0x62fc6a5b4ecef14f3dbc069a342221c05473817912414ef348074314902a145a", | ||
"stable_hash": "0xb7344aa6cc1780d46e643f82f5726bf00965c157ff312dda28eb30eb4938d16a" | ||
"stable_hash": "0x6cb319a261af453dc63b30b3a6962bf8293b740d1878d723d3fa3384a0b9320c" | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity ^0.8.0; | ||
|
||
// Our gas-optimized implementation of forge-std's stdMath library | ||
// We should inherit and override the relevant functions in the future when they make them virtual | ||
library stdMath { | ||
function delta(uint256 a, uint256 b) internal pure returns (uint256) { | ||
// SAFETY: The subtraction can never underflow as we explicitly sub the | ||
// smaller value from the larger. | ||
unchecked { | ||
return a > b ? a - b : b - a; | ||
} | ||
} | ||
|
||
function percentDelta(uint256 a, uint256 b) internal pure returns (uint256) { | ||
uint256 absDelta = delta(a, b); | ||
|
||
return absDelta * 1e18 / b; | ||
} | ||
} |