select
sum(case when action in ('Delegate') then amount end) as staked_amount,
sum(case when action in ('Undelegate') then amount end) as unstaked_amount,
sum(case when action in ('Delegate') then amount when action in ('Undelegate') then amount * -1 end) as net_staked,
127475474 as circulating_supply,
(net_staked / circulating_supply * 100) as circulating_supply_to_staked
from terra.core.ez_staking
where tx_succeeded = 'TRUE'
and action in ('Delegate', 'Undelegate')