Skip to content

add columns to polymarket models#9107

Open
hildobby wants to merge 88 commits intoduneanalytics:mainfrom
hildobby:polymarket_table_fixes
Open

add columns to polymarket models#9107
hildobby wants to merge 88 commits intoduneanalytics:mainfrom
hildobby:polymarket_table_fixes

Conversation

@hildobby
Copy link
Copy Markdown
Collaborator

@hildobby hildobby commented Dec 9, 2025

added columns to existing tables (needed for much more efficient queries) and created 3 tables:

  • one for protocol tvl
  • one for user balance changes
  • one for currently open positions (view)

@github-actions github-actions bot marked this pull request as draft December 9, 2025 18:48
@github-actions github-actions bot added WIP work in progress dbt: daily covers the Daily dbt subproject labels Dec 9, 2025
@hildobby hildobby marked this pull request as ready for review December 9, 2025 18:50
@github-actions github-actions bot added ready-for-review this PR development is complete, please review and removed WIP work in progress labels Dec 9, 2025
@cursor
Copy link
Copy Markdown

cursor bot commented Dec 11, 2025

PR Summary

Introduces new analytics surfaces and enriches existing Polymarket models for better querying and pricing.

  • Adds new incremental models: polymarket_polygon_protocol_tvl (hourly TVL/net flow from USDC.e transfers) and polymarket_polygon_users_balance_changes (inflow/outflow/internal per wallet); adds polymarket_polygon_open_positions view (latest positions with latest_price/open_interest)
  • Enhances polymarket_polygon_market_details with polymarket_link_slug, parsed start/end timestamps, and computed final_price
  • Extends trades: polymarket_polygon_market_trades_raw and ..._market_trades now include maker_asset_id/taker_asset_id and expose polymarket_link_slug
  • Upgrades polymarket_polygon_positions to incremental, adds daily pricing join and price/usd_value, and filters late/partial days
  • Refactors polymarket_polygon_market_prices_daily forward-fill to use utils_days and date bounds
  • Updates _schema.yml to document new columns/models and add tests

Written by Cursor Bugbot for commit d775b77. Configure here.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment @cursor review or bugbot run to trigger another review on this PR

@hildobby
Copy link
Copy Markdown
Collaborator Author

hildobby commented Mar 4, 2026

PR is ready btw, it has a a few new spells and some new columns in a few tables

I also optimised the spells a bunch since runtime was crazy on some of those. It's far from perfect but should require a lot less compute than they used to. I made sure to keep all old columns for backward compatibility.

The only missing thing is for the market details spell which needs to have uploaded base table switched from dune's (deprecated afaik) to polymarket's uploaded one but it's missing a needed column so I pinged Primo to ask if he could add it. We can merge as is and tackle that in another follow up PR

@0xBoxer

@hildobby
Copy link
Copy Markdown
Collaborator Author

@jeff-dude could you review this PR please?

@jeff-dude
Copy link
Copy Markdown
Member

jeff-dude commented Mar 13, 2026

@jeff-dude could you review this PR please?

before diving deep, want to give you heads up that we have three open PRs to materialize polymarket views into incremental tables. once those are deployed and rebuilt, you can merge changes into your branch here. then we can look into the additional columns and tables. our changes will not change the data output or schema at all, simply materialize into tables for performance downstream.

@hildobby
Copy link
Copy Markdown
Collaborator Author

@jeff-dude could you review this PR please?

before diving deep, want to give you heads up that we have three open PRs to materialize polymarket views into incremental tables. once those are deployed and rebuilt, you can merge changes into your branch here. then we can look into the additional columns and tables. our changes will not change the data output or schema at all, simply materialize into tables for performance downstream.

do as you need, I switched out of dune to using another more reliable source for polymarket data since most things blow past dune's query runtime anyways because the spells are in a rough state and merging this took way too long

@jeff-dude
Copy link
Copy Markdown
Member

do as you need, I switched out of dune to using another more reliable source for polymarket data since most things blow past dune's query runtime anyways because the spells are in a rough state and merging this took way too long

understood. this is why we materialized, to help with query performance. we are also spending time Q2 on enhancing prediction market datasets.

@hildobby
Copy link
Copy Markdown
Collaborator Author

hildobby commented Mar 31, 2026

@jeff-dude yes but materialising them won't fix this fyi. you can't even get volume from them right now and need to defer to decoded even tables, same for tvl (costs insane compute because dates are string for example) and many other super basic metrics. the queries are very suboptimal in their current state, hence my PR here. In this PR I tried to keep all currently active columns while adding new ones that I think are more useful (so it will remain with a ton of technical debt of unneeded stuff either way)

@jeff-dude
Copy link
Copy Markdown
Member

@jeff-dude yes but materialising them won't fix this fyi. you can't even get volume from them right now and need to defer to decoded even tables, same for tvl (costs insane compute because dates are string for example) and many other super basic metrics. the queries are very suboptimal in their current state, hence my PR here. In this PR I tried to keep all currently active columns while adding new ones that I think are more useful (so it will remain with a ton of technical debt of unneeded stuff either way)

okay thanks for clarifying. i have shared internally with the team for reference.

tomfutago and others added 4 commits April 9, 2026 16:57
Build user balance changes from capital actions instead of rescanning raw transfers so the initial full build uses a smaller input set and avoids Trino memory blowups.

Made-with: Cursor
@tomfutago
Copy link
Copy Markdown
Contributor

bugbot run

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 10, 2026

Bugbot couldn't run

Bugbot is not enabled for your user on this team.

Ask your team administrator to increase your team's hard limit for Bugbot seats or add you to the allowlist in the Cursor dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dbt: daily covers the Daily dbt subproject ready-for-review this PR development is complete, please review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants