Blog.

Chaos Labs Open Sources Chainlink Price Feed NPM Module

Cover Image for Chaos Labs Open Sources Chainlink Price Feed NPM Module
Omer Goldberg
Omer Goldberg

🔍 Overview

As a passionate DeFi contributor, Chaos Labs is always excited to partner with top DeFi protocols. Chainlink is the leading decentralized blockchain oracle network. As part of our commitment and mission to drive DeFi adoption, Chaos Labs builds and publishes open-source tools for the larger developer ecosystem. Today, we are proud to share the Chainlink Price Feeds NPM module.

🏆 Goals

Part of the stress tests and simulations we run at Chaos Labs involve heavy communication with Chainlink oracles. To that end, we wanted to create a NPM module to easiy interface with Chainlink price feeds and fetch feed data for various networks.

💻 Chainlink Price Feed Module

A simple package for fetching Chainlink price feeds for various networks. This package currently supports the following networks:

  • Ethereum
  • Avalanche
  • MoonRiver
  • Arbitrum
  • Binance Smart Chain
  • Fantom
  • Matic

Installation

npm i @chaos-labs/chainlink-price-feeds

API This module exposes 3 objects:

SUPPORTED_NETWORKS

const SUPPORTED_NETWORKS = {
  ETHEREUM: "ethereum",
  AVALANCHE: "avalanche",
  MOON_RIVER: "moon_river",
  ARBITRUM: "arbitrum",
  BSC: "bsc",
  FANTOM: "fantom",
  MATIC: "matic",
};

getPriceFeedsForNetwork(network: string)

Returns the following values for each supported network. Please pass the network param from SUPPORTED_NETWORKS. Exampe payload:

{
    "ethereum-addresses": {
        "title": "Ethereum Data Feeds",
        "networks": [
            {
                "name": "Ethereum Mainnet",
                "url": "https://etherscan.io/address/%s",
                "proxies": [
                    {
                        "pair": "1INCH / ETH",
                        "deviationThreshold": 2,
                        "heartbeat": "24h",
                        "decimals": 18,
                        "proxy": "0x72AFAECF99C9d9C8215fF44C77B94B99C28741e8"
                    },
                    {
                        "pair": "1INCH / USD",
                        "deviationThreshold": 1,
                        "heartbeat": "24h",
                        "decimals": 8,
                        "proxy": "0xc929ad75B72593967DE83E7F7Cda0493458261D9"
                    },
                    ...
                ]
            }
        ]
    },
    "matic-addresses": {
        "title": "Polygon (Matic) Data Feeds",
        "networks": [
            {
                "name": "Polygon Mainnet",
                "url": "https://polygonscan.com/address/%s",
                "proxies": [
                    {
                        "pair": "1INCH / ETH",
                        "deviationThreshold": 2,
                        "heartbeat": "24h",
                        "decimals": 18,
                        "proxy": "0x72AFAECF99C9d9C8215fF44C77B94B99C28741e8"
                    },
                    {
                        "pair": "1INCH / USD",
                        "deviationThreshold": 1,
                        "heartbeat": "24h",
                        "decimals": 8,
                        "proxy": "0xc929ad75B72593967DE83E7F7Cda0493458261D9"
                    },
                    ...
                ]
            },
            {
                "name": "Mumbai Testnet",
                "url": "https://mumbai.polygonscan.com/address/%s",
                "proxies": [...],
            }
        ],
    }

`getProxiesForNetwork()``

Returns the proxy addresses for each pair for a given network.

[
    {
        "pair": "1INCH / ETH",
        "deviationThreshold": 2,
        "heartbeat": "24h",
        "decimals": 18,
        "proxy": "0x72AFAECF99C9d9C8215fF44C77B94B99C28741e8"
    },
    {
        "pair": "1INCH / USD",
        "deviationThreshold": 1,
        "heartbeat": "24h",
        "decimals": 8,
        "proxy": "0xc929ad75B72593967DE83E7F7Cda0493458261D9"
    },
    {
        "pair": "AAPL / USD",
        "deviationThreshold": 0.5,
        "heartbeat": "24h",
        "decimals": 8,
        "proxy": "0x139C8512Cde1778e9b9a8e721ce1aEbd4dD43587"
    },
    {
        "pair": "AAVE / ETH",
        "deviationThreshold": 2,
        "heartbeat": "24h",
        "decimals": 18,
        "proxy": "0x6Df09E975c830ECae5bd4eD9d90f3A95a4f88012"
    },
    ...
]

⏭️ What's next?

We're currently in execution mode, researching and building more Chainlink infrastructure and tooling. Stay tuned for upcoming release of products and developer tools ğŸ˜Ž