From 6766e1fa2761e187072112cee101fa9490592aaa Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Mon, 1 Apr 2024 17:13:00 -0700 Subject: [PATCH 1/2] Modified basin daily snapshot to trigger at 9amPT/12pmEST --- projects/subgraph-basin/src/utils/Well.ts | 4 +++- projects/subgraph-core/utils/Dates.ts | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/projects/subgraph-basin/src/utils/Well.ts b/projects/subgraph-basin/src/utils/Well.ts index bc7d5c276b..6dd907913b 100644 --- a/projects/subgraph-basin/src/utils/Well.ts +++ b/projects/subgraph-basin/src/utils/Well.ts @@ -197,7 +197,9 @@ export function incrementWellWithdraw(wellAddress: Address): void { export function checkForSnapshot(wellAddress: Address, timestamp: BigInt, blockNumber: BigInt): void { // We check for the prior period snapshot and then take one if needed - let dayID = dayFromTimestamp(timestamp) - 1; + // Schedule the "day" to begin at 9am PT/12pm ET. + // Future work could include properly adjusting this when DST occurs. + let dayID = dayFromTimestamp(timestamp, 8 * 60 * 60) - 1; let hourID = hourFromTimestamp(timestamp) - 1; let well = loadWell(wellAddress); diff --git a/projects/subgraph-core/utils/Dates.ts b/projects/subgraph-core/utils/Dates.ts index fbc08e918d..b298406b11 100644 --- a/projects/subgraph-core/utils/Dates.ts +++ b/projects/subgraph-core/utils/Dates.ts @@ -1,7 +1,14 @@ import { BigInt } from "@graphprotocol/graph-ts"; -export function dayFromTimestamp(timestamp: BigInt): i32 { - let day_ts = timestamp.toI32() - (timestamp.toI32() % 86400); +/** + * Optionally accepts an offset, which adjusts the start of the day from UTC 00:00. + * @param timestamp - the timestamp to extract the day from + * @param offset - how much sooner the day should roll over (relative to UTC) + * for example, for PST (UTC-7), an appropriate offset would be -7 * 60 * 60. + * This would make the day roll over 7 hours later. + */ +export function dayFromTimestamp(timestamp: BigInt, offset: i32 = 0): i32 { + let day_ts = timestamp.toI32() + offset - ((timestamp.toI32() + offset) % 86400); return day_ts / 86400; } From 314c728e370798e9ff90d56420c024ab2416f354 Mon Sep 17 00:00:00 2001 From: Soil King <157099073+soilking@users.noreply.github.com> Date: Thu, 11 Apr 2024 12:23:32 -0700 Subject: [PATCH 2/2] gitignore --- projects/dev-graph-node/.gitignore | 1 + projects/subgraph-bean/.gitignore | 5 +++++ projects/subgraph-beanstalk/.gitignore | 1 + 3 files changed, 7 insertions(+) diff --git a/projects/dev-graph-node/.gitignore b/projects/dev-graph-node/.gitignore index aeae2fc767..456e193eda 100644 --- a/projects/dev-graph-node/.gitignore +++ b/projects/dev-graph-node/.gitignore @@ -1,2 +1,3 @@ .data graph-node +seed \ No newline at end of file diff --git a/projects/subgraph-bean/.gitignore b/projects/subgraph-bean/.gitignore index f5708adef4..bed545a0b5 100644 --- a/projects/subgraph-bean/.gitignore +++ b/projects/subgraph-bean/.gitignore @@ -3,3 +3,8 @@ generated/* yarn.lock .DS_Store node_modules/* + +# matchstick binary download info +tests/.latest.json +tests/.bin +tests/.docker \ No newline at end of file diff --git a/projects/subgraph-beanstalk/.gitignore b/projects/subgraph-beanstalk/.gitignore index 9f063af372..87a5e3f968 100644 --- a/projects/subgraph-beanstalk/.gitignore +++ b/projects/subgraph-beanstalk/.gitignore @@ -71,3 +71,4 @@ generated # matchstick binary download info tests/.latest.json tests/.bin +tests/.docker