-
Notifications
You must be signed in to change notification settings - Fork 22
/
Assets.ts
26 lines (20 loc) · 947 Bytes
/
Assets.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { BigInt, ethereum, log } from "@graphprotocol/graph-ts";
import {
TokenCategoryStable,
TokenCategoryVolatile,
} from "../../../shared/src/contracts/TokenDefinition";
import { getOwnedLiquidityBalances } from "./OwnedLiquidity";
import { getTokenBalances } from "./TokenBalances";
export function generateTokenRecords(timestamp: BigInt, blockNumber: BigInt): void {
getTokenBalances(timestamp, TokenCategoryStable, blockNumber);
getTokenBalances(timestamp, TokenCategoryVolatile, blockNumber);
getOwnedLiquidityBalances(timestamp, blockNumber);
}
export function handleAssets(block: ethereum.Block): void {
// Only index every 86,400th block (8 hours * 60 minutes * 60 seconds * 3 per second)
if (!block.number.mod(BigInt.fromString("86400")).equals(BigInt.zero())) {
return;
}
log.debug("handleAssets: *** Indexing block {}", [block.number.toString()]);
generateTokenRecords(block.timestamp, block.number);
}