Skip to content

Commit

Permalink
T
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Oct 6, 2023
1 parent 2b69306 commit ea6c499
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 65 deletions.
100 changes: 50 additions & 50 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ ERC2981Test:testSetAndGetRoyaltyInfo(uint256) (runs: 256, μ: 108118, ~: 104824)
ERC2981Test:test__codesize() (gas: 8419)
ERC4626Test:testDepositWithNoApprovalReverts() (gas: 16371)
ERC4626Test:testDepositWithNotEnoughApprovalReverts() (gas: 89884)
ERC4626Test:testDifferentialFullMulDiv(uint256,uint256,uint256) (runs: 256, μ: 3341, ~: 3201)
ERC4626Test:testDifferentialFullMulDiv(uint256,uint256,uint256) (runs: 256, μ: 3343, ~: 3201)
ERC4626Test:testMetadata() (gas: 15439)
ERC4626Test:testMintWithNoApprovalReverts() (gas: 16345)
ERC4626Test:testMintZero() (gas: 54317)
ERC4626Test:testMultipleMintDepositRedeemWithdraw() (gas: 425667)
ERC4626Test:testRedeemWithNoShareAmountReverts() (gas: 10918)
ERC4626Test:testRedeemWithNotEnoughShareAmountReverts() (gas: 142915)
ERC4626Test:testSingleDepositWithdraw(uint128) (runs: 256, μ: 202683, ~: 202694)
ERC4626Test:testSingleMintRedeem(uint128) (runs: 256, μ: 201604, ~: 201615)
ERC4626Test:testSingleDepositWithdraw(uint128) (runs: 256, μ: 202684, ~: 202694)
ERC4626Test:testSingleMintRedeem(uint128) (runs: 256, μ: 201605, ~: 201615)
ERC4626Test:testTryGetAssetDecimals() (gas: 30483816)
ERC4626Test:testUseVirtualShares() (gas: 2441768)
ERC4626Test:testVaultInteractionsForSomeoneElse() (gas: 296189)
Expand Down Expand Up @@ -502,7 +502,7 @@ LibCloneTest:testCloneDeterministicRevertsIfAddressAlreadyUsed() (gas: 96882825)
LibCloneTest:testCloneWithImmutableArgs() (gas: 120581)
LibCloneTest:testCloneWithImmutableArgs(uint256,address,uint256,uint256[],uint64,uint8) (runs: 256, μ: 981643, ~: 970078)
LibCloneTest:testCloneWithImmutableArgsRevertsIfDataTooBig() (gas: 97305784)
LibCloneTest:testStartsWithCaller(uint256) (runs: 256, μ: 28158, ~: 28382)
LibCloneTest:testStartsWithCaller(uint256) (runs: 256, μ: 28156, ~: 28382)
LibCloneTest:test__codesize() (gas: 15743)
LibMapTest:testFoundStatementDifferential(uint256,uint256,uint256) (runs: 256, μ: 499, ~: 499)
LibMapTest:testGeneralMapFunctionsGas() (gas: 3304775)
Expand Down Expand Up @@ -857,16 +857,16 @@ SafeCastLibTest:testSafeCastToUint(uint256) (runs: 256, μ: 4198, ~: 3351)
SafeCastLibTest:testSafeCastToUint256(int256) (runs: 256, μ: 1285, ~: 432)
SafeCastLibTest:testSafeCastToUintBench() (gas: 326306)
SafeCastLibTest:test__codesize() (gas: 16001)
SafeTransferLibTest:testApproveWithGarbageReverts(address,uint256) (runs: 256, μ: 107372, ~: 123373)
SafeTransferLibTest:testApproveWithGarbageReverts(address,uint256) (runs: 256, μ: 108251, ~: 123373)
SafeTransferLibTest:testApproveWithMissingReturn() (gas: 31945)
SafeTransferLibTest:testApproveWithMissingReturn(address,uint256) (runs: 256, μ: 31248, ~: 32104)
SafeTransferLibTest:testApproveWithNonContract() (gas: 2989)
SafeTransferLibTest:testApproveWithNonContract(address,address,uint256) (runs: 256, μ: 3524, ~: 3536)
SafeTransferLibTest:testApproveWithNonGarbage(address,uint256) (runs: 256, μ: 79648, ~: 81618)
SafeTransferLibTest:testApproveWithNonContract(address,address,uint256) (runs: 256, μ: 3523, ~: 3536)
SafeTransferLibTest:testApproveWithNonGarbage(address,uint256) (runs: 256, μ: 77983, ~: 59187)
SafeTransferLibTest:testApproveWithRetry() (gas: 768380)
SafeTransferLibTest:testApproveWithRetry(address,uint256,uint256) (runs: 256, μ: 766825, ~: 768524)
SafeTransferLibTest:testApproveWithRetry(address,uint256,uint256) (runs: 256, μ: 766714, ~: 768524)
SafeTransferLibTest:testApproveWithRetryWithNonContract() (gas: 2990)
SafeTransferLibTest:testApproveWithRetryWithNonContract(address,address,uint256) (runs: 256, μ: 3521, ~: 3533)
SafeTransferLibTest:testApproveWithRetryWithNonContract(address,address,uint256) (runs: 256, μ: 3520, ~: 3533)
SafeTransferLibTest:testApproveWithReturnsFalseReverts() (gas: 9515)
SafeTransferLibTest:testApproveWithReturnsFalseReverts(address,uint256) (runs: 256, μ: 9652, ~: 9652)
SafeTransferLibTest:testApproveWithReturnsTooLittleReverts() (gas: 9419)
Expand All @@ -881,58 +881,58 @@ SafeTransferLibTest:testApproveWithStandardERC20(address,uint256) (runs: 256, μ
SafeTransferLibTest:testBalanceOfStandardERC20() (gas: 7830)
SafeTransferLibTest:testBalanceOfStandardERC20(address,uint256) (runs: 256, μ: 39521, ~: 40437)
SafeTransferLibTest:testForceTransferETHToGriever() (gas: 1511304)
SafeTransferLibTest:testForceTransferETHToGriever(uint256,uint256) (runs: 256, μ: 528882, ~: 570828)
SafeTransferLibTest:testForceTransferETHToGriever(uint256,uint256) (runs: 256, μ: 533462, ~: 570828)
SafeTransferLibTest:testTransferAllETH() (gas: 34598)
SafeTransferLibTest:testTransferAllETH(address) (runs: 256, μ: 34786, ~: 35018)
SafeTransferLibTest:testTransferAllETH(address) (runs: 256, μ: 34671, ~: 35018)
SafeTransferLibTest:testTransferAllETHToContractWithoutFallbackReverts() (gas: 10788)
SafeTransferLibTest:testTransferAllETHToContractWithoutFallbackReverts(uint256) (runs: 256, μ: 10898, ~: 10898)
SafeTransferLibTest:testTransferAllFromWithStandardERC20() (gas: 33092)
SafeTransferLibTest:testTransferAllFromWithStandardERC20(address,address,uint256) (runs: 256, μ: 56508, ~: 56508)
SafeTransferLibTest:testTransferAllFromWithStandardERC20(address,address,uint256) (runs: 256, μ: 56507, ~: 56508)
SafeTransferLibTest:testTransferAllWithStandardERC20() (gas: 30735)
SafeTransferLibTest:testTransferAllWithStandardERC20(address,uint256) (runs: 256, μ: 42114, ~: 42114)
SafeTransferLibTest:testTransferETH() (gas: 34600)
SafeTransferLibTest:testTransferETH(address,uint256) (runs: 256, μ: 33440, ~: 35250)
SafeTransferLibTest:testTransferETH(address,uint256) (runs: 256, μ: 33698, ~: 35250)
SafeTransferLibTest:testTransferETHToContractWithoutFallbackReverts() (gas: 10846)
SafeTransferLibTest:testTransferETHToContractWithoutFallbackReverts(uint256) (runs: 256, μ: 10546, ~: 10928)
SafeTransferLibTest:testTransferFromWithGarbageReverts(address,address,uint256) (runs: 256, μ: 880068, ~: 782608)
SafeTransferLibTest:testTransferFromWithMissingReturn() (gas: 670073)
SafeTransferLibTest:testTransferFromWithMissingReturn(address,address,uint256) (runs: 256, μ: 745109, ~: 669563)
SafeTransferLibTest:testTransferETHToContractWithoutFallbackReverts(uint256) (runs: 256, μ: 10545, ~: 10928)
SafeTransferLibTest:testTransferFromWithGarbageReverts(address,address,uint256) (runs: 256, μ: 850929, ~: 782175)
SafeTransferLibTest:testTransferFromWithMissingReturn() (gas: 669607)
SafeTransferLibTest:testTransferFromWithMissingReturn(address,address,uint256) (runs: 256, μ: 778082, ~: 669069)
SafeTransferLibTest:testTransferFromWithNonContract() (gas: 3022)
SafeTransferLibTest:testTransferFromWithNonContract(address,address,address,uint256) (runs: 256, μ: 3670, ~: 3694)
SafeTransferLibTest:testTransferFromWithNonGarbage(address,address,uint256) (runs: 256, μ: 798677, ~: 719710)
SafeTransferLibTest:testTransferFromWithReturnsFalseReverts() (gas: 634862)
SafeTransferLibTest:testTransferFromWithReturnsFalseReverts(address,address,uint256) (runs: 256, μ: 774598, ~: 635391)
SafeTransferLibTest:testTransferFromWithReturnsTooLittleReverts() (gas: 635071)
SafeTransferLibTest:testTransferFromWithReturnsTooLittleReverts(address,address,uint256) (runs: 256, μ: 747085, ~: 635224)
SafeTransferLibTest:testTransferFromWithReturnsTooMuch() (gas: 669842)
SafeTransferLibTest:testTransferFromWithReturnsTooMuch(address,address,uint256) (runs: 256, μ: 773094, ~: 670375)
SafeTransferLibTest:testTransferFromWithReturnsTwoReverts(address,address,uint256) (runs: 256, μ: 761287, ~: 635329)
SafeTransferLibTest:testTransferFromWithRevertingReverts() (gas: 628723)
SafeTransferLibTest:testTransferFromWithRevertingReverts(address,address,uint256) (runs: 256, μ: 755856, ~: 628722)
SafeTransferLibTest:testTransferFromWithStandardERC20() (gas: 667611)
SafeTransferLibTest:testTransferFromWithStandardERC20(address,address,uint256) (runs: 256, μ: 757610, ~: 667323)
SafeTransferLibTest:testTransferWithGarbageReverts(address,uint256) (runs: 256, μ: 823816, ~: 747513)
SafeTransferLibTest:testTransferWithMissingReturn() (gas: 655488)
SafeTransferLibTest:testTransferWithMissingReturn(address,uint256) (runs: 256, μ: 758503, ~: 656037)
SafeTransferLibTest:testTransferFromWithNonGarbage(address,address,uint256) (runs: 256, μ: 864444, ~: 719174)
SafeTransferLibTest:testTransferFromWithReturnsFalseReverts() (gas: 634463)
SafeTransferLibTest:testTransferFromWithReturnsFalseReverts(address,address,uint256) (runs: 256, μ: 729540, ~: 634883)
SafeTransferLibTest:testTransferFromWithReturnsTooLittleReverts() (gas: 634672)
SafeTransferLibTest:testTransferFromWithReturnsTooLittleReverts(address,address,uint256) (runs: 256, μ: 793115, ~: 634825)
SafeTransferLibTest:testTransferFromWithReturnsTooMuch() (gas: 669442)
SafeTransferLibTest:testTransferFromWithReturnsTooMuch(address,address,uint256) (runs: 256, μ: 769331, ~: 669976)
SafeTransferLibTest:testTransferFromWithReturnsTwoReverts(address,address,uint256) (runs: 256, μ: 738529, ~: 634863)
SafeTransferLibTest:testTransferFromWithRevertingReverts() (gas: 628282)
SafeTransferLibTest:testTransferFromWithRevertingReverts(address,address,uint256) (runs: 256, μ: 746497, ~: 628256)
SafeTransferLibTest:testTransferFromWithStandardERC20() (gas: 667145)
SafeTransferLibTest:testTransferFromWithStandardERC20(address,address,uint256) (runs: 256, μ: 722510, ~: 666841)
SafeTransferLibTest:testTransferWithGarbageReverts(address,uint256) (runs: 256, μ: 815410, ~: 747180)
SafeTransferLibTest:testTransferWithMissingReturn() (gas: 655022)
SafeTransferLibTest:testTransferWithMissingReturn(address,uint256) (runs: 256, μ: 753603, ~: 655637)
SafeTransferLibTest:testTransferWithNonContract() (gas: 2988)
SafeTransferLibTest:testTransferWithNonContract(address,address,uint256) (runs: 256, μ: 3545, ~: 3557)
SafeTransferLibTest:testTransferWithNonGarbage(address,uint256) (runs: 256, μ: 821948, ~: 723111)
SafeTransferLibTest:testTransferWithReturnsFalseReverts() (gas: 631993)
SafeTransferLibTest:testTransferWithReturnsFalseReverts(address,uint256) (runs: 256, μ: 784941, ~: 632532)
SafeTransferLibTest:testTransferWithReturnsTooLittleReverts() (gas: 632604)
SafeTransferLibTest:testTransferWithReturnsTooLittleReverts(address,uint256) (runs: 256, μ: 746111, ~: 632323)
SafeTransferLibTest:testTransferWithReturnsTooMuch() (gas: 655955)
SafeTransferLibTest:testTransferWithReturnsTooMuch(address,uint256) (runs: 256, μ: 775940, ~: 656483)
SafeTransferLibTest:testTransferWithReturnsTwoReverts(address,uint256) (runs: 256, μ: 725766, ~: 632399)
SafeTransferLibTest:testTransferWithRevertingReverts() (gas: 631861)
SafeTransferLibTest:testTransferWithRevertingReverts(address,uint256) (runs: 256, μ: 728068, ~: 632357)
SafeTransferLibTest:testTransferWithStandardERC20() (gas: 656537)
SafeTransferLibTest:testTransferWithStandardERC20(address,uint256) (runs: 256, μ: 686408, ~: 656211)
SafeTransferLibTest:testTransferWithNonContract(address,address,uint256) (runs: 256, μ: 3544, ~: 3557)
SafeTransferLibTest:testTransferWithNonGarbage(address,uint256) (runs: 256, μ: 781869, ~: 711689)
SafeTransferLibTest:testTransferWithReturnsFalseReverts() (gas: 631527)
SafeTransferLibTest:testTransferWithReturnsFalseReverts(address,uint256) (runs: 256, μ: 809715, ~: 632011)
SafeTransferLibTest:testTransferWithReturnsTooLittleReverts() (gas: 632163)
SafeTransferLibTest:testTransferWithReturnsTooLittleReverts(address,uint256) (runs: 256, μ: 760800, ~: 631881)
SafeTransferLibTest:testTransferWithReturnsTooMuch() (gas: 655448)
SafeTransferLibTest:testTransferWithReturnsTooMuch(address,uint256) (runs: 256, μ: 745098, ~: 655984)
SafeTransferLibTest:testTransferWithReturnsTwoReverts(address,uint256) (runs: 256, μ: 765515, ~: 631957)
SafeTransferLibTest:testTransferWithRevertingReverts() (gas: 631462)
SafeTransferLibTest:testTransferWithRevertingReverts(address,uint256) (runs: 256, μ: 771071, ~: 632003)
SafeTransferLibTest:testTransferWithStandardERC20() (gas: 656029)
SafeTransferLibTest:testTransferWithStandardERC20(address,uint256) (runs: 256, μ: 679142, ~: 655811)
SafeTransferLibTest:testTryTransferAllETH() (gas: 148698)
SafeTransferLibTest:testTryTransferETH() (gas: 148745)
SafeTransferLibTest:testTryTransferETHWithNoGrief() (gas: 537083)
SafeTransferLibTest:testTryTransferETHWithNoStorageWrites() (gas: 192518)
SafeTransferLibTest:test__codesize() (gas: 37518)
SafeTransferLibTest:test__codesize() (gas: 37503)
SignatureCheckerLibTest:testEmptyCalldataHelpers() (gas: 3919)
SignatureCheckerLibTest:testSignatureChecker(bytes32) (runs: 256, μ: 54789, ~: 46781)
SignatureCheckerLibTest:testSignatureCheckerOnEOAWithInvalidSignature() (gas: 21179)
Expand All @@ -951,15 +951,15 @@ TestPlus:test__codesize() (gas: 406)
VerifyTest:testMatMul() (gas: 77512)
VerifyTest:testRationalAdd() (gas: 26033)
VerifyTest:test__codesize() (gas: 5178)
WETHInvariants:invariantTotalSupplyEqualsBalance() (runs: 256, calls: 3840, reverts: 1877)
WETHInvariants:invariantTotalSupplyEqualsBalance() (runs: 256, calls: 3840, reverts: 1740)
WETHInvariants:test__codesize() (gas: 6007)
WETHTest:testDeposit() (gas: 68090)
WETHTest:testDeposit(uint256) (runs: 256, μ: 65900, ~: 68384)
WETHTest:testDeposit(uint256) (runs: 256, μ: 65539, ~: 68384)
WETHTest:testFallbackDeposit() (gas: 67796)
WETHTest:testFallbackDeposit(uint256) (runs: 256, μ: 65561, ~: 68045)
WETHTest:testFallbackDeposit(uint256) (runs: 256, μ: 65200, ~: 68045)
WETHTest:testMetadata() (gas: 10098)
WETHTest:testPartialWithdraw() (gas: 79566)
WETHTest:testWithdraw() (gas: 59332)
WETHTest:testWithdraw(uint256,uint256) (runs: 256, μ: 76622, ~: 80326)
WETHTest:testWithdraw(uint256,uint256) (runs: 256, μ: 77037, ~: 80326)
WETHTest:testWithdrawToContractWithoutReceiveReverts() (gas: 93923)
WETHTest:test__codesize() (gas: 11079)
22 changes: 7 additions & 15 deletions src/utils/SafeTransferLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ library SafeTransferLib {
mstore(0x00, to) // Store the address in scratch space.
mstore8(0x0b, 0x73) // Opcode `PUSH20`.
mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
if iszero(create(amount, 0x0b, 0x16)) {
returndatacopy(gas(), returndatasize(), shr(20, gas())) // For gas estimation.
}
if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
}
}
}
Expand All @@ -110,9 +108,7 @@ library SafeTransferLib {
mstore(0x00, to) // Store the address in scratch space.
mstore8(0x0b, 0x73) // Opcode `PUSH20`.
mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
if iszero(create(selfbalance(), 0x0b, 0x16)) {
returndatacopy(gas(), returndatasize(), shr(20, gas())) // For gas estimation.
}
if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
}
}
}
Expand All @@ -129,9 +125,7 @@ library SafeTransferLib {
mstore(0x00, to) // Store the address in scratch space.
mstore8(0x0b, 0x73) // Opcode `PUSH20`.
mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
if iszero(create(amount, 0x0b, 0x16)) {
returndatacopy(gas(), returndatasize(), shr(20, gas())) // For gas estimation.
}
if iszero(create(amount, 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
}
}
}
Expand All @@ -141,15 +135,13 @@ library SafeTransferLib {
/// @solidity memory-safe-assembly
assembly {
// forgefmt: disable-next-line
if
iszero(call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00))
{
if iszero(
call(GAS_STIPEND_NO_GRIEF, to, selfbalance(), codesize(), 0x00, codesize(), 0x00)
) {
mstore(0x00, to) // Store the address in scratch space.
mstore8(0x0b, 0x73) // Opcode `PUSH20`.
mstore8(0x20, 0xff) // Opcode `SELFDESTRUCT`.
if iszero(create(selfbalance(), 0x0b, 0x16)) {
returndatacopy(gas(), returndatasize(), shr(20, gas())) // For gas estimation.
}
if iszero(create(selfbalance(), 0x0b, 0x16)) { revert(codesize(), codesize()) } // For gas estimation.
}
}
}
Expand Down

0 comments on commit ea6c499

Please sign in to comment.