Skip to content

Commit

Permalink
Opensea (#1194)
Browse files Browse the repository at this point in the history
* Added Seaport view_transactions on Dune v2

* modified seaport view_transaction metadata

* Add Seaport sources

* Update dbt_project.yml

* Update seaport_ethereum_view_transactions.sql

* set metadata to expose seaport view transactions in dune.com

* Update alter_table_properties.sql

* Update alter_table_properties.sql

* adding test for seaport_ethereum.view_transactions

Co-authored-by: soispoke <[email protected]>
  • Loading branch information
sohwak and soispoke authored Jun 21, 2022
1 parent 98e7395 commit b1a50d8
Show file tree
Hide file tree
Showing 7 changed files with 1,449 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spellbook/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ models:
+schema: magiceden_solana
+materialized: view

seaport:
+schema: seaport
+materialized: view
ethereum:
+schema: seaport_ethereum
+materialized: view

balances:
+schema: balances
+materialized: view
Expand Down
10 changes: 10 additions & 0 deletions spellbook/macros/alter_table_properties.sql
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ ALTER TABLE uniswap.trades SET TBLPROPERTIES('dune.public'='true',
'dune.data_explorer.contributors'='["soispoke"]');
{% endset %}

{% set seaport_ethereum_view_transactions %}
ALTER VIEW seaport_ethereum.view_transactions 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 %}

{% do run_query(balances_ethereum_erc20_day) %}
{% do run_query(balances_ethereum_erc20_hour) %}
{% do run_query(balances_ethereum_erc20_latest) %}
Expand All @@ -190,6 +199,7 @@ ALTER TABLE uniswap.trades SET TBLPROPERTIES('dune.public'='true',
{% do run_query(tokens_ethereum_erc20) %}
{% do run_query(transfers_ethereum_erc20) %}
{% do run_query(tokens_ethereum_nft) %}
{% do run_query(seaport_ethereum_view_transactions) %}
{% do run_query(uniswap_trades) %}

{% do log("Tables generated", info=True) %}
Expand Down
80 changes: 80 additions & 0 deletions spellbook/models/seaport/ethereum/seaport_ethereum_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
version: 2

models:
- name: seaport_ethereum_view_transactions
meta:
blockchain: ethereum
project: seaport
contributors: sohwak, soispoke
config:
tags: ['ethereum','seaport','opensea','transaction']
description: >
Seaport transactions on Ethereum
columns:
- &blockchain
name: blockchain
description: "Blockchain"
- name: block_time
description: "UTC event block time"
- name: nft_project_name
description: "name of the NFT collection"
- name: nft_token_id
description: "the token ID of the NFT transacted"
- name: erc_standard
description: "whether the NFTs transacted are ERC-721, ERC-1155 or a mix of both"
- name: platform
description: "platform on which transaction occurred (e.g. OpenSea)"
- name: platform_version
description: "Seaport is the 3rd exchange contract used by OpenSea (after Wyvern 2.2 and Wyvern 2.3)"
- name: trade_type
description: "identify whether it was a single NFT trade or multiple NFTs traded"
- name: number_of_items
description: "identify the number of items traded in the transaction"
- name: order_type
description: "basic order type and identifier criteria for collection and trait offers"
- name: evt_type
description: "identify these transactions as trades"
- name: usd_amount
description: "use the prices table to convert the original amount to amount in USD at the minute of the transaction"
- name: seller
description: "seller wallet address"
- name: buyer
description: "buyer wallet address"
- name: original_amount
description: "original amount in original currency (so 0.2 if original final price was 0.2E)"
- name: original_amount_raw
description: "raw original amount (can have many decimals or 0s in front)"
- name: original_currency
description: "symbol of original token used in payment"
- name: original_currency_contract
description: "contract address of original token used for payment"
- name: currency_contract
description: "contract address of original token used for payment, with ETH contract address swapped for WETH"
- name: nft_contract_address
description: "nft contract address, if only 1 nft was transacted"
- name: exchange_contract_address
description: "exchange contract address - in this case, Seaport contract address"
- name: tx_hash
description: "Transaction hash"
tests:
- unique
- name: block_number
description: "number of the ETH block in which transaction was executed "
- name: tx_from
description: "actual from wallet address from ethereum.transactions table "
- name: tx_to
description: "actual to wallet address from ethereum.transactions table (can be different from actual buyer if an aggregator is used)"
- name: evt_index
description: "index of transaction within the block"
- name: fee_receive_address
description: "wallet addresses receiving fees from the transaction"
- name: fee_currency
description: "symbol of the token in which fees are paid out"
- name: fee_amount_raw
description: "raw numerical amount of fees"
- name: fee_amount
description: "fee amount in original token currency (properly formatted in decimals)"
- name: fee_usd_amount
description: "fee amount in USD"
- name: zone_address
description: "A zone is an account (usually a contract) that performs additional validation prior to fulfillment, and that can cancel the listing on behalf of the offerer. We'll use this to select for OpenSea transactions on Seaport."
22 changes: 22 additions & 0 deletions spellbook/models/seaport/ethereum/seaport_ethereum_sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2

sources:
- name: seaport_ethereum
freshness:
warn_after: { count: 12, period: hour }
error_after: { count: 24, period: hour }
tables:
- name: Seaport_call_fulfillAvailableAdvancedOrders
loaded_at_field: evt_block_time
- name: Seaport_evt_OrderFulfilled
loaded_at_field: evt_block_time
- name: Seaport_call_fulfillOrder
loaded_at_field: evt_block_time
- name: Seaport_call_fulfillBasicOrder
loaded_at_field: evt_block_time
- name: Seaport_call_fulfillAdvancedOrder
loaded_at_field: evt_block_time
- name: Seaport_call_fulfillAvailableOrders
loaded_at_field: evt_block_time
- name: Seaport_call_matchOrders
loaded_at_field: evt_block_time
Loading

0 comments on commit b1a50d8

Please sign in to comment.