MadiHeld Time ME distr
Updated 2023-01-26
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
with
df_mint_magic as (select
date_trunc ('day', BLOCK_TIMESTAMP) as date, TX_ID, PURCHASER, MINT_PRICE, MINT
from solana.core.fact_nft_mints
where SUCCEEDED = 'TRUE' and MINT_CURRENCY = 'So11111111111111111111111111111111111111111'
and mint in (select DISTINCT mint from solana.core.fact_nft_sales
where MARKETPLACE in ('exchange art') and SUCCEEDED)),
df_sales_magic_eden as (select
date_trunc('day', BLOCK_TIMESTAMP) as date, TX_ID, SALES_AMOUNT, MINT, purchaser, seller
from solana.core.fact_nft_sales
where MARKETPLACE in ('exchange art') and SUCCEEDED),
rec as
(
SELECT date, PURCHASER, Mint as token_id, MINT_PRICE as SALES_AMOUNT FROM df_mint_magic
UNION ALL
SELECT date, PURCHASER,Mint as token_id, SALES_AMOUNT FROM df_sales_magic_eden),
recievers as ( select PURCHASER as buyer_address, token_id, SALES_AMOUNT as purch_amount, min (date) as purchase_date from rec
group by 1,2,3),
sellers as (SELECT SELLER as seller_address,Mint as token_id, SALES_AMOUNT as sales_amount, min (date) as sale_date
FROM df_sales_magic_eden group by 1,2,3),
df3 as (
select
datediff (day,purchase_date, sale_date) as Holding_Time,
buyer_address as wallet,
purch_amount-sales_amount as profit,
t1.token_id
from sellers t1 join recievers t2 on t1.seller_address = t2.buyer_address and t1.token_id = t2.token_id
where Holding_Time >= 0)
select
CASE