Skip to content

Commit 2a4cc06

Browse files
committed
simplify
1 parent b7ce6dd commit 2a4cc06

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

contracts/token/ERC20/extensions/ERC4626.sol

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,16 @@ abstract contract ERC4626 is ERC20, IERC4626 {
8787
*/
8888
function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool ok, uint8 assetDecimals) {
8989
Memory.Pointer ptr = Memory.getFreeMemoryPointer();
90-
(bool success, bytes32 encodedDecimals, ) = LowLevelCall.staticcallReturn64Bytes(
90+
(bool success, bytes32 returnedDecimals, ) = LowLevelCall.staticcallReturn64Bytes(
9191
address(asset_),
9292
abi.encodeCall(IERC20Metadata.decimals, ())
9393
);
94-
if (success && LowLevelCall.returnDataSize() >= 32) {
95-
uint256 returnedDecimals = uint256(encodedDecimals);
96-
if (returnedDecimals <= type(uint8).max) {
97-
Memory.setFreeMemoryPointer(ptr);
98-
return (true, uint8(returnedDecimals));
99-
}
100-
}
10194
Memory.setFreeMemoryPointer(ptr);
102-
return (false, 0);
95+
96+
return
97+
(success && LowLevelCall.returnDataSize() >= 32 && uint256(returnedDecimals) <= type(uint8).max)
98+
? (true, uint8(uint256(returnedDecimals)))
99+
: (false, 0);
103100
}
104101

105102
/**

0 commit comments

Comments
 (0)