@@ -81,8 +81,9 @@ export class PaymastersService {
81
81
maxPaymasterEthFees ,
82
82
true ,
83
83
) ;
84
-
85
84
const maxPaymasterEthFee = totalPaymasterEthFees ( maxPaymasterEthFees ) ;
85
+ const maxEthFees = maxNetworkEthFee . plus ( maxPaymasterEthFee ) . minus ( ethDiscount ) ;
86
+
86
87
const signedData : PaymasterSignedData = {
87
88
// User signs the maxPaymasterEthFee so can't be changed; (maxPaymasteEthFee - paymasterEthFee) is included in the discount
88
89
paymasterFee : asFp ( maxPaymasterEthFee , ETH ) ,
@@ -101,9 +102,6 @@ export class PaymastersService {
101
102
) ,
102
103
) ;
103
104
104
- const paymasterEthFee = totalPaymasterEthFees ( paymasterEthFees ) ;
105
- const maxEthFees = maxNetworkEthFee . plus ( paymasterEthFee ) . minus ( ethDiscount ) ;
106
-
107
105
const tokenPrice = await this . prices . price ( asUAddress ( feeToken , chain ) ) ;
108
106
const maxTokenFees = maxEthFees . div ( tokenPrice . eth ) ;
109
107
await this . prices . updatePriceFeedsIfNecessary ( chain , [ ETH . pythUsdPriceId , tokenPrice . id ] ) ;
@@ -200,7 +198,10 @@ export class PaymastersService {
200
198
) ;
201
199
202
200
// Provide a discount if currentPaymasterEthFee < maxPaymasterEthFee; ensuring the user benefits in case of feeToken:eth price change etc.
203
- const paymasterEthFees = await this . finalPaymasterEthFees ( maxPaymasterEthFees , { account } ) ;
201
+ const paymasterEthFees = await this . finalPaymasterEthFees ( maxPaymasterEthFees , {
202
+ account,
203
+ use,
204
+ } ) ;
204
205
const paymasterEthFee = totalPaymasterEthFees ( paymasterEthFees ) ;
205
206
const paymasterEthFeeDiscount =
206
207
totalPaymasterEthFees ( maxPaymasterEthFees ) . minus ( paymasterEthFee ) ;
@@ -238,9 +239,9 @@ export class PaymastersService {
238
239
239
240
private async finalPaymasterEthFees (
240
241
max : PaymasterFeeParts ,
241
- params : Omit < PaymasterEthFeeParams , 'use' > ,
242
+ params : PaymasterEthFeeParams ,
242
243
) : Promise < PaymasterFeeParts > {
243
- const current = await this . paymasterEthFees ( { ... params , use : true } ) ;
244
+ const current = await this . paymasterEthFees ( params ) ;
244
245
245
246
return {
246
247
activation : Decimal . min ( max . activation , current . activation ) ,
0 commit comments