KaskoazulUntitled Query
    Updated 2022-05-12
    with price as (
    select hour::date as fecha,
    token_address,
    avg(price) as avg_price
    from ethereum.token_prices_hourly_v2
    where fecha >= '2022-05-01'
    and token_address = lower('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48') --USDC
    or token_address = lower('0xdAC17F958D2ee523a2206206994597C13D831ec7') --USDT
    or token_address = lower('0x6B175474E89094C44Da98b954EedeAC495271d0F') --DAI
    or token_address = lower('0x4Fabb145d64652a948d72533023f6E7A623C7C53') --BUSD erc20
    or token_address = lower('0xe9e7cea3dedca5984780bafc599bd69add087d56') --BSUD bep20
    or token_address = lower('0x0000000000085d4780B73119b644AE5ecd22b376') --TUSD
    or token_address = lower('0x8e870d67f660d95d5be530380d0ec0bd388289e1') --PUSD
    group by 1,2
    )

    select b.balance_date,
    b.symbol,
    sum(b.balance * p.avg_price) as stables
    from ethereum.erc20_balances b
    inner join price p
    on b.balance_date = p.fecha
    and b.contract_address = p.token_address
    where b.balance_date >= '2022-05-01'
    and b.contract_address = lower('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48') --USDC
    or b.contract_address = lower('0x6B175474E89094C44Da98b954EedeAC495271d0F') --DAI
    or b.contract_address = lower('0x4Fabb145d64652a948d72533023f6E7A623C7C53') --BUSD erc20
    or b.contract_address = lower('0xe9e7cea3dedca5984780bafc599bd69add087d56') --BSUD bep20
    or b.contract_address = lower('0x0000000000085d4780B73119b644AE5ecd22b376') --TUSD
    or b.contract_address = lower('0x8e870d67f660d95d5be530380d0ec0bd388289e1') --PUSD
    group by 1,2
    Run a query to Download Data