ChainLinkLatestRoundData

Documentation for eth_defi.chainlink.round_data.ChainLinkLatestRoundData Python class.

class ChainLinkLatestRoundData[source]

Human-readable presentation for Chainlink price booking.

Wraps IChainlinkAggregator.latestRoundData() response.

See AggregatorV3Interface.

Example:

aggregator = chainlink_aggregator  # Point to any Chainlink aggregator contract
round_data = fetch_chainlink_round_data(web3, aggregator.address)
ago = datetime.datetime.utcnow() - round_data.update_time
print(f"   {feed.primitive_token.symbol}, current price is {round_data.price:,.4f} USDC, Chainlink feed is {round_data.description}, updated {ago} ago")

Attributes summary

decimals

How many decimals the aggregator has been configured for.

description

Chainlink provided description of this feed

price

Human-readable price in this response.

update_time

Python datetime when the feed price was updated.

aggregator

See ChainlinkAggregatorV2V3Interface.sol

round_id

Current round id

answer

Price, non-decimal converted

started_at

When processing started

updated_at

When price was updated last time

answered_in_round

Which round gave the answer

Methods summary

__init__(aggregator, round_id, answer, ...)

aggregator: web3.contract.contract.Contract

See ChainlinkAggregatorV2V3Interface.sol

round_id: int

Current round id

answer: int

Price, non-decimal converted

started_at: int

When processing started

updated_at: int

When price was updated last time

answered_in_round: int

Which round gave the answer

property decimals: int

How many decimals the aggregator has been configured for.

property update_time: datetime.datetime

Python datetime when the feed price was updated.

  • Naive timestamp

  • Always UTC

property price: decimal.Decimal

Human-readable price in this response.

property description: str

Chainlink provided description of this feed

__init__(aggregator, round_id, answer, started_at, updated_at, answered_in_round)
Parameters
  • aggregator (web3.contract.contract.Contract) –

  • round_id (int) –

  • answer (int) –

  • started_at (int) –

  • updated_at (int) –

  • answered_in_round (int) –

Return type

None