Oracle Proxy

Oracle is the primary endpoint for reading and writing asset information. As a user, you can use the various read endpoints.

Get One Value

Returns a single PriceTick object with a median price. The type field in the response object will indicate the median. The median is returned either as an on-chain (on L2) computed median, or during testing, may be a median calculation done off-chain.

Retrieve a single value for an asset

GET OracleProxy/get_value

Retrieve a single value for an asset. Note that the object being returned is of type PriceTick

Query Parameters

NameTypeDescription

assetId*

felt

Asset (uppercased string, ascii-encoded to base10 number), e.g. "ETH/USD"

// See PriceTick in Structures

Get Stats Bundle

Returns a PriceAggregate object containing more advanced price calculation. For example, the median price calculation is a liquidity weighted price, computed as follows:

1nmidpriceiliquidityiliquidityi\sum_1^n\frac{midprice_i*liquidity_i}{liquidity_i}

​where liquidity is defined as

midprice1%midpricebidPriceibidVolumei+midpricemidprice+1%askPriceiaskVolumei2\frac{\sum_{midprice-1\%}^{midprice}bidPrice_i*bidVolume_i+\sum_{midprice}^{midprice+1\%}askPrice_i*askVolume_i}{2}

Why use get_value instead of get_bundle, which contains more data about an asset? Consider the bundle to be reflective of the more detailed financial data, such as liquidity, used by more complex DeFi applications. At present, both endpoints can be used interchangeably, but expect the methods to differentiate in the future.

Retrieves a bundle of statistics about the asset

GET OracleProxy/get_price_bundle

Use this method to get access to variance, liquidity (see above for definition), and a liquidity weighted price.

Query Parameters

NameTypeDescription

asset*

felt

Asset (uppercased string, ascii-encoded to base10 number), e.g. "ETH/USD"

{
    // See PriceAggregate in structures
}

Get Multiple Values

This method is not yet implemented; coming Sep 2022.

Retrieves all applicable prices

GET OracleProxy/get_values

Note: This method is not yet implemented

Last updated