UniswapV2ExecutionModel#
tradeexecutor.ethereum.uniswap_v2_execution.UniswapV2ExecutionModel class.
- class UniswapV2ExecutionModel[source]#
Bases:
ExecutionModel
Run order execution on a single Uniswap v2 style exchanges.
- __init__(web3, hot_wallet, 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)[source]#
- Parameters
web3 (Web3) – Web3 connection used for this instance
hot_wallet (HotWallet) – 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__
(web3, hot_wallet[, ...])- param web3
execute_trades
(ts, state, trades, ...[, ...])Execute the trades determined by the algo on a designed Uniswap v2 instance.
Get needed details to establish a routing state.
Set up the wallet
is_live_trading
()Check that we can connect to the web3 node
Attributes
Which chain the live execution is connected to.
- __init__(web3, hot_wallet, 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)[source]#
- Parameters
web3 (Web3) – Web3 connection used for this instance
hot_wallet (HotWallet) – 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%.
- execute_trades(ts, state, trades, routing_model, routing_state, check_balances=False)[source]#
Execute the trades determined by the algo on a designed Uniswap v2 instance.
- Returns
Tuple List of succeeded trades, List of failed trades
- Parameters
ts (datetime) –
state (State) –
trades (List[TradeExecution]) –
routing_model (UniswapV2SimpleRoutingModel) –
routing_state (UniswapV2RoutingState) –