Skip to content

Conversation

@hildobby
Copy link
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

cursor bot commented Dec 11, 2025

PR Summary

Introduces TVL, open positions, and user balance change models while enriching market/trade data (link slug, parsed times, asset IDs, price modifier) and converting positions to incremental with pricing.

  • New models
    • polymarket_polygon_protocol_tvl (incremental): hourly TVL from USDC.e flows.
    • polymarket_polygon_users_balance_changes (incremental): inflow/outflow records for Polymarket wallets.
    • polymarket_polygon_open_positions (view): latest open positions with latest_price and open_interest.
  • Positions
    • polymarket_polygon_positions: switch to incremental; derive daily prices from hourly with price_modifier; add price and usd_value; incremental windowing filters.
  • Markets/Trades enrichment
    • polymarket_polygon_market_details: add polymarket_link_slug, parsed market_start_time_parsed/market_end_time_parsed, and price_modifier.
    • polymarket_polygon_market_trades_raw: include maker_asset_id/taker_asset_id.
    • polymarket_polygon_market_trades: expose new fields and polymarket_link_slug.
    • polymarket_polygon_market_prices_daily: refactor forward-fill to use utils_days and clean CTEs.
  • Schema
    • _schema.yml: document new columns and add entries for the new models.

Written by Cursor Bugbot for commit 9592bca. Configure here.

Copy link

@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
Collaborator Author

@cursor review

Copy link

@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
Collaborator Author

@cursor review

Copy link

@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
Collaborator Author

@cursor review

Copy link

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

✅ Bugbot reviewed your changes and found no bugs!


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

@hildobby
Copy link
Collaborator Author

@cursor review

Copy link

@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
Collaborator Author

https://github.com/cursor review

Copy link

@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

SELECT *,
CASE WHEN outcome = '50/50' THEN 0.5
WHEN LOWER(token_outcome) = outcome THEN 1
ELSE 0 END AS price_modifier
Copy link

Choose a reason for hiding this comment

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

Bug: Unresolved markets incorrectly get zero price modifier

The price_modifier calculation returns 0 for markets with outcome = 'unresolved' because neither the '50/50' check nor LOWER(token_outcome) = outcome matches when outcome is 'unresolved'. This differs from the existing behavior in polymarket_polygon_market_prices_daily.sql which preserves the original market price (ELSE ff.price) for unresolved markets. When used in polymarket_polygon_positions.sql, markets past their end time but not yet resolved will incorrectly show positions as worthless (price = 0) instead of using the last traded price.

Additional Locations (1)

Fix in Cursor Fix in Web

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.

1 participant