Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,15 @@ RETENTION_DAYS=30

# ─── API ─────────────────────────────────────────────────────
PORT=3000

# ─── Response cache (Redis) ──────────────────────────────────
# Opt-in caching for the hot read endpoints (/assets/popular, /search).
# Off by default; set CACHE_ENABLED=true to turn it on.
# Clients can force a fresh response with the `X-No-Cache` request header.
CACHE_ENABLED=false
REDIS_URL="redis://localhost:6379"
# Key namespace applied to every cached entry.
CACHE_KEY_PREFIX="wraith:cache:"
# Per-route TTLs in milliseconds.
CACHE_TTL_POPULAR_MS=60000
CACHE_TTL_SEARCH_MS=15000
130 changes: 124 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"express": "^4.18.3",
"express-rate-limit": "^8.3.2",
"graphql": "^16.11.0",
"ioredis": "^5.11.1",
"parquetjs-lite": "^0.8.7",
"ws": "^8.20.0",
"zod": "^4.4.3"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- Track contract liveness: one tombstone row per contract whose persistent
-- storage instance entry has expired (liveUntilLedger fell behind the current
-- ledger). Downstream consumers watch this table for a "contract gone" signal.
CREATE TABLE "wraith"."ContractTombstone" (
"id" SERIAL NOT NULL,
"contractId" TEXT NOT NULL,
"liveUntilLedger" INTEGER NOT NULL,
"detectedLedger" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "ContractTombstone_pkey" PRIMARY KEY ("id")
);

-- One tombstone per contract; first expiry detection wins, re-detection is a no-op.
CREATE UNIQUE INDEX "ContractTombstone_contractId_key" ON "wraith"."ContractTombstone"("contractId");

CREATE INDEX "ContractTombstone_detectedLedger_idx" ON "wraith"."ContractTombstone"("detectedLedger");
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- Surface liquidity-pool deposits/withdrawals as LP-share transfers. The shares
-- have no symbol of their own, so each row carries the pool whose shares moved
-- (poolId = the emitting pool contract). A deposit mints shares to "toAddress"
-- (no from); a withdrawal burns shares from "fromAddress" (no to).
CREATE TABLE "wraith"."LpShareTransfer" (
"id" SERIAL NOT NULL,
"poolId" TEXT NOT NULL,
"action" TEXT NOT NULL,
"fromAddress" TEXT,
"toAddress" TEXT,
"shares" TEXT NOT NULL,
"ledger" INTEGER NOT NULL,
"ledgerClosedAt" TIMESTAMP(3) NOT NULL,
"txHash" TEXT NOT NULL,
"eventId" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "LpShareTransfer_pkey" PRIMARY KEY ("id")
);

-- One row per event; replaying an overlapping ledger range never duplicates.
CREATE UNIQUE INDEX "LpShareTransfer_eventId_key" ON "wraith"."LpShareTransfer"("eventId");

CREATE INDEX "LpShareTransfer_poolId_idx" ON "wraith"."LpShareTransfer"("poolId");
CREATE INDEX "LpShareTransfer_toAddress_idx" ON "wraith"."LpShareTransfer"("toAddress");
CREATE INDEX "LpShareTransfer_fromAddress_idx" ON "wraith"."LpShareTransfer"("fromAddress");
CREATE INDEX "LpShareTransfer_ledger_idx" ON "wraith"."LpShareTransfer"("ledger");
CREATE INDEX "LpShareTransfer_txHash_idx" ON "wraith"."LpShareTransfer"("txHash");
CREATE INDEX "LpShareTransfer_poolId_action_idx" ON "wraith"."LpShareTransfer"("poolId", "action");
Loading
Loading