denze-e7j2NUArtist Snapshot by Wallet
    Updated 2023-11-08
    -- forked from 4be29dd4-8cb4-4d52-abe2-107460c61497

    WITH

    -- get the artist wallet as an input
    input_artist AS (
    SELECT
    *
    FROM VALUES
    (lower('{{artist_wallet}}'))
    AS data(artist_wallet)
    WHERE data.artist_wallet regexp '^0x[0-9a-fA-F]{40}$' -- check address is a valid format, i.e. starts with 0x and has 42 characters total
    )

    , input_time AS (
    SELECT
    CASE
    WHEN to_timestamp_ntz(data.snapshot_time) > date_trunc('minute', current_timestamp) THEN current_date + interval '1 day' - interval '1 second'
    ELSE date_trunc('minute', to_timestamp_ntz(data.snapshot_time))
    END AS snapshot_time
    FROM VALUES
    ('{{artist_snapshot_time}}')
    AS data(snapshot_time)
    )
    -- create a manual list of shared contracts with label
    , input_contracts AS (
    SELECT
    *
    FROM VALUES
    (lower('0x495f947276749Ce646f68AC8c248420045cb7b5e'), 'OpenSea Shared Storefront')
    , (lower('0xb932a70A57673d89f4acfFBE830E8ed7f75Fb9e0'), 'SuperRare')
    , (lower('0xc143bbfcdbdbed6d454803804752a064a622c1f3'), 'Async Blueprints')
    , (lower('0x2963bA471e265e5F51cAfaFca78310FE87F8E6D1'), 'MakersPlace')
    , (lower('0x2A46f2fFD99e19a89476E2f62270e0a35bBf0756'), 'MakersPlace') -- V2
    , (lower('0x3b3ee1931dc30c1957379fac9aba94d1c48a5405'), 'Foundation')
    Run a query to Download Data