-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
base: main
Are you sure you want to change the base?
Changes from all commits
c0acff4
b37b3f0
6586ead
63734bd
fedfdd8
fdaf6fd
60644e0
3738876
87446b7
8d9334d
640d19f
2d2b592
b383037
5531f67
66d87dc
c0502ff
ffe2b2f
1e25dc3
22e9e48
d4d2448
65327aa
e448b2d
f7e4ec9
0521891
c4515d1
e0a2193
6757066
803b7b1
eda05e4
5bf6195
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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, | ||
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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be 'Buy' or 'Sell'. |
||
'' as trade_type, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This always returns |
||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you want, you can keep these in this 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 |
---|---|---|
|
@@ -49,3 +49,6 @@ sources: | |
- name: nft_sei | ||
tables: | ||
- name: transfers | ||
- name: nft_ronin | ||
tables: | ||
- name: transfers |
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 | ||
|
There was a problem hiding this comment.
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