{"componentChunkName":"component---src-templates-post-template-js","path":"/posts/crypto/borrow","result":{"data":{"markdownRemark":{"id":"5dfc5aa7-6aa3-57fd-b099-6096af63a326","html":"<h1 id=\"asset-price-movements-and-liquidations\" style=\"position:relative;\"><a href=\"#asset-price-movements-and-liquidations\" aria-label=\"asset price movements and liquidations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Asset Price Movements and Liquidations</h1>\n<p>Synthetic Asset protocols ie DAI, Mirror, Synthetix, Yeti</p>\n<ul>\n<li>Needs oracle that provides prices of collateral asset</li>\n<li>Can mint new DAI when <code class=\"language-text\">O_t * a * c >= b</code> where O_t is the oracle price, a is the amount of collateral, c is the collateral factor(usually less than 1), b is the amount of synthetic tokens</li>\n<li>If the oracle updates and cause the above invariant not to hold, a liquidation of the position is allowed(This is very bad for the person who took out their position!!)</li>\n</ul>\n<p>For the multi-collateral case, O<em>t, a, c, b are all vectors and the following invariant is used\n`sum over collaterals(O</em>t * a * c) >= b`</p>\n<p>If you have a mixture of two assets(ie 50% eth and 50% bitcoin), as long as the oracle prices are not perfectly correlated, there is a smaller chance that the collaterals move in a way to get you liquidated.</p>\n<h3 id=\"arguments-for-not-doing-this\" style=\"position:relative;\"><a href=\"#arguments-for-not-doing-this\" aria-label=\"arguments for not doing this permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Arguments for not doing this?</h3>\n<p>Might be hard to set the parameters for <code class=\"language-text\">O_t, a, c, b</code>, but gauntlet already does this for collateral ratios on compound and aave</p>\n<h3 id=\"why-is-everything-correlated\" style=\"position:relative;\"><a href=\"#why-is-everything-correlated\" aria-label=\"why is everything correlated permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Why is everything correlated?</h3>\n<p>Things are empirically correlated and the why doesn’t really matter.</p>\n<p>People who invest in an asset class want to be diversified, if the bitcoin in their portfolio goes up, they want to rebalance to stay diversified so they sell part of their bitcoin and buy eth, causing the eth price to go up.</p>\n<h1 id=\"risk-modeling-for-protocols-with-liquidations\" style=\"position:relative;\"><a href=\"#risk-modeling-for-protocols-with-liquidations\" aria-label=\"risk modeling for protocols with liquidations permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Risk Modeling for Protocols with Liquidations</h1>\n<h2 id=\"example\" style=\"position:relative;\"><a href=\"#example\" aria-label=\"example permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Example</h2>\n<p>Max Loan Size\nSupply vector x collateral ratio * prices\nAsset | Collateral factor\nETH | .825\nDAI | .825\nWBTC | .7</p>\n<h1 id=\"mechanics-of-liquidation\" style=\"position:relative;\"><a href=\"#mechanics-of-liquidation\" aria-label=\"mechanics of liquidation permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Mechanics of Liquidation</h1>\n<p>When liquidation is allowed, liquidators repay the borrowed amount and gets a portion of the collateral + some bonus. THe liquidator immediately market dumps the collateral + bonus.</p>\n<p>There’s a routing library in Julia that Bain cap wrote(doesn’t support curve/univ3)</p>\n<h2 id=\"cascading-liquidation-feedback-loop\" style=\"position:relative;\"><a href=\"#cascading-liquidation-feedback-loop\" aria-label=\"cascading liquidation feedback loop permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Cascading Liquidation Feedback Loop</h2>\n<p>Liquidations -> Market Dump -> Price Drop -> More Liquidation</p>\n<p>Algorithm:</p>\n<ol>\n<li>Input current state of lending markets, exchanges, prices\nWhile True:\nCheck for liquidations\nIf liquidations:\nRoute them over exchange graph, update exchange states, update prices to post dump prices</li>\n</ol>\n<p>Why?\nAllows us to calculate structural component expected loss vector and variance covariance matrix based on actual state of the chain\nAllows us to better understand price trajectories. Can sell to people who care</p>\n<h3 id=\"questions\" style=\"position:relative;\"><a href=\"#questions\" aria-label=\"questions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Questions</h3>\n<p>What’s the intuition behind multi-collateral synthetics being less likely to liquidate? What about non-stablecoins?</p>","fields":{"slug":"/posts/crypto/borrow","tagSlugs":["/tag/notes/","/tag/de-fi/","/tag/borrowing-protocols/"]},"frontmatter":{"date":"2021-12-30T23:46:37.121Z","description":"A deep dive into borrowing protocols","tags":["Notes","DeFi","Borrowing protocols"],"title":"Borrowing Protocols"}}},"pageContext":{"slug":"/posts/crypto/borrow"}},"staticQueryHashes":["251939775","401334301","825871152"]}