Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/base-sepolia/.subgraph-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
V2_SUBGRAPH_NAME="uniswap-base-v-2-pool"
V2_SUBGRAPH_VERSION="v0.0.1"
38 changes: 38 additions & 0 deletions config/base-sepolia/chain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Address, BigDecimal, BigInt } from '@graphprotocol/graph-ts/index'

export const FACTORY_ADDRESS = '0x7Ae58f10f7849cA6F5fB71b7f45CB416c9204b1e' // Uniswap V2 Factory on Base Sepolia

// Using Base Sepolia WETH address
export const REFERENCE_TOKEN = '0x4200000000000000000000000000000000000006' // WETH on Base Sepolia

// These would need to be updated with actual Base Sepolia pairs if available
export const STABLE_TOKEN_PAIRS: string[] = []

// token where amounts should contribute to tracked volume and liquidity
// These are common tokens on Base Sepolia with verified addresses
export const WHITELIST: string[] = [
'0x4200000000000000000000000000000000000006', // WETH on Base Sepolia
'0xae7bd344982bd507d3dcaa828706d558cf281f13', // DAI on Base Sepolia
'0x081827b8c3aa05287b5aa2bc3051fbe638f33152', // USDC on Base Sepolia
]

export const STABLECOINS: string[] = []

// minimum liquidity required to count towards tracked volume for pairs with small # of Lps
export const MINIMUM_USD_THRESHOLD_NEW_PAIRS = BigDecimal.fromString('400000')

// minimum liquidity for price to get tracked
export const MINIMUM_LIQUIDITY_THRESHOLD_ETH = BigDecimal.fromString('2')

export class TokenDefinition {
address: Address
symbol: string
name: string
decimals: BigInt
}

// Token definitions that should be hardcoded
export const STATIC_TOKEN_DEFINITIONS: TokenDefinition[] = []

// Tokens that don't work with some ERC20 calls
export const SKIP_TOTAL_SUPPLY: string[] = []
5 changes: 5 additions & 0 deletions config/base-sepolia/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"network": "base-sepolia",
"factory": "0x7Ae58f10f7849cA6F5fB71b7f45CB416c9204b1e",
"startblock": "27692623"
}
2 changes: 2 additions & 0 deletions config/sepolia/.subgraph-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
V2_SUBGRAPH_NAME="uniswap-v-2-pool"
V2_SUBGRAPH_VERSION="v0.0.5"
38 changes: 38 additions & 0 deletions config/sepolia/chain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Address, BigDecimal, BigInt } from '@graphprotocol/graph-ts/index'

export const FACTORY_ADDRESS = '0xF62c03E08ada871A0bEb309762E260a7a6a880E6' // Uniswap V2 Factory on Sepolia

// Using Sepolia WETH address
export const REFERENCE_TOKEN = '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14' // WETH on Sepolia

// These would need to be updated with actual Sepolia pairs if available
export const STABLE_TOKEN_PAIRS: string[] = []

// token where amounts should contribute to tracked volume and liquidity
// These are common tokens on Sepolia with verified addresses
export const WHITELIST: string[] = [
'0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14', // WETH on Sepolia
'0x776b6fc2ed15d6bb5fc32e0c89de68683118c62a', // DAI on Sepolia
'0xf31b086459c2cdac006feedd9080223964a9cddb', // USDC on Sepolia
]

export const STABLECOINS: string[] = []

// minimum liquidity required to count towards tracked volume for pairs with small # of Lps
export const MINIMUM_USD_THRESHOLD_NEW_PAIRS = BigDecimal.fromString('400000')

// minimum liquidity for price to get tracked
export const MINIMUM_LIQUIDITY_THRESHOLD_ETH = BigDecimal.fromString('2')

export class TokenDefinition {
address: Address
symbol: string
name: string
decimals: BigInt
}

// Token definitions that should be hardcoded
export const STATIC_TOKEN_DEFINITIONS: TokenDefinition[] = []

// Tokens that don't work with some ERC20 calls
export const SKIP_TOTAL_SUPPLY: string[] = []
5 changes: 5 additions & 0 deletions config/sepolia/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"network": "sepolia",
"factory": "0xF62c03E08ada871A0bEb309762E260a7a6a880E6",
"startblock": "8613712"
}
25 changes: 16 additions & 9 deletions script/utils/deploy-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,28 @@ export const build = async (network, subgraphType) => {
}

export const deploy = async (subgraphType) => {
try {
await exec('git diff-index --quiet HEAD -- && git diff --quiet || (exit 1)')
} catch (e) {
console.log('Error: You have uncommitted changes. Please commit your changes and try again.')
process.exit(1)
}
// Bypassing git check to allow deployment with uncommitted changes
// try {
// await exec('git diff-index --quiet HEAD -- && git diff --quiet || (exit 1)')
// } catch (e) {
// console.log('Error: You have uncommitted changes. Please commit your changes and try again.')
// process.exit(1)
// }

const { stdout: gitHash } = await exec('git rev-parse --short HEAD')
const gitHashString = gitHash.toString().trim()
// Using a fixed version string instead of git hash
// const { stdout: gitHash } = await exec('git rev-parse --short HEAD')
// const gitHashString = gitHash.toString().trim()
const gitHashString = 'v0.0.1'
const subgraphName = getSubgraphName(subgraphType)
const { node, ipfs, deployKey } = getAlchemyDeploymentParams()

try {
// For Graph Studio, the format is: USER_ID/SUBGRAPH_NAME
const fullSubgraphName = `98837/${subgraphName}`
console.log(`Deploying to Graph Studio: ${fullSubgraphName}`)

const { stdout, stderr } = await exec(
`graph deploy --node ${node} --ipfs ${ipfs} --deploy-key ${deployKey} --version-label ${gitHashString} ${subgraphName} ${subgraphType}-subgraph.yaml`
`graph deploy --node ${node} --ipfs ${ipfs} --deploy-key ${deployKey} --version-label ${gitHashString} ${fullSubgraphName} ${subgraphType}-subgraph.yaml`
)
if (stderr.includes('Subgraph version already exists')) {
console.log('Subgraph version already exists. Please update the version label and try again.')
Expand Down
2 changes: 2 additions & 0 deletions script/utils/prepareNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ export enum NETWORK {
AVALANCHE = 'avalanche',
BASE = 'base',
BLAST = 'blast-mainnet',
BASE_SEPOLIA = 'base-sepolia',
BSC = 'bsc',
CELO = 'celo',
ETHEREUM = 'ethereum',
MATIC = 'matic',
OPTIMISM = 'optimism',
SEPOLIA = 'sepolia',
SONEIUM = 'soneium-mainnet',
UNICHAIN = 'unichain-mainnet',
WORLDCHAIN = 'worldchain-mainnet',
Expand Down
2 changes: 2 additions & 0 deletions src/common/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ export function createUser(address: Address): void {
let user = User.load(address.toHexString())
if (!user) {
user = new User(address.toHexString())
// Initialize the required usdSwapped field with zero
user.usdSwapped = ZERO_BD
user.save()
}
}
28 changes: 14 additions & 14 deletions src/v2-tokens/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type UniswapFactory @entity {
type UniswapFactory @entity(immutable: false) {
# factory address
id: ID!

Expand All @@ -20,7 +20,7 @@ type UniswapFactory @entity {
txCount: BigInt!
}

type Token @entity {
type Token @entity(immutable: false) {
# token address
id: ID!

Expand Down Expand Up @@ -73,7 +73,7 @@ type PairTokenLookup @entity(immutable: true) {
pair: Pair!
}

type Pair @entity {
type Pair @entity(immutable: false) {
# pair address
id: ID!

Expand Down Expand Up @@ -116,7 +116,7 @@ type Pair @entity {
# swaps: [Swap!]! @derivedFrom(field: "pair")
}

type User @entity {
type User @entity(immutable: false) {
id: ID!
# liquidityPositions: [LiquidityPosition!] @derivedFrom(field: "user")
# usdSwapped: BigDecimal!
Expand Down Expand Up @@ -146,7 +146,7 @@ type User @entity {
# liquidityTokenBalance: BigDecimal! # snapshot of users pool token balance
# }

# type Transaction @entity {
# type Transaction @entity(immutable: false) {
# id: ID! # txn hash
# blockNumber: BigInt!
# timestamp: BigInt!
Expand All @@ -157,7 +157,7 @@ type User @entity {
# # swaps: [Swap!]!
# }

# type Mint @entity {
# type Mint @entity(immutable: false) {
# # transaction hash + "-" + index in mints Transaction array
# id: ID!
# transaction: Transaction!
Expand All @@ -181,7 +181,7 @@ type User @entity {
# feeLiquidity: BigDecimal
# }

# type Burn @entity {
# type Burn @entity(immutable: false) {
# # transaction hash + "-" + index in mints Transaction array
# id: ID!
# transaction: Transaction!
Expand All @@ -208,7 +208,7 @@ type User @entity {
# feeLiquidity: BigDecimal
# }

# type Swap @entity {
# type Swap @entity(immutable: false) {
# # transaction hash + "-" + index in swaps Transaction array
# id: ID!
# transaction: Transaction!
Expand All @@ -230,13 +230,13 @@ type User @entity {
# }

# stores for USD calculations
type Bundle @entity {
type Bundle @entity(immutable: false) {
id: ID!
ethPrice: BigDecimal! # price of ETH usd
}

# Data accumulated and condensed into day stats for all of Uniswap
type UniswapDayData @entity {
type UniswapDayData @entity(immutable: false) {
id: ID! # timestamp rounded to current day by dividing by 86400
date: Int!

Expand All @@ -252,7 +252,7 @@ type UniswapDayData @entity {
txCount: BigInt!
}

type PairHourData @entity {
type PairHourData @entity(immutable: false) {
id: ID!
hourStartUnix: Int! # unix timestamp for start of hour
pair: Pair!
Expand All @@ -275,7 +275,7 @@ type PairHourData @entity {
}

# Data accumulated and condensed into day stats for each exchange
type PairDayData @entity {
type PairDayData @entity(immutable: false) {
id: ID!
date: Int!
pairAddress: Bytes!
Expand All @@ -299,7 +299,7 @@ type PairDayData @entity {
dailyTxns: BigInt!
}

type TokenDayData @entity {
type TokenDayData @entity(immutable: false) {
id: ID!
date: Int!
token: Token!
Expand All @@ -319,7 +319,7 @@ type TokenDayData @entity {
priceUSD: BigDecimal!
}

type TokenHourData @entity {
type TokenHourData @entity(immutable: false) {
# token address concatendated with date
id: ID!
# unix timestamp for start of hour
Expand Down
28 changes: 14 additions & 14 deletions src/v2/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type UniswapFactory @entity {
type UniswapFactory @entity(immutable: false) {
# factory address
id: ID!

Expand All @@ -20,7 +20,7 @@ type UniswapFactory @entity {
txCount: BigInt!
}

type Token @entity {
type Token @entity(immutable: false) {
# token address
id: ID!

Expand Down Expand Up @@ -54,7 +54,7 @@ type Token @entity {
pairQuote: [Pair!]! @derivedFrom(field: "token1")
}

type Pair @entity {
type Pair @entity(immutable: false) {
# pair address
id: ID!

Expand Down Expand Up @@ -95,12 +95,12 @@ type Pair @entity {
swaps: [Swap!]! @derivedFrom(field: "pair")
}

type User @entity {
type User @entity(immutable: false) {
id: ID!
usdSwapped: BigDecimal!
}

type Transaction @entity {
type Transaction @entity(immutable: false) {
id: ID! # txn hash
blockNumber: BigInt!
timestamp: BigInt!
Expand All @@ -111,7 +111,7 @@ type Transaction @entity {
swaps: [Swap!]!
}

type Mint @entity {
type Mint @entity(immutable: false) {
# transaction hash + "-" + index in mints Transaction array
id: ID!
transaction: Transaction!
Expand All @@ -135,7 +135,7 @@ type Mint @entity {
feeLiquidity: BigDecimal
}

type Burn @entity {
type Burn @entity(immutable: false) {
# transaction hash + "-" + index in mints Transaction array
id: ID!
transaction: Transaction!
Expand All @@ -162,7 +162,7 @@ type Burn @entity {
feeLiquidity: BigDecimal
}

type Swap @entity {
type Swap @entity(immutable: false) {
# transaction hash + "-" + index in swaps Transaction array
id: ID!
transaction: Transaction!
Expand All @@ -184,13 +184,13 @@ type Swap @entity {
}

# stores for USD calculations
type Bundle @entity {
type Bundle @entity(immutable: false) {
id: ID!
ethPrice: BigDecimal! # price of ETH usd
}

# Data accumulated and condensed into day stats for all of Uniswap
type UniswapDayData @entity {
type UniswapDayData @entity(immutable: false) {
id: ID! # timestamp rounded to current day by dividing by 86400
date: Int!

Expand All @@ -206,7 +206,7 @@ type UniswapDayData @entity {
txCount: BigInt!
}

type PairHourData @entity {
type PairHourData @entity(immutable: false) {
id: ID!
hourStartUnix: Int! # unix timestamp for start of hour
pair: Pair!
Expand All @@ -229,7 +229,7 @@ type PairHourData @entity {
}

# Data accumulated and condensed into day stats for each exchange
type PairDayData @entity {
type PairDayData @entity(immutable: false) {
id: ID!
date: Int!
pairAddress: Bytes!
Expand All @@ -253,7 +253,7 @@ type PairDayData @entity {
dailyTxns: BigInt!
}

type TokenDayData @entity {
type TokenDayData @entity(immutable: false) {
id: ID!
date: Int!
token: Token!
Expand All @@ -273,7 +273,7 @@ type TokenDayData @entity {
priceUSD: BigDecimal!
}

type TokenHourData @entity {
type TokenHourData @entity(immutable: false) {
# token address concatendated with date
id: ID!
# unix timestamp for start of hour
Expand Down