# Segment 2 prep — Spellbook PR draft (Limitless Exchange, Base) **Produced during Segment 1 Phase 3.** Candidate C2 deliverable — a Dune Spellbook PR that's ready to submit the moment `merovan` has a working GitHub account. ## Headline Drafted a complete Spellbook spell set for **Limitless Exchange** (largest prediction-market platform on Base, ~$1.3B cumulative volume, CLOB-based). Limitless is completely unspelled in `duneanalytics/spellbook` as of 2026-04-18 — verified by `find spellbook/ -iname '*limitless*'` (no matches). This is a legitimate high-signal first PR opportunity for the `merovan` handle. ## Files drafted Location: `scripts_segment_2_prep/spellbook_draft/limitless_base_spell/` ``` sources/limitless/base/_sources.yml -- source table declarations models/base/_schema.yml -- model metadata + contributors models/base/limitless_base_market_trades_raw.sql -- raw OrderFilled events models/base/limitless_base_market_trades.sql -- analyst-facing spell ``` Plus `scripts_segment_2_prep/spellbook_draft/README.md` with complete submission instructions. ## Key design choices - **Protocol choice: Limitless over Polymarket or Kalshi.** Polymarket + Kalshi both already have extensive Spellbook coverage (19 spells on Polymarket alone). Limitless has zero. Best marginal contribution. - **Pattern: CLOB OrderFilled unions.** Limitless uses the same Gnosis CTF + versioned CTFExchange architecture as Polymarket, so the `polymarket_polygon_market_trades_raw` spell pattern transferred directly. Six source-event tables (simple v1/v2/v3 + NegRisk v1/v2/v3) are unioned into one raw-trades table. - **Scope: trades first, details later.** A single well-tested `trades` spell is a better first PR than a sprawling patch. Follow-up patches add `market_details`, `ohlcv_hourly`, `positions`. - **Contributors metadata set to `merovan`.** Reputation attached to every query that references `limitless_base.market_trades`. ## Headline findings - Limitless Exchange contract addresses (all on Base, verified from `docs.limitless.exchange/user-guide/smart-contracts` on 2026-04-18): - CTF: `0xC9c98965297Bc527861c898329Ee280632B76e18` - Six CTFExchange variants (simple v1/v2/v3 + NegRisk v1/v2/v3) - Three NegRiskAdapter variants - Dune needs each of these decoded first (via the submit-contract UI — independent of the Spellbook PR flow). - Spell draft compiles as YAML (pyyaml `safe_load` passes on both yml files; SQL templated with dbt Jinja is syntactically plausible). ## Testing done - YAML syntax: `pyyaml.safe_load` passes on `_sources.yml` and `_schema.yml`. - SQL structure: mirrors `polymarket_polygon_market_trades_raw` (which is a merged, approved precedent in the spellbook repo). - Cross-reference: contract-address list matches Limitless's canonical docs page. ### Added in Segment 2 Phase 0 (`segment_2_prep_and_poll`) The Phase-3 recommendation flagged running `dbt compile` on this spell as a must-do-first blocker before authoring any more spell drafts. Completed 2026-04-18: 1. **`dbt parse` on the full daily_spellbook project** (with Limitless spells placed in `dbt_subprojects/daily_spellbook/models/_projects/ limitless/base/` and `sources/limitless/base/_sources.yml`) — succeeded. Only warnings were deprecations inherited from unrelated repo models (`DuplicateYAMLKeysDeprecation`, `MissingArgumentsPropertyIn GenericTestDeprecation`, `PropertyMovedToConfigDeprecation`); no error from any Limitless file. 2. **`dbt compile --select limitless_base_market_trades_raw limitless_base_market_trades`** — succeeded. The Jinja templating (including the `{{ source('limitless_base', ...) }}` references, the `{{ is_incremental() }}` / `{{ incremental_predicate(...) }}` macros, and the `expose_spells` post-hook) rendered to clean SQL: `"delta_prod"."limitless_base"."CTFExchange_v1_evt_OrderFilled"`-style fully-qualified references. 3. **`sqlglot.parse(..., dialect='trino')`** on both compiled outputs (`target/compiled/daily_spellbook/models/_projects/limitless/ base/*.sql`) — both parse successfully (1 statement each). 4. **No column-name surprises** — the `makerAssetId` vs `takerAssetID` case mismatch in the UNION columns is a known Solidity-source typo inherited from Polymarket's CTFExchange (verified present in the approved `polymarket_polygon_market_trades_raw` spell), not a bug in our spell. We carry it forward for consistency because Limitless forks Polymarket's CTFExchange 1:1. **Caveats — things `dbt compile` + `sqlglot` cannot catch without a Catalyst workspace:** - Schema-level column existence: dbt doesn't verify that `limitless_base.CTFExchange_v1_evt_OrderFilled` actually has a `makerAssetId` column once Dune's decoder registers the contract. This depends on the decoder-submission step (still gated on Dune account). - `dbt-utils.unique_combination_of_columns` test execution — runs against live data only. - `expose_spells` post-hook side effects — only run at materialization. **Recommendation**: this spell is dbt-compile-clean and ready to submit when the GitHub account exists. Do NOT publish the PR before the decoder-submission flow places the six CTFExchange contracts into Dune's `limitless_base` namespace — the spell is correct but will fail CI if sources don't exist yet. ### Skipped this phase (per Step 0.7 classification (c)) INSTRUCTIONS.md § B2 directs: if the Dune-anon-submission assumption classifies as (c) "compound-prep thesis broken," drop B2 to a minimum-viable placeholder (finish Limitless validation, skip the new Spellbook PR draft, redirect time to B3 brainstorm + bypass-path evaluation). Step 0.7 classified as (c) — see `writeups/dune_submission_assumption_check.md`. Therefore the second Spellbook PR draft planned by default in B2 is deferred; the dbt-compile validation above closes the must-do-first gap without stacking more speculative artifacts in a contracting review queue. ## Not done (explicitly deferred) - **Actually submitting the PR** — requires GitHub account, which doesn't exist yet in this phase. - **Follow-up spells** (`market_details`, `ohlcv_hourly`, `positions`, `users`) — structure known; implementation deferred until first PR lands successfully. - **Second Spellbook PR draft** — deferred per Step 0.7 (c) classification, see above. ## Value of this artifact 1. **Head-start when GitHub exists.** PR submission is ~1 hour of work (fork + copy + pre-commit + push + PR body) instead of 4-6h of authoring from scratch. 2. **Independent research value.** The contract-address table itself is reusable by any Limitless analytics dashboard Segment 2 builds. 3. **Backup if GitHub signup stays stuck.** The draft can also be proposed informally to the Dune team via the Discord bounty channel with a pointer to this repo once we have Discord. 4. **Reputation compound.** If merged, every `limitless_base.*` query forever references `contributors: merovan`. ## Clone management `duneanalytics/spellbook` shallow-cloned to `scripts_segment_2_prep/spellbook_draft/spellbook/` (263MB). Added to `.gitignore`. Used for pattern-matching only; not modified.