diff --git a/cowamm/kpi/competitors/curve/curve_largest_2token_pools_4232976.sql b/cowamm/kpi/competitors/curve/curve_largest_2token_pools_4232976.sql index 71d4aff5..5863466b 100644 --- a/cowamm/kpi/competitors/curve/curve_largest_2token_pools_4232976.sql +++ b/cowamm/kpi/competitors/curve/curve_largest_2token_pools_4232976.sql @@ -48,7 +48,6 @@ transfers as ( -- rebuilds the reserves from the transfers -- ETH transfers are not considered --- prices.usd reserves as ( select contract_address, diff --git a/cowamm/kpi/tvl_by_chain_4096107.sql b/cowamm/kpi/tvl_by_chain_4096107.sql index 439a8178..d5300e94 100644 --- a/cowamm/kpi/tvl_by_chain_4096107.sql +++ b/cowamm/kpi/tvl_by_chain_4096107.sql @@ -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 diff --git a/cowamm/profitability/10k_growth/balancer_4106553.sql b/cowamm/profitability/10k_growth/balancer_4106553.sql index fefa8acb..35f7ef4f 100644 --- a/cowamm/profitability/10k_growth/balancer_4106553.sql +++ b/cowamm/profitability/10k_growth/balancer_4106553.sql @@ -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 diff --git a/cowamm/profitability/10k_growth/cow_4047078.sql b/cowamm/profitability/10k_growth/cow_4047078.sql index 526be00b..56ff060f 100644 --- a/cowamm/profitability/10k_growth/cow_4047078.sql +++ b/cowamm/profitability/10k_growth/cow_4047078.sql @@ -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 diff --git a/cowamm/profitability/10k_growth/daily_rebalancing_4055484.sql b/cowamm/profitability/10k_growth/daily_rebalancing_4055484.sql index 8d9eda0a..6fe9ebc3 100644 --- a/cowamm/profitability/10k_growth/daily_rebalancing_4055484.sql +++ b/cowamm/profitability/10k_growth/daily_rebalancing_4055484.sql @@ -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 diff --git a/cowamm/profitability/10k_growth/hodl_4086902.sql b/cowamm/profitability/10k_growth/hodl_4086902.sql index 2398dba9..01fbc516 100644 --- a/cowamm/profitability/10k_growth/hodl_4086902.sql +++ b/cowamm/profitability/10k_growth/hodl_4086902.sql @@ -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}}') @@ -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}} diff --git a/cowamm/profitability/10k_growth/uni_v2_4047194.sql b/cowamm/profitability/10k_growth/uni_v2_4047194.sql index 61a702f7..700f1b37 100644 --- a/cowamm/profitability/10k_growth/uni_v2_4047194.sql +++ b/cowamm/profitability/10k_growth/uni_v2_4047194.sql @@ -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 diff --git a/cowamm/profitability/invariant_growth/balancer_4106329.sql b/cowamm/profitability/invariant_growth/balancer_4106329.sql index 51ed28d4..2fa9daa9 100644 --- a/cowamm/profitability/invariant_growth/balancer_4106329.sql +++ b/cowamm/profitability/invariant_growth/balancer_4106329.sql @@ -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 diff --git a/cowprotocol/solver_dashboard/cow_rewards_totals_1372979.sql b/cowprotocol/solver_dashboard/cow_rewards_totals_1372979.sql index b859a55d..672bbd3c 100644 --- a/cowprotocol/solver_dashboard/cow_rewards_totals_1372979.sql +++ b/cowprotocol/solver_dashboard/cow_rewards_totals_1372979.sql @@ -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 @@ -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 ( diff --git a/cowprotocol/solver_dashboard/deprecated_queries/solver_rewards_totals_1821285.sql b/cowprotocol/solver_dashboard/deprecated_queries/solver_rewards_totals_1821285.sql index a1ed4d7c..0fade013 100644 --- a/cowprotocol/solver_dashboard/deprecated_queries/solver_rewards_totals_1821285.sql +++ b/cowprotocol/solver_dashboard/deprecated_queries/solver_rewards_totals_1821285.sql @@ -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