DIA Nexus Documentation
  • Nexus Overview
  • Intro to Nexus
    • How it works
    • Nexus vs. Lumina
    • Integrated Chains
  • Data products
    • Token Price Feeds
    • RWA Price Feeds
    • Randomness
    • Fair-value Feeds
  • How-to Guides
    • Fetch Price Data
      • Solidity
      • Vyper
      • Demo Oracles
      • Chain-specific Guide
        • Aleph Zero
        • Alephium
        • Edu Chain
        • Hydration
        • Kadena
        • LUKSO
        • Somnia
        • Stacks
        • Superseed
        • XRP Ledger (XRPL)
    • Generate Randomness
      • Solidity
      • WASM
      • Demo Oracles
      • Chain-specific Guide
        • Alephium
    • Migrate to DIA
    • Fund the Oracle
    • Build a Scraper
      • Development Cluster Stack
      • DIA Test‐Space with Docker Compose
      • DIA Test‐Space with Minikube
      • Add a new exchange scraper
      • Add a new foreign scraper
      • Add a new liquidity scraper
      • Additional notes
  • Request a Custom Oracle
  • Reference
    • Architecture
      • Data sourcing
      • Data computation
      • Data delivery
    • APIs
      • Token prices
        • RestAPI
          • Request Samples
        • GraphQL
          • Request Samples
      • RWA prices
    • Pricing Methodologies
      • IR: Interquartile Range Filter
      • MAIR: Moving Average with Interquartile Range Filter
      • VWAP: Volume Weighted Average Price
      • VWAPIR: Volume Weighted Average Price with Interquartile Range Filter
      • LST fair price
    • Data Sources
      • CEXes Data
      • DEXes Data
    • Smart Contracts
      • DIAOracleV2.sol
      • DIARandomOracle.sol
    • Randomness Protocol
  • Resources
    • Audits
    • Community & Support
    • Security Bounty Program
    • Research
      • Return Rates in Crypto Farming
      • Crypto Volatility Index
      • Compounded Rates
      • Polkadot Medianizer
    • T&C
      • Licence Agreement
      • Contributor Covenant Code of Conduct
      • Disclaimer
Powered by GitBook
On this page
  • Add a new foreign scraper
  • Foreign Command
  • Foreign Test
Export as PDF
  1. How-to Guides
  2. Build a Scraper

Add a new foreign scraper

Add a new foreign scraper

Implement ForeignScrapperer interface at pkg/dia/scraper/foreign-scrapers/Scrapper.go file

type ForeignScrapperer interface {
	UpdateQuotation() error
	GetQuoteChannel() chan *models.ForeignQuotation
}

Add the scraper implementation a MyForeignScraper.go Golang file to pkg/dia/scraper/foreign-scrapers/ folder and add the next implementations:

func (scraper *MyForeignScraper) Pool() chan dia.Pool {}
func (scraper *MyForeignScraper) Done() chan bool {}
  1. Add a constructor for the scraper:

func NewMyForeignScraper(exchange dia.Exchange) *MyForeignScraper {}
  1. Add MyForeignScraper case at scraper file cmd/foreignscraper/foreign.go:

switch *scraperType {
	case "MyForeignScraper":
		log.Println("Start scraping data")
		sc = scrapers.NewMyForeignScraper(ds)
}

Foreign Command

go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && foreignscraper -foreignType=ForeignType

Foreign Test

go mod tidy -go=1.16 && go mod tidy -go=1.17 && go install && foreignscraper -foreignType=FOREIGN_TYPE
PreviousAdd a new exchange scraperNextAdd a new liquidity scraper