Skip to content

Repository files navigation

Growth Engineer at Envio — Candidate Package

CI

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 the envio-deploy-money-market branch. See PROOF_OF_WORK.md for 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.


Read order

Start at the framing memo, then trace into the diagnostics, then read the runnable code.

1 — Framing

2 — Week-One diagnostics (§8 of the playbook)

3 — Tech artifact specs (§3 + §4)

4 — Runnable proof-of-work (pow/)

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 from velodrome-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 test clean (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. The LiquidationCall handler updates both affected reserves and both users (victim + liquidator). pnpm install && pnpm codegen && pnpm test clean (5/5 vitest). 🟢 Verified live against Aave V3 on Polygon — see docs/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 REAL EventEmitter pattern on Arbitrum. Subscribes to a single global EventEmitter contract, routes events on eventName string, decodes the EventLogData typed dictionary. v1 scope: PositionIncrease only; v2 (PositionDecrease, Liquidation, Funding) is a mechanical extension documented inline. pnpm install && pnpm codegen && pnpm test clean (2/2 active vitest, 3 skipped pending v2). 🟢 Verified live against GMX v2 on Arbitrum — 9 markets, 1252 positions indexed end-to-end.

Shared tooling — multi-chain expansion CLI

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 chain

Idempotent — re-running with the same config is a no-op. Implements ENVIO_MULTICHAIN_EXPANSION_RUNBOOK.md as deterministic code.

Verification surface (every commit)

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.

Live indexing run — Aave V3 on Polygon

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).

Live-indexer assertion harnesses — 3/3 templates verified

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 MockDb with ~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.

A note on the prediction-markets vertical

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.

5 — Companion analysis (the grounding evidence)

The specs and diagnostics ground out in these analyses:

6 — Decks + supporting


How the pieces fit

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.


The bet

If forced to pick one vertical to own end-to-end in the first 90 days: Prediction Markets. Three reasons:

  1. The analytics-as-product overlap with the highest-tier ACV is structurally strongest.
  2. The vertical is currently under-named in the marketing surface — the leverage on positioning work is highest.
  3. The named-account list is short enough to actually move the needle in a quarter.

— Kaustubh

Releases

Packages

Contributors

Languages