maybeyonasthor_swap_single_from_native
    Updated 2022-06-12
    with
    single_swaps_txs as (
    select tx_id from (
    select
    tx_id,
    count(tx_id) as swaps
    from thorchain.swaps
    group by 1
    )
    where swaps = 1
    ),
    swap_from as (
    select
    block_timestamp,
    tx_id,
    from_asset,
    from_amount,
    from_amount_usd,
    to_amount,
    to_amount_usd
    from thorchain.swaps
    where to_asset = 'THOR.RUNE'
    and tx_id in ( select tx_id from single_swaps_txs)
    )

    select
    date(block_timestamp) as date,
    split(from_asset,'.')[0]::string as chain,
    split(from_asset,'-')[0]::string as asset,
    count(tx_id) as swaps,
    sum(from_amount) as from_amount,
    sum(from_amount_usd) as from_amount_usd,
    sum(to_amount) as to_amount,
    sum(to_amount_usd) as to_amount_usd
    from swap_from
    where block_timestamp >= '2022-05-01'
    Run a query to Download Data