@@ -451,8 +451,8 @@ def sign_create_grouped_orders(
451451 def sign_cancel_order (self , market_index : int , order_index : int , nonce : int = DEFAULT_NONCE , api_key_index : int = DEFAULT_API_KEY_INDEX ) -> Union [Tuple [str , str , str , None ], Tuple [None , None , None , str ]]:
452452 return self .__decode_tx_info (self .signer .SignCancelOrder (market_index , order_index , nonce , api_key_index , self .account_index ))
453453
454- def sign_withdraw (self , usdc_amount : int , nonce : int = DEFAULT_NONCE , api_key_index : int = DEFAULT_API_KEY_INDEX ) -> Union [Tuple [str , str , str , None ], Tuple [None , None , None , str ]]:
455- return self .__decode_tx_info (self .signer .SignWithdraw (usdc_amount , nonce , api_key_index , self .account_index ))
454+ def sign_withdraw (self , asset_index : int , route_type : int , amount : int , nonce : int = DEFAULT_NONCE , api_key_index : int = DEFAULT_API_KEY_INDEX ) -> Union [Tuple [str , str , str , None ], Tuple [None , None , None , str ]]:
455+ return self .__decode_tx_info (self .signer .SignWithdraw (asset_index , route_type , amount , nonce , api_key_index , self .account_index ))
456456
457457 def sign_create_sub_account (self , nonce : int = DEFAULT_NONCE , api_key_index : int = DEFAULT_API_KEY_INDEX ) -> Union [Tuple [str , str , str , None ], Tuple [None , None , None , str ]]:
458458 return self .__decode_tx_info (self .signer .SignCreateSubAccount (nonce , api_key_index , self .account_index ))
@@ -742,10 +742,15 @@ async def create_sl_limit_order(self, market_index, client_order_index, base_amo
742742 )
743743
744744 @process_api_key_and_nonce
745- async def withdraw (self , usdc_amount , nonce : int = DEFAULT_NONCE , api_key_index : int = DEFAULT_API_KEY_INDEX ) -> Union [Tuple [Withdraw , RespSendTx , None ], Tuple [None , None , str ]]:
746- usdc_amount = int (usdc_amount * self .USDC_TICKER_SCALE )
745+ async def withdraw (self , asset_id : int , route_type : int , amount : float , nonce : int = DEFAULT_NONCE , api_key_index : int = DEFAULT_API_KEY_INDEX ) -> Union [Tuple [Withdraw , RespSendTx , None ], Tuple [None , None , str ]]:
746+ if asset_id == self .ASSET_ID_USDC :
747+ amount = int (amount * self .USDC_TICKER_SCALE )
748+ elif asset_id == self .ASSET_ID_ETH :
749+ amount = int (amount * self .ETH_TICKER_SCALE )
750+ else :
751+ raise ValueError (f"Unsupported asset id: { asset_id } " )
747752
748- tx_type , tx_info , tx_hash , error = self .sign_withdraw (usdc_amount , nonce , api_key_index )
753+ tx_type , tx_info , tx_hash , error = self .sign_withdraw (asset_id , route_type , amount , nonce , api_key_index )
749754 if error is not None :
750755 return None , None , error
751756
0 commit comments