Skip to content

Commit

Permalink
fix: wallets Decimal err (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Nov 12, 2023
1 parent f2c6fa4 commit 14a4594
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions yearn/outputs/describers/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ async def describe_wallets(self, vault_address, block=None):
'total wallets': len(set(wallet for wallet, bal in balances.items())),
'wallet balances': {
wallet: {
"token balance": float(bal),
"usd balance": float(bal) * price
"token balance": bal,
"usd balance": bal * price
} for wallet, bal in balances.items()
}
}
Expand Down
5 changes: 3 additions & 2 deletions yearn/outputs/postgres/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from typing import Optional
from decimal import Decimal
from typing import Dict, Optional

from brownie import ZERO_ADDRESS, chain, convert
from brownie.convert.datatypes import HexString
Expand Down Expand Up @@ -115,7 +116,7 @@ def last_recorded_block(Entity: db.Entity) -> int:
return select(max(e.block) for e in Entity if e.chainid == chain.id).first()

@db_session
def fetch_balances(vault_address: str, block=None):
def fetch_balances(vault_address: str, block=None) -> Dict[str, Decimal]:
token_dbid = select(t.token_id for t in Token if t.chain.chainid == chain.id and t.address.address == vault_address).first()
if block and block > last_recorded_block(UserTx):
# NOTE: we use `postgres.` instead of `self.` so we can make use of parallelism
Expand Down
3 changes: 2 additions & 1 deletion yearn/prices/magic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
from decimal import Decimal
from typing import Optional

from brownie import chain
Expand All @@ -24,7 +25,7 @@

logger = logging.getLogger(__name__)

async def _get_price(token: AnyAddressType, block: Optional[Block]) -> float:
async def _get_price(token: AnyAddressType, block: Optional[Block]) -> Decimal:
""" Performs some checks before deferring to ypricemagic. """

if chain.id == Network.Mainnet:
Expand Down

0 comments on commit 14a4594

Please sign in to comment.