From d9529e1c4cb4e84234256acc57073c90ca80054d Mon Sep 17 00:00:00 2001 From: Carl Cervone <42869436+ccerv1@users.noreply.github.com> Date: Sat, 22 Jun 2024 22:43:14 -0400 Subject: [PATCH] update RF4 trusted user model to include airdrop data (#1693) * feat: add op airdrop trusted user signal * revise eigentrust global rank threshold --- .../dbt/macros/models/combine_op_airdrops.sql | 2 +- .../marts/superchain/rf4_trusted_users.sql | 31 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/warehouse/dbt/macros/models/combine_op_airdrops.sql b/warehouse/dbt/macros/models/combine_op_airdrops.sql index 4df87d5a2..5ca36fd17 100644 --- a/warehouse/dbt/macros/models/combine_op_airdrops.sql +++ b/warehouse/dbt/macros/models/combine_op_airdrops.sql @@ -14,7 +14,7 @@ -- Loop through each suffix and generate the full table reference {% for suffix in suffixes %} {% set table_name = 'op_airdrop' ~ suffix ~ '_addresses_detailed_list' %} - {% set query = "select address, op_amount_raw/1e18 as op_amount, cast('" ~ suffix ~ "' as int) as airdrop_round from " ~ source('static_data_sources', table_name) %} + {% set query = "select lower(cast(address as string)) as address, cast(op_amount_raw as numeric)/1e18 as op_amount, cast('" ~ suffix ~ "' as int) as airdrop_round from " ~ source('static_data_sources', table_name) %} {% do queries.append(query) %} {% endfor %} diff --git a/warehouse/dbt/models/marts/superchain/rf4_trusted_users.sql b/warehouse/dbt/models/marts/superchain/rf4_trusted_users.sql index d3fd1771b..05880e175 100644 --- a/warehouse/dbt/models/marts/superchain/rf4_trusted_users.sql +++ b/warehouse/dbt/models/marts/superchain/rf4_trusted_users.sql @@ -19,7 +19,7 @@ eigentrust_top_users as ( snapshot_time = '2024-05-21' and strategy_id = 1 order by eigentrust_rank desc - limit 50000 + limit 42000 ), optimist_nft_holders as ( @@ -39,6 +39,22 @@ passport_scores as ( from {{ ref('stg_passport__scores') }} ), +airdrop_recipients as ( + select + address, + 1 as airdrop_recipient, + CAST( + COALESCE(count_drops > 1, false) as int64 + ) as airdrop_verification + from ( + select + LOWER(address) as address, + COUNT(distinct airdrop_round) as count_drops + from {{ ref('stg_optimism_airdrop_addresses') }} + group by LOWER(address) + ) +), + all_addresses as ( select distinct address from ( @@ -47,6 +63,8 @@ all_addresses as ( select address from passport_scores union all select address from optimist_nft_holders + union all + select address from airdrop_recipients ) ), @@ -64,7 +82,11 @@ trusted_user_model as ( COALESCE(passport_scores.passport_verification, 0) as passport_verification, COALESCE(optimist_nft_holders.optimist_nft_verification, 0) - as optimist_nft_verification + as optimist_nft_verification, + COALESCE(airdrop_recipients.airdrop_recipient, 0) + as airdrop_recipient, + COALESCE(airdrop_recipients.airdrop_verification, 0) + as airdrop_verification from all_addresses left join farcaster_users on all_addresses.address = farcaster_users.address @@ -74,6 +96,8 @@ trusted_user_model as ( on all_addresses.address = passport_scores.address left join optimist_nft_holders on all_addresses.address = optimist_nft_holders.address + left join airdrop_recipients + on all_addresses.address = airdrop_recipients.address ) select @@ -84,11 +108,14 @@ select passport_user, passport_verification, optimist_nft_verification, + airdrop_recipient, + airdrop_verification, ( farcaster_user + farcaster_prepermissionless + eigentrust_verification + passport_verification + optimist_nft_verification + + airdrop_verification ) > 1 as is_trusted_user from trusted_user_model