add files to connect four new EVM chains on balancerv3#9425
add files to connect four new EVM chains on balancerv3#9425jeff-dude merged 16 commits intoduneanalytics:mainfrom
Conversation
📝 WalkthroughWalkthroughAdds Balancer v3 support for the Avalanche C chain: new schema declarations and ~30 dbt models (token balances, BPT, ERC4626, pools/LBPs, liquidity, protocol fees) and updates aggregation models to include the new Avalanche C sources. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/avalanche_c/balancer_v3_avalanche_c_erc4626_token_prices.sql`:
- Line 64: The LEAD(...) fallback uses CURRENT_DATE + INTERVAL '1' day which
makes next_change vary between runs; change the LEAD default for next_change
(the expression with LEAD(p.evt_block_time, 1, ... ) OVER (PARTITION BY
wrappedToken ORDER BY p.evt_block_time)) to use a stable far-future sentinel
timestamp (e.g. a constant like '9999-12-31' or similar) or alternatively modify
the incremental logic to always reprocess the previous terminal row per
wrappedToken so that the next_change value remains stable across runs; update
the LEAD fallback accordingly and ensure references to next_change continue to
use that column alias.
- Around line 49-50: The model currently joins on DATE_TRUNC('minute',
w.evt_block_time) but emits the raw evt_block_time as minute, causing sub-minute
rows; change the SELECT and any emitted minute column (and unique key) to use
DATE_TRUNC('minute', w.evt_block_time) (or p.minute) consistently so the
published minute grain is truncated to minute for functions/tables like minute
in the SELECT, the unique key, and any incremental filters (see the join using
w.evt_block_time, the emitted minute field, and the incremental block around
is_incremental()).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ae64a101-9a83-4936-a687-99d4c72ed4c9
📒 Files selected for processing (32)
dbt_subprojects/hourly_spellbook/models/_project/balancer/balances/avalanche_c/_schema.ymldbt_subprojects/hourly_spellbook/models/_project/balancer/balances/avalanche_c/balancer_v3_avalanche_c_token_balance_changes.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/balances/avalanche_c/balancer_v3_avalanche_c_token_balance_changes_daily.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/balances/balancer_token_balance_changes.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/balances/balancer_token_balance_changes_daily.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/avalanche_c/_schema.ymldbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/avalanche_c/balancer_v3_avalanche_c_bpt_prices.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/avalanche_c/balancer_v3_avalanche_c_bpt_supply.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/avalanche_c/balancer_v3_avalanche_c_bpt_supply_changes.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/avalanche_c/balancer_v3_avalanche_c_bpt_supply_changes_daily.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/avalanche_c/balancer_v3_avalanche_c_transfers_bpt.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_prices.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply_changes.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_bpt_supply_changes_daily.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/bpt/balancer_transfers_bpt.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/avalanche_c/_schema.ymldbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/avalanche_c/balancer_v3_avalanche_c_erc4626_token_mapping.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/avalanche_c/balancer_v3_avalanche_c_erc4626_token_prices.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/balancer_v3_erc4626_token_mapping.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/balancer_v3_erc4626_token_prices.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/avalanche_c/_schema.ymldbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/avalanche_c/balancer_v3_avalanche_c_liquidity.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/liquidity/balancer_liquidity.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/pools/avalanche_c/_schema.ymldbt_subprojects/hourly_spellbook/models/_project/balancer/pools/avalanche_c/balancer_avalanche_c_pools_tokens_weights.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/pools/avalanche_c/balancer_v3_avalanche_c_lbps.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/pools/avalanche_c/balancer_v3_avalanche_c_pools_tokens_weights.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/pools/balancer_v3_lbps.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/avalanche_c/_schema.ymldbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/avalanche_c/balancer_v3_avalanche_c_protocol_fee.sqldbt_subprojects/hourly_spellbook/models/_project/balancer/protocol_fee/balancer_protocol_fee.sql
There was a problem hiding this comment.
♻️ Duplicate comments (1)
dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/avalanche_c/balancer_v3_avalanche_c_erc4626_token_prices.sql (1)
19-20:⚠️ Potential issue | 🟠 MajorRecompute the previous terminal row for touched tokens.
The incremental filters on Line 20 and Line 31 only rebuild recent events. When a
wrapped_tokenchanges again after that window, the older row already stored in{{ this }}keeps the far-futurenext_changefrom Line 64, and the new row gets one too. That leaves overlapping validity ranges for the same token, so downstream as-of joins can match both prices after the new event. Re-include the prior terminal row for each touched token in incremental runs, or otherwise update itsnext_changebefore the merge.Based on learnings,
incremental_predicate('evt_block_time')typically filters to the last ~3 days.Also applies to: 30-31, 64-64
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/avalanche_c/balancer_v3_avalanche_c_erc4626_token_prices.sql` around lines 19 - 20, The incremental WHERE using incremental_predicate('evt_block_time') rebuilds only recent events and can leave an older terminal row in {{ this }} with a far-future next_change for the same wrapped_token, creating overlapping validity ranges; fix by, when is_incremental() is true, identifying wrapped_token values touched by the incremental window (using evt_block_time) and (a) re-selecting their previous terminal rows from {{ this }} (rows where next_change IS NULL or > max(evt_block_time)) into the incremental insert so the prior terminal row is recomputed, or (b) updating that prior row’s next_change to the new event time before the final merge — reference incremental_predicate('evt_block_time'), is_incremental(), wrapped_token, evt_block_time, next_change and {{ this }} to locate the code to change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In
`@dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/avalanche_c/balancer_v3_avalanche_c_erc4626_token_prices.sql`:
- Around line 19-20: The incremental WHERE using
incremental_predicate('evt_block_time') rebuilds only recent events and can
leave an older terminal row in {{ this }} with a far-future next_change for the
same wrapped_token, creating overlapping validity ranges; fix by, when
is_incremental() is true, identifying wrapped_token values touched by the
incremental window (using evt_block_time) and (a) re-selecting their previous
terminal rows from {{ this }} (rows where next_change IS NULL or >
max(evt_block_time)) into the incremental insert so the prior terminal row is
recomputed, or (b) updating that prior row’s next_change to the new event time
before the final merge — reference incremental_predicate('evt_block_time'),
is_incremental(), wrapped_token, evt_block_time, next_change and {{ this }} to
locate the code to change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ba79a840-b283-4505-8f5d-46f701c9d3fe
📒 Files selected for processing (1)
dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/avalanche_c/balancer_v3_avalanche_c_erc4626_token_prices.sql
|
all four chains merged to this PR |
Thank you for contributing to Spellbook 🪄
Please open the PR in draft and mark as ready when you want to request a review.
Description:
Connect Avalanche C chain into balancer_v3
quick links for more information: