EnzymeTransactionBuilder#

tradeexecutor.ethereum.enzyme.tx.EnzymeTransactionBuilder Python class in Trading Strategy framework.

class EnzymeTransactionBuilder[source]#

Bases: TransactionBuilder

Create transactions that are executed by Enzyme’s vaults.

Creates trackable transactions. TransactionHelper is initialised at the start of the each cycle.

Transaction builder can prepare multiple transactions in one batch. For all tranactions, we use the previously prepared gas price information.

__init__(hot_wallet, vault, vault_slippage_tolerance=0.9999)[source]#
Parameters:
  • hot_wallet (HotWallet) – Hot wallet the trade-executor uses to sign the transactions

  • vault (Vault) – Enzyme vault high-level wrapper

  • vault_slippage_tolerance (float) –

    How much we drop the slippage tolerance for the vault specific slippage tolerance checks (vs. DEX checks) to avoid slippage tolerance failures because of rounding errors.

    Default to 1 BPS.

    Set 1 to disable.

    Applies to eth_defi.tx.AssetDelta.

Methods

__init__(hot_wallet, vault[, ...])

param hot_wallet:

broadcast(tx)

Broadcast the transaction.

broadcast_and_wait_transactions_to_complete(...)

Watch multiple transactions executed at parallel.

decode_signed_bytes(tx)

Get raw transaction data out from the signed tx bytes.

fetch_gas_price_suggestion()

Calculate the suggested gas price based on a policy.

get_erc_20_balance_address()

Get the address that holds ERC-20 supply

get_gas_wallet_address()

Get the address that holds native token for gas fees

get_gas_wallet_balance()

Get the balance of the native currency (ETH, BNB, MATIC) of the wallet.

get_token_delivery_address()

Get the target address for ERC-20 approve()

init()

Initialise the transaction builder.

serialise_to_broadcast_format(tx)

Prepare a transaction as a format ready to broadcast.

sign_transaction(contract, args_bound_func)

Createa a signed tranaction and set up tx broadcast parameters.

Attributes

hot_wallet

Get the underlying web3 connection.

vault

Get the underlying web3 connection.

__init__(hot_wallet, vault, vault_slippage_tolerance=0.9999)[source]#
Parameters:
  • hot_wallet (HotWallet) – Hot wallet the trade-executor uses to sign the transactions

  • vault (Vault) – Enzyme vault high-level wrapper

  • vault_slippage_tolerance (float) –

    How much we drop the slippage tolerance for the vault specific slippage tolerance checks (vs. DEX checks) to avoid slippage tolerance failures because of rounding errors.

    Default to 1 BPS.

    Set 1 to disable.

    Applies to eth_defi.tx.AssetDelta.

property vault: Vault#

Get the underlying web3 connection.

property hot_wallet: HotWallet#

Get the underlying web3 connection.

init()[source]#

Initialise the transaction builder.

Called on application startup.

get_token_delivery_address()[source]#

Get the target address for ERC-20 approve()

Return type:

str

get_erc_20_balance_address()[source]#

Get the address that holds ERC-20 supply

Return type:

str

get_gas_wallet_address()[source]#

Get the address that holds native token for gas fees

Return type:

str

get_gas_wallet_balance()[source]#

Get the balance of the native currency (ETH, BNB, MATIC) of the wallet.

Useful to check if you have enough cryptocurrency for the gas fees.

Return type:

Decimal

sign_transaction(contract, args_bound_func, gas_limit=None, gas_price_suggestion=None, asset_deltas=None)[source]#

Createa a signed tranaction and set up tx broadcast parameters.

Parameters:
Returns:

Prepared BlockchainTransaction instance

Return type:

BlockchainTransaction