Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update network to polygon #174

Draft
wants to merge 1 commit into
base: 04-12-update_network_to_arbitrum-one
Choose a base branch
from
Draft
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 schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Token @entity {
totalLiquidity: BigDecimal!

# derived prices
# TODO: update this to derivedNative
derivedETH: BigDecimal!

# derived fields
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/mappings/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 7 additions & 11 deletions src/mappings/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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')
Expand All @@ -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
}

Expand Down
8 changes: 4 additions & 4 deletions subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,7 +34,7 @@ dataSources:
templates:
- kind: ethereum/contract
name: Pair
network: arbitrum-one
network: matic
source:
abi: Pair
mapping:
Expand Down