Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comptetitor aprs #75

Merged
merged 35 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
fcdb0bd
New queries to measure the kpis from competitors
PoloX2021 Nov 6, 2024
7bb4668
new parameter added because of the previous queries
PoloX2021 Nov 6, 2024
dd0dccc
Excludes possible negative tvls because of issues with ERC20/ETH tran…
PoloX2021 Nov 6, 2024
45d3f2a
Formatting
PoloX2021 Nov 6, 2024
752bf52
Added a missing blockchain parameter
PoloX2021 Nov 6, 2024
9fc431a
Simplified the querying of all tranactions from a curve pool
PoloX2021 Nov 15, 2024
7060d6d
Few comments and adapting to remarks for Curve
PoloX2021 Nov 15, 2024
db8459a
Added filter by x largest pools
PoloX2021 Nov 15, 2024
cb41f52
Added/propagated through queries number_of_pools parameter and variou…
PoloX2021 Nov 18, 2024
27ac2db
Removed the union for inactive pools. THe left join does the work
PoloX2021 Nov 19, 2024
1f328eb
Fixed the sqlfluff
PoloX2021 Nov 19, 2024
0bf6622
Moved the folder to kpis/competitors
PoloX2021 Nov 20, 2024
0d0f7f5
New query to replace the uni style querying. they are now grouped in …
PoloX2021 Nov 20, 2024
72f5c6a
Added the project value to classify the pools: uni/ pancake/sushi
PoloX2021 Nov 22, 2024
73a55b2
Comments
PoloX2021 Nov 22, 2024
77c8121
Added parameter for time window, and removed avg(tvl), avg(fee)
PoloX2021 Nov 22, 2024
a6478fa
upadated default parameter
PoloX2021 Nov 22, 2024
d53d5c0
Added syncs inline to kpis.
PoloX2021 Nov 22, 2024
7f4dbb9
Added flag uni/pancake/Sushi and parameter for time window
PoloX2021 Nov 22, 2024
5b26df3
New default value for day, few comments and renaming
PoloX2021 Nov 26, 2024
cd66d9f
Changed deployer contract addres for uniswap
PoloX2021 Nov 26, 2024
694d5cf
Query to regroup all the different projects kpis together
PoloX2021 Nov 26, 2024
df49fb1
Typo for chain_id
PoloX2021 Nov 26, 2024
f162872
fixed typo and added base
PoloX2021 Nov 26, 2024
f08a4b5
updated kpis to filter before joining and improve performance
PoloX2021 Nov 26, 2024
87e124c
increased number of pools to display
PoloX2021 Nov 27, 2024
e7d1ca0
Adding CoW AMMs to the list of AMMs to monitor
PoloX2021 Nov 27, 2024
cfce2fa
Merge branch 'main' into comptetitor-APRs
PoloX2021 Nov 27, 2024
18a234e
typo in chain_id
PoloX2021 Nov 28, 2024
c7a082f
Adding parameter for time window
PoloX2021 Nov 28, 2024
027cfd1
wrong join leading to less pools visible
PoloX2021 Nov 28, 2024
e61c63f
Adapting the query to get the info for every chain
PoloX2021 Nov 28, 2024
2883f13
wrong sum for volume/apr in curve and cow_amm kpis
PoloX2021 Nov 28, 2024
4f778a4
Merge branch 'main' into comptetitor-APRs
PoloX2021 Nov 29, 2024
69112e1
Renaming table temp + typo
PoloX2021 Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cowamm/kpi/competitors/all_competitors_4335231.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ select
end as chain_id
from "query_4232873(blockchain='ethereum', competitor_end_time='{{competitor_end_time}}')"
-- there are no significant curve pools on arbitrum/gnosis
where {{blockchain}} = 'ethereum'
where '{{blockchain}}' = 'ethereum'

union distinct

Expand Down
34 changes: 21 additions & 13 deletions cowamm/kpi/competitors/cow_amm/cow_amm_kpi_4340428.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@
select
contract_address,
tvl,
sum(usd_value) over (partition by contract_address order by latest_per_pool) as volume,
365 * sum(surplus_usd / tvl) over (partition by contract_address order by latest_per_pool) as apr
from "query_4340356(blockchain='{{blockchain}}')" as tvl
left join
( --noqa: ST05
select *
from cow_protocol_{{blockchain}}.trades
where
block_time >= date_add('day', -1, (case when '{{competitor_end_time}}' = '2100-01-01' then now() else timestamp '{{competitor_end_time}}' end))
) as t
on
t.tx_hash = tvl.tx_hash
and tvl.contract_address = trader
volume,
apr
from ( --noqa: ST05
select
contract_address,
tvl,
latest_per_pool,
sum(usd_value) over (partition by contract_address order by latest_per_pool desc) as volume,
365 * sum(surplus_usd / tvl) over (partition by contract_address order by latest_per_pool desc) as apr
from "query_4340356(blockchain='{{blockchain}}')" as tvl
left join
( --noqa: ST05
select *
from cow_protocol_{{blockchain}}.trades
where
block_time >= date_add('day', -1, (case when '{{competitor_end_time}}' = '2100-01-01' then now() else timestamp '{{competitor_end_time}}' end))
) as t
on
t.tx_hash = tvl.tx_hash
and tvl.contract_address = trader
)
where latest_per_pool = 1
47 changes: 28 additions & 19 deletions cowamm/kpi/competitors/curve/curve_kpis_4232873.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,32 @@
-- {{competitor_end_time}}: The end time of the time window (end_time - 1 day; end_time), defaults to now()
select
contract_address,
fee,
tvl,
sum(amount_usd) over (partition by contract_address order by latest_per_pool) as volume,
365 * sum(amount_usd * fee / tvl) over (partition by contract_address order by latest_per_pool) as apr
-- The first call to 4232976 gets the tvl after each tx to compute volume/tvl
from "query_4232976(blockchain='{{blockchain}}')" as r
left join
( --noqa: ST05
select *
from curve.trades
where
block_time >= date_add('day', -1, (case when '{{competitor_end_time}}' = '2100-01-01' then now() else timestamp '{{competitor_end_time}}' end))
) as t
on
r.contract_address = t.project_contract_address
and r.tx_hash = t.tx_hash
where
latest_per_pool = 1
-- This test avoids any possible issue with reconstructing the reserves of the pool
and tvl > 0
fee,
volume,
apr
from (
select
contract_address,
fee,
tvl,
latest_per_pool,
sum(amount_usd) over (partition by contract_address order by latest_per_pool) as volume,
365 * sum(amount_usd * fee / tvl) over (partition by contract_address order by latest_per_pool) as apr
-- The first call to 4232976 gets the tvl after each tx to compute volume/tvl
from "query_4232976(blockchain='{{blockchain}}')" as r
left join
( --noqa: ST05
select *
from curve.trades
where
block_time >= date_add('day', -1, (case when '{{competitor_end_time}}' = '2100-01-01' then now() else timestamp '{{competitor_end_time}}' end))
) as t
on
r.contract_address = t.project_contract_address
and r.tx_hash = t.tx_hash
where
-- This test avoids any possible issue with reconstructing the reserves of the pool
tvl > 0
)
where latest_per_pool = 1