Skip to content

Commit e920f08

Browse files
authored
frank/update driftpy (#34)
* chore: update driftpy 0.7.19 -> 0.7.20 * silence all the annoying mypy linter errors
1 parent 82ccbdd commit e920f08

File tree

5 files changed

+41
-41
lines changed

5 files changed

+41
-41
lines changed

python/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ python = "^3.10"
1313
python-dotenv = "^1.0.0"
1414
solana = "^0.30.1"
1515
anchorpy = "^0.17.1"
16-
driftpy = "^0.7.19"
16+
driftpy = "^0.7.20"
1717

1818
[build-system]
1919
requires = ["poetry-core"]

python/sdk/jit_proxy/jit_proxy_client.py

+21-21
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from typing import Optional, cast
33

44
from borsh_construct.enum import _rust_enum
5-
from sumtypes import constructor
5+
from sumtypes import constructor # type: ignore
66

7-
from solders.pubkey import Pubkey
7+
from solders.pubkey import Pubkey # type: ignore
88

99
from anchorpy import Context, Program
1010

@@ -74,7 +74,7 @@ async def jit(self, params: JitIxParams):
7474
await self.init()
7575

7676
sub_account_id = self.drift_client.get_sub_account_id_for_ix(
77-
params.sub_account_id
77+
params.sub_account_id # type: ignore
7878
)
7979

8080
order = next(
@@ -90,11 +90,11 @@ async def jit(self, params: JitIxParams):
9090
params.taker,
9191
self.drift_client.get_user_account(sub_account_id),
9292
],
93-
writable_spot_market_indexes=[order.market_index, QUOTE_SPOT_MARKET_INDEX]
94-
if is_variant(order.market_type, "Spot")
93+
writable_spot_market_indexes=[order.market_index, QUOTE_SPOT_MARKET_INDEX] # type: ignore
94+
if is_variant(order.market_type, "Spot") # type: ignore
9595
else [],
96-
writable_perp_market_indexes=[order.market_index]
97-
if is_variant(order.market_type, "Perp")
96+
writable_perp_market_indexes=[order.market_index] # type: ignore
97+
if is_variant(order.market_type, "Perp") # type: ignore
9898
else [],
9999
)
100100

@@ -114,35 +114,35 @@ async def jit(self, params: JitIxParams):
114114
)
115115
)
116116

117-
if is_variant(order.market_type, "Spot"):
117+
if is_variant(order.market_type, "Spot"): # type: ignore
118118
remaining_accounts.append(
119119
AccountMeta(
120-
pubkey=self.drift_client.get_spot_market_account(
121-
order.market_index
120+
pubkey=self.drift_client.get_spot_market_account( # type: ignore
121+
order.market_index # type: ignore
122122
).vault,
123123
is_writable=False,
124124
is_signer=False,
125125
)
126126
)
127127
remaining_accounts.append(
128128
AccountMeta(
129-
pubkey=self.drift_client.get_quote_spot_market_account().vault,
129+
pubkey=self.drift_client.get_quote_spot_market_account().vault, # type: ignore
130130
is_writable=False,
131131
is_signer=False,
132132
)
133133
)
134134

135-
jit_params = self.program.type["JitParams"](
135+
jit_params = self.program.type["JitParams"]( # type: ignore
136136
taker_order_id=params.taker_order_id,
137137
max_position=cast(int, params.max_position),
138138
min_position=cast(int, params.min_position),
139139
bid=cast(int, params.bid),
140140
ask=cast(int, params.ask),
141-
price_type=self.get_price_type(params.price_type),
141+
price_type=self.get_price_type(params.price_type), # type: ignore
142142
post_only=self.get_post_only(params.post_only),
143143
)
144144

145-
ix = self.program.instruction["jit"](
145+
ix = self.program.instruction["jit"]( # type: ignore
146146
jit_params,
147147
ctx=Context(
148148
accounts={
@@ -156,7 +156,7 @@ async def jit(self, params: JitIxParams):
156156
"authority": self.drift_client.wallet.public_key,
157157
"drift_program": self.drift_client.program_id,
158158
},
159-
signers={self.drift_client.wallet},
159+
signers={self.drift_client.wallet}, # type: ignore
160160
remaining_accounts=remaining_accounts,
161161
),
162162
)
@@ -167,16 +167,16 @@ async def jit(self, params: JitIxParams):
167167

168168
def get_price_type(self, price_type: PriceType):
169169
if is_variant(price_type, "Oracle"):
170-
return self.program.type["PriceType"].Oracle()
170+
return self.program.type["PriceType"].Oracle() # type: ignore
171171
elif is_variant(price_type, "Limit"):
172-
return self.program.type["PriceType"].Limit()
173-
else:
172+
return self.program.type["PriceType"].Limit() # type: ignore
173+
else:
174174
raise ValueError(f"Unknown price type: {str(price_type)}")
175175

176176
def get_post_only(self, post_only: PostOnlyParams):
177177
if is_variant(post_only, "MustPostOnly"):
178-
return self.program.type["PostOnlyParam"].MustPostOnly()
178+
return self.program.type["PostOnlyParam"].MustPostOnly() # type: ignore
179179
elif is_variant(post_only, "TryPostOnly"):
180-
return self.program.type["PostOnlyParam"].TryPostOnly()
180+
return self.program.type["PostOnlyParam"].TryPostOnly() # type: ignore
181181
elif is_variant(post_only, "Slide"):
182-
return self.program.type["PostOnlyParam"].Slide()
182+
return self.program.type["PostOnlyParam"].Slide() # type: ignore

python/sdk/jit_proxy/jitter/base_jitter.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from abc import ABC, abstractmethod
66
from dataclasses import dataclass
77

8-
from solders.pubkey import Pubkey
8+
from solders.pubkey import Pubkey # type: ignore
99

1010
from driftpy.types import is_variant, UserAccount, Order, UserStatsAccount, ReferrerInfo
1111
from driftpy.drift_client import DriftClient
@@ -72,7 +72,7 @@ async def on_account_update(self, taker: UserAccount, taker_key: Pubkey, slot: i
7272
taker_key_str = str(taker_key)
7373

7474
taker_stats_key = get_user_stats_account_public_key(
75-
self.drift_client.program_id, taker.authority
75+
self.drift_client.program_id, taker.authority # type: ignore
7676
)
7777

7878
self.logger.info(f"Taker: {taker.authority}")
@@ -110,7 +110,7 @@ async def on_account_update(self, taker: UserAccount, taker_key: Pubkey, slot: i
110110

111111
if (
112112
order.base_asset_amount - order.base_asset_amount_filled
113-
<= perp_market_account.amm.min_order_size
113+
<= perp_market_account.amm.min_order_size # type: ignore
114114
):
115115
self.logger.info("Order filled within min_order_size")
116116
self.logger.info("----------------------------")
@@ -138,7 +138,7 @@ async def on_account_update(self, taker: UserAccount, taker_key: Pubkey, slot: i
138138

139139
if (
140140
order.base_asset_amount - order.base_asset_amount_filled
141-
<= spot_market_account.min_order_size
141+
<= spot_market_account.min_order_size # type: ignore
142142
):
143143
self.logger.info("Order filled within min_order_size")
144144
self.logger.info("----------------------------")
@@ -177,7 +177,7 @@ async def create_try_fill(
177177
order: Order,
178178
order_sig: str,
179179
):
180-
future = asyncio.Future()
180+
future = asyncio.Future() # type: ignore
181181
future.set_result(None)
182182
return future
183183

python/sdk/jit_proxy/jitter/jitter_shotgun.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Any, Coroutine
44

5-
from solders.pubkey import Pubkey
5+
from solders.pubkey import Pubkey # type: ignore
66

77
from driftpy.drift_client import DriftClient
88
from driftpy.auction_subscriber.auction_subscriber import AuctionSubscriber

python/sdk/jit_proxy/jitter/jitter_sniper.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from dataclasses import dataclass
44
from typing import Any, Coroutine
55

6-
from solders.pubkey import Pubkey
6+
from solders.pubkey import Pubkey # type: ignore
77

88
from driftpy.drift_client import DriftClient
99
from driftpy.auction_subscriber.auction_subscriber import AuctionSubscriber
@@ -243,7 +243,7 @@ def get_auction_and_order_details(self, order: Order) -> AuctionAndOrderDetails:
243243

244244
auction_start_price = convert_to_number(
245245
get_auction_price_for_oracle_offset_auction(
246-
order, order.slot, oracle_price.price
246+
order, order.slot, oracle_price.price # type: ignore
247247
)
248248
if is_variant(order.order_type, "Oracle")
249249
else order.auction_start_price,
@@ -252,23 +252,23 @@ def get_auction_and_order_details(self, order: Order) -> AuctionAndOrderDetails:
252252

253253
auction_end_price = convert_to_number(
254254
get_auction_price_for_oracle_offset_auction(
255-
order, order.slot + order.auction_duration - 1, oracle_price.price
255+
order, order.slot + order.auction_duration - 1, oracle_price.price # type: ignore
256256
)
257257
if is_variant(order.order_type, "Oracle")
258258
else order.auction_end_price,
259259
PRICE_PRECISION,
260260
)
261261

262262
bid = (
263-
convert_to_number(oracle_price.price + params.bid, PRICE_PRECISION)
264-
if is_variant(params.price_type, "Oracle")
265-
else convert_to_number(params.bid, PRICE_PRECISION)
263+
convert_to_number(oracle_price.price + params.bid, PRICE_PRECISION) # type: ignore
264+
if is_variant(params.price_type, "Oracle") # type: ignore
265+
else convert_to_number(params.bid, PRICE_PRECISION) # type: ignore
266266
)
267267

268268
ask = (
269-
convert_to_number(oracle_price.price + params.ask, PRICE_PRECISION)
270-
if is_variant(params.price_type, "Oracle")
271-
else convert_to_number(params.ask, PRICE_PRECISION)
269+
convert_to_number(oracle_price.price + params.ask, PRICE_PRECISION) # type: ignore
270+
if is_variant(params.price_type, "Oracle") # type: ignore
271+
else convert_to_number(params.ask, PRICE_PRECISION) # type: ignore
272272
)
273273

274274
slots_until_cross = 0
@@ -282,7 +282,7 @@ def get_auction_and_order_details(self, order: Order) -> AuctionAndOrderDetails:
282282
if (
283283
convert_to_number(
284284
get_auction_price(
285-
order, order.slot + slots_until_cross, oracle_price.price
285+
order, order.slot + slots_until_cross, oracle_price.price # type: ignore
286286
),
287287
PRICE_PRECISION,
288288
)
@@ -294,7 +294,7 @@ def get_auction_and_order_details(self, order: Order) -> AuctionAndOrderDetails:
294294
if (
295295
convert_to_number(
296296
get_auction_price(
297-
order, order.slot + slots_until_cross, oracle_price.price
297+
order, order.slot + slots_until_cross, oracle_price.price # type: ignore
298298
),
299299
PRICE_PRECISION,
300300
)
@@ -312,12 +312,12 @@ def get_auction_and_order_details(self, order: Order) -> AuctionAndOrderDetails:
312312
auction_start_price,
313313
auction_end_price,
314314
step_size,
315-
oracle_price,
315+
oracle_price, # type: ignore
316316
)
317317

318318
async def wait_for_slot_or_cross_or_expiry(
319319
self, target_slot: int, order: Order, initial_details: AuctionAndOrderDetails
320-
) -> (int, AuctionAndOrderDetails):
320+
) -> (int, AuctionAndOrderDetails): # type: ignore
321321
auction_end_slot = order.auction_duration + order.slot
322322
current_details: AuctionAndOrderDetails = initial_details
323323
will_cross = initial_details.will_cross

0 commit comments

Comments
 (0)