lostariousUniswap V2 CRV-WETH pool stats
    Updated 2021-09-16
    with tvl as (SELECT balance_date as date,SUM(amount_usd) as TVL_usd
    FROM ethereum.erc20_balances where user_address = '0x3da1313ae46132a397d90d95b1424a9a7e3e0fce' -- WETH-CRV Pool
    AND contract_address IN ('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2','0xd533a949740bb3306d119cc777fa900ba034cd52') -- Tokens
    GROUP BY 1),
    vols as (SELECT to_date(block_timestamp)as date,sum(amount_usd) as swap_volume_usd FROM ethereum.dex_swaps where pool_address = '0x3da1313ae46132a397d90d95b1424a9a7e3e0fce' GROUP BY 1)
    SELECT t.date,t.TVL_usd,v.swap_volume_usd,v.swap_volume_usd / t.TVL_usd as efficiency,(v.swap_volume_usd * 0.03 / 100) / t.TVL_usd * 100 * 365 as APY FROM tvl t join vols v on t.date = v.date
    WHERE t.date >= CURRENT_DATE - interval '90 days' AND t.date != CURRENT_DATE
    ORDER BY 1
    Run a query to Download Data