Skip to main content

Stork Oracle Chromia extension

The Stork Oracle Chromia extension provides developers with real-time access to up-to-date asset prices, achieving sub-millisecond latency. With its advanced aggregation algorithms, Stork delivers highly accurate price feeds, making it essential for DeFi applications like perpetual DEXes, prediction markets, and financial protocols. Its geographically distributed network of data providers guarantees data stability and availability, even during high demand, which makes Stork perfect for real-world asset management, gaming platforms, and AI-driven dapps. By integrating with Chromia's relational blockchain architecture, Stork enables seamless data processing and opens up new opportunities for building decentralized applications that prioritize precision and performance.

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.yml
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.

If necessary, override the Stork public key and publisher public keys as follows:

chromia.yml
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.yml
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:

@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:

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 with 18 decimal places. Use the following utility function to convert prices to decimal format:

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.