John_GaltASTRO LPing
    Updated 2023-01-17
    with table1 as (select
    attributes:message:sender as mint_address,
    sum(SPLIT_PART (attributes:wasm:assets, 'terra', 1)) / pow(10, 6) as mint_amount
    from terra.core.ez_messages
    where (attributes:wasm:_contract_address_0 = 'terra1w579ysjvpx7xxhckxewk8sykxz70gm48wpcuruenl29rhe6p6raslhj0m6' and
    attributes:wasm:"action_0" = 'provide_liquidity')
    and tx_succeeded = 'true'
    group by mint_address
    ),
    table2 as (select
    attributes:message:sender as burn_address,
    sum(SPLIT_PART (attributes:wasm:refund_assets, 'terra', 1)) / pow(10, 6) as burn_amount1
    from terra.core.ez_messages
    where (attributes:wasm:"_contract_address_1" = 'terra1w579ysjvpx7xxhckxewk8sykxz70gm48wpcuruenl29rhe6p6raslhj0m6' and
    attributes:wasm:"action_1" = 'withdraw_liquidity')
    and tx_succeeded = 'true'
    group by burn_address
    ),
    table3 as (select mint_address, mint_amount, COALESCE(burn_amount1, 0) as burn_amount,
    mint_amount - COALESCE(burn_amount, 0) as LPd_astro
    from table1
    left outer join table2 on table1.mint_address = table2.burn_address
    )
    select * from table3
    order by LPd_astro desc


    Run a query to Download Data