diff --git a/config/mainnet.js b/config/mainnet.js index 724e14f7..7fc37527 100644 --- a/config/mainnet.js +++ b/config/mainnet.js @@ -43,6 +43,7 @@ module.exports = { "0xfe2e637202056d30016725477c5da089ab0a043a", // sETH2 "0x152649ea73beab28c5b49b26eb48f7ead6d4c898", // CAKE "0x5e8422345238f34275888049021821e8e08caa1f", // fraxETH + "0xae78736cd615f374d3085123a210448e74fc6393", // rETH ], nonfungiblePositionManagerAddress: "0x46a15b0b27311cedf172ab29e4f4766fbe7f4364", nonfungiblePositionManagerStartBlock: 16944786, diff --git a/subgraphs/exchange-v3/template/mappings/core.ts b/subgraphs/exchange-v3/template/mappings/core.ts index 62b3a262..8a78782b 100644 --- a/subgraphs/exchange-v3/template/mappings/core.ts +++ b/subgraphs/exchange-v3/template/mappings/core.ts @@ -1,7 +1,7 @@ /* eslint-disable prefer-const */ import { Bundle, Burn, Factory, Mint, Pool, Swap, Tick, Token, Collect } from "../generated/schema"; import { Pool as PoolABI } from "../generated/Factory/Pool"; -import { BigDecimal, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { BigDecimal, BigInt, ethereum, log } from "@graphprotocol/graph-ts"; import { Burn as BurnEvent, Flash as FlashEvent, @@ -349,11 +349,24 @@ export function handleSwap(event: SwapEvent): void { pool.token1Price = prices[1]; pool.save(); + let token0DerivedETH = token0.derivedETH; + // update USD pricing bundle.ethPriceUSD = getEthPriceInUSD(); bundle.save(); token0.derivedETH = findEthPerToken(token0 as Token); token1.derivedETH = findEthPerToken(token1 as Token); + + let transaction = loadTransaction(event); + + // fix for bad pricing on wbtc-weth 18450862 + if (transaction.blockNumber.equals(BigInt.fromI32(18450862))) { + if (token0.id == "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599") { + log.warning("bad pricing id: {}, token0: {}", [transaction.id, token0.derivedETH.toString()]); + token0.derivedETH = token0DerivedETH; + } + } + token0.derivedUSD = token0.derivedETH.times(bundle.ethPriceUSD); token1.derivedUSD = token1.derivedETH.times(bundle.ethPriceUSD); @@ -374,7 +387,6 @@ export function handleSwap(event: SwapEvent): void { ); // create Swap event - let transaction = loadTransaction(event); let swap = new Swap(transaction.id + "#" + pool.txCount.toString()); swap.transaction = transaction.id; swap.timestamp = transaction.timestamp; diff --git a/subgraphs/exchange-v3/template/utils/pricing.ts b/subgraphs/exchange-v3/template/utils/pricing.ts index 075b6052..9bd625b4 100644 --- a/subgraphs/exchange-v3/template/utils/pricing.ts +++ b/subgraphs/exchange-v3/template/utils/pricing.ts @@ -9,7 +9,7 @@ const WETH_ADDRESS = "0x5aea5775959fbc2557cc8789bc1bf90a239d9a91"; // prettier-ignore const USDC_WETH_03_POOL = "0x291d9f9764c72c9ba6ff47b451a9f7885ebf9977"; -const STABLE_IS_TOKEN0 = "true" as string; +const STABLE_IS_TOKEN0 = "false" as string; // token where amounts should contribute to tracked volume and liquidity // usually tokens that many tokens are paired with s @@ -19,7 +19,7 @@ export let WHITELIST_TOKENS: string[] = "0x5aea5775959fbc2557cc8789bc1bf90a239d9 // prettier-ignore let STABLE_COINS: string[] = "0x493257fd37edb34451f62edf8d2a0c418852ba4c,0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4,0x2039bb4116b4efc145ec4f0e2ea75012d6c0f181,0x4b9eb6c0b6ea15176bbf62841c6b2a8a398cb656,0x8e86e46278518efc1c5ced245cba2c7e3ef11557".split(","); -let MINIMUM_ETH_LOCKED = BigDecimal.fromString("0"); +let MINIMUM_ETH_LOCKED = BigDecimal.fromString("5"); let Q192 = 2 ** 192; export function sqrtPriceX96ToTokenPrices(sqrtPriceX96: BigInt, token0: Token, token1: Token): BigDecimal[] {