Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dAPIs Reference Section updates #568

Merged
merged 8 commits into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/reference/dapis/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ module.exports = [
text: 'dAPIs are data feeds',
link: '/reference/dapis/understand/',
},
{
text: 'Managed dAPIs',
link: '/reference/dapis/understand/managed',
},
{
text: 'Self-funded dAPIs',
link: '/reference/dapis/understand/self-funded',
},
{
text: 'Reading dAPIs',
link: '/reference/dapis/understand/read-dapis',
Expand Down
123 changes: 123 additions & 0 deletions docs/reference/dapis/understand/managed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
---
title: Managed dAPIs
sidebarHeader: Reference
sidebarSubHeader: dAPIs
pageHeader: Reference → dAPIs → Understanding dAPIs
path: /reference/dapis/understand/managed.html
outline: deep
tags:
---

<PageHeader/>

<SearchHighlight/>

<FlexStartTag/>

# {{$frontmatter.title}}

Managed dAPIs are sourced directly from mulitple
[first-party](/explore/airnode/why-first-party-oracles.html) data providers
running an [Airnode](/reference/airnode/latest/understand/) and aggregated using
Airnode's signed data. The gas costs and avaibality of Managed dAPIs is managed
by the dAPI team within [API3 DAO](/explore/dao-members/).

## How it works

[Datafeed values are stored on-chain](/reference/dapis/understand/#data-feeds-values-stored-on-chain)
within the
[`Api3ServerV1.sol`<ExternalLinkImage/>](https://github.com/api3dao/airnode-protocol-v1/tree/79b509f0e88a96fa4ea3cd576685051d37c9a504/contracts/api3-server-v1)
contract and are updated on the basis of `beaconIds`. To provide aggregated
data, beacon sets are used which are a collection of multiple `beaconIds` that
are then used to calculate the aggregated value on-chain using a median
function. The median value is then used to update the `beaconSetId` of the dAPI.
Beacon sets get updated by updating each underlying beacon using
`updateBeaconWithSignedData` and then calling the function to update the beacon
set `updateBeaconSetWithBeacons`.

dAPIs are human-readable mappings that maps to a `beaconId` or `beaconSetId`.
The `beaconId` for each dAPI gets updated when the price hits the set
[deviation threshold](/reference/dapis/understand/deviations.html)/[heartbeat](/reference/dapis/understand/deviations.html#heartbeat)
using
[Airnode's Signed Data](/reference/airnode/latest/understand/http-gateways.html).
[Airseeker](/reference/dapis/understand/managed.html#airseeker) and other
entites who have access to Airnode's signed data are responsible for updating
each individual `beaconId` for each dAPI.

A `beaconId` for each dAPI is derived from the hash of the provider's Airnode's
address and its Template ID(a hash of one of the Airnode's `endpointId` and
encoded parameters).

The dAPI team is running Airseekers which are primarily responsible for updating
the `beaconId` based on the specification of the dAPI. Providers also update the
`beaconId` at a higher deviation threshold/heartbeat as a fallback. There are
also other entites that serve as additional fallback which operate at an even
higher deviation threshold/heartbeat.

## Airseeker

Like Airnode,
[Airseeker<ExternalLinkImage/>](https://github.com/api3dao/airseeker/) is a
serverless lambda function that is responsible for updating the values of each
`beaconId` for each dAPI. It is used to update the beacons with signed responses
from
[Airnode's HTTP-Signed-Gateway](/reference/airnode/latest/understand/http-gateways.html).

Airseeker uses Airnode's built-in HTTP-Gateway to receive signed data and push
it on-chain in a tamper proof way.

Similar to Airnode's OIS, Airseeker also requires a configuration file that is
used to configure the Airseeker.
[Click here to see an example of an Airseeker configuration file.<ExternalLinkImage/>](https://github.com/api3dao/airseeker/blob/main/config/airseeker.example.json).
The configuration file is used to configure the deviation thresholds and
heartbeat for each `beaconId` or `beaconSetId`.

## Providers for Managed dAPIs

Currently, the [API3 Market<ExternalLinkImage/>](https://market.api3.org/) has 4
differnet asset classes that are listed below. For each type, there are multiple
providers that are running an Airnode and are providing data for the dAPIs. The
providers are listed below:

| Asset Type | Data Provider |
| -------------- | ----------------------------------------------------------------------- |
| Cryptocurrency | Nodary, Coinpaprika, Finage, Twelvedata, NCFX, Kaiko, dxFeed |
| Forex | Nodary, Finage, Twelvedata, NCFX, IEXCloud, Finnhub, dxFeed, Tradermade |
| Commodities | Nodary, Finage, Twelvedata, dxFeed, Tradermade |
| Equities | Nodary, Finage, Twelvedata, IEXCloud, finnhub, dxfeed |

All the data providers listed here are selected and properly tested by the dAPI
team to ensure the highest quality data availability for the listed dAPIs.

## Update Process

When a user places an order for a Managed service, the order will be created
on-chain and the dAPI team will manually update the mapping for the dAPI to
point to a particular `beaconSetId` with the requested deviation threshold and
heartbeat. The update process is currently manual and will be automated in the
future.

::: info Note

The proxy contract address to read from the dAPI will remain the same.
Purchasing a better configuration will not change the proxy contract address for
the dAPI.

:::

With Managed dAPIs, dApps can have an option to configure the dAPI's devation
threshold and heartbeat. For Managed feeds, dApps have the following options to
choose from based on the chain and dAPI:

| Deviation | Heartbeat |
| --------- | --------- |
| 0.25% | 2 minutes |
| 0.25% | 24 hours |
| 0.5% | 24 hours |
| 1% | 24 hours |

See the guide
[Subscribing to Managed dAPIs](/guides/dapis/subscribing-managed-dapis/) and
learn more on how to access Managed dAPIs.

<FlexEndTag/>
93 changes: 93 additions & 0 deletions docs/reference/dapis/understand/self-funded.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
title: Self-funded dAPIs
sidebarHeader: Reference
sidebarSubHeader: dAPIs
pageHeader: Reference → dAPIs → Understanding dAPIs
path: /reference/dapis/understand/self-funded.html
outline: deep
tags:
---

<PageHeader/>

<SearchHighlight/>

<FlexStartTag/>

# {{$frontmatter.title}}

Self-funded dAPIs are single-source data feeds that are funded by the users with
their own funds. The amount of gas supplied determines how long the dAPI will be
available to use. If it runs out of gas, the dAPI will no longer be updated
unless it is funded again.

## How it works

Unlike [Managed dAPIs](/reference/dapis/understand/managed.html), self-funded
dAPIs are single-source datafeeds. The data is sourced from a single
[first-party](/explore/airnode/why-first-party-oracles.html) data provider
running an [Airnode](/reference/airnode/latest/understand/) and an
[Airseeker](/reference/dapis/understand/self-funded.html#airseeker) which
updates the `beaconId` with Airnode's signed data. The gas costs for self-funded
dAPIs are managed by the users themselves. As long as the sponsor wallet of the
dAPI has enough gas, it will be updated.

Datafeed values for Self-funded dAPIs are also stored on-chain within the same
[`Api3ServerV1.sol`<ExternalLinkImage/>](https://github.com/api3dao/airnode-protocol-v1/tree/79b509f0e88a96fa4ea3cd576685051d37c9a504/contracts/api3-server-v1)
contract and are updated on the basis of `beaconIds`. The provider who is
running an Airnode is also running an Airseeker that is responsible for updating
the values of each `beaconId` for each dAPI.

dAPIs are human-readable mappings that maps to a certain `beaconId`.

A `beaconId` for each dAPI is derived from the hash of the provider's Airnode's
address and its Template ID(a hash of one of the Airnode's `endpointId` and
encoded parameters).

For each beacon, there is a dedicated Sponsor wallet that is used to pay for the
gas costs of updating the beacon. The Sponsor wallet is derived from the
`beaconId` ,its update parameters and the extended Public key of the `Airseeker`
mnemonic.

## Airseeker

Like Airnode,
[Airseeker<ExternalLinkImage/>](https://github.com/api3dao/airseeker/) is a
serverless lambda function that is responsible for updating the values of each
`beaconId` for each dAPI. It is used to update the beacons with signed responses
from
[Airnode's HTTP-Gateway](/reference/airnode/latest/understand/http-gateways.html).

Airseeker uses Airnode's built-in HTTP-Gateway to receive signed data and push
it on-chain in a tamper proof way.

Similar to Airnode's OIS, Airseeker also requires a configuration file that is
used to configure the Airseeker.
[Click here to see an example of an Airseeker configuration file.<ExternalLinkImage/>](https://github.com/api3dao/airseeker/blob/main/config/airseeker.example.json).
The configuration file is used to configure the
[deviation thresholds](/reference/dapis/understand/deviations.html) and
[heartbeat](/reference/dapis/understand/deviations.html#heartbeat) for each
`beaconId`. For self-funded dAPIs, the deviation threshold is set to 1% and the
heartbeat is set to 24 hours.

No aggregation services are provided for self-funded dAPIs.

For Self-funded dAPIs, A single data provider is running its own Airnode and
Airseeker and the dAPIs are pointed to it's own `beaconIds`. Anyone who decides
to fund a self-funded dAPI will be funding the the data provider's underlying
`beaconId` and their Sponsor wallets.

## Provider for Self-funded dAPIs

Currently, for self-funded dAPIs,
[Nodary<ExternalLinkImage/>](https://nodary.io/) is the data provider. Nodary is
an independent group within the API3 Ecosystem that are building high-impact
oracle services. They currently operate 139 crypto, forex, stock and commodity
asset price data feeds each on 24 chains, adding up to a total 3336 unique data
feeds.

See the guide
[Subscribing to Self-funded dAPIs](/guides/dapis/subscribing-self-funded-dapis/)
and learn more on how to access Self-funded dAPIs.

<FlexEndTag/>
Loading