From 64907751cb7744d848172d5dd79de7fe10b1685f Mon Sep 17 00:00:00 2001 From: Michael Wang <44713145+mzywang@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:24:03 -0400 Subject: [PATCH] update network to polygon --- schema.graphql | 2 ++ src/mappings/helpers.ts | 2 +- src/mappings/pricing.ts | 18 +++++++----------- subgraph.yaml | 8 ++++---- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/schema.graphql b/schema.graphql index 54f6dc4e..574efafc 100644 --- a/schema.graphql +++ b/schema.graphql @@ -44,6 +44,7 @@ type Token @entity { totalLiquidity: BigDecimal! # derived prices + # TODO: update this to derivedNative derivedETH: BigDecimal! # derived fields @@ -186,6 +187,7 @@ type Swap @entity { # stores for USD calculations type Bundle @entity { id: ID! + # update this to nativePriceUSD ethPrice: BigDecimal! # price of ETH usd } diff --git a/src/mappings/helpers.ts b/src/mappings/helpers.ts index 6946fd78..c229dc62 100644 --- a/src/mappings/helpers.ts +++ b/src/mappings/helpers.ts @@ -9,7 +9,7 @@ import { Factory as FactoryContract } from '../types/templates/Pair/Factory' import { TokenDefinition } from './tokenDefinition' export const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000' -export const FACTORY_ADDRESS = '0xf1D7CC64Fb4452F05c498126312eBE29f30Fbcf9' +export const FACTORY_ADDRESS = '0x9e5A52f57b3038F1B8EeE45F28b3C1967e22799C' export let ZERO_BI = BigInt.fromI32(0) export let ONE_BI = BigInt.fromI32(1) diff --git a/src/mappings/pricing.ts b/src/mappings/pricing.ts index c451a827..aba87744 100644 --- a/src/mappings/pricing.ts +++ b/src/mappings/pricing.ts @@ -4,11 +4,12 @@ import { Address, BigDecimal, BigInt } from '@graphprotocol/graph-ts/index' import { Bundle, Pair, Token } from '../types/schema' import { ADDRESS_ZERO, factoryContract, ONE_BD, UNTRACKED_PAIRS, ZERO_BD } from './helpers' -const WETH_ADDRESS = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1' -const USDC_WETH_PAIR = '0xf64dfe17c8b87f012fcf50fbda1d62bfa148366a' +const WRAPPED_NATIVE_ADDRESS = '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270' +const USDC_ADDRESS = '0x3c499c542cef5e3811e1192ce70d8cc03d5c3359' +const USDC_WRAPPED_NATIVE_PAIR = '0x1f0c5400a3c7e357cc7c9a3d2f7fe6ddf629d868' export function getEthPriceInUSD(): BigDecimal { - let usdcPair = Pair.load(USDC_WETH_PAIR) // usdc is token1 + let usdcPair = Pair.load(USDC_WRAPPED_NATIVE_PAIR) // usdc is token1 if (usdcPair !== null) { return usdcPair.token1Price } else { @@ -17,14 +18,9 @@ export function getEthPriceInUSD(): BigDecimal { } // token where amounts should contribute to tracked volume and liquidity -let WHITELIST: string[] = [ - '0x82af49447d8a07e3bd95bd0d56f35241523fbab1', // WETH - '0xaf88d065e77c8cc2239327c5edb3a432268e5831', // USDC -] +let WHITELIST: string[] = [WRAPPED_NATIVE_ADDRESS, USDC_ADDRESS] -const STABLECOINS: string[] = [ - '0xaf88d065e77c8cc2239327c5edb3a432268e5831', // USDC -] +const STABLECOINS: string[] = [USDC_ADDRESS] // minimum liquidity required to count towards tracked volume for pairs with small # of Lps let MINIMUM_USD_THRESHOLD_NEW_PAIRS = BigDecimal.fromString('10000') @@ -46,7 +42,7 @@ export function safeDiv(amount0: BigDecimal, amount1: BigDecimal): BigDecimal { * @todo update to be derived ETH (add stablecoin estimates) **/ export function findEthPerToken(token: Token): BigDecimal { - if (token.id == WETH_ADDRESS) { + if (token.id == WRAPPED_NATIVE_ADDRESS) { return ONE_BD } diff --git a/subgraph.yaml b/subgraph.yaml index 85bd3e4a..281fe280 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -6,11 +6,11 @@ schema: dataSources: - kind: ethereum/contract name: Factory - network: arbitrum-one + network: matic source: - address: '0xf1D7CC64Fb4452F05c498126312eBE29f30Fbcf9' + address: '0x9e5A52f57b3038F1B8EeE45F28b3C1967e22799C' abi: Factory - startBlock: 150442611 + startBlock: 49948178 mapping: kind: ethereum/events apiVersion: 0.0.7 @@ -34,7 +34,7 @@ dataSources: templates: - kind: ethereum/contract name: Pair - network: arbitrum-one + network: matic source: abi: Pair mapping: