Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crispheaney/python improvements #32

Merged
merged 4 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions python/sdk/jit_proxy/jit_proxy_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ async def jit(self, params: JitIxParams):
else [],
)

if params.referrer_info is not None:
remaining_accounts.append(
AccountMeta(
pubkey=params.referrer_info.referrer,
is_writable=True,
is_signer=False,
)
)
remaining_accounts.append(
AccountMeta(
pubkey=params.referrer_info.referrer_stats,
is_writable=True,
is_signer=False,
)
)

if is_variant(order.market_type, "Spot"):
remaining_accounts.append(
AccountMeta(
Expand Down
4 changes: 0 additions & 4 deletions python/sdk/jit_proxy/jitter/base_jitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,9 @@ async def on_account_update(self, taker: UserAccount, taker_key: Pubkey, slot: i

for order in taker.orders:
if not is_variant(order.status, "Open"):
self.logger.info("Order is closed.")
self.logger.info("----------------------------")
continue

if not has_auction_price(order, slot):
self.logger.info("Order does not have auction price.")
self.logger.info("----------------------------")
continue

if self.user_filter is not None:
Expand Down
18 changes: 10 additions & 8 deletions python/sdk/jit_proxy/jitter/jitter_shotgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ async def create_try_fill(
self.logger.info("JitterShotgun: Creating Try Fill")

async def try_fill():
for i in range(10):
taker_stats = await get_user_stats_account(
self.drift_client.program, taker.authority
)

referrer_info = self.get_referrer_info(taker_stats)

for i in range(order.auction_duration):
params = (
self.perp_params.get(order.market_index)
if is_variant(order.market_type, "Perp")
Expand All @@ -48,12 +54,6 @@ async def try_fill():
self.ongoing_auctions.pop(order_sig)
return

taker_stats = await get_user_stats_account(
self.drift_client.program, taker.authority
)

referrer_info = self.get_referrer_info(taker_stats)

self.logger.info(f"Trying to fill {order_sig} -> Attempt: {i + 1}")

try:
Expand All @@ -73,7 +73,7 @@ async def try_fill():
params.price_type,
referrer_info,
params.sub_account_id,
PostOnlyParams.TryPostOnly(),
PostOnlyParams.MustPostOnly(),
)
)

Expand All @@ -86,6 +86,8 @@ async def try_fill():
self.logger.error(f"Failed to fill Order: {order_sig}")
if "0x1770" in str(e) or "0x1771" in str(e):
self.logger.error(f"Order: {order_sig} does not cross params yet, retrying")
elif "0x1779" in str(e):
self.logger.error(f"Order: {order_sig} could not fill, retrying")
elif "0x1793" in str(e):
self.logger.error("Oracle invalid, retrying")
elif "0x1772" in str(e):
Expand Down
2 changes: 2 additions & 0 deletions python/sdk/jit_proxy/jitter/jitter_sniper.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ async def try_fill():
self.logger.error(f"Failed to fill {order_sig}: {e}")
if "0x1770" in str(e) or "0x1771" in str(e):
self.logger.error("Order does not cross params yet")
elif "0x1779" in str(e):
self.logger.error("Order could not fill, retrying")
elif "0x1793" in str(e):
self.logger.error("Oracle invalid")
elif "0x1772" in str(e):
Expand Down
Loading