Harbinger Wrapper

Harbingerarrow-up-right is an on-chain oracle that provides a signed price feed for digital assets. The feed represents normalized price candles with the following data: (1) start time, (2) end time, (3) open price, (4) high price, (5) low price, (6) close price, and (7) volume as well as an entrypoint for smart contracts to query the volume weighted average price for an asset over the past 6 updates.

Price data is independently updated with signed calls from different centralized exchanges (Coinbase, Binance, Gemini, OKEx). A separate Harbinger oracle is deployed for each price feed source. Currently, the only exchange that regularly posts price data is Coinbase.

Technically, a Harbinger oracle consists of two smart contracts, a storage contract that stores latest price updates and a normalizer contract that computes a volume-weighted average price from the last n updates.

Queries

Import Plugins

#import { Query, Connection } into Tezos from "w3://ens/tezos.web3api.eth"

Response Types

Get Asset Response

Type response for getting asset last candle details.

List Providers Response

List Assets Response

Get Candle Response

Get Normalized Price Response

Network

Select between various Tezos networks.

Custom Connection

Define custom connection parameters.

Query Functions

Get Asset Data

Returns data of a particular asset when the asset’s code is passed.

List Assets

List available price pairs for the requested provider. This can be achieved by reading the storage of the normalizer contract for provider and extracting the list of strings from storage.assetCodes.

Get Candle

Reads the most recent price data (OHLCV plus timestamps) sent by the provider. This can be achieved by reading the storage of the storage contract for provider and extracting the contents of bigmap oracleData at key assetCode.

List Providers

List price providers, returns a list of unique provider identifiers (names) that can be used in subsequent functions to query the relevant contracts.

Get Normalized Price

Reads the normalized price for asset assetCode from oracle feed for provider.

Oracle Data

All price oracle data is represented in two formats:

  • A standard unix timestamp for candle starts and ends

  • A natural number for prices and volumes, with six digits of precision. For instance, the price $123.45 would be represented as 123450000.

Creating a Web3 client with Tezos Plugin support

Call a function from the URI via Polywrap + GraphQL

Wrapper Example

The Harbinger wrapper can be found in the ./tezos/harbinger/wrapper folder. Install the node packages and build plugin-js

Running Tests

The e2e tests can be found in the src/tests/e2e folder. Run the e2e tests as follows:

Project Structure

Queries

Can be found in the ./src/query folder containing the index.ts file which is the AssemblyScript query logic and schema.graphql file which contains the GraphQL schemas for the functions in the query's index file.

Tests

To test the functions in query/index.ts, e2e tests are written in the __tests__/e2e folder.

Last updated