Skip to content

Commit

Permalink
[CoW AMM] 10k growth for HODL strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
fleupold committed Sep 27, 2024
1 parent e3f10dd commit 171e06b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
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
42 changes: 42 additions & 0 deletions cowamm/profitability/10k_growth/hodl_4086902.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
-- 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, 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

0 comments on commit 171e06b

Please sign in to comment.