From 6d291bac56b078c1a6fa8e635e249b251bcb143a Mon Sep 17 00:00:00 2001 From: wphan Date: Fri, 28 Apr 2023 13:48:17 -0700 Subject: [PATCH] remove noise on clearing house load --- src/driftpy/clearing_house.py | 39 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/driftpy/clearing_house.py b/src/driftpy/clearing_house.py index bccab1d9..30c5fccd 100644 --- a/src/driftpy/clearing_house.py +++ b/src/driftpy/clearing_house.py @@ -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. """ @@ -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 @@ -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) @@ -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. @@ -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. @@ -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. @@ -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: @@ -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 ) @@ -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, @@ -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, @@ -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] ) @@ -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, @@ -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) ) @@ -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) ) @@ -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"]( @@ -1561,4 +1560,4 @@ async def settle_revenue_to_insurance_fund( "token_program": TOKEN_PROGRAM_ID, } ), - ) + )