Skip to content

Commit

Permalink
use tvl query from #27
Browse files Browse the repository at this point in the history
  • Loading branch information
fleupold committed Sep 10, 2024
1 parent 3557134 commit 5c0690a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 92 deletions.
92 changes: 0 additions & 92 deletions cow_amm/profitability/invariant_growth/cow_amm_4059213.sql

This file was deleted.

30 changes: 30 additions & 0 deletions cowamm/profitability/invariant_growth/cow_amm_4059213.sql
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

0 comments on commit 5c0690a

Please sign in to comment.