@@ -301,6 +301,73 @@ def deposit_to_exchange(
301301 options = send_options ,
302302 )
303303
304+ def withdraw (
305+ self ,
306+ stark_public_key = None ,
307+ send_options = None ,
308+ ):
309+ '''
310+ Withdraw from exchange.
311+
312+ :param stark_public_key: optional
313+ :type stark_public_key: string
314+
315+ :param send_options: optional
316+ :type send_options: dict
317+
318+ :returns: transactionHash
319+
320+ :raises: ValueError
321+ '''
322+ stark_public_key = stark_public_key or self .stark_public_key
323+ if stark_public_key is None :
324+ raise ValueError ('No stark_public_key was provided' )
325+
326+ contract = self .get_exchange_contract ()
327+ return self .send_eth_transaction (
328+ method = contract .functions .withdraw (
329+ int (stark_public_key , 16 ),
330+ COLLATERAL_ASSET_ID_BY_NETWORK_ID [self .network_id ],
331+ ),
332+ options = send_options ,
333+ )
334+
335+ def withdraw_to (
336+ self ,
337+ recipient ,
338+ stark_public_key = None ,
339+ send_options = None ,
340+ ):
341+ '''
342+ Withdraw from exchange to address.
343+
344+ :param recipient: required
345+ :type recipient: string
346+
347+ :param stark_public_key: optional
348+ :type stark_public_key: string
349+
350+ :param send_options: optional
351+ :type send_options: dict
352+
353+ :returns: transactionHash
354+
355+ :raises: ValueError
356+ '''
357+ stark_public_key = stark_public_key or self .stark_public_key
358+ if stark_public_key is None :
359+ raise ValueError ('No stark_public_key was provided' )
360+
361+ contract = self .get_exchange_contract ()
362+ return self .send_eth_transaction (
363+ method = contract .functions .withdrawTo (
364+ int (stark_public_key , 16 ),
365+ COLLATERAL_ASSET_ID_BY_NETWORK_ID [self .network_id ],
366+ recipient ,
367+ ),
368+ options = send_options ,
369+ )
370+
304371 def transfer_eth (
305372 self ,
306373 to_address = None , # Require keyword args to avoid confusing the amount.
0 commit comments