AddressSyncModel#
API documentation for tradeexecutor.ethereum.address_sync_model.AddressSyncModel Python class in Trading Strategy framework.
- class AddressSyncModel[source]#
Bases:
SyncModel
Sync vault/wallet address by polling its list of assests
- __init__()#
Methods
__init__
()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_key_address
()Get the address that identifies the vault/wallet we are using.
Which is the onchain address that identifies this wallet/vault deployment.
Which is the onchain address having our token balances.
has_async_deposits
()Can deposit land only when we tell so.
has_position_sync
()Do we need to sync positions when we sync treasuty.
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[, reserve_asset, ...])Set up the initial sync details.
sync_interests
(timestamp, state, universe, ...)Update interest on all tokens that receive interest thru rebase.
sync_positions
(timestamp, state, ...)Detect any position balance changes due to deposit/redemptions of vault users.
sync_treasury
(strategy_cycle_ts, state[, ...])Poll chain for updated treasury token balances.
- abstract get_token_storage_address()[source]#
Which is the onchain address having our token balances.
- abstract get_main_address()[source]#
Which is the onchain address that identifies this wallet/vault deployment.
See also
get_token_storage_address()
- sync_initial(state, reserve_asset=None, reserve_token_price=None, **kwargs)[source]#
Set up the initial sync details.
Initialise vault deployment information
Set the reserve assets (optional, sometimes can be read from the chain)
- Parameters:
state (State) –
reserve_asset (tradeexecutor.state.identifier.AssetIdentifier | None) –
reserve_token_price (float | None) –
- sync_treasury(strategy_cycle_ts, state, supported_reserves=None, end_block=None, post_valuation=False)[source]#
Poll chain for updated treasury token balances.
Apply the balance sync before each strategy cycle.
TODO: end_block is being ignored
- Parameters:
- Return type:
- setup_all(state, supported_reserves)[source]#
Make sure we have everything set up and initial test balance synced.
A shortcut used in testing.
- Parameters:
state (State) –
supported_reserves (List[AssetIdentifier]) –
- 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:
- 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: