-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
230 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
{% macro get_wallet_dex_trades(chain) %} | ||
select | ||
origin_from_address as address, | ||
count(*) number_dex_trades, | ||
count(distinct pool_name) distinct_pools, | ||
sum(amount_in_usd) total_dex_volume, | ||
avg(amount_in_usd) avg_dex_trade, | ||
count(distinct platform) distinct_dex_platforms, | ||
count(distinct token_out) distint_token_out, | ||
count(distinct token_in) distinct_token_in, | ||
max(amount_in_usd) max_dex_trade, | ||
count(distinct date(block_timestamp)) distinct_days_traded | ||
from flipside_{{ chain }}.silver_dex.complete_dex_swaps | ||
group by 1 | ||
origin_from_address as address | ||
, count(distinct tx_hash) as number_dex_trades | ||
, count(distinct pool_name) as distinct_pools | ||
, sum(coalesce(amount_out_usd, amount_in_usd)) as total_dex_volume | ||
, avg(coalesce(amount_out_usd, amount_in_usd)) as avg_dex_trade | ||
, count(distinct token_out) distint_token_out | ||
, count(distinct token_in) distinct_token_in | ||
, max(coalesce(amount_out_usd, amount_in_usd)) as max_dex_trade | ||
, count(distinct date(block_timestamp)) as distinct_days_traded | ||
, count(distinct platform) distinct_dex_platforms | ||
from {{chain}}_flipside.defi.ez_dex_swaps | ||
group by origin_from_address | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
{{ | ||
config( | ||
materialized="table", | ||
snowflake_warehouse="BASE_MD", | ||
database="base", | ||
schema="core", | ||
alias="ez_address", | ||
) | ||
}} | ||
|
||
select | ||
coalesce(fundamental.address, stablecoin.address, dex.address, cex.address) as address, | ||
app_used, | ||
category_used, | ||
total_gas_spent_usd, | ||
total_gas_spent_native, | ||
total_txns, | ||
distinct_to_address, | ||
latest_transaction_timestamp, | ||
first_transaction_timestamp, | ||
first_app, | ||
top_app, | ||
top_to_address, | ||
first_native_transfer, | ||
first_native_received, | ||
first_bridge_used, | ||
top_from_address, | ||
first_from_address, | ||
number_dex_trades, | ||
distinct_pools, | ||
total_dex_volume, | ||
avg_dex_trade, | ||
distinct_dex_platforms, | ||
distint_token_out, | ||
distinct_token_in, | ||
max_dex_trade, | ||
distinct_days_traded, | ||
indodax_transfer_amt, | ||
simpleswap_transfer_amt, | ||
hotbit_transfer_amt, | ||
mexc_transfer_amt, | ||
bitso_transfer_amt, | ||
bitget_transfer_amt, | ||
catex_transfer_amt, | ||
coindcx_transfer_amt, | ||
coinbase_transfer_amt, | ||
swissborg_transfer_amt, | ||
btse_transfer_amt, | ||
cryptocom_transfer_amt, | ||
maskex_transfer_amt, | ||
woonetwork_transfer_amt, | ||
lbank_transfer_amt, | ||
mxc_transfer_amt, | ||
gateio_transfer_amt, | ||
fixedfloat_transfer_amt, | ||
bitfinex_transfer_amt, | ||
maicoin_transfer_amt, | ||
phemex_transfer_amt, | ||
bingx_transfer_amt, | ||
bitbee_transfer_amt, | ||
bybit_transfer_amt, | ||
binance_transfer_amt, | ||
bitbank_transfer_amt, | ||
juno_transfer_amt, | ||
okx_transfer_amt, | ||
cumberland_transfer_amt, | ||
kraken_transfer_amt, | ||
huobi_transfer_amt, | ||
bilaxy_transfer_amt, | ||
first_stablecoin_to_address, | ||
first_stablecoin_from_address, | ||
avg_stablecoin_send, | ||
avg_stablecoin_received, | ||
top_stablecoin_to_address, | ||
top_stablecoin_from_address, | ||
number_of_stablecoin_transfers_txns, | ||
number_of_stablecoin_received_txns, | ||
unique_count_to_address, | ||
unique_count_from_address, | ||
first_stablecoin_transfer_date, | ||
latest_stablecoin_transfer_date, | ||
first_stablecoin_received_date, | ||
latest_stablecoin_received_date | ||
from {{ ref("dim_base_wallets_fundamental_metrics") }} as fundamental | ||
full join | ||
{{ ref("dim_base_wallets_stablecoin_metrics") }} as stablecoin | ||
on fundamental.address = stablecoin.address | ||
full join | ||
{{ ref("dim_base_wallets_dex_trade") }} as dex | ||
on fundamental.address = dex.address | ||
full join | ||
{{ ref("dim_base_wallets_cex_funded") }} as cex | ||
on fundamental.address = cex.address | ||
WHERE fundamental.address is not null | ||
or stablecoin.address is not null | ||
or dex.address is not null | ||
or cex.address is not null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{ | ||
config( | ||
materialized="incremental", | ||
unique_key=["address", "contract_address", "block_timestamp"], | ||
snowflake_warehouse="BASE", | ||
database="base", | ||
schema="core", | ||
alias="ez_balances", | ||
) | ||
}} | ||
|
||
select | ||
address, | ||
contract_address, | ||
block_timestamp, | ||
balance_token | ||
from {{ref("fact_base_address_balances_by_token")}} | ||
{% if is_incremental() %} | ||
where block_timestamp >= dateadd('day', -7, to_date(sysdate())) | ||
{% endif %} |
38 changes: 38 additions & 0 deletions
38
models/staging/base/wallets/dim_base_wallets_cex_funded.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{{ config(materialized="table", snowflake_warehouse="BASE_MD") }} | ||
|
||
with wallet_cex_data as ({{ get_wallet_cex_amount_funded("base") }}) | ||
select | ||
address, | ||
indodax_transfer_amt, | ||
simpleswap_transfer_amt, | ||
hotbit_transfer_amt, | ||
mexc_transfer_amt, | ||
bitso_transfer_amt, | ||
bitget_transfer_amt, | ||
catex_transfer_amt, | ||
coindcx_transfer_amt, | ||
coinbase_transfer_amt, | ||
swissborg_transfer_amt, | ||
btse_transfer_amt, | ||
cryptocom_transfer_amt, | ||
maskex_transfer_amt, | ||
woonetwork_transfer_amt, | ||
lbank_transfer_amt, | ||
mxc_transfer_amt, | ||
gateio_transfer_amt, | ||
fixedfloat_transfer_amt, | ||
bitfinex_transfer_amt, | ||
maicoin_transfer_amt, | ||
phemex_transfer_amt, | ||
bingx_transfer_amt, | ||
bitbee_transfer_amt, | ||
bybit_transfer_amt, | ||
binance_transfer_amt, | ||
bitbank_transfer_amt, | ||
juno_transfer_amt, | ||
okx_transfer_amt, | ||
cumberland_transfer_amt, | ||
kraken_transfer_amt, | ||
huobi_transfer_amt, | ||
bilaxy_transfer_amt | ||
from wallet_cex_data |
15 changes: 15 additions & 0 deletions
15
models/staging/base/wallets/dim_base_wallets_dex_trade.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{ config(materialized="table", snowflake_warehouse="BASE_MD") }} | ||
|
||
with wallet_dex_data as ({{ get_wallet_dex_trades("base") }}) | ||
select | ||
address, | ||
number_dex_trades, | ||
distinct_pools, | ||
total_dex_volume, | ||
avg_dex_trade, | ||
distinct_dex_platforms, | ||
distint_token_out, | ||
distinct_token_in, | ||
max_dex_trade, | ||
distinct_days_traded | ||
from wallet_dex_data |
21 changes: 21 additions & 0 deletions
21
models/staging/base/wallets/dim_base_wallets_fundamental_metrics.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{ config(materialized="table", snowflake_warehouse="BASE_MD") }} | ||
with wallet_fundamental_data as ({{ get_wallet_fundamental_metrics("base") }}) | ||
select | ||
address, | ||
app_used, | ||
category_used, | ||
total_gas_spent_usd, | ||
total_gas_spent_native, | ||
total_txns, | ||
distinct_to_address, | ||
latest_transaction_timestamp, | ||
first_transaction_timestamp, | ||
first_app, | ||
top_app, | ||
top_to_address, | ||
first_native_transfer, | ||
first_native_received, | ||
first_bridge_used, | ||
top_from_address, | ||
first_from_address | ||
from wallet_fundamental_data |
20 changes: 20 additions & 0 deletions
20
models/staging/base/wallets/dim_base_wallets_stablecoin_metrics.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{ config(materialized="table", snowflake_warehouse="BASE_MD") }} | ||
|
||
with wallet_stablecoin_data as ({{ get_wallet_stablecoin_metrics("base") }}) | ||
select | ||
address, | ||
first_stablecoin_to_address, | ||
first_stablecoin_from_address, | ||
avg_stablecoin_send, | ||
avg_stablecoin_received, | ||
top_stablecoin_to_address, | ||
top_stablecoin_from_address, | ||
number_of_stablecoin_transfers_txns, | ||
number_of_stablecoin_received_txns, | ||
unique_count_to_address, | ||
unique_count_from_address, | ||
first_stablecoin_transfer_date, | ||
latest_stablecoin_transfer_date, | ||
first_stablecoin_received_date, | ||
latest_stablecoin_received_date | ||
from wallet_stablecoin_data |