Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gas-snapshot
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
7 changes: 4 additions & 3 deletions src/Gasback.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -247,6 +244,10 @@ contract Gasback {
gasToBurn = 0;
}

unchecked {
$.accrued += ethFromGas - ethToGive;
}

/// @solidity memory-safe-assembly
assembly {
if gasToBurn {
Expand Down
6 changes: 1 addition & 5 deletions test/utils/TestPlus.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down