diff --git a/models/nexusmutual/ethereum/covers/_schema.yml b/models/nexusmutual/ethereum/covers/_schema.yml new file mode 100644 index 00000000000..03ed1b24b78 --- /dev/null +++ b/models/nexusmutual/ethereum/covers/_schema.yml @@ -0,0 +1,329 @@ +version: 2 + +models: + - name: nexusmutual_ethereum_product_types_v2 + meta: + blockchain: ethereum + project: nexusmutual + contributors: tomfutago + config: + tags: ["ethereum", "nexusmutual", "covers"] + description: "Nexus Mutual Product Types v2" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - product_type_id + columns: + - &block_time + name: block_time + description: "UTC event block time" + tests: + - not_null + - &block_number + name: block_number + description: "Block number" + tests: + - not_null + - &product_type_id + name: product_type_id + description: "product type id" + tests: + - not_null + - &product_type_name + name: product_type_name + description: "product type name" + tests: + - not_null + - name: claim_method + description: "claim method" + - name: grace_period + description: "grace period" + - name: product_type_ipfs_metadata + description: "product type ipfs metadata" + - name: cover_wording_url + description: "cover wording url" + - &evt_index + name: evt_index + description: "event index" + - &tx_hash + name: tx_hash + description: "unique transaction hash value" + tests: + - not_null + + - name: nexusmutual_ethereum_products_v2 + meta: + blockchain: ethereum + project: nexusmutual + contributors: tomfutago + config: + tags: ["ethereum", "nexusmutual", "covers"] + description: "Nexus Mutual Products v2" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - product_id + columns: + - *block_time + - *block_number + - *product_type_id + - &product_id + name: product_id + description: "product id" + tests: + - not_null + - &product_name + name: product_name + description: "product name" + tests: + - not_null + - name: cover_assets + description: "cover assets: ETH, DAI, USDC" + - name: is_deprecated + description: "is deprecated flag" + - name: initial_price_ratio + description: "initial price ratio" + - name: use_fixed_price + description: "use fixed price?" + - name: capacity_reduction_ratio + description: "capacity reduction ratio" + - name: allowed_pools + description: "allowed pools (array)" + - name: yield_token_address + description: "yield token address" + - name: product_ipfs_metadata + description: "product ipfs metadata" + - *evt_index + - *tx_hash + + - name: nexusmutual_ethereum_products_v1 + meta: + blockchain: ethereum + project: nexusmutual + contributors: guyhow, tomfutago + config: + tags: ["ethereum", "nexusmutual", "covers"] + description: "Nexus Mutual Products v1" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - product_contract_address + columns: + - &product_contract_address + name: product_contract_address + description: "product contract address" + tests: + - unique + - *product_name + - &product_type + name: product_type + description: "product type" + - &date_added + name: date_added + description: "date added" + + - name: nexusmutual_ethereum_covers_v1 + meta: + blockchain: ethereum + project: nexusmutual + contributors: tomfutago + config: + tags: ["ethereum", "nexusmutual", "covers"] + description: "Nexus Mutual Covers v1" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - cover_id + columns: + - *block_time + - &block_date + name: block_date + description: "block date" + - *block_number + - &cover_id + name: block_date + description: "cover id" + tests: + - not_null + - &cover_start_time + name: cover_start_time + description: "cover start time" + tests: + - not_null + - &cover_end_time + name: cover_end_time + description: "cover end time" + tests: + - not_null + - &cover_start_date + name: cover_start_date + description: "cover start date" + - &cover_end_date + name: cover_end_date + description: "cover end date" + - &product_contract + name: product_contract + description: "product contract" + - name: syndicate + description: "syndicate" + - *product_name + - *product_type + - &cover_asset + name: cover_asset + description: "cover asset" + - &sum_assured + name: sum_assured + description: "total cover amount" + - &premium_asset + name: premium_asset + description: "premium asset" + - &premium + name: premium + description: "premium in cover asset" + - &premium_nxm + name: premium_nxm + description: "premium in NXM" + - &cover_owner + name: cover_owner + description: "cover owner" + - *evt_index + - *tx_hash + + - name: nexusmutual_ethereum_covers_v2 + meta: + blockchain: ethereum + project: nexusmutual + contributors: tomfutago + config: + tags: ["ethereum", "nexusmutual", "covers"] + description: "Nexus Mutual Covers v2" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - cover_id + - staking_pool + columns: + - *block_time + - *block_date + - *block_number + - *cover_id + - *cover_start_time + - *cover_end_time + - *cover_start_date + - *cover_end_date + - &staking_pool + name: staking_pool + description: "staking pool id" + - *product_type + - *product_name + - *cover_asset + - *sum_assured + - &partial_cover_amount + name: partial_cover_amount + description: "partial cover amount" + - *premium_asset + - *premium + - *premium_nxm + - &premium_incl_commission + name: premium_incl_commission + description: "premium incl commission" + - *cover_owner + - &is_migrated + name: is_migrated + description: "is migrated flag" + - *tx_hash + + + # to be deprecated: + - name: nexusmutual_ethereum_product_information + meta: + blockchain: ethereum + project: nexusmutual + contributors: [guyhow] + description: > + nexusmutual product information for v1 + columns: + - *product_contract_address + - *product_name + - *product_type + - *date_added + - name: syndicate + + - name: nexusmutual_ethereum_quotation_trades + meta: + blockchain: ethereum + project: nexusmutual + contributors: [zxf, jonah] + config: + tags: ["ethereum","nexusmutual","quotation_trades"] + description: > + nexusmutual quotation trades on Ethereum + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - evt_tx_hash + - evt_index + - cid + - check_seed: + seed_file: ref("nexusmutual_ethereum_trades_seed") + match_columns: + - evt_tx_hash + check_columns: + - premium + - premium_nxm + - sum_assured + columns: + - &cid + name: cid + - &contract_address + name: contract_address + - &symbol + name: symbol + - *evt_index + - &evt_tx_hash + name: evt_tx_hash + - &curr + name: curr + - *premium + - &pre_amount + name: pre_amount + - *premium_nxm + - &pre_nxm_amount + name: pre_nxm_amount + - &sc_add + name: sc_add + - *sum_assured + - &block_hash + name: block_hash + - &nonce + name: nonce + - &gas_limit + name: gas_limit + - &gas_price + name: gas_price + - &gas_used + name: gas_used + - &max_fee_per_gas + name: max_fee_per_gas + - &max_priority_fee_per_gas + name: max_priority_fee_per_gas + - &priority_fee_per_gas + name: priority_fee_per_gas + - &success + name: success + - &tx_type + name: tx_type + - &tx_value + name: tx_value + - &evt_block_number + name: evt_block_number + - &evt_block_time + name: evt_block_time + - &evt_expiry + name: evt_expiry + - &evt_expiry_date + name: evt_expiry_date + - *block_date + - &token_address + name: token_address diff --git a/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_covers_v1.sql b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_covers_v1.sql new file mode 100644 index 00000000000..9dd1b5c6e4c --- /dev/null +++ b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_covers_v1.sql @@ -0,0 +1,69 @@ +{{ + config( + schema = 'nexusmutual_ethereum', + alias = 'covers_v1', + materialized = 'view', + post_hook = '{{ expose_spells(\'["ethereum"]\', + "project", + "nexusmutual", + \'["tomfutago"]\') }}' + ) +}} + +with + +cover_details as ( + select + cde.evt_block_time as block_time, + cde.evt_block_number as block_number, + cde.cid as cover_id, + cde.evt_block_time as cover_start_time, + from_unixtime(cde.expiry) as cover_end_time, + cde.scAdd as product_contract, + cast(cde.sumAssured as double) as sum_assured, + case + when ct.call_success or cm.payWithNXM then 'NXM' + when cde.curr = 0x45544800 then 'ETH' + when cde.curr = 0x44414900 then 'DAI' + end as premium_asset, + cde.premium / 1e18 as premium, + case + when cde.curr = 0x45544800 then 'ETH' + when cde.curr = 0x44414900 then 'DAI' + end as cover_asset, + cde.premiumNXM / 1e18 as premium_nxm, + ac._userAddress as cover_owner, + cde.evt_index, + cde.evt_tx_hash as tx_hash + from {{ source('nexusmutual_ethereum', 'QuotationData_evt_CoverDetailsEvent') }} cde + left join {{ source('nexusmutual_ethereum', 'Quotation_call_buyCoverWithMetadata') }} cm + on cde.evt_tx_hash = cm.call_tx_hash and cde.evt_block_number = cm.call_block_number and cm.call_success + left join {{ source('nexusmutual_ethereum', 'Quotation_call_makeCoverUsingNXMTokens') }} ct + on cde.evt_tx_hash = ct.call_tx_hash and cde.evt_block_number = ct.call_block_number and ct.call_success + left join {{ source('nexusmutual_ethereum', 'QuotationData_call_addCover') }} ac + on cde.evt_tx_hash = ac.call_tx_hash and cde.evt_block_number = ac.call_block_number and ac.call_success +) + +select + cd.block_time, + date_trunc('day', cd.block_time) as block_date, + cd.block_number, + cd.cover_id, + cd.cover_start_time, + cd.cover_end_time, + date_trunc('day', cd.cover_start_time) as cover_start_date, + date_trunc('day', cd.cover_end_time) as cover_end_date, + cd.product_contract, + 'v1' as syndicate, + coalesce(p.product_name, 'unknown') as product_name, + coalesce(p.product_type, 'unknown') as product_type, + cd.cover_asset, + cd.sum_assured, + cd.premium_asset, + cd.premium, + cd.premium_nxm, + cd.cover_owner, + cd.evt_index, + cd.tx_hash +from cover_details cd + left join {{ ref('nexusmutual_ethereum_products_v1') }} p on cd.product_contract = p.product_contract_address diff --git a/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_covers_v2.sql b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_covers_v2.sql new file mode 100644 index 00000000000..fe18675a6cd --- /dev/null +++ b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_covers_v2.sql @@ -0,0 +1,226 @@ +{{ + config( + schema = 'nexusmutual_ethereum', + alias = 'covers_v2', + materialized = 'view', + post_hook = '{{ expose_spells(\'["ethereum"]\', + "project", + "nexusmutual", + \'["tomfutago"]\') }}' + ) +}} + +with + +cover_sales as ( + select + c.call_block_time as block_time, + c.call_block_number as block_number, + c.output_coverId as cover_id, + c.call_block_time as cover_start_time, + date_add('second', cast(json_query(c.params, 'lax $.period') as bigint), c.call_block_time) as cover_end_time, + cast(json_query(c.params, 'lax $.period') as bigint) as cover_period_seconds, + cast(json_query(t.pool_allocation, 'lax $.poolId') as uint256) as pool_id, + cast(json_query(c.params, 'lax $.productId') as uint256) as product_id, + from_hex(json_query(c.params, 'lax $.owner' omit quotes)) as cover_owner, + cast(json_query(c.params, 'lax $.amount') as uint256) as sum_assured, + cast(json_query(c.params, 'lax $.coverAsset') as int) as cover_asset, + cast(json_query(c.params, 'lax $.paymentAsset') as int) as payment_asset, + cast(json_query(c.params, 'lax $.maxPremiumInAsset') as uint256) as max_premium_in_asset, + cast(json_query(c.params, 'lax $.commissionRatio') as double) as commission_ratio, + from_hex(json_query(c.params, 'lax $.commissionDestination' omit quotes)) as commission_destination, + cast(json_query(t.pool_allocation, 'lax $.coverAmountInAsset') as uint256) as cover_amount_in_asset, + cast(json_query(t.pool_allocation, 'lax $.skip') as boolean) as pool_allocation_skip, + c.call_trace_address, + c.call_tx_hash as tx_hash + from {{ source('nexusmutual_ethereum', 'Cover_call_buyCover') }} c + cross join unnest(c.poolAllocationRequests) as t(pool_allocation) + where c.call_success +), + +staking_product_premiums as ( + select + call_block_time as block_time, + call_block_number as block_number, + poolId as pool_id, + productId as product_id, + output_premium as premium, + coverAmount as cover_amount, + initialCapacityUsed as initial_capacity_used, + totalCapacity as total_capacity, + globalMinPrice as global_min_price, + useFixedPrice as use_fixed_price, + nxmPerAllocationUnit as nxm_per_allocation_unit, + allocationUnitsPerNXM as allocation_units_per_nxm, + cast(period as bigint) as premium_period_seconds, + case + when date_add('second', cast(period as bigint), call_block_time) > now() + then (to_unixTime(now()) - to_unixTime(call_block_time)) / cast(period as bigint) + else 1 + end as premium_period_ratio, + call_trace_address, + call_tx_hash as tx_hash + from {{ source('nexusmutual_ethereum', 'StakingProducts_call_getPremium') }} + where call_success + and contract_address = 0xcafea573fbd815b5f59e8049e71e554bde3477e4 +), + +cover_premiums as ( + select + c.block_time, + c.block_number, + c.cover_id, + c.cover_start_time, + c.cover_end_time, + c.pool_id, + c.product_id, + p.cover_amount / 100.0 as partial_cover_amount, -- partial_cover_amount_in_nxm + p.premium / 1e18 as premium, + c.commission_ratio / 10000.0 as commission_ratio, + (1.0 + (c.commission_ratio / 10000.0)) * p.premium / 1e18 as premium_incl_commission, + case c.cover_asset + when 0 then 'ETH' + when 1 then 'DAI' + when 6 then 'USDC' + else 'NA' + end as cover_asset, + c.sum_assured / if(c.cover_asset = 6, 1e6, 1e18) as sum_assured, + case c.payment_asset + when 0 then 'ETH' + when 1 then 'DAI' + when 6 then 'USDC' + when 255 then 'NXM' + else 'NA' + end as premium_asset, + c.cover_owner, + c.commission_destination, + c.tx_hash + from cover_sales c + inner join staking_product_premiums p on c.tx_hash = p.tx_hash and c.block_number = p.block_number + and c.pool_id = p.pool_id and c.product_id = p.product_id +), + +products as ( + select + p.product_id, + p.product_name, + pt.product_type_id, + pt.product_type_name as product_type + from {{ ref('nexusmutual_ethereum_product_types_v2') }} pt + inner join {{ ref('nexusmutual_ethereum_products_v2') }} p on pt.product_type_id = p.product_type_id +), + +covers_v2 as ( + select + cp.block_time, + cp.block_number, + cp.cover_id, + cp.cover_start_time, + cp.cover_end_time, + cp.pool_id, + cp.product_id, + p.product_type, + p.product_name, + cp.partial_cover_amount, + cp.commission_ratio, + cp.cover_asset, + cp.sum_assured, + cp.premium_asset, + cp.premium, + cp.premium_incl_commission, + cp.cover_owner, + cp.commission_destination, + cp.tx_hash + from cover_premiums cp + left join products p on cp.product_id = p.product_id +), + +covers_v1_migrated as ( + select + cm.evt_block_time as block_time, + cm.evt_block_number as block_number, + cm.coverIdV2 as cover_id, + cv1.cover_start_time, + cv1.cover_end_time, + cv1.premium, + cv1.premium_nxm, + cv1.sum_assured, + cv1.syndicate, + cv1.product_name, + cv1.product_type, + cv1.cover_asset, + cv1.premium_asset, + cm.newOwner as cover_owner, + cm.evt_index, + 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 +), + +covers as ( + select + block_time, + block_number, + cover_id, + cover_start_time, + cover_end_time, + cast(pool_id as varchar) as staking_pool, + product_type, + product_name, + cover_asset, + premium_asset, + premium, + premium as premium_nxm, + premium_incl_commission, + sum_assured, + partial_cover_amount, -- in NXM + cover_owner, + false as is_migrated, + tx_hash + from covers_v2 + union all + select + block_time, + block_number, + cover_id, + cover_start_time, + cover_end_time, + syndicate as staking_pool, + product_type, + product_name, + cover_asset, + premium_asset, + premium, + premium_nxm, + premium_nxm as premium_incl_commission, + sum_assured, + sum_assured as partial_cover_amount, -- No partial covers in v1 migrated covers + cover_owner, + true as is_migrated, + tx_hash + from covers_v1_migrated +) + +select + block_time, + date_trunc('day', block_time) as block_date, + block_number, + cover_id, + cover_start_time, + cover_end_time, + date_trunc('day', cover_start_time) as cover_start_date, + date_trunc('day', cover_end_time) as cover_end_date, + staking_pool, + product_type, + product_name, + cover_asset, + sum_assured, + partial_cover_amount, -- in NXM + premium_asset, + premium, + premium_nxm, + premium_incl_commission, + cover_owner, + is_migrated, + tx_hash +from covers diff --git a/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_product_information.sql b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_product_information.sql new file mode 100644 index 00000000000..63387bfe202 --- /dev/null +++ b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_product_information.sql @@ -0,0 +1,13 @@ +{{ config( + schema = 'nexusmutual_ethereum', + alias = 'product_information', + materialized = 'view' + ) +}} + +SELECT product_contract_address, + product_name, + product_type, + date_added, + 'v1' AS syndicate +FROM {{ ref('nexusmutual_ethereum_products_v1') }} diff --git a/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_product_types_v2.sql b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_product_types_v2.sql new file mode 100644 index 00000000000..2a5436d22d1 --- /dev/null +++ b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_product_types_v2.sql @@ -0,0 +1,132 @@ +{{ + config( + schema = 'nexusmutual_ethereum', + alias = 'product_types_v2', + materialized = 'view', + post_hook = '{{ expose_spells(\'["ethereum"]\', + "project", + "nexusmutual", + \'["tomfutago"]\') }}' + ) +}} + +with + +product_type_events as ( + select + evt_block_time as block_time, + evt_block_number as block_number, + id as product_type_id, + ipfsMetadata 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', 'Cover_evt_ProductTypeSet') }} +), + +product_type_calls as ( + 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', 'Cover_call_setProductTypes') }} + where call_success +), + +product_type_data_raw as ( + select + pt.block_time, + pt.block_number, + pt.productTypeParams, + cast(json_extract_scalar(t.product_type_param, '$.productTypeId') as uint256) as product_type_id_input, + json_extract_scalar(t.product_type_param, '$.productTypeName') as product_type_name, + json_extract_scalar(t.product_type_param, '$.ipfsMetadata') as call_product_type_ipfs_metadata, + json_parse(json_query(t.product_type_param, 'lax $.productType' omit quotes)) as product_type_json, + t.product_type_ordinality, + pt.tx_hash + from product_type_calls pt + cross join unnest (pt.productTypeParams) with ordinality as t(product_type_param, product_type_ordinality) + where pt.tx_call_rn = 1 +), + +product_type_data as ( + select + block_time, + block_number, + product_type_id_input, + product_type_name, + try_cast(json_extract_scalar(product_type_json, '$.claimMethod') as int) as claim_method, + try_cast(json_extract_scalar(product_type_json, '$.gracePeriod') as bigint) as grace_period, + call_product_type_ipfs_metadata, + product_type_ordinality, + tx_hash, + row_number() over (partition by block_time, tx_hash order by product_type_ordinality) as call_rn + from product_type_data_raw +), + +product_types_ext as ( + select + e.block_time, + e.block_number, + e.product_type_id, + c.product_type_name, + c.claim_method, + c.grace_period, + coalesce(e.evt_product_type_ipfs_metadata, c.call_product_type_ipfs_metadata) as product_type_ipfs_metadata, + e.evt_index, + e.tx_hash + from product_type_events e + inner join product_type_data c on e.block_time = c.block_time and e.block_number = c.block_number and e.evt_rn = c.call_rn + union all + select + block_time, + block_number, + product_type_id_input as product_type_id, + product_type_name, + claim_method, + grace_period, + call_product_type_ipfs_metadata as product_type_ipfs_metadata, + cast(0 as bigint) as evt_index, + tx_hash + from product_type_data + where tx_hash = 0x9d6219f34e1474a788c4ece1a14b18d8402653ff34f792ca088c344b80a93bd9 -- exception without event logs +), + +product_types as ( + select + block_time, + block_number, + product_type_id, + if( + product_type_name <> '', + product_type_name, + lag(product_type_name) over (partition by product_type_id order by block_time) + ) as product_type_name, + claim_method, + grace_period, + if( + product_type_ipfs_metadata <> '', + product_type_ipfs_metadata, + lag(product_type_ipfs_metadata) over (partition by product_type_id order by block_time) + ) as product_type_ipfs_metadata, + evt_index, + tx_hash, + row_number() over (partition by product_type_id order by block_time desc) as rn + from product_types_ext +) + +select + block_time, + block_number, + product_type_id, + product_type_name, + claim_method, + grace_period, + product_type_ipfs_metadata, + concat('https://api.nexusmutual.io/ipfs/', product_type_ipfs_metadata) as cover_wording_url, + evt_index, + tx_hash +from product_types +where rn = 1 diff --git a/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_products_v1.sql b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_products_v1.sql new file mode 100644 index 00000000000..d04918290b7 --- /dev/null +++ b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_products_v1.sql @@ -0,0 +1,189 @@ +{{ + config( + schema = 'nexusmutual_ethereum', + alias = 'products_v1', + materialized = 'table', + tags = ['static'], + unique_key = ['product_contract_address'], + post_hook = '{{ expose_spells(\'["ethereum"]\', + "project", + "nexusmutual", + \'["guyhowlett","tomfutago"]\') }}' + ) +}} + +select + product_contract_address, + product_name, + product_type, + cast(date_added as date) as date_added +from ( +values + (0xF5DCe57282A584D2746FaF1593d3121Fcac444dC, 'Compound Sai', 'Protocol', '2020-01-01'), + (0x8B3d70d628Ebd30D4A2ea82DB95bA2e906c71633, 'bZx v1', 'Protocol', '2020-01-01'), + (0x5504a1d88005236147EC86C62cfb53043bD1276a, 'Unknown', 'Protocol', '2020-01-01'), + (0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, 'Compound ETH', 'Protocol', '2020-01-01'), + (0x080bf510FCbF18b91105470639e9561022937712, '0x v2.1', 'Protocol', '2020-01-01'), + (0x16de59092dAE5CcF4A1E6439D611fd0653f0Bd01, 'iearn yDAI v1', 'Protocol', '2020-01-01'), + (0xAF350211414C5DC176421Ea05423F0cC494261fB, 'Saturn DAO Token', 'Protocol', '2020-01-01'), + (0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643, 'Compound DAI', 'Protocol', '2020-01-01'), + (0x2157A7894439191e520825fe9399aB8655E0f708, 'Uniswap Exchange Template', 'Protocol', '2020-01-01'), + (0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2, 'Maker Token', 'Protocol', '2020-01-01'), + (0x6e95C8E8557AbC08b46F3c347bA06F8dC012763f, 'Legacy Gnosis MultiSig', 'Protocol', '2020-01-01'), + (0xb1CD6e4153B2a390Cf00A6556b0fC1458C4A5533, 'Bancor ETHBNT Token', 'Protocol', '2020-01-01'), + (0x29fe7D60DdF151E5b52e5FAB4f1325da6b2bD958, 'Pool Together DAI', 'Protocol', '2020-01-01'), + (0x4a57E687b9126435a9B19E4A802113e266AdeBde, 'Flexacoin Token', 'Protocol', '2020-01-01'), + (0x519b70055af55A007110B4Ff99b0eA33071c720a, 'dxDAO', 'Protocol', '2020-01-01'), + (0x802275979B020F0ec871c5eC1db6e412b72fF20b, 'Nuo', 'Protocol', '2020-01-01'), + (0xb7896fce748396EcFC240F5a0d3Cc92ca42D7d84, 'Pool Together SAI', 'Protocol', '2020-01-01'), + (0x932773aE4B661029704e731722CF8129e1B32494, 'Pool Together v2', 'Protocol', '2020-01-01'), + (0xB1dD690Cc9AF7BB1a906A9B5A94F94191cc553Ce, 'Argent', 'Protocol', '2020-01-01'), + (0x2b591e99afE9f32eAA6214f7B7629768c40Eeb39, 'Hex Token', 'Protocol', '2020-01-01'), + (0x2C4Bd064b998838076fa341A83d007FC2FA50957, 'Uniswap v1 MKR Pool', 'Protocol', '2020-01-01'), + (0x364508A5cA0538d8119D3BF40A284635686C98c4, 'dydx Perpetual', 'Protocol', '2020-01-01'), + (0x6B175474E89094C44Da98b954EedeAC495271d0F, 'DAI Token', 'Protocol', '2020-01-01'), + (0xD5D2b9e9bcd172D5fC8521AFd2C98Dd239F5b607, 'Unknown', 'Protocol', '2020-01-01'), + (0x241e82C79452F51fbfc89Fac6d912e021dB1a3B7, 'DDEX', 'Protocol', '2020-01-01'), + (0x12D66f87A04A9E220743712cE6d9bB1B5616B8Fc, 'Tornado Cash', 'Protocol', '2020-01-01'), + (0x5d22045DAcEAB03B158031eCB7D9d06Fad24609b, 'Deversifi', 'Protocol', '2020-06-20'), + (0x498b3BfaBE9F73db90D252bCD4Fa9548Cd0Fd981, 'Instadapp Registry', 'Protocol', '2020-01-01'), + (0x448a5065aeBB8E423F0896E6c5D525C040f59af3, 'Maker SCD', 'Protocol', '2020-01-01'), + (0xe80d347DF1209a76DD9d2319d62912ba98C54DDD, 'RenVM', 'Protocol', '2020-06-20'), + (0xB27F1DB0a7e473304A5a06E54bdf035F671400C0, '0x v3', 'Protocol', '2020-01-01'), + (0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e, 'dydx Margin', 'Protocol', '2020-01-01'), + (0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B, 'Compound v2', 'Protocol', '2020-01-01'), + (0x34CfAC646f301356fAa8B21e94227e3583Fe3F5F, 'Gnosis Safe', 'Protocol', '2020-01-01'), + (0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95, 'Uniswap v1', 'Protocol', '2020-01-01'), + (0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B, 'MakerDAO MCD', 'Protocol', '2020-01-01'), + (0x72338b82800400F5488eCa2B5A37270ba3B7A111, 'Paraswap - OLD', 'Protocol', '2020-01-01'), + (0xc1D2819CE78f3E15Ee69c6738eB1B400A26e632A, 'Aave v1', 'Protocol', '2020-01-01'), + (0x10eC0D497824e342bCB0EDcE00959142aAa766dD, 'Idle Finance - OLD', 'Protocol', '2020-01-01'), + (0x3dfd23A6c5E8BbcFc9581d2E864a68feb6a076d3, 'Aave Lending Core', 'Protocol', '2020-01-01'), + (0x45F783CCE6B7FF23B2ab2D70e416cdb7D6055f51, 'Curve fi - OLD', 'Protocol', '2020-01-01'), + (0x11111254369792b2Ca5d084aB5eEA397cA8fa48B, '1Inch (DEX & Liquidity Pools)', 'Protocol', '2020-01-01'), + (0xF92C1ad75005E6436B4EE84e88cB23Ed8A290988, 'Paraswap OLD', 'Protocol', '2020-01-01'), + (0xb529964F86fbf99a6aA67f72a27e59fA3fa4FEaC, 'Opyn', 'Protocol', '2020-01-01'), + (0x9D25057e62939D3408406975aD75Ffe834DA4cDd, 'Yearn Finance (all vaults)', 'Protocol', '2020-01-01'), + (0x77208a6000691E440026bEd1b178EF4661D37426, 'Totle', 'Protocol', '2020-01-01'), + (0x12f208476F64De6e6f933E55069Ba9596D818e08, 'Flexa Staking', 'Protocol', '2020-01-01'), + (0x78751B12Da02728F467A44eAc40F5cbc16Bd7934, 'Idle v3', 'Protocol', '2020-06-20'), + (0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714, 'Curve BTC Pools', 'Protocol', '2020-06-20'), + (0x79a8C46DeA5aDa233ABaFFD40F3A0A2B1e5A4F27, 'Curve All Pools (incl staking)', 'Protocol', '2020-06-20'), + (0x5B67871C3a857dE81A1ca0f9F7945e5670D986Dc, 'Set Protocol', 'Protocol', '2020-01-01'), + (0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 'Uniswap v2', 'Protocol', '2020-01-01'), + (0x9424B1412450D0f8Fc2255FAf6046b98213B76Bd, 'Balancer v1', 'Protocol', '2020-06-20'), + (0xD36132E0c1141B26E62733e018f12Eb38A7b7678, 'Ampleforth Tokengeyser', 'Protocol', '2020-06-20'), + (0x86969d29F5fd327E1009bA66072BE22DB6017cC6, 'Paraswap v1', 'Protocol', '2020-01-01'), + (0x5f9AE054C7F0489888B1ea46824b4B9618f8A711, 'Melon v1', 'Protocol', '2020-06-20'), + (0x1fd169A4f5c59ACf79d0Fd5d91D1201EF1Bce9f1, 'MolochDAO', 'Protocol', '2020-01-01'), + (0xAFcE80b19A8cE13DEc0739a1aaB7A028d6845Eb3, 'mStable', 'Protocol', '2020-06-20'), + (0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F, 'Synthetix', 'Protocol', '2020-06-20'), + (0x2a0c0DBEcC7E4D658f48E01e3fA353F44050c208, 'IDEX v1', 'Protocol', '2020-01-01'), + (0x9AAb3f75489902f3a48495025729a0AF77d4b11e, 'Kyber (Katalyst)', 'Protocol', '2020-07-07'), + (0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C, 'Bancor v2', 'Protocol', '2020-07-23'), + (0x3e532e6222afe9Bcf02DCB87216802c75D5113aE, 'UMA', 'Protocol', '2020-07-30'), + (0x02285AcaafEB533e03A7306C55EC031297df9224, 'dForce Yield Market', 'Protocol', '2020-08-13'), + (0x0e2298E3B3390e3b945a5456fBf59eCc3f55DA16, 'Yam Finance v1', 'Protocol', '2020-08-13'), + (0x3fE7940616e5Bc47b0775a0dccf6237893353bB4, 'Idle v4', 'Protocol', '2020-08-14'), + (0x71CD6666064C3A1354a3B4dca5fA1E2D3ee7D303, 'Mooniswap', 'Protocol', '2020-08-25'), + (0xe20A5C79b39bC8C363f0f49ADcFa82C2a01ab64a, 'tBTC Contracts v1', 'Protocol', '2020-09-28'), + (0xe9778E69a961e64d3cdBB34CF6778281d34667c2, 'NuCypher Worklock', 'Protocol', '2020-09-29'), + (0x4C39b37f5F20a0695BFDC59cf10bd85a6c4B7c30, 'Akropolis Delphi', 'Protocol', '2020-10-01'), + (0x3A97247DF274a17C59A3bd12735ea3FcDFb49950, 'DODO Exchange', 'Protocol', '2020-10-19'), + (0x26aaD4D82f6c9FA6E34D8c1067429C986A055872, 'CoFix', 'Protocol', '2020-10-26'), + (0xCB876f60399897db24058b2d58D0B9f713175eeF, 'Pool Together v3', 'Protocol', '2020-10-28'), + (0xa4c8d221d8BB851f83aadd0223a8900A6921A349, 'Set Protocol v2', 'Protocol', '2020-10-28'), + (0xB94199866Fe06B535d019C11247D3f921460b91A, 'Yield Protocol', 'Protocol', '2020-10-28'), + (0x00000000219ab540356cBB839Cbe05303d7705Fa, 'Eth 2.0 (deposit contract)', 'Protocol', '2020-11-06'), + (0x878F15ffC8b894A1BA7647c7176E4C01f74e140b, 'Hegic', 'Protocol', '2020-11-09'), + (0xfA5047c9c78B8877af97BDcb85Db743fD7313d4a, 'Keeper DAO', 'Protocol', '2020-11-19'), + (0x3d5BC3c8d13dcB8bF317092d84783c2697AE9258, 'CREAM v1', 'Protocol', '2020-11-24'), + (0x7a9701453249e84fd0D5AfE5951e9cBe9ed2E90f, 'TrueFi', 'Protocol', '2020-11-25'), + (0x67B66C99D3Eb37Fa76Aa3Ed1ff33E8e39F0b9c7A, 'Alpha Homora v1', 'Protocol', '2020-11-26'), + (0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9, 'Aave v2', 'Protocol', '2020-12-03'), + (0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd, 'SushiSwap v1', 'Protocol', '2020-12-09'), + (0xedfC81Bf63527337cD2193925f9C0cF2D537AccA, 'Cover Protocol v1', 'Protocol', '2020-12-11'), + (0xA51156F3F1e39d1036Ca4ba4974107A1C1815d1e, 'Perpetual Protocol', 'Protocol', '2020-12-17'), + (0x6354E79F21B56C11f48bcD7c451BE456D7102A36, 'BadgerDAO', 'Protocol', '2020-12-29'), + (0x9abd0b8868546105F6F48298eaDC1D9c82f7f683, 'Notional Finance v1', 'Protocol', '2021-01-18'), + (0xE75D77B1865Ae93c7eaa3040B038D7aA7BC02F70, 'Origin Dollar', 'Protocol', '2021-01-22'), + (0x7C06792Af1632E77cb27a558Dc0885338F4Bdf8E, 'Opyn v2', 'Protocol', '2021-02-25'), + (0xCC88a9d330da1133Df3A7bD823B95e52511A6962, 'Reflexer', 'Protocol', '2021-03-04'), + (0xa4F1671d3Aee73C05b552d57f2d16d3cfcBd0217, 'Vesper', 'Protocol', '2021-03-10'), + (0x5D9972dD3Ba5602574ABeA6bF9E1713568D49903, 'Benchmark Protocol', 'Protocol', '2021-03-22'), + (0xB17640796e4c27a39AF51887aff3F8DC0daF9567, 'Stake DAO', 'Protocol', '2021-03-29'), + (0xA39739EF8b0231DbFA0DcdA07d7e29faAbCf4bb2, 'Liquity', 'Protocol', '2021-04-05'), + (0x284D7200a0Dabb05ee6De698da10d00df164f61d, 'Harvest Finance', 'Protocol', '2021-04-16'), + (0x1F98431c8aD98523631AE4a59f267346ea31F984, 'Uniswap v3', 'Protocol', '2021-05-05'), + (0x4B8d90D68F26DEF303Dcb6CFc9b63A1aAEC15840, 'Barnbridge Smart Yield v1', 'Protocol', '2021-06-14'), + (0xF403C135812408BFbE8713b5A23a04b3D48AAE31, 'Convex Finance v1', 'Protocol', '2021-06-14'), + (0xc21D353FF4ee73C572425697f4F5aaD2109fe35b, 'Alchemix v1', 'Protocol', '2021-06-14'), + (0x99c666810bA4Bf9a4C2318CE60Cb2c279Ee2cF56, 'Homora v2', 'Protocol', '2021-06-23'), + (0xBA12222222228d8Ba445958a75a0704d566BF2C8, 'Balancer v2', 'Protocol', '2021-08-04'), + (0xA625AB01B08ce023B2a342Dbb12a16f2C8489A8F, 'Alpaca Finance', 'Protocol', '2021-08-13'), + (0x08FB62c84909dA3Aa5F59E01763E5FDC62De76e9, 'Gamma Strategies', 'Protocol', '2021-08-20'), + (0x8481a6EbAf5c7DABc3F7e09e44A89531fd31F822, 'Goldfinch', 'Protocol', '2021-09-24'), + (0xc57D000000000000000000000000000000000001, 'Celsius', 'Custody', '2020-12-02'), + (0xC57D000000000000000000000000000000000002, 'BlockFi', 'Custody', '2020-12-02'), + (0xC57d000000000000000000000000000000000003, 'Nexo', 'Custody', '2020-12-02'), + (0xc57d000000000000000000000000000000000004, 'inLock', 'Custody', '2020-12-02'), + (0xC57D000000000000000000000000000000000005, 'Ledn', 'Custody', '2020-12-02'), + (0xC57d000000000000000000000000000000000006, 'Hodlnaut', 'Custody', '2020-12-02'), + (0xC57d000000000000000000000000000000000007, 'Binance', 'Custody', '2021-01-12'), + (0xc57D000000000000000000000000000000000008, 'Coinbase', 'Custody', '2021-01-12'), + (0xc57d000000000000000000000000000000000009, 'Kraken', 'Custody', '2021-01-12'), + (0xc57d000000000000000000000000000000000010, 'Gemini', 'Custody', '2021-01-12'), + (0xC57d000000000000000000000000000000000011, 'FTX', 'Custody', '2021-05-04'), + (0xC57d000000000000000000000000000000000012, 'Crypto.com', 'Custody', '2021-07-06'), + (0xc57d000000000000000000000000000000000013, 'Yield.app', 'Custody', '2021-07-06'), + (0xefa94DE7a4656D787667C749f7E1223D71E9FD88, 'Pangolin', 'Protocol', '2021-10-12'), + (0x0CED6166873038Ac0cc688e7E6d19E2cBE251Bf0, 'Centrifuge Tinlake', 'Protocol', '2021-10-12'), + (0x835482FE0532f169024d5E9410199369aAD5C77E, 'Rari Capital', 'Protocol', '2021-10-12'), + (0xd96f48665a1410C0cd669A88898ecA36B9Fc2cce, 'Abracadabra', 'Protocol', '2021-11-01'), + (0x48D49466CB2EFbF05FaA5fa5E69f2984eDC8d1D7, 'Premia Finance', 'Protocol', '2021-11-04'), + (0x0000000000000000000000000000000000000001, 'Anchor', 'Protocol', '2021-04-26'), + (0x0000000000000000000000000000000000000002, 'Bunny', 'Protocol', '2021-04-26'), + (0x0000000000000000000000000000000000000003, 'Venus', 'Protocol', '2021-04-26'), + (0x0000000000000000000000000000000000000004, 'Thorchain', 'Protocol', '2021-04-26'), + (0x0000000000000000000000000000000000000005, 'Pancakeswap v1', 'Protocol', '2021-04-26'), + (0x0000000000000000000000000000000000000006, 'Yearn yvDAI v2', 'Token', '2021-05-25'), + (0x0000000000000000000000000000000000000007, 'Yearn yvUSDC v2', 'Token', '2021-05-25'), + (0x0000000000000000000000000000000000000008, 'Yearn ycrvstETH v2', 'Token', '2021-05-25'), + (0x0000000000000000000000000000000000000009, 'Curve 3pool LP (3Crv)', 'Token', '2021-05-25'), + (0x0000000000000000000000000000000000000010, 'Curve sETH LP (eCrv)', 'Token', '2021-05-25'), + (0x0000000000000000000000000000000000000011, 'Idle DAI v4 (idleDAIYield)', 'Token', '2021-07-05'), + (0x0000000000000000000000000000000000000012, 'Idle USDT v4 (idleUSDTYield)', 'Token', '2021-07-05'), + (0x0000000000000000000000000000000000000013, 'Convex stethCrv (cvxstethCrv)', 'Token', '2021-10-28'), + (0x0000000000000000000000000000000000000014, 'Convex 3CRV (cvx3CRV)', 'Token', '2021-10-28'), + (0x0000000000000000000000000000000000000015, 'Convex mimCrv (cvxmimCrv)', 'Token', '2021-10-28'), + (0xaE7b92C8B14E7bdB523408aE0A6fFbf3f589adD9, 'Popsicle Finance', 'Protocol', '2021-11-10'), + (0x1344A36A1B56144C3Bc62E7757377D288fDE0369, 'Notional Finance v2', 'Protocol', '2021-11-22'), + (0x575409F8d77c12B05feD8B455815f0e54797381c, 'OlympusDAO', 'Protocol', '2021-11-29'), + (0x25751853Eab4D0eB3652B5eB6ecB102A2789644B, 'Ribbon Finance v2', 'Protocol', '2021-12-06'), + (0xd89a09084555a7D0ABe7B111b1f78DFEdDd638Be, 'Pool Together v4', 'Protocol', '2021-12-09'), + (0x60aE616a2155Ee3d9A68541Ba4544862310933d4, 'Trader Joe', 'Protocol', '2021-12-14'), + (0x0000000000000000000000000000000000000016, 'Origin OUSD', 'Token', '2022-01-24'), + (0x2BB8de958134AFd7543d4063CaFAD0b7c6de08BC, 'Ondo', 'Protocol', '2022-01-28'), + (0x7e6d3b1161DF9c9c7527F68d651B297d2Fdb820B, 'Enzyme v3', 'Protocol', '2022-02-16'), + (0x453D4Ba9a2D594314DF88564248497F7D74d6b2C, 'Beefy', 'Protocol', '2022-03-04'), + (0xfdA462548Ce04282f4B6D6619823a7C64Fdc0185, 'Angle', 'Protocol', '2022-03-08'), + (0x66357dCaCe80431aee0A7507e2E361B7e2402370, 'Platypus', 'Protocol', '2022-03-18'), + (0x0000000000000000000000000000000000000017, 'FODL', 'Protocol', '2022-03-24'), + (0x5C6374a2ac4EBC38DeA0Fc1F8716e5Ea1AdD94dd, 'Alchemix v2', 'Protocol', '2022-03-24'), + (0x0000000000000000000000000000000000000018, 'Bundle: Gelt + mStable + Aave v2', 'Protocol', '2022-04-14'), + (0x0000000000000000000000000000000000000019, 'Yeti Finance', 'Protocol', '2022-04-28'), + (0x0000000000000000000000000000000000000020, 'Babylon Finance', 'Protocol', '2022-05-12'), + (0x0000000000000000000000000000000000000021, 'Vector', 'Protocol', '2022-05-12'), + (0x0000000000000000000000000000000000000022, 'Bancor v3', 'Protocol', '2022-05-12'), + (0x0000000000000000000000000000000000000023, 'Ease', 'Protocol', '2022-05-31'), + (0x0000000000000000000000000000000000000024, 'Iron Bank', 'Protocol', '2022-06-08'), + (0x0000000000000000000000000000000000000025, 'Stakewise operated (3 ETH / validator)', 'Eth2slashing', '2022-06-08'), + (0x0000000000000000000000000000000000000026, 'Stakewise 3rd party (3 ETH / validator)', 'Eth2slashing', '2022-06-08'), + (0x0000000000000000000000000000000000000027, 'Nested', 'Protocol', '2022-07-05'), + (0x0000000000000000000000000000000000000028, 'Euler', 'Protocol', '2022-08-29'), + (0x3D6bA331e3D9702C5e8A8d254e5d8a285F223aba, 'GMX', 'Protocol', '2022-09-01'), + (0x0000000000000000000000000000000000000029, 'Sherlock', 'Sherlock', '2022-10-17'), + (0x0000000000000000000000000000000000000030, 'Gearbox V2', 'Protocol', '2022-10-31'), + (0x0000000000000000000000000000000000000031, 'Aura', 'Protocol', '2022-11-16'), + (0x0000000000000000000000000000000000000032, 'Enzyme v4', 'Protocol', '2022-11-16') +) t (product_contract_address, product_name, product_type, date_added) diff --git a/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_products_v2.sql b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_products_v2.sql new file mode 100644 index 00000000000..7f65e2cbfa9 --- /dev/null +++ b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_products_v2.sql @@ -0,0 +1,145 @@ +{{ + config( + schema = 'nexusmutual_ethereum', + alias = 'products_v2', + materialized = 'view', + post_hook = '{{ expose_spells(\'["ethereum"]\', + "project", + "nexusmutual", + \'["tomfutago"]\') }}' + ) +}} + +with + +product_events as ( + select + evt_block_time as block_time, + evt_block_number as block_number, + id as product_id, + ipfsMetadata as evt_product_ipfs_metadata, + evt_index, + evt_tx_hash as tx_hash + from {{ source('nexusmutual_ethereum', 'Cover_evt_ProductSet') }} +), + +product_calls as ( + 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', 'Cover_call_setProducts') }} + where call_success + and contract_address = 0xcafeac0ff5da0a2777d915531bfa6b29d282ee62 +), + +product_data_raw as ( + select + p.block_time, + p.block_number, + p.productParams, + cast(json_extract_scalar(t.product_param, '$.productId') as uint256) as product_id, + json_extract_scalar(t.product_param, '$.productName') as product_name, + json_extract_scalar(t.product_param, '$.ipfsMetadata') as call_product_ipfs_metadata, + array_join(cast(json_extract(t.product_param, '$.allowedPools') as array(varchar)), ', ') as allowed_pools, + json_parse(json_query(t.product_param, 'lax $.product' omit quotes)) as product_json, + t.product_ordinality, + p.tx_hash + from product_calls p + cross join unnest (p.productParams) with ordinality as t(product_param, product_ordinality) + where p.tx_call_rn = 1 +), + +product_data as ( + select + block_time, + block_number, + product_id, + case + when product_id > 1000000 then row_number() over (partition by if(product_id < 1000000, 0, 1) order by block_time, product_ordinality) - 1 + else product_id + end as product_id_rn, + product_name, + cast(json_extract_scalar(product_json, '$.productType') as int) as product_type_id, + try_cast(json_extract_scalar(product_json, '$.capacityReductionRatio') as int) as capacity_reduction_ratio, + try_cast(json_extract_scalar(product_json, '$.coverAssets') as int) as cover_assets, + try_cast(json_extract_scalar(product_json, '$.initialPriceRatio') as int) as initial_price_ratio, + cast(json_extract_scalar(product_json, '$.isDeprecated') as boolean) as is_deprecated, + cast(json_extract_scalar(product_json, '$.useFixedPrice') as boolean) as use_fixed_price, + from_hex(json_extract_scalar(product_json, '$.yieldTokenAddress')) as yield_token_address, + call_product_ipfs_metadata, + allowed_pools, + product_ordinality, + tx_hash + from product_data_raw +), + +products_ext as ( + select + c.block_time, + c.block_number, + c.product_id_rn as product_id, + c.product_name, + c.product_type_id, + c.capacity_reduction_ratio, + c.cover_assets, + c.initial_price_ratio, + c.is_deprecated, + c.use_fixed_price, + c.yield_token_address, + c.allowed_pools, + coalesce(e.evt_product_ipfs_metadata, c.call_product_ipfs_metadata) as product_ipfs_metadata, + coalesce(e.evt_index, 0) as evt_index, + c.tx_hash + from product_data c + left join product_events e on e.block_time = c.block_time and e.block_number = c.block_number and e.product_id = c.product_id_rn +), + +products as ( + select + block_time, + block_number, + product_type_id, + product_id, + product_name, + case cover_assets + when 0 then 'ETH, DAI, USDC' + when 1 then 'ETH' + when 2 then 'DAI' + when 65 then 'ETH, USDC' + when 66 then 'DAI, USDC' + else 'unkown' + end as cover_assets, + is_deprecated, + initial_price_ratio, + use_fixed_price, + capacity_reduction_ratio, + allowed_pools, + yield_token_address, + product_ipfs_metadata, + evt_index, + tx_hash, + row_number() over (partition by product_id order by block_time desc) as rn + from products_ext +) + +select + block_time, + block_number, + product_type_id, + product_id, + product_name, + cover_assets, + is_deprecated, + initial_price_ratio, + use_fixed_price, + capacity_reduction_ratio, + allowed_pools, + yield_token_address, + product_ipfs_metadata, + evt_index, + tx_hash +from products +where rn = 1 diff --git a/models/nexusmutual/ethereum/nexusmutual_ethereum_quotation_trades.sql b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_quotation_trades.sql similarity index 91% rename from models/nexusmutual/ethereum/nexusmutual_ethereum_quotation_trades.sql rename to models/nexusmutual/ethereum/covers/nexusmutual_ethereum_quotation_trades.sql index da7076879a7..40748010a99 100644 --- a/models/nexusmutual/ethereum/nexusmutual_ethereum_quotation_trades.sql +++ b/models/nexusmutual/ethereum/covers/nexusmutual_ethereum_quotation_trades.sql @@ -1,15 +1,11 @@ {{ config( + schema = 'nexusmutual_ethereum', alias = 'quotation_trades', - partition_by = ['block_month'], materialized = 'incremental', file_format = 'delta', incremental_strategy = 'merge', - unique_key = ['block_date', 'evt_tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["ethereum"]\', - "project", - "nexusmutual", - \'["sharkxff"]\') }}' + unique_key = ['block_date', 'evt_tx_hash', 'evt_index'] ) }} diff --git a/models/nexusmutual/ethereum/nexusmutual_ethereum_product_information.sql b/models/nexusmutual/ethereum/nexusmutual_ethereum_product_information.sql deleted file mode 100755 index a033d2a112c..00000000000 --- a/models/nexusmutual/ethereum/nexusmutual_ethereum_product_information.sql +++ /dev/null @@ -1,188 +0,0 @@ -{{ config( - alias = 'product_information', - materialized='table', - file_format = 'delta', - tags=['static'], - unique_key = ['product_contract_address'], - post_hook='{{ expose_spells(\'["ethereum"]\', - "project", - "nexusmutual", - \'["guyhowlett"]\') }}' - ) -}} - -SELECT product_contract_address, - product_name, - product_type, - date_added, - syndicate -FROM ( -VALUES - (0xF5DCe57282A584D2746FaF1593d3121Fcac444dC, 'Compound Sai', 'Protocol', '2020-01-01', 'v1'), - (0x8B3d70d628Ebd30D4A2ea82DB95bA2e906c71633, 'bZx v1', 'Protocol', '2020-01-01', 'v1'), - (0x5504a1d88005236147EC86C62cfb53043bD1276a, 'Unknown', 'Protocol', '2020-01-01', 'v1'), - (0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5, 'Compound ETH', 'Protocol', '2020-01-01', 'v1'), - (0x080bf510FCbF18b91105470639e9561022937712, '0x v2.1', 'Protocol', '2020-01-01', 'v1'), - (0x16de59092dAE5CcF4A1E6439D611fd0653f0Bd01, 'iearn yDAI v1', 'Protocol', '2020-01-01', 'v1'), - (0xAF350211414C5DC176421Ea05423F0cC494261fB, 'Saturn DAO Token', 'Protocol', '2020-01-01', 'v1'), - (0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643, 'Compound DAI', 'Protocol', '2020-01-01', 'v1'), - (0x2157A7894439191e520825fe9399aB8655E0f708, 'Uniswap Exchange Template', 'Protocol', '2020-01-01', 'v1'), - (0x9f8F72aA9304c8B593d555F12eF6589cC3A579A2, 'Maker Token', 'Protocol', '2020-01-01', 'v1'), - (0x6e95C8E8557AbC08b46F3c347bA06F8dC012763f, 'Legacy Gnosis MultiSig', 'Protocol', '2020-01-01', 'v1'), - (0xb1CD6e4153B2a390Cf00A6556b0fC1458C4A5533, 'Bancor ETHBNT Token', 'Protocol', '2020-01-01', 'v1'), - (0x29fe7D60DdF151E5b52e5FAB4f1325da6b2bD958, 'Pool Together DAI', 'Protocol', '2020-01-01', 'v1'), - (0x4a57E687b9126435a9B19E4A802113e266AdeBde, 'Flexacoin Token', 'Protocol', '2020-01-01', 'v1'), - (0x519b70055af55A007110B4Ff99b0eA33071c720a, 'dxDAO', 'Protocol', '2020-01-01', 'v1'), - (0x802275979B020F0ec871c5eC1db6e412b72fF20b, 'Nuo', 'Protocol', '2020-01-01', 'v1'), - (0xb7896fce748396EcFC240F5a0d3Cc92ca42D7d84, 'Pool Together SAI', 'Protocol', '2020-01-01', 'v1'), - (0x932773aE4B661029704e731722CF8129e1B32494, 'Pool Together v2', 'Protocol', '2020-01-01', 'v1'), - (0xB1dD690Cc9AF7BB1a906A9B5A94F94191cc553Ce, 'Argent', 'Protocol', '2020-01-01', 'v1'), - (0x2b591e99afE9f32eAA6214f7B7629768c40Eeb39, 'Hex Token', 'Protocol', '2020-01-01', 'v1'), - (0x2C4Bd064b998838076fa341A83d007FC2FA50957, 'Uniswap v1 MKR Pool', 'Protocol', '2020-01-01', 'v1'), - (0x364508A5cA0538d8119D3BF40A284635686C98c4, 'dydx Perpetual', 'Protocol', '2020-01-01', 'v1'), - (0x6B175474E89094C44Da98b954EedeAC495271d0F, 'DAI Token', 'Protocol', '2020-01-01', 'v1'), - (0xD5D2b9e9bcd172D5fC8521AFd2C98Dd239F5b607, 'Unknown', 'Protocol', '2020-01-01', 'v1'), - (0x241e82C79452F51fbfc89Fac6d912e021dB1a3B7, 'DDEX', 'Protocol', '2020-01-01', 'v1'), - (0x12D66f87A04A9E220743712cE6d9bB1B5616B8Fc, 'Tornado Cash', 'Protocol', '2020-01-01', 'v1'), - (0x5d22045DAcEAB03B158031eCB7D9d06Fad24609b, 'Deversifi', 'Protocol', '2020-06-20', 'v1'), - (0x498b3BfaBE9F73db90D252bCD4Fa9548Cd0Fd981, 'Instadapp Registry', 'Protocol', '2020-01-01', 'v1'), - (0x448a5065aeBB8E423F0896E6c5D525C040f59af3, 'Maker SCD', 'Protocol', '2020-01-01', 'v1'), - (0xe80d347DF1209a76DD9d2319d62912ba98C54DDD, 'RenVM', 'Protocol', '2020-06-20', 'v1'), - (0xB27F1DB0a7e473304A5a06E54bdf035F671400C0, '0x v3', 'Protocol', '2020-01-01', 'v1'), - (0x1E0447b19BB6EcFdAe1e4AE1694b0C3659614e4e, 'dydx Margin', 'Protocol', '2020-01-01', 'v1'), - (0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B, 'Compound v2', 'Protocol', '2020-01-01', 'v1'), - (0x34CfAC646f301356fAa8B21e94227e3583Fe3F5F, 'Gnosis Safe', 'Protocol', '2020-01-01', 'v1'), - (0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95, 'Uniswap v1', 'Protocol', '2020-01-01', 'v1'), - (0x35D1b3F3D7966A1DFe207aa4514C12a259A0492B, 'MakerDAO MCD', 'Protocol', '2020-01-01', 'v1'), - (0x72338b82800400F5488eCa2B5A37270ba3B7A111, 'Paraswap - OLD', 'Protocol', '2020-01-01', 'v1'), - (0xc1D2819CE78f3E15Ee69c6738eB1B400A26e632A, 'Aave v1', 'Protocol', '2020-01-01', 'v1'), - (0x10eC0D497824e342bCB0EDcE00959142aAa766dD, 'Idle Finance - OLD', 'Protocol', '2020-01-01', 'v1'), - (0x3dfd23A6c5E8BbcFc9581d2E864a68feb6a076d3, 'Aave Lending Core', 'Protocol', '2020-01-01', 'v1'), - (0x45F783CCE6B7FF23B2ab2D70e416cdb7D6055f51, 'Curve fi - OLD', 'Protocol', '2020-01-01', 'v1'), - (0x11111254369792b2Ca5d084aB5eEA397cA8fa48B, '1Inch (DEX & Liquidity Pools)', 'Protocol', '2020-01-01', 'v1'), - (0xF92C1ad75005E6436B4EE84e88cB23Ed8A290988, 'Paraswap OLD', 'Protocol', '2020-01-01', 'v1'), - (0xb529964F86fbf99a6aA67f72a27e59fA3fa4FEaC, 'Opyn', 'Protocol', '2020-01-01', 'v1'), - (0x9D25057e62939D3408406975aD75Ffe834DA4cDd, 'Yearn Finance (all vaults)', 'Protocol', '2020-01-01', 'v1'), - (0x77208a6000691E440026bEd1b178EF4661D37426, 'Totle', 'Protocol', '2020-01-01', 'v1'), - (0x12f208476F64De6e6f933E55069Ba9596D818e08, 'Flexa Staking', 'Protocol', '2020-01-01', 'v1'), - (0x78751B12Da02728F467A44eAc40F5cbc16Bd7934, 'Idle v3', 'Protocol', '2020-06-20', 'v1'), - (0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714, 'Curve BTC Pools', 'Protocol', '2020-06-20', 'v1'), - (0x79a8C46DeA5aDa233ABaFFD40F3A0A2B1e5A4F27, 'Curve All Pools (incl staking)', 'Protocol', '2020-06-20', 'v1'), - (0x5B67871C3a857dE81A1ca0f9F7945e5670D986Dc, 'Set Protocol', 'Protocol', '2020-01-01', 'v1'), - (0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f, 'Uniswap v2', 'Protocol', '2020-01-01', 'v1'), - (0x9424B1412450D0f8Fc2255FAf6046b98213B76Bd, 'Balancer v1', 'Protocol', '2020-06-20', 'v1'), - (0xD36132E0c1141B26E62733e018f12Eb38A7b7678, 'Ampleforth Tokengeyser', 'Protocol', '2020-06-20', 'v1'), - (0x86969d29F5fd327E1009bA66072BE22DB6017cC6, 'Paraswap v1', 'Protocol', '2020-01-01', 'v1'), - (0x5f9AE054C7F0489888B1ea46824b4B9618f8A711, 'Melon v1', 'Protocol', '2020-06-20', 'v1'), - (0x1fd169A4f5c59ACf79d0Fd5d91D1201EF1Bce9f1, 'MolochDAO', 'Protocol', '2020-01-01', 'v1'), - (0xAFcE80b19A8cE13DEc0739a1aaB7A028d6845Eb3, 'mStable', 'Protocol', '2020-06-20', 'v1'), - (0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F, 'Synthetix', 'Protocol', '2020-06-20', 'v1'), - (0x2a0c0DBEcC7E4D658f48E01e3fA353F44050c208, 'IDEX v1', 'Protocol', '2020-01-01', 'v1'), - (0x9AAb3f75489902f3a48495025729a0AF77d4b11e, 'Kyber (Katalyst)', 'Protocol', '2020-07-07', 'v1'), - (0x1F573D6Fb3F13d689FF844B4cE37794d79a7FF1C, 'Bancor v2', 'Protocol', '2020-07-23', 'v1'), - (0x3e532e6222afe9Bcf02DCB87216802c75D5113aE, 'UMA', 'Protocol', '2020-07-30', 'v1'), - (0x02285AcaafEB533e03A7306C55EC031297df9224, 'dForce Yield Market', 'Protocol', '2020-08-13', 'v1'), - (0x0e2298E3B3390e3b945a5456fBf59eCc3f55DA16, 'Yam Finance v1', 'Protocol', '2020-08-13', 'v1'), - (0x3fE7940616e5Bc47b0775a0dccf6237893353bB4, 'Idle v4', 'Protocol', '2020-08-14', 'v1'), - (0x71CD6666064C3A1354a3B4dca5fA1E2D3ee7D303, 'Mooniswap', 'Protocol', '2020-08-25', 'v1'), - (0xe20A5C79b39bC8C363f0f49ADcFa82C2a01ab64a, 'tBTC Contracts v1', 'Protocol', '2020-09-28', 'v1'), - (0xe9778E69a961e64d3cdBB34CF6778281d34667c2, 'NuCypher Worklock', 'Protocol', '2020-09-29', 'v1'), - (0x4C39b37f5F20a0695BFDC59cf10bd85a6c4B7c30, 'Akropolis Delphi', 'Protocol', '2020-10-01', 'v1'), - (0x3A97247DF274a17C59A3bd12735ea3FcDFb49950, 'DODO Exchange', 'Protocol', '2020-10-19', 'v1'), - (0x26aaD4D82f6c9FA6E34D8c1067429C986A055872, 'CoFix', 'Protocol', '2020-10-26', 'v1'), - (0xCB876f60399897db24058b2d58D0B9f713175eeF, 'Pool Together v3', 'Protocol', '2020-10-28', 'v1'), - (0xa4c8d221d8BB851f83aadd0223a8900A6921A349, 'Set Protocol v2', 'Protocol', '2020-10-28', 'v1'), - (0xB94199866Fe06B535d019C11247D3f921460b91A, 'Yield Protocol', 'Protocol', '2020-10-28', 'v1'), - (0x00000000219ab540356cBB839Cbe05303d7705Fa, 'Eth 2.0 (deposit contract)', 'Protocol', '2020-11-06', 'v1'), - (0x878F15ffC8b894A1BA7647c7176E4C01f74e140b, 'Hegic', 'Protocol', '2020-11-09', 'v1'), - (0xfA5047c9c78B8877af97BDcb85Db743fD7313d4a, 'Keeper DAO', 'Protocol', '2020-11-19', 'v1'), - (0x3d5BC3c8d13dcB8bF317092d84783c2697AE9258, 'CREAM v1', 'Protocol', '2020-11-24', 'v1'), - (0x7a9701453249e84fd0D5AfE5951e9cBe9ed2E90f, 'TrueFi', 'Protocol', '2020-11-25', 'v1'), - (0x67B66C99D3Eb37Fa76Aa3Ed1ff33E8e39F0b9c7A, 'Alpha Homora v1', 'Protocol', '2020-11-26', 'v1'), - (0x7d2768dE32b0b80b7a3454c06BdAc94A69DDc7A9, 'Aave v2', 'Protocol', '2020-12-03', 'v1'), - (0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd, 'SushiSwap v1', 'Protocol', '2020-12-09', 'v1'), - (0xedfC81Bf63527337cD2193925f9C0cF2D537AccA, 'Cover Protocol v1', 'Protocol', '2020-12-11', 'v1'), - (0xA51156F3F1e39d1036Ca4ba4974107A1C1815d1e, 'Perpetual Protocol', 'Protocol', '2020-12-17', 'v1'), - (0x6354E79F21B56C11f48bcD7c451BE456D7102A36, 'BadgerDAO', 'Protocol', '2020-12-29', 'v1'), - (0x9abd0b8868546105F6F48298eaDC1D9c82f7f683, 'Notional Finance v1', 'Protocol', '2021-01-18', 'v1'), - (0xE75D77B1865Ae93c7eaa3040B038D7aA7BC02F70, 'Origin Dollar', 'Protocol', '2021-01-22', 'v1'), - (0x7C06792Af1632E77cb27a558Dc0885338F4Bdf8E, 'Opyn v2', 'Protocol', '2021-02-25', 'v1'), - (0xCC88a9d330da1133Df3A7bD823B95e52511A6962, 'Reflexer', 'Protocol', '2021-03-04', 'v1'), - (0xa4F1671d3Aee73C05b552d57f2d16d3cfcBd0217, 'Vesper', 'Protocol', '2021-03-10', 'v1'), - (0x5D9972dD3Ba5602574ABeA6bF9E1713568D49903, 'Benchmark Protocol', 'Protocol', '2021-03-22', 'v1'), - (0xB17640796e4c27a39AF51887aff3F8DC0daF9567, 'Stake DAO', 'Protocol', '2021-03-29', 'v1'), - (0xA39739EF8b0231DbFA0DcdA07d7e29faAbCf4bb2, 'Liquity', 'Protocol', '2021-04-05', 'v1'), - (0x284D7200a0Dabb05ee6De698da10d00df164f61d, 'Harvest Finance', 'Protocol', '2021-04-16', 'v1'), - (0x1F98431c8aD98523631AE4a59f267346ea31F984, 'Uniswap v3', 'Protocol', '2021-05-05', 'v1'), - (0x4B8d90D68F26DEF303Dcb6CFc9b63A1aAEC15840, 'Barnbridge Smart Yield v1', 'Protocol', '2021-06-14', 'v1'), - (0xF403C135812408BFbE8713b5A23a04b3D48AAE31, 'Convex Finance v1', 'Protocol', '2021-06-14', 'v1'), - (0xc21D353FF4ee73C572425697f4F5aaD2109fe35b, 'Alchemix v1', 'Protocol', '2021-06-14', 'v1'), - (0x99c666810bA4Bf9a4C2318CE60Cb2c279Ee2cF56, 'Homora v2', 'Protocol', '2021-06-23', 'v1'), - (0xBA12222222228d8Ba445958a75a0704d566BF2C8, 'Balancer v2', 'Protocol', '2021-08-04', 'v1'), - (0xA625AB01B08ce023B2a342Dbb12a16f2C8489A8F, 'Alpaca Finance', 'Protocol', '2021-08-13', 'v1'), - (0x08FB62c84909dA3Aa5F59E01763E5FDC62De76e9, 'Gamma Strategies', 'Protocol', '2021-08-20', 'v1'), - (0x8481a6EbAf5c7DABc3F7e09e44A89531fd31F822, 'Goldfinch', 'Protocol', '2021-09-24', 'v1'), - (0xc57D000000000000000000000000000000000001, 'Celsius', 'Custody', '2020-12-02', 'v1'), - (0xC57D000000000000000000000000000000000002, 'BlockFi', 'Custody', '2020-12-02', 'v1'), - (0xC57d000000000000000000000000000000000003, 'Nexo', 'Custody', '2020-12-02', 'v1'), - (0xc57d000000000000000000000000000000000004, 'inLock', 'Custody', '2020-12-02', 'v1'), - (0xC57D000000000000000000000000000000000005, 'Ledn', 'Custody', '2020-12-02', 'v1'), - (0xC57d000000000000000000000000000000000006, 'Hodlnaut', 'Custody', '2020-12-02', 'v1'), - (0xC57d000000000000000000000000000000000007, 'Binance', 'Custody', '2021-01-12', 'v1'), - (0xc57D000000000000000000000000000000000008, 'Coinbase', 'Custody', '2021-01-12', 'v1'), - (0xc57d000000000000000000000000000000000009, 'Kraken', 'Custody', '2021-01-12', 'v1'), - (0xc57d000000000000000000000000000000000010, 'Gemini', 'Custody', '2021-01-12', 'v1'), - (0xC57d000000000000000000000000000000000011, 'FTX', 'Custody', '2021-05-04', 'v1'), - (0xC57d000000000000000000000000000000000012, 'Crypto.com', 'Custody', '2021-07-06', 'v1'), - (0xc57d000000000000000000000000000000000013, 'Yield.app', 'Custody', '2021-07-06', 'v1'), - (0xefa94DE7a4656D787667C749f7E1223D71E9FD88, 'Pangolin', 'Protocol', '2021-10-12', 'v1'), - (0x0CED6166873038Ac0cc688e7E6d19E2cBE251Bf0, 'Centrifuge Tinlake', 'Protocol', '2021-10-12', 'v1'), - (0x835482FE0532f169024d5E9410199369aAD5C77E, 'Rari Capital', 'Protocol', '2021-10-12', 'v1'), - (0xd96f48665a1410C0cd669A88898ecA36B9Fc2cce, 'Abracadabra', 'Protocol', '2021-11-01', 'v1'), - (0x48D49466CB2EFbF05FaA5fa5E69f2984eDC8d1D7, 'Premia Finance', 'Protocol', '2021-11-04', 'v1'), - (0x0000000000000000000000000000000000000001, 'Anchor', 'Protocol', '2021-04-26', 'v1'), - (0x0000000000000000000000000000000000000002, 'Bunny', 'Protocol', '2021-04-26', 'v1'), - (0x0000000000000000000000000000000000000003, 'Venus', 'Protocol', '2021-04-26', 'v1'), - (0x0000000000000000000000000000000000000004, 'Thorchain', 'Protocol', '2021-04-26', 'v1'), - (0x0000000000000000000000000000000000000005, 'Pancakeswap v1', 'Protocol', '2021-04-26', 'v1'), - (0x0000000000000000000000000000000000000006, 'Yearn yvDAI v2', 'Token', '2021-05-25', 'v1'), - (0x0000000000000000000000000000000000000007, 'Yearn yvUSDC v2', 'Token', '2021-05-25', 'v1'), - (0x0000000000000000000000000000000000000008, 'Yearn ycrvstETH v2', 'Token', '2021-05-25', 'v1'), - (0x0000000000000000000000000000000000000009, 'Curve 3pool LP (3Crv)', 'Token', '2021-05-25', 'v1'), - (0x0000000000000000000000000000000000000010, 'Curve sETH LP (eCrv)', 'Token', '2021-05-25', 'v1'), - (0x0000000000000000000000000000000000000011, 'Idle DAI v4 (idleDAIYield)', 'Token', '2021-07-05', 'v1'), - (0x0000000000000000000000000000000000000012, 'Idle USDT v4 (idleUSDTYield)', 'Token', '2021-07-05', 'v1'), - (0x0000000000000000000000000000000000000013, 'Convex stethCrv (cvxstethCrv)', 'Token', '2021-10-28', 'v1'), - (0x0000000000000000000000000000000000000014, 'Convex 3CRV (cvx3CRV)', 'Token', '2021-10-28', 'v1'), - (0x0000000000000000000000000000000000000015, 'Convex mimCrv (cvxmimCrv)', 'Token', '2021-10-28', 'v1'), - (0xaE7b92C8B14E7bdB523408aE0A6fFbf3f589adD9, 'Popsicle Finance', 'Protocol', '2021-11-10', 'v1'), - (0x1344A36A1B56144C3Bc62E7757377D288fDE0369, 'Notional Finance v2', 'Protocol', '2021-11-22', 'v1'), - (0x575409F8d77c12B05feD8B455815f0e54797381c, 'OlympusDAO', 'Protocol', '2021-11-29', 'v1'), - (0x25751853Eab4D0eB3652B5eB6ecB102A2789644B, 'Ribbon Finance v2', 'Protocol', '2021-12-06', 'v1'), - (0xd89a09084555a7D0ABe7B111b1f78DFEdDd638Be, 'Pool Together v4', 'Protocol', '2021-12-09', 'v1'), - (0x60aE616a2155Ee3d9A68541Ba4544862310933d4, 'Trader Joe', 'Protocol', '2021-12-14', 'v1'), - (0x0000000000000000000000000000000000000016, 'Origin OUSD', 'Token', '2022-01-24', 'v1'), - (0x2BB8de958134AFd7543d4063CaFAD0b7c6de08BC, 'Ondo', 'Protocol', '2022-01-28', 'v1'), - (0x7e6d3b1161DF9c9c7527F68d651B297d2Fdb820B, 'Enzyme v3', 'Protocol', '2022-02-16', 'v1'), - (0x453D4Ba9a2D594314DF88564248497F7D74d6b2C, 'Beefy', 'Protocol', '2022-03-04', 'v1'), - (0xfdA462548Ce04282f4B6D6619823a7C64Fdc0185, 'Angle', 'Protocol', '2022-03-08', 'v1'), - (0x66357dCaCe80431aee0A7507e2E361B7e2402370, 'Platypus', 'Protocol', '2022-03-18', 'v1'), - (0x0000000000000000000000000000000000000017, 'FODL', 'Protocol', '2022-03-24', 'v1'), - (0x5C6374a2ac4EBC38DeA0Fc1F8716e5Ea1AdD94dd, 'Alchemix v2', 'Protocol', '2022-03-24', 'v1'), - (0x0000000000000000000000000000000000000018, 'Bundle: Gelt + mStable + Aave v2', 'Protocol', '2022-04-14', 'v1'), - (0x0000000000000000000000000000000000000019, 'Yeti Finance', 'Protocol', '2022-04-28', 'v1'), - (0x0000000000000000000000000000000000000020, 'Babylon Finance', 'Protocol', '2022-05-12', 'v1'), - (0x0000000000000000000000000000000000000021, 'Vector', 'Protocol', '2022-05-12', 'v1'), - (0x0000000000000000000000000000000000000022, 'Bancor v3', 'Protocol', '2022-05-12', 'v1'), - (0x0000000000000000000000000000000000000023, 'Ease', 'Protocol', '2022-05-31', 'v1'), - (0x0000000000000000000000000000000000000024, 'Iron Bank', 'Protocol', '2022-06-08', 'v1'), - (0x0000000000000000000000000000000000000025, 'Stakewise operated (3 ETH / validator)', 'Eth2slashing', '2022-06-08', 'v1'), - (0x0000000000000000000000000000000000000026, 'Stakewise 3rd party (3 ETH / validator)', 'Eth2slashing', '2022-06-08', 'v1'), - (0x0000000000000000000000000000000000000027, 'Nested', 'Protocol', '2022-07-05', 'v1'), - (0x0000000000000000000000000000000000000028, 'Euler', 'Protocol', '2022-08-29', 'v1'), - (0x3D6bA331e3D9702C5e8A8d254e5d8a285F223aba, 'GMX', 'Protocol', '2022-09-01', 'v1'), - (0x0000000000000000000000000000000000000029, 'Sherlock', 'Sherlock', '2022-10-17', 'v1'), - (0x0000000000000000000000000000000000000030, 'Gearbox V2', 'Protocol', '2022-10-31', 'v1'), - (0x0000000000000000000000000000000000000031, 'Aura', 'Protocol', '2022-11-16', 'v1'), - (0x0000000000000000000000000000000000000032, 'Enzyme v4', 'Protocol', '2022-11-16', 'v1') -) temp (product_contract_address, product_name, product_type, date_added, syndicate) diff --git a/models/nexusmutual/ethereum/nexusmutual_ethereum_schema.yml b/models/nexusmutual/ethereum/nexusmutual_ethereum_schema.yml index 9889e261c89..22817d2a9c7 100644 --- a/models/nexusmutual/ethereum/nexusmutual_ethereum_schema.yml +++ b/models/nexusmutual/ethereum/nexusmutual_ethereum_schema.yml @@ -1,272 +1 @@ version: 2 - -models: - - name: nexusmutual_ethereum_product_information - meta: - blockchain: ethereum - project: nexusmutual - contributors: [guyhow] - description: > - nexusmutual product information for v1 - tests: - - check_seed: - seed_file: ref("nexusmutual_ethereum_product_information_seed") - match_columns: - - product_contract_address - check_columns: - - product_name - - product_type - - syndicate - columns: - - &date_added - name: date_added - - &product_contract_address - name: product_contract_address - tests: - - unique - - &product_name - name: product_name - - &product_type - name: product_type - tests: - - accepted_values: - values: [ "Protocol", "Custody", "Token", "Eth2slashing", "Sherlock"] - - &syndicate - name: syndicate - - - name: nexusmutual_ethereum_quotation_trades - meta: - blockchain: ethereum - project: nexusmutual - contributors: [zxf, jonah] - config: - tags: ["ethereum","nexusmutual","quotation_trades"] - description: > - nexusmutual quotation trades on Ethereum - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - block_date - - evt_tx_hash - - evt_index - - cid - - check_seed: - seed_file: ref("nexusmutual_ethereum_trades_seed") - match_columns: - - evt_tx_hash - check_columns: - - premium - - premium_nxm - - sum_assured - columns: - - &cid - name: cid - - &contract_address - name: contract_address - - &symbol - name: symbol - - &evt_index - name: evt_index - - &evt_tx_hash - name: evt_tx_hash - - &curr - name: curr - - &premium - name: premium - tests: - - not_null - - &pre_amount - name: pre_amount - - &premium_nxm - name: premium_nxm - tests: - - not_null - - &pre_nxm_amount - name: pre_nxm_amount - - &sc_add - name: sc_add - - &sum_assured - name: sum_assured - tests: - - not_null - - &block_hash - name: block_hash - - &nonce - name: nonce - - &gas_limit - name: gas_limit - - &gas_price - name: gas_price - - &gas_used - name: gas_used - - &max_fee_per_gas - name: max_fee_per_gas - - &max_priority_fee_per_gas - name: max_priority_fee_per_gas - - &priority_fee_per_gas - name: priority_fee_per_gas - - &success - name: success - - &tx_type - name: tx_type - - &tx_value - name: tx_value - - &evt_block_number - name: evt_block_number - - &evt_block_time - name: evt_block_time - - &evt_expiry - name: evt_expiry - - &evt_expiry_date - name: evt_expiry_date - - &block_date - name: block_date - description: "UTC event block date of each DEX trade" - - &token_address - name: token_address - - - name: nexusmutual_ethereum_staking_pools - meta: - blockchain: ethereum - project: nexusmutual - contributors: tomfutago - config: - tags: ["ethereum","nexusmutual","staking"] - description: "Staking pools base data for Nexus Mutual on Ethereum" - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - pool_id - - product_id - columns: - - &pool_id - name: pool_id - description: "pool id" - - &pool_address - name: pool_address - description: "pool contract deployment address" - - &pool_name - name: pool_name - description: "pool name" - - &manager_address - name: manager_address - description: "manager address" - - &manager_ens - name: manager_ens - description: "manager ENS name (if available)" - - &manager - name: manager - description: "manager ENS name or address if ENS unavailable" - - &is_private_pool - name: is_private_pool - description: "is private pool? true/false" - - &initial_pool_fee - name: initial_pool_fee - description: "initial pool management fee" - - ¤t_pool_fee - name: current_pool_fee - description: "current pool management fee" - - &max_management_fee - name: max_management_fee - description: "max pool management fee" - - &product_id - name: product_id - description: "product id" - - &initial_price - name: initial_price - description: "product initial price" - - &target_price - name: target_price - description: "product target price" - - &initial_weight - name: initial_weight - description: "product initial weight" - - &target_weight - name: target_weight - description: "product target weight" - - &pool_created_time - name: pool_created_time - description: "pool created datetime in UTC" - - &product_added_time - name: product_added_time - description: "product added datetime in UTC" - - - name: nexusmutual_ethereum_staking_events - meta: - blockchain: ethereum - project: nexusmutual - contributors: tomfutago - config: - tags: ["ethereum","nexusmutual","staking"] - description: "Staking pools event history for Nexus Mutual on Ethereum" - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - flow_type - - block_time - - evt_index - - tx_hash - columns: - - &flow_type - name: flow_type - description: "flow event type: deposit, deposit extended, withdraw or stake burn" - - &block_time - name: block_time - description: "UTC event block time" - - *pool_address - - &token_id - name: token_id - description: "ERC721 token id representing staking position" - - &tranche_id - name: tranche_id - description: "staking tranche period" - - &init_tranche_id - name: init_tranche_id - description: "initial staking tranche period (applies to: deposit extended)" - - &new_tranche_id - name: new_tranche_id - description: "new staking tranche period (applies to: deposit extended)" - - &tranche_expiry_date - name: tranche_expiry_date - description: "staking period expiry date" - - &is_active - name: is_active - description: "is staking event still active or already expired" - - &amount - name: amount - description: "staking amount" - - &topup_amount - name: topup_amount - description: "staking top-up amount (applies to: deposit extended)" - - &user - name: user - description: "staking user" - - *evt_index - - &tx_hash - name: tx_hash - description: "unique transaction hash value" - - - name: nexusmutual_ethereum_staking_deposit_extensions - meta: - blockchain: ethereum - project: nexusmutual - contributors: tomfutago - config: - tags: ["ethereum","nexusmutual","staking"] - description: "Staking pools deposit extensions for Nexus Mutual on Ethereum" - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - pool_address - - token_id - - init_tranche_id - - current_tranche_id - columns: - - *pool_address - - *token_id - - *init_tranche_id - - name: current_tranche_id - description: "current staking tranche period (most recent one in the chain of extensions)" - - name: total_amount - description: "total staking amount (initial deposit + all top-up amounts)" - - *is_active diff --git a/models/nexusmutual/ethereum/staking/_schema.yml b/models/nexusmutual/ethereum/staking/_schema.yml new file mode 100644 index 00000000000..6ebcd18ef41 --- /dev/null +++ b/models/nexusmutual/ethereum/staking/_schema.yml @@ -0,0 +1,150 @@ +version: 2 + +models: + - name: nexusmutual_ethereum_staking_pools + meta: + blockchain: ethereum + project: nexusmutual + contributors: tomfutago + config: + tags: ["ethereum", "nexusmutual", "staking"] + description: "Staking pools base data for Nexus Mutual on Ethereum" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_id + - product_id + columns: + - &pool_id + name: pool_id + description: "pool id" + - &pool_address + name: pool_address + description: "pool contract deployment address" + - &pool_name + name: pool_name + description: "pool name" + - &manager_address + name: manager_address + description: "manager address" + - &manager_ens + name: manager_ens + description: "manager ENS name (if available)" + - &manager + name: manager + description: "manager ENS name or address if ENS unavailable" + - &is_private_pool + name: is_private_pool + description: "is private pool? true/false" + - &initial_pool_fee + name: initial_pool_fee + description: "initial pool management fee" + - ¤t_pool_fee + name: current_pool_fee + description: "current pool management fee" + - &max_management_fee + name: max_management_fee + description: "max pool management fee" + - &product_id + name: product_id + description: "product id" + - &initial_price + name: initial_price + description: "product initial price" + - &target_price + name: target_price + description: "product target price" + - &initial_weight + name: initial_weight + description: "product initial weight" + - &target_weight + name: target_weight + description: "product target weight" + - &pool_created_time + name: pool_created_time + description: "pool created datetime in UTC" + - &product_added_time + name: product_added_time + description: "product added datetime in UTC" + + - name: nexusmutual_ethereum_staking_events + meta: + blockchain: ethereum + project: nexusmutual + contributors: tomfutago + config: + tags: ["ethereum", "nexusmutual", "staking"] + description: "Staking pools event history for Nexus Mutual on Ethereum" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - flow_type + - block_time + - evt_index + - tx_hash + columns: + - &flow_type + name: flow_type + description: "flow event type: deposit, deposit extended, withdraw or stake burn" + - &block_time + name: block_time + description: "UTC event block time" + - *pool_address + - &token_id + name: token_id + description: "ERC721 token id representing staking position" + - &tranche_id + name: tranche_id + description: "staking tranche period" + - &init_tranche_id + name: init_tranche_id + description: "initial staking tranche period (applies to: deposit extended)" + - &new_tranche_id + name: new_tranche_id + description: "new staking tranche period (applies to: deposit extended)" + - &tranche_expiry_date + name: tranche_expiry_date + description: "staking period expiry date" + - &is_active + name: is_active + description: "is staking event still active or already expired" + - &amount + name: amount + description: "staking amount" + - &topup_amount + name: topup_amount + description: "staking top-up amount (applies to: deposit extended)" + - &user + name: user + description: "staking user" + - &evt_index + name: evt_index + description: "event index" + - &tx_hash + name: tx_hash + description: "unique transaction hash value" + + - name: nexusmutual_ethereum_staking_deposit_extensions + meta: + blockchain: ethereum + project: nexusmutual + contributors: tomfutago + config: + tags: ["ethereum", "nexusmutual", "staking"] + description: "Staking pools deposit extensions for Nexus Mutual on Ethereum" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_address + - token_id + - init_tranche_id + - current_tranche_id + columns: + - *pool_address + - *token_id + - *init_tranche_id + - name: current_tranche_id + description: "current staking tranche period (most recent one in the chain of extensions)" + - name: total_amount + description: "total staking amount (initial deposit + all top-up amounts)" + - *is_active diff --git a/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_events.sql b/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_events.sql index 249b517df9b..4adb37f7830 100644 --- a/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_events.sql +++ b/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_events.sql @@ -6,6 +6,7 @@ file_format = 'delta', incremental_strategy = 'merge', unique_key = ['flow_type', 'block_time', 'evt_index', 'tx_hash'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], post_hook = '{{ expose_spells(\'["ethereum"]\', "project", "nexusmutual", diff --git a/sources/nexusmutual/ethereum/nexusmutual_ethereum_sources.yml b/sources/nexusmutual/ethereum/nexusmutual_ethereum_sources.yml index 3ee02b81d8a..60fbf9c61c6 100644 --- a/sources/nexusmutual/ethereum/nexusmutual_ethereum_sources.yml +++ b/sources/nexusmutual/ethereum/nexusmutual_ethereum_sources.yml @@ -18,3 +18,13 @@ sources: - name: SafeTrackerNXMIS_evt_CoverReInvestmentUSDCUpdated - name: MCR_evt_MCREvent - name: MCR_evt_MCRUpdated + - name: Cover_evt_ProductTypeSet + - name: Cover_call_setProductTypes + - name: Cover_evt_ProductSet + - name: Cover_call_setProducts + - name: Quotation_call_buyCoverWithMetadata + - name: Quotation_call_makeCoverUsingNXMTokens + - name: QuotationData_call_addCover + - name: Cover_call_buyCover + - name: StakingProducts_call_getPremium + - name: CoverMigrator_evt_CoverMigrated