diff --git a/fin_depo/defi_partisia_blockchain.py b/fin_depo/defi_partisia_blockchain.py index 407167b..1d40368 100644 --- a/fin_depo/defi_partisia_blockchain.py +++ b/fin_depo/defi_partisia_blockchain.py @@ -10,7 +10,7 @@ import fin_defs import requests from frozendict import frozendict -from . import DepoGroup, DepoSingle +from .data import DepoGroup, DepoSingle logger = logging.getLogger(__name__) @@ -30,6 +30,7 @@ MPC_DECIMALS = 10000 def shard_id_for_address(address: str) -> str: + assert address is not None, 'missing address' if address.endswith('a'): return 'shards/Shard0/' # TODO elif address.endswith('2'): @@ -127,19 +128,29 @@ class PbcClient: return self.get_json(url, data=data) +BYOC_ASSETS = { + 'ETH': fin_defs.WELL_KNOWN_SYMBOLS['ETH'], + 'POLYGON_USDC': fin_defs.WELL_KNOWN_SYMBOLS['USDC'], + 'BNB': fin_defs.WELL_KNOWN_SYMBOLS['BNB'], + 'MATIC': fin_defs.WELL_KNOWN_SYMBOLS['MATIC'], +} + class PartisiaBlockchainAccountDepoFetcher: def __init__(self, session, blockchain_address: str): + assert session is not None, 'missing session' + assert blockchain_address is not None, 'missing blockchain_address' + self.client = PbcClient(session) self.blockchain_address = blockchain_address def get_depo(self) -> DepoGroup: balances = self.client.get_account_balances(self.blockchain_address) - depo_mpc = DepoSingle('MPC', balances.update_time, {fin_defs.MPC: balances.mpc}) + depo_mpc = DepoSingle('Native', balances.update_time, {fin_defs.MPC: balances.mpc}) depo_byoc = DepoSingle( 'BYOC', balances.update_time, - {fin_defs.WELL_KNOWN_SYMBOLS[k]: v for k, v in balances.byoc.items()}, + {BYOC_ASSETS[k]: v for k, v in balances.byoc.items()}, ) return DepoGroup(