WhiteSwap
  • About WhiteSwap
  • Protocol Overview
    • How WhiteSwap Works
    • Eсosystem Participants
    • Smart Contracts
    • Glossary
  • Core Concepts
    • Swaps
    • Pools
    • Flash Swaps
    • Oracles
    • Farming
    • WSD Staking
  • Advanced Topics
    • Fees
    • Pricing
    • Understanding Returns
    • Security
    • Research
  • Governance
    • Overview
    • Process
    • Glossary
  • Governance Token
    • Introducing WSD
    • Allocation & Vesting
    • Community Treasury
  • Developer Guides
    • Token Listing
    • Javascript SDK
      • SDK Quick Start
      • Fetching Data
      • Pricing
      • Trading
      • Pair Addresses
  • Reference
    • API
      • API Overview
      • Entities
      • Queries
    • SDK
      • Getting Started
      • Token
      • Pair
      • Route
      • Trade
      • Fractions
      • Fetcher
      • Other Exports
    • Smart Contracts
Powered by GitBook
On this page
  • Static Methods
  • fetchTokenData
  • fetchPairData

Was this helpful?

  1. Reference
  2. SDK

Fetcher

PreviousFractionsNextOther Exports

Last updated 4 years ago

Was this helpful?

The data fetching logic is split from the rest of the code for better tree-shaking, i.e. so that it does not get packaged into your code unless it is used. The SDK is otherwise unconcerned with how you get data from the blockchain.

This class contains static methods for constructing instances of pairs and tokens from on-chain data. It cannot be constructed.

Static Methods

fetchTokenData

async fetchTokenData(
  chainId: ChainId,
  address: string,
  provider = getDefaultProvider(getNetwork(chainId)),
  symbol?: string,
  name?: string
): Promise<Token>

Initializes a class instance from a chainId and token address, if the decimals of the token are unknown and cannot be fetched externally. Decimals are fetched via an v5 provider. If not passed in, a default provider is used.

fetchPairData

async fetchPairData(
  tokenA: Token,
  tokenB: Token,
  provider = getDefaultProvider(getNetwork(tokenA.chainId))
): Promise<Pair>

Initializes a class instance from two Tokens, if the pair’s balances of these tokens are unknown and cannot be fetched externally. Pair reserves are fetched via an v5 provider. If not passed in, a default provider is used.

ethers.js
ethers.js