kidaBuy per address
    Updated 2022-01-24
    WITH
    RE_events AS (
    SELECT
    block_timestamp,
    tx_id,
    event_attributes
    FROM
    terra.msg_events
    WHERE event_attributes:action = 'execute_orders'
    AND event_type = 'from_contract'
    AND tx_status = 'SUCCEEDED'
    ),

    RE_takers AS (
    SELECT DISTINCT
    tx_id,
    msg_value:sender as taker
    FROM
    terra.msgs
    WHERE
    tx_id IN (SELECT DISTINCT tx_id FROM RE_events)
    ),

    all_sales AS (
    SELECT
    *
    FROM (
    SELECT
    block_timestamp,
    tx_id,
    'Random Earth' as platform,
    action,
    IFF(action = 'SELL', maker, taker) as nft_from,
    IFF(action = 'ACCEPT BID', maker, taker) as nft_to,
    nft_address,
    Run a query to Download Data