Skip to content

Commit

Permalink
Adaptation of Subgraph for Saucerswap v2 (#41)
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 authored Apr 18, 2024
1 parent a93fd92 commit 12545a8
Show file tree
Hide file tree
Showing 23 changed files with 6,970 additions and 1,889 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,6 @@ auth-layer-proxy/tests/coverage.txt
auth-layer-proxy/tests/luacov.report.out
auth-layer-proxy/tests/luacov.report.out.index
auth-layer-proxy/tests/luacov.stats.out

# subgraphs buid files
subgraphs/saucerswap/*/build/*
2 changes: 1 addition & 1 deletion charts/hedera-the-graph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ helm install my-release hedera-the-graph
By default it will use testnet, to use mainnet set the following value file:

```bash
helm install sl charts/hedera-the-graph -f charts/hedera-the-graph/values-overrides/values-mainnet.yaml
helm install sl-htg3 charts/hedera-the-graph -f charts/hedera-the-graph/values-overrides/values-mainnet.yaml
```

same for previewnet:
Expand Down
14 changes: 14 additions & 0 deletions subgraphs/saucerswap/v2/.env.mainnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Nodes Config
HEDERA_THE_GRAPH_NODE=https://mainnet-thegraph.swirldslabs.com/manage
IPFS_URL=https://api.thegraph.com/ipfs/
ACCESS_TOKEN=YOUR_ACCESS_TOKEN

#SubGraph Config
GRAPH_CONTRACT_ADDRESS=0x00000000000000000000000000000000003c3951
GRAPH_START_BLOCK=55651154
GRAPH_NETWORK=mainnet
SUBGRAPH_NAME=saucerswap/saucerswapv2

# Specific to NFT Manager
GRAPH_CONTRACT_NFT_MANAGER_ADDRESS=0x00000000000000000000000000000000003ddbb9
GRAPH_CONTRACT_NFT_MANAGER_START_BLOCK=56514876
14 changes: 14 additions & 0 deletions subgraphs/saucerswap/v2/.env.testnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Nodes Config
HEDERA_THE_GRAPH_NODE=https://testnet-thegraph.swirldslabs.com/manage
IPFS_URL=https://api.thegraph.com/ipfs/
ACCESS_TOKEN=YOUR_ACCESS_TOKEN

# SubGraph Config
GRAPH_CONTRACT_ADDRESS=0x00000000000000000000000000000000001243ee
GRAPH_START_BLOCK=11957
GRAPH_NETWORK=testnet
SUBGRAPH_NAME=saucerswap/saucerswapv2

# Specific to NFT Manager
GRAPH_CONTRACT_NFT_MANAGER_ADDRESS=0x000000000000000000000000000000000013f618
GRAPH_CONTRACT_NFT_MANAGER_START_BLOCK=12991
5 changes: 5 additions & 0 deletions subgraphs/saucerswap/v2/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": ["plugin:@typescript-eslint/recommended", "prettier", "prettier/@typescript-eslint"]
}
6 changes: 6 additions & 0 deletions subgraphs/saucerswap/v2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build/
node_modules/
src/types/
.DS_STORE
yarn-error.log
generated/
5 changes: 5 additions & 0 deletions subgraphs/saucerswap/v2/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"printWidth": 120
}
53 changes: 50 additions & 3 deletions subgraphs/saucerswap/v2/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,54 @@
# Uniswap V3 Subgraph
# Saucerswap V2 Subgraph

### Subgraph Endpoint

Synced at: https://thegraph.com/hosted-service/subgraph/ianlapham/uniswap-v3-subgraph?selected=playground
Synced at: https://mainnet-thegraph.swirldslabs.com/subgraphs/name/saucerswap-v2?selected=playground

Pending Changes at same URL
### Transitioning to Saucerswap V2: Key Adjustments

The Saucerswap V2 subgraph is originally a fork of Uniswap v3 subgraph, but with some modifications to support Saucerswap V2.
- All references to ETH and WETH have been replaced with HBAR and WHBAR respectively.
- Token static definitions have been replaced with popular tokens on Hedera and Saucerswap.
- Factory contract address has been updated to Saucerswap V2 factory contract address.
- NFT Manager contract address has been updated to Saucerswap V2 NFT Manager contract address.
- Abis have been updated to Saucerswap V2 abis, since the Saucerswap V2 contracts have different function signatures in some cases. Smart contracts to generate ABI files can be found in their respective repositories.
- NFT Position Manager: https://github.com/saucerswaplabs/saucerswaplabs-v2-periphery
- Factory and Pool: https://github.com/saucerswaplabs/saucerswaplabs-v2-core

## Setup

### Pre-requisites
1. yarn
2. thegraph cli
3. nodejs
4. HederaTheGraph Index Server

### Getting Started

The subgraph is able to run on 2 different networks: `mainnet` and `testnet`, for each network there is an example `.env` file, `.env.mainnet` and `.env.testnet` respectively.
You will need to change the `ACCESS_TOKEN` for the correct one for the network you want to run the subgraph on, if you are planning to deploy on your own private node of `HederaTheGraph` instance you don't need to provide a valid one.

1. Clone the project and install dependencies:
```bash
yarn install
```

2. Create a `.env` file, you can use the example `.env.mainnet` or `.env.testnet` files as a template.
```bash
cp .env.mainnet .env
```

3. Compile the subgraph
```bash
npm run compile
```

4. Create the subgraph
```bash
npm run create
```

5. Deploy the subgraph
```bash
npm run deploy
```
Loading

0 comments on commit 12545a8

Please sign in to comment.