Closed sherlock-admin closed 4 months ago
Deleted the poc requesting comment wrongly, still require it by @RealLTDingZhen
2 comment(s) were left on this issue during the judging contest.
0xLogos commented:
invalid, desing decision
takarez commented:
invalid
It could be a design choice. I'm dropping the issue.
LTDingZhen
medium
Calculations in Keeperfee are too crude, making users pay more KeeperFee.
Summary
In
KeeperFee.sol
,KeeperFee
is calculated on a very rough estimate, making users pay more additional fees.Vulnerability Detail
In
KeeperFee.sol
,getKeeperFee()' would return
KeeperFee` in collateral:Currently, Transaction Fees on
OP STACK
chains are composed of an Execution Gas Fee and an L1 Data Fee. The total cost of a transaction is the sum of these two fees.Since L1 fees often account for more than 80% of a transaction, we will only discuss L1 fees here.
According to OP doc,
the L1 Data Fee is calculated based on the following parameters:
The L1 Data Fee calculation first begins with counting the number of zero bytes and non-zero bytes in the transaction data. Each zero byte costs 4 gas and each non-zero byte costs 16 gas. This is the same way that Ethereum calculates the gas cost of transaction data.
tx_data_gas = count_zero_bytes(tx_data) 4 + count_non_zero_bytes(tx_data) 16
After calculating the gas cost of the transaction data, the fixed and dynamic overhead values are applied.
Finally, the total L1 Data Fee is calculated by multiplying the total gas cost by the current Ethereum base fee.
But in current
Keeperfee.sol
,The
tx_data_gas
is just estimated to_gasUnitsL1
. So no matter what transaction Keepers perform, users will always pay Keepers the same amount of gas.Impact
Because
KeeperFee
should be able to cover all kinds of executions in terms of gas, this crude approximation will force users to pay more for orders that actually consume relatively little gas, such asexecutewithdraw
.Code Snippet
https://github.com/sherlock-audit/2023-12-flatmoney/blob/main/flatcoin-v1/src/misc/KeeperFee.sol#L104-L105
Tool used
Manual Review
Recommendation
Use something like
payExecutionFee
in GMX to refund users for their additional cost.