Alish"Small" LP Actions
    Updated 2022-04-16
    -- NOTE: COMMENTED OUT QUERIES ARE NOT RUNNING DUE TO LACK OF DATA + THE QUERY RETURNING NULL ON THE AVAILABLE DATASET
    with bellow_1000_terra_ust as (
    SELECT
    date_trunc('day', block_timestamp) as date,
    COUNT(*) as count_bellow_1000
    FROM thorchain.liquidity_actions
    WHERE POOL_NAME='TERRA.UST' AND LP_ACTION='add_liquidity' AND RUNE_AMOUNT_USD + ASSET_AMOUNT_USD >= 0 AND RUNE_AMOUNT_USD + ASSET_AMOUNT_USD < 1000
    GROUP BY 1
    ),
    bellow_1000_terra_luna as (
    SELECT
    date_trunc('day', block_timestamp) as date,
    COUNT(*) as count_bellow_1000
    FROM thorchain.liquidity_actions
    WHERE POOL_NAME='TERRA.LUNA' AND LP_ACTION='add_liquidity' AND RUNE_AMOUNT_USD + ASSET_AMOUNT_USD >= 0 AND RUNE_AMOUNT_USD + ASSET_AMOUNT_USD < 1000
    GROUP BY 1
    ),
    all_terra as (
    SELECT date_trunc('day', block_timestamp) as date,
    COUNT(*) as count_terra
    FROM thorchain.liquidity_actions
    WHERE POOL_NAME='TERRA.UST' OR POOL_NAME='TERRA.LUNA' AND LP_ACTION='add_liquidity'
    GROUP BY 1
    ),
    terra_table as
    (
    SELECT bellow_1000_terra_ust.date,
    (bellow_1000_terra_ust.count_bellow_1000 + bellow_1000_terra_luna.count_bellow_1000) as count_bellow,
    count_bellow/(all_terra.count_terra) *100 as pct_small_lps,
    'terra' as column_name,
    all_terra.count_terra as total_count_terra
    FROM bellow_1000_terra_ust
    INNER JOIN all_terra
    ON all_terra.date=bellow_1000_terra_ust.date
    INNER JOIN bellow_1000_terra_luna
    ON bellow_1000_terra_luna.date=all_terra.date
    Run a query to Download Data