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

Arbitrum base trades #4879

Merged
merged 71 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
e7727ac
revamp NFT sector to new spell design guidelines
0xRobin Oct 24, 2023
778ae37
wip
0xRobin Oct 24, 2023
668dc3b
fix compile
0xRobin Oct 24, 2023
48e947b
Merge branch 'main' into nft-sector-design
0xRobin Oct 25, 2023
077c12b
remove aliases
0xRobin Oct 25, 2023
781dce1
bugfix
0xRobin Oct 25, 2023
66f51a4
fix timestamp cast
0xRobin Oct 25, 2023
8d48ccf
fix for loops
0xRobin Oct 25, 2023
3eaf78b
syntax
0xRobin Oct 26, 2023
9566baa
re-trigger CI
0xRobin Oct 26, 2023
1919872
try incremental idk
0xRobin Oct 26, 2023
f1585a9
spent 4 hours looking for 2 missing brackets, great
0xRobin Oct 26, 2023
c695037
variable had wrong name..
0xRobin Oct 26, 2023
63128a7
temp disable aggregator marks
0xRobin Oct 26, 2023
3867502
Merge branch 'main' into nft-sector-design
0xRobin Oct 30, 2023
b403065
correct unique_trade_id
0xRobin Oct 30, 2023
e376c59
add version to liquidifty
0xRobin Oct 30, 2023
50c422a
trigger CI
0xRobin Oct 30, 2023
fdb7256
seeds
0xRobin Oct 30, 2023
6a9e9af
fix liquidifty v3
0xRobin Oct 30, 2023
d4b24f2
syntax
0xRobin Oct 30, 2023
8e76d97
syntax
0xRobin Oct 31, 2023
d278ee4
trigger CI
0xRobin Nov 7, 2023
ce6709f
wip
0xRobin Nov 7, 2023
d553443
Merge branch 'main' into nft-sector-design
0xRobin Nov 8, 2023
905bc48
32 bytes tx data marker
0xRobin Nov 8, 2023
3adbd37
macro naming
0xRobin Nov 8, 2023
304b455
fix syntax
0xRobin Nov 9, 2023
352ceb1
remove stub matching
0xRobin Nov 9, 2023
cf293da
Merge branch 'main' into nft-sector-design
0xRobin Nov 9, 2023
2ed5ccc
Merge branch 'nft-sector-design' into arbitrum-base-trades
0xRobin Nov 10, 2023
8ea5dc6
move files
0xRobin Nov 10, 2023
d00b958
Update nft_events.sql
0xRobin Nov 16, 2023
67127e5
Update nft_fees.sql
0xRobin Nov 16, 2023
353ad4d
Update nft_ethereum_base_trades.sql
0xRobin Nov 16, 2023
f57e559
Update nft_base_trades.sql
0xRobin Nov 16, 2023
d1b6a22
Update nft_trades.sql
0xRobin Nov 16, 2023
65f0385
Update nft_trades_beta.sql
0xRobin Nov 16, 2023
3653059
Update nft_old_base_trades.sql
0xRobin Nov 16, 2023
afedf28
Merge branch 'main' into nft-sector-design
0xRobin Nov 16, 2023
e696de2
fix incremental setup
0xRobin Nov 20, 2023
dbed6c6
Merge branch 'main' into nft-sector-design
0xRobin Nov 20, 2023
eb946c3
comma
0xRobin Nov 20, 2023
877e2d9
Merge branch 'nft-sector-design' into arbitrum-base-trades
0xRobin Nov 20, 2023
ee563fc
wip
0xRobin Nov 20, 2023
07e56b8
Merge branch 'main' into arbitrum-base-trades
0xRobin Nov 27, 2023
d276c41
refactor arbitrum models
0xRobin Nov 27, 2023
b3e1d23
eth models
0xRobin Nov 27, 2023
cdef755
syntax fix
0xRobin Nov 28, 2023
34fb971
syntax fix
0xRobin Nov 28, 2023
f0bc196
syntax fix
0xRobin Nov 28, 2023
07bd638
fix liquyidifty
0xRobin Nov 28, 2023
c929257
syntax fix
0xRobin Nov 28, 2023
baed02d
syntax fix
0xRobin Nov 28, 2023
afa1017
syntax fix
0xRobin Nov 28, 2023
250cb81
Merge branch 'main' into arbitrum-base-trades
0xRobin Nov 28, 2023
2d1a923
move tx data to platform models on ethereum
0xRobin Nov 28, 2023
70f6626
fix
0xRobin Nov 28, 2023
2ec4226
Merge branch 'main' into arbitrum-base-trades
0xRobin Nov 28, 2023
711fed3
Merge branch 'main' into arbitrum-base-trades
0xRobin Nov 29, 2023
7000d9a
Merge branch 'main' into arbitrum-base-trades
0xRobin Nov 30, 2023
6a6336a
Merge branch 'main' into arbitrum-base-trades
0xRobin Dec 1, 2023
8e48404
Merge branch 'main' into arbitrum-base-trades
0xRobin Dec 19, 2023
edebb57
revert changes to ETH models
0xRobin Dec 19, 2023
2f74406
bugfixz
0xRobin Dec 19, 2023
96d144c
Merge branch 'main' into arbitrum-base-trades
0xRobin Dec 19, 2023
9554b84
Merge branch 'main' into arbitrum-base-trades
0xRobin Jan 4, 2024
6a25971
macro
0xRobin Jan 4, 2024
c3aa9df
fix macro
0xRobin Jan 4, 2024
27aab0d
update old list
0xRobin Jan 4, 2024
30ba1d4
Merge branch 'main' into arbitrum-base-trades
0xRobin Jan 4, 2024
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 @@ -90,5 +90,5 @@ FROM tfe
)

-- this will be removed once tx_from and tx_to are available in the base event tables
{{ add_nft_tx_data('base_trades', 'polygon') }}
{{ add_nft_tx_data('base_trades', blockchain) }}
{% endmacro %}
3 changes: 1 addition & 2 deletions models/_sector/nft/mints/nft_mints.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ config(

alias = 'mints',
schema = 'nft',
partition_by = ['block_month'],
Expand All @@ -26,7 +26,6 @@
ref('nftb_bnb_events')
,ref('opensea_v1_ethereum_events')
,ref('magiceden_solana_events')
,ref('stealcam_arbitrum_events')
] %}

WITH project_mints as
Expand Down
55 changes: 55 additions & 0 deletions models/_sector/nft/trades/chains/_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: 2

# we don't include any tests here for performance reasons as the chain unions are only views.
models:
- name: nft_ethereum_base_trades
meta:
blockchain: ethereum
sector: nft
contributors: 0xRob
config:
tags: ['ethereum', 'nft', 'trades']
description: "NFT ethereum base trades"
columns:
- &blockchain
name: blockchain
- &project
name: project
- &project_version
name: project_version
- &tx_hash
name: tx_hash
- &sub_tx_trade_id
name: sub_tx_trade_id
- &trade_type
name: trade_type
- &trade_category
name: trade_category
- &price_raw
name: price_raw
- &tx_data_marker
name: tx_data_marker
- &currency_contract
name: currency_contract

- name: nft_arbitrum_base_trades
meta:
blockchain: arbitrum
sector: nft
contributors: 0xRob
config:
tags: [ 'arbitrum', 'nft', 'trades' ]
description: "NFT arbitrum base trades"
columns:
- *blockchain
- *project
- *project_version
- *tx_hash
- *sub_tx_trade_id
- *trade_type
- *trade_category
- *price_raw
- *tx_data_marker
- *currency_contract


Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{{ config(
schema = 'nft_arbitrum',
alias = 'base_trades',
materialized = 'view'
)
}}


{% set nft_models = [
ref('stealcam_arbitrum_base_trades')
,ref('tofu_arbitrum_base_trades')
,ref('trove_v1_arbitrum_base_trades')
,ref('trove_v2_arbitrum_base_trades')
] %}


SELECT * FROM (
{% for nft_model in nft_models %}
SELECT
blockchain,
project,
project_version,
cast(date_trunc('day', block_time) as date) as block_date,
cast(date_trunc('month', block_time) as date) as block_month,
block_time,
block_number,
tx_hash,
project_contract_address,
trade_category, --buy/sell/swap
trade_type, --primary/secondary
buyer,
seller,
nft_contract_address,
nft_token_id,
nft_amount, -- always 1 for erc721
price_raw,
currency_contract,
platform_fee_amount_raw,
royalty_fee_amount_raw,
platform_fee_address, -- optional
royalty_fee_address, -- optional
sub_tx_trade_id,
tx_from,
tx_to,
tx_data_marker,
row_number() over (partition by tx_hash, sub_tx_trade_id order by tx_hash) as duplicates_rank -- duplicates protection
FROM {{ nft_model }}
{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %}
)
where duplicates_rank = 1
58 changes: 58 additions & 0 deletions models/_sector/nft/trades/chains/arbitrum/platforms/_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: 2

models:
- name: tofu_arbitrum_base_trades
meta:
blockchain: arbitrum
sector: nft
project: tofu
contributors: 0xRob
config:
tags: ['arbitrum', 'nft', 'trades', 'tofu']
description: "Tofu 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']

- name: stealcam_arbitrum_base_trades
meta:
blockchain: arbitrum
project: stealcam
contributors: [ hildobby ]
config:
tags: [ 'arbitrum','stealcam','v1','trades' ]
description: >
Stealcam v1 trades on Arbitrum
tests:
- check_columns_nft_base_trades
- dbt_utils.unique_combination_of_columns:
combination_of_columns: [ 'block_number','tx_hash','sub_tx_trade_id' ]

- name: trove_v1_arbitrum_base_trades
meta:
blockchain: arbitrum
sector: nft
project: trove
contributors: bizzyvinci
config:
tags: [ 'trove', 'treasure', 'nft', 'trades' ]
description: "NFT trades on trove v1 on arbitrum blockchain"
tests:
- check_columns_nft_base_trades
- dbt_utils.unique_combination_of_columns:
combination_of_columns: [ 'block_number','tx_hash','sub_tx_trade_id' ]

- name: trove_v2_arbitrum_base_trades
meta:
blockchain: arbitrum
sector: nft
project: trove
contributors: bizzyvinci
config:
tags: [ 'trove', 'treasure', 'nft', 'trades' ]
description: "NFT trades on trove v2 on arbitrum blockchain"
tests:
- check_columns_nft_base_trades
- dbt_utils.unique_combination_of_columns:
combination_of_columns: [ 'block_number','tx_hash','sub_tx_trade_id' ]
17 changes: 17 additions & 0 deletions models/_sector/nft/trades/chains/arbitrum/platforms/_sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2

sources:
- name: tofunft_arbitrum
tables:
- name: MarketNG_call_run
- name: MarketNG_evt_EvInventoryUpdate
- name: stealcam_arbitrum
tables:
- name: Stealcam_evt_Stolen
- name: Stealcam_call_mint

- name: treasure_trove_arbitrum
tables:
- name: TreasureMarketplaceV2_evt_BidAccepted
- name: TreasureMarketplaceV2_evt_ItemSold
- name: TreasureMarketplaceV1_evt_ItemSold
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{ config(
schema = 'stealcam_arbitrum',
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 = "TIMESTAMP '2023-03-10'" %}

with stealcam as (
select
*
,case when value > uint256 '0' then cast((value-(0.001*pow(10,18)))/11.0+(0.001*pow(10,18)) as uint256) else uint256 '0' end as surplus_value
FROM {{ source('stealcam_arbitrum', 'Stealcam_evt_Stolen') }} sc
{% if is_incremental() %}
where {{incremental_predicate('evt_block_time')}}
{% endif %}
{% if not is_incremental() %}
WHERE evt_block_time >= {{project_start_date}}
{% endif %}

)

,base_trades as (
SELECT 'arbitrum' AS blockchain
, 'stealcam' AS project
, 'v1' AS project_version
, sc.evt_block_time AS block_time
, date_trunc('day',sc.evt_block_time) AS block_date
, date_trunc('month',sc.evt_block_time) AS block_month
, sc.evt_block_number AS block_number
, 'Buy' AS trade_category
, CASE WHEN sc.value=uint256 '0' THEN 'primary' ELSE 'secondary' END AS trade_type
, sc."from" AS seller
, sc.to AS buyer
, sc.contract_address AS nft_contract_address
, sc.id AS nft_token_id
, uint256 '1' AS nft_amount
, 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 AS currency_contract
, sc.value AS price_raw
, sc.contract_address AS project_contract_address
, sc.evt_tx_hash AS tx_hash
, CAST(double '0.1'*surplus_value AS uint256) AS platform_fee_amount_raw
, CAST(double '0.45'*surplus_value AS uint256) AS royalty_fee_amount_raw
, cast(null as varbinary) AS platform_fee_address
, m._creator AS royalty_fee_address
, sc.evt_index as sub_tx_trade_id
FROM stealcam sc
INNER JOIN {{ source('stealcam_arbitrum', 'Stealcam_call_mint') }} m ON m.call_success
AND m.id=sc.id
{% if is_incremental() %}
and {{incremental_predicate('m.call_block_time')}}
{% endif %}
{% if not is_incremental() %}
AND m.call_block_time >= {{project_start_date}}
{% endif %}
)
{{add_nft_tx_data('base_trades','arbitrum')}}
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
{{ config(
schema = 'tofu_arbitrum',
alias = 'events',

alias = 'base_trades',
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['block_number', 'blockchain', 'project', 'version', 'tx_hash', 'evt_index', 'bundle_index' ]
unique_key = ['block_number','tx_hash','sub_tx_trade_id']
)
}}

{{
tofu_v1_events(
tofu_v1_base_trades(
blockchain = 'arbitrum',
MarketNG_call_run = source('tofunft_arbitrum', 'MarketNG_call_run'),
MarketNG_evt_EvInventoryUpdate = source('tofunft_arbitrum', 'MarketNG_evt_EvInventoryUpdate'),
raw_transactions = source('arbitrum','transactions'),
project_start_date = "TIMESTAMP '2021-12-09'",
NATIVE_ERC20_REPLACEMENT = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1',
NATIVE_SYMBOL_REPLACEMENT = 'ARETH'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{ config(
schema='trove_v1_arbitrum',
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 = '2021-11-13' %}

with base_trades as (
select
'arbitrum' as blockchain,
'trove' 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,
tokenId as nft_token_id,
'secondary' as trade_type,
quantity as nft_amount,
'Buy' as trade_category,
seller,
buyer,
cast(pricePerItem * quantity as uint256) as price_raw,
0x539bde0d7dbd336b79148aa742883198bbf60342 as currency_contract,
nftAddress as nft_contract_address,
contract_address as project_contract_address,
evt_tx_hash as tx_hash,
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('treasure_trove_arbitrum', 'TreasureMarketplaceV1_evt_ItemSold') }}
{% 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','arbitrum')}}
Loading