├── data ├── .gitkeep └── silver_algorand__transaction_types.csv ├── analysis └── .gitkeep ├── macros ├── .gitkeep ├── grant_select_on_schema.sql ├── safe_math.sql ├── create_udfs.sql ├── labels_join.sql ├── grant_select_on_schemas.sql ├── algorand │ ├── all_udfs.sql │ └── sp_bulk_get_contract_info.sql ├── custom_naming_macros.sql ├── terra │ ├── all_udfs.sql │ └── sp_bulk_get_contract_info.sql ├── decimal_adjust.sql ├── tests │ └── all_ids_exist.sql ├── uniswap_math.sql ├── safe_balances.sql └── custom_query_tag.sql ├── snapshots └── .gitkeep ├── tests ├── .gitkeep ├── terra │ ├── terra__daily_balances__date-assert_no_gap.sql │ ├── terra__reward__currency-null_threshold.sql │ ├── terra__swaps__block_timestamp-assert_no_gap.sql │ ├── anchor │ │ ├── anchor__repay__borrower-null_threshold.sql │ │ ├── anchor__bonds__block_timestamp-assert_no_gap.sql │ │ ├── anchor__burns__block_timestamp-assert_no_gap.sql │ │ ├── anchor__repay__block_timestamp-assert_no_gap.sql │ │ ├── anchor__borrows__block_timestamp-assert_no_gap.sql │ │ ├── anchor__deposits__block_timestamp-assert_no_gap.sql │ │ ├── anchor__redeem__block_timestamp-assert_no_gap.sql │ │ ├── anchor__collateral__block_timestamp-assert_no_gap.sql │ │ ├── anchor__gov_staking__block_timestamp-assert_no_gap.sql │ │ └── anchor__reward_claims__block_timestamp-assert_no_gap.sql │ ├── terra__reward__block_timestamp-assert_no_gap.sql │ ├── terra__reward__price_usd-null_threshold.sql │ ├── terra__staking__block_timestamp-assert_no_gap.sql │ ├── terra__staking__currency-null_threshold.sql │ ├── terra__staking__price_usd-null_threshold.sql │ ├── terra__swaps__price0_usd-null_threshold.sql │ ├── terra__swaps__ask_currency-null_threshold.sql │ ├── terra__swaps__offer_currency-null_threshold.sql │ ├── terra__swaps__token_0_amount-null_threshold.sql │ ├── terra__transfers__block_timestamp-assert_no_gap.sql │ ├── terra__gov_vote__voting_power-null_threshold.sql │ ├── terra__swaps__offer_amount_usd-null_threshold.sql │ ├── terra__swaps__swap_fee_amount-null_threshold.sql │ ├── terra__swaps__token_0_currency-null_threshold.sql │ ├── silver │ │ ├── silver_terra__daily_balances__date-assert_no_gap.sql │ │ ├── silver_terra__transactions__block_timestamp-assert_no_gap.sql │ │ ├── silver_terra__block_synthetic_balances__date-assert_no_gap.sql │ │ ├── silver_terra__transfer_events__block_timestamp-assert_no_gap.sql │ │ ├── silver_terra__msgs__msg__index-assert_no_gap.sql │ │ ├── silver_terra__astroport_pool_reserves__block_id-assert_no_gap.sql │ │ ├── silver_terra__terraswap_pool_reserves__block_id-assert_no_gap.sql │ │ ├── silver_terra__transitions__index-assert_no_gap.sql │ │ ├── silver_terra__blocks__block_id-assert_no_gap.sql │ │ ├── silver_terra__tax_rate__block_number-assert_no_gap.sql │ │ └── silver_terra__msg_events__event_index-assert_no_gap.sql │ ├── swaps │ │ ├── terraswap__lp_stake__block_timestamp-assert_no_gap.sql │ │ └── terraswap__pool_reserves__block_timestamp-assert_no_gap.sql │ ├── terra__airdrop_claims__block_timestamp-assert_no_gap.sql │ ├── terra__oracle_prices__block_timestamp-assert_no_gap.sql │ ├── terra__reward__event_amount_usd-null_threshold.sql │ ├── terra__staking__event_amount_usd-null_threshold.sql │ ├── terra__swaps__swap_fee_amount_usd-null_threshold.sql │ ├── terra__swaps__swap_fee_currency-null_threshold.sql │ ├── terra__swaps__token_0_amount_usd-null_threshold.sql │ ├── terra__transfer_events__block_timestamp-assert_no_gap.sql │ ├── mirror │ │ ├── mirror__gov_staking__block_timestamp-assert_no_gap.sql │ │ ├── mirror__reward_claims__block_timestamp-assert_no_gap.sql │ │ └── mirror__gov_submit_proposal__poll_id-assert_no_gap.sql │ ├── terra__msgs__msg__index-assert_no_gap.sql │ ├── terra__validator_voting_power__block_timestamp-assert_no_gap.sql │ ├── terra__transitions__index-assert_no_gap.sql │ ├── terra__blocks__block_id-assert_no_gap.sql │ ├── terra__tax_rate__block_number-assert_no_gap.sql │ ├── terra__msg_events__event_index-assert_no_gap.sql │ ├── terra__msgs__block_id-assert_no_gap.sql │ ├── terra__transactions__block_id-assert_no_gap.sql │ ├── terra__msg_events__block_id-assert_no_gap.sql │ └── terra__event_actions__block_id-assert_no_gap.sql ├── uniswap │ ├── gold │ │ ├── uniswapv3__swaps-assert_no_gap.sql │ │ ├── uniswapv3__lp_actions-assert_no_gap.sql │ │ ├── uniswapv3__pool_stats-assert_no_gap.sql │ │ ├── uniswapv3__positions-assert_no_gap.sql │ │ └── uniswapv3__position_collected_fees.sql │ └── silver │ │ ├── silver_uniswapv3__swaps-assert_no_gap.sql │ │ ├── silver_uniswapv3__pool_stats-assert_no_gap.sql │ │ ├── silver_uniswapv3__positions-assert_no_gap.sql │ │ └── silver_uniswapv3__liquidity_actions-assert_no_gap.sql ├── consoles │ └── terra │ │ ├── consoles_terra__vesting-date-assert_no_gap.sql │ │ ├── consoles_terra__velocity-date-assert_no_gap.sql │ │ ├── consoles_terra__staked_unstaked-date-assert_no_gap.sql │ │ ├── consoles_terra__tax_rate_METRIC_DATE-assert_no_gaps.sql │ │ ├── consoles_terra__anchor_history_date-assert_no_gap.sql │ │ ├── consoles_terra__daily_rewards_USD-date-assert_no_gaps.sql │ │ ├── consoles_terra__dapp_flows-metric_date-assert_no_gap.sql │ │ ├── consoles_terra__fees_UST_block_date-assert_no_gap.sql │ │ ├── consoles_terra__krt_peg_variance-date-assert_no_gap.sql │ │ ├── consoles_terra__total_transactions_day-assert_no_gap.sql │ │ ├── consoles_terra__anchor_daily_inflow-assert_no_gap.sql │ │ ├── consoles_terra__anchor_total_users-assert_no_gap.sql │ │ ├── consoles_terra__fees_generated_BLOCK_DATE-assert_no_gaps.sql │ │ ├── consoles_terra__mirror_daily_inflow-assert_no_gap.sql │ │ ├── consoles_terra__mirror_total_users-assert_no_gap.sql │ │ ├── consoles_terra__operator_flows__metric_date-assert_no_gap.sql │ │ ├── consoles_terra__swap_spread__metric_date-assert_no_gap.sql │ │ ├── consoles_terra__terraswap_daily_vol-assert_no_gap.sql │ │ ├── consoles_terra__terraswap_volume_dayzz-assert_no_gap.sql │ │ ├── consoles_terra__token_cash_flow-date-assert_no_gap.sql │ │ ├── consoles_terra__circulating_supply-date-assert_no_gap.sql │ │ ├── consoles_terra__exchange_flows-metric_date-assert_no_gap.sql │ │ ├── consoles_terra__exchange_flows__metric_date-assert_no_gap.sql │ │ ├── consoles_terra__token_breakdown__metric_date-assert_no_gap.sql │ │ ├── consoles_terra__addresses_staking_LUNA-date-assert_no_gap.sql │ │ ├── consoles_terra__daily_swap_new_users_block_day-assert_no_gap.sql │ │ ├── consoles_terra__luna_staked_supply_usd_date-assert_no_gap.sql │ │ ├── consoles_terra__top_holder_flows__metric_date-assert_no_gap.sql │ │ ├── consoles_terra__daily_total_fees_USD_block_date-assert_no_gap.sql │ │ ├── consoles_terra__ust_peg_variance_date-assert_no_gap.sql │ │ ├── consoles_terra__usd_rewards_distribution_day-assert_no_gap.sql │ │ ├── consoles_terra__transactions_per_token_metric_date-assert_no_gap.sql │ │ └── consoles_terra__fees_by_stablecoin_by_day_in_UST_BLOCK_DATE-assert_no_gaps.sql ├── thorchain │ ├── thorchain__prices__block_id-assert_no_gaps.sql │ ├── thorchain__block_pool_depths__block_id-assert_no_gaps.sql │ ├── thorchain__pool_block_balances__block_id-assert_no_gaps.sql │ ├── thorchain__swaps_assert_all_ids_exist_swap_events.sql │ ├── thorchain__daily_tvl__day-assert_no_gaps.sql │ ├── thorchain__block_rewards__day-assert_no_gap.sql │ ├── thorchain__daily_earnings__day-assert_no_gaps.sql │ ├── thorchain__pool_block_fees__day-assert_no_gap.sql │ ├── thorchain__daily_pool_stats__day-assert_no_gaps.sql │ ├── thorchain__pool_block_statistics__day-assert_no_gap.sql │ ├── thorchain__total_block_rewards__block_id-assert_no_gaps.sql │ └── thorchain__total_value_locked__day-assert_no_gap.sql ├── algorand │ ├── silver_algorand__prices_swap__block_hour_date_gap.sql │ └── silver │ │ ├── silver_algorand__block__block_id-assert_no_gap.sql │ │ └── silver_algorand__transactions__intra-assert_no_gap.sql └── ethereum │ └── ethereum__transactions__tx_position-assert_no_gap.sql ├── models ├── terra │ ├── .DS_Store │ ├── anchor │ │ └── anchor__reward_claims_2.yml │ ├── gold │ │ ├── terra__blocks.sql │ │ ├── terra__transitions.sql │ │ ├── terra__msgs.sql │ │ ├── terra__labels.sql │ │ ├── terra__msg_events.sql │ │ ├── terra__transactions.sql │ │ ├── terra__tax_rate.sql │ │ ├── terra__event_actions.sql │ │ └── terra__tax_rate.yml │ ├── secure_views │ │ ├── terra_sv__blocks.sql │ │ ├── terra_sv__transitions.sql │ │ ├── terra_sv__msgs.sql │ │ ├── terra_sv__labels.sql │ │ ├── terra_sv__msg_events.sql │ │ ├── terra_sv__transactions.sql │ │ └── terra_sv__labels.yml │ ├── silver │ │ ├── silver_terra__undecoded_oracle_contracts.yml │ │ ├── silver_terra__undecoded_wormhole_contracts.yml │ │ ├── silver_terra__dex_contracts.yml │ │ ├── silver_terra__token_contracts.sql │ │ ├── silver_terra__contract_metadata.yml │ │ ├── silver_terra__tax_rate.yml │ │ ├── silver_terra__blocks.sql │ │ └── silver_terra__all_undecoded_contracts.sql │ └── terra_scored │ │ ├── terra_scored__swap_current_prices.yml │ │ └── terra_scored__contract_metadata.yml ├── algorand │ ├── descriptions │ │ ├── address.md │ │ ├── app_id.md │ │ ├── tx_type_name.md │ │ ├── algo_block_id.md │ │ ├── asset_id.md │ │ ├── extra.md │ │ ├── fee.md │ │ ├── tx_type.md │ │ ├── sender.md │ │ ├── tx_message.md │ │ ├── block_timestamp.md │ │ ├── tx_id.md │ │ ├── intra.md │ │ ├── genesis_hash.md │ │ ├── tx_group_id.md │ │ └── inner_tx.md │ ├── gold │ │ ├── algorand__app.sql │ │ ├── algorand__account_app.sql │ │ ├── algorand__prices_pool_balances.sql │ │ ├── algorand__transaction_participation.sql │ │ ├── algorand__block.sql │ │ ├── algorand__account_asset.sql │ │ ├── algorand__account.sql │ │ ├── algorand__nft_asset.sql │ │ ├── algorand__prices_swap.sql │ │ ├── algorand__transactions.sql │ │ ├── algorand__application_call_transaction.sql │ │ ├── algorand__daily_balances.sql │ │ ├── algorand__payment_transaction.sql │ │ ├── algorand__transfers.sql │ │ ├── algorand__asset_freeze_transaction.sql │ │ ├── algorand__asset_configuration_transaction.sql │ │ ├── algorand__asset_transfer_transaction.sql │ │ ├── algorand__key_registration_transaction.sql │ │ └── algorand__labels.sql │ ├── silver │ │ ├── silver_algorand__hourly_pool_balances.yml │ │ ├── silver_algorand__daily_balances.yml │ │ ├── silver_algorand__app.yml │ │ ├── silver_algorand__asset.yml │ │ ├── silver_algorand__indexer_tx.yml │ │ ├── silver_algorand__nft_asset.yml │ │ └── silver_algorand__account_app.yml │ └── api │ │ └── silver_algorand__get_tx.sql ├── thorchain │ ├── .DS_Store │ ├── silver │ │ ├── silver_thorchain__constants.sql │ │ ├── silver_thorchain__rewards_events.yml │ │ ├── silver_thorchain__slash_points.sql │ │ ├── silver_thorchain__slash_amounts.sql │ │ ├── silver_thorchain__active_vault_events.yml │ │ ├── silver_thorchain__thorname_change_events.sql │ │ ├── silver_thorchain__bond_events.yml │ │ ├── silver_thorchain__fee_events.yml │ │ ├── silver_thorchain__transfer_events.yml │ │ ├── silver_thorchain__block_log.sql │ │ ├── silver_thorchain__rewards_event_entries.yml │ │ ├── silver_thorchain__block_pool_depths.sql │ │ ├── silver_thorchain__block_log.yml │ │ ├── silver_thorchain__rewards_events.sql │ │ ├── silver_thorchain__gas_events.sql │ │ ├── silver_thorchain__pool_events.sql │ │ ├── silver_thorchain__errata_events.sql │ │ ├── silver_thorchain__set_mimir_events.sql │ │ ├── silver_thorchain__new_node_events.sql │ │ ├── silver_thorchain__fee_events.sql │ │ ├── silver_thorchain__switch_events.yml │ │ ├── silver_thorchain__inactive_vault_events.sql │ │ ├── silver_thorchain__rewards_event_entries.sql │ │ ├── silver_thorchain__active_vault_events.sql │ │ ├── silver_thorchain__set_version_events.sql │ │ ├── silver_thorchain__add_events.sql │ │ ├── silver_thorchain__set_ip_address_events.sql │ │ ├── silver_thorchain__switch_events.sql │ │ ├── silver_thorchain__transfer_events.sql │ │ ├── silver_thorchain__bond_events.sql │ │ ├── silver_thorchain__pool_balance_change_events.sql │ │ ├── silver_thorchain__reserve_events.sql │ │ ├── silver_thorchain__outbound_events.sql │ │ ├── silver_thorchain__refund_events.sql │ │ ├── silver_thorchain__set_node_keys_events.sql │ │ ├── silver_thorchain__stake_events.sql │ │ ├── silver_thorchain__swap_events.sql │ │ ├── silver_thorchain__asgard_fund_yggdrasil_events.sql │ │ ├── silver_thorchain__validator_request_leave_events.sql │ │ ├── silver_thorchain__update_node_account_status_events.sql │ │ ├── silver_thorchain__unstake_events.sql │ │ ├── silver_thorchain__pending_liquidity_events.sql │ │ ├── silver_thorchain__block_pool_depths.yml │ │ ├── silver_thorchain__pool_balance_change_events.yml │ │ ├── silver_thorchain__errata_events.yml │ │ └── silver_thorchain__gas_events.yml │ ├── gold │ │ ├── thorchain__pool_events.yml │ │ ├── thorchain__slash_amounts.yml │ │ ├── thorchain__new_node_events.yml │ │ ├── thorchain__reserve_events.yml │ │ ├── thorchain__set_mimir_events.yml │ │ ├── thorchain__set_version_events.yml │ │ ├── thorchain__set_node_keys_events.yml │ │ ├── thorchain__inactive_vault_events.yml │ │ ├── thorchain__set_ip_address_events.yml │ │ ├── thorchain__thorname_change_events.yml │ │ ├── thorchain__validator_request_leave_events.yml │ │ ├── thorchain__update_node_account_status_events.yml │ │ ├── thorchain__pool_balance_change_events.yml │ │ ├── thorchain__new_node_events.sql │ │ ├── thorchain__inactive_vault_events.sql │ │ ├── thorchain__asgard_fund_yggdrasil_events.sql │ │ ├── thorchain__errata_events.sql │ │ ├── thorchain__transfer_events.sql │ │ ├── thorchain__rewards_events.sql │ │ ├── thorchain__switch_events.sql │ │ ├── thorchain__set_mimir_events.sql │ │ ├── thorchain__pool_events.sql │ │ ├── thorchain__active_vault_events.sql │ │ ├── thorchain__slash_amounts.sql │ │ ├── thorchain__set_version_events.sql │ │ ├── thorchain__gas_events.sql │ │ ├── thorchain__pool_balance_change_events.sql │ │ ├── thorchain__rewards_event_entries.sql │ │ ├── thorchain__set_ip_address_events.sql │ │ ├── thorchain__thorname_change_events.sql │ │ ├── thorchain__fee_events.sql │ │ ├── thorchain__outbound_events.sql │ │ ├── thorchain__switch_events.yml │ │ ├── thorchain__set_node_keys_events.sql │ │ └── thorchain__slash_points.sql │ └── dbt │ │ ├── thorchain_dbt__add_events.sql │ │ ├── thorchain_dbt__block_log.sql │ │ ├── thorchain_dbt__constants.sql │ │ ├── thorchain_dbt__fee_events.sql │ │ ├── thorchain_dbt__gas_events.sql │ │ ├── thorchain_dbt__pool_events.sql │ │ ├── thorchain_dbt__stake_events.sql │ │ ├── thorchain_dbt__swap_events.sql │ │ ├── thorchain_dbt__errata_events.sql │ │ ├── thorchain_dbt__refund_events.sql │ │ ├── thorchain_dbt__slash_amounts.sql │ │ ├── thorchain_dbt__new_node_events.sql │ │ ├── thorchain_dbt__outbound_events.sql │ │ ├── thorchain_dbt__reserve_events.sql │ │ ├── thorchain_dbt__rewards_events.sql │ │ ├── thorchain_dbt__slash_points.sql │ │ ├── thorchain_dbt__transfer_events.sql │ │ ├── thorchain_dbt__unstake_events.sql │ │ ├── thorchain_dbt__block_pool_depths.sql │ │ ├── thorchain_dbt__set_mimir_events.sql │ │ ├── thorchain_dbt__set_version_events.sql │ │ ├── thorchain_dbt__active_vault_events.sql │ │ ├── thorchain_dbt__inactive_vault_events.sql │ │ ├── thorchain_dbt__rewards_event_entries.sql │ │ ├── thorchain_dbt__set_ip_address_events.sql │ │ ├── thorchain_dbt__thorname_change_events.sql │ │ ├── thorchain_dbt__set_node_keys_events.sql │ │ ├── thorchain_dbt__pending_liquidity_events.sql │ │ ├── thorchain_dbt__pool_balance_change_events.sql │ │ ├── thorchain_dbt__asgard_fund_yggdrasil_events.sql │ │ └── thorchain_dbt__validator_request_leave_events.sql ├── ethereum │ ├── aave │ │ ├── .DS_Store │ │ ├── Aave data audit and db structure.txt │ │ └── silver__aave_liquidity_mining.yml │ ├── ethereum__contracts.sql │ ├── ethereum__contracts.yml │ ├── silver │ │ ├── silver_ethereum__contracts.yml │ │ ├── silver_ethereum__prices.yml │ │ ├── silver_ethereum__balances.yml │ │ └── silver_ethereum__events.yml │ ├── ethereum__reads.sql │ ├── ethereum__labels.sql │ ├── nft │ │ └── ethereum__nft_events.yml │ ├── ethereum__token_prices_hourly.yml │ └── ethereum__reads.yml ├── solana │ ├── descriptions │ │ ├── mint.md │ │ ├── tx_id.md │ │ ├── amount.md │ │ ├── block_id.md │ │ ├── tx_from.md │ │ ├── purchaser.md │ │ ├── tx_to.md │ │ ├── ingested_at.md │ │ ├── sales_amount.md │ │ ├── block_timestamp.md │ │ ├── index.md │ │ ├── tx_succeeded.md │ │ ├── event_type.md │ │ ├── inner_instruction.md │ │ ├── program_id.md │ │ └── instruction.md │ ├── gold │ │ ├── solana__dim_labels.sql │ │ ├── solana__fact_blocks.sql │ │ ├── solana__fact_events.sql │ │ ├── solana__fact_nft_mints.sql │ │ ├── solana__fact_swaps.sql │ │ ├── solana__fact_gov_actions.sql │ │ ├── solana__dim_nft_metadata.sql │ │ ├── solana__fact_gauges_votes.sql │ │ ├── solana__fact_nft_sales.sql │ │ ├── solana__fact_proposal_votes.sql │ │ ├── solana__fact_transfers.sql │ │ ├── solana__fact_transactions.sql │ │ ├── solana__fact_votes_agg_block.sql │ │ ├── solana__fact_staking_lp_actions.sql │ │ └── solana__fact_votes_agg_block.yml │ └── bronze │ │ ├── bronze_solana__transactions.sql │ │ └── bronze_solana__blocks.sql ├── crosschain │ ├── docs │ │ ├── Event_index.md │ │ ├── Block_timestamp_UTC.md │ │ ├── Swap_symbol_in.md │ │ ├── Swap_token_in.md │ │ ├── Swap_Amount_in.md │ │ ├── Swap_symbol_out.md │ │ ├── Swap_token_out.md │ │ ├── lending │ │ │ ├── lending_pool.md │ │ │ ├── pool_address.md │ │ │ ├── amount.md │ │ │ ├── symbol.md │ │ │ ├── amount_usd.md │ │ │ ├── depositor.md │ │ │ ├── origin_from_address.md │ │ │ ├── lender_is_a_contract.md │ │ │ ├── action.md │ │ │ └── origin_to_address.md │ │ ├── Pool_address.md │ │ ├── Block_number.md │ │ ├── Swap_Amount_out.md │ │ ├── Borrowing │ │ │ ├── Borrow_symbol.md │ │ │ ├── Borrower.md │ │ │ ├── asset.md │ │ │ ├── action.md │ │ │ ├── borrower_is_a_contract.md │ │ │ ├── amount.md │ │ │ └── amount_usd.md │ │ ├── Swap_platform.md │ │ ├── Swap_amount_in_USD.md │ │ ├── TX_Hash.md │ │ ├── Swap_tx_to.md │ │ ├── Swap_sender.md │ │ ├── Swap_amount_out_USD.md │ │ ├── origin_to_address.md │ │ ├── origin_from_address.md │ │ └── Event_Log_id.md │ ├── crosschain__address_tags.sql │ ├── crosschain__nft_fair_market_value.sql │ └── crosschain__address_labels.sql ├── gold │ ├── gold__flow_transactions.yml │ ├── gold__near_delegator_counts.yml │ ├── gold__near_block_rewards.yml │ ├── gold__near_reward_flow.yml │ ├── gold__near_daily_balances.yml │ ├── gold__near_validators.yml │ ├── gold__flow_labels.sql │ ├── gold__flow_daily_balances_dedupped.yml │ ├── gold__flow_delegator_addresses.yml │ ├── gold__near_events.yml │ └── gold__flow_daily_balances.yml ├── uniswapv3 │ └── eth_mainnet │ │ ├── uniswapv3_dbt__pools.yml │ │ ├── uniswapv3_dbt__swaps.yml │ │ ├── uniswapv3_dbt__positions.yml │ │ ├── uniswapv3_dbt__pool_stats.yml │ │ ├── uniswapv3_dbt__liquidity_actions.yml │ │ ├── uniswapv3__pools.sql │ │ ├── uniswapv3__swaps.sql │ │ ├── uniswapv3__positions.sql │ │ ├── uniswapv3__pool_stats.sql │ │ ├── uniswapv3__lp_actions.sql │ │ └── uniswapv3__position_collected_fees.sql ├── ethereum_core │ ├── core │ │ ├── ethereum_core__dim_dates.sql │ │ ├── ethereum_core__dim_labels.sql │ │ ├── ethereum_core__dim_contracts.sql │ │ ├── ethereum_core__ez_dex_swaps.sql │ │ ├── ethereum_core__ez_nft_mints.sql │ │ ├── ethereum_core__ez_nft_sales.sql │ │ ├── ethereum_core__fact_blocks.sql │ │ ├── ethereum_core__fact_traces.sql │ │ ├── ethereum_core__fact_event_logs.sql │ │ ├── ethereum_core__ez_nft_transfers.sql │ │ ├── ethereum_core__ez_token_transfers.sql │ │ ├── ethereum_core__fact_transactions.sql │ │ ├── ethereum_core__fact_token_transfers.sql │ │ ├── ethereum_core__dim_dex_liquidity_pools.sql │ │ └── ethereum_core__fact_hourly_token_prices.sql │ └── sushi │ │ ├── ethereum_sushi__ez_swaps.sql │ │ └── ethereum_sushi__dim_distributor_reward_schedule.sql ├── consoles │ └── terra │ │ ├── consoles_terra__total_transactions.sql │ │ ├── consoles_terra__luna_staked_supply_usd.sql │ │ ├── consoles_terra__total_users.sql │ │ ├── consoles_terra__daily_swap_new_users.sql │ │ ├── consoles_terra__circulating_supply.sql │ │ ├── consoles_terra__ust_peg_variance.sql │ │ ├── consoles_terra__transactions_per_token.sql │ │ ├── consoles_terra__top_10_validators_by_rewards.yml │ │ ├── consoles_terra__staked_unstaked.sql │ │ └── consoles_terra__addresses_staking_LUNA.sql ├── polygon │ └── polygon__labels.sql └── flow │ └── silver │ ├── silver_flow__daily_staked_balances.yml │ └── silver_flow__daily_balances.yml ├── python_analysis └── environment.yml ├── packages.yml ├── .gitignore └── .github └── ISSUE_TEMPLATE └── add-a-new-table-or-view.md /data/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /analysis/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /macros/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /snapshots/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /models/terra/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlipsideCrypto/sql_models/HEAD/models/terra/.DS_Store -------------------------------------------------------------------------------- /models/algorand/descriptions/address.md: -------------------------------------------------------------------------------- 1 | {% docs address %} 2 | 3 | The account public key 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/algorand/descriptions/app_id.md: -------------------------------------------------------------------------------- 1 | {% docs app_id %} 2 | 3 | ID of the application 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/thorchain/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlipsideCrypto/sql_models/HEAD/models/thorchain/.DS_Store -------------------------------------------------------------------------------- /tests/terra/terra__daily_balances__date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("terra__daily_balances"), [], "date") }} -------------------------------------------------------------------------------- /tests/terra/terra__reward__currency-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__reward'), "currency", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__swaps__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("terra__swaps"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /models/algorand/descriptions/tx_type_name.md: -------------------------------------------------------------------------------- 1 | {% docs tx_type_name %} 2 | 3 | Transaction type name 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/ethereum/aave/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FlipsideCrypto/sql_models/HEAD/models/ethereum/aave/.DS_Store -------------------------------------------------------------------------------- /tests/terra/anchor/anchor__repay__borrower-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('anchor__repay'), "borrower", 0.9) }} -------------------------------------------------------------------------------- /tests/terra/terra__reward__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("terra__reward"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/terra__reward__price_usd-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__reward'), "price_usd", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__staking__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("terra__staking"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/terra__staking__currency-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__staking'), "currency", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__staking__price_usd-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__staking'), "price_usd", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__swaps__price0_usd-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__swaps'), "price0_usd", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/uniswap/gold/uniswapv3__swaps-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("uniswapv3__swaps"), [], "block_timestamp" )}} 2 | -------------------------------------------------------------------------------- /models/algorand/descriptions/algo_block_id.md: -------------------------------------------------------------------------------- 1 | {% docs algo_block_id %} 2 | 3 | ID of the confirmed block 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/algorand/descriptions/asset_id.md: -------------------------------------------------------------------------------- 1 | {% docs algo_asset_id%} 2 | 3 | ID associated with the asset 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/algorand/descriptions/extra.md: -------------------------------------------------------------------------------- 1 | {% docs extra %} 2 | 3 | Extra json associated with transaction 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/algorand/descriptions/fee.md: -------------------------------------------------------------------------------- 1 | {% docs fee %} 2 | 3 | Fee associated with the transaction, in ALGOs 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/terra/anchor/anchor__bonds__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("anchor__bonds"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/anchor/anchor__burns__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("anchor__burns"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/anchor/anchor__repay__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("anchor__repay"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/terra__swaps__ask_currency-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__swaps'), "ask_currency", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__swaps__offer_currency-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__swaps'), "offer_currency", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__swaps__token_0_amount-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__swaps'), "token_0_amount", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__transfers__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("terra__transfers"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /models/solana/descriptions/mint.md: -------------------------------------------------------------------------------- 1 | {% docs solana_mint %} 2 | 3 | Unique address representing a specific token 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/descriptions/tx_id.md: -------------------------------------------------------------------------------- 1 | {% docs solana_tx_id %} 2 | 3 | A unique key that identifies a transaction 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/terra/anchor/anchor__reward_claims_2.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: anchor__reward_claims_2 4 | enabled: False -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__vesting-date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__vesting"), [], "METRIC_DATE") }} -------------------------------------------------------------------------------- /tests/terra/anchor/anchor__borrows__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("anchor__borrows"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/anchor/anchor__deposits__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("anchor__deposits"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/anchor/anchor__redeem__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("anchor__redeem"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/terra__gov_vote__voting_power-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__gov_vote'), "voting_power", 0.25) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__swaps__offer_amount_usd-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__swaps'), "offer_amount_usd", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__swaps__swap_fee_amount-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__swaps'), "swap_fee_amount", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__swaps__token_0_currency-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__swaps'), "token_0_currency", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/thorchain/thorchain__prices__block_id-assert_no_gaps.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_distinct_gaps(ref("thorchain__prices"), "block_id") }} 2 | -------------------------------------------------------------------------------- /tests/uniswap/gold/uniswapv3__lp_actions-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("uniswapv3__lp_actions"), [], "block_timestamp" )}} 2 | -------------------------------------------------------------------------------- /tests/uniswap/gold/uniswapv3__pool_stats-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("uniswapv3__pool_stats"), [], "block_timestamp" )}} 2 | -------------------------------------------------------------------------------- /tests/uniswap/gold/uniswapv3__positions-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("uniswapv3__positions"), [], "block_timestamp" )}} 2 | -------------------------------------------------------------------------------- /macros/grant_select_on_schema.sql: -------------------------------------------------------------------------------- 1 | {% macro grant_select_on_schema( 2 | schema, 3 | role 4 | ) %}{% endmacro %} 5 | -------------------------------------------------------------------------------- /models/algorand/descriptions/tx_type.md: -------------------------------------------------------------------------------- 1 | {% docs tx_type %} 2 | 3 | Number associated with transaction type 4 | 5 | {% enddocs %} 6 | -------------------------------------------------------------------------------- /models/solana/descriptions/amount.md: -------------------------------------------------------------------------------- 1 | {% docs solana_amount %} 2 | 3 | The number of tokens sent during an event 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/descriptions/block_id.md: -------------------------------------------------------------------------------- 1 | {% docs solana_block_id %} 2 | 3 | Slot for which a block can be created. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/descriptions/tx_from.md: -------------------------------------------------------------------------------- 1 | {% docs solana_tx_from %} 2 | 3 | The wallet address that initiated an event 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__velocity-date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__velocity"), [], "METRIC_DATE") }} -------------------------------------------------------------------------------- /tests/terra/anchor/anchor__collateral__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("anchor__collateral"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/silver/silver_terra__daily_balances__date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("silver_terra__daily_balances"), [], "date") }} -------------------------------------------------------------------------------- /tests/terra/swaps/terraswap__lp_stake__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("terraswap__lp_stake"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/terra__airdrop_claims__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("terra__airdrop_claims"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/terra__oracle_prices__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("terra__oracle_prices"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/terra__reward__event_amount_usd-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__reward'), "event_amount_usd", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__staking__event_amount_usd-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__staking'), "event_amount_usd", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__swaps__swap_fee_amount_usd-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__swaps'), "swap_fee_amount_usd", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__swaps__swap_fee_currency-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__swaps'), "swap_fee_currency", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__swaps__token_0_amount_usd-null_threshold.sql: -------------------------------------------------------------------------------- 1 | {{ null_threshold(ref('terra__swaps'), "token_0_amount_usd", 0.9) }} 2 | -------------------------------------------------------------------------------- /tests/terra/terra__transfer_events__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("terra__transfer_events"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/uniswap/silver/silver_uniswapv3__swaps-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("silver_uniswapv3__swaps"), [], "block_timestamp" )}} 2 | -------------------------------------------------------------------------------- /models/solana/descriptions/purchaser.md: -------------------------------------------------------------------------------- 1 | {% docs solana_purchaser %} 2 | 3 | The wallet address that purchased the NFT 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/descriptions/tx_to.md: -------------------------------------------------------------------------------- 1 | {% docs solana_tx_to %} 2 | 3 | The wallet address that receives tokens in an event 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__staked_unstaked-date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__staked_unstaked"), [], "DAYZZ") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__tax_rate_METRIC_DATE-assert_no_gaps.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__tax_rate"), [], "METRIC_DATE") }} -------------------------------------------------------------------------------- /tests/terra/anchor/anchor__gov_staking__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("anchor__gov_staking"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/anchor/anchor__reward_claims__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("anchor__reward_claims"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/mirror/mirror__gov_staking__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("mirror__gov_staking"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/mirror/mirror__reward_claims__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("mirror__reward_claims"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/uniswap/gold/uniswapv3__position_collected_fees.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("uniswapv3__position_collected_fees"), [], "block_timestamp" )}} 2 | -------------------------------------------------------------------------------- /models/algorand/descriptions/sender.md: -------------------------------------------------------------------------------- 1 | {% docs sender %} 2 | 3 | Address of the wallet creating the transaction 4 | 5 | {% enddocs %} 6 | 7 | -------------------------------------------------------------------------------- /models/algorand/descriptions/tx_message.md: -------------------------------------------------------------------------------- 1 | {% docs tx_message %} 2 | 3 | Encoded JSON message associated with the transaction 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/descriptions/ingested_at.md: -------------------------------------------------------------------------------- 1 | {% docs solana_ingested_at %} 2 | 3 | Time the record was ingested by the source 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__anchor_history_date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__anchor_history"), [], "date") }} 2 | -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__daily_rewards_USD-date-assert_no_gaps.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__daily_rewards_USD"), [], "day") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__dapp_flows-metric_date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__dapp_flows"), [], "metric_date") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__fees_UST_block_date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__fees_UST"), [], "block_date") }} 2 | -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__krt_peg_variance-date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__krt_peg_variance"), [], "date") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__total_transactions_day-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__total_transactions"), [], "day") }} -------------------------------------------------------------------------------- /tests/terra/mirror/mirror__gov_submit_proposal__poll_id-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps(ref("mirror__gov_submit_proposal"), [], "poll_id") }} 2 | -------------------------------------------------------------------------------- /tests/terra/swaps/terraswap__pool_reserves__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("terraswap__pool_reserves"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/terra__msgs__msg__index-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps(ref("terra__msgs"), ["chain_id", "block_id", "tx_id"], "msg_index") }} 2 | -------------------------------------------------------------------------------- /tests/uniswap/silver/silver_uniswapv3__pool_stats-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("silver_uniswapv3__pool_stats"), [], "block_timestamp" )}} 2 | -------------------------------------------------------------------------------- /tests/uniswap/silver/silver_uniswapv3__positions-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("silver_uniswapv3__positions"), [], "block_timestamp" )}} 2 | -------------------------------------------------------------------------------- /models/algorand/descriptions/block_timestamp.md: -------------------------------------------------------------------------------- 1 | {% docs block_timestamp %} 2 | 3 | Timestamp of block minting(without a timezone) 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/algorand/descriptions/tx_id.md: -------------------------------------------------------------------------------- 1 | {% docs tx_id %} 2 | 3 | An identifier tied to a transaction and its inner transactions 4 | 5 | {% enddocs %} 6 | -------------------------------------------------------------------------------- /models/crosschain/docs/Event_index.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_event_index %} 2 | 3 | [BETA TABLE] - Event number within a transaction. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/descriptions/sales_amount.md: -------------------------------------------------------------------------------- 1 | {% docs solana_sales_amount %} 2 | 3 | The amount of Solana the NFT was purchased for 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/algorand/silver_algorand__prices_swap__block_hour_date_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref('silver_algorand__prices_swap'), ["asset_id"], "block_hour") }} 2 | -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__anchor_daily_inflow-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__anchor_daily_inflow"), [], "join_date") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__anchor_total_users-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__anchor_total_users"), [], "block_date") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__fees_generated_BLOCK_DATE-assert_no_gaps.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__fees_generated"), [], "BLOCK_DATE") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__mirror_daily_inflow-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__mirror_daily_inflow"), [], "join_date") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__mirror_total_users-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__mirror_total_users"), [], "block_date") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__operator_flows__metric_date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__dapp_flows"), [], "metric_date") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__swap_spread__metric_date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__swap_spread"), [], "metric_date") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__terraswap_daily_vol-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__terraswap_daily_vol"), [], "block_date") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__terraswap_volume_dayzz-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__terraswap_volume"), [], "dayzz") }} 2 | -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__token_cash_flow-date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__token_cash_flow"), [], "METRIC_DATE") }} -------------------------------------------------------------------------------- /tests/terra/silver/silver_terra__transactions__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("silver_terra__transactions"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/terra__validator_voting_power__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref('terra__validator_voting_power'), [], "block_timestamp") }} -------------------------------------------------------------------------------- /models/solana/descriptions/block_timestamp.md: -------------------------------------------------------------------------------- 1 | {% docs solana_block_timestamp %} 2 | 3 | The date and time at which the block began. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__circulating_supply-date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__circulating_supply"), [], "metric_date") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__exchange_flows-metric_date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__exchange_flows"), [], "metric_date") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__exchange_flows__metric_date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__exchange_flows"), [], "metric_date") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__token_breakdown__metric_date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__token_breakdown"), [], "metric_date") }} -------------------------------------------------------------------------------- /tests/ethereum/ethereum__transactions__tx_position-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps(ref("ethereum__transactions"), ["block_id", "tx_id"], "tx_position") }} -------------------------------------------------------------------------------- /tests/terra/silver/silver_terra__block_synthetic_balances__date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("silver_terra__block_synthetic_balances"), [], "date") }} -------------------------------------------------------------------------------- /tests/thorchain/thorchain__block_pool_depths__block_id-assert_no_gaps.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_distinct_gaps(ref("thorchain__block_pool_depths"), "block_id") }} 2 | -------------------------------------------------------------------------------- /models/algorand/descriptions/intra.md: -------------------------------------------------------------------------------- 1 | {% docs intra %} 2 | 3 | Transaction # into the block where this transaction was confirmed 4 | 5 | {% enddocs %} 6 | 7 | -------------------------------------------------------------------------------- /models/crosschain/docs/Block_timestamp_UTC.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_block_timestamp %} 2 | 3 | The block timestamp of this transaction in UTC 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/Swap_symbol_in.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_swap_symbol_in %} 2 | 3 | [BETA TABLE] - The symbol of the token sent for swap. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/Swap_token_in.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_swap_token_in %} 2 | 3 | [BETA TABLE] - The address of the token sent for swap. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/descriptions/index.md: -------------------------------------------------------------------------------- 1 | {% docs solana_index %} 2 | 3 | A unique key that identifies the event's position within a transaction 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/descriptions/tx_succeeded.md: -------------------------------------------------------------------------------- 1 | {% docs solana_tx_succeeded %} 2 | 3 | True when a transaction is successful, otherwise false. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__addresses_staking_LUNA-date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__addresses_staking_LUNA"), [], "date") }} 2 | -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__daily_swap_new_users_block_day-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__daily_swap_new_users"), [], "block_day") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__luna_staked_supply_usd_date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__luna_staked_supply_usd"), [], "date") }} 2 | -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__top_holder_flows__metric_date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__top_holder_flows"), [], "metric_date") }} -------------------------------------------------------------------------------- /tests/terra/silver/silver_terra__transfer_events__block_timestamp-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("silver_terra__transfer_events"), [], "block_timestamp") }} -------------------------------------------------------------------------------- /tests/terra/terra__transitions__index-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps(ref('terra__transitions'), ["chain_id", "block_id", "transition_type",], "INDEX") }} 2 | -------------------------------------------------------------------------------- /tests/thorchain/thorchain__pool_block_balances__block_id-assert_no_gaps.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_distinct_gaps(ref("thorchain__pool_block_balances"), "block_id") }} 2 | -------------------------------------------------------------------------------- /tests/thorchain/thorchain__swaps_assert_all_ids_exist_swap_events.sql: -------------------------------------------------------------------------------- 1 | {{ all_ids_exist(ref("thorchain__swap_events"), "tx_id", ref("thorchain__swaps"), "tx_id") }} -------------------------------------------------------------------------------- /tests/uniswap/silver/silver_uniswapv3__liquidity_actions-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("silver_uniswapv3__liquidity_actions"), [], "block_timestamp" )}} 2 | -------------------------------------------------------------------------------- /models/crosschain/docs/Swap_Amount_in.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_swap_amount_in %} 2 | 3 | [BETA TABLE] - The amount of tokens put into the swap. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/Swap_symbol_out.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_swap_symbol_out %} 2 | 3 | [BETA TABLE] - The symbol of the token being swapped to. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/Swap_token_out.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_swap_token_out %} 2 | 3 | [BETA TABLE] - The address of the token being swapped to. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/lending/lending_pool.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_lending_lending_pool %} 2 | 3 | [BETA TABLE] - The name of the lending pool. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/descriptions/event_type.md: -------------------------------------------------------------------------------- 1 | {% docs solana_event_type %} 2 | 3 | The type of event (i.e. "delegate", "withdraw") that is occurring 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/descriptions/inner_instruction.md: -------------------------------------------------------------------------------- 1 | {% docs solana_inner_instruction %} 2 | 3 | A call from one smart contract program to another 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__daily_total_fees_USD_block_date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__daily_total_fees_USD"), [], "block_date") }} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__ust_peg_variance_date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__ust_peg_variance"), ["currency"], "METRIC_DATE") }} 2 | -------------------------------------------------------------------------------- /tests/terra/silver/silver_terra__msgs__msg__index-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps(ref("silver_terra__msgs"), ["chain_id", "block_id", "tx_id"], "msg_index") }} 2 | -------------------------------------------------------------------------------- /models/crosschain/docs/Pool_address.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_swap_pool_address %} 2 | 3 | [BETA TABLE] - The contract address for the liquidity pool. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__usd_rewards_distribution_day-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__usd_rewards_distribution"), ["type"], "day") }} 2 | -------------------------------------------------------------------------------- /tests/terra/silver/silver_terra__astroport_pool_reserves__block_id-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_distinct_gaps(ref('silver_terra__astroport_pool_reserves'), "block_id") }} -------------------------------------------------------------------------------- /tests/terra/silver/silver_terra__terraswap_pool_reserves__block_id-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_distinct_gaps(ref('silver_terra__terraswap_pool_reserves'), "block_id") }} -------------------------------------------------------------------------------- /tests/terra/terra__blocks__block_id-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps_buffered_look_back(ref('terra__blocks'), ["chain_id"], "block_id", "block_timestamp", "2 HOURS") }} -------------------------------------------------------------------------------- /tests/terra/terra__tax_rate__block_number-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps_buffered_look_back(ref('terra__tax_rate'), [], "block_number", "block_timestamp", "2 HOURS") }} -------------------------------------------------------------------------------- /models/crosschain/docs/Block_number.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_block_number %} 2 | 3 | [BETA TABLE] - The block number at which the transaction is finalized. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__transactions_per_token_metric_date-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__transactions_per_token"), [], "metric_date") }} 2 | -------------------------------------------------------------------------------- /models/algorand/descriptions/genesis_hash.md: -------------------------------------------------------------------------------- 1 | {% docs genesis_hash %} 2 | 3 | The hash of the genesis block of the network for which the transaction is valid 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/lending/pool_address.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_lending_pool_address %} 2 | 3 | [BETA TABLE] - The contract address for the lending pool. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/terra/silver/silver_terra__transitions__index-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps(ref('silver_terra__transitions'), ["chain_id", "block_id", "transition_type",], "INDEX") }} 2 | -------------------------------------------------------------------------------- /models/crosschain/docs/Swap_Amount_out.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_swap_amount_out %} 2 | 3 | [BETA TABLE] - The amount of tokens taken out of or received from the swap. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/lending/amount.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_lending_amount %} 2 | 3 | [BETA TABLE] - The amount of the asset that is being deposited for lending 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/lending/symbol.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_lending_symbol %} 2 | 3 | [BETA TABLE] - The symbol of the asset that is being deposited for lending. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/terra/terra__msg_events__event_index-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps(ref('terra__msg_events'), ["chain_id", "tx_id", "block_id", "event_type", "msg_index"], "event_index") }} 2 | -------------------------------------------------------------------------------- /models/algorand/descriptions/tx_group_id.md: -------------------------------------------------------------------------------- 1 | {% docs tx_group_id%} 2 | 3 | Transaction group ID, can be NULL. Exists when a group of transactions are tied together 4 | 5 | {% enddocs %} 6 | -------------------------------------------------------------------------------- /models/crosschain/docs/Borrowing/Borrow_symbol.md: -------------------------------------------------------------------------------- 1 | {% docs crosschain_borrow_symbol %} 2 | 3 | The symbol of the asset that is repayed or borrowed, depending on the action 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/Swap_platform.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_swap_platform %} 2 | 3 | [BETA TABLE] - This field denotes which application the liquidity pool belongs to. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/consoles/terra/consoles_terra__fees_by_stablecoin_by_day_in_UST_BLOCK_DATE-assert_no_gaps.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("consoles_terra__fees_by_stablecoin_by_day_in_UST"), [], "BLOCK_DATE") }} -------------------------------------------------------------------------------- /models/crosschain/docs/Borrowing/Borrower.md: -------------------------------------------------------------------------------- 1 | {% docs crosschain_borrower %} 2 | 3 | Its the address of the user who is Borrowing or repaying the loan, depending on the action. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/Borrowing/asset.md: -------------------------------------------------------------------------------- 1 | {% docs crosschain_borrow_asset %} 2 | 3 | The address of the asset (token) that is being borrowed/repayed, depending on the action 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/algorand/silver/silver_algorand__block__block_id-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps_buffered_look_back(ref('silver_algorand__block'), [], "block_id", "_inserted_timestamp", "15 HOURS") }} 2 | -------------------------------------------------------------------------------- /models/crosschain/docs/lending/amount_usd.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_lending_amount_usd %} 2 | 3 | [BETA TABLE] - The amount of the asset that is being deposited for lending in USD. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/lending/depositor.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_lending_depositor %} 2 | 3 | [BETA TABLE] - The address of the user or contract that is depositing funds for lending 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/terra/silver/silver_terra__blocks__block_id-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps_buffered_look_back(ref('silver_terra__blocks'), ["chain_id"], "block_id", "_inserted_timestamp", "2 HOURS") }} 2 | -------------------------------------------------------------------------------- /tests/terra/silver/silver_terra__tax_rate__block_number-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps_buffered_look_back(ref('silver_terra__tax_rate'), [], "block_number", "_inserted_timestamp", "2 HOURS") }} 2 | -------------------------------------------------------------------------------- /models/crosschain/docs/lending/origin_from_address.md: -------------------------------------------------------------------------------- 1 | {% docs crosschain_lending_origin_from_address %} 2 | 3 | [BETA TABLE] - The address of the user who initiates the transaction. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/terra/silver/silver_terra__msg_events__event_index-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps(ref('silver_terra__msg_events'), ["chain_id", "tx_id", "block_id", "event_type","msg_index",], "event_index") }} 2 | -------------------------------------------------------------------------------- /macros/safe_math.sql: -------------------------------------------------------------------------------- 1 | {% macro multiply(col_a, col_b) -%} 2 | 3 | CASE WHEN {{col_a}} IS NOT NULL AND {{col_b}} IS NOT NULL 4 | THEN {{col_a}} * {{col_b}} 5 | ELSE NULL 6 | END 7 | 8 | {%- endmacro %} 9 | -------------------------------------------------------------------------------- /tests/thorchain/thorchain__daily_tvl__day-assert_no_gaps.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("thorchain__daily_tvl"), [], "day", dict(start_date = "cast('2021-07-22' as date)", end_date = "cast('2021-08-11' as date)")) }} 2 | -------------------------------------------------------------------------------- /models/crosschain/docs/Swap_amount_in_USD.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_swap_amount_in_usd %} 2 | 3 | [BETA TABLE] - The amount of tokens put into the swap converted to USD using the price of the token. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/TX_Hash.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_tx_hash %} 2 | 3 | [BETA TABLE] - Transaction hash is a unique 66-character identifier that is generated when a transaction is executed. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/algorand/silver/silver_algorand__transactions__intra-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ sequence_gaps_buffered_look_back(ref('silver_algorand__transactions'), ["block_id"], "intra", "_inserted_timestamp", "15 HOURS") }} 2 | -------------------------------------------------------------------------------- /tests/thorchain/thorchain__block_rewards__day-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("thorchain__block_rewards"), [], "day", dict(start_date = "cast('2021-07-22' as date)", end_date = "cast('2021-08-11' as date)")) }} 2 | -------------------------------------------------------------------------------- /data/silver_algorand__transaction_types.csv: -------------------------------------------------------------------------------- 1 | typeenum,type,name 2 | 1,pay,payment 3 | 2,keyreg,key registration 4 | 3,acfg,asset configuration 5 | 4,axfer,asset transfer 6 | 5,afrz,asset freeze 7 | 6,appl,application call -------------------------------------------------------------------------------- /models/solana/gold/solana__dim_labels.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'dim_labels' 11 | ) }} 12 | -------------------------------------------------------------------------------- /models/solana/gold/solana__fact_blocks.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'fact_blocks' 11 | ) }} 12 | -------------------------------------------------------------------------------- /models/solana/gold/solana__fact_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'fact_events' 11 | ) }} 12 | -------------------------------------------------------------------------------- /models/solana/gold/solana__fact_nft_mints.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'fact_nft_mints' 11 | ) }} -------------------------------------------------------------------------------- /models/solana/gold/solana__fact_swaps.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'fact_swaps' 11 | ) }} 12 | -------------------------------------------------------------------------------- /tests/thorchain/thorchain__daily_earnings__day-assert_no_gaps.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("thorchain__daily_earnings"), [], "day", dict(start_date = "cast('2021-07-22' as date)", end_date = "cast('2021-08-11' as date)")) }} 2 | -------------------------------------------------------------------------------- /tests/thorchain/thorchain__pool_block_fees__day-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("thorchain__pool_block_fees"), [], "day", dict(start_date = "cast('2021-07-22' as date)", end_date = "cast('2021-08-11' as date)")) }} 2 | -------------------------------------------------------------------------------- /models/solana/descriptions/program_id.md: -------------------------------------------------------------------------------- 1 | {% docs solana_program_id %} 2 | 3 | An address that identifies the program that is being interacted with. I.E. which DEX for a swap or marketplace for an NFT sale. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/gold/solana__fact_gov_actions.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'fact_gov_actions' 11 | ) }} -------------------------------------------------------------------------------- /python_analysis/environment.yml: -------------------------------------------------------------------------------- 1 | name: SQL_MODELS 2 | channels: 3 | - defaults 4 | dependencies: 5 | - python=3.9 6 | - pandas 7 | - snowflake-sqlalchemy 8 | prefix: /usr/local/Caskroom/miniconda/base/envs/SQL_MODELS 9 | -------------------------------------------------------------------------------- /tests/thorchain/thorchain__daily_pool_stats__day-assert_no_gaps.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("thorchain__daily_pool_stats"), [], "day", dict(start_date = "cast('2021-07-22' as date)", end_date = "cast('2021-08-11' as date)")) }} 2 | -------------------------------------------------------------------------------- /models/crosschain/docs/Swap_tx_to.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_swap_tx_to %} 2 | 3 | [BETA TABLE] - The tx_to is the address who receives the swapped token. This corresponds to the "to" field in the swap function. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/gold/solana__dim_nft_metadata.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'dim_nft_metadata' 11 | ) }} 12 | -------------------------------------------------------------------------------- /models/solana/gold/solana__fact_gauges_votes.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'fact_gauges_votes' 11 | ) }} -------------------------------------------------------------------------------- /models/solana/gold/solana__fact_nft_sales.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'fact_nft_sales' 11 | ) }} 12 | -------------------------------------------------------------------------------- /models/solana/gold/solana__fact_proposal_votes.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'fact_proposal_votes' 11 | ) }} -------------------------------------------------------------------------------- /models/solana/gold/solana__fact_transfers.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'fact_transfers' 11 | ) }} 12 | -------------------------------------------------------------------------------- /tests/thorchain/thorchain__pool_block_statistics__day-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("thorchain__pool_block_statistics"), [], "day", dict(start_date = "cast('2021-07-22' as date)", end_date = "cast('2021-08-11' as date)")) }} 2 | -------------------------------------------------------------------------------- /macros/create_udfs.sql: -------------------------------------------------------------------------------- 1 | {% macro create_udfs() %} 2 | {% set sql %} 3 | {{ udf_bulk_get_contract_info() }}; 4 | {{ create_algorand_udf_bulk_get_tx_info() }}; 5 | {% endset %} 6 | {% do run_query(sql) %} 7 | {% endmacro %} 8 | -------------------------------------------------------------------------------- /models/crosschain/docs/Swap_sender.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_swap_sender %} 2 | 3 | [BETA TABLE] - The address of the wallet or contract that creates the swap. The Router is usually the Sender in the swap function. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/gold/solana__fact_transactions.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'fact_transactions' 11 | ) }} 12 | -------------------------------------------------------------------------------- /packages.yml: -------------------------------------------------------------------------------- 1 | packages: 2 | - package: calogica/dbt_expectations 3 | version: 0.8.0 4 | - package: dbt-labs/dbt_external_tables 5 | version: [">=0.8.0", "<0.9.0"] 6 | - package: dbt-labs/dbt_utils 7 | version: 0.9.2 8 | -------------------------------------------------------------------------------- /tests/thorchain/thorchain__total_block_rewards__block_id-assert_no_gaps.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | warn_if = "> 10", 3 | severity = "warn" 4 | ) }} 5 | {{ sequence_distinct_gaps(ref("thorchain__total_block_rewards"), "block_id") }} 6 | -------------------------------------------------------------------------------- /models/crosschain/docs/Swap_amount_out_USD.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_swap_amount_out_usd %} 2 | 3 | [BETA TABLE] - The amount of tokens taken out of or received from the swap converted to USD using the price of the token. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/gold/solana__fact_votes_agg_block.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'fact_votes_agg_block' 11 | ) }} 12 | -------------------------------------------------------------------------------- /models/crosschain/docs/lending/lender_is_a_contract.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_lending_lender_is_a_contract %} 2 | 3 | [BETA TABLE] - If the depositor is a contract then its a Yes, if the depositor is a normal address it is a No. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/solana/gold/solana__fact_staking_lp_actions.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | * 7 | FROM 8 | {{ source( 9 | 'solana', 10 | 'fact_staking_lp_actions' 11 | ) }} 12 | -------------------------------------------------------------------------------- /models/solana/descriptions/instruction.md: -------------------------------------------------------------------------------- 1 | {% docs solana_instruction %} 2 | 3 | Specifies which program it is calling, which accounts it wants to read or modify, and additional data that serves as auxiliary input to the program 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/algorand/descriptions/inner_tx.md: -------------------------------------------------------------------------------- 1 | {% docs inner_tx %} 2 | 3 | A boolean true or false on whether or not this transaction has a parent transaction. The TX_ID will be the same as the parent transaction but will have it's own intra 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/origin_to_address.md: -------------------------------------------------------------------------------- 1 | {% docs origin_to_address %} 2 | 3 | [BETA TABLE] - The person who initiates the swap has to interact with this address. This address belongs to the decentralized exchange and/or is a router. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/Borrowing/action.md: -------------------------------------------------------------------------------- 1 | {% docs crosschain_borrow_action %} 2 | 3 | The action that the user is taking. 4 | Borrow: user is borrowing an asset 5 | Repay: user is repaying the asset that they have borrowed in a previous loan 6 | 7 | {% enddocs %} -------------------------------------------------------------------------------- /models/crosschain/docs/Borrowing/borrower_is_a_contract.md: -------------------------------------------------------------------------------- 1 | {% docs crosschain_lending_borrower_is_a_contract %} 2 | 3 | If the depositor of collateral is a contract then its a Yes, if the depositor of collateral is a normal address it is a No. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /macros/labels_join.sql: -------------------------------------------------------------------------------- 1 | {% macro labels_join(source_join_col, blockchain, alias) -%} 2 | {{ source('shared', 'udm_address_labels')}} as {{ alias }} 3 | ON {{ source_join_col }} = {{ alias }}.address AND {{ alias }}.blockchain = '{{ blockchain }}' 4 | {%- endmacro %} -------------------------------------------------------------------------------- /models/crosschain/docs/origin_from_address.md: -------------------------------------------------------------------------------- 1 | {% docs origin_from_address %} 2 | 3 | [BETA TABLE] - The address of the user who initiates the swap. If a swap action generates multiple swaps, all of them will have the same address as origin_from_address. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__constants.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'constants'] 4 | ) }} 5 | 6 | SELECT 7 | C.key, 8 | C.value 9 | FROM 10 | {{ ref('thorchain_dbt__constants') }} C 11 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__pool_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__pool_events 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..` to .core.
schema -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__slash_amounts.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__slash_amounts 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..
` to .core.
schema -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__new_node_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__new_node_events 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..
` to .core.
schema -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__reserve_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__reserve_events 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..
` to .core.
schema -------------------------------------------------------------------------------- /models/ethereum/ethereum__contracts.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'ethereum_contracts'] 4 | ) }} 5 | 6 | SELECT 7 | address, 8 | meta, 9 | NAME 10 | FROM 11 | {{ ref('silver_ethereum__contracts') }} -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__set_mimir_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__set_mimir_events 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..
` to .core.
schema -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__set_version_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__set_version_events 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..
` to .core.
schema -------------------------------------------------------------------------------- /models/crosschain/docs/lending/action.md: -------------------------------------------------------------------------------- 1 | {% docs crosschain_action %} 2 | 3 | The action that the user is taking. 4 | Deposit: user is depositing funds to be used for lending 5 | Withdraw: user has changed their mind and are no longer willing to lend, so they withdraw their asset 6 | 7 | {% enddocs %} -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__set_node_keys_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__set_node_keys_events 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..
` to .core.
schema -------------------------------------------------------------------------------- /macros/grant_select_on_schemas.sql: -------------------------------------------------------------------------------- 1 | {% macro grant_select_on_schemas( 2 | schemas, 3 | role 4 | ) %} 5 | {% for schema in schemas %} 6 | {{ grant_select_on_schema( 7 | schema, 8 | role 9 | ) }} 10 | {% endfor %} 11 | {% endmacro %} 12 | -------------------------------------------------------------------------------- /models/crosschain/docs/lending/origin_to_address.md: -------------------------------------------------------------------------------- 1 | {% docs crosschain_lending_origin_to_address %} 2 | 3 | [BETA TABLE] - The person who initiates the depositing transaction has to interact with this address. This address belongs to the lending platform or directs the transactio there. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /models/gold/gold__flow_transactions.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | models: 4 | - name: gold__flow_transactions 5 | columns: 6 | - name: "BLOCK_TIMESTAMP" 7 | tests: 8 | - not_null 9 | - name: "TX_TYPE" 10 | - name: "TX_ID" 11 | tests: 12 | - unique -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__inactive_vault_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__inactive_vault_events 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..
` to .core.
schema -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__set_ip_address_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__set_ip_address_events 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..
` to .core.
schema -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__thorname_change_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__thorname_change_events 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..
` to .core.
schema -------------------------------------------------------------------------------- /models/uniswapv3/eth_mainnet/uniswapv3_dbt__pools.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: uniswapv3_dbt__pools 4 | columns: 5 | - name: BLOCK_TIMESTAMP 6 | tests: 7 | - dbt_expectations.expect_row_values_to_have_recent_data: 8 | datepart: day 9 | interval: 7 -------------------------------------------------------------------------------- /models/uniswapv3/eth_mainnet/uniswapv3_dbt__swaps.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: uniswapv3_dbt__swaps 4 | columns: 5 | - name: BLOCK_TIMESTAMP 6 | tests: 7 | - dbt_expectations.expect_row_values_to_have_recent_data: 8 | datepart: day 9 | interval: 1 -------------------------------------------------------------------------------- /tests/thorchain/thorchain__total_value_locked__day-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ date_gaps(ref("thorchain__total_value_locked"), [], "day", dict(start_date = "cast('2021-07-22' as date)", end_date = "cast('2021-08-11' as date)"), dict(start_date = "cast('2021-11-12' as date)", end_date = "cast('2021-11-18' as date)") ) }} 2 | -------------------------------------------------------------------------------- /models/ethereum/ethereum__contracts.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: ethereum__contracts 4 | description: Deprecating soon - please migrate query to ethereum database by 9/13 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | combination_of_columns: 8 | - ADDRESS 9 | -------------------------------------------------------------------------------- /models/uniswapv3/eth_mainnet/uniswapv3_dbt__positions.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: uniswapv3_dbt__positions 4 | columns: 5 | - name: BLOCK_TIMESTAMP 6 | tests: 7 | - dbt_expectations.expect_row_values_to_have_recent_data: 8 | datepart: day 9 | interval: 7 -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__validator_request_leave_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__validator_request_leave_events 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..
` to .core.
schema -------------------------------------------------------------------------------- /models/uniswapv3/eth_mainnet/uniswapv3_dbt__pool_stats.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: uniswapv3_dbt__pool_stats 4 | columns: 5 | - name: BLOCK_TIMESTAMP 6 | tests: 7 | - dbt_expectations.expect_row_values_to_have_recent_data: 8 | datepart: day 9 | interval: 1 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | target/ 3 | dbt_modules/ 4 | # newer versions of dbt use this directory instead of dbt_modules for test dependencies 5 | dbt_packages/ 6 | logs/ 7 | 8 | .venv/ 9 | .python-version 10 | 11 | # Visual Studio Code files 12 | */.vscode 13 | *.code-workspace 14 | .history/ 15 | **/.DS_Store 16 | .vscode/ 17 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__update_node_account_status_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__update_node_account_status_events 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..
` to .core.
schema -------------------------------------------------------------------------------- /models/uniswapv3/eth_mainnet/uniswapv3_dbt__liquidity_actions.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: uniswapv3_dbt__liquidity_actions 4 | columns: 5 | - name: BLOCK_TIMESTAMP 6 | tests: 7 | - dbt_expectations.expect_row_values_to_have_recent_data: 8 | datepart: day 9 | interval: 1 -------------------------------------------------------------------------------- /models/gold/gold__near_delegator_counts.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: gold__near_delegator_counts 4 | description: Daily delegate counts by address 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | combination_of_columns: 8 | - DATE 9 | - VALIDATOR_ADDRESS 10 | -------------------------------------------------------------------------------- /models/terra/gold/terra__blocks.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'terra_views', 'blocks', 'terra'], 4 | ) }} 5 | 6 | SELECT 7 | block_id, 8 | block_timestamp, 9 | blockchain, 10 | chain_id, 11 | proposer_address, 12 | tx_count 13 | FROM 14 | {{ ref('silver_terra__blocks') }} 15 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__app.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'app', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | app_id, 8 | creator_address, 9 | app_closed, 10 | closed_at, 11 | created_at, 12 | params 13 | FROM 14 | {{ ref('silver_algorand__app') }} 15 | -------------------------------------------------------------------------------- /models/ethereum/silver/silver_ethereum__contracts.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_ethereum__contracts 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - ADDRESS 8 | columns: 9 | - name: ADDRESS 10 | tests: 11 | - not_null 12 | -------------------------------------------------------------------------------- /models/gold/gold__near_block_rewards.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: gold__near_block_rewards 4 | description: Rewards given per block 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | combination_of_columns: 8 | - BLOCKCHAIN 9 | - BLOCK_NUMBER 10 | - ADDRESS 11 | -------------------------------------------------------------------------------- /models/uniswapv3/eth_mainnet/uniswapv3__pools.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'incremental', 3 | sort = 'block_timestamp', 4 | unique_key = 'tx_id', 5 | incremental_strategy = 'delete+insert', 6 | tags = ['snowflake', 'uniswapv3', 'pools'] 7 | ) }} 8 | {{ uniswapv3_pools(ref('silver_uniswapv3__pools'), ref("ethereum__token_prices_hourly")) }} 9 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__account_app.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'account_app', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | address, 8 | app_id, 9 | app_closed, 10 | closed_at, 11 | created_at, 12 | app_info 13 | FROM 14 | {{ ref('silver_algorand__account_app') }} 15 | -------------------------------------------------------------------------------- /models/crosschain/docs/Event_Log_id.md: -------------------------------------------------------------------------------- 1 | {% docs cross_chain_event_log_id %} 2 | 3 | [BETA TABLE] - This is the primary key for this table. This is a concatenation of the transaction hash and the event index at which the event occurred. This field can be used within other event based tables such as ```fact_transfers``` & ```ez_token_transfers```. 4 | 5 | {% enddocs %} -------------------------------------------------------------------------------- /tests/terra/terra__msgs__block_id-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ config(error_if = '>10', warn_if = '>1') }} 2 | 3 | SELECT 4 | block_id 5 | FROM {{ ref('silver_terra__blocks') }} 6 | WHERE block_id NOT IN ( 7 | SELECT 8 | block_id 9 | FROM {{ ref('terra__msgs') }} 10 | ) 11 | 12 | AND tx_count > 0 13 | AND block_timestamp::date >= '2021-10-01' -------------------------------------------------------------------------------- /models/algorand/gold/algorand__prices_pool_balances.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | block_hour, 7 | asset_id, 8 | asset_name, 9 | price_usd, 10 | algo_balance, 11 | non_algo_balance, 12 | pool_name, 13 | pool_address 14 | FROM 15 | {{ ref('silver_algorand__prices_pool_balances') }} 16 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__transaction_participation.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'transaction_participation', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | block_timestamp, 8 | block_id, 9 | intra, 10 | address 11 | FROM 12 | {{ ref('silver_algorand__transaction_participation') }} 13 | -------------------------------------------------------------------------------- /models/ethereum/aave/Aave data audit and db structure.txt: -------------------------------------------------------------------------------- 1 | Document for auditing purposes 2 | 3 | 4 | Aave future schemas can be found here: https://docs.google.com/document/d/1Hb2DvXYqZYC6WoKfwmOHV4KL62gfgEY0VqACS5-vwMw/edit 5 | 6 | 7 | A Flipside data audit has been summarised here: https://docs.google.com/document/d/16POCfrIqL7cxNAKmYAp8QhIMzj8hYmpwlTnawGVITl4/edit -------------------------------------------------------------------------------- /models/gold/gold__near_reward_flow.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: gold__near_reward_flow 4 | description: Daily rewards by address 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | combination_of_columns: 8 | - BLOCKCHAIN 9 | - DATE 10 | - ADDRESS 11 | - METRIC_SLUG 12 | -------------------------------------------------------------------------------- /models/terra/secure_views/terra_sv__blocks.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | secure = 'true', 4 | tags = ['snowflake', 'terra_views', 'blocks', 'terra', 'secure_views'], 5 | ) }} 6 | 7 | SELECT 8 | block_id, 9 | block_timestamp, 10 | blockchain, 11 | chain_id, 12 | proposer_address 13 | FROM 14 | {{ ref('silver_terra__blocks') }} 15 | -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__dim_dates.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'dim_dates' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__dim_labels.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'dim_labels' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/gold/gold__near_daily_balances.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: gold__near_daily_balances 4 | description: Daily balances by address 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | combination_of_columns: 8 | - DATE 9 | - ADDRESS 10 | - BALANCE_TYPE 11 | enabled: False 12 | -------------------------------------------------------------------------------- /models/crosschain/crosschain__address_tags.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'crosschain', 'address_tags', 'tags'], 4 | ) }} 5 | 6 | SELECT 7 | blockchain, 8 | creator, 9 | address, 10 | tag_name, 11 | tag_type, 12 | start_date, 13 | end_date 14 | FROM {{ ref('silver_crosschain__address_tags') }} -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__dim_contracts.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'dim_contracts' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__ez_dex_swaps.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'ez_dex_swaps' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__ez_nft_mints.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'ez_nft_mints' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__ez_nft_sales.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'ez_nft_sales' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__fact_blocks.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'fact_blocks' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__fact_traces.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'fact_traces' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/ethereum_core/sushi/ethereum_sushi__ez_swaps.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db_sushi', 13 | 'ez_swaps' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/gold/gold__near_validators.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: gold__near_validators 4 | description: Validator staked amounts over blocks 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | combination_of_columns: 8 | - BLOCKCHAIN 9 | - BLOCK_NUMBER 10 | - ADDRESS 11 | - STATUS 12 | -------------------------------------------------------------------------------- /tests/terra/terra__transactions__block_id-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ config(error_if = '>10', warn_if = '>1') }} 2 | 3 | SELECT 4 | block_id 5 | FROM {{ ref('silver_terra__blocks') }} 6 | WHERE block_id NOT IN ( 7 | SELECT 8 | block_id 9 | FROM {{ ref('terra__transactions') }} 10 | ) 11 | 12 | AND tx_count > 0 13 | AND block_timestamp::date >= '2021-10-01' -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__fact_event_logs.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'fact_event_logs' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/terra/gold/terra__transitions.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'terra_views', 'transitions', 'terra'] 4 | ) }} 5 | 6 | SELECT 7 | block_id, 8 | block_timestamp, 9 | blockchain, 10 | chain_id, 11 | transition_type, 12 | INDEX, 13 | event, 14 | event_attributes 15 | FROM 16 | {{ ref('silver_terra__transitions') }} 17 | -------------------------------------------------------------------------------- /models/uniswapv3/eth_mainnet/uniswapv3__swaps.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'incremental', 3 | sort = 'block_timestamp', 4 | unique_key = 'tx_id', 5 | incremental_strategy = 'delete+insert', 6 | tags = ['snowflake', 'uniswapv3', 'swaps'] 7 | ) }} 8 | {{ uniswapv3_swaps(ref('silver_uniswapv3__swaps'), ref('silver_uniswapv3__pools'), ref("ethereum__token_prices_hourly")) }} 9 | -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__ez_nft_transfers.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'ez_nft_transfers' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__ez_token_transfers.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'ez_token_transfers' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__fact_transactions.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'fact_transactions' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__fact_token_transfers.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'fact_token_transfers' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__block.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'block', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | block_id, 8 | block_timestamp, 9 | rewardslevel, 10 | network, 11 | genesis_hash, 12 | prev_block_hash, 13 | txn_root, 14 | header 15 | FROM 16 | {{ ref('silver_algorand__block') }} 17 | -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__dim_dex_liquidity_pools.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'dim_dex_liquidity_pools' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/uniswapv3/eth_mainnet/uniswapv3__positions.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'incremental', 3 | sort = 'block_timestamp', 4 | unique_key = 'tx_id', 5 | incremental_strategy = 'delete+insert', 6 | tags = ['snowflake', 'uniswapv3', 'positions'] 7 | ) }} 8 | {{ uniswapv3_positions(ref('silver_uniswapv3__positions'), ref('silver_uniswapv3__pools'), ref("ethereum__token_prices_hourly")) }} 9 | -------------------------------------------------------------------------------- /models/ethereum_core/core/ethereum_core__fact_hourly_token_prices.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db', 13 | 'fact_hourly_token_prices' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/uniswapv3/eth_mainnet/uniswapv3__pool_stats.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'incremental', 3 | sort = 'block_timestamp', 4 | unique_key = 'block_id', 5 | incremental_strategy = 'delete+insert', 6 | tags = ['snowflake', 'uniswapv3', 'pool_stats'] 7 | ) }} 8 | {{ uniswapv3_pool_stats(ref('silver_uniswapv3__pool_stats'), ref('silver_uniswapv3__pools'), ref("ethereum__token_prices_hourly")) }} 9 | -------------------------------------------------------------------------------- /models/uniswapv3/eth_mainnet/uniswapv3__lp_actions.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'incremental', 3 | sort = 'block_timestamp', 4 | unique_key = 'tx_id', 5 | incremental_strategy = 'delete+insert', 6 | tags = ['snowflake', 'uniswapv3', 'lp_actions'] 7 | ) }} 8 | {{ uniswapv3_lp_actions(ref('silver_uniswapv3__liquidity_actions'), ref('silver_uniswapv3__pools'), ref("ethereum__token_prices_hourly")) }} 9 | -------------------------------------------------------------------------------- /models/crosschain/docs/Borrowing/amount.md: -------------------------------------------------------------------------------- 1 | {% docs crosschain_borrow_amount %} 2 | 3 | The meaning depends on the action: 4 | Borrow: The amount of the asset that the user is borrowing or 5 | Repay: The amount of the asset that the user is repaying 6 | Deposit_collateral: The amount of collateral that the user is depositing 7 | Withdraw_collateral: The amount of collateral that the user is withdrawing 8 | 9 | {% enddocs %} -------------------------------------------------------------------------------- /models/algorand/gold/algorand__account_asset.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'account_asset', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | address, 8 | asset_id, 9 | asset_name, 10 | amount, 11 | asset_added_at, 12 | asset_last_removed, 13 | asset_closed, 14 | frozen 15 | FROM 16 | {{ ref('silver_algorand__account_asset') }} 17 | -------------------------------------------------------------------------------- /models/ethereum_core/sushi/ethereum_sushi__dim_distributor_reward_schedule.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum', 'gold_ethereum', 'new_eth'], 4 | persist_docs ={ "relation": true, 5 | "columns": true } 6 | ) }} 7 | 8 | SELECT 9 | * 10 | FROM 11 | {{ source( 12 | 'ethereum_db_sushi', 13 | 'dim_distributor_reward_schedule' 14 | ) }} 15 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__account.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'account', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | address, 8 | account_closed, 9 | rewardsbase, 10 | rewards_total, 11 | balance, 12 | closed_at, 13 | created_at, 14 | wallet_type, 15 | account_data 16 | FROM 17 | {{ ref('silver_algorand__account') }} 18 | -------------------------------------------------------------------------------- /models/consoles/terra/consoles_terra__total_transactions.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'terra', 'console', 'terra_total_transactions'] 4 | ) }} 5 | 6 | SELECT 7 | DATE(block_timestamp) AS DAY, 8 | COUNT( 9 | DISTINCT tx_id 10 | ) AS tx_count 11 | FROM 12 | {{ ref('terra__msgs') }} 13 | WHERE 14 | DAY <= CURRENT_DATE 15 | GROUP BY 16 | DAY 17 | ORDER BY 18 | DAY DESC 19 | -------------------------------------------------------------------------------- /models/terra/secure_views/terra_sv__transitions.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | secure = 'true', 4 | tags = ['snowflake', 'terra_views', 'transitions', 'terra', 'secure_views'] 5 | ) }} 6 | 7 | SELECT 8 | block_id, 9 | block_timestamp, 10 | blockchain, 11 | chain_id, 12 | transition_type, 13 | INDEX, 14 | event, 15 | event_attributes 16 | FROM 17 | {{ ref('silver_terra__transitions') }} 18 | -------------------------------------------------------------------------------- /models/terra/gold/terra__msgs.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'terra_views', 'msgs', 'terra'] 4 | ) }} 5 | 6 | SELECT 7 | block_id, 8 | block_timestamp, 9 | blockchain, 10 | chain_id, 11 | tx_id, 12 | tx_status, 13 | tx_module, 14 | tx_type, 15 | tx_memo, 16 | msg_index, 17 | msg_module, 18 | msg_type, 19 | msg_value 20 | FROM 21 | {{ ref('silver_terra__msgs') }} 22 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__rewards_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_thorchain__rewards_events 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - BLOCK_TIMESTAMP 8 | columns: 9 | - name: BLOCK_TIMESTAMP 10 | tests: 11 | - not_null 12 | - name: BOND_E8 13 | tests: 14 | - not_null -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__slash_points.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'slash_points'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__slash_points') }} 10 | 11 | {% if is_incremental() %} 12 | WHERE 13 | __HEVO_loaded_at >= ( 14 | SELECT 15 | MAX(__HEVO_loaded_at) 16 | FROM 17 | {{ this }} 18 | ) 19 | {% endif %} 20 | -------------------------------------------------------------------------------- /models/crosschain/docs/Borrowing/amount_usd.md: -------------------------------------------------------------------------------- 1 | {% docs crosschain_borrow_amount_usd %} 2 | 3 | The meaning depends on the action: 4 | Borrow: The amount of the asset in USD that the user is borrowing or 5 | Repay: The amount of the asset in USD that the user is repaying 6 | Deposit_collateral: The amount of collateral in USD that the user is depositing 7 | Withdraw_collateral: The amount of collateral in USD that the user is withdrawing 8 | {% enddocs %} -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__slash_amounts.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'slash_amounts'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__slash_amounts') }} 10 | 11 | {% if is_incremental() %} 12 | WHERE 13 | __HEVO_loaded_at >= ( 14 | SELECT 15 | MAX(__HEVO_loaded_at) 16 | FROM 17 | {{ this }} 18 | ) 19 | {% endif %} 20 | -------------------------------------------------------------------------------- /models/ethereum/ethereum__reads.sql: -------------------------------------------------------------------------------- 1 | 2 | {{ config( 3 | materialized = 'view', 4 | tags = ['snowflake', 'ethereum', 'reads', 'ethereum__reads'] 5 | ) }} 6 | 7 | SELECT 8 | block_timestamp, 9 | block_id, 10 | contract_address, 11 | contract_name, 12 | function_name, 13 | inputs, 14 | project_id, 15 | project_name, 16 | value_numeric, 17 | value_string 18 | FROM {{ ref('silver_ethereum__reads') }} 19 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__add_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'add_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_add_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__block_log.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'block_log'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_block_log' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__constants.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'constants'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_constants' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__fee_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'fee_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_fee_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__gas_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'gas_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_gas_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/algorand/silver/silver_algorand__hourly_pool_balances.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_algorand__hourly_pool_balances 4 | tests: 5 | columns: 6 | - name: ADDRESS 7 | tests: 8 | - not_null 9 | - name: DATE 10 | tests: 11 | - not_null 12 | - name: ASSET_ID 13 | tests: 14 | - not_null 15 | - name: BALANCE 16 | tests: 17 | - not_null -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__pool_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'pool_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_pool_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__stake_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'stake_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_stake_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__swap_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'swap_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_swap_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__errata_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'errata_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_errata_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__refund_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'refund_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_refund_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__slash_amounts.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'slash_amounts'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_slash_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/gold/gold__flow_labels.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized='view', 3 | tags=['snowflake', 'flow_views', 'labels', 'flow_labels', 'address_labels'] 4 | ) 5 | }} 6 | 7 | SELECT 8 | blockchain, 9 | creator, 10 | address, 11 | l1_label as label_type, 12 | l2_label as label_subtype, 13 | project_name as label, 14 | address_name as address_name 15 | FROM {{ref('silver_crosschain__address_labels')}} 16 | WHERE blockchain = 'flow' -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__new_node_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'new_node_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_new_node_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__outbound_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'outbound_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_outbound_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__reserve_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'reserve_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_reserve_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__rewards_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'rewards_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_rewards_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__slash_points.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'slash_points'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_slash_points_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__transfer_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'transfer_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_transfer_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__unstake_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'unstake_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_unstake_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/terra/gold/terra__labels.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized='view', 3 | tags=['snowflake', 'terra_views', 'labels', 'terra_labels', 'address_labels'] 4 | ) 5 | }} 6 | 7 | SELECT 8 | blockchain, 9 | address, 10 | creator, 11 | l1_label as label_type, 12 | l2_label as label_subtype, 13 | project_name as label, 14 | address_name as address_name 15 | FROM {{ref('silver_crosschain__address_labels')}} 16 | WHERE blockchain = 'terra' -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__block_pool_depths.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'block_pool_depths'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_block_pool_depths' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__set_mimir_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'set_mimir_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_set_mimir_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/uniswapv3/eth_mainnet/uniswapv3__position_collected_fees.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'incremental', 3 | sort = 'block_timestamp', 4 | unique_key = 'tx_id', 5 | incremental_strategy = 'delete+insert', 6 | tags = ['snowflake', 'uniswapv3', 'position_collected_fees'] 7 | ) }} 8 | {{ uniswapv3_position_collected_fees(ref('silver_uniswapv3__pools'), ref('ethereum__events_emitted'), ref('silver_uniswapv3__positions'), ref("ethereum__token_prices_hourly")) }} 9 | -------------------------------------------------------------------------------- /models/polygon/polygon__labels.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized='view', 3 | tags=['snowflake', 'polygon_views', 'labels', 'polygon_labels', 'address_labels'] 4 | ) 5 | }} 6 | 7 | SELECT 8 | blockchain, 9 | creator, 10 | address, 11 | l1_label as label_type, 12 | l2_label as label_subtype, 13 | project_name as label, 14 | address_name as address_name 15 | FROM {{ref('silver_crosschain__address_labels')}} 16 | WHERE blockchain = 'polygon' -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__set_version_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'set_version_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_set_version_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /macros/algorand/all_udfs.sql: -------------------------------------------------------------------------------- 1 | {% macro create_algorand_udf_bulk_get_tx_info() %} 2 | CREATE 3 | OR REPLACE EXTERNAL FUNCTION silver_algorand.udf_bulk_get_tx() returns text api_integration = aws_algorand_api AS {% if target.name == "prod" -%} 4 | 'https://koklizm6jc.execute-api.us-east-1.amazonaws.com/prod/bulk_get_tx_info' 5 | {% else %} 6 | 'https://vfc3eyv16g.execute-api.us-east-1.amazonaws.com/dev/bulk_get_tx_info' 7 | {%- endif %} 8 | {% endmacro %} 9 | -------------------------------------------------------------------------------- /macros/custom_naming_macros.sql: -------------------------------------------------------------------------------- 1 | {% macro generate_schema_name(custom_schema_name=none, node=none) -%} 2 | {% set node_name = node.name %} 3 | {% set split_name = node_name.split('__') %} 4 | {{ split_name[0] | trim }} 5 | {%- endmacro %} 6 | 7 | {% macro generate_alias_name(custom_alias_name=none, node=none) -%} 8 | {% set node_name = node.name %} 9 | {% set split_name = node_name.split('__') %} 10 | {{ split_name[1] | trim }} 11 | {%- endmacro %} 12 | -------------------------------------------------------------------------------- /models/crosschain/crosschain__nft_fair_market_value.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'crosschain', 'address_labels', 'gold_address_labels'], 4 | ) }} 5 | 6 | SELECT 7 | collection 8 | , mint 9 | , token_id 10 | , deal_score_rank 11 | , rarity_rank 12 | , floor_price 13 | , fair_market_price 14 | , price_low 15 | , price_high 16 | FROM 17 | {{ ref('silver_crosschain__nft_fair_market_value') }} -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__active_vault_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'active_vault_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_active_vault_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /macros/terra/all_udfs.sql: -------------------------------------------------------------------------------- 1 | {% macro udf_bulk_get_contract_info() %} 2 | CREATE 3 | OR REPLACE EXTERNAL FUNCTION silver_terra.udf_bulk_get_contract_info() returns text api_integration = aws_terra_api AS {% if target.name == "prod" -%} 4 | 'https://t8z22zn7gi.execute-api.us-east-1.amazonaws.com/prod/bulk_get_contract_info' 5 | {% else %} 6 | 'https://3wcc5lj48d.execute-api.us-east-1.amazonaws.com/dev/bulk_get_contract_info' 7 | {%- endif %} 8 | {% endmacro %} 9 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__nft_asset.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | SELECT 6 | nft_asset_id, 7 | nft_asset_name, 8 | nft_total_supply, 9 | decimals, 10 | created_at, 11 | collection_name, 12 | creator_address, 13 | nft_url, 14 | collection_nft, 15 | arc69_nft, 16 | ar3_nft, 17 | ar19_nft, 18 | traditional_nft, 19 | asset_deleted 20 | FROM 21 | {{ ref('silver_algorand__nft_asset') }} 22 | -------------------------------------------------------------------------------- /models/crosschain/crosschain__address_labels.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'crosschain', 'labels', 'gold_address_labels'], 4 | ) }} 5 | 6 | SELECT 7 | system_created_at, 8 | insert_date, 9 | blockchain, 10 | address, 11 | creator, 12 | l1_label AS label_type, 13 | l2_label AS label_subtype, 14 | address_name, 15 | project_name 16 | FROM 17 | {{ ref('silver_crosschain__address_labels') }} -------------------------------------------------------------------------------- /models/terra/gold/terra__msg_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'terra_views', 'msg_events', 'terra'] 4 | ) }} 5 | 6 | SELECT 7 | block_id, 8 | block_timestamp, 9 | blockchain, 10 | chain_id, 11 | tx_id, 12 | tx_status, 13 | tx_module, 14 | tx_type, 15 | msg_index, 16 | msg_module, 17 | msg_type, 18 | event_index, 19 | event_type, 20 | event_attributes 21 | FROM 22 | {{ ref('silver_terra__msg_events') }} 23 | -------------------------------------------------------------------------------- /models/terra/secure_views/terra_sv__msgs.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | secure = 'true', 4 | tags = ['snowflake', 'terra_views', 'msgs', 'terra', 'secure_views'] 5 | ) }} 6 | 7 | SELECT 8 | block_id, 9 | block_timestamp, 10 | blockchain, 11 | chain_id, 12 | tx_id, 13 | tx_status, 14 | tx_module, 15 | tx_type, 16 | tx_memo, 17 | msg_index, 18 | msg_module, 19 | msg_type, 20 | msg_value 21 | FROM 22 | {{ ref('silver_terra__msgs') }} 23 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__inactive_vault_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'inactive_vault_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_inactive_vault_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__rewards_event_entries.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'rewards_event_entries'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_rewards_event_entries' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__set_ip_address_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'set_ip_address_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_set_ip_address_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__thorname_change_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'thorname_change_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_thorname_change_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__prices_swap.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'algorand_swaps', 'algorand_prices_swap', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | block_hour, 8 | asset_id, 9 | asset_name, 10 | price_usd, 11 | min_price_usd_hour, 12 | max_price_usd_hour, 13 | volatility_measure, 14 | swaps_in_hour, 15 | volume_usd_in_hour 16 | FROM 17 | {{ ref('silver_algorand__prices_swap') }} 18 | -------------------------------------------------------------------------------- /models/algorand/silver/silver_algorand__daily_balances.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_algorand__daily_balances 4 | columns: 5 | - name: ADDRESS 6 | tests: 7 | - not_null 8 | - name: DATE 9 | tests: 10 | - not_null 11 | - dbt_expectations.expect_row_values_to_have_recent_data: 12 | datepart: day 13 | interval: 1 14 | - name: BALANCE 15 | tests: 16 | - not_null -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__set_node_keys_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'fee_set_node_keys_eventsevents'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_set_node_keys_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__pool_balance_change_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__pool_balance_change_events 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..
` to .core.
schema 5 | columns: 6 | - name: BLOCK_TIMESTAMP 7 | tests: 8 | - not_null 9 | - name: BLOCK_ID 10 | tests: 11 | - not_null 12 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__active_vault_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_thorchain__active_vault_events 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - BLOCK_TIMESTAMP 8 | - ADD_ASGARD_ADDR 9 | columns: 10 | - name: BLOCK_TIMESTAMP 11 | tests: 12 | - not_null 13 | - name: ADD_ASGARD_ADDR 14 | tests: 15 | - not_null -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__thorname_change_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'thorname_change_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref( 10 | 'thorchain_dbt__thorname_change_events' 11 | ) }} 12 | 13 | {% if is_incremental() %} 14 | WHERE 15 | __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__pending_liquidity_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'pending_liquidity_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_pending_liquidity_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/terra/silver/silver_terra__undecoded_oracle_contracts.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_terra__undecoded_oracle_contracts 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - TOKEN_CONTRACT 8 | columns: 9 | - name: TOKEN_CONTRACT 10 | tests: 11 | - not_null 12 | - dbt_expectations.expect_column_values_to_match_regex: 13 | regex: terra[0-9a-zA-Z]{39,40} -------------------------------------------------------------------------------- /models/terra/silver/silver_terra__undecoded_wormhole_contracts.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_terra__undecoded_wormhole_contracts 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - TOKEN_CONTRACT 8 | columns: 9 | - name: TOKEN_CONTRACT 10 | tests: 11 | - not_null 12 | - dbt_expectations.expect_column_values_to_match_regex: 13 | regex: terra[0-9a-zA-Z]{39,40} -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__pool_balance_change_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'pool_balance_change_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_pool_balance_change_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__bond_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_thorchain__bond_events 4 | columns: 5 | - name: BLOCK_TIMESTAMP 6 | tests: 7 | - not_null 8 | - name: TX 9 | tests: 10 | - not_null 11 | - name: ASSET_E8 12 | tests: 13 | - not_null 14 | - name: BOND_TYPE 15 | tests: 16 | - not_null 17 | - name: E8 18 | tests: 19 | - not_null -------------------------------------------------------------------------------- /models/terra/gold/terra__transactions.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'terra_views', 'transactions', 'terra'] 4 | ) }} 5 | 6 | SELECT 7 | block_id, 8 | block_timestamp, 9 | blockchain, 10 | chain_id, 11 | tx_id, 12 | tx_from, 13 | tx_to, 14 | tx_type, 15 | tx_status, 16 | tx_status_msg, 17 | tx_code, 18 | tx_module, 19 | codespace, 20 | fee, 21 | gas_used, 22 | gas_wanted 23 | FROM 24 | {{ ref('silver_terra__transactions') }} 25 | -------------------------------------------------------------------------------- /models/terra/secure_views/terra_sv__labels.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized='view', 3 | secure = 'true', 4 | tags=['snowflake', 'terra_views', 'labels', 'terra_labels', 'secure_views', 'address_labels'] 5 | ) 6 | }} 7 | 8 | SELECT 9 | blockchain, 10 | address, 11 | l1_label as label_type, 12 | l2_label as label_subtype, 13 | project_name as label, 14 | address_name as address_name 15 | FROM {{ref('silver_crosschain__address_labels')}} 16 | WHERE blockchain = 'terra' -------------------------------------------------------------------------------- /models/terra/silver/silver_terra__dex_contracts.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_terra__dex_contracts 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - CONTRACT_ADDRESS 8 | columns: 9 | - name: BLOCK_TIMESTAMP 10 | tests: 11 | - not_null 12 | - name: TX_ID 13 | tests: 14 | - not_null 15 | - name: CONTRACT_ADDRESS 16 | tests: 17 | - not_null -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__asgard_fund_yggdrasil_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'asgard_fund_yggdrasil_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_asgard_fund_yggdrasil_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/dbt/thorchain_dbt__validator_request_leave_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain_dbt', 'validator_request_leave_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ source( 10 | 'thorchain_midgard', 11 | 'midgard_validator_request_leave_events' 12 | ) }} 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__fee_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_thorchain__fee_events 4 | columns: 5 | - name: BLOCK_TIMESTAMP 6 | tests: 7 | - not_null 8 | - name: TX 9 | tests: 10 | - not_null 11 | - name: ASSET 12 | tests: 13 | - not_null 14 | - name: POOL_DEDUCT 15 | tests: 16 | - not_null 17 | - name: ASSET_E8 18 | tests: 19 | - not_null 20 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__transactions.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'transactions', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | block_timestamp, 8 | intra, 9 | block_id, 10 | tx_group_id, 11 | tx_id, 12 | inner_tx, 13 | asset_id, 14 | sender, 15 | fee, 16 | tx_type, 17 | tx_type_name, 18 | genesis_hash, 19 | tx_message, 20 | extra 21 | FROM 22 | {{ ref('silver_algorand__transactions') }} 23 | -------------------------------------------------------------------------------- /models/solana/bronze/bronze_solana__transactions.sql: -------------------------------------------------------------------------------- 1 | {{ config ( 2 | materialized = 'view', 3 | tags = ['snowflake', 'solana', 'bronze_solana', 'solana_transactions'] 4 | ) }} 5 | 6 | SELECT 7 | record_id, 8 | tx_id, 9 | tx_block_index, 10 | offset_id AS block_id, 11 | block_id AS offset_id, 12 | block_timestamp, 13 | network, 14 | chain_id, 15 | tx, 16 | ingested_at 17 | FROM 18 | {{ source( 19 | 'prod', 20 | 'solana_txs' 21 | ) }} 22 | WHERE 23 | offset_id >= 110547628 24 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__new_node_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'new_node_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.node_addr AS node_address 12 | FROM 13 | {{ ref('silver_thorchain__new_node_events') }} 14 | e 15 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 16 | bl 17 | ON bl.timestamp = e.block_timestamp 18 | -------------------------------------------------------------------------------- /models/ethereum/ethereum__labels.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'ethereum_views', 'labels', 'ethereum_labels', 'address_labels'] 4 | ) }} 5 | 6 | SELECT 7 | blockchain, 8 | creator, 9 | address, 10 | l1_label AS label_type, 11 | l2_label AS label_subtype, 12 | project_name AS label, 13 | address_name AS address_name 14 | FROM 15 | {{ ref('silver_crosschain__address_labels') }} 16 | WHERE 17 | blockchain = 'ethereum' 18 | AND LOWER(address) LIKE '0x%' 19 | -------------------------------------------------------------------------------- /models/ethereum/silver/silver_ethereum__prices.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_ethereum__prices 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - TOKEN_ADDRESS 8 | - SYMBOL 9 | - HOUR 10 | columns: 11 | - name: HOUR 12 | tests: 13 | - not_null 14 | - dbt_expectations.expect_row_values_to_have_recent_data: 15 | datepart: day 16 | interval: 1 -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__transfer_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_thorchain__transfer_events 4 | columns: 5 | - name: BLOCK_TIMESTAMP 6 | tests: 7 | - not_null 8 | - name: ASSET 9 | tests: 10 | - not_null 11 | - name: AMOUNT_E8 12 | tests: 13 | - not_null 14 | - name: FROM_ADDR 15 | tests: 16 | - not_null 17 | - name: TO_ADDR 18 | tests: 19 | - not_null 20 | -------------------------------------------------------------------------------- /tests/terra/terra__msg_events__block_id-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ config(error_if = '>10', warn_if = '>1') }} 2 | 3 | SELECT 4 | block_id 5 | FROM {{ ref('silver_terra__blocks') }} 6 | WHERE block_id NOT IN ( 7 | SELECT 8 | block_id 9 | FROM {{ ref('terra__msg_events') }} 10 | ) 11 | 12 | AND tx_count > 0 13 | AND block_timestamp::date >= '2021-10-01' 14 | AND block_id IN (SELECT DISTINCT block_id FROM {{ ref('terra__msgs') }} where tx_status = 'SUCCEEDED' AND block_timestamp::date >= '2021-10-01' ) -------------------------------------------------------------------------------- /models/flow/silver/silver_flow__daily_staked_balances.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | models: 4 | - name: silver_flow__daily_staked_balances 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | combination_of_columns: 8 | - BALANCE_DATE 9 | - NODE_ID 10 | - DELEGATOR_ID 11 | 12 | columns: 13 | - name: "DELEGATED_AMOUNT" 14 | - name: "BALANCE_DATE" 15 | tests: 16 | - not_null 17 | - name: "DELEGATOR_ID" 18 | - name: "NODE_ID" -------------------------------------------------------------------------------- /models/solana/bronze/bronze_solana__blocks.sql: -------------------------------------------------------------------------------- 1 | {{ config ( 2 | materialized = 'view', 3 | tags = ['snowflake', 'solana', 'bronze_solana', 'solana_blocks'] 4 | ) }} 5 | 6 | SELECT 7 | record_id, 8 | offset_id AS block_id, 9 | block_id AS offset_id, 10 | block_timestamp, 11 | network, 12 | chain_id, 13 | tx_count, 14 | header, 15 | ingested_at 16 | FROM 17 | {{ source( 18 | 'prod', 19 | 'solana_blocks' 20 | ) }} 21 | WHERE 22 | offset_id >= 110547628 23 | -------------------------------------------------------------------------------- /macros/decimal_adjust.sql: -------------------------------------------------------------------------------- 1 | {% macro decimal_adjust(col_to_adjust, decimal_col) -%} 2 | 3 | CASE WHEN {{col_to_adjust}} IS NOT NULL AND {{decimal_col}} IS NOT NULL 4 | THEN {{col_to_adjust}} / pow(10, {{decimal_col}}) 5 | ELSE NULL 6 | END 7 | 8 | {%- endmacro %} 9 | 10 | 11 | {% macro decimal_adjust_with_inputs(col_to_adjust, num, denom) -%} 12 | 13 | CASE WHEN {{col_to_adjust}} IS NOT NULL AND {{denom}} IS NOT NULL 14 | THEN {{num}} / pow(10, {{denom}}) 15 | ELSE NULL 16 | END 17 | 18 | {%- endmacro %} 19 | -------------------------------------------------------------------------------- /models/terra/secure_views/terra_sv__msg_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | secure = 'true', 4 | tags = ['snowflake', 'terra_views', 'msg_events', 'terra', 'secure_views'] 5 | ) }} 6 | 7 | SELECT 8 | block_id, 9 | block_timestamp, 10 | blockchain, 11 | chain_id, 12 | tx_id, 13 | tx_status, 14 | tx_module, 15 | tx_type, 16 | msg_index, 17 | msg_module, 18 | msg_type, 19 | event_index, 20 | event_type, 21 | event_attributes 22 | FROM 23 | {{ ref('silver_terra__msg_events') }} 24 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__inactive_vault_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'gas_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.add_asgard_addr AS add_asgard_address 12 | FROM 13 | {{ ref('silver_thorchain__inactive_vault_events') }} 14 | e 15 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 16 | bl 17 | ON bl.timestamp = e.block_timestamp 18 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__block_log.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'block_log'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__block_log') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY height, TIMESTAMP, HASH 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/ethereum/silver/silver_ethereum__balances.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_ethereum__balances 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - ADDRESS 8 | - BLOCK_ID 9 | - CONTRACT_ADDRESS 10 | columns: 11 | - name: BLOCK_TIMESTAMP 12 | tests: 13 | - not_null 14 | - dbt_expectations.expect_row_values_to_have_recent_data: 15 | datepart: day 16 | interval: 1 -------------------------------------------------------------------------------- /models/terra/terra_scored/terra_scored__swap_current_prices.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: terra_scored__swap_current_prices 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - TOKEN 8 | - PRICE 9 | - SOURCE 10 | columns: 11 | - name: TOKEN 12 | tests: 13 | - not_null 14 | - name: PRICE 15 | tests: 16 | - not_null 17 | - name: SOURCE 18 | tests: 19 | - not_null -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__rewards_event_entries.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_thorchain__rewards_event_entries 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - BLOCK_TIMESTAMP 8 | - POOL 9 | columns: 10 | - name: BLOCK_TIMESTAMP 11 | tests: 12 | - not_null 13 | - name: RUNE_E8 14 | tests: 15 | - not_null 16 | - name: POOL 17 | tests: 18 | - not_null -------------------------------------------------------------------------------- /tests/terra/terra__event_actions__block_id-assert_no_gap.sql: -------------------------------------------------------------------------------- 1 | {{ config(error_if = '>10', warn_if = '>1') }} 2 | 3 | SELECT DISTINCT 4 | block_id 5 | FROM {{ ref('silver_terra__msg_events') }} 6 | WHERE block_id NOT IN ( 7 | SELECT DISTINCT 8 | block_id 9 | FROM {{ ref('terra__event_actions') }} 10 | WHERE block_timestamp::date >= '2021-10-01' 11 | ) 12 | 13 | AND block_timestamp::date >= '2021-10-01' 14 | AND tx_status = 'SUCCEEDED' 15 | AND msg_type = 'wasm/MsgExecuteContract' 16 | AND event_type = 'from_contract' -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__asgard_fund_yggdrasil_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'asgard_fund_yggdrasil_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | asset, 11 | tx AS tx_id, 12 | vault_key, 13 | asset_e8 14 | FROM 15 | {{ ref('silver_thorchain__asgard_fund_yggdrasil_events') }} 16 | 17 | {% if is_incremental() %} 18 | WHERE block_timestamp >= getdate() - INTERVAL '5 days' 19 | {% endif %} 20 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__errata_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'errata_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.asset_e8, 12 | e.rune_e8, 13 | e.in_tx, 14 | e.asset 15 | FROM 16 | {{ ref('silver_thorchain__errata_events') }} 17 | e 18 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 19 | bl 20 | ON bl.timestamp = e.block_timestamp 21 | 22 | -------------------------------------------------------------------------------- /models/terra/secure_views/terra_sv__transactions.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | secure = 'true', 4 | tags = ['snowflake', 'terra_views', 'transactions', 'terra', 'secure_views'] 5 | ) }} 6 | 7 | SELECT 8 | block_id, 9 | block_timestamp, 10 | blockchain, 11 | chain_id, 12 | tx_id, 13 | tx_from, 14 | tx_to, 15 | tx_type, 16 | tx_status, 17 | tx_status_msg, 18 | tx_code, 19 | tx_module, 20 | codespace, 21 | fee, 22 | gas_used, 23 | gas_wanted 24 | FROM 25 | {{ ref('silver_terra__transactions') }} 26 | -------------------------------------------------------------------------------- /models/terra/silver/silver_terra__token_contracts.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'incremental', 3 | unique_key = "token_contract", 4 | incremental_strategy = 'merge', 5 | ) }} 6 | 7 | SELECT 8 | event_attributes :contract_address :: STRING AS token_contract, 9 | 'WORMHOLE' AS description, 10 | SYSDATE() AS _inserted_timestamp 11 | FROM 12 | {{ ref("silver_terra__msg_events") }} 13 | WHERE 14 | event_attributes :creator = 'terra10nmmwe8r3g99a9newtqa7a75xfgs2e8z87r2sf' --wormhole contracts 15 | AND block_timestamp > '2021-06-01' 16 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__block_pool_depths.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'block_pool_depths'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__block_pool_depths') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY pool, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | AND __HEVO_loaded_at >= ( 16 | SELECT 17 | MAX(__HEVO_loaded_at) 18 | FROM 19 | {{ this }} 20 | ) 21 | {% endif %} 22 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__application_call_transaction.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'application_call_transaction', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | block_timestamp, 8 | intra, 9 | block_id, 10 | tx_group_id, 11 | tx_id, 12 | inner_tx, 13 | sender, 14 | fee, 15 | app_id, 16 | tx_type, 17 | tx_type_name, 18 | genesis_hash, 19 | tx_message, 20 | extra 21 | FROM 22 | {{ ref('silver_algorand__application_call_transaction') }} 23 | -------------------------------------------------------------------------------- /models/gold/gold__flow_daily_balances_dedupped.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | models: 4 | - name: gold__flow_daily_balances_dedupped 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | combination_of_columns: 8 | - DATE 9 | - CURRENCY 10 | - ADDRESS 11 | - BALANCE_TYPE 12 | columns: 13 | - name: "BALANCE" 14 | - name: "DATE" 15 | tests: 16 | - not_null 17 | - name: "ADDRESS" 18 | - name: "CURRENCY" 19 | - name: "ADDRESS_LABEL_SUBTYPE" -------------------------------------------------------------------------------- /models/gold/gold__flow_delegator_addresses.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | models: 4 | - name: gold__flow_delegator_addresses 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | combination_of_columns: 8 | - BLOCK_ID 9 | - TX_ID 10 | - NODE_ID 11 | columns: 12 | - name: "NODE_ID" 13 | - name: "BLOCK_ID" 14 | - name: "TX_ID" 15 | - name: "DELEGATOR_ADDRESS" 16 | - name: "BLOCK_TIMESTAMP" 17 | tests: 18 | - not_null 19 | - name: "DELEGATOR_ID" -------------------------------------------------------------------------------- /models/algorand/silver/silver_algorand__app.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_algorand__app 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - APP_ID 8 | columns: 9 | - name: APP_ID 10 | tests: 11 | - not_null 12 | - name: CREATOR_ADDRESS 13 | tests: 14 | - not_null 15 | - name: APP_CLOSED 16 | tests: 17 | - not_null 18 | - name: CREATED_AT 19 | tests: 20 | - not_null -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__block_log.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_thorchain__block_log 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - HEIGHT 8 | - TIMESTAMP 9 | - HASH 10 | - AGG_STATE 11 | columns: 12 | - name: TIMESTAMP 13 | tests: 14 | - not_null 15 | - name: HEIGHT 16 | tests: 17 | - not_null 18 | - name: HASH 19 | tests: 20 | - not_null -------------------------------------------------------------------------------- /models/consoles/terra/consoles_terra__luna_staked_supply_usd.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | unique_key = 'date', 4 | tags = ['snowflake', 'terra', 'console'] 5 | ) }} 6 | 7 | SELECT 8 | DATE, 9 | SUM(balance_usd) AS staked_supply_usd 10 | FROM 11 | {{ ref('terra__daily_balances') }} 12 | WHERE 13 | currency = 'LUNA' 14 | AND balance_type = 'staked' 15 | AND address <> 'terra1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3nln0mh' -- excluding terra foundation address 16 | GROUP BY 17 | DATE 18 | ORDER BY 19 | DATE DESC 20 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__rewards_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'rewards_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__rewards_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/algorand/api/silver_algorand__get_tx.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view' 3 | ) }} 4 | 5 | WITH tx AS ( 6 | 7 | SELECT 8 | sender AS account_id, 9 | tx_id 10 | FROM 11 | {{ ref("silver_algorand__transactions") }} 12 | WHERE 13 | block_timestamp :: DATE > '2022-07-27' qualify (ROW_NUMBER() over (PARTITION BY tx_id 14 | ORDER BY 15 | sender)) = 1 16 | ) 17 | SELECT 18 | account_id, 19 | tx_id 20 | FROM 21 | tx 22 | EXCEPT 23 | SELECT 24 | account_id, 25 | tx_id 26 | FROM 27 | {{ ref("silver_algorand__indexer_tx") }} 28 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__daily_balances.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'incremental', 3 | unique_key = "CONCAT_WS('-', date, address)", 4 | incremental_strategy = 'delete+insert', 5 | cluster_by = ['date'] 6 | ) }} 7 | 8 | SELECT 9 | address, 10 | DATE, 11 | balance 12 | FROM 13 | {{ ref('silver_algorand__daily_balances') }} 14 | WHERE 15 | balance > 0 16 | 17 | {% if is_incremental() %} 18 | AND DATE >=( 19 | SELECT 20 | DATEADD('day', -2, MAX(DATE)) 21 | FROM 22 | {{ this }}) 23 | {% endif %} 24 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__payment_transaction.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'payment_transaction', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | block_timestamp, 8 | intra, 9 | block_id, 10 | tx_group_id, 11 | tx_id, 12 | inner_tx, 13 | asset_id, 14 | sender, 15 | receiver, 16 | amount, 17 | fee, 18 | tx_type, 19 | tx_type_name, 20 | genesis_hash, 21 | tx_message, 22 | extra 23 | FROM 24 | {{ ref('silver_algorand__payment_transaction') }} 25 | -------------------------------------------------------------------------------- /models/flow/silver/silver_flow__daily_balances.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | models: 4 | - name: silver_flow__daily_balances 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | combination_of_columns: 8 | - DATE 9 | - CURRENCY 10 | - ADDRESS 11 | - BALANCE_TYPE 12 | columns: 13 | - name: "DATE" 14 | tests: 15 | - not_null 16 | - name: "CURRENCY" 17 | - name: "BALANCE_TYPE" 18 | - name: "ADDRESS" 19 | - name: "BLOCKCHAIN" 20 | - name: "BALANCE" -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__gas_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'gas_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__gas_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, asset, tx_count, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__pool_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'pool_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__pool_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, asset, status, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__errata_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'errata_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__errata_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, in_tx, asset, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__set_mimir_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'set_mimir_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__set_mimir_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, key, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__transfers.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'transactions', 'transfers', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | block_timestamp, 8 | intra, 9 | block_id, 10 | tx_group_id, 11 | tx_id, 12 | inner_tx, 13 | asset_sender, 14 | tx_sender, 15 | receiver, 16 | asset_id, 17 | amount, 18 | fee, 19 | tx_type, 20 | tx_type_name, 21 | genesis_hash, 22 | tx_message, 23 | extra 24 | FROM 25 | {{ ref('silver_algorand__transfers') }} 26 | -------------------------------------------------------------------------------- /models/algorand/silver/silver_algorand__asset.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_algorand__asset 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - ASSET_ID 8 | columns: 9 | - name: ASSET_ID 10 | tests: 11 | - not_null 12 | - name: CREATOR_ADDRESS 13 | tests: 14 | - not_null 15 | - name: ASSET_DELETED 16 | tests: 17 | - not_null 18 | - name: CREATED_AT 19 | tests: 20 | - not_null 21 | -------------------------------------------------------------------------------- /models/gold/gold__near_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: gold__near_events 4 | description: Near emitted events 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | # XXX: The original Redshift query produces duplicate rows. 8 | # This isn't the PK of the table. 9 | config: 10 | enabled: false 11 | combination_of_columns: 12 | - BLOCKCHAIN 13 | - BLOCK_NUMBER 14 | - TX_ID 15 | - TX_FROM 16 | - TX_TO 17 | - EVENT_TYPE 18 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__transfer_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'transfer_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.asset, 12 | e.amount_e8, 13 | e.from_addr AS from_address, 14 | e.to_addr AS to_address 15 | FROM 16 | {{ ref('silver_thorchain__transfer_events') }} 17 | e 18 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 19 | bl 20 | ON bl.timestamp = e.block_timestamp 21 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__new_node_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'new_node_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__new_node_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, node_addr, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/ethereum/nft/ethereum__nft_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: ethereum__nft_events 4 | description: Deprecating soon - please migrate query to ethereum database by 9/13 5 | # tests: 6 | # - dbt_utils.unique_combination_of_columns: 7 | # combination_of_columns: 8 | # - TX_ID 9 | # - TOKEN_ID 10 | columns: 11 | - name: BLOCK_TIMESTAMP 12 | tests: 13 | - not_null 14 | - dbt_expectations.expect_row_values_to_have_recent_data: 15 | datepart: day 16 | interval: 3 -------------------------------------------------------------------------------- /models/terra/silver/silver_terra__contract_metadata.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_terra__contract_metadata 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - CONTRACT_ADDRESS 8 | columns: 9 | - name: BLOCK_TIMESTAMP 10 | tests: 11 | - not_null 12 | - name: TX_ID 13 | tests: 14 | - not_null 15 | - name: CONTRACT_ADDRESS 16 | tests: 17 | - not_null 18 | - name: IS_WORMHOLE 19 | tests: 20 | - not_null -------------------------------------------------------------------------------- /macros/tests/all_ids_exist.sql: -------------------------------------------------------------------------------- 1 | {% macro all_ids_exist( 2 | base_table, 3 | base_id, 4 | other_table, 5 | other_id 6 | ) %} 7 | WITH base AS ( 8 | SELECT 9 | DISTINCT {{ base_id }} AS id 10 | FROM 11 | {{ base_table }} 12 | ), other AS ( 13 | SELECT 14 | DISTINCT {{ other_id }} AS id 15 | FROM 16 | {{ other_table }} 17 | ) 18 | SELECT b.* 19 | FROM 20 | base b 21 | LEFT JOIN 22 | other o 23 | ON o.id = b.id 24 | WHERE o.id IS NULL 25 | {% endmacro %} 26 | -------------------------------------------------------------------------------- /models/solana/gold/solana__fact_votes_agg_block.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: solana__fact_votes_agg_block 4 | description: deprecating soon - please migrate query to solana database by changing 'from' statements from `flipside_prod_db.solana.
` to `solana.core.
` 5 | columns: 6 | - name: BLOCK_TIMESTAMP 7 | description: "{{ doc('solana_block_timestamp') }}" 8 | - name: BLOCK_ID 9 | description: "{{ doc('solana_block_id') }}" 10 | - name: NUM_VOTES 11 | description: The number of vote events that occurred within the block -------------------------------------------------------------------------------- /models/terra/terra_scored/terra_scored__contract_metadata.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: terra_scored__contract_metadata 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - CONTRACT_ADDRESS 8 | columns: 9 | - name: BLOCK_TIMESTAMP 10 | tests: 11 | - not_null 12 | - name: TX_ID 13 | tests: 14 | - not_null 15 | - name: CONTRACT_ADDRESS 16 | tests: 17 | - not_null 18 | - name: IS_WORMHOLE 19 | tests: 20 | - not_null -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__fee_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'fee_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__fee_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, asset, asset_e8, pool_deduct, block_timestamp, tx 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__switch_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_thorchain__switch_events 4 | columns: 5 | - name: BLOCK_TIMESTAMP 6 | tests: 7 | - not_null 8 | - name: TO_ADDR 9 | tests: 10 | - not_null 11 | - name: BURN_ASSET 12 | tests: 13 | - not_null 14 | - name: FROM_ADDR 15 | tests: 16 | - not_null 17 | - name: BURN_E8 18 | tests: 19 | - not_null 20 | - name: MINT_E8 21 | tests: 22 | - not_null 23 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__asset_freeze_transaction.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'asset_freeze_transaction', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | block_timestamp, 8 | intra, 9 | block_id, 10 | tx_group_id, 11 | tx_id, 12 | inner_tx, 13 | asset_id, 14 | asset_address, 15 | asset_freeze, 16 | sender, 17 | fee, 18 | tx_type, 19 | tx_type_name, 20 | genesis_hash, 21 | tx_message, 22 | extra 23 | FROM 24 | {{ ref('silver_algorand__asset_freeze_transaction') }} 25 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__inactive_vault_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'gas_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__inactive_vault_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, add_asgard_addr, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__rewards_event_entries.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'rewards_event_entries'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__rewards_event_entries') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, pool, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/ethereum/silver/silver_ethereum__events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_ethereum__events 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - BLOCK_ID 8 | - COALESCE(LOG_INDEX, -1) 9 | - TX_HASH 10 | - FROM_UK 11 | - TO_UK 12 | columns: 13 | - name: BLOCK_TIMESTAMP 14 | tests: 15 | - not_null 16 | - dbt_expectations.expect_row_values_to_have_recent_data: 17 | datepart: day 18 | interval: 1 19 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__active_vault_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'active_vault_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__active_vault_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, add_asgard_addr, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO__LOADED_AT >= ( 17 | SELECT 18 | MAX(__HEVO__LOADED_AT) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__set_version_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'set_version_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__set_version_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, node_addr, block_timestamp, version 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/terra/secure_views/terra_sv__labels.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: terra_sv__labels 4 | columns: 5 | - name: ADDRESS 6 | tests: 7 | - not_null 8 | - dbt_expectations.expect_column_values_to_match_regex: 9 | regex: terra[0-9a-z]{39,39} 10 | - name: BLOCKCHAIN 11 | tests: 12 | - not_null 13 | - name: LABEL 14 | tests: 15 | - not_null 16 | - name: LABEL_SUBTYPE 17 | tests: 18 | - not_null 19 | - name: LABEL_TYPE 20 | tests: 21 | - not_null 22 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__rewards_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'rewards_events'] 4 | ) }} 5 | 6 | SELECT 7 | DISTINCT TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.bond_e8 12 | FROM 13 | {{ ref('silver_thorchain__rewards_events') }} 14 | e 15 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 16 | bl 17 | ON bl.timestamp = e.block_timestamp 18 | {% if is_incremental() %} 19 | WHERE e.block_timestamp >= getdate() - INTERVAL '5 days' 20 | {% endif %} -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__switch_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'switch_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.burn_asset, 12 | e.burn_e8, 13 | e.mint_e8, 14 | e.to_addr AS to_address, 15 | e.from_addr AS from_address, 16 | e.tx 17 | FROM 18 | {{ ref('silver_thorchain__switch_events') }} 19 | e 20 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 21 | bl 22 | ON bl.timestamp = e.block_timestamp 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__add_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'add_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__add_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, tx, chain, from_addr, to_addr, asset, memo, pool, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO__LOADED_AT >= ( 17 | SELECT 18 | MAX(__HEVO__LOADED_AT) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__set_ip_address_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'set_ip_address_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__set_ip_address_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, ip_addr, block_timestamp, node_addr 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__switch_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'switch_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__switch_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY tx, from_addr, to_addr, burn_asset, burn_e8, mint_e8, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__transfer_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'transfer_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__transfer_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, from_addr, to_addr, asset, amount_e8, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__set_mimir_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'set_mimir_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.key, 12 | e.value 13 | FROM 14 | {{ ref('silver_thorchain__set_mimir_events') }} 15 | e 16 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 17 | bl 18 | ON bl.timestamp = e.block_timestamp 19 | {% if is_incremental() %} 20 | WHERE e.block_timestamp >= getdate() - INTERVAL '5 days' 21 | {% endif %} -------------------------------------------------------------------------------- /models/consoles/terra/consoles_terra__total_users.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'table', 3 | unique_key = 'date', 4 | incremental_strategy = 'delete+insert', 5 | cluster_by = ['date'], 6 | tags = ['snowflake', 'terra', 'console', 'terra_total_users'] 7 | ) }} 8 | 9 | SELECT 10 | date, 11 | COUNT(DISTINCT address) as total_users 12 | FROM {{ ref('terra__daily_balances') }} 13 | WHERE date >= CURRENT_DATE - 30 14 | 15 | {% if is_incremental() %} 16 | AND block_timestamp :: DATE >= (SELECT MAX( block_timestamp :: DATE )FROM {{ ref('silver_terra__msgs') }}) 17 | {% endif %} 18 | 19 | GROUP BY 1 -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__bond_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'bond_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__bond_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY tx, from_addr, asset_e8, bond_type, e8, block_timestamp, to_addr, chain, asset, memo 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__pool_balance_change_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'pool_balance_change_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__pool_balance_change_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, asset, reason, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__reserve_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'reserve_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__reserve_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, tx, chain, from_addr, to_addr, asset, memo, addr, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__asset_configuration_transaction.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'asset_configuration_transaction', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | block_timestamp, 8 | intra, 9 | block_id, 10 | tx_group_id, 11 | tx_id, 12 | inner_tx, 13 | asset_id, 14 | asset_supply, 15 | sender, 16 | fee, 17 | asset_parameters, 18 | tx_type, 19 | tx_type_name, 20 | genesis_hash, 21 | tx_message, 22 | extra 23 | FROM 24 | {{ ref('silver_algorand__asset_configuration_transaction') }} 25 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__pool_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'pool_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.asset, 12 | e.status 13 | FROM 14 | {{ ref('silver_thorchain__pool_events') }} 15 | e 16 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 17 | bl 18 | ON bl.timestamp = e.block_timestamp 19 | 20 | {% if is_incremental() %} 21 | WHERE 22 | e.block_timestamp >= getdate() - INTERVAL '5 days' 23 | {% endif %} 24 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__outbound_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'outbound_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__outbound_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, tx, chain, from_addr, to_addr, asset, memo, in_tx, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__active_vault_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'active_vault_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.add_asgard_addr 12 | FROM 13 | {{ ref('silver_thorchain__active_vault_events') }} 14 | e 15 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 16 | bl 17 | ON bl.timestamp = e.block_timestamp 18 | 19 | {% if is_incremental() %} 20 | WHERE e.block_timestamp >= getdate() - INTERVAL '5 days' 21 | {% endif %} -------------------------------------------------------------------------------- /models/consoles/terra/consoles_terra__daily_swap_new_users.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'terra', 'console', 'terra_daily_swap_new_users'] 4 | ) }} 5 | 6 | SELECT 7 | DATE_TRUNC( 8 | 'day', 9 | block_timestamp 10 | ) AS block_day, 11 | COUNT(DISTINCT(msg_value :sender :: STRING)) AS sender 12 | FROM 13 | {{ ref('terra__msgs') }} 14 | WHERE 15 | msg_value :contract = 'terra1tndcaqxkpc5ce9qee5ggqf430mr2z3pefe5wj6' 16 | AND DATE_TRUNC( 17 | 'day', 18 | block_timestamp 19 | ) >= '2021-01-01' 20 | GROUP BY 21 | block_day 22 | ORDER BY 23 | block_day DESC 24 | -------------------------------------------------------------------------------- /models/ethereum/ethereum__token_prices_hourly.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: ethereum__token_prices_hourly 4 | description: Deprecating soon - please migrate query to ethereum database by 9/13 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | combination_of_columns: 8 | - HOUR 9 | - TOKEN_ADDRESS 10 | columns: 11 | - name: HOUR 12 | tests: 13 | - dbt_expectations.expect_row_values_to_have_recent_data: 14 | datepart: day 15 | interval: 1 16 | - name: PRICE 17 | tests: 18 | - not_null -------------------------------------------------------------------------------- /models/terra/gold/terra__tax_rate.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'incremental', 3 | sort = 'block_timestamp', 4 | unique_key = "CONCAT_WS('-', block_number)", 5 | incremental_strategy = 'delete+insert', 6 | cluster_by = ['block_timestamp::DATE'], 7 | tags = ['snowflake', 'terra', 'tax_rate'] 8 | ) }} 9 | 10 | SELECT 11 | chain_id AS blockchain, 12 | block_timestamp, 13 | block_number, 14 | tax_rate 15 | FROM 16 | {{ ref( 17 | 'silver_terra__tax_rate' 18 | ) }} 19 | WHERE 20 | 1 = 1 21 | 22 | {% if is_incremental() %} 23 | AND block_timestamp >= getdate() - INTERVAL '1 days' 24 | {% endif %} 25 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__refund_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'refund_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__refund_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, tx, chain, from_addr, to_addr, asset, asset_2nd, memo, code, reason, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/consoles/terra/consoles_terra__circulating_supply.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | unique_key = "CONCAT_WS('-', metric_date, currency)", 4 | tags = ['snowflake', 'terra', 'balances', 'console', 'circulating_supply'] 5 | ) }} 6 | 7 | SELECT 8 | DATE_TRUNC( 9 | 'day', 10 | DATE 11 | ) AS metric_date, 12 | currency, 13 | SUM(balance) AS total_balance 14 | FROM 15 | {{ ref('terra__daily_balances') }} 16 | WHERE 17 | currency IN( 18 | 'KRT', 19 | 'LUNA', 20 | 'SDT', 21 | 'UST' 22 | ) 23 | GROUP BY 24 | metric_date, 25 | currency 26 | ORDER BY 27 | metric_date DESC 28 | -------------------------------------------------------------------------------- /models/ethereum/ethereum__reads.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: ethereum__reads 4 | description: Deprecating soon - please migrate query to ethereum database by 9/13 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | combination_of_columns: 8 | - BLOCK_ID 9 | - CONTRACT_ADDRESS 10 | - FUNCTION_NAME 11 | - INPUTS 12 | columns: 13 | - name: BLOCK_TIMESTAMP 14 | tests: 15 | - not_null 16 | - dbt_expectations.expect_row_values_to_have_recent_data: 17 | datepart: day 18 | interval: 1 -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__slash_amounts.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'slash_amounts'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.asset_e8, 12 | e.pool AS pool_name, 13 | e.asset 14 | FROM 15 | {{ ref('silver_thorchain__slash_amounts') }} 16 | e 17 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 18 | bl 19 | ON bl.timestamp = e.block_timestamp 20 | {% if is_incremental() %} 21 | WHERE e.block_timestamp >= getdate() - INTERVAL '5 days' 22 | {% endif %} -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__set_node_keys_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'set_node_keys_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__set_node_keys_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, node_addr, secp256k1, ed25519, block_timestamp, validator_consensus 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__stake_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'stake_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__stake_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, pool, rune_tx, asset_chain, stake_units, rune_addr, asset_tx, asset_addr, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__swap_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'swap_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__swap_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, tx, chain, to_addr, from_addr, from_asset, from_e8, to_asset, to_e8, memo, pool, _direction 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/consoles/terra/consoles_terra__ust_peg_variance.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | unique_key = "CONCAT_WS('-', METRIC_DATE, currency)", 4 | tags = ['snowflake', 'terra', 'console'] 5 | ) }} 6 | 7 | SELECT 8 | DATE_TRUNC( 9 | 'day', 10 | block_timestamp 11 | ) AS metric_date, 12 | currency, 13 | symbol, 14 | AVG(price_usd) AS "AVG" 15 | FROM 16 | {{ ref('terra__oracle_prices') }} 17 | WHERE 18 | block_timestamp :: DATE > CURRENT_DATE - 180 19 | AND symbol = 'UST' 20 | AND price_usd > 0 21 | GROUP BY 22 | metric_date, 23 | currency, 24 | symbol 25 | ORDER BY 26 | metric_date DESC 27 | -------------------------------------------------------------------------------- /models/terra/gold/terra__event_actions.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'terra_views', 'event_actions', 'terra'] 4 | ) }} 5 | 6 | SELECT 7 | block_id, 8 | block_timestamp, 9 | a.blockchain, 10 | chain_id, 11 | tx_id, 12 | action_index, 13 | msg_index, 14 | action_contract_address, 15 | l.address_name AS contract_label, 16 | action_method, 17 | action_log 18 | FROM 19 | {{ ref('silver_terra__event_actions') }} a 20 | LEFT OUTER JOIN {{ ref('silver_crosschain__address_labels') }} AS l 21 | ON action_contract_address = l.address AND l.blockchain = 'terra' AND l.creator = 'flipside' -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__set_version_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'set_version_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.node_addr AS node_address, 12 | e.version 13 | FROM 14 | {{ ref('silver_thorchain__set_version_events') }} 15 | e 16 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 17 | bl 18 | ON bl.timestamp = e.block_timestamp 19 | {% if is_incremental() %} 20 | WHERE e.block_timestamp >= getdate() - INTERVAL '5 days' 21 | {% endif %} -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__asgard_fund_yggdrasil_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'asgard_fund_yggdrasil_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__asgard_fund_yggdrasil_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, tx, asset, asset_e8, vault_key, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO__LOADED_AT >= ( 17 | SELECT 18 | MAX(__HEVO__LOADED_AT) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__validator_request_leave_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'validator_request_leave_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__validator_request_leave_events') }} 10 | e qualify(ROW_NUMBER() over(PARTITION BY event_id, tx, block_timestamp, from_addr, node_addr 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/algorand/silver/silver_algorand__indexer_tx.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_algorand__indexer_tx 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - tx_id 8 | columns: 9 | - name: TX_ID 10 | tests: 11 | - not_null 12 | - name: ACCOUNT_ID 13 | tests: 14 | - not_null 15 | - name: BLOCK_ID 16 | tests: 17 | - not_null 18 | - name: DATA 19 | tests: 20 | - not_null 21 | - name: _INSERTED_TIMESTAMP 22 | tests: 23 | - not_null 24 | 25 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__gas_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'gas_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.rune_e8, 12 | e.tx_count, 13 | e.asset_e8, 14 | e.asset 15 | FROM 16 | {{ ref('silver_thorchain__gas_events') }} 17 | e 18 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 19 | bl 20 | ON bl.timestamp = e.block_timestamp 21 | 22 | {% if is_incremental() %} 23 | WHERE e.block_timestamp >= getdate() - INTERVAL '5 days' 24 | {% endif %} -------------------------------------------------------------------------------- /macros/uniswap_math.sql: -------------------------------------------------------------------------------- 1 | {% macro uni_math_tick_to_price_1_0(decimals0, decimals1, tick) -%} 2 | CASE 3 | WHEN {{decimals0}} IS NULL OR {{decimals1}} IS NULL OR {{tick}} IS NULL THEN NULL 4 | -- We want a positive exponent 5 | ELSE pow(1.0001, {{tick}}) / pow(10, {{decimals1}} - {{decimals0}}) 6 | END 7 | {%- endmacro %} 8 | 9 | {% macro uni_math_tick_to_price_0_1(decimals0, decimals1, tick) -%} 10 | CASE 11 | WHEN {{decimals0}} IS NULL OR {{decimals1}} IS NULL OR {{tick}} IS NULL THEN NULL 12 | -- We want a negative exponent 13 | ELSE pow(pow(1.0001, {{tick}}) / pow(10, {{decimals1}} - {{decimals0}}),-1) 14 | END 15 | {%- endmacro %} -------------------------------------------------------------------------------- /models/algorand/gold/algorand__asset_transfer_transaction.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'asset_transfer_transaction', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | block_timestamp, 8 | intra, 9 | block_id, 10 | tx_group_id, 11 | tx_id, 12 | inner_tx, 13 | asset_id, 14 | sender, 15 | fee, 16 | asset_sender, 17 | asset_receiver, 18 | asset_amount, 19 | asset_transferred, 20 | tx_type, 21 | tx_type_name, 22 | genesis_hash, 23 | tx_message, 24 | extra 25 | FROM 26 | {{ ref('silver_algorand__asset_transfer_transaction') }} 27 | -------------------------------------------------------------------------------- /models/ethereum/aave/silver__aave_liquidity_mining.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver__aave_liquidity_mining 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - BLOCKHOUR 8 | - TOKEN_ADDRESS 9 | columns: 10 | - name: BLOCKHOUR 11 | tests: 12 | - not_null 13 | - dbt_expectations.expect_row_values_to_have_recent_data: 14 | datepart: day 15 | interval: 1 16 | - name: TOKEN_ADDRESS 17 | tests: 18 | - not_null 19 | - name: EMISSIONPERSECOND 20 | - not_null -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__pool_balance_change_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'pool_balance_change_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.reason, 12 | e.asset, 13 | e.rune_amt AS rune_amount, 14 | e.asset_add, 15 | e.asset_amt AS asset_amount, 16 | e.rune_add 17 | FROM 18 | {{ ref('silver_thorchain__pool_balance_change_events') }} 19 | e 20 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 21 | bl 22 | ON bl.timestamp = e.block_timestamp 23 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__rewards_event_entries.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'rewards_event_entries'] 4 | ) }} 5 | 6 | SELECT 7 | DISTINCT TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.pool AS pool_name, 12 | e.rune_e8 13 | FROM 14 | {{ ref('silver_thorchain__rewards_event_entries') }} 15 | e 16 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 17 | bl 18 | ON bl.timestamp = e.block_timestamp 19 | {% if is_incremental() %} 20 | WHERE e.block_timestamp >= getdate() - INTERVAL '5 days' 21 | {% endif %} -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__set_ip_address_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'set_ip_address_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.ip_addr, 12 | e.node_addr AS node_address 13 | FROM 14 | {{ ref('silver_thorchain__set_ip_address_events') }} 15 | e 16 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 17 | bl 18 | ON bl.timestamp = e.block_timestamp 19 | {% if is_incremental() %} 20 | WHERE e.block_timestamp >= getdate() - INTERVAL '5 days' 21 | {% endif %} -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__thorname_change_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'thorname_change_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.owner, 12 | e.chain, 13 | e.address, 14 | e.expire, 15 | e.name, 16 | e.fund_amount_e8, 17 | e.registration_fee_e8 18 | FROM 19 | {{ ref( 20 | 'silver_thorchain__thorname_change_events' 21 | ) }} 22 | e 23 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 24 | bl 25 | ON bl.timestamp = e.block_timestamp 26 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__update_node_account_status_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'update_node_account_status_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__update_node_account_status_events') }} 10 | e qualify(ROW_NUMBER() over(PARTITION BY node_addr, block_timestamp, former, current_flag 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /models/terra/silver/silver_terra__tax_rate.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_terra__tax_rate 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - BLOCK_NUMBER 8 | columns: 9 | - name: CHAIN_ID 10 | tests: 11 | - not_null 12 | - name: BLOCK_NUMBER 13 | tests: 14 | - not_null 15 | - unique 16 | - name: BLOCK_TIMESTAMP 17 | tests: 18 | - not_null 19 | - dbt_expectations.expect_row_values_to_have_recent_data: 20 | datepart: day 21 | interval: 1 22 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__fee_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'fee_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.tx AS tx_id, 12 | e.asset, 13 | e.pool_deduct, 14 | e.asset_e8 15 | FROM 16 | {{ ref('silver_thorchain__fee_events') }} 17 | e 18 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 19 | bl 20 | ON bl.timestamp = e.block_timestamp 21 | 22 | {% if is_incremental() %} 23 | WHERE e.block_timestamp >= getdate() - INTERVAL '5 days' 24 | {% endif %} -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/add-a-new-table-or-view.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Add a new table or view 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Table name 11 | 12 | What is the goal of the table or what does this add? 13 | 14 | What is the cadence of refresh this table needs? 15 | 16 | Is this a protocol specific table? 17 | [x] yes [x] no 18 | If yes: 19 | What are the relative contract addresses: 20 | 21 | What are the event Types? ie: OpenSea orders matched event name 22 | 23 | 24 | SQL query: 25 | Please add comments and relevant information for context in reviewing your code 26 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__key_registration_transaction.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'key_registration_transaction', 'gold'], 4 | ) }} 5 | 6 | SELECT 7 | block_timestamp, 8 | intra, 9 | block_id, 10 | tx_group_id, 11 | tx_id, 12 | inner_tx, 13 | sender, 14 | fee, 15 | participation_key, 16 | vrf_public_key, 17 | vote_first, 18 | vote_last, 19 | vote_keydilution, 20 | tx_type, 21 | tx_type_name, 22 | genesis_hash, 23 | tx_message, 24 | extra 25 | FROM 26 | {{ ref('silver_algorand__key_registration_transaction') }} 27 | -------------------------------------------------------------------------------- /models/algorand/silver/silver_algorand__nft_asset.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_algorand__nft_asset 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - NFT_ASSET_ID 8 | columns: 9 | - name: NFT_ASSET_ID 10 | tests: 11 | - not_null 12 | - name: DECIMALS 13 | tests: 14 | - not_null 15 | - name: CREATED_AT 16 | tests: 17 | - not_null 18 | - name: CREATOR_ADDRESS 19 | tests: 20 | - not_null 21 | - name: ASSET_DELETED 22 | tests: 23 | - not_null 24 | -------------------------------------------------------------------------------- /macros/safe_balances.sql: -------------------------------------------------------------------------------- 1 | {% macro safe_ethereum_balances(src_balances_table, incremental_days = '30 days', full_refresh_days = '9 months') -%} 2 | 3 | SELECT * 4 | FROM 5 | ( 6 | SELECT 7 | *, 8 | row_number() OVER (PARTITION BY balance_date, address, contract_address, symbol ORDER BY balance_date DESC) AS rn 9 | FROM {{ src_balances_table }} 10 | WHERE 11 | {% if is_incremental() %} 12 | balance_date >= getdate() - interval '{{incremental_days}}' 13 | {% else %} 14 | balance_date >= getdate() - interval '{{full_refresh_days}}' 15 | {% endif %} 16 | ) sq 17 | WHERE 18 | sq.rn = 1 19 | 20 | {%- endmacro %} -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__unstake_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'unstake_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref( 10 | 'thorchain_dbt__unstake_events' 11 | ) }} 12 | e qualify(ROW_NUMBER() over(PARTITION BY event_id, tx, chain, memo, stake_units, basis_points, block_timestamp, pool, asset, from_addr, to_addr 13 | ORDER BY 14 | __HEVO__INGESTED_AT DESC)) = 1 15 | 16 | {% if is_incremental() %} 17 | WHERE 18 | __HEVO_loaded_at >= ( 19 | SELECT 20 | MAX(__HEVO_loaded_at) 21 | FROM 22 | {{ this }} 23 | ) 24 | {% endif %} 25 | -------------------------------------------------------------------------------- /models/consoles/terra/consoles_terra__transactions_per_token.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'terra', 'console', 'terra_transactions_per_token'] 4 | ) }} 5 | 6 | SELECT 7 | block_timestamp :: DATE AS metric_date, 8 | event_currency AS currency, 9 | COUNT( 10 | DISTINCT tx_id 11 | ) AS metric_value 12 | FROM 13 | {{ ref('terra__transfers') }} 14 | WHERE 15 | event_currency IN( 16 | 'KRT', 17 | 'LUNA', 18 | 'SDT', 19 | 'UST' 20 | ) 21 | AND block_timestamp :: DATE >= CURRENT_DATE - 180 22 | GROUP BY 23 | metric_date, 24 | currency 25 | ORDER BY 26 | metric_date DESC, 27 | currency DESC 28 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__outbound_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'outbound_events'] 4 | ) }} 5 | 6 | SELECT 7 | DISTINCT TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.tx AS tx_id, 12 | e.asset, 13 | e.to_addr AS to_address, 14 | e.from_addr AS from_address, 15 | e.memo, 16 | e.asset_e8, 17 | e.chain AS blockchain, 18 | e.in_tx 19 | FROM 20 | {{ ref('silver_thorchain__outbound_events') }} 21 | e 22 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 23 | bl 24 | ON bl.timestamp = e.block_timestamp 25 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__pending_liquidity_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'silver_thorchain', 'pending_liquidity_events'] 4 | ) }} 5 | 6 | SELECT 7 | * 8 | FROM 9 | {{ ref('thorchain_dbt__pending_liquidity_events') }} 10 | qualify(ROW_NUMBER() over(PARTITION BY event_id, pool, asset_tx, asset_chain, asset_addr, rune_tx, rune_addr, pending_type, block_timestamp 11 | ORDER BY 12 | __HEVO__INGESTED_AT DESC)) = 1 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | __HEVO_loaded_at >= ( 17 | SELECT 18 | MAX(__HEVO_loaded_at) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | -------------------------------------------------------------------------------- /macros/algorand/sp_bulk_get_contract_info.sql: -------------------------------------------------------------------------------- 1 | {% macro create_algorand_sp_bulk_get_contract_info() %} 2 | {% set sql %} 3 | CREATE 4 | OR REPLACE PROCEDURE silver_algorand.sp_bulk_get_tx() returns variant LANGUAGE SQL AS $$ 5 | DECLARE 6 | RESULT variant; 7 | row_cnt INTEGER; 8 | BEGIN 9 | row_cnt:= ( 10 | SELECT 11 | COUNT(1) 12 | FROM 13 | {{ ref('silver_algorand__get_tx') }} 14 | ); 15 | if ( 16 | row_cnt > 0 17 | ) THEN RESULT:= ( 18 | SELECT 19 | silver_algorand.udf_bulk_get_tx() 20 | ); 21 | ELSE RESULT:= NULL; 22 | END if; 23 | RETURN RESULT; 24 | END;$$ {% endset %} 25 | {% do run_query(sql) %} 26 | {% endmacro %} 27 | -------------------------------------------------------------------------------- /macros/custom_query_tag.sql: -------------------------------------------------------------------------------- 1 | {% macro set_query_tag() -%} 2 | {% set new_json = {"repo":project_name, "object":this.table, "profile":target.profile_name, "env":target.name, "existing_tag":get_current_query_tag() } %} 3 | {% set new_query_tag = tojson(new_json) | as_text %} 4 | {% if new_query_tag %} 5 | {% set original_query_tag = get_current_query_tag() %} 6 | {{ log("Setting query_tag to '" ~ new_query_tag ~ "'. Will reset to '" ~ original_query_tag ~ "' after materialization.") }} 7 | {% do run_query("alter session set query_tag = '{}'".format(new_query_tag)) %} 8 | {{ return(original_query_tag)}} 9 | {% endif %} 10 | {{ return(none)}} 11 | {% endmacro %} -------------------------------------------------------------------------------- /models/consoles/terra/consoles_terra__top_10_validators_by_rewards.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: consoles_terra__top_10_validators_by_rewards 4 | description: The ten validators who have earned the most LUNA staking rewards 5 | tests: 6 | - dbt_utils.unique_combination_of_columns: 7 | combination_of_columns: 8 | - VALIDATOR 9 | - REWARD 10 | columns: 11 | - name: VALIDATOR 12 | description: Validator's LUNA address 13 | tests: 14 | - not_null 15 | - name: REWARD 16 | description: Total amount of LUNA staking rewards in USD 17 | tests: 18 | - not_null 19 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__block_pool_depths.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_thorchain__block_pool_depths 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - BLOCK_TIMESTAMP 8 | - POOL 9 | columns: 10 | - name: BLOCK_TIMESTAMP 11 | tests: 12 | - not_null 13 | - name: POOL 14 | tests: 15 | - not_null 16 | - name: ASSET_E8 17 | tests: 18 | - not_null 19 | - name: RUNE_E8 20 | tests: 21 | - not_null 22 | - name: SYNTH_E8 23 | tests: 24 | - not_null -------------------------------------------------------------------------------- /models/terra/gold/terra__tax_rate.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: terra__tax_rate 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - BLOCK_NUMBER 8 | columns: 9 | - name: BLOCKCHAIN 10 | tests: 11 | - not_null 12 | - name: BLOCK_NUMBER 13 | tests: 14 | - not_null 15 | - name: BLOCK_TIMESTAMP 16 | tests: 17 | - not_null 18 | - dbt_expectations.expect_row_values_to_have_recent_data: 19 | datepart: day 20 | interval: 1 21 | - name: TAX_RATE 22 | tests: 23 | - not_null 24 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__switch_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: thorchain__switch_events 4 | description: deprecating soon - please migrate query to database by changing 'from' statements from `flipside_prod_db..
` to .core.
schema 5 | columns: 6 | - name: BLOCK_TIMESTAMP::DATE 7 | tests: 8 | - not_null 9 | - dbt_expectations.expect_row_values_to_have_recent_data: 10 | datepart: day 11 | interval: 1 12 | - name: BLOCK_TIMESTAMP 13 | tests: 14 | - not_null 15 | - name: BLOCK_ID 16 | tests: 17 | - not_null 18 | -------------------------------------------------------------------------------- /macros/terra/sp_bulk_get_contract_info.sql: -------------------------------------------------------------------------------- 1 | {% macro sp_bulk_get_contract_info() %} 2 | {% set sql %} 3 | CREATE 4 | OR REPLACE PROCEDURE silver_terra.sp_bulk_get_contract_info() returns variant LANGUAGE SQL AS $$ 5 | DECLARE 6 | RESULT VARCHAR; 7 | row_cnt INTEGER; 8 | BEGIN 9 | row_cnt:= ( 10 | SELECT 11 | COUNT(1) 12 | FROM 13 | {{ ref('silver_terra__all_undecoded_contracts') }} 14 | ); 15 | if ( 16 | row_cnt > 0 17 | ) THEN RESULT:= ( 18 | SELECT 19 | silver_terra.udf_bulk_get_contract_info() 20 | ); 21 | ELSE RESULT:= NULL; 22 | END if; 23 | RETURN RESULT; 24 | END;$$ {% endset %} 25 | {% do run_query(sql) %} 26 | {% endmacro %} 27 | -------------------------------------------------------------------------------- /models/algorand/gold/algorand__labels.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'algorand_views', 'labels', 'algorand_labels', 'address_labels'] 4 | ) }} 5 | 6 | SELECT 7 | blockchain, 8 | creator, 9 | address, 10 | l1_label AS label_type, 11 | l2_label AS label_subtype, 12 | project_name AS label, 13 | address_name AS address_name 14 | FROM 15 | {{ ref('silver_crosschain__address_labels') }} 16 | WHERE 17 | blockchain = 'algorand' 18 | UNION 19 | SELECT 20 | blockchain, 21 | creator, 22 | address, 23 | label_type, 24 | label_subtype, 25 | label, 26 | address_name 27 | FROM 28 | {{ ref('silver_algorand__pool_addresses') }} 29 | -------------------------------------------------------------------------------- /models/terra/silver/silver_terra__blocks.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'incremental', 3 | unique_key = "CONCAT_WS('-', chain_id, block_id)", 4 | incremental_strategy = 'delete+insert', 5 | cluster_by = ['block_timestamp::DATE'], 6 | tags = ['snowflake', 'terra_silver', 'terra_blocks'] 7 | ) }} 8 | 9 | SELECT 10 | * 11 | FROM 12 | {{ ref('terra_dbt__blocks') }} 13 | 14 | {% if is_incremental() %} 15 | WHERE 16 | _inserted_timestamp >= ( 17 | SELECT 18 | MAX(_inserted_timestamp) 19 | FROM 20 | {{ this }} 21 | ) 22 | {% endif %} 23 | 24 | qualify(ROW_NUMBER() over(PARTITION BY chain_id, block_id 25 | ORDER BY 26 | system_created_at DESC)) = 1 27 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__pool_balance_change_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_thorchain__pool_balance_change_events 4 | columns: 5 | - name: BLOCK_TIMESTAMP 6 | tests: 7 | - not_null 8 | - name: ASSET 9 | tests: 10 | - not_null 11 | - name: RUNE_AMT 12 | tests: 13 | - not_null 14 | - name: RUNE_ADD 15 | tests: 16 | - not_null 17 | - name: ASSET_AMT 18 | tests: 19 | - not_null 20 | - name: ASSET_ADD 21 | tests: 22 | - not_null 23 | - name: REASON 24 | tests: 25 | - not_null 26 | 27 | -------------------------------------------------------------------------------- /models/terra/silver/silver_terra__all_undecoded_contracts.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | post_hook = "call silver_terra.sp_bulk_get_contract_info()" 4 | ) }} 5 | ( 6 | 7 | SELECT 8 | token_contract AS address 9 | FROM 10 | {{ ref("silver_terra__undecoded_oracle_contracts") }} 11 | UNION ALL 12 | SELECT 13 | token_contract AS address 14 | FROM 15 | {{ ref("silver_terra__undecoded_wormhole_contracts") }} 16 | UNION ALL 17 | SELECT 18 | token_contract AS address 19 | FROM 20 | {{ ref("silver_terra__undecoded_token_contracts") }} 21 | ) 22 | EXCEPT 23 | SELECT 24 | address 25 | FROM 26 | {{ ref("silver_terra__contract_info") }} 27 | -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__errata_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_thorchain__errata_events 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - IN_TX 8 | - ASSET 9 | - BLOCK_TIMESTAMP 10 | columns: 11 | - name: BLOCK_TIMESTAMP 12 | tests: 13 | - not_null 14 | - name: IN_TX 15 | tests: 16 | - not_null 17 | - name: ASSET 18 | tests: 19 | - not_null 20 | - name: ASSET_E8 21 | tests: 22 | - not_null 23 | - name: RUNE_E8 24 | tests: 25 | - not_null -------------------------------------------------------------------------------- /models/thorchain/silver/silver_thorchain__gas_events.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_thorchain__gas_events 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - ASSET 8 | - TX_COUNT 9 | - BLOCK_TIMESTAMP 10 | columns: 11 | - name: BLOCK_TIMESTAMP 12 | tests: 13 | - not_null 14 | - name: ASSET 15 | tests: 16 | - not_null 17 | - name: RUNE_E8 18 | tests: 19 | - not_null 20 | - name: TX_COUNT 21 | tests: 22 | - not_null 23 | - name: ASSET_E8 24 | tests: 25 | - not_null -------------------------------------------------------------------------------- /models/gold/gold__flow_daily_balances.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: gold__flow_daily_balances 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - date 8 | - node_id 9 | - address 10 | - delegator_id 11 | columns: 12 | - name: "BALANCE" 13 | - name: "DATE" 14 | - name: "DELEGATOR_ID" 15 | - name: "ADDRESS" 16 | - name: "ADDRESS_LABEL_SUBTYPE" 17 | - name: "ADDRESS_LABEL" 18 | - name: "ADDRESS_LABEL_TYPE" 19 | - name: "BALANCE_TYPE" 20 | - name: "ADDRESS_ADDRESS_NAME" 21 | - name: "CURRENCY" 22 | - name: "NODE_ID" -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__set_node_keys_events.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | tags = ['snowflake', 'thorchain', 'set_node_keys_events'] 4 | ) }} 5 | 6 | SELECT 7 | TO_TIMESTAMP( 8 | e.block_timestamp / 1000000000 9 | ) AS block_timestamp, 10 | bl.height AS block_id, 11 | e.node_addr AS node_address, 12 | e.secp256k1, 13 | e.ed25519, 14 | e.validator_consensus 15 | FROM 16 | {{ ref('silver_thorchain__set_node_keys_events') }} 17 | e 18 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 19 | bl 20 | ON bl.timestamp = e.block_timestamp 21 | {% if is_incremental() %} 22 | WHERE e.block_timestamp >= getdate() - INTERVAL '5 days' 23 | {% endif %} -------------------------------------------------------------------------------- /models/algorand/silver/silver_algorand__account_app.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | models: 3 | - name: silver_algorand__account_app 4 | tests: 5 | - dbt_utils.unique_combination_of_columns: 6 | combination_of_columns: 7 | - ADDRESS 8 | - APP_ID 9 | columns: 10 | - name: ADDRESS 11 | tests: 12 | - not_null 13 | - name: APP_ID 14 | tests: 15 | - not_null 16 | - name: APP_CLOSED 17 | tests: 18 | - not_null 19 | - name: CREATED_AT 20 | tests: 21 | - not_null 22 | - name: APP_INFO 23 | tests: 24 | - not_null: 25 | where: APP_CLOSED = FALSE -------------------------------------------------------------------------------- /models/consoles/terra/consoles_terra__staked_unstaked.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | unique_key = "CONCAT_WS('-', DAYZZ, BALANCE_TYPE)", 4 | tags = ['snowflake', 'terra', 'console'] 5 | ) }} 6 | 7 | SELECT 8 | DATE_TRUNC( 9 | 'day', 10 | DATE 11 | ) AS dayzz, 12 | SUM(balance) AS bal, 13 | SUM(balance_usd) AS balus, 14 | balance_type 15 | FROM 16 | {{ ref('terra__daily_balances') }} 17 | WHERE 18 | dayzz >= CURRENT_DATE - INTERVAL '365 days' 19 | AND currency = 'LUNA' 20 | AND address <> 'terra1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3nln0mh' 21 | GROUP BY 22 | dayzz, 23 | balance_type 24 | ORDER BY 25 | dayzz DESC 26 | -------------------------------------------------------------------------------- /models/thorchain/gold/thorchain__slash_points.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'incremental', 3 | incremental_strategy = 'delete+insert', 4 | tags = ['snowflake', 'thorchain', 'slash_points'] 5 | ) }} 6 | 7 | SELECT 8 | TO_TIMESTAMP( 9 | e.block_timestamp / 1000000000 10 | ) AS block_timestamp, 11 | bl.height AS block_id, 12 | e.node_address, 13 | e.slash_points, 14 | e.reason 15 | FROM 16 | {{ ref('silver_thorchain__slash_points') }} 17 | e 18 | INNER JOIN {{ ref('silver_thorchain__block_log') }} 19 | bl 20 | ON bl.timestamp = e.block_timestamp 21 | 22 | {% if is_incremental() %} 23 | WHERE 24 | e.block_timestamp >= getdate() - INTERVAL '5 days' 25 | {% endif %} 26 | -------------------------------------------------------------------------------- /models/consoles/terra/consoles_terra__addresses_staking_LUNA.sql: -------------------------------------------------------------------------------- 1 | {{ config( 2 | materialized = 'view', 3 | unique_key = "CONCAT_WS('-', date, addresses)", 4 | tags = ['snowflake', 'console', 'terra', 'addresses_staking_LUNA'] 5 | ) }} 6 | 7 | WITH tmp AS( 8 | 9 | SELECT 10 | DATE, 11 | address, 12 | balance 13 | FROM 14 | {{ ref('terra__daily_balances') }} 15 | WHERE 16 | balance_type = 'staked' 17 | AND currency = 'LUNA' 18 | AND DATE :: DATE >= CURRENT_DATE - 60 19 | ) 20 | SELECT 21 | DATE, 22 | COUNT( 23 | DISTINCT address 24 | ) AS addresses 25 | FROM 26 | tmp 27 | WHERE 28 | balance > 0 29 | GROUP BY 30 | DATE 31 | ORDER BY 32 | DATE DESC 33 | --------------------------------------------------------------------------------