From adf833081eae497ab53f671eef936effb0002e1a Mon Sep 17 00:00:00 2001 From: JQQQ Date: Tue, 7 Nov 2023 13:25:09 +1300 Subject: [PATCH 1/2] update mapping --- .../ethereum-uniswap-v3/src/mappings/core.ts | 7 ++++-- .../src/mappings/utils/utils.ts | 22 ++++++------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/Ethereum/ethereum-uniswap-v3/src/mappings/core.ts b/Ethereum/ethereum-uniswap-v3/src/mappings/core.ts index 830061bc..7d5cc1bb 100644 --- a/Ethereum/ethereum-uniswap-v3/src/mappings/core.ts +++ b/Ethereum/ethereum-uniswap-v3/src/mappings/core.ts @@ -34,6 +34,7 @@ import { } from "../types/contracts/Pool"; import { Pool__factory } from "../types/contracts/factories/Pool__factory"; import assert from "assert"; +import {MintLog, SwapLog, SwapTransaction} from "../types/abi-interfaces/Pool"; export async function handleInitialize( event: EthereumLog @@ -76,8 +77,9 @@ export async function handleInitialize( } export async function handleMint( - event: EthereumLog + event: MintLog ): Promise { + const poolAddress = event.address; const pool = await Pool.get(poolAddress); @@ -353,7 +355,7 @@ export async function handleBurn( } export async function handleSwap( - event: EthereumLog + event: SwapLog ): Promise { const poolContract = Pool__factory.connect(event.address, api); const [ @@ -375,6 +377,7 @@ export async function handleSwap( ]); assert(pool); + // hot fix for bad pricing if (pool.id == "0x9663f2ca0454accad3e094448ea6f77443880454") { return; diff --git a/Ethereum/ethereum-uniswap-v3/src/mappings/utils/utils.ts b/Ethereum/ethereum-uniswap-v3/src/mappings/utils/utils.ts index f15fef44..b2091b9b 100644 --- a/Ethereum/ethereum-uniswap-v3/src/mappings/utils/utils.ts +++ b/Ethereum/ethereum-uniswap-v3/src/mappings/utils/utils.ts @@ -48,28 +48,20 @@ export function convertTokenToDecimal( } export async function loadTransaction( - event: EthereumLog + log: EthereumLog ): Promise { - let transaction = await Transaction.get(event.transactionHash); + let transaction = await Transaction.get(log.transactionHash); if (transaction === undefined) { transaction = Transaction.create({ - id: event.transactionHash, - blockNumber: BigInt(event.blockNumber), - timestamp: event.block.timestamp, + id: log.transactionHash, + blockNumber: BigInt(log.blockNumber), + timestamp: log.block.timestamp, gasPrice: BigInt(0), gasUsed: BigInt(0), }); } - - // transaction.gasPrice = event.block.gasPrice - const eventTransaction = event.block.transactions.find( - (transaction) => - transaction.transactionIndex == - BigNumber.from(event.transactionIndex).toBigInt() - ); - assert(eventTransaction); - transaction.gasUsed = (await eventTransaction.receipt()).gasUsed; - transaction.gasPrice = eventTransaction.gasPrice; + transaction.gasUsed = (await log.transaction.receipt()).gasUsed; + transaction.gasPrice = log.transaction.gasPrice; await transaction.save(); return transaction; } From bd5df89f7909489e1e3389ab5c5daa7bf76c2d14 Mon Sep 17 00:00:00 2001 From: JQQQ Date: Wed, 8 Nov 2023 11:58:50 +1300 Subject: [PATCH 2/2] update --- Ethereum/ethereum-uniswap-v3/src/mappings/core.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ethereum/ethereum-uniswap-v3/src/mappings/core.ts b/Ethereum/ethereum-uniswap-v3/src/mappings/core.ts index 7d5cc1bb..77e363fa 100644 --- a/Ethereum/ethereum-uniswap-v3/src/mappings/core.ts +++ b/Ethereum/ethereum-uniswap-v3/src/mappings/core.ts @@ -34,10 +34,10 @@ import { } from "../types/contracts/Pool"; import { Pool__factory } from "../types/contracts/factories/Pool__factory"; import assert from "assert"; -import {MintLog, SwapLog, SwapTransaction} from "../types/abi-interfaces/Pool"; +import {InitializeLog, MintLog, SwapLog, SwapTransaction} from "../types/abi-interfaces/Pool"; export async function handleInitialize( - event: EthereumLog + event: InitializeLog ): Promise { const [pool, ethPrice] = await Promise.all([ Pool.get(event.address),