marquOP DEX Aggregators - Slingshot assets in
    Updated 2022-09-29
    with

    swap_txs as (

    select

    block_timestamp,
    tx_hash,
    label_aggregator,

    from_amount_raw,
    from_amount_raw / pow(10,ifnull(prices_from.decimals,18)) as from_amount,
    coalesce(from_amount * prices_from.price,
    to_amount_raw / pow(10,ifnull(prices_to.decimals,18)) * prices_to.price,
    0) as from_amount_usd,
    prices_from.symbol as from_symbol

    from (
    select distinct

    block_timestamp,
    tx_hash,
    'Slingshot' as label_aggregator,
    origin_from_address as user_address,

    first_value(raw_amount) over (partition by tx_hash order by regexp_replace(_log_id,'0x[A-z0-9]*-','')::int) as from_amount_raw,
    first_value(contract_address) over (partition by tx_hash order by regexp_replace(_log_id,'0x[A-z0-9]*-','')::int) as from_token_address,

    last_value(raw_amount) over (partition by tx_hash order by regexp_replace(_log_id,'0x[A-z0-9]*-','')::int) as to_amount_raw,
    last_value(contract_address) over (partition by tx_hash order by regexp_replace(_log_id,'0x[A-z0-9]*-','')::int) as to_token_address

    from optimism.core.fact_token_transfers
    where origin_to_address in ('0x00c0184c0b5d42fba6b7ca914b31239b419ab80b','0xedd118e091eee0e7fa9eeb9b4db717518f56cb15')
    and origin_function_signature = '0x06e75722'
    and block_timestamp >= current_date() - interval '{{timeframe_months}} months'
    Run a query to Download Data