Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add campfire avalanche nft trades - Ready for Review #5651

Merged
merged 5 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@


{% set nft_models = [
ref('hyperspace_avalanche_c_base_trades')
ref('campfire_avalanche_c_base_trades')
,ref('hyperspace_avalanche_c_base_trades')
] %}


Expand Down
26 changes: 26 additions & 0 deletions models/_sector/nft/trades/chains/avalanche_c/platforms/_schema.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
version: 2

models:
- name: campfire_avalanche_c_base_trades
meta:
blockchain: avalanche_c
sector: nft
project: campfire
contributors: Henrystats
config:
tags: ['avalanche', 'nft', 'trades', 'campfore']
description: "Campfire base trades"
tests:
- check_columns_nft_base_trades
- dbt_utils.unique_combination_of_columns:
combination_of_columns: ['block_number','tx_hash','sub_tx_trade_id']
- check_seed:
seed_file: ref('campfire_avalanche_c_base_trades_seed')
match_columns:
- block_number
- tx_hash
- sub_tx_trade_id
check_columns:
- buyer
- seller
- nft_contract_address
- nft_token_id
- price_raw

- name: hyperspace_avalanche_c_base_trades
meta:
blockchain: avalanche_c
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{ config(
schema='campfire_avalanche_c',
alias = 'base_trades',
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['block_number','tx_hash','sub_tx_trade_id']
)}}

{% set project_start_date = '2022-03-14' %}

WITH

base_trades as (
SELECT
'avalanche_c' as blockchain,
'campfire' as project,
'v1' as project_version,
evt_block_time as block_time,
date_trunc('day',evt_block_time) as block_date,
date_trunc('month',evt_block_time) as block_month,
nftTokenId as nft_token_id,
'secondary' as trade_type,
UINT256 '1' as nft_amount,
CASE
WHEN kind = UINT256 '1' THEN 'Buy'
ELSE 'Sell'
END as trade_category,
seller,
buyer,
price as price_raw,
0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7 as currency_contract,
nftContractAddress as nft_contract_address,
evt_tx_hash as tx_hash,
contract_address as project_contract_address,
evt_block_number as block_number,
CAST(NULL as UINT256) as platform_fee_amount_raw,
CAST(NULL as UINT256) as royalty_fee_amount_raw,
CAST(NULL as VARBINARY) as royalty_fee_address,
CAST(NULL as VARBINARY) as platform_fee_address,
evt_index as sub_tx_trade_id
FROM
{{ source('campfire_avalanche_c', 'CampfireMarket_evt_Sale') }}
{% if is_incremental() %}
WHERE {{incremental_predicate('evt_block_time')}}
{% else %}
WHERE evt_block_time >= TIMESTAMP '{{project_start_date}}'
{% endif %}
)

{{add_nft_tx_data('base_trades','avalanche_c')}}
10 changes: 10 additions & 0 deletions seeds/_sector/nft/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,16 @@ seeds:
platform_fee_amount_raw: uint256
royalty_fee_amount_raw: uint256
nft_token_id: uint256

- name: campfire_avalanche_c_base_trades_seed
config:
column_types:
tx_hash: varbinary
buyer: varbinary
seller: varbinary
nft_contract_address: varbinary
price_raw: uint256
nft_token_id: uint256

- name: hyperspace_avalanche_c_base_trades_seed
config:
Expand Down
3 changes: 3 additions & 0 deletions seeds/_sector/nft/campfire_avalanche_c_base_trades_seed.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
block_number,tx_hash,sub_tx_trade_id,buyer,seller,nft_contract_address,nft_token_id,price_raw
12115532,0xe30683aa12c236c3f8bb6d09e32aa096e5a3410e9b6a19398e19179e4bfbc9c5,6,0xd2d3fc6abc92a146062f222e042698c1057b04ba,0xd55316fc244c7f5b44dc246e725c1c6c3e0cb8c2,0x5e4504663ab2a8060715a1d1f162873f39df9abf,3,10000000000000000
27822010,0x498b845045c8c9953aa0cb8447fe8aec5347dada2e274ad3562224f5499c8776,2,0x39ffa0838b7b89e35dbf1ff2017001769b76dd37,0x767dc13b7c297b214489d7324652830570a5a108,0xe2f91f3c873ea808ac7307d5ccc81544a5f08aef,0,1000000000000000000
5 changes: 4 additions & 1 deletion sources/_sector/nft/trades/avalanche_c_sources.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
version: 2

sources:
- name: campfire_avalanche_c
tables:
- name: CampfireMarket_evt_Sale
- name: hyperspace_avalanche_c
tables:
- name: ERC721OrdersFeature_evt_ERC721OrderFilled
- name: ERC721OrdersFeature_evt_ERC721OrderFilled
Loading