You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
More gas-efficient implementation of SafeERC20.forceApprove in the case where the token returns a bool on approve.
Expected savings are a little more than a call to EXTCODESIZE, that is 2600 gas in the worst case of no access lists or 100 gas otherwise.
The required code changes are very small.
馃摑 Details
forceApprove is the only function calling _callOptionalReturnBool (code).
This function is supposed to behave like _callOptionalReturn except that if the inner call reverts then it returns false instead of reverting.
The output is currently computed as:
With the proposed change, if returnsEmptyOutput is false then the evalutation of the second &&short-circuits and the code is assumed to have code.
This is the same assumption made in _callOptionalReturn through functionCall.
The text was updated successfully, but these errors were encountered:
馃 Motivation
More gas-efficient implementation of
SafeERC20.forceApprove
in the case where the token returns a bool onapprove
.Expected savings are a little more than a call to
EXTCODESIZE
, that is 2600 gas in the worst case of no access lists or 100 gas otherwise.The required code changes are very small.
馃摑 Details
forceApprove
is the only function calling_callOptionalReturnBool
(code).This function is supposed to behave like
_callOptionalReturn
except that if the inner call reverts then it returnsfalse
instead of reverting.The output is currently computed as:
My proposal it to change this expression to:
With the proposed change, if
returnsEmptyOutput
is false then the evalutation of the second&&
short-circuits and the code is assumed to have code.This is the same assumption made in
_callOptionalReturn
throughfunctionCall
.The text was updated successfully, but these errors were encountered: