Skip to content

Commit

Permalink
Cleaned-up: Changes needed to adapt uniswap v2 to saucerswap v1 (#69)
Browse files Browse the repository at this point in the history
Signed-off-by: Alfredo Gutierrez <[email protected]>
  • Loading branch information
AlfredoG87 authored Apr 26, 2024
1 parent 2af849c commit 74d7042
Show file tree
Hide file tree
Showing 22 changed files with 1,960 additions and 3,717 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,5 @@ auth-layer-proxy/tests/luacov.stats.out

# subgraphs buid files
subgraphs/saucerswap/*/build/*
subgraphs/saucerswap/*/generated/*
subgraphs/saucerswap/*/src/types/*
10 changes: 10 additions & 0 deletions subgraphs/saucerswap/v1/.env.mainnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 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=0x0000000000000000000000000000000000103780
GRAPH_START_BLOCK=35164593
GRAPH_NETWORK=mainnet
SUBGRAPH_NAME=saucerswap/saucerswap-v1
10 changes: 10 additions & 0 deletions subgraphs/saucerswap/v1/.env.testnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# 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=0x00000000000000000000000000000000000026e7
GRAPH_START_BLOCK=3354
GRAPH_NETWORK=testnet
SUBGRAPH_NAME=saucerswap/saucerswap-v1
58 changes: 55 additions & 3 deletions subgraphs/saucerswap/v1/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Uniswap V2 Subgraph

[Uniswap](https://uniswap.org/) is a decentralized protocol for automated token exchange on Ethereum.
# SAUCERSWAP V1 Subgraph

This subgraph dynamically tracks any pair created by the uniswap factory. It tracks of the current state of Uniswap contracts, and contains derived stats for things like historical data and USD prices.

Expand Down Expand Up @@ -55,3 +53,57 @@ This query fetches aggredated data from all uniswap pairs and tokens, to give a
}
}
```

### Subgraph Endpoint

Synced at for mainnet: https://mainnet-thegraph.swirldslabs.com/subgraphs/name/saucerswap/saucerswap-v1?selected=playground

Synced at for testnet: https://testnet-thegraph.swirldslabs.com/subgraphs/name/saucerswap/saucerswap-v1?selected=playground

### Transitioning to Saucerswap V1: Key Adjustments

The Saucerswap V1 subgraph is originally a fork of Uniswap v2 subgraph, but with some modifications to support Saucerswap V1.
- 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 V1 factory contract address.
- Abis have been updated to Saucerswap V1 abis, since the Saucerswap V1 contracts have different function signatures in some cases. Smart contracts to generate ABI files can be found in their respective repositories.
- Factory and Pool: https://github.com/saucerswaplabs/saucerswaplabs-core
- Periphery: https://github.com/saucerswaplabs/saucerswap-periphery

## 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
```
2 changes: 1 addition & 1 deletion subgraphs/saucerswap/v1/abis/ERC20.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"outputs": [
{
"name": "",
"type": "uint32"
"type": "uint8"
}
],
"payable": false,
Expand Down
Loading

0 comments on commit 74d7042

Please sign in to comment.