Skip to content

Commit

Permalink
add CoverProducts contract, update covers v2 back to view (duneanalyt…
Browse files Browse the repository at this point in the history
  • Loading branch information
tomfutago authored Aug 8, 2024
1 parent 88fe12c commit 355bcea
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
config(
schema = 'nexusmutual_ethereum',
alias = 'covers_v2',
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
materialized = 'view',
unique_key = ['cover_id', 'staking_pool'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
post_hook = '{{ expose_spells(\'["ethereum"]\',
"project",
"nexusmutual",
\'["tomfutago"]\') }}'
post_hook = '{{ expose_spells(blockchains = \'["ethereum"]\',
spell_type = "project",
spell_name = "nexusmutual",
contributors = \'["tomfutago"]\') }}'
)
}}

Expand Down Expand Up @@ -40,9 +37,6 @@ cover_sales as (
from {{ source('nexusmutual_ethereum', 'Cover_call_buyCover') }} c
cross join unnest(c.poolAllocationRequests) as t(pool_allocation)
where c.call_success
{% if is_incremental() %}
and {{ incremental_predicate('c.call_block_time') }}
{% endif %}
),

staking_product_premiums as (
Expand Down Expand Up @@ -70,9 +64,6 @@ staking_product_premiums as (
from {{ source('nexusmutual_ethereum', 'StakingProducts_call_getPremium') }}
where call_success
and contract_address = 0xcafea573fbd815b5f59e8049e71e554bde3477e4
{% if is_incremental() %}
and {{ incremental_predicate('call_block_time') }}
{% endif %}
),

cover_premiums as (
Expand Down Expand Up @@ -169,9 +160,6 @@ covers_v1_migrated as (
cm.evt_tx_hash as tx_hash
from {{ source('nexusmutual_ethereum', 'CoverMigrator_evt_CoverMigrated') }} cm
inner join {{ ref('nexusmutual_ethereum_covers_v1') }} cv1 on cm.coverIdV1 = cv1.cover_id
{% if is_incremental() %}
where {{ incremental_predicate('cm.evt_block_time') }}
{% endif %}
),

covers as (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
schema = 'nexusmutual_ethereum',
alias = 'product_types_v2',
materialized = 'view',
post_hook = '{{ expose_spells(\'["ethereum"]\',
"project",
"nexusmutual",
\'["tomfutago"]\') }}'
unique_key = ['product_type_id'],
post_hook = '{{ expose_spells(blockchains = \'["ethereum"]\',
spell_type = "project",
spell_name = "nexusmutual",
contributors = \'["tomfutago"]\') }}'
)
}}

Expand All @@ -22,6 +23,16 @@ product_type_events as (
evt_tx_hash as tx_hash,
row_number() over (partition by evt_block_time, evt_tx_hash order by evt_index) as evt_rn
from {{ source('nexusmutual_ethereum', 'Cover_evt_ProductTypeSet') }}
union all
select
evt_block_time as block_time,
evt_block_number as block_number,
id as product_type_id,
cast(null as varchar) as evt_product_type_ipfs_metadata,
evt_index,
evt_tx_hash as tx_hash,
row_number() over (partition by evt_block_time, evt_tx_hash order by evt_index) as evt_rn
from {{ source('nexusmutual_ethereum', 'CoverProducts_evt_ProductTypeSet') }}
),

product_type_calls as (
Expand All @@ -33,6 +44,15 @@ product_type_calls as (
row_number() over (partition by call_block_time, call_tx_hash order by call_trace_address desc) as tx_call_rn
from {{ source('nexusmutual_ethereum', 'Cover_call_setProductTypes') }}
where call_success
union all
select
call_block_time as block_time,
call_block_number as block_number,
productTypeParams,
call_tx_hash as tx_hash,
row_number() over (partition by call_block_time, call_tx_hash order by call_trace_address desc) as tx_call_rn
from {{ source('nexusmutual_ethereum', 'CoverProducts_call_setProductTypes') }}
where call_success
),

product_type_data_raw as (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
schema = 'nexusmutual_ethereum',
alias = 'products_v2',
materialized = 'view',
post_hook = '{{ expose_spells(\'["ethereum"]\',
"project",
"nexusmutual",
\'["tomfutago"]\') }}'
unique_key = ['product_id'],
post_hook = '{{ expose_spells(blockchains = \'["ethereum"]\',
spell_type = "project",
spell_name = "nexusmutual",
contributors = \'["tomfutago"]\') }}'
)
}}

Expand All @@ -21,6 +22,15 @@ product_events as (
evt_index,
evt_tx_hash as tx_hash
from {{ source('nexusmutual_ethereum', 'Cover_evt_ProductSet') }}
union all
select
evt_block_time as block_time,
evt_block_number as block_number,
id as product_id,
cast(null as varchar) as evt_product_ipfs_metadata,
evt_index,
evt_tx_hash as tx_hash
from {{ source('nexusmutual_ethereum', 'CoverProducts_evt_ProductSet') }}
),

product_calls as (
Expand All @@ -33,6 +43,15 @@ product_calls as (
from {{ source('nexusmutual_ethereum', 'Cover_call_setProducts') }}
where call_success
and contract_address = 0xcafeac0ff5da0a2777d915531bfa6b29d282ee62
union all
select
call_block_time as block_time,
call_block_number as block_number,
productParams,
call_tx_hash as tx_hash,
row_number() over (partition by call_block_time, call_tx_hash order by call_trace_address desc) as tx_call_rn
from {{ source('nexusmutual_ethereum', 'CoverProducts_call_setProducts') }}
where call_success
),

product_data_raw as (
Expand Down
4 changes: 4 additions & 0 deletions sources/nexusmutual/ethereum/nexusmutual_ethereum_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ sources:
- name: Cover_call_setProductTypes
- name: Cover_evt_ProductSet
- name: Cover_call_setProducts
- name: CoverProducts_evt_ProductTypeSet
- name: CoverProducts_call_setProductTypes
- name: CoverProducts_evt_ProductSet
- name: CoverProducts_call_setProducts
- name: Quotation_call_buyCoverWithMetadata
- name: Quotation_call_makeCoverUsingNXMTokens
- name: QuotationData_call_addCover
Expand Down

0 comments on commit 355bcea

Please sign in to comment.