Skip to content

Commit

Permalink
fix: dedupe certain contracts and get bridge txns (#1717)
Browse files Browse the repository at this point in the history
* fix: dedupe certain contracts and get bridge txns

* fix: linting error
  • Loading branch information
ccerv1 authored Jun 26, 2024
1 parent 9316f59 commit f47f91d
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
with bridges as (
select distinct artifact_source_id
from {{ ref('int_artifacts_in_ossd_by_project') }}
where
artifact_type = 'BRIDGE'
and artifact_type = 'EOA'
where artifact_type = 'BRIDGE'
),

transactions as (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
with contracts_deployed_no_factory as (
{#
This gets all of the contracts that weren't deployed with a factory
#}
select
network,
deployer_address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,63 @@ artifacts as (
artifact_id,
artifact_name
from {{ ref('artifacts_v1') }}
),

events_to_project as (
select
events.bucket_day,
events.project_id,
projects_v1.project_name,
from_artifacts.artifact_name as from_artifact_name,
to_artifacts.artifact_name as to_artifact_name,
events.event_source,
events.event_type,
events.amount,
case
when rf4_trusted_users.is_trusted_user is true
then rf4_trusted_users.address
end as trusted_user_id
from events
left join artifacts as to_artifacts
on events.to_artifact_id = to_artifacts.artifact_id
left join artifacts as from_artifacts
on events.from_artifact_id = from_artifacts.artifact_id
left join {{ ref('projects_v1') }}
on events.project_id = projects_v1.project_id
left join {{ ref('rf4_trusted_users') }}
on from_artifacts.artifact_name = rf4_trusted_users.address
where events.amount > 0
),

duped_contracts as (
select distinct
event_source,
to_artifact_name,
project_name
from events_to_project
where project_name in ('zora', 'aerodrome-finance')
),

filtered_events as (
select events_to_project.*
from events_to_project
left join duped_contracts
on
events_to_project.to_artifact_name = duped_contracts.to_artifact_name
and events_to_project.event_source = duped_contracts.event_source
where
duped_contracts.project_name is null
or duped_contracts.project_name = events_to_project.project_name
)

select
events.bucket_day,
events.project_id,
projects_v1.project_name,
from_artifacts.artifact_name as from_artifact_name,
to_artifacts.artifact_name as to_artifact_name,
events.event_source,
events.event_type,
events.amount,
case
when rf4_trusted_users.is_trusted_user is true
then rf4_trusted_users.address
end as trusted_user_id
from events
left join artifacts as to_artifacts
on events.to_artifact_id = to_artifacts.artifact_id
left join artifacts as from_artifacts
on events.from_artifact_id = from_artifacts.artifact_id
left join {{ ref('projects_v1') }}
on events.project_id = projects_v1.project_id
left join {{ ref('rf4_trusted_users') }}
on from_artifacts.artifact_name = rf4_trusted_users.address
where events.amount > 0
bucket_day,
project_id,
project_name,
from_artifact_name,
to_artifact_name,
event_source,
event_type,
amount,
trusted_user_id
from filtered_events

0 comments on commit f47f91d

Please sign in to comment.