Skip to content

Commit

Permalink
uhhh
Browse files Browse the repository at this point in the history
  • Loading branch information
soundsonacid committed Jul 24, 2024
1 parent dd69f41 commit b14643b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 51 deletions.
24 changes: 12 additions & 12 deletions src/driftpy/accounts/cache/drift_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ async def update_cache(self):
spot_market_and_slot.data.oracle,
spot_market_and_slot.data.oracle_source,
)
oracle_data[
str(spot_market_and_slot.data.oracle)
] = oracle_price_data_and_slot
oracle_data[str(spot_market_and_slot.data.oracle)] = (
oracle_price_data_and_slot
)

self.cache["spot_markets"] = spot_markets

Expand All @@ -98,9 +98,9 @@ async def update_cache(self):
perp_market_and_slot.data.amm.oracle,
perp_market_and_slot.data.amm.oracle_source,
)
oracle_data[
str(perp_market_and_slot.data.amm.oracle)
] = oracle_price_data_and_slot
oracle_data[str(perp_market_and_slot.data.amm.oracle)] = (
oracle_price_data_and_slot
)

self.cache["perp_markets"] = perp_markets

Expand Down Expand Up @@ -128,9 +128,9 @@ async def update_cache(self):
spot_market_and_slot.data.oracle,
spot_market_and_slot.data.oracle_source,
)
oracle_data[
str(spot_market_and_slot.data.oracle)
] = oracle_price_data_and_slot
oracle_data[str(spot_market_and_slot.data.oracle)] = (
oracle_price_data_and_slot
)

self.cache["spot_markets"] = spot_markets

Expand All @@ -149,9 +149,9 @@ async def update_cache(self):
perp_market_and_slot.data.amm.oracle,
perp_market_and_slot.data.amm.oracle_source,
)
oracle_data[
str(perp_market_and_slot.data.amm.oracle)
] = oracle_price_data_and_slot
oracle_data[str(perp_market_and_slot.data.amm.oracle)] = (
oracle_price_data_and_slot
)

self.cache["perp_markets"] = perp_markets

Expand Down
60 changes: 27 additions & 33 deletions src/driftpy/drift_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,9 +1103,9 @@ async def place_spot_order(
self.get_place_spot_order_ix(order_params, sub_account_id),
]
)
self.last_spot_market_seen_cache[
order_params.market_index
] = tx_sig_and_slot.slot
self.last_spot_market_seen_cache[order_params.market_index] = (
tx_sig_and_slot.slot
)
self.last_spot_market_seen_cache[QUOTE_SPOT_MARKET_INDEX] = tx_sig_and_slot.slot
return tx_sig_and_slot.tx_sig

Expand Down Expand Up @@ -1151,9 +1151,9 @@ async def place_perp_order(
self.get_place_perp_order_ix(order_params, sub_account_id),
]
)
self.last_perp_market_seen_cache[
order_params.market_index
] = tx_sig_and_slot.slot
self.last_perp_market_seen_cache[order_params.market_index] = (
tx_sig_and_slot.slot
)
return tx_sig_and_slot.tx_sig

def get_place_perp_order_ix(
Expand Down Expand Up @@ -1199,13 +1199,13 @@ async def place_orders(

for order_param in order_params:
if is_variant(order_param.market_type, "Perp"):
self.last_perp_market_seen_cache[
order_param.market_index
] = tx_sig_and_slot.slot
self.last_perp_market_seen_cache[order_param.market_index] = (
tx_sig_and_slot.slot
)
else:
self.last_spot_market_seen_cache[
order_param.market_index
] = tx_sig_and_slot.slot
self.last_spot_market_seen_cache[order_param.market_index] = (
tx_sig_and_slot.slot
)

return tx_sig_and_slot.tx_sig

Expand Down Expand Up @@ -1399,13 +1399,13 @@ async def cancel_and_place_orders(

for order_param in place_order_params:
if is_variant(order_param.market_type, "Perp"):
self.last_perp_market_seen_cache[
order_param.market_index
] = tx_sig_and_slot.slot
self.last_perp_market_seen_cache[order_param.market_index] = (
tx_sig_and_slot.slot
)
else:
self.last_spot_market_seen_cache[
order_param.market_index
] = tx_sig_and_slot.slot
self.last_spot_market_seen_cache[order_param.market_index] = (
tx_sig_and_slot.slot
)

return tx_sig_and_slot.tx_sig

Expand Down Expand Up @@ -1525,9 +1525,9 @@ async def place_and_take_perp_order(
),
]
)
self.last_perp_market_seen_cache[
order_params.market_index
] = tx_sig_and_slot.slot
self.last_perp_market_seen_cache[order_params.market_index] = (
tx_sig_and_slot.slot
)
return tx_sig_and_slot.tx_sig

def get_place_and_take_perp_order_ix(
Expand All @@ -1546,9 +1546,7 @@ def get_place_and_take_perp_order_ix(
maker_infos = (
maker_info
if isinstance(maker_info, list)
else [maker_info]
if maker_info
else []
else [maker_info] if maker_info else []
)

user_accounts = [self.get_user_account(sub_account_id)]
Expand Down Expand Up @@ -1623,9 +1621,9 @@ async def place_and_take_spot_order(
),
]
)
self.last_spot_market_seen_cache[
order_params.market_index
] = tx_sig_and_slot.slot
self.last_spot_market_seen_cache[order_params.market_index] = (
tx_sig_and_slot.slot
)
return tx_sig_and_slot.tx_sig

def get_place_and_take_spot_order_ix(
Expand All @@ -1648,9 +1646,7 @@ def get_place_and_take_spot_order_ix(
maker_infos = (
maker_info
if isinstance(maker_info, list)
else [maker_info]
if maker_info
else []
else [maker_info] if maker_info else []
)
for maker_info in maker_infos:
user_accounts.append(maker_info.maker_user_account)
Expand Down Expand Up @@ -2608,9 +2604,7 @@ async def get_fill_perp_order_ix(
maker_info = (
maker_info
if isinstance(maker_info, list)
else [maker_info]
if maker_info
else []
else [maker_info] if maker_info else []
)

user_accounts = [user_account]
Expand Down
12 changes: 6 additions & 6 deletions src/driftpy/pickle/vat.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@ def load_oracles(
with open(perp_filename, "rb") as f:
perp_oracles: list[PickledData] = pickle.load(f)
for oracle in perp_oracles:
self.perp_oracles[
oracle.pubkey
] = oracle.data # oracle.pubkey is actually a market index
self.perp_oracles[oracle.pubkey] = (
oracle.data
) # oracle.pubkey is actually a market index
else:
raise FileNotFoundError(f"File {perp_filename} not found")

if os.path.exists(spot_filename):
with open(spot_filename, "rb") as f:
spot_oracles: list[PickledData] = pickle.load(f)
for oracle in spot_oracles:
self.spot_oracles[
oracle.pubkey
] = oracle.data # oracle.pubkey is actually a market index
self.spot_oracles[oracle.pubkey] = (
oracle.data
) # oracle.pubkey is actually a market index
else:
raise FileNotFoundError(f"File {spot_filename} not found")

0 comments on commit b14643b

Please sign in to comment.