FixedPriceOracle

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

class FixedPriceOracle[source]

Always use the same hardcoded exchange rate.

Most useful for unit testing.

Methods summary

__init__(exchange_rate)

calculate_price([block_number])

Get a price for the current block.

__init__(exchange_rate)[source]
Parameters

exchange_rate (decimal.Decimal) –

calculate_price(block_number=None)[source]

Get a price for the current block.

Parameters

block_number (Optional[int]) – Hint of what is the current block. We do not support prices for historical blocks, but we may cache the result of the previous block calculation for speedups.

Return type

decimal.Decimal