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 the address that holds ERC-20 supply
Get the address that holds native token for gas fees
Get the balance of the native currency (ETH, BNB, MATIC) of the wallet.
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
Get the underlying web3 connection.
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
.
- 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:
- 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:
args_bound_func (ContractFunction) – Web3 function thingy
asset_deltas (Optional[List[AssetDelta]]) –
Expected asset deltas (how much of incoming tokens we are going to give out and receive).
Calculated in
tradeexecutor.ethereum.routing_model.EthereumRoutingModel.execute_trades_internal()
contract (Contract) –
gas_price_suggestion (Optional[GasPriceSuggestion]) –
- Returns:
Prepared BlockchainTransaction instance
- Return type: