feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
import { onchainTable, index } from 'ponder';
|
2025-10-07 19:26:08 +02:00
|
|
|
import { TAX_RATE_OPTIONS } from 'kraiken-lib/taxRates';
|
2025-09-23 14:18:04 +02:00
|
|
|
|
|
|
|
|
export const HOURS_IN_RING_BUFFER = 168; // 7 days * 24 hours
|
|
|
|
|
const RING_BUFFER_SEGMENTS = 4; // ubi, minted, burned, tax
|
|
|
|
|
|
|
|
|
|
// Global protocol stats - singleton with id "0x01"
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
export const stats = onchainTable('stats', t => ({
|
|
|
|
|
id: t.text().primaryKey(), // Always "0x01"
|
|
|
|
|
kraikenTotalSupply: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
stakeTotalSupply: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
outstandingStake: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
2025-09-23 14:18:04 +02:00
|
|
|
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
// Totals
|
|
|
|
|
totalMinted: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
totalBurned: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
totalTaxPaid: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
totalUbiClaimed: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
2025-09-23 14:18:04 +02:00
|
|
|
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
// Rolling windows - calculated from ring buffer
|
|
|
|
|
mintedLastWeek: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
mintedLastDay: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
mintNextHourProjected: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
2025-09-23 14:18:04 +02:00
|
|
|
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
burnedLastWeek: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
burnedLastDay: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
burnNextHourProjected: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
2025-09-23 14:18:04 +02:00
|
|
|
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
taxPaidLastWeek: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
taxPaidLastDay: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
taxPaidNextHourProjected: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
2025-09-23 14:18:04 +02:00
|
|
|
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
ubiClaimedLastWeek: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
ubiClaimedLastDay: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
ubiClaimedNextHourProjected: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
2025-09-23 14:18:04 +02:00
|
|
|
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
// Ring buffer state (flattened array of length HOURS_IN_RING_BUFFER * 4)
|
|
|
|
|
ringBufferPointer: t
|
|
|
|
|
.integer()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0),
|
|
|
|
|
lastHourlyUpdateTimestamp: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
ringBuffer: t
|
|
|
|
|
.jsonb()
|
|
|
|
|
.$type<string[]>()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => Array(HOURS_IN_RING_BUFFER * RING_BUFFER_SEGMENTS).fill('0')),
|
|
|
|
|
}));
|
2025-09-23 14:18:04 +02:00
|
|
|
|
|
|
|
|
// Individual staking positions
|
|
|
|
|
export const positions = onchainTable(
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
'positions',
|
|
|
|
|
t => ({
|
2025-09-23 14:18:04 +02:00
|
|
|
id: t.text().primaryKey(), // Position ID from contract
|
|
|
|
|
owner: t.hex().notNull(),
|
|
|
|
|
share: t.real().notNull(), // Share as decimal (0-1)
|
2025-10-07 19:26:08 +02:00
|
|
|
taxRate: t.real().notNull(), // Tax rate as decimal (e.g., 0.01 for 1%) - for display
|
|
|
|
|
taxRateIndex: t.integer().notNull(), // Tax rate index from contract - source of truth
|
2025-09-23 14:18:04 +02:00
|
|
|
kraikenDeposit: t.bigint().notNull(),
|
|
|
|
|
stakeDeposit: t.bigint().notNull(),
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
taxPaid: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
|
|
|
|
snatched: t
|
|
|
|
|
.integer()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0),
|
2025-09-23 14:18:04 +02:00
|
|
|
creationTime: t.bigint().notNull(),
|
|
|
|
|
lastTaxTime: t.bigint().notNull(),
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
status: t
|
|
|
|
|
.text()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 'Active'), // "Active" or "Closed"
|
2025-09-23 14:18:04 +02:00
|
|
|
createdAt: t.bigint().notNull(),
|
|
|
|
|
closedAt: t.bigint(),
|
|
|
|
|
totalSupplyInit: t.bigint().notNull(),
|
|
|
|
|
totalSupplyEnd: t.bigint(),
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
payout: t
|
|
|
|
|
.bigint()
|
|
|
|
|
.notNull()
|
|
|
|
|
.$default(() => 0n),
|
2025-09-23 14:18:04 +02:00
|
|
|
}),
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
table => ({
|
2025-09-23 14:18:04 +02:00
|
|
|
ownerIdx: index().on(table.owner),
|
|
|
|
|
statusIdx: index().on(table.status),
|
2025-10-07 19:26:08 +02:00
|
|
|
taxRateIndexIdx: index().on(table.taxRateIndex),
|
2025-09-23 14:18:04 +02:00
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
|
2025-10-07 19:26:08 +02:00
|
|
|
// Export decimal values for backward compatibility in event handlers
|
|
|
|
|
// Maps index → decimal (e.g., TAX_RATES[0] = 0.01 for 1% yearly)
|
|
|
|
|
export const TAX_RATES = TAX_RATE_OPTIONS.map(opt => opt.decimal);
|
2025-09-23 14:18:04 +02:00
|
|
|
|
|
|
|
|
// Helper constants
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
export const STATS_ID = '0x01';
|
2025-09-23 14:18:04 +02:00
|
|
|
export const SECONDS_IN_HOUR = 3600;
|