6
6
import inspect
7
7
import pandas as pd
8
8
9
- from anchorpy import Wallet
9
+ from anchorpy . provider import Wallet
10
10
from dotenv import load_dotenv
11
11
from driftpy .drift_client import DriftClient
12
12
from driftpy .market_map .market_map import MarketMap
@@ -30,7 +30,7 @@ def format_pubkey(pubkey: str) -> str:
30
30
"""Truncate pubkey for display."""
31
31
return f"{ str (pubkey )[:10 ]} ...{ str (pubkey )[- 10 :]} "
32
32
33
- def format_number (number : int , decimals = 6 ) -> str :
33
+ def format_number (number : int | float , decimals = 6 ) -> str :
34
34
"""Format large numbers for better readability."""
35
35
return f"{ number / (10 ** decimals ):,.6f} "
36
36
@@ -146,7 +146,7 @@ def display_attribute(market_data, attr_path: str, debug_mode: bool = False):
146
146
147
147
# If it's a Pubkey or similar
148
148
if hasattr (val , '__class__' ) and val .__class__ .__name__ == 'Pubkey' :
149
- return f"{ attr_path } : { format_pubkey (val )} "
149
+ return f"{ attr_path } : { format_pubkey (str ( val ) )} "
150
150
151
151
# If it's an int that might represent a 'price' or 'reserve'
152
152
if isinstance (val , int ):
@@ -201,7 +201,7 @@ def format_complex_object(attr_name, obj):
201
201
if isinstance (attr_val , (int , float )) and any (x in attr_name .lower () for x in ["price" , "amount" , "balance" ]):
202
202
formatted_value = format_number (attr_val , 6 )
203
203
elif hasattr (attr_val , '__class__' ) and attr_val .__class__ .__name__ == 'Pubkey' :
204
- formatted_value = format_pubkey (attr_val )
204
+ formatted_value = format_pubkey (str ( attr_val ) )
205
205
else :
206
206
formatted_value = str (attr_val )
207
207
result .append (f" • { attr_name } : { formatted_value } " )
@@ -228,7 +228,7 @@ def format_complex_object(attr_name, obj):
228
228
if isinstance (value , (int , float )) and any (x in name .lower () for x in ["price" , "amount" , "balance" ]):
229
229
formatted_value = format_number (value , 6 )
230
230
elif hasattr (value , '__class__' ) and value .__class__ .__name__ == 'Pubkey' :
231
- formatted_value = format_pubkey (value )
231
+ formatted_value = format_pubkey (str ( value ) )
232
232
elif (hasattr (value , '__class__' )
233
233
and not isinstance (value , (str , int , float , bool , list , dict ))
234
234
and hasattr (value , '__dict__' )):
@@ -278,7 +278,7 @@ async def _fetch_market_maps():
278
278
perp_market_map = MarketMap (
279
279
MarketMapConfig (
280
280
drift_client .program ,
281
- MarketType .Perp (),
281
+ MarketType .Perp (), # type: ignore
282
282
WebsocketConfig (resub_timeout_ms = 10000 ),
283
283
connection ,
284
284
)
@@ -289,7 +289,7 @@ async def _fetch_market_maps():
289
289
spot_market_map = MarketMap (
290
290
MarketMapConfig (
291
291
drift_client .program ,
292
- MarketType .Spot (),
292
+ MarketType .Spot (), # type: ignore
293
293
WebsocketConfig (resub_timeout_ms = 10000 ),
294
294
connection ,
295
295
)
0 commit comments