calculate_account_corrections#

API documentation for tradeexecutor.strategy.account_correction.calculate_account_corrections Python function.

calculate_account_corrections(pair_universe, reserve_assets, state, sync_model, relative_epsilon=Decimal('0.000100000000000000004792173602385929598312941379845142364501953125'), all_balances=False, block_identifier=None)[source]#

Figure out differences between our internal ledger (state) and on-chain balances.

Parameters:
  • pair_universe (PandasPairUniverse) – Needed to know what asses we are looking for

  • reserve_assets (Collection[AssetIdentifier]) – Needed to know what asses we are looking for

  • state (State) – The current state of the internal ledger

  • sync_model (SyncModel) – How ot access on-chain balances

  • dust_epsilon – Minimum amount of token (abs quantity) before it is considered as a rounding error

  • all_balances – If True iterate all balances even if there are no mismatch.

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

Raises:

UnexpectedAccountingCorrectionIssue – If we find on-chain tokens we do not know how to map any of our strategy positions

Returns:

Difference in balances or all balances if all_balances is true.

Yield one entry per token in positions.

Return type:

Iterable[AccountingBalanceCheck]