Skip to content

Commit

Permalink
🥢 ~~
Browse files Browse the repository at this point in the history
  • Loading branch information
z0r0z committed Feb 14, 2024
1 parent c1f7921 commit fe6cab8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ IETest:testBalanceInETH() (gas: 40333)
IETest:testCommandSendERC0() (gas: 102992)
IETest:testCommandSendETH() (gas: 69474)
IETest:testCommandSendUSDC() (gas: 135722)
IETest:testCommandSwapDAI() (gas: 101711)
IETest:testCommandSwapETH() (gas: 112535)
IETest:testCommandSwapUSDC() (gas: 156092)
IETest:testCommandSwapDAI() (gas: 101991)
IETest:testCommandSwapETH() (gas: 113467)
IETest:testCommandSwapUSDC() (gas: 157045)
IETest:testDeploy() (gas: 2599275)
IETest:testENSNameOwnership() (gas: 84088)
IETest:testIENameSetting() (gas: 8142)
Expand Down
18 changes: 9 additions & 9 deletions src/IE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ contract IE {
bytes memory executeCallData
)
{
_token = _returnConstant(bytes32(bytes(token))); // Check constant.
_token = _returnTokenConstant(bytes32(bytes(token))); // Check constant.
if (_token == address(0)) _token = tokens[token]; // Check storage.
bool isETH = _token == ETH; // Memo whether the token is ETH or not.
(, _to,) = whatIsTheAddressOf(to); // Fetch receiver address from ENS.
Expand All @@ -213,9 +213,9 @@ contract IE {
virtual
returns (uint256 _amountIn, address _tokenIn, address _tokenOut)
{
_tokenIn = _returnConstant(bytes32(bytes(tokenIn)));
_tokenIn = _returnTokenConstant(bytes32(bytes(tokenIn)));
if (_tokenIn == address(0)) _tokenIn = tokens[tokenIn];
_tokenOut = _returnConstant(bytes32(bytes(tokenOut)));
_tokenOut = _returnTokenConstant(bytes32(bytes(tokenOut)));
if (_tokenOut == address(0)) _tokenOut = tokens[tokenOut];
_amountIn = _stringToUint(amountIn, _tokenIn == ETH ? 18 : _tokenIn.readDecimals());
}
Expand Down Expand Up @@ -245,7 +245,7 @@ contract IE {
}

/// @dev Checks and returns the canonical constant for a matched intent string.
function _returnConstant(bytes32 token) internal view virtual returns (address _token) {
function _returnTokenConstant(bytes32 token) internal view virtual returns (address _token) {
if (token == "eth" || token == "ether") return ETH;
if (token == "usdc") return USDC;
if (token == "usdt") return USDT;
Expand Down Expand Up @@ -279,7 +279,7 @@ contract IE {
payable
virtual
{
address _token = _returnConstant(bytes32(bytes(token)));
address _token = _returnTokenConstant(bytes32(bytes(token)));
if (_token == address(0)) _token = tokens[token];
(, address _to,) = whatIsTheAddressOf(to);
if (_token == ETH) {
Expand All @@ -295,9 +295,9 @@ contract IE {
payable
virtual
{
address _tokenIn = _returnConstant(bytes32(bytes(tokenIn)));
address _tokenIn = _returnTokenConstant(bytes32(bytes(tokenIn)));
if (_tokenIn == address(0)) _tokenIn = tokens[tokenIn];
address _tokenOut = _returnConstant(bytes32(bytes(tokenOut)));
address _tokenOut = _returnTokenConstant(bytes32(bytes(tokenOut)));
if (_tokenOut == address(0)) _tokenOut = tokens[tokenOut];
bool isETH = _tokenIn == ETH;
if (isETH) _tokenIn = WETH;
Expand Down Expand Up @@ -386,7 +386,7 @@ contract IE {
{
(, address _name,) = whatIsTheAddressOf(name);
string memory normalized = _lowercase(token);
address _token = _returnConstant(bytes32(bytes(normalized)));
address _token = _returnTokenConstant(bytes32(bytes(normalized)));
if (_token == address(0)) _token = tokens[token];
bool isETH = _token == ETH;
balance = isETH ? _name.balance : _token.balanceOf(_name);
Expand All @@ -400,7 +400,7 @@ contract IE {
virtual
returns (uint256 supply, uint256 supplyAdjusted)
{
address _token = _returnConstant(bytes32(bytes(token)));
address _token = _returnTokenConstant(bytes32(bytes(token)));
if (_token == address(0)) _token = tokens[token];
if (_token == ETH) revert InvalidSyntax();
supply = _totalSupply(_token);
Expand Down

0 comments on commit fe6cab8

Please sign in to comment.