# Using Price Feeds

### Get all supported price feeds and their addresses

```javascript
import PublicPriceOracle from 0xAddress

// oracleAddress => oracleTag
pub fun main(): {Address: String} {
    return PublicPriceOracle.getAllSupportedOracles()
} 
```

Sample result:

```javascript
{
    0xf5d12412c09d2470	:    "USDC/USD"
    0xe385412159992e11	:    "FLOW/USD"
    0x1a9caf561de25a86	:    "FUSD/USD"
    0x031dabc5ba1d2932	:    "stFlow/USD"
    0x11b69dcfd16724af	:    "BLT/USD"
    0x07e2f8fc48632ece	:    "USDT/USD"
}
```

### Get latest result and update time

```javascript
import PublicPriceOracle from 0xAddress

pub fun main(oracle: Address): [UFix64] {
    let lastResult = PublicPriceOracle.getLatestPrice(oracleAddr: oracle)
    let lastBlockNum = PublicPriceOracle.getLatestBlockHeight(oracleAddr: oracle)
    // Get block timestamp does not always work: the # of recent blocks cached and servicable are depending on execution nodes. 
    let lastTimestamp = getBlock(at: lastBlockNum)?.timestamp
    return [
        lastResult,
        UFix64(lastBlockNum),
        lastTimestamp ?? 0.0
    ]
}
```

Sample result for "Flow/USD" price feed:

```javascript
[0.58717715, 57835057.00000000, 1690794621.00000000]
```

Note that:&#x20;

* The data is updated whichever condition is met first:
  * Deviation is beyond certain threshold (by default 0.5%)
  * A fixed window of time has passed (by default 2000 blocks)&#x20;
* Users of the PublicPriceOracle need to check the latest update time and handle the extreme condition if this data is too old.
* We recommend to use [blockHeight](https://developers.flow.com/cadence/language/environment-information#block-information), as the block timestamp is not accurate or not always retrievable: the number of recent blocks cached and servicable are depending on execution nodes.&#x20;

### DEX-based TWAP Price Oracle

Check examples [here](https://docs.increment.fi/protocols/decentralized-exchange/smart-contract-api#build-a-twap-oracle).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.increment.fi/protocols/decentralized-price-feed-oracle/using-price-feeds.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
