LogoLogo
GitHub
  • Quickstart
    • What is EO?
    • EO Vision
    • Use EO
  • Build on EO
    • Introduction to EO Stack
    • What is an OVS
    • EO Features
    • EO Data Processing Flow
    • Builders Workflow
      • Set-up
      • Off-chain Computation
      • On-chain Components
      • Target Chains Publishing
    • Smart Contracts Overview
      • EO Chain contracts
      • Target Contracts
    • Aggregation Library
      • Median
      • Clustering
      • TWAP
      • Robust Aggregation 101
    • EO Cryptographic Broadcaster
    • Incentives Management
      • 🄢On-chain-Subjective Slashing Framework
    • Active Specialized Blockchain Oracles
      • EtherOracle - Peg Securing Blockchain Oracle by Etherfi
      • Pulse - Risk Blockchain Oracle By Bitpulse
      • ECHO - Social Media Blockchain Oracle
      • Borsa - Intent Optimisation
  • ePRICE
    • Introduction to ePRICE
    • Integration Guide
    • Risk Management and Market Integrity
    • Feeds Addresses
      • Price Feed Addresses
        • Arbitrum
        • Arbitrum Sepolia
        • Base
        • Base Sepolia Testnet
        • Berachain
        • Blast
        • BNB Smart Chain
        • BOB
        • B Squared
        • B Squared Testnet
        • Hemi
        • Ink Sepolia
        • Ink Mainnet
        • Linea
        • Linea Sepolia
        • Ethereum
        • Manta
        • Manta Sepolia Tesnet
        • Mode
        • Mode Testnet
        • Monad Testnet
        • Morph
        • Morph Holesky
        • Polygon zkEVM
        • Polygon zkEVM Cardona Testnet
        • Plume
        • Plume Testnet
        • Scroll
        • Soneium
        • Sonic
        • Soneium Testnet
        • TAC Turin Testnet
        • Taiko Mainnet
        • Unichain
        • Unichain Sepolia
        • Zircuit
        • Zircuit Testnet
        • zkLink Nova Mainnet
      • PT Feeds Addresses
        • Pendle
          • Ethereum
          • Sonic
      • Custom Asset Feeds
    • API Reference
      • 🧩Examples
      • 🧩Off-chain Examples
    • Advanced
      • šŸ¤–Automating EO consumption
      • šŸ’±Getting a different currency pair
  • EO Token
    • The EO Token
    • Ecosystem Participants
    • EO Token Utility
    • EO Token Flywheel
    • Security and Enforcement
    • A New Chapter in Blockchain Oracle Design
  • Understand EO
    • EO Trust Model
    • Architecture Overview
    • Data Processing
    • Security
      • Cryptoeconomic Security
      • Aegis - Validator Set Configuration
  • Operators
    • Installation
    • Registration
    • Running the Client
    • Monitoring
  • šŸ”Concepts
    • EigenLayer
    • Data Validators
    • Chain Validators
    • eBFT
    • OVS
    • EO Chain
Powered by GitBook
On this page
Export as PDF
  1. ePRICE
  2. Advanced

Getting a different currency pair

EO feeds are provided in <SYMBOL>/USD by default. If you need a different currency pair, you can calculate it using two existing data feeds. For instance, to get the BTC/ETH price, you can use the BTC/USD feed and the ETH/USD feed and calculate BTC/ETH by dividing the two.

BTC/USDETH/USD=BTC/ETH\dfrac{BTC/USD}{ETH/USD}=BTC/ETHETH/USDBTC/USD​=BTC/ETH

Here is an example:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IEOFeedManager {
    struct PriceFeed {
        uint256 value;
        uint256 timestamp;
    }
    function getLatestPriceFeed(uint16 symbol) external view returns (PriceFeed memory);
    function getLatestPriceFeeds(uint16[] calldata symbols) external view returns (PriceFeed[] memory);
}

/**
 * Network: Holesky
 * FeedManager: 0x723BD409703EF60d6fB9F8d986eb90099A170fd0
 */


contract PairConverter {
    uint256 constant PRECISION = 1e18; 
    function getConvertedPrice(
        address _feedManager,
    ) public view returns (int256) {
        uint256 btcRate  =  _feedManager.getLatestPriceFeed(1).rate; 
        uint256 ethRate =  _feedManager.getLatestPriceFeed(2).rate; 
        return ((btcRate * PRECISION) / ethRate);
    }


}
PreviousAutomating EO consumptionNextThe EO Token

Last updated 21 days ago

šŸ’±