@@ -24,6 +24,7 @@ contract MeteePaymaster is BasePaymaster {
24
24
25
25
uint256 private constant VALID_TIMESTAMP_OFFSET = 20 ;
26
26
uint256 private constant SIGNATURE_OFFSET = VALID_TIMESTAMP_OFFSET + 64 ;
27
+ uint256 private constant POST_OP_OVERHEAD = 34982 ;
27
28
28
29
constructor (IEntryPoint _entryPoint , address _verifyingSigner , MetaPaymaster _metaPaymaster ) BasePaymaster (_entryPoint) Ownable () {
29
30
verifyingSigner = _verifyingSigner;
@@ -80,15 +81,21 @@ contract MeteePaymaster is BasePaymaster {
80
81
81
82
// no need for other on-chain validation: entire UserOp should have been checked
82
83
// by the external service prior to signing it.
83
- return (" " , _packValidationData (false , validUntil, validAfter));
84
+ return (abi.encode (userOp.maxFeePerGas, userOp.maxPriorityFeePerGas) , _packValidationData (false , validUntil, validAfter));
84
85
}
85
86
86
- function _postOp (PostOpMode mode , bytes calldata /* context*/ , uint256 actualGasCost ) internal override {
87
+ function _postOp (PostOpMode mode , bytes calldata context , uint256 actualGasCost ) internal override {
87
88
if (mode != PostOpMode.postOpReverted) {
88
- metaPaymaster.fund (address (this ), actualGasCost + 3453969250695 );
89
+ (uint256 maxFeePerGas , uint256 maxPriorityFeePerGas ) = abi.decode (context, (uint256 , uint256 ));
90
+ uint256 gasPrice = min (maxFeePerGas, maxPriorityFeePerGas + block .basefee );
91
+ metaPaymaster.fund (address (this ), actualGasCost + POST_OP_OVERHEAD* gasPrice);
89
92
}
90
93
}
91
94
95
+ function min (uint256 a , uint256 b ) internal pure returns (uint256 ) {
96
+ return a < b ? a : b;
97
+ }
98
+
92
99
function parsePaymasterAndData (bytes calldata paymasterAndData )
93
100
internal pure returns (uint48 validUntil , uint48 validAfter , bytes calldata signature ) {
94
101
(validUntil, validAfter) = abi.decode (paymasterAndData[VALID_TIMESTAMP_OFFSET:SIGNATURE_OFFSET],(uint48 , uint48 ));
0 commit comments