From 1e84b0cedda2a369d4133bc11c7059f7aa0652a4 Mon Sep 17 00:00:00 2001 From: Data-Nexus Date: Sun, 4 Feb 2024 15:43:55 -0500 Subject: [PATCH 1/6] Update graph-ts, MIN_ETH, ABI, AS syntax --- abis/ERC20.json | 2 +- package.json | 4 +- src/mappings/core.ts | 88 ++++++++++++++++---------------- src/mappings/position-manager.ts | 44 ++++++++++------ src/utils/index.ts | 2 +- src/utils/intervalUpdates.ts | 10 ++-- src/utils/pricing.ts | 16 +++--- src/utils/token.ts | 22 ++++---- subgraph.yaml | 10 ++-- 9 files changed, 105 insertions(+), 93 deletions(-) diff --git a/abis/ERC20.json b/abis/ERC20.json index 405d6b36..327c0fad 100644 --- a/abis/ERC20.json +++ b/abis/ERC20.json @@ -84,7 +84,7 @@ "outputs": [ { "name": "", - "type": "uint8" + "type": "uint32" } ], "payable": false, diff --git a/package.json b/package.json index 97d719e0..c28f17ec 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "watch-local": "graph deploy ianlapham/uniswap-v3-bsc --watch --debug --node http://127.0.0.1:8020/ --ipfs http://localhost:5001" }, "devDependencies": { - "@graphprotocol/graph-cli": "^0.20.0", - "@graphprotocol/graph-ts": "^0.20.0", + "@graphprotocol/graph-cli": "^0.64.1", + "@graphprotocol/graph-ts": "^0.32.0", "@typescript-eslint/eslint-plugin": "^2.0.0", "@typescript-eslint/parser": "^2.0.0", "eslint": "^6.2.2", diff --git a/src/mappings/core.ts b/src/mappings/core.ts index 261a7eea..22e2f371 100644 --- a/src/mappings/core.ts +++ b/src/mappings/core.ts @@ -25,20 +25,19 @@ import { createTick, feeTierToTickSpacing } from '../utils/tick' export function handleInitialize(event: Initialize): void { // update pool sqrt price and tick let pool = Pool.load(event.address.toHexString()) - if (!pool) return + if (!pool) return pool.sqrtPrice = event.params.sqrtPriceX96 pool.tick = BigInt.fromI32(event.params.tick) pool.save() - + // update token prices let token0 = Token.load(pool.token0) let token1 = Token.load(pool.token1) - // update ETH price now that prices could have changed let bundle = Bundle.load('1') - if (!token0 || !token1 || !bundle) return + if (!token0 || !token1 || !bundle) return bundle.ethPriceUSD = getEthPriceInUSD() bundle.save() @@ -53,7 +52,6 @@ export function handleInitialize(event: Initialize): void { token1.save() } - function updateTickFeeVarsAndSave(tick: Tick, event: ethereum.Event): void { let poolAddress = event.address // not all ticks are initialized so obtaining null is expected behavior @@ -66,7 +64,6 @@ function updateTickFeeVarsAndSave(tick: Tick, event: ethereum.Event): void { updateTickDayData(tick, event) } - export function handleMint(event: MintEvent): void { let bundle = Bundle.load('1') let poolAddress = event.address.toHexString() @@ -76,7 +73,7 @@ export function handleMint(event: MintEvent): void { let token0 = Token.load(pool.token0) let token1 = Token.load(pool.token1) - if (!token0 || !token1) return + if (!token0 || !token1) return let amount0 = convertTokenToDecimal(event.params.amount0, token0.decimals) let amount1 = convertTokenToDecimal(event.params.amount1, token1.decimals) @@ -185,8 +182,8 @@ export function handleMint(event: MintEvent): void { mint.save() // Update inner tick vars and save the ticks - updateTickFeeVarsAndSave(lowerTick!, event) - updateTickFeeVarsAndSave(upperTick!, event) + updateTickFeeVarsAndSave(lowerTick, event) + updateTickFeeVarsAndSave(upperTick, event) } export function handleBurn(event: BurnEvent): void { @@ -199,7 +196,7 @@ export function handleBurn(event: BurnEvent): void { let token0 = Token.load(pool.token0) let token1 = Token.load(pool.token1) - if (!token0 || !token1) return + if (!token0 || !token1) return let amount0 = convertTokenToDecimal(event.params.amount0, token0.decimals) let amount1 = convertTokenToDecimal(event.params.amount1, token1.decimals) @@ -270,7 +267,7 @@ export function handleBurn(event: BurnEvent): void { let upperTickId = poolAddress + '#' + BigInt.fromI32(event.params.tickUpper).toString() let lowerTick = Tick.load(lowerTickId) let upperTick = Tick.load(upperTickId) - if (!lowerTick || !upperTick) return + if (!lowerTick || !upperTick) return let amount = event.params.amount lowerTick.liquidityGross = lowerTick.liquidityGross.minus(amount) @@ -285,8 +282,8 @@ export function handleBurn(event: BurnEvent): void { updateTokenDayData(token1 as Token, event) updateTokenHourData(token0 as Token, event) updateTokenHourData(token1 as Token, event) - updateTickFeeVarsAndSave(lowerTick!, event) - updateTickFeeVarsAndSave(upperTick!, event) + updateTickFeeVarsAndSave(lowerTick, event) + updateTickFeeVarsAndSave(upperTick, event) token0.save() token1.save() @@ -304,16 +301,15 @@ function loadTickUpdateFeeVarsAndSave(tickId: i32, event: ethereum.Event): void .concat(tickId.toString()) ) if (tick !== null) { - updateTickFeeVarsAndSave(tick!, event) + updateTickFeeVarsAndSave(tick, event) } } - export function handleSwap(event: SwapEvent): void { let bundle = Bundle.load('1') let factory = Factory.load(FACTORY_ADDRESS) let pool = Pool.load(event.address.toHexString()) - if (!factory || !pool || !bundle) return + if (!factory || !pool || !bundle) return // hot fix for bad pricing if (pool.id == '0x9663f2ca0454accad3e094448ea6f77443880454') { @@ -322,7 +318,7 @@ export function handleSwap(event: SwapEvent): void { let token0 = Token.load(pool.token0) let token1 = Token.load(pool.token1) - if (!token0 || !token1) return + if (!token0 || !token1) return let oldTick = pool.tick @@ -509,34 +505,36 @@ export function handleSwap(event: SwapEvent): void { // Update inner vars of current or crossed ticks let newTick = pool.tick let tickSpacing = feeTierToTickSpacing(pool.feeTier) - let modulo = newTick.mod(tickSpacing) - if (modulo.equals(ZERO_BI)) { - // Current tick is initialized and needs to be updated - loadTickUpdateFeeVarsAndSave(newTick.toI32(), event) - } - - if (!oldTick) return - - let numIters = oldTick - .minus(newTick!) - .abs() - .div(tickSpacing) - - if (numIters.gt(BigInt.fromI32(100))) { - // In case more than 100 ticks need to be updated ignore the update in - // order to avoid timeouts. From testing this behavior occurs only upon - // pool initialization. This should not be a big issue as the ticks get - // updated later. For early users this error also disappears when calling - // collect - } else if (newTick.gt(oldTick!)) { - let firstInitialized = oldTick.plus(tickSpacing.minus(modulo)) - for (let i = firstInitialized; i.le(newTick!); i = i.plus(tickSpacing)) { - loadTickUpdateFeeVarsAndSave(i.toI32(), event) + if (newTick) { + let modulo = newTick.mod(tickSpacing) + if (modulo.equals(ZERO_BI)) { + // Current tick is initialized and needs to be updated + loadTickUpdateFeeVarsAndSave(newTick.toI32(), event) } - } else if (newTick.lt(oldTick!)) { - let firstInitialized = oldTick.minus(modulo) - for (let i = firstInitialized; i.ge(newTick!); i = i.minus(tickSpacing)) { - loadTickUpdateFeeVarsAndSave(i.toI32(), event) + + if (oldTick) { + let numIters = oldTick + .minus(newTick) + .abs() + .div(tickSpacing) + + if (numIters.gt(BigInt.fromI32(100))) { + // In case more than 100 ticks need to be updated ignore the update in + // order to avoid timeouts. From testing this behavior occurs only upon + // pool initialization. This should not be a big issue as the ticks get + // updated later. For early users this error also disappears when calling + // collect + } else if (newTick.gt(oldTick)) { + let firstInitialized = oldTick.plus(tickSpacing.minus(modulo)) + for (let i = firstInitialized; i.le(newTick); i = i.plus(tickSpacing)) { + loadTickUpdateFeeVarsAndSave(i.toI32(), event) + } + } else if (newTick.lt(oldTick)) { + let firstInitialized = oldTick.minus(modulo) + for (let i = firstInitialized; i.ge(newTick); i = i.minus(tickSpacing)) { + loadTickUpdateFeeVarsAndSave(i.toI32(), event) + } + } } } } @@ -544,7 +542,7 @@ export function handleSwap(event: SwapEvent): void { export function handleFlash(event: FlashEvent): void { // update fee growth let pool = Pool.load(event.address.toHexString()) - if (!pool) return + if (!pool) return let poolContract = PoolABI.bind(event.address) let feeGrowthGlobal0X128 = poolContract.feeGrowthGlobal0X128() diff --git a/src/mappings/position-manager.ts b/src/mappings/position-manager.ts index 5eaa1520..81c50e5d 100644 --- a/src/mappings/position-manager.ts +++ b/src/mappings/position-manager.ts @@ -100,18 +100,20 @@ export function handleIncreaseLiquidity(event: IncreaseLiquidity): void { let token0 = Token.load(position.token0) let token1 = Token.load(position.token1) - let amount0 = convertTokenToDecimal(event.params.amount0, token0.decimals) - let amount1 = convertTokenToDecimal(event.params.amount1, token1.decimals) + if (token0 && token1) { + let amount0 = convertTokenToDecimal(event.params.amount0, token0.decimals) + let amount1 = convertTokenToDecimal(event.params.amount1, token1.decimals) - position.liquidity = position.liquidity.plus(event.params.liquidity) - position.depositedToken0 = position.depositedToken0.plus(amount0) - position.depositedToken1 = position.depositedToken1.plus(amount1) + position.liquidity = position.liquidity.plus(event.params.liquidity) + position.depositedToken0 = position.depositedToken0.plus(amount0) + position.depositedToken1 = position.depositedToken1.plus(amount1) + } - updateFeeVars(position!, event, event.params.tokenId) + updateFeeVars(position, event, event.params.tokenId) position.save() - savePositionSnapshot(position!, event) + savePositionSnapshot(position, event) } export function handleDecreaseLiquidity(event: DecreaseLiquidity): void { @@ -134,16 +136,19 @@ export function handleDecreaseLiquidity(event: DecreaseLiquidity): void { let token0 = Token.load(position.token0) let token1 = Token.load(position.token1) - let amount0 = convertTokenToDecimal(event.params.amount0, token0.decimals) - let amount1 = convertTokenToDecimal(event.params.amount1, token1.decimals) - position.liquidity = position.liquidity.minus(event.params.liquidity) - position.withdrawnToken0 = position.withdrawnToken0.plus(amount0) - position.withdrawnToken1 = position.withdrawnToken1.plus(amount1) + if (token0 && token1) { + let amount0 = convertTokenToDecimal(event.params.amount0, token0.decimals) + let amount1 = convertTokenToDecimal(event.params.amount1, token1.decimals) - position = updateFeeVars(position!, event, event.params.tokenId) + position.liquidity = position.liquidity.minus(event.params.liquidity) + position.withdrawnToken0 = position.withdrawnToken0.plus(amount0) + position.withdrawnToken1 = position.withdrawnToken1.plus(amount1) + } + + position = updateFeeVars(position, event, event.params.tokenId) position.save() - savePositionSnapshot(position!, event) + savePositionSnapshot(position, event) } export function handleCollect(event: Collect): void { @@ -157,9 +162,14 @@ export function handleCollect(event: Collect): void { } let token0 = Token.load(position.token0) - let amount0 = convertTokenToDecimal(event.params.amount0, token0.decimals) - position.collectedFeesToken0 = position.collectedFeesToken0.plus(amount0) - position.collectedFeesToken1 = position.collectedFeesToken1.plus(amount0) + let token1 = Token.load(position.token1) + + if (token0 && token1) { + let amount0 = convertTokenToDecimal(event.params.amount0, token0.decimals) + let amount1 = convertTokenToDecimal(event.params.amount0, token1.decimals) + position.collectedFeesToken0 = position.collectedFeesToken0.plus(amount0) + position.collectedFeesToken1 = position.collectedFeesToken1.plus(amount1) + } position = updateFeeVars(position!, event, event.params.tokenId) position.save() diff --git a/src/utils/index.ts b/src/utils/index.ts index d947feee..9c3d9737 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -87,7 +87,7 @@ export function loadTransaction(event: ethereum.Event): Transaction { } transaction.blockNumber = event.block.number transaction.timestamp = event.block.timestamp - transaction.gasUsed = event.transaction.gasUsed + transaction.gasUsed = BigInt.zero() //needs to be moved to transaction receipt transaction.gasPrice = event.transaction.gasPrice transaction.save() return transaction as Transaction diff --git a/src/utils/intervalUpdates.ts b/src/utils/intervalUpdates.ts index c63cd5ef..1e0c0e40 100644 --- a/src/utils/intervalUpdates.ts +++ b/src/utils/intervalUpdates.ts @@ -21,7 +21,7 @@ import { ethereum } from '@graphprotocol/graph-ts' * @param event */ export function updateUniswapDayData(event: ethereum.Event): UniswapDayData { - let uniswap = Factory.load(FACTORY_ADDRESS) + let uniswap = Factory.load(FACTORY_ADDRESS)! let timestamp = event.block.timestamp.toI32() let dayID = timestamp / 86400 // rounded let dayStartTimestamp = dayID * 86400 @@ -48,7 +48,7 @@ export function updatePoolDayData(event: ethereum.Event): PoolDayData { .toHexString() .concat('-') .concat(dayID.toString()) - let pool = Pool.load(event.address.toHexString()) + let pool = Pool.load(event.address.toHexString())! let poolDayData = PoolDayData.load(dayPoolID) if (poolDayData === null) { poolDayData = new PoolDayData(dayPoolID) @@ -97,7 +97,7 @@ export function updatePoolHourData(event: ethereum.Event): PoolHourData { .toHexString() .concat('-') .concat(hourIndex.toString()) - let pool = Pool.load(event.address.toHexString()) + let pool = Pool.load(event.address.toHexString())! let poolHourData = PoolHourData.load(hourPoolID) if (poolHourData === null) { poolHourData = new PoolHourData(hourPoolID) @@ -141,7 +141,7 @@ export function updatePoolHourData(event: ethereum.Event): PoolHourData { } export function updateTokenDayData(token: Token, event: ethereum.Event): TokenDayData { - let bundle = Bundle.load('1') + let bundle = Bundle.load('1')! let timestamp = event.block.timestamp.toI32() let dayID = timestamp / 86400 let dayStartTimestamp = dayID * 86400 @@ -184,7 +184,7 @@ export function updateTokenDayData(token: Token, event: ethereum.Event): TokenDa } export function updateTokenHourData(token: Token, event: ethereum.Event): TokenHourData { - let bundle = Bundle.load('1') + let bundle = Bundle.load('1')! let timestamp = event.block.timestamp.toI32() let hourIndex = timestamp / 3600 // get unique hour within unix history let hourStartUnix = hourIndex * 3600 // want the rounded effect diff --git a/src/utils/pricing.ts b/src/utils/pricing.ts index dedcf119..e5c27d71 100644 --- a/src/utils/pricing.ts +++ b/src/utils/pricing.ts @@ -9,18 +9,16 @@ const USDC_WBNB_03_POOL = '0x6bcb0Ba386E9de0C29006e46B2f01f047cA1806E' // token where amounts should contribute to tracked volume and liquidity // usually tokens that many tokens are paired with s -export let WHITELIST_TOKENS: string[] = [ - WBNB_ADDRESS, -] +export let WHITELIST_TOKENS: string[] = [WBNB_ADDRESS] let STABLE_COINS: string[] = [ '0x55d398326f99059ff775485246999027b3197955', // USDT - '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d', // USDC + '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d' // USDC ] -let MINIMUM_ETH_LOCKED = BigDecimal.fromString('0') +let MINIMUM_ETH_LOCKED = BigDecimal.fromString('300') -let Q192 = 2 ** 192 +let Q192 = BigInt.fromI32(2).pow(192 as u8) export function sqrtPriceX96ToTokenPrices(sqrtPriceX96: BigInt, token0: Token, token1: Token): BigDecimal[] { let num = sqrtPriceX96.times(sqrtPriceX96).toBigDecimal() let denom = BigDecimal.fromString(Q192.toString()) @@ -74,7 +72,7 @@ export function findBnbPerToken(token: Token): BigDecimal { if (!pool) { return ZERO_BD } - + if (pool.liquidity.gt(ZERO_BI)) { if (pool.token0 == token.id) { // whitelist token is token1 @@ -82,7 +80,7 @@ export function findBnbPerToken(token: Token): BigDecimal { if (!token1) { return ZERO_BD } - + // get the derived ETH in pool let ethLocked = pool.totalValueLockedToken1.times(token1.derivedETH) if (ethLocked.gt(largestLiquidityETH) && ethLocked.gt(MINIMUM_ETH_LOCKED)) { @@ -96,7 +94,7 @@ export function findBnbPerToken(token: Token): BigDecimal { if (!token0) { return ZERO_BD } - + // get the derived ETH in pool let ethLocked = pool.totalValueLockedToken0.times(token0.derivedETH) if (ethLocked.gt(largestLiquidityETH) && ethLocked.gt(MINIMUM_ETH_LOCKED)) { diff --git a/src/utils/token.ts b/src/utils/token.ts index db21b4e6..675d3863 100644 --- a/src/utils/token.ts +++ b/src/utils/token.ts @@ -22,7 +22,7 @@ export function fetchTokenSymbol(tokenAddress: Address): string { } else { // try with the static definition let staticTokenDefinition = StaticTokenDefinition.fromAddress(tokenAddress) - if(staticTokenDefinition != null) { + if (staticTokenDefinition != null) { symbolValue = staticTokenDefinition.symbol } } @@ -50,7 +50,7 @@ export function fetchTokenName(tokenAddress: Address): string { } else { // try with the static definition let staticTokenDefinition = StaticTokenDefinition.fromAddress(tokenAddress) - if(staticTokenDefinition != null) { + if (staticTokenDefinition != null) { nameValue = staticTokenDefinition.name } } @@ -64,28 +64,30 @@ export function fetchTokenName(tokenAddress: Address): string { export function fetchTokenTotalSupply(tokenAddress: Address): BigInt { let contract = ERC20.bind(tokenAddress) - let totalSupplyValue = null + let totalSupplyValue = BigInt.zero() let totalSupplyResult = contract.try_totalSupply() if (!totalSupplyResult.reverted) { - totalSupplyValue = totalSupplyResult as i32 + totalSupplyValue = totalSupplyResult.value } - return BigInt.fromI32(totalSupplyValue as i32) + return totalSupplyValue } -export function fetchTokenDecimals(tokenAddress: Address): BigInt { +export function fetchTokenDecimals(tokenAddress: Address): BigInt | null { let contract = ERC20.bind(tokenAddress) // try types uint8 for decimals - let decimalValue = null let decimalResult = contract.try_decimals() + if (!decimalResult.reverted) { - decimalValue = decimalResult.value + if (decimalResult.value.lt(BigInt.fromI32(255))) { + return decimalResult.value + } } else { // try with the static definition let staticTokenDefinition = StaticTokenDefinition.fromAddress(tokenAddress) - if(staticTokenDefinition != null) { + if (staticTokenDefinition) { return staticTokenDefinition.decimals } } - return BigInt.fromI32(decimalValue as i32) + return null } diff --git a/subgraph.yaml b/subgraph.yaml index df70c0f7..be756fcd 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -1,10 +1,14 @@ -specVersion: 0.0.2 +specVersion: 0.0.4 description: Uniswap is a decentralized protocol for automated token exchange on Ethereum. repository: https://github.com/Uniswap/uniswap-v3-subgraph schema: file: ./schema.graphql +graft: + base: QmSnpjbMEbFU7EJhJKSDsL6T2xNvgMcebWWcX4DpWX5u9e + block: 35850000 features: - nonFatalErrors + - grafting dataSources: - kind: ethereum/contract name: Factory @@ -15,7 +19,7 @@ dataSources: startBlock: 25605652 mapping: kind: ethereum/events - apiVersion: 0.0.4 + apiVersion: 0.0.7 language: wasm/assemblyscript file: ./src/mappings/factory.ts entities: @@ -43,7 +47,7 @@ templates: abi: Pool mapping: kind: ethereum/events - apiVersion: 0.0.4 + apiVersion: 0.0.7 language: wasm/assemblyscript file: ./src/mappings/core.ts entities: From 39e3ae30c0d344f553d252eb01b2c9261e588562 Mon Sep 17 00:00:00 2001 From: Data-Nexus Date: Sun, 4 Feb 2024 16:25:58 -0500 Subject: [PATCH 2/6] rewind prior to UITP TVL issue --- subgraph.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subgraph.yaml b/subgraph.yaml index be756fcd..8130d126 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -5,7 +5,7 @@ schema: file: ./schema.graphql graft: base: QmSnpjbMEbFU7EJhJKSDsL6T2xNvgMcebWWcX4DpWX5u9e - block: 35850000 + block: 27236113 features: - nonFatalErrors - grafting From 5a34ba766cb0351b8ed3deb49dfc4f6a0bc2e117 Mon Sep 17 00:00:00 2001 From: Data-Nexus Date: Sun, 4 Feb 2024 16:31:55 -0500 Subject: [PATCH 3/6] Moved graft block later on chain. --- subgraph.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subgraph.yaml b/subgraph.yaml index 8130d126..2dd1c8ad 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -5,7 +5,7 @@ schema: file: ./schema.graphql graft: base: QmSnpjbMEbFU7EJhJKSDsL6T2xNvgMcebWWcX4DpWX5u9e - block: 27236113 + block: 34643120 features: - nonFatalErrors - grafting From 566994ee1cbd874fc5945043cfa93617f29e77f1 Mon Sep 17 00:00:00 2001 From: Data-Nexus Date: Mon, 5 Feb 2024 13:06:36 -0500 Subject: [PATCH 4/6] Updated reference pool --- src/utils/pricing.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/pricing.ts b/src/utils/pricing.ts index e5c27d71..1a4a2035 100644 --- a/src/utils/pricing.ts +++ b/src/utils/pricing.ts @@ -5,7 +5,7 @@ import { BigDecimal, BigInt } from '@graphprotocol/graph-ts' import { exponentToBigDecimal, safeDiv } from '../utils/index' const WBNB_ADDRESS = '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c' -const USDC_WBNB_03_POOL = '0x6bcb0Ba386E9de0C29006e46B2f01f047cA1806E' +const USDC_WBNB_03_POOL = '0x0f338ec12d3f7c3d77a4b9fcc1f95f3fb6ad0ea6' // token where amounts should contribute to tracked volume and liquidity // usually tokens that many tokens are paired with s From 7eec947ec69b723d78788e6a9ebfe157e15c383c Mon Sep 17 00:00:00 2001 From: Data-Nexus Date: Mon, 5 Feb 2024 13:20:29 -0500 Subject: [PATCH 5/6] Updated reference pool --- src/utils/pricing.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/pricing.ts b/src/utils/pricing.ts index 1a4a2035..a88b5c2a 100644 --- a/src/utils/pricing.ts +++ b/src/utils/pricing.ts @@ -5,7 +5,7 @@ import { BigDecimal, BigInt } from '@graphprotocol/graph-ts' import { exponentToBigDecimal, safeDiv } from '../utils/index' const WBNB_ADDRESS = '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c' -const USDC_WBNB_03_POOL = '0x0f338ec12d3f7c3d77a4b9fcc1f95f3fb6ad0ea6' +const USDC_WBNB_03_POOL = '0x6fe9e9de56356f7edbfcbb29fab7cd69471a4869' // token where amounts should contribute to tracked volume and liquidity // usually tokens that many tokens are paired with s From d4054b042f211f4c737ecd180c13bf0b2f1dcf77 Mon Sep 17 00:00:00 2001 From: Data-Nexus Date: Sat, 10 Feb 2024 08:48:46 -0500 Subject: [PATCH 6/6] Fixed holey array --- src/utils/staticTokenDefinition.ts | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/utils/staticTokenDefinition.ts b/src/utils/staticTokenDefinition.ts index 897b84cd..9b220eeb 100644 --- a/src/utils/staticTokenDefinition.ts +++ b/src/utils/staticTokenDefinition.ts @@ -1,37 +1,27 @@ -import { - Address, - BigInt, -} from "@graphprotocol/graph-ts" - +import { Address, BigInt } from '@graphprotocol/graph-ts' + // Initialize a Token Definition with the attributes export class StaticTokenDefinition { - address : Address + address: Address symbol: string name: string decimals: BigInt - // Initialize a Token Definition with its attributes - constructor(address: Address, symbol: string, name: string, decimals: BigInt) { - this.address = address - this.symbol = symbol - this.name = name - this.decimals = decimals - } - // Get all tokens with a static defintion static getStaticDefinitions(): Array { - return new Array(6) + const staticDefinitions: Array = [] + return staticDefinitions } // Helper for hardcoded tokens - static fromAddress(tokenAddress: Address) : StaticTokenDefinition | null { + static fromAddress(tokenAddress: Address): StaticTokenDefinition | null { const staticDefinitions = this.getStaticDefinitions() const tokenAddressHex = tokenAddress.toHexString() // Search the definition using the address for (let i = 0; i < staticDefinitions.length; i++) { const def = staticDefinitions[i] - if(def.address.toHexString() == tokenAddressHex) { + if (def.address.toHexString() == tokenAddressHex) { return def } } @@ -39,5 +29,4 @@ export class StaticTokenDefinition { // If not found, return null return null } - -} \ No newline at end of file +}