Skip to content

Instantly share code, notes, and snippets.

@vivekascoder
Created October 21, 2024 09:25
Show Gist options
  • Save vivekascoder/114a82f50daa732ed1e92562821d5cd6 to your computer and use it in GitHub Desktop.
Save vivekascoder/114a82f50daa732ed1e92562821d5cd6 to your computer and use it in GitHub Desktop.
with
combined as (
select
"from" as addr,
"blockTimestamp",
pool
from
indexer_blue."AddLiquidity"
union
select
"from" as addr,
"blockTimestamp",
pool
from
indexer_blue."RemoveLiquidity"
union
select
"from" as addr,
"blockTimestamp",
pool
from
indexer_blue."OpenLong"
union
select
"from" as addr,
"blockTimestamp",
pool
from
indexer_blue."CloseLong"
union
select
"from" as addr,
"blockTimestamp",
pool
from
indexer_blue."OpenShort"
union
select
"from" as addr,
"blockTimestamp",
pool
from
indexer_blue."CloseShort"
),
last_month as (
SELECT
EXTRACT(
EPOCH
FROM
NOW ()
) - 86400 AS lm
),
last_month_addresses as (
select distinct
addr
from
combined
where
"blockTimestamp" < (
select
lm
from
last_month
)
),
this_month_addresses as (
select distinct
addr
from
combined
where
"blockTimestamp" >= (
select
lm
from
last_month
)
)
select
count(distinct current.addr)
from
this_month_addresses current
LEFT JOIN last_month_addresses ON current.addr = last_month_addresses.addr;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment