Gyroscope Protocol
HomeApp
  • tldr: What is Gyroscope
  • Audit Reports
  • POOLS
    • Overview
    • 2-CLPs
    • 3-CLPs
    • E-CLPs
    • Dynamic CLPs
    • Rehype CLPs
    • Technical documents
  • Governance
    • Overview
    • How it works
      • Voting Vaults
        • The Founding Member Vault
        • Councillor Vault
        • Associated DAO Vault
        • GYD LP Vault
        • GYFI Vault
      • Action Tiering
      • On-chain proposals
      • Vote delegation
      • Conditional cashflows
      • GYD Recovery Module
      • Optimistic Approval
        • Emergency Recovery
        • Limiting Upgradeability
    • Governance process
    • GYFI Tokenomics
      • Token Allocation
      • Release schedules
      • Eligibility
  • GYD
    • Overview
    • How it works
      • Reserve design
      • Autonomous pricing
        • Dynamic Stability Mechanism
        • GYD Trading Pools
        • Economic intuition
      • Reserve Safety Checks
      • Complementary stability mechanisms
      • Oracles & price feeds
        • Consolidated price feed
        • LP share pricing
      • Risks
      • DSM error codes
      • Protocol fees
    • sGYD
      • Yield Emission Process
      • Security
      • Audit Report
      • Code Repositories
      • Contract Addresses
      • Supported Venues
      • sGYD Internals
      • Risks
    • Technical Documents
  • Deployed Contracts
    • Contract addresses
      • Bridged GYD
      • GYFI
      • Pools
      • GYD Core
      • Governance
        • L1 Governance
        • L2 Governance
      • Gyro Proto
      • Consolidated price feed
  • Official channels
  • FAQ
    • Coinmarketcap
    • Is there info on the Gamified Testnet?
    • Is there a Gyroscope whitepaper?
    • How is Gyroscope different?
    • Why is it called Gyroscope?
    • How scalable is Gyroscope?
    • What are use cases of Gyroscope?
    • Gyroscope & Academia
    • Classical FAQ
    • Coingecko
  • Press kit
  • Learn more
  • Licensing
Powered by GitBook
On this page
  • Interacting with the price feed
  • Example
  • Deployed contracts

Was this helpful?

  1. Deployed Contracts
  2. Contract addresses

Consolidated price feed

Details about how to interact with the consolidated price feed

Interacting with the price feed

The main function to retrieve prices from with the consolidated price feed is:

function getPricesUSD(address[] tokenAddresses) view returns (uint256[])

It expectes an array of asset addresses and returns an array of prices, denominated in USD.

Example

Here is an example to retrieve the prices of (wrapped) Bitcoin and USDC. Note that this uses the Polygon asset addresses.

interface IConsolidatedPriceFeed {
    function getPricesUSD(address[] memory baseAssets) external view returns (uint256[] memory);
}

address oracle = IConsolidatedPriceFeed(0xBa116c6f9e631413847747dF3cF6Dc5cDD1455C7);

address[] memory assets = new address[](2);
assets[0] = 0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6; // WBTC
assets[1] = 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174; // USDC
uint256[] memory prices = oracle.getPricesUSD(assets);
const ethers = require("ethers");
const provider = new ethers.providers.JsonRpcProvider("https://polygon-rpc.com");
const oracleAddress = "0xBa116c6f9e631413847747dF3cF6Dc5cDD1455C7";
const oracleAbi = [
  "function getPricesUSD(address[] tokenAddresses) view returns (uint256[])"
];

const oracle = new ethers.Contract(oracleAddress, oracleAbi, provider);

const assets = [
  "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6", // WBTC
  "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" // USDC
];
const prices = await oracle.getPricesUSD(assets);
console.log(prices);

Deployed contracts

The consolidated price feed is currently deployed on the following networks:

PreviousGyro ProtoNextOfficial channels

Last updated 3 months ago

Was this helpful?

Polygon mainnet:

0xBa116c6f9e631413847747dF3cF6Dc5cDD1455C7