Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CoW AMM] 10k growth for HODL strategy #47

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cowamm/profitability/10k_growth/daily_rebalancing_4055484.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Computes the balances and current value of a counterfactual portfolio that invests 10k evenly into two tokens and re-balances once a day to keep a 50:50 exposure
-- Parameters
-- {{token_a}} - either token of the desired uni pool
-- {{token_b}} - other token of the desired uni pool
-- {{token_a}} - either token
-- {{token_b}} - other token
-- {{start}} - date as of which the analysis should run

-- Note: not using a simpler recursive approach due to Dune's recursion depth limitation.
Expand Down
43 changes: 43 additions & 0 deletions cowamm/profitability/10k_growth/hodl_4086902.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
-- Computes the balances and current value of a counterfactual portfolio that invests 10k evenly into two tokens and holds them
-- Parameters
-- {{token_a}} - either token
-- {{token_b}} - other token
-- {{start}} - date as of which the analysis should run

-- limit the relevant date range
with date_series as (
select t.day
from
unnest(sequence(
date(timestamp '{{start}}'),
date(now())
)) t (day) --noqa: AL01
),

starting_balance as (
select
5000 / p1.price_close as token_a_start,
5000 / p2.price_close as token_b_start
from prices.usd_daily as p1
inner join prices.usd_daily as p2
on
p1.day = p2.day
and p1.day = date(timestamp '{{start}}')
and p1.contract_address = {{token_a}}
and p2.contract_address = {{token_b}}
)

select
ds.day,
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.usd_daily as p1
on
ds.day = p1.day
and p1.contract_address = {{token_a}}
inner join prices.usd_daily as p2
on
ds.day = p2.day
and p2.contract_address = {{token_b}}
order by 1 desc
Loading