From c1b5417a186c4701e452fcaeea1ebebaea625653 Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Tue, 4 Jun 2024 00:19:10 +0100 Subject: [PATCH 1/2] Organize Balancer Spells into folders (#6005) * test folders * fix typo * again * organize balancer spells into folders * fix indentation * fix schema references * again * again * remove legacy model for zkevm * Remove balancer from dbt_project.yml * rerun a few schemas * again * fix macro * again * force run schemas * rerun * fix indentation issues and remove legacy trades models * update post hooks * fix typo * again * again * again * move all folders into _project --------- Co-authored-by: Huang Geyang --- dbt_project.yml | 13 - .../balancer/balancer_bpt_supply_macro.sql | 34 +- ...l_token_supply_changes_daily_agg_macro.sql | 37 + ...lancer_pool_token_supply_changes_macro.sql | 130 ++++ ..._token_balance_changes_daily_agg_macro.sql | 184 +++++ .../balancer_token_balance_changes_macro.sql | 169 +++++ models/_project/balancer/balances/_schema.yml | 98 +++ .../balancer/balances/arbitrum/_schema.yml | 100 +++ ...ncer_v2_arbitrum_token_balance_changes.sql | 16 + ...2_arbitrum_token_balance_changes_daily.sql | 17 + .../balancer/balances/avalanche_c/_schema.yml | 100 +++ ...r_v2_avalanche_c_token_balance_changes.sql | 16 + ...valanche_c_token_balance_changes_daily.sql | 17 + .../balancer_token_balance_changes.sql | 46 ++ .../balancer_token_balance_changes_daily.sql | 43 ++ .../balancer/balances/base/_schema.yml | 100 +++ ...balancer_v2_base_token_balance_changes.sql | 16 + ...er_v2_base_token_balance_changes_daily.sql | 17 + .../balancer/balances/ethereum/_schema.yml | 131 ++++ .../ethereum/balancer_ethereum_balances.sql | 11 +- ...ncer_v2_ethereum_token_balance_changes.sql | 16 + ...2_ethereum_token_balance_changes_daily.sql | 17 + .../balancer/balances/gnosis/_schema.yml | 100 +++ ...lancer_v2_gnosis_token_balance_changes.sql | 16 + ..._v2_gnosis_token_balance_changes_daily.sql | 17 + .../balancer/balances/optimism/_schema.yml | 100 +++ ...ncer_v2_optimism_token_balance_changes.sql | 16 + ...2_optimism_token_balance_changes_daily.sql | 17 + .../balancer/balances/polygon/_schema.yml | 100 +++ ...ancer_v2_polygon_token_balance_changes.sql | 16 + ...v2_polygon_token_balance_changes_daily.sql | 17 + .../balancer/balances/zkevm/_schema.yml | 100 +++ ...alancer_v2_zkevm_token_balance_changes.sql | 16 + ...r_v2_zkevm_token_balance_changes_daily.sql | 17 + models/_project/balancer/bpt/_schema.yml | 176 +++++ .../balancer/bpt/arbitrum/_schema.yml | 178 +++++ .../balancer_v2_arbitrum_bpt_prices.sql | 0 .../balancer_v2_arbitrum_bpt_supply.sql | 0 ...alancer_v2_arbitrum_bpt_supply_changes.sql | 20 + ...r_v2_arbitrum_bpt_supply_changes_daily.sql | 17 + .../balancer_v2_arbitrum_transfers_bpt.sql | 0 .../balancer/bpt/avalanche_c/_schema.yml | 178 +++++ .../balancer_v2_avalanche_c_bpt_prices.sql | 0 .../balancer_v2_avalanche_c_bpt_supply.sql | 0 ...ncer_v2_avalanche_c_bpt_supply_changes.sql | 20 + ...2_avalanche_c_bpt_supply_changes_daily.sql | 17 + .../balancer_v2_avalanche_c_transfers_bpt.sql | 0 .../balancer/bpt}/balancer_bpt_prices.sql | 8 +- .../balancer/bpt}/balancer_bpt_supply.sql | 8 +- .../bpt/balancer_bpt_supply_changes.sql | 44 ++ .../bpt/balancer_bpt_supply_changes_daily.sql | 38 + .../balancer/bpt}/balancer_transfers_bpt.sql | 8 +- models/_project/balancer/bpt/base/_schema.yml | 178 +++++ .../bpt}/base/balancer_v2_base_bpt_prices.sql | 0 .../bpt}/base/balancer_v2_base_bpt_supply.sql | 0 .../balancer_v2_base_bpt_supply_changes.sql | 20 + ...ancer_v2_base_bpt_supply_changes_daily.sql | 17 + .../base/balancer_v2_base_transfers_bpt.sql | 0 .../balancer/bpt/ethereum/_schema.yml | 178 +++++ .../balancer_v2_ethereum_bpt_prices.sql | 0 .../balancer_v2_ethereum_bpt_supply.sql | 0 ...alancer_v2_ethereum_bpt_supply_changes.sql | 20 + ...r_v2_ethereum_bpt_supply_changes_daily.sql | 17 + .../balancer_v2_ethereum_transfers_bpt.sql | 0 .../_project/balancer/bpt/gnosis/_schema.yml | 178 +++++ .../gnosis/balancer_v2_gnosis_bpt_prices.sql | 0 .../gnosis/balancer_v2_gnosis_bpt_supply.sql | 0 .../balancer_v2_gnosis_bpt_supply_changes.sql | 20 + ...cer_v2_gnosis_bpt_supply_changes_daily.sql | 17 + .../balancer_v2_gnosis_transfers_bpt.sql | 0 .../balancer/bpt/optimism/_schema.yml | 178 +++++ .../balancer_v2_optimism_bpt_prices.sql | 0 .../balancer_v2_optimism_bpt_supply.sql | 0 ...alancer_v2_optimism_bpt_supply_changes.sql | 20 + ...r_v2_optimism_bpt_supply_changes_daily.sql | 17 + .../balancer_v2_optimism_transfers_bpt.sql | 0 .../_project/balancer/bpt/polygon/_schema.yml | 178 +++++ .../balancer_v2_polygon_bpt_prices.sql | 0 .../balancer_v2_polygon_bpt_supply.sql | 0 ...balancer_v2_polygon_bpt_supply_changes.sql | 20 + ...er_v2_polygon_bpt_supply_changes_daily.sql | 17 + .../balancer_v2_polygon_transfers_bpt.sql | 0 .../_project/balancer/bpt/zkevm/_schema.yml | 178 +++++ .../zkevm/balancer_v2_zkevm_bpt_prices.sql | 0 .../zkevm/balancer_v2_zkevm_bpt_supply.sql | 0 .../balancer_v2_zkevm_bpt_supply_changes.sql | 20 + ...ncer_v2_zkevm_bpt_supply_changes_daily.sql | 17 + .../zkevm/balancer_v2_zkevm_transfers_bpt.sql | 0 .../_project/balancer/flashloans/_schema.yml | 35 + .../balancer/flashloans/arbitrum/_schema.yml | 36 + .../balancer_v2_arbitrum_flashloans.sql | 4 - .../flashloans/avalanche_c/_schema.yml | 36 + .../balancer_v2_avalanche_c_flashloans.sql | 4 - .../flashloans}/balancer_flashloans.sql | 11 +- .../balancer/flashloans/base/_schema.yml | 36 + .../base/balancer_v2_base_flashloans.sql | 4 - .../balancer/flashloans/ethereum/_schema.yml | 36 + .../balancer_v2_ethereum_flashloans.sql | 4 - .../balancer/flashloans/gnosis/_schema.yml | 36 + .../gnosis/balancer_v2_gnosis_flashloans.sql | 4 - .../balancer/flashloans/optimism/_schema.yml | 36 + .../balancer_v2_optimism_flashloans.sql | 4 - .../balancer/flashloans/polygon/_schema.yml | 36 + .../balancer_v2_polygon_flashloans.sql | 4 - .../balancer/flashloans/zkevm/_schema.yml | 36 + .../zkevm/balancer_v2_zkevm_flashloans.sql | 4 - .../_project/balancer/liquidity/_schema.yml | 60 ++ .../balancer/liquidity/arbitrum/_schema.yml | 58 ++ .../balancer_v2_arbitrum_liquidity.sql | 6 +- .../liquidity/avalanche_c/_schema.yml | 58 ++ .../balancer_v2_avalanche_c_liquidity.sql | 6 +- .../liquidity}/balancer_liquidity.sql | 9 +- .../balancer/liquidity/base/_schema.yml | 58 ++ .../base/balancer_v2_base_liquidity.sql | 6 +- .../balancer/liquidity/ethereum/_schema.yml | 96 +++ .../balancer_v1_ethereum_liquidity.sql | 6 +- .../balancer_v2_ethereum_liquidity.sql | 6 +- .../balancer/liquidity/gnosis/_schema.yml | 58 ++ .../gnosis/balancer_v2_gnosis_liquidity.sql | 6 +- .../balancer/liquidity/optimism/_schema.yml | 58 ++ .../balancer_v2_optimism_liquidity.sql | 6 +- .../balancer/liquidity/polygon/_schema.yml | 58 ++ .../polygon/balancer_v2_polygon_liquidity.sql | 6 +- .../balancer/liquidity/zkevm/_schema.yml | 58 ++ .../zkevm/balancer_v2_zkevm_liquidity.sql | 6 +- models/_project/balancer/pools/_schema.yml | 173 +++++ .../balancer/pools/arbitrum/_schema.yml | 105 +++ ...balancer_arbitrum_pools_tokens_weights.sql | 0 .../balancer_v2_arbitrum_pools_fees.sql | 11 +- ...ancer_v2_arbitrum_pools_tokens_weights.sql | 1 - .../balancer/pools/avalanche_c/_schema.yml | 105 +++ ...ancer_avalanche_c_pools_tokens_weights.sql | 0 .../balancer_v2_avalanche_c_pools_fees.sql | 9 +- ...er_v2_avalanche_c_pools_tokens_weights.sql | 1 - .../pools}/balancer_gauge_mappings.sql | 7 +- .../balancer/pools}/balancer_pools_fees.sql | 9 +- .../pools}/balancer_pools_metrics_daily.sql | 0 .../pools}/balancer_pools_tokens_weights.sql | 8 +- .../_project/balancer/pools/base/_schema.yml | 105 +++ .../balancer_base_pools_tokens_weights.sql | 0 .../base/balancer_v2_base_pools_fees.sql | 9 +- .../balancer_v2_base_pools_tokens_weights.sql | 1 - .../balancer/pools/ethereum/_schema.yml | 149 ++++ ...balancer_ethereum_pools_tokens_weights.sql | 0 ...ancer_v1_ethereum_pools_tokens_weights.sql | 7 +- .../ethereum/balancer_v2_ethereum_lbps.sql | 0 .../balancer_v2_ethereum_pools_fees.sql | 7 +- ...ancer_v2_ethereum_pools_tokens_weights.sql | 1 - .../balancer/pools/gnosis/_schema.yml | 105 +++ .../balancer_gnosis_pools_tokens_weights.sql | 0 .../gnosis/balancer_v2_gnosis_pools_fees.sql | 9 +- ...alancer_v2_gnosis_pools_tokens_weights.sql | 1 - .../balancer/pools/optimism/_schema.yml | 146 ++++ .../balancer_optimism_gauge_mappings.sql | 7 +- ...balancer_optimism_pools_tokens_weights.sql | 3 +- .../balancer_v2_optimism_pools_fees.sql | 9 +- ...ancer_v2_optimism_pools_tokens_weights.sql | 1 - .../balancer/pools/polygon/_schema.yml | 128 ++++ .../balancer_polygon_pools_tokens_weights.sql | 0 .../polygon/balancer_v2_polygon_lbps.sql | 0 .../balancer_v2_polygon_pools_fees.sql | 9 +- ...lancer_v2_polygon_pools_tokens_weights.sql | 1 - .../_project/balancer/pools/zkevm/_schema.yml | 105 +++ .../zkevm/balancer_v2_zkevm_pools_fees.sql | 6 +- ...balancer_v2_zkevm_pools_tokens_weights.sql | 0 .../balancer_zkevm_pools_tokens_weights.sql | 0 .../balancer/protocol_fee/_schema.yml | 61 ++ .../protocol_fee/arbitrum/_schema.yml | 61 ++ .../balancer_v2_arbitrum_protocol_fee.sql | 0 .../protocol_fee/avalanche_c/_schema.yml | 61 ++ .../balancer_v2_avalanche_c_protocol_fee.sql | 0 .../protocol_fee}/balancer_protocol_fee.sql | 8 +- .../balancer/protocol_fee/base/_schema.yml | 61 ++ .../base/balancer_v2_base_protocol_fee.sql | 0 .../protocol_fee/ethereum/_schema.yml | 61 ++ .../balancer_v2_ethereum_protocol_fee.sql | 0 .../balancer/protocol_fee/gnosis/_schema.yml | 61 ++ .../balancer_v2_gnosis_protocol_fee.sql | 0 .../protocol_fee/optimism/_schema.yml | 61 ++ .../balancer_v2_optimism_protocol_fee.sql | 0 .../balancer/protocol_fee/polygon/_schema.yml | 61 ++ .../balancer_v2_polygon_protocol_fee.sql | 0 .../balancer/protocol_fee/zkevm/_schema.yml | 61 ++ .../zkevm/balancer_v2_zkevm_protocol_fee.sql | 0 models/_project/balancer/support/_schema.yml | 56 ++ .../balancer_single_recipient_gauges.sql | 0 .../support}/balancer_token_whitelist.sql | 0 .../balancer/trades/arbitrum/_schema.yml | 149 ++++ .../arbitrum/balancer_arbitrum_trades.sql | 0 .../arbitrum/balancer_v2_arbitrum_trades.sql | 6 +- .../balancer/trades/avalanche_c/_schema.yml | 149 ++++ .../balancer_avalanche_c_trades.sql | 0 .../balancer_v2_avalanche_c_trades.sql | 8 +- .../balancer/{ => trades}/balancer_trades.sql | 0 .../_project/balancer/trades/base/_schema.yml | 149 ++++ .../trades}/base/balancer_base_trades.sql | 0 .../trades}/base/balancer_v2_base_trades.sql | 6 +- .../balancer/trades/ethereum/_schema.yml | 145 ++++ .../ethereum/balancer_ethereum_trades.sql | 0 .../ethereum/balancer_v1_ethereum_trades.sql | 0 .../ethereum/balancer_v2_ethereum_trades.sql | 6 +- .../balancer/trades/gnosis/_schema.yml | 149 ++++ .../trades}/gnosis/balancer_gnosis_trades.sql | 0 .../gnosis/balancer_v2_gnosis_trades.sql | 6 +- .../balancer/trades/optimism/_schema.yml | 149 ++++ .../optimism/balancer_optimism_trades.sql | 0 .../optimism/balancer_v2_optimism_trades.sql | 6 +- .../balancer/trades/polygon/_schema.yml | 149 ++++ .../polygon/balancer_polygon_trades.sql | 0 .../polygon/balancer_v2_polygon_trades.sql | 6 +- .../balancer/trades/zkevm/_schema.yml | 110 +++ .../zkevm/balancer_v2_zkevm_trades.sql | 6 +- .../trades}/zkevm/balancer_zkevm_trades.sql | 0 .../balancer/vebal/ethereum/_schema.yml | 91 +++ .../balancer_ethereum_vebal_balances_day.sql | 7 +- .../balancer_ethereum_vebal_slopes.sql | 9 +- .../balancer_ethereum_vebal_votes.sql | 8 +- .../arbitrum/balancer_arbitrum_schema.yml | 432 ------------ .../balancer_avalanche_c_schema.yml | 405 ----------- models/balancer/balancer_schema.yml | 365 ---------- models/balancer/base/balancer_base_schema.yml | 405 ----------- .../ethereum/balancer_ethereum_schema.yml | 665 ------------------ .../gnosis/balancer_gnosis_schema.yml | 404 ----------- .../optimism/balancer_optimism_schema.yml | 464 ------------ .../polygon/balancer_polygon_schema.yml | 454 ------------ .../balancer/zkevm/balancer_zkevm_schema.yml | 431 ------------ 226 files changed, 7748 insertions(+), 4295 deletions(-) create mode 100644 macros/models/_project/balancer/balancer_pool_token_supply_changes_daily_agg_macro.sql create mode 100644 macros/models/_project/balancer/balancer_pool_token_supply_changes_macro.sql create mode 100644 macros/models/_project/balancer/balancer_token_balance_changes_daily_agg_macro.sql create mode 100644 macros/models/_project/balancer/balancer_token_balance_changes_macro.sql create mode 100644 models/_project/balancer/balances/_schema.yml create mode 100644 models/_project/balancer/balances/arbitrum/_schema.yml create mode 100644 models/_project/balancer/balances/arbitrum/balancer_v2_arbitrum_token_balance_changes.sql create mode 100644 models/_project/balancer/balances/arbitrum/balancer_v2_arbitrum_token_balance_changes_daily.sql create mode 100644 models/_project/balancer/balances/avalanche_c/_schema.yml create mode 100644 models/_project/balancer/balances/avalanche_c/balancer_v2_avalanche_c_token_balance_changes.sql create mode 100644 models/_project/balancer/balances/avalanche_c/balancer_v2_avalanche_c_token_balance_changes_daily.sql create mode 100644 models/_project/balancer/balances/balancer_token_balance_changes.sql create mode 100644 models/_project/balancer/balances/balancer_token_balance_changes_daily.sql create mode 100644 models/_project/balancer/balances/base/_schema.yml create mode 100644 models/_project/balancer/balances/base/balancer_v2_base_token_balance_changes.sql create mode 100644 models/_project/balancer/balances/base/balancer_v2_base_token_balance_changes_daily.sql create mode 100644 models/_project/balancer/balances/ethereum/_schema.yml rename models/{balancer => _project/balancer/balances}/ethereum/balancer_ethereum_balances.sql (88%) create mode 100644 models/_project/balancer/balances/ethereum/balancer_v2_ethereum_token_balance_changes.sql create mode 100644 models/_project/balancer/balances/ethereum/balancer_v2_ethereum_token_balance_changes_daily.sql create mode 100644 models/_project/balancer/balances/gnosis/_schema.yml create mode 100644 models/_project/balancer/balances/gnosis/balancer_v2_gnosis_token_balance_changes.sql create mode 100644 models/_project/balancer/balances/gnosis/balancer_v2_gnosis_token_balance_changes_daily.sql create mode 100644 models/_project/balancer/balances/optimism/_schema.yml create mode 100644 models/_project/balancer/balances/optimism/balancer_v2_optimism_token_balance_changes.sql create mode 100644 models/_project/balancer/balances/optimism/balancer_v2_optimism_token_balance_changes_daily.sql create mode 100644 models/_project/balancer/balances/polygon/_schema.yml create mode 100644 models/_project/balancer/balances/polygon/balancer_v2_polygon_token_balance_changes.sql create mode 100644 models/_project/balancer/balances/polygon/balancer_v2_polygon_token_balance_changes_daily.sql create mode 100644 models/_project/balancer/balances/zkevm/_schema.yml create mode 100644 models/_project/balancer/balances/zkevm/balancer_v2_zkevm_token_balance_changes.sql create mode 100644 models/_project/balancer/balances/zkevm/balancer_v2_zkevm_token_balance_changes_daily.sql create mode 100644 models/_project/balancer/bpt/_schema.yml create mode 100644 models/_project/balancer/bpt/arbitrum/_schema.yml rename models/{balancer => _project/balancer/bpt}/arbitrum/balancer_v2_arbitrum_bpt_prices.sql (100%) rename models/{balancer => _project/balancer/bpt}/arbitrum/balancer_v2_arbitrum_bpt_supply.sql (100%) create mode 100644 models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_bpt_supply_changes.sql create mode 100644 models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_bpt_supply_changes_daily.sql rename models/{balancer => _project/balancer/bpt}/arbitrum/balancer_v2_arbitrum_transfers_bpt.sql (100%) create mode 100644 models/_project/balancer/bpt/avalanche_c/_schema.yml rename models/{balancer => _project/balancer/bpt}/avalanche_c/balancer_v2_avalanche_c_bpt_prices.sql (100%) rename models/{balancer => _project/balancer/bpt}/avalanche_c/balancer_v2_avalanche_c_bpt_supply.sql (100%) create mode 100644 models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_bpt_supply_changes.sql create mode 100644 models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_bpt_supply_changes_daily.sql rename models/{balancer => _project/balancer/bpt}/avalanche_c/balancer_v2_avalanche_c_transfers_bpt.sql (100%) rename models/{balancer => _project/balancer/bpt}/balancer_bpt_prices.sql (69%) rename models/{balancer => _project/balancer/bpt}/balancer_bpt_supply.sql (68%) create mode 100644 models/_project/balancer/bpt/balancer_bpt_supply_changes.sql create mode 100644 models/_project/balancer/bpt/balancer_bpt_supply_changes_daily.sql rename models/{balancer => _project/balancer/bpt}/balancer_transfers_bpt.sql (70%) create mode 100644 models/_project/balancer/bpt/base/_schema.yml rename models/{balancer => _project/balancer/bpt}/base/balancer_v2_base_bpt_prices.sql (100%) rename models/{balancer => _project/balancer/bpt}/base/balancer_v2_base_bpt_supply.sql (100%) create mode 100644 models/_project/balancer/bpt/base/balancer_v2_base_bpt_supply_changes.sql create mode 100644 models/_project/balancer/bpt/base/balancer_v2_base_bpt_supply_changes_daily.sql rename models/{balancer => _project/balancer/bpt}/base/balancer_v2_base_transfers_bpt.sql (100%) create mode 100644 models/_project/balancer/bpt/ethereum/_schema.yml rename models/{balancer => _project/balancer/bpt}/ethereum/balancer_v2_ethereum_bpt_prices.sql (100%) rename models/{balancer => _project/balancer/bpt}/ethereum/balancer_v2_ethereum_bpt_supply.sql (100%) create mode 100644 models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_bpt_supply_changes.sql create mode 100644 models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_bpt_supply_changes_daily.sql rename models/{balancer => _project/balancer/bpt}/ethereum/balancer_v2_ethereum_transfers_bpt.sql (100%) create mode 100644 models/_project/balancer/bpt/gnosis/_schema.yml rename models/{balancer => _project/balancer/bpt}/gnosis/balancer_v2_gnosis_bpt_prices.sql (100%) rename models/{balancer => _project/balancer/bpt}/gnosis/balancer_v2_gnosis_bpt_supply.sql (100%) create mode 100644 models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_bpt_supply_changes.sql create mode 100644 models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_bpt_supply_changes_daily.sql rename models/{balancer => _project/balancer/bpt}/gnosis/balancer_v2_gnosis_transfers_bpt.sql (100%) create mode 100644 models/_project/balancer/bpt/optimism/_schema.yml rename models/{balancer => _project/balancer/bpt}/optimism/balancer_v2_optimism_bpt_prices.sql (100%) rename models/{balancer => _project/balancer/bpt}/optimism/balancer_v2_optimism_bpt_supply.sql (100%) create mode 100644 models/_project/balancer/bpt/optimism/balancer_v2_optimism_bpt_supply_changes.sql create mode 100644 models/_project/balancer/bpt/optimism/balancer_v2_optimism_bpt_supply_changes_daily.sql rename models/{balancer => _project/balancer/bpt}/optimism/balancer_v2_optimism_transfers_bpt.sql (100%) create mode 100644 models/_project/balancer/bpt/polygon/_schema.yml rename models/{balancer => _project/balancer/bpt}/polygon/balancer_v2_polygon_bpt_prices.sql (100%) rename models/{balancer => _project/balancer/bpt}/polygon/balancer_v2_polygon_bpt_supply.sql (100%) create mode 100644 models/_project/balancer/bpt/polygon/balancer_v2_polygon_bpt_supply_changes.sql create mode 100644 models/_project/balancer/bpt/polygon/balancer_v2_polygon_bpt_supply_changes_daily.sql rename models/{balancer => _project/balancer/bpt}/polygon/balancer_v2_polygon_transfers_bpt.sql (100%) create mode 100644 models/_project/balancer/bpt/zkevm/_schema.yml rename models/{balancer => _project/balancer/bpt}/zkevm/balancer_v2_zkevm_bpt_prices.sql (100%) rename models/{balancer => _project/balancer/bpt}/zkevm/balancer_v2_zkevm_bpt_supply.sql (100%) create mode 100644 models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_bpt_supply_changes.sql create mode 100644 models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_bpt_supply_changes_daily.sql rename models/{balancer => _project/balancer/bpt}/zkevm/balancer_v2_zkevm_transfers_bpt.sql (100%) create mode 100644 models/_project/balancer/flashloans/_schema.yml create mode 100644 models/_project/balancer/flashloans/arbitrum/_schema.yml rename models/{balancer => _project/balancer/flashloans}/arbitrum/balancer_v2_arbitrum_flashloans.sql (88%) create mode 100644 models/_project/balancer/flashloans/avalanche_c/_schema.yml rename models/{balancer => _project/balancer/flashloans}/avalanche_c/balancer_v2_avalanche_c_flashloans.sql (88%) rename models/{balancer => _project/balancer/flashloans}/balancer_flashloans.sql (69%) create mode 100644 models/_project/balancer/flashloans/base/_schema.yml rename models/{balancer => _project/balancer/flashloans}/base/balancer_v2_base_flashloans.sql (88%) create mode 100644 models/_project/balancer/flashloans/ethereum/_schema.yml rename models/{balancer => _project/balancer/flashloans}/ethereum/balancer_v2_ethereum_flashloans.sql (88%) create mode 100644 models/_project/balancer/flashloans/gnosis/_schema.yml rename models/{balancer => _project/balancer/flashloans}/gnosis/balancer_v2_gnosis_flashloans.sql (88%) create mode 100644 models/_project/balancer/flashloans/optimism/_schema.yml rename models/{balancer => _project/balancer/flashloans}/optimism/balancer_v2_optimism_flashloans.sql (88%) create mode 100644 models/_project/balancer/flashloans/polygon/_schema.yml rename models/{balancer => _project/balancer/flashloans}/polygon/balancer_v2_polygon_flashloans.sql (88%) create mode 100644 models/_project/balancer/flashloans/zkevm/_schema.yml rename models/{balancer => _project/balancer/flashloans}/zkevm/balancer_v2_zkevm_flashloans.sql (88%) create mode 100644 models/_project/balancer/liquidity/_schema.yml create mode 100644 models/_project/balancer/liquidity/arbitrum/_schema.yml rename models/{balancer => _project/balancer/liquidity}/arbitrum/balancer_v2_arbitrum_liquidity.sql (52%) create mode 100644 models/_project/balancer/liquidity/avalanche_c/_schema.yml rename models/{balancer => _project/balancer/liquidity}/avalanche_c/balancer_v2_avalanche_c_liquidity.sql (53%) rename models/{balancer => _project/balancer/liquidity}/balancer_liquidity.sql (74%) create mode 100644 models/_project/balancer/liquidity/base/_schema.yml rename models/{balancer => _project/balancer/liquidity}/base/balancer_v2_base_liquidity.sql (51%) create mode 100644 models/_project/balancer/liquidity/ethereum/_schema.yml rename models/{balancer => _project/balancer/liquidity}/ethereum/balancer_v1_ethereum_liquidity.sql (92%) rename models/{balancer => _project/balancer/liquidity}/ethereum/balancer_v2_ethereum_liquidity.sql (52%) create mode 100644 models/_project/balancer/liquidity/gnosis/_schema.yml rename models/{balancer => _project/balancer/liquidity}/gnosis/balancer_v2_gnosis_liquidity.sql (51%) create mode 100644 models/_project/balancer/liquidity/optimism/_schema.yml rename models/{balancer => _project/balancer/liquidity}/optimism/balancer_v2_optimism_liquidity.sql (52%) create mode 100644 models/_project/balancer/liquidity/polygon/_schema.yml rename models/{balancer => _project/balancer/liquidity}/polygon/balancer_v2_polygon_liquidity.sql (52%) create mode 100644 models/_project/balancer/liquidity/zkevm/_schema.yml rename models/{balancer => _project/balancer/liquidity}/zkevm/balancer_v2_zkevm_liquidity.sql (51%) create mode 100644 models/_project/balancer/pools/_schema.yml create mode 100644 models/_project/balancer/pools/arbitrum/_schema.yml rename models/{balancer => _project/balancer/pools}/arbitrum/balancer_arbitrum_pools_tokens_weights.sql (100%) rename models/{balancer => _project/balancer/pools}/arbitrum/balancer_v2_arbitrum_pools_fees.sql (75%) rename models/{balancer => _project/balancer/pools}/arbitrum/balancer_v2_arbitrum_pools_tokens_weights.sql (99%) create mode 100644 models/_project/balancer/pools/avalanche_c/_schema.yml rename models/{balancer => _project/balancer/pools}/avalanche_c/balancer_avalanche_c_pools_tokens_weights.sql (100%) rename models/{balancer => _project/balancer/pools}/avalanche_c/balancer_v2_avalanche_c_pools_fees.sql (77%) rename models/{balancer => _project/balancer/pools}/avalanche_c/balancer_v2_avalanche_c_pools_tokens_weights.sql (99%) rename models/{balancer => _project/balancer/pools}/balancer_gauge_mappings.sql (78%) rename models/{balancer => _project/balancer/pools}/balancer_pools_fees.sql (69%) rename models/{balancer => _project/balancer/pools}/balancer_pools_metrics_daily.sql (100%) rename models/{balancer => _project/balancer/pools}/balancer_pools_tokens_weights.sql (71%) create mode 100644 models/_project/balancer/pools/base/_schema.yml rename models/{balancer => _project/balancer/pools}/base/balancer_base_pools_tokens_weights.sql (100%) rename models/{balancer => _project/balancer/pools}/base/balancer_v2_base_pools_fees.sql (77%) rename models/{balancer => _project/balancer/pools}/base/balancer_v2_base_pools_tokens_weights.sql (99%) create mode 100644 models/_project/balancer/pools/ethereum/_schema.yml rename models/{balancer => _project/balancer/pools}/ethereum/balancer_ethereum_pools_tokens_weights.sql (100%) rename models/{balancer => _project/balancer/pools}/ethereum/balancer_v1_ethereum_pools_tokens_weights.sql (93%) rename models/{balancer => _project/balancer/pools}/ethereum/balancer_v2_ethereum_lbps.sql (100%) rename models/{balancer => _project/balancer/pools}/ethereum/balancer_v2_ethereum_pools_fees.sql (78%) rename models/{balancer => _project/balancer/pools}/ethereum/balancer_v2_ethereum_pools_tokens_weights.sql (99%) create mode 100644 models/_project/balancer/pools/gnosis/_schema.yml rename models/{balancer => _project/balancer/pools}/gnosis/balancer_gnosis_pools_tokens_weights.sql (100%) rename models/{balancer => _project/balancer/pools}/gnosis/balancer_v2_gnosis_pools_fees.sql (77%) rename models/{balancer => _project/balancer/pools}/gnosis/balancer_v2_gnosis_pools_tokens_weights.sql (99%) create mode 100644 models/_project/balancer/pools/optimism/_schema.yml rename models/{balancer => _project/balancer/pools}/optimism/balancer_optimism_gauge_mappings.sql (87%) rename models/{balancer => _project/balancer/pools}/optimism/balancer_optimism_pools_tokens_weights.sql (86%) rename models/{balancer => _project/balancer/pools}/optimism/balancer_v2_optimism_pools_fees.sql (77%) rename models/{balancer => _project/balancer/pools}/optimism/balancer_v2_optimism_pools_tokens_weights.sql (99%) create mode 100644 models/_project/balancer/pools/polygon/_schema.yml rename models/{balancer => _project/balancer/pools}/polygon/balancer_polygon_pools_tokens_weights.sql (100%) rename models/{balancer => _project/balancer/pools}/polygon/balancer_v2_polygon_lbps.sql (100%) rename models/{balancer => _project/balancer/pools}/polygon/balancer_v2_polygon_pools_fees.sql (77%) rename models/{balancer => _project/balancer/pools}/polygon/balancer_v2_polygon_pools_tokens_weights.sql (99%) create mode 100644 models/_project/balancer/pools/zkevm/_schema.yml rename models/{balancer => _project/balancer/pools}/zkevm/balancer_v2_zkevm_pools_fees.sql (82%) rename models/{balancer => _project/balancer/pools}/zkevm/balancer_v2_zkevm_pools_tokens_weights.sql (100%) rename models/{balancer => _project/balancer/pools}/zkevm/balancer_zkevm_pools_tokens_weights.sql (100%) create mode 100644 models/_project/balancer/protocol_fee/_schema.yml create mode 100644 models/_project/balancer/protocol_fee/arbitrum/_schema.yml rename models/{balancer => _project/balancer/protocol_fee}/arbitrum/balancer_v2_arbitrum_protocol_fee.sql (100%) create mode 100644 models/_project/balancer/protocol_fee/avalanche_c/_schema.yml rename models/{balancer => _project/balancer/protocol_fee}/avalanche_c/balancer_v2_avalanche_c_protocol_fee.sql (100%) rename models/{balancer => _project/balancer/protocol_fee}/balancer_protocol_fee.sql (75%) create mode 100644 models/_project/balancer/protocol_fee/base/_schema.yml rename models/{balancer => _project/balancer/protocol_fee}/base/balancer_v2_base_protocol_fee.sql (100%) create mode 100644 models/_project/balancer/protocol_fee/ethereum/_schema.yml rename models/{balancer => _project/balancer/protocol_fee}/ethereum/balancer_v2_ethereum_protocol_fee.sql (100%) create mode 100644 models/_project/balancer/protocol_fee/gnosis/_schema.yml rename models/{balancer => _project/balancer/protocol_fee}/gnosis/balancer_v2_gnosis_protocol_fee.sql (100%) create mode 100644 models/_project/balancer/protocol_fee/optimism/_schema.yml rename models/{balancer => _project/balancer/protocol_fee}/optimism/balancer_v2_optimism_protocol_fee.sql (100%) create mode 100644 models/_project/balancer/protocol_fee/polygon/_schema.yml rename models/{balancer => _project/balancer/protocol_fee}/polygon/balancer_v2_polygon_protocol_fee.sql (100%) create mode 100644 models/_project/balancer/protocol_fee/zkevm/_schema.yml rename models/{balancer => _project/balancer/protocol_fee}/zkevm/balancer_v2_zkevm_protocol_fee.sql (100%) create mode 100644 models/_project/balancer/support/_schema.yml rename models/{balancer => _project/balancer/support}/balancer_single_recipient_gauges.sql (100%) rename models/{balancer => _project/balancer/support}/balancer_token_whitelist.sql (100%) create mode 100644 models/_project/balancer/trades/arbitrum/_schema.yml rename models/{balancer => _project/balancer/trades}/arbitrum/balancer_arbitrum_trades.sql (100%) rename models/{balancer => _project/balancer/trades}/arbitrum/balancer_v2_arbitrum_trades.sql (94%) create mode 100644 models/_project/balancer/trades/avalanche_c/_schema.yml rename models/{balancer => _project/balancer/trades}/avalanche_c/balancer_avalanche_c_trades.sql (100%) rename models/{balancer => _project/balancer/trades}/avalanche_c/balancer_v2_avalanche_c_trades.sql (94%) rename models/_project/balancer/{ => trades}/balancer_trades.sql (100%) create mode 100644 models/_project/balancer/trades/base/_schema.yml rename models/{balancer => _project/balancer/trades}/base/balancer_base_trades.sql (100%) rename models/{balancer => _project/balancer/trades}/base/balancer_v2_base_trades.sql (94%) create mode 100644 models/_project/balancer/trades/ethereum/_schema.yml rename models/{balancer => _project/balancer/trades}/ethereum/balancer_ethereum_trades.sql (100%) rename models/{balancer => _project/balancer/trades}/ethereum/balancer_v1_ethereum_trades.sql (100%) rename models/{balancer => _project/balancer/trades}/ethereum/balancer_v2_ethereum_trades.sql (94%) create mode 100644 models/_project/balancer/trades/gnosis/_schema.yml rename models/{balancer => _project/balancer/trades}/gnosis/balancer_gnosis_trades.sql (100%) rename models/{balancer => _project/balancer/trades}/gnosis/balancer_v2_gnosis_trades.sql (94%) create mode 100644 models/_project/balancer/trades/optimism/_schema.yml rename models/{balancer => _project/balancer/trades}/optimism/balancer_optimism_trades.sql (100%) rename models/{balancer => _project/balancer/trades}/optimism/balancer_v2_optimism_trades.sql (94%) create mode 100644 models/_project/balancer/trades/polygon/_schema.yml rename models/{balancer => _project/balancer/trades}/polygon/balancer_polygon_trades.sql (100%) rename models/{balancer => _project/balancer/trades}/polygon/balancer_v2_polygon_trades.sql (94%) create mode 100644 models/_project/balancer/trades/zkevm/_schema.yml rename models/{balancer => _project/balancer/trades}/zkevm/balancer_v2_zkevm_trades.sql (94%) rename models/{balancer => _project/balancer/trades}/zkevm/balancer_zkevm_trades.sql (100%) create mode 100644 models/_project/balancer/vebal/ethereum/_schema.yml rename models/{balancer => _project/balancer/vebal}/ethereum/balancer_ethereum_vebal_balances_day.sql (94%) rename models/{balancer => _project/balancer/vebal}/ethereum/balancer_ethereum_vebal_slopes.sql (93%) rename models/{balancer => _project/balancer/vebal}/ethereum/balancer_ethereum_vebal_votes.sql (92%) delete mode 100644 models/balancer/arbitrum/balancer_arbitrum_schema.yml delete mode 100644 models/balancer/avalanche_c/balancer_avalanche_c_schema.yml delete mode 100644 models/balancer/balancer_schema.yml delete mode 100644 models/balancer/base/balancer_base_schema.yml delete mode 100644 models/balancer/ethereum/balancer_ethereum_schema.yml delete mode 100644 models/balancer/gnosis/balancer_gnosis_schema.yml delete mode 100644 models/balancer/optimism/balancer_optimism_schema.yml delete mode 100644 models/balancer/polygon/balancer_polygon_schema.yml delete mode 100644 models/balancer/zkevm/balancer_zkevm_schema.yml diff --git a/dbt_project.yml b/dbt_project.yml index c73e8699cff..91320626953 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -71,19 +71,6 @@ models: optimism: +schema: aave_optimism - balancer: - +schema: balancer - arbitrum: - +schema: balancer_arbitrum - ethereum: - +schema: balancer_ethereum - polygon: - +schema: balancer_polygon - optimism: - +schema: balancer_optimism - gnosis: - +schema: balancer_gnosis - ens: +schema: ens ethereum: diff --git a/macros/models/_project/balancer/balancer_bpt_supply_macro.sql b/macros/models/_project/balancer/balancer_bpt_supply_macro.sql index 60cf5a6e4bc..1b1dab0a80a 100644 --- a/macros/models/_project/balancer/balancer_bpt_supply_macro.sql +++ b/macros/models/_project/balancer/balancer_bpt_supply_macro.sql @@ -79,12 +79,12 @@ WITH pool_labels AS ( joins AS ( SELECT DATE_TRUNC('day', evt_block_time) AS block_date, - tokenOut AS token, + tokenOut, pool_type, CASE WHEN pool_type IN ('weighted') THEN 0 ELSE SUM(amountOut / POWER(10, 18)) - END AS amount + END AS ajoins FROM {{ source('balancer_v2_' + blockchain, 'Vault_evt_Swap') }} LEFT JOIN pool_labels ON BYTEARRAY_SUBSTRING(poolId, 1, 20) = address WHERE tokenOut = BYTEARRAY_SUBSTRING(poolId, 1, 20) @@ -94,37 +94,25 @@ WITH pool_labels AS ( exits AS ( SELECT DATE_TRUNC('day', evt_block_time) AS block_date, - tokenIn AS token, + tokenIn, pool_type, CASE WHEN pool_type IN ('weighted') THEN 0 - ELSE SUM( -amountIn / POWER(10, 18)) - END AS amount + ELSE SUM(amountIn / POWER(10, 18)) + END AS aexits FROM {{ source('balancer_v2_' + blockchain, 'Vault_evt_Swap') }} LEFT JOIN pool_labels ON BYTEARRAY_SUBSTRING(poolId, 1, 20) = address WHERE tokenIn = BYTEARRAY_SUBSTRING(poolId, 1, 20) GROUP BY 1, 2, 3 ), - joins_and_exits_1 AS ( - SELECT - * - FROM joins - - UNION ALL - - SELECT - * - FROM exits - ), - joins_and_exits AS ( SELECT - block_date, - token AS bpt, - LEAD(block_date, 1, NOW()) OVER (PARTITION BY token ORDER BY block_date) AS day_of_next_change, - SUM(amount) OVER (PARTITION BY token ORDER BY block_date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS adelta - FROM joins_and_exits_1 + j.block_date, + j.tokenOut AS bpt, + SUM(COALESCE(ajoins, 0) - COALESCE(aexits, 0)) OVER (PARTITION BY j.tokenOut ORDER BY j.block_date ASC) AS adelta + FROM joins j + FULL OUTER JOIN exits e ON j.block_date = e.block_date AND e.tokenIn = j.tokenOut ), calendar AS ( @@ -142,7 +130,7 @@ WITH pool_labels AS ( COALESCE(SUM(b.supply - COALESCE(preminted_bpts, 0) + COALESCE(adelta, 0)),0) AS supply FROM calendar c LEFT JOIN balances b ON b.day <= c.day AND c.day < b.day_of_next_change - LEFT JOIN joins_and_exits j ON j.block_date <= c.day AND c.day < j.day_of_next_change AND b.token = j.bpt + LEFT JOIN joins_and_exits j ON c.day = j.block_date AND b.token = j.bpt LEFT JOIN premints p ON b.token = p.bpt LEFT JOIN pool_labels l ON b.token = l.address WHERE l.pool_type IN ('weighted', 'LBP', 'investment', 'stable', 'linear', 'ECLP', 'managed', 'FX') diff --git a/macros/models/_project/balancer/balancer_pool_token_supply_changes_daily_agg_macro.sql b/macros/models/_project/balancer/balancer_pool_token_supply_changes_daily_agg_macro.sql new file mode 100644 index 00000000000..d94bbccf741 --- /dev/null +++ b/macros/models/_project/balancer/balancer_pool_token_supply_changes_daily_agg_macro.sql @@ -0,0 +1,37 @@ +{% macro + bpt_supply_changes_daily_agg_macro( + blockchain, version + ) +%} +WITH + daily_balance AS ( + SELECT + block_date, + blockchain, + pool_type, + pool_symbol, + token_address, + LEAD(block_date, 1, NOW()) OVER (PARTITION BY token_address ORDER BY block_date) AS day_of_next_change, + SUM(delta_amount) AS daily_amount + FROM {{ ref('balancer_bpt_supply_changes') }} + WHERE blockchain = '{{blockchain}}' + GROUP BY 1, 2, 3, 4, 5 + ), + + calendar AS ( + SELECT date_sequence AS day + FROM unnest(sequence(date('2021-04-21'), date(now()), interval '1' day)) as t(date_sequence) + ) + + SELECT + c.day AS block_date, + '{{blockchain}}' as blockchain, + '{{version}}' AS version, + b.pool_type, + b.pool_symbol, + b.token_address, + b.daily_amount AS daily_delta + FROM calendar c + LEFT JOIN daily_balance b ON b.block_date = c.day + WHERE b.token_address IS NOT NULL + {% endmacro %} \ No newline at end of file diff --git a/macros/models/_project/balancer/balancer_pool_token_supply_changes_macro.sql b/macros/models/_project/balancer/balancer_pool_token_supply_changes_macro.sql new file mode 100644 index 00000000000..5b876cca011 --- /dev/null +++ b/macros/models/_project/balancer/balancer_pool_token_supply_changes_macro.sql @@ -0,0 +1,130 @@ +{% macro + bpt_supply_changes_macro( + blockchain, version + ) +%} +WITH pool_labels AS ( + SELECT + address, + name, + pool_type + FROM {{ ref('labels_balancer_v2_pools') }} + WHERE blockchain = '{{blockchain}}' + ), + + -- Extract mints and burns from transfers + transfers AS ( + SELECT + t.evt_block_time, + t.evt_block_number, + t.evt_tx_hash, + t.evt_index, + t.contract_address AS token, + CASE + WHEN t."from" = 0x0000000000000000000000000000000000000000 + THEN 'mint' + WHEN t.to = 0x0000000000000000000000000000000000000000 + THEN 'burn' + END AS label, + l.pool_type, + l.name, + CASE + WHEN t."from" = 0x0000000000000000000000000000000000000000 + THEN value + WHEN t.to = 0x0000000000000000000000000000000000000000 + THEN - value + ELSE 0 + END AS amount + FROM {{ ref('balancer_transfers_bpt') }} t + LEFT JOIN pool_labels l ON t.contract_address = l.address + WHERE t.blockchain = '{{blockchain}}' + AND t.version = '{{version}}' + {% if is_incremental() %} + AND {{ incremental_predicate('t.evt_block_time') }} + {% endif %} + ), + + -- Calculating Joins(mint) and Exits(burn) via Swap + joins AS ( + SELECT + s.evt_block_time, + s.evt_block_number, + s.evt_tx_hash, + s.evt_index, + s.tokenOut AS token, + 'join' AS label, + l.pool_type, + l.name, + CASE WHEN l.pool_type IN ('weighted') + THEN 0 + ELSE s.amountOut + END AS amount + FROM {{ source('balancer_v2_' + blockchain, 'Vault_evt_Swap') }} s + LEFT JOIN pool_labels l ON BYTEARRAY_SUBSTRING(s.poolId, 1, 20) = l.address + WHERE tokenOut = BYTEARRAY_SUBSTRING(s.poolId, 1, 20) + {% if is_incremental() %} + AND {{ incremental_predicate('s. evt_block_time') }} + {% endif %} + + ), + + exits AS ( + SELECT + s.evt_block_time, + s.evt_block_number, + s.evt_tx_hash, + s.evt_index, + s.tokenIn AS token, + 'exit' AS label, + l.pool_type, + l.name, + CASE WHEN l.pool_type IN ('weighted') + THEN 0 + ELSE - s.amountIn + END AS amount + FROM {{ source('balancer_v2_' + blockchain, 'Vault_evt_Swap') }} s + LEFT JOIN pool_labels l ON BYTEARRAY_SUBSTRING(s.poolId, 1, 20) = l.address + WHERE tokenIn = BYTEARRAY_SUBSTRING(s.poolId, 1, 20) + {% if is_incremental() %} + AND {{ incremental_predicate('s. evt_block_time') }} + {% endif %} + ) + + SELECT + date_trunc('day', evt_block_time) AS block_date, + evt_block_time, + evt_block_number, + '{{blockchain}}' AS blockchain, + evt_tx_hash, + evt_index, + pool_type, + name AS pool_symbol, + '{{version}}' AS version, + label, + token AS token_address, + amount AS delta_amount_raw, + amount / POWER (10, 18) AS delta_amount --18 decimals standard for BPTs + FROM + ( + SELECT + * + FROM joins + + UNION ALL + + SELECT + * + FROM exits + + UNION ALL + + SELECT + * + FROM transfers + WHERE label IS NOT NULL + ) + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + + {% endmacro %} \ No newline at end of file diff --git a/macros/models/_project/balancer/balancer_token_balance_changes_daily_agg_macro.sql b/macros/models/_project/balancer/balancer_token_balance_changes_daily_agg_macro.sql new file mode 100644 index 00000000000..7500f5d7e82 --- /dev/null +++ b/macros/models/_project/balancer/balancer_token_balance_changes_daily_agg_macro.sql @@ -0,0 +1,184 @@ +{% macro + balancer_token_balance_changes_daily_agg_macro( + blockchain, version + ) +%} +WITH + prices AS ( + SELECT + date_trunc('day', minute) AS day, + contract_address AS token, + decimals, + AVG(price) AS price + FROM {{ source('prices', 'usd') }} + WHERE blockchain = '{{blockchain}}' + {% if is_incremental() %} + WHERE {{ incremental_predicate('minute') }} + {% endif %} + GROUP BY 1, 2, 3 + ), + + dex_prices_1 AS ( + SELECT + date_trunc('day', HOUR) AS DAY, + contract_address AS token, + approx_percentile(median_price, 0.5) AS price, + sum(sample_size) AS sample_size + FROM {{ ref('dex_prices') }} + {% if is_incremental() %} + WHERE {{ incremental_predicate('hour') }} + {% endif %} + GROUP BY 1, 2 + HAVING sum(sample_size) > 3 + ), + + dex_prices_2 AS( + SELECT + day, + token, + price, + lag(price) OVER(PARTITION BY token ORDER BY day) AS previous_price + FROM dex_prices_1 + ), + + dex_prices AS ( + SELECT + day, + token, + price, + LEAD(DAY, 1, NOW()) OVER (PARTITION BY token ORDER BY DAY) AS day_of_next_change + FROM dex_prices_2 + WHERE (price < previous_price * 1e4 AND price > previous_price / 1e4) + ), + + bpt_prices AS( + SELECT DISTINCT + day, + contract_address AS token, + decimals, + bpt_price + FROM {{ ref('balancer_bpt_prices') }} + WHERE blockchain = '{{blockchain}}' + {% if is_incremental() %} + AND {{ incremental_predicate('day') }} + {% endif %} + AND version = '{{version}}' + ), + + eth_prices AS ( + SELECT + DATE_TRUNC('day', minute) as day, + AVG(price) as eth_price + FROM {{ source('prices', 'usd') }} + WHERE symbol = 'ETH' + {% if is_incremental() %} + WHERE {{ incremental_predicate('minute') }} + {% endif %} + GROUP BY 1 + ), + + gyro_prices AS ( + SELECT + token_address, + decimals, + price + FROM {{ ref('gyroscope_gyro_tokens') }} + WHERE blockchain = '{{blockchain}}' + ), + + daily_balance AS ( + SELECT + block_date, + pool_id, + pool_symbol, + pool_type, + token_address, + token_symbol, + LEAD(block_date, 1, NOW()) OVER (PARTITION BY token_address, pool_id ORDER BY block_date) AS day_of_next_change, + SUM(delta_amount) AS daily_amount + FROM {{ ref('balancer_token_balance_changes') }} + WHERE blockchain = '{{blockchain}}' + GROUP BY 1, 2, 3, 4, 5, 6 + ), + + calendar AS ( + SELECT date_sequence AS day + FROM unnest(sequence(date('2021-04-21'), date(now()), interval '1' day)) as t(date_sequence) + ), + + daily_usd_balance AS ( + SELECT + c.day AS block_date, + '{{blockchain}}"' as blockchain, + b.pool_id, + b.pool_symbol, + b.pool_type, + b.token_address, + b.token_symbol, + daily_amount, + daily_amount * COALESCE(p1.price, p2.price, p3.bpt_price, p4.price, 0) AS daily_amount_usd + FROM calendar c + LEFT JOIN daily_balance b ON b.block_date <= c.day + AND c.day < b.day_of_next_change + LEFT JOIN prices p1 ON p1.day = b.block_date + AND p1.token = b.token_address + LEFT JOIN dex_prices p2 ON p2.day <= c.day + AND c.day < p2.day_of_next_change + AND p2.token = b.token_address + LEFT JOIN bpt_prices p3 ON p3.day = b.block_date + AND p3.token = b.token_address + LEFT JOIN gyro_prices p4 ON p4.token_address = b.token_address + WHERE b.token_address != BYTEARRAY_SUBSTRING(b.pool_id, 1, 20) + ), + + weighted_pool_amount_estimates AS ( + SELECT + b.block_date, + b.pool_id, + q.name, + pool_type, + ROW_NUMBER() OVER (PARTITION BY b.block_date, b.pool_id ORDER BY SUM(b.daily_amount_usd) ASC) AS pricing_count, --to avoid double count in pools with multiple pricing assets + SUM(b.daily_amount_usd) / COALESCE(SUM(w.normalized_weight), 1) AS weighted_daily_amount_usd + FROM daily_usd_balance b + LEFT JOIN {{ ref('balancer_pools_tokens_weights') }} w ON b.pool_id = w.pool_id + AND b.token_address = w.token_address + AND b.daily_amount_usd > 0 + LEFT JOIN {{ ref('balancer_token_whitelist') }} q ON b.token_address = q.address + AND b.blockchain = q.chain + WHERE q.name IS NOT NULL + AND b.pool_type = 'weighted' -- filters for weighted pools with pricing assets + AND w.blockchain = '{{blockchain}}' + AND w.version = '2' + GROUP BY 1, 2, 3, 4 + ), + + weighted_pool_amount_estimates_2 AS( + SELECT e.block_date, + e.pool_id, + SUM(e.weighted_daily_amount_usd) / MAX(e.pricing_count) AS weighted_daily_amount_usd + FROM weighted_pool_amount_estimates e + GROUP BY 1,2 + ) + + SELECT + c.block_date, + c.pool_id, + BYTEARRAY_SUBSTRING(c.pool_id, 1, 20) AS pool_address, + c.pool_symbol, + '2' AS version, + 'ethereum' AS blockchain, + c.pool_type, + c.token_address, + c.token_symbol, + c.daily_amount AS daily_delta, + COALESCE(b.weighted_daily_amount_usd * w.normalized_weight, c.daily_amount_usd) AS daily_delta_usd, + COALESCE(b.weighted_daily_amount_usd * w.normalized_weight, c.daily_amount_usd)/e.eth_price AS daily_delta_eth + FROM daily_usd_balance c + FULL OUTER JOIN weighted_pool_amount_estimates_2 b ON c.block_date = b.block_date + AND c.pool_id = b.pool_id + LEFT JOIN {{ ref('balancer_pools_tokens_weights') }} w ON b.pool_id = w.pool_id + AND w.blockchain = 'ethereum' + AND w.version = '2' + AND w.token_address = c.token_address + LEFT JOIN eth_prices e ON e.day = c.block_date + {% endmacro %} \ No newline at end of file diff --git a/macros/models/_project/balancer/balancer_token_balance_changes_macro.sql b/macros/models/_project/balancer/balancer_token_balance_changes_macro.sql new file mode 100644 index 00000000000..b16c9bf038e --- /dev/null +++ b/macros/models/_project/balancer/balancer_token_balance_changes_macro.sql @@ -0,0 +1,169 @@ +{% macro + balancer_token_balance_changes_macro( + blockchain, version + ) +%} +WITH pool_labels AS ( + SELECT + address AS pool_id, + name AS pool_symbol, + pool_type + FROM {{ ref('labels_balancer_v2_pools') }} + WHERE blockchain = '{{blockchain}}' + ), + + swaps_changes AS ( + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool_id, + token, + SUM(COALESCE(delta, INT256 '0')) AS delta + FROM + ( + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + poolId AS pool_id, + tokenIn AS token, + CAST(amountIn as int256) AS delta + FROM {{ source('balancer_v2_' + blockchain, 'Vault_evt_Swap') }} + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + + UNION ALL + + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + poolId AS pool_id, + tokenOut AS token, + -CAST(amountOut AS int256) AS delta + FROM {{ source('balancer_v2_' + blockchain, 'Vault_evt_Swap') }} + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + ) swaps + GROUP BY 1, 2, 3, 4, 5, 6 + ), + + zipped_balance_changes AS ( + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + poolId AS pool_id, + t.tokens, + d.deltas, + p.protocolFeeAmounts + FROM {{ source('balancer_v2_' + blockchain, 'Vault_evt_PoolBalanceChanged') }} + CROSS JOIN UNNEST (tokens) WITH ORDINALITY as t(tokens,i) + CROSS JOIN UNNEST (deltas) WITH ORDINALITY as d(deltas,i) + CROSS JOIN UNNEST (protocolFeeAmounts) WITH ORDINALITY as p(protocolFeeAmounts,i) + WHERE t.i = d.i + AND d.i = p.i + {% if is_incremental() %} + AND {{ incremental_predicate('evt_block_time') }} + {% endif %} + ), + + balances_changes AS ( + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool_id, + tokens AS token, + deltas - CAST(protocolFeeAmounts as int256) AS delta + FROM zipped_balance_changes + ), + + managed_changes AS ( + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + poolId AS pool_id, + token, + cashDelta + managedDelta AS delta + FROM {{ source('balancer_v2_' + blockchain, 'Vault_evt_PoolBalanceManaged') }} + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + ) + + + SELECT + date_trunc('day', b.evt_block_time) AS block_date, + b.evt_block_time, + b.evt_block_number, + '{{blockchain}}' AS blockchain, + b.evt_tx_hash, + b.evt_index, + b.pool_id, + BYTEARRAY_SUBSTRING(b.pool_id, 1, 20) AS pool_address, + p.pool_symbol, + p.pool_type, + '{{version}}' AS version, + b.token AS token_address, + t.symbol AS token_symbol, + b.amount AS delta_amount_raw, + CASE WHEN BYTEARRAY_SUBSTRING(b.pool_id, 1, 20) = b.token + THEN amount / POWER (10, 18) --for Balancer Pool Tokens + ELSE amount / POWER (10, COALESCE(t.decimals, 0)) + END AS delta_amount + FROM + ( + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool_id, + token, + COALESCE(delta, INT256 '0') AS amount + FROM balances_changes + + UNION ALL + + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool_id, + token, + delta AS amount + FROM + swaps_changes + + UNION ALL + + SELECT + evt_block_time, + evt_block_number, + evt_tx_hash, + evt_index, + pool_id, + token, + CAST(delta AS int256) AS amount + FROM managed_changes + ) b + LEFT JOIN {{ source('tokens', 'erc20') }} t ON t.contract_address = b.token + AND blockchain = '{{blockchain}}' + LEFT JOIN pool_labels p ON p.pool_id = BYTEARRAY_SUBSTRING(b.pool_id, 1, 20) + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + + {% endmacro %} \ No newline at end of file diff --git a/models/_project/balancer/balances/_schema.yml b/models/_project/balancer/balances/_schema.yml new file mode 100644 index 00000000000..9d8b84cf3a1 --- /dev/null +++ b/models/_project/balancer/balances/_schema.yml @@ -0,0 +1,98 @@ +version: 2 + +models: + - name: balancer_token_balance_changes + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevm + contributors: viniabussafi + config: + tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - token_address + columns: + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &blockchain + name: blockchain + description: "Blockchain" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction at the time of execution in the original currency" + + - name: balancer_token_balance_changes_daily + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevm + contributors: viniabussafi + config: + tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools, grouped by day. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - pool_id + - token_address + columns: + - *block_date + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - &daily_delta + name: daily_delta + description: "Daily total impact on token balance" + - &daily_delta_usd + name: daily_delta_usd + description: "Daily total impact on token balance, in USD" + - &daily_delta_eth + name: daily_delta_eth + description: "Daily total impact on token balance, in eth" \ No newline at end of file diff --git a/models/_project/balancer/balances/arbitrum/_schema.yml b/models/_project/balancer/balances/arbitrum/_schema.yml new file mode 100644 index 00000000000..ff5e07ed5d8 --- /dev/null +++ b/models/_project/balancer/balances/arbitrum/_schema.yml @@ -0,0 +1,100 @@ +version: 2 + +models: + - name: balancer_v2_arbitrum_token_balance_changes + meta: + blockchain: arbitrum + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['arbitrum', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - token_address + columns: + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &blockchain + name: blockchain + description: "Blockchain" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction at the time of execution in the original currency" + + - name: balancer_v2_arbitrum_token_balance_changes_daily + meta: + blockchain: arbitrum + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['arbitrum', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools, grouped by day. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - pool_id + - token_address + columns: + - *block_date + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - &daily_delta + name: daily_delta + description: "Daily total impact on token balance" + - &daily_delta_usd + name: daily_delta_usd + description: "Daily total impact on token balance, in USD" + - &daily_delta_eth + name: daily_delta_eth + description: "Daily total impact on token balance, in eth" \ No newline at end of file diff --git a/models/_project/balancer/balances/arbitrum/balancer_v2_arbitrum_token_balance_changes.sql b/models/_project/balancer/balances/arbitrum/balancer_v2_arbitrum_token_balance_changes.sql new file mode 100644 index 00000000000..ca58f713377 --- /dev/null +++ b/models/_project/balancer/balances/arbitrum/balancer_v2_arbitrum_token_balance_changes.sql @@ -0,0 +1,16 @@ +{% set blockchain = 'arbitrum' %} + +{{ config( + schema = 'balancer_v2_arbitrum', + alias = 'token_balance_changes', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/arbitrum/balancer_v2_arbitrum_token_balance_changes_daily.sql b/models/_project/balancer/balances/arbitrum/balancer_v2_arbitrum_token_balance_changes_daily.sql new file mode 100644 index 00000000000..c35d7b60259 --- /dev/null +++ b/models/_project/balancer/balances/arbitrum/balancer_v2_arbitrum_token_balance_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'arbitrum' %} + +{{ + config( + schema = 'balancer_v2_arbitrum', + alias = 'token_balance_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/avalanche_c/_schema.yml b/models/_project/balancer/balances/avalanche_c/_schema.yml new file mode 100644 index 00000000000..e341729e2fa --- /dev/null +++ b/models/_project/balancer/balances/avalanche_c/_schema.yml @@ -0,0 +1,100 @@ +version: 2 + +models: + - name: balancer_v2_avalanche_c_token_balance_changes + meta: + blockchain: avalanche_c + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['avalanche_c', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - token_address + columns: + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &blockchain + name: blockchain + description: "Blockchain" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction at the time of execution in the original currency" + + - name: balancer_v2_avalanche_c_token_balance_changes_daily + meta: + blockchain: avalanche_c + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['avalanche_c', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools, grouped by day. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - pool_id + - token_address + columns: + - *block_date + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - &daily_delta + name: daily_delta + description: "Daily total impact on token balance" + - &daily_delta_usd + name: daily_delta_usd + description: "Daily total impact on token balance, in USD" + - &daily_delta_eth + name: daily_delta_eth + description: "Daily total impact on token balance, in eth" \ No newline at end of file diff --git a/models/_project/balancer/balances/avalanche_c/balancer_v2_avalanche_c_token_balance_changes.sql b/models/_project/balancer/balances/avalanche_c/balancer_v2_avalanche_c_token_balance_changes.sql new file mode 100644 index 00000000000..ab55e6e99f1 --- /dev/null +++ b/models/_project/balancer/balances/avalanche_c/balancer_v2_avalanche_c_token_balance_changes.sql @@ -0,0 +1,16 @@ +{% set blockchain = 'avalanche_c' %} + +{{ config( + schema = 'balancer_v2_avalanche_c', + alias = 'token_balance_changes', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/avalanche_c/balancer_v2_avalanche_c_token_balance_changes_daily.sql b/models/_project/balancer/balances/avalanche_c/balancer_v2_avalanche_c_token_balance_changes_daily.sql new file mode 100644 index 00000000000..35ed123547e --- /dev/null +++ b/models/_project/balancer/balances/avalanche_c/balancer_v2_avalanche_c_token_balance_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'avalanche_c' %} + +{{ + config( + schema = 'balancer_v2_avalanche_c', + alias = 'token_balance_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/balancer_token_balance_changes.sql b/models/_project/balancer/balances/balancer_token_balance_changes.sql new file mode 100644 index 00000000000..7f531a769f3 --- /dev/null +++ b/models/_project/balancer/balances/balancer_token_balance_changes.sql @@ -0,0 +1,46 @@ +{{ config( + schema = 'balancer', + alias = 'token_balance_changes', + post_hook='{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["viniabussafi"]\') }}' + ) +}} + +{% set balancer_models = [ + ref('balancer_v2_arbitrum_token_balance_changes'), + ref('balancer_v2_avalanche_c_token_balance_changes'), + ref('balancer_v2_base_token_balance_changes'), + ref('balancer_v2_ethereum_token_balance_changes'), + ref('balancer_v2_gnosis_token_balance_changes'), + ref('balancer_v2_optimism_token_balance_changes'), + ref('balancer_v2_polygon_token_balance_changes'), + ref('balancer_v2_zkevm_token_balance_changes') +] %} + +SELECT * +FROM ( + {% for model in balancer_models %} + SELECT + block_date + , evt_block_time + , evt_block_number + , blockchain + , evt_tx_hash + , evt_index + , pool_id + , pool_address + , pool_symbol + , pool_type + , version + , token_address + , token_symbol + , delta_amount_raw + , delta_amount + FROM {{ model }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} +) \ No newline at end of file diff --git a/models/_project/balancer/balances/balancer_token_balance_changes_daily.sql b/models/_project/balancer/balances/balancer_token_balance_changes_daily.sql new file mode 100644 index 00000000000..8e199a25708 --- /dev/null +++ b/models/_project/balancer/balances/balancer_token_balance_changes_daily.sql @@ -0,0 +1,43 @@ +{{ config( + schema = 'balancer', + alias = 'token_balance_changes_daily', + post_hook='{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["viniabussafi"]\') }}' + ) +}} + +{% set balancer_models = [ + ref('balancer_v2_arbitrum_token_balance_changes_daily'), + ref('balancer_v2_avalanche_c_token_balance_changes_daily'), + ref('balancer_v2_base_token_balance_changes_daily'), + ref('balancer_v2_ethereum_token_balance_changes_daily'), + ref('balancer_v2_gnosis_token_balance_changes_daily'), + ref('balancer_v2_optimism_token_balance_changes_daily'), + ref('balancer_v2_polygon_token_balance_changes_daily'), + ref('balancer_v2_zkevm_token_balance_changes_daily') +] %} + +SELECT * +FROM ( + {% for model in balancer_models %} + SELECT + block_date + , pool_id + , pool_address + , pool_symbol + , version + , blockchain + , pool_type + , token_address + , token_symbol + , daily_delta + , daily_delta_usd + , daily_delta_eth + FROM {{ model }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} +) \ No newline at end of file diff --git a/models/_project/balancer/balances/base/_schema.yml b/models/_project/balancer/balances/base/_schema.yml new file mode 100644 index 00000000000..89a11b3e539 --- /dev/null +++ b/models/_project/balancer/balances/base/_schema.yml @@ -0,0 +1,100 @@ +version: 2 + +models: + - name: balancer_v2_base_token_balance_changes + meta: + blockchain: base + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['base', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - token_address + columns: + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &blockchain + name: blockchain + description: "Blockchain" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction at the time of execution in the original currency" + + - name: balancer_v2_base_token_balance_changes_daily + meta: + blockchain: base + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['base', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools, grouped by day. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - pool_id + - token_address + columns: + - *block_date + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - &daily_delta + name: daily_delta + description: "Daily total impact on token balance" + - &daily_delta_usd + name: daily_delta_usd + description: "Daily total impact on token balance, in USD" + - &daily_delta_eth + name: daily_delta_eth + description: "Daily total impact on token balance, in eth" \ No newline at end of file diff --git a/models/_project/balancer/balances/base/balancer_v2_base_token_balance_changes.sql b/models/_project/balancer/balances/base/balancer_v2_base_token_balance_changes.sql new file mode 100644 index 00000000000..1f35750f21d --- /dev/null +++ b/models/_project/balancer/balances/base/balancer_v2_base_token_balance_changes.sql @@ -0,0 +1,16 @@ +{% set blockchain = 'base' %} + +{{ config( + schema = 'balancer_v2_base', + alias = 'token_balance_changes', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/base/balancer_v2_base_token_balance_changes_daily.sql b/models/_project/balancer/balances/base/balancer_v2_base_token_balance_changes_daily.sql new file mode 100644 index 00000000000..fe24b712bee --- /dev/null +++ b/models/_project/balancer/balances/base/balancer_v2_base_token_balance_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'base' %} + +{{ + config( + schema = 'balancer_v2_base', + alias = 'token_balance_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/ethereum/_schema.yml b/models/_project/balancer/balances/ethereum/_schema.yml new file mode 100644 index 00000000000..dab33f52016 --- /dev/null +++ b/models/_project/balancer/balances/ethereum/_schema.yml @@ -0,0 +1,131 @@ +version: 2 + +models: + - name: balancer_ethereum_balances + meta: + blockchain: ethereum + project: balancer + contributors: jacektrocinski, metacrypto, viniabussafi + config: + tags: ['ethereum', 'balancer', 'balances'] + description: > + ERC20 token rolling sum balances on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool + - token + columns: + - &day + name: day + description: "UTC event block time truncated to the day mark" + tests: + - not_null + - &pool + name: pool + description: "Balancer pool contract address" + - &token + name: token + description: "Token contract address" + - &cumulative_amount + name: cumulative_amount + description: "Balance of a token" + + - name: balancer_v2_ethereum_token_balance_changes + meta: + blockchain: ethereum + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['ethereum', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - token_address + columns: + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &evt_block_time + name: evt_block_time + description: "Block time of transfer event" + - &evt_block_number + name: evt_block_number + description: "Block number of transfer event" + - &blockchain + name: blockchain + description: "Blockchain" + - &evt_tx_hash + name: evt_tx_hash + description: "Transaction hash of transfer event" + - &evt_index + name: evt_index + description: "Event index" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction at the time of execution in the original currency" + + - name: balancer_v2_ethereum_token_balance_changes_daily + meta: + blockchain: ethereum + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['ethereum', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools, grouped by day. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - pool_id + - token_address + columns: + - *block_date + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - &daily_delta + name: daily_delta + description: "Daily total impact on token balance" + - &daily_delta_usd + name: daily_delta_usd + description: "Daily total impact on token balance, in USD" + - &daily_delta_eth + name: daily_delta_eth + description: "Daily total impact on token balance, in ETH" \ No newline at end of file diff --git a/models/balancer/ethereum/balancer_ethereum_balances.sql b/models/_project/balancer/balances/ethereum/balancer_ethereum_balances.sql similarity index 88% rename from models/balancer/ethereum/balancer_ethereum_balances.sql rename to models/_project/balancer/balances/ethereum/balancer_ethereum_balances.sql index bddec24d0bf..aa584c6c39d 100644 --- a/models/balancer/ethereum/balancer_ethereum_balances.sql +++ b/models/_project/balancer/balances/ethereum/balancer_ethereum_balances.sql @@ -1,11 +1,11 @@ {{ config( + schema = 'balancer_ethereum', alias = 'balances', - post_hook='{{ expose_spells(\'["ethereum"]\', - "project", - "balancer", - \'["metacrypto", "jacektrocinski", "viniabussafi"]\') }}' + spell_type = "project", + spell_name = "balancer", + contributors = \'["metacrypto", "jacektrocinski", "viniabussafi"]\') }}' )  }} @@ -72,5 +72,4 @@ running_cumulative_balance_by_token AS ( LEFT JOIN cumulative_balance_by_token b ON b.day <= c.day AND c.day < b.day_of_next_change ) -SELECT * FROM running_cumulative_balance_by_token - +SELECT * FROM running_cumulative_balance_by_token \ No newline at end of file diff --git a/models/_project/balancer/balances/ethereum/balancer_v2_ethereum_token_balance_changes.sql b/models/_project/balancer/balances/ethereum/balancer_v2_ethereum_token_balance_changes.sql new file mode 100644 index 00000000000..12b1a61ad46 --- /dev/null +++ b/models/_project/balancer/balances/ethereum/balancer_v2_ethereum_token_balance_changes.sql @@ -0,0 +1,16 @@ +{% set blockchain = 'ethereum' %} + +{{ config( + schema = 'balancer_v2_ethereum', + alias = 'token_balance_changes', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/ethereum/balancer_v2_ethereum_token_balance_changes_daily.sql b/models/_project/balancer/balances/ethereum/balancer_v2_ethereum_token_balance_changes_daily.sql new file mode 100644 index 00000000000..44aeb0ee7b8 --- /dev/null +++ b/models/_project/balancer/balances/ethereum/balancer_v2_ethereum_token_balance_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'ethereum' %} + +{{ + config( + schema = 'balancer_v2_ethereum', + alias = 'token_balance_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/gnosis/_schema.yml b/models/_project/balancer/balances/gnosis/_schema.yml new file mode 100644 index 00000000000..9fdd91e45e3 --- /dev/null +++ b/models/_project/balancer/balances/gnosis/_schema.yml @@ -0,0 +1,100 @@ +version: 2 + +models: + - name: balancer_v2_gnosis_token_balance_changes + meta: + blockchain: gnosis + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['gnosis', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - token_address + columns: + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &blockchain + name: blockchain + description: "Blockchain" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction at the time of execution in the original currency" + + - name: balancer_v2_gnosis_token_balance_changes_daily + meta: + blockchain: gnosis + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['gnosis', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools, grouped by day. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - pool_id + - token_address + columns: + - *block_date + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - &daily_delta + name: daily_delta + description: "Daily total impact on token balance" + - &daily_delta_usd + name: daily_delta_usd + description: "Daily total impact on token balance, in USD" + - &daily_delta_eth + name: daily_delta_eth + description: "Daily total impact on token balance, in eth" \ No newline at end of file diff --git a/models/_project/balancer/balances/gnosis/balancer_v2_gnosis_token_balance_changes.sql b/models/_project/balancer/balances/gnosis/balancer_v2_gnosis_token_balance_changes.sql new file mode 100644 index 00000000000..e3e0177541d --- /dev/null +++ b/models/_project/balancer/balances/gnosis/balancer_v2_gnosis_token_balance_changes.sql @@ -0,0 +1,16 @@ +{% set blockchain = 'gnosis' %} + +{{ config( + schema = 'balancer_v2_gnosis', + alias = 'token_balance_changes', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/gnosis/balancer_v2_gnosis_token_balance_changes_daily.sql b/models/_project/balancer/balances/gnosis/balancer_v2_gnosis_token_balance_changes_daily.sql new file mode 100644 index 00000000000..434e9b096fb --- /dev/null +++ b/models/_project/balancer/balances/gnosis/balancer_v2_gnosis_token_balance_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'gnosis' %} + +{{ + config( + schema = 'balancer_v2_gnosis', + alias = 'token_balance_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/optimism/_schema.yml b/models/_project/balancer/balances/optimism/_schema.yml new file mode 100644 index 00000000000..952aefc44ee --- /dev/null +++ b/models/_project/balancer/balances/optimism/_schema.yml @@ -0,0 +1,100 @@ +version: 2 + +models: + - name: balancer_v2_optimism_token_balance_changes + meta: + blockchain: optimism + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['optimism', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - token_address + columns: + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &blockchain + name: blockchain + description: "Blockchain" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction at the time of execution in the original currency" + + - name: balancer_v2_optimism_token_balance_changes_daily + meta: + blockchain: optimism + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['optimism', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools, grouped by day. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - pool_id + - token_address + columns: + - *block_date + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - &daily_delta + name: daily_delta + description: "Daily total impact on token balance" + - &daily_delta_usd + name: daily_delta_usd + description: "Daily total impact on token balance, in USD" + - &daily_delta_eth + name: daily_delta_eth + description: "Daily total impact on token balance, in eth" \ No newline at end of file diff --git a/models/_project/balancer/balances/optimism/balancer_v2_optimism_token_balance_changes.sql b/models/_project/balancer/balances/optimism/balancer_v2_optimism_token_balance_changes.sql new file mode 100644 index 00000000000..39fd96a795d --- /dev/null +++ b/models/_project/balancer/balances/optimism/balancer_v2_optimism_token_balance_changes.sql @@ -0,0 +1,16 @@ +{% set blockchain = 'optimism' %} + +{{ config( + schema = 'balancer_v2_optimism', + alias = 'token_balance_changes', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/optimism/balancer_v2_optimism_token_balance_changes_daily.sql b/models/_project/balancer/balances/optimism/balancer_v2_optimism_token_balance_changes_daily.sql new file mode 100644 index 00000000000..ac9db7d6bd7 --- /dev/null +++ b/models/_project/balancer/balances/optimism/balancer_v2_optimism_token_balance_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'optimism' %} + +{{ + config( + schema = 'balancer_v2_optimism', + alias = 'token_balance_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/polygon/_schema.yml b/models/_project/balancer/balances/polygon/_schema.yml new file mode 100644 index 00000000000..70c27f9cac4 --- /dev/null +++ b/models/_project/balancer/balances/polygon/_schema.yml @@ -0,0 +1,100 @@ +version: 2 + +models: + - name: balancer_v2_polygon_token_balance_changes + meta: + blockchain: polygon + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['polygon', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - token_address + columns: + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &blockchain + name: blockchain + description: "Blockchain" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction at the time of execution in the original currency" + + - name: balancer_v2_polygon_token_balance_changes_daily + meta: + blockchain: polygon + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['polygon', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools, grouped by day. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - pool_id + - token_address + columns: + - *block_date + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - &daily_delta + name: daily_delta + description: "Daily total impact on token balance" + - &daily_delta_usd + name: daily_delta_usd + description: "Daily total impact on token balance, in USD" + - &daily_delta_eth + name: daily_delta_eth + description: "Daily total impact on token balance, in eth" \ No newline at end of file diff --git a/models/_project/balancer/balances/polygon/balancer_v2_polygon_token_balance_changes.sql b/models/_project/balancer/balances/polygon/balancer_v2_polygon_token_balance_changes.sql new file mode 100644 index 00000000000..efbac69046b --- /dev/null +++ b/models/_project/balancer/balances/polygon/balancer_v2_polygon_token_balance_changes.sql @@ -0,0 +1,16 @@ +{% set blockchain = 'polygon' %} + +{{ config( + schema = 'balancer_v2_polygon', + alias = 'token_balance_changes', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/polygon/balancer_v2_polygon_token_balance_changes_daily.sql b/models/_project/balancer/balances/polygon/balancer_v2_polygon_token_balance_changes_daily.sql new file mode 100644 index 00000000000..fa318aaec80 --- /dev/null +++ b/models/_project/balancer/balances/polygon/balancer_v2_polygon_token_balance_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'polygon' %} + +{{ + config( + schema = 'balancer_v2_polygon', + alias = 'token_balance_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/zkevm/_schema.yml b/models/_project/balancer/balances/zkevm/_schema.yml new file mode 100644 index 00000000000..3fae28a259a --- /dev/null +++ b/models/_project/balancer/balances/zkevm/_schema.yml @@ -0,0 +1,100 @@ +version: 2 + +models: + - name: balancer_v2_zkevm_token_balance_changes + meta: + blockchain: zkevm + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['zkevm', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - token_address + columns: + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &blockchain + name: blockchain + description: "Blockchain" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction at the time of execution in the original currency" + + - name: balancer_v2_zkevm_token_balance_changes_daily + meta: + blockchain: zkevm + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['zkevm', 'bpt', 'supply', 'changes'] + description: > + Token Balance Changes on Balancer Pools, grouped by day. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - pool_id + - token_address + columns: + - *block_date + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - &daily_delta + name: daily_delta + description: "Daily total impact on token balance" + - &daily_delta_usd + name: daily_delta_usd + description: "Daily total impact on token balance, in USD" + - &daily_delta_eth + name: daily_delta_eth + description: "Daily total impact on token balance, in eth" \ No newline at end of file diff --git a/models/_project/balancer/balances/zkevm/balancer_v2_zkevm_token_balance_changes.sql b/models/_project/balancer/balances/zkevm/balancer_v2_zkevm_token_balance_changes.sql new file mode 100644 index 00000000000..80eff1513b7 --- /dev/null +++ b/models/_project/balancer/balances/zkevm/balancer_v2_zkevm_token_balance_changes.sql @@ -0,0 +1,16 @@ +{% set blockchain = 'zkevm' %} + +{{ config( + schema = 'balancer_v2_zkevm', + alias = 'token_balance_changes', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/balances/zkevm/balancer_v2_zkevm_token_balance_changes_daily.sql b/models/_project/balancer/balances/zkevm/balancer_v2_zkevm_token_balance_changes_daily.sql new file mode 100644 index 00000000000..9bd7cabbb72 --- /dev/null +++ b/models/_project/balancer/balances/zkevm/balancer_v2_zkevm_token_balance_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'zkevm' %} + +{{ + config( + schema = 'balancer_v2_zkevm', + alias = 'token_balance_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + balancer_token_balance_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/bpt/_schema.yml b/models/_project/balancer/bpt/_schema.yml new file mode 100644 index 00000000000..4afa2327ca2 --- /dev/null +++ b/models/_project/balancer/bpt/_schema.yml @@ -0,0 +1,176 @@ +version: 2 + +models: + - name: balancer_transfers_bpt + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevmn + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'bpt', 'transfers'] + description: > + Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - evt_tx_hash + - evt_index + - block_date + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'zkevm address for the liquidity pool used in transaction' + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &block_month + name: block_month + description: "UTC event block month of each DEX trade" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &from + name: from + description: 'Address of BPT provider of transfer event' + - &to + name: to + description: 'Address of BPT receiver of transfer event' + - &value + name: value + description: 'Amount of BPT transferred in transfer event' + + - name: balancer_bpt_prices + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevm + sector: dex + contributors: thetroyharris, victorstefenon, viniabussafi + config: + tags: ['balancer', 'amm', 'dex', 'bpt', 'prices', 'ethereum', 'arbitrum', 'optimism', 'polygon', 'gnosis', 'avalanche_c', 'base', 'zkevm'] + description: > + Balancer Pool Token (BPT) hourly median price by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - day + - contract_address + columns: + - *blockchain + - &day + name: day + description: "Block date in UTC" + - *version + - &decimals + name: decimals + description: "Token decimals. 18, by default, on BPTs" + - *contract_address + - &bpt_price + name: bpt_price + description: "Price of the BPT" + + + - name: balancer_bpt_supply + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevm + contributors: thetroyharris, viniabussafi + config: + tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'bpt'] + description: > + The Balancer Pool Token (BPT) supply over time of ComposableStablePools versions 4+ + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - blockchain + - token_address + columns: + - *day + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - *version + - *blockchain + - &token_address + name: token_address + description: "Contract address of the BPT" + - &supply + name: supply + description: "Supply of the BPT, discounted of premints" + + - name: balancer_bpt_supply_changes + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevm + contributors: viniabussafi + config: + tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - label + columns: + - *block_date + - *evt_block_time + - *evt_block_number + - *blockchain + - *evt_tx_hash + - *evt_index + - *pool_type + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - *version + - &label + name: label + description: "Nature of the transaction (Join/Exit via swap or Mint/Burn via transfer)" + - *token_address + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction on token supply at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction on token supply at the time of execution in the original currency" + + + - name: balancer_bpt_supply_changes_daily + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevm + contributors: viniabussafi + config: + tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. grouped by day + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - token_address + columns: + - *block_date + - *blockchain + - *pool_type + - *pool_symbol + - *version + - *token_address + - &daily_delta + name: daily_delta + description: "Daily total impact on BPT supply" \ No newline at end of file diff --git a/models/_project/balancer/bpt/arbitrum/_schema.yml b/models/_project/balancer/bpt/arbitrum/_schema.yml new file mode 100644 index 00000000000..c32bee8b667 --- /dev/null +++ b/models/_project/balancer/bpt/arbitrum/_schema.yml @@ -0,0 +1,178 @@ +version: 2 + +models: + - name: balancer_v2_arbitrum_transfers_bpt + meta: + blockchain: arbitrum + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['arbitrum', 'bpt', 'transfers'] + description: > + Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on Arbitrum. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - evt_tx_hash + - evt_index + - block_date + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'Arbitrum address for the liquidity pool used in transaction' + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &block_month + name: block_month + description: "UTC event block month of each DEX trade" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &from + name: from + description: 'Address of BPT provider of transfer event' + - &to + name: to + description: 'Address of BPT receiver of transfer event' + - &value + name: value + description: 'Amount of BPT transferred in transfer event' + + - name: balancer_v2_arbitrum_bpt_prices + meta: + blockchain: arbitrum + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['arbitrum', 'bpt', 'prices'] + description: > + Balancer Pool Token (BPT) daily price by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - day + - contract_address + columns: + - *blockchain + - &day + name: day + description: "Block date in UTC" + - *version + - &decimals + name: decimals + description: "Token decimals. 18, by default, on BPTs" + - *contract_address + - &bpt_price + name: bpt_price + description: "Price of the BPT" + + - name: balancer_v2_arbitrum_bpt_supply + meta: + blockchain: arbitrum + project: balancer_v2 + contributors: thetroyharris, viniabussafi + config: + tags: ['arbitrum', 'bpt', 'supply'] + description: > + Balancer Pool Token (BPT) supply by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - blockchain + - token_address + columns: + - *day + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - *version + - *blockchain + - &token_address + name: token_address + description: "Contract address of the BPT" + - &supply + name: supply + description: "Supply of the BPT, discounted of premints" + + - name: balancer_v2_arbitrum_bpt_supply_changes + meta: + blockchain: arbitrum + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['arbitrum', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - label + columns: + - *block_date + - *evt_block_time + - *evt_block_number + - *blockchain + - *evt_tx_hash + - *evt_index + - *pool_type + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - *version + - &label + name: label + description: "Nature of the transaction (Join/Exit via swap or Mint/Burn via transfer)" + - *token_address + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction on token supply at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction on token supply at the time of execution in the original currency" + + - name: balancer_v2_arbitrum_bpt_supply_changes_daily + meta: + blockchain: arbitrum + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['arbitrum', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. grouped by day + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - token_address + columns: + - *block_date + - *blockchain + - *pool_type + - *pool_symbol + - *version + - *token_address + - &daily_delta + name: daily_delta + description: "Daily total impact on BPT supply" \ No newline at end of file diff --git a/models/balancer/arbitrum/balancer_v2_arbitrum_bpt_prices.sql b/models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_bpt_prices.sql similarity index 100% rename from models/balancer/arbitrum/balancer_v2_arbitrum_bpt_prices.sql rename to models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_bpt_prices.sql diff --git a/models/balancer/arbitrum/balancer_v2_arbitrum_bpt_supply.sql b/models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_bpt_supply.sql similarity index 100% rename from models/balancer/arbitrum/balancer_v2_arbitrum_bpt_supply.sql rename to models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_bpt_supply.sql diff --git a/models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_bpt_supply_changes.sql b/models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_bpt_supply_changes.sql new file mode 100644 index 00000000000..b30224001c3 --- /dev/null +++ b/models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_bpt_supply_changes.sql @@ -0,0 +1,20 @@ +{% set blockchain = 'arbitrum' %} + +{{ + config( + schema = 'balancer_v2_arbitrum', + alias = 'bpt_supply_changes', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_date', 'evt_tx_hash', 'evt_index', 'label'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +{{ + bpt_supply_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_bpt_supply_changes_daily.sql b/models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_bpt_supply_changes_daily.sql new file mode 100644 index 00000000000..df606a75ceb --- /dev/null +++ b/models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_bpt_supply_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'ethereum' %} + +{{ + config( + schema = 'balancer_v2_ethereum', + alias = 'bpt_supply_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + bpt_supply_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/balancer/arbitrum/balancer_v2_arbitrum_transfers_bpt.sql b/models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_transfers_bpt.sql similarity index 100% rename from models/balancer/arbitrum/balancer_v2_arbitrum_transfers_bpt.sql rename to models/_project/balancer/bpt/arbitrum/balancer_v2_arbitrum_transfers_bpt.sql diff --git a/models/_project/balancer/bpt/avalanche_c/_schema.yml b/models/_project/balancer/bpt/avalanche_c/_schema.yml new file mode 100644 index 00000000000..8bde08a0ad8 --- /dev/null +++ b/models/_project/balancer/bpt/avalanche_c/_schema.yml @@ -0,0 +1,178 @@ +version: 2 + +models: + - name: balancer_v2_avalanche_c_transfers_bpt + meta: + blockchain: avalanche_c + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['avalanche_c', 'bpt', 'transfers'] + description: > + Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on avalanche_c. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - evt_tx_hash + - evt_index + - block_date + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'avalanche_c address for the liquidity pool used in transaction' + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &block_month + name: block_month + description: "UTC event block month of each DEX trade" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &from + name: from + description: 'Address of BPT provider of transfer event' + - &to + name: to + description: 'Address of BPT receiver of transfer event' + - &value + name: value + description: 'Amount of BPT transferred in transfer event' + + - name: balancer_v2_avalanche_c_bpt_prices + meta: + blockchain: avalanche_c + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['avalanche_c', 'bpt', 'prices'] + description: > + Balancer Pool Token (BPT) daily price by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - day + - contract_address + columns: + - *blockchain + - &day + name: day + description: "Block date in UTC" + - *version + - &decimals + name: decimals + description: "Token decimals. 18, by default, on BPTs" + - *contract_address + - &bpt_price + name: bpt_price + description: "Price of the BPT" + + - name: balancer_v2_avalanche_c_bpt_supply + meta: + blockchain: avalanche_c + project: balancer_v2 + contributors: thetroyharris, viniabussafi + config: + tags: ['avalanche_c', 'bpt', 'supply'] + description: > + Balancer Pool Token (BPT) supply by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - blockchain + - token_address + columns: + - *day + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - *version + - *blockchain + - &token_address + name: token_address + description: "Contract address of the BPT" + - &supply + name: supply + description: "Supply of the BPT, discounted of premints" + + - name: balancer_v2_avalanche_c_bpt_supply_changes + meta: + blockchain: avalanche_c + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['avalanche_c', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - label + columns: + - *block_date + - *evt_block_time + - *evt_block_number + - *blockchain + - *evt_tx_hash + - *evt_index + - *pool_type + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - *version + - &label + name: label + description: "Nature of the transaction (Join/Exit via swap or Mint/Burn via transfer)" + - *token_address + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction on token supply at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction on token supply at the time of execution in the original currency" + + - name: balancer_v2_avalanche_c_bpt_supply_changes_daily + meta: + blockchain: avalanche_c + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['avalanche_c', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. grouped by day + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - token_address + columns: + - *block_date + - *blockchain + - *pool_type + - *pool_symbol + - *version + - *token_address + - &daily_delta + name: daily_delta + description: "Daily total impact on BPT supply" \ No newline at end of file diff --git a/models/balancer/avalanche_c/balancer_v2_avalanche_c_bpt_prices.sql b/models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_bpt_prices.sql similarity index 100% rename from models/balancer/avalanche_c/balancer_v2_avalanche_c_bpt_prices.sql rename to models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_bpt_prices.sql diff --git a/models/balancer/avalanche_c/balancer_v2_avalanche_c_bpt_supply.sql b/models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_bpt_supply.sql similarity index 100% rename from models/balancer/avalanche_c/balancer_v2_avalanche_c_bpt_supply.sql rename to models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_bpt_supply.sql diff --git a/models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_bpt_supply_changes.sql b/models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_bpt_supply_changes.sql new file mode 100644 index 00000000000..db1052cb8d8 --- /dev/null +++ b/models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_bpt_supply_changes.sql @@ -0,0 +1,20 @@ +{% set blockchain = 'avalanche_c' %} + +{{ + config( + schema = 'balancer_v2_avalanche_c', + alias = 'bpt_supply_changes', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_date', 'evt_tx_hash', 'evt_index', 'label'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +{{ + bpt_supply_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_bpt_supply_changes_daily.sql b/models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_bpt_supply_changes_daily.sql new file mode 100644 index 00000000000..5ce53b4aa92 --- /dev/null +++ b/models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_bpt_supply_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'avalanche_c' %} + +{{ + config( + schema = 'balancer_v2_avalanche_c', + alias = 'bpt_supply_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + bpt_supply_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/balancer/avalanche_c/balancer_v2_avalanche_c_transfers_bpt.sql b/models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_transfers_bpt.sql similarity index 100% rename from models/balancer/avalanche_c/balancer_v2_avalanche_c_transfers_bpt.sql rename to models/_project/balancer/bpt/avalanche_c/balancer_v2_avalanche_c_transfers_bpt.sql diff --git a/models/balancer/balancer_bpt_prices.sql b/models/_project/balancer/bpt/balancer_bpt_prices.sql similarity index 69% rename from models/balancer/balancer_bpt_prices.sql rename to models/_project/balancer/bpt/balancer_bpt_prices.sql index ad8502801b9..0a1180a8013 100644 --- a/models/balancer/balancer_bpt_prices.sql +++ b/models/_project/balancer/bpt/balancer_bpt_prices.sql @@ -1,10 +1,10 @@ {{ config( schema = 'balancer', alias = 'bpt_prices', - post_hook='{{ expose_spells(\'["ethereum", "arbitrum", "polygon", "gnosis", "optimism","avalanche_c", "base", "zkevm"]\', - "project", - "balancer", - \'["thetroyharris", "viniabussafi"]\') }}' + post_hook='{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["thetroyharris", "viniabussafi"]\') }}' ) }} diff --git a/models/balancer/balancer_bpt_supply.sql b/models/_project/balancer/bpt/balancer_bpt_supply.sql similarity index 68% rename from models/balancer/balancer_bpt_supply.sql rename to models/_project/balancer/bpt/balancer_bpt_supply.sql index a15ed33c911..e43ef846b55 100644 --- a/models/balancer/balancer_bpt_supply.sql +++ b/models/_project/balancer/bpt/balancer_bpt_supply.sql @@ -1,10 +1,10 @@ {{ config( schema = 'balancer', alias = 'bpt_supply', - post_hook = '{{ expose_spells(\'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', - "project", - "balancer", - \'["thetroyharris", "viniabussafi"]\') }}' + post_hook = '{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["thetroyharris", "viniabussafi"]\') }}' ) }} diff --git a/models/_project/balancer/bpt/balancer_bpt_supply_changes.sql b/models/_project/balancer/bpt/balancer_bpt_supply_changes.sql new file mode 100644 index 00000000000..e46a587b3b0 --- /dev/null +++ b/models/_project/balancer/bpt/balancer_bpt_supply_changes.sql @@ -0,0 +1,44 @@ +{{ config( + schema = 'balancer', + alias = 'bpt_supply_changes', + post_hook='{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["viniabussafi"]\') }}' + ) +}} + +{% set balancer_models = [ + ref('balancer_v2_arbitrum_bpt_supply_changes'), + ref('balancer_v2_avalanche_c_bpt_supply_changes'), + ref('balancer_v2_base_bpt_supply_changes'), + ref('balancer_v2_ethereum_bpt_supply_changes'), + ref('balancer_v2_gnosis_bpt_supply_changes'), + ref('balancer_v2_optimism_bpt_supply_changes'), + ref('balancer_v2_polygon_bpt_supply_changes'), + ref('balancer_v2_zkevm_bpt_supply_changes') +] %} + +SELECT * +FROM ( + {% for model in balancer_models %} + SELECT + block_date + , evt_block_time + , evt_block_number + , blockchain + , evt_tx_hash + , evt_index + , pool_type + , pool_symbol + , version + , label + , token_address + , delta_amount_raw + , delta_amount + FROM {{ model }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} +) \ No newline at end of file diff --git a/models/_project/balancer/bpt/balancer_bpt_supply_changes_daily.sql b/models/_project/balancer/bpt/balancer_bpt_supply_changes_daily.sql new file mode 100644 index 00000000000..5b593cef48a --- /dev/null +++ b/models/_project/balancer/bpt/balancer_bpt_supply_changes_daily.sql @@ -0,0 +1,38 @@ +{{ config( + schema = 'balancer', + alias = 'bpt_supply_changes_daily', + post_hook='{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["viniabussafi"]\') }}' + ) +}} + +{% set balancer_models = [ + ref('balancer_v2_arbitrum_bpt_supply_changes_daily'), + ref('balancer_v2_avalanche_c_bpt_supply_changes_daily'), + ref('balancer_v2_base_bpt_supply_changes_daily'), + ref('balancer_v2_ethereum_bpt_supply_changes_daily'), + ref('balancer_v2_gnosis_bpt_supply_changes_daily'), + ref('balancer_v2_optimism_bpt_supply_changes_daily'), + ref('balancer_v2_polygon_bpt_supply_changes_daily'), + ref('balancer_v2_zkevm_bpt_supply_changes_daily') +] %} + +SELECT * +FROM ( + {% for model in balancer_models %} + SELECT + block_date + , blockchain + , pool_type + , pool_symbol + , version + , token_address + , daily_delta + FROM {{ model }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} +) \ No newline at end of file diff --git a/models/balancer/balancer_transfers_bpt.sql b/models/_project/balancer/bpt/balancer_transfers_bpt.sql similarity index 70% rename from models/balancer/balancer_transfers_bpt.sql rename to models/_project/balancer/bpt/balancer_transfers_bpt.sql index bd6fe9064c5..dda9c32ecb1 100644 --- a/models/balancer/balancer_transfers_bpt.sql +++ b/models/_project/balancer/bpt/balancer_transfers_bpt.sql @@ -1,10 +1,10 @@ {{ config( schema = 'balancer', alias = 'transfers_bpt', - post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', - "project", - "balancer", - \'["thetroyharris", "victorstefenon", "viniabussafi"]\') }}' + post_hook='{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["thetroyharris", "victorstefenon", "viniabussafi"]\') }}' ) }} diff --git a/models/_project/balancer/bpt/base/_schema.yml b/models/_project/balancer/bpt/base/_schema.yml new file mode 100644 index 00000000000..a32b805f7e2 --- /dev/null +++ b/models/_project/balancer/bpt/base/_schema.yml @@ -0,0 +1,178 @@ +version: 2 + +models: + - name: balancer_v2_base_transfers_bpt + meta: + blockchain: base + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['base', 'bpt', 'transfers'] + description: > + Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on base. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - evt_tx_hash + - evt_index + - block_date + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'base address for the liquidity pool used in transaction' + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &block_month + name: block_month + description: "UTC event block month of each DEX trade" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &from + name: from + description: 'Address of BPT provider of transfer event' + - &to + name: to + description: 'Address of BPT receiver of transfer event' + - &value + name: value + description: 'Amount of BPT transferred in transfer event' + + - name: balancer_v2_base_bpt_prices + meta: + blockchain: base + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['base', 'bpt', 'prices'] + description: > + Balancer Pool Token (BPT) daily price by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - day + - contract_address + columns: + - *blockchain + - &day + name: day + description: "Block date in UTC" + - *version + - &decimals + name: decimals + description: "Token decimals. 18, by default, on BPTs" + - *contract_address + - &bpt_price + name: bpt_price + description: "Price of the BPT" + + - name: balancer_v2_base_bpt_supply + meta: + blockchain: base + project: balancer_v2 + contributors: thetroyharris, viniabussafi + config: + tags: ['base', 'bpt', 'supply'] + description: > + Balancer Pool Token (BPT) supply by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - blockchain + - token_address + columns: + - *day + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - *version + - *blockchain + - &token_address + name: token_address + description: "Contract address of the BPT" + - &supply + name: supply + description: "Supply of the BPT, discounted of premints" + + - name: balancer_v2_base_bpt_supply_changes + meta: + blockchain: base + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['base', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - label + columns: + - *block_date + - *evt_block_time + - *evt_block_number + - *blockchain + - *evt_tx_hash + - *evt_index + - *pool_type + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - *version + - &label + name: label + description: "Nature of the transaction (Join/Exit via swap or Mint/Burn via transfer)" + - *token_address + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction on token supply at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction on token supply at the time of execution in the original currency" + + - name: balancer_v2_base_bpt_supply_changes_daily + meta: + blockchain: base + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['base', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. grouped by day + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - token_address + columns: + - *block_date + - *blockchain + - *pool_type + - *pool_symbol + - *version + - *token_address + - &daily_delta + name: daily_delta + description: "Daily total impact on BPT supply" \ No newline at end of file diff --git a/models/balancer/base/balancer_v2_base_bpt_prices.sql b/models/_project/balancer/bpt/base/balancer_v2_base_bpt_prices.sql similarity index 100% rename from models/balancer/base/balancer_v2_base_bpt_prices.sql rename to models/_project/balancer/bpt/base/balancer_v2_base_bpt_prices.sql diff --git a/models/balancer/base/balancer_v2_base_bpt_supply.sql b/models/_project/balancer/bpt/base/balancer_v2_base_bpt_supply.sql similarity index 100% rename from models/balancer/base/balancer_v2_base_bpt_supply.sql rename to models/_project/balancer/bpt/base/balancer_v2_base_bpt_supply.sql diff --git a/models/_project/balancer/bpt/base/balancer_v2_base_bpt_supply_changes.sql b/models/_project/balancer/bpt/base/balancer_v2_base_bpt_supply_changes.sql new file mode 100644 index 00000000000..1d273f4e49e --- /dev/null +++ b/models/_project/balancer/bpt/base/balancer_v2_base_bpt_supply_changes.sql @@ -0,0 +1,20 @@ +{% set blockchain = 'base' %} + +{{ + config( + schema = 'balancer_v2_base', + alias = 'bpt_supply_changes', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_date', 'evt_tx_hash', 'evt_index', 'label'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +{{ + bpt_supply_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/bpt/base/balancer_v2_base_bpt_supply_changes_daily.sql b/models/_project/balancer/bpt/base/balancer_v2_base_bpt_supply_changes_daily.sql new file mode 100644 index 00000000000..b90fdf94033 --- /dev/null +++ b/models/_project/balancer/bpt/base/balancer_v2_base_bpt_supply_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'base' %} + +{{ + config( + schema = 'balancer_v2_base', + alias = 'bpt_supply_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + bpt_supply_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/balancer/base/balancer_v2_base_transfers_bpt.sql b/models/_project/balancer/bpt/base/balancer_v2_base_transfers_bpt.sql similarity index 100% rename from models/balancer/base/balancer_v2_base_transfers_bpt.sql rename to models/_project/balancer/bpt/base/balancer_v2_base_transfers_bpt.sql diff --git a/models/_project/balancer/bpt/ethereum/_schema.yml b/models/_project/balancer/bpt/ethereum/_schema.yml new file mode 100644 index 00000000000..aa54846a5f3 --- /dev/null +++ b/models/_project/balancer/bpt/ethereum/_schema.yml @@ -0,0 +1,178 @@ +version: 2 + +models: + - name: balancer_v2_ethereum_transfers_bpt + meta: + blockchain: ethereum + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['ethereum', 'bpt', 'transfers'] + description: > + Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on ethereum. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - evt_tx_hash + - evt_index + - block_date + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'ethereum address for the liquidity pool used in transaction' + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &block_month + name: block_month + description: "UTC event block month of each DEX trade" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &from + name: from + description: 'Address of BPT provider of transfer event' + - &to + name: to + description: 'Address of BPT receiver of transfer event' + - &value + name: value + description: 'Amount of BPT transferred in transfer event' + + - name: balancer_v2_ethereum_bpt_prices + meta: + blockchain: ethereum + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['ethereum', 'bpt', 'prices'] + description: > + Balancer Pool Token (BPT) daily price by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - day + - contract_address + columns: + - *blockchain + - &day + name: day + description: "Block date in UTC" + - *version + - &decimals + name: decimals + description: "Token decimals. 18, by default, on BPTs" + - *contract_address + - &bpt_price + name: bpt_price + description: "Price of the BPT" + + - name: balancer_v2_ethereum_bpt_supply + meta: + blockchain: ethereum + project: balancer_v2 + contributors: thetroyharris, viniabussafi + config: + tags: ['ethereum', 'bpt', 'supply'] + description: > + Balancer Pool Token (BPT) supply by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - blockchain + - token_address + columns: + - *day + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - *version + - *blockchain + - &token_address + name: token_address + description: "Contract address of the BPT" + - &supply + name: supply + description: "Supply of the BPT, discounted of premints" + + - name: balancer_v2_ethereum_bpt_supply_changes + meta: + blockchain: ethereum + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['ethereum', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - label + columns: + - *block_date + - *evt_block_time + - *evt_block_number + - *blockchain + - *evt_tx_hash + - *evt_index + - *pool_type + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - *version + - &label + name: label + description: "Nature of the transaction (Join/Exit via swap or Mint/Burn via transfer)" + - *token_address + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction on token supply at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction on token supply at the time of execution in the original currency" + + - name: balancer_v2_ethereum_bpt_supply_changes_daily + meta: + blockchain: ethereum + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['ethereum', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. grouped by day + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - token_address + columns: + - *block_date + - *blockchain + - *pool_type + - *pool_symbol + - *version + - *token_address + - &daily_delta + name: daily_delta + description: "Daily total impact on BPT supply" \ No newline at end of file diff --git a/models/balancer/ethereum/balancer_v2_ethereum_bpt_prices.sql b/models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_bpt_prices.sql similarity index 100% rename from models/balancer/ethereum/balancer_v2_ethereum_bpt_prices.sql rename to models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_bpt_prices.sql diff --git a/models/balancer/ethereum/balancer_v2_ethereum_bpt_supply.sql b/models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_bpt_supply.sql similarity index 100% rename from models/balancer/ethereum/balancer_v2_ethereum_bpt_supply.sql rename to models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_bpt_supply.sql diff --git a/models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_bpt_supply_changes.sql b/models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_bpt_supply_changes.sql new file mode 100644 index 00000000000..1fa7db6b904 --- /dev/null +++ b/models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_bpt_supply_changes.sql @@ -0,0 +1,20 @@ +{% set blockchain = 'ethereum' %} + +{{ + config( + schema = 'balancer_v2_ethereum', + alias = 'bpt_supply_changes', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_date', 'evt_tx_hash', 'evt_index', 'label'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +{{ + bpt_supply_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_bpt_supply_changes_daily.sql b/models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_bpt_supply_changes_daily.sql new file mode 100644 index 00000000000..74d3be91fdf --- /dev/null +++ b/models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_bpt_supply_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'arbitrum' %} + +{{ + config( + schema = 'balancer_v2_arbitrum', + alias = 'bpt_supply_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + bpt_supply_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/balancer/ethereum/balancer_v2_ethereum_transfers_bpt.sql b/models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_transfers_bpt.sql similarity index 100% rename from models/balancer/ethereum/balancer_v2_ethereum_transfers_bpt.sql rename to models/_project/balancer/bpt/ethereum/balancer_v2_ethereum_transfers_bpt.sql diff --git a/models/_project/balancer/bpt/gnosis/_schema.yml b/models/_project/balancer/bpt/gnosis/_schema.yml new file mode 100644 index 00000000000..aae23d80a8a --- /dev/null +++ b/models/_project/balancer/bpt/gnosis/_schema.yml @@ -0,0 +1,178 @@ +version: 2 + +models: + - name: balancer_v2_gnosis_transfers_bpt + meta: + blockchain: gnosis + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['gnosis', 'bpt', 'transfers'] + description: > + Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on gnosis. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - evt_tx_hash + - evt_index + - block_date + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'gnosis address for the liquidity pool used in transaction' + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &block_month + name: block_month + description: "UTC event block month of each DEX trade" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &from + name: from + description: 'Address of BPT provider of transfer event' + - &to + name: to + description: 'Address of BPT receiver of transfer event' + - &value + name: value + description: 'Amount of BPT transferred in transfer event' + + - name: balancer_v2_gnosis_bpt_prices + meta: + blockchain: gnosis + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['gnosis', 'bpt', 'prices'] + description: > + Balancer Pool Token (BPT) daily price by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - day + - contract_address + columns: + - *blockchain + - &day + name: day + description: "Block date in UTC" + - *version + - &decimals + name: decimals + description: "Token decimals. 18, by default, on BPTs" + - *contract_address + - &bpt_price + name: bpt_price + description: "Price of the BPT" + + - name: balancer_v2_gnosis_bpt_supply + meta: + blockchain: gnosis + project: balancer_v2 + contributors: thetroyharris, viniabussafi + config: + tags: ['gnosis', 'bpt', 'supply'] + description: > + Balancer Pool Token (BPT) supply by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - blockchain + - token_address + columns: + - *day + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - *version + - *blockchain + - &token_address + name: token_address + description: "Contract address of the BPT" + - &supply + name: supply + description: "Supply of the BPT, discounted of premints" + + - name: balancer_v2_gnosis_bpt_supply_changes + meta: + blockchain: gnosis + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['gnosis', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - label + columns: + - *block_date + - *evt_block_time + - *evt_block_number + - *blockchain + - *evt_tx_hash + - *evt_index + - *pool_type + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - *version + - &label + name: label + description: "Nature of the transaction (Join/Exit via swap or Mint/Burn via transfer)" + - *token_address + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction on token supply at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction on token supply at the time of execution in the original currency" + + - name: balancer_v2_gnosis_bpt_supply_changes_daily + meta: + blockchain: gnosis + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['gnosis', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. grouped by day + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - token_address + columns: + - *block_date + - *blockchain + - *pool_type + - *pool_symbol + - *version + - *token_address + - &daily_delta + name: daily_delta + description: "Daily total impact on BPT supply" \ No newline at end of file diff --git a/models/balancer/gnosis/balancer_v2_gnosis_bpt_prices.sql b/models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_bpt_prices.sql similarity index 100% rename from models/balancer/gnosis/balancer_v2_gnosis_bpt_prices.sql rename to models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_bpt_prices.sql diff --git a/models/balancer/gnosis/balancer_v2_gnosis_bpt_supply.sql b/models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_bpt_supply.sql similarity index 100% rename from models/balancer/gnosis/balancer_v2_gnosis_bpt_supply.sql rename to models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_bpt_supply.sql diff --git a/models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_bpt_supply_changes.sql b/models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_bpt_supply_changes.sql new file mode 100644 index 00000000000..fd1539a9495 --- /dev/null +++ b/models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_bpt_supply_changes.sql @@ -0,0 +1,20 @@ +{% set blockchain = 'gnosis' %} + +{{ + config( + schema = 'balancer_v2_gnosis', + alias = 'bpt_supply_changes', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_date', 'evt_tx_hash', 'evt_index', 'label'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +{{ + bpt_supply_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_bpt_supply_changes_daily.sql b/models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_bpt_supply_changes_daily.sql new file mode 100644 index 00000000000..516f2e2dc0c --- /dev/null +++ b/models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_bpt_supply_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'gnosis' %} + +{{ + config( + schema = 'balancer_v2_gnosis', + alias = 'bpt_supply_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + bpt_supply_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/balancer/gnosis/balancer_v2_gnosis_transfers_bpt.sql b/models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_transfers_bpt.sql similarity index 100% rename from models/balancer/gnosis/balancer_v2_gnosis_transfers_bpt.sql rename to models/_project/balancer/bpt/gnosis/balancer_v2_gnosis_transfers_bpt.sql diff --git a/models/_project/balancer/bpt/optimism/_schema.yml b/models/_project/balancer/bpt/optimism/_schema.yml new file mode 100644 index 00000000000..746fd32e9da --- /dev/null +++ b/models/_project/balancer/bpt/optimism/_schema.yml @@ -0,0 +1,178 @@ +version: 2 + +models: + - name: balancer_v2_optimism_transfers_bpt + meta: + blockchain: optimism + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['optimism', 'bpt', 'transfers'] + description: > + Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on optimism. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - evt_tx_hash + - evt_index + - block_date + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'optimism address for the liquidity pool used in transaction' + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &block_month + name: block_month + description: "UTC event block month of each DEX trade" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &from + name: from + description: 'Address of BPT provider of transfer event' + - &to + name: to + description: 'Address of BPT receiver of transfer event' + - &value + name: value + description: 'Amount of BPT transferred in transfer event' + + - name: balancer_v2_optimism_bpt_prices + meta: + blockchain: optimism + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['optimism', 'bpt', 'prices'] + description: > + Balancer Pool Token (BPT) daily price by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - day + - contract_address + columns: + - *blockchain + - &day + name: day + description: "Block date in UTC" + - *version + - &decimals + name: decimals + description: "Token decimals. 18, by default, on BPTs" + - *contract_address + - &bpt_price + name: bpt_price + description: "Price of the BPT" + + - name: balancer_v2_optimism_bpt_supply + meta: + blockchain: optimism + project: balancer_v2 + contributors: thetroyharris, viniabussafi + config: + tags: ['optimism', 'bpt', 'supply'] + description: > + Balancer Pool Token (BPT) supply by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - blockchain + - token_address + columns: + - *day + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - *version + - *blockchain + - &token_address + name: token_address + description: "Contract address of the BPT" + - &supply + name: supply + description: "Supply of the BPT, discounted of premints" + + - name: balancer_v2_optimism_bpt_supply_changes + meta: + blockchain: optimism + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['optimism', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - label + columns: + - *block_date + - *evt_block_time + - *evt_block_number + - *blockchain + - *evt_tx_hash + - *evt_index + - *pool_type + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - *version + - &label + name: label + description: "Nature of the transaction (Join/Exit via swap or Mint/Burn via transfer)" + - *token_address + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction on token supply at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction on token supply at the time of execution in the original currency" + + - name: balancer_v2_optimism_bpt_supply_changes_daily + meta: + blockchain: optimism + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['optimism', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. grouped by day + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - token_address + columns: + - *block_date + - *blockchain + - *pool_type + - *pool_symbol + - *version + - *token_address + - &daily_delta + name: daily_delta + description: "Daily total impact on BPT supply" \ No newline at end of file diff --git a/models/balancer/optimism/balancer_v2_optimism_bpt_prices.sql b/models/_project/balancer/bpt/optimism/balancer_v2_optimism_bpt_prices.sql similarity index 100% rename from models/balancer/optimism/balancer_v2_optimism_bpt_prices.sql rename to models/_project/balancer/bpt/optimism/balancer_v2_optimism_bpt_prices.sql diff --git a/models/balancer/optimism/balancer_v2_optimism_bpt_supply.sql b/models/_project/balancer/bpt/optimism/balancer_v2_optimism_bpt_supply.sql similarity index 100% rename from models/balancer/optimism/balancer_v2_optimism_bpt_supply.sql rename to models/_project/balancer/bpt/optimism/balancer_v2_optimism_bpt_supply.sql diff --git a/models/_project/balancer/bpt/optimism/balancer_v2_optimism_bpt_supply_changes.sql b/models/_project/balancer/bpt/optimism/balancer_v2_optimism_bpt_supply_changes.sql new file mode 100644 index 00000000000..225b00465db --- /dev/null +++ b/models/_project/balancer/bpt/optimism/balancer_v2_optimism_bpt_supply_changes.sql @@ -0,0 +1,20 @@ +{% set blockchain = 'optimism' %} + +{{ + config( + schema = 'balancer_v2_optimism', + alias = 'bpt_supply_changes', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_date', 'evt_tx_hash', 'evt_index', 'label'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +{{ + bpt_supply_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/bpt/optimism/balancer_v2_optimism_bpt_supply_changes_daily.sql b/models/_project/balancer/bpt/optimism/balancer_v2_optimism_bpt_supply_changes_daily.sql new file mode 100644 index 00000000000..f816df8d206 --- /dev/null +++ b/models/_project/balancer/bpt/optimism/balancer_v2_optimism_bpt_supply_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'optimism' %} + +{{ + config( + schema = 'balancer_v2_optimism', + alias = 'bpt_supply_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + bpt_supply_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/balancer/optimism/balancer_v2_optimism_transfers_bpt.sql b/models/_project/balancer/bpt/optimism/balancer_v2_optimism_transfers_bpt.sql similarity index 100% rename from models/balancer/optimism/balancer_v2_optimism_transfers_bpt.sql rename to models/_project/balancer/bpt/optimism/balancer_v2_optimism_transfers_bpt.sql diff --git a/models/_project/balancer/bpt/polygon/_schema.yml b/models/_project/balancer/bpt/polygon/_schema.yml new file mode 100644 index 00000000000..3e0b5c419f6 --- /dev/null +++ b/models/_project/balancer/bpt/polygon/_schema.yml @@ -0,0 +1,178 @@ +version: 2 + +models: + - name: balancer_v2_polygon_transfers_bpt + meta: + blockchain: polygon + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['polygon', 'bpt', 'transfers'] + description: > + Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on polygon. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - evt_tx_hash + - evt_index + - block_date + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'polygon address for the liquidity pool used in transaction' + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &block_month + name: block_month + description: "UTC event block month of each DEX trade" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &from + name: from + description: 'Address of BPT provider of transfer event' + - &to + name: to + description: 'Address of BPT receiver of transfer event' + - &value + name: value + description: 'Amount of BPT transferred in transfer event' + + - name: balancer_v2_polygon_bpt_prices + meta: + blockchain: polygon + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['polygon', 'bpt', 'prices'] + description: > + Balancer Pool Token (BPT) daily price by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - day + - contract_address + columns: + - *blockchain + - &day + name: day + description: "Block date in UTC" + - *version + - &decimals + name: decimals + description: "Token decimals. 18, by default, on BPTs" + - *contract_address + - &bpt_price + name: bpt_price + description: "Price of the BPT" + + - name: balancer_v2_polygon_bpt_supply + meta: + blockchain: polygon + project: balancer_v2 + contributors: thetroyharris, viniabussafi + config: + tags: ['polygon', 'bpt', 'supply'] + description: > + Balancer Pool Token (BPT) supply by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - blockchain + - token_address + columns: + - *day + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - *version + - *blockchain + - &token_address + name: token_address + description: "Contract address of the BPT" + - &supply + name: supply + description: "Supply of the BPT, discounted of premints" + + - name: balancer_v2_polygon_bpt_supply_changes + meta: + blockchain: polygon + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['polygon', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - label + columns: + - *block_date + - *evt_block_time + - *evt_block_number + - *blockchain + - *evt_tx_hash + - *evt_index + - *pool_type + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - *version + - &label + name: label + description: "Nature of the transaction (Join/Exit via swap or Mint/Burn via transfer)" + - *token_address + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction on token supply at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction on token supply at the time of execution in the original currency" + + - name: balancer_v2_polygon_bpt_supply_changes_daily + meta: + blockchain: polygon + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['polygon', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. grouped by day + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - token_address + columns: + - *block_date + - *blockchain + - *pool_type + - *pool_symbol + - *version + - *token_address + - &daily_delta + name: daily_delta + description: "Daily total impact on BPT supply" \ No newline at end of file diff --git a/models/balancer/polygon/balancer_v2_polygon_bpt_prices.sql b/models/_project/balancer/bpt/polygon/balancer_v2_polygon_bpt_prices.sql similarity index 100% rename from models/balancer/polygon/balancer_v2_polygon_bpt_prices.sql rename to models/_project/balancer/bpt/polygon/balancer_v2_polygon_bpt_prices.sql diff --git a/models/balancer/polygon/balancer_v2_polygon_bpt_supply.sql b/models/_project/balancer/bpt/polygon/balancer_v2_polygon_bpt_supply.sql similarity index 100% rename from models/balancer/polygon/balancer_v2_polygon_bpt_supply.sql rename to models/_project/balancer/bpt/polygon/balancer_v2_polygon_bpt_supply.sql diff --git a/models/_project/balancer/bpt/polygon/balancer_v2_polygon_bpt_supply_changes.sql b/models/_project/balancer/bpt/polygon/balancer_v2_polygon_bpt_supply_changes.sql new file mode 100644 index 00000000000..7ff8034b96b --- /dev/null +++ b/models/_project/balancer/bpt/polygon/balancer_v2_polygon_bpt_supply_changes.sql @@ -0,0 +1,20 @@ +{% set blockchain = 'polygon' %} + +{{ + config( + schema = 'balancer_v2_polygon', + alias = 'bpt_supply_changes', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_date', 'evt_tx_hash', 'evt_index', 'label'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +{{ + bpt_supply_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/bpt/polygon/balancer_v2_polygon_bpt_supply_changes_daily.sql b/models/_project/balancer/bpt/polygon/balancer_v2_polygon_bpt_supply_changes_daily.sql new file mode 100644 index 00000000000..57615beb139 --- /dev/null +++ b/models/_project/balancer/bpt/polygon/balancer_v2_polygon_bpt_supply_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'polygon' %} + +{{ + config( + schema = 'balancer_v2_polygon', + alias = 'bpt_supply_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + bpt_supply_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/balancer/polygon/balancer_v2_polygon_transfers_bpt.sql b/models/_project/balancer/bpt/polygon/balancer_v2_polygon_transfers_bpt.sql similarity index 100% rename from models/balancer/polygon/balancer_v2_polygon_transfers_bpt.sql rename to models/_project/balancer/bpt/polygon/balancer_v2_polygon_transfers_bpt.sql diff --git a/models/_project/balancer/bpt/zkevm/_schema.yml b/models/_project/balancer/bpt/zkevm/_schema.yml new file mode 100644 index 00000000000..fbdd80ddb56 --- /dev/null +++ b/models/_project/balancer/bpt/zkevm/_schema.yml @@ -0,0 +1,178 @@ +version: 2 + +models: + - name: balancer_v2_zkevm_transfers_bpt + meta: + blockchain: zkevm + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['zkevm', 'bpt', 'transfers'] + description: > + Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on zkevm. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - evt_tx_hash + - evt_index + - block_date + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'zkevm address for the liquidity pool used in transaction' + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &block_month + name: block_month + description: "UTC event block month of each DEX trade" + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash of transfer event' + - &evt_index + name: evt_index + description: 'Event index' + - &evt_block_time + name: evt_block_time + description: 'Block time of transfer event' + - &evt_block_number + name: evt_block_number + description: 'Block number of transfer event' + - &from + name: from + description: 'Address of BPT provider of transfer event' + - &to + name: to + description: 'Address of BPT receiver of transfer event' + - &value + name: value + description: 'Amount of BPT transferred in transfer event' + + - name: balancer_v2_zkevm_bpt_prices + meta: + blockchain: zkevm + project: balancer_v2 + contributors: victorstefenon, thetroyharris, viniabussafi + config: + tags: ['zkevm', 'bpt', 'prices'] + description: > + Balancer Pool Token (BPT) daily price by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - day + - contract_address + columns: + - *blockchain + - &day + name: day + description: "Block date in UTC" + - *version + - &decimals + name: decimals + description: "Token decimals. 18, by default, on BPTs" + - *contract_address + - &bpt_price + name: bpt_price + description: "Price of the BPT" + + - name: balancer_v2_zkevm_bpt_supply + meta: + blockchain: zkevm + project: balancer_v2 + contributors: thetroyharris, viniabussafi + config: + tags: ['zkevm', 'bpt', 'supply'] + description: > + Balancer Pool Token (BPT) supply by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - blockchain + - token_address + columns: + - *day + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - *version + - *blockchain + - &token_address + name: token_address + description: "Contract address of the BPT" + - &supply + name: supply + description: "Supply of the BPT, discounted of premints" + + - name: balancer_v2_zkevm_bpt_supply_changes + meta: + blockchain: zkevm + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['zkevm', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - label + columns: + - *block_date + - *evt_block_time + - *evt_block_number + - *blockchain + - *evt_tx_hash + - *evt_index + - *pool_type + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - *version + - &label + name: label + description: "Nature of the transaction (Join/Exit via swap or Mint/Burn via transfer)" + - *token_address + - &delta_amount_raw + name: delta_amount_raw + description: "Raw value of the transaction on token supply at the time of execution in the original currency" + - &delta_amount + name: delta_amount + description: "Normalized value of the transaction on token supply at the time of execution in the original currency" + + - name: balancer_v2_zkevm_bpt_supply_changes_daily + meta: + blockchain: zkevm + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['zkevm', 'bpt', 'supply', 'changes'] + description: > + Balancer Pool Token (BPT) supply change events. grouped by day + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - token_address + columns: + - *block_date + - *blockchain + - *pool_type + - *pool_symbol + - *version + - *token_address + - &daily_delta + name: daily_delta + description: "Daily total impact on BPT supply" \ No newline at end of file diff --git a/models/balancer/zkevm/balancer_v2_zkevm_bpt_prices.sql b/models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_bpt_prices.sql similarity index 100% rename from models/balancer/zkevm/balancer_v2_zkevm_bpt_prices.sql rename to models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_bpt_prices.sql diff --git a/models/balancer/zkevm/balancer_v2_zkevm_bpt_supply.sql b/models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_bpt_supply.sql similarity index 100% rename from models/balancer/zkevm/balancer_v2_zkevm_bpt_supply.sql rename to models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_bpt_supply.sql diff --git a/models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_bpt_supply_changes.sql b/models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_bpt_supply_changes.sql new file mode 100644 index 00000000000..f11227e4013 --- /dev/null +++ b/models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_bpt_supply_changes.sql @@ -0,0 +1,20 @@ +{% set blockchain = 'zkevm' %} + +{{ + config( + schema = 'balancer_v2_zkevm', + alias = 'bpt_supply_changes', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_date', 'evt_tx_hash', 'evt_index', 'label'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +{{ + bpt_supply_changes_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_bpt_supply_changes_daily.sql b/models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_bpt_supply_changes_daily.sql new file mode 100644 index 00000000000..4e548f4bcf7 --- /dev/null +++ b/models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_bpt_supply_changes_daily.sql @@ -0,0 +1,17 @@ +{% set blockchain = 'zkevm' %} + +{{ + config( + schema = 'balancer_v2_zkevm', + alias = 'bpt_supply_changes_daily', + materialized = 'table', + file_format = 'delta' + ) +}} + +{{ + bpt_supply_changes_daily_agg_macro( + blockchain = blockchain, + version = '2' + ) +}} \ No newline at end of file diff --git a/models/balancer/zkevm/balancer_v2_zkevm_transfers_bpt.sql b/models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_transfers_bpt.sql similarity index 100% rename from models/balancer/zkevm/balancer_v2_zkevm_transfers_bpt.sql rename to models/_project/balancer/bpt/zkevm/balancer_v2_zkevm_transfers_bpt.sql diff --git a/models/_project/balancer/flashloans/_schema.yml b/models/_project/balancer/flashloans/_schema.yml new file mode 100644 index 00000000000..948574c1ad6 --- /dev/null +++ b/models/_project/balancer/flashloans/_schema.yml @@ -0,0 +1,35 @@ +version: 2 + +models: + - name: balancer_flashloans + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevm + sector: lending + contributors: hildobby, viniabussafi + config: + tags: ['ethereum', 'arbitrum', 'optimism', 'polygon', 'gnosis','avalanche_c', 'base', 'zkevm', 'flashloans'] + description: > + All Balancer flashloans + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - name: blockchain + - name: project + - name: version + - name: block_time + - name: block_month + - name: block_number + - name: amount + - name: amount_usd + - name: tx_hash + - name: evt_index + - name: fee + - name: currency_contract + - name: currency_symbol + - name: recipient + - name: contract_address + \ No newline at end of file diff --git a/models/_project/balancer/flashloans/arbitrum/_schema.yml b/models/_project/balancer/flashloans/arbitrum/_schema.yml new file mode 100644 index 00000000000..562e948bde1 --- /dev/null +++ b/models/_project/balancer/flashloans/arbitrum/_schema.yml @@ -0,0 +1,36 @@ +version: 2 + +models: + - name: balancer_v2_arbitrum_flashloans + meta: + blockchain: arbitrum + sector: lending + contributors: hildobby, viniabussafi + config: + tags: ['arbitrum', 'flashloans'] + description: > + All Balancer v2 flashloans on Arbitrum + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - name: blockchain + - name: project + - name: version + - name: block_time + - name: block_number + - name: amount + - name: amount_usd + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - name: evt_index + - name: fee + - name: currency_contract + - name: currency_symbol + - name: recipient + - name: contract_address + - name: block_month \ No newline at end of file diff --git a/models/balancer/arbitrum/balancer_v2_arbitrum_flashloans.sql b/models/_project/balancer/flashloans/arbitrum/balancer_v2_arbitrum_flashloans.sql similarity index 88% rename from models/balancer/arbitrum/balancer_v2_arbitrum_flashloans.sql rename to models/_project/balancer/flashloans/arbitrum/balancer_v2_arbitrum_flashloans.sql index 52ec11d81ee..bf21ac0ece7 100644 --- a/models/balancer/arbitrum/balancer_v2_arbitrum_flashloans.sql +++ b/models/_project/balancer/flashloans/arbitrum/balancer_v2_arbitrum_flashloans.sql @@ -6,10 +6,6 @@ , file_format = 'delta' , incremental_strategy = 'merge' , unique_key = ['tx_hash', 'evt_index'] - , post_hook='{{ expose_spells(\'["arbitrum"]\', - "project", - "balancer_v2", - \'["hildobby"]\') }}' ) }} diff --git a/models/_project/balancer/flashloans/avalanche_c/_schema.yml b/models/_project/balancer/flashloans/avalanche_c/_schema.yml new file mode 100644 index 00000000000..6a0a0a719f3 --- /dev/null +++ b/models/_project/balancer/flashloans/avalanche_c/_schema.yml @@ -0,0 +1,36 @@ +version: 2 + +models: + - name: balancer_v2_avalanche_c_flashloans + meta: + blockchain: avalanche_c + sector: lending + contributors: hildobby, viniabussafi + config: + tags: ['avalanche_c', 'flashloans'] + description: > + All Balancer v2 flashloans on avalanche_c + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - name: blockchain + - name: project + - name: version + - name: block_time + - name: block_number + - name: amount + - name: amount_usd + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - name: evt_index + - name: fee + - name: currency_contract + - name: currency_symbol + - name: recipient + - name: contract_address + - name: block_month \ No newline at end of file diff --git a/models/balancer/avalanche_c/balancer_v2_avalanche_c_flashloans.sql b/models/_project/balancer/flashloans/avalanche_c/balancer_v2_avalanche_c_flashloans.sql similarity index 88% rename from models/balancer/avalanche_c/balancer_v2_avalanche_c_flashloans.sql rename to models/_project/balancer/flashloans/avalanche_c/balancer_v2_avalanche_c_flashloans.sql index eca6b3b0809..d4ec0d2e79d 100644 --- a/models/balancer/avalanche_c/balancer_v2_avalanche_c_flashloans.sql +++ b/models/_project/balancer/flashloans/avalanche_c/balancer_v2_avalanche_c_flashloans.sql @@ -6,10 +6,6 @@ , file_format = 'delta' , incremental_strategy = 'merge' , unique_key = ['tx_hash', 'evt_index'] - , post_hook='{{ expose_spells(\'["avalanche_c"]\', - "project", - "balancer_v2", - \'["hildobby", "viniabussafi"]\') }}' ) }} diff --git a/models/balancer/balancer_flashloans.sql b/models/_project/balancer/flashloans/balancer_flashloans.sql similarity index 69% rename from models/balancer/balancer_flashloans.sql rename to models/_project/balancer/flashloans/balancer_flashloans.sql index bf79fcbf7f9..19f69ad6231 100644 --- a/models/balancer/balancer_flashloans.sql +++ b/models/_project/balancer/flashloans/balancer_flashloans.sql @@ -1,10 +1,10 @@ {{ config( - + schema = 'balancer', alias = 'flashloans', - post_hook='{{ expose_spells(\'["ethereum","arbitrum", "optimism", "polygon", "gnosis", "avalanche_c", "base", "zkevm"]\', - "project", - "balancer", - \'["hildobby", "viniabussafi"]\') }}' + post_hook='{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["hildobby", "viniabussafi"]\') }}' ) }} @@ -19,7 +19,6 @@ ref('balancer_v2_ethereum_flashloans') , ref('balancer_v2_zkevm_flashloans') ] %} - SELECT * FROM ( {% for flash_model in balancer_models %} diff --git a/models/_project/balancer/flashloans/base/_schema.yml b/models/_project/balancer/flashloans/base/_schema.yml new file mode 100644 index 00000000000..3664ca0dbb5 --- /dev/null +++ b/models/_project/balancer/flashloans/base/_schema.yml @@ -0,0 +1,36 @@ +version: 2 + +models: + - name: balancer_v2_base_flashloans + meta: + blockchain: base + sector: lending + contributors: hildobby, viniabussafi + config: + tags: ['base', 'flashloans'] + description: > + All Balancer v2 flashloans on base + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - name: blockchain + - name: project + - name: version + - name: block_time + - name: block_number + - name: amount + - name: amount_usd + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - name: evt_index + - name: fee + - name: currency_contract + - name: currency_symbol + - name: recipient + - name: contract_address + - name: block_month \ No newline at end of file diff --git a/models/balancer/base/balancer_v2_base_flashloans.sql b/models/_project/balancer/flashloans/base/balancer_v2_base_flashloans.sql similarity index 88% rename from models/balancer/base/balancer_v2_base_flashloans.sql rename to models/_project/balancer/flashloans/base/balancer_v2_base_flashloans.sql index 9438b88cf9c..da8cb9d2ae1 100644 --- a/models/balancer/base/balancer_v2_base_flashloans.sql +++ b/models/_project/balancer/flashloans/base/balancer_v2_base_flashloans.sql @@ -6,10 +6,6 @@ , file_format = 'delta' , incremental_strategy = 'merge' , unique_key = ['tx_hash', 'evt_index'] - , post_hook='{{ expose_spells(\'["base"]\', - "project", - "balancer_v2", - \'["hildobby", "viniabussafi"]\') }}' ) }} diff --git a/models/_project/balancer/flashloans/ethereum/_schema.yml b/models/_project/balancer/flashloans/ethereum/_schema.yml new file mode 100644 index 00000000000..48e15def9f8 --- /dev/null +++ b/models/_project/balancer/flashloans/ethereum/_schema.yml @@ -0,0 +1,36 @@ +version: 2 + +models: + - name: balancer_v2_ethereum_flashloans + meta: + blockchain: ethereum + sector: lending + contributors: hildobby, viniabussafi + config: + tags: ['ethereum', 'flashloans'] + description: > + All Balancer v2 flashloans on ethereum + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - name: blockchain + - name: project + - name: version + - name: block_time + - name: block_number + - name: amount + - name: amount_usd + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - name: evt_index + - name: fee + - name: currency_contract + - name: currency_symbol + - name: recipient + - name: contract_address + - name: block_month \ No newline at end of file diff --git a/models/balancer/ethereum/balancer_v2_ethereum_flashloans.sql b/models/_project/balancer/flashloans/ethereum/balancer_v2_ethereum_flashloans.sql similarity index 88% rename from models/balancer/ethereum/balancer_v2_ethereum_flashloans.sql rename to models/_project/balancer/flashloans/ethereum/balancer_v2_ethereum_flashloans.sql index cdbd54e0a7c..652ad476e88 100644 --- a/models/balancer/ethereum/balancer_v2_ethereum_flashloans.sql +++ b/models/_project/balancer/flashloans/ethereum/balancer_v2_ethereum_flashloans.sql @@ -6,10 +6,6 @@ , file_format = 'delta' , incremental_strategy = 'merge' , unique_key = ['tx_hash', 'evt_index'] - , post_hook='{{ expose_spells(\'["ethereum"]\', - "project", - "balancer_v2", - \'["hildobby"]\') }}' ) }} diff --git a/models/_project/balancer/flashloans/gnosis/_schema.yml b/models/_project/balancer/flashloans/gnosis/_schema.yml new file mode 100644 index 00000000000..a7db5e36011 --- /dev/null +++ b/models/_project/balancer/flashloans/gnosis/_schema.yml @@ -0,0 +1,36 @@ +version: 2 + +models: + - name: balancer_v2_gnosis_flashloans + meta: + blockchain: gnosis + sector: lending + contributors: hildobby, viniabussafi + config: + tags: ['gnosis', 'flashloans'] + description: > + All Balancer v2 flashloans on gnosis + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - name: blockchain + - name: project + - name: version + - name: block_time + - name: block_number + - name: amount + - name: amount_usd + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - name: evt_index + - name: fee + - name: currency_contract + - name: currency_symbol + - name: recipient + - name: contract_address + - name: block_month \ No newline at end of file diff --git a/models/balancer/gnosis/balancer_v2_gnosis_flashloans.sql b/models/_project/balancer/flashloans/gnosis/balancer_v2_gnosis_flashloans.sql similarity index 88% rename from models/balancer/gnosis/balancer_v2_gnosis_flashloans.sql rename to models/_project/balancer/flashloans/gnosis/balancer_v2_gnosis_flashloans.sql index 7a4dd71de65..f8d11b83452 100644 --- a/models/balancer/gnosis/balancer_v2_gnosis_flashloans.sql +++ b/models/_project/balancer/flashloans/gnosis/balancer_v2_gnosis_flashloans.sql @@ -6,10 +6,6 @@ , file_format = 'delta' , incremental_strategy = 'merge' , unique_key = ['tx_hash', 'evt_index'] - , post_hook='{{ expose_spells(\'["gnosis"]\', - "project", - "balancer_v2", - \'["hildobby"]\') }}' ) }} diff --git a/models/_project/balancer/flashloans/optimism/_schema.yml b/models/_project/balancer/flashloans/optimism/_schema.yml new file mode 100644 index 00000000000..64a96dc514f --- /dev/null +++ b/models/_project/balancer/flashloans/optimism/_schema.yml @@ -0,0 +1,36 @@ +version: 2 + +models: + - name: balancer_v2_optimism_flashloans + meta: + blockchain: optimism + sector: lending + contributors: hildobby, viniabussafi + config: + tags: ['optimism', 'flashloans'] + description: > + All Balancer v2 flashloans on optimism + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - name: blockchain + - name: project + - name: version + - name: block_time + - name: block_number + - name: amount + - name: amount_usd + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - name: evt_index + - name: fee + - name: currency_contract + - name: currency_symbol + - name: recipient + - name: contract_address + - name: block_month \ No newline at end of file diff --git a/models/balancer/optimism/balancer_v2_optimism_flashloans.sql b/models/_project/balancer/flashloans/optimism/balancer_v2_optimism_flashloans.sql similarity index 88% rename from models/balancer/optimism/balancer_v2_optimism_flashloans.sql rename to models/_project/balancer/flashloans/optimism/balancer_v2_optimism_flashloans.sql index 9908e24f7b3..c7036fcc2ac 100644 --- a/models/balancer/optimism/balancer_v2_optimism_flashloans.sql +++ b/models/_project/balancer/flashloans/optimism/balancer_v2_optimism_flashloans.sql @@ -6,10 +6,6 @@ , file_format = 'delta' , incremental_strategy = 'merge' , unique_key = ['tx_hash', 'evt_index'] - , post_hook='{{ expose_spells(\'["optimism"]\', - "project", - "balancer_v2", - \'["hildobby"]\') }}' ) }} diff --git a/models/_project/balancer/flashloans/polygon/_schema.yml b/models/_project/balancer/flashloans/polygon/_schema.yml new file mode 100644 index 00000000000..305a7252c6c --- /dev/null +++ b/models/_project/balancer/flashloans/polygon/_schema.yml @@ -0,0 +1,36 @@ +version: 2 + +models: + - name: balancer_v2_polygon_flashloans + meta: + blockchain: polygon + sector: lending + contributors: hildobby, viniabussafi + config: + tags: ['polygon', 'flashloans'] + description: > + All Balancer v2 flashloans on polygon + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - name: blockchain + - name: project + - name: version + - name: block_time + - name: block_number + - name: amount + - name: amount_usd + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - name: evt_index + - name: fee + - name: currency_contract + - name: currency_symbol + - name: recipient + - name: contract_address + - name: block_month \ No newline at end of file diff --git a/models/balancer/polygon/balancer_v2_polygon_flashloans.sql b/models/_project/balancer/flashloans/polygon/balancer_v2_polygon_flashloans.sql similarity index 88% rename from models/balancer/polygon/balancer_v2_polygon_flashloans.sql rename to models/_project/balancer/flashloans/polygon/balancer_v2_polygon_flashloans.sql index 0f0cb1d9982..392c3866d89 100644 --- a/models/balancer/polygon/balancer_v2_polygon_flashloans.sql +++ b/models/_project/balancer/flashloans/polygon/balancer_v2_polygon_flashloans.sql @@ -6,10 +6,6 @@ , file_format = 'delta' , incremental_strategy = 'merge' , unique_key = ['tx_hash', 'evt_index'] - , post_hook='{{ expose_spells(\'["polygon"]\', - "project", - "balancer_v2", - \'["hildobby"]\') }}' ) }} diff --git a/models/_project/balancer/flashloans/zkevm/_schema.yml b/models/_project/balancer/flashloans/zkevm/_schema.yml new file mode 100644 index 00000000000..feb6c20d41b --- /dev/null +++ b/models/_project/balancer/flashloans/zkevm/_schema.yml @@ -0,0 +1,36 @@ +version: 2 + +models: + - name: balancer_v2_zkevm_flashloans + meta: + blockchain: zkevm + sector: lending + contributors: hildobby, viniabussafi + config: + tags: ['zkevm', 'flashloans'] + description: > + All Balancer v2 flashloans on zkevm + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - name: blockchain + - name: project + - name: version + - name: block_time + - name: block_number + - name: amount + - name: amount_usd + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - name: evt_index + - name: fee + - name: currency_contract + - name: currency_symbol + - name: recipient + - name: contract_address + - name: block_month \ No newline at end of file diff --git a/models/balancer/zkevm/balancer_v2_zkevm_flashloans.sql b/models/_project/balancer/flashloans/zkevm/balancer_v2_zkevm_flashloans.sql similarity index 88% rename from models/balancer/zkevm/balancer_v2_zkevm_flashloans.sql rename to models/_project/balancer/flashloans/zkevm/balancer_v2_zkevm_flashloans.sql index a11355919f7..3e1d9d1a6f5 100644 --- a/models/balancer/zkevm/balancer_v2_zkevm_flashloans.sql +++ b/models/_project/balancer/flashloans/zkevm/balancer_v2_zkevm_flashloans.sql @@ -6,10 +6,6 @@ , file_format = 'delta' , incremental_strategy = 'merge' , unique_key = ['tx_hash', 'evt_index'] - , post_hook='{{ expose_spells(\'["zkevm"]\', - "project", - "balancer_v2", - \'["hildobby", "viniabussafi"]\') }}' ) }} diff --git a/models/_project/balancer/liquidity/_schema.yml b/models/_project/balancer/liquidity/_schema.yml new file mode 100644 index 00000000000..b014ad151e4 --- /dev/null +++ b/models/_project/balancer/liquidity/_schema.yml @@ -0,0 +1,60 @@ +version: 2 + +models: + - name: balancer_liquidity + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevm + project: balancer + contributors: viniabussafi + config: + tags: ['balancer', 'amm', 'dex', 'liquidity', 'ethereum', 'arbitrum', 'optimism', 'polygon', 'avalanche_c', 'base', 'zkevm'] + description: > + Liquidity by token on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - blockchain + - token_address + - token_symbol + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - name: token_balance_raw + description: 'Raw balance of the token in the pool in the original currency' + - name: token_balance + description: 'Scaled balance of the token in the pool in the original currency' + - name: protocol_liquidity_usd + description: 'Liquidity of the token in the pool in USD, except BPTs' + - name: protocol_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, except BPTs' + - name: pool_liquidity_usd + description: 'Liquidity of the token in the pool in USD, including BPTs' + - name: pool_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, including BPTs' \ No newline at end of file diff --git a/models/_project/balancer/liquidity/arbitrum/_schema.yml b/models/_project/balancer/liquidity/arbitrum/_schema.yml new file mode 100644 index 00000000000..ca88eb050b8 --- /dev/null +++ b/models/_project/balancer/liquidity/arbitrum/_schema.yml @@ -0,0 +1,58 @@ +version: 2 + +models: + - name: balancer_v2_arbitrum_liquidity + meta: + blockchain: arbitrum + project: balancer_v2 + contributors: victorstefenon, viniabussafi, thetroyharris + config: + tags: ['arbitrum', 'balancer', 'pools', 'liquidity'] + description: > + Balancer v2 pools liquidity by token in Arbitrum. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - name: token_balance_raw + description: 'Raw balance of the token in the pool in the original currency' + - name: token_balance + description: 'Scaled balance of the token in the pool in the original currency' + - name: protocol_liquidity_usd + description: 'Liquidity of the token in the pool in USD, except BPTs' + - name: protocol_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, except BPTs' + - name: pool_liquidity_usd + description: 'Liquidity of the token in the pool in USD, including BPTs' + - name: pool_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, including BPTs' \ No newline at end of file diff --git a/models/balancer/arbitrum/balancer_v2_arbitrum_liquidity.sql b/models/_project/balancer/liquidity/arbitrum/balancer_v2_arbitrum_liquidity.sql similarity index 52% rename from models/balancer/arbitrum/balancer_v2_arbitrum_liquidity.sql rename to models/_project/balancer/liquidity/arbitrum/balancer_v2_arbitrum_liquidity.sql index c78ddea2ad7..c32f49c73ac 100644 --- a/models/balancer/arbitrum/balancer_v2_arbitrum_liquidity.sql +++ b/models/_project/balancer/liquidity/arbitrum/balancer_v2_arbitrum_liquidity.sql @@ -6,11 +6,7 @@ schema = 'balancer_v2_arbitrum', alias = 'liquidity', materialized = 'table', - file_format = 'delta', - post_hook="{{ expose_spells('[\"" + blockchain + '"]' + '\', - "project", - "balancer_v2", - \'["stefenon", "viniabussafi"]\') }}' + file_format = 'delta' ) }} diff --git a/models/_project/balancer/liquidity/avalanche_c/_schema.yml b/models/_project/balancer/liquidity/avalanche_c/_schema.yml new file mode 100644 index 00000000000..cd5e9580b08 --- /dev/null +++ b/models/_project/balancer/liquidity/avalanche_c/_schema.yml @@ -0,0 +1,58 @@ +version: 2 + +models: + - name: balancer_v2_avalanche_c_liquidity + meta: + blockchain: avalanche_c + project: balancer_v2 + contributors: victorstefenon, viniabussafi, thetroyharris + config: + tags: ['avalanche_c', 'balancer', 'pools', 'liquidity'] + description: > + Balancer v2 pools liquidity by token in Arbitrum. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - name: token_balance_raw + description: 'Raw balance of the token in the pool in the original currency' + - name: token_balance + description: 'Scaled balance of the token in the pool in the original currency' + - name: protocol_liquidity_usd + description: 'Liquidity of the token in the pool in USD, except BPTs' + - name: protocol_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, except BPTs' + - name: pool_liquidity_usd + description: 'Liquidity of the token in the pool in USD, including BPTs' + - name: pool_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, including BPTs' \ No newline at end of file diff --git a/models/balancer/avalanche_c/balancer_v2_avalanche_c_liquidity.sql b/models/_project/balancer/liquidity/avalanche_c/balancer_v2_avalanche_c_liquidity.sql similarity index 53% rename from models/balancer/avalanche_c/balancer_v2_avalanche_c_liquidity.sql rename to models/_project/balancer/liquidity/avalanche_c/balancer_v2_avalanche_c_liquidity.sql index 15b3912d3ee..30e2856d411 100644 --- a/models/balancer/avalanche_c/balancer_v2_avalanche_c_liquidity.sql +++ b/models/_project/balancer/liquidity/avalanche_c/balancer_v2_avalanche_c_liquidity.sql @@ -6,11 +6,7 @@ schema = 'balancer_v2_avalanche_c', alias = 'liquidity', materialized = 'table', - file_format = 'delta', - post_hook="{{ expose_spells('[\"" + blockchain + '"]' + '\', - "project", - "balancer_v2", - \'["stefenon", "viniabussafi"]\') }}' + file_format = 'delta' ) }} diff --git a/models/balancer/balancer_liquidity.sql b/models/_project/balancer/liquidity/balancer_liquidity.sql similarity index 74% rename from models/balancer/balancer_liquidity.sql rename to models/_project/balancer/liquidity/balancer_liquidity.sql index 0f003bc5d6d..57fb1122ef5 100644 --- a/models/balancer/balancer_liquidity.sql +++ b/models/_project/balancer/liquidity/balancer_liquidity.sql @@ -2,11 +2,10 @@ schema = 'balancer', alias = 'liquidity', - post_hook='{{ expose_spells(\'["ethereum","arbitrum", "optimism", "polygon", "gnosis","avalanche_c", "base", "zkevm" - ]\', - "project", - "balancer", - \'["viniabussafi"]\') }}' + post_hook='{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["viniabussafi"]\') }}' ) }} diff --git a/models/_project/balancer/liquidity/base/_schema.yml b/models/_project/balancer/liquidity/base/_schema.yml new file mode 100644 index 00000000000..d4b57b38164 --- /dev/null +++ b/models/_project/balancer/liquidity/base/_schema.yml @@ -0,0 +1,58 @@ +version: 2 + +models: + - name: balancer_v2_base_liquidity + meta: + blockchain: base + project: balancer_v2 + contributors: victorstefenon, viniabussafi, thetroyharris + config: + tags: ['base', 'balancer', 'pools', 'liquidity'] + description: > + Balancer v2 pools liquidity by token in Arbitrum. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - name: token_balance_raw + description: 'Raw balance of the token in the pool in the original currency' + - name: token_balance + description: 'Scaled balance of the token in the pool in the original currency' + - name: protocol_liquidity_usd + description: 'Liquidity of the token in the pool in USD, except BPTs' + - name: protocol_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, except BPTs' + - name: pool_liquidity_usd + description: 'Liquidity of the token in the pool in USD, including BPTs' + - name: pool_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, including BPTs' \ No newline at end of file diff --git a/models/balancer/base/balancer_v2_base_liquidity.sql b/models/_project/balancer/liquidity/base/balancer_v2_base_liquidity.sql similarity index 51% rename from models/balancer/base/balancer_v2_base_liquidity.sql rename to models/_project/balancer/liquidity/base/balancer_v2_base_liquidity.sql index 10b08a41262..20f257ad753 100644 --- a/models/balancer/base/balancer_v2_base_liquidity.sql +++ b/models/_project/balancer/liquidity/base/balancer_v2_base_liquidity.sql @@ -6,11 +6,7 @@ schema = 'balancer_v2_base', alias = 'liquidity', materialized = 'table', - file_format = 'delta', - post_hook="{{ expose_spells('[\"" + blockchain + '"]' + '\', - "project", - "balancer_v2", - \'["stefenon", "viniabussafi"]\') }}' + file_format = 'delta' ) }} diff --git a/models/_project/balancer/liquidity/ethereum/_schema.yml b/models/_project/balancer/liquidity/ethereum/_schema.yml new file mode 100644 index 00000000000..42866a2e449 --- /dev/null +++ b/models/_project/balancer/liquidity/ethereum/_schema.yml @@ -0,0 +1,96 @@ +version: 2 + +models: + - name: balancer_v2_ethereum_liquidity + meta: + blockchain: ethereum + project: balancer_v2 + contributors: victorstefenon, viniabussafi, thetroyharris + config: + tags: ['ethereum', 'balancer', 'pools', 'liquidity'] + description: > + Balancer v2 pools liquidity by token in Ethereum. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - &token_balance_raw + name: token_balance_raw + description: 'Raw balance of the token in the pool in the original currency' + - &token_balance + name: token_balance + description: 'Scaled balance of the token in the pool in the original currency' + - &protocol_liquidity_usd + name: protocol_liquidity_usd + description: 'Liquidity of the token in the pool in USD, except BPTs' + - &protocol_liquidity_eth + name: protocol_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, except BPTs' + - &pool_liquidity_usd + name: pool_liquidity_usd + description: 'Liquidity of the token in the pool in USD, including BPTs' + - &pool_liquidity_eth + name: pool_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, including BPTs' + + - name: balancer_v1_ethereum_liquidity + meta: + blockchain: ethereum + project: balancer_v1 + contributors: markusbkoch, mendesfabio, victorstefenon, viniabussafi, thetroyharris + config: + tags: ['ethereum', 'balancer', 'pools', 'liquidity'] + description: > + Balancer v1 pools liquidity by token in Ethereum. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - *day + - *pool_id + - *pool_address + - *pool_symbol + - *version + - *blockchain + - *pool_type + - *token_address + - *token_symbol + - *token_balance_raw + - *token_balance + - *protocol_liquidity_usd + - *protocol_liquidity_eth + - *pool_liquidity_usd + - *pool_liquidity_eth \ No newline at end of file diff --git a/models/balancer/ethereum/balancer_v1_ethereum_liquidity.sql b/models/_project/balancer/liquidity/ethereum/balancer_v1_ethereum_liquidity.sql similarity index 92% rename from models/balancer/ethereum/balancer_v1_ethereum_liquidity.sql rename to models/_project/balancer/liquidity/ethereum/balancer_v1_ethereum_liquidity.sql index 31601ee7cdd..b433278b8db 100644 --- a/models/balancer/ethereum/balancer_v1_ethereum_liquidity.sql +++ b/models/_project/balancer/liquidity/ethereum/balancer_v1_ethereum_liquidity.sql @@ -3,11 +3,7 @@ schema='balancer_v1_ethereum', alias = 'liquidity', materialized = 'table', - file_format = 'delta', - post_hook='{{ expose_spells(\'["ethereum"]\', - "project", - "balancer_v1", - \'["stefenon", "viniabussafi"]\') }}' + file_format = 'delta' ) }} diff --git a/models/balancer/ethereum/balancer_v2_ethereum_liquidity.sql b/models/_project/balancer/liquidity/ethereum/balancer_v2_ethereum_liquidity.sql similarity index 52% rename from models/balancer/ethereum/balancer_v2_ethereum_liquidity.sql rename to models/_project/balancer/liquidity/ethereum/balancer_v2_ethereum_liquidity.sql index 56ccd353f93..54efdce06c3 100644 --- a/models/balancer/ethereum/balancer_v2_ethereum_liquidity.sql +++ b/models/_project/balancer/liquidity/ethereum/balancer_v2_ethereum_liquidity.sql @@ -6,11 +6,7 @@ schema = 'balancer_v2_ethereum', alias = 'liquidity', materialized = 'table', - file_format = 'delta', - post_hook="{{ expose_spells('[\"" + blockchain + '"]' + '\', - "project", - "balancer_v2", - \'["stefenon", "viniabussafi"]\') }}' + file_format = 'delta' ) }} diff --git a/models/_project/balancer/liquidity/gnosis/_schema.yml b/models/_project/balancer/liquidity/gnosis/_schema.yml new file mode 100644 index 00000000000..d21460430ab --- /dev/null +++ b/models/_project/balancer/liquidity/gnosis/_schema.yml @@ -0,0 +1,58 @@ +version: 2 + +models: + - name: balancer_v2_gnosis_liquidity + meta: + blockchain: gnosis + project: balancer_v2 + contributors: victorstefenon, viniabussafi, thetroyharris + config: + tags: ['gnosis', 'balancer', 'pools', 'liquidity'] + description: > + Balancer v2 pools liquidity by token in Arbitrum. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - name: token_balance_raw + description: 'Raw balance of the token in the pool in the original currency' + - name: token_balance + description: 'Scaled balance of the token in the pool in the original currency' + - name: protocol_liquidity_usd + description: 'Liquidity of the token in the pool in USD, except BPTs' + - name: protocol_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, except BPTs' + - name: pool_liquidity_usd + description: 'Liquidity of the token in the pool in USD, including BPTs' + - name: pool_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, including BPTs' \ No newline at end of file diff --git a/models/balancer/gnosis/balancer_v2_gnosis_liquidity.sql b/models/_project/balancer/liquidity/gnosis/balancer_v2_gnosis_liquidity.sql similarity index 51% rename from models/balancer/gnosis/balancer_v2_gnosis_liquidity.sql rename to models/_project/balancer/liquidity/gnosis/balancer_v2_gnosis_liquidity.sql index 478f1b6c77f..fc5885a24e0 100644 --- a/models/balancer/gnosis/balancer_v2_gnosis_liquidity.sql +++ b/models/_project/balancer/liquidity/gnosis/balancer_v2_gnosis_liquidity.sql @@ -6,11 +6,7 @@ schema = 'balancer_v2_gnosis', alias = 'liquidity', materialized = 'table', - file_format = 'delta', - post_hook="{{ expose_spells('[\"" + blockchain + '"]' + '\', - "project", - "balancer_v2", - \'["stefenon", "viniabussafi"]\') }}' + file_format = 'delta' ) }} diff --git a/models/_project/balancer/liquidity/optimism/_schema.yml b/models/_project/balancer/liquidity/optimism/_schema.yml new file mode 100644 index 00000000000..d41d2cb3e49 --- /dev/null +++ b/models/_project/balancer/liquidity/optimism/_schema.yml @@ -0,0 +1,58 @@ +version: 2 + +models: + - name: balancer_v2_optimism_liquidity + meta: + blockchain: optimism + project: balancer_v2 + contributors: victorstefenon, viniabussafi, thetroyharris + config: + tags: ['optimism', 'balancer', 'pools', 'liquidity'] + description: > + Balancer v2 pools liquidity by token in Arbitrum. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - name: token_balance_raw + description: 'Raw balance of the token in the pool in the original currency' + - name: token_balance + description: 'Scaled balance of the token in the pool in the original currency' + - name: protocol_liquidity_usd + description: 'Liquidity of the token in the pool in USD, except BPTs' + - name: protocol_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, except BPTs' + - name: pool_liquidity_usd + description: 'Liquidity of the token in the pool in USD, including BPTs' + - name: pool_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, including BPTs' \ No newline at end of file diff --git a/models/balancer/optimism/balancer_v2_optimism_liquidity.sql b/models/_project/balancer/liquidity/optimism/balancer_v2_optimism_liquidity.sql similarity index 52% rename from models/balancer/optimism/balancer_v2_optimism_liquidity.sql rename to models/_project/balancer/liquidity/optimism/balancer_v2_optimism_liquidity.sql index d9e8ac55868..b34e0e3557a 100644 --- a/models/balancer/optimism/balancer_v2_optimism_liquidity.sql +++ b/models/_project/balancer/liquidity/optimism/balancer_v2_optimism_liquidity.sql @@ -6,11 +6,7 @@ schema = 'balancer_v2_optimism', alias = 'liquidity', materialized = 'table', - file_format = 'delta', - post_hook="{{ expose_spells('[\"" + blockchain + '"]' + '\', - "project", - "balancer_v2", - \'["stefenon", "viniabussafi"]\') }}' + file_format = 'delta' ) }} diff --git a/models/_project/balancer/liquidity/polygon/_schema.yml b/models/_project/balancer/liquidity/polygon/_schema.yml new file mode 100644 index 00000000000..5054f2a9740 --- /dev/null +++ b/models/_project/balancer/liquidity/polygon/_schema.yml @@ -0,0 +1,58 @@ +version: 2 + +models: + - name: balancer_v2_polygon_liquidity + meta: + blockchain: polygon + project: balancer_v2 + contributors: victorstefenon, viniabussafi, thetroyharris + config: + tags: ['polygon', 'balancer', 'pools', 'liquidity'] + description: > + Balancer v2 pools liquidity by token in Arbitrum. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - name: token_balance_raw + description: 'Raw balance of the token in the pool in the original currency' + - name: token_balance + description: 'Scaled balance of the token in the pool in the original currency' + - name: protocol_liquidity_usd + description: 'Liquidity of the token in the pool in USD, except BPTs' + - name: protocol_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, except BPTs' + - name: pool_liquidity_usd + description: 'Liquidity of the token in the pool in USD, including BPTs' + - name: pool_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, including BPTs' \ No newline at end of file diff --git a/models/balancer/polygon/balancer_v2_polygon_liquidity.sql b/models/_project/balancer/liquidity/polygon/balancer_v2_polygon_liquidity.sql similarity index 52% rename from models/balancer/polygon/balancer_v2_polygon_liquidity.sql rename to models/_project/balancer/liquidity/polygon/balancer_v2_polygon_liquidity.sql index f830e2df02c..3f0c521ade6 100644 --- a/models/balancer/polygon/balancer_v2_polygon_liquidity.sql +++ b/models/_project/balancer/liquidity/polygon/balancer_v2_polygon_liquidity.sql @@ -6,11 +6,7 @@ schema = 'balancer_v2_polygon', alias = 'liquidity', materialized = 'table', - file_format = 'delta', - post_hook="{{ expose_spells('[\"" + blockchain + '"]' + '\', - "project", - "balancer_v2", - \'["stefenon", "viniabussafi"]\') }}' + file_format = 'delta' ) }} diff --git a/models/_project/balancer/liquidity/zkevm/_schema.yml b/models/_project/balancer/liquidity/zkevm/_schema.yml new file mode 100644 index 00000000000..67f36eb3b21 --- /dev/null +++ b/models/_project/balancer/liquidity/zkevm/_schema.yml @@ -0,0 +1,58 @@ +version: 2 + +models: + - name: balancer_v2_zkevm_liquidity + meta: + blockchain: zkevm + project: balancer_v2 + contributors: victorstefenon, viniabussafi, thetroyharris + config: + tags: ['zkevm', 'balancer', 'pools', 'liquidity'] + description: > + Balancer v2 pools liquidity by token in Arbitrum. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token" + - &token_symbol + name: token_symbol + description: "Token symbol" + - name: token_balance_raw + description: 'Raw balance of the token in the pool in the original currency' + - name: token_balance + description: 'Scaled balance of the token in the pool in the original currency' + - name: protocol_liquidity_usd + description: 'Liquidity of the token in the pool in USD, except BPTs' + - name: protocol_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, except BPTs' + - name: pool_liquidity_usd + description: 'Liquidity of the token in the pool in USD, including BPTs' + - name: pool_liquidity_eth + description: 'Liquidity of the token in the pool in ETH, including BPTs' \ No newline at end of file diff --git a/models/balancer/zkevm/balancer_v2_zkevm_liquidity.sql b/models/_project/balancer/liquidity/zkevm/balancer_v2_zkevm_liquidity.sql similarity index 51% rename from models/balancer/zkevm/balancer_v2_zkevm_liquidity.sql rename to models/_project/balancer/liquidity/zkevm/balancer_v2_zkevm_liquidity.sql index f3fd420bb39..737b858ca3c 100644 --- a/models/balancer/zkevm/balancer_v2_zkevm_liquidity.sql +++ b/models/_project/balancer/liquidity/zkevm/balancer_v2_zkevm_liquidity.sql @@ -6,11 +6,7 @@ schema = 'balancer_v2_zkevm', alias = 'liquidity', materialized = 'table', - file_format = 'delta', - post_hook="{{ expose_spells('[\"" + blockchain + '"]' + '\', - "project", - "balancer_v2", - \'["stefenon", "viniabussafi"]\') }}' + file_format = 'delta' ) }} diff --git a/models/_project/balancer/pools/_schema.yml b/models/_project/balancer/pools/_schema.yml new file mode 100644 index 00000000000..65c86555a7c --- /dev/null +++ b/models/_project/balancer/pools/_schema.yml @@ -0,0 +1,173 @@ +version: 2 + +models: + - name: balancer_pools_fees + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevm + contributors: jacektrocinski, thetroyharris, viniabussafi + config: + tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'pools', 'fees'] + description: > + Balancer v2 swap fees stored at the pool level. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - block_number + - tx_hash + - index + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'zkevm address for the liquidity pool used in transaction' + tests: + - not_null + - &tx_hash + name: tx_hash + description: 'Transaction hash' + tests: + - not_null + - &index + name: index + description: 'Event Index' + tests: + - not_null + - &tx_index + name: tx_index + description: 'Transaction Index' + tests: + - not_null + - &block_time + name: block_time + description: 'Block time in UTC' + tests: + - not_null + - &block_number + name: block_number + description: 'Event Block Number' + tests: + - not_null + - &swap_fee_percentage + name: swap_fee_percentage + description: 'Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)' + tests: + - not_null + + - name: balancer_pools_tokens_weights + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, 'zkevm' + contributors: jacektrocinski, viniabussafi + config: + tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'bpt', 'transfers'] + description: > + Token weights in Balancer pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - pool_id + - token_address + columns: + - *blockchain + - *version + - &pool_id + name: pool_id + description: 'Unique encoded identifier that refers to each pool' + tests: + - not_null + - &token_address + name: token_address + description: 'Contract address for the token' + - &normalized_weight + name: normalized_weight + description: 'Weight of the token in the pool.' + + + - name: balancer_pools_metrics_daily + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevm + contributors: viniabussafi, metacrypto + config: + tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'balancer', 'pool', 'stats', 'volume', 'tvl', 'fee'] + description: > + This spell aggregates data from the trades, liquidity and protocol fees spells, by day and pool, while also displaying some basic information about the pool + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - project_contract_address + columns: + - *blockchain + - &project + name: project + description: "Project name (balancer)" + - *version + - &block_date + name: block_date + description: "Block date in UTC" + - &project_contract_address + name: project_contract_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &swap_amount_usd + name: swap_amount_usd + description: "Daily swap volume on a pool, in USD" + - &tvl_usd + name: tvl_usd + description: "Total Value Locked on a pool, in USD" + - &tvl_eth + name: tvl_eth + description: "Total Value Locked on a pool, in eth" + - &fee_amount_usd + name: fee_amount_usd + description: "Daily fees collected on a pool, in USD" + + - name: balancer_gauge_mappings + meta: + blockchain: optimism + sector: dex + contributors: msilb7 + config: + tags: ['balancer', 'amm', 'trades', 'dex', 'incentives'] + description: > + Gauge to Pool mappings for balancer on all chains + columns: + - *blockchain + - *version + - &pool_contract + name: pool_contract + description: "Address of the liquidity pool contract" + - *pool_id + - &incentives_contract + name: incentives_contract + description: "Address of the contract where incentives are stored and emitted." + - &incentives_type + name: incentives_type + description: "Description of the incentives address type." + - &evt_block_time + name: evt_block_time + description: "Block time in UTC" + - &evt_block_number + name: evt_block_number + description: 'Event Block Number' + - *contract_address + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash' + - &evt_index + name: evT_index + description: 'Event Index' \ No newline at end of file diff --git a/models/_project/balancer/pools/arbitrum/_schema.yml b/models/_project/balancer/pools/arbitrum/_schema.yml new file mode 100644 index 00000000000..fd04cb90077 --- /dev/null +++ b/models/_project/balancer/pools/arbitrum/_schema.yml @@ -0,0 +1,105 @@ +version: 2 + +models: + - name: balancer_v2_arbitrum_pools_fees + meta: + blockchain: arbitrum + project: balancer_v2 + contributors: jacektrocinski, thetroyharris, viniabussafi + config: + tags: ['arbitrum', 'balancer', 'pools_fees'] + description: > + Balancer v2 swap fees stored at the pool level. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_number + - tx_hash + - index + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'Arbitrum address for the liquidity pool used in transaction' + tests: + - not_null + - &tx_hash + name: tx_hash + description: 'Transaction hash' + tests: + - not_null + - &index + name: index + description: 'Event Index' + tests: + - not_null + - &tx_index + name: tx_index + description: 'Transaction Index' + tests: + - not_null + - &block_time + name: block_time + description: 'Block time in UTC' + tests: + - not_null + - &block_number + name: block_number + description: 'Event Block Number' + tests: + - not_null + - &swap_fee_percentage + name: swap_fee_percentage + description: 'Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)' + tests: + - not_null + + - name: balancer_arbitrum_pools_tokens_weights + meta: + blockchain: arbitrum + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['arbitrum', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer pools. + columns: + - *blockchain + - *version + - &pool_id + name: pool_id + description: 'Unique encoded identifier that refers to each pool' + tests: + - not_null + - &token_address + name: token_address + description: 'Contract address for the token' + - &normalized_weight + name: normalized_weight + description: 'Weight of the token in the pool.' + + - name: balancer_v2_arbitrum_pools_tokens_weights + meta: + blockchain: arbitrum + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['arbitrum', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer v2 pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_id + - token_address + columns: + - *blockchain + - *version + - *pool_id + - *token_address + - *normalized_weight \ No newline at end of file diff --git a/models/balancer/arbitrum/balancer_arbitrum_pools_tokens_weights.sql b/models/_project/balancer/pools/arbitrum/balancer_arbitrum_pools_tokens_weights.sql similarity index 100% rename from models/balancer/arbitrum/balancer_arbitrum_pools_tokens_weights.sql rename to models/_project/balancer/pools/arbitrum/balancer_arbitrum_pools_tokens_weights.sql diff --git a/models/balancer/arbitrum/balancer_v2_arbitrum_pools_fees.sql b/models/_project/balancer/pools/arbitrum/balancer_v2_arbitrum_pools_fees.sql similarity index 75% rename from models/balancer/arbitrum/balancer_v2_arbitrum_pools_fees.sql rename to models/_project/balancer/pools/arbitrum/balancer_v2_arbitrum_pools_fees.sql index 105650c0b9b..39b5671f202 100644 --- a/models/balancer/arbitrum/balancer_v2_arbitrum_pools_fees.sql +++ b/models/_project/balancer/pools/arbitrum/balancer_v2_arbitrum_pools_fees.sql @@ -1,17 +1,12 @@ {{ config( - schema = 'balancer_v2_arbitrum', - + schema = 'balancer_v2_arbitrum', alias = 'pools_fees', materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['block_number', 'tx_hash', 'index'], - post_hook='{{ expose_spells(\'["arbitrum"]\', - "project", - "balancer_v2", - \'["metacrypto", "jacektrocinski", "thetroyharris", "viniabussafi"]\') }}' - )  + unique_key = ['block_number', 'tx_hash', 'index'] + ) }} {% set event_signature = '0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc' %} diff --git a/models/balancer/arbitrum/balancer_v2_arbitrum_pools_tokens_weights.sql b/models/_project/balancer/pools/arbitrum/balancer_v2_arbitrum_pools_tokens_weights.sql similarity index 99% rename from models/balancer/arbitrum/balancer_v2_arbitrum_pools_tokens_weights.sql rename to models/_project/balancer/pools/arbitrum/balancer_v2_arbitrum_pools_tokens_weights.sql index 16ee7481c9b..ae20e0126b1 100644 --- a/models/balancer/arbitrum/balancer_v2_arbitrum_pools_tokens_weights.sql +++ b/models/_project/balancer/pools/arbitrum/balancer_v2_arbitrum_pools_tokens_weights.sql @@ -2,7 +2,6 @@ config( schema='balancer_v2_arbitrum', alias = 'pools_tokens_weights', - materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/models/_project/balancer/pools/avalanche_c/_schema.yml b/models/_project/balancer/pools/avalanche_c/_schema.yml new file mode 100644 index 00000000000..2c5082a751c --- /dev/null +++ b/models/_project/balancer/pools/avalanche_c/_schema.yml @@ -0,0 +1,105 @@ +version: 2 + +models: + - name: balancer_v2_avalanche_c_pools_fees + meta: + blockchain: avalanche_c + project: balancer_v2 + contributors: jacektrocinski, thetroyharris, viniabussafi + config: + tags: ['avalanche_c', 'balancer', 'pools_fees'] + description: > + Balancer v2 swap fees stored at the pool level. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_number + - tx_hash + - index + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'avalanche_c address for the liquidity pool used in transaction' + tests: + - not_null + - &tx_hash + name: tx_hash + description: 'Transaction hash' + tests: + - not_null + - &index + name: index + description: 'Event Index' + tests: + - not_null + - &tx_index + name: tx_index + description: 'Transaction Index' + tests: + - not_null + - &block_time + name: block_time + description: 'Block time in UTC' + tests: + - not_null + - &block_number + name: block_number + description: 'Event Block Number' + tests: + - not_null + - &swap_fee_percentage + name: swap_fee_percentage + description: 'Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)' + tests: + - not_null + + - name: balancer_avalanche_c_pools_tokens_weights + meta: + blockchain: avalanche_c + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['avalanche_c', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer pools. + columns: + - *blockchain + - *version + - &pool_id + name: pool_id + description: 'Unique encoded identifier that refers to each pool' + tests: + - not_null + - &token_address + name: token_address + description: 'Contract address for the token' + - &normalized_weight + name: normalized_weight + description: 'Weight of the token in the pool.' + + - name: balancer_v2_avalanche_c_pools_tokens_weights + meta: + blockchain: avalanche_c + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['avalanche_c', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer v2 pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_id + - token_address + columns: + - *blockchain + - *version + - *pool_id + - *token_address + - *normalized_weight \ No newline at end of file diff --git a/models/balancer/avalanche_c/balancer_avalanche_c_pools_tokens_weights.sql b/models/_project/balancer/pools/avalanche_c/balancer_avalanche_c_pools_tokens_weights.sql similarity index 100% rename from models/balancer/avalanche_c/balancer_avalanche_c_pools_tokens_weights.sql rename to models/_project/balancer/pools/avalanche_c/balancer_avalanche_c_pools_tokens_weights.sql diff --git a/models/balancer/avalanche_c/balancer_v2_avalanche_c_pools_fees.sql b/models/_project/balancer/pools/avalanche_c/balancer_v2_avalanche_c_pools_fees.sql similarity index 77% rename from models/balancer/avalanche_c/balancer_v2_avalanche_c_pools_fees.sql rename to models/_project/balancer/pools/avalanche_c/balancer_v2_avalanche_c_pools_fees.sql index 1b52e13c114..e3aae2cdf1a 100644 --- a/models/balancer/avalanche_c/balancer_v2_avalanche_c_pools_fees.sql +++ b/models/_project/balancer/pools/avalanche_c/balancer_v2_avalanche_c_pools_fees.sql @@ -1,17 +1,12 @@ {{ config( schema = 'balancer_v2_avalanche_c', - alias = 'pools_fees', materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['block_number', 'tx_hash', 'index'], - post_hook='{{ expose_spells(\'["avalanche_c"]\', - "project", - "balancer_v2", - \'["metacrypto", "jacektrocinski", "thetroyharris", "viniabussafi"]\') }}' - )  + unique_key = ['block_number', 'tx_hash', 'index'] + ) }} {% set event_signature = '0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc' %} diff --git a/models/balancer/avalanche_c/balancer_v2_avalanche_c_pools_tokens_weights.sql b/models/_project/balancer/pools/avalanche_c/balancer_v2_avalanche_c_pools_tokens_weights.sql similarity index 99% rename from models/balancer/avalanche_c/balancer_v2_avalanche_c_pools_tokens_weights.sql rename to models/_project/balancer/pools/avalanche_c/balancer_v2_avalanche_c_pools_tokens_weights.sql index 730b6b327f5..48bbb28e693 100644 --- a/models/balancer/avalanche_c/balancer_v2_avalanche_c_pools_tokens_weights.sql +++ b/models/_project/balancer/pools/avalanche_c/balancer_v2_avalanche_c_pools_tokens_weights.sql @@ -2,7 +2,6 @@ config( schema='balancer_v2_avalanche_c', alias = 'pools_tokens_weights', - materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/models/balancer/balancer_gauge_mappings.sql b/models/_project/balancer/pools/balancer_gauge_mappings.sql similarity index 78% rename from models/balancer/balancer_gauge_mappings.sql rename to models/_project/balancer/pools/balancer_gauge_mappings.sql index b764f659dde..0ad73a0a700 100644 --- a/models/balancer/balancer_gauge_mappings.sql +++ b/models/_project/balancer/pools/balancer_gauge_mappings.sql @@ -1,11 +1,10 @@ {{ config( schema = 'balancer', - alias = 'gauge_mappings', post_hook='{{ expose_spells(\'["optimism"]\', - "project", - "balancer", - \'["msilb7"]\') }}' + spell_type = "project", + spell_name = "balancer", + contributors = \'["msilb7"]\') }}' ) }} diff --git a/models/balancer/balancer_pools_fees.sql b/models/_project/balancer/pools/balancer_pools_fees.sql similarity index 69% rename from models/balancer/balancer_pools_fees.sql rename to models/_project/balancer/pools/balancer_pools_fees.sql index e638f381024..2a54b518ec1 100644 --- a/models/balancer/balancer_pools_fees.sql +++ b/models/_project/balancer/pools/balancer_pools_fees.sql @@ -1,11 +1,10 @@ {{ config( schema = 'balancer', - alias = 'pools_fees', - post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', - "project", - "balancer", - \'["thetroyharris", "viniabussafi"]\') }}' + post_hook='{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["thetroyharris", "viniabussafi"]\') }}' ) }} diff --git a/models/balancer/balancer_pools_metrics_daily.sql b/models/_project/balancer/pools/balancer_pools_metrics_daily.sql similarity index 100% rename from models/balancer/balancer_pools_metrics_daily.sql rename to models/_project/balancer/pools/balancer_pools_metrics_daily.sql diff --git a/models/balancer/balancer_pools_tokens_weights.sql b/models/_project/balancer/pools/balancer_pools_tokens_weights.sql similarity index 71% rename from models/balancer/balancer_pools_tokens_weights.sql rename to models/_project/balancer/pools/balancer_pools_tokens_weights.sql index 95a71d1c294..d2e50c49ce9 100644 --- a/models/balancer/balancer_pools_tokens_weights.sql +++ b/models/_project/balancer/pools/balancer_pools_tokens_weights.sql @@ -1,10 +1,10 @@ {{ config( schema = 'balancer', alias = 'pools_tokens_weights', - post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon"]\', - "project", - "balancer", - \'["viniabussafi"]\') }}' + post_hook='{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["viniabussafi"]\') }}' ) }} diff --git a/models/_project/balancer/pools/base/_schema.yml b/models/_project/balancer/pools/base/_schema.yml new file mode 100644 index 00000000000..0949d82f17c --- /dev/null +++ b/models/_project/balancer/pools/base/_schema.yml @@ -0,0 +1,105 @@ +version: 2 + +models: + - name: balancer_v2_base_pools_fees + meta: + blockchain: base + project: balancer_v2 + contributors: jacektrocinski, thetroyharris, viniabussafi + config: + tags: ['base', 'balancer', 'pools_fees'] + description: > + Balancer v2 swap fees stored at the pool level. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_number + - tx_hash + - index + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'base address for the liquidity pool used in transaction' + tests: + - not_null + - &tx_hash + name: tx_hash + description: 'Transaction hash' + tests: + - not_null + - &index + name: index + description: 'Event Index' + tests: + - not_null + - &tx_index + name: tx_index + description: 'Transaction Index' + tests: + - not_null + - &block_time + name: block_time + description: 'Block time in UTC' + tests: + - not_null + - &block_number + name: block_number + description: 'Event Block Number' + tests: + - not_null + - &swap_fee_percentage + name: swap_fee_percentage + description: 'Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)' + tests: + - not_null + + - name: balancer_base_pools_tokens_weights + meta: + blockchain: base + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['base', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer pools. + columns: + - *blockchain + - *version + - &pool_id + name: pool_id + description: 'Unique encoded identifier that refers to each pool' + tests: + - not_null + - &token_address + name: token_address + description: 'Contract address for the token' + - &normalized_weight + name: normalized_weight + description: 'Weight of the token in the pool.' + + - name: balancer_v2_base_pools_tokens_weights + meta: + blockchain: base + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['base', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer v2 pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_id + - token_address + columns: + - *blockchain + - *version + - *pool_id + - *token_address + - *normalized_weight \ No newline at end of file diff --git a/models/balancer/base/balancer_base_pools_tokens_weights.sql b/models/_project/balancer/pools/base/balancer_base_pools_tokens_weights.sql similarity index 100% rename from models/balancer/base/balancer_base_pools_tokens_weights.sql rename to models/_project/balancer/pools/base/balancer_base_pools_tokens_weights.sql diff --git a/models/balancer/base/balancer_v2_base_pools_fees.sql b/models/_project/balancer/pools/base/balancer_v2_base_pools_fees.sql similarity index 77% rename from models/balancer/base/balancer_v2_base_pools_fees.sql rename to models/_project/balancer/pools/base/balancer_v2_base_pools_fees.sql index 7aaf2ef8939..c4029cb33d6 100644 --- a/models/balancer/base/balancer_v2_base_pools_fees.sql +++ b/models/_project/balancer/pools/base/balancer_v2_base_pools_fees.sql @@ -1,17 +1,12 @@ {{ config( schema = 'balancer_v2_base', - alias = 'pools_fees', materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['block_number', 'tx_hash', 'index'], - post_hook='{{ expose_spells(\'["base"]\', - "project", - "balancer_v2", - \'["metacrypto", "jacektrocinski", "thetroyharris", "viniabussafi"]\') }}' - )  + unique_key = ['block_number', 'tx_hash', 'index'] + ) }} {% set event_signature = '0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc' %} diff --git a/models/balancer/base/balancer_v2_base_pools_tokens_weights.sql b/models/_project/balancer/pools/base/balancer_v2_base_pools_tokens_weights.sql similarity index 99% rename from models/balancer/base/balancer_v2_base_pools_tokens_weights.sql rename to models/_project/balancer/pools/base/balancer_v2_base_pools_tokens_weights.sql index 29086428514..531e3214489 100644 --- a/models/balancer/base/balancer_v2_base_pools_tokens_weights.sql +++ b/models/_project/balancer/pools/base/balancer_v2_base_pools_tokens_weights.sql @@ -2,7 +2,6 @@ config( schema='balancer_v2_base', alias = 'pools_tokens_weights', - materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/models/_project/balancer/pools/ethereum/_schema.yml b/models/_project/balancer/pools/ethereum/_schema.yml new file mode 100644 index 00000000000..ea4a24ef8c8 --- /dev/null +++ b/models/_project/balancer/pools/ethereum/_schema.yml @@ -0,0 +1,149 @@ +version: 2 + +models: + - name: balancer_v2_ethereum_pools_fees + meta: + blockchain: ethereum + project: balancer_v2 + contributors: jacektrocinski, thetroyharris, viniabussafi + config: + tags: ['ethereum', 'balancer', 'pools', 'fees'] + description: > + Balancer v2 swap fees stored at the pool level. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_number + - tx_hash + - index + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'zkevm address for the liquidity pool used in transaction' + tests: + - not_null + - &tx_hash + name: tx_hash + description: 'Transaction hash' + tests: + - not_null + - &index + name: index + description: 'Event Index' + tests: + - not_null + - &tx_index + name: tx_index + description: 'Transaction Index' + tests: + - not_null + - &block_time + name: block_time + description: 'Block time in UTC' + tests: + - not_null + - &block_number + name: block_number + description: 'Event Block Number' + tests: + - not_null + - &swap_fee_percentage + name: swap_fee_percentage + description: 'Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)' + tests: + - not_null + + - name: balancer_ethereum_pools_tokens_weights + meta: + blockchain: ethereum + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['ethereum', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer pools. + columns: + - *blockchain + - *version + - &pool_id + name: pool_id + description: 'Unique encoded identifier that refers to each pool' + tests: + - not_null + - &token_address + name: token_address + description: 'Contract address for the token' + - &normalized_weight + name: normalized_weight + description: 'Weight of the token in the pool.' + + - name: balancer_v1_ethereum_pools_tokens_weights + meta: + blockchain: ethereum + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['ethereum', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer v1 pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_id + - token_address + columns: + - *blockchain + - *version + - *pool_id + - *token_address + - *normalized_weight + + - name: balancer_v2_ethereum_pools_tokens_weights + meta: + blockchain: ethereum + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['ethereum', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer v2 pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_id + - token_address + columns: + - *blockchain + - *version + - *pool_id + - *token_address + - *normalized_weight + + - name: balancer_v2_ethereum_lbps + meta: + blockchain: ethereum + project: balancer_v2 + contributors: stefenon + config: + tags: ['ethereum', 'balancer', 'lbp'] + description: > + Record of the Liquidity Boostrapping Pools (LBP) of Balancer, an automated portfolio manager and trading platform, on Ethereum. + columns: + - name: name + description: "Name of the LBP" + - name: pool_id + description: "ID of the LBP" + - name: token_sold + description: "Contract address of the token sold by the LBP" + - name: token_symbol + description: "Symbol of the token sold by the LBP" + - name: start_time + description: "LBP start time" + - name: end_time + description: "LBP end time" \ No newline at end of file diff --git a/models/balancer/ethereum/balancer_ethereum_pools_tokens_weights.sql b/models/_project/balancer/pools/ethereum/balancer_ethereum_pools_tokens_weights.sql similarity index 100% rename from models/balancer/ethereum/balancer_ethereum_pools_tokens_weights.sql rename to models/_project/balancer/pools/ethereum/balancer_ethereum_pools_tokens_weights.sql diff --git a/models/balancer/ethereum/balancer_v1_ethereum_pools_tokens_weights.sql b/models/_project/balancer/pools/ethereum/balancer_v1_ethereum_pools_tokens_weights.sql similarity index 93% rename from models/balancer/ethereum/balancer_v1_ethereum_pools_tokens_weights.sql rename to models/_project/balancer/pools/ethereum/balancer_v1_ethereum_pools_tokens_weights.sql index 01b031110e7..eb0bd2626f6 100644 --- a/models/balancer/ethereum/balancer_v1_ethereum_pools_tokens_weights.sql +++ b/models/_project/balancer/pools/ethereum/balancer_v1_ethereum_pools_tokens_weights.sql @@ -2,15 +2,10 @@ config( schema='balancer_v1_ethereum', alias = 'pools_tokens_weights', - materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['pool_id', 'token_address'], - post_hook='{{ expose_spells(\'["ethereum"]\', - "project", - "balancer_v1", - \'["metacrypto", "jacektrocinski"]\') }}' + unique_key = ['pool_id', 'token_address'] ) }} diff --git a/models/balancer/ethereum/balancer_v2_ethereum_lbps.sql b/models/_project/balancer/pools/ethereum/balancer_v2_ethereum_lbps.sql similarity index 100% rename from models/balancer/ethereum/balancer_v2_ethereum_lbps.sql rename to models/_project/balancer/pools/ethereum/balancer_v2_ethereum_lbps.sql diff --git a/models/balancer/ethereum/balancer_v2_ethereum_pools_fees.sql b/models/_project/balancer/pools/ethereum/balancer_v2_ethereum_pools_fees.sql similarity index 78% rename from models/balancer/ethereum/balancer_v2_ethereum_pools_fees.sql rename to models/_project/balancer/pools/ethereum/balancer_v2_ethereum_pools_fees.sql index 08bee4948e9..8e6041c0a42 100644 --- a/models/balancer/ethereum/balancer_v2_ethereum_pools_fees.sql +++ b/models/_project/balancer/pools/ethereum/balancer_v2_ethereum_pools_fees.sql @@ -1,16 +1,11 @@ {{ config( schema = 'balancer_v2_ethereum', - alias = 'pools_fees', materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['block_number', 'tx_hash', 'index'], - post_hook='{{ expose_spells(\'["ethereum"]\', - "project", - "balancer_v2", - \'["metacrypto", "jacektrocinski", "thetroyharris", "viniabussafi"]\') }}' + unique_key = ['block_number', 'tx_hash', 'index'] )  }} diff --git a/models/balancer/ethereum/balancer_v2_ethereum_pools_tokens_weights.sql b/models/_project/balancer/pools/ethereum/balancer_v2_ethereum_pools_tokens_weights.sql similarity index 99% rename from models/balancer/ethereum/balancer_v2_ethereum_pools_tokens_weights.sql rename to models/_project/balancer/pools/ethereum/balancer_v2_ethereum_pools_tokens_weights.sql index fd0cfd29bb6..3fe74c18771 100644 --- a/models/balancer/ethereum/balancer_v2_ethereum_pools_tokens_weights.sql +++ b/models/_project/balancer/pools/ethereum/balancer_v2_ethereum_pools_tokens_weights.sql @@ -2,7 +2,6 @@ config( schema='balancer_v2_ethereum', alias = 'pools_tokens_weights', - materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/models/_project/balancer/pools/gnosis/_schema.yml b/models/_project/balancer/pools/gnosis/_schema.yml new file mode 100644 index 00000000000..ac61b0140a4 --- /dev/null +++ b/models/_project/balancer/pools/gnosis/_schema.yml @@ -0,0 +1,105 @@ +version: 2 + +models: + - name: balancer_v2_gnosis_pools_fees + meta: + blockchain: gnosis + project: balancer_v2 + contributors: jacektrocinski, thetroyharris, viniabussafi + config: + tags: ['gnosis', 'balancer', 'pools_fees'] + description: > + Balancer v2 swap fees stored at the pool level. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_number + - tx_hash + - index + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'gnosis address for the liquidity pool used in transaction' + tests: + - not_null + - &tx_hash + name: tx_hash + description: 'Transaction hash' + tests: + - not_null + - &index + name: index + description: 'Event Index' + tests: + - not_null + - &tx_index + name: tx_index + description: 'Transaction Index' + tests: + - not_null + - &block_time + name: block_time + description: 'Block time in UTC' + tests: + - not_null + - &block_number + name: block_number + description: 'Event Block Number' + tests: + - not_null + - &swap_fee_percentage + name: swap_fee_percentage + description: 'Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)' + tests: + - not_null + + - name: balancer_gnosis_pools_tokens_weights + meta: + blockchain: gnosis + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['gnosis', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer pools. + columns: + - *blockchain + - *version + - &pool_id + name: pool_id + description: 'Unique encoded identifier that refers to each pool' + tests: + - not_null + - &token_address + name: token_address + description: 'Contract address for the token' + - &normalized_weight + name: normalized_weight + description: 'Weight of the token in the pool.' + + - name: balancer_v2_gnosis_pools_tokens_weights + meta: + blockchain: gnosis + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['gnosis', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer v2 pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_id + - token_address + columns: + - *blockchain + - *version + - *pool_id + - *token_address + - *normalized_weight \ No newline at end of file diff --git a/models/balancer/gnosis/balancer_gnosis_pools_tokens_weights.sql b/models/_project/balancer/pools/gnosis/balancer_gnosis_pools_tokens_weights.sql similarity index 100% rename from models/balancer/gnosis/balancer_gnosis_pools_tokens_weights.sql rename to models/_project/balancer/pools/gnosis/balancer_gnosis_pools_tokens_weights.sql diff --git a/models/balancer/gnosis/balancer_v2_gnosis_pools_fees.sql b/models/_project/balancer/pools/gnosis/balancer_v2_gnosis_pools_fees.sql similarity index 77% rename from models/balancer/gnosis/balancer_v2_gnosis_pools_fees.sql rename to models/_project/balancer/pools/gnosis/balancer_v2_gnosis_pools_fees.sql index de1a7618af6..086072fc70b 100644 --- a/models/balancer/gnosis/balancer_v2_gnosis_pools_fees.sql +++ b/models/_project/balancer/pools/gnosis/balancer_v2_gnosis_pools_fees.sql @@ -1,17 +1,12 @@ {{ config( schema = 'balancer_v2_gnosis', - alias = 'pools_fees', materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['block_number', 'tx_hash', 'index'], - post_hook='{{ expose_spells(\'["gnosis"]\', - "project", - "balancer_v2", - \'["metacrypto", "jacektrocinski", "thetroyharris", "viniabussafi"]\') }}' - )  + unique_key = ['block_number', 'tx_hash', 'index'] + ) }} {% set event_signature = '0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc' %} diff --git a/models/balancer/gnosis/balancer_v2_gnosis_pools_tokens_weights.sql b/models/_project/balancer/pools/gnosis/balancer_v2_gnosis_pools_tokens_weights.sql similarity index 99% rename from models/balancer/gnosis/balancer_v2_gnosis_pools_tokens_weights.sql rename to models/_project/balancer/pools/gnosis/balancer_v2_gnosis_pools_tokens_weights.sql index ee2bef6e0a7..a4b0a7688a8 100644 --- a/models/balancer/gnosis/balancer_v2_gnosis_pools_tokens_weights.sql +++ b/models/_project/balancer/pools/gnosis/balancer_v2_gnosis_pools_tokens_weights.sql @@ -2,7 +2,6 @@ config( schema='balancer_v2_gnosis', alias = 'pools_tokens_weights', - materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/models/_project/balancer/pools/optimism/_schema.yml b/models/_project/balancer/pools/optimism/_schema.yml new file mode 100644 index 00000000000..289820cd3bc --- /dev/null +++ b/models/_project/balancer/pools/optimism/_schema.yml @@ -0,0 +1,146 @@ +version: 2 + +models: + - name: balancer_v2_optimism_pools_fees + meta: + blockchain: optimism + project: balancer_v2 + contributors: jacektrocinski, thetroyharris, viniabussafi + config: + tags: ['optimism', 'balancer', 'pools_fees'] + description: > + Balancer v2 swap fees stored at the pool level. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_number + - tx_hash + - index + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'optimism address for the liquidity pool used in transaction' + tests: + - not_null + - &tx_hash + name: tx_hash + description: 'Transaction hash' + tests: + - not_null + - &index + name: index + description: 'Event Index' + tests: + - not_null + - &tx_index + name: tx_index + description: 'Transaction Index' + tests: + - not_null + - &block_time + name: block_time + description: 'Block time in UTC' + tests: + - not_null + - &block_number + name: block_number + description: 'Event Block Number' + tests: + - not_null + - &swap_fee_percentage + name: swap_fee_percentage + description: 'Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)' + tests: + - not_null + + - name: balancer_optimism_pools_tokens_weights + meta: + blockchain: optimism + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['optimism', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer pools. + columns: + - *blockchain + - *version + - &pool_id + name: pool_id + description: 'Unique encoded identifier that refers to each pool' + tests: + - not_null + - &token_address + name: token_address + description: 'Contract address for the token' + - &normalized_weight + name: normalized_weight + description: 'Weight of the token in the pool.' + + - name: balancer_v2_optimism_pools_tokens_weights + meta: + blockchain: optimism + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['optimism', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer v2 pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_id + - token_address + columns: + - *blockchain + - *version + - *pool_id + - *token_address + - *normalized_weight + + - name: balancer_optimism_gauge_mappings + meta: + blockchain: optimism + project: balancer + contributors: msilb7 + config: + tags: ['optimism', 'balancer', 'gauges', 'incentives'] + description: > + Balancer gauge to pool mappings on Optimism. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_contract + - incentives_contract + columns: + - *blockchain + - *version + - &pool_contract + name: pool_contract + description: "Address of the liquidity pool contract" + - *pool_id + - &incentives_contract + name: incentives_contract + description: "Address of the contract where incentives are stored and emitted." + - &incentives_type + name: incentives_type + description: "Description of the incentives address type." + - &evt_block_time + name: evt_block_time + description: "Block time in UTC" + - &evt_block_number + name: evt_block_number + description: 'Event Block Number' + - *contract_address + - &evt_tx_hash + name: evt_tx_hash + description: 'Transaction hash' + - &evt_index + name: evT_index + description: 'Event Index' \ No newline at end of file diff --git a/models/balancer/optimism/balancer_optimism_gauge_mappings.sql b/models/_project/balancer/pools/optimism/balancer_optimism_gauge_mappings.sql similarity index 87% rename from models/balancer/optimism/balancer_optimism_gauge_mappings.sql rename to models/_project/balancer/pools/optimism/balancer_optimism_gauge_mappings.sql index 382424a91be..10ecdde4e86 100644 --- a/models/balancer/optimism/balancer_optimism_gauge_mappings.sql +++ b/models/_project/balancer/pools/optimism/balancer_optimism_gauge_mappings.sql @@ -1,16 +1,15 @@ {{ config( schema = 'balancer_optimism', - alias = 'gauge_mappings', materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', unique_key = ['pool_contract', 'incentives_contract'], post_hook='{{ expose_spells(\'["optimism"]\', - "project", - "balancer", - \'["msilb7"]\') }}' + spell_type = "project", + spell_name = "balancer", + contributors = \'["msilb7"]\') }}' )  }} diff --git a/models/balancer/optimism/balancer_optimism_pools_tokens_weights.sql b/models/_project/balancer/pools/optimism/balancer_optimism_pools_tokens_weights.sql similarity index 86% rename from models/balancer/optimism/balancer_optimism_pools_tokens_weights.sql rename to models/_project/balancer/pools/optimism/balancer_optimism_pools_tokens_weights.sql index b6bdf48de02..204da50aa15 100644 --- a/models/balancer/optimism/balancer_optimism_pools_tokens_weights.sql +++ b/models/_project/balancer/pools/optimism/balancer_optimism_pools_tokens_weights.sql @@ -1,7 +1,6 @@ {{ config( schema = 'balancer_optimism', - alias = 'pools_tokens_weights', - + alias = 'pools_tokens_weights' ) }} diff --git a/models/balancer/optimism/balancer_v2_optimism_pools_fees.sql b/models/_project/balancer/pools/optimism/balancer_v2_optimism_pools_fees.sql similarity index 77% rename from models/balancer/optimism/balancer_v2_optimism_pools_fees.sql rename to models/_project/balancer/pools/optimism/balancer_v2_optimism_pools_fees.sql index adeeb98918e..7cde533a681 100644 --- a/models/balancer/optimism/balancer_v2_optimism_pools_fees.sql +++ b/models/_project/balancer/pools/optimism/balancer_v2_optimism_pools_fees.sql @@ -1,17 +1,12 @@ {{ config( schema = 'balancer_v2_optimism', - alias = 'pools_fees', materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['block_number', 'tx_hash', 'index'], - post_hook='{{ expose_spells(\'["optimism"]\', - "project", - "balancer_v2", - \'["metacrypto", "jacektrocinski", "thetroyharris", "viniabussafi"]\') }}' - )  + unique_key = ['block_number', 'tx_hash', 'index'] + ) }} {% set event_signature = '0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc' %} diff --git a/models/balancer/optimism/balancer_v2_optimism_pools_tokens_weights.sql b/models/_project/balancer/pools/optimism/balancer_v2_optimism_pools_tokens_weights.sql similarity index 99% rename from models/balancer/optimism/balancer_v2_optimism_pools_tokens_weights.sql rename to models/_project/balancer/pools/optimism/balancer_v2_optimism_pools_tokens_weights.sql index 74220656f88..0888c1c2a0b 100644 --- a/models/balancer/optimism/balancer_v2_optimism_pools_tokens_weights.sql +++ b/models/_project/balancer/pools/optimism/balancer_v2_optimism_pools_tokens_weights.sql @@ -2,7 +2,6 @@ config( schema='balancer_v2_optimism', alias = 'pools_tokens_weights', - materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/models/_project/balancer/pools/polygon/_schema.yml b/models/_project/balancer/pools/polygon/_schema.yml new file mode 100644 index 00000000000..40929f01c30 --- /dev/null +++ b/models/_project/balancer/pools/polygon/_schema.yml @@ -0,0 +1,128 @@ +version: 2 + +models: + - name: balancer_v2_polygon_pools_fees + meta: + blockchain: polygon + project: balancer_v2 + contributors: jacektrocinski, thetroyharris, viniabussafi + config: + tags: ['polygon', 'balancer', 'pools', 'fees'] + description: > + Balancer v2 swap fees stored at the pool level. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_number + - tx_hash + - index + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'zkevm address for the liquidity pool used in transaction' + tests: + - not_null + - &tx_hash + name: tx_hash + description: 'Transaction hash' + tests: + - not_null + - &index + name: index + description: 'Event Index' + tests: + - not_null + - &tx_index + name: tx_index + description: 'Transaction Index' + tests: + - not_null + - &block_time + name: block_time + description: 'Block time in UTC' + tests: + - not_null + - &block_number + name: block_number + description: 'Event Block Number' + tests: + - not_null + - &swap_fee_percentage + name: swap_fee_percentage + description: 'Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)' + tests: + - not_null + + - name: balancer_polygon_pools_tokens_weights + meta: + blockchain: polygon + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['polygon', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer pools. + columns: + - *blockchain + - *version + - &pool_id + name: pool_id + description: 'Unique encoded identifier that refers to each pool' + tests: + - not_null + - &token_address + name: token_address + description: 'Contract address for the token' + - &normalized_weight + name: normalized_weight + description: 'Weight of the token in the pool.' + + - name: balancer_v2_polygon_pools_tokens_weights + meta: + blockchain: polygon + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['polygon', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer v2 pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_id + - token_address + columns: + - *blockchain + - *version + - *pool_id + - *token_address + - *normalized_weight + + - name: balancer_v2_polygon_lbps + meta: + blockchain: polygon + project: balancer_v2 + contributors: stefenon + config: + tags: ['polygon', 'balancer', 'lbp'] + description: > + Record of the Liquidity Boostrapping Pools (LBP) of Balancer, an automated portfolio manager and trading platform, on polygon. + columns: + - name: name + description: "Name of the LBP" + - name: pool_id + description: "ID of the LBP" + - name: token_sold + description: "Contract address of the token sold by the LBP" + - name: token_symbol + description: "Symbol of the token sold by the LBP" + - name: start_time + description: "LBP start time" + - name: end_time + description: "LBP end time" \ No newline at end of file diff --git a/models/balancer/polygon/balancer_polygon_pools_tokens_weights.sql b/models/_project/balancer/pools/polygon/balancer_polygon_pools_tokens_weights.sql similarity index 100% rename from models/balancer/polygon/balancer_polygon_pools_tokens_weights.sql rename to models/_project/balancer/pools/polygon/balancer_polygon_pools_tokens_weights.sql diff --git a/models/balancer/polygon/balancer_v2_polygon_lbps.sql b/models/_project/balancer/pools/polygon/balancer_v2_polygon_lbps.sql similarity index 100% rename from models/balancer/polygon/balancer_v2_polygon_lbps.sql rename to models/_project/balancer/pools/polygon/balancer_v2_polygon_lbps.sql diff --git a/models/balancer/polygon/balancer_v2_polygon_pools_fees.sql b/models/_project/balancer/pools/polygon/balancer_v2_polygon_pools_fees.sql similarity index 77% rename from models/balancer/polygon/balancer_v2_polygon_pools_fees.sql rename to models/_project/balancer/pools/polygon/balancer_v2_polygon_pools_fees.sql index 556cb0003af..586839b9ff9 100644 --- a/models/balancer/polygon/balancer_v2_polygon_pools_fees.sql +++ b/models/_project/balancer/pools/polygon/balancer_v2_polygon_pools_fees.sql @@ -1,17 +1,12 @@ {{ config( schema = 'balancer_v2_polygon', - alias = 'pools_fees', materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['block_number', 'tx_hash', 'index'], - post_hook='{{ expose_spells(\'["polygon"]\', - "project", - "balancer_v2", - \'["metacrypto", "jacektrocinski", "thetroyharris", "viniabussafi"]\') }}' - )  + unique_key = ['block_number', 'tx_hash', 'index'] + ) }} {% set event_signature = '0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc' %} diff --git a/models/balancer/polygon/balancer_v2_polygon_pools_tokens_weights.sql b/models/_project/balancer/pools/polygon/balancer_v2_polygon_pools_tokens_weights.sql similarity index 99% rename from models/balancer/polygon/balancer_v2_polygon_pools_tokens_weights.sql rename to models/_project/balancer/pools/polygon/balancer_v2_polygon_pools_tokens_weights.sql index afc223ecb81..20023ba61c3 100644 --- a/models/balancer/polygon/balancer_v2_polygon_pools_tokens_weights.sql +++ b/models/_project/balancer/pools/polygon/balancer_v2_polygon_pools_tokens_weights.sql @@ -2,7 +2,6 @@ config( schema='balancer_v2_polygon', alias = 'pools_tokens_weights', - materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', diff --git a/models/_project/balancer/pools/zkevm/_schema.yml b/models/_project/balancer/pools/zkevm/_schema.yml new file mode 100644 index 00000000000..03f7ab4e6be --- /dev/null +++ b/models/_project/balancer/pools/zkevm/_schema.yml @@ -0,0 +1,105 @@ +version: 2 + +models: + - name: balancer_v2_zkevm_pools_fees + meta: + blockchain: zkevm + project: balancer_v2 + contributors: jacektrocinski, thetroyharris, viniabussafi + config: + tags: ['zkevm', 'balancer', 'pools_fees'] + description: > + Balancer v2 swap fees stored at the pool level. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_number + - tx_hash + - index + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &version + name: version + description: "Version of Balancer where the liquidity pool used in transaction is deployed" + - &contract_address + name: contract_address + description: 'zkevm address for the liquidity pool used in transaction' + tests: + - not_null + - &tx_hash + name: tx_hash + description: 'Transaction hash' + tests: + - not_null + - &index + name: index + description: 'Event Index' + tests: + - not_null + - &tx_index + name: tx_index + description: 'Transaction Index' + tests: + - not_null + - &block_time + name: block_time + description: 'Block time in UTC' + tests: + - not_null + - &block_number + name: block_number + description: 'Event Block Number' + tests: + - not_null + - &swap_fee_percentage + name: swap_fee_percentage + description: 'Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)' + tests: + - not_null + + - name: balancer_zkevm_pools_tokens_weights + meta: + blockchain: zkevm + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['zkevm', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer pools. + columns: + - *blockchain + - *version + - &pool_id + name: pool_id + description: 'Unique encoded identifier that refers to each pool' + tests: + - not_null + - &token_address + name: token_address + description: 'Contract address for the token' + - &normalized_weight + name: normalized_weight + description: 'Weight of the token in the pool.' + + - name: balancer_v2_zkevm_pools_tokens_weights + meta: + blockchain: zkevm + project: balancer + contributors: jacektrocinski, viniabussafi + config: + tags: ['zkevm', 'balancer', 'pools', 'tokens', 'weights'] + description: > + Token weights in Balancer v2 pools. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_id + - token_address + columns: + - *blockchain + - *version + - *pool_id + - *token_address + - *normalized_weight \ No newline at end of file diff --git a/models/balancer/zkevm/balancer_v2_zkevm_pools_fees.sql b/models/_project/balancer/pools/zkevm/balancer_v2_zkevm_pools_fees.sql similarity index 82% rename from models/balancer/zkevm/balancer_v2_zkevm_pools_fees.sql rename to models/_project/balancer/pools/zkevm/balancer_v2_zkevm_pools_fees.sql index a92e4c5c00c..87bf3434eba 100644 --- a/models/balancer/zkevm/balancer_v2_zkevm_pools_fees.sql +++ b/models/_project/balancer/pools/zkevm/balancer_v2_zkevm_pools_fees.sql @@ -6,11 +6,7 @@ file_format = 'delta', incremental_strategy = 'merge', unique_key = ['block_number', 'tx_hash', 'index'], - post_hook='{{ expose_spells(\'["zkevm"]\', - "project", - "balancer_v2", - \'["metacrypto", "jacektrocinski", "thetroyharris", "viniabussafi"]\') }}' - )  + ) }} {% set event_signature = '0xa9ba3ffe0b6c366b81232caab38605a0699ad5398d6cce76f91ee809e322dafc' %} diff --git a/models/balancer/zkevm/balancer_v2_zkevm_pools_tokens_weights.sql b/models/_project/balancer/pools/zkevm/balancer_v2_zkevm_pools_tokens_weights.sql similarity index 100% rename from models/balancer/zkevm/balancer_v2_zkevm_pools_tokens_weights.sql rename to models/_project/balancer/pools/zkevm/balancer_v2_zkevm_pools_tokens_weights.sql diff --git a/models/balancer/zkevm/balancer_zkevm_pools_tokens_weights.sql b/models/_project/balancer/pools/zkevm/balancer_zkevm_pools_tokens_weights.sql similarity index 100% rename from models/balancer/zkevm/balancer_zkevm_pools_tokens_weights.sql rename to models/_project/balancer/pools/zkevm/balancer_zkevm_pools_tokens_weights.sql diff --git a/models/_project/balancer/protocol_fee/_schema.yml b/models/_project/balancer/protocol_fee/_schema.yml new file mode 100644 index 00000000000..ddc320d1692 --- /dev/null +++ b/models/_project/balancer/protocol_fee/_schema.yml @@ -0,0 +1,61 @@ +version: 2 + +models: + - name: balancer_protocol_fee + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevm + project: balancer + contributors: viniabussafi + config: + tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'fees'] + description: > + Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token in which protocol fees were collected" + - &token_symbol + name: token_symbol + description: Token symbol of the token in which protocol fees were collected" + - &token_amount_raw + name: token_amount_raw + description: "Raw amount of fees of the token in the pool at time of execution in the original currency" + - &token_amount + name: token_amount + description: "Normalized amount of fees of the token in the pool at time of execution in the original currency" + - &protocol_fee_collected_usd + name: protocol_fee_collected_usd + description: "USD value of the collected fee" + - &treasury_share + name: treasury_share + description: "Share of total fee that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" + - &treasury_revenue_usd + name: treasury_revenue_usd + description: "USD value of fee directed to Balancer DAO's treasury" \ No newline at end of file diff --git a/models/_project/balancer/protocol_fee/arbitrum/_schema.yml b/models/_project/balancer/protocol_fee/arbitrum/_schema.yml new file mode 100644 index 00000000000..b529565a645 --- /dev/null +++ b/models/_project/balancer/protocol_fee/arbitrum/_schema.yml @@ -0,0 +1,61 @@ +version: 2 + +models: + - name: balancer_v2_arbitrum_protocol_fee + meta: + blockchain: arbitrum + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['arbitrum', 'protocol', 'fees'] + description: > + Daily Protocol Fee collected and Treasury Revenue by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token in which protocol fees were collected" + - &token_symbol + name: token_symbol + description: Token symbol of the token in which protocol fees were collected" + - &token_amount_raw + name: token_amount_raw + description: "Raw amount of fees of the token in the pool at time of execution in the original currency" + - &token_amount + name: token_amount + description: "Normalized amount of fees of the token in the pool at time of execution in the original currency" + - &protocol_fee_collected_usd + name: protocol_fee_collected_usd + description: "USD value of the collected fee" + - &treasury_share + name: treasury_share + description: "Share of total fee that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" + - &treasury_revenue_usd + name: treasury_revenue_usd + description: "USD value of fee directed to Balancer DAO's treasury" \ No newline at end of file diff --git a/models/balancer/arbitrum/balancer_v2_arbitrum_protocol_fee.sql b/models/_project/balancer/protocol_fee/arbitrum/balancer_v2_arbitrum_protocol_fee.sql similarity index 100% rename from models/balancer/arbitrum/balancer_v2_arbitrum_protocol_fee.sql rename to models/_project/balancer/protocol_fee/arbitrum/balancer_v2_arbitrum_protocol_fee.sql diff --git a/models/_project/balancer/protocol_fee/avalanche_c/_schema.yml b/models/_project/balancer/protocol_fee/avalanche_c/_schema.yml new file mode 100644 index 00000000000..536823df10d --- /dev/null +++ b/models/_project/balancer/protocol_fee/avalanche_c/_schema.yml @@ -0,0 +1,61 @@ +version: 2 + +models: + - name: balancer_v2_avalanche_c_protocol_fee + meta: + blockchain: avalanche_c + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['avalanche_c', 'revenue', 'fees'] + description: > + Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token in which protocol fees were collected" + - &token_symbol + name: token_symbol + description: Token symbol of the token in which protocol fees were collected" + - &token_amount_raw + name: token_amount_raw + description: "Raw amount of fees of the token in the pool at time of execution in the original currency" + - &token_amount + name: token_amount + description: "Normalized amount of fees of the token in the pool at time of execution in the original currency" + - &protocol_fee_collected_usd + name: protocol_fee_collected_usd + description: "USD value of the collected fee" + - &treasury_share + name: treasury_share + description: "Share of total fee that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" + - &treasury_revenue_usd + name: treasury_revenue_usd + description: "USD value of fee directed to Balancer DAO's treasury" \ No newline at end of file diff --git a/models/balancer/avalanche_c/balancer_v2_avalanche_c_protocol_fee.sql b/models/_project/balancer/protocol_fee/avalanche_c/balancer_v2_avalanche_c_protocol_fee.sql similarity index 100% rename from models/balancer/avalanche_c/balancer_v2_avalanche_c_protocol_fee.sql rename to models/_project/balancer/protocol_fee/avalanche_c/balancer_v2_avalanche_c_protocol_fee.sql diff --git a/models/balancer/balancer_protocol_fee.sql b/models/_project/balancer/protocol_fee/balancer_protocol_fee.sql similarity index 75% rename from models/balancer/balancer_protocol_fee.sql rename to models/_project/balancer/protocol_fee/balancer_protocol_fee.sql index d871a6aef89..37fef24dc85 100644 --- a/models/balancer/balancer_protocol_fee.sql +++ b/models/_project/balancer/protocol_fee/balancer_protocol_fee.sql @@ -1,10 +1,10 @@ {{ config( schema = 'balancer', alias = 'protocol_fee', - post_hook='{{ expose_spells(\'["ethereum", "arbitrum", "polygon", "gnosis", "optimism","avalanche_c", "base"]\', - "project", - "balancer", - \'["viniabussafi"]\') }}' + post_hook='{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["viniabussafi"]\') }}' ) }} diff --git a/models/_project/balancer/protocol_fee/base/_schema.yml b/models/_project/balancer/protocol_fee/base/_schema.yml new file mode 100644 index 00000000000..cebb1c312e9 --- /dev/null +++ b/models/_project/balancer/protocol_fee/base/_schema.yml @@ -0,0 +1,61 @@ +version: 2 + +models: + - name: balancer_v2_base_protocol_fee + meta: + blockchain: base + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['base', 'revenue', 'fees'] + description: > + Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token in which protocol fees were collected" + - &token_symbol + name: token_symbol + description: Token symbol of the token in which protocol fees were collected" + - &token_amount_raw + name: token_amount_raw + description: "Raw amount of fees of the token in the pool at time of execution in the original currency" + - &token_amount + name: token_amount + description: "Normalized amount of fees of the token in the pool at time of execution in the original currency" + - &protocol_fee_collected_usd + name: protocol_fee_collected_usd + description: "USD value of the collected fee" + - &treasury_share + name: treasury_share + description: "Share of total fee that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" + - &treasury_revenue_usd + name: treasury_revenue_usd + description: "USD value of fee directed to Balancer DAO's treasury" \ No newline at end of file diff --git a/models/balancer/base/balancer_v2_base_protocol_fee.sql b/models/_project/balancer/protocol_fee/base/balancer_v2_base_protocol_fee.sql similarity index 100% rename from models/balancer/base/balancer_v2_base_protocol_fee.sql rename to models/_project/balancer/protocol_fee/base/balancer_v2_base_protocol_fee.sql diff --git a/models/_project/balancer/protocol_fee/ethereum/_schema.yml b/models/_project/balancer/protocol_fee/ethereum/_schema.yml new file mode 100644 index 00000000000..b6830c20e7e --- /dev/null +++ b/models/_project/balancer/protocol_fee/ethereum/_schema.yml @@ -0,0 +1,61 @@ +version: 2 + +models: + - name: balancer_v2_ethereum_protocol_fee + meta: + blockchain: ethereum + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['ethereum', 'revenue', 'fees'] + description: > + Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token in which protocol fees were collected" + - &token_symbol + name: token_symbol + description: Token symbol of the token in which protocol fees were collected" + - &token_amount_raw + name: token_amount_raw + description: "Raw amount of fees of the token in the pool at time of execution in the original currency" + - &token_amount + name: token_amount + description: "Normalized amount of fees of the token in the pool at time of execution in the original currency" + - &protocol_fee_collected_usd + name: protocol_fee_collected_usd + description: "USD value of the collected fee" + - &treasury_share + name: treasury_share + description: "Share of total fee that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" + - &treasury_revenue_usd + name: treasury_revenue_usd + description: "USD value of fee directed to Balancer DAO's treasury" \ No newline at end of file diff --git a/models/balancer/ethereum/balancer_v2_ethereum_protocol_fee.sql b/models/_project/balancer/protocol_fee/ethereum/balancer_v2_ethereum_protocol_fee.sql similarity index 100% rename from models/balancer/ethereum/balancer_v2_ethereum_protocol_fee.sql rename to models/_project/balancer/protocol_fee/ethereum/balancer_v2_ethereum_protocol_fee.sql diff --git a/models/_project/balancer/protocol_fee/gnosis/_schema.yml b/models/_project/balancer/protocol_fee/gnosis/_schema.yml new file mode 100644 index 00000000000..defa5e74781 --- /dev/null +++ b/models/_project/balancer/protocol_fee/gnosis/_schema.yml @@ -0,0 +1,61 @@ +version: 2 + +models: + - name: balancer_v2_gnosis_protocol_fee + meta: + blockchain: gnosis + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['gnosis', 'revenue', 'fees'] + description: > + Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token in which protocol fees were collected" + - &token_symbol + name: token_symbol + description: Token symbol of the token in which protocol fees were collected" + - &token_amount_raw + name: token_amount_raw + description: "Raw amount of fees of the token in the pool at time of execution in the original currency" + - &token_amount + name: token_amount + description: "Normalized amount of fees of the token in the pool at time of execution in the original currency" + - &protocol_fee_collected_usd + name: protocol_fee_collected_usd + description: "USD value of the collected fee" + - &treasury_share + name: treasury_share + description: "Share of total fee that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" + - &treasury_revenue_usd + name: treasury_revenue_usd + description: "USD value of fee directed to Balancer DAO's treasury" \ No newline at end of file diff --git a/models/balancer/gnosis/balancer_v2_gnosis_protocol_fee.sql b/models/_project/balancer/protocol_fee/gnosis/balancer_v2_gnosis_protocol_fee.sql similarity index 100% rename from models/balancer/gnosis/balancer_v2_gnosis_protocol_fee.sql rename to models/_project/balancer/protocol_fee/gnosis/balancer_v2_gnosis_protocol_fee.sql diff --git a/models/_project/balancer/protocol_fee/optimism/_schema.yml b/models/_project/balancer/protocol_fee/optimism/_schema.yml new file mode 100644 index 00000000000..6b096a72bc6 --- /dev/null +++ b/models/_project/balancer/protocol_fee/optimism/_schema.yml @@ -0,0 +1,61 @@ +version: 2 + +models: + - name: balancer_v2_optimism_protocol_fee + meta: + blockchain: optimism + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['optimism', 'revenue', 'fees'] + description: > + Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token in which protocol fees were collected" + - &token_symbol + name: token_symbol + description: Token symbol of the token in which protocol fees were collected" + - &token_amount_raw + name: token_amount_raw + description: "Raw amount of fees of the token in the pool at time of execution in the original currency" + - &token_amount + name: token_amount + description: "Normalized amount of fees of the token in the pool at time of execution in the original currency" + - &protocol_fee_collected_usd + name: protocol_fee_collected_usd + description: "USD value of the collected fee" + - &treasury_share + name: treasury_share + description: "Share of total fee that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" + - &treasury_revenue_usd + name: treasury_revenue_usd + description: "USD value of fee directed to Balancer DAO's treasury" \ No newline at end of file diff --git a/models/balancer/optimism/balancer_v2_optimism_protocol_fee.sql b/models/_project/balancer/protocol_fee/optimism/balancer_v2_optimism_protocol_fee.sql similarity index 100% rename from models/balancer/optimism/balancer_v2_optimism_protocol_fee.sql rename to models/_project/balancer/protocol_fee/optimism/balancer_v2_optimism_protocol_fee.sql diff --git a/models/_project/balancer/protocol_fee/polygon/_schema.yml b/models/_project/balancer/protocol_fee/polygon/_schema.yml new file mode 100644 index 00000000000..b541beceb65 --- /dev/null +++ b/models/_project/balancer/protocol_fee/polygon/_schema.yml @@ -0,0 +1,61 @@ +version: 2 + +models: + - name: balancer_v2_polygon_protocol_fee + meta: + blockchain: polygon + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['polygon', 'revenue', 'fees'] + description: > + Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token in which protocol fees were collected" + - &token_symbol + name: token_symbol + description: Token symbol of the token in which protocol fees were collected" + - &token_amount_raw + name: token_amount_raw + description: "Raw amount of fees of the token in the pool at time of execution in the original currency" + - &token_amount + name: token_amount + description: "Normalized amount of fees of the token in the pool at time of execution in the original currency" + - &protocol_fee_collected_usd + name: protocol_fee_collected_usd + description: "USD value of the collected fee" + - &treasury_share + name: treasury_share + description: "Share of total fee that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" + - &treasury_revenue_usd + name: treasury_revenue_usd + description: "USD value of fee directed to Balancer DAO's treasury" \ No newline at end of file diff --git a/models/balancer/polygon/balancer_v2_polygon_protocol_fee.sql b/models/_project/balancer/protocol_fee/polygon/balancer_v2_polygon_protocol_fee.sql similarity index 100% rename from models/balancer/polygon/balancer_v2_polygon_protocol_fee.sql rename to models/_project/balancer/protocol_fee/polygon/balancer_v2_polygon_protocol_fee.sql diff --git a/models/_project/balancer/protocol_fee/zkevm/_schema.yml b/models/_project/balancer/protocol_fee/zkevm/_schema.yml new file mode 100644 index 00000000000..b8c5d67a600 --- /dev/null +++ b/models/_project/balancer/protocol_fee/zkevm/_schema.yml @@ -0,0 +1,61 @@ +version: 2 + +models: + - name: balancer_v2_zkevm_protocol_fee + meta: + blockchain: zkevm + project: balancer_v2 + contributors: viniabussafi + config: + tags: ['zkevm', 'revenue', 'fees'] + description: > + Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - pool_id + - token_address + columns: + - &day + name: day + description: "Block date in UTC" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &pool_address + name: pool_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &version + name: version + description: "Version of the project" + - &blockchain + name: blockchain + description: "Blockchain" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &token_address + name: token_address + description: "Contract address of the token in which protocol fees were collected" + - &token_symbol + name: token_symbol + description: Token symbol of the token in which protocol fees were collected" + - &token_amount_raw + name: token_amount_raw + description: "Raw amount of fees of the token in the pool at time of execution in the original currency" + - &token_amount + name: token_amount + description: "Normalized amount of fees of the token in the pool at time of execution in the original currency" + - &protocol_fee_collected_usd + name: protocol_fee_collected_usd + description: "USD value of the collected fee" + - &treasury_share + name: treasury_share + description: "Share of total fee that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" + - &treasury_revenue_usd + name: treasury_revenue_usd + description: "USD value of fee directed to Balancer DAO's treasury" \ No newline at end of file diff --git a/models/balancer/zkevm/balancer_v2_zkevm_protocol_fee.sql b/models/_project/balancer/protocol_fee/zkevm/balancer_v2_zkevm_protocol_fee.sql similarity index 100% rename from models/balancer/zkevm/balancer_v2_zkevm_protocol_fee.sql rename to models/_project/balancer/protocol_fee/zkevm/balancer_v2_zkevm_protocol_fee.sql diff --git a/models/_project/balancer/support/_schema.yml b/models/_project/balancer/support/_schema.yml new file mode 100644 index 00000000000..fbb445cf773 --- /dev/null +++ b/models/_project/balancer/support/_schema.yml @@ -0,0 +1,56 @@ +version: 2 + +models: + - name: balancer_token_whitelist + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, 'zkevm' + contributors: viniabussafi + config: + tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm'] + description: > + These tokens are whitelisted to be used as pricing assets on liquidity calculations for weighted pools, due to the trustability of their data. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - address + - name + - chain + columns: + - &address + name: address + description: "Token address" + - &name + name: name + description: "Token symbol" + - &chain + name: chain + description: "Token blockchain" + + - name: balancer_single_recipient_gauges + meta: + blockchain: ethereum + contributors: viniabussafi + config: + tags: ['ethereum', 'gauges'] + description: > + These gauges are deployed by the SingleRecipientGauge contract and this mapping manually links each gauge to it's correspondent pool and project + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - gauge_address + - pool_id + - project + - blockchain + columns: + - &gauge_address + name: gauge_address + descripton: "Gauge address" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool to which each gauge directs incentives" + - &project + name: project + description: "ve8020 project for each gauge" + - &blockchain + name: blockchain + description: "Blockchain" \ No newline at end of file diff --git a/models/balancer/balancer_single_recipient_gauges.sql b/models/_project/balancer/support/balancer_single_recipient_gauges.sql similarity index 100% rename from models/balancer/balancer_single_recipient_gauges.sql rename to models/_project/balancer/support/balancer_single_recipient_gauges.sql diff --git a/models/balancer/balancer_token_whitelist.sql b/models/_project/balancer/support/balancer_token_whitelist.sql similarity index 100% rename from models/balancer/balancer_token_whitelist.sql rename to models/_project/balancer/support/balancer_token_whitelist.sql diff --git a/models/_project/balancer/trades/arbitrum/_schema.yml b/models/_project/balancer/trades/arbitrum/_schema.yml new file mode 100644 index 00000000000..09ef97905b8 --- /dev/null +++ b/models/_project/balancer/trades/arbitrum/_schema.yml @@ -0,0 +1,149 @@ +version: 2 + +models: + - name: balancer_arbitrum_trades + meta: + blockchain: arbitrum + sector: dex + contributors: bizzyvinci, viniabussafi + config: + tags: ['balancer', 'arbitrum', 'amm', 'trades', 'dex'] + description: > + DEX trades on balancer on arbitrum + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - tx_hash + - evt_index + - check_dex_seed: + blockchain: arbitrum + project: balancer + version: 2 + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &project + name: project + description: "Project name (balancer)" + - &version + name: version + description: "Version of the project" + - &block_month + name: block_month + description: "Block month in UTC" + - &block_date + name: block_date + description: "Block date in UTC" + - &block_time + name: block_time + description: 'Block time in UTC' + - &block_number + name: block_number + description: 'Block number' + - &token_bought_symbol + name: token_bought_symbol + description: "Token symbol for token bought in the trade" + - &token_sold_symbol + name: token_sold_symbol + description: "Token symbol for token sold in the trade" + - &token_pair + name: token_pair + description: "Token symbol pair for each token involved in the trade" + - &token_bought_amount + name: token_bought_amount + description: "Value of the token bought at time of execution in the original currency" + - &token_sold_amount + name: token_sold_amount + description: "Value of the token sold at time of execution in the original currency" + - &token_bought_amount_raw + name: token_bought_amount_raw + description: "Raw value of the token bought at time of execution in the original currency" + - &token_sold_amount_raw + name: token_sold_amount_raw + description: "Raw value of the token sold at time of execution in the original currency" + - &amount_usd + name: amount_usd + description: "USD value of the trade at time of execution" + - &token_bought_address + name: token_bought_address + description: "Contract address of the token bought" + - &token_sold_address + name: token_sold_address + description: "Contract address of the token sold" + - &taker + name: taker + description: "Address of trader who purchased a token" + - &maker + name: maker + description: "Address of trader who sold a token" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &swap_fee + name: swap_fee + description: 'Swap fee' + - &project_contract_address + name: project_contract_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - &tx_from + name: tx_from + description: "transaction.from" + - &tx_to + name: tx_to + description: "transaction.to" + - &evt_index + name: evt_index + description: 'Event index' + + - name: balancer_v2_arbitrum_trades + meta: + blockchain: arbitrum + sector: dex + contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi + config: + tags: [ 'balancer', 'arbitrum', 'amm', 'trades', 'dex', 'beta' ] + description: > + DEX trades on balancer v2 on arbitrum + columns: + - *blockchain + - *project + - *version + - *block_month + - *block_date + - *block_time + - *block_number + - *token_bought_symbol + - *token_sold_symbol + - *token_pair + - *token_bought_amount + - *token_sold_amount + - *token_bought_amount_raw + - *token_sold_amount_raw + - *amount_usd + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *project_contract_address + - *pool_symbol + - *pool_type + - *pool_id + - *swap_fee + - *tx_hash + - *tx_from + - *tx_to + - *evt_index \ No newline at end of file diff --git a/models/balancer/arbitrum/balancer_arbitrum_trades.sql b/models/_project/balancer/trades/arbitrum/balancer_arbitrum_trades.sql similarity index 100% rename from models/balancer/arbitrum/balancer_arbitrum_trades.sql rename to models/_project/balancer/trades/arbitrum/balancer_arbitrum_trades.sql diff --git a/models/balancer/arbitrum/balancer_v2_arbitrum_trades.sql b/models/_project/balancer/trades/arbitrum/balancer_v2_arbitrum_trades.sql similarity index 94% rename from models/balancer/arbitrum/balancer_v2_arbitrum_trades.sql rename to models/_project/balancer/trades/arbitrum/balancer_v2_arbitrum_trades.sql index 750f467f653..2baa6afd2b2 100644 --- a/models/balancer/arbitrum/balancer_v2_arbitrum_trades.sql +++ b/models/_project/balancer/trades/arbitrum/balancer_v2_arbitrum_trades.sql @@ -4,9 +4,9 @@ alias = 'trades', materialized = 'view', post_hook = '{{ expose_spells(\'["arbitrum"]\', - "project", - "balancer_v2", - \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' + spell_type = "project", + spell_name = "balancer", + contributors = \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' ) }} diff --git a/models/_project/balancer/trades/avalanche_c/_schema.yml b/models/_project/balancer/trades/avalanche_c/_schema.yml new file mode 100644 index 00000000000..86aca24b807 --- /dev/null +++ b/models/_project/balancer/trades/avalanche_c/_schema.yml @@ -0,0 +1,149 @@ +version: 2 + +models: + - name: balancer_avalanche_c_trades + meta: + blockchain: avalanche_c + sector: dex + contributors: bizzyvinci, viniabussafi + config: + tags: ['balancer', 'avalanche_c', 'amm', 'trades', 'dex'] + description: > + DEX trades on balancer on avalanche_c + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - tx_hash + - evt_index + - check_dex_seed: + blockchain: avalanche_c + project: balancer + version: 2 + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &project + name: project + description: "Project name (balancer)" + - &version + name: version + description: "Version of the project" + - &block_month + name: block_month + description: "Block month in UTC" + - &block_date + name: block_date + description: "Block date in UTC" + - &block_time + name: block_time + description: 'Block time in UTC' + - &block_number + name: block_number + description: 'Block number' + - &token_bought_symbol + name: token_bought_symbol + description: "Token symbol for token bought in the trade" + - &token_sold_symbol + name: token_sold_symbol + description: "Token symbol for token sold in the trade" + - &token_pair + name: token_pair + description: "Token symbol pair for each token involved in the trade" + - &token_bought_amount + name: token_bought_amount + description: "Value of the token bought at time of execution in the original currency" + - &token_sold_amount + name: token_sold_amount + description: "Value of the token sold at time of execution in the original currency" + - &token_bought_amount_raw + name: token_bought_amount_raw + description: "Raw value of the token bought at time of execution in the original currency" + - &token_sold_amount_raw + name: token_sold_amount_raw + description: "Raw value of the token sold at time of execution in the original currency" + - &amount_usd + name: amount_usd + description: "USD value of the trade at time of execution" + - &token_bought_address + name: token_bought_address + description: "Contract address of the token bought" + - &token_sold_address + name: token_sold_address + description: "Contract address of the token sold" + - &taker + name: taker + description: "Address of trader who purchased a token" + - &maker + name: maker + description: "Address of trader who sold a token" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &swap_fee + name: swap_fee + description: 'Swap fee' + - &project_contract_address + name: project_contract_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - &tx_from + name: tx_from + description: "transaction.from" + - &tx_to + name: tx_to + description: "transaction.to" + - &evt_index + name: evt_index + description: 'Event index' + + - name: balancer_v2_avalanche_c_trades + meta: + blockchain: avalanche_c + sector: dex + contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi + config: + tags: [ 'balancer', 'avalanche_c', 'amm', 'trades', 'dex', 'beta' ] + description: > + DEX trades on balancer v2 on avalanche_c + columns: + - *blockchain + - *project + - *version + - *block_month + - *block_date + - *block_time + - *block_number + - *token_bought_symbol + - *token_sold_symbol + - *token_pair + - *token_bought_amount + - *token_sold_amount + - *token_bought_amount_raw + - *token_sold_amount_raw + - *amount_usd + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *project_contract_address + - *pool_symbol + - *pool_type + - *pool_id + - *swap_fee + - *tx_hash + - *tx_from + - *tx_to + - *evt_index \ No newline at end of file diff --git a/models/balancer/avalanche_c/balancer_avalanche_c_trades.sql b/models/_project/balancer/trades/avalanche_c/balancer_avalanche_c_trades.sql similarity index 100% rename from models/balancer/avalanche_c/balancer_avalanche_c_trades.sql rename to models/_project/balancer/trades/avalanche_c/balancer_avalanche_c_trades.sql diff --git a/models/balancer/avalanche_c/balancer_v2_avalanche_c_trades.sql b/models/_project/balancer/trades/avalanche_c/balancer_v2_avalanche_c_trades.sql similarity index 94% rename from models/balancer/avalanche_c/balancer_v2_avalanche_c_trades.sql rename to models/_project/balancer/trades/avalanche_c/balancer_v2_avalanche_c_trades.sql index 54dfd905dbc..d1a0eb61af5 100644 --- a/models/balancer/avalanche_c/balancer_v2_avalanche_c_trades.sql +++ b/models/_project/balancer/trades/avalanche_c/balancer_v2_avalanche_c_trades.sql @@ -4,10 +4,10 @@ alias = 'trades', materialized = 'view', post_hook = '{{ expose_spells(\'["avalanche_c"]\', - "project", - "balancer_v2", - \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' - ) + spell_type = "project", + spell_name = "balancer", + contributors = \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' + ) }} WITH diff --git a/models/_project/balancer/balancer_trades.sql b/models/_project/balancer/trades/balancer_trades.sql similarity index 100% rename from models/_project/balancer/balancer_trades.sql rename to models/_project/balancer/trades/balancer_trades.sql diff --git a/models/_project/balancer/trades/base/_schema.yml b/models/_project/balancer/trades/base/_schema.yml new file mode 100644 index 00000000000..4a0bd85156f --- /dev/null +++ b/models/_project/balancer/trades/base/_schema.yml @@ -0,0 +1,149 @@ +version: 2 + +models: + - name: balancer_base_trades + meta: + blockchain: base + sector: dex + contributors: bizzyvinci, viniabussafi + config: + tags: ['balancer', 'base', 'amm', 'trades', 'dex'] + description: > + DEX trades on balancer on base + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - tx_hash + - evt_index + - check_dex_seed: + blockchain: base + project: balancer + version: 2 + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &project + name: project + description: "Project name (balancer)" + - &version + name: version + description: "Version of the project" + - &block_month + name: block_month + description: "Block month in UTC" + - &block_date + name: block_date + description: "Block date in UTC" + - &block_time + name: block_time + description: 'Block time in UTC' + - &block_number + name: block_number + description: 'Block number' + - &token_bought_symbol + name: token_bought_symbol + description: "Token symbol for token bought in the trade" + - &token_sold_symbol + name: token_sold_symbol + description: "Token symbol for token sold in the trade" + - &token_pair + name: token_pair + description: "Token symbol pair for each token involved in the trade" + - &token_bought_amount + name: token_bought_amount + description: "Value of the token bought at time of execution in the original currency" + - &token_sold_amount + name: token_sold_amount + description: "Value of the token sold at time of execution in the original currency" + - &token_bought_amount_raw + name: token_bought_amount_raw + description: "Raw value of the token bought at time of execution in the original currency" + - &token_sold_amount_raw + name: token_sold_amount_raw + description: "Raw value of the token sold at time of execution in the original currency" + - &amount_usd + name: amount_usd + description: "USD value of the trade at time of execution" + - &token_bought_address + name: token_bought_address + description: "Contract address of the token bought" + - &token_sold_address + name: token_sold_address + description: "Contract address of the token sold" + - &taker + name: taker + description: "Address of trader who purchased a token" + - &maker + name: maker + description: "Address of trader who sold a token" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &swap_fee + name: swap_fee + description: 'Swap fee' + - &project_contract_address + name: project_contract_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - &tx_from + name: tx_from + description: "transaction.from" + - &tx_to + name: tx_to + description: "transaction.to" + - &evt_index + name: evt_index + description: 'Event index' + + - name: balancer_v2_base_trades + meta: + blockchain: base + sector: dex + contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi + config: + tags: [ 'balancer', 'base', 'amm', 'trades', 'dex', 'beta' ] + description: > + DEX trades on balancer v2 on base + columns: + - *blockchain + - *project + - *version + - *block_month + - *block_date + - *block_time + - *block_number + - *token_bought_symbol + - *token_sold_symbol + - *token_pair + - *token_bought_amount + - *token_sold_amount + - *token_bought_amount_raw + - *token_sold_amount_raw + - *amount_usd + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *project_contract_address + - *pool_symbol + - *pool_type + - *pool_id + - *swap_fee + - *tx_hash + - *tx_from + - *tx_to + - *evt_index \ No newline at end of file diff --git a/models/balancer/base/balancer_base_trades.sql b/models/_project/balancer/trades/base/balancer_base_trades.sql similarity index 100% rename from models/balancer/base/balancer_base_trades.sql rename to models/_project/balancer/trades/base/balancer_base_trades.sql diff --git a/models/balancer/base/balancer_v2_base_trades.sql b/models/_project/balancer/trades/base/balancer_v2_base_trades.sql similarity index 94% rename from models/balancer/base/balancer_v2_base_trades.sql rename to models/_project/balancer/trades/base/balancer_v2_base_trades.sql index ccf037af146..b94589a490a 100644 --- a/models/balancer/base/balancer_v2_base_trades.sql +++ b/models/_project/balancer/trades/base/balancer_v2_base_trades.sql @@ -4,9 +4,9 @@ alias = 'trades', materialized = 'view', post_hook = '{{ expose_spells(\'["base"]\', - "project", - "balancer_v2", - \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' + spell_type = "project", + spell_name = "balancer", + contributors = \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' ) }} diff --git a/models/_project/balancer/trades/ethereum/_schema.yml b/models/_project/balancer/trades/ethereum/_schema.yml new file mode 100644 index 00000000000..42d29d7e17d --- /dev/null +++ b/models/_project/balancer/trades/ethereum/_schema.yml @@ -0,0 +1,145 @@ +version: 2 + +models: + - name: balancer_ethereum_trades + meta: + blockchain: ethereum + sector: dex + contributors: bizzyvinci, thetroyharris, viniabussafi + config: + tags: ['balancer', 'ethereum', 'amm', 'trades', 'dex'] + description: > + DEX trades on balancer on ethereum + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &project + name: project + description: "Project name (balancer)" + - &version + name: version + description: "Version of the project" + - &block_month + name: block_month + description: "Block month in UTC" + - &block_date + name: block_date + description: "Block date in UTC" + - &block_time + name: block_time + description: 'Block time in UTC' + - &block_number + name: block_number + description: 'Block number' + - &token_bought_symbol + name: token_bought_symbol + description: "Token symbol for token bought in the trade" + - &token_sold_symbol + name: token_sold_symbol + description: "Token symbol for token sold in the trade" + - &token_pair + name: token_pair + description: "Token symbol pair for each token involved in the trade" + - &token_bought_amount + name: token_bought_amount + description: "Value of the token bought at time of execution in the original currency" + - &token_sold_amount + name: token_sold_amount + description: "Value of the token sold at time of execution in the original currency" + - &token_bought_amount_raw + name: token_bought_amount_raw + description: "Raw value of the token bought at time of execution in the original currency" + - &token_sold_amount_raw + name: token_sold_amount_raw + description: "Raw value of the token sold at time of execution in the original currency" + - &amount_usd + name: amount_usd + description: "USD value of the trade at time of execution" + - &token_bought_address + name: token_bought_address + description: "Contract address of the token bought" + - &token_sold_address + name: token_sold_address + description: "Contract address of the token sold" + - &taker + name: taker + description: "Address of trader who purchased a token" + - &maker + name: maker + description: "Address of trader who sold a token" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &swap_fee + name: swap_fee + description: 'Swap fee' + - &project_contract_address + name: project_contract_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - &tx_from + name: tx_from + description: "transaction.from" + - &tx_to + name: tx_to + description: "transaction.to" + - &evt_index + name: evt_index + description: 'Event index' + + - name: balancer_v1_ethereum_trades + meta: + blockchain: ethereum + sector: dex + contributors: bizzyvinci, thetroyharris, viniabussafi + config: + tags: [ 'balancer', 'ethereum', 'amm', 'trades', 'dex' ] + description: > + DEX trades on balancer v1 on ethereum + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_time + - tx_hash + - evt_index + - check_dex_seed: + blockchain: ethereum + project: balancer + version: 1 + columns: + - *blockchain + - *project + - *version + - *block_month + - *block_date + - *block_time + - *token_bought_symbol + - *token_sold_symbol + - *token_pair + - *token_bought_amount + - *token_sold_amount + - *token_bought_amount_raw + - *token_sold_amount_raw + - *amount_usd + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *pool_id + - *swap_fee + - *project_contract_address + - *pool_symbol + - *pool_type + - *tx_hash + - *tx_from + - *tx_to + - *evt_index \ No newline at end of file diff --git a/models/balancer/ethereum/balancer_ethereum_trades.sql b/models/_project/balancer/trades/ethereum/balancer_ethereum_trades.sql similarity index 100% rename from models/balancer/ethereum/balancer_ethereum_trades.sql rename to models/_project/balancer/trades/ethereum/balancer_ethereum_trades.sql diff --git a/models/balancer/ethereum/balancer_v1_ethereum_trades.sql b/models/_project/balancer/trades/ethereum/balancer_v1_ethereum_trades.sql similarity index 100% rename from models/balancer/ethereum/balancer_v1_ethereum_trades.sql rename to models/_project/balancer/trades/ethereum/balancer_v1_ethereum_trades.sql diff --git a/models/balancer/ethereum/balancer_v2_ethereum_trades.sql b/models/_project/balancer/trades/ethereum/balancer_v2_ethereum_trades.sql similarity index 94% rename from models/balancer/ethereum/balancer_v2_ethereum_trades.sql rename to models/_project/balancer/trades/ethereum/balancer_v2_ethereum_trades.sql index 3fe902cf12b..dfb4c2439bf 100644 --- a/models/balancer/ethereum/balancer_v2_ethereum_trades.sql +++ b/models/_project/balancer/trades/ethereum/balancer_v2_ethereum_trades.sql @@ -4,9 +4,9 @@ alias = 'trades', materialized = 'view', post_hook = '{{ expose_spells(\'["ethereum"]\', - "project", - "balancer_v2", - \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' + spell_type = "project", + spell_name = "balancer", + contributors = \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' ) }} diff --git a/models/_project/balancer/trades/gnosis/_schema.yml b/models/_project/balancer/trades/gnosis/_schema.yml new file mode 100644 index 00000000000..ae5ae4065a2 --- /dev/null +++ b/models/_project/balancer/trades/gnosis/_schema.yml @@ -0,0 +1,149 @@ +version: 2 + +models: + - name: balancer_gnosis_trades + meta: + blockchain: gnosis + sector: dex + contributors: bizzyvinci, viniabussafi + config: + tags: ['balancer', 'gnosis', 'amm', 'trades', 'dex'] + description: > + DEX trades on balancer on gnosis + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - tx_hash + - evt_index + - check_dex_seed: + blockchain: gnosis + project: balancer + version: 2 + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &project + name: project + description: "Project name (balancer)" + - &version + name: version + description: "Version of the project" + - &block_month + name: block_month + description: "Block month in UTC" + - &block_date + name: block_date + description: "Block date in UTC" + - &block_time + name: block_time + description: 'Block time in UTC' + - &block_number + name: block_number + description: 'Block number' + - &token_bought_symbol + name: token_bought_symbol + description: "Token symbol for token bought in the trade" + - &token_sold_symbol + name: token_sold_symbol + description: "Token symbol for token sold in the trade" + - &token_pair + name: token_pair + description: "Token symbol pair for each token involved in the trade" + - &token_bought_amount + name: token_bought_amount + description: "Value of the token bought at time of execution in the original currency" + - &token_sold_amount + name: token_sold_amount + description: "Value of the token sold at time of execution in the original currency" + - &token_bought_amount_raw + name: token_bought_amount_raw + description: "Raw value of the token bought at time of execution in the original currency" + - &token_sold_amount_raw + name: token_sold_amount_raw + description: "Raw value of the token sold at time of execution in the original currency" + - &amount_usd + name: amount_usd + description: "USD value of the trade at time of execution" + - &token_bought_address + name: token_bought_address + description: "Contract address of the token bought" + - &token_sold_address + name: token_sold_address + description: "Contract address of the token sold" + - &taker + name: taker + description: "Address of trader who purchased a token" + - &maker + name: maker + description: "Address of trader who sold a token" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &swap_fee + name: swap_fee + description: 'Swap fee' + - &project_contract_address + name: project_contract_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - &tx_from + name: tx_from + description: "transaction.from" + - &tx_to + name: tx_to + description: "transaction.to" + - &evt_index + name: evt_index + description: 'Event index' + + - name: balancer_v2_gnosis_trades + meta: + blockchain: gnosis + sector: dex + contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi + config: + tags: [ 'balancer', 'gnosis', 'amm', 'trades', 'dex', 'beta' ] + description: > + DEX trades on balancer v2 on gnosis + columns: + - *blockchain + - *project + - *version + - *block_month + - *block_date + - *block_time + - *block_number + - *token_bought_symbol + - *token_sold_symbol + - *token_pair + - *token_bought_amount + - *token_sold_amount + - *token_bought_amount_raw + - *token_sold_amount_raw + - *amount_usd + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *project_contract_address + - *pool_symbol + - *pool_type + - *pool_id + - *swap_fee + - *tx_hash + - *tx_from + - *tx_to + - *evt_index \ No newline at end of file diff --git a/models/balancer/gnosis/balancer_gnosis_trades.sql b/models/_project/balancer/trades/gnosis/balancer_gnosis_trades.sql similarity index 100% rename from models/balancer/gnosis/balancer_gnosis_trades.sql rename to models/_project/balancer/trades/gnosis/balancer_gnosis_trades.sql diff --git a/models/balancer/gnosis/balancer_v2_gnosis_trades.sql b/models/_project/balancer/trades/gnosis/balancer_v2_gnosis_trades.sql similarity index 94% rename from models/balancer/gnosis/balancer_v2_gnosis_trades.sql rename to models/_project/balancer/trades/gnosis/balancer_v2_gnosis_trades.sql index c895c351328..090b5b9e737 100644 --- a/models/balancer/gnosis/balancer_v2_gnosis_trades.sql +++ b/models/_project/balancer/trades/gnosis/balancer_v2_gnosis_trades.sql @@ -4,9 +4,9 @@ alias = 'trades', materialized = 'view', post_hook = '{{ expose_spells(\'["gnosis"]\', - "project", - "balancer_v2", - \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' + spell_type = "project", + spell_name = "balancer", + contributors = \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' ) }} diff --git a/models/_project/balancer/trades/optimism/_schema.yml b/models/_project/balancer/trades/optimism/_schema.yml new file mode 100644 index 00000000000..481a7f9073b --- /dev/null +++ b/models/_project/balancer/trades/optimism/_schema.yml @@ -0,0 +1,149 @@ +version: 2 + +models: + - name: balancer_optimism_trades + meta: + blockchain: optimism + sector: dex + contributors: bizzyvinci, viniabussafi + config: + tags: ['balancer', 'optimism', 'amm', 'trades', 'dex'] + description: > + DEX trades on balancer on optimism + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - tx_hash + - evt_index + - check_dex_seed: + blockchain: optimism + project: balancer + version: 2 + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &project + name: project + description: "Project name (balancer)" + - &version + name: version + description: "Version of the project" + - &block_month + name: block_month + description: "Block month in UTC" + - &block_date + name: block_date + description: "Block date in UTC" + - &block_time + name: block_time + description: 'Block time in UTC' + - &block_number + name: block_number + description: 'Block number' + - &token_bought_symbol + name: token_bought_symbol + description: "Token symbol for token bought in the trade" + - &token_sold_symbol + name: token_sold_symbol + description: "Token symbol for token sold in the trade" + - &token_pair + name: token_pair + description: "Token symbol pair for each token involved in the trade" + - &token_bought_amount + name: token_bought_amount + description: "Value of the token bought at time of execution in the original currency" + - &token_sold_amount + name: token_sold_amount + description: "Value of the token sold at time of execution in the original currency" + - &token_bought_amount_raw + name: token_bought_amount_raw + description: "Raw value of the token bought at time of execution in the original currency" + - &token_sold_amount_raw + name: token_sold_amount_raw + description: "Raw value of the token sold at time of execution in the original currency" + - &amount_usd + name: amount_usd + description: "USD value of the trade at time of execution" + - &token_bought_address + name: token_bought_address + description: "Contract address of the token bought" + - &token_sold_address + name: token_sold_address + description: "Contract address of the token sold" + - &taker + name: taker + description: "Address of trader who purchased a token" + - &maker + name: maker + description: "Address of trader who sold a token" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &swap_fee + name: swap_fee + description: 'Swap fee' + - &project_contract_address + name: project_contract_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - &tx_from + name: tx_from + description: "transaction.from" + - &tx_to + name: tx_to + description: "transaction.to" + - &evt_index + name: evt_index + description: 'Event index' + + - name: balancer_v2_optimism_trades + meta: + blockchain: optimism + sector: dex + contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi + config: + tags: [ 'balancer', 'optimism', 'amm', 'trades', 'dex', 'beta' ] + description: > + DEX trades on balancer v2 on optimism + columns: + - *blockchain + - *project + - *version + - *block_month + - *block_date + - *block_time + - *block_number + - *token_bought_symbol + - *token_sold_symbol + - *token_pair + - *token_bought_amount + - *token_sold_amount + - *token_bought_amount_raw + - *token_sold_amount_raw + - *amount_usd + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *project_contract_address + - *pool_symbol + - *pool_type + - *pool_id + - *swap_fee + - *tx_hash + - *tx_from + - *tx_to + - *evt_index \ No newline at end of file diff --git a/models/balancer/optimism/balancer_optimism_trades.sql b/models/_project/balancer/trades/optimism/balancer_optimism_trades.sql similarity index 100% rename from models/balancer/optimism/balancer_optimism_trades.sql rename to models/_project/balancer/trades/optimism/balancer_optimism_trades.sql diff --git a/models/balancer/optimism/balancer_v2_optimism_trades.sql b/models/_project/balancer/trades/optimism/balancer_v2_optimism_trades.sql similarity index 94% rename from models/balancer/optimism/balancer_v2_optimism_trades.sql rename to models/_project/balancer/trades/optimism/balancer_v2_optimism_trades.sql index 03327617f4f..b53e845ddd6 100644 --- a/models/balancer/optimism/balancer_v2_optimism_trades.sql +++ b/models/_project/balancer/trades/optimism/balancer_v2_optimism_trades.sql @@ -4,9 +4,9 @@ alias = 'trades', materialized = 'view', post_hook = '{{ expose_spells(\'["optimism"]\', - "project", - "balancer_v2", - \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' + spell_type = "project", + spell_name = "balancer", + contributors = \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' ) }} diff --git a/models/_project/balancer/trades/polygon/_schema.yml b/models/_project/balancer/trades/polygon/_schema.yml new file mode 100644 index 00000000000..c0dfa6ac51b --- /dev/null +++ b/models/_project/balancer/trades/polygon/_schema.yml @@ -0,0 +1,149 @@ +version: 2 + +models: + - name: balancer_polygon_trades + meta: + blockchain: polygon + sector: dex + contributors: bizzyvinci, viniabussafi + config: + tags: ['balancer', 'polygon', 'amm', 'trades', 'dex'] + description: > + DEX trades on balancer on polygon + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - tx_hash + - evt_index + - check_dex_seed: + blockchain: polygon + project: balancer + version: 2 + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &project + name: project + description: "Project name (balancer)" + - &version + name: version + description: "Version of the project" + - &block_month + name: block_month + description: "Block month in UTC" + - &block_date + name: block_date + description: "Block date in UTC" + - &block_time + name: block_time + description: 'Block time in UTC' + - &block_number + name: block_number + description: 'Block number' + - &token_bought_symbol + name: token_bought_symbol + description: "Token symbol for token bought in the trade" + - &token_sold_symbol + name: token_sold_symbol + description: "Token symbol for token sold in the trade" + - &token_pair + name: token_pair + description: "Token symbol pair for each token involved in the trade" + - &token_bought_amount + name: token_bought_amount + description: "Value of the token bought at time of execution in the original currency" + - &token_sold_amount + name: token_sold_amount + description: "Value of the token sold at time of execution in the original currency" + - &token_bought_amount_raw + name: token_bought_amount_raw + description: "Raw value of the token bought at time of execution in the original currency" + - &token_sold_amount_raw + name: token_sold_amount_raw + description: "Raw value of the token sold at time of execution in the original currency" + - &amount_usd + name: amount_usd + description: "USD value of the trade at time of execution" + - &token_bought_address + name: token_bought_address + description: "Contract address of the token bought" + - &token_sold_address + name: token_sold_address + description: "Contract address of the token sold" + - &taker + name: taker + description: "Address of trader who purchased a token" + - &maker + name: maker + description: "Address of trader who sold a token" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &swap_fee + name: swap_fee + description: 'Swap fee' + - &project_contract_address + name: project_contract_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - &tx_from + name: tx_from + description: "transaction.from" + - &tx_to + name: tx_to + description: "transaction.to" + - &evt_index + name: evt_index + description: 'Event index' + + - name: balancer_v2_polygon_trades + meta: + blockchain: polygon + sector: dex + contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi + config: + tags: [ 'balancer', 'polygon', 'amm', 'trades', 'dex', 'beta' ] + description: > + DEX trades on balancer v2 on polygon + columns: + - *blockchain + - *project + - *version + - *block_month + - *block_date + - *block_time + - *block_number + - *token_bought_symbol + - *token_sold_symbol + - *token_pair + - *token_bought_amount + - *token_sold_amount + - *token_bought_amount_raw + - *token_sold_amount_raw + - *amount_usd + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *project_contract_address + - *pool_symbol + - *pool_type + - *pool_id + - *swap_fee + - *tx_hash + - *tx_from + - *tx_to + - *evt_index \ No newline at end of file diff --git a/models/balancer/polygon/balancer_polygon_trades.sql b/models/_project/balancer/trades/polygon/balancer_polygon_trades.sql similarity index 100% rename from models/balancer/polygon/balancer_polygon_trades.sql rename to models/_project/balancer/trades/polygon/balancer_polygon_trades.sql diff --git a/models/balancer/polygon/balancer_v2_polygon_trades.sql b/models/_project/balancer/trades/polygon/balancer_v2_polygon_trades.sql similarity index 94% rename from models/balancer/polygon/balancer_v2_polygon_trades.sql rename to models/_project/balancer/trades/polygon/balancer_v2_polygon_trades.sql index a17dabab52d..37b12105abe 100644 --- a/models/balancer/polygon/balancer_v2_polygon_trades.sql +++ b/models/_project/balancer/trades/polygon/balancer_v2_polygon_trades.sql @@ -4,9 +4,9 @@ alias = 'trades', materialized = 'view', post_hook = '{{ expose_spells(\'["polygon"]\', - "project", - "balancer_v2", - \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' + spell_type = "project", + spell_name = "balancer", + contributors = \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' ) }} diff --git a/models/_project/balancer/trades/zkevm/_schema.yml b/models/_project/balancer/trades/zkevm/_schema.yml new file mode 100644 index 00000000000..80f42ffe980 --- /dev/null +++ b/models/_project/balancer/trades/zkevm/_schema.yml @@ -0,0 +1,110 @@ +version: 2 + +models: + - name: balancer_zkevm_trades + meta: + blockchain: zkevm + sector: dex + contributors: bizzyvinci, viniabussafi + config: + tags: ['balancer', 'zkevm', 'amm', 'trades', 'dex'] + description: > + DEX trades on balancer on zkevm + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - tx_hash + - evt_index + - check_dex_seed: + blockchain: zkevm + project: balancer + version: 2 + columns: + - &blockchain + name: blockchain + description: "Blockchain" + - &project + name: project + description: "Project name (balancer)" + - &version + name: version + description: "Version of the project" + - &block_month + name: block_month + description: "Block month in UTC" + - &block_date + name: block_date + description: "Block date in UTC" + - &block_time + name: block_time + description: 'Block time in UTC' + - &block_number + name: block_number + description: 'Block number' + - &token_bought_symbol + name: token_bought_symbol + description: "Token symbol for token bought in the trade" + - &token_sold_symbol + name: token_sold_symbol + description: "Token symbol for token sold in the trade" + - &token_pair + name: token_pair + description: "Token symbol pair for each token involved in the trade" + - &token_bought_amount + name: token_bought_amount + description: "Value of the token bought at time of execution in the original currency" + - &token_sold_amount + name: token_sold_amount + description: "Value of the token sold at time of execution in the original currency" + - &token_bought_amount_raw + name: token_bought_amount_raw + description: "Raw value of the token bought at time of execution in the original currency" + - &token_sold_amount_raw + name: token_sold_amount_raw + description: "Raw value of the token sold at time of execution in the original currency" + - &amount_usd + name: amount_usd + description: "USD value of the trade at time of execution" + - &token_bought_address + name: token_bought_address + description: "Contract address of the token bought" + - &token_sold_address + name: token_sold_address + description: "Contract address of the token sold" + - &taker + name: taker + description: "Address of trader who purchased a token" + - &maker + name: maker + description: "Address of trader who sold a token" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &swap_fee + name: swap_fee + description: 'Swap fee' + - &project_contract_address + name: project_contract_address + description: "Pool address" + - &pool_symbol + name: pool_symbol + description: "Token symbols, followed by their respective weights, if applicable" + - &pool_type + name: pool_type + description: "Pool attributes, determined by the pool's factory" + - &tx_hash + name: tx_hash + description: "Tx. Hash" + - &tx_from + name: tx_from + description: "transaction.from" + - &tx_to + name: tx_to + description: "transaction.to" + - &evt_index + name: evt_index + description: 'Event index' \ No newline at end of file diff --git a/models/balancer/zkevm/balancer_v2_zkevm_trades.sql b/models/_project/balancer/trades/zkevm/balancer_v2_zkevm_trades.sql similarity index 94% rename from models/balancer/zkevm/balancer_v2_zkevm_trades.sql rename to models/_project/balancer/trades/zkevm/balancer_v2_zkevm_trades.sql index 340fbe1dbd8..36cc38e4a44 100644 --- a/models/balancer/zkevm/balancer_v2_zkevm_trades.sql +++ b/models/_project/balancer/trades/zkevm/balancer_v2_zkevm_trades.sql @@ -4,9 +4,9 @@ alias = 'trades', materialized = 'view', post_hook = '{{ expose_spells(\'["zkevm"]\', - "project", - "balancer_v2", - \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' + spell_type = "project", + spell_name = "balancer", + contributors = \'["mendesfabio", "jacektrocinski", "thetroyharris", "tomfutago", "viniabussafi"]\') }}' ) }} diff --git a/models/balancer/zkevm/balancer_zkevm_trades.sql b/models/_project/balancer/trades/zkevm/balancer_zkevm_trades.sql similarity index 100% rename from models/balancer/zkevm/balancer_zkevm_trades.sql rename to models/_project/balancer/trades/zkevm/balancer_zkevm_trades.sql diff --git a/models/_project/balancer/vebal/ethereum/_schema.yml b/models/_project/balancer/vebal/ethereum/_schema.yml new file mode 100644 index 00000000000..ab2ba4d4bdf --- /dev/null +++ b/models/_project/balancer/vebal/ethereum/_schema.yml @@ -0,0 +1,91 @@ +version: 2 + +models: + - name: balancer_ethereum_vebal_balances_day + meta: + blockchain: ethereum + project: balancer + contributors: markusbkoch, mendesfabio, victorstefenon, viniabussafi + config: + tags: ['balancer', 'ethereum', 'vebal', 'day'] + description: > + Daily balances of veBAL per wallet + Depends on veBAL_call_create_lock, veBAL_evt_Deposit and veBAL_evt_Withdraw + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - wallet_address + columns: + - name: day + - name: wallet_address + description: "Address of the wallet holding the veBAL" + - name: bpt_balance + description: "Amount of BPT held in the veBAL lock" + - name: vebal_balance + description: "Amount of veBAL" + - name: lock_time + description: "Amount of time the BPT was locked for at the last time the lock was updated" + + - name: balancer_ethereum_vebal_slopes + meta: + blockchain: ethereum + project: balancer + contributors: markusbkoch, mendesfabio, victorstefenon, viniabussafi + config: + tags: ['balancer', 'ethereum', 'vebal', 'slope'] + description: > + Slope and bias of veBAL per wallet after each balance update + Depends on veBAL_call_create_lock, veBAL_evt_Deposit and veBAL_evt_Withdraw + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_number + - wallet_address + columns: + - name: block_number + - name: block_time + - name: block_timestamp + description: "Block timestamp" + - name: wallet_address + description: "Address of the wallet holding the veBAL" + - name: bpt_balance + description: "Amount of BPT held in the veBAL lock" + - name: unlocked_at + description: "Timestamp at which B-80BAL-20WETH BPT can be unlocked" + - name: slope + description: "veBAL decay rate (per second)" + - name: bias + description: "veBAL balance at the moment user locks or re-locks" + - name: block_date + description: "Block time trunc to date" + + - name: balancer_ethereum_vebal_votes + meta: + blockchain: ethereum + project: balancer + contributors: markusbkoch, mendesfabio, stefenon, viniabussafi + config: + tags: ['balancer', 'ethereum', 'vebal', 'votes'] + description: > + Records of votes for Balancer gauges by provider at each voting round + Depends on GaugeController_evt_VoteForGauge and the vebal_slopes spell + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - round_id + - gauge + - provider + columns: + - name: round_id + description: "ID of the voting round" + - name: start_date + description: "Day of the voting round start date" + - name: end_date + description: "Day of the voting round end date" + - name: gauge + description: "Address of the gauge which provider votes for" + - name: provider + description: "Address of the wallet which voted for the gauge" + - name: vote + description: "Weight of the vote performed by the provider for the gauge" \ No newline at end of file diff --git a/models/balancer/ethereum/balancer_ethereum_vebal_balances_day.sql b/models/_project/balancer/vebal/ethereum/balancer_ethereum_vebal_balances_day.sql similarity index 94% rename from models/balancer/ethereum/balancer_ethereum_vebal_balances_day.sql rename to models/_project/balancer/vebal/ethereum/balancer_ethereum_vebal_balances_day.sql index 31df281cbcf..dbeb8065ba9 100644 --- a/models/balancer/ethereum/balancer_ethereum_vebal_balances_day.sql +++ b/models/_project/balancer/vebal/ethereum/balancer_ethereum_vebal_balances_day.sql @@ -1,12 +1,11 @@ {{ config( schema="balancer_ethereum", - alias = 'vebal_balances_day', post_hook='{{ expose_spells(\'["ethereum"]\', - "project", - "balancer", - \'["markusbkoch", "mendesfabio", "stefenon", "viniabussafi"]\') }}' + spell_type = "project", + spell_name = "balancer", + contributors = \'["markusbkoch", "mendesfabio", "stefenon", "viniabussafi"]\') }}' ) }} diff --git a/models/balancer/ethereum/balancer_ethereum_vebal_slopes.sql b/models/_project/balancer/vebal/ethereum/balancer_ethereum_vebal_slopes.sql similarity index 93% rename from models/balancer/ethereum/balancer_ethereum_vebal_slopes.sql rename to models/_project/balancer/vebal/ethereum/balancer_ethereum_vebal_slopes.sql index 7f549cd9a81..bf49f4f5471 100644 --- a/models/balancer/ethereum/balancer_ethereum_vebal_slopes.sql +++ b/models/_project/balancer/vebal/ethereum/balancer_ethereum_vebal_slopes.sql @@ -1,12 +1,11 @@ {{ config( - schema="balancer_ethereum", - + schema="balancer_ethereum", alias = 'vebal_slopes', post_hook='{{ expose_spells(\'["ethereum"]\', - "project", - "balancer", - \'["markusbkoch", "mendesfabio", "stefenon", "viniabussafi"]\') }}' + spell_type = "project", + spell_name = "balancer", + contributors = \'["markusbkoch", "mendesfabio", "stefenon", "viniabussafi"]\') }}' ) }} diff --git a/models/balancer/ethereum/balancer_ethereum_vebal_votes.sql b/models/_project/balancer/vebal/ethereum/balancer_ethereum_vebal_votes.sql similarity index 92% rename from models/balancer/ethereum/balancer_ethereum_vebal_votes.sql rename to models/_project/balancer/vebal/ethereum/balancer_ethereum_vebal_votes.sql index 17929d1105c..d52c0fe757f 100644 --- a/models/balancer/ethereum/balancer_ethereum_vebal_votes.sql +++ b/models/_project/balancer/vebal/ethereum/balancer_ethereum_vebal_votes.sql @@ -1,13 +1,13 @@ {{ config( - + schema = 'balancer_ethereum', alias = 'vebal_votes', materialized = 'table', file_format = 'delta', post_hook='{{ expose_spells(\'["ethereum"]\', - "project", - "balancer", - \'["markusbkoch", "mendesfabio", "stefenon", "viniabussafi"]\') }}' + spell_type = "project", + spell_name = "balancer", + contributors = \'["markusbkoch", "mendesfabio", "stefenon", "viniabussafi"]\') }}' ) }} diff --git a/models/balancer/arbitrum/balancer_arbitrum_schema.yml b/models/balancer/arbitrum/balancer_arbitrum_schema.yml deleted file mode 100644 index c533ff3ff10..00000000000 --- a/models/balancer/arbitrum/balancer_arbitrum_schema.yml +++ /dev/null @@ -1,432 +0,0 @@ -version: 2 - -models: - - name: balancer_v2_arbitrum_pools_fees - meta: - blockchain: arbitrum - project: balancer_v2 - contributors: jacektrocinski, thetroyharris, viniabussafi - config: - tags: ['arbitrum', 'balancer', 'pools_fees'] - description: > - Balancer v2 swap fees stored at the pool level. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_number - - tx_hash - - index - columns: - - name: blockchain - - name: version - - &contract_address - name: contract_address - description: 'Arbitrum address for the liquidity pool used in transaction' - tests: - - not_null - - &tx_hash - name: tx_hash - description: 'Transaction hash' - tests: - - not_null - - &index - name: index - description: '' - tests: - - not_null - - &tx_index - name: tx_index - description: '' - tests: - - not_null - - &block_time - name: block_time - description: 'Block time in UTC' - tests: - - not_null - - &block_number - name: block_number - description: '' - tests: - - not_null - - &swap_fee_percentage - name: swap_fee_percentage - description: 'Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)' - tests: - - not_null - - - name: balancer_v2_arbitrum_transfers_bpt - meta: - blockchain: arbitrum - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['arbitrum', 'bpt', 'transfers'] - description: > - Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on Arbitrum. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - evt_tx_hash - - evt_index - - block_date - columns: - - &blockchain - name: blockchain - description: "Blockchain" - - name: version - - *contract_address - - &block_date - name: block_date - description: "UTC event block date of each DEX trade" - - &block_month - name: block_month - description: "UTC event block month of each DEX trade" - - &evt_tx_hash - name: evt_tx_hash - description: 'Transaction hash of transfer event' - - &evt_index - name: evt_index - description: 'Event index' - - &evt_block_time - name: evt_block_time - description: 'Block time of transfer event' - - &evt_block_number - name: evt_block_number - description: 'Block number of transfer event' - - &from - name: from - description: 'Address of BPT provider of transfer event' - - &to - name: to - description: 'Address of BPT receiver of transfer event' - - &value - name: value - description: 'Amount of BPT transferred in transfer event' - - - name: balancer_arbitrum_pools_tokens_weights - meta: - blockchain: arbitrum - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['arbitrum', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer pools. - columns: - - *blockchain - - name: version - - &pool_id - name: pool_id - description: 'Unique encoded identifier that refers to each pool' - tests: - - not_null - - &token_address - name: token_address - description: 'Contract address for the token' - - &normalized_weight - name: normalized_weight - description: 'Weight of the token in the pool.' - - - name: balancer_v2_arbitrum_pools_tokens_weights - meta: - blockchain: arbitrum - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['arbitrum', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer v2 pools. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - pool_id - - token_address - columns: - - *blockchain - - name: version - - *pool_id - - *token_address - - *normalized_weight - - - name: balancer_arbitrum_trades - meta: - blockchain: arbitrum - sector: dex - contributors: bizzyvinci - config: - tags: ['balancer', 'arbitrum', 'amm', 'trades', 'dex'] - description: > - DEX trades on balancer on arbitrum - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_date - - blockchain - - project - - version - - tx_hash - - evt_index - - check_dex_seed: - blockchain: arbitrum - project: balancer - version: 2 - columns: - - *blockchain - - &project - name: project - description: "Project name (balancer)" - - &version - name: version - description: "Version of the project" - - *block_month - - *block_date - - *block_time - - &token_bought_symbol - name: token_bought_symbol - description: "Token symbol for token bought in the trade" - - &token_sold_symbol - name: token_sold_symbol - description: "Token symbol for token sold in the trade" - - &token_pair - name: token_pair - description: "Token symbol pair for each token involved in the trade" - - &token_bought_amount - name: token_bought_amount - description: "Value of the token bought at time of execution in the original currency" - - &token_sold_amount - name: token_sold_amount - description: "Value of the token sold at time of execution in the original currency" - - &token_bought_amount_raw - name: token_bought_amount_raw - description: "Raw value of the token bought at time of execution in the original currency" - - &token_sold_amount_raw - name: token_sold_amount_raw - description: "Raw value of the token sold at time of execution in the original currency" - - &amount_usd - name: amount_usd - description: "USD value of the trade at time of execution" - - &token_bought_address - name: token_bought_address - description: "Contract address of the token bought" - - &token_sold_address - name: token_sold_address - description: "Contract address of the token sold" - - &taker - name: taker - description: "Address of trader who purchased a token" - - &maker - name: maker - description: "Address of trader who sold a token" - - *pool_id - - &swap_fee - name: swap_fee - description: 'Swap fee' - - &project_contract_address - name: project_contract_address - description: "Pool address" - - name: pool_symbol - - name: pool_type - - *tx_hash - - &tx_from - name: tx_from - description: "transaction.from" - - &tx_to - name: tx_to - description: "transaction.to" - - *evt_index - - - name: balancer_v2_arbitrum_trades - meta: - blockchain: arbitrum - sector: dex - contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi - config: - tags: [ 'balancer', 'arbitrum', 'amm', 'trades', 'dex', 'beta' ] - description: > - DEX trades on balancer v2 on arbitrum - columns: - - *blockchain - - *project - - *version - - *block_month - - *block_date - - *block_time - - *block_number - - *token_bought_symbol - - *token_sold_symbol - - *token_pair - - *token_bought_amount - - *token_sold_amount - - *token_bought_amount_raw - - *token_sold_amount_raw - - *amount_usd - - *token_bought_address - - *token_sold_address - - *taker - - *maker - - *project_contract_address - - name: pool_symbol - - name: pool_type - - *pool_id - - *swap_fee - - *tx_hash - - *tx_from - - *tx_to - - *evt_index - - - name: balancer_v2_arbitrum_liquidity - meta: - blockchain: arbitrum - project: balancer_v2 - contributors: victorstefenon, viniabussafi, thetroyharris - config: - tags: ['arbitrum', 'balancer', 'pools', 'liquidity'] - description: > - Balancer v2 pools liquidity by token in Arbitrum. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - description: 'UTC event block time truncated to the day mark' - - *pool_id - - name: pool_address - - name: pool_symbol - description: 'Symbol of the pool, consisting of the symbol of its tokens and their respective weights' - - name: version - description: 'Version of Balancer in which pool was deployed' - - name: blockchain - description: 'Blockchain in which pool was deployed' - - *token_address - - name: token_symbol - description: 'Symbol of the token' - - name: token_balance_raw - description: 'Raw balance of the token in the pool' - - name: token_balance - description: 'Scaled balance of the token in the pool' - - name: protocol_liquidity_usd - description: 'Liquidity of the token in the pool in USD, except BPTs' - - name: protocol_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, except BPTs' - - name: pool_liquidity_usd - description: 'Liquidity of the token in the pool in USD, including BPTs' - - name: pool_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, including BPTs' - - - - name: balancer_v2_arbitrum_flashloans - meta: - blockchain: arbitrum - sector: lending - contributors: hildobby - config: - tags: ['arbitrum', 'flashloans'] - description: > - All Balancer v2 flashloans on Arbitrum - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - tx_hash - - evt_index - columns: - - name: blockchain - - name: project - - name: version - - name: block_time - - name: block_number - - name: amount - - name: amount_usd - - name: tx_hash - - name: evt_index - - name: fee - - name: currency_contract - - name: currency_symbol - - name: recipient - - name: contract_address - - name: block_month - - - name: balancer_v2_arbitrum_bpt_prices - meta: - blockchain: arbitrum - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['arbitrum', 'bpt', 'prices'] - description: > - Balancer Pool Token (BPT) daily price by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - day - - contract_address - columns: - - name: blockchain - - name: day - - name: version - - name: decimals - - name: contract_address - - name: bpt_price - - - name: balancer_v2_arbitrum_protocol_fee - meta: - blockchain: arbitrum - project: balancer_v2 - contributors: viniabussafi - config: - tags: ['arbitrum', 'revenue', 'fees'] - description: > - Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - - name: pool_id - - name: pool_address - - name: pool_symbol - - name: version - - name: blockchain - - name: token_address - - name: token_symbol - - name: token_amount_raw - description: "Raw amount of revenues of the token in the pool" - - name: token_amount - description: "Amount of revenues of the token in the pool" - - name: protocol_fee_collected_usd - description: "Fee collected in the pool in USD" - - name: treasury_share - description: "Share of total revenue that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" - - name: treasury_revenue_usd - description: "Total revenue directed to Balancer DAO's treasury" - - - name: balancer_v2_arbitrum_bpt_supply - meta: - blockchain: arbiturm - project: balancer_v2 - contributors: thetroyharris, viniabussafi - config: - tags: ['arbiturm', 'bpt', 'supply'] - description: > - Balancer Pool Token (BPT) supply for ComposableStablePools versions 4 and 5. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - blockchain - - token_address - columns: - - name: day - - name: pool_type - - name: version - - name: blockchain - - name: token_address - - name: supply \ No newline at end of file diff --git a/models/balancer/avalanche_c/balancer_avalanche_c_schema.yml b/models/balancer/avalanche_c/balancer_avalanche_c_schema.yml deleted file mode 100644 index 93cc2e87629..00000000000 --- a/models/balancer/avalanche_c/balancer_avalanche_c_schema.yml +++ /dev/null @@ -1,405 +0,0 @@ -version: 2 - -models: - - - name: balancer_avalanche_c_trades - meta: - blockchain: avalanche_c - sector: dex - contributors: bizzyvinci - config: - tags: ['balancer', 'avalanche_c', 'amm', 'trades', 'dex'] - description: > - DEX trades on balancer on avalanche_c - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_date - - blockchain - - project - - version - - tx_hash - - evt_index - - check_dex_seed: - blockchain: avalanche_c - project: balancer - version: 2 - columns: - - &blockchain - name: blockchain - description: "Blockchain" - - &project - name: project - description: "Project name (balancer)" - - &version - name: version - description: "Version of the project" - - &block_month - name: block_month - description: "Block month in UTC" - - &block_date - name: block_date - description: "Block date in UTC" - - &block_time - name: block_time - description: 'Block time in UTC' - - &token_bought_symbol - name: token_bought_symbol - description: "Token symbol for token bought in the trade" - - &token_sold_symbol - name: token_sold_symbol - description: "Token symbol for token sold in the trade" - - &token_pair - name: token_pair - description: "Token symbol pair for each token involved in the trade" - - &token_bought_amount - name: token_bought_amount - description: "Value of the token bought at time of execution in the original currency" - - &token_sold_amount - name: token_sold_amount - description: "Value of the token sold at time of execution in the original currency" - - &token_bought_amount_raw - name: token_bought_amount_raw - description: "Raw value of the token bought at time of execution in the original currency" - - &token_sold_amount_raw - name: token_sold_amount_raw - description: "Raw value of the token sold at time of execution in the original currency" - - &amount_usd - name: amount_usd - description: "USD value of the trade at time of execution" - - &token_bought_address - name: token_bought_address - description: "Contract address of the token bought" - - &token_sold_address - name: token_sold_address - description: "Contract address of the token sold" - - &taker - name: taker - description: "Address of trader who purchased a token" - - &maker - name: maker - description: "Address of trader who sold a token" - - &pool_id - name: pool_id - description: 'Unique encoded identifier that refers to each pool' - - &swap_fee - name: swap_fee - description: 'Swap fee' - - &project_contract_address - name: project_contract_address - description: "Pool address" - - name: pool_symbol - - name: pool_type - - &tx_hash - name: tx_hash - description: "Transaction hash" - - &tx_from - name: tx_from - description: "transaction.from" - - &tx_to - name: tx_to - description: "transaction.to" - - &evt_index - name: evt_index - description: "Event index" - - - name: balancer_v2_avalanche_c_trades - meta: - blockchain: avalanche_c - sector: dex - contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi - config: - tags: [ 'balancer', 'avalanche_c', 'amm', 'trades', 'dex', 'beta' ] - description: > - DEX trades on balancer v2 on avalanche_c - columns: - - *blockchain - - *project - - *version - - *block_month - - *block_date - - *block_time - - name: block_number - - *token_bought_symbol - - *token_sold_symbol - - *token_pair - - *token_bought_amount - - *token_sold_amount - - *token_bought_amount_raw - - *token_sold_amount_raw - - *amount_usd - - *token_bought_address - - *token_sold_address - - *taker - - *maker - - *project_contract_address - - name: pool_symbol - - name: pool_type - - *pool_id - - *swap_fee - - *tx_hash - - *tx_from - - *tx_to - - *evt_index - - - name: balancer_avalanche_c_pools_tokens_weights - meta: - blockchain: avalanche_c - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['avalanche_c', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer pools. - columns: - - *blockchain - - name: version - - *pool_id - - &token_address - name: token_address - description: 'Contract address for the token' - - &normalized_weight - name: normalized_weight - description: 'Weight of the token in the pool.' - - - name: balancer_v2_avalanche_c_pools_tokens_weights - meta: - blockchain: avalanche_c - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['avalanche_c', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer v2 pools. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - pool_id - - token_address - columns: - - *blockchain - - name: version - - *pool_id - - *token_address - - *normalized_weight - - - name: balancer_v2_avalanche_c_liquidity - meta: - blockchain: avalanche_c - project: balancer_v2 - contributors: victorstefenon, viniabussafi, thetroyharris - config: - tags: ['avalanche_c', 'balancer', 'pools', 'liquidity'] - description: > - Balancer v2 pools liquidity by token in avalanche_c. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - description: 'UTC event block time truncated to the day mark' - - *pool_id - - name: pool_address - - name: pool_symbol - description: 'Symbol of the pool, consisting of the symbol of its tokens and their respective weights' - - name: version - description: 'Version of Balancer in which pool was deployed' - - name: blockchain - description: 'Blockchain in which pool was deployed' - - *token_address - - name: token_symbol - description: 'Symbol of the token' - - name: token_balance_raw - description: 'Raw balance of the token in the pool' - - name: token_balance - description: 'Scaled balance of the token in the pool' - - name: protocol_liquidity_usd - description: 'Liquidity of the token in the pool in USD, except BPTs' - - name: protocol_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, except BPTs' - - name: pool_liquidity_usd - description: 'Liquidity of the token in the pool in USD, including BPTs' - - name: pool_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, including BPTs' - - - - name: balancer_v2_avalanche_c_bpt_prices - meta: - blockchain: avalanche_c - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['avalanche_c', 'bpt', 'prices'] - description: > - Balancer Pool Token (BPT) hourly median price by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - day - - contract_address - columns: - - name: blockchain - - name: day - - name: version - - name: decimals - - name: contract_address - - name: bpt_price - - - name: balancer_v2_avalanche_c_transfers_bpt - meta: - blockchain: avalanche_c - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['avalanche_c', 'bpt', 'transfers'] - description: > - Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on Avalanche C Chain. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - evt_tx_hash - - evt_index - - block_date - columns: - - name: blockchain - - name: version - - name: contract_address - - name: block_date - - name: block_month - - name: evt_tx_hash - - name: evt_index - - &evt_block_time - name: evt_block_time - description: 'Block time of transfer event' - - &evt_block_number - name: evt_block_number - description: 'Block number of transfer event' - - &from - name: from - description: 'Address of BPT provider of transfer event' - - &to - name: to - description: 'Address of BPT receiver of transfer event' - - &value - name: value - description: 'Amount of BPT transferred in transfer event' - - - name: balancer_v2_avalanche_c_pools_fees - meta: - blockchain: avalanche_c - project: balancer_v2 - contributors: jacektrocinski, thetroyharris, viniabussafi - config: - tags: ['avalanche_c', 'balancer', 'pools', 'fees'] - description: > - Balancer v2 swap fees stored at the pool level. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_number - - tx_hash - - index - columns: - - name: blockchain - - name: version - - name: contract_address - - name: tx_hash - - name: index - - name: tx_index - - name: block_time - - name: block_number - - name: swap_fee_percentage - - - name: balancer_v2_avalanche_c_flashloans - meta: - blockchain: avalanche_c - sector: lending - contributors: hildobby, viniabussafi - config: - tags: ['avalanche_c', 'flashloans'] - description: > - All Balancer v2 flashloans on avalanche_c - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - tx_hash - - evt_index - columns: - - name: blockchain - - name: project - - name: version - - name: block_time - - name: block_number - - name: amount - - name: amount_usd - - name: tx_hash - - name: evt_index - - name: fee - - name: currency_contract - - name: currency_symbol - - name: recipient - - name: contract_address - - name: block_month - - - name: balancer_v2_avalanche_c_protocol_fee - meta: - blockchain: avalanche_c - project: balancer_v2 - contributors: viniabussafi - config: - tags: ['avalanche_c', 'revenue', 'fees'] - description: > - Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - - name: pool_id - - name: pool_address - - name: pool_symbol - - name: version - - name: blockchain - - name: token_address - - name: token_symbol - - name: token_amount_raw - description: "Raw amount of revenues of the token in the pool" - - name: token_amount - description: "Amount of revenues of the token in the pool" - - name: protocol_fee_collected_usd - description: "Fee collected in the pool in USD" - - name: treasury_share - description: "Share of total revenue that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" - - name: treasury_revenue_usd - description: "Total revenue directed to Balancer DAO's treasury" - - - name: balancer_v2_avalanche_c_bpt_supply - meta: - blockchain: avalanche_c - project: balancer_v2 - contributors: thetroyharris, viniabussafi - config: - tags: ['avalanche_c', 'bpt', 'supply'] - description: > - Balancer Pool Token (BPT) supply for ComposableStablePools versions 4 and 5. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - blockchain - - token_address - columns: - - name: day - - name: pool_type - - name: version - - name: blockchain - - name: token_address - - name: supply \ No newline at end of file diff --git a/models/balancer/balancer_schema.yml b/models/balancer/balancer_schema.yml deleted file mode 100644 index 5e7fb29a97b..00000000000 --- a/models/balancer/balancer_schema.yml +++ /dev/null @@ -1,365 +0,0 @@ -version: 2 - -models: - - name: balancer_gauge_mappings - meta: - blockchain: optimism - sector: dex - contributors: msilb7 - config: - tags: ['balancer', 'amm', 'trades', 'dex', 'incentives'] - description: > - Gauge to Pool mappings for balancer on all chains - columns: - - &blockchain - name: blockchain - description: "Blockchain" - - &project - name: project - description: "Project name (balancer)" - - &version - name: version - description: "Version of the project" - - &pool_contract - name: pool_contract - description: "Address of the liquidity pool contract" - - &pool_id - name: pool_id - description: "Pool id" - - &incentives_contract - name: incentives_contract - description: "Address of the contract where incentives are stored and emitted." - - &incentives_type - name: incentives_type - description: "Description of the incentives address type." - - &evt_block_time - name: evt_block_time - description: 'Block time in UTC' - - &evt_block_number - name: evt_block_number - description: 'Block Number' - - &contract_address - name: contract_address - description: 'Gauge Creator Contract Address' - - &evt_tx_hash - name: evt_tx_hash - description: 'Tx Hash' - - &evt_index - name: evt_index - description: 'Event index' - - - name: balancer_flashloans - meta: - blockchain: ethereum, arbitrum, optimism, polygon, gnosis - sector: lending - contributors: hildobby - config: - tags: ['ethereum', 'arbitrum', 'optimism', 'polygon', 'gnosis','avalanche_c', 'base', 'flashloans'] - description: > - All Balancer flashloans - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - tx_hash - - evt_index - columns: - - name: blockchain - - name: project - - name: version - - name: block_time - - name: block_month - - name: block_number - - name: amount - - name: amount_usd - - name: tx_hash - - name: evt_index - - name: fee - - name: currency_contract - - name: currency_symbol - - name: recipient - - name: contract_address - - name: block_month - - - name: balancer_bpt_prices - meta: - blockchain: ethereum, arbitrum, optimism, polygon, gnosis, avalanche_c, base - sector: dex - contributors: thetroyharris, victorstefenon, viniabussafi - config: - tags: ['balancer', 'amm', 'dex', 'bpt', 'prices', 'ethereum', 'arbitrum', 'optimism', 'polygon', 'gnosis', 'avalanche_c', 'base'] - description: > - Balancer Pool Token (BPT) hourly median price by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - day - - contract_address - columns: - - name: blockchain - - name: day - - name: version - - name: decimals - - name: contract_address - - name: pool_type - - name: bpt_price - - - name: balancer_liquidity - meta: - blockchain: ethereum, arbitrum, optimism, polygon, gnosis, avalanche_c, base - project: balancer - contributors: viniabussafi - config: - tags: ['balancer', 'amm', 'dex', 'liquidity', 'ethereum', 'arbitrum', 'optimism', 'polygon', 'avalanche_c', 'base'] - description: > - Liquidity by token on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - blockchain - - token_address - - token_symbol - columns: - - name: day - description: 'UTC event block time truncated to the day mark' - - *pool_id - - name: pool_address - - name: pool_symbol - description: 'Symbol of the pool, consisting of the symbol of its tokens and their respective weights' - - name: version - description: 'Version of Balancer in which pool was deployed' - - name: blockchain - description: 'Blockchain in which pool was deployed' - - name: pool_type - - name: token_address - - name: token_symbol - description: 'Symbol of the token' - - name: token_balance_raw - description: 'Raw balance of the token in the pool' - - name: token_balance - description: 'Scaled balance of the token in the pool' - - name: protocol_liquidity_usd - description: 'Liquidity of the token in the pool in USD, except BPTs' - - name: protocol_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, except BPTs' - - name: pool_liquidity_usd - description: 'Liquidity of the token in the pool in USD, including BPTs' - - name: pool_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, including BPTs' - - - - name: balancer_transfers_bpt - meta: - blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'bpt', 'transfers'] - description: > - Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - evt_tx_hash - - evt_index - - block_date - columns: - - *blockchain - - name: version - - *contract_address - - &block_date - name: block_date - description: "Block date in UTC" - - *evt_tx_hash - - *evt_index - - *evt_block_time - - *evt_block_number - - &from - name: from - description: 'Address of BPT provider of transfer event' - - &to - name: to - description: 'Address of BPT receiver of transfer event' - - &value - name: value - description: 'Amount of BPT transferred in transfer event' - - - name: balancer_pools_fees - meta: - blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon - contributors: jacektrocinski, thetroyharris, viniabussafi - config: - tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'bpt', 'transfers'] - description: > - Balancer v2 swap fees stored at the pool level. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - block_number - - tx_hash - - index - columns: - - name: blockchain - - name: version - - name: contract_address - - name: tx_hash - - name: index - - name: tx_index - - name: block_time - - name: block_number - - name: swap_fee_percentage - - - name: balancer_protocol_fee - meta: - blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon - project: balancer - contributors: viniabussafi - config: - tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'revenue', 'fees'] - description: > - Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - - *pool_id - - name: pool_address - - name: pool_symbol - - *version - - *blockchain - - name: pool_type - - name: token_address - - name: token_symbol - - name: token_amount_raw - description: "Raw amount of revenues of the token in the pool" - - name: token_amount - description: "Amount of revenues of the token in the pool" - - name: protocol_fee_collected_usd - description: "Fee collected in the pool in USD" - - name: treasury_share - description: "Share of total revenue that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" - - name: treasury_revenue_usd - description: "Total revenue directed to Balancer DAO's treasury" - - - name: balancer_bpt_supply - meta: - blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon - contributors: thetroyharris, viniabussafi - config: - tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'bpt'] - description: > - The Balancer Pool Token (BPT) supply over time of ComposableStablePools versions 4+ - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - blockchain - - token_address - columns: - - name: day - - name: pool_type - - name: version - - name: blockchain - - name: token_address - - name: supply - - - name: balancer_token_whitelist - meta: - blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon - contributors: viniabussafi - config: - tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'bpt'] - description: > - These tokens are whitelisted to be used as pricing assets on liquidity calculations for weighted pools, due to the trustability of their data. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - address - - name - - chain - columns: - - name: address - - name: name - - name: chain - - - name: balancer_pools_tokens_weights - meta: - blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon - contributors: jacektrocinski, viniabussafi - config: - tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'bpt', 'transfers'] - description: > - Token weights in Balancer pools. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - pool_id - - token_address - columns: - - *blockchain - - name: version - - *pool_id - - name: token_address - - name: normalized_weight - - - name: balancer_single_recipient_gauges - meta: - blockchain: ethereum - contributors: viniabussafi - config: - tags: ['ethereum', 'gauges'] - description: > - These gauges are deployed by the SingleRecipientGauge contract and this mapping manually links each gauge to it's correspondent pool and project - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - gauge_address - - pool_id - - project - - blockchain - columns: - - name: gauge_address - - name: pool_id - - name: project - - name: blockchain - - - name: balancer_pools_metrics_daily - meta: - blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevm - contributors: viniabussafi, metacrypto - config: - tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'balancer', 'pool', 'stats', 'volume', 'tvl', 'fee'] - description: > - This spell aggregates data from the trades, liquidity and protocol fees spells, by day and pool, while also displaying some basic information about the pool - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_date - - blockchain - - project - - version - - project_contract_address - columns: - - name: blockchain - - name: project - - name: version - - name: block_date - - name: project_contract_address - - name: pool_symbol - - name: pool_type - - name: swap_amount_usd - description: "Daily swap volume on a pool, in USD" - - name: tvl_usd - description: "Total Value Locked on a pool, in USD" - - name: tvl_eth - description: "Total Value Locked on a pool, in eth" - - name: fee_amount_usd - description: "Daily fees collected on a pool, in USD" \ No newline at end of file diff --git a/models/balancer/base/balancer_base_schema.yml b/models/balancer/base/balancer_base_schema.yml deleted file mode 100644 index d6e170e5536..00000000000 --- a/models/balancer/base/balancer_base_schema.yml +++ /dev/null @@ -1,405 +0,0 @@ -version: 2 - -models: - - - name: balancer_base_trades - meta: - blockchain: base - sector: dex - contributors: bizzyvinci - config: - tags: ['balancer', 'base', 'amm', 'trades', 'dex'] - description: > - DEX trades on balancer on base - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_date - - blockchain - - project - - version - - tx_hash - - evt_index - - check_dex_seed: - blockchain: base - project: balancer - version: 2 - columns: - - &blockchain - name: blockchain - description: "Blockchain" - - &project - name: project - description: "Project name (balancer)" - - &version - name: version - description: "Version of the project" - - &block_month - name: block_month - description: "Block month in UTC" - - &block_date - name: block_date - description: "Block date in UTC" - - &block_time - name: block_time - description: 'Block time in UTC' - - &token_bought_symbol - name: token_bought_symbol - description: "Token symbol for token bought in the trade" - - &token_sold_symbol - name: token_sold_symbol - description: "Token symbol for token sold in the trade" - - &token_pair - name: token_pair - description: "Token symbol pair for each token involved in the trade" - - &token_bought_amount - name: token_bought_amount - description: "Value of the token bought at time of execution in the original currency" - - &token_sold_amount - name: token_sold_amount - description: "Value of the token sold at time of execution in the original currency" - - &token_bought_amount_raw - name: token_bought_amount_raw - description: "Raw value of the token bought at time of execution in the original currency" - - &token_sold_amount_raw - name: token_sold_amount_raw - description: "Raw value of the token sold at time of execution in the original currency" - - &amount_usd - name: amount_usd - description: "USD value of the trade at time of execution" - - &token_bought_address - name: token_bought_address - description: "Contract address of the token bought" - - &token_sold_address - name: token_sold_address - description: "Contract address of the token sold" - - &taker - name: taker - description: "Address of trader who purchased a token" - - &maker - name: maker - description: "Address of trader who sold a token" - - &pool_id - name: pool_id - description: 'Unique encoded identifier that refers to each pool' - - &swap_fee - name: swap_fee - description: 'Swap fee' - - &project_contract_address - name: project_contract_address - description: "Pool address" - - name: pool_symbol - - name: pool_type - - &tx_hash - name: tx_hash - description: "Transaction hash" - - &tx_from - name: tx_from - description: "transaction.from" - - &tx_to - name: tx_to - description: "transaction.to" - - &evt_index - name: evt_index - description: "Event index" - - - name: balancer_v2_base_trades - meta: - blockchain: base - sector: dex - contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi - config: - tags: [ 'balancer', 'base', 'amm', 'trades', 'dex', 'beta' ] - description: > - DEX trades on balancer v2 on base - columns: - - *blockchain - - *project - - *version - - *block_month - - *block_date - - *block_time - - name: block_number - - *token_bought_symbol - - *token_sold_symbol - - *token_pair - - *token_bought_amount - - *token_sold_amount - - *token_bought_amount_raw - - *token_sold_amount_raw - - *amount_usd - - *token_bought_address - - *token_sold_address - - *taker - - *maker - - *project_contract_address - - name: pool_symbol - - name: pool_type - - *pool_id - - *swap_fee - - *tx_hash - - *tx_from - - *tx_to - - *evt_index - - - name: balancer_v2_base_pools_fees - meta: - blockchain: base - project: balancer_v2 - contributors: jacektrocinski, thetroyharris, viniabussafi - config: - tags: ['base', 'balancer', 'pools', 'fees'] - description: > - Balancer v2 swap fees stored at the pool level. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_number - - tx_hash - - index - columns: - - name: blockchain - - name: version - - name: contract_address - - name: tx_hash - - name: index - - name: tx_index - - name: block_time - - name: block_number - - name: swap_fee_percentage - - - name: balancer_base_pools_tokens_weights - meta: - blockchain: base - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['base', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer pools. - columns: - - *blockchain - - name: version - - *pool_id - - &token_address - name: token_address - description: 'Contract address for the token' - - &normalized_weight - name: normalized_weight - description: 'Weight of the token in the pool.' - - - name: balancer_v2_base_pools_tokens_weights - meta: - blockchain: base - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['base', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer v2 pools. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - pool_id - - token_address - columns: - - *blockchain - - name: version - - *pool_id - - *token_address - - *normalized_weight - - - name: balancer_v2_base_liquidity - meta: - blockchain: base - project: balancer_v2 - contributors: victorstefenon, viniabussafi, thetroyharris - config: - tags: ['base', 'balancer', 'pools', 'liquidity'] - description: > - Balancer v2 pools liquidity by token in base. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - description: 'UTC event block time truncated to the day mark' - - *pool_id - - name: pool_address - - name: pool_symbol - description: 'Symbol of the pool, consisting of the symbol of its tokens and their respective weights' - - name: version - description: 'Version of Balancer in which pool was deployed' - - name: blockchain - description: 'Blockchain in which pool was deployed' - - *token_address - - name: token_symbol - description: 'Symbol of the token' - - name: token_balance_raw - description: 'Raw balance of the token in the pool' - - name: token_balance - description: 'Scaled balance of the token in the pool' - - name: protocol_liquidity_usd - description: 'Liquidity of the token in the pool in USD, except BPTs' - - name: protocol_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, except BPTs' - - name: pool_liquidity_usd - description: 'Liquidity of the token in the pool in USD, including BPTs' - - name: pool_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, including BPTs' - - - - name: balancer_v2_base_bpt_prices - meta: - blockchain: base - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['base', 'bpt', 'prices'] - description: > - Balancer Pool Token (BPT) hourly median price by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - day - - contract_address - columns: - - name: blockchain - - name: day - - name: version - - name: decimals - - name: contract_address - - name: bpt_price - - - name: balancer_v2_base_transfers_bpt - meta: - blockchain: base - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['base', 'bpt', 'transfers'] - description: > - Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on Base. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - evt_tx_hash - - evt_index - - block_date - columns: - - name: blockchain - - name: version - - name: contract_address - - name: block_date - - name: block_month - - name: evt_tx_hash - - name: evt_index - - &evt_block_time - name: evt_block_time - description: 'Block time of transfer event' - - &evt_block_number - name: evt_block_number - description: 'Block number of transfer event' - - &from - name: from - description: 'Address of BPT provider of transfer event' - - &to - name: to - description: 'Address of BPT receiver of transfer event' - - &value - name: value - description: 'Amount of BPT transferred in transfer event' - - - name: balancer_v2_base_flashloans - meta: - blockchain: base - sector: lending - contributors: hildobby, viniabussafi - config: - tags: ['base', 'flashloans'] - description: > - All Balancer v2 flashloans on base - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - tx_hash - - evt_index - columns: - - name: blockchain - - name: project - - name: version - - name: block_time - - name: block_number - - name: amount - - name: amount_usd - - name: tx_hash - - name: evt_index - - name: fee - - name: currency_contract - - name: currency_symbol - - name: recipient - - name: contract_address - - name: block_month - - - name: balancer_v2_base_protocol_fee - meta: - blockchain: base - project: balancer_v2 - contributors: viniabussafi - config: - tags: ['base', 'revenue', 'fees'] - description: > - Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - - name: pool_id - - name: pool_address - - name: pool_symbol - - name: version - - name: blockchain - - name: token_address - - name: token_symbol - - name: token_amount_raw - description: "Raw amount of revenues of the token in the pool" - - name: token_amount - description: "Amount of revenues of the token in the pool" - - name: protocol_fee_collected_usd - description: "Fee collected in the pool in USD" - - name: treasury_share - description: "Share of total revenue that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" - - name: treasury_revenue_usd - description: "Total revenue directed to Balancer DAO's treasury" - - - name: balancer_v2_base_bpt_supply - meta: - blockchain: base - project: balancer_v2 - contributors: thetroyharris, viniabussafi - config: - tags: ['base', 'bpt', 'supply'] - description: > - Balancer Pool Token (BPT) supply for ComposableStablePools versions 4 and 5. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - blockchain - - token_address - columns: - - name: day - - name: pool_type - - name: version - - name: blockchain - - name: token_address - - name: supply \ No newline at end of file diff --git a/models/balancer/ethereum/balancer_ethereum_schema.yml b/models/balancer/ethereum/balancer_ethereum_schema.yml deleted file mode 100644 index d2f899d1c61..00000000000 --- a/models/balancer/ethereum/balancer_ethereum_schema.yml +++ /dev/null @@ -1,665 +0,0 @@ -version: 2 - -models: - - name: balancer_v2_ethereum_pools_fees - meta: - blockchain: ethereum - project: balancer_v2 - contributors: jacektrocinski, thetroyharris, viniabussafi - config: - tags: ['ethereum', 'balancer', 'pools', 'fees'] - description: > - Balancer v2 swap fees stored at the pool level. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_number - - tx_hash - - index - columns: - - name: blockchain - - name: version - - &contract_address - name: contract_address - description: "Ethereum address for the liquidity pool used in transaction" - tests: - - not_null - - &tx_hash - name: tx_hash - description: "Transaction hash" - tests: - - not_null - - &index - name: index - description: "" - tests: - - not_null - - &tx_index - name: tx_index - description: "" - tests: - - not_null - - &block_time - name: block_time - description: "Block time in UTC" - tests: - - not_null - - &block_number - name: block_number - description: "Block number" - tests: - - not_null - - &swap_fee_percentage - name: swap_fee_percentage - description: "Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)" - tests: - - not_null - - - name: balancer_ethereum_balances - meta: - blockchain: ethereum - project: balancer - contributors: jacektrocinski - config: - tags: ['ethereum', 'balancer', 'balances'] - description: > - ERC20 token rolling sum balances on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool - - token - columns: - - &day - name: day - description: "UTC event block time truncated to the day mark" - tests: - - not_null - - &pool - name: pool - description: "Balancer pool contract address" - - &token - name: token - description: "Token contract address" - - &cumulative_amount - name: cumulative_amount - description: "Balance of a token" - - - name: balancer_v2_ethereum_transfers_bpt - meta: - blockchain: ethereum - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['ethereum', 'bpt', 'transfers'] - description: > - Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on Ethereum. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - evt_tx_hash - - evt_index - - block_date - columns: - - &blockchain - name: blockchain - description: "Blockchain" - - name: version - - *contract_address - - &block_date - name: block_date - description: "UTC event block date" - - &block_month - name: block_month - description: "UTC event block month" - - &evt_tx_hash - name: evt_tx_hash - description: "Transaction hash of transfer event" - - &evt_index - name: evt_index - description: "Event index" - - &evt_block_time - name: evt_block_time - description: "Block time of transfer event" - - &evt_block_number - name: evt_block_number - description: "Block number of transfer event" - - &from - name: from - description: "Address of BPT provider of transfer event" - - &to - name: to - description: "Address of BPT receiver of transfer event" - - &value - name: value - description: "Amount of BPT transferred in transfer event" - - - name: balancer_ethereum_pools_tokens_weights - meta: - blockchain: ethereum - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['ethereum', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer pools. - columns: - - *blockchain - - name: version - - &pool_id - name: pool_id - description: "Unique encoded identifier that refers to each pool" - - &token_address - name: token_address - description: "Contract address for the token" - - &normalized_weight - name: normalized_weight - description: "Weight of the token in the pool." - - - name: balancer_v1_ethereum_pools_tokens_weights - meta: - blockchain: ethereum - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['ethereum', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer v1 pools. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - pool_id - - token_address - columns: - - *blockchain - - name: version - - *pool_id - - *token_address - - *normalized_weight - - - name: balancer_v2_ethereum_pools_tokens_weights - meta: - blockchain: ethereum - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['ethereum', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer v2 pools. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - pool_id - - token_address - columns: - - *blockchain - - name: version - - *pool_id - - *token_address - - *normalized_weight - - - name: balancer_ethereum_vebal_balances_day - meta: - blockchain: ethereum - project: balancer - contibutors: markusbkoch, mendesfabio, victorstefenon - config: - tags: ['balancer', 'ethereum', 'vebal', 'day', 'markusbkoch', 'mendesfabio'] - description: > - Daily balances of veBAL per wallet - Depends on veBAL_call_create_lock, veBAL_evt_Deposit and veBAL_evt_Withdraw - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - wallet_address - columns: - - *day - - name: wallet_address - description: "Address of the wallet holding the veBAL" - - name: bpt_balance - description: "Amount of BPT held in the veBAL lock" - - name: vebal_balance - description: "Amount of veBAL" - - name: lock_time - description: "Amount of time the BPT was locked for at the last time the lock was updated" - - - name: balancer_ethereum_vebal_slopes - meta: - blockchain: ethereum - project: balancer - contibutors: markusbkoch, mendesfabio, victorstefenon - config: - tags: ['balancer', 'ethereum', 'vebal', 'slope', 'markusbkoch', 'mendesfabio', 'victorstefenon'] - description: > - Slope and bias of veBAL per wallet after each balance update - Depends on veBAL_call_create_lock, veBAL_evt_Deposit and veBAL_evt_Withdraw - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_number - - wallet_address - columns: - - *block_number - - *block_time - - name: block_timestamp - description: "Block timestamp" - - name: wallet_address - description: "Address of the wallet holding the veBAL" - - name: bpt_balance - description: "Amount of BPT held in the veBAL lock" - - name: unlocked_at - description: "Timestamp at which B-80BAL-20WETH BPT can be unlocked" - - name: slope - description: "veBAL decay rate (per second)" - - name: bias - description: "veBAL balance at the moment user locks or re-locks" - - name: block_date - description: "Block time trunc to date" - - - name: balancer_ethereum_trades - meta: - blockchain: ethereum - sector: dex - contributors: bizzyvinci, thetroyharris - config: - tags: ['balancer', 'ethereum', 'amm', 'trades', 'dex'] - description: > - DEX trades on balancer on ethereum - columns: - - *blockchain - - &project - name: project - description: "Project name (balancer)" - - &version - name: version - description: "Version of the project" - - *block_month - - *block_date - - *block_time - - &token_bought_symbol - name: token_bought_symbol - description: "Token symbol for token bought in the trade" - - &token_sold_symbol - name: token_sold_symbol - description: "Token symbol for token sold in the trade" - - &token_pair - name: token_pair - description: "Token symbol pair for each token involved in the trade" - - &token_bought_amount - name: token_bought_amount - description: "Value of the token bought at time of execution in the original currency" - - &token_sold_amount - name: token_sold_amount - description: "Value of the token sold at time of execution in the original currency" - - &token_bought_amount_raw - name: token_bought_amount_raw - description: "Raw value of the token bought at time of execution in the original currency" - - &token_sold_amount_raw - name: token_sold_amount_raw - description: "Raw value of the token sold at time of execution in the original currency" - - &amount_usd - name: amount_usd - description: "USD value of the trade at time of execution" - - &token_bought_address - name: token_bought_address - description: "Contract address of the token bought" - - &token_sold_address - name: token_sold_address - description: "Contract address of the token sold" - - &taker - name: taker - description: "Address of trader who purchased a token" - - &maker - name: maker - description: "Address of trader who sold a token" - - *pool_id - - &swap_fee - name: swap_fee - description: 'Swap fee' - - &project_contract_address - name: project_contract_address - description: "Pool address" - - name: pool_symbol - - name: pool_type - - *tx_hash - - &tx_from - name: tx_from - description: "transaction.from" - - &tx_to - name: tx_to - description: "transaction.to" - - *evt_index - - - name: balancer_v1_ethereum_trades - meta: - blockchain: ethereum - sector: dex - contributors: bizzyvinci, thetroyharris, viniabussafi - config: - tags: [ 'balancer', 'ethereum', 'amm', 'trades', 'dex' ] - description: > - DEX trades on balancer v1 on ethereum - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_time - - tx_hash - - evt_index - - check_dex_seed: - blockchain: ethereum - project: balancer - version: 1 - columns: - - *blockchain - - *project - - *version - - *block_month - - *block_date - - *block_time - - *token_bought_symbol - - *token_sold_symbol - - *token_pair - - *token_bought_amount - - *token_sold_amount - - *token_bought_amount_raw - - *token_sold_amount_raw - - *amount_usd - - *token_bought_address - - *token_sold_address - - *taker - - *maker - - *pool_id - - *swap_fee - - *project_contract_address - - name: pool_symbol - - name: pool_type - - *tx_hash - - *tx_from - - *tx_to - - *evt_index - - - name: balancer_v2_ethereum_trades - meta: - blockchain: ethereum - sector: dex - contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi - config: - tags: [ 'balancer', 'ethereum', 'amm', 'trades', 'dex', 'beta' ] - description: > - DEX trades on balancer v2 on ethereum - columns: - - *blockchain - - *project - - *version - - *block_month - - *block_date - - *block_time - - *block_number - - *token_bought_symbol - - *token_sold_symbol - - *token_pair - - *token_bought_amount - - *token_sold_amount - - *token_bought_amount_raw - - *token_sold_amount_raw - - *amount_usd - - *token_bought_address - - *token_sold_address - - *taker - - *maker - - *project_contract_address - - name: pool_symbol - - name: pool_type - - *pool_id - - *swap_fee - - *tx_hash - - *tx_from - - *tx_to - - *evt_index - - - name: balancer_v2_ethereum_liquidity - meta: - blockchain: ethereum - project: balancer_v2 - contributors: victorstefenon, viniabussafi, thetroyharris - config: - tags: ['ethereum', 'balancer', 'pools', 'liquidity'] - description: > - Balancer v2 pools liquidity by token in Ethereum. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - description: 'UTC event block time truncated to the day mark' - - *pool_id - - name: pool_address - - name: pool_symbol - description: 'Symbol of the pool, consisting of the symbol of its tokens and their respective weights' - - name: version - description: 'Version of Balancer in which pool was deployed' - - name: blockchain - description: 'Blockchain in which pool was deployed' - - *token_address - - name: token_symbol - description: 'Symbol of the token' - - name: token_balance_raw - description: 'Raw balance of the token in the pool' - - name: token_balance - description: 'Scaled balance of the token in the pool' - - name: protocol_liquidity_usd - description: 'Liquidity of the token in the pool in USD, except BPTs' - - name: protocol_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, except BPTs' - - name: pool_liquidity_usd - description: 'Liquidity of the token in the pool in USD, including BPTs' - - name: pool_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, including BPTs' - - - name: balancer_ethereum_vebal_votes - meta: - blockchain: ethereum - project: balancer - contibutors: markusbkoch, mendesfabio, stefenon - config: - tags: ['balancer', 'ethereum', 'vebal', 'votes', 'markusbkoch', 'mendesfabio', 'stefenon'] - description: > - Records of votes for Balancer gauges by provider at each voting round - Depends on GaugeController_evt_VoteForGauge and the vebal_slopes spell - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - round_id - - gauge - - provider - columns: - - name: round_id - description: "ID of the voting round" - - name: start_date - description: "Day of the voting round start date" - - name: end_date - description: "Day of the voting round end date" - - name: gauge - description: "Address of the gauge which provider votes for" - - name: provider - description: "Address of the wallet which voted for the gauge" - - name: vote - description: "Weight of the vote performed by the provider for the gauge" - - - name: balancer_v2_ethereum_lbps - meta: - blockchain: ethereum - project: balancer_v2 - contributors: stefenon - config: - tags: ['ethereum', 'balancer', 'lbp'] - description: > - Record of the Liquidity Boostrapping Pools (LBP) of Balancer, an automated portfolio manager and trading platform, on Ethereum. - columns: - - name: name - description: "Name of the LBP" - - name: pool_id - description: "ID of the LBP" - - name: token_sold - description: "Contract address of the token sold by the LBP" - - name: token_symbol - description: "Symbol of the token sold by the LBP" - - name: start_time - description: "LBP start time" - - name: end_time - description: "LBP end time" - - - name: balancer_v1_ethereum_liquidity - meta: - blockchain: ethereum - project: balancer_v1 - contributors: markusbkoch, mendesfabio, victorstefenon, viniabussafi, thetroyharris - config: - tags: ['ethereum', 'balancer', 'pools', 'liquidity'] - description: > - Balancer v1 pools liquidity by token in Ethereum. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - description: "UTC event block time truncated to the day mark" - - *pool_id - - name: pool_address - - name: pool_symbol - description: "Symbol of the pool, consisting of the symbol of its tokens and their respective weights" - - name: version - description: "Version of Balancer in which pool was deployed" - - *blockchain - - *token_address - - name: token_symbol - description: "Symbol of the token" - - name: token_balance_raw - description: "Raw balance of the token in the pool" - - name: token_balance - description: "Scaled balance of the token in the pool" - - name: protocol_liquidity_usd - description: "Liquidity of the token in the pool in USD, except BPTs" - - name: pool_liquidity_usd - description: "Liquidity of the token in the pool in USD, including BPTs" - - - name: balancer_v2_ethereum_flashloans - meta: - blockchain: ethereum - sector: lending - contributors: hildobby - config: - tags: ['ethereum', 'flashloans'] - description: > - All Balancer flashloans on Ethereum - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - tx_hash - - evt_index - columns: - - name: blockchain - - name: project - - name: version - - name: block_time - - name: block_number - - name: amount - - name: amount_usd - - name: tx_hash - - name: evt_index - - name: fee - - name: currency_contract - - name: currency_symbol - - name: recipient - - name: contract_address - - name: block_month - - - name: balancer_v2_ethereum_bpt_prices - meta: - blockchain: ethereum - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['ethereum', 'bpt', 'prices'] - description: > - Balancer Pool Token (BPT) hourly median price by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - day - - contract_address - columns: - - name: blockchain - - name: day - - name: version - - name: decimals - - name: contract_address - - name: bpt_price - - - name: balancer_v2_ethereum_protocol_fee - meta: - blockchain: ethereum - project: balancer_v2 - contributors: viniabussafi - config: - tags: ['ethereum', 'revenue', 'fees'] - description: > - Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - - name: pool_id - - name: pool_address - - name: pool_symbol - - name: version - - name: blockchain - - name: token_address - - name: token_symbol - - name: token_amount_raw - description: "Raw amount of revenues of the token in the pool" - - name: token_amount - description: "Amount of revenues of the token in the pool" - - name: protocol_fee_collected_usd - description: "Fee collected in the pool in USD" - - name: treasury_share - description: "Share of total revenue that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" - - name: treasury_revenue_usd - description: "Total revenue directed to Balancer DAO's treasury" - - - name: balancer_v2_ethereum_bpt_supply - meta: - blockchain: ethereum - project: balancer_v2 - contributors: thetroyharris, viniabussafi - config: - tags: ['ethereum', 'bpt', 'supply'] - description: > - Balancer Pool Token (BPT) supply for ComposableStablePools versions 4 and 5. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - blockchain - - token_address - columns: - - name: day - - name: pool_type - - name: version - - name: blockchain - - name: token_address - - name: supply \ No newline at end of file diff --git a/models/balancer/gnosis/balancer_gnosis_schema.yml b/models/balancer/gnosis/balancer_gnosis_schema.yml deleted file mode 100644 index a9ef89846ef..00000000000 --- a/models/balancer/gnosis/balancer_gnosis_schema.yml +++ /dev/null @@ -1,404 +0,0 @@ -version: 2 - -models: - - name: balancer_gnosis_trades - meta: - blockchain: gnosis - sector: dex - contributors: bizzyvinci - config: - tags: ['balancer', 'gnosis', 'amm', 'trades', 'dex'] - description: > - DEX trades on balancer on gnosis - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_date - - blockchain - - project - - version - - tx_hash - - evt_index - - check_dex_seed: - blockchain: gnosis - project: balancer - version: 2 - columns: - - &blockchain - name: blockchain - description: "Blockchain" - - &project - name: project - description: "Project name (balancer)" - - &version - name: version - description: "Version of the project" - - &block_month - name: block_month - description: "Block month in UTC" - - &block_date - name: block_date - description: "Block date in UTC" - - &block_time - name: block_time - description: 'Block time in UTC' - - &token_bought_symbol - name: token_bought_symbol - description: "Token symbol for token bought in the trade" - - &token_sold_symbol - name: token_sold_symbol - description: "Token symbol for token sold in the trade" - - &token_pair - name: token_pair - description: "Token symbol pair for each token involved in the trade" - - &token_bought_amount - name: token_bought_amount - description: "Value of the token bought at time of execution in the original currency" - - &token_sold_amount - name: token_sold_amount - description: "Value of the token sold at time of execution in the original currency" - - &token_bought_amount_raw - name: token_bought_amount_raw - description: "Raw value of the token bought at time of execution in the original currency" - - &token_sold_amount_raw - name: token_sold_amount_raw - description: "Raw value of the token sold at time of execution in the original currency" - - &amount_usd - name: amount_usd - description: "USD value of the trade at time of execution" - - &token_bought_address - name: token_bought_address - description: "Contract address of the token bought" - - &token_sold_address - name: token_sold_address - description: "Contract address of the token sold" - - &taker - name: taker - description: "Address of trader who purchased a token" - - &maker - name: maker - description: "Address of trader who sold a token" - - &pool_id - name: pool_id - description: 'Unique encoded identifier that refers to each pool' - - &swap_fee - name: swap_fee - description: 'Swap fee' - - &project_contract_address - name: project_contract_address - description: "Pool address" - - name: pool_symbol - - name: pool_type - - &tx_hash - name: tx_hash - description: "Transaction hash" - - &tx_from - name: tx_from - description: "transaction.from" - - &tx_to - name: tx_to - description: "transaction.to" - - &evt_index - name: evt_index - description: "Event index" - - - name: balancer_v2_gnosis_flashloans - meta: - blockchain: gnosis - sector: lending - contributors: hildobby - config: - tags: ['gnosis', 'flashloans'] - description: > - All Balancer flashloans on Gnosis - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - tx_hash - - evt_index - columns: - - name: blockchain - - name: project - - name: version - - name: block_time - - name: block_number - - name: amount - - name: amount_usd - - name: tx_hash - - name: evt_index - - name: fee - - name: currency_contract - - name: currency_symbol - - name: recipient - - name: contract_address - - name: block_month - - - name: balancer_v2_gnosis_bpt_prices - meta: - blockchain: gnosis - project: balancer_v2 - contributors: thetroyharris, viniabussafi - config: - tags: ['gnosis', 'bpt', 'prices'] - description: > - Balancer Pool Token (BPT) hourly median price by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - day - - contract_address - columns: - - name: blockchain - - name: day - - name: version - - name: decimals - - name: contract_address - - name: bpt_price - - - name: balancer_v2_gnosis_pools_fees - meta: - blockchain: gnosis - project: balancer_v2 - contributors: jacektrocinski, thetroyharris, viniabussafi - config: - tags: ['gnosis', 'balancer', 'pools_fees'] - description: > - Balancer v2 swap fees stored at the pool level. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_number - - tx_hash - - index - columns: - - name: blockchain - - name: version - - name: contract_address - - name: tx_hash - - name: index - - name: tx_index - - name: block_time - - name: block_number - - name: swap_fee_percentage - - - name: balancer_v2_gnosis_trades - meta: - blockchain: gnosis - sector: dex - contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi - config: - tags: [ 'balancer', 'gnosis', 'amm', 'trades', 'dex', 'beta' ] - description: > - DEX trades on balancer v2 on gnosis - columns: - - *blockchain - - *project - - *version - - *block_month - - *block_date - - *block_time - - name: block_number - - *token_bought_symbol - - *token_sold_symbol - - *token_pair - - *token_bought_amount - - *token_sold_amount - - *token_bought_amount_raw - - *token_sold_amount_raw - - *amount_usd - - *token_bought_address - - *token_sold_address - - *taker - - *maker - - *project_contract_address - - name: pool_symbol - - name: pool_type - - *pool_id - - *swap_fee - - *tx_hash - - *tx_from - - *tx_to - - *evt_index - - - name: balancer_v2_gnosis_liquidity - meta: - blockchain: gnosis - project: balancer_v2 - contributors: victorstefenon, viniabussafi, thetroyharris - config: - tags: ['gnosis', 'balancer', 'pools', 'liquidity'] - description: > - Balancer v2 pools liquidity by token in Gnosis. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - description: 'UTC event block time truncated to the day mark' - - *pool_id - - name: pool_address - - name: pool_symbol - description: 'Symbol of the pool, consisting of the symbol of its tokens and their respective weights' - - name: version - description: 'Version of Balancer in which pool was deployed' - - name: blockchain - description: 'Blockchain in which pool was deployed' - - name: token_address - - name: token_symbol - description: 'Symbol of the token' - - name: token_balance_raw - description: 'Raw balance of the token in the pool' - - name: token_balance - description: 'Scaled balance of the token in the pool' - - name: protocol_liquidity_usd - description: 'Liquidity of the token in the pool in USD, except BPTs' - - name: protocol_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, except BPTs' - - name: pool_liquidity_usd - description: 'Liquidity of the token in the pool in USD, including BPTs' - - name: pool_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, including BPTs' - - - - name: balancer_gnosis_pools_tokens_weights - meta: - blockchain: gnosis - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['gnosis', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer pools. - columns: - - *blockchain - - name: version - - *pool_id - - &token_address - name: token_address - description: 'Contract address for the token' - - &normalized_weight - name: normalized_weight - description: 'Weight of the token in the pool.' - - - name: balancer_v2_gnosis_pools_tokens_weights - meta: - blockchain: gnosis - project: balancer - contributors: metacrypto, jacektrocinski, viniabussafi - config: - tags: ['gnosis', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer v2 pools. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - pool_id - - token_address - columns: - - *blockchain - - name: version - - *pool_id - - *token_address - - *normalized_weight - - - name: balancer_v2_gnosis_transfers_bpt - meta: - blockchain: gnosis - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['gnosis', 'bpt', 'transfers'] - description: > - Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on Gnosis. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - evt_tx_hash - - evt_index - - block_date - columns: - - name: blockchain - - name: version - - name: contract_address - - name: block_date - - name: block_month - - name: evt_tx_hash - - name: evt_index - - &evt_block_time - name: evt_block_time - description: 'Block time of transfer event' - - &evt_block_number - name: evt_block_number - description: 'Block number of transfer event' - - &from - name: from - description: 'Address of BPT provider of transfer event' - - &to - name: to - description: 'Address of BPT receiver of transfer event' - - &value - name: value - description: 'Amount of BPT transferred in transfer event' - - - name: balancer_v2_gnosis_protocol_fee - meta: - blockchain: gnosis - project: balancer_v2 - contributors: viniabussafi - config: - tags: ['gnosis', 'revenue', 'fees'] - description: > - Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - - name: pool_id - - name: pool_address - - name: pool_symbol - - name: version - - name: blockchain - - name: token_address - - name: token_symbol - - name: token_amount_raw - description: "Raw amount of revenues of the token in the pool" - - name: token_amount - description: "Amount of revenues of the token in the pool" - - name: protocol_fee_collected_usd - description: "Fee collected in the pool in USD" - - name: treasury_share - description: "Share of total revenue that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" - - name: treasury_revenue - description: "Total revenue directed to Balancer DAO's treasury" - - - name: balancer_v2_gnosis_bpt_supply - meta: - blockchain: gnosis - project: balancer_v2 - contributors: thetroyharris, viniabussafi - config: - tags: ['gnosis', 'bpt', 'supply'] - description: > - Balancer Pool Token (BPT) supply for ComposableStablePools versions 4 and 5. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - blockchain - - token_address - columns: - - name: day - - name: pool_type - - name: version - - name: blockchain - - name: token_address - - name: supply \ No newline at end of file diff --git a/models/balancer/optimism/balancer_optimism_schema.yml b/models/balancer/optimism/balancer_optimism_schema.yml deleted file mode 100644 index bb4c52fbe0e..00000000000 --- a/models/balancer/optimism/balancer_optimism_schema.yml +++ /dev/null @@ -1,464 +0,0 @@ -version: 2 - -models: - - name: balancer_v2_optimism_pools_fees - meta: - blockchain: optimism - project: balancer_v2 - contributors: jacektrocinski, thetroyharris, viniabussafi - config: - tags: ['optimism', 'balancer', 'pools_fees'] - description: > - Balancer v2 swap fees stored at the pool level. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_number - - tx_hash - - index - columns: - - name: blockchain - - name: version - - &contract_address - name: contract_address - description: 'Optimism address for the liquidity pool used in transaction' - tests: - - not_null - - &tx_hash - name: tx_hash - description: 'Transaction hash' - tests: - - not_null - - &index - name: index - description: '' - tests: - - not_null - - &tx_index - name: tx_index - description: '' - tests: - - not_null - - &block_time - name: block_time - description: 'Block time in UTC' - tests: - - not_null - - &block_number - name: block_number - description: 'Block number' - tests: - - not_null - - &swap_fee_percentage - name: swap_fee_percentage - description: 'Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)' - tests: - - not_null - - - name: balancer_v2_optimism_transfers_bpt - meta: - blockchain: optimism - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['optimism', 'bpt', 'transfers'] - description: > - Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on Optimism. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - evt_tx_hash - - evt_index - - block_date - columns: - - &blockchain - name: blockchain - description: "Blockchain" - - name: version - - *contract_address - - &block_date - name: block_date - description: "UTC event block date of each DEX trade" - - &block_month - name: block_month - description: "UTC event block month of each DEX trade" - - &evt_tx_hash - name: evt_tx_hash - description: 'Transaction hash of transfer event' - - &evt_index - name: evt_index - description: 'Event index' - - &evt_block_time - name: evt_block_time - description: 'Block time of transfer event' - - &evt_block_number - name: evt_block_number - description: 'Block number of transfer event' - - &from - name: from - description: 'Address of BPT provider of transfer event' - - &to - name: to - description: 'Address of BPT receiver of transfer event' - - &value - name: value - description: 'Amount of BPT transferred in transfer event' - - - name: balancer_optimism_pools_tokens_weights - meta: - blockchain: optimism - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['optimism', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer pools. - columns: - - *blockchain - - name: version - - &pool_id - name: pool_id - description: 'Unique encoded identifier that refers to each pool' - tests: - - not_null - - &token_address - name: token_address - description: 'Contract address for the token' - - &normalized_weight - name: normalized_weight - description: 'Weight of the token in the pool.' - - - name: balancer_v2_optimism_pools_tokens_weights - meta: - blockchain: optimism - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['optimism', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer v2 pools. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - pool_id - - token_address - columns: - - *blockchain - - name: version - - *pool_id - - *token_address - - *normalized_weight - - - name: balancer_optimism_trades - meta: - blockchain: optimism - sector: dex - contributors: bizzyvinci - config: - tags: ['balancer', 'optimism', 'amm', 'trades', 'dex'] - description: > - DEX trades on balancer on optimism - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_date - - blockchain - - project - - version - - tx_hash - - evt_index - - check_dex_seed: - blockchain: optimism - project: balancer - version: 2 - columns: - - *blockchain - - &project - name: project - description: "Project name (balancer)" - - &version - name: version - description: "Version of the project" - - *block_month - - *block_date - - *block_time - - &token_bought_symbol - name: token_bought_symbol - description: "Token symbol for token bought in the trade" - - &token_sold_symbol - name: token_sold_symbol - description: "Token symbol for token sold in the trade" - - &token_pair - name: token_pair - description: "Token symbol pair for each token involved in the trade" - - &token_bought_amount - name: token_bought_amount - description: "Value of the token bought at time of execution in the original currency" - - &token_sold_amount - name: token_sold_amount - description: "Value of the token sold at time of execution in the original currency" - - &token_bought_amount_raw - name: token_bought_amount_raw - description: "Raw value of the token bought at time of execution in the original currency" - - &token_sold_amount_raw - name: token_sold_amount_raw - description: "Raw value of the token sold at time of execution in the original currency" - - &amount_usd - name: amount_usd - description: "USD value of the trade at time of execution" - - &token_bought_address - name: token_bought_address - description: "Contract address of the token bought" - - &token_sold_address - name: token_sold_address - description: "Contract address of the token sold" - - &taker - name: taker - description: "Address of trader who purchased a token" - - &maker - name: maker - description: "Address of trader who sold a token" - - *pool_id - - &swap_fee - name: swap_fee - description: 'Swap fee' - - &project_contract_address - name: project_contract_address - description: "Pool address" - - name: pool_symbol - - name: pool_type - - *tx_hash - - &tx_from - name: tx_from - description: "transaction.from" - - &tx_to - name: tx_to - description: "transaction.to" - - *evt_index - - - name: balancer_v2_optimism_liquidity - meta: - blockchain: optimism - project: balancer_v2 - contributors: victorstefenon, viniabussafi, thetroyharris - config: - tags: ['optimism', 'balancer', 'pools', 'liquidity'] - description: > - Balancer v2 pools liquidity by token in Optimism. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - description: 'UTC event block time truncated to the day mark' - - *pool_id - - name: pool_address - - name: pool_symbol - description: 'Symbol of the pool, consisting of the symbol of its tokens and their respective weights' - - name: version - description: 'Version of Balancer in which pool was deployed' - - name: blockchain - description: 'Blockchain in which pool was deployed' - - *token_address - - name: token_symbol - description: 'Symbol of the token' - - name: token_balance_raw - description: 'Raw balance of the token in the pool' - - name: token_balance - description: 'Scaled balance of the token in the pool' - - name: protocol_liquidity_usd - description: 'Liquidity of the token in the pool in USD, except BPTs' - - name: protocol_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, except BPTs' - - name: pool_liquidity_usd - description: 'Liquidity of the token in the pool in USD, including BPTs' - - name: pool_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, including BPTs' - - - name: balancer_optimism_gauge_mappings - meta: - blockchain: optimism - project: balancer - contributors: msilb7 - config: - tags: ['optimism', 'balancer', 'gauges', 'incentives'] - description: > - Balancer gauge to pool mappings on Optimism. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - pool_contract - - incentives_contract - columns: - - *blockchain - - *version - - &pool_contract - name: pool_contract - description: "Address of the liquidity pool contract" - - *pool_id - - &incentives_contract - name: incentives_contract - description: "Address of the contract where incentives are stored and emitted." - - &incentives_type - name: incentives_type - description: "Description of the incentives address type." - - *evt_block_time - - *evt_block_number - - *contract_address - - *evt_tx_hash - - *evt_index - - - name: balancer_v2_optimism_flashloans - meta: - blockchain: optimism - sector: lending - contributors: hildobby - config: - tags: ['optimism', 'flashloans'] - description: > - All Balancer flashloans on Optimism - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - tx_hash - - evt_index - columns: - - name: blockchain - - name: project - - name: version - - name: block_time - - name: block_number - - name: amount - - name: amount_usd - - name: tx_hash - - name: evt_index - - name: fee - - name: currency_contract - - name: currency_symbol - - name: recipient - - name: contract_address - - name: block_month - - - name: balancer_v2_optimism_bpt_prices - meta: - blockchain: optimism - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['optimism', 'bpt', 'prices'] - description: > - Balancer Pool Token (BPT) hourly median price by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - day - - contract_address - columns: - - name: blockchain - - name: day - - name: version - - name: decimals - - name: contract_address - - name: bpt_price - - - name: balancer_v2_optimism_trades - meta: - blockchain: optimism - sector: dex - contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi - config: - tags: [ 'balancer', 'optimism', 'amm', 'trades', 'dex', 'beta' ] - description: > - DEX trades on balancer v2 on optimism - columns: - - *blockchain - - *project - - *version - - *block_month - - *block_date - - *block_time - - name: block_number - - *token_bought_symbol - - *token_sold_symbol - - *token_pair - - *token_bought_amount - - *token_sold_amount - - *token_bought_amount_raw - - *token_sold_amount_raw - - *amount_usd - - *token_bought_address - - *token_sold_address - - *taker - - *maker - - *project_contract_address - - name: pool_symbol - - name: pool_type - - *pool_id - - *swap_fee - - *tx_hash - - *tx_from - - *tx_to - - *evt_index - - - name: balancer_v2_optimism_protocol_fee - meta: - blockchain: optimism - project: balancer_v2 - contributors: viniabussafi - config: - tags: ['optimism', 'revenue', 'fees'] - description: > - Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - - name: pool_id - - name: pool_address - - name: pool_symbol - - name: version - - name: blockchain - - name: token_address - - name: token_symbol - - name: token_amount_raw - description: "Raw amount of revenues of the token in the pool" - - name: token_amount - description: "Amount of revenues of the token in the pool" - - name: protocol_fee_collected_usd - description: "Fee collected in the pool in USD" - - name: treasury_share - description: "Share of total revenue that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" - - name: treasury_revenue_usd - description: "Total revenue directed to Balancer DAO's treasury" - - - name: balancer_v2_optimism_bpt_supply - meta: - blockchain: optimism - project: balancer_v2 - contributors: thetroyharris, viniabussafi - config: - tags: ['optimism', 'bpt', 'supply'] - description: > - Balancer Pool Token (BPT) supply for ComposableStablePools versions 4 and 5. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - blockchain - - token_address - columns: - - name: day - - name: pool_type - - name: version - - name: blockchain - - name: token_address - - name: supply \ No newline at end of file diff --git a/models/balancer/polygon/balancer_polygon_schema.yml b/models/balancer/polygon/balancer_polygon_schema.yml deleted file mode 100644 index 4f2bbd24412..00000000000 --- a/models/balancer/polygon/balancer_polygon_schema.yml +++ /dev/null @@ -1,454 +0,0 @@ -version: 2 - -models: - - name: balancer_v2_polygon_pools_fees - meta: - blockchain: polygon - project: balancer_v2 - contributors: jacektrocinski, thetroyharris, viniabussafi - config: - tags: ['polygon', 'balancer', 'pools_fees'] - description: > - Balancer v2 swap fees stored at the pool level. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_number - - tx_hash - - index - columns: - - name: blockchain - - name: version - - &contract_address - name: contract_address - description: 'Polygon address for the liquidity pool used in transaction' - tests: - - not_null - - &tx_hash - name: tx_hash - description: 'Transaction hash' - tests: - - not_null - - &index - name: index - description: '' - tests: - - not_null - - &tx_index - name: tx_index - description: '' - tests: - - not_null - - &block_time - name: block_time - description: '' - tests: - - not_null - - &block_number - name: block_number - description: 'Block number' - tests: - - not_null - - &swap_fee_percentage - name: swap_fee_percentage - description: 'Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)' - tests: - - not_null - - - name: balancer_v2_polygon_transfers_bpt - meta: - blockchain: polygon - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['polygon', 'bpt', 'transfers'] - description: > - Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on Polygon. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - evt_tx_hash - - evt_index - - block_date - columns: - - &blockchain - name: blockchain - description: "Blockchain" - - name: version - - *contract_address - - &block_date - name: block_date - description: "UTC event block date of each DEX trade" - - &block_month - name: block_month - description: "UTC event block month of each DEX trade" - - &evt_tx_hash - name: evt_tx_hash - description: 'Transaction hash of transfer event' - - &evt_index - name: evt_index - description: 'Event index' - - &evt_block_time - name: evt_block_time - description: 'Block time of transfer event' - - &evt_block_number - name: evt_block_number - description: 'Block number of transfer event' - - &from - name: from - description: 'Address of BPT provider of transfer event' - - &to - name: to - description: 'Address of BPT receiver of transfer event' - - &value - name: value - description: 'Amount of BPT transferred in transfer event' - - - name: balancer_polygon_pools_tokens_weights - meta: - blockchain: polygon - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['polygon', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer pools. - columns: - - *blockchain - - name: version - - &pool_id - name: pool_id - description: 'Unique encoded identifier that refers to each pool' - tests: - - not_null - - &token_address - name: token_address - description: 'Contract address for the token' - - &normalized_weight - name: normalized_weight - description: 'Weight of the token in the pool.' - - - name: balancer_v2_polygon_pools_tokens_weights - meta: - blockchain: polygon - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['polygon', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer v2 pools. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - pool_id - - token_address - columns: - - *blockchain - - name: version - - *pool_id - - *token_address - - *normalized_weight - - - name: balancer_polygon_trades - meta: - blockchain: polygon - sector: dex - contributors: bizzyvinci - config: - tags: ['balancer', 'polygon', 'amm', 'trades', 'dex'] - description: > - DEX trades on balancer on polygon - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_date - - blockchain - - project - - version - - tx_hash - - evt_index - - check_dex_seed: - blockchain: polygon - project: balancer - version: 2 - columns: - - *blockchain - - &project - name: project - description: "Project name (balancer)" - - &version - name: version - description: "Version of the project" - - *block_month - - *block_date - - *block_time - - &token_bought_symbol - name: token_bought_symbol - description: "Token symbol for token bought in the trade" - - &token_sold_symbol - name: token_sold_symbol - description: "Token symbol for token sold in the trade" - - &token_pair - name: token_pair - description: "Token symbol pair for each token involved in the trade" - - &token_bought_amount - name: token_bought_amount - description: "Value of the token bought at time of execution in the original currency" - - &token_sold_amount - name: token_sold_amount - description: "Value of the token sold at time of execution in the original currency" - - &token_bought_amount_raw - name: token_bought_amount_raw - description: "Raw value of the token bought at time of execution in the original currency" - - &token_sold_amount_raw - name: token_sold_amount_raw - description: "Raw value of the token sold at time of execution in the original currency" - - &amount_usd - name: amount_usd - description: "USD value of the trade at time of execution" - - &token_bought_address - name: token_bought_address - description: "Contract address of the token bought" - - &token_sold_address - name: token_sold_address - description: "Contract address of the token sold" - - &taker - name: taker - description: "Address of trader who purchased a token" - - &maker - name: maker - description: "Address of trader who sold a token" - - *pool_id - - &swap_fee - name: swap_fee - description: 'Swap fee' - - &project_contract_address - name: project_contract_address - description: "Pool address" - - name: pool_symbol - - name: pool_type - - *tx_hash - - &tx_from - name: tx_from - description: "transaction.from" - - &tx_to - name: tx_to - description: "transaction.to" - - *evt_index - - - name: balancer_v2_polygon_liquidity - meta: - blockchain: polygon - project: balancer_v2 - contributors: victorstefenon, viniabussafi, thetroyharris - config: - tags: ['polygon', 'balancer', 'pools', 'liquidity'] - description: > - Balancer v2 pools liquidity by token in Polygon. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - description: 'UTC event block time truncated to the day mark' - - *pool_id - - name: pool_address - - name: pool_symbol - description: 'Symbol of the pool, consisting of the symbol of its tokens and their respective weights' - - name: version - description: 'Version of Balancer in which pool was deployed' - - name: blockchain - description: 'Blockchain in which pool was deployed' - - *token_address - - name: token_symbol - description: 'Symbol of the token' - - name: token_balance_raw - description: 'Raw balance of the token in the pool' - - name: token_balance - description: 'Scaled balance of the token in the pool' - - name: protocol_liquidity_usd - description: 'Liquidity of the token in the pool in USD, except BPTs' - - name: protocol_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, except BPTs' - - name: pool_liquidity_usd - description: 'Liquidity of the token in the pool in USD, including BPTs' - - name: pool_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, including BPTs' - - - name: balancer_v2_polygon_lbps - meta: - blockchain: polygon - project: balancer_v2 - contributors: stefenon - config: - tags: ['polygon', 'balancer', 'lbp'] - description: > - Record of the Liquidity Boostrapping Pools (LBP) of Balancer, an automated portfolio manager and trading platform, on Polygon. - columns: - - name: name - description: 'Name of the LBP' - - name: pool_id - description: 'ID of the LBP' - - name: token_sold - description: 'Contract address of the token sold by the LBP' - - name: token_symbol - description: 'Symbol of the token sold by the LBP' - - name: start_time - description: 'LBP start time' - - name: end_time - description: 'LBP end time' - - - name: balancer_v2_polygon_flashloans - meta: - blockchain: polygon - sector: lending - contributors: hildobby - config: - tags: ['polygon', 'flashloans'] - description: > - All Balancer flashloans on Polygon - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - tx_hash - - evt_index - columns: - - name: blockchain - - name: project - - name: version - - name: block_time - - name: block_number - - name: amount - - name: amount_usd - - name: tx_hash - - name: evt_index - - name: fee - - name: currency_contract - - name: currency_symbol - - name: recipient - - name: contract_address - - name: block_month - - - name: balancer_v2_polygon_bpt_prices - meta: - blockchain: polygon - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['polygon', 'bpt', 'prices'] - description: > - Balancer Pool Token (BPT) hourly median price by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - day - - contract_address - columns: - - name: blockchain - - name: day - - name: version - - name: decimals - - name: contract_address - - name: bpt_price - - - name: balancer_v2_polygon_trades - meta: - blockchain: polygon - sector: dex - contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi - config: - tags: [ 'balancer', 'polygon', 'amm', 'trades', 'dex', 'beta' ] - description: > - DEX trades on balancer v2 on polygon - columns: - - *blockchain - - *project - - *version - - *block_month - - *block_date - - *block_time - - name: block_number - - *token_bought_symbol - - *token_sold_symbol - - *token_pair - - *token_bought_amount - - *token_sold_amount - - *token_bought_amount_raw - - *token_sold_amount_raw - - *amount_usd - - *token_bought_address - - *token_sold_address - - *taker - - *maker - - *project_contract_address - - name: pool_symbol - - name: pool_type - - *pool_id - - *swap_fee - - *tx_hash - - *tx_from - - *tx_to - - *evt_index - - - name: balancer_v2_polygon_protocol_fee - meta: - blockchain: polygon - project: balancer_v2 - contributors: viniabussafi - config: - tags: ['polygon', 'revenue', 'fees'] - description: > - Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - - name: pool_id - - name: pool_address - - name: pool_symbol - - name: version - - name: blockchain - - name: token_address - - name: token_symbol - - name: token_amount_raw - description: "Raw amount of revenues of the token in the pool" - - name: token_amount - description: "Amount of revenues of the token in the pool" - - name: protocol_fee_collected_usd - description: "Fee collected in the pool in USD" - - name: treasury_share - description: "Share of total revenue that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" - - name: treasury_revenue_usd - description: "Total revenue directed to Balancer DAO's treasury" - - - name: balancer_v2_polygon_bpt_supply - meta: - blockchain: polygon - project: balancer_v2 - contributors: thetroyharris, viniabussafi - config: - tags: ['polygon', 'bpt', 'supply'] - description: > - Balancer Pool Token (BPT) supply for ComposableStablePools versions 4 and 5. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - blockchain - - token_address - columns: - - name: day - - name: pool_type - - name: version - - name: blockchain - - name: token_address - - name: supply \ No newline at end of file diff --git a/models/balancer/zkevm/balancer_zkevm_schema.yml b/models/balancer/zkevm/balancer_zkevm_schema.yml deleted file mode 100644 index a573e89563d..00000000000 --- a/models/balancer/zkevm/balancer_zkevm_schema.yml +++ /dev/null @@ -1,431 +0,0 @@ -version: 2 - -models: - - name: balancer_v2_zkevm_pools_fees - meta: - blockchain: zkevm - project: balancer_v2 - contributors: jacektrocinski, thetroyharris, viniabussafi - config: - tags: ['zkevm', 'balancer', 'pools_fees'] - description: > - Balancer v2 swap fees stored at the pool level. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_number - - tx_hash - - index - columns: - - name: blockchain - - name: version - - &contract_address - name: contract_address - description: 'zkevm address for the liquidity pool used in transaction' - tests: - - not_null - - &tx_hash - name: tx_hash - description: 'Transaction hash' - tests: - - not_null - - &index - name: index - description: '' - tests: - - not_null - - &tx_index - name: tx_index - description: '' - tests: - - not_null - - &block_time - name: block_time - description: '' - tests: - - not_null - - &block_number - name: block_number - description: 'Block number' - tests: - - not_null - - &swap_fee_percentage - name: swap_fee_percentage - description: 'Swap fees for the pool, values are returned with 18 decimals (1e18 meaning 100%)' - tests: - - not_null - - - name: balancer_v2_zkevm_transfers_bpt - meta: - blockchain: zkevm - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['zkevm', 'bpt', 'transfers'] - description: > - Balancer Pool Token (BPT) transfer logs on Balancer, an automated portfolio manager and trading platform, on Polygon. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - evt_tx_hash - - evt_index - - block_date - columns: - - &blockchain - name: blockchain - description: "Blockchain" - - name: version - - *contract_address - - &block_date - name: block_date - description: "UTC event block date of each DEX trade" - - &block_month - name: block_month - description: "UTC event block month of each DEX trade" - - &evt_tx_hash - name: evt_tx_hash - description: 'Transaction hash of transfer event' - - &evt_index - name: evt_index - description: 'Event index' - - &evt_block_time - name: evt_block_time - description: 'Block time of transfer event' - - &evt_block_number - name: evt_block_number - description: 'Block number of transfer event' - - &from - name: from - description: 'Address of BPT provider of transfer event' - - &to - name: to - description: 'Address of BPT receiver of transfer event' - - &value - name: value - description: 'Amount of BPT transferred in transfer event' - - - name: balancer_zkevm_pools_tokens_weights - meta: - blockchain: zkevm - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['zkevm', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer pools. - columns: - - name: blockchain - - name: version - - &pool_id - name: pool_id - description: 'Unique encoded identifier that refers to each pool' - tests: - - not_null - - &token_address - name: token_address - description: 'Contract address for the token' - - &normalized_weight - name: normalized_weight - description: 'Weight of the token in the pool.' - - - name: balancer_v2_zkevm_pools_tokens_weights - meta: - blockchain: zkevm - project: balancer - contributors: jacektrocinski, viniabussafi - config: - tags: ['zkevm', 'balancer', 'pools', 'tokens', 'weights'] - description: > - Token weights in Balancer v2 pools. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - pool_id - - token_address - columns: - - name: blockchain - - name: version - - name: pool_id - - name: token_address - - name: normalized_weight - - - name: balancer_zkevm_trades - meta: - blockchain: zkevm - sector: dex - contributors: bizzyvinci, viniabussafi - config: - tags: ['balancer', 'zkevm', 'amm', 'trades', 'dex'] - description: > - DEX trades on balancer on zkevm - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_date - - blockchain - - project - - version - - tx_hash - - evt_index - - check_dex_seed: - blockchain: zkevm - project: balancer - version: 2 - columns: - - name: blockchain - - &project - name: project - description: "Project name (balancer)" - - &version - name: version - description: "Version of the project" - - name: block_month - - name: block_date - - name: block_time - - &token_bought_symbol - name: token_bought_symbol - description: "Token symbol for token bought in the trade" - - &token_sold_symbol - name: token_sold_symbol - description: "Token symbol for token sold in the trade" - - &token_pair - name: token_pair - description: "Token symbol pair for each token involved in the trade" - - &token_bought_amount - name: token_bought_amount - description: "Value of the token bought at time of execution in the original currency" - - &token_sold_amount - name: token_sold_amount - description: "Value of the token sold at time of execution in the original currency" - - &token_bought_amount_raw - name: token_bought_amount_raw - description: "Raw value of the token bought at time of execution in the original currency" - - &token_sold_amount_raw - name: token_sold_amount_raw - description: "Raw value of the token sold at time of execution in the original currency" - - &amount_usd - name: amount_usd - description: "USD value of the trade at time of execution" - - &token_bought_address - name: token_bought_address - description: "Contract address of the token bought" - - &token_sold_address - name: token_sold_address - description: "Contract address of the token sold" - - &taker - name: taker - description: "Address of trader who purchased a token" - - &maker - name: maker - description: "Address of trader who sold a token" - - name: pool_id - - &swap_fee - name: swap_fee - description: 'Swap fee' - - &project_contract_address - name: project_contract_address - description: "Pool address" - - name: pool_symbol - - name: pool_type - - name: tx_hash - - &tx_from - name: tx_from - description: "transaction.from" - - &tx_to - name: tx_to - description: "transaction.to" - - name: evt_index - - - name: balancer_v2_zkevm_liquidity - meta: - blockchain: zkevm - project: balancer_v2 - contributors: victorstefenon, viniabussafi, thetroyharris - config: - tags: ['zkevm', 'balancer', 'pools', 'liquidity'] - description: > - Balancer v2 pools liquidity by token in zkevm. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - description: 'UTC event block time truncated to the day mark' - - name: pool_id - - name: pool_address - - name: pool_symbol - description: 'Symbol of the pool, consisting of the symbol of its tokens and their respective weights' - - name: version - description: 'Version of Balancer in which pool was deployed' - - name: blockchain - description: 'Blockchain in which pool was deployed' - - name: token_address - - name: token_symbol - description: 'Symbol of the token' - - name: token_balance_raw - description: 'Raw balance of the token in the pool' - - name: token_balance - description: 'Scaled balance of the token in the pool' - - name: protocol_liquidity_usd - description: 'Liquidity of the token in the pool in USD, except BPTs' - - name: protocol_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, except BPTs' - - name: pool_liquidity_usd - description: 'Liquidity of the token in the pool in USD, including BPTs' - - name: pool_liquidity_eth - description: 'Liquidity of the token in the pool in ETH, including BPTs' - - - name: balancer_v2_zkevm_flashloans - meta: - blockchain: zkevm - sector: lending - contributors: hildobby, viniabussafi - config: - tags: ['zkevm', 'flashloans'] - description: > - All Balancer flashloans on zkevm - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - tx_hash - - evt_index - columns: - - name: blockchain - - name: project - - name: version - - name: block_time - - name: block_number - - name: amount - - name: amount_usd - - name: tx_hash - - name: evt_index - - name: fee - - name: currency_contract - - name: currency_symbol - - name: recipient - - name: contract_address - - name: block_month - - - name: balancer_v2_zkevm_bpt_prices - meta: - blockchain: zkevm - project: balancer_v2 - contributors: victorstefenon, thetroyharris, viniabussafi - config: - tags: ['zkevm', 'bpt', 'prices'] - description: > - Balancer Pool Token (BPT) hourly median price by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - day - - contract_address - columns: - - name: blockchain - - name: day - - name: version - - name: decimals - - name: contract_address - - name: bpt_price - - - name: balancer_v2_zkevm_trades - meta: - blockchain: zkevm - sector: dex - contributors: bizzyvinci, thetroyharris, tomfutago, viniabussafi - config: - tags: [ 'balancer', 'zkevm', 'amm', 'trades', 'dex', 'beta' ] - description: > - DEX trades on balancer v2 on zkevm - columns: - - name: blockchain - - name: project - - name: version - - name: block_month - - name: block_date - - name: block_time - - name: block_number - - name: token_bought_symbol - - name: token_sold_symbol - - name: token_pair - - name: token_bought_amount - - name: token_sold_amount - - name: token_bought_amount_raw - - name: token_sold_amount_raw - - name: amount_usd - - name: token_bought_address - - name: token_sold_address - - name: taker - - name: maker - - name: project_contract_address - - name: pool_symbol - - name: pool_type - - name: pool_id - - name: swap_fee - - name: tx_hash - - name: tx_from - - name: tx_to - - name: evt_index - - - name: balancer_v2_zkevm_protocol_fee - meta: - blockchain: zkevm - project: balancer_v2 - contributors: viniabussafi - config: - tags: ['zkevm', 'revenue', 'fees'] - description: > - Daily Protocol Fee collected and Revenue by pool on Balancer, an automated portfolio manager and trading platform. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - pool_id - - token_address - columns: - - name: day - - name: pool_id - - name: pool_address - - name: pool_symbol - - name: version - - name: blockchain - - name: token_address - - name: token_symbol - - name: token_amount_raw - description: "Raw amount of revenues of the token in the pool" - - name: token_amount - description: "Amount of revenues of the token in the pool" - - name: protocol_fee_collected_usd - description: "Fee collected in the pool in USD" - - name: treasury_share - description: "Share of total revenue that is directed to Balancer DAO's treasury, as per BIPs 19, 161 and 371" - - name: treasury_revenue_usd - description: "Total revenue directed to Balancer DAO's treasury" - - - name: balancer_v2_zkevm_bpt_supply - meta: - blockchain: zkevm - project: balancer_v2 - contributors: thetroyharris, viniabussafi - config: - tags: ['zkevm', 'bpt', 'supply'] - description: > - Balancer Pool Token (BPT) supply for ComposableStablePools versions 4 and 5. - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - day - - blockchain - - token_address - columns: - - name: day - - name: pool_type - - name: version - - name: blockchain - - name: token_address - - name: supply From d108e3db088e56690956f9fb36676a3ae474101b Mon Sep 17 00:00:00 2001 From: Alan Ghobadi Date: Tue, 4 Jun 2024 01:20:17 +0200 Subject: [PATCH 2/2] Transfers incremental predicate (#6046) * Update transfer models to use incremental predicate macro * Update transfer macros to use incremental predicate macro * More updates * Remove schema * Add incremental_predicates to merge intos --- dbt_project.yml | 2 - .../transfers/erc20/transfers_erc20.sql | 84 ++++++++--------- .../erc20/transfers_erc20_agg_day.sql | 6 +- .../erc20/transfers_erc20_agg_hour.sql | 6 +- .../erc20/transfers_arbitrum_erc20.sql | 43 ++++----- .../transfers_arbitrum_erc20_agg_day.sql | 9 +- .../transfers_arbitrum_erc20_agg_hour.sql | 9 +- .../base/erc20/transfers_base_erc20.sql | 11 ++- models/transfers/base/transfers_base_eth.sql | 11 ++- .../bitcoin/transfers_bitcoin_satoshi.sql | 55 +++++------ .../transfers_bitcoin_satoshi_agg_day.sql | 5 +- .../bnb/bep20/transfers_bnb_bep20.sql | 91 ++++++++++--------- .../bnb/bep20/transfers_bnb_bep20_agg_day.sql | 9 +- .../bep20/transfers_bnb_bep20_agg_hour.sql | 9 +- .../transfers/bnb/bnb/transfers_bnb_bnb.sql | 79 ++++++++-------- .../bnb/bnb/transfers_bnb_bnb_agg_day.sql | 7 +- .../bnb/bnb/transfers_bnb_bnb_agg_hour.sql | 7 +- .../celo/erc1155/transfers_celo_erc1155.sql | 13 +-- .../transfers_celo_erc1155_agg_day.sql | 7 +- .../transfers_celo_erc1155_agg_hour.sql | 7 +- .../celo/erc20/transfers_celo_erc20.sql | 20 ++-- .../erc20/transfers_celo_erc20_agg_day.sql | 7 +- .../erc20/transfers_celo_erc20_agg_hour.sql | 7 +- .../transfers_celo_erc20_rolling_day.sql | 5 +- .../transfers_celo_erc20_rolling_hour.sql | 6 +- .../celo/erc721/transfers_celo_erc721.sql | 9 +- .../erc721/transfers_celo_erc721_agg_day.sql | 7 +- .../erc721/transfers_celo_erc721_agg_hour.sql | 7 +- models/transfers/celo/transfers_celo_celo.sql | 11 ++- .../ethereum/transfers_ethereum_eth.sql | 19 ++-- .../fantom/erc20/transfers_fantom_erc20.sql | 76 ---------------- .../fantom/erc20/transfers_fantom_schema.yml | 37 -------- .../optimism/transfers_optimism_eth.sql | 11 ++- .../polygon/erc20/transfers_polygon_erc20.sql | 5 +- .../erc20/transfers_polygon_erc20_agg_day.sql | 3 +- .../transfers_polygon_erc20_agg_hour.sql | 3 +- .../polygon/matic/transfers_polygon_matic.sql | 79 ++++++++-------- .../matic/transfers_polygon_matic_agg_day.sql | 7 +- .../transfers_polygon_matic_agg_hour.sql | 7 +- .../fantom/transfers_fantom_erc20_test.sql | 16 ---- 40 files changed, 356 insertions(+), 456 deletions(-) delete mode 100644 models/transfers/fantom/erc20/transfers_fantom_erc20.sql delete mode 100644 models/transfers/fantom/erc20/transfers_fantom_schema.yml delete mode 100644 tests/transfers/fantom/transfers_fantom_erc20_test.sql diff --git a/dbt_project.yml b/dbt_project.yml index 91320626953..1daa6f7fd4a 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -437,8 +437,6 @@ models: +schema: transfers_arbitrum polygon: +schema: transfers_polygon - fantom: - +schema: transfers_fantom base: +schema: transfers_base celo: diff --git a/macros/models/_sector/transfers/erc20/transfers_erc20.sql b/macros/models/_sector/transfers/erc20/transfers_erc20.sql index ce02f2a1880..5f58c1bcdce 100644 --- a/macros/models/_sector/transfers/erc20/transfers_erc20.sql +++ b/macros/models/_sector/transfers/erc20/transfers_erc20.sql @@ -4,98 +4,98 @@ WITH erc20_transfers as ( - SELECT - 'receive' as transfer_type, + SELECT + 'receive' as transfer_type, evt_tx_hash, - evt_index, + evt_index, evt_block_time, - to as wallet_address, + to as wallet_address, contract_address as token_address, CAST(value as double) as amount_raw - FROM + FROM {{ erc20_evt_transfer }} {% if is_incremental() %} - WHERE evt_block_time >= date_trunc('day', now() - interval '3' Day) + WHERE {{ incremental_predicate('evt_block_time') }} {% endif %} - UNION ALL + UNION ALL - SELECT - 'send' as transfer_type, + SELECT + 'send' as transfer_type, evt_tx_hash, - evt_index, + evt_index, evt_block_time, - "from" as wallet_address, + "from" as wallet_address, contract_address as token_address, -CAST(value as double) as amount_raw - FROM + FROM {{ erc20_evt_transfer }} {% if is_incremental() %} - WHERE evt_block_time >= date_trunc('day', now() - interval '3' Day) + WHERE {{ incremental_predicate('evt_block_time') }} {% endif %} ) {% if wrapped_token_deposit and wrapped_token_withdrawal %} , wrapped_token_events as ( - SELECT - 'deposit' as transfer_type, - evt_tx_hash, - evt_index, + SELECT + 'deposit' as transfer_type, + evt_tx_hash, + evt_index, evt_block_time, - dst as wallet_address, - contract_address as token_address, + dst as wallet_address, + contract_address as token_address, CAST(wad as double)as amount_raw - FROM + FROM {{ wrapped_token_deposit }} {% if is_incremental() %} - WHERE evt_block_time >= date_trunc('day', now() - interval '3' Day) + WHERE {{ incremental_predicate('evt_block_time') }} {% endif %} - UNION ALL + UNION ALL - SELECT - 'withdraw' as transfer_type, - evt_tx_hash, - evt_index, + SELECT + 'withdraw' as transfer_type, + evt_tx_hash, + evt_index, evt_block_time, - src as wallet_address, - contract_address as token_address, + src as wallet_address, + contract_address as token_address, -CAST(wad as double)as amount_raw - FROM + FROM {{ wrapped_token_withdrawal }} {% if is_incremental() %} - WHERE evt_block_time >= date_trunc('day', now() - interval '3' Day) + WHERE {{ incremental_predicate('evt_block_time') }} {% endif %} ) {% endif %} SELECT - '{{blockchain}}' as blockchain, + '{{blockchain}}' as blockchain, transfer_type, - evt_tx_hash, + evt_tx_hash, evt_index, evt_block_time, CAST(date_trunc('month', evt_block_time) as date) as block_month, - wallet_address, - token_address, + wallet_address, + token_address, amount_raw -FROM +FROM erc20_transfers {% if wrapped_token_deposit and wrapped_token_withdrawal %} -UNION ALL +UNION ALL -SELECT - '{{blockchain}}' as blockchain, +SELECT + '{{blockchain}}' as blockchain, transfer_type, - evt_tx_hash, + evt_tx_hash, evt_index, evt_block_time, CAST(date_trunc('month', evt_block_time) as date) as block_month, - wallet_address, - token_address, + wallet_address, + token_address, amount_raw -FROM +FROM wrapped_token_events {% endif %} diff --git a/macros/models/_sector/transfers/erc20/transfers_erc20_agg_day.sql b/macros/models/_sector/transfers/erc20/transfers_erc20_agg_day.sql index 12607fce1e3..e4ce5f93ff3 100644 --- a/macros/models/_sector/transfers/erc20/transfers_erc20_agg_day.sql +++ b/macros/models/_sector/transfers/erc20/transfers_erc20_agg_day.sql @@ -9,13 +9,13 @@ SELECT t.symbol, sum(tr.amount_raw) as amount_raw, sum(tr.amount_raw / power(10, t.decimals)) as amount -FROM +FROM {{ transfers_erc20 }} tr -LEFT JOIN +LEFT JOIN {{ tokens_erc20 }} t on t.contract_address = tr.token_address {% if is_incremental() %} -- this filter will only be applied on an incremental run -WHERE tr.evt_block_time >= date_trunc('day', now() - interval '3' Day) +WHERE {{ incremental_predicate('tr.evt_block_time') }} {% endif %} GROUP BY 1, 2, 3, 4, 5, 6 diff --git a/macros/models/_sector/transfers/erc20/transfers_erc20_agg_hour.sql b/macros/models/_sector/transfers/erc20/transfers_erc20_agg_hour.sql index 9b6d8ccf5d2..f28169a5f8d 100644 --- a/macros/models/_sector/transfers/erc20/transfers_erc20_agg_hour.sql +++ b/macros/models/_sector/transfers/erc20/transfers_erc20_agg_hour.sql @@ -9,13 +9,13 @@ SELECT t.symbol, sum(tr.amount_raw) as amount_raw, sum(tr.amount_raw / power(10, t.decimals)) as amount -FROM +FROM {{ transfers_erc20 }} tr -LEFT JOIN +LEFT JOIN {{ tokens_erc20 }} t on t.contract_address = tr.token_address {% if is_incremental() %} -- this filter will only be applied on an incremental run -WHERE tr.evt_block_time >= date_trunc('hour', now() - interval '3' Day) +WHERE {{ incremental_predicate('tr.evt_block_time') }} {% endif %} GROUP BY 1, 2, 3, 4, 5, 6 diff --git a/models/transfers/arbitrum/erc20/transfers_arbitrum_erc20.sql b/models/transfers/arbitrum/erc20/transfers_arbitrum_erc20.sql index b2285e92538..3919e8ea425 100644 --- a/models/transfers/arbitrum/erc20/transfers_arbitrum_erc20.sql +++ b/models/transfers/arbitrum/erc20/transfers_arbitrum_erc20.sql @@ -1,59 +1,60 @@ {{ config( - + materialized = 'incremental', partition_by = ['block_month'], file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['transfer_type', 'evt_tx_hash', 'evt_index', 'wallet_address'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')], + unique_key = ['transfer_type', 'evt_tx_hash', 'evt_index', 'wallet_address'], alias = 'erc20', post_hook='{{ expose_spells(\'["arbitrum"]\', "sector", "transfers", \'["Henrystats"]\') }}') }} -WITH +WITH erc20_transfers as ( - SELECT - 'receive' as transfer_type, + SELECT + 'receive' as transfer_type, evt_tx_hash, - evt_index, + evt_index, evt_block_time, - to as wallet_address, + to as wallet_address, contract_address as token_address, CAST(value as double) as amount_raw - FROM + FROM {{ source('erc20_arbitrum', 'evt_transfer') }} {% if is_incremental() %} - WHERE evt_block_time >= date_trunc('day', now() - interval '3' Day) + WHERE {{ incremental_predicate('evt_block_time') }} {% endif %} - UNION ALL + UNION ALL - SELECT - 'send' as transfer_type, + SELECT + 'send' as transfer_type, evt_tx_hash, - evt_index, + evt_index, evt_block_time, - "from" as wallet_address, + "from" as wallet_address, contract_address as token_address, -CAST(value as double) as amount_raw - FROM + FROM {{ source('erc20_arbitrum', 'evt_transfer') }} {% if is_incremental() %} - WHERE evt_block_time >= date_trunc('day', now() - interval '3' Day) + WHERE {{ incremental_predicate('evt_block_time') }} {% endif %} ) SELECT - 'arbitrum' as blockchain, + 'arbitrum' as blockchain, transfer_type, - evt_tx_hash, + evt_tx_hash, evt_index, evt_block_time, CAST(date_trunc('month', evt_block_time) as date) as block_month, - wallet_address, - token_address, + wallet_address, + token_address, amount_raw -FROM +FROM erc20_transfers \ No newline at end of file diff --git a/models/transfers/arbitrum/erc20/transfers_arbitrum_erc20_agg_day.sql b/models/transfers/arbitrum/erc20/transfers_arbitrum_erc20_agg_day.sql index ed191363adb..b78ec3fac43 100644 --- a/models/transfers/arbitrum/erc20/transfers_arbitrum_erc20_agg_day.sql +++ b/models/transfers/arbitrum/erc20/transfers_arbitrum_erc20_agg_day.sql @@ -1,10 +1,11 @@ {{ config( - + alias = 'erc20_agg_day', materialized ='incremental', partition_by = ['block_month'], file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_day')], unique_key = ['block_day', 'wallet_address', 'token_address'] ) }} @@ -18,12 +19,12 @@ select t.symbol, sum(tr.amount_raw) as amount_raw, sum(tr.amount_raw / power(10, t.decimals)) as amount -FROM +FROM {{ ref('transfers_arbitrum_erc20') }} tr -LEFT JOIN +LEFT JOIN {{ source('tokens_arbitrum', 'erc20') }} t on t.contract_address = tr.token_address {% if is_incremental() %} -- this filter will only be applied on an incremental run -WHERE tr.evt_block_time >= date_trunc('day', now() - interval '3' Day) +WHERE {{ incremental_predicate('tr.evt_block_time') }} {% endif %} GROUP BY 1, 2, 3, 4, 5, 6 \ No newline at end of file diff --git a/models/transfers/arbitrum/erc20/transfers_arbitrum_erc20_agg_hour.sql b/models/transfers/arbitrum/erc20/transfers_arbitrum_erc20_agg_hour.sql index 4c7b879e68f..0e18fd08b5a 100644 --- a/models/transfers/arbitrum/erc20/transfers_arbitrum_erc20_agg_hour.sql +++ b/models/transfers/arbitrum/erc20/transfers_arbitrum_erc20_agg_hour.sql @@ -1,10 +1,11 @@ {{ config( - + alias = 'erc20_agg_hour', materialized ='incremental', partition_by = ['block_month'], file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_hour')], unique_key = ['block_hour', 'wallet_address', 'token_address'] ) }} @@ -18,12 +19,12 @@ select t.symbol, sum(tr.amount_raw) as amount_raw, sum(tr.amount_raw / power(10, t.decimals)) as amount -FROM +FROM {{ ref('transfers_arbitrum_erc20') }} tr -LEFT JOIN +LEFT JOIN {{ source('tokens_arbitrum', 'erc20') }} t on t.contract_address = tr.token_address {% if is_incremental() %} -- this filter will only be applied on an incremental run -WHERE tr.evt_block_time >= date_trunc('hour', now() - interval '3' Day) +WHERE {{ incremental_predicate('tr.evt_block_time') }} {% endif %} GROUP BY 1, 2, 3, 4, 5, 6 \ No newline at end of file diff --git a/models/transfers/base/erc20/transfers_base_erc20.sql b/models/transfers/base/erc20/transfers_base_erc20.sql index b0ca8109d14..67c954bcdf6 100644 --- a/models/transfers/base/erc20/transfers_base_erc20.sql +++ b/models/transfers/base/erc20/transfers_base_erc20.sql @@ -1,9 +1,10 @@ {{ config( alias = 'erc20', - + materialized ='incremental', file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')], unique_key='unique_transfer_id', post_hook='{{ expose_spells(\'["base"]\', "sector", @@ -22,7 +23,7 @@ with {{ source('erc20_base', 'evt_transfer') }} where 1=1 {% if is_incremental() %} -- this filter will only be applied on an incremental run - and evt_block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('evt_block_time') }} {% endif %} ) @@ -38,7 +39,7 @@ with {{ source('erc20_base', 'evt_transfer') }} where 1=1 {% if is_incremental() %} -- this filter will only be applied on an incremental run - and evt_block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('evt_block_time') }} {% endif %} ) @@ -56,7 +57,7 @@ with WHERE contract_address = 0x4200000000000000000000000000000000000006 AND topic0 = 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c --deposit {% if is_incremental() %} -- this filter will only be applied on an incremental run - and block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('block_time') }} {% endif %} ) @@ -73,7 +74,7 @@ with WHERE contract_address = 0x4200000000000000000000000000000000000006 AND topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65 --withdrawal {% if is_incremental() %} -- this filter will only be applied on an incremental run - and block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('block_time') }} {% endif %} ) diff --git a/models/transfers/base/transfers_base_eth.sql b/models/transfers/base/transfers_base_eth.sql index 14bfe7258be..448ee7df82d 100644 --- a/models/transfers/base/transfers_base_eth.sql +++ b/models/transfers/base/transfers_base_eth.sql @@ -1,10 +1,11 @@ {{ config( alias ='eth', - + materialized ='incremental', file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.tx_block_time')], unique_key='unique_transfer_id', post_hook='{{ expose_spells(\'["base"]\', "sector", @@ -38,8 +39,8 @@ with eth_transfers as ( and r.success and r.value > uint256 '0' {% if is_incremental() %} -- this filter will only be applied on an incremental run - and r.block_time >= date_trunc('day', now() - interval '7' day) - and t.block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('r.block_time') }} + and {{ incremental_predicate('t.block_time') }} {% endif %} union all @@ -69,8 +70,8 @@ with eth_transfers as ( and t.success and r.value > uint256 '0' {% if is_incremental() %} -- this filter will only be applied on an incremental run - and r.evt_block_time >= date_trunc('day', now() - interval '7' day) - and t.block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('r.evt_block_time') }} + and {{ incremental_predicate('t.block_time') }} {% endif %} ) select * diff --git a/models/transfers/bitcoin/transfers_bitcoin_satoshi.sql b/models/transfers/bitcoin/transfers_bitcoin_satoshi.sql index e174852f8be..e50f7c9f04d 100644 --- a/models/transfers/bitcoin/transfers_bitcoin_satoshi.sql +++ b/models/transfers/bitcoin/transfers_bitcoin_satoshi.sql @@ -1,16 +1,17 @@ {{ config( - + schema = 'transfers_bitcoin', alias = 'satoshi', materialized='incremental', file_format = 'delta', incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['type', 'tx_id', 'index', 'wallet_address'], post_hook='{{ expose_spells(\'["bitcoin"]\', "sector", "transfers", \'["longnhbkhn", "hosuke"]\') }}') }} -with +with input_transfers as ( select 'input' as type, @@ -22,13 +23,13 @@ with block_height, -1 * value as amount_raw from - {{ source('bitcoin', 'inputs') }} + {{ source('bitcoin', 'inputs') }} where address is not null {% if is_incremental() %} - and block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('block_time') }} {% endif %} ) - , + , output_transfers as ( select 'output' as type, @@ -40,38 +41,38 @@ with block_height, value as amount_raw from - {{ source('bitcoin', 'outputs') }} + {{ source('bitcoin', 'outputs') }} where address is not null {% if is_incremental() %} - and block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('block_time') }} {% endif %} ) , transfer_btc as ( - select any_value(type) as type, - tx_id, - index, - 'bitcoin' as blockchain, - any_value(wallet_address) as wallet_address, - any_value(block_time) as block_time, - any_value(block_date) as block_date, - any_value(block_height) as block_height, + select any_value(type) as type, + tx_id, + index, + 'bitcoin' as blockchain, + any_value(wallet_address) as wallet_address, + any_value(block_time) as block_time, + any_value(block_date) as block_date, + any_value(block_height) as block_height, any_value(amount_raw) as amount_raw from input_transfers - group by + group by tx_id , index union all - select any_value(type) as type, - tx_id, - index, - 'bitcoin' as blockchain, - any_value(wallet_address) as wallet_address, - any_value(block_time) as block_time, - any_value(block_date) as block_date, - any_value(block_height) as block_height, + select any_value(type) as type, + tx_id, + index, + 'bitcoin' as blockchain, + any_value(wallet_address) as wallet_address, + any_value(block_time) as block_time, + any_value(block_date) as block_date, + any_value(block_height) as block_height, any_value(amount_raw) as amount_raw - from output_transfers - group by + from output_transfers + group by tx_id , index ) @@ -81,7 +82,7 @@ with where symbol='BTC' and blockchain is null {% if is_incremental() %} - and minute >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('minute') }} {% endif %} ) diff --git a/models/transfers/bitcoin/transfers_bitcoin_satoshi_agg_day.sql b/models/transfers/bitcoin/transfers_bitcoin_satoshi_agg_day.sql index 277a1b2e805..562584dcd91 100644 --- a/models/transfers/bitcoin/transfers_bitcoin_satoshi_agg_day.sql +++ b/models/transfers/bitcoin/transfers_bitcoin_satoshi_agg_day.sql @@ -1,10 +1,11 @@ {{ config( schema = 'transfers_bitcoin', alias = 'satoshi_agg_day', - + materialized ='incremental', file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')], unique_key = ['day', 'wallet_address'] ) }} @@ -18,6 +19,6 @@ select from {{ ref('transfers_bitcoin_satoshi') }} tr {% if is_incremental() %} -- this filter will only be applied on an incremental run -where tr.block_date >= date_trunc('day', now() - interval '7' day) +where {{ incremental_predicate('tr.block_date ') }} {% endif %} group by 1, 2, 3 diff --git a/models/transfers/bnb/bep20/transfers_bnb_bep20.sql b/models/transfers/bnb/bep20/transfers_bnb_bep20.sql index 8921398de71..2caafa44c6e 100644 --- a/models/transfers/bnb/bep20/transfers_bnb_bep20.sql +++ b/models/transfers/bnb/bep20/transfers_bnb_bep20.sql @@ -1,10 +1,11 @@ {{ config( - + materialized = 'incremental', partition_by = ['block_month'], file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['transfer_type', 'evt_tx_hash', 'evt_index', 'wallet_address'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')], + unique_key = ['transfer_type', 'evt_tx_hash', 'evt_index', 'wallet_address'], alias = 'erc20', post_hook='{{ expose_spells(\'["bnb"]\', "sector", @@ -12,95 +13,95 @@ \'["soispoke", "dot2dotseurat", "tschubotz", "Henrystats"]\') }}' ) }} -WITH +WITH erc20_transfers as ( - SELECT - 'receive' as transfer_type, + SELECT + 'receive' as transfer_type, evt_tx_hash, - evt_index, + evt_index, evt_block_time, - to as wallet_address, + to as wallet_address, contract_address as token_address, CAST(value as double) as amount_raw - FROM + FROM {{ source('erc20_bnb', 'evt_transfer') }} {% if is_incremental() %} - WHERE evt_block_time >= date_trunc('day', now() - interval '3' Day) + WHERE {{ incremental_predicate('evt_block_time') }} {% endif %} - UNION ALL + UNION ALL - SELECT - 'send' as transfer_type, + SELECT + 'send' as transfer_type, evt_tx_hash, - evt_index, + evt_index, evt_block_time, - "from" as wallet_address, + "from" as wallet_address, contract_address as token_address, -CAST(value as double) as amount_raw - FROM + FROM {{ source('erc20_bnb', 'evt_transfer') }} {% if is_incremental() %} - WHERE evt_block_time >= date_trunc('day', now() - interval '3' Day) + WHERE {{ incremental_predicate('evt_block_time') }} {% endif %} ), wbnb_events as ( - SELECT - 'deposit' as transfer_type, - evt_tx_hash, - evt_index, + SELECT + 'deposit' as transfer_type, + evt_tx_hash, + evt_index, evt_block_time, - dst as wallet_address, - contract_address as token_address, + dst as wallet_address, + contract_address as token_address, CAST(wad as double)as amount_raw - FROM + FROM {{ source('bnb_bnb', 'WBNB_evt_Deposit') }} {% if is_incremental() %} - WHERE evt_block_time >= date_trunc('day', now() - interval '3' Day) + WHERE {{ incremental_predicate('evt_block_time') }} {% endif %} - UNION ALL + UNION ALL - SELECT - 'withdraw' as transfer_type, - evt_tx_hash, - evt_index, + SELECT + 'withdraw' as transfer_type, + evt_tx_hash, + evt_index, evt_block_time, - src as wallet_address, - contract_address as token_address, + src as wallet_address, + contract_address as token_address, -CAST(wad as double)as amount_raw - FROM + FROM {{ source('bnb_bnb', 'WBNB_evt_Withdrawal') }} {% if is_incremental() %} - WHERE evt_block_time >= date_trunc('day', now() - interval '3' Day) + WHERE {{ incremental_predicate('evt_block_time') }} {% endif %} ) SELECT - 'bnb' as blockchain, + 'bnb' as blockchain, transfer_type, - evt_tx_hash, + evt_tx_hash, evt_index, evt_block_time, CAST(date_trunc('month', evt_block_time) as date) as block_month, - wallet_address, - token_address, + wallet_address, + token_address, amount_raw -FROM +FROM erc20_transfers -UNION ALL +UNION ALL -SELECT - 'bnb' as blockchain, +SELECT + 'bnb' as blockchain, transfer_type, - evt_tx_hash, + evt_tx_hash, evt_index, evt_block_time, CAST(date_trunc('month', evt_block_time) as date) as block_month, - wallet_address, - token_address, + wallet_address, + token_address, amount_raw -FROM +FROM wbnb_events diff --git a/models/transfers/bnb/bep20/transfers_bnb_bep20_agg_day.sql b/models/transfers/bnb/bep20/transfers_bnb_bep20_agg_day.sql index 387f8f73270..9dd7c1d891d 100644 --- a/models/transfers/bnb/bep20/transfers_bnb_bep20_agg_day.sql +++ b/models/transfers/bnb/bep20/transfers_bnb_bep20_agg_day.sql @@ -1,10 +1,11 @@ {{ config( - + alias = 'bep20_agg_day', partition_by = ['block_month'], materialized ='incremental', file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')], unique_key = ['day', 'wallet_address', 'token_address'] ) }} @@ -18,12 +19,12 @@ select t.symbol, sum(tr.amount_raw) as amount_raw, sum(tr.amount_raw / power(10, t.decimals)) as amount -FROM +FROM {{ ref('transfers_bnb_bep20') }} tr -LEFT JOIN +LEFT JOIN {{ source('tokens_bnb', 'bep20') }} t on t.contract_address = tr.token_address {% if is_incremental() %} -- this filter will only be applied on an incremental run -WHERE tr.evt_block_time >= date_trunc('day', now() - interval '3' Day) +WHERE {{ incremental_predicate('tr.evt_block_time') }} {% endif %} GROUP BY 1, 2, 3, 4, 5, 6 \ No newline at end of file diff --git a/models/transfers/bnb/bep20/transfers_bnb_bep20_agg_hour.sql b/models/transfers/bnb/bep20/transfers_bnb_bep20_agg_hour.sql index 3f860895ae7..b2f067a8e71 100644 --- a/models/transfers/bnb/bep20/transfers_bnb_bep20_agg_hour.sql +++ b/models/transfers/bnb/bep20/transfers_bnb_bep20_agg_hour.sql @@ -1,10 +1,11 @@ {{ config( - + alias = 'bep20_agg_hour', partition_by = ['block_month'], materialized ='incremental', file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.hour')], unique_key = ['hour', 'wallet_address', 'token_address'] ) }} @@ -18,12 +19,12 @@ select t.symbol, sum(tr.amount_raw) as amount_raw, sum(tr.amount_raw / power(10, t.decimals)) as amount -FROM +FROM {{ ref('transfers_bnb_bep20') }} tr -LEFT JOIN +LEFT JOIN {{ source('tokens_bnb', 'bep20') }} t on t.contract_address = tr.token_address {% if is_incremental() %} -- this filter will only be applied on an incremental run -WHERE tr.evt_block_time >= date_trunc('hour', now() - interval '3' Day) +WHERE {{ incremental_predicate('tr.evt_block_time') }} {% endif %} GROUP BY 1, 2, 3, 4, 5, 6 \ No newline at end of file diff --git a/models/transfers/bnb/bnb/transfers_bnb_bnb.sql b/models/transfers/bnb/bnb/transfers_bnb_bnb.sql index aaa482009d5..8406a09b907 100644 --- a/models/transfers/bnb/bnb/transfers_bnb_bnb.sql +++ b/models/transfers/bnb/bnb/transfers_bnb_bnb.sql @@ -1,103 +1,104 @@ {{ config( - + materialized = 'incremental', partition_by = ['block_month'], file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['transfer_type', 'tx_hash', 'trace_address', 'wallet_address', 'block_time'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['transfer_type', 'tx_hash', 'trace_address', 'wallet_address', 'block_time'], alias = 'bnb', post_hook='{{ expose_spells(\'["bnb"]\', "sector", "transfers", \'["Henrystats"]\') }}') }} -WITH +WITH bnb_transfers as ( - SELECT - 'receive' as transfer_type, + SELECT + 'receive' as transfer_type, tx_hash, - trace_address, + trace_address, block_time, - to as wallet_address, + to as wallet_address, 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c as token_address, CAST(value as double) as amount_raw - FROM + FROM {{ source('bnb', 'traces') }} WHERE (call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR call_type IS NULL) AND success AND CAST(value as double) > 0 - AND to IS NOT NULL + AND to IS NOT NULL AND to != 0x0000000000000000000000000000000000000000 {% if is_incremental() %} - AND block_time >= date_trunc('day', now() - interval '3' Day) + AND {{ incremental_predicate('block_time') }} {% endif %} - UNION ALL + UNION ALL - SELECT - 'send' as transfer_type, + SELECT + 'send' as transfer_type, tx_hash, - trace_address, + trace_address, block_time, - "from" as wallet_address, + "from" as wallet_address, 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c as token_address, -CAST(value as double) as amount_raw - FROM + FROM {{ source('bnb', 'traces') }} WHERE (call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR call_type IS NULL) AND success AND CAST(value as double) > 0 - AND "from" IS NOT NULL + AND "from" IS NOT NULL AND "from" != 0x0000000000000000000000000000000000000000 -- this is causing duplicates in the test because for some weird reason there are transactions showing in bnb.transactions of this address that doesn't have a tx_hash {% if is_incremental() %} - AND block_time >= date_trunc('day', now() - interval '3' Day) + AND {{ incremental_predicate('block_time') }} {% endif %} ), gas_fee as ( - SELECT + SELECT 'gas_fee' as transfer_type, - hash as tx_hash, - array[index] as trace_address, - block_time, - "from" as wallet_address, - 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c as token_address, - -(CASE + hash as tx_hash, + array[index] as trace_address, + block_time, + "from" as wallet_address, + 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c as token_address, + -(CASE WHEN CAST(gas_price as double) = 0 THEN 0 ELSE (CAST(gas_used as DOUBLE) * CAST(gas_price as DOUBLE)) END) as amount_raw - FROM + FROM {{ source('bnb', 'transactions') }} {% if is_incremental() %} - WHERE block_time >= date_trunc('day', now() - interval '3' Day) + WHERE {{ incremental_predicate('block_time') }} {% endif %} ) SELECT - 'bnb' as blockchain, + 'bnb' as blockchain, transfer_type, - tx_hash, + tx_hash, trace_address, block_time, CAST(date_trunc('month', block_time) as date) as block_month, - wallet_address, - token_address, + wallet_address, + token_address, amount_raw -FROM +FROM bnb_transfers -UNION ALL +UNION ALL -SELECT - 'bnb' as blockchain, +SELECT + 'bnb' as blockchain, transfer_type, - tx_hash, + tx_hash, trace_address, block_time, CAST(date_trunc('month', block_time) as date) as block_month, - wallet_address, - token_address, + wallet_address, + token_address, amount_raw -FROM +FROM gas_fee diff --git a/models/transfers/bnb/bnb/transfers_bnb_bnb_agg_day.sql b/models/transfers/bnb/bnb/transfers_bnb_bnb_agg_day.sql index 6cf61e7754e..e6230256d7f 100644 --- a/models/transfers/bnb/bnb/transfers_bnb_bnb_agg_day.sql +++ b/models/transfers/bnb/bnb/transfers_bnb_bnb_agg_day.sql @@ -1,10 +1,11 @@ {{ config( - + alias = 'bnb_agg_day', partition_by = ['block_month'], materialized ='incremental', file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')], unique_key = ['day', 'wallet_address', 'token_address'] ) }} @@ -18,10 +19,10 @@ select 'BNB' as symbol, sum(tr.amount_raw) as amount_raw, sum(tr.amount_raw / power(10, 18)) as amount -FROM +FROM {{ ref('transfers_bnb_bnb') }} tr {% if is_incremental() %} -- this filter will only be applied on an incremental run -WHERE tr.block_time >= date_trunc('day', now() - interval '3' Day) +WHERE {{ incremental_predicate('tr.block_time') }} {% endif %} GROUP BY 1, 2, 3, 4, 5, 6 \ No newline at end of file diff --git a/models/transfers/bnb/bnb/transfers_bnb_bnb_agg_hour.sql b/models/transfers/bnb/bnb/transfers_bnb_bnb_agg_hour.sql index d3ba23b4505..7b993c6073f 100644 --- a/models/transfers/bnb/bnb/transfers_bnb_bnb_agg_hour.sql +++ b/models/transfers/bnb/bnb/transfers_bnb_bnb_agg_hour.sql @@ -1,10 +1,11 @@ {{ config( - + alias = 'bnb_agg_hour', partition_by = ['block_month'], materialized ='incremental', file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.hour')], unique_key = ['hour', 'wallet_address', 'token_address'] ) }} @@ -18,10 +19,10 @@ select 'BNB' as symbol, sum(tr.amount_raw) as amount_raw, sum(tr.amount_raw / power(10, 18)) as amount -FROM +FROM {{ ref('transfers_bnb_bnb') }} tr {% if is_incremental() %} -- this filter will only be applied on an incremental run -WHERE tr.block_time >= date_trunc('hour', now() - interval '3' Day) +WHERE {{ incremental_predicate('tr.block_time') }} {% endif %} GROUP BY 1, 2, 3, 4, 5, 6 \ No newline at end of file diff --git a/models/transfers/celo/erc1155/transfers_celo_erc1155.sql b/models/transfers/celo/erc1155/transfers_celo_erc1155.sql index 2247d6c37ad..6130e6e6add 100644 --- a/models/transfers/celo/erc1155/transfers_celo_erc1155.sql +++ b/models/transfers/celo/erc1155/transfers_celo_erc1155.sql @@ -1,11 +1,12 @@ -{{ +{{ config( - + alias = 'erc1155', partition_by = ['block_month'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'transfer_type', 'wallet_address', 'token_address', 'token_id', 'amount'], post_hook='{{ expose_spells(\'["celo"]\', "sector", @@ -37,7 +38,7 @@ sent_transfers as ( from {{ source('erc1155_celo', 'evt_transfersingle') }} where 1=1 {% if is_incremental() %} -- this filter will only be applied on an incremental run - and evt_block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('evt_block_time') }} {% endif %} union all select @@ -52,7 +53,7 @@ sent_transfers as ( from transfer_batch where 1=1 {% if is_incremental() %} -- this filter will only be applied on an incremental run - and evt_block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('evt_block_time') }} {% endif %} ), @@ -69,7 +70,7 @@ received_transfers as ( from {{ source('erc1155_celo', 'evt_transfersingle') }} where 1=1 {% if is_incremental() %} -- this filter will only be applied on an incremental run - and evt_block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('evt_block_time') }} {% endif %} union all select @@ -84,7 +85,7 @@ received_transfers as ( from transfer_batch where 1=1 {% if is_incremental() %} -- this filter will only be applied on an incremental run - and evt_block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('evt_block_time') }} {% endif %} ) diff --git a/models/transfers/celo/erc1155/transfers_celo_erc1155_agg_day.sql b/models/transfers/celo/erc1155/transfers_celo_erc1155_agg_day.sql index 83b0dc0ee18..575f22cc07d 100644 --- a/models/transfers/celo/erc1155/transfers_celo_erc1155_agg_day.sql +++ b/models/transfers/celo/erc1155/transfers_celo_erc1155_agg_day.sql @@ -1,11 +1,12 @@ -{{ +{{ config( - + alias = 'erc1155_agg_day', partition_by = ['block_month'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_day')], unique_key = ['wallet_address', 'token_address', 'block_day', 'token_id'], post_hook='{{ expose_spells(\'["celo"]\', "sector", @@ -25,6 +26,6 @@ select from {{ ref('transfers_celo_erc1155') }} tr {% if is_incremental() %} -- this filter will only be applied on an incremental run -where tr.block_time >= date_trunc('day', now() - interval '7' day) +where t{{ incremental_predicate('r.block_time') }} {% endif %} group by 1, 2, 3, 4, 5, 6 diff --git a/models/transfers/celo/erc1155/transfers_celo_erc1155_agg_hour.sql b/models/transfers/celo/erc1155/transfers_celo_erc1155_agg_hour.sql index 82ecd34afe4..e400b55eb3a 100644 --- a/models/transfers/celo/erc1155/transfers_celo_erc1155_agg_hour.sql +++ b/models/transfers/celo/erc1155/transfers_celo_erc1155_agg_hour.sql @@ -1,11 +1,12 @@ -{{ +{{ config( - + alias = 'erc1155_agg_hour', partition_by = ['block_month'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_hour')], unique_key = ['wallet_address', 'token_address', 'block_hour', 'token_id'], post_hook='{{ expose_spells(\'["celo"]\', "sector", @@ -25,6 +26,6 @@ select from {{ ref('transfers_celo_erc1155') }} tr {% if is_incremental() %} -- this filter will only be applied on an incremental run -where tr.block_time >= date_trunc('day', now() - interval '7' day) +where t{{ incremental_predicate('r.block_time') }} {% endif %} group by 1, 2, 3, 4, 5, 6 diff --git a/models/transfers/celo/erc20/transfers_celo_erc20.sql b/models/transfers/celo/erc20/transfers_celo_erc20.sql index d2836e1f579..eb3f092dc1b 100644 --- a/models/transfers/celo/erc20/transfers_celo_erc20.sql +++ b/models/transfers/celo/erc20/transfers_celo_erc20.sql @@ -1,11 +1,11 @@ -{{ +{{ config( - + alias = 'erc20', partition_by = ['block_month'], materialized = 'incremental', file_format = 'delta', - incremental_strategy = 'merge', + incremental_strategy = 'merge',incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'transfer_type', 'evt_index', 'wallet_address'], post_hook='{{ expose_spells(\'["celo"]\', "sector", @@ -29,10 +29,10 @@ with {{ source('erc20_celo', 'evt_transfer') }} where 1=1 {% if is_incremental() %} -- this filter will only be applied on an incremental run - and evt_block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('evt_block_time') }} {% endif %} ), - + received_transfers as ( select 'received' as transfer_type, @@ -47,11 +47,11 @@ with {{ source('erc20_celo', 'evt_transfer') }} where 1=1 {% if is_incremental() %} -- this filter will only be applied on an incremental run - and evt_block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('evt_block_time') }} {% endif %} ) - + /*, -- Wrapped Celo looks to work differently than WETH - commenting this section out for now deposited_wcelo as ( @@ -69,7 +69,7 @@ with and topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef --deposit and bytearray_substring(topic1,13,20) <> 0x0000000000000000000000000000000000000000 {% if is_incremental() %} -- this filter will only be applied on an incremental run - and block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('block_time') }} {% endif %} ), @@ -88,11 +88,11 @@ with and topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef --withdrawal and bytearray_substring(topic1,13,20) = 0x0000000000000000000000000000000000000000 {% if is_incremental() %} -- this filter will only be applied on an incremental run - and block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('block_time') }} {% endif %} ) */ - + select 'celo' as blockchain, transfer_type, wallet_address, token_address, block_time, block_month, amount_raw, evt_index, tx_hash from sent_transfers union diff --git a/models/transfers/celo/erc20/transfers_celo_erc20_agg_day.sql b/models/transfers/celo/erc20/transfers_celo_erc20_agg_day.sql index 44ba0912566..22a114a417f 100644 --- a/models/transfers/celo/erc20/transfers_celo_erc20_agg_day.sql +++ b/models/transfers/celo/erc20/transfers_celo_erc20_agg_day.sql @@ -1,11 +1,12 @@ -{{ +{{ config( - + alias = 'erc20_agg_day', partition_by = ['block_month'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_day')], unique_key = ['wallet_address', 'token_address', 'block_day'], post_hook='{{ expose_spells(\'["celo"]\', "sector", @@ -27,6 +28,6 @@ from {{ ref('transfers_celo_erc20') }} tr left join {{ source('tokens_celo', 'erc20') }} t on t.contract_address = tr.token_address {% if is_incremental() %} -- this filter will only be applied on an incremental run -where tr.block_time >= date_trunc('day', now() - interval '7' day) +where t{{ incremental_predicate('r.block_time') }} {% endif %} group by 1, 2, 3, 4, 5, 6 diff --git a/models/transfers/celo/erc20/transfers_celo_erc20_agg_hour.sql b/models/transfers/celo/erc20/transfers_celo_erc20_agg_hour.sql index 115e6cea85e..66d71999af6 100644 --- a/models/transfers/celo/erc20/transfers_celo_erc20_agg_hour.sql +++ b/models/transfers/celo/erc20/transfers_celo_erc20_agg_hour.sql @@ -1,11 +1,12 @@ -{{ +{{ config( - + alias = 'erc20_agg_hour', partition_by = ['block_month'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_hour')], unique_key = ['wallet_address', 'token_address', 'block_hour'], post_hook='{{ expose_spells(\'["celo"]\', "sector", @@ -27,6 +28,6 @@ from {{ ref('transfers_celo_erc20') }} tr left join {{ source('tokens_celo', 'erc20') }} t on t.contract_address = tr.token_address {% if is_incremental() %} -- this filter will only be applied on an incremental run -where tr.block_time >= date_trunc('day', now() - interval '7' day) +where t{{ incremental_predicate('r.block_time') }} {% endif %} group by 1, 2, 3, 4, 5, 6 diff --git a/models/transfers/celo/erc20/transfers_celo_erc20_rolling_day.sql b/models/transfers/celo/erc20/transfers_celo_erc20_rolling_day.sql index fa092d432b7..6c155e0fa0a 100644 --- a/models/transfers/celo/erc20/transfers_celo_erc20_rolling_day.sql +++ b/models/transfers/celo/erc20/transfers_celo_erc20_rolling_day.sql @@ -1,11 +1,12 @@ -{{ +{{ config( - + alias = 'erc20_rolling_day', partition_by = ['block_month'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_day')], unique_key = ['wallet_address', 'token_address', 'block_day'], post_hook='{{ expose_spells(\'["celo"]\', "sector", diff --git a/models/transfers/celo/erc20/transfers_celo_erc20_rolling_hour.sql b/models/transfers/celo/erc20/transfers_celo_erc20_rolling_hour.sql index c716e959a38..88ff7c0c44c 100644 --- a/models/transfers/celo/erc20/transfers_celo_erc20_rolling_hour.sql +++ b/models/transfers/celo/erc20/transfers_celo_erc20_rolling_hour.sql @@ -1,11 +1,11 @@ -{{ +{{ config( - + alias = 'erc20_rolling_hour', partition_by = ['block_month'], materialized = 'incremental', file_format = 'delta', - incremental_strategy = 'merge', + incremental_strategy = 'merge',incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_hour')], unique_key = ['wallet_address', 'token_address', 'block_hour'], post_hook='{{ expose_spells(\'["celo"]\', "sector", diff --git a/models/transfers/celo/erc721/transfers_celo_erc721.sql b/models/transfers/celo/erc721/transfers_celo_erc721.sql index ad8e1ede0b9..2eff96ee8e4 100644 --- a/models/transfers/celo/erc721/transfers_celo_erc721.sql +++ b/models/transfers/celo/erc721/transfers_celo_erc721.sql @@ -1,11 +1,12 @@ -{{ +{{ config( - + alias = 'erc721', partition_by = ['block_month'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'transfer_type', 'wallet_address', 'token_address', 'token_id'], post_hook='{{ expose_spells(\'["celo"]\', "sector", @@ -29,7 +30,7 @@ sent_transfers as ( from {{ source('erc721_celo', 'evt_transfer') }} where 1=1 {% if is_incremental() %} -- this filter will only be applied on an incremental run - and evt_block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('evt_block_time') }} {% endif %} ), @@ -46,7 +47,7 @@ received_transfers as ( from {{ source('erc721_celo', 'evt_transfer') }} where 1=1 {% if is_incremental() %} -- this filter will only be applied on an incremental run - and evt_block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('evt_block_time') }} {% endif %} ) diff --git a/models/transfers/celo/erc721/transfers_celo_erc721_agg_day.sql b/models/transfers/celo/erc721/transfers_celo_erc721_agg_day.sql index 76032aa249e..2b050159e4c 100644 --- a/models/transfers/celo/erc721/transfers_celo_erc721_agg_day.sql +++ b/models/transfers/celo/erc721/transfers_celo_erc721_agg_day.sql @@ -1,11 +1,12 @@ -{{ +{{ config( - + alias = 'erc721_agg_day', partition_by = ['block_month'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_day')], unique_key = ['wallet_address', 'token_address', 'block_day', 'token_id'], post_hook='{{ expose_spells(\'["celo"]\', "sector", @@ -25,6 +26,6 @@ select from {{ ref('transfers_celo_erc721') }} tr {% if is_incremental() %} -- this filter will only be applied on an incremental run -where tr.block_time >= date_trunc('day', now() - interval '7' day) +where t{{ incremental_predicate('r.block_time') }} {% endif %} group by 1, 2, 3, 4, 5, 6 diff --git a/models/transfers/celo/erc721/transfers_celo_erc721_agg_hour.sql b/models/transfers/celo/erc721/transfers_celo_erc721_agg_hour.sql index af48081d25d..c623c320093 100644 --- a/models/transfers/celo/erc721/transfers_celo_erc721_agg_hour.sql +++ b/models/transfers/celo/erc721/transfers_celo_erc721_agg_hour.sql @@ -1,11 +1,12 @@ -{{ +{{ config( - + alias = 'erc721_agg_hour', partition_by = ['block_month'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_hour')], unique_key = ['wallet_address', 'token_address', 'block_hour', 'token_id'], post_hook='{{ expose_spells(\'["celo"]\', "sector", @@ -25,6 +26,6 @@ select from {{ ref('transfers_celo_erc721') }} tr {% if is_incremental() %} -- this filter will only be applied on an incremental run -where tr.block_time >= date_trunc('day', now() - interval '7' day) +where t{{ incremental_predicate('r.block_time') }} {% endif %} group by 1, 2, 3, 4, 5, 6 diff --git a/models/transfers/celo/transfers_celo_celo.sql b/models/transfers/celo/transfers_celo_celo.sql index 3da630dd3cc..d8817179c54 100644 --- a/models/transfers/celo/transfers_celo_celo.sql +++ b/models/transfers/celo/transfers_celo_celo.sql @@ -1,11 +1,12 @@ {{ config( - + alias = 'celo', partition_by = ['block_month'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.tx_block_time')], unique_key = ['tx_hash', 'trace_address'], post_hook='{{ expose_spells(\'["celo"]\', "sector", @@ -40,8 +41,8 @@ with celo_transfers as ( and r.success and r.value > uint256 '0' {% if is_incremental() %} -- this filter will only be applied on an incremental run - and r.block_time >= date_trunc('day', now() - interval '7' day) - and t.block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('r.block_time') }} + and {{ incremental_predicate('t.block_time') }} {% endif %} union all @@ -71,8 +72,8 @@ with celo_transfers as ( and t.success and r.value > uint256 '0' {% if is_incremental() %} -- this filter will only be applied on an incremental run - and r.evt_block_time >= date_trunc('day', now() - interval '7' day) - and t.block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('r.evt_block_time') }} + and {{ incremental_predicate('t.block_time') }} {% endif %} ) select * diff --git a/models/transfers/ethereum/transfers_ethereum_eth.sql b/models/transfers/ethereum/transfers_ethereum_eth.sql index f9da5171501..a364db16bf6 100644 --- a/models/transfers/ethereum/transfers_ethereum_eth.sql +++ b/models/transfers/ethereum/transfers_ethereum_eth.sql @@ -1,10 +1,11 @@ -{{ +{{ config( - alias = 'eth', - + alias = 'eth', + materialized ='incremental', file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.tx_block_time')], unique_key=['tx_hash', 'trace_address'], post_hook='{{ expose_spells(\'["ethereum"]\', "sector", @@ -13,7 +14,7 @@ ) }} -select +select r."from" ,r.to --Using the ETH placeholder address to match with prices tables @@ -22,19 +23,19 @@ select ,cast(r.value as double)/1e18 as value_decimal ,r.tx_hash ,r.trace_address - ,r.block_time as tx_block_time - ,r.block_number as tx_block_number + ,r.block_time as tx_block_time + ,r.block_number as tx_block_number ,bytearray_substring(t.data, 1, 4) as tx_method_id ,t.to AS tx_to ,t."from" AS tx_from -from {{ source('ethereum', 'traces') }} as r -join {{ source('ethereum', 'transactions') }} as t +from {{ source('ethereum', 'traces') }} as r +join {{ source('ethereum', 'transactions') }} as t on r.tx_hash = t.hash and r.block_number = t.block_number {% if is_incremental() %} -- this filter will only be applied on an incremental run and {{incremental_predicate('t.block_time')}} {% endif %} -where +where (r.call_type not in ('delegatecall', 'callcode', 'staticcall') or r.call_type is null) and r.tx_success = true and r.success = true diff --git a/models/transfers/fantom/erc20/transfers_fantom_erc20.sql b/models/transfers/fantom/erc20/transfers_fantom_erc20.sql deleted file mode 100644 index 7cf2e78af04..00000000000 --- a/models/transfers/fantom/erc20/transfers_fantom_erc20.sql +++ /dev/null @@ -1,76 +0,0 @@ -{{ config( -tags=['prod_exclude'], - alias = 'erc20', - materialized = 'incremental', - file_format = 'delta', - incremental_strategy = 'merge', - unique_key = ['transfer_type', 'evt_tx_hash', 'evt_index', 'wallet_address'], - post_hook='{{ expose_spells(\'["fantom"]\', - "sector", - "transfers", - \'["soispoke", "dot2dotseurat", "tschubotz", "hosuke"]\') }}' - ) -}} - -/* - note: this spell has not been migrated to dunesql, therefore is only a view on spark - please migrate to dunesql to ensure up-to-date logic & data -*/ - -with - sent_transfers as ( - select - 'send'as transfer_type, - evt_tx_hash, - evt_index, - et.to as wallet_address, - contract_address as token_address, - evt_block_time, - value as amount_raw - from - {{ source('erc20_fantom', 'evt_transfer') }} et - {% if is_incremental() %} - where evt_block_time >= date_trunc("day", now() - interval '1 week') - {% endif %} - ), - received_transfers as ( - select - 'receive'as transfer_type, - evt_tx_hash, - evt_index, - et.from as wallet_address, - contract_address as token_address, - evt_block_time, - '-' || CAST(value AS VARCHAR(100)) as amount_raw - from - {{ source('erc20_fantom', 'evt_transfer') }} et - {% if is_incremental() %} - where evt_block_time >= date_trunc("day", now() - interval '1 week') - {% endif %} - ) - --- There is no need to add wrapped FTM deposits / withdrawals since wrapped FTM on fantom triggers transfer events for both. - -select - transfer_type, - 'fantom' as blockchain, - evt_tx_hash, - evt_index, - wallet_address, - token_address, - evt_block_time, - CAST(amount_raw AS VARCHAR(100)) as amount_raw -from sent_transfers - -union - -select - transfer_type, - 'fantom' as blockchain, - evt_tx_hash, - evt_index, - wallet_address, - token_address, - evt_block_time, - CAST(amount_raw AS VARCHAR(100)) as amount_raw -from received_transfers diff --git a/models/transfers/fantom/erc20/transfers_fantom_schema.yml b/models/transfers/fantom/erc20/transfers_fantom_schema.yml deleted file mode 100644 index d0bfea93ae9..00000000000 --- a/models/transfers/fantom/erc20/transfers_fantom_schema.yml +++ /dev/null @@ -1,37 +0,0 @@ -version: 2 - -models: - - name: transfers_fantom_erc20 - meta: - blockchain: fantom - sector: transfers - project: erc20 - contributors: soispoke, dot2dotseurat, tschubotz, hosuke - config: - tags: ['transfers', 'fantom', 'erc20'] - description: "ERC20 Token Transfers on fantom. This table is updated every 30 minutes." - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - transfer_type - - evt_tx_hash - - evt_index - - wallet_address - columns: - - name: unique_transfer_id - description: "Unique transfer ID (used for testing for duplicates)" - - &blockchain - name: blockchain - description: "Blockchain" - - &wallet_address - name: wallet_address - description: "Wallet address of sender or receiver. If amount is negative, wallet address is the sender's." - - &token_address - name: token_address - description: "Contract address for token" - - &evt_block_time - name: evt_block_time - description: "Timestamp for block event time in UTC" - - &amount_raw - name: amount_raw - description: "Raw amount of ERC20 token held *before* taking into account token decimals" diff --git a/models/transfers/optimism/transfers_optimism_eth.sql b/models/transfers/optimism/transfers_optimism_eth.sql index 2f00544a8d7..18af49bb26c 100644 --- a/models/transfers/optimism/transfers_optimism_eth.sql +++ b/models/transfers/optimism/transfers_optimism_eth.sql @@ -1,10 +1,11 @@ {{ config( alias ='eth', - + materialized ='incremental', file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.tx_block_time')], unique_key='unique_transfer_id', post_hook='{{ expose_spells(\'["optimism"]\', "sector", @@ -38,8 +39,8 @@ with eth_transfers as ( and r.success and r.value > uint256 '0' {% if is_incremental() %} -- this filter will only be applied on an incremental run - and r.block_time >= date_trunc('day', now() - interval '7' day) - and t.block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('r.block_time') }} + and {{ incremental_predicate('t.block_time') }} {% endif %} union all @@ -69,8 +70,8 @@ with eth_transfers as ( and t.success and r.value > uint256 '0' {% if is_incremental() %} -- this filter will only be applied on an incremental run - and r.evt_block_time >= date_trunc('day', now() - interval '7' day) - and t.block_time >= date_trunc('day', now() - interval '7' day) + and {{ incremental_predicate('r.evt_block_time') }} + and {{ incremental_predicate('t.block_time') }} {% endif %} ) select * diff --git a/models/transfers/polygon/erc20/transfers_polygon_erc20.sql b/models/transfers/polygon/erc20/transfers_polygon_erc20.sql index 3b5a549c296..b574cb43315 100644 --- a/models/transfers/polygon/erc20/transfers_polygon_erc20.sql +++ b/models/transfers/polygon/erc20/transfers_polygon_erc20.sql @@ -1,10 +1,11 @@ {{ config( - + materialized = 'incremental', partition_by = ['block_month'], file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['transfer_type', 'evt_tx_hash', 'evt_index', 'wallet_address'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')], + unique_key = ['transfer_type', 'evt_tx_hash', 'evt_index', 'wallet_address'], alias = 'erc20', post_hook='{{ expose_spells(\'["polygon"]\', "sector", diff --git a/models/transfers/polygon/erc20/transfers_polygon_erc20_agg_day.sql b/models/transfers/polygon/erc20/transfers_polygon_erc20_agg_day.sql index a0682edd544..e30315898d0 100644 --- a/models/transfers/polygon/erc20/transfers_polygon_erc20_agg_day.sql +++ b/models/transfers/polygon/erc20/transfers_polygon_erc20_agg_day.sql @@ -1,10 +1,11 @@ {{ config( - + alias = 'erc20_agg_day', partition_by = ['block_month'], materialized ='incremental', file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_day')], unique_key = ['block_day', 'wallet_address', 'token_address'] ) }} diff --git a/models/transfers/polygon/erc20/transfers_polygon_erc20_agg_hour.sql b/models/transfers/polygon/erc20/transfers_polygon_erc20_agg_hour.sql index c563c45d4eb..b2cae84b8cd 100644 --- a/models/transfers/polygon/erc20/transfers_polygon_erc20_agg_hour.sql +++ b/models/transfers/polygon/erc20/transfers_polygon_erc20_agg_hour.sql @@ -1,10 +1,11 @@ {{ config( - + alias = 'erc20_agg_hour', partition_by = ['block_month'], materialized ='incremental', file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_hour')], unique_key = ['block_hour', 'wallet_address', 'token_address'] ) }} diff --git a/models/transfers/polygon/matic/transfers_polygon_matic.sql b/models/transfers/polygon/matic/transfers_polygon_matic.sql index 160215cbfd5..7fa06a2d5cb 100644 --- a/models/transfers/polygon/matic/transfers_polygon_matic.sql +++ b/models/transfers/polygon/matic/transfers_polygon_matic.sql @@ -1,101 +1,102 @@ {{ config( - + materialized = 'incremental', partition_by = ['block_month'], file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['transfer_type', 'tx_hash', 'trace_address', 'wallet_address', 'block_time'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['transfer_type', 'tx_hash', 'trace_address', 'wallet_address', 'block_time'], alias = 'matic', post_hook='{{ expose_spells(\'["polygon"]\', "sector", "transfers", \'["Henrystats"]\') }}') }} -WITH +WITH matic_transfers as ( - SELECT - 'receive' as transfer_type, + SELECT + 'receive' as transfer_type, tx_hash, - trace_address, + trace_address, block_time, - to as wallet_address, + to as wallet_address, 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270 as token_address, CAST(value as double) as amount_raw - FROM + FROM {{ source('polygon', 'traces') }} WHERE (call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR call_type IS NULL) AND success AND CAST(value as double) > 0 - AND to IS NOT NULL + AND to IS NOT NULL {% if is_incremental() %} - AND block_time >= date_trunc('day', now() - interval '3' Day) + and {{ incremental_predicate('block_time') }} {% endif %} - UNION ALL + UNION ALL - SELECT - 'send' as transfer_type, + SELECT + 'send' as transfer_type, tx_hash, - trace_address, + trace_address, block_time, - "from" as wallet_address, + "from" as wallet_address, 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270 as token_address, -CAST(value as double) as amount_raw - FROM + FROM {{ source('polygon', 'traces') }} WHERE (call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR call_type IS NULL) AND success AND CAST(value as double) > 0 - AND "from" IS NOT NULL + AND "from" IS NOT NULL {% if is_incremental() %} - AND block_time >= date_trunc('day', now() - interval '3' Day) + and {{ incremental_predicate('block_time') }} {% endif %} ), gas_fee as ( - SELECT + SELECT 'gas_fee' as transfer_type, - hash as tx_hash, - array[index] as trace_address, - block_time, - "from" as wallet_address, - 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270 as token_address, - -(CASE + hash as tx_hash, + array[index] as trace_address, + block_time, + "from" as wallet_address, + 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270 as token_address, + -(CASE WHEN CAST(gas_price as double) = 0 THEN 0 ELSE (CAST(gas_used as DOUBLE) * CAST(gas_price as DOUBLE)) END) as amount_raw - FROM + FROM {{ source('polygon', 'transactions') }} {% if is_incremental() %} - WHERE block_time >= date_trunc('day', now() - interval '3' Day) + WHERE {{ incremental_predicate('block_time') }} {% endif %} ) SELECT - 'polygon' as blockchain, + 'polygon' as blockchain, transfer_type, - tx_hash, + tx_hash, trace_address, block_time, CAST(date_trunc('month', block_time) as date) as block_month, - wallet_address, - token_address, + wallet_address, + token_address, amount_raw -FROM +FROM matic_transfers -UNION ALL +UNION ALL -SELECT - 'polygon' as blockchain, +SELECT + 'polygon' as blockchain, transfer_type, - tx_hash, + tx_hash, trace_address, block_time, CAST(date_trunc('month', block_time) as date) as block_month, - wallet_address, - token_address, + wallet_address, + token_address, amount_raw -FROM +FROM gas_fee diff --git a/models/transfers/polygon/matic/transfers_polygon_matic_agg_day.sql b/models/transfers/polygon/matic/transfers_polygon_matic_agg_day.sql index 796ea4111bb..64c2dc6f1ce 100644 --- a/models/transfers/polygon/matic/transfers_polygon_matic_agg_day.sql +++ b/models/transfers/polygon/matic/transfers_polygon_matic_agg_day.sql @@ -1,10 +1,11 @@ {{ config( - + alias = 'matic_agg_day', partition_by = ['block_month'], materialized ='incremental', file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')], unique_key = ['day', 'wallet_address', 'token_address'] ) }} @@ -18,10 +19,10 @@ select 'MATIC' as symbol, sum(tr.amount_raw) as amount_raw, sum(tr.amount_raw / power(10, 18)) as amount -FROM +FROM {{ ref('transfers_polygon_matic') }} tr {% if is_incremental() %} -- this filter will only be applied on an incremental run -WHERE tr.block_time >= date_trunc('day', now() - interval '3' Day) +WHERE {{ incremental_predicate('tr.block_time') }} {% endif %} GROUP BY 1, 2, 3, 4, 5, 6 \ No newline at end of file diff --git a/models/transfers/polygon/matic/transfers_polygon_matic_agg_hour.sql b/models/transfers/polygon/matic/transfers_polygon_matic_agg_hour.sql index 0e96ebfa12f..c1bef60a800 100644 --- a/models/transfers/polygon/matic/transfers_polygon_matic_agg_hour.sql +++ b/models/transfers/polygon/matic/transfers_polygon_matic_agg_hour.sql @@ -1,10 +1,11 @@ {{ config( - + alias = 'matic_agg_hour', partition_by = ['block_month'], materialized ='incremental', file_format ='delta', incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.hour')], unique_key = ['hour', 'wallet_address', 'token_address'] ) }} @@ -18,10 +19,10 @@ select 'MATIC' as symbol, sum(tr.amount_raw) as amount_raw, sum(tr.amount_raw / power(10, 18)) as amount -FROM +FROM {{ ref('transfers_polygon_matic') }} tr {% if is_incremental() %} -- this filter will only be applied on an incremental run -WHERE tr.block_time >= date_trunc('hour', now() - interval '3' Day) +WHERE {{ incremental_predicate('tr.block_time') }} {% endif %} GROUP BY 1, 2, 3, 4, 5, 6 \ No newline at end of file diff --git a/tests/transfers/fantom/transfers_fantom_erc20_test.sql b/tests/transfers/fantom/transfers_fantom_erc20_test.sql deleted file mode 100644 index ce620e51703..00000000000 --- a/tests/transfers/fantom/transfers_fantom_erc20_test.sql +++ /dev/null @@ -1,16 +0,0 @@ --- Check that number of transfers in data range is correct - -with test_data as ( - select count(*) as total - from {{ ref('transfers_fantom_erc20') }} - where evt_block_time between '2023-01-01' and '2023-02-01' -), - -test_result as ( - select case when total = 69781172 then true else false end as success - from test_data -) - -select * -from test_result -where success = false