From fe83a1e87609fae5a7c8a69ef532638eb0dd4539 Mon Sep 17 00:00:00 2001 From: Matt Romano <42412983+mattromano@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:34:35 -0800 Subject: [PATCH] remove gold (#316) --- .../velodrome__ez_claimed_rewards.sql | 137 ---------- .../velodrome__ez_claimed_rewards.yml | 48 ---- .../velodrome/velodrome__ez_gauges.sql | 62 ----- .../velodrome/velodrome__ez_lp_actions.sql | 128 --------- .../velodrome/velodrome__ez_lp_actions.yml | 62 ----- .../velodrome/velodrome__ez_pool_details.sql | 44 --- .../velodrome/velodrome__ez_pool_details.yml | 36 --- .../velodrome__ez_staking_actions.sql | 66 ----- .../velodrome__ez_staking_actions.yml | 94 ------- .../velodrome/velodrome__ez_swaps.sql | 254 ------------------ .../velodrome/velodrome__ez_swaps.yml | 144 ---------- .../velodrome/velodrome__ez_velo_locks.sql | 69 ----- .../velodrome/velodrome__ez_velo_locks.yml | 42 --- .../velodrome/velodrome__ez_votes.sql | 90 ------- .../velodrome/velodrome__ez_votes.yml | 64 ----- 15 files changed, 1340 deletions(-) delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_claimed_rewards.sql delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_claimed_rewards.yml delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_gauges.sql delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_lp_actions.sql delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_lp_actions.yml delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_pool_details.sql delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_pool_details.yml delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_staking_actions.sql delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_staking_actions.yml delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_swaps.sql delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_swaps.yml delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_velo_locks.sql delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_velo_locks.yml delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_votes.sql delete mode 100644 models/gold/protocols/velodrome/velodrome__ez_votes.yml diff --git a/models/gold/protocols/velodrome/velodrome__ez_claimed_rewards.sql b/models/gold/protocols/velodrome/velodrome__ez_claimed_rewards.sql deleted file mode 100644 index 2cb1a239..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_claimed_rewards.sql +++ /dev/null @@ -1,137 +0,0 @@ -{{ config( - materialized = 'view', - persist_docs ={ "relation": true, - "columns": true }, - meta ={ 'database_tags':{ 'table':{ 'PROTOCOL': 'VELODROME', - 'PURPOSE': 'DEFI, DEX' } } } -) }} - -WITH velo_pools AS ( - - SELECT - pool_address, - pool_name, - pool_type, - token0_symbol, - token1_symbol, - token0_address, - token1_address, - token0_decimals, - token1_decimals - FROM - {{ ref('silver__velodrome_pools') }} -), -tokens AS ( - SELECT - DISTINCT token_address, - token_symbol, - token_decimals - FROM - ( - SELECT - token0_address AS token_address, - token0_symbol AS token_symbol, - token0_decimals AS token_decimals - FROM - velo_pools - UNION - SELECT - token1_address AS token_address, - token1_symbol AS token_symbol, - token1_decimals AS token_decimals - FROM - velo_pools - ) -) -SELECT - block_number, - block_timestamp, - tx_hash, - origin_function_signature, - origin_from_address, - origin_to_address, - base.contract_address, - event_index, - reward_type, - token_id, - CASE - WHEN reward_type = 'venft_distribution' THEN claimed_amount - ELSE COALESCE( - claimed_amount / pow( - 10, - t.token_decimals - ), - claimed_amount - ) - END AS claimed_amount, - CASE - WHEN reward_type = 'venft_distribution' THEN ROUND( - claimed_amount * prices.price, - 2 - ) - WHEN reward_type <> 'venft_distribution' - AND t.token_decimals IS NOT NULL THEN ROUND( - ( - claimed_amount / pow( - 10, - t.token_decimals - ) - ) * prices.price, - 2 - ) - ELSE NULL - END AS claimed_amount_usd, - COALESCE( - t.token_symbol, - C.token_symbol - ) AS token_symbol, - base.token_address AS token_address, - claim_epoch, - max_epoch, - COALESCE ( - claimed_rewards_id, - {{ dbt_utils.generate_surrogate_key( - ['tx_hash', 'event_index'] - ) }} - ) AS ez_claimed_rewards_id, - greatest( - COALESCE( - base.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - prices.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - C.inserted_timestamp, - '2000-01-01' - ) - ) AS inserted_timestamp, - greatest( - COALESCE( - base.modified_timestamp, - '2000-01-01' - ), - COALESCE( - prices.modified_timestamp, - '2000-01-01' - ), - COALESCE( - C.modified_timestamp, - '2000-01-01' - )) AS modified_timestamp -FROM - {{ ref('silver__velodrome_claimed_rewards') }} - base - LEFT JOIN tokens t - ON t.token_address = base.token_address - LEFT JOIN {{ ref('price__ez_prices_hourly') }} - prices - ON HOUR = DATE_TRUNC( - 'hour', - block_timestamp - ) - AND prices.token_address = base.token_address - LEFT JOIN {{ ref('silver__contracts') }} C - ON C.contract_address = base.token_address diff --git a/models/gold/protocols/velodrome/velodrome__ez_claimed_rewards.yml b/models/gold/protocols/velodrome/velodrome__ez_claimed_rewards.yml deleted file mode 100644 index 81cc9aa3..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_claimed_rewards.yml +++ /dev/null @@ -1,48 +0,0 @@ -version: 2 -models: - - name: velodrome__ez_claimed_rewards - description: '{{ doc("velo_claimed_table_doc") }}' - - - columns: - - name: BLOCK_NUMBER - description: '{{ doc("opt_block_number") }}' - - name: BLOCK_TIMESTAMP - description: '{{ doc("opt_block_timestamp") }}' - - name: TX_HASH - description: '{{ doc("opt_tx_hash") }}' - - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("opt_origin_sig") }}' - - name: ORIGIN_FROM_ADDRESS - description: '{{ doc("opt_origin_from") }}' - - name: ORIGIN_TO_ADDRESS - description: '{{ doc("opt_origin_to") }}' - - name: CONTRACT_ADDRESS - description: 'The contract address interacted with in this event.' - - name: EVENT_INDEX - description: 'The event index within the transaction.' - - name: REWARD_TYPE - description: 'The type of rewards claimed, either `voter_rewards`, `venft_distribution`, or `lp_reward`.' - - name: TOKEN_ID - description: 'The veNFT token ID. Only applies to veNFT distributions.' - - name: CLAIMED_AMOUNT - description: 'The amount of tokens claimed, decimal adjusted.' - - name: CLAIMED_AMOUNT_USD - description: 'The amount of tokens claimed, in USD.' - - name: TOKEN_SYMBOL - description: 'The symbol of the claimed tokens.' - tests: - - not_null: - where: CLAIMED_AMOUNT <> 0 - - name: TOKEN_ADDRESS - description: 'The contract address of the claimed tokens' - - name: CLAIM_EPOCH - description: 'The claim epoch, only applicable to veNFT distributions.' - - name: MAX_EPOCH - description: 'The max epoch, only applicable to veNFT distributions.' - - name: EZ_CLAIMED_REWARDS_ID - description: '{{ doc("pk") }}' - - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' - - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/protocols/velodrome/velodrome__ez_gauges.sql b/models/gold/protocols/velodrome/velodrome__ez_gauges.sql deleted file mode 100644 index 0dbf4f43..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_gauges.sql +++ /dev/null @@ -1,62 +0,0 @@ -{{ config( - materialized = 'view', - persist_docs ={ "relation": true, - "columns": true }, - meta={ - 'database_tags':{ - 'table': { - 'PROTOCOL': 'VELODROME', - 'PURPOSE': 'DEFI, DEX' - } - } - } -) }} - -SELECT - block_timestamp, - block_number, - tx_hash, - event_index, - contract_address, - gauge_address, - external_bribe_address, - internal_bribe_address, - creator_address, - A.pool_address AS pool_address, - pool_name, - pool_type, - token0_symbol, - token1_symbol, - token0_address, - token1_address, - COALESCE ( - gauges_id, - {{ dbt_utils.generate_surrogate_key( - ['tx_hash', 'event_index'] - ) }} - ) AS ez_guages_id, - GREATEST( - COALESCE( - A.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - b.inserted_timestamp, - '2000-01-01' - ) - ) AS inserted_timestamp, - GREATEST( - COALESCE( - A.modified_timestamp, - '2000-01-01' - ), - COALESCE( - b.modified_timestamp, - '2000-01-01' - ) - ) AS modified_timestamp -FROM - {{ ref('silver__velodrome_gauges') }} A - LEFT JOIN {{ ref('silver__velodrome_pools') }} - b - ON A.pool_address = b.pool_address diff --git a/models/gold/protocols/velodrome/velodrome__ez_lp_actions.sql b/models/gold/protocols/velodrome/velodrome__ez_lp_actions.sql deleted file mode 100644 index 8722d99d..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_lp_actions.sql +++ /dev/null @@ -1,128 +0,0 @@ -{{ config( - materialized = 'view', - persist_docs ={ "relation": true, - "columns": true }, - meta={ - 'database_tags':{ - 'table': { - 'PROTOCOL': 'VELODROME', - 'PURPOSE': 'DEFI, DEX' - } - } - } -) }} - -SELECT - block_number, - block_timestamp, - tx_hash, - event_index, - origin_function_signature, - origin_from_address, - origin_to_address, - pool_address, - pool_name, - pool_type, - sender_address, - lp_action, - token0_symbol, - token1_symbol, - CASE - WHEN token0_decimals IS NOT NULL THEN amount0_unadj / pow( - 10, - token0_decimals - ) - ELSE amount0_unadj - END AS token0_amount, - CASE - WHEN token1_decimals IS NOT NULL THEN amount1_unadj / pow( - 10, - token1_decimals - ) - ELSE amount1_unadj - END AS token1_amount, - CASE - WHEN token0_decimals IS NOT NULL THEN ROUND( - token0_amount * p0.price, - 2 - ) - ELSE NULL - END AS token0_amount_usd, - CASE - WHEN token1_decimals IS NOT NULL THEN ROUND( - token1_amount * p1.price, - 2 - ) - ELSE NULL - END AS token1_amount_usd, - token0_address, - token1_address, - lp_token_action, - lp_token_amount, - token0_amount_usd + token1_amount_usd AS lp_token_amount_usd, - COALESCE ( - lp_actions_id, - {{ dbt_utils.generate_surrogate_key( - ['tx_hash', 'event_index'] - ) }} - ) AS ez_lp_actions_id, - GREATEST( - COALESCE( - base.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - pools.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - p0.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - p1.inserted_timestamp, - '2000-01-01' - ) - ) AS inserted_timestamp, - GREATEST( - COALESCE( - base.modified_timestamp, - '2000-01-01' - ), - COALESCE( - pools.modified_timestamp, - '2000-01-01' - ), - COALESCE( - p0.modified_timestamp, - '2000-01-01' - ), - COALESCE( - p1.modified_timestamp, - '2000-01-01' - ) - ) AS modified_timestamp -FROM - {{ ref('silver__velodrome_LP_actions') }} - base - INNER JOIN {{ ref('silver__velodrome_pools') }} - pools - ON LOWER( - base.contract_address - ) = LOWER( - pools.pool_address - ) - LEFT JOIN {{ ref('price__ez_prices_hourly') }} - p0 - ON p0.hour = DATE_TRUNC( - 'hour', - block_timestamp - ) - AND token0_address = p0.token_address - LEFT JOIN {{ ref('price__ez_prices_hourly') }} - p1 - ON p1.hour = DATE_TRUNC( - 'hour', - block_timestamp - ) - AND token1_address = p1.token_address diff --git a/models/gold/protocols/velodrome/velodrome__ez_lp_actions.yml b/models/gold/protocols/velodrome/velodrome__ez_lp_actions.yml deleted file mode 100644 index c3fe678c..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_lp_actions.yml +++ /dev/null @@ -1,62 +0,0 @@ -version: 2 -models: - - name: velodrome__ez_lp_actions - description: 'This table contains details about deposits and withdraws into Velodrome liquidity pools.' - - columns: - - name: BLOCK_NUMBER - description: '{{ doc("opt_block_number") }}' - - name: BLOCK_TIMESTAMP - description: '{{ doc("opt_block_timestamp") }}' - - name: TX_HASH - description: '{{ doc("opt_tx_hash") }}' - - name: EVENT_INDEX - description: '{{ doc("opt_event_index") }}' - - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("opt_origin_sig") }}' - - name: ORIGIN_FROM_ADDRESS - description: '{{ doc("opt_origin_from") }}' - - name: ORIGIN_TO_ADDRESS - description: '{{ doc("opt_origin_to") }}' - - name: POOL_ADDRESS - description: '{{ doc("op_pool_address") }}' - - name: POOL_NAME - description: '{{ doc("op_pool_name") }}' - - name: POOL_TYPE - description: '{{ doc("op_pool_type") }}' - - name: SENDER_ADDRESS - description: 'The sender of the liquidity action.' - tests: - - not_null - - name: LP_ACTION - description: 'The liquidity action, either deposit or withdraw.' - - name: TOKEN0_SYMBOL - description: '{{ doc("op_token0_symbol") }}' - - name: TOKEN1_SYMBOL - description: '{{ doc("op_token1_symbol") }}' - - name: TOKEN0_AMOUNT - description: 'The amount of token0 deposited or withdrawn.' - - name: TOKEN1_AMOUNT - description: 'The amount of token1 deposited or withdrawn.' - - name: TOKEN0_AMOUNT_USD - description: 'The amount of token0 in USD deposited or withdrawn.' - - name: TOKEN1_AMOUNT_USD - description: 'The amount of token1 in USD deposited or withdrawn.' - - name: TOKEN0_ADDRESS - description: '{{ doc("op_token0_address") }}' - - name: TOKEN1_ADDRESS - description: '{{ doc("op_token1_address") }}' - - name: LP_TOKEN_ACTION - description: 'The LP token action, either mint or burn.' - - name: LP_TOKEN_AMOUNT - description: 'The amount of LP tokens minted or burned.' - tests: - - not_null - - name: LP_TOKEN_AMOUNT_USD - description: 'The amount of LP tokens minted or burned in USD.' - - name: EZ_LP_ACTIONS_ID - description: '{{ doc("pk") }}' - - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' - - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/protocols/velodrome/velodrome__ez_pool_details.sql b/models/gold/protocols/velodrome/velodrome__ez_pool_details.sql deleted file mode 100644 index 9efe9b9e..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_pool_details.sql +++ /dev/null @@ -1,44 +0,0 @@ -{{ config( - materialized = 'view', - persist_docs ={ "relation": true, - "columns": true }, - meta={ - 'database_tags':{ - 'table': { - 'PROTOCOL': 'VELODROME', - 'PURPOSE': 'DEFI, DEX' - } - } - } -) }} - -SELECT - pool_address, - pool_name, - pool_type, - token0_symbol, - token1_symbol, - token0_address, - token1_address, - token0_decimals, - token1_decimals, - created_timestamp, - created_block, - created_hash, - _inserted_timestamp, - COALESCE ( - pools_id, - {{ dbt_utils.generate_surrogate_key( - ['pool_address'] - ) }} - ) AS ez_pool_details_id, - COALESCE( - inserted_timestamp, - '2000-01-01' - ) AS inserted_timestamp, - COALESCE( - modified_timestamp, - '2000-01-01' - ) AS modified_timestamp -FROM - {{ ref('silver__velodrome_pools') }} diff --git a/models/gold/protocols/velodrome/velodrome__ez_pool_details.yml b/models/gold/protocols/velodrome/velodrome__ez_pool_details.yml deleted file mode 100644 index b45bb932..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_pool_details.yml +++ /dev/null @@ -1,36 +0,0 @@ -version: 2 -models: - - name: velodrome__ez_pool_details - description: 'This table contains metadata details for liquidity pools on Velodrome.' - - columns: - - name: POOL_ADDRESS - description: 'The address of the liquidity pool.' - - name: POOL_NAME - description: 'The name of the liquidity pool.' - - name: POOL_TYPE - description: '{{ doc("op_pool_type") }}' - - name: TOKEN0_SYMBOL - description: 'The symbol of token0 in the pool.' - - name: TOKEN1_SYMBOL - description: 'The symbol of token1 in the pool.' - - name: TOKEN0_ADDRESS - description: 'The address of token0 in the pool.' - - name: TOKEN1_ADDRESS - description: 'The address of token1 in the pool.' - - name: TOKEN0_DECIMALS - description: 'The decimals of token0 in the pool.' - - name: TOKEN1_DECIMALS - description: 'The decimals of token1 in the pool.' - - name: CREATED_TIMESTAMP - description: 'The timestamp the pool was created.' - - name: CREATED_BLOCK - description: 'The block at which the pool was created.' - - name: CREATED_HASH - description: 'The tx hash in which the pool was created.' - - name: EZ_POOL_DETAILS_ID - description: '{{ doc("pk") }}' - - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' - - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/protocols/velodrome/velodrome__ez_staking_actions.sql b/models/gold/protocols/velodrome/velodrome__ez_staking_actions.sql deleted file mode 100644 index 69f56e7c..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_staking_actions.sql +++ /dev/null @@ -1,66 +0,0 @@ -{{ config( - materialized = 'view', - persist_docs ={ "relation": true, - "columns": true }, - meta={ - 'database_tags':{ - 'table': { - 'PROTOCOL': 'VELODROME', - 'PURPOSE': 'DEFI, DEX' - } - } - } -) }} - -SELECT - block_number, - block_timestamp, - tx_hash, - origin_function_signature, - origin_from_address, - origin_to_address, - contract_address, - event_index, - staking_action_type, - lp_token_amount, - lp_provider_address, - gauge_address, - base.pool_address, - pool_name, - pool_type, - token0_symbol, - token1_symbol, - token0_address, - token1_address, - COALESCE ( - locks_id, - {{ dbt_utils.generate_surrogate_key( - ['tx_hash', 'event_index'] - ) }} - ) AS ez_staking_actions_id, - GREATEST( - COALESCE( - base.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - pools.inserted_timestamp, - '2000-01-01' - ) - ) AS inserted_timestamp, - GREATEST( - COALESCE( - base.modified_timestamp, - '2000-01-01' - ), - COALESCE( - pools.modified_timestamp, - '2000-01-01' - ) - ) AS modified_timestamp -FROM - {{ ref('silver__velodrome_staking_actions') }} - base - INNER JOIN {{ ref('silver__velodrome_pools') }} - pools - ON base.pool_address = pools.pool_address diff --git a/models/gold/protocols/velodrome/velodrome__ez_staking_actions.yml b/models/gold/protocols/velodrome/velodrome__ez_staking_actions.yml deleted file mode 100644 index eb25afbc..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_staking_actions.yml +++ /dev/null @@ -1,94 +0,0 @@ -version: 2 -models: - - name: velodrome__ez_staking_actions - description: 'This table contains details on liquidity pool staking actions for Velodrome.' - - columns: - - name: BLOCK_NUMBER - description: '{{ doc("opt_block_number") }}' - - name: BLOCK_TIMESTAMP - description: '{{ doc("opt_block_timestamp") }}' - - name: TX_HASH - description: '{{ doc("opt_tx_hash") }}' - - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("opt_origin_sig") }}' - - name: ORIGIN_FROM_ADDRESS - description: '{{ doc("opt_origin_from") }}' - - name: ORIGIN_TO_ADDRESS - description: '{{ doc("opt_origin_to") }}' - - name: CONTRACT_ADDRESS - description: 'The contract address interacted with in this event.' - - name: EVENT_INDEX - description: 'The index of this event within the transaction.' - - name: STAKING_ACTION_TYPE - description: 'The type of staking action, either deposit or withdraw.' - - name: LP_TOKEN_AMOUNT - description: 'The amount of LP tokens deposited or withdrawn.' - - name: LP_PROVIDER_ADDRESS - description: 'The address of the liquidity provider.' - - name: GAUGE_ADDRESS - description: 'The address of the gauge. Gauges are used for voting on pools in a given epoch.' - - name: POOL_ADDRESS - description: 'The address of the liquidity pool.' - - name: POOL_NAME - description: 'The name of the liquidity pool.' - tests: - - not_null: - config: - severity: error - error_if: ">1000" - warn_if: ">500" - - dbt_expectations.expect_column_values_to_be_in_type_list: - column_type_list: - - STRING - - VARCHAR - - name: POOL_TYPE - description: '{{ doc("op_pool_type") }}' - tests: - - not_null - - dbt_expectations.expect_column_values_to_be_in_type_list: - column_type_list: - - STRING - - VARCHAR - - name: TOKEN0_SYMBOL - description: '{{ doc("op_token0_symbol") }}' - tests: - - not_null: - config: - severity: error - error_if: ">1000" - warn_if: ">500" - - dbt_expectations.expect_column_values_to_be_in_type_list: - column_type_list: - - STRING - - VARCHAR - - name: TOKEN1_SYMBOL - description: '{{ doc("op_token0_symbol") }}' - tests: - - not_null: - config: - severity: error - error_if: ">1000" - warn_if: ">500" - - dbt_expectations.expect_column_values_to_be_in_type_list: - column_type_list: - - STRING - - VARCHAR - - name: TOKEN0_ADDRESS - description: '{{ doc("op_token0_address") }}' - tests: - - not_null - - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ - - name: TOKEN1_ADDRESS - description: '{{ doc("op_token1_address") }}' - tests: - - not_null - - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ - - name: EZ_STAKING_ACTIONS_ID - description: '{{ doc("pk") }}' - - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' - - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/protocols/velodrome/velodrome__ez_swaps.sql b/models/gold/protocols/velodrome/velodrome__ez_swaps.sql deleted file mode 100644 index eaeb93b0..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_swaps.sql +++ /dev/null @@ -1,254 +0,0 @@ -{{ config( - materialized = 'view', - persist_docs ={ "relation": true, - "columns": true }, - meta ={ 'database_tags':{ 'table':{ 'PROTOCOL': 'VELODROME', - 'PURPOSE': 'DEFI, DEX, SWAPS' } } } -) }} - -WITH velo_pools AS ( - - SELECT - pool_address, - pool_name, - pool_type, - token0_symbol, - token1_symbol, - token0_address, - token1_address, - token0_decimals, - token1_decimals - FROM - {{ ref('silver__velodrome_pools') }} -), -tokens AS ( - SELECT - DISTINCT token0_address AS token_address, - token0_decimals AS token_decimals, - token0_symbol AS token_symbol - FROM - velo_pools - UNION - SELECT - DISTINCT token1_address AS token_address, - token1_decimals AS token_decimals, - token1_symbol AS token_symbol - FROM - velo_pools -) -SELECT - block_number, - block_timestamp, - origin_function_signature, - origin_from_address, - origin_to_address, - tx_hash, - event_index, - event_name, - platform, - contract_address, - pool_address, - pool_name, - sender_address, - to_address, - CASE - WHEN amount0_in_unadj <> 0 THEN amount0_in_unadj - WHEN amount1_in_unadj <> 0 THEN amount1_in_unadj - END AS amount_in_unadj, - CASE - WHEN ( - CASE - WHEN amount0_in_unadj <> 0 THEN token0_decimals - WHEN amount1_in_unadj <> 0 THEN token1_decimals - END - ) IS NOT NULL THEN ( - CASE - WHEN amount0_in_unadj <> 0 THEN amount0_in_unadj - WHEN amount1_in_unadj <> 0 THEN amount1_in_unadj - END - ) / pow( - 10, - CASE - WHEN amount0_in_unadj <> 0 THEN token0_decimals - WHEN amount1_in_unadj <> 0 THEN token1_decimals - END - ) - ELSE ( - CASE - WHEN amount0_in_unadj <> 0 THEN amount0_in_unadj - WHEN amount1_in_unadj <> 0 THEN amount1_in_unadj - END - ) - END AS amount_in, - CASE - WHEN ( - CASE - WHEN amount0_in_unadj <> 0 THEN token0_decimals - WHEN amount1_in_unadj <> 0 THEN token1_decimals - END - ) IS NOT NULL THEN ROUND( - amount_in * p0.price, - 2 - ) - END AS amount_in_usd, - CASE - WHEN amount0_out_unadj <> 0 THEN amount0_out_unadj - WHEN amount1_out_unadj <> 0 THEN amount1_out_unadj - END AS amount_out_unadj, - CASE - WHEN ( - CASE - WHEN amount0_out_unadj <> 0 THEN token0_decimals - WHEN amount1_out_unadj <> 0 THEN token1_decimals - END - ) IS NOT NULL THEN ( - CASE - WHEN amount0_out_unadj <> 0 THEN amount0_out_unadj - WHEN amount1_out_unadj <> 0 THEN amount1_out_unadj - END - ) / pow( - 10, - CASE - WHEN amount0_out_unadj <> 0 THEN token0_decimals - WHEN amount1_out_unadj <> 0 THEN token1_decimals - END - ) - ELSE ( - CASE - WHEN amount0_out_unadj <> 0 THEN amount0_out_unadj - WHEN amount1_out_unadj <> 0 THEN amount1_out_unadj - END - ) - END AS amount_out, - CASE - WHEN ( - CASE - WHEN amount0_out_unadj <> 0 THEN token0_decimals - WHEN amount1_out_unadj <> 0 THEN token1_decimals - END - ) IS NOT NULL THEN ROUND( - amount_out * p1.price, - 2 - ) - END AS amount_out_usd, - CASE - WHEN amount0_in_unadj <> 0 THEN token0_address - WHEN amount1_in_unadj <> 0 THEN token1_address - END AS token_address_in, - CASE - WHEN amount0_out_unadj <> 0 THEN token0_address - WHEN amount1_out_unadj <> 0 THEN token1_address - END AS token_address_out, - CASE - WHEN amount0_in_unadj <> 0 THEN token0_symbol - WHEN amount1_in_unadj <> 0 THEN token1_symbol - END AS symbol_in, - CASE - WHEN amount0_out_unadj <> 0 THEN token0_symbol - WHEN amount1_out_unadj <> 0 THEN token1_symbol - END AS symbol_out, - COALESCE( - lp_fee_unadj / pow( - 10, - COALESCE( - tokens.token_decimals, - 0 - ) - ), - lp_fee_unadj, - 0 - ) AS lp_fee, - CASE - WHEN tokens.token_decimals IS NOT NULL THEN ROUND( - lp_fee * p2.price, - 2 - ) - END AS lp_fee_usd, - tokens.token_symbol AS lp_fee_symbol, - CASE - WHEN fee_currency IS NULL - AND lp_fee <> 0 - AND pool_address <> '0xce9accfbb25eddce91845c3a7c3d1613d1d7081f' THEN token_address_in - ELSE fee_currency - END AS lp_fee_token_address, - _log_id, - COALESCE ( - swaps_id, - {{ dbt_utils.generate_surrogate_key( - ['tx_hash', 'event_index'] - ) }} - ) AS fact_blocks_id, - GREATEST( - COALESCE( - base.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - p0.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - p1.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - p2.inserted_timestamp, - '2000-01-01' - ) - ) AS inserted_timestamp, - GREATEST( - COALESCE( - base.modified_timestamp, - '2000-01-01' - ), - COALESCE( - p0.modified_timestamp, - '2000-01-01' - ), - COALESCE( - p1.modified_timestamp, - '2000-01-01' - ), - COALESCE( - p2.modified_timestamp, - '2000-01-01' - ) - ) AS modified_timestamp -FROM - {{ ref('silver__velodrome_swaps') }} - base - INNER JOIN velo_pools pools - ON LOWER( - base.contract_address - ) = LOWER( - pools.pool_address - ) - LEFT JOIN tokens - ON tokens.token_address = fee_currency - LEFT JOIN {{ ref('price__ez_prices_hourly') }} - p0 - ON p0.hour = DATE_TRUNC( - 'hour', - block_timestamp - ) - AND p0.token_address = CASE - WHEN amount0_in_unadj <> 0 THEN token0_address - WHEN amount1_in_unadj <> 0 THEN token1_address - END - LEFT JOIN {{ ref('price__ez_prices_hourly') }} - p1 - ON p1.hour = DATE_TRUNC( - 'hour', - block_timestamp - ) - AND p1.token_address = CASE - WHEN amount0_out_unadj <> 0 THEN token0_address - WHEN amount1_out_unadj <> 0 THEN token1_address - END - LEFT JOIN {{ ref('price__ez_prices_hourly') }} - p2 - ON p2.hour = DATE_TRUNC( - 'hour', - block_timestamp - ) - AND p2.token_address = fee_currency diff --git a/models/gold/protocols/velodrome/velodrome__ez_swaps.yml b/models/gold/protocols/velodrome/velodrome__ez_swaps.yml deleted file mode 100644 index cd8be181..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_swaps.yml +++ /dev/null @@ -1,144 +0,0 @@ -version: 2 -models: - - name: velodrome__ez_swaps - description: 'This table contains details on swaps executed on Velodrome.' - - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - _LOG_ID - columns: - - name: BLOCK_NUMBER - description: '{{ doc("opt_block_number") }}' - - name: BLOCK_TIMESTAMP - description: '{{ doc("opt_block_timestamp") }}' - - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("opt_origin_sig") }}' - - name: ORIGIN_FROM_ADDRESS - description: '{{ doc("opt_origin_from") }}' - - name: ORIGIN_TO_ADDRESS - description: '{{ doc("opt_origin_to") }}' - - name: TX_HASH - description: '{{ doc("opt_tx_hash") }}' - - name: EVENT_INDEX - description: 'The index of this event within this transcation.' - - name: PLATFORM - description: 'The name of the dex. In this case, Velodrome.' - - name: CONTRACT_ADDRESS - description: 'The address of the contract interacted with in the swap.' - - name: POOL_ADDRESS - description: 'The address of the liquidity pool used for the swap.' - tests: - - not_null - - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ - - name: POOL_NAME - description: 'The name of the liquidity pool used for the swap.' - tests: - - not_null: - config: - severity: error - error_if: ">1000" - warn_if: ">500" - - dbt_expectations.expect_column_values_to_be_in_type_list: - column_type_list: - - STRING - - VARCHAR - - name: SENDER_ADDRESS - description: 'The sender of the swap event.' - - name: TO_ADDRESS - description: 'The receiver of the swap event.' - - name: AMOUNT_IN_UNADJ - description: 'The amount of tokens in without decimal adjustment.' - - name: AMOUNT_IN - description: 'The amount of tokens in.' - tests: - - not_null - - dbt_expectations.expect_column_values_to_be_in_type_list: - column_type_list: - - FLOAT - - NUMBER - - name: AMOUNT_IN_USD - description: 'The amount of tokens in, in USD.' - - name: AMOUNT_OUT_UNADJ - description: 'The amount of tokens out without decimal adjustment.' - - name: AMOUNT_OUT - description: 'The amount of tokens out.' - tests: - - not_null - - dbt_expectations.expect_column_values_to_be_in_type_list: - column_type_list: - - FLOAT - - NUMBER - - name: AMOUNT_OUT_USD - description: 'The amount of tokens out, in USD.' - - name: TOKEN_ADDRESS_IN - description: 'The contract address of the token in.' - tests: - - not_null - - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ - - name: TOKEN_ADDRESS_OUT - description: 'The contract address of the token out.' - tests: - - not_null - - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ - - name: SYMBOL_IN - description: 'The symbol of the token in.' - tests: - - not_null: - config: - severity: error - error_if: ">1000" - warn_if: ">500" - - dbt_expectations.expect_column_values_to_be_in_type_list: - column_type_list: - - STRING - - VARCHAR - - name: SYMBOL_OUT - description: 'The symbol of the token out.' - tests: - - not_null: - config: - severity: error - error_if: ">1000" - warn_if: ">500" - - dbt_expectations.expect_column_values_to_be_in_type_list: - column_type_list: - - STRING - - VARCHAR - - name: LP_FEE - description: 'The amount of tokens paid to the LP as a fee.' - tests: - - not_null - - dbt_expectations.expect_column_values_to_be_in_type_list: - column_type_list: - - NUMBER - - FLOAT - - name: LP_FEE_USD - description: 'The amount of tokens paid to the LP as a fee, in USD.' - - name: LP_FEE_SYMBOL - description: 'The symbol of the LP token fees.' - tests: - - dbt_expectations.expect_column_values_to_be_in_type_list: - column_type_list: - - STRING - - VARCHAR - - name: LP_FEE_TOKEN_ADDRESS - description: 'The contract address of the LP token fees.' - tests: - - not_null: - where: LP_FEE <> 0 and POOL_ADDRESS <> '0xce9accfbb25eddce91845c3a7c3d1613d1d7081f' - - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ - - name: _LOG_ID - description: '{{ doc("internal_column") }}' - tests: - - not_null - - name: EZ_SWAPS_ID - description: '{{ doc("pk") }}' - - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' - - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/protocols/velodrome/velodrome__ez_velo_locks.sql b/models/gold/protocols/velodrome/velodrome__ez_velo_locks.sql deleted file mode 100644 index 3df0cb94..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_velo_locks.sql +++ /dev/null @@ -1,69 +0,0 @@ -{{ config( - materialized = 'view', - persist_docs ={ "relation": true, - "columns": true }, - meta={ - 'database_tags':{ - 'table': { - 'PROTOCOL': 'VELODROME', - 'PURPOSE': 'DEFI, DEX' - } - } - } -) }} - -SELECT - block_number, - block_timestamp, - tx_hash, - origin_function_signature, - origin_from_address, - origin_to_address, - contract_address, - event_index, - provider_address, - velo_action, - unlock_date, - token_id, - velo_amount, - ROUND( - velo_amount * price, - 2 - ) AS velo_amount_usd, - deposit_type, - COALESCE ( - locks_id, - {{ dbt_utils.generate_surrogate_key( - ['tx_hash', 'event_index'] - ) }} - ) AS ez_velo_locks_id, - GREATEST( - COALESCE( - l.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - prices.inserted_timestamp, - '2000-01-01' - ) - ) AS inserted_timestamp, - GREATEST( - COALESCE( - l.modified_timestamp, - '2000-01-01' - ), - COALESCE( - prices.modified_timestamp, - '2000-01-01' - ) - ) AS modified_timestamp -FROM - {{ ref('silver__velodrome_locks') }} l - LEFT JOIN {{ ref('price__ez_prices_hourly') }} - prices - ON HOUR = DATE_TRUNC( - 'hour', - block_timestamp - ) -WHERE - symbol = 'VELO' diff --git a/models/gold/protocols/velodrome/velodrome__ez_velo_locks.yml b/models/gold/protocols/velodrome/velodrome__ez_velo_locks.yml deleted file mode 100644 index 6991bb24..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_velo_locks.yml +++ /dev/null @@ -1,42 +0,0 @@ -version: 2 -models: - - name: velodrome__ez_velo_locks - description: 'This table contains details on the locking and unlocking of VELO positions.' - - columns: - - name: BLOCK_NUMBER - description: '{{ doc("opt_block_number") }}' - - name: BLOCK_TIMESTAMP - description: '{{ doc("opt_block_timestamp") }}' - - name: TX_HASH - description: '{{ doc("opt_tx_hash") }}' - - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("opt_origin_sig") }}' - - name: ORIGIN_FROM_ADDRESS - description: '{{ doc("opt_origin_from") }}' - - name: ORIGIN_TO_ADDRESS - description: '{{ doc("opt_origin_to") }}' - - name: CONTRACT_ADDRESS - description: 'The address of the contract interacted with in the event.' - - name: EVENT_INDEX - description: 'The index of the event within the transaction.' - - name: PROVIDER_ADDRESS - description: 'The address of the VELO provider.' - - name: UNLOCK_DATE - description: 'The date at which the lock expires.' - - name: TOKEN_ID - description: 'The token ID of the created lock.' - - name: VELO_ACTION - description: 'Users can create new VELO locks (deposits) or withdraw their VELO tokens. Either deposit or withdraw.' - - name: VELO_AMOUNT - description: 'The amount of VELO tokens locked.' - - name: VELO_AMOUNT_USD - description: 'The amount of VELO tokens locked, in USD.' - - name: DEPOSIT_TYPE - description: 'The type of deposit.' - - name: EZ_VELO_LOCKS_ID - description: '{{ doc("pk") }}' - - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' - - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file diff --git a/models/gold/protocols/velodrome/velodrome__ez_votes.sql b/models/gold/protocols/velodrome/velodrome__ez_votes.sql deleted file mode 100644 index b95cb5f2..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_votes.sql +++ /dev/null @@ -1,90 +0,0 @@ -{{ config( - materialized = 'view', - persist_docs ={ "relation": true, - "columns": true }, - meta ={ 'database_tags':{ 'table':{ 'PROTOCOL': 'VELODROME', - 'PURPOSE': 'DEFI, DEX' }}} -) }} - -SELECT - base.block_number AS block_number, - base.block_timestamp AS block_timestamp, - base.tx_hash AS tx_hash, - base.origin_function_signature AS origin_function_signature, - base.origin_from_address AS origin_from_address, - base.origin_to_address AS origin_to_address, - COALESCE( - g1.gauge_address, - g0.gauge_address - ) AS gauge_address, - COALESCE( - g1.external_bribe_address, - g0.external_bribe_address - ) AS external_bribe_address, - COALESCE( - g1.internal_bribe_address, - g0.internal_bribe_address - ) AS internal_bribe_address, - COALESCE( - g1.pool_address, - g0.pool_address - ) AS pool_address, - COALESCE( - g1.pool_name, - g0.pool_name - ) AS pool_name, - from_address, - token_id, - vote_amount, - vote_action, - COALESCE ( - votes_id, - {{ dbt_utils.generate_surrogate_key( - ['base.tx_hash', 'base.event_index'] - ) }} - ) AS ez_votes_id, - GREATEST( - COALESCE( - base.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - g1.inserted_timestamp, - '2000-01-01' - ), - COALESCE( - g0.inserted_timestamp, - '2000-01-01' - ) - ) AS inserted_timestamp, - GREATEST( - COALESCE( - base.modified_timestamp, - '2000-01-01' - ), - COALESCE( - g1.modified_timestamp, - '2000-01-01' - ), - COALESCE( - g0.inserted_timestamp, - '2000-01-01' - ) - ) AS modified_timestamp -FROM - {{ ref('silver__velodrome_votes') }} - base - LEFT JOIN {{ ref('velodrome__ez_gauges') }} - g1 - ON LOWER( - base.contract_address - ) = LOWER( - g1.external_bribe_address - ) - LEFT JOIN {{ ref('velodrome__ez_gauges') }} - g0 - ON LOWER( - base.contract_address - ) = LOWER( - g0.internal_bribe_address - ) diff --git a/models/gold/protocols/velodrome/velodrome__ez_votes.yml b/models/gold/protocols/velodrome/velodrome__ez_votes.yml deleted file mode 100644 index 2fb2b79e..00000000 --- a/models/gold/protocols/velodrome/velodrome__ez_votes.yml +++ /dev/null @@ -1,64 +0,0 @@ -version: 2 -models: - - name: velodrome__ez_votes - description: 'This table contains details on LP voting events by VELO lockers on Velodrome.' - - columns: - - name: BLOCK_NUMBER - description: '{{ doc("opt_block_number") }}' - - name: BLOCK_TIMESTAMP - description: '{{ doc("opt_block_timestamp") }}' - - name: TX_HASH - description: '{{ doc("opt_tx_hash") }}' - - name: ORIGIN_FUNCTION_SIGNATURE - description: '{{ doc("opt_origin_sig") }}' - - name: ORIGIN_FROM_ADDRESS - description: '{{ doc("opt_origin_from") }}' - - name: ORIGIN_TO_ADDRESS - description: '{{ doc("opt_origin_to") }}' - - name: GAUGE_ADDRESS - description: 'The address of the gauge in this vote or unvote. Gauges are used for voting on pools in a given epoch.' - tests: - - not_null - - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ - - name: EXTERNAL_BRIBE_ADDRESS - description: 'The external bribe address for the gauge used in the event. External bribes can come from anyone and are distributed to voters on that pool.' - tests: - - not_null - - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ - - name: INTERNAL_BRIBE_ADDRESS - description: 'The internal bribe address for the gauge used in the event.' - tests: - - not_null - - dbt_expectations.expect_column_values_to_match_regex: - regex: 0[xX][0-9a-fA-F]+ - - name: POOL_ADDRESS - description: 'The pool address of the vote or unvote event.' - - name: POOL_NAME - description: 'The pool name of the vote or unvote event.' - tests: - - not_null: - config: - severity: error - error_if: ">100" - warn_if: ">50" - - dbt_expectations.expect_column_values_to_be_in_type_list: - column_type_list: - - STRING - - VARCHAR - - name: FROM_ADDRESS - description: 'The address voting or unvoting.' - - name: TOKEN_ID - description: 'The token ID associated with the vote or unvote event' - - name: VOTE_AMOUNT - description: 'The amount of tokens voted.' - - name: VOTE_ACTION - description: 'The type of action, either vote or unvote.' - - name: EZ_VOTES_ID - description: '{{ doc("pk") }}' - - name: INSERTED_TIMESTAMP - description: '{{ doc("inserted_timestamp") }}' - - name: MODIFIED_TIMESTAMP - description: '{{ doc("modified_timestamp") }}' \ No newline at end of file