-
Notifications
You must be signed in to change notification settings - Fork 134
Gas Price Suggesting may cause loss to the bundler #342
Description
Before sending a bundle transaction, gas price has to be estimated base on the current network status and max gas price settings of all batch user operations. The current method used is to calculate the average gas price of the entire batch without considering the max available gas limit each user operation may consume. This may cause some loss of gas fee to the bundler.
Let's say, we have three user operations (op0, op1, op2) as a batch, with gas price of (10 Gwei, 20 Gwei, 30 Gwei) and max gas limit of (300k, 200k, 100k) respectively. The estimated gas price from chain rpc is 10 Gwei, so that all user operation can be included in a bundle transaction.
If we don't take gas limit of each user operation into consideration, the suggested gas price for this bundle transaction would be MAX(10 Gwei, (10+20+30)/3 Gwei) = 20Gwei. Assumed the gas estimate is very accurate so that all gas limit of each user opearion is fully consumed, so the bundler would take (100k + 200k + 300k) * 20 Gwei = 12000k Gwei gas fee, whereas the prefunded gas fee from all user operations is 300k * 10 Gwei + 200k * 20 Gwei + 100k * 30Gwei = 10000k Gwei. As a result, the bundler would loss an extra of 2000k Gwei gas fee.