PriceEntry

Documentation for eth_defi.price_oracle.oracle.PriceEntry Python class.

class PriceEntry

Bases: object

A single source entry for price calculations.

PriceOracle maintains a buffer of these to calculate a smoothed out price, like py:func:time_weighted_average_price.

Price entry can be sourced from:

  • Manually entered price

  • Price from Uniswap v2 sync events

  • Price from some other event

Attributes summary

block_hash

block_number

first_seen_at_block_number

pool_contract_address

tx_hash

volume

Methods summary

__init__(timestamp, price, source[, volume, ...])

update_chain_reorg(new_entry)

Update entry data in the case of chain reorganisation.

__init__(timestamp, price, source, volume=None, pool_contract_address=None, block_number=None, tx_hash=None, block_hash=None, first_seen_at_block_number=None)
Parameters
Return type

None

update_chain_reorg(new_entry)

Update entry data in the case of chain reorganisation.

TODO: We are not yet dealing with the situation if the transaction gets reorganisated and rejected.

Parameters

new_entry (eth_defi.price_oracle.oracle.PriceEntry) –