Skip to content

Commit

Permalink
fix: uni v3 get_balance for non verified token (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Mar 3, 2024
1 parent d2546b7 commit 01eb53c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions y/prices/dex/uniswap/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ async def check_liquidity(self, token: AnyAddressType, block: Block) -> Optional
if block < await self.deploy_block(sync=False):
logger.debug("block %s prior to %s deploy block", block, self)
return 0
liquidity = await self[token].balance_of(self.address, block, sync=False)
try:
liquidity = await self[token].balance_of(self.address, block, sync=False)
except ContractNotVerified:
logger.debug("%s is not verified and we cannot fetch balance the usual way. returning 0.", token)
logger.debug("%s liquidity for %s at %s: %s", self, token, block, liquidity)
return liquidity

Expand Down Expand Up @@ -209,7 +212,7 @@ async def check_liquidity(self, token: Address, block: Block, ignore_pools: Tupl
if len(token_out_liquidity[token_out]) > 1 and liquidity == token_out_min_liquidity[token_out]:
logger.debug("ignoring liquidity for %s", pool)
token_in_tasks.pop(pool)
elif token_out == weth and await task < 10 ** 19: # 10 ETH
elif token_out == weth and liquidity < 10 ** 19: # 10 ETH
# NOTE: this is totally arbitrary, works for all known cases but eventually will probably cause issues
logger.debug("insufficient liquidity for %s", pool)
token_in_tasks.pop(pool)
Expand Down

0 comments on commit 01eb53c

Please sign in to comment.