Skip to content

Commit

Permalink
fix if staking rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNineteen committed Dec 12, 2022
1 parent 7059ba6 commit c211672
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/driftpy/clearing_house.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ async def get_remaining_accounts(

if isinstance(user_id, int):
user_id = [user_id]
assert len(user_id) == len(authority)
assert len(user_id) == len(authority) or len(user_id) == 0

accounts = []
for pk, id in zip(authority, user_id):
Expand Down Expand Up @@ -250,9 +250,6 @@ async def track_spot_market(spot_market_index, is_writable):
market_index = position.market_index
await track_market(market_index, is_writable=True)

if writable_market_index is not None:
await track_market(writable_market_index, is_writable=True)

if include_spot_markets:
for spot_market_balance in user_account.spot_positions:
if not is_spot_position_available(spot_market_balance):
Expand All @@ -267,12 +264,15 @@ async def track_spot_market(spot_market_index, is_writable):
for i in readable_spot_market_index:
await track_spot_market(i, is_writable=False)

if writable_spot_market_index is not None:
if isinstance(writable_spot_market_index, int):
writable_spot_market_index = [writable_spot_market_index]
if writable_market_index is not None:
await track_market(writable_market_index, is_writable=True)

if writable_spot_market_index is not None and include_spot_markets:
if isinstance(writable_spot_market_index, int):
writable_spot_market_index = [writable_spot_market_index]

for i in writable_spot_market_index:
await track_spot_market(i, is_writable=True)
for i in writable_spot_market_index:
await track_spot_market(i, is_writable=True)

remaining_accounts = [
*oracle_map.values(),
Expand Down Expand Up @@ -1271,7 +1271,8 @@ async def get_request_remove_insurance_fund_stake_ix(
amount: int,
):
ra = await self.get_remaining_accounts(
writable_spot_market_index=spot_market_index
writable_spot_market_index=spot_market_index,
user_id=[] # dont need the user account (might not exist)
)

return self.program.instruction["request_remove_insurance_fund_stake"](
Expand Down Expand Up @@ -1304,7 +1305,8 @@ async def remove_insurance_fund_stake(self, spot_market_index: int):

async def get_remove_insurance_fund_stake_ix(self, spot_market_index: int):
ra = await self.get_remaining_accounts(
writable_spot_market_index=spot_market_index
writable_spot_market_index=spot_market_index,
user_id=[] # dont need the user account (might not exist)
)

return self.program.instruction["remove_insurance_fund_stake"](
Expand Down

0 comments on commit c211672

Please sign in to comment.