-- 按时间排序,找出该合约最近的10笔交易with lastest_trades as (select*from nft.trades where nft_contract_address = 0xed5af388653567af2f388e6224dc7c4b3241c544 -- azuki NFT的合约地址-- and block_time > now() - interval '24' hour --你也可以按时间排序order by block_time desclimit10)selectmin(amount_original) as floor_price --直接获取最小值-- percentile_cont(.05) within GROUP (order by amount_original) as floor_price --这么做是取最低和最高价之间5%分位数,防止一些过低的价格交易影响from lastest_tradeswhere currency_symbol IN ('ETH', 'WETH')andcast(number_of_items asinteger) =1-- 这里可以按不同的链,不同的交易token进行过滤
参考链接:https://dune.com/queries/1660139
成交量、总成交额度、总交易笔数等、24小时/7天/1月成交额度
with total_volume as(SELECTsum(amount_original) as"Total Trade Volume(ETH)", --总成交量ETHsum(amount_usd) as"Total Trade Volume(USD)", --总成交量USDcount(amount_original) as"Total Trade Tx"--总交易笔数FROM nft.tradesWHERE nft_contract_address = 0xed5af388653567af2f388e6224dc7c4b3241c544-- AND currency_symbol IN ('ETH', 'WETH') ),total_fee as (selectsum(royalty_fee_amount) as"Total Royalty Fee(ETH)", --总版权税ETHsum(royalty_fee_amount_usd) as"Total Royalty Fee(USD)", --总版权税USDsum(platform_fee_amount) as"Total Platform Fee(ETH)", --总平台抽成ETHsum(platform_fee_amount_usd) as"Total Platform Fee(USD)"--总平台抽成USDfrom nft.fees WHERE nft_contract_address = 0xed5af388653567af2f388e6224dc7c4b3241c544-- AND royalty_fee_currency_symbol IN ('ETH', 'WETH') )select*from total_volume, total_fee
参考链接:https://dune.com/queries/1660292
每日/每月/每周成交量
with hourly_trade_summary as (select date_trunc('day', block_time) as block_date, sum(number_of_items) as items_traded,sum(amount_raw) / 1e18 as amount_raw_traded,sum(amount_usd) as amount_usd_tradedfrom opensea.tradeswhere nft_contract_address = 0xed5af388653567af2f388e6224dc7c4b3241c544-- and block_time > now() - interval '90' daygroup by1order by1)select block_date, items_traded, amount_raw_traded, amount_usd_traded,sum(items_traded) over (order by block_date asc) as accumulate_items_traded,sum(amount_raw_traded) over (order by block_date asc) as accumulate_amount_raw_traded,sum(amount_usd_traded) over (order by block_date asc) as accumulate_amount_usd_tradedfrom hourly_trade_summaryorder by block_date
参考链接:https://dune.com/queries/1664420
当前持有人数,总token数量,holder的分布等
with nft_trade_details as ( --获取交易的买入卖出方详细信息表,卖出方是负数,买入方是select seller as trader,-1*cast(number_of_items asinteger) as hold_item_countfrom nft.tradeswhere nft_contract_address = 0xed5af388653567af2f388e6224dc7c4b3241c544union allselect buyer as trader,cast(number_of_items asinteger) as hold_item_countfrom nft.tradeswhere nft_contract_address = 0xed5af388653567af2f388e6224dc7c4b3241c544),nft_traders as (select trader,sum(hold_item_count) as hold_item_countfrom nft_trade_detailsgroup by traderhavingsum(hold_item_count) >0order by2desc),nft_traders_summary as (select (casewhen hold_item_count >=100then'Hold >= 100 NFT'when hold_item_count >=20and hold_item_count <100then'Hold 20 - 100'when hold_item_count >=10and hold_item_count <20then'Hold 10 - 20'when hold_item_count >=3and hold_item_count <10then'Hold 3 - 10'else'Hold 1 or 2 NFT'end) as hold_count_type,count(*) as holders_countfrom nft_tradersgroup by1order by2desc),total_traders_count as (selectcount(*) as total_holders_count,max(hold_item_count) as max_hold_item_countfrom nft_traders),total_summary as (select0as total_nft_count,count(*) as transaction_count,sum(number_of_items) as number_of_items_traded,sum(amount_raw) / 1e18 as eth_amount_traded,sum(amount_usd) as usd_amount_tradedfrom opensea.tradeswhere nft_contract_address = 0xed5af388653567af2f388e6224dc7c4b3241c544)select*from nft_traders_summaryjoin total_traders_count on truejoin total_summary on true