Skip to content

Commit ab0d8a2

Browse files
committed
Refactor README for clarity and detail, including updates to project purpose, system architecture, configuration instructions, and usage steps. Enhanced feature descriptions and added information on subgraph health monitoring.
1 parent 8a33988 commit ab0d8a2

File tree

1 file changed

+26
-53
lines changed

1 file changed

+26
-53
lines changed

README.md

Lines changed: 26 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,32 @@
33
## 1. Project Overview
44

55
### Purpose
6-
The Giveth Economy Subgraph is a Graph Protocol subgraph that indexes and makes queryable the Giveth Economy smart contracts. It provides a way to efficiently query blockchain data related to GIV token locking, staking, rewards distribution, and Uniswap V3 integration.
6+
The Giveth Economy Subgraph is a Graph Protocol subgraph that is built for the Giveth Economy smart contracts. It is used to index and make queryable the Giveth Economy smart contracts.
77

88
### Key Features
9-
- Tracks GIV token locking and unlocking events
10-
- Monitors Uniswap V3 liquidity positions and staking
11-
- Records token distributions and allocations
12-
- Tracks user balances and rewards across different pools
9+
- Supports GIVeconomy DeFi protocol variety of balances, e.g. GIV Power, GIV Token Lock, GIV Merkle Distro, GIV Uniswap V3 Liquidity Mining, Givers PFP, etc.
1310
- Provides historical snapshots of GIV Power
11+
- Provides GIVPower locked positions information, e.g. amount, unlocked, unlockable at,...
12+
- Automatic indexing config generation using handlebars templates
1413

1514
### Live Links
1615
- Mainnet Subgraph: https://thegraph.com/hosted-service/subgraph/giveth/giveth-economy-second-mainnet
1716
- Gnosis Chain Subgraph: https://thegraph.com/hosted-service/subgraph/giveth/giveth-economy-second-xdai
1817

19-
## 2. Architecture Overview
18+
## 2. System Architecture
2019

21-
### System Diagram
20+
### Flow Diagram
2221
```mermaid
23-
graph TD
24-
A[Smart Contracts] --> B[Subgraph]
25-
B --> C[GraphQL API]
26-
C --> D[Frontend Applications]
27-
28-
subgraph Smart Contracts
29-
A1[GIVPower]
30-
A2[Unipool]
31-
A3[MerkleDistro]
32-
A4[UniswapV3]
33-
end
34-
35-
subgraph Subgraph
36-
B1[Event Handlers]
37-
B2[Entity Mappings]
38-
B3[Schema]
39-
end
22+
flowchart LR
23+
A(Config networks.yaml) --> |generate manifest| B(Subgraph Deployment yaml file)
24+
B --> |deploy| C(The Graph)
4025
```
4126

4227
### Tech Stack
4328
- Graph Protocol
4429
- TypeScript/AssemblyScript
4530
- GraphQL
46-
- Ethereum/Gnosis Chain
31+
- Handlebars
4732

4833
### Data Flow
4934
1. Smart contracts emit events
@@ -55,8 +40,7 @@ graph TD
5540

5641
### Prerequisites
5742
- Node.js (v14 or higher)
58-
- Yarn package manager
59-
- Graph CLI (`npm install -g @graphprotocol/graph-cli`)
43+
- NPM or Yarn package manager
6044
- Access to The Graph hosted service
6145

6246
### Installation Steps
@@ -78,58 +62,45 @@ yarn auth
7862

7963
### Configuration
8064
The subgraph configuration is managed through:
81-
- `subgraph.template.yaml`: Template for subgraph configuration
82-
- `networks.yaml`: Network-specific contract addresses and configurations
83-
- Environment variables for deployment keys
65+
- `subgraph.template.yaml`: Template for subgraph configuration. No need to write manually if you use the networks.yaml file and the generate-manifests command.
66+
- `networks.yaml`: A template to configure contract addresses and start blocks for each network. This will be processed by the generate-manifests command to create the subgraph deployment yaml file.
8467

8568
## 4. Usage Instructions
8669

8770
### Running the Application
8871
To build and deploy the subgraph:
8972

90-
1. Generate manifests:
91-
```bash
92-
yarn generate-manifests
93-
```
73+
1. Update the networks.yaml file with the correct contract addresses and start blocks for each network.
9474

95-
2. Build the subgraph:
75+
2. Build: This will generate the subgraph deployment yaml file and subgraph code.
9676
```bash
9777
yarn build
9878
```
9979

100-
3. Deploy to specific network:
80+
3. Deploy to specific network:
10181
```bash
10282
# For Gnosis Chain
10383
yarn deploy:gnosis:production
10484

10585
# For Mainnet
10686
yarn deploy:mainnet:production
10787
```
88+
Look at the corresponding scripts in the package.json to customize it for new networks.
10889

10990
### Testing
11091
The subgraph includes linting and type checking:
11192
```bash
11293
yarn lint
11394
```
11495

115-
### Common Tasks
116-
- Generate TypeScript types:
96+
### Build Issues
97+
Test type and build issues with build command.
11798
```bash
118-
yarn codegen:deployment-7
119-
```
120-
121-
- Build specific deployment:
122-
```bash
123-
yarn build:deployment-7
99+
yarn build
124100
```
125101

126102
## 5. Deployment Process
127103

128-
### Environments
129-
- Production (Mainnet & Gnosis Chain)
130-
- Staging (Various test networks)
131-
- Development (Local development)
132-
133104
### Deployment Steps
134105
1. Update contract addresses in `networks.yaml` if needed
135106
2. Generate manifests with updated configurations
@@ -146,23 +117,25 @@ Deployments are managed through GitHub Actions in the `.github/workflows` direct
146117
- Check network configuration in `networks.yaml`
147118
- Verify contract addresses and start blocks
148119
- Ensure proper authentication with The Graph
120+
- Check the graph hosted service accessability
149121

150122
2. **Query Errors**
151123
- Verify entity schema matches the GraphQL schema
152-
- Check event handler implementations
153-
- Ensure proper indexing of events
124+
- Check subgraph health, i.e. sync status, indexing status, etc.
154125

155126
### Logs and Debugging
156127
- Use Graph Protocol's dashboard to monitor indexing status
157128
- Check deployment logs in The Graph's hosted service
158-
- Monitor subgraph health through GraphQL queries
129+
- Monitor subgraph health through GraphQL queries, e.g. block number,...
130+
- Unreliable subgraph results due to malfunctioning subgraph nodes
159131

160132
## Schema Documentation
161133

162134
The subgraph defines several key entities:
163135

164136
### Core Entities
165-
- `GIVPower`: Tracks overall GIV Power statistics
137+
- `GIVPower`: Tracks overall GIV Power balances
138+
- `ERC20`: Tracks ERC20 token balances, i.e. simple tokens and LP tokens
166139
- `TokenLock`: Records individual token locks
167140
- `User`: Manages user balances and relationships
168141
- `Unipool`: Tracks liquidity pool information

0 commit comments

Comments
 (0)