denze-e7j2NUCreator Fees Paid by {{nft_contract_address}} - Multiple Contracts
    Updated 2023-06-16
    -- forked from 14b22438-ed22-4592-bb3c-f7d7782ead95

    WITH

    input_contracts AS (
    SELECT
    trim(F.value) AS nft_contract_address
    FROM (
    SELECT
    SPLIT(data.nft_contract_address, ';') AS input -- input can be separated by semi-colons
    FROM VALUES
    (lower('{{nft_contract_address}}'))
    AS data(nft_contract_address)
    ) i
    , Table(Flatten(i.input)) AS F
    WHERE trim(F.value) 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 date_trunc('day', current_timestamp) -- adjust the time if input is a future time
    ELSE date_trunc('day', to_timestamp_ntz(data.snapshot_time))
    END AS snapshot_time -- use the end of the previous day / start of specified day as the snapshot time
    FROM VALUES
    ('{{snapshot_time}}')
    AS data(snapshot_time)
    )

    , input_creator_fee_perc AS (
    SELECT
    *
    FROM VALUES
    ({{creator_fee_perc}})
    AS data(creator_fee_perc)
    )
    Run a query to Download Data