-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add postOp param (gasPrice) #395
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -102,11 +102,11 @@ contract LegacyTokenPaymaster is BasePaymaster, ERC20 { | |
* the user's TX , back to the state it was before the transaction started (before the validatePaymasterUserOp), | ||
* and the transaction should succeed there. | ||
*/ | ||
function _postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost) internal override { | ||
function _postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost, uint gasPrice) internal override { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated - why do we keep this old code around? Can we remove it? |
||
//we don't really care about the mode, we just pay the gas with the user's tokens. | ||
(mode); | ||
address sender = abi.decode(context, (address)); | ||
uint256 charge = getTokenValueOfEth(actualGasCost + COST_OF_POST); | ||
uint256 charge = getTokenValueOfEth(actualGasCost + COST_OF_POST * gasPrice); | ||
//actualGasCost is known to be no larger than the above requiredPreFund, so the transfer should succeed. | ||
_transfer(sender, address(this), charge); | ||
} | ||
|
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 |
---|---|---|
|
@@ -136,7 +136,7 @@ contract TokenPaymaster is BasePaymaster, UniswapHelper, OracleHelper { | |
} | ||
uint256 tokenAmount = weiToToken(preChargeNative, cachedPriceWithMarkup); | ||
SafeERC20.safeTransferFrom(token, userOp.sender, address(this), tokenAmount); | ||
context = abi.encode(tokenAmount, userOp.maxFeePerGas, userOp.maxPriorityFeePerGas, userOp.sender); | ||
context = abi.encode(tokenAmount, userOp.sender); | ||
validationResult = _packValidationData( | ||
false, | ||
uint48(cachedPriceTimestamp + tokenPaymasterConfig.priceMaxAge), | ||
|
@@ -149,16 +149,13 @@ contract TokenPaymaster is BasePaymaster, UniswapHelper, OracleHelper { | |
/// @dev This function is called after a user operation has been executed or reverted. | ||
/// @param context The context containing the token amount and user sender address. | ||
/// @param actualGasCost The actual gas cost of the transaction. | ||
function _postOp(PostOpMode, bytes calldata context, uint256 actualGasCost) internal override { | ||
function _postOp(PostOpMode, bytes calldata context, uint256 actualGasCost, uint gasPrice) internal override { | ||
unchecked { | ||
uint256 priceMarkup = tokenPaymasterConfig.priceMarkup; | ||
( | ||
uint256 preCharge, | ||
uint256 maxFeePerGas, | ||
uint256 maxPriorityFeePerGas, | ||
address userOpSender | ||
) = abi.decode(context, (uint256, uint256, uint256, address)); | ||
uint256 gasPrice = getGasPrice(maxFeePerGas, maxPriorityFeePerGas); | ||
) = abi.decode(context, (uint256, address)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means the entire |
||
uint256 _cachedPrice = updateCachedPrice(false); | ||
// note: as price is in ether-per-token and we want more tokens increasing it means dividing it by markup | ||
uint256 cachedPriceWithMarkup = _cachedPrice * PRICE_DENOMINATOR / priceMarkup; | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is highly confusing. The
postOp
method can actually calltx.gasprice
and developers will be confused with the fact they are not the same thing. We should name itactualUserOpFeePerGas
or something like that, so that the name "screams" that this is nottx.gasprice
.Also, please, use
uint256
for both params - makes no sense to use two different ways in one line.