Skip to content

BeraTrax/beratrax-subgraph

Repository files navigation

BeraTrax Subgraph

A subgraph for tracking BeraTrax protocol vaults.

📋 Table of Contents

🔍 Overview

This subgraph indexes various DeFi protocols and their vault contracts on the Berachain network, providing GraphQL APIs for querying vault activities, deposits, withdrawals, and transfers.

➕ Adding a New Pool

Follow these steps to add a new pool to an existing protocol:

Example: Adding a Pool to the Burrbear Protocol

Step 1: Modify the Vault File

📁 File: src/BurrbearVault.ts

Before:

let idArray = [22, 24];
let tokenNameArray = ["Nect-USDC-Honey", "wBERA-wgBERA"];
let vaultArray: Array<string> = [
  "0xFD2dE4473577fd5a786E0DFaA611Bbd334fAc8eA",
  "0x066Eb1D1e33027bc36FaF3055cf12C8F892408fA",
];

Data to Add:

  • Pool ID: 25
  • Pool Name: Nect-wgBERA
  • Pool Vault: 0x5490235e55E13CA58e821d873260f4979d650682

After:

let idArray = [22, 24, 25];
let tokenNameArray = ["Nect-USDC-Honey", "wBERA-wgBERA", "Nect-wgBERA"];
let vaultArray: Array<string> = [
  "0xFD2dE4473577fd5a786E0DFaA611Bbd334fAc8eA",
  "0x066Eb1D1e33027bc36FaF3055cf12C8F892408fA",
  "0x5490235e55E13CA58e821d873260f4979d650682",
];

Step 2: Update Subgraph Configuration

📁 File: subgraph.yaml

Add the following entry under the dataSources section:

- kind: ethereum/contract
  name: Nect-wgBERA-BurrbearVault
  network: berachain-mainnet
  source:
    address: "0x5490235e55E13CA58e821d873260f4979d650682"
    abi: BurrbearVault
    startBlock: 2205365
  mapping:
    kind: ethereum/events
    apiVersion: 0.0.7
    language: wasm/assemblyscript
    entities:
      - Approval
      - Transfer
    abis:
      - name: BurrbearVault
        file: ./abis/BurrbearVault.json
    eventHandlers:
      - event: Approval(indexed address,indexed address,uint256)
        handler: handleApproval
      - event: Transfer(indexed address,indexed address,uint256)
        handler: handleTransfer
      - event: Deposit(indexed address,indexed address,uint256,uint256)
        handler: handleDeposit
      - event: Withdraw(indexed address,indexed address,indexed address,uint256,uint256)
        handler: handleWithdraw
    file: ./src/BurrbearVault.ts

🚀 Deployment

Execute the following commands in order:

1. Generate Code

yarn codegen

2. Build the Subgraph

yarn build

3. Deploy to Goldsky

goldsky subgraph deploy beratrax-mainnet-subgraph/x.0.0 --path .

🏷️ Version Management

By default, subgraph API endpoints are named after the subgraph name and version. When you update your subgraph to a new version, you'll need to update your frontend to point to the new endpoint.

Using Tags for Seamless Updates

Tags allow you to manage versions and seamlessly upgrade your subgraph without changing the URL.

Create a production tag:

goldsky subgraph tag create beratrax-mainnet-subgraph/x.0.0 --tag prod

This associates your subgraph version with a stable prod tag, enabling version updates without the need to update the URLs on frontend and backend.


📚 Additional Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors