-
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
2 changed files
with
30 additions
and
92 deletions.
There are no files selected for viewing
92 changes: 0 additions & 92 deletions
92
cow_amm/profitability/invariant_growth/cow_amm_4059213.sql
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
-- Computes the absolute surplus per $100 tvl per day (aka its invariant growth) for a CoW AMM. | ||
-- Parameters | ||
-- {{token_a}} - either token of the desired uni pool | ||
-- {{token_b}} - other token of the desired uni pool | ||
-- {{start}} - date as of which the analysis should run | ||
|
||
-- Finds the CoW AMM pool address given tokens specified in query parameters (regardless of order) | ||
with cow_amm_pool as ( | ||
select | ||
created_at, | ||
address | ||
from query_3959044 | ||
where ((token_1_address = {{token_a}} and token_2_address = {{token_b}}) or (token_2_address = {{token_a}} and token_1_address = {{token_b}})) | ||
order by 1 desc | ||
limit 1 | ||
) | ||
|
||
-- computes, surplus, tvl and thus relative surplus (per $100) | ||
select | ||
block_date, | ||
SUM(surplus_usd) as absolute_invariant_growth, | ||
AVG(tvl) as tvl, | ||
SUM(surplus_usd / tvl) * 100 as pct_invariant_growth | ||
from cow_protocol_ethereum.trades as t | ||
inner join "query_4059700(token_a='{{token_a}}', token_b='{{token_b}}')" as tvl | ||
on | ||
t.tx_hash = tvl.tx_hash | ||
and tvl.pool = trader | ||
and trader = (select address from cow_amm_pool) | ||
group by 1 |