with pools as (
select origin_from_address, sum(lp_token_amount_usd) as amount
from optimism.velodrome.ez_lp_actions
where
pool_address = '0x4f7ebc19844259386dbddb7b2eb759eefc6f8353' and
lp_action = 'deposit' and
lp_token_amount_usd is not null
group by 1
union all
select origin_from_address, -sum(lp_token_amount_usd) as amount
from optimism.velodrome.ez_lp_actions
where
pool_address = '0x4f7ebc19844259386dbddb7b2eb759eefc6f8353' and
lp_action = 'withdraw' and
lp_token_amount_usd is not null
group by 1
),
liq as (
select
origin_from_address,
sum(amount) as lp
from pools
group by 1 having lp > 0
)
select
var_pop(lp) as variance,
avg(lp) as avg,
sqrt(variance) as standard_deviation
from liq