Improvements to PBC
This commit is contained in:
parent
949244656a
commit
d4a4d255fc
|
@ -10,7 +10,7 @@ import fin_defs
|
||||||
import requests
|
import requests
|
||||||
from frozendict import frozendict
|
from frozendict import frozendict
|
||||||
|
|
||||||
from . import DepoGroup, DepoSingle
|
from .data import DepoGroup, DepoSingle
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ MPC_DECIMALS = 10000
|
||||||
|
|
||||||
|
|
||||||
def shard_id_for_address(address: str) -> str:
|
def shard_id_for_address(address: str) -> str:
|
||||||
|
assert address is not None, 'missing address'
|
||||||
if address.endswith('a'):
|
if address.endswith('a'):
|
||||||
return 'shards/Shard0/' # TODO
|
return 'shards/Shard0/' # TODO
|
||||||
elif address.endswith('2'):
|
elif address.endswith('2'):
|
||||||
|
@ -127,19 +128,29 @@ class PbcClient:
|
||||||
return self.get_json(url, data=data)
|
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:
|
class PartisiaBlockchainAccountDepoFetcher:
|
||||||
def __init__(self, session, blockchain_address: str):
|
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.client = PbcClient(session)
|
||||||
self.blockchain_address = blockchain_address
|
self.blockchain_address = blockchain_address
|
||||||
|
|
||||||
def get_depo(self) -> DepoGroup:
|
def get_depo(self) -> DepoGroup:
|
||||||
balances = self.client.get_account_balances(self.blockchain_address)
|
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(
|
depo_byoc = DepoSingle(
|
||||||
'BYOC',
|
'BYOC',
|
||||||
balances.update_time,
|
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(
|
return DepoGroup(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user