Stork is a true decentralized oracle with on-chain price computation. This means that median prices are calculated on StarkNet based on price quotes provided by individual publishers, rather than being aggregated off-chain. This design also means that individual publisher quotes are available as standalone data points that can be requested should users choose to perform their own calculations with the data.
The key StarkNet components of the Stork are the publisher contract and oracle contract. Both contracts follow a proxy/implementation pattern, where users interact with the Proxy contract. This pattern allows for some implementation to change without changing the address used by calling projects. This is particularly important early in development to allow for fast iteration, but over time this ability is restricted to prevent misuse by anyone, including Stork.
The Oracle contract handles all pricing operations and storage. The Oracle Proxy is the primary contract called by other external contracts. Its responsibilities include:
- Managing (receiving, validating ,storing and returning) a list of permitted price feeds
- Managing (receiving, validating, and storing) prices received from from publishers
- Properly aggregating and returning price feeds received from publishers
The Publisher contract handles publisher allowlisting and validation. Its responsibilities include:
- Managing list of allowlisted publishers
- Managing list of "standard publishers", whose results are returned in aggregation
- Verifying signatures and validating publishers
Stork has native support for metadata such as liquidity or volatility. While it is possible to perform these calculations on StarkNet based on raw data, at this stage we suggest using metadata publishers as this significantly reduces the cost of storage.
# For each publisher/oracle whose price P may(1) be used in aggregation:
# keep only nvalid (2) prices
# Sort valid prices by price value
# (Optionally, discard high/low/95%, if cardinality is above a threshold)
# return median
# (1) some publishers may provide useful prices that are nonetheless not
# desireable in aggregation, e.g. if they compute price in some novel way
# (2) prices need to have a recent timestamp to be considered valid, to avoid
# including prices provided by a stale publisher
As described in our Medium article, while StarkNet drastically reduces on-chain computation costs by replacing consensus with verification, data validium (in effect, keeping data off-chain) can reduce the marginal cost of data to a point where the size of the data catalog is no longer limited by storage costs.