From 43201c7123957161aaa83cc6d539541b5e530adc Mon Sep 17 00:00:00 2001 From: j6i <43463199+j6i@users.noreply.github.com> Date: Sat, 31 Jan 2026 01:52:17 -0800 Subject: [PATCH 1/2] move accrued calc --- src/Gasback.sol | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Gasback.sol b/src/Gasback.sol index b7f3270..504438e 100644 --- a/src/Gasback.sol +++ b/src/Gasback.sol @@ -217,9 +217,6 @@ contract Gasback { uint256 ethFromGas = gasToBurn * block.basefee; uint256 ethToGive = (ethFromGas * $.gasbackRatioNumerator) / GASBACK_RATIO_DENOMINATOR; - unchecked { - $.accrued += ethFromGas - ethToGive; - } uint256 selfBalance = address(this).balance; // If the contract has insufficient ETH, try to pull from the base fee vault. @@ -247,6 +244,10 @@ contract Gasback { gasToBurn = 0; } + unchecked { + $.accrued += ethFromGas - ethToGive; + } + /// @solidity memory-safe-assembly assembly { if gasToBurn { From 1d941f9ef7add972a052122d835bd3b0a5c4a794 Mon Sep 17 00:00:00 2001 From: j6i <43463199+j6i@users.noreply.github.com> Date: Sat, 31 Jan 2026 01:53:14 -0800 Subject: [PATCH 2/2] format, snapshot --- .gas-snapshot | 2 +- test/utils/TestPlus.sol | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index 152f635..1e4e94f 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,5 +1,5 @@ GasbackTest:testConvertGasback() (gas: 73039) -GasbackTest:testConvertGasback(uint256,uint256) (runs: 257, μ: 423506, ~: 308109) +GasbackTest:testConvertGasback(uint256,uint256) (runs: 256, μ: 434549, ~: 294047) GasbackTest:testConvertGasbackBaseFeeVault() (gas: 27070) GasbackTest:testConvertGasbackMaxBaseFee() (gas: 44525) GasbackTest:testConvertGasbackMinVaultBalance() (gas: 26953) diff --git a/test/utils/TestPlus.sol b/test/utils/TestPlus.sol index ea13e1d..ae8d095 100644 --- a/test/utils/TestPlus.sol +++ b/test/utils/TestPlus.sol @@ -553,11 +553,7 @@ contract TestPlus is Brutalizer { /// @dev Truncate the bytes to `n` bytes. /// Returns the result for function chaining. - function _truncateBytes(bytes memory b, uint256 n) - internal - pure - returns (bytes memory result) - { + function _truncateBytes(bytes memory b, uint256 n) internal pure returns (bytes memory result) { /// @solidity memory-safe-assembly assembly { if gt(mload(b), n) { mstore(b, n) }