<?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 Guillaume Bonnot on Medium]]></title>
        <description><![CDATA[Stories by Guillaume Bonnot on Medium]]></description>
        <link>https://medium.com/@bonnotguillaume?source=rss-e088db98aabe------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6vIszBYMeK4CcQqpi3X16Q.png</url>
            <title>Stories by Guillaume Bonnot on Medium</title>
            <link>https://medium.com/@bonnotguillaume?source=rss-e088db98aabe------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 21:27:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bonnotguillaume/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[[DeFi] Introducing Next-Gen features for DEX Derivatives protocols.]]></title>
            <link>https://medium.com/@bonnotguillaume/defi-introducing-next-gen-features-for-dex-derivatives-protocols-c3af68f6baac?source=rss-e088db98aabe------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3af68f6baac</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[dex]]></category>
            <category><![CDATA[derivatives]]></category>
            <category><![CDATA[defi]]></category>
            <dc:creator><![CDATA[Guillaume Bonnot]]></dc:creator>
            <pubDate>Sun, 24 Dec 2023 16:52:07 GMT</pubDate>
            <atom:updated>2023-12-24T16:52:07.742Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this article, I will introduce several new features that would greatly improve the user experience using DEX derivatives platforms.</em></p><h4>Motivation</h4><p>With a background in shaping crypto derivatives trading on centralized exchanges back in 2015, I am optimistic that 2024 marks the rise of decentralized derivatives protocols.</p><p>However, crucial improvements are needed to make these protocols fully functional and competitive compared to their centralized counterparts.</p><h4>Abstract</h4><p>In this article, we will introduce several new features:<br>- margin call, to enable a proto cross-margin capability<br>- future tokens, derived from yield bearing token at a fixed rate<br>- futures contracts, a market to trade future tokens<br>- options, to cover leveraged futures positions</p><p>Let’s go, embark on the journey to the future of DeFi !</p><h4>Margin Call</h4><p>The grail for a DEX is to be able to offer cross-margin across multiple protocols across multiple chains.</p><p>The solution proposed here would lead to a very similar behavior, let’s introduce this feature coming directly from TradFi: Margin Call !</p><p>The concept is very simple: when the price falls down and the user’s position become under-collateralized, instead of immediately and unconditionally liquidating the position, the DEX will first make a margin call, giving the user the possibility to re-collateralize its position and avoid liquidation.</p><p>This requires some special setup, where each user should use a smart contract as user account for the DEX, and would have previously registered a callback to be executed on margin-call.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*0JGZ7BBIom7RkhU1g_qzCA.png" /></figure><p>The workflow would look like the following:<br>1. The Position becomes under-collateralized.<br>2. The DEX calls the User Account for a margin call.<br>The User Account executes a pre-registered callback:<br>3. Borrowing funds on Aave<br>4. Adding those funds as additional collateral to the position.</p><p>After the callback is executed, the DEX checks if the position is now healthy against. If the minimal required collateral has not been added by the callback, the position liquidated.</p><p>Furthermore, it is possible to enable cross-chain margin calls by introducing a timer between the margin-call and the next liquidation check, giving enough time for cross-check operations to be executed.</p><h4>Yield Bearing Tokens</h4><p>While yield-bearing tokens are the best assets a user can hold due to their expected appreciation over-time, they are not the best suited when it comes to serving as the base token in a derivatives trading pair.</p><p>In derivatives markets, the value of the derivative is intrinsically tied to the underlying asset from which it derives its value. The stability and established price behavior of the underlying asset are crucial for precise pricing and robust risk management within the market.</p><p>The best of both world would be to allow users to use yield bearing tokens as collateral, enjoying the yield for themselves while trading the base token on the platform.</p><p>One way to achieve this goal involves the introduction of synthetic versions of base tokens on the platform, each tied to a Collateralized Debt Protocol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*bSExCjStiSdsJ3JK1fM2iw.png" /></figure><p>This mechanism enables users to leverage their yield-bearing tokens as collateral, allowing them to retain the associated yield while actively trading the corresponding base tokens on the platform.</p><p>For instance, users can deposit sDAI as collateral, and receive synthetic USD, or use wstETH as collateral, and receive synthetic ETH.</p><p>The Collateralized Debt Protocol would be similar to Alchemix, where users deposit yield-bearing tokens as collateral to borrow the synthetic token without exposure to liquidation risks.</p><p>However, unlike Alchemix, users keep the generated yield for themselves rather than being used by the protocol to repay the loan.</p><p>This solution also allows the platform to use a unified abstraction for correlated tokens, consolidating them into a single synthetic token.</p><p>For instance, tokens like USDT, USDC, and DAI collectively represent a synthetic USD.</p><p>This solution also consolidates liquidity into a single trading pair, such as ETH/USD, as opposed to having fragmented liquidity across multiple pairs like USDT/ETH, USDC/ETH, and DAI/ETH.</p><h4>Future Yield Tokens</h4><p>To understand the concepts discussed in the following sections, it’s crucial to comprehend the mechanics of future yield protocols, like Pendle Finance or Chainge Finance.</p><p>In these protocols, yield bearing tokens can be exchanged to instantly receive a fixed rate yield in asset futures with an established maturity date. On that specific date, futures can be redeemed into spot assets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*eDrOvztOW6e-ibBJUH69Kg.png" /></figure><p>For example, the protocol could enable users to exchange 1 ETH against 1.03 future ETH redeemable a year later. The underlying yield strategy could be using a Liquid Staking Derivative with an estimated 3.5% APY.</p><p>This is made possible by establishing a future yield market, where users with lower aversion to risk can trade the potential yield of their tokens against a (lower) fixed rate offered by more risk-tolerant users seeking better yields.</p><p>In the case of Pendle Finance, a yield-bearing token locked until the maturity date will be divided into two distinct tokens: the principal token, representing the current value in underlying tokens, and the yield token, representing the additional tokens generated at maturity.</p><p>Basically, low-risk users exchange their yield tokens for principal tokens on the open market, with high-risk users on the other end of the trade.</p><p>However, we won’t delve into the details of these specific protocols in this article. Our focus here is on future tokens that exhibit two key properties:</p><ol><li>The ability to exchange spot tokens for future tokens at a fixed rate.</li><li>The capability to exchange future tokens at maturity for spot tokens at a 1-to-1 ratio.</li></ol><h4>Futures Contracts</h4><p>Futures contracts, a well-known instrument in traditional finance, are yet to find a robust representation in DeFi.</p><blockquote>Futures are a type of derivative contract agreement to buy or sell a specific commodity asset or security at a set future date for a set price.</blockquote><p>Despite their prevalence in traditional markets, the adoption of futures contracts in DeFi remains a challenge and is poised for significant growth.</p><p>Understanding the dynamics of futures contracts is crucial, their prices can differ from spot prices due to factors like market expectations, interest rates, and the time remaining until maturity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OoLUMocZjFTE1PbP.png" /><figcaption>futures premium narrowing until expiration</figcaption></figure><p>Usually, the crypto futures trade at a premium, following the price of money and the growth potential of the asset.</p><p>However, in a period of extreme fear (usually when the market just crashed at the top of the bull market and enters a bear market), the premium can be negative.</p><p>In order to get a futures price closer to the spot price, we introduce a future contract that can be traded using future tokens, which inherently include future yields, as discussed earlier.</p><p>For instance, consider a yearly ETHUSD futures contract expiring on December 31, 2024, enabling users to trade their ETH and USD future tokens, both maturing simultaneously.</p><p>At expiration, positions are settled, and the tokens are converted back to the underlying tokens.</p><p>This approach aligns the DeFi futures market more closely with spot prices, providing users with a clearer and more predictable understanding of their positions.</p><p>Another interesting feature of futures contracts, is the ability to create synthetic future tokens from a fully collateralized future position.</p><p>For example, a futures position to buy 1 ETH for 1000 USD, collateralized with 1000 future USD of the same maturity, can be transformed into a synthetic future ETH for that maturity.</p><p>Similarly, a futures position to sell 1 ETH for 1000 USD, collateralized with 1 future ETH, can be transformed into a synthetic future 1000 USD for the same maturity.</p><p>Futures contracts present distinct advantages compared to perpetuals, benefiting both users and protocols.</p><p>Users appreciate the certainty of knowing what they paid and what they will receive, while protocols benefit from the settlement at expiration, exerting pressure for synthetic assets to remain pegged.</p><p>This stands in contrast to perpetuals and CDPs, where open positions can lead to deviations from spot prices, compelling high fees to incentivize users to close positions and restore the peg.</p><h4>Options &amp; Liquidation Protection</h4><p>There are already some DeFi protocols offering options, with the majority of them relying on liquidity pools for market making.</p><p>However, there is a clear problem associating consumer demand with the risk taken by liquidity providers. Users tend to follow trends, often massively placing bets on the same side, forcing liquidity pools to take the opposite side of the bet and making risk hedging nearly impossible.</p><p>A potential solution lies in the concept of fully collateralized options writing, a strategy exemplified by the approach taken by Chainge Finance.</p><blockquote>Writing an option refers to selling an options contract in which a fee, or premium, is collected by the writer in exchange for the right to buy or sell shares at a future price and date.</blockquote><p>In this model, the idea is to write a call option by locking the underlying token as collateral, where the collateral will appreciate in conjunction with the option — a strategy known as a covered call.</p><p>For instance, you could create (write) an ETH call option using 1 ETH as collateral.</p><p>Similarly, the ability to write a put option involves locking an amount of stablecoin equivalent to the strike price as collateral. The entire collateral amount is then available to cover potential losses if the underlying asset reaches zero — a strategy known as a cash-secured put.</p><p>As an example, you could create (write) an ETH put option with a strike price of 1000 USD, using 1000 USD as collateral.</p><p>The same way future tokens find utility in futures contracts, they are an obvious choice for options markets. Utilizing future tokens as collateral not only enhances capital efficiency but also increases the usage and liquidity of these future tokens.</p><p>Once an options market is established for future tokens, a valuable application emerges: the ability to hedge leveraged futures positions.</p><p>A long position can be covered by acquiring a put option with a strike price matching the position’s liquidation price, thus preventing the position from being liquidated, at the cost of a small premium.</p><p>Similarly, a short position could be covered by buying a call option. However, it’s important to note that, given the market’s prevailing bias towards long positions, employing this strategy can be a relatively more expensive option.</p><h4>Conclusion</h4><p>While derivatives stand as the future of DeFi, the ecosystem is still in its early phase and current protocols needs to mature before they can reach mass adoption.</p><p><em>If you liked this article, please share and subscribe !<br>Looking for a blockchain expert ? Let’s connect on </em><a href="https://www.linkedin.com/in/guillaumebonnot/"><em>LinkedIn</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3af68f6baac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[DeFi] Masterclass on Collateralized Debt Protocols, Part 3: Alchemix]]></title>
            <link>https://medium.com/@bonnotguillaume/defi-masterclass-on-collateralized-debt-protocols-part-3-alchemix-c14099e3db89?source=rss-e088db98aabe------2</link>
            <guid isPermaLink="false">https://medium.com/p/c14099e3db89</guid>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[curve-finance]]></category>
            <category><![CDATA[alchemix]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Guillaume Bonnot]]></dc:creator>
            <pubDate>Mon, 18 Dec 2023 01:34:55 GMT</pubDate>
            <atom:updated>2023-12-18T01:37:50.857Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this article, I will talk about Alchemix, the self-repaying loan protocol. Let’s find out what makes this protocol so resilient.</em></p><p>This article is the part of a series containing the following articles:<br>- <a href="https://medium.com/@bonnotguillaume/defi-masterclass-on-collateralized-debt-protocols-part-1-makerdao-v1-9baf0fe2860e">MakerDAO v1</a><br>- <a href="https://medium.com/@bonnotguillaume/defi-masterclass-on-collateralized-debt-protocols-part-2-makerdao-v2-83c8476157d2">MakerDAO v2</a><br>- <a href="https://medium.com/@bonnotguillaume/defi-masterclass-on-collateralized-debt-protocols-part-3-alchemix-c14099e3db89">Alchemix</a></p><h4>Abstract</h4><p>This article is going to show how a good design can make a protocol resilient to adverse effects.</p><p>First, we will talk about the concept of self-repaying loans introduced by Alchemix, we will see why it is both a brilliant and a terrible design choice, how the Transmuter helps keeping the price at peg, we will introduce the concept of Algorithmic Market Operator with the Elixir, and finally we will talk about the Curve exploit’s and how it affected Alchemix.</p><h4>Self-repaying loans</h4><p>Alchemix is a Collateralized Debt Protocol offering self-repaying loans. Several strategies yield strategies are supported from reputable protocols.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SDN0vBHtHc-sj_JnUfIbfg.png" /><figcaption>deposit DAI and use Yearn as yield strategy and borrow alUSD</figcaption></figure><p>Users can deposit ETH or a USD stablecoin as collateral and borrow Alchemix’s own synthetic of the collateral (ETH -&gt; alETH, USD -&gt; alUSD).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RMjOLcJGx1S_RnTiQS3tpA.png" /><figcaption>deposit ETH to stake with Frax and borrow alETH</figcaption></figure><p>Using synthetics and using the same denomination for the collateral and the debt, greatly reduces the default risk and allows it to never liquidate.</p><p>The protocol will regularly harvest the yield generated buy the chosen strategy, and use it to incrementally repay the loan on the user’s behalf.</p><h4>Why it sucks</h4><p>The concept of self-repaying loans is both brilliant and incredibly stupid.</p><p>It is brilliant because of how people’s brain is wired, most people hate paying interest on their loans and are willing to go an extra mile to make sure the debt is paid asap.</p><p>But its also incredibly stupid, because this is the worst financial decision for both the user and the protocol. Have you ever heard the famous quote: “Compound interest is the eighth wonder of the world.” ? There is a reason.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PPhB8llVvMyUaFJD.png" /></figure><p>Compounding is where the money is made, investors should prioritize strategies that increase compounding, not reduce it.</p><p>Every time the user’s collateral’s yield is harvested by the protocol and used to partially repay the debt, it stops the compounding effect created by the yield. But in the mean time, it also decreases the fees paid to the protocol when reducing the outstanding debt.</p><p>This is a loose-loose situation: the user looses the compounding effect on its collateral and the protocol looses the compounding effect on the accrual of the fees.</p><p>Anyway, I love this protocol because this makes it very resilient.</p><h4>The Transmuter</h4><p>Alchemix’s Transmuter is used to convert base assets into synthetic assets back and forth (ETH &lt;-&gt; alETH, USDC &lt;-&gt; alUSD) on a 1–1 basis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-BITrCOOAmCU3s0u" /></figure><p>Converting from the base asset to the synthetic is straight forward, the user just deposits ETH and get the same amount of freshly minted alETH from the transmuter. This conversion is only useful when the synthetic asset is over-the-peg, otherwise the user is better off getting it, with a discount, from the open market when under-the-peg.</p><p>Converting the synthetic asset back to the base asset is more complex. Users who want convert it back must enter a kind of queue. Periodically, when the protocol harvests yields, a part of it is allocated to the transmuter and will be distributed pro-rata to users in the queue.</p><p>This mechanism can be very slow when there is a lot demand to exit the protocol and the peg is under sell pressure, but it is a great way to ensure the synthetic asset stays at-the-peg under normal conditions.</p><h4>The Elixir AMO</h4><p>The Elixir is Alchemix’s Algorithmic Market Operator (AMO).</p><p>An AMO is a smart-contract used to deploy the assets in the treasury using different strategies, in order to gain additional yields for the protocol.</p><p>For example, when users use the transmuter and deposit USDC against alUSD, the protocol new has USDC in its treasury. The Elixir is going to use those assets, and say, depositing it in Aave in order to get more yield.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LSrqbk6_Wvu7dt-d" /><figcaption>the actual Elixir’s strategy</figcaption></figure><p>The AMO is a critical part of any DeFi project with an idle treasury and has 2 greatly beneficial effects on the protocol:<br>- more assets to back the outstanding debt, better collateral ratio<br>- more profits for ALCX holders</p><h4>Curve’s Exploit</h4><blockquote>“On 30 July 2023, a number of Curve pools were exploited to the tune of tens of millions of dollars. Among these exploited pools was the alETH-ETH pool that is used to support the Alchemix ecosystem. […] This permanent loss amounted to 3,856 alETH in aggregate.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i09kO2uu6rGqzQhTo66HDQ.png" /></figure><p>This event caused the alETH price to substantially depeg, for the first time of its history. As we can see, before the hack, the price has always been oscillating near the peg, highlighting the robust design of the protocol.</p><p>At the time of writing, the alETH price is slowly coming back to the peg, following the decision by Curve’s DAO to compensate users who have by defrauded by the hacker. When the funds will be released by Curve, alETH should be fully backed again and the peg should be restored.</p><h4>Conclusion</h4><p>Alchemix has taken a very different approach to CDP that its competitors, with a very good risk management by utilizing yield bearing tokens to repay loans and denominating the loan in the collateral asset, removing the risk of liquidation for the user and the risk of systemic losses for the protocol.</p><p>Even after the recent hack, the protocol has shown its ability to stay pegged, showing the strength of its conservative design.</p><p>However, the design might a be bit too conservative for users who want to fully benefit from the collateral yields and their compounding effect.</p><p>Let me know what protocol you would like me to analyze next time !</p><p><em>If you liked this article, please share and subscribe !<br>Looking for a blockchain expert ? Let’s connect on </em><a href="https://www.linkedin.com/in/guillaumebonnot/"><em>LinkedIn</em></a></p><h4>Links</h4><p><a href="https://1902439814-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzG9qcxzJ1K3kNTlZ81Xj%2Fuploads%2FwhvgqIuvGYxbAlYgP1M0%2FAlchemix_Q3_2023_Financial_Report.pdf?alt=media&amp;token=b08c7227-04c5-47f9-95c2-9cd07f442be9">Alchemix Q3 2023 Financial Report</a><br><a href="https://vote.convexfinance.com/#/proposal/0x2f277d436b478cbe8439a463363f6ca9d4617313fcb02257fd0df7a855224f38">Vote for CurveDAO to compensate victims of the exploit</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c14099e3db89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[DeFi] Masterclass on Collateralized Debt Protocols, Part 2: MakerDAO v2]]></title>
            <link>https://medium.com/@bonnotguillaume/defi-masterclass-on-collateralized-debt-protocols-part-2-makerdao-v2-83c8476157d2?source=rss-e088db98aabe------2</link>
            <guid isPermaLink="false">https://medium.com/p/83c8476157d2</guid>
            <category><![CDATA[makerdao]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Guillaume Bonnot]]></dc:creator>
            <pubDate>Sun, 03 Dec 2023 17:21:25 GMT</pubDate>
            <atom:updated>2023-12-18T01:37:59.264Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this article, I will talk about the current version of MarkerDAO, how it has improved over-time, but also where it should do better.</em></p><p>This article is the part of a series containing the following articles:<br>- <a href="https://medium.com/@bonnotguillaume/defi-masterclass-on-collateralized-debt-protocols-part-1-makerdao-v1-9baf0fe2860e">MakerDAO v1</a><br>- <a href="https://medium.com/@bonnotguillaume/defi-masterclass-on-collateralized-debt-protocols-part-2-makerdao-v2-83c8476157d2">MakerDAO v2</a><br>- <a href="https://medium.com/@bonnotguillaume/defi-masterclass-on-collateralized-debt-protocols-part-3-alchemix-c14099e3db89">Alchemix</a></p><h4>Abstract</h4><p>The current version of MakerDAO includes significant improvements from the original design:</p><ul><li>using yield bearing tokens as collateral</li><li>adjusting the lending fees based on the leverage taken</li><li>staking DAI to get the yield from short-term T-Bills</li><li>using MKR to stabilize the system</li></ul><p>But there still some shortcomings with the protocol:</p><ul><li>crazy high fees</li><li>dynamic lending rate adjustment</li></ul><p>Let’s talk about MakerDAO in-depth !</p><h4>Maker DAO v2</h4><p>This new version of MakerDAO is bringing new collateral types, such as WBTC, which both brings more opportunities for users, but also reduces the systemic risk by diversifying the underlying assets backing the whole system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JRqmKu_b5ATTf4PZyE9QSQ.png" /><figcaption>Collateral selection</figcaption></figure><p>The most interesting type of collateral they introduced, are yield bearing token, which are most complex, but where the amount of underlying asset being collateralized should increase over-time.</p><p>For example, WSTEH is a Liquid Staking Derivative (LSD) currently yielding 3.5% APY on ETH, by using it as collateral, you would be able to offset the totality or a part of the borrowing fees.</p><p>This compounding effect can be extremely powerful and greatly increase capital efficiency of DeFi users. That’s why CDPs should focus on offering the best type of collateral if they want to reduce the competing on driving down the borrowing fees.</p><h4>Leverage &amp; Risk Management</h4><p>The next feature improves risk management by offering users different strategies for the same collateral.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*cB5JO_SxXh2_PmIr95rGbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*ufXDiTb6WltF6F7_LCFmUg.png" /><figcaption>WSTETH-A &amp; WSETH-B Vaults</figcaption></figure><p>The WSTETH-A Vault offers a 150% liquidation ratio and a 5.25% stability fee, while the WSTETH-B Vault offers a 175% liquidation ratio and a 5% stability fee.</p><p>The user is offered a trade-off, use less leverage and pay less fees, or choose for a more aggressive strategy and pay more fees. This is a smart way for the protocol to adjust the fees with the risk taken.</p><h4>Stability Fees</h4><p>This topic is very important, and let’s be honest, the 5% rate seen before is just outrageous. The rate is too damn high !</p><p>Let’s see what the documentation says, and how they justify it:</p><blockquote>The Stability Fee parameter is an annual percentage fee charged on the DAI generated on vaults.</blockquote><p>Ok, fair ! You use a service, you pay for the service.</p><blockquote>Each vault type has its own Stability Fee that can be adjusted by Maker Governance.</blockquote><p>Here we have 2 information:</p><ul><li>Each vault type has its own Stability Fee, as seen before, the rate will be adjusted based on the collateral and the leverage offered.</li><li>The Stability Fee can be adjusted by Maker Governance: basically, the rate is set by MKR holders</li></ul><blockquote>The primary purpose of the Stability Fee parameter is to compensate the Maker Protocol for the risk it takes being exposed to changes in the price of the collateral used to back the generated DAI.</blockquote><p>Exactly, the rate should be proportional to the risk taken by accepting the collateral ! So why are they charging 5% on ETH, with a liquidation ratio of 175% ?</p><p>MKR holders are incentivized to extract the maximum value from users, and in practice, the increase of the stability fee did not have a significant impact on MakerDAO’s market share, as we did not see a massive migration of users to any competitors.</p><p>In my opinion, charging 5% on money you can print for free is just insane ! Maybe MakerDAO is able to charge this much because the demand for DAI is still very strong thanks to the DSR, but I don’t think it will last, and I am convinced that it will be detrimental for the future of the protocol.</p><p>Do we really think that DeFi will revolutionize Finance by charging 5% to print basically free money ? Nope, I don’t think so !</p><h4>Dynamic Fees Adjustment</h4><p>Dynamically adjusting the lending rate is terrible in term of user experience.</p><p>Long term users usually open a position and keep it running for years possibly, without having to check the position, only checking the price of the collateral and assume the position should still be healthy.</p><p>If the DAO decides to unilaterally crank up the lending rate, there no way to make sure all users are aware, there is nothing like sending an email to an address !</p><p>The unsuspecting users would assume business as usual, while being ripped off by outrageous fees, while if he knew about it, he would have had the chance to reconsider if the new rate fits with his strategy and potentially close his position.</p><p>Of course, in this case, the best move would be to choose an other CDP offering a better rate or at least having a system that treat their users better.</p><h4>System Stabilizer Module</h4><p>MakerDAO has introduced a new system to handle Risk Management:</p><blockquote>The System Stabilizer Module’s purpose is to correct the system when the value of the collateral backing Dai drops below the liquidation level (determined by governance) when the stability of the system is at risk.</blockquote><p>The MakerDAO protocol can be in 2 states: healthy or unhealthy.</p><p>The system is considered healthy when all positions are over-collateralized and the system is in surplus via collecting fees.</p><p>When the system is healthy, the SSM will use the surplus to buy &amp; burn MKR, therefore increasing the value of all MKR holders.</p><p>The system is unhealthy when some positions are under-collateralized, liquidation failed and bad debt was created.</p><p>When the system is unhealthy, the SSM will mint &amp; sell MKR in order to repay the bad debt, therefore diluting and decreasing the value of all MKR holders.</p><h4>Dai Savings Rate</h4><p>One of the major problem of Collateralized Debt Positions (CDPs) must tackle in order to succeed, is the absence of incentives to hold the stablecoin, especially when compared to the risk-free 5% APR offered by the Fed.</p><p>The Dai Savings Rate (DSR) was created to incentivize Dai holders to keep their Dai in the MakerDAO ecosystem, rather than exchanging it for other cryptocurrencies or fiat currencies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*991QMB3BpPmIPnf4m5weXg.png" /></figure><p>Using the DAI locked in the DSR to acquire short-term treasuries, the DSR facilitates the transfer of yields from real-world assets (RWA) on-chain.</p><p>The DSR can be considered as a vampire attack on USDC, as anyone holding USDC without earning any APR may find it advantageous to convert their USDC to DAI and place them in the DSR, capitalizing on the 5% APR.</p><h4>Tokenomics</h4><p>Now that we have seen how MakerDAO works, let’s look at the numbers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZWlVh0ThjKmd4eEXwaYhPQ.png" /><figcaption>TVL</figcaption></figure><p>The Total Value Locked (TVL) chart clearly shows tremendous growth during DeFi summer in 2021, followed by a sharp decline during the bear market of 2022.</p><p>However, it seems the protocol’s TVL is still declining despite the whole ecosystem slowly recovering in 2023.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WRUSs4NRlAcDtuIahWe_Kw.png" /><figcaption>Fees</figcaption></figure><p>The fees generated by the protocol seemed to strictly follow the TVL until end of 2022, and have since been growing at a steady rate. This sharp rise in revenue for the protocol coincides with the release of the DSR, which is now the main source of profit for the protocol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A7U6dvdWG_Js8tXsei7x7g.png" /><figcaption>MKR price</figcaption></figure><p>The price chart for MKR is a bit more complex to analyze. We can clearly see the epic rise leading to the ATH being reached during DeFi Summer, as well as the steady decline during the bear market.</p><p>What’s puzzling me is the slow and steady price increase, when the fees are at all time high, MKR is still down 3x from the top.</p><p>With the conjunction of the DSR and DSM, MakerDAO is literally printing money and burning MKR, exercising huge buying pressure, it should send the MKR price to the moon.</p><p>However, this is not what has been happening, so far…</p><h4>Conclusion</h4><p>In its current iteration, MakerDAO stands as a vastly improved product from its original design, introducing new collateral like LSD, enhancing DAI’s appeal with the DSR, and delivering substantial profits for MKR holders while fortifying risk management through the DSM.</p><p>Undoubtedly, MakerDAO stands out as one of the most trusted and robust collateral debt protocols (CDPs). However, there’s a notable gap between the protocol’s success and the corresponding benefits reaped by MKR holders. Despite its strengths, the protocol still grapples with certain shortcomings.</p><p>As previously highlighted, these weaknesses leave room for potential competitors to seize opportunities. Competitors could offer collateral with superior yields, such as leveraging assets like sfrxETH instead of stETH, or they might focus on reducing the fees, with a target around 1–2%.</p><p>Next time, we will talk about another very robust protocol: Alchemix !</p><p><em>If you liked this article, please share and subscribe !<br>Looking for a blockchain expert ? Let’s connect on </em><a href="https://www.linkedin.com/in/guillaumebonnot/"><em>LinkedIn</em></a></p><h4>Sources</h4><p><a href="https://cryptobanking.network/the-history-of-a-dai-at-par-value/">https://cryptobanking.network/the-history-of-a-dai-at-par-value/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83c8476157d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[DeFi] Masterclass on Collateralized Debt Protocols, Part 1 : MakerDAO v1]]></title>
            <link>https://medium.com/@bonnotguillaume/defi-masterclass-on-collateralized-debt-protocols-part-1-makerdao-v1-9baf0fe2860e?source=rss-e088db98aabe------2</link>
            <guid isPermaLink="false">https://medium.com/p/9baf0fe2860e</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[makerdao]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Guillaume Bonnot]]></dc:creator>
            <pubDate>Fri, 24 Nov 2023 20:35:35 GMT</pubDate>
            <atom:updated>2023-12-18T01:38:30.384Z</atom:updated>
            <content:encoded><![CDATA[<h3>[DeFi] Masterclass on Collateralized Debt Protocols, Part 1 : MakerDAO v1</h3><p><em>In this article, I will introduce the basic concepts of Collateralized Debt Protocols using the original version of MarkerDAO as a first concrete example.</em></p><p>This article is the first part of a series containing the following articles:<br>- <a href="https://medium.com/@bonnotguillaume/defi-masterclass-on-collateralized-debt-protocols-part-1-makerdao-v1-9baf0fe2860e">MakerDAO v1</a><br>- <a href="https://medium.com/@bonnotguillaume/defi-masterclass-on-collateralized-debt-protocols-part-2-makerdao-v2-83c8476157d2">MakerDAO v2</a><br>- <a href="https://medium.com/@bonnotguillaume/defi-masterclass-on-collateralized-debt-protocols-part-3-alchemix-c14099e3db89">Alchemix</a></p><h4>Motivation</h4><p>CDPs are the backbone of Defi, they enable users to maximize capital efficiencies and allow affordable leverage via their unique money creation capabilities.</p><p>However, I am not satisfied with the current designs proposed by existing protocols.</p><p>That’s why I started this series — to look into various protocols and eventually suggest ways to enhance them…</p><h3>MakerDAO v1</h3><h4>Over-collateralized Stablecoin</h4><p>MakerDAO was originally a simple collateral debt protocol (CDP), introducing the concept of over-collateralized stablecoin.</p><p>The protocol enables users to deposit ETH as collateral to borrow DAI, a stablecoin pegged 1-to-1 to USD.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*lGD_EDNThlfyzF539phr5A.png" /></figure><h4>Borrowing &amp; Minting</h4><p>For instance, a user deposits $1000 worth of ETH, allowing them to borrow 500 DAI, theoretically valued at $500.</p><p>DAI is minted ex-nihilo by the protocol and is backed by the user’s collateral.</p><p>Consequently, the user possesses 500 DAI, and the protocol retains the ETH as collateral.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ip9aH-YdirnEpv4WbFAx6w.png" /></figure><h4>Debt &amp; Position</h4><p>To reclaim the deposited collateral, the user must repay the borrowed debt.</p><p>While the position is opened, the user incurs fees based on the borrowed amount, which contribute to MakerDAO’s treasury, bolstering the collateral peg.</p><p>The lending rate is fixed by MakerDAO’s DAO, in order to safeguard the peg while optimizing utilization.</p><h4>Bad Debt &amp; Liquidation</h4><p>Users are incentivized to repay their debt as long as the value of the collateral is greater than the debt.</p><p>If the collateral’s value drops below the borrowed amount, the protocol faces bad debt, resulting in systemic losses.</p><p>To prevent this, the protocol must liquidate the collateral and repay the debt, before the collateral value drops under the break-even point.</p><p>If the protocol cannot liquidate the collateral in time, the stablecoin issued by the protocol could not be 100% backed anymore and its price would depeg.</p><h4>Defending the Peg</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*1P9synocvUWimismiUYGKQ.png" /><figcaption>DAI price chart</figcaption></figure><p>An analysis of DAI’s price history reveals two distinct periods, one with a lot of of volatility at the beginning, and a second one where the peg has been very stable since then.</p><p>Initially, MakerDAO relied on adjusting borrowing rates and leveraging arbitrage to maintain the peg.</p><p>However, this approach proved insufficient during events like Black Thursday, when DAI liquidity was needed to close borrowing positions, and DeFi Summer, when stablecoins were in high demand.</p><h4>Price Stability Module &amp; USDC</h4><p>In response, MakerDAO introduced the Price Stability Module (PSM), enabling the minting of DAI against USDC at a 1–1 ratio, effectively capping the DAI price at 1 USDC.</p><p>This strategy led to a situation where up to 80% of the MakerDAO treasury backing DAI comprised USDC, raising concerns about decentralization and risk management.</p><h4>Usage</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*tIKVsECvAyvumzFuimIM3A.png" /></figure><p>There were 2 primary strategies when opening a MakerDAO’s position:<br>- leverage: mint DAI, sell DAI, buy more ETH or another altcoin<br>- lending: mint DAI at 1%, lend it at 5% on platforms like Compound</p><h4>Conclusion</h4><p>While the initial version of MakerDAO achieved significant success, the current DeFi landscape presents new challenges.</p><p>New factors such as the availability of staked ETH and alternative investment options like T-Bills at 5% APY have reshaped MakerDAO’s role in today’s ecosystem.</p><p><em>If you liked this article, please share and subscribe !<br>Looking for a blockchain expert ? Let’s connect on </em><a href="https://www.linkedin.com/in/guillaumebonnot/"><em>LinkedIn</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9baf0fe2860e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[DeFi] Tomb.Finance : FTM on steroids with farming & auto-compounding using Grim.Finance]]></title>
            <link>https://medium.com/@bonnotguillaume/defi-tomb-finance-ftm-on-steroids-with-farming-auto-compounding-using-grim-finance-9b40bb57c108?source=rss-e088db98aabe------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b40bb57c108</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[fantom]]></category>
            <category><![CDATA[yield-farming]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[tomb-finance]]></category>
            <dc:creator><![CDATA[Guillaume Bonnot]]></dc:creator>
            <pubDate>Sat, 04 Dec 2021 20:29:21 GMT</pubDate>
            <atom:updated>2021-12-04T20:29:21.914Z</atom:updated>
            <content:encoded><![CDATA[<h3>[DeFi] Tomb.Finance : FTM on steroids with farming &amp; auto-compounding using Grim.Finance</h3><p><em>In this article, I explain how to get insane APR for your FTM via staking and auto-compounding using tomb.finance and grim.finance.</em></p><h4>Fantom (FTM)</h4><p>Fantom is currently one the <strong>best </strong>performing blockchain, thank to its very <strong>cheap </strong>transaction fees and <strong>fast </strong>confirmation time.</p><blockquote>Fantom is a fast, high-throughput open-source smart contract platform for digital assets and dApps.</blockquote><p>Fantom has built a lot of <strong>traction </strong>lately because of the many great <strong>Dapps </strong>that were build on it. This has been made possible because Fantom is <strong>EVM </strong>compatible, meaning than any Ethereum <strong>smart-contract</strong> can also be deployed on this chain.</p><blockquote>FTM is the primary token on the Fantom network. FTM is used for securing the network through staking, for governance, for payments, and for fees.</blockquote><p>FTM is a very useful token, and many people want to <strong>hold </strong>it as they expect its value to <strong>rise </strong>with the <strong>adoption </strong>of the Fantom blockchain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*pgR33hCMD9SJZNL2il8PgA.jpeg" /></figure><p>In fact, FTM is so <strong>useful </strong>that most people don&#39;t want get rid of it and this has led to huge <strong>liquidity </strong>issues, especially when dealing with blockchain <strong>bridges</strong>, or simply <strong>withdrawing </strong>FTM from exchanges.</p><p>But those liquidity issues could <strong>soon </strong>become a thing of the past…</p><h4>Tomb Finance</h4><p>Tomb Finance is a <strong>DeFi</strong> platform on Fantom Opera network which <strong>goal </strong>is to create a token (TOMB) <strong>pegged </strong>1-to-1 to FTM and highly <strong>liquid</strong>.</p><p>Algorithmic stablecoins are a <strong>revolution </strong>in the DeFi world and if you are not familiar with the concept, you should definitely take a look at the <a href="https://www.olympusdao.finance/">Olympus DAO (OHM)</a> project. <em>Disclaimer : </em><strong><em>do not</em></strong><em> invest in OHM if you don’t know what you are doing, and spoiler : you clearly don’t know what you are doing.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7l_jwTC_bcwTbcJSfcZj_w.png" /></figure><p>Tomb Finance uses advanced <strong>tokenomics </strong>in order to eventually maintain this peg. There are complex <strong>interactions </strong>between the 3 different assets :</p><ul><li>TOMB : will be <strong>pegged </strong>with FTM at the end of the <strong>expansion </strong>phase when all the TOMB have been printed (<strong>inflation</strong>), don’t hold this token, <strong>stake </strong>it.</li><li>TSHARE : represents a claim<strong> </strong>to a <strong>share </strong>of the TOMB that will be <strong>printed </strong>during the <strong>expansion </strong>phase (hold when 1 TOMB &gt; 1 FTM).</li><li>TBOND : used to buy TOMB at a <strong>discount </strong>when 1 TOMB &lt; 1 FTM.</li></ul><p>Let’s see in more details what is the <strong>role </strong>of each asset in the protocol.</p><h4>Tomb (TOMB)</h4><p>TOMB is an <strong>algorithmic </strong>stablecoin on Fantom Opera, <strong>pegged </strong>to the price of 1 FTM via seigniorage, it is automatically <strong>devaluated </strong>when above the peg.</p><blockquote>TOMB token is designed to be used as a medium of exchange. The built-in stability mechanism in the protocol aims to maintain Tomb’s peg to 1 Fantom (FTM) token in the long run.</blockquote><p>The <strong>long term</strong> goal of Tomb is indeed to be <strong>pegged </strong>1-to-1 with FTM, so the Tomb token can be used <strong>cross-chain</strong> without impacting the Fantom Opera network where FTM resides.</p><p>But, we are not there yet, the tomb.finance protocol is still very <strong>young </strong>and we are now in the <strong>expansion phase</strong>. During the expansion phase, users are <strong>incentivized </strong>to buy TOMB at a <strong>premium </strong>(&gt;1 FTM), so they can take advantage of the <strong>initial distribution</strong> mechanism.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DU-FddugcCVpEK3ESNrwow.png" /></figure><p>During the expansion phase, the protocol is literally printing TOMB tokens and distribute them to <strong>TSHARE </strong>holders, so holders of TOMB are incentivized to use their TOMB tokens by <strong>staking </strong>them in order to mitigate <strong>inflation</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BmwLDqpz9dbMLPNtNGmb7A.png" /></figure><p>The best way to <strong>stake </strong>TOMB is to use the TOMB-FTM <strong>liquidity pool</strong> on <a href="https://spookyswap.finance/">SpookySwap</a> and then deposit those LP tokens into the <a href="https://tomb.finance/cemetery/TombFtmLPTShareRewardPool">cemetery</a> and earn <strong>TSHARE </strong>as an extra reward.</p><h4>Tomb Shares (TSHARE)</h4><p>TSHARE represents a <strong>share </strong>of all the TOMB that will be minted in the <strong>future</strong>.<br>TSHARE should be the most <strong>valuable </strong>asset during the <strong>expansion </strong>phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*agDg4CUGKfCSqfnwLwn6tw.png" /></figure><p>When TOMB price is <strong>above </strong>the peg, the protocol will distribute freshly <strong>minted </strong>TOMB tokens to those who <strong>staked </strong>TSHARE in the <a href="https://tomb.finance/masonry">masonry</a>, this inflationary mechanism will <strong>gradually </strong>push the price back to a 1-to-1 peg.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bxczko23w1NRW8svkdKr4A.png" /></figure><p>Another way to <strong>stake </strong>TSHARE is to use the TSHARE-FTM <strong>liquidity pool</strong> on <a href="https://spookyswap.finance/">SpookySwap</a> and then deposit those LP tokens into the <a href="https://tomb.finance/cemetery/TshareFtmLPTShareRewardPool">cemetery</a> and earn even <strong>more </strong>TSHARE<strong> </strong>as an extra reward.</p><h4>Tomb Bonds (TBOND)</h4><p>TBOND is a token sold by the protocol when the TOMB price is <strong>under </strong>the peg.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*seOvqARR1lUOvbXRGj82VQ.png" /></figure><p>TBOND can be purchased in the <a href="https://tomb.finance/pit">pit</a> as TOMB with a <strong>discount</strong>. TOMB used to buy the TBOND are <strong>burned</strong>, driving the price up by reducing the supply.</p><p>TBOND can be <strong>redeemed </strong>when the TOMB price is back to the peg. TBOND holders are incentivized to <strong>hold </strong>their token even longer, as the TOMB reward <strong>increases </strong>quadratically with the current price.</p><h4>Game Theory</h4><p>The <a href="http://tomb.finance/">tomb.finance</a> protocol is very <strong>complex </strong>but it can be broken down :</p><ul><li>When TOMB price is <strong>over the peg</strong>, TOMB holders get <strong>diluted </strong>in favor of TSHARE holders as new TOMB are minted to drive the price <strong>down</strong>.</li><li>When TOMB price is <strong>at the peg</strong>, TOMB holders can use the TOMB-FTM liquidity pool to increase their <strong>yield </strong>on FTM without the risk of <strong>impermanent loss</strong>. At this point, TSHARE are <strong>worthless </strong>because no TOMB are printed anymore.</li><li>When TOMB price is <strong>under the peg</strong>, TOMB holders should buy TBOND to <strong>help </strong>the price return to the peg and benefit from the <strong>discount</strong>.</li></ul><p>Now, let’s analyze <strong>feedback </strong>loops between the different staking strategies :</p><p>When you <strong>stake </strong>TOMB, you <strong>receive </strong>TSHARE. If you <strong>sell </strong>THSARE to <strong>buy </strong>more TOMB, you drive the TOMB price <strong>up</strong>, making TSHARE more valuable through <strong>rebases </strong>while making your TOMB less valuable in the mean time.</p><p>When you <strong>stake </strong>TSHARE, you <strong>receive </strong>TOMB. If you <strong>sell </strong>TOMB to <strong>buy </strong>more TSHARE, you drive the TOMB price <strong>down</strong>, making your TSHARE less valuable by <strong>reducing </strong>the emissions of new TOMB.</p><p>When you <strong>buy </strong>TBOND, the TOMB are <strong>burned</strong>, reducing the supply and you drive the TOMB price <strong>up</strong>, making your TBOND more <strong>valuable </strong>if other people decide to <strong>cooperate </strong>and are also bonding with you.</p><p>Over the long run, approximately one year after the launch, the expansion phase will <strong>stop </strong>and the TOMB price should <strong>eventually </strong>remain at the peg.<br>At this time, TSHARE will be <strong>worthless </strong>because the inflation stopped.</p><h4>Yield Farming</h4><p>The best<strong> yield aggregator</strong> for tomb.finance is grim.finance.<br>Grim will help to dramatically increase your ROI by automatically <strong>compounding </strong>the farming rewards you get when staking or providing liquidity. This is the best way to achieve <strong>insane </strong>APY on new protocols.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SDcuhdEAEPKzC-XlEyqooQ.png" /></figure><p>The TOMB-FTM liquidity pool strategy is the best way to achieve <strong>consistent </strong>returns over a <strong>long </strong>period of time. <strong>Beware</strong>, do not enter this strategy when the TOMB price is <strong>too high</strong> because you will suffer <strong>impermanent loss</strong> when the price ultimately goes back to peg.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dJSP9UGf0E5M55xnK5lstw.png" /></figure><p>The TSHARE-FTM liquidity pool strategy is a good way to <strong>boost </strong>your potential returns if you think the expansion phase will continue for a while. <strong>Beware</strong>, you need to <strong>exit </strong>this strategy <strong>before </strong>the expansion phase stops and your TSHARE become <strong>worthless</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nl6wzbFpSaTlDhlpM48Lrw.png" /></figure><p>This strategy is by far the most <strong>risky</strong>, it is make or break. YOLO !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XlHFxJo2GG34vnwckFOGRA.png" /></figure><p>To be frank, I don&#39;t know what to think about this strategy but it is <strong>sexy</strong>.<br>On one hand, it makes perfect sense to play it <strong>both ways</strong>, but if you take a <strong>min-max</strong> approach, then this should be the <strong>worst </strong>choice as it should <strong>underperform </strong>compared to the best strategy.</p><p>Determining the <strong>best </strong>strategy is the main problem here :</p><ul><li>if the protocol is a <strong>great success</strong>, then definitely go for TSHARE !</li><li>if you are in for the <strong>long run</strong>, then steadily increase your TOMB !</li><li>if you don’t want to make a choice, you could <strong>try </strong>the 60/40 strategy.</li></ul><p>Independently of the choice you will make, remember that DeFi is still <strong>young </strong>and this technology is <strong>immature </strong>. Only play what you can afford to loose !</p><p><em>If you liked this article, please share and subscribe !<br>Money is a sin, you can get absolution by sending it to my wallet :<br>FTM/TOMB/MIM: 0x1f356622Be58D6490269E16077ECd8B2Bf06fE56</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b40bb57c108" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[DeFi] Get +25% more CHNG in 45 days by writing call options in Chainge.Finance]]></title>
            <link>https://medium.com/@bonnotguillaume/defi-get-25-more-chng-in-45-days-by-writing-call-options-in-chainge-finance-ca59e9d6db65?source=rss-e088db98aabe------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca59e9d6db65</guid>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[decentralized-finance]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[fusion-network]]></category>
            <dc:creator><![CDATA[Guillaume Bonnot]]></dc:creator>
            <pubDate>Sun, 28 Nov 2021 14:31:33 GMT</pubDate>
            <atom:updated>2021-12-24T11:37:24.582Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this post, I describe step by step how to accumulate even more CHNG using the write option features from chainge.finance mobile app.</em></p><h4>Strategy Overview</h4><p>This accumulation strategy is based on 2 assumptions :</p><ul><li>CHNG price will go up in the future (long/medium term)</li><li>CHNG price will not reach 0.16$ before 2021 (short term)</li></ul><p>Based on those assumptions, the best move is to <strong>increase </strong>the amount of CHNG you are currently <strong>hodling</strong>. In other words, <strong>accumulate </strong>in 2021 before CHNG goes to the <strong>moon </strong>on 2022.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*IhGIDJd3FkfdgQGzht2VKw.jpeg" /></figure><p>In order to execute this strategy, it is important to check that the CHNG <strong>call option</strong> (CHNG-CO) is deeply <strong>OTM </strong>(Out of The Money) but still with a good <strong>premium</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c35GS5a2bEaM4anQFCGlbA.jpeg" /></figure><p>With a current <strong>spot price</strong> of 0.077$ USDT/CHNG and an <strong>exercise price</strong> of 0.16$, the CHNG price would have to more than <strong>double </strong>in 45 days for the option to <strong>expire </strong>ITM (In The Money).</p><p>The current <strong>premium </strong>is 0.018$ which is a great <strong>opportunity </strong>since it represents 23% of the price of the underlying asset. This means that you can use this money to <strong>buy </strong>even <strong>more </strong>CHNG after you have sold the options.</p><p>Since we are <strong>already holding</strong> CHNG, writing options against it would only make us <strong>miss out </strong>if the price goes over 0.16$. Basically, by taking this strategy, we agree to <strong>limit </strong>our profit to only <strong>double </strong>our initial investment, in case the underlying asset <strong>over perform</strong> on this very <strong>limited </strong>time-frame.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7gfY_bqXkv5ccWps5AeCXQ.jpeg" /></figure><p>I will show you a <strong>step by step</strong> break down of the strategy using an initial investment of 1000 CHNG worth 77$ at the time.</p><h4>Step 1: Exchange CHNG for TF-CHNG</h4><p>The <strong>most popular feature</strong> of the <strong>Chainge.Finance</strong> app is called <strong>Earn</strong>. It allows you to <strong>lock </strong>your tokens until the end of the year and receive <strong>extra tokens</strong> (5–10% APY). You can compare this feature to <strong>staking</strong>, except it is way more than that !</p><p><em>Technical details:<br>Chainge is built on top the </em><strong><em>Fusion </em></strong><em>blockchain which has a super cool feature called </em><strong><em>Time Frame</em></strong><em>, which we are not going to explain here, which basically allows you to </em><strong><em>split </em></strong><em>your token in two parts : </em><strong><em>first part</em></strong><em> represents the token from now to the end of the year, </em><strong><em>second part</em></strong><em> represents the token after the end of the year. The trick is that you can </em><strong><em>lend </em></strong><em>the part before the end of the year for a </em><strong><em>profit </em></strong><em>and </em><strong><em>keep </em></strong><em>the second part for yourself because the token will be made </em><strong><em>whole </em></strong><em>again when the first </em><strong><em>expires </em></strong><em>at the end the year.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rma5pM_hdHZseex-nBxsrw.jpeg" /></figure><p>As a first step, I exchanged 1000 CHNG for 1021 TF-CHNG (+2.1%). So basically, I exchanged CHNG <strong>now </strong>for 2.1% more CHNG in the <strong>future </strong>(they will become CHNG on 01/01/2022). In order to get a <strong>better rate</strong>, I did not use the <strong>Earn </strong>feature, instead I directly use the Decentralized Exchange (<strong>DEX</strong>) to <strong>swap </strong>CHNG against TF-CHNG because it offered me a better rate.</p><h4>Step 2: Write CHNG Call Options</h4><p>Another <strong>great feature</strong> of the <strong>Chainge.Finance</strong> app is the possibility to <strong>write </strong>and<strong> exchange </strong>PUT &amp; CALL <strong>options</strong>.</p><blockquote><em>A call option gives the holder the right to buy a stock and a put option gives the holder the right to sell a stock. Think of a call option as a down payment on a future purchase.</em></blockquote><p>You can use your TF-CHNG (future) to write CHNG <strong>call options</strong>. Those options will be displayed on the app as “<strong>Written</strong>” CHNG-CO, it represents <strong>both </strong>the call-option and its counterparty. The call option <strong>CHNG-CO</strong> can be <strong>sold </strong>on the market, and the <strong>writer </strong>will now only hold the <strong>counterparty </strong>of the option. The “<strong>Written</strong>” option (<strong>CHNG-WCO</strong>) will become “<strong>Redeemable</strong>”(<strong>CHNG-RCO</strong>).</p><blockquote><em>TF-CHNG -&gt; CHNG-WCO -&gt; CHNG-CO + CHNG-RCO</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_VJYmG7qD--6MI8v2ihC5g.jpeg" /></figure><p>The <strong>call options</strong> on CHNG(CHNG-CO) have an <strong>exercising price</strong> of 0.16$ and can be <strong>exercised </strong>until 31/12/2021 and will <strong>expire </strong>on 01/01/22. The owner of CHNG-CO has the right to <strong>exercise </strong>the option <strong>anytime </strong>before expiration. Exercising the CHNG-CO option forces the <strong>writer </strong>of the option to <strong>sell </strong>TF-CHNG to the holder of the option at the <strong>predetermined </strong>price of 0.16$/TF-CHNG. If the option is <strong>not exercised</strong> before it expires, the <strong>writer </strong>of the option <strong>gets back</strong> the underlying TF-CHNG <strong>collateral </strong>that will become CHNG since both futures and options are settled at the <strong>same date</strong>.</p><p>As a second step, I used my TF-CHNG to <strong>write </strong>CHNG call options, which means that I transformed my 1021 TF-CHNG into 1021 CHNG-WCO.</p><h4>Step 3: Sell CHNG Call Options</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iv7yH6W-_QN8iG5n7pLbEg.jpeg" /></figure><p>As a third step, I sold 1021 CHNG-CO<strong> </strong>for 18.42 USDT @ 0.018 USDT/CHNG-CO, by selling the associated CHNG-CO, my CHNG-WCO became CHNG-RCO.<br>I now have 1021 CHNG-RCO and 18.42 USDT.</p><h4>HODL</h4><p>Usually, I would have used those 18.42$ to buy <strong>more </strong>CHNG (+24%) and go for <strong>another round</strong> of writing and selling call options, like described in this article :</p><p><a href="https://medium.com/@bonnotguillaume/defi-how-to-secure-25-roi-in-2-months-using-chainge-finance-97e9358e4f74">[DeFi] How to secure 25% ROI in 2 months using Chainge.Finance</a></p><p>But in this article, I want to show something else and instead of being bullish and increasing our exposure, we will be <strong>cautious </strong>and limit our risk.</p><h4>Step 4: Buy CHNG Put Options</h4><p>Put options (CHNG-PO) are going to <strong>protect </strong>us from taking more <strong>losses </strong>if the price is under 0.06 USDT/CHNG.</p><p>For a small <strong>fee </strong>(premium), we will be able to <strong>sell </strong>our CHNG at the price of 0.06$ if the market <strong>crashes</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EkfxErRSM0q0WYomwQqW1g.jpeg" /></figure><p>As a forth step, I bought1021 CHNG-PO<strong> </strong>for 8.90 USDT @ 0.018 USDT/CHNG-PO. I now have 1021 CHNG-RCO, 1021 CHNG-PO and 9.52 USDT.</p><h3>Profits &amp; Losses</h3><p>With an <strong>initial investment</strong> of 1000 CHNG (77.11$), I am have now 1021 CHNG-RCO, 1021 CHNG-PO and 9.52 USDT.</p><p>For those options, there are only 3 possible <strong>outcomes </strong>on 31 December 2021:</p><p><em>Scenario 1 : </em>CHNG <em>&gt; 0.16$</em></p><p>The 1021 CHNG-RCO will be <strong>exercised </strong>for 0.16$ each and I will <strong>receive </strong>163.36<strong> </strong>USDT, making a whooping 95.77$ (<strong>+126%</strong>) profit in 45 days !</p><p><em>Scenario 2 : </em>CHNG <em>&lt; 0.06$</em></p><p>I will <strong>exercise </strong>my 1021 CHNG-PO and sell my 1021 CHNG @ 0.06$ and get 61.26$, making a total of 70.78$ and a limited loss of only 6.33$ (<strong>-8.2%</strong>).</p><p>Scenario 3 : <em>0.06$ &lt; </em>CHNG &lt; <em>0.16$</em></p><p>This is the second best scenario, you now have more 1021 CHNG (<strong>+2.1%</strong>) and some USDT (9.52$) that you should have already reinvested to either buy more CHNG or on an another opportunity.</p><p>Let’s <strong>simplify </strong>this and estimate the <strong>profit </strong>to be exactly 9.52$ (<strong>+12%</strong>).</p><h4>Conclusion</h4><p>There are a lot of <strong>opportunities </strong>on DeFi because we are very <strong>early </strong>and the market is still <strong>inefficient</strong>. We can take advantage of those <strong>discrepancies </strong>and build very <strong>safe </strong>investing strategies with <strong>high return</strong> !</p><p>There are a lot of <strong>free lunches</strong> in Defi, follow me if you want more !</p><p><em>If you liked this article, please share and subscribe !<br>Please consider sharing the free money you get using the Chainge app, this is my wallet address where you can send me some CHNG :<br>FSN/ETH/BSC : 0x3196E6442C9380B0855e80dd470B4D72A14f4777</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca59e9d6db65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[DeFi] How to secure 25% ROI in 2 months using Chainge.Finance]]></title>
            <link>https://medium.com/@bonnotguillaume/defi-how-to-secure-25-roi-in-2-months-using-chainge-finance-97e9358e4f74?source=rss-e088db98aabe------2</link>
            <guid isPermaLink="false">https://medium.com/p/97e9358e4f74</guid>
            <dc:creator><![CDATA[Guillaume Bonnot]]></dc:creator>
            <pubDate>Wed, 03 Nov 2021 18:02:44 GMT</pubDate>
            <atom:updated>2021-11-14T14:41:12.369Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this post, I describe step by step how I secured a 25% ROI for my initial 1000$ investment using advanced features from chainge.finance mobile app.</em></p><h4>Overview</h4><p>Using the <strong>Chainge.Finance </strong>app, I spotted a good financial opportunity between the <strong>spot</strong>, <strong>futures </strong>and call <strong>options </strong>prices for BNB. Those are quite <strong>advanced </strong>financial instruments that can used to maximize your <strong>profits</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*NDjpN27LyA8OJrLzoUA-BQ.jpeg" /></figure><blockquote>Chainge is <strong>a DeFi app running on the Fusion blockchain</strong> that empowers people from all corners of the world to become their own digital bank. With Chainge’s automated financial services, users have complete control over their wealth while enjoying 100% freedom &amp; security.</blockquote><p>This <strong>strategy </strong>can be broken down in <strong>5 steps</strong> :</p><ul><li>Buy spot</li><li>Exchange for futures</li><li>Write Call options</li><li>Sell Call options</li><li>Repeat</li><li>Profit !</li></ul><p>Let’s see how this went out !</p><h4>Step 1 : Buy BNB on Binance</h4><p><strong>Binance </strong>is often the best place to buy cryptocurrencies, they provide great <strong>liquidity </strong>so you will always get the <strong>best price</strong>, they also offer a large choice of tokens and you can use the Binance Smart Chain (<strong>BSC</strong>) to make <strong>cheap transfers</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZH97Pf35zBx1FpBEO4APuA.jpeg" /></figure><p>As a first step, I bought 1.8925 BNB for 1000 USDT @ 528.4 BNB/USDT.<br>Once I got my BNB , I transferred from Binance to my Chainge wallet.</p><h4>Step 2 : Exchange BNB for TF-BNB</h4><p>The <strong>most popular feature</strong> of the <strong>Chainge.Finance</strong> app is called <strong>Earn</strong>. It allows you to <strong>lock </strong>your tokens until the end of the year and receive <strong>extra tokens</strong> (5–10% APY). You can compare this feature to <strong>staking</strong>, except it is way more than that !</p><p><em>Technical details:<br>Chainge is built on top the </em><strong><em>Fusion </em></strong><em>blockchain which has a super cool feature called </em><strong><em>Time Frame</em></strong><em>, which we are not going to explain here, which basically allows you to </em><strong><em>split </em></strong><em>your token in two parts : </em><strong><em>first part</em></strong><em> represents the token from now to the end of the year, </em><strong><em>second part</em></strong><em> represents the token after the end of the year. The trick is that you can </em><strong><em>lend </em></strong><em>the part before the end of the year for a </em><strong><em>profit </em></strong><em>and </em><strong><em>keep </em></strong><em>the second part for yourself because the token will be made </em><strong><em>whole </em></strong><em>again when the first </em><strong><em>expires </em></strong><em>at the end the year.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UmljYlRC9tRddlWX8MNEUQ.jpeg" /></figure><p>As a second step, I exchanged 1.8968 BNB for 2 TF-BNB (+5,4%). So basically, I exchanged BNB <strong>now </strong>for 5,4% more BNB in the <strong>future </strong>(they will become BNB on 01/01/2022). In order to get a <strong>better rate</strong>, I did not use the <strong>Earn </strong>feature, instead I directly use the Decentralized Exchange (<strong>DEX</strong>) to <strong>swap </strong>BNB against TF-BNB because it offered me a better rate.</p><h4>Step 3 : Write BNB Call Options</h4><p>Another <strong>great feature</strong> of the <strong>Chainge.Finance</strong> app is the possibility to <strong>write </strong>and<strong> exchange </strong>PUT &amp; CALL <strong>options</strong>.</p><blockquote>A call option gives the holder the right to buy a stock and a put option gives the holder the right to sell a stock. Think of a call option as a down payment on a future purchase.</blockquote><p>You can use your TF-BNB (future) to write BNB <strong>call options</strong>. Those options will be displayed on the app as “<strong>Written</strong>” BNB-CO, it represents <strong>both </strong>the call-option and its counterparty. The call option <strong>BNB-CO</strong> can be <strong>sold </strong>on the market, and the <strong>writer </strong>will now only hold the <strong>counterparty </strong>of the option. The “<strong>Written</strong>” option (<strong>BNB-WCO</strong>) will become “<strong>Redeemable</strong>”(<strong>BNB-RCO</strong>).</p><blockquote>TF-BNB -&gt; BNB-WCO -&gt; BNB-CO + BNB-RCO</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sgVPOhbrnzyKurkRXpTjXQ.jpeg" /></figure><p>The <strong>call options</strong> on BNB (BNB-CO) have an <strong>exercising price</strong> of 480$ and can be <strong>exercised </strong>until 31/12/2021 and will <strong>expire </strong>on 01/01/22. The owner of BNB-CO has the right to <strong>exercise </strong>the option <strong>anytime </strong>before expiration. Exercising the BNB-CO option forces the <strong>writer </strong>of the option to <strong>sell </strong>TF-BNB to the holder of the option at the <strong>predetermined </strong>price of 480$/TF-BNB. If the option is <strong>not exercised</strong> before it expires, the <strong>writer </strong>of the option <strong>gets back</strong> the underlying TF-BNB <strong>collateral </strong>that will become BNB since both futures and options are settled at the <strong>same date</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xnn_RoUIfAKcs3qxET46dg.jpeg" /></figure><p>As a third step, I used my TF-BNB<strong> </strong>to <strong>write </strong>BNB call options, which means that I transformed my 2 TF-BNB into 2 BNB-WCO.</p><h4>Step 4 : Sell BNB Call Options</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*weWznig0nzMqE8McIQ7gOQ.jpeg" /></figure><p>As a forth step, I sold 2 BNB-CO<strong> </strong>for 246.32 USDT @ 123.16 USDT/BNB-CO, by selling the associated BNB-CO, my BNB-WCO became BNB-RCO.<br>I now have 2 BNB-RCO and 246.32 USDT.</p><h4>Step 5 : Rinse &amp; Repeat</h4><p>You can <strong>repeat </strong>the operation <strong>several times </strong>using the cash you got from selling the call options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5mI5TbszxbJt-2Z8p1wLBA.jpeg" /></figure><p>As a fifth step, I used my 246.32 USDT to buy BNB, <strong>etc</strong>… After <strong>several rounds</strong>, I finally have 2.6339 BNB-RCO.</p><h4>Profits &amp; Losses</h4><p>With an <strong>initial investment</strong> of 1000$, I am have now 2.6339 BNB “Redeemable” Call Options.</p><p>For those options, there are only 2 possible <strong>outcomes </strong>on 31 December 2021:</p><p><em>Scenario 1 : BNB &gt; 480$</em></p><p>The 2.6339 BNB-RCO will be <strong>exercised </strong>for 480$ each and I will <strong>receive </strong>1264.27 USDT, making a whooping 264.27$ (<strong>+26%</strong>) profit in 2 months !</p><p><em>Scenario 2 : BNB &lt; 480$</em></p><p>The 2.6339 BNB-RCO will <strong>not </strong>be exercised and I will have 2.6339 BNB. However, in order to <strong>break even</strong> the price must remain higher than 380$.<br>If the BNB price is higher than $380, I will make a <strong>profit</strong>. Otherwise if the BNB price is lower than $, I will take a <strong>loss</strong>.</p><p>But I <strong>bet </strong>that scenario will not happen ! Oh wait… I just did !</p><h4>Scouting Good Opportunities</h4><p>This <strong>strategy </strong>consist in looking for <strong>Call Options</strong> which are already In The Money (<strong>ITM</strong>) and are offering you a good premium :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d3CZUvZu6ecswp7kap5hvw.jpeg" /><figcaption>Juicy 43$ premium !</figcaption></figure><blockquote>exercising price + option price &gt;&gt; spot price</blockquote><p>The <strong>premium </strong>is the main source of <strong>profit </strong>for this strategy.</p><blockquote>premium = exercising price + option price - spot price</blockquote><p>By choosing an option with a spot price <strong>way higher</strong> than the exercising price, you will get 2 <strong>benefits </strong>:</p><ul><li><strong>decrease </strong>the <strong>risk </strong>of taking a loss by having the option being out of the money (OTM) at the time it expires</li><li><strong>increase </strong>the <strong>cash </strong>you will get back by selling the option and used it for another round</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hLYkMIaRbPFfWt46Kcheig.jpeg" /><figcaption>5.5% more BNB over 2 months ! Great success !</figcaption></figure><p>Another important factor for this strategy is to find tokens with good TF <strong>APY</strong>. Even a <strong>small percentage</strong> made when exchanging your token for a <strong>future </strong>can <strong>substantially increase</strong> the potential <strong>profits </strong>you will get !</p><p><strong>Bonus</strong></p><p>Here is the <strong>spreadsheet </strong>I made that helped me finding this <strong>opportunity </strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_9pZ-g5_c7nN1XnJ-L8VxQ.png" /></figure><p>The numbers are quite <strong>optimistic </strong>because they don’t take into account the <strong>slippage</strong>, however, the profits are not taking into account subsequent rounds using the remaining capital that has not been locked on the first iteration.</p><p>It’s worth noting that I could not use this strategy for Chainlink because of the lack of liquidity ! Next time, maybe ?</p><p><em>If you liked this article, please share and subscribe !<br>Please consider sharing the free money you get using the Chainge app, this is my wallet address where you can send me some CHNG :<br>FSN/ETH/BSC : 0x3196E6442C9380B0855e80dd470B4D72A14f4777</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97e9358e4f74" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Blockchain] Introduction to the Hyperledger ecosystem]]></title>
            <link>https://medium.com/@bonnotguillaume/blockchain-introduction-to-the-hyperledger-ecosystem-23279a090c4f?source=rss-e088db98aabe------2</link>
            <guid isPermaLink="false">https://medium.com/p/23279a090c4f</guid>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[hyperledger]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[distributed-ledgers]]></category>
            <dc:creator><![CDATA[Guillaume Bonnot]]></dc:creator>
            <pubDate>Sat, 12 Jun 2021 16:16:30 GMT</pubDate>
            <atom:updated>2021-06-12T16:16:30.506Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this article, we will explore the Hyperledger blockchain ecosystem and see how it contributes to the open source community.</em></p><h4>Overview</h4><p>Hyperledger is an ecosystem of open source blockchain projects and related tools hosted by the Linux Foundation. Hyperledger is the result of the collaboration from the blockchain industry to produce standardized modules that can be used in the development of blockchain-based distributed ledgers.</p><blockquote>Only an Open Source, collaborative software development approach can ensure the transparency, longevity, interoperability and support required to bring blockchain technologies forward to mainstream commercial adoption. That is what Hyperledger is about — communities of software developers building blockchain frameworks and platforms.</blockquote><p>Hyperledger provides an alternative to the cryptocurrency-based blockchain model, and focuses on developing blockchain frameworks, tools and libraries to support global enterprise solutions. The focus of Hyperledger is to provide a transparent and collaborative approach to blockchain development.</p><p>The main goals of the Hyperledger initiative can be summarized in 3 points:</p><ul><li>Provide neutral, open, and community-driven infrastructures, supported by technical and business governance.</li><li>Create enterprise grade, open source, distributed ledger frameworks and code bases to support business transactions.</li><li>Educate the public about the market opportunity for blockchain technology.</li></ul><h4>Hyperledger Greenhouse</h4><p><a href="https://www.hyperledger.org/about">Hyperledger</a> incubates and promotes a range of business blockchain technologies, including distributed ledger frameworks, smart contract engines, client libraries, graphical interfaces, utility libraries, and sample applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YasaVkRtcDMrgVV56-JM4g.png" /></figure><p>Hyperledger projects follow a rigorous lifecycle process in 6 steps :</p><ul><li><strong>Proposal</strong></li><li><strong>Incubation</strong></li><li><strong>Active</strong></li><li><strong>First Major Release</strong></li><li><strong>Deprecated</strong></li><li><strong>End of Life</strong></li></ul><p>When a project goes through this rigorous vetting process, it signals to the public that they can now trust the code, that the code can be used to build applications upon it.</p><h4>Hyperledger Frameworks</h4><p>Hyperledger business blockchain frameworks are used to build enterprise DLT for a consortium of organizations. Hyperledger frameworks include:</p><ul><li>An append-only distributed ledger</li><li>A consensus algorithm for agreeing to changes in the ledger</li><li>Privacy of transactions through permissioned access</li><li>Smart contracts to process transaction requests.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*B0cmUjLaZGQ9IWeSlMu-GQ.jpeg" /></figure><h4>Hyperledger Fabric</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*tJfmymoQHorYRidnMyd4XQ.jpeg" /></figure><p><a href="https://www.hyperledger.org/projects/fabric">Hyperledger Fabric</a> is an open source, production ready, permissioned blockchain framework implementation that was designed to serve as a foundation for developing applications or solutions with a modular architecture.</p><p>Its modular architecture allows components such as consensus and membership services to be plug-and-play. It also features a powerful container technology to host any mainstream language for smart contract development.</p><p>One of the key advantages of Hyperledger Fabric is that it allows entities to conduct confidential transactions without passing information through a central authority.</p><h4>Hyperledger Sawtooth</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nUlXKw9ILHkUk2BIGjD-ng.png" /></figure><p><a href="https://www.hyperledger.org/projects/sawtooth">Hyperledger Sawtooth</a>, is an open source blockchain framework that utilizes a highly modular platform for building, deploying, and running distributed ledger applications and networks, making smart contracts safe, particularly for enterprise use.</p><p>Hyperledger Sawtooth introduced Proof of Elapsed Time (PoET) which is a scheduler based consensus algorithm using Intel’s specialized hardware SGX (Software Guard Extensions) to produce the proof the validator has waited a certain amount of time. SGX is a set of instructions included on Intel chips that allows applications to run trusted code in a protected environment.</p><h4>Hyperledger Besu</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*G_GQOQutk7huDrrSSKdCoA.png" /></figure><p><a href="https://www.hyperledger.org/use/besu">Hyperledger Besu</a> is an open source blockchain written in Java that is fully compatible with Ethereum and Implements the <a href="https://entethalliance.org/">Enterprise Ethereum Alliance</a> (EEA) specification. The blockchain is composed of several modules :</p><p>The Ethereum Virtual Machine (EVM), which allows deployment and execution of smart contracts via transactions within an Ethereum blockchain.</p><p>The Consensus Engine supports both Proof of Authority and Proof of Work.</p><h4>Hyperledger Burrow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z-NManyvH4wf6EYJkvGD-Q.png" /></figure><p>Hyperledger Burrow is a complete single-binary blockchain distribution focussed on simplicity, speed, and developer ergonomics. It supports both EVM and WASM based smart contracts and uses BFT consensus via the Tendermint algorithm.</p><h4>Conclusion</h4><p>Hyperledger has created a very mature ecosystem where the blockchain industry collaborate together in order to elaborate new standards that will be used as the foundation for Distributed Ledger Technology in the next decade.</p><p><em>This article was strongly inspired by this free course proposed by The Linux Foundation : </em><a href="https://www.edx.org/course/introduction-to-hyperledger-blockchain-technologie"><em>Introduction to Hyperledger Blockchain Technologies</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23279a090c4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Software Architecture] Id Sequence Number Obfuscation : Scrambler]]></title>
            <link>https://medium.com/@bonnotguillaume/software-architecture-id-sequence-number-obfuscation-scrambler-33a00b525459?source=rss-e088db98aabe------2</link>
            <guid isPermaLink="false">https://medium.com/p/33a00b525459</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Guillaume Bonnot]]></dc:creator>
            <pubDate>Fri, 21 Aug 2020 06:01:00 GMT</pubDate>
            <atom:updated>2020-08-21T06:01:00.982Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Software Architecture] Id Sequence Number Obfuscation : Scrambler</h3><p><em>In this article, we will analyze the answer found on the internet for the question : how to generate a reversible pseudo-random number from a sequence number.</em></p><h4>The Question</h4><p>Every user-facing application will have this existential problem :</p><ul><li>Users should be able to use a simple ID for each object.</li><li>Users should not be able to get the internal sequence ID.</li></ul><p>The commonly accepted solution is to use an external ID that will be public and an internal ID that will be private, and to use a reversible one-to-one function that can transform the given id into the other one.</p><pre>id == decode(encode(id))</pre><p>Let’s ask the internet on what could be such a function…</p><h4>The Answer</h4><p>Bingo ! We found something crystal clear and easy to implement :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6OYyF2OCeVs-2vFZjqqtdA.png" /><figcaption><a href="https://stackoverflow.com/questions/1537921/simple-pseudo-random-algorithm/23875298#23875298">https://stackoverflow.com/questions/1537921/simple-pseudo-random-algorithm/23875298#23875298</a></figcaption></figure><p>Now that we have the answer, we need to ask ourselves a new question :<br>Will it live up to our expectations ?</p><p>The truth is that most answers for your technical questions found on internet forums are utter trash, especially on stack-overflow… Sad but true !</p><p>We will to investigate if we want to find the truth.</p><h4>The Investigation</h4><p>The main lead for our investigation is this Germanic name : Tausworthe.</p><p>Let’s ask the internet once again :</p><blockquote>Tausworthe Generator is a kind of multiplicative recursive generator which produces random bits.</blockquote><p>Explanations from this <a href="https://homes.luddy.indiana.edu/kapadia/project2/node9.html">article</a> are very technical and seems to indicate that our mysterious function is not really a Tausworthe Generator.</p><p>However, here is a part of the article that seems really interesting :</p><blockquote>This results in a very fast, hardware-based implementation technique called Feedback Shift Register (FSR) which involves shift, AND, and XOR operations on a small set of k-bit registers.</blockquote><p>According to <a href="https://en.wikipedia.org/wiki/Linear-feedback_shift_register">Wikipedia</a> there are different types of Feedback Shift Register : Fibonacci, Gallois and Xorshift.</p><p>Xorshift… Yes, this is exactly what our function is doing.</p><blockquote>Xorshift random number generators are a class of pseudorandom number generators that were discovered by George Marsaglia. They are a subset of linear-feedback shift registers which allow a particularly efficient implementation without using excessively sparse polynomials. They generate the next number in their sequence by repeatedly taking the exclusive or of a number with a bit-shifted version of itself. This makes them extremely fast on modern computer architectures.</blockquote><p>Looks like the main culprit is not R.C. Tausworthe anymore but George Marsaglia. Nailed it !</p><p>So our mysterious function seems to really be a thing, even if it is based on a quite different use case :</p><pre>n+1 = xorshift(n)</pre><p>Let’s use it as a base for our scrambler !</p><h4>The Scrambler</h4><p>The scrambler has 2 functions encode and decode :</p><pre>external_id = encode(internal_id)<br>internal_id = decode(external_id)</pre><p>Let’s translate the pseudo code to fully functional C#.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7084f538c0ecf8db122df0cdff3ba8c9/href">https://medium.com/media/7084f538c0ecf8db122df0cdff3ba8c9/href</a></iframe><p>For some reason, you should avoid to use unsigned integers in most of your code, so we will be using an Int32 as a UInt31 and assume the input is positive. After every left shift, we need to reset the sign bit to zero.</p><p>You may wonder where I got the decode part from and you would be right, this is the next step of our journey, understanding how the sequence number is transformed and how it can be reversed.</p><p>We need to address the zero fixed point and add salt to our scrambler :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9c63b9fb7ed9bd64ab46faef81a9931/href">https://medium.com/media/c9c63b9fb7ed9bd64ab46faef81a9931/href</a></iframe><p>You can use different salt values to have different sequences in your project.</p><p>Let’s quickly test the implementation of our scrambler and empirically verify that every number that we encode can be decoded.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e91aac302750c0a2b060d13ee5d7656/href">https://medium.com/media/7e91aac302750c0a2b060d13ee5d7656/href</a></iframe><h4>The Analysis</h4><p>In order to have a better understanding of what our scrambler is doing, we need to be able to track and represent every bit of the seed number.</p><pre>0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...</pre><p>Because the first bit is always zero, we can represent zeros as the first bit (0).</p><p>We also need to represent each operation that will transform this array of bits.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/371c0ccb7404cfed704c33967dfdc66e/href">https://medium.com/media/371c0ccb7404cfed704c33967dfdc66e/href</a></iframe><p>If we apply a shift right operation for 1 bit on the seed number, we have :</p><pre>0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...</pre><p>The bit at position n has the value of bit of position n-1 of the seed number.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7df6724db7bc4fc2908b78da1a677b9c/href">https://medium.com/media/7df6724db7bc4fc2908b78da1a677b9c/href</a></iframe><p>We apply a xor operation on the seed number and the previous number :</p><pre>0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...<br>0 0 1 2 3 4 5 6 7 8 9  10 11 12 13 14 ...</pre><p>We can now see how the bits from the seed number are combined together.</p><p>XOR is a powerful operation with really interesting properties :</p><pre>A XOR A = 0<br>A XOR 0 = A<br>A XOR B XOR A = B</pre><p>Those properties will enable us to simplify the bits we are tracking.</p><p>Let’s describe the encoding and decoding algorithm using those operations :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3bd32765bef949637c402c618cb4aaad/href">https://medium.com/media/3bd32765bef949637c402c618cb4aaad/href</a></iframe><p>If the encoding and decoding implementations are correct, we expect the analysis pipeline output to be the initial seed number :</p><pre>0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...</pre><p>But first, let’s take a look at the encoding function :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-XCfuDVIaQqRk3dPuV7ulw.png" /></figure><p>To prove that no information was lost in the transformation, the output number must basically satisfy 2 conditions :</p><ul><li>Every bit of the seed number must be present in the output number.</li><li>Every bit of the output number must be a unique combination.</li></ul><p>Now that we have a clear understanding of the encoding function, we can create a decoding function that will set the bits back to their original position :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6q6dcPD0n8ib9yc2ikGX9g.png" /></figure><p>As expected, the output of the encoding and decoding pipeline gives us back the original number. Great success !</p><h4>The Conclusion</h4><p>Don’t believe everything you find on the internet, kids ! When you find something that sounds interesting, it is only the beginning of your journey. You need to find the source of the information and verify what is claimed.</p><p><em>The complete source code for the example can be found on </em><a href="https://github.com/guillaumebonnot/software-architecture/tree/master/Helios.Architecture.Scrambler/Helios.Architecture.Scrambler"><em>github</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33a00b525459" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Software Architecture] The Pipeline Design Pattern — From Zero to Hero]]></title>
            <link>https://medium.com/@bonnotguillaume/software-architecture-the-pipeline-design-pattern-from-zero-to-hero-b5c43d8a4e60?source=rss-e088db98aabe------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5c43d8a4e60</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[pipeline]]></category>
            <dc:creator><![CDATA[Guillaume Bonnot]]></dc:creator>
            <pubDate>Sat, 04 Apr 2020 06:52:30 GMT</pubDate>
            <atom:updated>2020-04-04T06:55:58.696Z</atom:updated>
            <content:encoded><![CDATA[<h3>[Software Architecture] The Pipeline Design Pattern — From Zero to Hero</h3><p><em>In this article, we will explore the different ways to implement the pipeline design pattern starting from the basics to more complex solutions.</em></p><h4>The Pipeline Pattern</h4><p>The pipeline pattern is a software design pattern that provides the ability to <strong>build </strong>and execute a <strong>sequence </strong>of operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*SKxf_rYg6akD7rQylffe6A.gif" /><figcaption><a href="https://www.hojjatk.com/2012/11/chain-of-responsibility-pipeline-design.html">https://www.hojjatk.com/2012/11/chain-of-responsibility-pipeline-design.html</a></figcaption></figure><p>This pattern is better used in conjunction with the <strong>plugin</strong> pattern, to <strong>dynamically </strong>build the <strong>pipeline </strong>when the application starts.</p><h4>Sequence</h4><p>The most basic implementation of a pipeline would be a simple sequence of operations.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e47186443325c3c16ecb1ba7a12f504/href">https://medium.com/media/6e47186443325c3c16ecb1ba7a12f504/href</a></iframe><p>The interface of an <strong>operation </strong>can be invoked to <strong>process </strong>data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5b716dc2455c05732adccf05da148d5/href">https://medium.com/media/d5b716dc2455c05732adccf05da148d5/href</a></iframe><p>The <strong>pipeline </strong>processes each operation <strong>one by one</strong>. The pipeline class is also implementing the IOperation interface so they can be <strong>combined</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/64b0671b653180eb09601aa89ab6f2d7/href">https://medium.com/media/64b0671b653180eb09601aa89ab6f2d7/href</a></iframe><p>The operation can be written in a dedicated <strong>class</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c542a29489cb8aee3eb87245a10a6fff/href">https://medium.com/media/c542a29489cb8aee3eb87245a10a6fff/href</a></iframe><p>Or use a <strong>wrapper</strong> to automatically create an operation from a <strong>lambda</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86d41f3886f60bf9435ec8bd2143c211/href">https://medium.com/media/86d41f3886f60bf9435ec8bd2143c211/href</a></iframe><p>The pipeline operations should be <strong>registered </strong>before the pipeline is invoked.</p><h4>Circuit Breaker</h4><p>The first <strong>feature </strong>you want to add to your pipeline is to add a <strong>circuit breaker</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1e01e7d59eeb67fc1f03bedfc1600cee/href">https://medium.com/media/1e01e7d59eeb67fc1f03bedfc1600cee/href</a></iframe><p>Each operation will return the result : <strong>fail </strong>or <strong>success</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3dfaa9b9992b0e6f150cd9525a95e091/href">https://medium.com/media/3dfaa9b9992b0e6f150cd9525a95e091/href</a></iframe><p>If an operation <strong>fails</strong>, the pipeline execution should <strong>stop</strong>.</p><h4>Asynchronous</h4><p>Another requirement could be to have a pipeline that can deal with <strong>asynchronous </strong>operations.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/22d37098b370be6784327751ab3ef496/href">https://medium.com/media/22d37098b370be6784327751ab3ef496/href</a></iframe><p>Every <strong>operation </strong>will now have to call the <strong>next </strong>operation in pipeline, <strong>after </strong>they are finished processing the data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9b4e217523058e4cedec14d7db6329fe/href">https://medium.com/media/9b4e217523058e4cedec14d7db6329fe/href</a></iframe><p>The <strong>pipeline </strong>is a bit more complex, because it need to set the <strong>next </strong>operation when a new operation is <strong>registered</strong>. Another solution is to use a <strong>builder</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84479b51608e78c7e18de46733ec2c34/href">https://medium.com/media/84479b51608e78c7e18de46733ec2c34/href</a></iframe><p>This operation is <strong>asynchronous </strong>and will run in a dedicated <strong>thread</strong>, when the time is out, it will invoke the <strong>next </strong>operation to continue the pipeline.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cddd3653b377f29e69d23ee12328b39/href">https://medium.com/media/1cddd3653b377f29e69d23ee12328b39/href</a></iframe><p>The generic operation can be used both with a simple <strong>action</strong>, or use a built-in <strong>circuit-breaker</strong> if you use a <strong>function</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b873a33cdcdc996f77fc362e7ef2f96/href">https://medium.com/media/6b873a33cdcdc996f77fc362e7ef2f96/href</a></iframe><p>This <strong>simple </strong>example uses several of the <strong>features </strong>we implemented.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*183-ZodKW37e8q7GpCVD8A.png" /></figure><p>Now you know how to make your pipeline <strong>asynchronous </strong>!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*viW_1b5vjuqPk50IvuHrrg.png" /></figure><p>It would be even better if had another callback to the <strong>previous </strong>operation so you could have the <strong>result </strong>going <strong>counter-flow</strong> through the pipeline.</p><h4>Plugin</h4><p>The main reason to use the pipeline design patter is often the <strong>requirement </strong>to be able to add <strong>plugins </strong>that will either <strong>append </strong>operations to an existing pipeline or to <strong>hook </strong>an operation in the middle of it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/272f71d3fc5e153c70a7d0d2247faeed/href">https://medium.com/media/272f71d3fc5e153c70a7d0d2247faeed/href</a></iframe><p>The pipeline is really <strong>basic</strong>, but this time, the operations are <strong>exposed</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8407a8f5850f42b42dc19568f1577e8/href">https://medium.com/media/e8407a8f5850f42b42dc19568f1577e8/href</a></iframe><p>Let’s take a simple application with a pipeline that will only display the 3 steps in the console. This application also supports <strong>plugins </strong>to modify the pipeline.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6cca0598cfaae74af94d652fd81e073/href">https://medium.com/media/a6cca0598cfaae74af94d652fd81e073/href</a></iframe><p>The first plugin will <strong>hook </strong>another operation in the second slot of the pipeline.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d8a71ca5382f11ca357e4e2f6c3a1a3/href">https://medium.com/media/5d8a71ca5382f11ca357e4e2f6c3a1a3/href</a></iframe><p>The second plugin will <strong>append </strong>a new operation at the end of the pipeline.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f1160f394d4dc07a322ab9a1603d65f0/href">https://medium.com/media/f1160f394d4dc07a322ab9a1603d65f0/href</a></iframe><p>The <strong>application </strong>and the <strong>plugins </strong>are put together, we can invoke the pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RdS8cRCVErwUNSFglrQpAA.png" /></figure><h4>Batch</h4><p>Another useful feature is to be able to process <strong>batch </strong>data in the <strong>same </strong>pipeline than <strong>single </strong>items.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6f410a7c0d6ecb290f471800b859530/href">https://medium.com/media/a6f410a7c0d6ecb290f471800b859530/href</a></iframe><p>The batch pipeline <strong>wraps </strong>a pipeline and calls <strong>every </strong>operation on <strong>every </strong>item.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e04a640604c289778647bc9f8c6b10ca/href">https://medium.com/media/e04a640604c289778647bc9f8c6b10ca/href</a></iframe><p>Every item is wrapped, so we can remember the result of the <strong>circuit breaker</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/77ad781abd66a9dee8002f45c3bcf2ad/href">https://medium.com/media/77ad781abd66a9dee8002f45c3bcf2ad/href</a></iframe><p>This operation <strong>checks </strong>if the integer has the required <strong>order of magnitude</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cddb10f2db590c4db5083839ed0147d/href">https://medium.com/media/1cddb10f2db590c4db5083839ed0147d/href</a></iframe><p>The <strong>pipeline </strong>is going to check the order of magnitude of a <strong>batch </strong>of integers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mVpHltG2vpEE5ZKrhAarAA.png" /></figure><p>The pipeline only invokes the <strong>next </strong>operation for items that did not <strong>failed</strong>.</p><h4>High Performance Pipeline</h4><p>The Pipeline Design Pattern can also be referring to a much more specific and <strong>performance </strong>oriented software architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ew47lWB9Ddxtsl-rj9b06A.png" /></figure><p>Some projects use a pipeline to <strong>optimize </strong>the processing of a huge amount of data by running each <strong>operation </strong>of the pipeline in a <strong>dedicated</strong> thread.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d74f2617e39e8856a2bcbfa86eea74fe/href">https://medium.com/media/d74f2617e39e8856a2bcbfa86eea74fe/href</a></iframe><p>Each thread will <strong>consume </strong>and <strong>produce </strong>data from a concurrent queue that will act a <strong>buffer</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc834f32becdc1a917cd5831ac3f4e63/href">https://medium.com/media/fc834f32becdc1a917cd5831ac3f4e63/href</a></iframe><p>This time, we will use <strong>asynchronous </strong>operations with a <strong>circuit-breaker</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96f0493c8fd85774363fd9fea72ab338/href">https://medium.com/media/96f0493c8fd85774363fd9fea72ab338/href</a></iframe><p>If the operation is <strong>successful</strong>, it should invoke <strong>next, </strong>or <strong>terminate </strong>if <strong>failed</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/deb50f7516c3847451d26034dea4f32a/href">https://medium.com/media/deb50f7516c3847451d26034dea4f32a/href</a></iframe><p>The <strong>pipeline </strong>is designed to <strong>bypass </strong>the <strong>circuit-breaker</strong>. Success or Fail, it will always continue the <strong>parent </strong>pipeline sequence and call the <strong>next </strong>operation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a85c63519510a5e2fff5b7245ccff9d0/href">https://medium.com/media/a85c63519510a5e2fff5b7245ccff9d0/href</a></iframe><p>The scenario is bit <strong>complex</strong>, so I won’t explain everything. The idea is to have different <strong>threads </strong>to <strong>process</strong> incoming <strong>orders</strong>. When an order is <strong>finished </strong>processing, we check the <strong>status </strong>of the order.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1a1ee77d66d80c848e73c0aeafea2243/href">https://medium.com/media/1a1ee77d66d80c848e73c0aeafea2243/href</a></iframe><p>Each order processor is isolated in a <strong>dedicated </strong>thread, so you can <strong>optimize </strong>how you store the data and have <strong>direct </strong>memory access <strong>without </strong>using <strong>lock</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a2a4a6f36471a33526efe4370629e0f/href">https://medium.com/media/5a2a4a6f36471a33526efe4370629e0f/href</a></iframe><p>The payment order processor is the <strong>only </strong>thread that can access user balances. It can get or update any balance <strong>without </strong>concern about <strong>concurrency </strong>issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R7kywZNbk9gBZYDTkx1zRg.png" /></figure><p>The <strong>pipeline </strong>is processing the <strong>sequence</strong> of operations as <strong>fast</strong> as possible.</p><h4>Conclusion</h4><p>The <strong>Pipeline Design Pattern</strong> has a lot of very different ways to be implemented, from a simple <strong>Chain of Command </strong>to a more complex <strong>Workflow</strong>.</p><p>Many features can be required such as <strong>circuit-breaker</strong>, <strong>asynchronous</strong> or <strong>buffer</strong>, but most of the time, you want to use pipelines when you want to have <strong>plugins </strong>that can <strong>hook </strong>in the pipeline execution flow.</p><p><em>The complete source code for the example can be found on </em><a href="https://github.com/guillaumebonnot/software-architecture/tree/master/Helios.Architecture.Pipeline"><em>github</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5c43d8a4e60" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>