<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pandichef on Medium]]></title>
        <description><![CDATA[Stories by Pandichef on Medium]]></description>
        <link>https://medium.com/@pandichef?source=rss-f58d870c98dc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Vu4c7oAdFKQ26MdQ36HnMA.png</url>
            <title>Stories by Pandichef on Medium</title>
            <link>https://medium.com/@pandichef?source=rss-f58d870c98dc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 02:53:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pandichef/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How I Think About Portfolio Optimization]]></title>
            <link>https://pandichef.medium.com/how-i-think-about-portfolio-optimization-0a8230da0a17?source=rss-f58d870c98dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a8230da0a17</guid>
            <category><![CDATA[portfolio-optimization]]></category>
            <category><![CDATA[sharpe-ratio]]></category>
            <category><![CDATA[modern-portfolio-theory]]></category>
            <category><![CDATA[investment-management]]></category>
            <dc:creator><![CDATA[Pandichef]]></dc:creator>
            <pubDate>Sun, 18 Aug 2024 06:29:19 GMT</pubDate>
            <atom:updated>2024-08-18T06:29:19.876Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://citeseerx.ist.psu.edu/document?repid=rep1&amp;type=pdf&amp;doi=d3cad2002b7905581106bf372d034fe0cfc9ea96">DeMiguel, Garlappi, and Uppal (2009)</a> summarize the current state of academic thinking about applied portfolio optimization:</p><blockquote>In about the fourth century, Rabbi Issac bar Aha proposed the following rule for asset allocation: “One should always divide his wealth into three parts: a third in land, a third in merchandise, and a third ready to hand.” After a “brief” lull in the literature on asset allocation, there have been considerable advances starting with the pathbreaking work of Markowitz (1952), who derived the optimal rule for allocating wealth across risky assets in a static setting when investors care only about the mean and variance of a portfolio’s return. Because the implementation of these portfolios with moments estimated via their sample analogues is notorious for producing extreme weights that fluctuate substantially over time and perform poorly out of sample, considerable effort has been devoted to the issue of handling estimation error with the goal of improving the performance of the Markowitz model… of the 14 models evaluated, none is<br>consistently better than the naive 1/N benchmark…</blockquote><p>The naive 1/N — or Talmudic—asset allocation strategy is to weigh all stocks equally. For example, if you have a population of 10 stocks, you invest 10% of your portfolio in each stock.</p><p>Starting around 2009, academics started noting that a naive 1/N approach often performs better than the intricate approach introduced by Markowitz, which entails estimating means (μ) and standard deviations (σ) (of asset returns) from historical data. The key intuition is that estimates of μ, σ, and ρ introduce estimation bias large enough to invalidate the optimal weight computations. Moreover, small changes in μ/σ/ρ estimates can lead to large changes in optimal portfolio weights.</p><p>To be sure, more research is needed in this field, but in the meantime, real-world portfolio managers have to make decisions.</p><p>The rest of this post summarizes my approach using the <a href="https://medium.com/@pandichef/the-marginal-sharpe-ratio-a-new-heuristic-for-asset-selection-72cb5339f410">Marginal Sharpe Ratio</a>, which I introduced in 2021.</p><h4>An Example</h4><p>This article was inspired by this counterintuitive example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*DZfr3T8mnNsSPYBNn_isAg.png" /></figure><p>In this setup, we currently own the stock market (e.g., an index fund) and want to add two additional stocks. Stock 2 has a higher Sharpe Ratio and a higher Alpha, but the classical Markowitz optimization algorithm leads to the result that 81.5% of the portfolio should be in Stock 1 and just 9.8% should be in Stack 2. Why is this happening?</p><h4>Adding One Asset to the Market Portfolio</h4><p>Consider the case where we have the market portfolio (m) and decide to add just a single new asset (p). Then</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/143/1*zbCqPjKIUWSuYldi6ntioA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*F80B6H0ScQYxFc1NMIyANw.png" /></figure><p>We’re trying to find the optimal portfolio weight (w), assuming all other variables are constant. To simplify the problem, let</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/138/1*s-tZz02CqFQtNUFlOEj4-g.png" /></figure><p>Then</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*RYm-9jim05P_Q430NOvy7g.png" /></figure><p>We’re trying to find the optimal h for any value of μₚ. We can take the first derivative of SR with respect to h and set it to 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*A4VVey6WC8ucKas9s1dzEw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*41VaY5UFUN-owUbVOfDJqw.png" /></figure><p>After a few steps of algebra, we have</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*8A49DzS05iZpUmGXOFk0NQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*qULMv_NMlIZnD-cACPpjJQ.png" /></figure><p>This equation shows that a high value of σₚ is associated with a lower optimal portfolio weight. This is consistent with the earlier example. Moreover,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*31NXsonFYMEiI1qnaDpyFQ.png" /></figure><p>The interesting thing to note about this equation is that the volatility factors drop out and we have an expression that only depends on Sharpe Ratios and correlations.</p><h4>Asset Power</h4><p>The last equation suggests the following definition: An asset’s “Power” is the difference between the portfolio-optimal Sharpe Ratio and the Sharpe Ratio of m alone. In other words, it’s the potential contribution of an asset to the market portfolio.</p><p>The following table adds the asset power to the earlier example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*wYy_iCfnOgbDSSqrO5zbhg.png" /></figure><p>Even though the weights of stocks 1 and 2 are quite different, the Marginal Sharpe Ratios and Asset Powers are the same. The above equation for the optimal portfolio Sharpe Ratio confirms that there should be a tight relationship between the Marginal Sharpe Ratio and Asset Power.</p><p>Moreover, we shouldn’t be too surprised about the different weights. What matters is Asset Power, not the specific optimal weights.</p><h4>Taylor Series Approximation</h4><p>To see this more clearly, we can use a Taylor Series approximation of the portfolio Sharpe Ratio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*jZkMPTRiX_fsHQ57SQYH7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*5D9QR_4EcsnUrP3HHUZRUw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*5ylaHucYVXNwLh8G60miuw.png" /></figure><p>In other words, the portfolio Sharpe Ratio will increase if the asset’s Marginal Sharpe Ratio is positive. The factor σₚ/σₘ can be interpreted as implied leverage. In other words, a higher σₚ gives you more of that asset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N0gBh3dHUOYJ9JItkcK_lg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*gjELzg-79PUteavcETzW5Q.png" /></figure><p>As an approximation, we can now write</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*O6XOnue1QZmWiewPplO_LA.png" /></figure><p>To find the maximum value, we can write</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/230/1*BbE-pH8GeU3GxRzcdluF0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/149/1*gW1NLZVAE3TEaC5Mz-sqpQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*ZSQMVTlUQl07ZMwf-qu6Uw.png" /></figure><p>Finally, we can estimate the Asset Power as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*kqJ4WuwxdyCDlqQRMN0uSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*fKNEOIOgYiyS3djI63dtGA.png" /></figure><p>Here, we see again that Asset Power primarily depends on the Marginal Sharpe Ratio i.e., μ and σ drop out.</p><p>The above shows us two things about the Marginal Sharpe Ratio:</p><ol><li>For small h, the portfolio Sharpe Ratio increases linearly with the asset’s Marginal Sharpe Ratio.</li><li>The Marginal Sharpe Ratio — and not alpha or standard deviation — is closely associated with Asset Power.</li></ol><p>These observations confirm that the Marginal Sharpe Ratio is a potent metric of asset quality. This is especially true for small values of h.</p><h4>My Portfolio Optimization Heuristic</h4><p>While we can solve for optimal weights, the naive 1/N research suggests this isn’t the best approach. Rather, I propose the following:</p><ol><li>Compute Marginal Sharpe Ratios for N assets and put them in quartile buckets. Each quartile indicates the amount of <em>equity </em>we’d like to associate with each asset.</li><li>In f′(0), the factor σₚ/σₘ indicates the risk level of the asset. Moreover, <em>leverage </em>associated with the asset should be scaled up or down based on this ratio. For example, if two assets have the same Marginal Sharpe Ratio but one has double the σₚ, its weight should be half that of the low σₚ asset.</li></ol><p>This approach blends the best aspects of classic Markowitz and naive 1/N optimization algorithms.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a8230da0a17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Estimate a Sharpe Ratio With Aggregated Data]]></title>
            <link>https://pandichef.medium.com/how-to-estimate-a-sharpe-ratio-with-aggregated-data-c81adb994bba?source=rss-f58d870c98dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/c81adb994bba</guid>
            <category><![CDATA[investing]]></category>
            <category><![CDATA[sharpe-ratio]]></category>
            <category><![CDATA[maximum-likelihood]]></category>
            <category><![CDATA[missing-data]]></category>
            <category><![CDATA[portfolio-management]]></category>
            <dc:creator><![CDATA[Pandichef]]></dc:creator>
            <pubDate>Mon, 06 Jun 2022 04:05:32 GMT</pubDate>
            <atom:updated>2022-06-06T04:05:32.429Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometimes you want to estimate a Sharpe Ratio, but you don’t have a clean return time series i.e., the return data is available at heterogenous intervals of time. For example, perhaps you compute returns every day during month 1, then compute weekly returns during month 2, then revert to computing daily returns in month 3.</p><p>This typically happens when you a) don’t mark to market on a regular basis due to resource constraints (or laziness!) or b) you’re in a market where benchmark prices aren’t available at regular intervals.</p><p>Let’s imagine a case where we have m observations. For example, observation 1 might be the total return over 5 days, observation 2 might be the total return over 2 days, etc. Each observation i consists of nᵢ periods (e.g., 5 days).</p><p>Let’s assume returns are <a href="https://en.wikipedia.org/wiki/Normal_distribution">normally distributed</a> (and <a href="https://en.wikipedia.org/wiki/Independent_and_identically_distributed_random_variables">IID</a>). Then we can write</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/208/1*YnQ887Kb1GB0BEnDF3rCWg.png" /></figure><p>where x is the return in each period. Note that each x is not observable directly. We only know the sum or mean of the x’s in each observation. The mean of x is distributed as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*Fl_mjngWCyxckM1hKJpFOg.png" /></figure><p>Now we can use <a href="https://en.wikipedia.org/wiki/Maximum_likelihood_estimation">maximum likelihood estimation (MLE)</a> to estimate μ and σ.</p><p>From elementary Statistics, we know that the <a href="https://en.wikipedia.org/wiki/Probability_density_function">probability density function</a> of the normal distribution is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/1*biy8MvGi5A2t96ucsqQFZQ.png" /></figure><p>The <a href="https://en.wikipedia.org/wiki/Likelihood_function">likelihood function</a> for our case is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*npQipKugcyHXUuLyRwh18g.png" /></figure><p>and the log-likelihood function is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*bD_XPown_8SJGjTW-xkAmQ.png" /></figure><p>To find μ that maximizes the likelihood function, we differentiate the log-likelihood function with respect to μ and set it to 0 i.e.,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*PlhRjg-Y3SuuP3JSZuFeOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/191/1*YzG_05jPcnMJJovPPRHhxw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/105/1*k6lo6wn2DtWKAcVsyDPSHw.png" /></figure><p>To find σ² that maximizes the likelihood function, we differentiate the log-likelihood function with respect to σ² and set it to 0 i.e.,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/210/1*o2EBrXNV92uhU0TdHUdnHg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*VbMtgFjngu7EVqOFdEDbUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*jd9yKau7ePGcEN1I-kBmmA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*J-53rMQ-Y4ItnuAsjv6OaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/178/1*p2zslGtlDiNOpInyk1PuSw.png" /></figure><p>Finally, we can write</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/98/1*BwtraSCPaDPcPOGwXYMHdg.png" /></figure><h4>References</h4><ul><li><a href="https://stats.stackexchange.com/questions/177770/how-to-calculate-the-sample-variance-of-aggregated-data">How to calculate the sample variance of aggregated data</a></li><li><a href="https://www.statlect.com/fundamentals-of-statistics/normal-distribution-maximum-likelihood">Normal distribution - Maximum likelihood estimation</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c81adb994bba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Am I a Good Investor? How Long Should a Performance Track Record Be To Know For Sure]]></title>
            <link>https://pandichef.medium.com/am-i-a-good-investor-how-long-should-a-performance-track-record-be-to-know-for-sure-d54cdc4386a?source=rss-f58d870c98dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/d54cdc4386a</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[cryptocurrency-investment]]></category>
            <category><![CDATA[hedge-funds]]></category>
            <category><![CDATA[portfolio-management]]></category>
            <category><![CDATA[sharpe-ratio]]></category>
            <dc:creator><![CDATA[Pandichef]]></dc:creator>
            <pubDate>Sun, 05 Jun 2022 22:19:32 GMT</pubDate>
            <atom:updated>2022-07-03T23:01:38.013Z</atom:updated>
            <content:encoded><![CDATA[<p>The following post focuses on using <em>performance data</em> to evaluate the quality of a trader or investment manager. To be sure, qualitative assessments are also valuable but are not considered here explicitly.</p><h4>The Sharpe Ratio</h4><p>The most commonly used tool to judge traders (and hedge funds) is the Sharpe Ratio (SR), defined as the ratio of the excess expected returns to the standard deviation of returns i.e.,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/98/1*jc1xGuTzqcQdf1Vja5DqCw.png" /></figure><p>where the excess expected return is usually computed relative to the risk-free rate, Rf. Given a daily or weekly performance track record measured over N periods, the SR’s parameters can be estimated with the familiar estimators i.e.,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/96/1*r6ePSlJv_MHq6jgN1xiXGw.png" /></figure><p>and</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/159/1*Zsgjmyvxa9pdGn3UFruYmQ.png" /></figure><p>where Rᵢ is the return in each period i.</p><p>Note that mean and variance both grow linearly with N, <em>assuming each period is uncorrelated with prior periods</em>. Therefore, the SR grows with the square root of N. To see this, observe that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/252/1*bhjnnX2niNaMdu8esovPiA.png" /></figure><p>For purposes of comparison, therefore, the Sharpe Ratio is almost always annualized. For example, we can estimate the daily SR and then multiply it by √365 (or √252 if we only use stock market trading days).</p><h4>Estimation Error of the Sharpe Ratio</h4><p><a href="https://alo.mit.edu/wp-content/uploads/2017/06/The-Statistics-of-Sharpe-Ratios.pdf">Lo (2002)</a> shows how we can compute the standard errors for SR. A standard result from Statistics is that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/101/1*EfFe5KYKk40yMJOYWq0S4w.png" /></figure><p>and</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/121/1*_f2bMYCEeAkR_1Fd7cy-uw.png" /></figure><p>(Note that these equations hold asymptotically i.e., for “large” N.)</p><p>Now say that we have a new statistic (b) that is a function g() of other statistics a1, a2, etc. With a lot of fancy math, it can be shown that if</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/133/1*RZLxALSrwvesoDkX8Pkb2Q.png" /></figure><p>then</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/133/1*U83FUKShPvk0dPE-BM-SXA.png" /></figure><p>and</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/227/1*x1hdTw6IXHEki4P0EfJWaw.png" /></figure><p>(Note that this assumes that estimators for aⱼ and aₖ are uncorrelated.)</p><p>Hence, for the SR, we can write</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/98/1*fpfDe3i3TP7SM05iJWg2Zg.png" /></figure><p>and</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/297/1*FCF-oGlYCCHp_Rrd6jlZPw.png" /></figure><p>where</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*KPRVrK0pfSfM2-QcLseArg.png" /></figure><p>Therefore,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*x9onAuZrjLpkKth3MDycPw.png" /></figure><p>With this result, we can compute the 95% confidence interval for SR as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/168/1*IQMT8NkX1FqKncIKNGFAZg.png" /></figure><h4>Annualization of the Sharpe Ratio</h4><p>As mentioned earlier, Sharpe Ratios are typically expressed in annualized terms with</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/130/1*42hEfvqc7RhzKbt6Kfug3w.png" /></figure><p>If SR is measured with daily returns data, then q = 365 (or 252 if we only include trading days).</p><p>To estimate the annualized version of the Sharpe Ratio, we compute</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*DmJD2xO9hg9kkrcaf_skcA.png" /></figure><p>Where T is the number of years in the return time series. Note that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/169/1*BHOfTllHTq5IdyJY5CWO_g.png" /></figure><p>Typically, daily or even weekly returns are adequate to use this version of the formula.</p><p>Finally, we can write</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/247/1*he9KohYMBYBNRVCLWBHwXg.png" /></figure><p>This result is amazing because it shows that the precision of SR estimation depends only on the number of years.</p><p>So how many years is enough? If we want to know the SR within 1.0, then</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/120/1*FDlOXlM1Yf6maBwdJDZCwA.png" /></figure><p>T = 3.84 years! In other words, assuming a “good” Sharpe Ratio is over 1.0, an investor’s track record should be at least 3.84 years old.</p><h4>Sharpe Ratios Can Be Misleading</h4><p>There are a couple of problems with this procedure.</p><p>One problem is that it assumes that the “true” SR remains constant over time. Consider an investor with a 4-year track record. Say that the investor manages risk wisely in years 1 and 2 (i.e., low σ), but then gets overconfident and reckless in year 3 (i.e., high σ). After 2 years, we’d estimate a high SR, but the “true” SR for year 3 is lower.</p><p>In other words, investors’ performance quality <em>does not remain constant over time</em>. Hence, measuring Sharpe Ratio over 20 years isn’t necessarily more meaningful than measuring it over 5 years.</p><p>There is a trade-off here: more data reduces the statistical error, but it increases overall estimation error since recent data is probably more informative than older data. One solution to this problem is simply not to use more than ~5 years of data.</p><p>The second problem is that multiplication by √N only works if returns are not correlated over time. This is especially relevant at the aggregate market level. For example, the stock market seems to have periods lasting 5–15 years where short-term returns are correlated.</p><p>Consider a 3-decade period in the stock market; each decade has SRs of -1.0, -1.0, 2.0, respectively. Say an investor does nothing but invest in the stock market during the last decade. Based on the SR estimation procedure, we’d conclude that this investor’s SR is 2.0. However, this would be misleading because the true SR over 3 decades is actually net zero.</p><p>We can largely address this latter problem with the <em>Marginal Sharpe Ratio</em> (see below). For more fun facts about the problem of correlated returns, see <a href="http://pwork.com/browse/bench">Lo (2002)</a>.</p><h4>Estimation Error of the Marginal Sharpe Ratio (MSR)</h4><p>I introduced the MSR in a <a href="https://pandichef.medium.com/the-marginal-sharpe-ratio-a-new-heuristic-for-asset-selection-72cb5339f410">prior post</a>. It solves the market correlation problem because it directly benchmarks the SR against market returns. An ancillary benefit, as shown below, is that it almost always has a standard error less than that of the ordinary SR.</p><p>As discussed in the earlier post,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/80/1*9wxEFtrhW6Qn7f6yJEMpLQ.png" /></figure><p>To derive the standard error, we can use the same procedure as above. First note that α is the constant term of a simple regression, where y is the return of <strong>p</strong> and x is the return of <strong>m</strong>. From elementary Statistics, we know that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/1*W4xY7ZVI5ihrOR-yi34wAw.png" /></figure><p>where σₑ is the standard error of the regression. We can rewrite this as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*6O4iyJvt5Pswvl6PU9uXvQ.png" /></figure><p>or</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/1*RLozPf1jA2gWP8dh30muIA.png" /></figure><p>To simplify further, we can write</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*ppvZrKXeyIue6PQyJQxAyA.png" /></figure><p>or</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/131/1*CE_Q8P2cN78B4kE2Zj0pKA.png" /></figure><p>Therefore</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*tzZw5pY2qrD5EGgNXKmPrg.png" /></figure><p>Now, we can apply the same method as above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/108/1*nRPv7dTdLghb4ef3tF4lAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*Jn8nkK005fLt8TWw6alrow.png" /></figure><p>Finally, we can annualize this formula.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*z9N-MJqjje8u4SLy8KzcUw.png" /></figure><p>Moreover</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*rRzsnxeNcH2loeRobcrn5g.png" /></figure><p>In other words, the MSR has an ancillary benefit over the ordinary SR: for large q, it always has standard errors less than those of the SR.</p><h4>α vs MSR</h4><p>To be sure, one might ask “why not just compute standard errors on alpha directly?” Of course, we could do so. However, the result is less elegant.</p><p>It can be shown that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*DycNxHwiYnmwadyLJiwW5w.png" /></figure><p>Note that, unlike before, σ² doesn’t cancel out.</p><h4>Conclusion</h4><p>Finally, we can offer the following heuristic to measure performance quality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*kbw5z6qVbhyT3Ydq5aBStw.png" /></figure><p>If this condition is true, then an investor is highly likely to have a positive MSR and hence a positive alpha. That said, for the reasons discussed above, data more than ~5 years old should be viewed with suspicion.</p><h4>References</h4><p><a href="https://alo.mit.edu/wp-content/uploads/2017/06/The-Statistics-of-Sharpe-Ratios.pdf">Lo, A. W. (2002). The statistics of Sharpe ratios. Financial Analysts Journal, 58(4):36–52.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d54cdc4386a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Marginal Sharpe Ratio: A New Heuristic for Asset Selection]]></title>
            <link>https://pandichef.medium.com/the-marginal-sharpe-ratio-a-new-heuristic-for-asset-selection-72cb5339f410?source=rss-f58d870c98dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/72cb5339f410</guid>
            <category><![CDATA[sharpe-ratio]]></category>
            <category><![CDATA[alpha]]></category>
            <category><![CDATA[beta]]></category>
            <category><![CDATA[investment-management]]></category>
            <category><![CDATA[asset-allocation]]></category>
            <dc:creator><![CDATA[Pandichef]]></dc:creator>
            <pubDate>Sun, 05 Jun 2022 04:18:51 GMT</pubDate>
            <atom:updated>2022-06-05T04:24:43.370Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://en.wikipedia.org/wiki/Portfolio_optimization">Portfolio optimization</a> strategies typically involve an unintuitive procedure that combines individual assets’ expected returns, individual assets’ risks (i.e., standard deviations of expected returns), and the correlations amongst all assets to determine an optimal portfolio.</p><p>The following post explores a simple heuristic that greatly simplifies the standard portfolio optimization algorithm: the Marginal Sharpe Ratio.</p><p>Consider an asset <strong>p</strong> being added to an existing portfolio <strong>m</strong>. Moreover, say that an investor’s goal is to choose a quantity of <strong>p</strong> and <strong>m</strong> that maximize the portfolio’s Sharpe Ratio.</p><p>Let μₚ be the expected return of <strong>p</strong> and μₘ be the expected return of <strong>m</strong>. Moreover, let σₚ and σₘ be the expected standard deviation of the returns of <strong>p</strong> and <strong>m</strong>, respectively.</p><p>The standard result from Portfolio Theory is that an asset has a place in our portfolio if its “alpha” is greater than 0 i.e.,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*e-wb6_xrkfXSb4ZSQeUTnA.png" /></figure><p>or</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/101/1*RpSixHloLq3Q5l01Ra3_gw.png" /></figure><p>Here, βₚ,ₘ is the <a href="https://en.wikipedia.org/wiki/Beta_(finance)">standard definition</a> used in Portfolio Theory.</p><p>Note that this heuristic doesn’t give us the exact optimal quantity of <strong>p</strong>. It just tells us that the optimal quantity is greater than 0.</p><p>It can be shown that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/88/1*_QGy4IAserLOniOXMREuDA.png" /></figure><p>Note that beta is not invertible i.e.,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/93/1*VypclW5diO0RdNsgTFx0NA.png" /></figure><p>We can also consider the case where we currently own <strong>p</strong> and want to add some amount of <strong>m</strong> to our portfolio. In this case, Portfolio Theory suggests that we want some amount <strong>p</strong> if</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*r7xhrI2Y5dJ6KzCYAYZ9Og.png" /></figure><p>or</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/101/1*QMMHH3DNPm4MwuIqdNVNew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/78/1*JvM4UcsemsNXpOwIqh8N4g.png" /></figure><p>(Of course, to do this division, we’re assuming that beta (and hence rho) is greater than 0.)</p><p>Now we can say the following about the optimal weight (w) of <strong>p</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*mapPlTQDhq0SruV1olUulw.png" /></figure><p>While this heuristic works, it’s not very intuitive because the betas aren’t invertible. Instead, note that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*e-wb6_xrkfXSb4ZSQeUTnA.png" /></figure><p>can be rewritten as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*O-neSGcVvHU08YK4dAv9bQ.png" /></figure><p>Note that μ/σ is the Ordinary Sharpe Ratio (SR). Now we can define the <strong>Marginal Sharpe Ratio</strong> (ξ) as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*WpTCx3dv1qg59kodLu0hDg.png" /></figure><p>Then</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*O3b8hJ7TlPN8f8-t6PzvKA.png" /></figure><p>and</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*OX4m5L4m0OWdgoGrw7379Q.png" /></figure><p>Now we can rewrite our heuristic as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*2mKvHdz7oWCVlwFIklJ5xQ.png" /></figure><p>which is arguably much easier to interpret than the earlier version (primarily since ρ is invertible while β is not). This result suggests that the Marginal Sharpe Ratio is a convenient - and <em>semantically consistent</em> - alternative to alpha. It also provides better intuition about the relationship between the Orindary Sharpe Ratio and an asset’s value in the context of a portfolio.</p><p><em>Example: </em>Say two hedge funds both report a 1.00 Sharpe Ratio at a time period when the (estimated) Sharpe Ratio of the S&amp;P 500 was 1.50. Moreover, say fund 1 has a 0.25 correlation with the S&amp;P 500, whereas fund 2 has a 0.75 correlation. In this case, fund 1 has a Marginal Sharpe Ratio of 0.625, whereas fund 2 has a Marginal Sharpe Ratio of just -0.125. In other words, fund 1 would be deemed investment-worthy, while fund 2 would not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72cb5339f410" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Communal Equity: a New Model for Crypto Startup Financing]]></title>
            <link>https://pandichef.medium.com/communal-equity-a-new-model-for-crypto-startup-financing-814ff350699e?source=rss-f58d870c98dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/814ff350699e</guid>
            <category><![CDATA[social-justice]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Pandichef]]></dc:creator>
            <pubDate>Sun, 27 Feb 2022 01:47:51 GMT</pubDate>
            <atom:updated>2022-02-27T02:04:07.066Z</atom:updated>
            <content:encoded><![CDATA[<p>Last September, the Wall Journal Journal <a href="https://www.wsj.com/articles/regulators-investigate-crypto-exchange-developer-uniswap-labs-11630666800">reported</a> that the SEC started investigating Uniswap for violation of securities regulations. Since then, Gary Gensler at the SEC has repeatedly called for more regulation of cryptocurrencies, even suggestively stating that an outright ban is “up to Congress”.</p><p>Meanwhile, in the crypto world, the focus has been on circumventing securities regulation by framing tokens to avoid the “security” designation. However, few have considered whether this new technology warrants an entirely new approach to securities regulation.</p><p>Modern securities laws begin in the 1930s on the heels of the 1929 stock market crash. Prior to the Securities Act of 1933 in the U.S., there were few laws that enforced the nature and scope of disclosures. As a result, during the bull market of the 1920s, fraud was rampant and difficult to enforce.</p><p>Since only a few institutions at the time controlled the issuance and trading of securities, the most obvious legislative response was to centralize the nature of security disclosures. Today, public securities offerings not only require accurate and complete disclosures, but they must go through a <a href="https://www.investopedia.com/terms/s/sec-form-s-1.asp">costly registration process with the SEC</a>.</p><p>But equity-like tokens reflect an entirely new reality for two reasons:</p><ol><li>Issuance and distribution of tokens are almost free. This opens the door to new compensation models that are more equitable to contributors and limit concentrations of power and money.</li><li>In theory, all information about a protocol is disclosed on the blockchain. Hence, there is no need for centralized enforcement of disclosures (i.e., the S-1 registration).</li></ol><h4>Zero Economies of Scale</h4><p>Stock sales prior to 1933 were not that different than they are today: the founders formed a company, developed a track record generating revenue, and finally hired a dealer to list and distribute their stock.</p><p>Note that listing and distribution, both then and now, have high economies of scale. It doesn’t make sense to sell $10mm of stock if it costs $5mm to list and distribute the stock. Hence, when the SEC opted to consolidate the enforcement of disclosures (via the S-1 registration), it didn’t materially change the economics of the transaction. Going from high costs to <em>higher </em>costs didn’t fundamentally alter the microeconomics of IPOs.</p><p>However, when the costs are close to $0, the dynamics and opportunities are entirely different. For example, VC financing and employee equity grants are distributed largely on the basis of somewhat arbitrary norms and conventions. For example, convention dictates that founders get x% of equity, employees y%, and seed investors z%, etc. These are all ad hoc representations of value creation.</p><p>A better model would be for all employees to have an <em>equal </em>share of value creation, which could be called <em>communal equity</em>. Assume you need 5 engineers to bootstrap a software project. Initially, everyone gets 20% equity. As you bring on more employees, you keep going with this model; in the future, the distribution of new equity would be based on the <em>gains</em>. So say the market capitalization of a governance token increases by $25mm over a quarter and there are now 10 employees. Then new tokens could be minted such that all 10 employees get $2.5mm market value of equity.</p><p>This model also eliminates the need for contentious and time-consuming salary negotiations. Everyone that joins the project has the same terms. A potential employee only needs to decide if the product is worth her attention and if she respects the other contributors.</p><p>Additionally, it totally obviates the need for VC financing and the status-centric culture that this entails. Contributors “invest” their time in lieu of a salary. If and when a project’s contributor needs cash, she can just sell some equity on a decentralized exchange. There is no longer a need for a neo-aristocracy that takes massive fees to act as a gatekeeper to bridge the gap between current cash flow needs and an IPO in the distant future.</p><blockquote>No Title of Nobility shall be granted by the United States: And no Person holding any Office of Profit or Trust under them, shall, without the Consent of the Congress, accept of any present, Emolument, Office, or Title, of any kind whatever, from any King, Prince, or foreign State.<br>- The U.S. Constitution, Article I/Section 9</blockquote><p>Essentially, this is a model where employees are self-financing with their own contribution of time. The employee now has equal status as a VC, which has two broader implications. First, it means that builders decide what is important to focus on. Since builders typically understand the technology better than ivory tower investors, this means a better allocation of resources. Second, it means that there will be <em>more</em> builders/operators and fewer VCs since VCs have a more limited role to play in this kind of ecosystem. This is a great thing for society and capitalism… and it simply cannot exist within the current securities framework.</p><h4>Hyper-Disclosure</h4><p>The securities regulations assume that people who sell equity are oftentimes crooks who deliberately hide information to make money.</p><p>However, the very nature of open-source and decentralized systems implies that all information is public and control structures are communal property. So why is SEC registration even required?!</p><p>To be sure, there is a myriad of ways to build centralization into smart contract protocols. However, it makes sense that the regulatory framework is amended to exempt protocols that meet certain criteria e.g. if the contracts are not upgradable and there are no keeper wallets.</p><p>In simple terms, smart contract protocols exhibit <em>hyper-disclosure </em>i.e. they already disclose far more information to investors than what’s typically available in an S-1 registration document. In the ethos of open-source, decentralized protocols, everything about a project is disclosed, not only things that an expensive lawyer might arbitrarily deem “material”.</p><p>In the context of hyper-disclosure, centralized registration of securities is simply a vestigial artifact of the 20th century.</p><h4>Suggestions for Future Development</h4><ol><li>Crypto projects should gain the moral high ground by using the communal equity model to highlight that blockchain technology demands an entirely new regulatory framework for securities offerings.</li><li>The SEC should consider exempting token sales from registration if they meet certain well-defined disclosure criteria.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=814ff350699e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Brief History of Uniswap and Its Math]]></title>
            <link>https://pandichef.medium.com/a-brief-history-of-uniswap-and-its-math-90443241c9b7?source=rss-f58d870c98dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/90443241c9b7</guid>
            <category><![CDATA[smart-contract-blockchain]]></category>
            <category><![CDATA[uniswap]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[amm]]></category>
            <dc:creator><![CDATA[Pandichef]]></dc:creator>
            <pubDate>Sun, 27 Feb 2022 01:45:12 GMT</pubDate>
            <atom:updated>2025-01-02T22:50:26.814Z</atom:updated>
            <content:encoded><![CDATA[<p>An automated market maker (AMM) is an algorithmic method for price discovery in a given market. This contrasts with the order book model used by traditional market makers.</p><p>Central to the story of AMMs on public blockchains is Uniswap, which is the most successful AMM by TVL/volume and has inspired many other AMM protocols.</p><p>The rest of this post summarizes the history of Uniswap and the math that makes it possible.</p><h4><strong>Timeline of Events</strong></h4><p><em>October 2016</em>: Vitalik Buterin publishes a <a href="https://www.reddit.com/r/ethereum/comments/55m04x/lets_run_onchain_decentralized_exchanges_the_way/">Reddit post</a> introducing the general concept of an “on-chain automated market maker (AMM)”.</p><p><em>May 2017</em>: Bancor publishes a <a href="https://cryptorating.eu/whitepapers/Bancor/bancor_protocol_whitepaper_en.pdf">whitepaper</a> that describes the first AMM. Bancor’s approach was subjected to a <a href="https://hackingdistributed.com/2017/06/19/bancor-is-flawed/">lot of criticism</a> that likely stifled the project’s growth.</p><p><em>June 2017:</em> Vitalik publishes a <a href="https://vitalik.ca/general/2017/06/22/marketmakers.html">blog post</a> that introduces the constant product AMM. This would become the basis for Uniswap v1. (Vitalik credits <a href="https://twitter.com/koeppelmann?lang=en">Martin Köppelmann from Gnosis</a> as the originator of this specific AMM formulation, but Hayden says it was actually <a href="https://blog.gnosis.pm/building-a-decentralized-exchange-in-ethereum-eea4e7452d6e">Alan Lu at Gnosis</a> that conceived of the idea.)</p><p><em>October 2017:</em> Hayden Adams builds a proof-of-concept (“POC”) of Uniswap. The POC was never launched on the Ethereum Mainnet and consists of a single liquidity pool i.e., it allowed swapping of ETH for “UNI” (a generic testnet ERC20 token). Moreover, the liquidity pool only supports a single liquidity provider i.e., 2 or more wallets can’t contribute to the liquidity pool.</p><p><em>November 2017:</em> <a href="https://www.linkedin.com/in/karlfloersch/">Karl Floersch</a> discusses AMMs at <a href="https://archive.devcon.org/archive/playlists/devcon-3/">Devcon 3</a> and <a href="https://youtu.be/-alrVUv6E24?t=862">briefly presents Hayden’s proof-of-concept website</a>. <a href="https://twitter.com/PascalVanHecke">Pascal Van Hecke</a>, who attended Karl’s presentation, becomes Hayden’s advisor.</p><p><em>March 2018: </em>Hayden Adams and a few friends (“Uniswap”) build the first <a href="https://haydenadams.github.io/uniswap-prealpha/">fully-featured demo of Uniswap v1</a>. v1 features a factory contract that enables third parties to create an arbitrary number of liquidity pools. Moreover, each liquidity pool can be funded by an arbitrary number of wallets.</p><p><em>April 2018:</em> Karl Floersch introduces Hayden Adams to Vitalik at <a href="https://deconomy.com/deconomy-2018-recap/">Deconomy 2018</a> in Seoul, Korea. Vitalik encourages Hayden to apply for an <a href="https://ethereum.org/en/community/grants/">Ethereum Foundation grant</a>.</p><p><em>July 2018:</em> Uniswap receives an Ethereum Foundation grant of $100,000.</p><p><em>October 2018: </em>Hayden Adams finalizes the <a href="https://hackmd.io/C-DvwDSfSxuh-Gd4WKE_ig">Uniswap v1 whitepaper</a> and receives <a href="https://github.com/runtimeverification/verified-smart-contracts/tree/uniswap/uniswap/results">audit results</a> from <a href="https://runtimeverification.com/">Runtime Verification</a>. (Runtime Verification also produces a <a href="https://github.com/runtimeverification/verified-smart-contracts/blob/uniswap/uniswap/x-y-k.pdf">formal specification</a> of the protocol.) Meanwhile, <a href="https://www.linkedin.com/in/chikeichan/">Jacky Chan</a> at <a href="https://www.kyokan.io/">Kyokan</a> builds a completely new version of the Uniswap v1 UI.</p><p><em>November 2018:</em> Hayden Adams <a href="https://twitter.com/haydenzadams/status/1058376395108376577">launches Uniswap v1</a> at <a href="https://archive.devcon.org/archive/playlists/devcon-4/">Devcon 4</a>.</p><p><em>April 2019:</em> Uniswap raises a <a href="https://twitter.com/haydenzadams/status/1120759500137537539?lang=en">seed round</a> led by Paradigm.</p><p><em>March 2020:</em> <a href="https://uniswap.org/blog/uniswap-v2">Uniswap v2 is launched</a>. Uniswap v2 makes marginal improvements to v1. For example, it supports direct ERC20-to-ERC20 transfers; v1 required ETH as an intermediary for all such trades.</p><p><em>May 2021:</em> <a href="https://uniswap.org/blog/launch-uniswap-v3">Uniswap v3 is launched</a>, a new design that features concentrated liquidity.</p><h4>The Constant Product AMM</h4><p><em>Note: the following assumes a basic knowledge of differential calculus.</em></p><p>Uniswap v1 and v2 implement an ordinary constant product AMM. This is an algorithm for trading two fungible tokens, α and β. Let x be the liquidity pool reserves of α and y and the reserves of β. The market has reserves x &gt; 0 and y &gt; 0, constant product xy = L².</p><p>Consider the case where one desires to sell Δx units of α in exchange for Δy units of β. When the fee is 0,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/179/1*frExZ-QHUDNTyKoVEFHiOw.png" /></figure><p>The name <em>constant product market</em> comes from the fact that any trade Δx to Δy must change the reserves in such a way that the product of x and y remains equal to the constant L².</p><p>After each transaction, the reserves are updated in the following way: y ↦ y − Δy, x ↦ x + Δx, and L² ↦ L².</p><p>From an implementation perspective, there are two cases to consider:</p><ol><li>A trader wants to sell Δx units of α and the smart contract needs to compute Δy</li><li>A trader wants to buy Δy units of β and the smart contract needs to compute Δx</li></ol><p>For the first case, we have</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*M1uJVpNatWxipTYG8KSwqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*RvDnOgUwGQEDy4uwXTGC-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*PVq0q2fhWdejxMsziF3rNg.png" /></figure><p>For the second case, we have</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*uy1Q-TohbbRcXb9t0nLyYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*uy1Q-TohbbRcXb9t0nLyYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*ilyVdt8yB7rp4UUayubC7w.png" /></figure><p>These formulae are implemented <a href="https://github.com/Uniswap/v1-contracts/blob/c10c08d81d6114f694baa8bd32f555a40f6264da/contracts/uniswap_exchange.vy#L99">here</a> and <a href="https://github.com/Uniswap/v1-contracts/blob/c10c08d81d6114f694baa8bd32f555a40f6264da/contracts/uniswap_exchange.vy#L113">here</a> in Uniswap v1 and <a href="https://github.com/Uniswap/v2-periphery/blob/2efa12e0f2d808d9b49737927f0e416fafa5af68/contracts/libraries/UniswapV2Library.sol#L42">here</a> and <a href="https://github.com/Uniswap/v2-periphery/blob/2efa12e0f2d808d9b49737927f0e416fafa5af68/contracts/libraries/UniswapV2Library.sol#L52">here</a> in Uniswap v2. (Note that fees are ignored in this article.)</p><p>The price that a user realizes is simply</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/143/1*9_B4wubkf1oTVkGMVjevsA.png" /></figure><p>Moreover, we can define a <em>marginal price</em>, or the <em>current price</em> (P), as the swap price realized for small changes in x or y i.e.,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/99/1*Jq0BdOiw1Qtmpg6aSF3bYw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/130/1*nsoZ4bTrPNUlQ0GvQ8tIOw.png" /></figure><p>This formula suggests another approach to do the swap math. Note that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/134/1*fqsmvqxwAV_af2s1sjAPig.png" /></figure><p>and</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/134/1*qbBsdw2fVjLrbP3_2ogM1g.png" /></figure><p>Or</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/93/1*_JHQBTA10W0jqlgireo2RQ.png" /></figure><p>which implies that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*vVCZ5j_1ygBM8yD9lkPM-w.png" /></figure><p>These formulae represent an alternative way of computing Δx given Δy (and vice versa). In fact, this is the approach taken by Uniswap v3 to “avoid having to take any square roots when computing swaps”. (The whitepaper doesn’t go into the details motivating this approach, but all math in v3 is done on the square root of the price; the front-end application converts from √P to P and vice versa.)</p><h4><strong>Concentrated Liquidity</strong></h4><p>Uniswap v3’s primary innovation is <em>concentrated liquidity</em>. As stated in the whitepaper, Uniswap v1 and v2 “were designed to provide liquidity across the entire price range (0, ∞). This… means that much of the assets held in a pool are never touched. Having considered this, it seems reasonable to allow LPs to concentrate their liquidity to smaller price ranges than (0, ∞).”</p><p>In other words, Uniswap v3 allows <em>all</em> of a user’s liquidity to be utilized within a specified price range i.e., all reserves are depleted at the boundaries of that price range.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*UtLSF5Ic4Ydw7ZoCA1H8-A.png" /></figure><p>This involves a transformation of the constant product AMM formula into 3 ranges as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*hX_LMXCTha6ukIKVDv8AkQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*JpbVXLhkFqZiN8J7iI6CFw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*cwVfM79PdXKZNk8EEl-dMQ.png" /></figure><p>To understand why this formula makes sense, we can consider the boundaries i.e., we require P = pₐ when y = 0 and P = pᵦ when x = 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*Ce2mooUvgc6V5828W8NhLQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/157/1*gH4sApBOnBPD38DWxEtKGA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*HjbNLNT7togDTWRAsDin1g.png" /></figure><p>So when x = 0,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/187/1*FQAGSZEwpQp_JbY3eAUjMg.png" /></figure><p>and when y = 0,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/203/1*Jw_JjOIoGVsOSac7j6eRew.png" /></figure><p>By substitution, we can also see that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/146/1*d1Q1VCbJss_H-WT8ZVEikA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/139/1*nJSxLZgot0US6h1fGWKXNw.png" /></figure><p>In other words, x is a linear function of 1/√P and y is a linear function of √P.</p><p>So just as Uniswap v1 and v2,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*vVCZ5j_1ygBM8yD9lkPM-w.png" /></figure><p>As stated in the Uniswap v3 whitepaper, “when swapping one token for the other, the pool contract can first compute the new √P… and then can compute the amount of (x) or (y) to send out…”. (As stated earlier, in Uniswap v3, all calculations use √P as an intermediary variable; the front-end has the responsibility of squaring √P before it’s displayed to a user.)</p><p>That’s all there is to it! What makes v3’s <em>code </em>complicated (compared to v1 and v2) is the nuanced position accounting. There is not just a single liquidity pool anymore for each pair. Rather, there are a potentially unlimited number of <em>positions</em> that each have their own values of pₐ and pᵦ.</p><h4><strong>References</strong></h4><p><a href="https://uniswap.org/blog/uniswap-history">Hayden Adams’ Summary of the Early History of Uniswap</a></p><p><a href="https://ethresear.ch/t/improving-front-running-resistance-of-x-y-k-market-makers/1281">An Early Post from Vitalik on Improving Front Running Resistance</a></p><p><a href="https://uniswap.org/whitepaper.pdf">Uniswap v2 Whitepaper</a></p><p><a href="https://uniswap.org/whitepaper-v3.pdf">Uniswap v3 Whitepaper</a></p><p><a href="https://web.stanford.edu/~guillean/papers/uniswap_analysis.pdf">An Analysis of Uniswap Markets</a></p><p><a href="https://github.com/atiselsts/uniswap-v3-liquidity-math">Liquidity Math in Uniswap v3</a></p><p><a href="https://atiselsts.medium.com/uniswap-v3-liquidity-formula-explained-de8bd42afc3c">Uniswap v3 Liquidity Formula Explained</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90443241c9b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Centralized Finance Rips Off Ordinary Americans]]></title>
            <link>https://pandichef.medium.com/how-centralized-finance-rips-off-ordinary-americans-2602368aa852?source=rss-f58d870c98dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/2602368aa852</guid>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[securitization]]></category>
            <category><![CDATA[mortgage-lending]]></category>
            <category><![CDATA[regulation]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Pandichef]]></dc:creator>
            <pubDate>Tue, 29 Jun 2021 04:28:06 GMT</pubDate>
            <atom:updated>2021-06-29T20:55:58.152Z</atom:updated>
            <content:encoded><![CDATA[<p>This post is a tale of two stories. The first is a story about how antiquated technology and regulations give a small cabal of Wall Street hedge fund managers enormous wealth and power. The second is a story about the invisible taxes buried deep in the mortgage creation process that continue to centralize power and money in D.C. And both come at the expense of ordinary American borrowers.</p><h3>Story #1: The Ellington Money Machine</h3><p>Recently, <a href="https://www.ellington.com/leadership/michael-vranos">Mike Vranos</a> of <a href="https://www.ellington.com/">Ellington Management Group</a> appeared on the podcast <a href="https://podcasts.apple.com/us/podcast/michael-vranos-lessons-from-the-king-of-structured-credit/id1210383304?i=1000527160475">Real Vision: Finance, Business &amp; The Global Economy</a>. In the 66th minute of the podcast, there is a fascinating dialog that highlights how wealth creation happens on Wall Street. The interviewer asks, “this kind of basket of private sector loans; what kind of yields are you seeing in that market or even spread and how did it change over the last 12 months?” Vranos replies:</p><blockquote>…on the consumer side, it’s still LIBOR+600bp or something like that… but I can’t stress to you how dirty your hands get… very expensive, these are very small loans, there is a lot that goes into securitizing and leveraging prior to securitization. But that’s the answer. That number has sort of ratcheted down over time, but it’s making that money the hard way… it’s not accessible to a retail investor or even to a lot of institutional investors. The non-QM mortgage side, let’s say you have a 3-year spread duration, you’re still in the LIBOR+300bp at least, gross spread, pre-securitization. And then you saw the results of the securitization, where you’re basically securitizing at LIBOR+100bp where you’re taking out almost all your risk. That’s almost sort of a pseudo arbitrage than it is a cash-and-carry trade… but you’re buying them in loan form. You not buying them in CUSIP form.</blockquote><p>There is a lot of jargon here. But Mike’s statement can be summarized as follows: “We at Ellington borrow money at ~1% per year and lend to consumers at 6% per year. So we make 5% net per year. But then we use securitization (the same stuff that blew up the economy in 2008 ) to monetize that 5% spread at a 3x multiple. So when American consumers borrow money at 6%, we’ve figured out how to extract a 15% profit margin. And we deserve this money because this opportunity isn’t available to ordinary investors”.</p><p>So how did we get here? The answer is basically a regulatory regime that creates opportunities for people like Mike. Here is a subset of all the complicated regulations involved in the process that Mike describes:</p><ol><li>Mortgage lending licensing requirements that are ever-so-slightly different from state to state and extremely costly to set up</li><li>Mortgage servicing licensing requirements that are ever-so-slightly different from state to state and extremely costly to set up</li><li>Mortgage lending compliance requirements that create significant litigation liability for originators and require massive legal resources to avoid</li><li>Consumer privacy laws that only allow guys like Mike to see the loan data needed to bid on loans</li><li>Securities laws that make the legal fees for securitization so expensive that only large institutions can participate in such markets</li><li>Securitization “risk retention rules” that force issuers to hold 5% of securities that they issue and hence limit participation to investors with a lot of money</li><li>Securities regulations that constrain investor participation in such assets to “sophisticated” investors like Mike and his team</li></ol><p>And why does Mike actively talk about such things so openly? Because he’s marketing to wealthy hedge fund clients. He’s saying: “there is no way you could buy this stuff on your own, so you should pay me to manage it for you”. In essence, these regulations created a system where ordinary Americans borrow money at 6% and all but 1% of that goes to guys like Mike and his wealthy clients.</p><h3>Story #2: The FHFA Power Machine</h3><p>Last week, the <a href="https://www.latimes.com/business/story/2021-06-23/fannie-freddie-shares-plunge-after-supreme-court-deals-blow-to-investors">Supreme Court ruled on the conservatorship of Fannie Mae and Freddie Mac</a>. In short, the Court ruled that:</p><p>a) The FHFA director can be hired and fired by the president at will</p><p>b) The federal government has the legal authority to confiscate Fannie Mae’s and Freddie Mac’s profits</p><p>In essence, the Court ruled to strengthen the centralization of home financing in the federal government. But it’s actually a much bigger story.</p><p>Fannie Mae is a semi-private organization that has its origins in the Great Depression era. Its <a href="https://www.fanniemae.com/about-us/who-we-are">mission</a> is “… to provide liquidity and promote stability and affordability in the U.S. housing finance industry.” Beyond Fannie Mae, there is a vast complex of D.C.-based institutions whose stated purpose is to help promote homeownership. And at the peak of this hierarchy is the FHFA, an institution that essentially dictates policy to Fannie Mae in the most opaque and centralized way.</p><p>The small group of people that run the FHFA set U.S. housing policy through Fannie Mae and other related agencies. Moreover, Fannie Mae buys ordinary mortgage loans and issues “government-sponsored mortgage-backed securities (MBS)”. This market, also known as “agency MBS”, finances the vast majority of homes in the United States.</p><p>But that’s not the end of the story. Since 2009, the Fed has been printing trillions of dollars every year to buy the aforementioned agency MBS, which of course immediately gives Fannie Mae uncompetitive pricing power. Finally, the Treasury does a “profit sweep” to grab Fannie Mae’s cash flow, which puts the final touch on this crazy system of centralized power and money.</p><p>In terms of economics, Fannie Mae and Freddie Mac charge a ~4% profit margin on the balance of every loan. At ~$4 trillion in U.S. mortgage volume in 2020, that equates to ~$150 billion in a single year.</p><p>Now, you would think that mortgage company executives would be protesting against the nationalization of an entire industry. However, the Fed implicitly or explicitly lets mortgage company executives also keep roughly 50% of the gross profits so they don’t actively lobby against this system.</p><p>Most mortgage companies are private, so until recently, mortgage company earnings were opaque. However, Rocket Companies Inc., one of the countries largest lenders, <a href="https://www.quickenloans.com/press-room/2020/08/05/rocket-companies-announces-pricing-of-initial-public-offering/">went public last year</a>. In the latest 10-K, we learned that they made $9.4 billion in profits on $7.8 billion in equity in 2020. This is many multiples higher than what you’d expect in a mature and stable market. In the document, they don’t even attempt to hide the math:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nnjjDbs-MyJrG5J3lfYubQ.png" /></figure><p>That’s right. Rocket made a 4.46% average profit margin for the $320 billion worth of loans that they originated in 2020! So instead of efficient capital markets giving consumers a rate of 2%, FHFA sandwiches mortgage companies into the middle of this process and they offer borrowers a 3.25% interest rate instead. If you do the math, the mortgage industry collectively made ~$150 billion from inflated mortgage rates in 2020.</p><p>In other words, when a $250,000 mortgage loan is created, the federal government makes $10,000 (via the Fannie/Freddie profit sweep) and mortgage company owners make another $10,000. Combined, this equates to ~$300 billion dollars per year in costs to American consumers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2602368aa852" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bitcoin Wasn’t Designed to Be “Cheaper or Faster”]]></title>
            <link>https://pandichef.medium.com/bitcoin-wasnt-designed-to-be-cheaper-or-faster-d8565fdb7c37?source=rss-f58d870c98dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8565fdb7c37</guid>
            <category><![CDATA[democracy]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[censorship]]></category>
            <category><![CDATA[decentralization]]></category>
            <dc:creator><![CDATA[Pandichef]]></dc:creator>
            <pubDate>Tue, 25 May 2021 22:18:03 GMT</pubDate>
            <atom:updated>2021-05-26T17:10:30.243Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://law.duke.edu/fac/reiners/">Lee Reiners of Duke Law</a> recently wrote <a href="https://www.wsj.com/articles/ban-cryptocurrency-to-fight-ransomware-11621962831">an op-ed for the Wall Street Journal</a> where he states, “I have yet to identify a single task or process that crypto makes easier, better, cheaper or faster”. He concludes that cryptocurrencies should be banned because they encourage ransomware attacks and serve no purpose aside from making a “quick buck”.</p><p>To be sure, ransomware attacks and other exploits are serious problems and they should be addressed. However, cryptocurrencies’ primary use case is totally unrelated to efficiency and speed. Rather, they are designed to encourage decentralized decision-making with the aim of producing a more democratic and <a href="https://en.wikipedia.org/wiki/Antifragile">antifragile </a>society.</p><p>People who live in developed countries have never experienced a total meltdown in the fabric of society. So they assume that “easier” and “faster” systems are the goal and they take stability for granted. However, for those who have experienced debilitating political adversity, the picture is very different. Imagine you live in Russia in 1919 and the Red Army confiscated your property. Or you live in a country that suffers through perpetual hyperinflation due to incompetent policy-makers. Or you live in a moment of ethnic cleansing where your property is confiscated and your citizenship is stripped.</p><p>In these cases, you want a set of systems that are robust to the various ways that political power can be abused or corrupted. Decentralization via an ingenious consensus algorithm is Bitcoin’s solution to this problem. Bitcoin’s narrow application was to address corruption in monetary policy. However, the principle of decentralization can be applied to many political problems.</p><p>The rest of this post considers various properties of blockchain technology, in an attempt to provide some context for those who are ambivalent about its widespread adoption.</p><h3>The Four Faces of Blockchain Technology</h3><h4><em>1. “Decentralized / Trustless”</em></h4><p>“Decentralized” means that no single central authority is required to keep the system functioning. “Trustless” means that you don’t need to trust a centralized authority.</p><p>In contrast, almost every other aspect of life requires centralization to some extent. For example, representative democracy was a huge leap forward in decentralizing political activity. However, in 2021, we still need a physical national capital with legislators to represent us; as a result, there are perpetual injustices in the form of lobbying, unholy bargains, side deals, etc. Blockchain technology might enable us to create the first truly democratic institutions i.e., democracy <em>without </em>representation.</p><h4><em>2. “Immutable / Censorship-Resistant”</em></h4><p>“Immutability” means that transactions cannot be reverted and it is a byproduct of the Bitcoin consensus algorithm. But that doesn’t mean that we can’t build <em>mutable </em>systems that are also decentralized. In other words, we could build systems where decisions to revert transactions are also handled in a decentralized fashion.</p><p>To be sure, immutability encourages ransomware attacks and hacks of decentralized applications. For example, if a hacker is successful in draining a <a href="https://www.investopedia.com/decentralized-finance-defi-5113835">DeFi</a> protocol’s <a href="https://www.investopedia.com/terms/s/smart-contracts.asp">smart contracts</a>, those transactions cannot be reverted. In contrast, if a piece of bank software is faulty and customers receive $1mm accidentally, such transactions <em>can </em>usually be reverted.</p><p>On the other hand, immutability also has key advantages. One example is that it enables censorship-resistant applications e.g., hosting a Twitter clone on a public blockchain. Another example is that decentralized applications only need to be audited once. (There are no continuous deployments like traditional web applications that might inadvertently introduce a bug.)</p><p>Overall, I think the verdict is out on immutability being a virtue of blockchain technology. It would be nice to see a new blockchain that could support transaction reversions in a completely decentralized fashion.</p><h4><em>3. “Transparent”</em></h4><p>People sometimes quote transparency as being a virtue of blockchain technology. However, this is not accurate. It is true that transactions can be viewed on the Bitcoin and Ethereum blockchains. In general, however, centralized systems can be designed to be transparent and decentralized systems can be designed to be opaque e.g., <a href="https://www.investopedia.com/terms/z/zcash.asp">Zcash</a>.</p><h4><em>4. “Cheaper / Better / Faster”</em></h4><p>Almost all technology innovations <em>until </em>Bitcoin were about “easier”, “cheaper” and “faster”. As mentioned above, Bitcoin introduced a completely new use case for software technology: antifragility. That said, recent innovations in blockchain technology are also revealing use cases that are truly cheaper and faster than traditional software designs.</p><p>For example, a company token can be created <em>and</em> listed on a decentralized exchange in less than 1 minute and for just a few hundred dollars. In contrast, it would cost millions to issue public stock using traditional financial systems.</p><h3>Conclusion</h3><p>In short, Lee Reiners is right about the need to address ransomware attacks and other exploits. However, such solutions can and will come from the cryptocurrency development community, not from heavy-handed regulation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8565fdb7c37" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Primer on DeFi Due Diligence]]></title>
            <link>https://pandichef.medium.com/a-primer-on-defi-due-diligence-a5f1ee9aed49?source=rss-f58d870c98dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5f1ee9aed49</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[uraniumfinance]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[binance-smart-chain]]></category>
            <category><![CDATA[yield-farming]]></category>
            <dc:creator><![CDATA[Pandichef]]></dc:creator>
            <pubDate>Sat, 01 May 2021 06:05:04 GMT</pubDate>
            <atom:updated>2021-06-14T16:32:49.569Z</atom:updated>
            <content:encoded><![CDATA[<p>In the following post, I look at the recent hack on <a href="https://uranium.finance/">Uranium Finance</a> (Binance Smart Chain), identify points of failure and make suggestions for performing adequate due diligence in the context of making investments in DeFi smart contracts.</p><p>Early April 28th (UTC), the Uranium Finance liquidity pools were drained. As highlighted in <a href="https://www.rekt.news/uranium-rekt/">others posts</a>, the source of the hack was a simple typo in the smart contracts. While there is some speculation that the typo was deliberate, in this post, I’m going to assume it was an honest mistake.</p><p>According to a <a href="https://uraniumfinance.medium.com/exploit-d3a88921531c">post published by the Uranium team</a>,</p><blockquote>The audit included private peer review by Defiyield.info and code review by Hyperjump who are both very active in the AMM/farm space and a full audit by BSC Gemz. Not one of these audits picked this up as a critical vulnerability, but BSC Gemz did highlight an associated low level risk. The complete code base was available with not only these groups but was available on our GitHub and viewable on BSCscan.</blockquote><p>How could three independent auditors have missed such a glaring problem?</p><p>Let’s look at each audit independently:</p><p><em>Defiyield.info</em></p><p>One of two anonymous Uranium developers (“Cataldo”) has been active in the Uranium Telegram chat since the hack occurred.</p><p>From those posts, it’s not even clear who performed this “private peer review”. (Note that this was not a formal audit and all parties agree that no one was paid.) On Telegram, “Farming Lord³ / DefiYield.info” denies the assertion that he did any kind of peer review or “lite audit”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*98EX9_obz2rUP7-C4cLtRw.png" /></figure><p>In response, Cataldo @ Uranium posts the interactions with “DefiYield.info”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ndMQCru4fF7Q3WNtmfoVrA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z6re8XzCh07CR_HYQGWTug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qnjUpE1nmGZFhiJi2ONhOQ.png" /></figure><p>To which “Farming Lord³/ Defiyield.info” responds on the Uranium chat:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*qBWRSx0ssdRTG-ofM4L3ZQ.png" /></figure><p>From these interactions, it seems that:</p><ul><li>The Uranium team had only a vague idea who was auditing their code</li><li>The Uranium team had little evidence that “defiyield.info” did anything</li><li>At best, “defiyield.info” ran Uranium’s test suite, which obviously is a far cry from a legit audit</li></ul><p>After I originally published this post, “Farming Lord³/ Defiyield.info” reached out to me to clarify certain points. Apparently, a certain “Wendel” — a volunteer in the defiyield.info Telegram channel — checked the code for just “20 minutes”. Moreover, the faulty AMM code apparently wasn’t even included in that review.</p><p><em>Hyperjump</em></p><p>Hyperjump’s audit appears to have been the only paid audit completed <em>before</em> Uranium v2 was deployed. Here’s the <em>entire</em> audit report:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*4pdjgfd4Clk9cgZ8JcJ0eA.png" /></figure><p>Observations:</p><ul><li>As with defiyield.info, Hyperjump is a DeFi project in its own right, not a professional auditing firm.</li><li>There is no discussion in the Hyperjump audit report of the methodology employed to stress test the contracts; in fact, the audit comments imply that they only did a high-level review of the code.</li></ul><p><em>BSC Gemz</em></p><p>According to the Uranium team, the BSC Gemz audit was all but complete (albeit never published) a few days before the hack and is what tipped them off to the bug. (Cataldo at Uranium mentioned that a person named Ogle was involved in this audit in some way, who discusses the hack <a href="https://twitter.com/cryptogle/status/1387453342763425792">here</a>.) One thing to note here is that the Uranium team released v2 <em>before</em> the audit was complete. In other words, they released v2 based on the incredibly inadequate reviews by “defiyield.info” and Hyperjump. (Note: as stated earlier, “defiyield.info” was apparently just a moderator named Wendel on the defiyield.info Telegram group.)</p><h4>Points of Failure</h4><p>There are a few points of failure that made this project almost doomed to fail:</p><ul><li>The Uranium team is anonymous. With minimal reputation risk, they seem to have hacked away at code in an irresponsible way. Moreover, Cataldo at Uranium has admitted that he thinks that someone in his team leaked knowledge of the hack to an acquaintance (perhaps to protect them from the exploit), but he refuses to identify individuals’ names to authorities.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aaz8g47hSW0HYnFl5eKVdg.png" /><figcaption>Cataldo acknowledging that someone in his team probably leaked info about the smart contract bug</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nBbbr30Iz23P6geof4fm3A.png" /><figcaption>Cataldo refuses to share team identities</figcaption></figure><ul><li>The Uranium team did the real audit — the one by BSC Gemz — <em>after</em> they deployed the smart contracts. Obviously, this makes almost no sense whatsoever and was clearly motivated by a desire to ship as quickly as possible. Moreover, any number of people at BSC Gemz and the 7 members of the Uranium team knew that there was a vulnerability. And any of these people might be the hacker or might have tipped off the hacker.</li><li>The Uranium team didn’t have a clear game plan when they discovered a bug. Ideally, they should have drained the LPs themselves and immediately and return the money to LP stakers. (Note that doing this competently is not trivial.) Instead, they decided to do something really crazy. They announced the release of v2.1 just ~10 days after the release of v2. In traditional software development, x.1 generally indicates that bugs are being fixed relatively to x.0. There is no such thing as x.1 in DeFi! They implicitly announced to the entire world that they found a bug.</li></ul><h4>Due Diligence for Investors</h4><p>Based on the above, I’d suggest the following due diligence rules for investing in DeFi smart contracts:</p><ul><li>Has v1 of the protocol has been around for at least 3 months? Don’t be one of the first people to ape into a project.</li><li>Has the most <em>recent </em>version of a protocol been around for at least 2 weeks? As seen with the recent Pancakeswap v2 release, upgrades are likely points of failure.</li><li>Did the development team spend at least 3 months working on the project prior to deployment of v1? (Check the commit history in their public repo and the age of the domain name on <a href="https://whois.domaintools.com/">whois.domaintools.com</a>.)</li><li>Is there any other indication of sloppiness in the code? Is the repo poorly maintained? Was the code written rapidly during a hot market? Check the repo commit timeline. (Uranium’s token &amp; LP designs were very ambitious, but they had just two devs and seem to have made changes at a breakneck pace.)</li><li>Is the project a simple fork of a battle-tested protocol or is the project’s scope to be too ambitious for the development team? If the latter, the smart contracts are more likely to have bugs.</li><li>Are the developer identities known? As mentioned earlier, a known developer simply can’t afford to deploy irresponsible code.</li><li>Have the developers received sponsorship from a reputable institution? e.g., a grant or a Series A from Binance, Ethereum Foundation, Pantera, etc.</li><li>Is the TVL greater than $100mm?</li><li>Are the returns reasonable relative to other DeFi platforms? (Some of the Uranium LPs had returns north of 1,000% APY.)</li><li>Was the audit done before deployment or is it “in progress”?</li><li>Did the audit actually run a battery of tests or was it a casual review?</li><li>Is the audit report professionally done? Is their methodology explained?</li><li>Does the project have more than 100k Twitter followers or is at least one reputable Twitter account (&gt;100k followers) promoting it?</li><li>Is the project a fork? If so, diff the code vs the source repo and ask the developers why they made certain changes.</li><li>Download the code and run the tests. How do the tests compare to the source repo’s tests? Do they seem to have taken shortcuts or did they go above and beyond to find weaknesses?</li><li>Is the project audited by a reputable company? Needless to say, auditors associated with <a href="https://www.rekt.news/leaderboard/">prior hacks</a> are probably <em>not</em> reputable.</li><li>Was the project hacked before? What were the details? In almost all cases, don’t touch a project that was previously hacked. Check the <em>Rugsteemer</em> group on Telegram.</li><li>Is the project’s token listed on Coingecko? Uranium’s token, U92, was not. As Coingecko does <a href="https://www.coingecko.com/en/listing_terms">minimal due diligence</a> on projects, not being on Coingecko is a reg flag.</li><li>Can you answer all the above diligence questions relatively easily? Is the development team transparent in their documentation and Telegram group?</li></ul><p>If you choose to overlook these guidelines for some reason, consider that investment to be speculative and limit exposure to 5% of your portfolio.</p><h4>Lessons for the Industry</h4><p>Industry titans like Binance and the Ethereum Foundation should come together and:</p><ol><li>Establish clear guidelines on how good audits should be done. Audit firms should attest that they’ve followed those guidelines. To date, I haven’t seen any DeFi audit reports that strike me as comprehensive and thorough.</li><li>Establish clear guidelines for how project devs should handle bugs that are discovered after deployment.</li></ol><p>Moreover, projects can implicitly self insure by publicly stating the reward amount for white hats. It is much better if 10% is lost in a white hat reward than 100% lost to a criminal hacker. Since the incentives are relatively high to <em>legally </em>hack the contracts (as there would be no legal repercussions), white hats are likely to exploit protocols before a criminal.</p><p>Finally, I think we’ll eventually see decentralized KYC protocols implemented for law enforcement purposes. For example, a new KYC protocol called SecureFi might offer users the opportunity to <em>voluntarily </em>KYC. The KYC data would be encrypted and not accessible even by members of the SecureFi development team. Then a new DeFi protocol (like Uranium) could require that users are whitelisted with SecureFi. If there is a hack, SecureFi token holders could vote to decrypt the KYC data associated with the hacker’s account, but only if requested by law enforcement authorities. Such a protocol would be a deterrent to would-be hackers while protecting most users’ identities.</p><h4>References:</h4><p><a href="https://www.rekt.news/uranium-rekt/">Rekt - Uranium Finance - REKT</a></p><p>Fork of the flawed Uranium v2 code (the original repo is no longer public): <a href="https://github.com/3v3rt0n/DextroFinance">https://github.com/3v3rt0n/DextroFinance</a></p><ul><li><a href="https://letmeape.medium.com/how-to-spot-a-potential-rug-clear-signs-something-is-sketchy-169fb84c7084">How To Spot a Potential RUG — Clear signs something is sketchy</a></li><li><a href="https://letmeape.medium.com/how-to-keep-your-funds-safe-metamask-guide-816773968310">How to Keep Your Funds SAFE — MetaMask Guide</a></li></ul><h3>DeFi Kombat on Twitter: &quot;It&#39;s been a while since we&#39;ve had detailed discussion about #BSC safety, so I present...Evaluating YFs and Their Contract Code. Some quick things to look out for. Let&#39;s start easy:0. Linked: Valid projects link their contracts from their site (or documentation). 𝙋𝙚𝙧𝙞𝙤𝙙. pic.twitter.com/tzs6Pj6MB4 / Twitter&quot;</h3><p>It&#39;s been a while since we&#39;ve had detailed discussion about #BSC safety, so I present...Evaluating YFs and Their Contract Code. Some quick things to look out for. Let&#39;s start easy:0. Linked: Valid projects link their contracts from their site (or documentation). 𝙋𝙚𝙧𝙞𝙤𝙙. pic.twitter.com/tzs6Pj6MB4</p><ul><li><a href="https://thedefiant.io/red-flag-alert-a-framework-for-vetting-crypto-projects-part-ii/">Red Flag Alert: A Framework for Vetting Crypto Projects Part II - The Defiant - DeFi News</a></li><li><a href="https://safe.defiyield.app/audits">DEFIYIELD</a></li><li><a href="https://defisafety.com/">DeFi Safety</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5f1ee9aed49" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Slippage Ratio: A New Metric to Understand Curve.fi’s AMM Protocol]]></title>
            <link>https://pandichef.medium.com/the-slippage-ratio-a-new-metric-to-understand-curve-fis-amm-protocol-fddf0ba4d6c8?source=rss-f58d870c98dc------2</link>
            <guid isPermaLink="false">https://medium.com/p/fddf0ba4d6c8</guid>
            <category><![CDATA[dex]]></category>
            <category><![CDATA[stable-coin]]></category>
            <category><![CDATA[amm]]></category>
            <category><![CDATA[uniswap]]></category>
            <category><![CDATA[defi]]></category>
            <dc:creator><![CDATA[Pandichef]]></dc:creator>
            <pubDate>Fri, 18 Dec 2020 20:23:12 GMT</pubDate>
            <atom:updated>2020-12-18T20:23:12.274Z</atom:updated>
            <content:encoded><![CDATA[<p>The <a href="https://www.curve.fi/stableswap-paper.pdf">Curve Whitepaper</a> concisely highlights an approach to building an AMM that allows developers to control slippage. Curve’s primary use case is swapping stablecoins, where low slippage is essential to compete with centralized exchanges. In contrast, <a href="https://uniswap.org/">Uniswap </a>and <a href="https://balancer.finance/">Balancer</a> use a constant-product invariant (as the Curve Whitepaper describes it); on Uniswap, slippage would be 25% for a trade that is 10% of the size of a liquidity pool. Intuitively, this isn’t acceptable for two assets that are nominally equivalent e.g., USDC vs DAI.</p><p><a href="https://www.curve.fi/">Curve.fi</a> has maintained a large and stable market share, indicating the success of its approach (see figure 1). It’s natural to consider whether the protocol might be applicable to any token pair that has a notion of parity. By <em>parity</em>, I mean that there is some kind of “normal” or mean-reverting price implicit in the asset. For example, a corporate bond issued by General Motors would be expected to trade around 1.0 (i.e., par), barring some kind of credit or interest rate event. We can characterize <em>GM-bond/USD</em> as a <em>parity token pair</em>. A stablecoin is just one example of a parity token pair.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*WmPH6nmhn-pBHXbTX5CgWQ.png" /><figcaption>Figure 1. Weekly DEX Volume Market Share</figcaption></figure><p>The rest of this post considers the Curve AMM protocol (also called the <em>StableSwap Invariant</em> in the Whitepaper) in the context of any parity token pair. Stablecoins are expected to always trade at or near 1.0; in general, however, the price of a parity token pair may deviate substantially from 1.0. Therefore, we have to give serious consideration to the protocol’s stability in such scenarios. In doing so, I introduce the <em>slippage ratio</em>, which measures the slippage of an AMM protocol at a given pair price. For the Uniswap AMM, the slippage ratio is always 2. But for Curve.fi, the slippage ratio is dependent on the pair price.</p><p><strong>Defining the Slippage Ratio</strong></p><p>Let x and y be the quantities of two pairs in a liquidity pool. For example, y might be the quantity of USDC and x might be the quantity of another parity token (e.g., a 3-year USDC denominated loan collateralized by WBTC). By definition,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/160/1*Z7R7Ej384C0QavkZnA8WDw.png" /></figure><p>If Δx is small, then there is 0 slippage and we can write</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/229/1*6KUeMgzetFzcviDPYJX3hw.png" /></figure><p>Assuming there are no arbitrage opportunities, we can assume that the zero-slippage price is exogenous. Let π be the exogenous market price of a pair. In a no-arbitrage equilibrium, the pair price is defined by</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/73/1*OTErMMd8eNqm7T9uDBKw4w.png" /></figure><p>An AMM protocol is defined by a functional relationship between x and y i.e.,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/71/1*8Hhvzvb13zE-Q8jecApXqA.png" /></figure><p>We can write out f(x) as a Taylor Series expansion i.e.,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*87T5MZ5B7i0BHd6wH25pUA.png" /></figure><p>Therefore,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*PGquK6eRDdVsrPMKh8gBrw.png" /></figure><p>Now we can define slippage as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*7PqqpJfLoGWyWuhgQBfaew.png" /></figure><p>In general, slippage will vary based on the size of a trade relative to a liquidity pool’s size. Therefore, it’s natural to normalize the slippage by the trade size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*7PQ2FfGJ1A2KabMAr2s31A.png" /></figure><p>Now we can define</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*g34IAL6a8ITj-LrvP99pBQ.png" /></figure><p>This quantity characterizes the slippage for a trade that is “small” relative to the liquidity pool’s market value.</p><p><strong>The Constant-Product Invariant a.k.a., Uniswap</strong></p><p>I’ll first consider the slippage ratio for a constant-product invariant AMM (e.g., Uniswap).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/53/1*pMtSMudnyLxbVpeKYru1cQ.png" /></figure><p>Taking the first derivative, we have</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/93/1*iF_bd2kQ0HFIitoDofP7yQ.png" /></figure><p>Therefore,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/100/1*SaSNib4kNrmMVaM7K3GJlA.png" /></figure><p>In other words, the market price is equal to the ratio of the quantities of the two pairs. Note that this result is <em>unique</em> to a constant-product invariant. It is <em>not</em> a general feature of all AMM protocols. Moreover,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/72/1*mwgoH3MxuYZtscXmpj4MAw.png" /></figure><p>Therefore,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*W8hErWE4cV8YLPC01S5xGA.png" /></figure><p>But note that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/61/1*TLDJXov3mq01EvOcVn-Xnw.png" /></figure><p>Therefore,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/156/1*JBuf4yfps2GSBPgZ2EnXaw.png" /></figure><p>In other words, a trade that is 1% of the liquidity pool’s size would have slippage of ~2%. (The actual slippage for a 1% trade is 2.04%.)</p><p>Finally, token two’s market value weight is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*fBusUUPhfT9i0ilfGr-NtQ.png" /></figure><p>We now have three unique properties of a constant-product invariant:</p><p>1) The market price is always equal to the ratio of the quantities of the two tokens</p><p>2) The slippage ratio is always 2</p><p>3) The market value weights remain constant (50/50 in the case of Uniswap)</p><p><strong>The StableSwap Invariant a.k.a., Curve.fi</strong></p><p>The <a href="https://www.curve.fi/stableswap-paper.pdf">Curve Whitepaper</a> describes the StableSwap invariant in terms of n coins (with equal weight) in a single liquidity pool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*APcy3eQmvzMwBF3MQtgcWA.png" /></figure><p><strong>D</strong> is the variable that remains constant before and after a given trade.</p><p><strong>A</strong> is called an <em>amplification coefficient</em> in the Curve Whitepaper. This subjective parameter is set based on the desired properties of the AMM. For example, a higher value of A would decrease slippage (at least at certain price points).</p><p>If n=2,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/226/1*MtKHIMULgRJ_2YOZOifubw.png" /></figure><p>where</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/112/1*XUnVv4tk20EuQIsybta3gA.png" /></figure><p>To understand this formula better, let A=0. Then</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/66/1*6C7dmk-Hs5RlPexBW3TxbA.png" /></figure><p>which of course is the constant-product invariant. If we write y=f(x), note that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/81/1*prLgTqwpRVVWoCdRujflWQ.png" /></figure><p>and</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/96/1*ZYo3TKgTM3rhmdXFlYPuVg.png" /></figure><p>In other words, when x=y, the zero-slippage price is exactly 1.</p><p>On the other hand, as A approaches infinity, we have</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/80/1*EkdJJ0YsadbAPcCv8QJ_zQ.png" /></figure><p>which is what the Curve Whitepaper calls a linear invariant or a constant-sum invariant i.e., the case where the two coins always have the same price.</p><p>As before, we have</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/81/1*prLgTqwpRVVWoCdRujflWQ.png" /></figure><p>and</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/96/1*ZYo3TKgTM3rhmdXFlYPuVg.png" /></figure><p>Again, when x=y, the price is 1. In other words, the constant-sum and constant-product invariants are similar when the stablecoin pair has equal quantities in the liquidity pool. Figure 2 shows the StableSwap invariant relative to these two special cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*8MRWD_xfdIyCbkK5fJQ9dw.jpeg" /><figcaption>Figure 2</figcaption></figure><p>In order to implement this algorithm, one has to solve for D. The Curve Whitepaper considers any number of coins i.e., we have to solve an n-degree polynomial. If n&gt;3, there is no closed-form solution. Hence, Curve.fi apparently solves for D numerically. Here’s the relevant snippet from <a href="https://github.com/curvefi/curve-contract/blob/master/contracts/pools/usdt/StableSwapUSDT.vy">Github</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fde1360a643979411cbdbab395f02ec8/href">https://medium.com/media/fde1360a643979411cbdbab395f02ec8/href</a></iframe><p>But since we’re focusing on a pool with just 2 pairs, we can derive a closed-form solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*McPnFWWowtnR7-1yNn-HwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*7-icWnRm51Hcm5uZhrjccA.png" /></figure><p>Using Cardano’s formula for a cubic polynomial, we have</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*f5hElS2HHJmz7I6xhqBDpg.png" /></figure><p>where</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/134/1*G7SrEr89BmpAdRYxJXG3Dg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/158/1*cOdp6mPdQqOsZt4q-qWUKg.png" /></figure><p>To implement this protocol, we also need to solve for y.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*9uKdpnq6K3EnEA_btz9jYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*Q_DRka6ILQ-qg3VCdVBDPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*UI3hy666h0E-BpUXw2ngxA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*5iYnr7R5oRffi2qz7HEUyA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*SshgloJRAo4M9uGi6FBTfg.png" /></figure><p>Using the quadratic formula, we have</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/162/1*9yerNBwH4qLrIDsZGSCIJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/56/1*bXs0BEIipIWOtAhwW0kJBw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*lmYZvqcE4iTIvAruOdwVyQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/71/1*bQS5-nDY2L6VAqQpnyb-cQ.png" /></figure><p>As discussed earlier, the zero-slippage price of the pair is determined by the first derivative of this curve i.e.,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*SshgloJRAo4M9uGi6FBTfg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*lXc-cZ-R1Ki4EV0y_DQqkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*trTGQVKhqheViEhOerkWLA.png" /></figure><p>Moreover, as before,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*knPFFyqlRFeXJTIIUjJRbQ.png" /></figure><p>We can use the above formulae to evaluate how the StableSwap invariant behaves at various price levels. The results are shown in figures 3, 4, and 5. Note that the x-axis in all these graphs is the exogenously determined pair price.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*fo6F0H6hBo2IxOVganKcGg.jpeg" /><figcaption>Figure 3</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*iKZAVfRaKn-AL5Z2gH6vKQ.jpeg" /><figcaption>Figure 4</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*ndg_rkCLGRgpALFBpO4Mbg.jpeg" /><figcaption>Figure 5</figcaption></figure><p><strong>Conclusions</strong></p><p>The StableSwap AMM has clear advantages over the constant-product invariant:</p><ol><li>It’s flexible i.e., the constant-product invariant is a special case of the StableSwap invariant</li><li>It enables a dramatic reduction in slippage under normal circumstances i.e., when the price is close to par</li><li>It’s inherently stabilizing. In order to drive prices below par, traders would have to actively sell the parity token into the AMM. For example, when A=20, 85% of the liquidity pool has to consist of the parity token to drive prices down to 80%.</li></ol><p>However, the StableSwap AMM also has some cons:</p><ol><li>The slippage can be much higher than a constant-product invariant if the pair price deviates significantly from par</li><li>As mentioned above, the market value weights need to vary in order to drive prices above or below par. This means that larger trades need to be executed in order to maintain a no-arbitrage equilibrium. As fewer players are able to trade in larger sizes, the StableSwap AMM might be prone to longer-lasting market dislocations. In other words, the AMM price might deviate from off-chain prices for a longer period of time.</li></ol><p><strong>References</strong></p><p><a href="https://en.wikipedia.org/wiki/Quadratic_formula">https://en.wikipedia.org/wiki/Quadratic_formula</a></p><ul><li><a href="https://encyclopediaofmath.org/index.php?title=Cardano_formula">Cardano formula</a></li><li><a href="https://duneanalytics.com/hagaetc/dex-metrics">DEX metrics 📊</a></li></ul><p><a href="https://github.com/curvefi/curve-contract/blob/master/contracts/pools/usdt/StableSwapUSDT.vy">https://github.com/curvefi/curve-contract/blob/master/contracts/pools/usdt/StableSwapUSDT.vy</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fddf0ba4d6c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>