Kaustubh Agrawal · April 2026 · prepared for the Envio Growth Engineer role
🟢 Live on Envio hosted service: the money-market template is deployed and queryable at
https://indexer.dev.hyperindex.xyz/8fc0607/v1/graphql. Deployed from theenvio-deploy-money-marketbranch. SeePROOF_OF_WORK.mdfor sample queries.
This repository is the full candidate package: a strategy memo set, four Week-One diagnostics, a populated pain-map matrix, six tech-artifact specs, and two runnable Envio indexer scaffolds (pow/) that implement the patterns the specs describe.
The atomic unit of the package is the vertical. Two anchor verticals are picked: DeFi (Sablier, Velodrome+Aerodrome, LI.FI, Beefy) and Prediction Markets (Polymarket, Limitless). Each is run end-to-end through the same five-stage funnel framework — diagnose → dual interventions → sequence by ARR-velocity → compound through case studies → productise.
Start at the framing memo, then trace into the diagnostics, then read the runnable code.
ENVIO_VERTICAL_PLAYBOOK.md— the dual-angle (engineer + business operator) framework. Read this first.ENVIO_PAIN_MAP_MATRIX.md— 5 funnel stages × 2 root causes × 2 verticals, populated with named accounts and named owning artifacts.
ENVIO_DEFI_TECH_DIAGNOSTIC.mdENVIO_DEFI_POSITIONING_AUDIT.mdENVIO_MONEY_MARKET_TECH_DIAGNOSTIC.mdENVIO_MONEY_MARKET_POSITIONING_AUDIT.md
ENVIO_EFFECT_API_PATTERN.md— canonical Effect API + entity-cache-first preload patternENVIO_DEFI_60MIN_TEMPLATE.md— production-grade DeFi indexer in 60 minutesENVIO_MULTICHAIN_EXPANSION_RUNBOOK.md— chain #2 in one afternoonENVIO_LIQUIDATION_HANDLER_REFERENCE.md— race-safe liquidation handler (the trickiest event in money markets)ENVIO_RISK_DASHBOARD_QUERY_ARCHITECTURE.md— risk-dashboard architecture, the "risk-dashboard tier"ENVIO_MONEY_MARKET_TEMPLATE.md— capstone money-market indexer spec
Three forkable Envio indexer scaffolds — one per DeFi shape the playbook §3 names (DEX, money market, perp). They are the answer to "can this person actually write the code, or just memos about code?"
pow/envio-defi-template-v1/— DEX indexer with three-layer architecture (EventHandlers → Aggregators → Snapshots) mirrored fromvelodrome-finance/indexer. Real ABIs, real factory addresses (Velodrome V2 OP, Aerodrome Base). Real ERC-20 metadata reads via viem inside an Effect-cached handler.pnpm install && pnpm codegen && pnpm testclean (10/10 vitest, including 3 Effect-cache hit/miss tests). Add an RPC URL, run.pow/envio-money-market-template-v1/— money-market indexer with Aave-V3-shaped events (Supply,Withdraw,Borrow,Repay,LiquidationCall,ReserveDataUpdated). Per-reserve aggregator + per-user cross-reserve aggregator + ReserveRateSnapshot time series. TheLiquidationCallhandler updates both affected reserves and both users (victim + liquidator).pnpm install && pnpm codegen && pnpm testclean (5/5 vitest). 🟢 Verified live against Aave V3 on Polygon — seedocs/screenshots/for real GraphQL responses (16 reserves, 119 liquidations, 1000+ user-reserves indexed end-to-end).pow/envio-perp-template-v1/— perp-protocol indexer wrapping GMX v2's REALEventEmitterpattern on Arbitrum. Subscribes to a single global EventEmitter contract, routes events oneventNamestring, decodes theEventLogDatatyped dictionary. v1 scope:PositionIncreaseonly; v2 (PositionDecrease, Liquidation, Funding) is a mechanical extension documented inline.pnpm install && pnpm codegen && pnpm testclean (2/2 active vitest, 3 skipped pending v2). 🟢 Verified live against GMX v2 on Arbitrum — 9 markets, 1252 positions indexed end-to-end.
Each template ships an add-chain CLI at scripts/add-chain.ts that turns the multi-chain expansion runbook into a one-command operation:
cd pow/envio-defi-template-v1
pnpm add-chain ./examples/arbitrum.json # patches config.yaml + Constants.ts
pnpm codegen && pnpm dev # restart with new chainIdempotent — re-running with the same config is a no-op. Implements ENVIO_MULTICHAIN_EXPANSION_RUNBOOK.md as deterministic code.
| Check | Tests |
|---|---|
pow/envio-defi-template-v1 — install / codegen / tsc / test |
10 |
pow/envio-money-market-template-v1 — install / codegen / tsc / test |
5 |
pow/envio-perp-template-v1 — install / codegen / tsc / test |
4 |
19 automated tests across 3 vitest suites, all running in CI on every push. See docs/architecture.md for the architecture diagrams + CHANGELOG.md for the package's evolution history.
Beyond the tests: the money-market template was run end-to-end against the real Aave V3 deployment on Polygon mainnet, indexing ~1.4M Polygon blocks of Aave V3 history (block 25,826,028 → ~27,300,000+). Captured artifacts live in docs/screenshots/:
- 6 GraphQL response dumps in
queries/*.json— real, reproducible, diff-able. Top reserves by total supplied, 10 most recent liquidations (real victim + liquidator addresses, real collateral/debt amounts in BigInt wei from April 2022), most-liquidated users, top liquidators, recent rate snapshots, sample counts across all entities. - 2 PNG screenshots in
png/— Hasura GraphQL playground + a styled HTML summary of indexer state.
Surfaced + fixed a real template-quality bug in the process. pnpm dev failed on first run with ERR_REQUIRE_ESM because Envio v2's ts-node loader couldn't handle our "type": "module" + "module": "ESNext" combo. Fixed by removing "type": "module" from package.json and adding a "ts-node" block in tsconfig.json that overrides to "module": "CommonJS" for the runtime path while keeping ESNext for vitest/tsc. All three templates now pnpm dev-clean. This is the kind of bug a reviewer would catch in the first 60 seconds; running the indexer ourselves caught it first.
To reproduce the live capture: cd scripts/demo-capture && pnpm install && pnpm capture (with pnpm dev running in the template).
scripts/demo-capture/ ships three assertion harnesses (one per template) that query the live indexer and check cross-entity invariants the schema implies. All 3 pass on real on-chain data:
| Template | Harness | Network | Invariants | Checks passing |
|---|---|---|---|---|
| Money market | pnpm assert |
Polygon Aave V3 | 9 | 14,401 / 14,401 |
| DEX | pnpm assert:defi |
Optimism Velodrome V2 | 8 | 31,091 / 31,091 |
| Perp | pnpm assert:perp |
Arbitrum GMX v2 (v1 scope) | 4 | 2,522 / 2,522 |
Total: 48,014 cross-entity checks passing across 21 invariants on three different real-world protocols.
The DEX harness alone caught two real bugs in itself during development (unstable Hasura pagination, a wrong heuristic invariant) — both fixed; the indexer's data was always consistent. That's the value of the harness pattern: it forces you to write down what you actually believe should hold, and Postgres+real-data tells you if you got it wrong.
| # | Invariant | Catches |
|---|---|---|
| L1–L2 | every Liquidation.{collateralAsset,debtAsset} has a corresponding Reserve |
Missed lazy-create on either side |
| L3–L4 | every Liquidation.{user,liquidator} has correct UserAggregator counter |
Missing victim/liquidator counter increments |
| L5 | ReserveAggregator.totalLiquidations >= count of liquidations touching this reserve |
Single-side increment bug |
| L6–L7 | uniqueSuppliers >= 1 when totalSupplied > 0 (same for borrowers) |
Counter sanity |
| L8–L9 | netSupplyPosition == cumulativeSupplied - cumulativeWithdrawn (same for debt) |
Withdraw/Repay arithmetic drift |
This catches a different class of bug from the unit tests:
- Unit tests use
MockDbwith ~5–10 events; pass/fail on synthetic data - The harness queries 1000+ real liquidations and fails if any of them violate cross-entity invariants
Why this isn't in CI: the harness needs a running pnpm dev against Polygon (not feasible in GitHub Actions without standing up the indexer infrastructure inside CI). Documented as a manual reproduction step. See scripts/demo-capture/README.md for the full invariant table + sample output.
This package previously included a synthesised PM template + Solidity contracts + Foundry tests. After discovering enviodev/polymarket-v2-indexer — Envio's production-shipped indexer for Polymarket V2 — the PM artifacts were removed. They were at best parallel work and at worst redundant against Envio's own production reference. Money market (Aave V3) replaced PM as the third DeFi shape; my contribution to the PM vertical going forward lands as PRs against the production repo, not as parallel candidate scaffolds.
The specs and diagnostics ground out in these analyses:
ENVIO_INDEXER_TEARDOWN.md— architectural teardown of Sablier + Velodrome production indexersENVIO_CLICKHOUSE_TEARDOWN.md— analytical workloads, dual-write architecture, query patternsENVIO_ONBOARDING_FORENSIC.md— first-30-minutes funnel friction in the docs / Greeter tutorialENVIO_REVENUE.md— canonical revenue memo (six levers, $250k–$880k year-1 sensitivity, live in-package proof for Lever 6). The earlier 3 docs (MODEL,MATH,MATH_V2) are redirect stubs preserving the lineage in git history.ENVIO_GROWTH_PLAN.md,ENVIO_FIRST_24_HOURS.md— quarterly milestones + day-1 brief
Every doc footer carries a pain-map cell (<funnel stage> × <tech|business>) and a revenue mechanism (net-new acquisition | tier-up to Dedicated | expansion ARR). The matrix in ENVIO_PAIN_MAP_MATRIX.md is the index — every other artifact is a populated cell the role would own.
The pow/ templates are the proof that the prose specs aren't just specs. The dual-reserve LiquidationCall handler in pow/envio-money-market-template-v1/src/EventHandlers/Pool.ts is what ENVIO_LIQUIDATION_HANDLER_REFERENCE.md describes. The Effect-API + entity-cache-first preload in pow/envio-defi-template-v1/src/EventHandlers/PoolFactory.ts is what ENVIO_EFFECT_API_PATTERN.md names as the production default.
If forced to pick one vertical to own end-to-end in the first 90 days: Prediction Markets. Three reasons:
- The analytics-as-product overlap with the highest-tier ACV is structurally strongest.
- The vertical is currently under-named in the marketing surface — the leverage on positioning work is highest.
- The named-account list is short enough to actually move the needle in a quarter.
— Kaustubh