Skip to content

adapt beets.trades to balancer.trades #8286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

franzns
Copy link
Contributor

@franzns franzns commented May 30, 2025

adapting beets.trades to balancer.trades to use the same schema

@Copilot Copilot AI review requested due to automatic review settings May 30, 2025 10:40
@github-actions github-actions bot marked this pull request as draft May 30, 2025 10:41
@github-actions github-actions bot added WIP work in progress dbt: dex covers the DEX dbt subproject labels May 30, 2025
@dune-eng
Copy link

Workflow run id 15344960155 approved.

@dune-eng
Copy link

Workflow run id 15344960167 approved.

@dune-eng
Copy link

Workflow run id 15344960238 approved.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adapts the existing beets.trades models to the Balancer schema by:

  • Introducing separate base trade models for Beets V2 and V3 using the balancer_compatible macros
  • Removing the old combined Sonic base trades and root beets_trades view
  • Adding new project-level views (beets_v2_sonic_trades, beets_v3_sonic_trades) and updating the schema YAML

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
dbt_subprojects/dex/models/trades/sonic/platforms/beets_v3_sonic_base_trades.sql New V3 base trades model invoking balancer_compatible_v3_trades
dbt_subprojects/dex/models/trades/sonic/platforms/beets_v2_sonic_base_trades.sql New V2 base trades model invoking balancer_compatible_v2_trades
dbt_subprojects/dex/models/trades/sonic/platforms/beets_sonic_base_trades.sql Removed old combined Sonic base trades
dbt_subprojects/dex/models/_projects/beets/beets_v3_sonic_trades.sql Added project-level V3 trades view
dbt_subprojects/dex/models/_projects/beets/beets_v2_sonic_trades.sql Added project-level V2 trades view
dbt_subprojects/dex/models/_projects/beets/beets_trades.sql Removed old unified beets_trades view
dbt_subprojects/dex/models/_projects/beets/_schema.yml Updated model entries and anchors for V2/V3 Sonic trades
Comments suppressed due to low confidence (1)

dbt_subprojects/dex/models/_projects/beets/_schema.yml:209

  • No data_tests are defined for the new beets_v2_sonic_trades and beets_v3_sonic_trades models. Consider adding a dbt_utils.unique_combination_of_columns test on the primary key columns (block_date, blockchain, project, version, tx_hash, evt_index).
- name: beets_v3_sonic_trades

swap_fee,
pool_symbol,
pool_type
FROM {{ ref('balancer_v2_ethereum_base_trades') }}
Copy link
Preview

Copilot AI May 30, 2025

Choose a reason for hiding this comment

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

The ref call should point to the new V2 base model (beets_v2_sonic_base_trades.sql, alias base_trades) instead of balancer_v2_ethereum_base_trades. Change to ref('beets_v2_sonic_base_trades') or ref('base_trades').

Suggested change
FROM {{ ref('balancer_v2_ethereum_base_trades') }}
FROM {{ ref('beets_v2_sonic_base_trades') }}

Copilot uses AI. Check for mistakes.

FROM dexs
LEFT JOIN {{ source('balancer_v2_ethereum', 'bpt_prices') }} bpt_prices
ON bpt_prices.contract_address = dexs.token_bought_address
AND bpt_prices.day <= DATE_TRUNC('day', dexs.block_time)
Copy link
Preview

Copilot AI May 30, 2025

Choose a reason for hiding this comment

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

The join on bpt_prices lacks a filter on the blockchain column, which may pull in records from other chains. Add AND bpt_prices.blockchain = 'ethereum' to the join condition.

Suggested change
AND bpt_prices.day <= DATE_TRUNC('day', dexs.block_time)
AND bpt_prices.day <= DATE_TRUNC('day', dexs.block_time)
AND bpt_prices.blockchain = 'ethereum'

Copilot uses AI. Check for mistakes.

@dune-eng
Copy link

Workflow run id 15345169652 approved.

@dune-eng
Copy link

Workflow run id 15345169824 approved.

@dune-eng
Copy link

Workflow run id 15345169722 approved.

@dune-eng
Copy link

Workflow run id 15345263958 approved.

@dune-eng
Copy link

Workflow run id 15345263963 approved.

@dune-eng
Copy link

Workflow run id 15345264167 approved.

@dune-eng
Copy link

Workflow run id 15345342772 approved.

@dune-eng
Copy link

Workflow run id 15345342762 approved.

@dune-eng
Copy link

Workflow run id 15345343062 approved.

@dune-eng
Copy link

Workflow run id 15345667079 approved.

@dune-eng
Copy link

Workflow run id 15345667090 approved.

@dune-eng
Copy link

Workflow run id 15345667411 approved.

This reverts commit 01b41b1.
@dune-eng
Copy link

Workflow run id 15345790458 approved.

@dune-eng
Copy link

Workflow run id 15345790421 approved.

@dune-eng
Copy link

Workflow run id 15345790428 approved.

@dune-eng
Copy link

Workflow run id 15346021311 approved.

@dune-eng
Copy link

Workflow run id 15346021300 approved.

@dune-eng
Copy link

Workflow run id 15346021478 approved.

@dune-eng
Copy link

Workflow run id 15346066034 approved.

@dune-eng
Copy link

Workflow run id 15346066037 approved.

@dune-eng
Copy link

Workflow run id 15346066345 approved.

@dune-eng
Copy link

Workflow run id 15346696830 approved.

@dune-eng
Copy link

Workflow run id 15346696844 approved.

@dune-eng
Copy link

Workflow run id 15346697110 approved.

@franzns franzns marked this pull request as ready for review May 30, 2025 12:52
@github-actions github-actions bot added ready-for-review this PR development is complete, please review and removed WIP work in progress labels May 30, 2025
@dune-eng
Copy link

Workflow run id 15347205520 approved.

@0xBoxer 0xBoxer added the prio:useful PRs that add value to existing curated data models or create alligned new models label Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dbt: dex covers the DEX dbt subproject prio:useful PRs that add value to existing curated data models or create alligned new models ready-for-review this PR development is complete, please review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants