
    N%jS                        d dl mZ d dlmZ d dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZmZ d dlmZ  ed	
           G d d                      Z G d d          ZdS )    )annotations)	dataclassN)Any)Decimal)OrderIntent)PreparedOrderPayloadprepare_order_payload)HyperliquidAssetMetaT)frozenc                  N    e Zd ZU ded<   ded<   dZded<   dZd	ed
<   dZded<   dS )ExecutionResultstrstatusr   intentNr   exchange_response ztuple[str, ...]side_effectszPreparedOrderPayload | Noneprepared_payload)__name__
__module____qualname____annotations__r   r   r   r       ]/home/agent/projects/CryptoTradingBot/Crypto_Agent/src/execution/hyperliquid_live_executor.pyr   r      s\         KKK!!!!!$&L&&&&48888888r   r   c                  4    e Zd ZddddZddZddZddZdS )HyperliquidLiveExecutorF)dry_runexchanger   expected_confirmationr   r   boolreturnNonec               0    || _         || _        || _        d S )N)r   r   r   )selfr   r   r   s       r   __init__z HyperliquidLiveExecutor.__init__   s     %:"r   c                    t          j        dd                                          dk    rt          d          t          j        d          | j        k    rt          d          d S )NCTB_LIVE_TRADING_ALLOWED truez;CTB_LIVE_TRADING_ALLOWED must be true before live executionCTB_LIVE_CONFIRMATIONz:CTB_LIVE_CONFIRMATION does not match expected confirmation)osgetenvlowerPermissionErrorr   )r$   s    r   _check_live_gatesz)HyperliquidLiveExecutor._check_live_gates   sf    9/44::<<FF!"_```9,--1KKK!"^___ LKr   r   r   metar
   min_notional_usdr   r   c               &    t          |||          S )N)r1   )r	   )r$   r   r0   r1   s       r   prepare_payloadz'HyperliquidLiveExecutor.prepare_payload"   s    $VTDTUUUUr   r   c                   | j         rt          d|d          S |                                  |j        dk    }| j                            |j        |t          |j                  d d           }t          d||d          S )Nr   r   )r   r   r   buy	submitted)hyperliquid_order)r   r   r   r   )	r   r   r/   sider   market_opencoinfloatsize)r$   r   is_buyresponses       r   executezHyperliquidLiveExecutor.execute%   s    < 	U")FQSTTTT   %=,,V[&%BTBTVZ\`aak&T\  lB  C  C  C  	Cr   N)r   r   r   r   r   r    r!   r"   )r!   r"   )r   r   r0   r
   r1   r   r!   r   )r   r   r!   r   )r   r   r   r%   r/   r3   r?   r   r   r   r   r      s        UZ      
` ` ` `V V V VC C C C C Cr   r   )
__future__r   dataclassesr   r+   typingr   decimalr   src.execution.order_intentr   src.execution.payloadsr   r	   src.hyperliquid.roundingr
   r   r   r   r   r   <module>rG      s   " " " " " " ! ! ! ! ! ! 				             2 2 2 2 2 2 N N N N N N N N 9 9 9 9 9 9 $9 9 9 9 9 9 9 9C C C C C C C C C Cr   