Skip to content

Commit

Permalink
πŸ₯’ ~~
Browse files Browse the repository at this point in the history
  • Loading branch information
z0r0z committed Feb 15, 2024
1 parent 46f3661 commit 445430c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
38 changes: 19 additions & 19 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
IETest:testBalanceInERC20() (gas: 52391)
IETest:testBalanceInETH() (gas: 43495)
IETest:testCommandSendERC0() (gas: 103640)
IETest:testCommandSendETH() (gas: 70119)
IETest:testCommandSendUSDC() (gas: 136370)
IETest:testCommandSwapDAI() (gas: 102128)
IETest:testCommandSwapETH() (gas: 113501)
IETest:testCommandSwapForETH() (gas: 123704)
IETest:testCommandSwapUSDC() (gas: 156135)
IETest:testCommandSwapUSDCForWBTC() (gas: 164392)
IETest:testDeploy() (gas: 2650229)
IETest:testENSNameOwnership() (gas: 87602)
IETest:testIENameSetting() (gas: 10978)
IETest:testPreviewCommandSendDecimals() (gas: 96485)
IETest:testPreviewCommandSendUSDC() (gas: 69606)
IETest:testPreviewSend() (gas: 46115)
IETest:testPreviewSendCommand() (gas: 57997)
IETest:testSendETH() (gas: 60357)
IETest:testTotalSupply() (gas: 18031)
IETest:testBalanceInERC20() (gas: 49207)
IETest:testBalanceInETH() (gas: 40333)
IETest:testCommandSendERC0() (gas: 102975)
IETest:testCommandSendETH() (gas: 69457)
IETest:testCommandSendUSDC() (gas: 135705)
IETest:testCommandSwapDAI() (gas: 102106)
IETest:testCommandSwapETH() (gas: 113473)
IETest:testCommandSwapForETH() (gas: 123421)
IETest:testCommandSwapUSDC() (gas: 156848)
IETest:testCommandSwapUSDCForWBTC() (gas: 165030)
IETest:testDeploy() (gas: 2647221)
IETest:testENSNameOwnership() (gas: 84066)
IETest:testIENameSetting() (gas: 8142)
IETest:testPreviewCommandSendDecimals() (gas: 91972)
IETest:testPreviewCommandSendUSDC() (gas: 66096)
IETest:testPreviewSend() (gas: 42673)
IETest:testPreviewSendCommand() (gas: 54554)
IETest:testSendETH() (gas: 59695)
IETest:testTotalSupply() (gas: 14808)
2 changes: 1 addition & 1 deletion lib/forge-std
11 changes: 4 additions & 7 deletions src/IE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -445,17 +445,14 @@ contract IE {
address _token = _returnTokenConstant(bytes32(bytes(token)));
if (_token == address(0)) _token = tokens[token];
if (_token == ETH) revert InvalidSyntax();
supply = _totalSupply(_token);
supplyAdjusted = supply / 10 ** _token.readDecimals();
}

/// @dev Returns the total supply of ERC20/721 `token`.
function _totalSupply(address token) internal view virtual returns (uint256 supply) {
assembly ("memory-safe") {
mstore(0x00, 0x18160ddd) // `totalSupply()`.
if iszero(staticcall(gas(), token, 0x1c, 0x04, 0x20, 0x20)) { revert(codesize(), 0x00) }
if iszero(staticcall(gas(), _token, 0x1c, 0x04, 0x20, 0x20)) {
revert(codesize(), 0x00)
}
supply := mload(0x20)
}
supplyAdjusted = supply / 10 ** _token.readDecimals();
}

/// ====================== ENS VERIFICATION ====================== ///
Expand Down

0 comments on commit 445430c

Please sign in to comment.