diff --git a/package.json b/package.json index a3a750fb..8d7cf371 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "build": "graph build", "create-local": "graph create davekaj/uniswap --node http://127.0.0.1:8020", "deploy-local": "graph deploy davekaj/uniswap --debug --ipfs http://localhost:5001 --node http://127.0.0.1:8020", - "deploy": "graph deploy ianlapham/uniswapv2 --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --debug", + "deploy": "graph deploy ianlapham/uniswap-v2-rinkeby --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/ --debug", "deploy-staging": "graph deploy $THE_GRAPH_GITHUB_USER/$THE_GRAPH_SUBGRAPH_NAME /Uniswap --ipfs https://api.staging.thegraph.com/ipfs/ --node https://api.staging.thegraph.com/deploy/", "watch-local": "graph deploy graphprotocol/Uniswap2 --watch --debug --node http://127.0.0.1:8020/ --ipfs http://localhost:5001" }, diff --git a/schema.graphql b/schema.graphql index 58be0567..59889190 100644 --- a/schema.graphql +++ b/schema.graphql @@ -68,7 +68,9 @@ type Pair @entity { # derived liquidity reserveETH: BigDecimal! reserveUSD: BigDecimal! - trackedReserveETH: BigDecimal! # used for separating per pair reserves and global + # used for separating per pair reserves and global + trackedReserveETH: BigDecimal! + # Price in terms of the asset pair token0Price: BigDecimal! token1Price: BigDecimal! diff --git a/src/mappings/factory.ts b/src/mappings/factory.ts index a17ef8bb..e07a452f 100644 --- a/src/mappings/factory.ts +++ b/src/mappings/factory.ts @@ -45,6 +45,7 @@ export function handleNewPair(event: PairCreated): void { token0.name = fetchTokenName(event.params.token0) token0.totalSupply = fetchTokenTotalSupply(event.params.token0) let decimals = fetchTokenDecimals(event.params.token0) + // bail if we couldn't figure out the decimals if (decimals === null) { log.debug('mybug the decimal on token 0 was null', []) diff --git a/src/mappings/helpers.ts b/src/mappings/helpers.ts index a1459369..833b9f35 100644 --- a/src/mappings/helpers.ts +++ b/src/mappings/helpers.ts @@ -18,6 +18,9 @@ export let BI_18 = BigInt.fromI32(18) export let factoryContract = FactoryContract.bind(Address.fromString(FACTORY_ADDRESS)) +// rebass tokens, dont count in tracked volume +export let UNTRACKED_PAIRS: string[] = ['0x9ea3b5b4ec044b70375236a281986106457b20ef'] + export function exponentToBigDecimal(decimals: BigInt): BigDecimal { let bd = BigDecimal.fromString('1') for (let i = ZERO_BI; i.lt(decimals as BigInt); i = i.plus(ONE_BI)) { diff --git a/src/mappings/pricing.ts b/src/mappings/pricing.ts index c0b80400..2a7a7af3 100644 --- a/src/mappings/pricing.ts +++ b/src/mappings/pricing.ts @@ -1,7 +1,7 @@ /* eslint-disable prefer-const */ import { Pair, Token, Bundle } from '../types/schema' import { BigDecimal, Address, BigInt } from '@graphprotocol/graph-ts/index' -import { ZERO_BD, factoryContract, ADDRESS_ZERO, ONE_BD } from './helpers' +import { ZERO_BD, factoryContract, ADDRESS_ZERO, ONE_BD, UNTRACKED_PAIRS } from './helpers' const WETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' const USDC_WETH_PAIR = '0xb4e16d0168e52d35cacd2c6185b44281ec28c9dc' // created 10008355 @@ -55,7 +55,11 @@ let WHITELIST: string[] = [ '0x960b236a07cf122663c4303350609a66a7b288c0', //ANT '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f', //SNX '0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e', //YFI - '0xdf5e0e81dff6faf3a7e52ba697820c5e32d806a8' // yCurv + '0xdf5e0e81dff6faf3a7e52ba697820c5e32d806a8', // yCurv + '0x853d955acef822db058eb8505911ed77f175b99e', // FRAX + '0xa47c8bf37f92abed4a126bda807a7b7498661acd', // WUST + '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984', // UNI + '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599' // WBTC ] // minimum liquidity required to count towards tracked volume for pairs with small # of Lps @@ -107,6 +111,11 @@ export function getTrackedVolumeUSD( let price0 = token0.derivedETH.times(bundle.ethPrice) let price1 = token1.derivedETH.times(bundle.ethPrice) + // dont count tracked volume on these pairs - usually rebass tokens + if (UNTRACKED_PAIRS.includes(pair.id)) { + return ZERO_BD + } + // if less than 5 LPs, require high minimum reserve amount amount or return 0 if (pair.liquidityProviderCount.lt(BigInt.fromI32(5))) { let reserve0USD = pair.reserve0.times(price0) diff --git a/subgraph.yaml b/subgraph.yaml index a4ba4508..6bdc35b5 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -34,7 +34,7 @@ dataSources: templates: - kind: ethereum/contract name: Pair - network: mainnet + network: rinkeby source: abi: Pair mapping: