Skip to content

Commit

Permalink
Update dAPI reference and guides section (#723)
Browse files Browse the repository at this point in the history
* update reference and guides

* 2.1 Market Updates

* removed IProxy interface, removed old videos

---------

Co-authored-by: vanshwassan <vanshwassan@users.noreply.github.com>
Co-authored-by: Ashar Shahid <Ashar2shahid@gmail.com>
  • Loading branch information
3 people authored Apr 29, 2024
1 parent e28a76c commit e9a7b9e
Show file tree
Hide file tree
Showing 51 changed files with 623 additions and 1,500 deletions.
Binary file added docs/explore/assets/images/dAPI_q2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 17 additions & 16 deletions docs/explore/dapis/OEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,29 @@ capture value that would otherwise have gone to third parties.

### What is OEV?

Oracle Extractable Value (OEV) is a subset of MEV related to the way oracles are
currently designed. Any update to data feeds, or a lack thereof, can create
opportunities for OEV such as arbitrage and liquidations. During each of these
interactions value is leaking from the dApp users to both searchers and
validators. Learn more about OEV in a summary of the
Any update to data feeds, or a lack thereof, can create opportunities for OEV
such as arbitrage and liquidations. During each of these interactions value is
leaking from the dApp users to both searchers and blockchain validators. Learn
more about OEV in a summary of the
[OEV Litepaper](https://medium.com/api3/oracle-extractable-value-oev-13c1b6d53c5b).

### Leveraging OEV alongside dAPIs

Integrating OEV data feeds can turn this fee previously being imposed on your
users into a powerful economic incentive driving value to your ecosystem. OEV
data feeds will maximize the value returned to your dapp from OEV through a
sealed bid auction process similar to the one you might be familiar with from
Flashbots and MEV-Boost.
Integrating OEV-enabled data feeds can turn this fee previously being imposed on
your users into a powerful economic incentive for your protocol. With the OEV
Network, fees typically extracted through liquidation bots will be recaptured
and be able to be used for more productive means. API3 has delivered a
specialized Order Flow Auction (OFA) that maximizes the value returned to your
dApp from OEV through a sealed bid auction process similar to the one you might
be familiar with from Flashbots and MEV-Boost.

Instead of overpaying for liquidations with a fixed incentive, that during large
liquidation opportunities can be much too high than it needs to be, a sealed bid
auction hosted at the oracle can minimize the value being paid out and return
most of it back to the dapp. The liquidations will also be able to occur in a
more timely manner because you do not have to wait for a deviation threshold to
trigger oracle updates, creating a lower latency and more robust liquidation
process.
liquidation opportunities can be much much higher than it needs to be, a sealed
bid auction hosted at the oracle can minimize the value being paid out and
return most of it back to the dapp. The liquidations will also be able to occur
in a more timely manner because you do not have to wait for a deviation
threshold to trigger oracle updates, creating a lower latency and more robust
liquidation process.

### Re-directing MEV to dApps

Expand Down
42 changes: 31 additions & 11 deletions docs/explore/dapis/how-are-dAPIs-maintained.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,36 @@ dAPIs are provided on. API3 also provides access to individual beacons or beacon
sets for the users that require full control over the curation of the data feeds
they use.

## DapiServer Contract

As mentioned above, dAPIs are an abstraction layer over beacons and beacon sets.
The primary purpose of
[DapiServer.sol➚](https://github.com/api3dao/airnode-protocol-v1/blob/v0.5.1/contracts/dapis/DapiServer.sol)
is to return dAPI values to requesters (smart contracts) that has authorized to
read a particular dAPI.

::: info Read more

Learn about how the dAPI Server
## Role of `API3Server.sol`

A dAPI points to an individual beacon or an aggregation of multiple beacons
(beacon set). Each dAPI has a human-readable name (e.g., `AVAX/USD`) that makes
them easy to categorize. The contract
[API3ServerV1.sol](https://github.com/api3dao/contracts/blob/main/contracts/api3-server-v1/Api3ServerV1.sol)
maintains the link between a dAPI name and the beacon(s) it uses for the dAPI.
dApps use an API3 Market proxy contract to read any dAPI from
`API3ServerV1.sol`.

dApp owners use a proxy contract, available on the
[API3 Market](https://market.api3.org), to access a dAPI. Proxy contracts use
the
[API3Server.sol](https://github.com/api3dao/contracts/blob/main/contracts/api3-server-v1/Api3ServerV1.sol)
contract to access dAPIs. Developers can easily set the proxy contract address
in a dApp contract to start reading from the dAPIs.

<img src="../assets/images/dAPI_explainer.png" style="width:500px">

The `API3ServerV1.sol` contract reads directly from its data store of beacons,
which are powered by API provider-operated
[Airnodes](/reference/airnode/latest/understand/). Thus proxies allow dAPIs to
be used like libraries. The smart contract only needs to
[import the interface](/guides/dapis/read-a-dapi/index.md#_2-read-a-dapi) for
calling the proxy contract.

This means once a dAPI is integrated to read a different data feed, the contract
does not need to change the code itself, rather it only needs to use a different
proxy address when calling the `read()` function on the proxy contract. If the
dAPI interface has previously been imported, it abstracts away the technical
implementation of accessing new data feeds.

<FlexEndTag/>
37 changes: 8 additions & 29 deletions docs/explore/dapis/security-considerations.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ There are various moving parts in the operation of dAPIs which bring with it a
variety of security considerations. When using dAPIs integrating parties should
be aware of and understand these processes.

## Multi-sig dependency
### Multi-sig dependency

As previously mentioned, a dAPI is a mapping towards a specific beacon or beacon
Set ID, which can be changed. Currently the ability to do so rests with
Expand All @@ -37,40 +37,19 @@ ability drastically once dAPI operations have matured, by capping the amount of
changes that are allowed to be made in addition to giving the API3 DAO the
ability to revoke dAPI name setting rights through a governance vote.

## Self-funded dAPIs

Compared to managed dAPIs, self-funded dAPIs are sourced from a single datafeed
(beacon) and are hence susceptible to more risk. Downtime with the associated
Airnode or the sourced API operation will consequently lead to a stale data
point. For this reason, self-funded dAPIs are treated as an introduction to
dAPIs as well as a testing ground for data feeds. It is recommended that use
cases with higher security requirements make use of managed dAPIs when
available.

### Sponsor Wallets

Self-funded dAPIs will only update if the respective sponsor wallet has
sufficient funds available to create the on-chain transaction. Consequently, it
is imperative that the status of a respective sponsor wallet is monitored if it
is used in any capacity because there will be no updates without funds. Keeping
the sponsor wallet at a desired level can be automated with services offered by
projects like Gelato. Please note, that funds send to a sponsor wallet are not
recoverable, which means that sending small amounts to keep it operational
repeatedly is recommended over sending large amounts.

## Managed dAPIs

With managed dAPIs, API3 takes over the gas management overhead that is
associated with running dAPIs. The underlying
[beacon sets](/reference/dapis/understand/index.md) of a managed dAPI are kept
up to date by collecting signed data from the respective underlying Airnodes of
a beacon set via Airnode's HTTP-Gateway and updating the beacon values on-chain.
dAPIs will only update if the respective sponsor wallet has sufficient funds
available to create the on-chain transaction. When a user activates a dAPI and
purchases a configuration for it, the sponsor wallet gets funded with the
required gas to keep the dAPI updated. If the sponsor wallet runs out of funds,
the dAPI will not update until the sponsor wallet is re-funded/ or a new
configuration is purchased.

### Working towards absolute decentralization

It is important that no central authority has the opportunity to impact the
delivery of a dAPI's value. API3 is committed to keep the beacon sets behind a
managed dAPI updated in a completely decentralized fashion. Therefore
decentralization will be a key feature when managed dAPIs are made available.
dAPI updated in a completely decentralized fashion.

<FlexEndTag/>
125 changes: 23 additions & 102 deletions docs/explore/dapis/using-dapis.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,118 +21,39 @@ tags:
As outlined on the page [What are dAPIs?](/explore/dapis/what-are-dapis.md),
API3 has created a unified, user-friendly implementation that is designed to
simplify the process of obtaining data feed services. The API3 Market enables
dApp owners to connect to a decentralized API and access its data feeds. There
are two types of dAPIs:
dApp owners to connect to a decentralized API and access its data feeds.

- Self-funded dAPIs
- Managed dAPIs
## A Next Generation Push Oracle

## Self-funded dAPIs
dAPIs are sourced from multiple first-party oracles and aggregated using a
median function. They operate using a push model with a variety of update
specifications based on deviation thresholds. dAPIs have been designed to be
simple to integrate, manage and change.

Self-funded dAPIs currently rely on a single first-party oracle. They offer dApp
owners the opportunity to make use of data feeds with minimal up-front
commitment and are accessible
[permissionlessly](https://www.gemini.com/en-US/cryptopedia/what-is-permissionless-crypto-permissionlessness-blockchain)
for developers.
### Accessing dAPIs

### Using Self-funded dAPIs
dAPI are accessible through the [API3 Market](https://market.api3.org/dapis).
The market enables developers to permissionlessly access price feeds and manage
them once integrated. Once gas overheads required to activate a feed are
provided, within minutes price reference data will be readable on-chain.

Self-funded dAPIs require any dApp owner to provide funds into a sponsor wallet.
These funds are used by the first-party oracle, that supports a particular data
feed, to pay gas costs when placing the value of the data feed on-chain. Once
sufficient funds are available, updates will begin automatically within a 15
minute window. In accordance with deviation thresholds and heartbeat these funds
will be used to maintain the on-chain price of the respective dAPI until they
are depleted. In many cases you will find that the a dAPI's sponsor wallet has
already been funded and any dApp owner can proceed to use the dAPI.
<!-- <img src="../assets/images/Managed_dAPI_visual.png" style="width:500px"> -->

<img src="../assets/images/Sponsoring_a_feed_overview.png" style="width:500px">
It is worth noting that API3 operates all infrastructure required for data feed
updates, there is no additional infrastructure to set up, operate and maintain
by a dApp looking to utilize a dAPI.

<!--::: info Developer info
## API3 Market

dAPI implementation to your solidity contract is simple, learn more [within this
starter kit](link to API3 DAO starter kit).
The API3 Market lists all available dAPIs. It represents a hub that allows
developers to:

:::-->

<!--Self-funded dAPIs currently rely on a single first-party oracle and projects utilizing these in production and high value use cases should consider the risk and security implications.
Read more in our
[security considerations](/explore/dapis/security-considerations.md)-->

### Accessing a self-funded dAPI

The [API3 Market](https://market.api3.org) features a user-friendly UI that
enables easy activation and management of self-funded dAPIs. To use a
self-funded data feed you:

- Select a data feed within the API3 Market
- [Fund a sponsor wallet](/guides/dapis/subscribing-self-funded-dapis/) (if not
already funded)
- Deploy the proxy contract (if not already deployed)
- [Read the dAPI](/guides/dapis/read-a-dapi/)

<img src="../assets/images/self_funded_market_process_notext.png" style="width:500px">

The dAPI integration process has been designed to be simple and abstract away
any further technical lifting, offering a standardized implementation for all
data feeds. Developers then obtain the value of by reading the dAPIs value using
a [proxy contract](/reference/dapis/understand/proxy-contracts.md).

::: info Get started

Developers can use the API3 Market now to
[<span style="color:rgb(16, 185, 129);">read</span>](/guides/dapis/read-a-dapi/)
a self-funded dAPI.

:::

### Why use self-funded dAPIs

A self-funded data feed provides advantages for dApp owners:

- Developers can utilize dAPIs in a permissionless fashion using the self-serve
tooling within the [API3 Market](https://market.api3.org/dapis)
- Developers have the ability to use a first-party oracle within early stages of
the development life cycle without an ongoing commitment
- dApps that may only require data feeds for a short period of time can activate
a self-funded dAPI as needed

<!--Additionally, the API3 Market provides an intuitive interface to check the
status of respective self-funded dAPIs and fund them accordingly.-->

## Managed dAPIs

Managed dAPIs are sourced from multiple first-party oracles and aggregated using
a median function.

### Accessing Managed dAPIs

When available, self-funded dAPIs can be upgraded to a managed dAPI by paying
the API3 DAO. The API3 Market will facilitate this process and allow potential
users to specify desired amount of first-party oracles that should be included
in the aggregation. API3 will create the respective
[beacon set](/reference/dapis/understand/index.md) for a dAPI from the best
available first-party oracles for the requested data set and point the dAPI
towards this creation.

<img src="../assets/images/Managed_dAPI_visual.png" style="width:500px">

In addition, API3 takes over the gas management overhead associated with
operating managed dAPIs. Compared to self-funded dAPIs, managed dAPIs are
monetized, as API3 requires payment in USDC on Ethereum Mainnet to operate them.
API3 recommends the usage of managed dAPIs in high value production use cases.

# API3 Market

The API3 Market lists all available dAPIs, self-funded and managed dAPis. It
represents a hub that allows developers to:

- Browse through a catalogue of potential data feeds to integrate
- Fund their operation in the case of self-funded dAPIs
- Pay for the upgrade to a managed version
- Search for available dAPIs data feeds to integrate
- Provide gas for dAPIs to activate a decentralized oracle
- Access the proxy address to read the value of a required data pair
- Request new data types

You can head to the [API3 Market](https://market.api3.org/dapis) now and use
self-funded dAPIs.
You can head to the [API3 Market](https://market.api3.org/dapis) to explore this
further.

<FlexEndTag/>
Loading

0 comments on commit e9a7b9e

Please sign in to comment.