OneDeltaRoutingState#

API documentation for tradeexecutor.ethereum.one_delta.one_delta_routing.OneDeltaRoutingState Python class in Trading Strategy framework.

class OneDeltaRoutingState[source]#

Bases: EthereumRoutingState

__init__(pair_universe, tx_builder=None, swap_gas_limit=2000000)[source]#
Parameters:
  • pair_universe (PandasPairUniverse) – Pairs we trade

  • tx_builder (Optional[HotWalletTransactionBuilder]) –

    For creating trade transactions.

    Can be set to None on DummyExecutionModel.

  • web3

    Use for routing smart contract reads.

    Given when tx_builder is not present.

  • swap_gas_limit – What is the max gas we are willing to pay for a swap.

Methods

__init__(pair_universe[, tx_builder, ...])

param pair_universe:

adjust_spend(asset, required_amount[, ...])

Check that our on-chain balances have enough tokens to cover the trade.

check_has_enough_tokens(erc_20, amount)

Check we have enough buy side tokens to do a trade.

create_signed_transaction(contract, ...[, notes])

ensure_multiple_tokens_approved(*, ...[, ...])

Make sure we have ERC-20 approve() for the 1delta

ensure_token_approved(token_address, ...[, ...])

Make sure we have ERC-20 approve() for the trade

ensure_vtoken_delegation_approved(...[, amount])

Make sure we have approveDelegation() for the trade

get_aave_v3_for_pair(address_map, target_pair)

get_one_delta_for_pair(address_map, target_pair)

get_uniswap_for_pair(address_map, target_pair)

Get a router for a trading pair.

is_approved_on_chain(token_address, ...)

is_route_approved(router_address)

lend_via_one_delta(*, one_delta, ...[, ...])

mark_router_approved(token_address, ...)

trade_on_one_delta(*, one_delta, uniswap, ...)

trade_on_router_three_way(uniswap, ...[, ...])

Not used for now

trade_on_router_two_way(uniswap, ...[, ...])

Not used for now

validate_exchange(target_pair, intermediary_pair)

Check routing happens on the same exchange

validate_pairs(target_pair, intermediary_pair)

Check we can chain two pairs

Attributes

__init__(pair_universe, tx_builder=None, swap_gas_limit=2000000)[source]#
Parameters:
  • pair_universe (PandasPairUniverse) – Pairs we trade

  • tx_builder (Optional[HotWalletTransactionBuilder]) –

    For creating trade transactions.

    Can be set to None on DummyExecutionModel.

  • web3

    Use for routing smart contract reads.

    Given when tx_builder is not present.

  • swap_gas_limit – What is the max gas we are willing to pay for a swap.

get_uniswap_for_pair(address_map, target_pair)[source]#

Get a router for a trading pair.

Parameters:
Return type:

UniswapV3Deployment

trade_on_router_two_way(uniswap, target_pair, reserve_asset, reserve_amount, max_slippage, check_balances, asset_deltas=None, notes='', one_delta=None)[source]#

Not used for now

Parameters:
trade_on_router_three_way(uniswap, target_pair, intermediary_pair, reserve_asset, reserve_amount, max_slippage, check_balances, asset_deltas=None, notes='', one_delta=None)[source]#

Not used for now

Parameters:
ensure_multiple_tokens_approved(*, one_delta, aave_v3, collateral_token_address, borrow_token_address, atoken_address, vtoken_address, uniswap_v3=None)[source]#

Make sure we have ERC-20 approve() for the 1delta

  • Infinite approval on-chain

  • …or previous approval in this state,

Parameters:
Returns:

Create 0 or 1 transactions if needs to be approved

Return type:

list[tradeexecutor.state.blockhain_transaction.BlockchainTransaction]

ensure_vtoken_delegation_approved(token_address, destination_address, amount=115792089237316195423570985008687907853269984665640564039457584007913129639935)[source]#

Make sure we have approveDelegation() for the trade

  • Infinite approval on-chain

  • …or previous approval in this state,

Parameters:
  • token_address (str) –

  • destination_address (str) –

  • amount (int) – How much to approve, default to approve infinite amount

Returns:

Create 0 or 1 transactions if needs to be approved

Return type:

list[tradeexecutor.state.blockhain_transaction.BlockchainTransaction]