HotWalletSyncModel#

API documentation for tradeexecutor.ethereum.hot_wallet_sync_model.HotWalletSyncModel Python class in Trading Strategy framework.

class HotWalletSyncModel[source]#

Bases: SyncModel

V0 prototype version of sync model, only for.

Warning

TODO: This model is unfinished and needs to be migrated to event based.

__init__(web3, hot_wallet)[source]#
Parameters:

Methods

__init__(web3, hot_wallet)

create_transaction_builder()

Creates a transaction builder instance to make trades against this asset management model.

fetch_onchain_balances(assets[, ...])

Read the on-chain asset details.

get_hot_wallet()

Get the vault address we are using.

get_token_storage_address()

Get the address where tokens are stored.

get_vault_address()

Get the vault address we are using.

init()

is_ready_for_live_trading(state)

Check that the state and sync model is ready for live trading.

reset_deposits(state)

Clear out pending withdrawals/deposits events.

resync_nonce()

Re-read hot wallet nonce before trade execution.

setup_all(state, supported_reserves)

Make sure we have everything set up and initial test balance synced.

sync_initial(state, **kwargs)

Set u[ initial sync details.

sync_interests(timestamp, state, universe, ...)

Update interest on all tokens that receive interest thru rebase.

sync_treasury(strategy_cycle_ts, state[, ...])

Apply the balance sync before each strategy cycle.

__init__(web3, hot_wallet)[source]#
Parameters:
get_hot_wallet()[source]#

Get the vault address we are using.

Returns:

None if the executor is not using hot wallet (dummy, backtesting, etc.)

Return type:

Optional[HotWallet]

get_token_storage_address()[source]#

Get the address where tokens are stored.

Returns:

Vault address for enzyme, wallet address for hot wallet.

Return None for DummySyncModel e.g. in the case of unit and backtests.

Return type:

Optional[str]

resync_nonce()[source]#

Re-read hot wallet nonce before trade execution.

Ensures that if the private key is used outside the trade executor, we are not getting wrong nonce error when broadcasting the transaction.

sync_initial(state, **kwargs)[source]#

Set u[ initial sync details.

Parameters:

state (State) –

sync_treasury(strategy_cycle_ts, state, supported_reserves=None, end_block=None)[source]#

Apply the balance sync before each strategy cycle.

TODO: end_block is being ignored

Parameters:
Return type:

List[BalanceUpdate]

create_transaction_builder()[source]#

Creates a transaction builder instance to make trades against this asset management model.

Only needed when trades are being executed.

Returns:

Depending on the asset management mode.

Return type:

HotWalletTransactionBuilder

setup_all(state, supported_reserves)[source]#

Make sure we have everything set up and initial test balance synced.

A shortcut used in testing.

Parameters:
fetch_onchain_balances(assets, filter_zero=True, block_identifier=None)[source]#

Read the on-chain asset details.

  • Mark the block we are reading at the start

  • Asset list is sorted to be by address to make sure the return order is deterministic

Parameters:
  • filter_zero – Do not return zero balances

  • block_identifier (Union[Literal['latest', 'earliest', 'pending', 'safe', 'finalized'], ~eth_typing.evm.BlockNumber, ~eth_typing.evm.Hash32, ~eth_typing.encoding.HexStr, ~hexbytes.main.HexBytes, int]) – Cbeck at certain block height.

  • assets (List[AssetIdentifier]) –

Returns:

Iterator for assets by the sort order.

Return type:

Iterable[OnChainBalance]

sync_interests(timestamp, state, universe, pricing_model)[source]#

Update interest on all tokens that receive interest thru rebase.

  • Credit supply positions: aToken

  • Short positions: aToken, vToken

Parameters:
  • timestamp (datetime) –

    Wall clock time.

    This function can be called outside the strategy cycle.

  • state (State) – Current strategy state

  • universe (TradingStrategyUniverse) – Trading universe that must include lending data.

  • pricing_model (PricingModel) – Used to re-value loans

Returns:

All triggered balance update events, one per asset per position

Return type:

List[BalanceUpdate]