# Stork Oracle · Chromia Docs (concept)

> Stork is the leading oracle for low-latency DeFi protocols, delivering price data at ultra-low latency.

Source: https://docs.chromia.com/ecosystem/extensions/stork/

# Stork Oracle

On this page

* [Blockchain configuration](#blockchain-configuration)
* [Rell Integration](#rell-integration)

Stork is the leading oracle for low-latency DeFi protocols, delivering price data at ultra-low latency. Stork supports a
wide range of use cases including perpetuals markets, lending protocols, and DeFi ecosystems. You can learn more about
Stork [here](https://stork.network) and in the Stork [docs](https://docs.stork.network).

The Stork Oracle Chromia extension integrates Stork price feeds into Chromia blockchains by verifying and injecting the
latest price updates at the beginning of each block.

## Blockchain configuration

When you lease your container, ensure you select the **Stork Oracle Chromia extension**. To start using the extension,
configure your blockchain to listen for asset updates and include the necessary Stork extensions. Below is a sample
configuration:

chromia.ymlYAML

```
blockchains:
  <my_blockchain_name>:
    module: <module_name>
    config:
      gtx:
        modules:
          - "net.postchain.stork.StorkOracleGTXModule"
      sync_ext:
        - "net.postchain.stork.StorkOracleSynchronizationInfrastructureExtension"
      stork:
        assets:
          - "BTCUSD"
          - "ETHUSD"
          - "..."
```

`Assets`: Specify the list of assets (e.g., BTCUSD, ETHUSD) that you want the extension to monitor for updates. You can
find the complete list of assets at [this link](https://docs.stork.network/resources/asset-id-registry).

The extension should already be aware of all publisher public keys. However, if it should ever be necessary, you can
override the Stork public key and publisher public keys as follows:

chromia.ymlYAML

```
blockchains:
  <my_blockchain_name>:
    module: <module_name>
    config:
      stork:
        stork_pubkey: x"0a803F9b1CCe32e2773e0d2e98b37E0775cA5d44"
        publisher_pubkeys: # List ALL publisher keys here if you want to override
          - x"5c946686b0302be54d85394015a9f9fa0952984e"
          - "..."
```

## Rell Integration

Integrate the Stork Oracle Extension library into your Rell project by adding it to your configuration:

chromia.ymlYAML

```
libs:
  stork:
    registry: https://gitlab.com/chromaway/core/stork-oracle-chromia-extension
    path: rell/src/stork
    tagOrBranch: 1.0.1
    rid: x"EBB409F91EBC5EB3816570C9FDB5A170180249CF7F74EEDFC09C428E288F4114"
    insecure: false
```

To process price updates in your application, extend the `on_stork_oracle_prices_update` hook:

Rell

```
@extend(on_stork_oracle_prices_update) function handle_price_update(stork_oracle_prices) {
    // Add your custom logic here
}
```

The `stork_oracle_prices` struct provides detailed information about price updates:

Rell

```
struct stork_oracle_prices {
    asset: text;
    stork_price;
    publisher_prices: list<publisher_price>;
}

struct stork_price {
    price: big_integer;
    signature;
    timestamp_nanos: integer;
    merkle_root: byte_array;
    type: text;
    version: text;
    checksum: byte_array;
}

struct publisher_price {
    price: big_integer;
    signature;
    timestamp_seconds: integer;
}

struct signature {
    signer: byte_array;
    r: byte_array;
    s: byte_array;
    v: byte_array;
}
```

The extension automatically verifies the signatures, so you don't need to include that logic in your Rell code.

Prices are represented as [`big_integer`](https://docs.chromia.com/pages/rell-stdlib/-rell-system-library/root/big_integer/) with 18 decimal places. Use the following utility function to convert prices to
decimal format:

Rell

```
function convert_price_to_decimal(price: big_integer): decimal
```

You can find the source code and further details about the Stork Oracle Chromia extension in the
[official repository](https://gitlab.com/chromaway/core/stork-oracle-chromia-extension).

[View this page on docs.chromia.com](https://docs.chromia.com/ecosystem/extensions/stork/)Content mirrored from the live docs
