MLDZMNHIP7
    Updated 2022-11-27
    with price_tab as (
    select recorded_at::date as day,
    lower(symbol) as symbol11,
    avg (price) as token_price
    from osmosis.core.dim_prices
    group by 1,2

    union ALL

    select hour::date as day,
    case when symbol = 'USDC' then 'USDC.axl'
    when symbol = 'USDT' then 'USDT.axl'
    when symbol = 'aTUSD' then 'USDC.grv'
    when symbol = 'sUSD' then 'USDT.grv'
    when symbol = 'iUSD' then 'USDX'
    when symbol = 'WETH' then 'WETH.axl'
    when symbol = 'aWETH' then 'WETH.grv'
    when symbol = 'WBTC' then 'WBTC.axl'
    when symbol = 'uWBTC' then 'WBTC.grv'
    when symbol = 'DAI' then 'DAI.axl'
    when symbol = 'aDAI' then 'DAI.grv'
    when symbol = 'FRAX' then 'FRAX.axl'
    else symbol end as symbol11,
    avg (price) as token_price
    from ethereum.core.fact_hourly_token_prices
    group by 1,2),

    tb1 as (SELECT
    LIQUIDITY_PROVIDER_ADDRESS as user1,
    a.Label as symbol1,
    case when currency = 'ibc/64BA6E31FE887D66C6F8F31C7B1A80C7CA179239677B4088BB55F5EA07DBE273' then amount*token_price/pow(10,18)
    else amount*token_price/pow(10,decimal) end as amount_usd,
    *
    from osmosis.core.fact_liquidity_provider_actions s left join osmosis.core.dim_labels a on s.currency=a.ADDRESS
    join price_tab b on a.label=b.symbol11 and s.block_timestamp::date=b.day
    where tx_status='SUCCEEDED'
    Run a query to Download Data