This project aims to document the swap actions executed by the v2.ref-finance.near contract on the NEAR mainnet. Ref Finance, a community-driven DeFi platform on the NEAR Protocol, provides an excellent opportunity to gain practical experience in understanding Graph's functionality through a real-world example.

Our objective is to demystify the entire process, ensuring accessibility for users of all skill levels. Whether you're a seasoned developer or just embarking on your journey into the Web3 realm, this guide empowers you with the knowledge and confidence needed to navigate Ref Finance or any protocol built on NEAR and its core components seamlessly.

Key resources:

Example

In this project, various entities can be queried. The schema encompasses a Swap entity with a distinct identifier, linked to a particular Pool, and involving two tokens (firstToken and secondToken). The Token type denotes a generic token with a unique identifier, while the Pool type signifies a pool with its unique identifier. You can collectively query these entities using the following query:

{
  query {
    swaps {
      nodes {
        id
        firstToken {
          id
        }
        secondToken {
          id
        }
        pool {
          id
        }
      }
    }
  }
}

The possible response is as follows:

{
  "data": {
    "query": {
      "swaps": {
        "nodes": [
          {
            "id": "107215746-6n73gva1H7X2ctEQiQ2kdnVCkvfJpDN9M3zAUzDQmugL-0-2",
            "firstToken": {
              "id": "\"f5cfbc74057c610c8ef151a439252680ac68c6dc.factory.bridge.near\""
            },
            "secondToken": {
              "id": "\"wrap.near\""
            },
            "pool": null
          },
          {
            "id": "107215746-6n73gva1H7X2ctEQiQ2kdnVCkvfJpDN9M3zAUzDQmugL-0-1",
            "firstToken": {
              "id": "\"meta-pool.near\""
            },
            "secondToken": {
              "id": "\"f5cfbc74057c610c8ef151a439252680ac68c6dc.factory.bridge.near\""
            },
            "pool": null
          }
        ]
      }
    }
  }
}

In essence, the SubQuery's SDK simplifies the process for developers to retrieve trading data from the Ref protocol, highlighting its capabilities. This demonstrates how developers can seamlessly incorporate on-chain data from the NEAR ecosystem.

About Ref Finance

Ref unifies the fundamental elements of DeFi, encompassing a decentralised exchange (DEX), lending protocol, synthetic asset issuer, and more, within a unified and synchronised DeFi platform. 

Ref boasts several competitive advantages compared to similar products. However, its most compelling features include a low-transaction fee model, built-in developer incentives, an innovative liquidity pool design, established interoperability with Ethereum through the Rainbow bridge, and decentralised governance facilitated by the Ref DAO. Harnessing the 1-2 second finality, cost-effectiveness, and user-friendly, interoperable infrastructure of NEAR, Ref endeavours to bring DeFi one step closer to a broader audience.

As Ref progresses into the future, anticipate the introduction of more products, crypto-economic innovations, community governance enhancements, and increased token trading activity on the platform.

About SubQuery

SubQuery Network is innovating web3 infrastructure with tools that empower builders to decentralise the future. Our fast, flexible, and open data indexer supercharges dApps on over 120 networks, enabling a user-focused web3 world. Soon, our Data Node will provide breakthroughs in the RPC industry, and deliver decentralisation without compromise. We pioneer the web3 revolution for visionaries and forward-thinkers. We’re not just a company - we’re a movement driving an inclusive and decentralised web3 era.

Linktree | Website | Discord | Telegram | Twitter | Blog | Medium | LinkedIn | YouTube

Share this post