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 Mavis Market to nft.trades #7355

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
c0acff4
Add Mavis Market to nft.trades
peterrliem Dec 19, 2024
b37b3f0
Add Ronin Sources
peterrliem Dec 19, 2024
6586ead
Update _sources.yml
peterrliem Dec 19, 2024
63734bd
Update mavis_marketplace.sql
peterrliem Dec 19, 2024
fedfdd8
Update nft_base_trades.sql
peterrliem Dec 19, 2024
fdaf6fd
Update nft_trades.sql
peterrliem Dec 19, 2024
60644e0
Create _schema.yml
peterrliem Dec 19, 2024
3738876
Remove schema file
peterrliem Dec 19, 2024
87446b7
Update and rename dbt_subprojects/nft/models/_sector/trades/chains/ro…
peterrliem Dec 19, 2024
8d9334d
Rename mavis_marketplace.sql to mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
640d19f
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
2d2b592
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
b383037
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
5531f67
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
66d87dc
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
c0502ff
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
ffe2b2f
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
1e25dc3
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
22e9e48
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
d4d2448
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
65327aa
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
e448b2d
Merge branch 'main' into patch-15
peterrliem Dec 19, 2024
f7e4ec9
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
0521891
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
c4515d1
Update mavis_ronin_base_trades.sql
peterrliem Dec 19, 2024
e0a2193
Merge branch 'main' into patch-15
peterrliem Dec 20, 2024
6757066
Create _schema.yml
peterrliem Dec 20, 2024
803b7b1
Update _schema.yml
peterrliem Dec 20, 2024
eda05e4
Merge branch 'main' into patch-15
0xRobin Dec 20, 2024
5bf6195
Merge branch 'main' into patch-15
0xRobin Dec 23, 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
@@ -0,0 +1,49 @@
{{ config(
schema = 'nft_ronin',
alias = 'base_trades',
materialized = 'view'
)
}}
-- (project, project_version, model)
{% set nft_models = [
ref('mavis_ronin_base_trades')
] %}

with base_union as (
SELECT * FROM (
{% for nft_model in nft_models %}
SELECT
blockchain,
project,
project_version,
block_time,
block_date,
block_month,
block_number,
tx_hash,
project_contract_address,
trade_category,
trade_type,
buyer,
seller,
nft_contract_address,
nft_token_id,
nft_amount,
price_raw,
currency_contract,
platform_fee_amount_raw,
royalty_fee_amount_raw,
platform_fee_address,
royalty_fee_address,
sub_tx_trade_id,
tx_from,
tx_to,
tx_data_marker
FROM {{ nft_model }}
{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %}
)
)
select * from base_union
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2

models:
- name: mavis_ronin_base_trades
meta:
blockchain: ronin
sector: nft
project: mavis_ronin
contributors: ['peterrliem' ]
config:
tags: [ 'ronin', 'nft', 'trades', 'mavis' ]
description: "mavis marketplace base trades"
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{{ config(
schema = 'mavis_ronin',
alias = 'base_trades',
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['block_number','tx_hash','sub_tx_trade_id'],
)
}}


with trade_details as (

select
evt_block_time as block_time,
evt_block_date as block_date,
evt_block_number as block_number,
evt_tx_hash as tx_hash,
evt_tx_from as tx_from,
evt_tx_to as tx_to,
evt_index,
contract_address,
COALESCE(FROM_HEX(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[5].recipient')),FROM_HEX(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')), '$.maker'))) as seller,
FROM_HEX(json_extract_scalar("order", '$.recipient')) as buyer,
json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')), '$.kind') as kind,
cast(json_extract_scalar(replace(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')),'$.assets[0]'),'\\', ''),'$.erc') as double) as erc,
FROM_HEX(json_extract_scalar(replace(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')),'$.assets[0]'),'\\', ''),'$.addr')) as nft_contract_address,
cast(json_extract_scalar(replace(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')),'$.assets[0]'),'\\', ''),'$.id') as double) as nft_token_id,
cast(json_extract_scalar(replace(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')),'$.assets[0]'),'\\', ''),'$.quantity') as double) as quantity,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to return 0 in quite some cases, it should always be 1 or greater

FROM_HEX(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')), '$.paymentToken')) as currency_address,
CAST(json_extract_scalar("order", '$.realPrice') AS DOUBLE) as price_raw,
CAST(json_extract_scalar(json_parse(json_extract_scalar("order", '$.info')), '$.baseUnitPrice') AS DOUBLE) as base_unit_price_raw,
FROM_HEX(json_extract_scalar("order", '$.refunder')) as refunder,
FROM_HEX(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[1].recipient')) as platform_address,
CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[1].ratio') AS DOUBLE) as platform_fee_amount_raw,
FROM_HEX(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[2].recipient')) as axie_treasury_address,
CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[2].ratio') AS DOUBLE) as axie_fee_raw,
CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[2].value') AS DOUBLE) as axie_fee_amount_raw,
FROM_HEX(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[3].recipient')) as ronin_treasury_address,
CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[3].ratio') AS DOUBLE) as ronin_fee,
CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[3].value') AS DOUBLE) as ronin_treasury_fee_amount_raw,
FROM_HEX(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[4].recipient')) as creator_royalty_address,
CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[4].ratio') AS DOUBLE) as creator_royalty_fee,
CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[4].value') AS DOUBLE) as creator_royalty_fee_amount_raw,
CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[5].ratio')AS DOUBLE) AS seller_percentage_fee,
CAST(json_extract_scalar(json_parse(cast(concat('[', array_join(receivedAllocs, ','), ']') as varchar)),'$[5].value')AS DOUBLE) AS seller_amount_raw
FROM
{{ source('mavis_marketplace_ronin','MavisMarketPlace_evt_OrderMatched') }}
{% if is_incremental() %}
WHERE {{incremental_predicate('evt_block_time')}}
{% endif %}
),

base_trades as (

select
'ronin' as blockchain,
'mavis market' as project,
'v1' as project_version,
block_time,
cast(date_trunc('day', block_time) as date) as block_date,
cast(date_trunc('month', block_time) as date) as block_month,
block_number,
nft_contract_address,
nft_token_id,
quantity as nft_amount,
seller,
buyer,
'' as trade_category,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 'Buy' or 'Sell'.
If it's not possible to determine the trade direction, feel free to just set 'Buy' as the default.

'' as trade_type,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 'secondary'

price_raw,
currency_address as currency_contract,
contract_address as project_contract_address,
tx_hash,
platform_address as platform_fee_address,
platform_fee_amount_raw,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This always returns 200 currently which seems to be the ratio and not the actual raw value?

creator_royalty_address as royalty_fee_address,
creator_royalty_fee_amount_raw as royalty_fee_amount_raw,
-- axie_fee_amount_raw,
-- ronin_treasury_fee_amount_raw,
Comment on lines +79 to +80
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want, you can keep these in this model.
They won't make it into nft.trades but at least they'll be available in the project specific model.

evt_index as sub_tx_trade_id
FROM trade_details
)

-- this will be removed once tx_from and tx_to are available in the base event tables
{{ add_nft_tx_data('base_trades', 'ronin') }}



Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
,ref('nft_blast_base_trades')
,ref('nft_fantom_base_trades')
,ref('nft_nova_base_trades')
,ref('nft_ronin_base_trades')
] %}

with base_union as (
Expand Down
2 changes: 1 addition & 1 deletion dbt_subprojects/nft/models/_sector/trades/nft_trades.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
schema = 'nft',
alias = 'trades',
materialized = 'view',
post_hook='{{ expose_spells(\'["ethereum","solana","bnb","optimism","arbitrum","polygon","zksync", "blast"]\',
post_hook='{{ expose_spells(\'["ethereum","solana","bnb","optimism","arbitrum","polygon","zksync", "blast", "ronin", "nova"]\',
"sector",
"nft",
\'["soispoke","0xRob", "hildobby"]\') }}')
Expand Down
3 changes: 3 additions & 0 deletions sources/_sector/nft/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ sources:
- name: nft_sei
tables:
- name: transfers
- name: nft_ronin
tables:
- name: transfers
7 changes: 7 additions & 0 deletions sources/_sector/nft/trades/ronin_sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2

sources:
- name: mavis_marketplace_ronin
tables:
- name: MavisMarketPlace_evt_OrderMatched

Loading