Skip to content

setraprotocol/setra-subgraph

Repository files navigation

Setra Subgraph

TheGraph subgraph indexing settlement events for the Setra protocol on Robinhood Chain.

Overview

Setra is the canonical settlement layer for tokenized equities. This subgraph indexes on-chain events from three core contracts:

  • DVPEngine — Delivery versus payment settlements between counterparties
  • AssetRegistry — Tokenized equity registration and lifecycle management
  • NettingEngine — Multilateral netting epochs and trade aggregation

Schema

Core Entities

Entity Description
Settlement Individual DVP settlement record
BatchSettlement Batch settlement execution
FailedSettlement Failed settlement with reason
Asset Registered tokenized equity
Issuer Asset issuer with portfolio tracking

Aggregation Entities

Entity Description
DailyVolume Per-asset daily settlement volume
NettingEpoch Netting cycle with participant metrics
NettingTrade Individual trade within a netting epoch
ProtocolStats Global protocol statistics

Example Queries

Recent Settlements

{
  settlements(first: 10, orderBy: blockTimestamp, orderDirection: desc) {
    id
    intentHash
    buyer
    seller
    asset {
      isin
      tokenAddress
    }
    amount
    price
    blockTimestamp
  }
}

Top Assets by Volume

{
  assets(first: 20, orderBy: totalVolume, orderDirection: desc) {
    isin
    tokenAddress
    totalSettlements
    totalVolume
    active
    issuer {
      address
      assetCount
    }
  }
}

Protocol Stats

{
  protocolStats(id: "1") {
    totalSettlements
    totalVolume
    totalAssets
    totalBatches
    totalFailures
  }
}

Daily Volume

{
  dailyVolumes(first: 30, orderBy: date, orderDirection: desc) {
    date
    asset {
      isin
    }
    volume
    count
  }
}

Netting Epochs

{
  nettingEpoches(first: 5, orderBy: epoch, orderDirection: desc) {
    epoch
    participantCount
    netVolume
    finalized
    trades {
      buyer
      seller
      amount
      price
    }
  }
}

Development

Prerequisites

  • Node.js >= 18
  • Docker & Docker Compose (for local Graph Node)

Setup

npm install
npm run codegen
npm run build

Local Development

Start a local Graph Node with Docker:

docker-compose up -d

Create and deploy the subgraph locally:

npm run create-local
npm run deploy-local

Query at http://localhost:8000/subgraphs/name/setra/settlement.

Deployment

npx graph auth --product hosted-service <access-token>
npm run deploy

License

MIT

About

TheGraph subgraph for indexing Setra settlement events and registry state

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages