MoeNFT values - collateral - based on average price of collection
    Updated 2022-09-07
    with nfts as ( with collections as
    (select '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d' as contract_address , 'BAYC'as collection union all
    select '0x60e4d786628fea6478f785a6d7e704777c86a7c6' as contract_address , 'MAYC'as collection union all
    select '0x8a90cab2b38dba80c64b7734e58ee1db38b8992e' as contract_address , 'Doodles' as collection union all
    select '0xed5af388653567af2f388e6224dc7c4b3241c544' as contract_address , 'Azuki' as collection union all
    select '0x620b70123fb810f6c653da7644b5dd0b6312e4d8' as contract_address , 'Space Doodles' as collection union all
    select '0x49cf6f5d44e70224e2e23fdcdd2c053f30ada28b' as contract_address , 'CloneX' as collection )


    select
    date_trunc(week,BLOCK_TIMESTAMP)::date as weeks,
    collection,t.contract_address,
    count (distinct TX_HASH) as tx_count,
    count(distinct ORIGIN_FROM_ADDRESS) as users,
    sum(tx_count)over(partition by collection order by weeks rows between unbounded preceding and current row ) as cum_tx_count

    from ethereum.core.fact_event_logs t
    join collections c on t.contract_address = c.contract_address
    where t.contract_address in (select contract_address from collections)
    and EVENT_NAME = 'Transfer'
    and event_inputs:to = '0x3b968d2d299b895a5fcf3bba7a64ad0f566e6f88'
    and origin_to_address = '0x3b968d2d299b895a5fcf3bba7a64ad0f566e6f88'
    and BLOCK_TIMESTAMP >= current_date - {{days_back}}
    group by 1,2,3)

    ,prices as (
    select
    NFT_ADDRESS,
    avg(price) as price
    from ethereum.core.ez_nft_sales
    where BLOCK_TIMESTAMP >= CURRENT_DATE-60
    group by 1
    )

    select
    Run a query to Download Data