-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ignored contracts to account for classic boosts
- Loading branch information
Showing
6 changed files
with
86 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Bytes } from "@graphprotocol/graph-ts" | ||
import { IgnoredContract } from "../../../generated/schema" | ||
|
||
export function shouldIgnoreContract(contractAddress: Bytes): boolean { | ||
return IgnoredContract.load(contractAddress) !== null | ||
} | ||
|
||
export function getIgnoredContract(contractAddress: Bytes): IgnoredContract { | ||
let ignoredcontract = IgnoredContract.load(contractAddress) | ||
if (!ignoredcontract) { | ||
ignoredcontract = new IgnoredContract(contractAddress) | ||
} | ||
|
||
return ignoredcontract | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { assert, test, describe } from "matchstick-as/assembly/index" | ||
import { BigInt } from "@graphprotocol/graph-ts" | ||
import { DAY, HOUR, MONTH, QUARTER, WEEK, YEAR, getIntervalFromTimestamp, getPreviousIntervalFromTimestamp } from "../../src/common/utils/time" | ||
|
||
describe("time.getIntervalFromTimestamp", () => { | ||
test("Support all the different periods", () => { | ||
const timestamp = BigInt.fromString("1712744972") | ||
|
||
// simple periods | ||
let res = getIntervalFromTimestamp(timestamp, HOUR) | ||
assert.assertTrue(res.equals(BigInt.fromString("1712743200"))) | ||
|
||
res = getIntervalFromTimestamp(timestamp, DAY) | ||
assert.assertTrue(res.equals(BigInt.fromString("1712707200"))) | ||
|
||
res = getIntervalFromTimestamp(timestamp, WEEK) | ||
assert.assertTrue(res.equals(BigInt.fromString("1712448000"))) | ||
|
||
res = getIntervalFromTimestamp(timestamp, MONTH) | ||
assert.assertTrue(res.equals(BigInt.fromString("1711929600"))) | ||
|
||
res = getIntervalFromTimestamp(timestamp, QUARTER) | ||
assert.assertTrue(res.equals(BigInt.fromString("1711929600"))) | ||
|
||
res = getIntervalFromTimestamp(timestamp, YEAR) | ||
assert.assertTrue(res.equals(BigInt.fromString("1704067200"))) | ||
}) | ||
|
||
test("can query the previous interval as well", () => { | ||
const timestamp = BigInt.fromString("1712744972") | ||
|
||
// simple periods | ||
let res = getPreviousIntervalFromTimestamp(timestamp, HOUR) | ||
assert.assertTrue(res.equals(BigInt.fromString("1712739600"))) | ||
|
||
res = getPreviousIntervalFromTimestamp(timestamp, DAY) | ||
assert.assertTrue(res.equals(BigInt.fromString("1712620800"))) | ||
|
||
res = getPreviousIntervalFromTimestamp(timestamp, WEEK) | ||
assert.assertTrue(res.equals(BigInt.fromString("1711843200"))) | ||
|
||
res = getPreviousIntervalFromTimestamp(timestamp, MONTH) | ||
assert.assertTrue(res.equals(BigInt.fromString("1709251200"))) | ||
|
||
res = getPreviousIntervalFromTimestamp(timestamp, QUARTER) | ||
assert.assertTrue(res.equals(BigInt.fromString("1704067200"))) | ||
|
||
res = getPreviousIntervalFromTimestamp(timestamp, YEAR) | ||
assert.assertTrue(res.equals(BigInt.fromString("1672531200"))) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters