Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes in Algebra Subgraph logic #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Algebra/src/mappings/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions Algebra/src/utils/intervalUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down