-
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.
* AMMs on Base * Query which references/displays pools * Query to track volume evolution, with base * TVL evolution with base * Total volume, adapted for base * Comments * Answering remarks * Changing cow_protocol.trades * Adding aggregate_by value
- Loading branch information
Showing
6 changed files
with
131 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--Query computes the trading volume over all Cow AMMs (matching users and rebalancing) and 7 day growth thereof. | ||
with cow_trades as ( | ||
select | ||
block_date, | ||
sum(amount_usd) as volume | ||
from cow_protocol.trades as t | ||
inner join query_3959044 as pool | ||
on t.taker = pool.address | ||
group by 1 | ||
), | ||
|
||
cumulative_volume as ( | ||
select | ||
block_date as day, --noqa: RF04 | ||
sum(volume) over (order by block_date) as tvl | ||
from cow_trades | ||
) | ||
|
||
select | ||
prev.tvl as prev, | ||
curr.tvl as curr, | ||
100 * (curr.tvl - prev.tvl) / prev.tvl as growth | ||
from cumulative_volume as curr | ||
inner join cumulative_volume as prev | ||
on curr.day = prev.day + interval '7' day | ||
-- we don't have data for today | ||
and curr.day = date(now()) - interval '1' day |
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,21 @@ | ||
-- Query computes the TVL over all CoW AMMs | ||
|
||
-- Parameters | ||
-- {{aggregate_by}}: the frequence of the data, e.g. 'day', 'week', 'month' | ||
|
||
with prep as ( | ||
select * from "query_4096107(blockchain='ethereum')" | ||
union all | ||
select * from "query_4096107(blockchain='gnosis')" | ||
union all | ||
select * from "query_4096107(blockchain='arbitrum')" | ||
union all | ||
select * from "query_4096107(blockchain='base')" | ||
) | ||
|
||
select | ||
date_trunc('{{aggregate_by}}', day) as period, | ||
sum(tvl) as tvl | ||
from prep | ||
group by 1 | ||
order by 1 desc |
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,37 @@ | ||
-- This query displays all cow amms (all chains) and references a link to the micro dashboard | ||
|
||
select --noqa:ST06 | ||
concat( | ||
'<a href="https://dune.com/cowprotocol/cow-amm-micro-v2?token_a=', cast(token_1_address as varchar), '&token_b=', cast(token_2_address as varchar), '&blockchain=', t.blockchain, '&ref_token_a=', cast(token_1_address as varchar), '&ref_token_b=', cast(token_2_address as varchar), '&ref_blockchain=', t.blockchain, | ||
'" target="_blank">', cast(address as varchar), '</a>' | ||
) as cow_amm_address, | ||
t.blockchain, | ||
total_tvl, | ||
t1.symbol as token_1_symbol, | ||
t2.symbol as token_2_symbol, | ||
365 * surplus_1d / total_tvl as "1d APY", | ||
365 * surplus_7d / total_tvl / 7 as "7d APY", | ||
365 * surplus_30d / total_tvl / 30 as "30d APY", | ||
token_1_address, | ||
token_2_address | ||
from ( | ||
select | ||
-- created_at, | ||
address, | ||
blockchain, | ||
token_1_address, | ||
token_2_address, | ||
rank() over (partition by token_1_address, token_2_address order by created_at desc) as ranking | ||
from query_3959044 | ||
) as t | ||
inner join tokens.erc20 as t1 | ||
on token_1_address = t1.contract_address | ||
left join tokens.erc20 as t2 | ||
on token_2_address = t2.contract_address | ||
left join query_4062965 as tvl | ||
on tvl.pool = address | ||
where | ||
t.ranking = 1 | ||
and total_tvl > 0 | ||
group by 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 | ||
order by total_tvl desc --noqa: AM06 |
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,15 @@ | ||
--Query computes the trading volume over all Cow AMMs (matching users and rebalancing) | ||
|
||
-- Parameters: | ||
-- {{aggregate_by}}: the frequence of the data, e.g. 'day', 'week', 'month' | ||
with cow_trades as ( | ||
select | ||
date_trunc('{{aggregate_by}}', block_date) as period, | ||
sum(amount_usd) as volume | ||
from cow_protocol.trades as t | ||
inner join query_3959044 as pool | ||
on t.taker = pool.address | ||
group by 1 | ||
) | ||
|
||
select * from cow_trades |