Skip to content

Commit

Permalink
remove noise on clearing house load
Browse files Browse the repository at this point in the history
  • Loading branch information
wphan committed Apr 28, 2023
1 parent 66a0704 commit 6d291ba
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions src/driftpy/clearing_house.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
DEFAULT_USER_NAME = "Main Account"

class ClearingHouse:
"""This class is the main way to interact with Drift Protocol including
"""This class is the main way to interact with Drift Protocol including
depositing, opening new positions, closing positions, placing orders, etc.
"""

Expand All @@ -56,7 +56,7 @@ def __init__(self, program: Program, authority: Keypair = None):

@staticmethod
def from_config(config: Config, provider: Provider, authority: Keypair = None):
"""Initializes the clearing house object from a Config
"""Initializes the clearing house object from a Config
Args:
config (Config): the config to initialize form
Expand All @@ -68,7 +68,6 @@ def from_config(config: Config, provider: Provider, authority: Keypair = None):
"""
# read the idl
file = Path(str(driftpy.__path__[0]) + "/idl/drift.json")
print(file)
with file.open() as f:
idl_dict = json.load(f)
idl = Idl.from_json(idl_dict)
Expand Down Expand Up @@ -116,7 +115,7 @@ async def send_ixs(
return await self.program.provider.send(tx, signers=signers)

async def intialize_user(self, user_id: int = 0):
"""intializes a drift user
"""intializes a drift user
Args:
user_id (int, optional): subaccount id to initialize. Defaults to 0.
Expand Down Expand Up @@ -293,7 +292,7 @@ async def withdraw(
Args:
amount (int): amount to withdraw
spot_market_index (int):
spot_market_index (int):
user_token_account (PublicKey): ata of the account to withdraw to
reduce_only (bool, optional): if True will only withdraw existing funds else if False will allow taking out borrows. Defaults to False.
user_id (int, optional): subaccount. Defaults to 0.
Expand Down Expand Up @@ -359,8 +358,8 @@ async def deposit(
Args:
amount (int): amount to deposit
spot_market_index (int):
user_token_account (PublicKey):
spot_market_index (int):
user_token_account (PublicKey):
user_id (int, optional): subaccount to deposit into. Defaults to 0.
reduce_only (bool, optional): paying back borrow vs depositing new assets. Defaults to False.
user_initialized (bool, optional): if need to initialize user account too set this to False. Defaults to True.
Expand Down Expand Up @@ -467,7 +466,7 @@ async def remove_liquidity(self, amount: int, market_index: int, user_id: int =
Args:
amount (int): amount of lp tokens to burn
market_index (int):
market_index (int):
user_id (int, optional): subaccount id. Defaults to 0.
Returns:
Expand Down Expand Up @@ -634,7 +633,7 @@ async def get_place_spot_order_ix(
user_account_public_key = self.get_user_account_public_key(user_id)

remaining_accounts = await self.get_remaining_accounts(
readable_spot_market_index=[0, order_params.market_index],
readable_spot_market_index=[0, order_params.market_index],
user_id=user_id
)

Expand Down Expand Up @@ -866,8 +865,8 @@ def default_order_params(
async def liquidate_spot(
self,
user_authority: PublicKey,
asset_market_index: int,
liability_market_index: int,
asset_market_index: int,
liability_market_index: int,
max_liability_transfer: int,
user_subaccount_id: int = 0,
liq_subaccount_id: int = 0,
Expand All @@ -888,9 +887,9 @@ async def liquidate_spot(
async def get_liquidate_spot_ix(
self,
user_authority: PublicKey,
asset_market_index: int,
liability_market_index: int,
max_liability_transfer: int,
asset_market_index: int,
liability_market_index: int,
max_liability_transfer: int,
limit_price: int = None,
user_subaccount_id: int = 0,
liq_subaccount_id: int = 0,
Expand Down Expand Up @@ -969,7 +968,7 @@ async def get_liquidate_perp_ix(
liq_stats_pk = self.get_user_stats_public_key()

remaining_accounts = await self.get_remaining_accounts(
writable_market_index=market_index,
writable_market_index=market_index,
authority=[user_authority, self.authority],
user_id=[user_subaccount_id, liq_subaccount_id]
)
Expand All @@ -992,7 +991,7 @@ async def get_liquidate_perp_ix(
)

async def liquidate_perp_pnl_for_deposit(
self,
self,
user_authority: PublicKey,
perp_market_index: int,
spot_market_index: int,
Expand Down Expand Up @@ -1309,7 +1308,7 @@ 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)
)

Expand Down Expand Up @@ -1381,7 +1380,7 @@ 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)
)

Expand Down Expand Up @@ -1540,7 +1539,7 @@ async def get_update_amm_ix(
)

async def settle_revenue_to_insurance_fund(
self,
self,
spot_market_index: int
):
return await self.program.rpc["settle_revenue_to_insurance_fund"](
Expand All @@ -1561,4 +1560,4 @@ async def settle_revenue_to_insurance_fund(
"token_program": TOKEN_PROGRAM_ID,
}
),
)
)

0 comments on commit 6d291ba

Please sign in to comment.