UniswapV2Execution#
API documentation for tradeexecutor.ethereum.uniswap_v2.uniswap_v2_execution.UniswapV2Execution Python class in Trading Strategy framework.
- class UniswapV2Execution[source]#
- Bases: - EthereumExecution- Run order execution on a single Uniswap v2 style exchanges. - __init__(tx_builder, min_balance_threshold=Decimal('0.5'), confirmation_block_count=6, confirmation_timeout=datetime.timedelta(seconds=300), max_slippage=0.01, stop_on_execution_failure=True, swap_gas_fee_limit=2000000, mainnet_fork=False)[source]#
- Parameters:
- web3 – Web3 connection used for this instance 
- tx_builder (TransactionBuilder) – Hot wallet instance used for this execution 
- min_balance_threshold – Abort execution if our hot wallet gas fee balance drops below this 
- confirmation_block_count – How many blocks to wait for the receipt confirmations to mitigate unstable chain tip issues 
- confirmation_timeout – How long we wait transactions to clear 
- stop_on_execution_failure – Raise an exception if any of the trades fail top execute 
- max_slippage (float) – Max slippage tolerance per trade. 0.01 is 1%. 
 
 
 - Methods - __init__(tx_builder[, ...])- param web3:
 - analyse_trade_by_receipt(web3, *, ...[, ...])- broadcast_and_resolve_mev_blocker(...[, ...])- Sequential broadcast of txs. - broadcast_and_resolve_multiple_nodes(...[, ...])- Do the live trade execution using multiple nodes. - broadcast_and_resolve_old(state, trades, ...)- Do the live trade execution. - create_default_routing_model(strategy_universe)- Get the default routing model for this executor. - execute_trades(ts, state, trades, ...[, ...])- Execute the trades determined by the algo on a designed Uniswap v2 instance. - get_balance_address()- Get the address where the strat holds tokens. - get_routing_state_details()- Get needed details to establish a routing state. - get_safe_latest_block()- Fix the block number for all checks and actions. - initialize()- Set up the wallet - is_live_trading()- is_stop_loss_supported()- Do we support stop-loss/take profit functionality with this execution model? - is_v3()- Returns true if instance is related to Uniswap V3, else false. - mock_partial_deployment_for_analysis(web3, ...)- pre_execute_assertions(ts, routing_model, ...)- preflight_check()- Check that we can connect to the web3 node - repair_unconfirmed_trades(state)- Repair unconfirmed trades. - resolve_trades(ts, routing_model, state, ...)- Resolve trade outcome. - update_confirmation_status(ts, tx_map, receipts)- First update the state of all transactions, as we now have receipt for them. - Attributes - chain_id- Which chain the live execution is connected to. - web3- __init__(tx_builder, min_balance_threshold=Decimal('0.5'), confirmation_block_count=6, confirmation_timeout=datetime.timedelta(seconds=300), max_slippage=0.01, stop_on_execution_failure=True, swap_gas_fee_limit=2000000, mainnet_fork=False)[source]#
- Parameters:
- web3 – Web3 connection used for this instance 
- tx_builder (TransactionBuilder) – Hot wallet instance used for this execution 
- min_balance_threshold – Abort execution if our hot wallet gas fee balance drops below this 
- confirmation_block_count – How many blocks to wait for the receipt confirmations to mitigate unstable chain tip issues 
- confirmation_timeout – How long we wait transactions to clear 
- stop_on_execution_failure – Raise an exception if any of the trades fail top execute 
- max_slippage (float) – Max slippage tolerance per trade. 0.01 is 1%.