-
Notifications
You must be signed in to change notification settings - Fork 0
/
ponder.schema.ts
89 lines (81 loc) · 2.3 KB
/
ponder.schema.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { createSchema } from '@ponder/core';
export default createSchema((p) => ({
Note: p.createTable({
id: p.bigint(),
collatRatio: p.bigint().optional(),
kerosene: p.bigint().optional(),
dyad: p.bigint().optional(),
xp: p.bigint().optional(),
collateral: p.bigint().optional(),
lastLiquidation: p.bigint().optional(),
exoCollateral: p.bigint().optional(),
}),
Tvl: p.createTable({
id: p.bigint(),
tvl: p.bigint(),
timestamp: p.bigint(),
}),
NoteLiquidity: p.createTable(
{
id: p.string(), // keccak256(abi.encode(note.id, blockNumber, pool.id))
liquidityId: p.string().references('Liquidity.id'),
pool: p.string().references('Pool.id'),
noteId: p.bigint(),
blockNumber: p.bigint(),
liquidity: p.bigint(),
xp: p.bigint(),
timestamp: p.bigint(),
},
{
blockNumberIndex: p.index(['liquidityId', 'blockNumber']),
poolIndex: p.index(['pool']),
},
),
Liquidity: p.createTable(
{
id: p.string(), // keccak256(abi.encode(pool.id, blockNumber))
blockNumber: p.bigint(),
pool: p.string().references('Pool.id'),
totalLiquidity: p.bigint(),
totalXp: p.bigint(),
timestamp: p.bigint(),
notes: p.many('NoteLiquidity.liquidityId'),
},
{
blockNumberIndex: p.index(['pool', 'blockNumber']),
},
),
Pool: p.createTable({
id: p.string(),
lpToken: p.string(),
liquidity: p.many('Liquidity.pool'),
rewardRates: p.many('RewardRate.pool'),
}),
RewardRate: p.createTable(
{
id: p.string(), // keccak256(abi.encode(pool.id, blockNumber))
pool: p.string().references('Pool.id'),
blockNumber: p.bigint(),
rate: p.bigint(),
timestamp: p.bigint(),
},
{
blockNumberIndex: p.index(['pool', 'blockNumber']),
poolIndex: p.index(['pool']),
},
),
Reward: p.createTable({
id: p.string(), // keccak256(abi.encode(noteId, pool.id, fromBlockNumber, toBlockNumber))
pool: p.string().references('Pool.id'),
fromBlockNumber: p.bigint(),
toBlockNumber: p.bigint(),
noteId: p.bigint(),
amount: p.bigint(),
timestamp: p.bigint(),
}),
TotalReward: p.createTable({
id: p.bigint(), // note id
amount: p.bigint(),
lastUpdated: p.bigint(), // block number
}),
}));