Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fleupold committed Nov 29, 2024
1 parent 6ab399a commit c77f449
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ transfers as (

-- rebuilds the reserves from the transfers
-- ETH transfers are not considered
-- prices.usd
reserves as (
select
contract_address,
Expand Down
2 changes: 1 addition & 1 deletion cowamm/kpi/tvl_by_chain_4096107.sql
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ tvl as (
balance,
(balance * p.price_close) / pow(10, decimals) as tvl
from reserves_by_day as r
inner join prices.minute_daily as p
inner join prices.day as p
on
r.day = p.day
and p.contract_address = token
Expand Down
2 changes: 1 addition & 1 deletion cowamm/profitability/10k_growth/balancer_4106553.sql
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ tvl as (
on
l.pool_address = pool.pool_address
and l.blockchain = pool.blockchain
left join prices.minute_daily as p1
left join prices.day as p1
on
l.blockchain = p1.blockchain
and l.token_address = p1.contract_address
Expand Down
4 changes: 2 additions & 2 deletions cowamm/profitability/10k_growth/cow_4047078.sql
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ tvl as (
-- performance optimisation: only look at the last update of the day
and tvl.latest = 1
) as tvl_complete
inner join prices.minute_daily as p1
inner join prices.day as p1
on
tvl_complete.day = p1.day
and p1.contract_address = token1
and p1.blockchain = '{{blockchain}}'
inner join prices.minute_daily as p2
inner join prices.day as p2
on
tvl_complete.day = p2.day
and p2.contract_address = token2
Expand Down
8 changes: 4 additions & 4 deletions cowamm/profitability/10k_growth/daily_rebalancing_4055484.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ daily_price_change as (
p1.price_close / previous_p1.price_close as p1,
p2.price_close / previous_p2.price_close as p2
from date_series as ds
inner join prices.minute_daily as p1
inner join prices.day as p1
on
p1.day = ds.day
and p1.contract_address = {{token_a}}
left join prices.minute_daily as previous_p1
left join prices.day as previous_p1
on
previous_p1.day = ds.day - interval '1' day
-- avoid computing price change on first day
and previous_p1.day >= date(timestamp '{{start}}')
and previous_p1.contract_address = {{token_a}}
inner join prices.minute_daily as p2
inner join prices.day as p2
on
p2.day = ds.day
and p2.contract_address = {{token_b}}
left join prices.minute_daily as previous_p2
left join prices.day as previous_p2
on
previous_p2.day = ds.day - interval '1' day
-- avoid computing price change on first day
Expand Down
8 changes: 4 additions & 4 deletions cowamm/profitability/10k_growth/hodl_4086902.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ starting_balance as (
select
5000 / p1.price_close as token_a_start,
5000 / p2.price_close as token_b_start
from prices.minute_daily as p1
inner join prices.minute_daily as p2
from prices.day as p1
inner join prices.day as p2
on
p1.day = p2.day
and p1.day = date(timestamp '{{start}}')
Expand All @@ -32,11 +32,11 @@ select
token_a_start * p1.price_close + token_b_start * p2.price_close as current_value_of_investment
from starting_balance
cross join date_series as ds
inner join prices.minute_daily as p1
inner join prices.day as p1
on
ds.day = p1.day
and p1.contract_address = {{token_a}}
inner join prices.minute_daily as p2
inner join prices.day as p2
on
ds.day = p2.day
and p2.contract_address = {{token_b}}
Expand Down
2 changes: 1 addition & 1 deletion cowamm/profitability/10k_growth/uni_v2_4047194.sql
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ tvl as (
token1 as token
from reserve_balances
) as balances
left join prices.minute_daily as prices
left join prices.day as prices
on
blockchain = '{{blockchain}}'
and balances.token = prices.contract_address
Expand Down
2 changes: 1 addition & 1 deletion cowamm/profitability/invariant_growth/balancer_4106329.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ tvl as (
on
l.pool_address = pool.pool_address
and l.blockchain = pool.blockchain
left join prices.minute_daily as p1
left join prices.day as p1
on
l.blockchain = p1.blockchain
and l.token_address = p1.contract_address
Expand Down
6 changes: 4 additions & 2 deletions cowprotocol/solver_dashboard/cow_rewards_totals_1372979.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- This query computes the total amount of COW distributed as rewards
-- it uses all of the outgoing transactions from the rewards safe
-- and the price is converted to USD using the latest price from the prices.minute_latest table
-- and the price is converted to USD using the latest price from the prices.minute table
-- the inception date is defined as 2022-03-01

-- finally the query calculates the daily payout and the project budget for the year
Expand All @@ -26,10 +26,12 @@ addresses as (
),

latest_cow_price as (
select price from prices.minute_latest
select price from prices.minute
where
blockchain = '{{blockchain}}'
and contract_address = (select token from addresses where blockchain = '{{blockchain}}')
order by timestamp desc
limit 1
),

solver_cow_rewards as (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ select
*,
total_cow_rewarded * (
select price
from prices.minute_latest
from prices.minute
where
contract_address = 0xdef1ca1fb7fbcdc777520aa7f396b4e015f497ab
and blockchain = 'ethereum'
order by timestamp desc
limit 1
) as cow_rewarded_usd
from final_tally

0 comments on commit c77f449

Please sign in to comment.