Skip to content

First-party price feed contracts for EVM chains

Notifications You must be signed in to change notification settings

neccdao/price-feeds-evm

Repository files navigation

Flux - First-Party Price Feeds for EVM

This repository contains contracts for first-party price feeds for EVM chains, using OpenZeppelin for access control. Those with a validator role can post numeric data to deployed contracts at any interval. Contracts are compatible with Chainlink's V2 and V3 aggregator interface.

Supported networks: arbitrum, arbitrum-testnet, aurora, aurora-testnet, avalanche, avalanche-testnet, bsc, bsc-testnet, celo, fantom, goerli, harmony, harmony-testnet, kovan, mainnet, matic-testnet, polygon, rinkeby, ropsten, xdai

Usage

Pre-Requisites

Before running any command, you need to create a .env file and set a BIP-39 compatible mnemonic as an environment variable. Follow the example in .env.example. If you don't already have a mnemonic, use this website to generate one.

Then, proceed with installing dependencies:

yarn install

Next, compile the smart contracts with Hardhat:

$ yarn compile

Deploy

Deploy a price feed contract (e.g. to Aurora):

$ yarn deploy --decimals 8 --description "ETH / USD" --network aurora

Save the deployed contract address outputted by the command above.

Optionally include --validator "0xMyAddress" to grant a different address the initial validator role rather than the one derived from the mnemonic in the .env file.

Note: We deployed a price feed contract on Aurora at address 0xb5c82C7F2a5a90b040f411fe7D80C154Cc082160 with all role-based permissions removed. Feel free to try posting and fetching data on this contract without deploying your own!

Update answer

Using the mnemonic of the validator in the .env file, update the value on a deployed contract:

$ yarn transmit --contract "0xContractAddress" --answer 4200000000 --network aurora

Fetch latest answer

$ yarn latestAnswer --contract "0xContractAddress" --network aurora

4200000000

TypeChain

Compile the smart contracts and generate TypeChain artifacts:

$ yarn typechain

Lint Solidity

Lint the Solidity code:

$ yarn lint:sol

Lint TypeScript

Lint the TypeScript code:

$ yarn lint:ts

Test

Run the Mocha tests:

$ yarn test

Coverage

Generate the code coverage report:

$ yarn coverage

Report Gas

See the gas usage per unit test and average gas per method call:

$ REPORT_GAS=true yarn test

Clean

Delete the smart contract artifacts, the coverage reports and the Hardhat cache:

$ yarn clean

Syntax Highlighting

If you use VSCode, you can enjoy syntax highlighting for your Solidity code via the vscode-solidity extension. The recommended approach to set the compiler version is to add the following fields to your VSCode user settings:

{
  "solidity.compileUsingRemoteVersion": "v0.8.4+commit.c7e474f2",
  "solidity.defaultCompiler": "remote"
}

Where of course v0.8.4+commit.c7e474f2 can be replaced with any other version.

About

First-party price feed contracts for EVM chains

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published