Sectortest1
Updated 2022-10-09
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
›
⌄
--Log
-- 1. Need incorporate simplified holder list from NFT_Transfers. Current list does not account for transfers and shows multiple holders for a token with current date.
-- 1a. I am matching buys and sells by nft_contract and tokenid. What about ERC1155 tokens where the token id is the same for each? How is it counting those?
-- 2. need to create individual wallet PnL tracker to perform QA. Create subsections to perform QA from begining to end to isolate issues.
-- 3. Need to evaluate solution for duplicate wallets. If a wallet holds 2 are their trades being counted twice? If we eliminate duplicate wallets will this impact someone who bought, sold then bought again?
-- Done: Add to holders table since distinct will not work. ROW_NUMBER() OVER (PARTITION BY wallet ORDER BY buy/sell_date DESC) AS rank, then in the next table: where rank=1
-- Still Need to verify this works.
-- select
-- ROW_NUMBER() OVER (PARTITION BY nft_to_address, tokenid ORDER BY block_timestamp DESC) AS rank,
-- block_timestamp as date,
-- nft_to_address as buyer,
-- nft_from_address as seller,
-- tokenid
-- from ethereum.core.ez_nft_transfers
-- where nft_address = lower('0x08d7c0242953446436f34b4c78fe9da38c73668d')
With mint_or_buy as (
select
date_trunc('day', block_timestamp) as mint_or_buy_date,
nft_to_address as wallet,
tokenid
from ethereum.core.ez_nft_mints
where nft_address = lower('0x08d7c0242953446436f34b4c78fe9da38c73668d')
union
--Find all wallets that purchased and join it with the minted list. These are all wallets that at one point acquired one
select
date_trunc('day', block_timestamp) as mint_or_buy_date,
buyer_address as wallet,
tokenid
from ethereum.core.ez_nft_sales a
where nft_address = lower('0x08d7c0242953446436f34b4c78fe9da38c73668d')
),
--Find all wallets that have ever sold
Run a query to Download Data