feat/ponder-lm-indexing (#142)
This commit is contained in:
parent
de3c8eef94
commit
31063379a8
107 changed files with 12517 additions and 367 deletions
|
|
@ -133,6 +133,72 @@ export const stats = onchainTable('stats', t => ({
|
|||
.$type<string[]>()
|
||||
.notNull()
|
||||
.$default(() => Array(HOURS_IN_RING_BUFFER * RING_BUFFER_SEGMENTS).fill('0')),
|
||||
|
||||
// LiquidityManager stats
|
||||
holderCount: t
|
||||
.integer()
|
||||
.notNull()
|
||||
.$default(() => 0),
|
||||
lastRecenterTimestamp: t
|
||||
.bigint()
|
||||
.notNull()
|
||||
.$default(() => 0n),
|
||||
lastRecenterTick: t
|
||||
.integer()
|
||||
.notNull()
|
||||
.$default(() => 0),
|
||||
recentersLastDay: t
|
||||
.integer()
|
||||
.notNull()
|
||||
.$default(() => 0),
|
||||
recentersLastWeek: t
|
||||
.integer()
|
||||
.notNull()
|
||||
.$default(() => 0),
|
||||
lastEthReserve: t
|
||||
.bigint()
|
||||
.notNull()
|
||||
.$default(() => 0n),
|
||||
lastVwapTick: t
|
||||
.integer()
|
||||
.notNull()
|
||||
.$default(() => 0),
|
||||
|
||||
// 7-day ETH reserve growth metrics
|
||||
ethReserve7dAgo: t.bigint(),
|
||||
ethReserveGrowthBps: t.integer(),
|
||||
|
||||
// 7-day trading fees earned
|
||||
feesEarned7dEth: t
|
||||
.bigint()
|
||||
.notNull()
|
||||
.$default(() => 0n),
|
||||
feesEarned7dKrk: t
|
||||
.bigint()
|
||||
.notNull()
|
||||
.$default(() => 0n),
|
||||
feesLastUpdated: t.bigint(),
|
||||
|
||||
// Floor price metrics
|
||||
floorTick: t.integer(),
|
||||
floorPriceWei: t.bigint(),
|
||||
currentPriceWei: t.bigint(),
|
||||
floorDistanceBps: t.integer(),
|
||||
}));
|
||||
|
||||
// ETH reserve history - tracks ethBalance over time for 7d growth calculation
|
||||
export const ethReserveHistory = onchainTable('ethReserveHistory', t => ({
|
||||
id: t.text().primaryKey(), // block_logIndex format
|
||||
timestamp: t.bigint().notNull(),
|
||||
ethBalance: t.bigint().notNull(),
|
||||
}));
|
||||
|
||||
// Fee history - tracks fees earned over time for 7d totals
|
||||
export const feeHistory = onchainTable('feeHistory', t => ({
|
||||
id: t.text().primaryKey(), // block_logIndex format
|
||||
timestamp: t.bigint().notNull(),
|
||||
ethFees: t.bigint().notNull(),
|
||||
krkFees: t.bigint().notNull(),
|
||||
}));
|
||||
|
||||
// Individual staking positions
|
||||
|
|
@ -180,6 +246,29 @@ export const positions = onchainTable(
|
|||
// Maps index → decimal (e.g., TAX_RATES[0] = 0.01 for 1% yearly)
|
||||
export const TAX_RATES = TAX_RATE_OPTIONS.map(opt => opt.decimal);
|
||||
|
||||
// Recenters - track LiquidityManager recenter events
|
||||
export const recenters = onchainTable('recenters', t => ({
|
||||
id: t.text().primaryKey(), // block_logIndex format
|
||||
timestamp: t.bigint().notNull(),
|
||||
currentTick: t.integer().notNull(),
|
||||
isUp: t.boolean().notNull(),
|
||||
ethBalance: t.bigint(), // nullable - only from Scarcity/Abundance events
|
||||
outstandingSupply: t.bigint(), // nullable
|
||||
vwapTick: t.integer(), // nullable
|
||||
}));
|
||||
|
||||
// Holders - track Kraiken token holders
|
||||
export const holders = onchainTable(
|
||||
'holders',
|
||||
t => ({
|
||||
address: t.hex().primaryKey(),
|
||||
balance: t.bigint().notNull(),
|
||||
}),
|
||||
table => ({
|
||||
addressIdx: index().on(table.address),
|
||||
})
|
||||
);
|
||||
|
||||
// Helper constants
|
||||
export const STATS_ID = '0x01';
|
||||
export const SECONDS_IN_HOUR = 3600;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue