-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
182 additions
and
132 deletions.
There are no files selected for viewing
40 changes: 22 additions & 18 deletions
40
cowamm/profitability/competitor_kpis/curve/curve_kpis_4232873.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
-- Computes volume, tvl and APR for Curve pools | ||
-- APR is measured as the fees earned per $ invested, over the last 24 hours, projected over 1 year | ||
-- Input: blockchain | ||
select r.contract_address, | ||
sum(amount_usd) as volume, | ||
365*sum(amount_usd*fee/tvl) as apr, | ||
avg(fee) as fee, | ||
avg(tvl) as tvl | ||
from "query_4232976(blockchain='{{blockchain}}')" r | ||
left join curve.trades t | ||
on r.contract_address = t.project_contract_address | ||
and r.tx_hash = t.tx_hash | ||
where t.block_time>=date_add('day', -1, now()) | ||
-- This test avoids any possible issue with reconstructing the reserves of the pool | ||
and tvl >0 | ||
select | ||
r.contract_address, | ||
sum(amount_usd) as volume, | ||
365 * sum(amount_usd * fee / tvl) as apr, | ||
avg(fee) as fee, | ||
avg(tvl) as tvl | ||
from "query_4232976(blockchain='{{blockchain}}')" as r | ||
left join curve.trades as t | ||
on | ||
r.contract_address = t.project_contract_address | ||
and r.tx_hash = t.tx_hash | ||
where | ||
t.block_time >= date_add('day', -1, now()) | ||
-- This test avoids any possible issue with reconstructing the reserves of the pool | ||
and tvl > 0 | ||
group by r.contract_address | ||
|
||
union | ||
select | ||
contract_address, | ||
0 as volume, | ||
union distinct | ||
select | ||
contract_address, | ||
0 as volume, | ||
0 as apr, | ||
fee, | ||
tvl | ||
from "query_4232976(blockchain='{{blockchain}}')" | ||
where time<date_add('day', -1, now()) | ||
and latest = 1 | ||
where | ||
time < date_add('day', -1, now()) | ||
and latest = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.