feat(token-aggregation): add historical pricing context, backfill, and indexer hardening
Some checks failed
CI/CD Pipeline / Solidity Contracts (pull_request) Failing after 1m6s
CI/CD Pipeline / Security Scanning (pull_request) Successful in 12m42s
CI/CD Pipeline / Lint and Format (pull_request) Failing after 42s
CI/CD Pipeline / Terraform Validation (pull_request) Failing after 25s
CI/CD Pipeline / Kubernetes Validation (pull_request) Successful in 27s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (pull_request) Failing after 49s
OMNL reconcile anchor / Run omnl:reconcile and upload artifacts (pull_request) Failing after 26s
Validation / validate-genesis (pull_request) Successful in 36s
Validation / validate-terraform (pull_request) Failing after 28s
Validation / validate-kubernetes (pull_request) Failing after 12s
Validation / validate-smart-contracts (pull_request) Failing after 13s
Validation / validate-security (pull_request) Failing after 1m39s
Validation / validate-documentation (pull_request) Failing after 18s
Some checks failed
CI/CD Pipeline / Solidity Contracts (pull_request) Failing after 1m6s
CI/CD Pipeline / Security Scanning (pull_request) Successful in 12m42s
CI/CD Pipeline / Lint and Format (pull_request) Failing after 42s
CI/CD Pipeline / Terraform Validation (pull_request) Failing after 25s
CI/CD Pipeline / Kubernetes Validation (pull_request) Successful in 27s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (pull_request) Failing after 49s
OMNL reconcile anchor / Run omnl:reconcile and upload artifacts (pull_request) Failing after 26s
Validation / validate-genesis (pull_request) Successful in 36s
Validation / validate-terraform (pull_request) Failing after 28s
Validation / validate-kubernetes (pull_request) Failing after 12s
Validation / validate-smart-contracts (pull_request) Failing after 13s
Validation / validate-security (pull_request) Failing after 1m39s
Validation / validate-documentation (pull_request) Failing after 18s
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
import { existsSync } from 'fs';
|
||||
import { HistoricalPricingBackfillService } from '../src/services/historical-pricing-backfill';
|
||||
|
||||
const rootEnvCandidates = [
|
||||
path.resolve(__dirname, '../../../.env'),
|
||||
path.resolve(__dirname, '../../../../.env'),
|
||||
];
|
||||
|
||||
for (const candidate of rootEnvCandidates) {
|
||||
if (existsSync(candidate)) {
|
||||
dotenv.config({ path: candidate });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dotenv.config();
|
||||
|
||||
function readInt(name: string, fallback: number): number {
|
||||
const raw = String(process.env[name] || '').trim();
|
||||
if (!raw) return fallback;
|
||||
const parsed = Number(raw);
|
||||
return Number.isFinite(parsed) ? parsed : fallback;
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const chainId = readInt('BACKFILL_CHAIN_ID', 138);
|
||||
const days = readInt('BACKFILL_DAYS', 30);
|
||||
const chunkSize = readInt('BACKFILL_CHUNK_SIZE', 2500);
|
||||
const poolLimit = readInt('BACKFILL_POOL_LIMIT', 500);
|
||||
|
||||
const service = new HistoricalPricingBackfillService();
|
||||
const summary = await service.backfillChain({
|
||||
chainId,
|
||||
days,
|
||||
chunkSize,
|
||||
poolLimit,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(JSON.stringify(summary, null, 2));
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -91,13 +91,21 @@ CREATE TABLE IF NOT EXISTS swap_events (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
chain_id INTEGER NOT NULL,
|
||||
pool_address TEXT NOT NULL,
|
||||
transaction_hash TEXT,
|
||||
block_number BIGINT,
|
||||
log_index INTEGER,
|
||||
token0_address TEXT NOT NULL,
|
||||
token1_address TEXT NOT NULL,
|
||||
amount0_in NUMERIC(78, 0) NOT NULL DEFAULT 0,
|
||||
amount1_in NUMERIC(78, 0) NOT NULL DEFAULT 0,
|
||||
amount0_out NUMERIC(78, 0) NOT NULL DEFAULT 0,
|
||||
amount1_out NUMERIC(78, 0) NOT NULL DEFAULT 0,
|
||||
amount_usd NUMERIC(38, 18) NOT NULL DEFAULT 0,
|
||||
price_usd NUMERIC(38, 18),
|
||||
transaction_hash TEXT,
|
||||
log_index INTEGER,
|
||||
block_number BIGINT,
|
||||
token0_price_usd NUMERIC(38, 18),
|
||||
token1_price_usd NUMERIC(38, 18),
|
||||
sender TEXT,
|
||||
to_address TEXT,
|
||||
timestamp TIMESTAMPTZ NOT NULL
|
||||
);
|
||||
|
||||
@@ -105,13 +113,9 @@ CREATE INDEX IF NOT EXISTS idx_swap_events_pool_time
|
||||
ON swap_events (chain_id, pool_address, timestamp DESC);
|
||||
CREATE INDEX IF NOT EXISTS idx_swap_events_token_time
|
||||
ON swap_events (chain_id, token0_address, token1_address, timestamp DESC);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_swap_events_unique_log
|
||||
ON swap_events (
|
||||
chain_id,
|
||||
pool_address,
|
||||
COALESCE(transaction_hash, ''),
|
||||
COALESCE(log_index, -1)
|
||||
);
|
||||
DROP INDEX IF EXISTS idx_swap_events_unique_log;
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_swap_events_chain_tx_log
|
||||
ON swap_events (chain_id, transaction_hash, log_index);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS token_ohlcv (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
|
||||
Reference in New Issue
Block a user