Skip to content

Commit

Permalink
chore: refactor common.py (#586)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Apr 22, 2024
1 parent b9753c3 commit 295ba2f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions y/classes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,7 @@ async def total_supply(self, block: Optional[Block] = None) -> int:
return await totalSupply(self.address, block=block, sync=False)

async def total_supply_readable(self, block: Optional[Block] = None) -> float:
total_supply, scale = await asyncio.gather(
self.total_supply(block=block, sync=False),
self.__scale__
)
total_supply, scale = await asyncio.gather(self.total_supply(block=block, sync=False), self.__scale__)
return total_supply / scale

async def balance_of(self, address: AnyAddressType, block: Optional[Block] = None) -> int:
Expand Down Expand Up @@ -301,7 +298,7 @@ async def readable(self) -> Decimal:

@a_sync.aka.property
async def price(self) -> Decimal:
price = await self.token.price(block=self.block, skip_cache=self._skip_cache, ignore_pools=self._ignore_pools, sync=False)
price = Decimal(await self.token.price(block=self.block, skip_cache=self._skip_cache, ignore_pools=self._ignore_pools, sync=False))
self._logger.debug("balance: %s price: %s", self, price)
return price
__price__: HiddenMethodDescriptor[Self, Decimal]
Expand All @@ -311,7 +308,7 @@ async def value_usd(self) -> Decimal:
if self.balance == 0:
return 0
balance, price = await asyncio.gather(self.__readable__, self.__price__)
value = balance * Decimal(price)
value = balance * price
self._logger.debug("balance: %s price: %s value: %s", balance, price, value)
return value
__value_usd__: HiddenMethodDescriptor[Self, Decimal]
Expand Down

0 comments on commit 295ba2f

Please sign in to comment.