Skip to content

OlympusDAO/yrf-subgraph

Repository files navigation

Olympus Yield Repurchase Facility Subgraph

A subgraph for indexing and querying data from Olympus Protocol's Yield Repurchase Facility contracts across multiple versions.

Overview

The Yield Repurchase Facility (YRF) is a mechanism for managing yield generated by Olympus Protocol's reserves. This subgraph tracks events from across multiple contract versions: 1.0, 1.1, 1.2

For more information about the YRF contracts, see the YieldRepurchaseFacility implementation in the olympus-v3 repository.

Features

  • Version-aware processing: Separate handlers for different contract versions
  • Token metadata: Automatic lookup of ERC20 token information (symbol, name, decimals)
  • Decimal conversion: Human-readable decimal amounts alongside raw values
  • Contract tracking: Version detection and reserve token mapping
  • Event indexing: Complete coverage of NextYieldSet, RepoMarket, and Shutdown events

Schema

Entities

  • Contract: Contract instances with version info and reserve token
  • Token: ERC20 token metadata (DAI and other reserve tokens)
  • NextYieldSet: Yield adjustment events with decimal conversion
  • RepoMarket: Market creation events with bid amounts
  • Shutdown: Contract shutdown events

Key Fields

All monetary amounts include both raw (BigInt) and decimal-adjusted (BigDecimal) fields:

  • nextYield / nextYieldDecimal
  • bidAmount / bidAmountDecimal

Architecture

Version-Specific Handlers

src/handlers/
├── v1_0-handlers.ts    # Handles v1.0 contract events
└── v1_1-handlers.ts    # Handles v1.1+ contract events

Utility Functions

src/utils/
├── contract-lookup-v1_0.ts    # v1.0 contract creation (uses dai())
├── contract-lookup-v1_1.ts    # v1.1+ contract creation (uses VERSION() and reserve())
├── token-lookup.ts             # ERC20 token metadata fetching
└── decimal-conversion.ts       # BigInt to BigDecimal conversion

Contract Versions

Version Address Reserve Token Method
v1.0 0x30A967eB957E5B1eE053B75F1A57ea6bfb2e907E DAI dai()
v1.1 0xcaA3d3E653A626e2656d2E799564fE952D39d855 DAI reserve()
v1.2 0x271e35a8555a62F6bA76508E85dfD76D580B0692 DAI reserve()

Development

Prerequisites

  • Node.js 16+
  • Yarn
  • Graph CLI

Setup

# Install dependencies
yarn

# Generate code from schema and ABIs
yarn codegen

# Build the subgraph
yarn build

Testing

# Run tests
yarn test

Deployment

# Deploy to The Graph Studio
yarn deploy

# Deploy locally (requires local graph node)
yarn deploy-local

Code Quality

# Run linting and formatting
yarn lint

# Check code style
yarn lint:check

Query Examples

Get all contracts with their reserve tokens

{
  contracts {
    id
    address
    version
    majorVersion
    minorVersion
    reserveToken {
      symbol
      name
      decimals
    }
  }
}

Get recent yield adjustments

{
  nextYieldSets(first: 10, orderBy: blockTimestamp, orderDirection: desc) {
    id
    contract {
      version
    }
    nextYield
    nextYieldDecimal
    blockTimestamp
    transactionHash
  }
}

Get market activity by version

{
  repoMarkets(where: { contract_: { majorVersion: 1, minorVersion_gte: 1 } }) {
    id
    marketId
    bidAmount
    bidAmountDecimal
    contract {
      version
    }
  }
}

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and linting
  5. Submit a pull request

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published