From 1fb0eae99ccac28e2f1f1c55c04e08f8cb56f1c9 Mon Sep 17 00:00:00 2001 From: secsec2025 Date: Wed, 21 Feb 2024 20:04:13 +0530 Subject: [PATCH 1/2] Fixed PoolFeeData id in handleChangeFee --- Algebra/src/mappings/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Algebra/src/mappings/core.ts b/Algebra/src/mappings/core.ts index deda8af..3a15dd5 100644 --- a/Algebra/src/mappings/core.ts +++ b/Algebra/src/mappings/core.ts @@ -661,7 +661,7 @@ export function handleChangeFee(event: ChangeFee): void { pool.fee = BigInt.fromI32(event.params.fee as i32) pool.save() - let fee = PoolFeeData.load(event.address.toHexString() + event.block.timestamp.toString()) + let fee = PoolFeeData.load(event.block.timestamp.toString() + event.address.toHexString()) if (fee == null){ fee = new PoolFeeData(event.block.timestamp.toString() + event.address.toHexString()) fee.pool = event.address.toHexString() From 30a7b1a03f21b4cc69fd259356255821077a9c4f Mon Sep 17 00:00:00 2001 From: secsec2025 Date: Wed, 21 Feb 2024 20:12:07 +0530 Subject: [PATCH 2/2] Noted some issues inside the intervalUpdates.ts --- Algebra/src/utils/intervalUpdates.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Algebra/src/utils/intervalUpdates.ts b/Algebra/src/utils/intervalUpdates.ts index 6834cae..c4a89c5 100644 --- a/Algebra/src/utils/intervalUpdates.ts +++ b/Algebra/src/utils/intervalUpdates.ts @@ -24,6 +24,8 @@ import { ethereum, BigInt } from '@graphprotocol/graph-ts' */ export function updateAlgebraDayData(event: ethereum.Event): AlgebraDayData { let algebra = Factory.load(FACTORY_ADDRESS)! + // ? Fetching the Factory again from DB, while the Factory is changed inside the handlers and not persisted + // This `event` belongs to the same dayId (same day), yet it uses the old values of Factory let timestamp = event.block.timestamp.toI32() let dayID = timestamp / 86400 // rounded let dayStartTimestamp = dayID * 86400 @@ -52,6 +54,9 @@ export function updatePoolDayData(event: ethereum.Event): PoolDayData { .concat('-') .concat(dayID.toString()) let pool = Pool.load(event.address.toHexString())! + // ? Fetching the Pool again from DB, while the Pool is changed inside the handlers and not persisted + // This `event` belongs to the same dayId (same day), yet it uses the old values of Pool + let poolDayData = PoolDayData.load(dayPoolID) if (poolDayData === null) { poolDayData = new PoolDayData(dayPoolID) @@ -136,6 +141,9 @@ export function updatePoolHourData(event: ethereum.Event): PoolHourData { .concat('-') .concat(hourIndex.toString()) let pool = Pool.load(event.address.toHexString())! + // ? Fetching the Pool again from DB, while the Pool is changed inside the handlers and not persisted + // This `event` belongs to the same hourId (same hour), yet it uses the old values of Pool + let poolHourData = PoolHourData.load(hourPoolID) if (poolHourData === null) { poolHourData = new PoolHourData(hourPoolID)