'ohlc' pubsub message has period

This commit is contained in:
Tim
2024-03-19 18:27:38 -04:00
parent 5fcc592f35
commit 45c87ea2b5
2 changed files with 4 additions and 3 deletions

View File

@@ -505,10 +505,11 @@ def save_json(obj, filename):
def pub_ohlc(_series:str, key: OHLCKey, bars: list[NativeOHLC]):
pool_addr, period = key
chain_id = current_chain.get().chain_id
period = period_name(period)
return (
f'{chain_id}|{pool_addr}|{period_name(period)}', # channel name is like 0x...|1m
f'{chain_id}|{pool_addr}|{period}', # channel name is like 0x...|1m
'ohlc',
(chain_id, pool_addr, [b.ohlc for b in bars])
(chain_id, pool_addr, period, [b.ohlc for b in bars])
)
def ohlc_key_to_str(k):

View File

@@ -44,7 +44,7 @@ async def load_pool(address: str) -> PoolDict:
decimals = token0['decimals'] - token1['decimals']
found = PoolDict(type='Pool', chain=chain_id, address=address, exchange=Exchange.UniswapV3.value,
base=t0, quote=t1, fee=fee, decimals=decimals)
log.debug(f'new UniswapV3 pool {token0["symbol"]}/{token1["symbol"]} '
log.debug(f'new UniswapV3 pool {token0["symbol"]}/{token1["symbol"]} {fee/1_000_000:.2%}'
f'{("."+str(decimals)) if decimals >= 0 else (str(-decimals)+".")} {address}')
except ContractLogicError:
pass