Skip to content

Commit

Permalink
Add seaport transfers and Opensea v3 events/trades (#1291)
Browse files Browse the repository at this point in the history
* Add seaport transfers and Opensea v3 events/trades

* Update seaport_ethereum_transfers.sql

* Update seaport_ethereum_transfers.sql

* Update seaport_ethereum_transfers.sql

* standardize block number across nft tables

* add test seaport transfers

* Update seaport_ethereum_transfers.sql
  • Loading branch information
soispoke authored Jul 20, 2022
1 parent 7147b9a commit 9bba8ab
Show file tree
Hide file tree
Showing 15 changed files with 2,094 additions and 54 deletions.
10 changes: 10 additions & 0 deletions spellbook/macros/alter_table_properties.sql
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ ALTER VIEW seaport_ethereum.view_transactions SET TBLPROPERTIES('dune.public'='t
'dune.data_explorer.contributors'='["sohawk","soispoke"]');
{% endset %}

{% set seaport_ethereum_transfers %}
ALTER TABLE seaport_ethereum.transfers SET TBLPROPERTIES('dune.public'='true',
'dune.data_explorer.blockchains'='["ethereum"]',
'dune.data_explorer.category'='abstraction',
'dune.data_explorer.abstraction.type'='project',
'dune.data_explorer.abstraction.name'='seaport',
'dune.data_explorer.contributors'='["sohawk","soispoke"]');
{% endset %}

{% set ens_view_expirations %}
ALTER VIEW ens.view_expirations SET TBLPROPERTIES('dune.public'='true',
'dune.data_explorer.blockchains'='["ethereum"]',
Expand Down Expand Up @@ -367,6 +376,7 @@ ALTER VIEW ens.view_renewals SET TBLPROPERTIES('dune.public'='true',
{% do run_query(transfers_ethereum_erc20) %}
{% do run_query(tokens_ethereum_nft) %}
{% do run_query(seaport_ethereum_view_transactions) %}
{% do run_query(seaport_ethereum_transfers) %}
{% do run_query(uniswap_trades) %}
{% do run_query(ens_view_expirations) %}
{% do run_query(ens_view_registrations) %}
Expand Down
23 changes: 14 additions & 9 deletions spellbook/macros/optimize_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ OPTIMIZE transfers_ethereum.erc1155_agg_hour;
OPTIMIZE transfers_ethereum.erc1155_agg_day;
{% endset %}

{% set opensea_transactions %}
OPTIMIZE opensea.transactions;
{% set opensea_events %}
OPTIMIZE opensea.events;
{% endset %}

{% set magiceden_transactions %}
OPTIMIZE magiceden.transactions;
{% set seaport_ethereum_transfers %}
OPTIMIZE seaport_ethereum.transfers;
{% endset %}

{% set nft_transactions %}
OPTIMIZE nft.transactions;
{% set magiceden_events %}
OPTIMIZE magiceden.events;
{% endset %}

{% set nft_events %}
OPTIMIZE nft.events;
{% endset %}

{% set nft_trades %}
Expand Down Expand Up @@ -62,9 +66,10 @@ OPTIMIZE uniswap.trades;
{% do run_query(transfers_ethereum_erc721_agg_day) %}
{% do run_query(transfers_ethereum_erc1155_agg_hour) %}
{% do run_query(transfers_ethereum_erc1155_agg_day) %}
{% do run_query(opensea_transactions) %}
{% do run_query(magiceden_transactions) %}
{% do run_query(nft_transactions) %}
{% do run_query(opensea_events) %}
{% do run_query(seaport_ethereum_transfers) %}
{% do run_query(magiceden_events) %}
{% do run_query(nft_events) %}
{% do run_query(nft_trades) %}
{% do run_query(nft_mints) %}
{% do run_query(nft_burns) %}
Expand Down
1 change: 1 addition & 0 deletions spellbook/models/magiceden/magiceden_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ project_contract_address,
NULL::string as aggregator_name,
NULL::string as aggregator_address,
tx_hash,
block_number,
NULL::string as tx_from,
NULL::string as tx_to,
NULL::double as platform_fee_amount_raw,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ SELECT
END as version,
signatures[0] as tx_hash,
block_time,
block_slot::string as block_number,
abs(post_balances[0] / 1e9 - pre_balances[0] / 1e9) * p.price AS amount_usd,
abs(post_balances[0] / 1e9 - pre_balances[0] / 1e9) AS amount_original,
abs(post_balances[0] - pre_balances[0])::string AS amount_raw,
Expand Down
41 changes: 3 additions & 38 deletions spellbook/models/opensea/ethereum/opensea_ethereum_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,9 @@
)
}}


SELECT blockchain,
project,
version,
block_time,
token_id,
collection,
amount_usd,
token_standard,
trade_type,
number_of_items,
trade_category,
evt_type,
seller,
buyer,
amount_original,
amount_raw,
currency_symbol,
currency_contract,
nft_contract_address,
project_contract_address,
aggregator_name,
aggregator_address,
tx_hash,
tx_from,
tx_to,
platform_fee_amount_raw,
platform_fee_amount,
platform_fee_amount_usd,
platform_fee_percentage,
royalty_fee_amount_raw,
royalty_fee_amount,
royalty_fee_amount_usd,
royalty_fee_percentage,
royalty_fee_receive_address,
royalty_fee_currency_symbol,
unique_trade_id
FROM ({{ ref('opensea_v1_ethereum_events') }})
SELECT * FROM ({{ ref('opensea_v1_ethereum_events') }})
UNION
SELECT * FROM ({{ ref('opensea_v3_ethereum_events') }})

{% if is_incremental() %}
-- this filter will only be applied on an incremental run
Expand Down
56 changes: 51 additions & 5 deletions spellbook/models/opensea/ethereum/opensea_ethereum_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,16 @@ models:
description: "Symbol of the token in which fees are paid out"
- name: unique_trade_id
description: "Unique trade ID"

- name: opensea_ethereum_events
- name: opensea_v3_ethereum_events
meta:
blockchain: ethereum
project: opensea
contributors: soispoke
contributors: soispoke, sohwak
config:
tags: ['ethereum','opensea','events']
tags: ['ethereum','opensea','v3','events']
description: >
OpenSea events on Ethereum
OpenSea V3 events on Ethereum
columns:
- *blockchain
- *project
Expand Down Expand Up @@ -205,6 +205,52 @@ models:
description: "Unique trade ID"
tests:
- unique

- name: opensea_ethereum_events
meta:
blockchain: ethereum
project: opensea
contributors: soispoke
config:
tags: ['ethereum','opensea','events']
description: >
OpenSea events on Ethereum
columns:
- *blockchain
- *project
- *version
- *block_time
- *token_id
- *collection
- *amount_usd
- *token_standard
- *trade_type
- *number_of_items
- *trade_category
- *evt_type
- *seller
- *buyer
- *amount_original
- *amount_raw
- *currency_symbol
- *currency_contract
- *nft_contract_address
- *project_contract_address
- *aggregator_name
- *aggregator_address
- *tx_hash
- *block_number
- *tx_from
- *tx_to
- *platform_fee_amount_raw
- *platform_fee_amount
- *platform_fee_amount_usd
- *royalty_fee_amount_raw
- *royalty_fee_amount
- *royalty_fee_amount_usd
- *royalty_fee_receive_address
- *royalty_fee_currency_symbol
- *unique_trade_id

- name: opensea_ethereum_trades
meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ tx_hash,
tx_from,
tx_to,
unique_trade_id
FROM (SELECT * FROM {{ ref('opensea_v1_ethereum_events') }} )
FROM (SELECT * FROM {{ ref('opensea_ethereum_events') }} )
WHERE evt_type = 'Trade'
44 changes: 44 additions & 0 deletions spellbook/models/opensea/ethereum/opensea_v3_ethereum_events.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{ config(schema = 'opensea_v3_ethereum',
alias='events') }}

SELECT blockchain,
'opensea' as project,
'v3' as version,
block_time,
token_id,
collection,
amount_usd,
token_standard,
trade_type,
number_of_items,
trade_category,
evt_type,
seller,
buyer,
amount_original,
amount_raw,
currency_symbol,
currency_contract,
nft_contract_address,
project_contract_address,
aggregator_name,
aggregator_address,
tx_hash,
block_number,
tx_from,
tx_to,
platform_fee_amount_raw,
platform_fee_amount,
platform_fee_amount_usd,
platform_fee_percentage,
royalty_fee_amount_raw,
royalty_fee_amount,
royalty_fee_amount_usd,
royalty_fee_percentage,
royalty_fee_receive_address,
royalty_fee_currency_symbol,
unique_trade_id
FROM {{ ref('seaport_ethereum_transfers') }}
WHERE zone in ('0xf397619df7bfd4d1657ea9bdd9df7ff888731a11'
,'0x9b814233894cd227f561b78cc65891aa55c62ad2'
,'0x004c00500000ad104d7dbd00e3ae0a5c00560c00')
2 changes: 2 additions & 0 deletions spellbook/models/opensea/opensea_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ project_contract_address,
aggregator_name,
aggregator_address,
tx_hash,
block_number,
tx_from,
tx_to,
platform_fee_amount_raw,
Expand Down Expand Up @@ -71,6 +72,7 @@ project_contract_address,
NULL::string as aggregator_name,
NULL::string as aggregator_address,
tx_hash,
block_number,
NULL::string as tx_from,
NULL::string as tx_to,
NULL::double as platform_fee_amount_raw,
Expand Down
1 change: 1 addition & 0 deletions spellbook/models/opensea/solana/opensea_solana_events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SELECT
'v1' as version,
signatures[0] as tx_hash,
block_time,
block_slot::string as block_number,
abs(post_balances[0] / 1e9 - pre_balances[0] / 1e9) * p.price AS amount_usd,
abs(post_balances[0] / 1e9 - pre_balances[0] / 1e9) AS amount_original,
abs(post_balances[0] - pre_balances[0])::string AS amount_raw,
Expand Down
Loading

0 comments on commit 9bba8ab

Please sign in to comment.