How to Get Stargate Cross Chain Data

How to Get Stargate Cross Chain Data

Pyours

Pyours

Chainbase Intern

Introduction

Stargate, an emerging name in the finance world, especially when it comes to cross-chain data. In this tutorial, we'll dive deep into the world of Stargate Finance, exploring its intricate features, functionalities, and the invaluable dataset it provides through Chainbase. This DeFi dataset, in particular, empowers us to fetch the trading data seamlessly.

For all the blockchain enthusiasts and developers out there, this guide will be your beacon in navigating and understanding Stargate's data via Chainbase. Are you ready? Let's embark on this enlightening journey!

Prerequisites

  1. A free account at Chainbase with an API key.
  2. An IDE. Our examples are shown in JavaScript, you can use VS Code as your IDE for example.

Account Info on Stargate Finance

Querying Account Information

By providing the account ID, you can retrieve details about transfers, deposits, withdraws, and messages associated with that account.

Example GraphQL Query:

query GetAccountInfo($accountId: ID!) {
  accounts(where: {id: $accountId}) {
    id
    transfers {
      id
      amountUSD
      crossTransactionID
      crosschainToken {
        chainID
        network
      }
      fromChainID
      toChainID
      type
    }
    deposits {
      blockNumber
      chainID
      amountUSD
      timestamp
    }
    withdraws {
      id
      amountUSD
      chainID
    }
    withdrawCount
    messages {
      id
      crossTransactionID
      fromChainID
      toChainID
    }
    messageSentCount
    messageReceivedCount
  }
}

Querying Protocol Information

Using GraphQL, you can retrieve detailed information about the protocols available on Stargate Finance. This includes cumulative protocol side revenue, cumulative supply side revenue, total revenue, and daily usage metrics.

Example GraphQL Query:

query protocolsInfo {
  protocols(where: {id: "0x808d7c71ad2ba3fa531b068a2417c63106bc0949"}) {
    id
    cumulativeProtocolSideRevenueUSD
    cumulativeSupplySideRevenueUSD
    cumulativeTotalRevenueUSD
    dailyUsageMetrics(first: 5, orderBy: timestamp) {
      cumulativeLiquidityDepositCount
      cumulativeTransactionCount
    }
    totalValueLockedUSD
    type
    ... on BridgeProtocol {
      id
      name
    }
  }
}

Exploring DeFi Tokens on Stargate Finance

Tokens play a crucial role in the DeFi ecosystem, representing various assets and enabling seamless transactions and interactions within protocols.

Querying Token Information

Chainbase dataset allows users to explore information about reward tokens and regular tokens. This includes token symbols and their last prices in USD.

Example GraphQL Query:

query TokenInfo {
  rewardTokens {
    type
    token {
      symbol
    }
  }
  tokens {
    symbol
    lastPriceUSD
  }
}

Diving into Liquidity Pools on Stargate Finance

Liquidity pools are at the heart of decentralized exchanges, providing liquidity for trading and earning rewards for users.

Querying Liquidity Information

Our dataset enables users to access data about liquidity events, including liquidity deposits and withdrawals. This information is crucial for understanding pool dynamics and user participation.

Example GraphQL Query:

query liquidityInfo {
  events(first: 5, orderBy: timestamp, orderDirection: desc) {
    hash
    from
    to
    timestamp
    ... on LiquidityDeposit {
      id
      amountUSD
      blockNumber
      chainID
    }
    ... on LiquidityWithdraw {
      id
      amountUSD
      blockNumber
      chainID
    }
    protocol {
      netVolumeUSD
    }
  }
}

Querying Specific Pool Information

By providing the input token symbol, users can obtain detailed data about specific liquidity pools, including their creation timestamp, input and output tokens, and total value locked.

Example GraphQL Query:

query GetInfo($inputToken: String!) {
  pools(where: {inputToken_: {symbol:$inputToken}}) {
    createdBlockNumber
    createdTimestamp
    inputToken {
      lastPriceUSD
      name
      symbol
    }
    inputTokenBalance
    outputToken {
      lastPriceUSD
      name
      symbol
    }
    outputTokenPriceUSD
    totalValueLockedUSD
  }
}

# eg.
{
  "inputToken":"S*USDC"
}

Conclusion

In this illuminating voyage through Stargate Finance using Chainbase, we've unearthed how to query account info, protocol details, token specifics, and liquidity pool intricacies. Chainbase, with its powerful dataset, is the bridge connecting developers to the expansive universe of on-chain data.

FAQs

  1. What is the primary purpose of Stargate Finance?
    • It's designed for cross-chain data transactions in the defi realm.
  2. Is Chainbase free to use?
    • Yes, you can sign up for a free account.
  3. How does GraphQL help in querying Stargate's data?
    • GraphQL facilitates structured data fetching, enabling users to specify what they need, thus reducing redundancy and increasing efficiency.
  4. What's the significance of liquidity pools in decentralized exchanges?
    • Liquidity pools are fundamental, ensuring smooth trading and offering rewards to users providing liquidity.
  5. Can I access real-time data using Chainbase?
    • Yes, Chainbase provides enriched on-chain data, and while it's comprehensive, always consult our documentation for real-time capabilities.

About Chainbase

Chainbase is an all-in-one data infrastructure for Web3 that allows you to index, transform, and use on-chain data at scale. By leveraging enriched on-chain data and streaming computing technologies across one data infrastructure, Chainbase automates the indexing and querying of blockchain data, enabling developers to accomplish more with less effort.

Want to learn more about Chainbase?

Visit our website chainbase.com Sign up for a free account, and Check out our documentation.

Website|Blog|Twitter|Discord|Link3

You might also like

Diving Deep into zkSync Data: Unveiling Transaction Insights with Chainbase API
Research

Diving Deep into zkSync Data: Unveiling Transaction Insights with Chainbase API

In this blog, we're exploring the function deeper, seeking insights from the vast ocean of zkSync public chain data.

Chainbase Staking Infrastructure -- Stake to Empower Developer-Centric Growth
Staking

Chainbase Staking Infrastructure -- Stake to Empower Developer-Centric Growth

Chainbase has transcended its role as a data platform to become advocates and nurturers of the developer community. Actively engaged in various networks, we contribute to security through validator and sequencer technology, drive community engagement for network governance, and provide on-chain analysis for Dapps and ecosystems. The inception of Chainbase Staking Infrastructure under ChainbaseHQ represents a milestone in our Developer Adoption Journey. This initiative underscores our commitment to delivering not only data solutions but also a comprehensive support system, fostering a cohesive and supportive environment for developers.

Chainbase Staking Partners with ZetaChain: Simple, Fast, and Secure Omnichain Blockchain
Staking

Chainbase Staking Partners with ZetaChain: Simple, Fast, and Secure Omnichain Blockchain

ZetaChain is a simple, fast, and secure Omnichain Blockchain. A pioneer implementing the concept of chain abstraction, ZetaChain serves as the base-layer of the decentralized internet. With ZetaChain’s Omnichain Smart Contracts, developers can build truly interoperable dApps that span multiple chains from any existing blockchain from Ethereum to Bitcoin and beyond. Access all of crypto from any chain, including new blockchain innovations into the future. ZetaChain’s mission is to build a platform for global access, simplicity, and utility across any blockchain.