Skip to content

Commit f74d23a

Browse files
committed
test: fixed test for v1
1 parent 8ea74cf commit f74d23a

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎tests/test_uniswap.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,10 @@ def test_get_price_input(self, client, tokens, token0, token1, qty, kwargs):
169169
"token0, token1, qty, kwargs",
170170
[
171171
("ETH", "UNI", ONE_ETH, {}),
172-
("UNI", "ETH", ONE_ETH, {}),
172+
("UNI", "ETH", ONE_ETH // 100, {}),
173173
("ETH", "DAI", ONE_ETH, {}),
174174
("DAI", "ETH", ONE_ETH, {}),
175175
("ETH", "UNI", 2 * ONE_ETH, {}),
176-
("UNI", "ETH", 2 * ONE_ETH, {}),
177176
("WETH", "DAI", ONE_ETH, {}),
178177
("DAI", "WETH", ONE_ETH, {}),
179178
("DAI", "USDC", ONE_USDC, {"fee": 500}),

‎uniswap/uniswap.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,15 @@ def get_token(self, address: AddressLike, abi_name: str = "erc20") -> ERC20Token
12101210
"""
12111211
# FIXME: This function should always return the same output for the same input
12121212
# and would therefore benefit from caching
1213+
if address == "0x0000000000000000000000000000000000000000":
1214+
# This isn't exactly right, but for all intents and purposes,
1215+
# ETH is treated as a ERC20 by Uniswap.
1216+
return ERC20Token(
1217+
address=address,
1218+
name="ETH",
1219+
symbol="ETH",
1220+
decimals=18,
1221+
)
12131222
token_contract = _load_contract(self.w3, abi_name, address=address)
12141223
try:
12151224
_name = token_contract.functions.name().call()
@@ -1222,11 +1231,11 @@ def get_token(self, address: AddressLike, abi_name: str = "erc20") -> ERC20Token
12221231
raise InvalidToken(address)
12231232
try:
12241233
name = _name.decode()
1225-
except:
1234+
except Exception:
12261235
name = _name
12271236
try:
12281237
symbol = _symbol.decode()
1229-
except:
1238+
except Exception:
12301239
symbol = _symbol
12311240
return ERC20Token(symbol, address, name, decimals)
12321241

0 commit comments

Comments
 (0)