https://github.com/smartcontractkit/feed-registry
Chainlink Feed Registry
https://github.com/smartcontractkit/feed-registry
Last synced: about 1 month ago
JSON representation
Chainlink Feed Registry
- Host: GitHub
- URL: https://github.com/smartcontractkit/feed-registry
- Owner: smartcontractkit
- License: other
- Created: 2021-03-12T17:28:54.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-07-15T14:09:48.000Z (almost 4 years ago)
- Last Synced: 2025-04-30T18:47:18.081Z (about 1 month ago)
- Language: TypeScript
- Homepage: https://docs.chain.link/docs/feed-registry
- Size: 1.08 MB
- Stars: 6
- Watchers: 120
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Chainlink Feed Registry
The Chainlink Feed Registry is an on-chain mapping of assets to feeds. It enables you to query Chainlink price feeds from a pair of asset and denomination addresses directly, without needing to know the feed contract addresses. They enable smart contracts to retrieve the latest price of an asset in a single call, from a single contract.
## Background
DeFi protocols that use Chainlink often implement their own on-chain registry of token addresses to Chainlink feeds. To speed up integration and ensure that protocols use the correct feeds, the Feed Registry provides a canonical on-chain registry of assets to feeds.
## Architecture

The Feed Registry consists of the following contracts:
- `FeedRegistry` is an on-chain mapping of `(address base, address quote)` pairs to Chainlink aggregator contracts.
- `PairReadAccessController` is an access controller contract to allowlist specific contracts from reading the feed registry.
- `Denominations` is an external library contract containing base and quote identifiers for assets that do not have a canonical Ethereum address.## Feed Registry price feed getters
The `FeedRegistry` implements a similar interface as the [`AggregatorProxy`](https://github.com/smartcontractkit/chainlink/blob/develop/evm-contracts/src/v0.6/AggregatorProxy.sol) contract, except it takes in two additional inputs: `base` and `quote`.
```solidity
interface FeedRegistryInterface {function latestAnswer(
address base,
address quote
)
external
view
returns (
int256 answer
);... other getters
}
```The `address` type is used for `base` and `quote` after gathering feedback from multiple users. These `base` and `quote` address represent a specific pair. For example, to query the LINK / USD feed, you call:
```solidity
latestAnswer(address base, address quote)
```by supplying an `base` and `quote` parameter, with the LINK token address and the `Denominations.USD` address respectively.
## Feed Registry price feed management
The `FeedRegistry` contract has the following setters to add / update / remove feeds to / from the registry:
- `proposeFeed()`
- `confirmFeed()`These functions follow the same 2-step design that exists in other Chainlink contracts, such as `AggregatorProxy` and `ConfirmedOwner`.
## Feed Registry round helpers
A set of round helper functions help to simplify the process of querying historical round data, by surfacing more round information previously not captured in `AggregatorProxy` `Phase`s:
- `getRoundFeed()` returns the underlying aggregator for a specific round
- `getPhaseRange()` returns the starting and ending round ids of a phase
- `getPreviousRoundId()` and `getNextRoundId()` provides hypermedia-like links to query previous and next rounds even across multiple phases.## Setup
```sh
$ yarn install
```Create a `.env` following the `.env.example`:
```
INFURA_API_KEY=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
MNEMONIC=here is where your twelve words mnemonic should be put my friend
```### Compile
Compile the smart contracts with Hardhat:
```sh
$ yarn compile
```### TypeChain
Compile the smart contracts and generate TypeChain artifacts:
```sh
$ yarn typechain
```### Lint Solidity
Lint the Solidity code:
```sh
$ yarn lint:sol
```### Lint TypeScript
Lint the TypeScript code:
```sh
$ yarn lint:ts
```### Test
Run the Mocha tests:
```sh
$ yarn test
```To run a single test:
```sh
$ yarn test test/FeedRegistry.test.ts
```### Coverage
Generate the code coverage report:
```sh
$ yarn coverage
```### Clean
Delete the smart contract artifacts, the coverage reports and the Hardhat cache:
```sh
$ yarn clean
```## Tooling
- [Hardhat](https://github.com/nomiclabs/hardhat): compile and run the smart contracts on a local development network
- [TypeChain](https://github.com/ethereum-ts/TypeChain): generate TypeScript types for smart contracts
- [Ethers](https://github.com/ethers-io/ethers.js/): renowned Ethereum library and wallet implementation
- [Waffle](https://github.com/EthWorks/Waffle): tooling for writing comprehensive smart contract tests
- [Solhint](https://github.com/protofire/solhint): linter
- [Solcover](https://github.com/sc-forks/solidity-coverage) code coverage
- [Prettier Plugin Solidity](https://github.com/prettier-solidity/prettier-plugin-solidity): code formatter