Skip to content

Commit

Permalink
clean up validateRevert
Browse files Browse the repository at this point in the history
  • Loading branch information
ConjunctiveNormalForm committed Dec 20, 2023
1 parent 753d11a commit 386a957
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions contracts/lens/Quoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ contract Quoter is IQuoter, ILockCallback {
/// @dev custom error function selector length
uint256 internal constant MINIMUM_CUSTOM_ERROR_LENGTH = 4;

/// @dev function selector + length of bytes as uint256 + min length of revert reason padded to multiple of 32 bytes
uint256 internal constant MINIMUM_REASON_LENGTH = 68;

/// @dev min valid reason is 3-words long
/// @dev int128[2] + sqrtPriceX96After padded to 32bytes + intializeTicksLoaded padded to 32bytes
uint256 internal constant MINIMUM_VALID_RESPONSE_LENGTH = 96;
Expand Down Expand Up @@ -123,19 +120,7 @@ contract Quoter is IQuoter, ILockCallback {
/// @dev check revert bytes and pass through if considered valid; otherwise revert with different message
function validateRevertReason(bytes memory reason) private pure returns (bytes memory) {
if (reason.length < MINIMUM_VALID_RESPONSE_LENGTH) {
//if InvalidLockAcquiredSender()
if (reason.length <= MINIMUM_CUSTOM_ERROR_LENGTH) {
assembly {
revert(reason, 4)
}
}
if (reason.length < MINIMUM_REASON_LENGTH) {
revert UnexpectedRevertBytes(reason);
}
assembly {
reason := add(reason, 0x04)
}
revert(abi.decode(reason, (string)));
revert UnexpectedRevertBytes(reason);
}
return reason;
}
Expand Down

0 comments on commit 386a957

Please sign in to comment.