<?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[Euler Labs - Medium]]></title>
        <description><![CDATA[We’re a UK tech startup harnessing the power of mathematics to build high-performance non-custodial protocols on #Ethereum and other blockchains. - Medium]]></description>
        <link>https://medium.com/eulerfinance?source=rss----26caa30240---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Euler Labs - Medium</title>
            <link>https://medium.com/eulerfinance?source=rss----26caa30240---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 13 Nov 2026 01:59:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/eulerfinance" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Securing Euler]]></title>
            <link>https://medium.com/eulerfinance/securing-euler-4f70a5fd664f?source=rss----26caa30240---4</link>
            <guid isPermaLink="false">https://medium.com/p/4f70a5fd664f</guid>
            <dc:creator><![CDATA[Miguel Cruz]]></dc:creator>
            <pubDate>Tue, 13 Aug 2024 13:13:29 GMT</pubDate>
            <atom:updated>2024-08-13T13:13:29.903Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QtFYb4aJ8HeX9-9r.png" /></figure><p>Security came first in every step of building Euler v2.</p><p>The vision for transitioning Euler into a modular protocol dates back to 2022. Since then, various code designs have been explored as proof of concepts long before work officially began on what will be launched in the very near future.</p><p>As we head toward that milestone, we’re proud to share today that Euler v2 has undergone one of the most expensive and comprehensive security processes for any DeFi protocol to-date. <a href="https://snapshot.org/#/eulerdao.eth/proposal/0x8ac487df0dc8e5e219922a5e823a049ab254f433534a5d766d7e3f691b06a80d">Roughly $4m was allocated by Euler DAO</a> to security — an incredible budget for an app-layer protocol, with many protocols budgeting closer to low six figures. Those costs covered the hiring of a <a href="https://x.com/eulerfinance/status/1728114011357475253">dedicated Senior Cybersecurity Engineer</a> to oversee development processes, engagements with world-class security researchers early in protocol development, the creation of bespoke fuzz testing and formal verification testing suites, 29 audits from 12 different firms, all culminating in the largest ever ($1.25m) code audit competition.</p><p>We draw inspiration from <a href="https://morpho.mirror.xyz/7mfZLV0KQpBiHF3QLHyWaQ_7gf_2_WmgMeCvqGY-kpY">Morpho’s excellent framework on the same topic.</a> Note that we have limited the content to only the key processes in the development of the smart contracts, but this is only one part of a bigger picture covering the security of Euler.</p><h3>Reinforcing Security Through Modularity</h3><p>The primary goal of Euler v2’s modular design was to improve the security and <a href="https://www.coindesk.com/opinion/2024/02/27/risk-management-in-defi-paternalism-vs-the-invisible-hand/">risk management of the protocol</a>. We believe <a href="https://medium.com/eulerfinance/modularity-the-way-forward-to-building-defi-systems-35fa95f7329a">modularity is the way forward</a> for protocol development because it can lead to more secure software that isolates risk, is easier to test, analyze, and audit, and reduces single points of failure. The core modules in Euler v2 are designed to do a small number of things in a very well-specified way. These modules include:</p><ul><li>Ethereum Vault Connector (EVC)</li><li>Euler Vault Kit (EVK)</li><li>Euler Price Oracle (EPO)</li></ul><p>The audit process detailed later in this blog post highlights the key benefits of Euler v2’s modular design, which enabled internal and external teams to develop and test modules both in isolation and in composition with other modules.</p><h3>Security-first processes</h3><p>While it is common to develop a protocol and later bring in auditors to consider its security after it has been developed, Euler v2 development turned this process upside down.</p><p>With the goal of implementing the <a href="https://www.sciencedirect.com/science/article/abs/pii/S0022103120303930?via%3Dihub">“Swiss Cheese” model of security</a> for v2, <a href="https://snapshot.org/#/eulerdao.eth/proposal/0x8ac487df0dc8e5e219922a5e823a049ab254f433534a5d766d7e3f691b06a80d">Euler DAO allocated roughly $4m to security</a> — an incredible budget for a DeFi protocol, with many protocols budgeting low six figures. This capital allowed us to bring in world-class protocol engineers and security researchers early on during the design and proof-of-concept stages of Euler’s development.</p><p>To oversee processes and operations for security, Erik Arfvidson was hired by Euler Labs as Head of Security. Erik has over 16 years of experience in security, spanning web2 and web3. In addition to managing day-to-day security operations and working closely with external security partners, Erik has been working to ensure that all development practices at Euler are compliant with <a href="https://www.iso.org/standard/27001">ISO27001 standards</a>, which is a certification standard used by banks and defense companies.</p><p>At the onset, we engaged:</p><ul><li>Certora to bring two security engineers in-house for six months to help guide development and formally prove assumptions about code operations;</li><li>Alberto Cuesta Cañada, ERC-4626 pioneer and developer of Yield protocol, to challenge the structure behind v2 and helped dive deep into thorny attack vectors for lending protocols. This work led to our publishing of an article on <a href="https://www.euler.finance/blog/exchange-rate-manipulation-in-erc4626-vaults">exchange rate manipulation of lending protocols</a>; and</li><li>Cmichel and StErMi, leading security engineers from Spearbit and experts in lending protocol attack vectors, to come in-house to challenge the designs behind the protocol’s architecture, carry out threat modeling, and help conduct line-by-line analysis of key parts of the early codebase.</li></ul><h3>Testing, fuzz testing and formal verification</h3><p>As the protocol began to take shape, a comprehensive suite of unit and invariant tests were also developed alongside Euler v2. Enigma Dark’s Victor Martinez was hired to build a dedicated fuzz testing suite using Medusa and Echidna, while Certora helped build a formal verification testing suite.</p><p>These two methodologies are important complementary tools for testing protocol invariants and finding edge cases in which, despite best efforts, unexpected things happen in a protocol’s code. Fuzz testing bombards a protocol’s code with randomness to find when key assumptions <em>might</em> be broken. Formal verification turns the codebase into a system of equations and helps formally prove that certain invariants cannot <em>ever </em>be broken. Fuzz testing is generally more flexible to apply but cannot prove things, while formal verification is harder to use in all cases but provides formal proofs when it works.</p><p>One of the most important invariants a lending protocol needs to test is that a user’s health should not change unless their balances or the prices of the assets they hold do. Breaking this invariant, or proving it couldn’t be broken, was set as a key challenge for both invariant testing suites. Formally proving that it couldn’t be broken was considered a <a href="https://ethcc.io/archive/Preventing-Unknown-Attacks-in-DeFi">‘Holy grail’ for formal verification</a>, which is something Certora’s team, with significant contributions from <a href="https://www.linkedin.com/in/andrew-ferraiuolo/">Andrew Ferraiuolo</a>, duly delivered on (see below).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/0*0cfCk4uYPE6OZ4Sd" /></figure><h3>Internal and external audits</h3><p>Once each module of Euler v2 was completed, it was manually audited both internally (within Euler Labs) and externally (by leading web3 security firms). Euler Labs is fortunate to house multiple smart contract teams, each of which can be used to audit another team’s code once it is completed prior to it being sent out to an external firm. To date, 29 external audits by 12 different firms have been carried out on the Euler v2 codebase.</p><p>The audit process for Euler v2 highlights a key benefit of its modular design. Each module in Euler is designed to do a few things in a very well-specified way, which allows for better documentation of assumptions about what the code should do and ultimately makes things easier for auditors. In particular, it allows for independent teams to develop and test modules both in isolation and in composition with other modules.</p><p>Utilising multiple audit firms allowed world-class security researchers with diverse backgrounds to bring their domain expertise to designing and battle testing the codebase. This helped to break ground on new areas of research, especially technical issues, such as those surrounding <a href="https://docs.euler.finance/Dutch_Liquidation_Analysis.pdf">Dutch-auction-style liquidations</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rug0YzCvd4U3A8Yh" /></figure><p><em>Euler was audited by the world’s best web3 security firms.</em></p><h3>Coordinating the Largest Code Audit Competition Ever</h3><p>Code audit competitions have emerged as an essential part of the auditing pipeline, which go beyond manual reviews and formal audit engagements by experts to crowdsource security to the general public. This style of auditing is highly complementary to formal auditing processes as it invites a far more diverse cross-section of candidates to challenge a codebase using whatever experience and techniques they have at their disposal.</p><p>Cantina was therefore engaged to carry out the world’s largest ever* code audit competitions on the Euler v2 codebase with <a href="https://cantina.xyz/competitions/41306bb9-2bb8-4da6-95c3-66b85e11639f">$1.25m allocated</a> to security researchers who could find any additional post-audit bugs. The largest prize was for issues with High severity. The contest went viral, with more than 600 participants worldwide participating and, in some cases, <a href="https://x.com/search?q=euler+cantina&amp;src=typed_query">live blogging</a> about their attempts to claim the top prize.</p><p>Ultimately, <a href="https://x.com/eulerfinance/status/1808133340173611492">no high or medium</a> severity issues were found in the post-audit code (see Appendix for severity definitions), which is almost unheard of in contests of this scale. Despite this, we awarded researchers by <a href="https://x.com/eulerfinance/status/1808133340173611492">allocating</a> $200k for low issues found, as a way of thanking the security community for all of their hard work and contribution.</p><p>*Other projects have since followed Euler’s trend and hosted even larger competitions.</p><h3>Conclusion</h3><p>To summarise, Euler v2 has been secured by experienced security professionals who have monitored and shaped its development from start to finish, from its modular design to line-by-line code reviews.</p><p>It is crucial to note, however, that security does not stop with audits and is not limited to securing a protocol’s smart contracts only. The work highlighted here is only part of a much bigger security picture for the protocol. This article has not touched on countless other security initiatives that help secure the protocol, including bug bounties, monitoring, penetration tests for the user interface, plans for critical incidents, and much else.</p><p>When it comes to security, there is always more to be done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rLld7EitR6ygH1HC" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f70a5fd664f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eulerfinance/securing-euler-4f70a5fd664f">Securing Euler</a> was originally published in <a href="https://medium.com/eulerfinance">Euler Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Euler v2 Code Reveal]]></title>
            <link>https://medium.com/eulerfinance/euler-v2-code-reveal-25bab552fd55?source=rss----26caa30240---4</link>
            <guid isPermaLink="false">https://medium.com/p/25bab552fd55</guid>
            <dc:creator><![CDATA[Miguel Cruz]]></dc:creator>
            <pubDate>Wed, 24 Apr 2024 15:09:15 GMT</pubDate>
            <atom:updated>2024-05-22T16:02:04.522Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jMcb2MEwj_o3pilIqCshMA.png" /></figure><h3>TL;DR:</h3><ul><li>Euler Vault Kit (EVK) and Euler Price Oracle code is made public today.</li><li>Auditors encouraged to begin familiarising themselves with the code ahead of $1.25m record-breaking Cantina code audit contest begins on May 20th.</li><li>Builders and integrators can begin learning how to create and connect together their own custom lending and borrowing vaults, or their own synthetic assets.</li><li>For further questions or inquiries about integrating with Euler, reach out to us on <a href="https://discord.gg/CdG97VSYGk">Discord</a> or <a href="https://t.me/eulerfinance_official">Telegram</a></li></ul><h3>Building in public</h3><p>We are delighted to unveil today the codebase for the <a href="https://github.com/euler-xyz/euler-vault-kit">Euler Vault Kit</a> (EVK), one of the main modular components of Euler v2 alongside the <a href="https://github.com/euler-xyz/ethereum-vault-connector">Ethereum Vault Connector</a> (EVC). This follows from the publication of the EVC code several months <a href="https://www.euler.finance/blog/introducing-the-ethereum-vault-connector-a-new-era-of-lending-is-here">ago</a>.</p><p>Additionally, we’re also unveiling the <a href="https://github.com/euler-xyz/euler-price-oracle/">Euler Price Oracle</a>, a library of immutable integrations for engaging with pricing systems which benefits not only the EVK but also the broader DeFi ecosystem.</p><p>Whilst the EVK + Price Oracle repos are still undergoing audits and further minor developments, the code is being made available publicly now as part of our commitment to build in public wherever possible and ensure that best security practices are being followed at all times.</p><p>Although it is important to note that the code and documentation that ultimately ships at launch could differ from the preliminary codebase and documents being shared today, early publication of the code will ensure that security professionals and future vault creators have sufficient time to familiarise themselves with how things work and scrutinise the code thoroughly ahead of future code audit competitions and deployments.</p><h3>Cantina Code Audit Competition</h3><p>A record-breaking $1.25m Cantina code audit <a href="https://www.euler.finance/blog/euler-and-spearbit-set-to-host-cryptos-largest-audit-competition">competition</a> for Euler v2 begins on May 20th. The EVK, Euler Price Oracle and EVC codebases are all in scope for that competition and now publicly available for security engineers to scrutinise.</p><p>Whilst there will no doubt be improvements and alterations to code and its documentation ahead of the start of the competition, security engineers who begin reviewing the code early will likely give themselves the best chance possible of uncovering valuable bugs.</p><h3>Time to get building</h3><p>Euler v2 works quite differently from Euler v1, with users able to create their own customised lending and borrowing vaults in a permissionless fashion using the EVK and then chain them together using the EVC. Today’s publication of the EVK code allows builders and integrators to start better understanding how to get started using Euler v2.</p><p>Advanced builders can create their own vaults from scratch and build on top of the open-source EVC, or use the EVK’s tailor-made, productised vaults, which come equipped with popular features out of the box and can typically be deployed in just a few clicks.</p><p>You can read more about the philosophy of how lending protocols work in this blog <a href="https://www.euler.finance/blog/paternalism-versus-the-invisible-hand-in-the-risk-management-of-lending-protocols">post</a>.</p><h3>Resources for getting started</h3><p>For those wanting to dig in straight away, the main resources are available here:</p><p><strong>Repos</strong></p><p><a href="https://github.com/euler-xyz/euler-vault-kit">https://github.com/euler-xyz/euler-vault-kit</a></p><p><a href="https://github.com/euler-xyz/euler-price-oracle/tree/master">https://github.com/euler-xyz/euler-price-oracle/</a></p><p><a href="https://github.com/euler-xyz/ethereum-vault-connector">https://github.com/euler-xyz/ethereum-vault-connector</a></p><p><strong>Docs</strong></p><p><a href="https://evc.wtf/docs/whitepaper">https://evc.wtf/docs/whitepaper</a></p><p><a href="https://docs.euler.finance/euler-vault-kit-white-paper/">https://docs.euler.finance/euler-vault-kit-white-paper/</a></p><h3>Join the Community</h3><p>Follow us on <a href="https://twitter.com/eulerfinance">Twitter</a>. Join the <a href="https://discord.gg/CdG97VSYGk">Discord</a>. Keep in touch on Telegram (<a href="https://t.me/eulerfinance_official">community</a>, <a href="https://t.me/eulerfinance">announcements</a>). Check out the Euler Finance <a href="https://www.euler.finance/">website</a>.</p><p>Disclaimer:</p><p>This piece is provided by Euler Labs Ltd. for informational purposes only and should not be interpreted as investment, tax, legal, insurance, or business advice. Euler Labs Ltd. and The Euler Foundation are independent entities.</p><p>Neither Euler Labs Ltd., The Euler Foundation, nor any of their owners, members, directors, officers, employees, agents, independent contractors, or affiliates are registered as an investment advisor, broker-dealer, futures commission merchant, or commodity trading advisor or are members of any self-regulatory organization.</p><p>The information provided herein is not intended to be, and should not be construed in any manner whatsoever, as personalized advice or advice tailored to the needs of any specific person. Nothing on the Website should be construed as an offer to sell, a solicitation of an offer to buy, or a recommendation for any asset or transaction.</p><p>This post reflects the current opinions of the authors and is not made on behalf of Euler Labs, The Euler Foundation, or their affiliates and does not necessarily reflect the opinions of Euler Labs, The Euler Foundation, their affiliates, or individuals associated with Euler Labs or The Euler Foundation.</p><p>Euler Labs Ltd. and The Euler Foundation do not represent or speak for or on behalf of the users of Euler Finance. The commentary and opinions provided by Euler Labs Ltd. or The Euler Foundation are for general informational purposes only, are provided “AS IS,” and without any warranty of any kind. To the best of our knowledge and belief, all information contained herein is accurate and reliable and has been obtained from public sources believed to be accurate and reliable at the time of publication.</p><p>The information provided is presented only as of the date published or indicated and may be superseded by subsequent events or for other reasons. As events and markets change continuously, previously published information and data may not be current and should not be relied upon.</p><p>The opinions reflected herein are subject to change without being updated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25bab552fd55" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eulerfinance/euler-v2-code-reveal-25bab552fd55">Euler v2 Code Reveal</a> was originally published in <a href="https://medium.com/eulerfinance">Euler Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Euler v2: The Modular Lending Platform]]></title>
            <link>https://medium.com/eulerfinance/euler-v2-the-modular-lending-platform-51ca9fafd3ff?source=rss----26caa30240---4</link>
            <guid isPermaLink="false">https://medium.com/p/51ca9fafd3ff</guid>
            <category><![CDATA[euler-finance]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[lending]]></category>
            <dc:creator><![CDATA[Michael Bentley]]></dc:creator>
            <pubDate>Thu, 22 Feb 2024 14:56:28 GMT</pubDate>
            <atom:updated>2024-02-22T14:56:28.083Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5XsVAdZ7bM_3D3VI" /></figure><p>It’s official. Euler is relaunching! Today, we’re excited to unveil Euler v2— The Modular Lending Platform. Check out the <a href="https://docs.euler.finance/euler-v2-lite-paper/">lite paper</a> or read on below to find out more.</p><h3><strong>Introduction</strong></h3><p>Euler v2 is a modular lending platform that will have two main components at launch: 1) the <a href="https://docs.euler.finance/euler-vault-kit-white-paper/">Euler Vault Kit</a> (EVK), which empowers builders to deploy and chain together their own customised lending vaults in a permissionless manner; and 2) the <a href="https://www.euler.finance/blog/introducing-the-ethereum-vault-connector-a-new-era-of-lending-is-here">Ethereum Vault Connector</a> (EVC), a powerful, immutable, primitive which give vaults superpowers by allowing their use as collateral for other vaults. Together, the EVK and EVC provide the flexibility to build or recreate any type of pre-existing or future-state lending product inside the Euler ecosystem.</p><p>Euler v2 provides a best-in-class experience for lenders and traders alike, by providing unparalleled access to diverse risk/reward opportunities, new collateral options, lower net borrowing costs, advanced risk management tools such as sub-accounts and profit and loss simulators, custom-built limit order types (including stop-loss and take-profit), and greatly reduced liquidation costs.</p><p><strong>Features will include:</strong></p><ul><li><strong>Customizable Vaults: </strong>Euler v2 introduces the Euler Vault Kit (EVK), allowing developers to build ERC-4626 vaults with complete freedom. No constraints on governance, oracles, or upgradability.</li><li><strong>Core Vault Class:</strong> Create governed lending products for risk-managed, capital-efficient lending experiences. Euler v2 enhances the user journey for borrowers and traders.</li><li><strong>Edge Vault Class:</strong> Develop ungoverned, modular vaults for establishing permissionless lending markets. Euler Edge forms the base layer for a free-market approach to risk management.</li><li><strong>Escrow Vault Class: </strong>Enable any ERC20 token as collateral without earning yield. Escrow vaults ensure collateral accessibility for liquidations and offer protection to borrowers.</li></ul><h3>New Features of EVK</h3><ul><li><strong>Synthetic Assets</strong>: Euler v2 enables the creation of collateralized debt positions and synthetic assets. Explore new synthetic assets within Euler with a permissionless approach to product creation.</li><li><strong>Nested Vaults</strong>: Tokenize vault shares and create nested vaults for innovative lending and borrowing opportunities. Opt-in to riskier collateral types without affecting other lenders.</li><li><strong>Permissionless Rewards</strong>: Leverage RewardStreams, an open-source module, for seamless distribution of rewards without staking. Foster dynamic and efficient user engagement.</li></ul><h3>Ethereum Vault Connector (EVC)</h3><ul><li><strong>Interoperability Layer</strong>: The Ethereum Vault Connector (EVC) serves as an open-source interoperability layer, allowing easy connection of vaults within the Euler ecosystem.</li><li><strong>Advanced Trading and Risk Management</strong>: For developers, the EVC provides multicall batching, flash liquidity, gasless transactions, and an “operator concept” for advanced trading and risk management strategies.</li></ul><h3>FeeFlow: Empowering the Euler DAO</h3><ul><li><strong>Fee Auction Mechanism</strong>: FeeFlow, an open-source module, introduces a reverse Dutch auction mechanism, empowering the Euler DAO to control fees on Euler markets and convert them into other types of assets.</li><li><strong>Passive Income for Vault Creators</strong>: Vault creators can set fees, creating a passive income stream while contributing to the Euler DAO’s financial flexibility.</li></ul><h3>We’re Just Getting Started</h3><p>Euler v2 addresses the <a href="https://www.euler.finance/blog/paternalism-versus-the-invisible-hand-in-the-risk-management-of-lending-protocols">limitations</a> of monolithic and isolated lending protocols, aiming to become the primary liquidity layer for DeFi. The modular architecture resolves liquidity fragmentation, allowing permissionless creation of vaults that seamlessly connect across the ecosystem.</p><p>In the decentralised finance (DeFi) landscape, the foundational practice of lending and borrowing digital assets is crucial for the emergence of capital markets. Traditional monolithic lending protocols often impose restrictions on borrowing, limiting asset selections and enforcing conservative loan-to-value (LTV) requirements. Additionally, heavy fines for liquidation further hinder the trading experience for borrowers and traders. On the other hand, isolated lending markets offer greater flexibility, but come with the downside of fragmenting collateral and inhibiting rehypothecation, resulting in lower capital efficiency.</p><p>Euler v2 will be a first-of-its kind solution to these challenges, with the goal of becoming the primary liquidity layer for DeFi. Its modular architecture addresses the liquidity fragmentation problem by enabling the permissionless creation of Edge vaults, allowing seamless collateral usage across the broader ecosystem. This innovative approach connects different vaults from various product lines via the Ethereum Vault Connector (EVC), ensuring unparalleled flexibility for lenders, borrowers, builders, and traders without compromising on security or risk management.</p><p>But Euler’s vision extends beyond existing possibilities. We see a world that includes real-world assets, non-fungible tokens, IOUs for uncollateralized lending, peer-to-peer lending, and oracle-free lending. The modular design and forthcoming developments aim to establish Euler as a global liquidity layer and a comprehensive hub for lending, borrowing, and trading on EVM-based networks.</p><p>To join us on this journey, please see our lite paper <a href="https://docs.euler.finance/euler-v2-lite-paper/">here</a>, and more technical white paper <a href="https://docs.euler.finance/euler-vault-kit-white-paper/">here</a>. Happy building.</p><h3>Join the Community</h3><p>Follow us on <a href="https://twitter.com/eulerfinance">Twitter</a>. Join the <a href="https://discord.gg/CdG97VSYGk">Discord</a>. Keep in touch on Telegram (<a href="https://t.me/eulerfinance_official">community</a>, <a href="https://t.me/eulerfinance">announcements</a>). Check out the Euler Finance <a href="https://www.euler.finance/">website</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51ca9fafd3ff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eulerfinance/euler-v2-the-modular-lending-platform-51ca9fafd3ff">Euler v2: The Modular Lending Platform</a> was originally published in <a href="https://medium.com/eulerfinance">Euler Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Paternalism Versus The Invisible Hand in the Risk Management of Lending Protocols]]></title>
            <link>https://medium.com/eulerfinance/paternalism-versus-the-invisible-hand-in-the-risk-management-of-lending-protocols-60221359360e?source=rss----26caa30240---4</link>
            <guid isPermaLink="false">https://medium.com/p/60221359360e</guid>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[lending]]></category>
            <category><![CDATA[euler-finance]]></category>
            <dc:creator><![CDATA[Michael Bentley]]></dc:creator>
            <pubDate>Wed, 21 Feb 2024 16:29:21 GMT</pubDate>
            <atom:updated>2024-05-22T16:04:28.205Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OueAPlinzVmeZzYlxJv50g.png" /></figure><h3><strong>Introduction</strong></h3><p>Suppose a lending protocol allows borrowers to use USDC as collateral to take out loans of ETH. What is the maximum amount of ETH that can be borrowed with the USDC collateral?</p><p>Asked in terms of protocol risk management, what is the correct loan-to-value (LTV) ratio the protocol should adopt for such a trade?</p><p>A straightforward answer is that it is the LTV that maximises the risk/reward payoff for lenders. Unfortunately, knowing what this is at any given point in time is practically impossible to calculate, especially on-chain. Not only does the optimal LTV for a protocol depend on the expected price volatility of underlying assets, but also on liquidity, the exposure of the protocol to other assets, the number of open positions on other protocols, the rate of market arbitrage, and many other factors. The true optimal LTV therefore not only changes from moment to moment, but it needs extensive calculations to be able to verify its value at each of those moments.</p><p>Given these challenges, lending protocol design always requires heuristics and pragmatic choices. These choices mean that there is no one-size-fits-all solution when it comes to lending protocols. Significant trade-offs exist between different designs, especially when it comes to the degree to which a lending protocol is supposed to be able to adapt to changing external conditions. In this article, I divide the major design patterns into three classifications (Fig. 1) and highlight some of their trade-offs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iz_dDCoSubEJijpkgUJRIA.png" /></figure><p><strong>Figure 1 | Liquidity and risk management models. </strong>In A, under global paternalism, lenders all deposit to a single governed pool. The collateral factor setting the required loan-to-value (LTV) ratio for borrowers is determined globally in a paternalistic manner. If the risk environment deteriorates, then governance may opt to lower the LTV for the entire protocol from a higher value (Before) to something lower (After). This model allows lenders, and to some degree borrowers, to hold open positions in a relatively passive manner. In B, under the invisible hand, lenders deposit directly into a range of pools with different fixed risk parameters. In this model, if the risk environment deteriorates, lenders must actively pull deposits from higher risk pools themselves (Before) and manually move them to lower risk pools (After). This model allows lenders maximum flexibility into where they put their deposits, and helps them avoid fees and the risks of bad governance, but still requires borrowers to actively manage opening and closing loans across different pools. In C, under local paternalism, lenders deposit into pools with different fixed risk parameters via an aggregator. The aggregator may opt to put a small percentage of their liquidity into higher risk pools and some in lower risk pools. Aggregators compete against each other for deposit customers based on their ability to manage risk and deliver a reward. If the risk environment deteriorates, they will pull deposits from higher risk pools (Before) and move them to lower risk pools (After). This model allows lenders to deposit passively into the aggregator of their choosing and have risk/reward managed for them, but still requires borrowers to actively manage opening and closing loans across different pools.</p><h3><strong>Global Paternalism via DAO Governance</strong></h3><p>One of the most popular solutions for risk management of lending protocols has been a mechanism of governance over key risk parameters by decentralised autonomous organisations (DAOs) and their risk management associates (specialist risk manager organisations like Gauntlet, Chaos and Warden). I call this the ‘paternalistic’ model of risk management (Fig 1). It is ‘global’ as opposed to ‘local’ paternalism (see below), because risk is managed globally for the entire protocol and its users, not for a subset of pools or users.</p><p>This model has been used by so-called ‘monolithic’ lending protocols, like Euler v1, Compound v2, Aave v2/v3 and Spark, where LTV ratios are generally set conservatively, but not too conservatively, at some value at which every user deposit goes into. If the environment becomes less favourable for lending, then it is the responsibility of governance or governance-appointed risk manager to move the protocol-wide LTV ratios for all users from risk-on (Fig 1A — Before) to a more risk-off setting (Fig 1A — After).</p><p>Governance of risk parameters allows risk specialists to monitor on-chain activity and risk factors and adjust governed pools in a paternalistic fashion as the environment changes. It also helps prevent a fragmentation of liquidity because liquidity converges inside a single governed pool. Importantly, monolithic lending protocols are also capital efficient for borrowers, because they allow them to earn yield on their collateral, reducing their net borrowing costs. These kinds of protocols were the first to find product-market fit in DeFi and have helped brands like Compound and Aave establish themselves as early market leaders, serving as useful tools for 80% of users even if not providing a perfect risk/reward match for any given user.</p><p>However, governance-based risk management also has a number of drawbacks. DAOs are often composed of people with varied skill sets, many of whom may not be qualified to vote directly on risk parameters themselves. Delegation of voting power can help put control in more qualified DAO member hands, but this only helps to centralise decision making over a large number of parameters in the hands of a few individuals, who often end up wielding considerable power. Even when these specialists make ‘good’ decisions, DAO governance takes time and decisions might not be implemented sufficiently quickly if the environment changes rapidly. Governance also forces protocol users to accept or reject a single risk/reward outcome, when in reality users have very different tolerances. It also arguably trains users to expect that risk will be managed for them paternalistically, so that they are ill-equipped to take responsibility for managing their own risk/reward decisions.</p><h3><strong>The Invisible Hand via (Immutable) Isolated Pools</strong></h3><p>The other major class of lending protocol relies on more free market principles to allow lenders to choose a risk/reward suitable for themselves and live or die by their decisions. The philosophy behind these models is that the ‘invisible hand’ will manage risk for the market. Lenders have more freedom with respect to risk/reward under this model, but they must be prepared to take more of an active role in the management of their deposits. Free market models generally have lenders depositing into a range of different, typically ungoverned, isolated pools. They can do this either directly themselves (Fig 1B) or sometimes through an aggregator (Fig 1C, see below).</p><p>Variants of this model have been used by protocols like Kashi, Silo, Compound v3, Morpho Blue, Ajna and FraxLend. With many pools to choose from, users are free to lend across a wide range of possible LTV ratios (and other risk parameters). Some might take a cautious approach, lending at low LTV ratios, but attracting fewer borrowers, whilst others might be more open to risk, lending at higher LTV ratios, attracting more borrowers and people taking on leveraged positions. As users express their own preferences, a distribution of risk/reward tolerance emerges, which might have a central tendency, but has no single value to suit everyone (Fig 1B). If the environment becomes less favourable for lending, then it is the responsibility of individuals to move their liquidity from more risk-on pools (Figs 1B — Before) to more risk-off pools (Figs 1B — After).</p><p>Free market risk management allows lenders and borrowers maximum flexibility with respect to managing their own risk/reward tolerance. This, in turn, allows different use-cases for lending and borrowing to emerge. Borrowers taking short-term trades may be happy to pay a very high interest rate for a few days, whilst borrowers looking to collateralise their crypto assets might seek lower cost, longer-term borrowing opportunities. These different types of users can seek out similarly-minded risk/reward lenders. At the protocol layer things are often somewhat simpler with free market models too. The absence of governance allows immutable primitives to be constructed that can be used by anyone. Complexity and product-specifics can be pushed to an aggregation-layer or user-interface layer (see below). Whilst this does not necessarily reduce the complexity of the system overall, it does simplify the complexity of the trusted codebase for the subset of users who are happy to manage their own risks. Ultimately, for most users, system complexity is like a bubble under the carpet: it can be minimised and moved, but never entirely removed.</p><p>There are a number of drawbacks with free-market systems too, however. Perhaps the most important of these is the impact on capital efficiency that liquidity fragmentation brings. New isolated markets often struggle to compete with paternalistic lending protocols due to the costs of use for lenders and borrowers alike. Isolated pools not only make it harder for lenders and borrowers to find one another, but they often also make borrowing more expensive (even when users are able to find a match). That’s because in most isolated lending market protocols borrowers must use collateral which earns them no yield (see Morpho Blue, Compound v3, FraxLend). In contrast, in monolithic lending protocols borrowers can simultaneously use an asset as collateral and lend it out at the same time. This can substantially reduce the costs of borrowing, and even make borrowing <strong>profitable</strong>, enabling interest-rate arbitrage (via “carry trades”). And with more borrowing, comes more yield for lenders. Note that there is no free lunch here. Lenders are exposed to rehypothecation risks on monolithic lending protocols in a way that they are not on isolated lending protocols.</p><h3><strong>Local Paternalism via Aggregators</strong></h3><p>The major drawback of isolated lending markets is that they may require lenders to take their life into their own hands and manage their own risks. This will simply not be practical for many lenders. This is where aggregators can be useful. Aggregator protocols allow users to deposit assets into a single managed pool, where risk management is delegated to a local risk manager (which may be an organisation or an automated smart contract) who further deposits assets into isolated downstream lending markets (Fig 1C). Note that aggregators are therefore a layer above the lending protocol layer and can be used in conjunction with monolithic lending protocols and isolated lending markets simultaneously.</p><p>Aggregators today come in several flavours. There are free market aggregators, like Yearn and Idle, which are generally agnostic about the downstream lending markets they deposit into. They simply try to maximise the risk/reward payoff for their users, regardless of how rewards are achieved. And there are aggregators, like MetaMorpho, that are more opinionated about where the yield comes from. They generally try to preserve capital inside their own ecosystem products. In either case, the goal of aggregators is for a defined risk manager (which may be an organisation or an automated smart contract) to construct a portfolio of lender deposits in pools with different risk properties. If the environment becomes less favourable for lending, then it is the responsibility of the risk manager to construct a new portfolio for the lenders it serves by moving liquidity from more risk-on pools (Figs 1C — Before) to more risk-off pools (Figs 1C — After).</p><p>Aggregators are especially useful for lenders because they help them to access a wide range of risk/reward opportunities across a variety of different pools or protocols in a relatively passive manner. They can also limit the gas costs of constant risk/reward optimisation, especially for smaller depositors. On the downside, aggregators will often charge additional fees for their services. Being paternalistic in nature, they also suffer many of the same drawbacks as paternalistic governance too.</p><p>It is also often claimed that aggregators help to solve the liquidity fragmentation problem associated with isolated pools, since the isolation is largely abstracted away for lenders. However, lenders are only half the equation here. Even when lenders use aggregators, the picture for borrowers is still fragmented. Borrowers will generally still need aggregator systems of their own to manage their risks, and may therefore continue to prefer using monolithic lending protocols whose liquidity is typically larger and less volatile (especially when borrowers can earn yield on their collateral). Otherwise borrowing from illiquid pools can make for a particularly poor experience for borrowers, whose cost of borrowing can become unpredictable during supply side shocks, and even drive them towards liquidation.</p><h3><strong>Scaling lending protocols</strong></h3><p>In order for DeFi lending to compete with traditional finance, we should accept that there is no one-size-fits-all solution to building a lending protocol. DeFi needs a lending ecosystem with modularity at its core, in which different protocol designs serve different user needs.</p><p>Governed monolithic lending protocols provide DeFi users today with unparalleled capital efficiency, but have significant drawbacks when it comes to providing diverse risk/reward opportunities and exposing users to the many risks of governance. Isolated lending markets relying on the flow of the free market help provide a wide range of choice for users, and may form primitives on top of which custom products can be built, but often lack capital efficiency and expose users to risks that they may not be able to manage sufficiently well or in a cost-effective manner. They may also make life more difficult for borrowers.</p><h3><strong>Conclusion</strong></h3><p>To truly scale lending in DeFi requires development of an agnostic ecosystem in which different types of lending protocols can flourish alongside one another. This requires increased composability and connectedness of diverse collateral types from different protocols. True freedom is not about choosing between paternalism vs the invisible hand; it is about being able to switch seamlessly between whichever kind of model you prefer at any time you want.</p><p>This is why we’re building Euler v2: a modular platform allowing users to create and use a suite of highly customizable lending vaults tailored to their needs. Built on top of the Ethereum Vault Connector (EVC), Euler will bridge the gap between monolithic lending protocols and isolated pools. It will recognise that different users have different risk/reward appetites and enable users to deploy and link together their own customised lending vaults in a permissionless manner. With this flexibility, any type of pre-existing or future lending protocol — monolithic or otherwise — can be recreated inside the Euler ecosystem and connected to vaults from elsewhere in the ecosystem.</p><p>The EVC and Euler v2 will be a 0 to 1 moment for the composability and connectedness of collateral in DeFi. Together, they will provide vault creators with unparalleled opportunities for innovation and growth via network effects as more and more diverse vault types are deployed within the Euler ecosystem.</p><h3>Join the Community</h3><p>Follow us on <a href="https://twitter.com/eulerfinance">Twitter</a>. Join our <a href="https://discord.gg/CdG97VSYGk">Discord</a>. Keep in touch on Telegram (<a href="https://t.me/eulerfinance_official">community</a>, <a href="https://t.me/eulerfinance">announcements</a>). Check out our <a href="https://www.euler.finance/">website</a>.</p><p>Disclaimer:</p><p>This piece is provided by Euler Labs Ltd. for informational purposes only and should not be interpreted as investment, tax, legal, insurance, or business advice. Euler Labs Ltd. and The Euler Foundation are independent entities.</p><p>Neither Euler Labs Ltd., The Euler Foundation, nor any of their owners, members, directors, officers, employees, agents, independent contractors, or affiliates are registered as an investment advisor, broker-dealer, futures commission merchant, or commodity trading advisor or are members of any self-regulatory organization.</p><p>The information provided herein is not intended to be, and should not be construed in any manner whatsoever, as personalized advice or advice tailored to the needs of any specific person. Nothing on the Website should be construed as an offer to sell, a solicitation of an offer to buy, or a recommendation for any asset or transaction.</p><p>This post reflects the current opinions of the authors and is not made on behalf of Euler Labs, The Euler Foundation, or their affiliates and does not necessarily reflect the opinions of Euler Labs, The Euler Foundation, their affiliates, or individuals associated with Euler Labs or The Euler Foundation.</p><p>Euler Labs Ltd. and The Euler Foundation do not represent or speak for or on behalf of the users of Euler Finance. The commentary and opinions provided by Euler Labs Ltd. or The Euler Foundation are for general informational purposes only, are provided “AS IS,” and without any warranty of any kind. To the best of our knowledge and belief, all information contained herein is accurate and reliable and has been obtained from public sources believed to be accurate and reliable at the time of publication.</p><p>The information provided is presented only as of the date published or indicated and may be superseded by subsequent events or for other reasons. As events and markets change continuously, previously published information and data may not be current and should not be relied upon.</p><p>The opinions reflected herein are subject to change without being updated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60221359360e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eulerfinance/paternalism-versus-the-invisible-hand-in-the-risk-management-of-lending-protocols-60221359360e">Paternalism Versus The Invisible Hand in the Risk Management of Lending Protocols</a> was originally published in <a href="https://medium.com/eulerfinance">Euler Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing the Ethereum Vault Connector — A New Era Of Lending Is Here]]></title>
            <link>https://medium.com/eulerfinance/introducing-the-ethereum-vault-connector-a-new-era-of-lending-is-here-191430255c1c?source=rss----26caa30240---4</link>
            <guid isPermaLink="false">https://medium.com/p/191430255c1c</guid>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[vault]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[lending]]></category>
            <dc:creator><![CDATA[Kasper]]></dc:creator>
            <pubDate>Thu, 11 Jan 2024 13:09:18 GMT</pubDate>
            <atom:updated>2024-05-22T16:06:19.575Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introducing the Ethereum Vault Connector — A New Era Of Lending Is Here</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-4zCKPL2o-QXYyurttb1Mw.png" /></figure><p>Today marks a significant day for Euler Labs, as we proudly introduce <a href="https://evc.wtf/">The Ethereum Vault Connector</a>, a public good, open-source primitive designed to make lending markets more customizable and interconnected, powering the creation of novel use cases.</p><h3>DeFi is Dead, Long live DeFi.</h3><p>DeFi emerged as the answer to traditional finance’s shortcomings — limited choices, opacity, and centralised control. For DeFi to continue fulfilling its mission, we believe our efforts must extend beyond just decentralising applications and focus on making it easier to develop new foundational structures. In lending, this means empowering users and developers to go beyond the current status quo and giving them an expanded range of customizable options to create tailored lending markets, products, and protocols.</p><p>In this spirit, we’re excited to introduce the <a href="https://evc.wtf/"><strong>Ethereum Vault Connector (EVC)</strong></a><strong> — A powerful primitive that enables everyone and anyone to build protocols and new products on top.</strong></p><p>The EVC <a href="https://github.com/euler-xyz/ethereum-vault-connector/tree/master/src">code</a> has been subjected to three smart contract <a href="https://github.com/euler-xyz/ethereum-vault-connector/tree/master/audits">audits</a> by yAudit, Certora, and Hunter Security, along with a comprehensive review by Spearbit. A fourth audit by Trail of Bits is currently underway. While additional audits are already scheduled we welcome feedback and discussions from the community on the current version of the <a href="https://github.com/euler-xyz/ethereum-vault-connector/tree/master/src">code</a> and the <a href="https://evc.wtf/docs/whitepaper">white paper</a>. We also encourage everyone to participate in our <a href="https://evc.wtf/docs/security/bug-bounty">ongoing</a> bug bounty.</p><h3>The Ethereum Vault Connector — What does it do exactly?</h3><p>The Ethereum Vault Connector (EVC) is a primitive that facilitates seamless communication between ERC-4626 vaults, amongst other smart contracts.</p><p>It supercharges vaults with new capabilities and allows them to accept collateral from one another, in a network composed of other vaults.</p><p>The EVC empowers developers with absolute freedom to innovate by streamlining the intricacies within core lending and borrowing contracts, lowering barriers to development.</p><p>With the EVC, developers no longer need to start from scratch, when building lending protocols, stablecoins, yield aggregators, margin trading apps, or others.</p><p>Immutable, unopinionated, without governance , zero fees — it’s intended to be a true public good for DeFi.</p><h3>Why build on the Ethereum Vault Connector?</h3><h4>1. Unified interoperability layer</h4><p>The EVC creates network effects by facilitating access to unified liquidity. It enables protocols to accept deposits as collateral from the vaults in the network, offering convenience to users by eliminating the need to transfer their collateral assets from one protocol to another.</p><p>Additionally, this integration allows vault creators to easily bootstrap lending products by connecting with vaults and utilising existing deposits within the network as recognized collateral.</p><h4>2. Underlying asset flexibility</h4><p>Its unopinionated nature extends to assets, giving you full control over the assets that can be used as collateral or liabilities.</p><p>This flexibility enables the creation of lending products backed not only by ERC-20 tokens but also by irregular asset classes, such as RWAs, NFTs, uncollateralized IOUs, or synthetics.</p><h4>3. Advanced position management</h4><p>The EVC also excels in the domain of automations as it allows external contracts to act on behalf of your account so the following can be implemented:</p><ul><li>Position Managers</li><li>Conditional Orders</li><li>Intent-Based Systems</li><li>Custom Liquidation Flows</li></ul><h4>4. Generalised flash loans and batching</h4><p>Should you choose, you can rely on the EVC to perform multiple operations affecting multiple vaults and external smart contracts within a single batch transaction.</p><p>This is more convenient for UI users, more gas efficient, and allows deferring account liquidity and vault constraints checks until the end of the batch.</p><h3>Infinite use cases, infinite possibilities</h3><p><strong>EVC allows for a modular design that opens up</strong> up a limitless number of use cases for products that can be built on top of it. These include, but are not limited to:</p><ol><li>Traditional, overcollateralized lending products</li><li>Uncollateralized lending products</li><li>Real World Assets (RWA) lending products</li><li>NFT lending products</li><li>P2P lending products</li><li>Oracle-free lending products</li><li>Automations (conditional orders, custom liquidation flows, strategies, position managers, optimizers, guardians etc.)</li><li>Smart contract tooling (i.e. swap hubs using new dexes or new dex aggregators)</li></ol><h3>Build (and audit) with us</h3><p>When finally deployed, the EVC will be one of the most audited contracts in DeFi. To date, it has undergone <a href="https://github.com/euler-xyz/ethereum-vault-connector/tree/master/audits">three smart contract audits</a> (yAudit, Certora, Hunter Security) and a detailed code review conducted by Spearbit. A fourth audit with Trail of Bits is currently in progress. We are also proud to have Alberto Cuesta Cañada, co-founder of Yield and ERC-4626 pioneer, contributing to the EVC and assisting us with architecture and security design.</p><p>We intend to continue to review the EVC, as further audits are already scheduled. As for bug bounties, the first one is now <a href="https://evc.wtf/docs/security/bug-bounty">open</a>. Similar to our audit approach, you can expect more bounties to be announced soon.</p><p>Additionally, it’s important to add that the EVC is set to be included in the Euler v2’s final audit, contributing to the overall scope of the security review.</p><p>To learn more about the EVC and its full possibilities we invite you to <a href="https://www.encode.club/euler-educate">join</a> our workshops with Encode starting today at 11 AM ET, which will also have a bug bounty up to $100,000.</p><h3>The Future of Euler v2</h3><p>The EVC will be the foundation on which Euler v2 will be built, enabling it to be more flexible, with a stronger emphasis on risk management and yield optimization.</p><p>Euler v2’s modular design will allow users incredible freedom to create and deploy lending markets tailored to their needs. This includes choosing oracles, setting governance structures, selecting asset types, and defining risk management mechanisms and interest rate models.</p><p>Whether users are activating a market with our ready-to-use components, customising them to fit their unique requirements, or building completely new ones from scratch, the possibilities to create truly personalised markets will be endless.</p><p>Euler v2 holds many more surprises, but this is all we’re revealing for now. Worry not, though; the full details of Euler v2 will soon be announced.</p><p><strong>Disclaimer</strong>:</p><p>This piece is provided by Euler Labs Ltd. for informational purposes only and should not be interpreted as investment, tax, legal, insurance, or business advice. Euler Labs Ltd. and The Euler Foundation are independent entities.</p><p>Neither Euler Labs Ltd., The Euler Foundation, nor any of their owners, members, directors, officers, employees, agents, independent contractors, or affiliates are registered as an investment advisor, broker-dealer, futures commission merchant, or commodity trading advisor or are members of any self-regulatory organization.</p><p>The information provided herein is not intended to be, and should not be construed in any manner whatsoever, as personalized advice or advice tailored to the needs of any specific person. Nothing on the Website should be construed as an offer to sell, a solicitation of an offer to buy, or a recommendation for any asset or transaction.</p><p>This post reflects the current opinions of the authors and is not made on behalf of Euler Labs, The Euler Foundation, or their affiliates and does not necessarily reflect the opinions of Euler Labs, The Euler Foundation, their affiliates, or individuals associated with Euler Labs or The Euler Foundation.</p><p>Euler Labs Ltd. and The Euler Foundation do not represent or speak for or on behalf of the users of Euler Finance. The commentary and opinions provided by Euler Labs Ltd. or The Euler Foundation are for general informational purposes only, are provided “AS IS,” and without any warranty of any kind. To the best of our knowledge and belief, all information contained herein is accurate and reliable and has been obtained from public sources believed to be accurate and reliable at the time of publication.</p><p>The information provided is presented only as of the date published or indicated and may be superseded by subsequent events or for other reasons. As events and markets change continuously, previously published information and data may not be current and should not be relied upon.</p><p>The opinions reflected herein are subject to change without being updated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=191430255c1c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eulerfinance/introducing-the-ethereum-vault-connector-a-new-era-of-lending-is-here-191430255c1c">Introducing the Ethereum Vault Connector — A New Era Of Lending Is Here</a> was originally published in <a href="https://medium.com/eulerfinance">Euler Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hello 2024, Hello new Euler look.]]></title>
            <link>https://medium.com/eulerfinance/hello-2024-hello-new-euler-look-c339e8209587?source=rss----26caa30240---4</link>
            <guid isPermaLink="false">https://medium.com/p/c339e8209587</guid>
            <dc:creator><![CDATA[Matija Skrnjug]]></dc:creator>
            <pubDate>Wed, 10 Jan 2024 15:25:10 GMT</pubDate>
            <atom:updated>2024-05-22T16:06:32.306Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rzeolu8k8IVsNll9drjTnQ.png" /></figure><p><em>“Tell me I can’t, and then watch me work twice as hard to prove you wrong” — Unknown</em></p><p>This feeling has resonated with us and with everyone in crypto for the last two years. As we now see, crypto is coming back, stronger than before. And it’s not just crypto making a comeback — Euler is too.</p><p>Behind the scenes, we’ve been diligently building. Over the past several months, our team has been in stealth mode, developing not one, but three projects. The moment to draw back the curtain and unveil to the world what we have built is now closer than ever.</p><h3>The same Euler, but wiser and stronger</h3><p>As we enter 2024, we are excited to present a refined Euler brand that reflects our vision for this year: The same Euler, but wiser and stronger. While the Euler<strong><em> </em></strong>brand still represents our foundational values and who we are, it now reflects our resilient journey and emboldened future.</p><p>The newly refined Euler brand includes a new logo, typography, color palette, and website.</p><h3>Logo Design</h3><p>The Euler logo has three parallel lines that come together in the shape of an “E”, symbolizing forward movement. The clean, PP Mori font used alongside the logo reflects our brand’s focus on clarity and precision.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6CuHHzImYuyacgF4.png" /></figure><h3>Symbol</h3><p>Our symbol is a timeless representation of Euler, it serves as an alternative to the full logo when space is limited, ensuring our brand’s identity remains distinct and recognizable at any size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bo-eWFk08cpqDDf6.png" /></figure><h3>Color Palette</h3><p>Our brand palette showcases a vibrant, bright green — embodying vitality and growth — complemented by sophisticated shades of navy. These colours, mirroring our product, evoke innovation and trust, fostering a harmonious brand-product relationship.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7qALE_kH5YamYyf3.png" /></figure><h3>Typography</h3><p>Our brand’s choice of serif headlines embodies experience and wisdom, exuding elegance and authority. Paired with sans-serif body text, this deliberate contrast signifies modernity and readability, ensuring impactful, harmonious communication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bjtJsN_mEE4meVJR.png" /></figure><h3>Looking Forward</h3><p>The rebrand unveiled today is just the beginning. We are committed to making 2024, Euler Labs’ most impactful year. The transformative projects that we will launch this year will bring us closer to our mission of creating a truly modular DeFi ecosystem.<strong><em> </em></strong>Stay tuned and keep an eye on our socials, who knows we might announce one of those projects, sooner than you think!</p><p><strong>Disclaimer:</strong></p><p>This piece is provided by Euler Labs Ltd. for informational purposes only and should not be interpreted as investment, tax, legal, insurance, or business advice. Euler Labs Ltd. and The Euler Foundation are independent entities.</p><p>Neither Euler Labs Ltd., The Euler Foundation, nor any of their owners, members, directors, officers, employees, agents, independent contractors, or affiliates are registered as an investment advisor, broker-dealer, futures commission merchant, or commodity trading advisor or are members of any self-regulatory organization.</p><p>The information provided herein is not intended to be, and should not be construed in any manner whatsoever, as personalized advice or advice tailored to the needs of any specific person. Nothing on the Website should be construed as an offer to sell, a solicitation of an offer to buy, or a recommendation for any asset or transaction.</p><p>This post reflects the current opinions of the authors and is not made on behalf of Euler Labs, The Euler Foundation, or their affiliates and does not necessarily reflect the opinions of Euler Labs, The Euler Foundation, their affiliates, or individuals associated with Euler Labs or The Euler Foundation.</p><p>Euler Labs Ltd. and The Euler Foundation do not represent or speak for or on behalf of the users of Euler Finance. The commentary and opinions provided by Euler Labs Ltd. or The Euler Foundation are for general informational purposes only, are provided “AS IS,” and without any warranty of any kind. To the best of our knowledge and belief, all information contained herein is accurate and reliable and has been obtained from public sources believed to be accurate and reliable at the time of publication.</p><p>The information provided is presented only as of the date published or indicated and may be superseded by subsequent events or for other reasons. As events and markets change continuously, previously published information and data may not be current and should not be relied upon.</p><p>The opinions reflected herein are subject to change without being updated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c339e8209587" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eulerfinance/hello-2024-hello-new-euler-look-c339e8209587">Hello 2024, Hello new Euler look.</a> was originally published in <a href="https://medium.com/eulerfinance">Euler Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[War & Peace]]></title>
            <link>https://medium.com/eulerfinance/war-peace-ab2670711175?source=rss----26caa30240---4</link>
            <guid isPermaLink="false">https://medium.com/p/ab2670711175</guid>
            <category><![CDATA[hacks]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[euler-finance]]></category>
            <dc:creator><![CDATA[Michael Bentley]]></dc:creator>
            <pubDate>Wed, 10 Jan 2024 13:33:26 GMT</pubDate>
            <atom:updated>2024-05-22T16:07:12.784Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>War &amp; Peace: Behind the Scenes of Euler’s $240M Exploit Recovery</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wYlT21EFTfIKmMMVS2jqsA.png" /></figure><h3><strong>TL;DR:</strong></h3><ul><li>In March 2023, the Euler Protocol was exploited for ~$197 million in assets.</li><li>Over the course of the following three weeks, the Euler Labs team engaged in a highly strategic recovery effort that led to the return of ~$240 million in the stolen assets.</li><li>During the operation, multiple twists and turns threatened to throw things off course. These included the intervention of the notorious Lazarus Group, multiple red herrings, an unpredictable attacker and frontrunning bots.</li><li>The team that pulled off this exceptional feat is the same Euler Labs team that has been hard at work over the past year building a stronger, more powerful and modular V2 of the Euler platform which we’re excited to help rollout over the coming weeks and months.</li></ul><h3>Introduction</h3><p>As we enter 2024, I want to give you an update on what the Euler Labs team has been up to. While 2023 was not the year we had hoped for, we are more bullish than ever that 2024 will be a huge year for DeFi, and Euler especially. The brand refresh being unveiled today is just the beginning of a series of announcements we have planned over the coming months. The Euler team has been working on some transformative projects that will bring us ever closer to our mission of creating a truly modular DeFi trading ecosystem. But before we talk about the future let’s reflect on the series of events that took place this past year.</p><h4><strong>2023 — A look back</strong></h4><p>There’s no other way to put this: 2023 was a bit of a shit year.</p><p>I can’t think of a better way to say goodbye to it than by telling the story of how it played out. The tale starts very positively, for me at least, with the birth of my son, but then very quickly takes a dark turn with a devastating $200M attack on the Euler protocol and its users, before picking back up with an unprecedented $240M recovery story. So strap in for a tale of babies, bank runs, exploits, MEV bots, sleuthing, trolling, counter hacks, North Korea, negotiations, heart attacks, Laurence Day, recoveries, and much more.</p><p>It is my hope that by telling the story of the Euler exploit we can set the record straight and move onto the next chapter of the Euler story. As with many big news cycles, there was a lot of misinformation published and an endless amount of innuendo and rumours on social media. We enforced a communication blackout as part of our recovery strategy, which turned out to be essential for the recovery itself, but allowed external observers to have a field day speculating on how the recovery came about. Right now whenever we talk about Euler, people always want to look backwards — I want to put an end to that this year and get people excited about Euler’s future.</p><p>The most important part of this story is that Euler users’ assets were fully recovered and that the Euler community ultimately came out on top. The how and why will be interesting to some, perhaps insightful to others. Considering the complexities of crypto, the fact that we were dealing with what turned out to be an irrational bad actor(s), and interference from one of the world’s most ruthless hacking teams, this is a remarkable outcome.</p><p>I also want to make sure the people on our team and the broader investigation get credit for the monumental effort they put into the recovery. On one of our company all-hands calls shortly after the attack I told everyone I would help them get new jobs, to which one person replied: “<em>I’m not going anywhere until we find him</em>”. That attitude really sums up how our entire team responded to this incident. Our team really gave everything to the recovery effort, and we simply wouldn’t have seen the outcome we achieved without this extraordinary commitment. We’re a stronger, more resilient team today than we were in March 2023. Not only have we retained almost everyone that was with us a year ago, we’ve added top talent that have been drawn to Euler Labs because they believe in our potential to build great software.</p><p>Finally, it’s also just an objectively interesting story that I think deserves to be told. I can’t tell the story in its entirety for a variety of reasons. Not least because I have no intention of revealing the techniques we used to bring about the recovery. But the twists and turns and human elements are far more interesting than the technical details anyway.</p><p>I also want to emphasise that a lot of people were impacted by the events of 2023 and their stories are just as important as mine, but ultimately not mine to tell. This is my story as I experienced it. I’m going to tell it from a first-person perspective in chronological order because I can’t think of a better way to do it. I’ve generally avoided mentioning anyone else by name to protect people’s identities, but those people who helped in this case know who they are and have my eternal gratitude.</p><p>Ok, let’s dig in.</p><h3><strong>Euler in the beginning</strong></h3><p>I am one of three co-founders of a project called Euler, which started in the midst of the pandemic back in 2020. Back then, my co-founders and I started Euler with the goal to develop a decentralised finance (DeFi) protocol that would allow people to lend/borrow a wide variety of crypto assets directly from/to one another in an open, non-custodial manner.</p><p>Before starting the project I worked as an interdisciplinary research scientist at the University of Oxford, where I used to build game-theoretic mathematical and computational models of populations of organisms cooperating or competing with one another. I worked on topics as wide ranging as the evolution of cancer, antibiotic resistant evolution in bacteria, and the spread of invasive Hornet species. This might sound like a world away from DeFi, but the underlying game-theoretic principles are really not that dissimilar. That’s ultimately what attracted me to the DeFi movement that was starting to really take off in late 2019. I realised that many of the tried and tested mathematical techniques I was using in my day job could be applied to a brand new discipline.</p><p>My co-founders and I initially tried to differentiate Euler from market leaders like Compound and Aave with novel mechanisms around how interest rates could be set in a decentralised manner. We also designed the protocol to compose tightly with decentralised exchanges like Uniswap in order to offer users access to more lending markets than ever before. Over time, however, we ended up introducing a range of new innovations to the DeFi lending space, many of which focused on new ways of quantifying and managing risk. This helped the project to find admirers, especially among the DeFi developer community.</p><p>As the team and project grew, we also gained a reputation for taking security seriously. We weren’t building fast and breaking things as some others were boasting about doing at the time. We didn’t want the project to be a flash in the pan. We developed the protocol slowly and methodically, even as the wider crypto market was taking off and many other projects rushed to launch.</p><p>To reinforce our security-first approach, we had the protocol audited at great expense many more times than is the industry standard. Our audits invariably came back with excellent feedback from auditors. We had the UI audited. We put in place a $1M bug bounty for anyone who found critical bugs in Euler, higher than anything offered by other leaders in the space. We secured $10M insurance cover for the protocol by forging a partnership with a DeFi insurance firm (extremely rare in DeFi). Overall, we tried to go above and beyond the industry norms when it came to security wherever possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Mwyu2H7EtOJ94c0A" /></figure><p>Following deployment in Dec 2021, the protocol continued to grow in popularity. Even as the broader market was cooling due to the collapse of Luna, Celsius, FTX and others, Euler continued to find new users and grow its market share. And its enhanced liquidation module had been proven a success, lowering the cost of liquidations for borrowers more than 10x in some cases. Owing to its gas-efficient design and risk management features, it was also particularly popular with other decentralised organisations (DAOs) seeking to deposit treasury assets. Some of its biggest users resulted from integrations with other protocols like Angle, Balancer, and Idle.</p><p>Going into 2023 things looked very positive for Euler. It had been live on chain for over a year and had survived unprecedented and hostile market conditions for much of its existence, growing where others were wavering, pushing on where others were slowing down. That is until March 13th 2023, when things changed dramatically.</p><h3><strong>March 9th</strong></h3><h4><strong>Babies and bank runs</strong></h4><p>In the first few months of 2023 there was a sense of cautious optimism in the crypto industry. Most of the bad actors had been washed out the year prior. Green shoots of recovery were seemingly on the horizon. At Euler, we had been hard at work developing the core of what will soon become the next iteration of the Euler platform, what we’re currently calling “Euler V2.”</p><p>I was also waiting for the birth of my second child, who was due in early March. On Thursday March 9th, close to midnight, he arrived. My wife and I spent the next day with him and I told my team to expect me to be off on paternity leave for a couple of weeks. Everything was seemingly perfect, but as we all know, this didn’t last.</p><p>Outside of crypto, the wider global economy had been faltering and inflation was soaring. Interest rates had risen faster than at any time in history and many banks in the US were caught short. A lot of those struggling were holding US treasuries that were rapidly decreasing in value and lenders started to worry they might not be able to satisfy short-term requests for withdrawals. Silicon Valley Bank was the first domino to fall.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UK_W1AQqqWZuExuR" /></figure><p>One might think that a bank run on a fairly small bank in the US would have had a limited impact on crypto markets, but that wasn’t the case. One of the largest tokens by market capitalisation is a USD denominated stablecoin called USDC, which gives users digital dollars to use on chain. USDC should ordinarily be redeemable for exactly $1, because it is matched 1:1 with USD bank deposits, but hours after my son was born the bank run started to threaten its backing and it began to de-peg from $1 and trade lower as redemptions stalled.</p><p>The problem for Euler was twofold: First, the Euler DAO had a treasury holding more than $25m in USDC. Second, the Euler protocol had many millions in USDC used as collateral for loans. If USDC went to zero, it could send the treasury to zero and cause problems for protocol users along with it.</p><p>With my son less than 24 hours old, I had to get to work. I spent the whole weekend making calls to other teams, banks, investors, and others, trying to map out what, if anything, could be done. It felt like Euler could be in real trouble.</p><p>Fortunately, as quickly as the drama started, it went away. By late Sunday night, U.S. banking regulators had taken extraordinary measures to shore up deposits in the impacted banks. Likewise, over the next days and weeks international regulators took steps to provide additional liquidity and oversight to their own shaky depository institutions. All that worry for nothing it seemed. I went to bed exhausted, but looking forward to spending more time with my son on Monday.</p><h3><strong>March 13th</strong></h3><h4><strong>Euler exploited</strong></h4><p>The next morning, on March 13th, during our usual breakfast routine, I could hear something ringing upstairs in my office. I rushed up to see what all the noise was about, expecting it to be something related to the bank run, but it was much much worse. Messages were coming from all directions telling me something unusual was happening with the Euler protocol. An attack was ongoing and tens of millions of dollars appeared to have already been drained. I jumped on a call with other members of our team as we tried to figure out what was actually happening.</p><p>Of all the times for this to happen as well, it seemed so cruel. The ups and downs of the previous days gushed over me and I knew that things would likely get worse before they got better. Unfortunately there was no time to grieve for the situation though. As the adrenalin kicked in I got to work with my team. There was so much to do.</p><h4><strong>WTF is the donateToReserves function?</strong></h4><p>One of the first tasks was figuring out exactly how the attack was carried out. Fortunately this was done exceptionally quickly because the entirety of the Ethereum security community had been digging through the rubble of the exploit within minutes of it being detected. The cause was identified as a single missing line of code in an obscure code path involving the now famous ‘<em>donateToReserves’</em> function inside of Euler.</p><p>To understand how the attack worked, it’s important to understand the purpose of the <em>donateToReserves</em> function in the first place. People looking into the details of this function noticed that it was not present in the initial Euler code base when it was deployed back in 2021.</p><p>So where did it come from? Why would you ever want to donate your own assets to the protocol’s reserves? Unfortunately some people rushed to speculate about this on social media. Rumours were soon spread that <em>donateToReserves</em> was unaudited code introduced for vanity purposes. This was simply not true at all. The code was introduced for an important reason, and most definitely audited. Some people were even saying that the Euler developers had introduced the function deliberately as a back door to drain the protocol themselves — insinuating that we were about to go on the run! There was a lot of noise to filter out in those first few hours.</p><p>The truth is that <em>donateToReserves</em> was introduced in order to fix a much smaller ‘first depositor’ bug in the protocol that had been missed by all previous auditors of Euler. That bug was eventually reported by a white hat hacker (ethical hacker) as part of the Euler bug bounty program via Immunefi almost a year <a href="https://twitter.com/kankodu/status/1698992717089604064">prior</a> to the 2023 attack. The white hat had identified in their submission that the original version of the Euler protocol was vulnerable to allowing first depositors in new, uninitialised pools to have their deposits stolen by a front-runner. The reason they highlighted was that an internal exchange rate in the protocol was not properly initialised when there were no pre-existing depositors, allowing would-be front-runners to set it arbitrarily.</p><p>At the time the bug bounty submission came in for the first depositor bug it had not been spotted by prior auditors or been exploited. Had it been exploited, it would have likely led to minimal losses and would very likely have been covered by the $10M insurance programme Euler had in place. Nevertheless, bugs that permit theft of assets, no matter how small, need to be mitigated. So a plan was put in place to make sure it was patched. That patch created the vector for the March 2023 exploit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/0*ZAKAxcGDmGepWuw5" /></figure><p>The proposed solution was developed and sent to the auditors for review. That solution would work for all new markets activated after the patch, but for a subset of pre-existing it would not. So a new function — <em>donateToReserves</em> — was included to make sure that the internal exchange rate of those pre-existing markets could be addressed too.</p><p>The solution was sent to audit by the most recent auditor of Euler. That auditor was also the protocol’s insurer, with a $10M insurance payout potentially on the line if anything went wrong. So they were strongly incentivised to get it right. On completion of the audit, an upgrade to the smart contracts was proposed to the Euler DAO community, and by July 2022 the first depositor bug was patched.</p><p>Unfortunately there was a critical issue with the introduction of <em>donateToReserves</em> that no one spotted at the time (or for a prolonged period after). Specifically, the function lacked a health check to make sure that an existing user wouldn’t be able to put themselves in an unhealthy state just by donating to the reserves. Clearly this is something that an ordinary user should never want to do, so in retrospect it’s not hard to see how it was missed at the time.</p><p>Ultimately, the attacker exploited the missing health check in this function to instead donate a large amount of their own collateral to the reserves in order to make themselves eligible for liquidation. They then self-liquidated themselves to claim a liquidation bonus that was greater than the losses caused by the donation.</p><p><strong>First clues left by the attacker</strong></p><p>When something like this happens in the crypto industry, the worst case scenario is that it is perpetrated by organised crime or a state-sponsored actor, because then there’s very little hope of recovery, regardless of how good the investigation into what happened is. But if the attack is carried out by an individual or is opportunistic in nature, there is a much better chance of finding out who did it and getting some or all of the stolen assets back.</p><p>Fortunately for Euler users, there were early signs that this attack was not carried out by an experienced black hat hacker. There was a sliver of hope. There is a small sub-group of security specialists, sleuths, and white hat hackers within the Ethereum community that will often offer to help projects in such circumstances, and they were the first to notice something rather strange about the way the exploit had been carried out. We were hugely appreciative for their support in the immediate aftermath of the exploit and for their continued and dedicated support in the weeks that followed.</p><p>Most exploits begin with the withdrawal of funds to a privacy-preserving protocol like Tornado Cash (a protocol which provides users with a greater degree of anonymity than they would normally expect to have from transacting on Ethereum, which is ultimately a public ledger). The withdrawn funds, whose origins are then hard to trace, are then used to pay for deployment of exploit code and exploit transactions. Most exploits will take place in a single clean transaction very soon after the code encoding the exploit logic has been deployed on chain. However, in the case of the Euler exploit, the first few transactions were anything but <a href="https://twitter.com/SlowMist_Team/status/1635241569887617024">clean</a>.</p><h4><strong>The exploit in real-time</strong></h4><p><em>Note that hereafter sections involving communications and transfers are often told in present tense rather than past for clarity and ease of understanding.</em></p><ul><li>At 8:50:23 am UTC the attacker uses an address labelled as <a href="https://etherscan.io/address/0xb2698c2d99ad2c302a95a8db26b08d17a77cedd4">Euler Finance Exploiter 1</a> to deploy the exploit smart contract (labelled as <a href="https://etherscan.io/address/0x036cec1a199234fc02f72d29e596a09440825f1c#tokentxns">Euler Exploit Contract 2</a>) to Ethereum. This contains the logic for the theft of assets from Euler, but does not actually steal anything itself unless the attacker carries out further transactions using it. Note that the labelling of the exploit smart contract by Etherscan is a little confusing here (why 2 and not 1?). This will become clear in a moment.</li><li>We would normally expect an attacker to start using their exploit smart contract very soon after they have deployed it to carry out the attack itself, but that is not what happens here. Instead, at 8:50:35 am UTC, just seconds after the first exploit smart contract is deployed, a second copy of the exact same smart contract is deployed (labelled as <a href="https://etherscan.io/address/0xebc29199c817dc47ba12e3f86102564d640cbf99#tokentxns">Euler Exploit Contract 1</a>) by another address labelled as <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a>.</li><li>Shortly after, at 8:50:59 am UTC, <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a> carries out the first exploit: a single <a href="https://etherscan.io/tx/0xc310a0affe2169d1f6feec1c63dbc7f7c62a887fa48795d327d4d2da2d6b111d">transaction</a> which steals around ~$8.8M worth of assets from the protocol. Then they halt their attack and go strangely quiet.</li><li>At 8:56:35 am UTC <a href="https://etherscan.io/address/0xb2698c2d99ad2c302a95a8db26b08d17a77cedd4">Euler Finance Exploiter 1</a> picks up where <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a> left off, triggering several more exploit <a href="https://etherscan.io/tx/0x298bde3f9e53f7a5d870f7f5d56ee2f5e41fa25e6eb5e74611ac97025405db55">transactions</a> over a period of around 15 minutes. They then convert most of their stolen assets to ETH and DAI and withdraw the majority to a second attacker-controlled address, labelled as <a href="https://etherscan.io/address/0xb66cd966670d962c227b3eaba30a872dbfb995db">Euler Finance Exploiter 2</a>.</li><li>At 10:33 am UTC, <a href="https://etherscan.io/address/0xb66cd966670d962c227b3eaba30a872dbfb995db">Euler Finance Exploiter 2</a> then <a href="https://etherscan.io/tx/0x32be972bef6302d42d83ef624765ffd962728912a5896ce7e5d2092ff009ae07">sends</a> 100 ETH to yet another attacker-controlled address, labelled as <a href="https://etherscan.io/address/0xc66dfa84bc1b93df194bd964a41282da65d73c9a">Euler Finance Exploiter 4</a>.</li><li>At 10:38 am UTC <a href="https://etherscan.io/address/0xb2698c2d99ad2c302a95a8db26b08d17a77cedd4">Euler Finance Exploiter 1</a> then <a href="https://etherscan.io/tx/0x4e6e4631f3f128d2fb0e8613e868c200da8439cb6e6367288b3569a257d63f5c">sends</a> 100 ETH onwards to Tornado Cash. This was considered to be bad news, because anyone sending funds to a privacy-preserving protocol probably does not have plans to return them.</li></ul><p>Immediately after the attack, the balances controlled by the four main addresses involved are:</p><ul><li>Main attacker address <a href="https://etherscan.io/address/0xb2698c2d99ad2c302a95a8db26b08d17a77cedd4">Euler Finance Exploiter 1</a> which holds ~$13.6M worth of ETH (~8,080 ETH)</li><li>Main attacker address <a href="https://etherscan.io/address/0xb66cd966670d962c227b3eaba30a872dbfb995db">Euler Finance Exploiter 2</a> which holds ~$34M worth of DAI and ~$149.2M worth of ETH (~88,752 ETH)</li><li>Main attacker address <a href="https://etherscan.io/address/0xc66dfa84bc1b93df194bd964a41282da65d73c9a">Euler Finance Exploiter 4</a> which holds only 1 ETH after the attack, but which becomes important in the story later on</li><li>Secondary attacker address <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a> which holds ~$8.8M worth of DAI</li></ul><p>The main attacker has also transferred ~$168k worth of ETH (100 ETH) from <a href="https://etherscan.io/address/0xc66dfa84bc1b93df194bd964a41282da65d73c9a">Euler Finance Exploiter 4</a> to Tornado Cash.</p><p>In total, stolen assets are worth ~$197M at the time of the attack, with several thousand affected users. Among the largest impacted users are other DAOs. Angle protocol, in particular, is severely hit, with ~$17M in losses. Those losses lead its over-collateralized stable coin to de-peg, threatening the viability of the entire protocol. Also impacted are protocols like Balancer, Idle, Yield, and many more. The number of other protocols with deposits in Euler really highlights its composability and just how much it was trusted by the wider developer community at the time.</p><p>Over the next few weeks, with the price of ETH rising during the negotiation period, the attacker eventually returns ~$240M worth of assets to Euler users. Some affected users even joke on social media that the attacker is a better trader than they are. It’s hard to overstate just how special an outcome this is for the Euler community. For users to come out ahead after an attack like this would be an outcome very few would expect — but they did.</p><p>Before we get there though, there’s a lot to cover in between.</p><h4><strong>Attacker gets front-run by a bot</strong></h4><p>Overall, the attack is a bit of a mess. What on earth happened here? <a href="https://etherscan.io/address/0xb2698c2d99ad2c302a95a8db26b08d17a77cedd4">Euler Finance Exploiter 1</a> is the first to deploy the exploit smart contract, but second to steal the funds. <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a> is second to deploy the exploit smart contract, but the first to steal funds. Digging into the details, we see that <a href="https://etherscan.io/address/0xb2698c2d99ad2c302a95a8db26b08d17a77cedd4">Euler Finance Exploiter 1</a> and <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a> both paid for the exploit to be carried out using different sources of funds.</p><p><a href="https://etherscan.io/address/0xb2698c2d99ad2c302a95a8db26b08d17a77cedd4">Euler Finance Exploiter 1</a> is funded by Tornado Cash. They are clearly the developer of the exploit smart contract, but it is difficult to trace the source of their funds back any further than that because of the privacy-preserving nature of Tornado Cash.</p><p><a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a> is funded by a mixture of two other protocols, called FixedFloat and Multichain, respectively. Interestingly, the source of their funds can be traced back a little further, all the way back to an <a href="https://x.com/SlowMist_Team/status/1635241569887617024?s=20">exploit</a> of another protocol just 30 days prior.</p><p>So, is there a single exploiter or two? If there is a single exploiter, did they make a mistake and accidentally deploy their exploit smart contract twice, leaving clues as to their identity?</p><p>At 11:38:11 am UTC the <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a> <a href="https://etherscan.io/tx/0xdae809e4a1ddf77c39d44a4acfe6165bedbc19a385c4b241242cc9bd582a80b9">withdraws</a> ~$8.8m worth of DAI back to <a href="https://etherscan.io/address/0xb2698c2d99ad2c302a95a8db26b08d17a77cedd4">Euler Finance Exploiter 1</a>. This might make it seem like <a href="https://etherscan.io/address/0xb2698c2d99ad2c302a95a8db26b08d17a77cedd4">Euler Finance Exploiter 1</a> and <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a> are one and the same, which could be good news for identifying the attacker because of the traceability of the source of funds for <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a>.</p><p>Unfortunately, however, at 12:08:35 pm UTC a <a href="https://etherscan.io/tx/0x44b559c86ca8ccac5c16df507516ef19c06042a48cdbd865cb9db4c52d15ea17">message</a> from <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a> is sent on chain which gives further details about what happened. They claim that the two attackers are unrelated parties after all. It reads:</p><p>“<em>Hi, I am the owner of a MEV bot that has accidentally frontrun the first tx of the hacker. It tried to frontrun the second tx but failed and only the contract has been created. I tried to return the money but the contract can only send to an address already in bytecode. Unfotunately it sent the money to the hacker’s address. I tried my best and I am very sorry for anyone who lost money.</em>”</p><p>The claim here is that <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a> did not mean to steal the first batch of funds. How is this possible? If not, why did they send funds to the hacker and not back to the protocol?</p><p>For those that aren’t aware, transactions on Ethereum are often made semi-public before they are processed by network validators for inclusion on the blockchain. This gives rise to opportunities for other users to extract value from them (so called ‘maximum/miner extractable value’ or MEV for short). Most forms of MEV involve some kind of front-running. A classic example is a <a href="https://support.uniswap.org/hc/en-us/articles/19387081481741-What-is-a-sandwich-attack-">sandwich attack</a>, in which an MEV searcher places an order right before and after a trade on a decentralised exchange protocol takes place. This allows them to front and back-run the transaction to make profit. A related type of profiteering happens in traditional finance via high-frequency trading (HFT).</p><p>Front-running is not just possible for exchange transactions though. Sophisticated MEV searchers will take any transaction they get advance notice of, rapidly simulate it, and if it makes a profit, try to copy it for themselves. In the case of the Euler exploit, the claim by <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a> is that their bot saw a very profitable transaction ahead of time and simply copied it, front-running the attack from <a href="https://etherscan.io/address/0xb2698c2d99ad2c302a95a8db26b08d17a77cedd4">Euler Finance Exploiter 1</a> on Euler.</p><p>Why then did <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a> send the stolen assets back to <a href="https://etherscan.io/address/0xb66cd966670d962c227b3eaba30a872dbfb995db">Euler Finance Exploiter 2</a> if they had no intention to steal anything? Decompilation of the exploit smart contract from bytecode back to human-readable code showed that the code they copied had a withdraw function that pointed back to <a href="https://etherscan.io/address/0xb66cd966670d962c227b3eaba30a872dbfb995db">Euler Finance Exploiter 2</a>. So it was simply not possible for <a href="https://etherscan.io/address/0x5f259d0b76665c337c6104145894f4d1d2758b8c">Euler Finance Exploiter 3</a> to do anything but send the assets back to the main exploiter, even if a smart contract deployed by their own address held them for a short period of time.</p><p>Did the MEV front-runner help? In many ways, clearly not. Their intervention led to a lot of wasted time by investigators trying to figure out the relationship between all the addresses involved that ultimately could have been better spent focussing on the main exploiter.</p><p>However, the front-running did help reveal some information about the main exploiter. In particular, it confirmed to us that this was unlikely to be a sophisticated state-sponsored actor or organised crime group. Why? Because, if it had been, the attack would have been orchestrated in a much cleaner way. There are techniques more sophisticated users can use to prevent front-running.</p><h4><strong>Information gathering</strong></h4><p>In the aftermath of an attack there is an enormous amount of information that needs to be gathered. Our team quickly organised around this task and started the painstaking process of identifying potential leads. To use a cliché, no stone was left unturned.</p><p>The amount of data we had to work with would take weeks to sift through and it was a largely manual task. The search would throw up countless leads and red herrings. The world of crypto is still small, and everyone is connected to everyone else if you look hard enough. And believe me, our team couldn’t have looked harder.</p><p>In conjunction with the decompiled smart contracts, analysis of the content and style of the exploit code logic, and some other tricks we had up our sleeves from information gathering, we were able to formulate a list of leads early on and figure out what kind of attacker we were likely working with.</p><h4><strong>Communications begin</strong></h4><p>As is normal after any exploit, we tried to reach out to the attacker the very same day with an on chain <a href="https://etherscan.io/tx/0x539c6fff0fce70e02dddd80a5534acf3df57deafbdc40f41abb20aa8f94a6d0d">message</a>. Our opening gambit to the attacker was simple and neutral in tone:</p><p>“<em>We understand that you are responsible for this morning’s attack on the Euler platform. We are writing to see whether you would be open to speaking with us about any potential next steps.</em>”</p><p>Ultimately there is a low probability that an attacker will respond to any message, regardless of what it says. However, it is obviously important to try to say <em>something</em> as a way to break the ice. Until sufficient evidence has been gathered to the contrary, it is always important to leave the door open to the (very) remote possibility that an attacker might be able to provide an explanation for what has happened. They might be open to exiting the situation as a white hat.</p><p>We were not particularly hopeful though. There were already several strong indications that this attacker was not likely to be open to negotiating in good faith. First, they had already converted most of the stolen assets into ETH and DAI. This incurred huge losses in slippage costs and is not something someone would normally do if they intended to exit as a white hat. Second, the attacker had already <a href="https://etherscan.io/tx/0x4e6e4631f3f128d2fb0e8613e868c200da8439cb6e6367288b3569a257d63f5c">transferred</a> 100 ETH to Tornado Cash within an hour or so of the attack. Given that they were already laundering stolen assets through a US-sanctioned protocol, it seemed unlikely that they would be open to negotiating in good-faith.</p><p>Normally the people handling exploit communications will start with a more deferential tone than the one we took. Something that tries to paint the attacker in a positive light. It might even say ‘congratulations’ to them for finding the vulnerability or highlight their skill. I don’t know why that approach has become the industry norm, but, for good reasons, including those stated above, it was not the approach taken here.</p><p>Ultimately, there is very little evidence that taking a deferential tone in negotiations actually works. If an attacker is not already minded to return assets voluntarily, they are unlikely to be persuaded of this by an overly-friendly message. In general, pretending to be nice to someone who has clearly harmed you is more likely to make you look weak and perhaps even comes across as patronising/infantilising.</p><p>In the meantime, we also enforced a company-wide blackout on social media communications except for a handful of carefully crafted and very deliberate Twitter updates. This went against industry trends, where the people dealing with the fallout of an exploit will often spend time on social media answering questions and trying to bring clarity to the situation. This is a completely reasonable and appropriate approach in many circumstances.</p><p>However, it wasn’t appropriate in our case because we had already gathered enough information about the attacker to know that there was a good chance that they might be anxious about what they had done. Anxiety is generally a feeling that you reduce by getting information that helps you collapse the vast state of uncertainty in front of you to something more contained and manageable. Even something as simple as a reply to an unrelated social media message can help collapse uncertainty and leak information. Limiting communication helped maintain maximum uncertainty in the attacker’s mind by starving them of information.</p><p>Our communications approach was quite different to how people have tended to handle exploit communications in the past and was initially criticised by a lot of people. Since we could not discuss our communications strategy at the time, it is my hope that this post goes some way to making it clear that the communications choices we made throughout the whole process were extremely strategic, almost obsessively so.</p><h4><strong>Laurence Day shows up</strong></h4><p>Late into the evening my wife and I had a visit.</p><p>Laurence Day is a crypto Twitter micro celebrity who gets accused of being behind every and all hacks in crypto as part of a longstanding joke. The reason for this is because he was a core contributor to another protocol that was exploited, and when the international media first wrote the story up about it they accidentally put a picture of his face next to the sub-heading ‘exploiter’, which then inevitably got copied far and wide. And so he became ‘the exploiter’ of his own protocol and pretty much everything else after that.</p><p>I didn’t know him all too well before this event, but as luck would have it he lives quite close to me and he had a newborn himself arrive just a few weeks before my son. I was on a lengthy call discussing the case when Laurence arrived and so I left him downstairs talking to my wife. After everything that had happened that day I can only imagine what she made of his appearance.</p><p>Laurence wasn’t the only person to show such kindness in the aftermath. Ethereum is an amazing community and we really felt that in the days and weeks that followed. Many people reached out to offer their support. Another person I’d never met, but who’d been through something similar, reached out just to talk about how I was feeling and see if they could offer some emotional support. That really helped me process things mentally.</p><h3><strong>March 14th</strong></h3><h4><strong>Reward for information launched</strong></h4><p>Unsurprisingly, no response was received to our first message. So the next day, on March 14th, we decided to take a more direct approach. We made a recommendation to the Euler Foundation to urgently launch a reward for information that might lead to an arrest and a return of all funds. Shortly after a new <a href="https://etherscan.io/tx/0x8f2b61a0c70012df1e3d918e7ac6486a1c332a9e530f3d4061735c6620f960d9">message</a> was sent on chain:</p><p>“<em>Following up on our message from yesterday. If 90% of the funds are not returned within 24 hours, tomorrow we will launch a $1M reward for information that leads to your arrest and the return of all funds.</em>”</p><p>Beyond actually getting information from a whistleblower or motivated sleuth, the goal here was to increase pressure on the attacker, to maintain their state of anxiety, and perhaps provoke a response from their side in order to gain further information about who they were.</p><p>Whilst a reward for information is not common in the industry, and some people felt that it was too soon and/or too aggressive from our side to be taking an approach like this, it was a strategic move that we felt we needed to make early to keep the attacker on edge.</p><p>Later we will learn from private communications with the attacker that this approach had worked better than we had ever imagined possible, but given what happened next, we wouldn’t know it at the time.</p><h3><strong>March 15th</strong></h3><h4><strong>A final message</strong></h4><p>Before the 24-hour deadline was up, we followed up with what we expected would be a final <a href="https://etherscan.io/tx/0x6715fb8f0e8dfe7b6c5ad7577a5bdc773dc7baca84a7c63492863aeaf2f6b1fe">message</a> that gave the attacker a final chance to work towards a more positive resolution:</p><p>“<em>The simplest way to move forward today is to return 90% of both the DAI and ETH under your control to the EulerDAO treasury address: 0xcAD001c30E96765aC90307669d578219D4fb1DCe. Then investigations can be halted, and the focus here can turn to distribution of that back to protocol users, without needing to go the legal route.</em>”</p><p>Here we wanted to give just enough of a hint that we had already gathered information to go the legal route whilst still offering an olive branch to achieve a swift resolution.</p><h4><strong>Community messages</strong></h4><p>We were not the only people sending messages to the attacker in the early days after the attack. Many other affected Euler users had been sending their own messages on chain pleading with the attacker to reverse their actions. One <a href="https://etherscan.io/tx/0xbe21a9719a4f89f7dc98419f60b247d69780b569cd8869c0031aae000f98cf17">message</a> that plays an important role in the story read:</p><p><em>“Please consider returning 90%/80%. I’m just a user that only had 78 wstETH as my life savings deposited into Euler, I’m not whale or millionaire. You can’t imagine the mess I’m into right now, completely destroyed. I’m pretty sure 20M is already life changing for you and you’ll bring back joy to a lot of affected people.”</em></p><p>Among the sad messages like this one there were also people messaging the attacker offering them tips on how to launder the proceeds of the attack (pretty common after exploits), as well as plenty of people just trying to bring a bit of humour to the situation (also pretty common).</p><p>Whilst probably quite hard to understand for people outside the industry, the gallows humour that follows these kinds of bad events in crypto is a key part of what binds the broader community together. It’s a nascent industry, bad things happen and so people build resilience through humour. It’s one of my favourite aspects of the culture. Anyway, one <a href="https://x.com/_bbodd/status/1637862795847819268?s=20">message</a> that was sent to the attacker that got a few laughs on social media purported to be from the aforementioned Laurence Day:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tUjqCqNQZTAbhRJq" /></figure><h3><strong>March 16th</strong></h3><h4><strong>More Tornado Cash transfers</strong></h4><p>At 1:19 am UTC on March 16th we finally seem to get a response to our messages, and it is not good. The attacker <a href="https://etherscan.io/tx/0x53f47eba4656a0713aea7f8ac67317bec43c04f3c7fa76ddf4a63e6e8d127213">transfers</a> another 2500 ETH to <a href="https://etherscan.io/address/0xc66dfa84bc1b93df194bd964a41282da65d73c9a">Euler Finance Exploiter 4</a>, and then <a href="https://etherscan.io/txs?a=0xc66dfa84bc1b93df194bd964a41282da65d73c9a&amp;p=3">transfers</a> another 1000 ETH of this into Tornado cash. This doesn’t look like behaviour consistent with someone planning to imminently negotiate a return of funds. Although it isn’t all the ETH, which gives us some hope.</p><p>There’s something odd about the way the attacker is working here though — the transfers are all in batches of 100 ETH. There is no reason to send ETH around in batches like this. Sleuths assisting the investigation and a number of people on social <a href="https://twitter.com/spreekaway/status/1636177626699005954">media</a> picked up on this unusual behaviour too and started to consider its implications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8NrTYSRHgy24zurI" /></figure><p>We saw it as more evidence that the attacker was either inexperienced at using Tornado Cash, or that they were on edge and acting irrationally. Either way, we felt like it might be good news for our chances of identifying and catching them.</p><h4><strong>A victim is refunded — who are they, and why?</strong></h4><p>Moments after the Tornado Cash transfers something even more remarkable happens. Out of nowhere the attacker <a href="https://etherscan.io/tx/0xcc8edbe70d22176e90027bb07047b5cc7541b169ef9ef71ae6d6793f344b8bc5">sends</a> 100 ETH to the victim who sent the message quoted above asking for the attacker to take a deal. The refund is even more than the victim lost in the attack (closer to 88 ETH). Why did the attacker do this? Social media lights up. Theories start flying.</p><p>Perhaps the attacker just craves attention or enjoys the power dynamic. They know the impact of this refund will be to provoke many more people to start sending messages asking for refunds too. Why would they want to encourage that kind of behaviour?</p><p>Or perhaps the attacker felt genuine sympathy for the victim after their message. If so, why send assets back to only one person? Many other people sent similar heartfelt messages of loss. What is special about this user?</p><p>Or perhaps the refund victim knows the attacker. Even wilder, maybe they <em>are </em>the attacker.</p><p>Or perhaps the attacker is just trolling, responding negatively to the messages we have sent them with a ‘fuck you’ signal. This is how many users interpret the situation. Frustration boils over in some cases as people start to express their concern about our approach to communication. One user gave particularly stinging feedback in a <a href="https://etherscan.io/tx/0x2699b544f8edce461a10530e14dec1d27fb1a03362fd5ff2082d1119a8faaada">message</a> on chain:</p><p>“<em>This dude is clowning on you all, are you not embarrassed? Making threats against him with no leverage. Escalating then practically begging for him to return our money when you had NOTHING to offer. Now we re almost certain it isn t NK and what, still nothing? Why would your first move be to threaten him legally, as if he wasn t aware the FBI was looking into it already? Your only shot was to appeal to his evidently existing good nature and offer up the 10%, but instead you re out here sheepishly asking about next steps ? What a joke you ve made yourselves out to be.</em>”</p><p>Messages like these were difficult for our team to process, but also understandable considering the situation Euler’s users were in. People had been hard hit by the attacker’s actions and wanted to know that everything possible was being done to get a positive outcome. Whilst our team was working extremely hard towards that goal in the background, and nothing was done without a reason, ultimately we had nothing to show for our hard work at this point. And we didn’t want to jeopardise our strategy by commenting publicly. So the only thing we could do was keep pushing with the investigation. It seemed clear that we were going to need to make further progress towards getting some leverage on the attacker.</p><h4><strong>Refund victim red herring</strong></h4><p>We began to investigate the refund victim’s address, and what we found made our eyes light up. Unlike the attacker’s address, which was harder to connect to any real-world identities directly, the address belonging to the refund victim participated in many transactions that meant it was not too difficult to track it back to a likely owner.</p><p>That person turned out to be a developer who had contributed to building another lending protocol. Which seemed very coincidental indeed.</p><p>At this point we have identified that the refund victim has means to commit the attack. We also find evidence of their familiarity with the Euler code base and there are other significant links too. No smoking guns, but a lot of coincidences. Little did we know that we weren’t the only ones looking into the identity of the refund victim though.</p><p>Later that day a crypto media outlet tracked the refund victim down independently and put it to them that they might be the hacker (see the article <a href="https://www.dlnews.com/articles/regulation/euler-finance-hacker-eth-wallets-solidity-developer-exploit/">here</a>). To which the refund victim replied: “Seriously? No, I’m not the hacker.” Shortly after the user <a href="https://etherscan.io/tx/0xbb450229bf8eaf62d41e62b8d4e6495f1d952a10da0ef72bf048c376c56719e1">returned</a> the excess 12 ETH sent by the attacker to the EulerDAO treasury with the message:</p><p>“<em>I was affected by the recent Euler Finance hack and fortunately, I received back 100 ETH from the hacker, which is 12 ETH more than my original deposit of ~78 wstETH. With this transaction, I’m returning the extra 12 ETH that doesn’t belong to me to the Euler Finance Deployer.</em>”</p><p>Could this all be a coincidence? Ultimately it turned out to be just that. For a short period of time though it appeared that it could be a major breakthrough. But it was just one of several red herrings that turned up during the investigation.</p><h3><strong>March 17th</strong></h3><h4><strong>Attacker sends funds to North Korea</strong></h4><p>At 3:48 am UTC on March 17th the attacker makes a new <a href="https://etherscan.io/tx/0x202a67d3a1d52e4dd5e1eebe49da511164b6e4a1ebe717dcf4674dd83a2bd457">transaction</a>. This time it is not to a victim, himself or to Tornado Cash, but, astonishingly, to an address labelled as <a href="https://etherscan.io/address/0x098b716b8aaf21512996dc57eb0615e2383e2f96">Ronin Bridge Exploiter</a>. This is the address of an exploiter that carried out an $600M+ attack on a bridge protocol a year earlier. What is astonishing about the address is that it was attributed by the US Treasury’s Office of Foreign Assets Control as belonging to <a href="https://www.cfr.org/cyber-operations/lazarus-group">Lazarus</a>, a group of state-sponsored professional hackers that do work for <a href="https://www.elliptic.co/blog/540-million-stolen-from-the-ronin-defi-bridge">North Korea</a>.</p><p>This is a major escalation and marks a major shift in the nature of the investigation. On the one hand, this could be a major blow as it could be a signal that the attacker is Lazarus themselves or is so confident in their ability to not get caught that they can comfortably troll Euler users by transferring funds to a sanctioned entity.</p><p>On the other hand, we had already gathered a lot of information about the attacker at this point and were confident that they were not associated with Lazarus. So we felt like this was either a poor attempt at misdirection or someone spiralling and out of their depth. Both of which were good news for our chances of catching them.</p><h3><strong>March 18th</strong></h3><h4><strong>Attacker sends a small percentage of funds back to Euler</strong></h4><p>Given what happened the day before, we were not expecting the attacker to send assets back to Euler users anytime soon, but at 6:20 am UTC on March 18th, that’s exactly what they started doing.</p><p>Beginning with a <a href="https://etherscan.io/tx/0x20f89e9f029c1552ac1b1e2346c8305924ac76d9252a84c91a2b3157c669ab6a">transaction</a> for 1000 ETH, a total of 3000 ETH is sent back (worth ~$5.3M). Overall, this amounts to less than 3% of the total stolen funds, so is a drop in the ocean in the scale of things. Whilst the initial transaction gets everyone’s hopes up, it’s hard to take this as a positive signal when the assets stop being sent back. Given what happened the day before, it feels like the actions of someone trolling or at best unsure of what to do next.</p><p>The attacker has now sent stolen funds to a second attacker-controlled address, Tornado Cash, a seemingly random victim, Lazarus, and Euler. There seems to be no real rational explanation for this behaviour, unless they are just trolling, which is how most people interpret it at the time.</p><p>A few hours later, at 10:20 am UTC, another transaction is made. This time it is an empty <a href="https://etherscan.io/tx/0xfa2a703767e3bfc854288dc5228c25bcde240bee8f1faac019c2f10ed2165b9d">transaction</a>, with no message or ETH sent. This could be seen as yet more trolling, and we think that is the most likely reason for it, and yet, there’s an outside chance it is a prompt to communicate. We need to respond. Despite it feeling like the attacker is still just trolling, at 12:00 pm UTC we send a <a href="https://etherscan.io/tx/0xc72d8b553651500c88730573a9839f230a98273dba16d1aad2496c8916ab1d04">message</a> that attempts to encourage a continuation of funds returned:</p><p>“<em>Thank you for returning a portion of the assets. The original offer still stands if you would like to continue by returning the funds. The reward for information will be removed immediately and all our investigations will be dropped.</em>”</p><p>In the meantime, we have now gathered a lot of information about the leads we have been following. We have been working non-stop on the investigation since the day of the exploit.</p><p>We ponder whether or not to get on the front-foot a bit more, reaching out via back channels to leads. Doing this could be risky though, because we could alert the attacker themselves, causing them to flee, or disturb someone entirely unrelated, causing them to protest their innocence on social media. Ultimately we decide to bide our time and keep working.</p><h4><strong>Team safety</strong></h4><p>Meanwhile, one of the key team members helping on the investigation called me in the early hours of their day. They wanted to discuss their personal situation because, for a variety of reasons I can’t disclose, they weren’t feeling safe. We explored options to help increase the safety of their situation and even talked about getting them on a plane that very day and putting them up in alternative accommodation abroad. It was traumatic in the extreme for the person involved. They could have been forgiven for walking away at that point, but if anything it only redoubled their resolve in the coming days. Words can’t express my appreciation for the dedication and resolve of our team.</p><h3><strong>March 19th</strong></h3><p>The team continues to do intensive research potential leads, but it’s Sunday and the attacker appears to be taking a day off. Not so for the Euler team — much was happening behind the scenes. Although there were some days where little was publicly disclosed or there was little visible communication, there was hard work around the clock — running down each and every lead, helping to coordinate multiple parallel and tangential investigations, and other things we cannot disclose.</p><h3><strong>March 20th</strong></h3><h4><strong>A breakthrough?</strong></h4><p>On March 20th at 4:10 pm UTC, a new mysterious <a href="https://etherscan.io/tx/0x404d90f39628aafc040959f07ccf7de8c6492a82855d14d11ff3361cf84677f1">message</a> comes through from <a href="https://etherscan.io/address/0xb2698c2d99ad2c302a95a8db26b08d17a77cedd4">Euler Finance Exploiter 1</a>. This one simply reads:</p><p>“T_27”</p><p>There is lots of speculation among our investigation about what this might mean. It shows up as a tank on google search. Perhaps it is something encoded as bytes. 2 and 7 are the first few digits of Euler’s number ‘e’. Is this just more trolling?</p><p>As the debate rages, a breakthrough moment happens. At 4:51 pm UTC, a new <a href="https://etherscan.io/tx/0xcc73d182db1f36dbadf14205de7d543cfd1343396b50d34c768529aaab46a1c0">message</a> is sent from <a href="https://etherscan.io/address/0xb66cd966670d962c227b3eaba30a872dbfb995db">Euler Finance Exploiter 2</a>:</p><p>“<em>We want to make this easy on all those affected. No intention of keeping what is not ours. Setting up secure communication. Let us come to an agreement.</em>”</p><p>At 7:14 pm UTC we <a href="https://etherscan.io/tx/0x9c25b6ca65c5bd0597a13ceae6f0d6edcef4b10279f338114550926ad0387ce4">respond</a>:</p><p>“<em>Message received. Let’s talk in private on blockscan via the Euler Deployer address and one of your EOAs, via signed messages over email at contact@euler.foundation, or any other channel of your choice. Reply with your preference.</em>”</p><p>We eagerly await a response, but none is forthcoming. Was this just yet more trolling? The use of the plural ‘we’ is a point of interest. We continue to keep digging and uncover more information about the leads we have been working on. The team has been working around the clock on this, with many of us getting 3 hours a night sleep.</p><h3><strong>March 21st</strong></h3><h4><strong>The return of Lazarus</strong></h4><p>It’s now March 21st, and we are still hard at work, but the day is going slowly. The risk feels like it is growing that the attacker is buying time in preparation for something unpleasant, perhaps to flee or strike a deal with another black hat. It’s been 8 days since the exploit and less than 3% of the funds have been returned.</p><p>All of a sudden, at 5:02 pm a new <a href="https://etherscan.io/tx/0xcf0b3487dc443f1ef92b4fe27ff7f89e07588cdc0e2b37d50adb8158c697cea6">message</a> is sent. This time it is not from the Euler attacker though. It is from the <a href="https://etherscan.io/address/0x098b716b8aaf21512996dc57eb0615e2383e2f96">Ronin Bridge Exploiter</a> to the <a href="https://etherscan.io/address/0xb66cd966670d962c227b3eaba30a872dbfb995db">Euler Finance Exploiter 2</a> address:</p><p>“<em>Decrypt with the private key of 0xb66cd966670d962c227b3eaba30a872dbfb995db (https://github.com/LimelabsTech/eth-ecies).</em></p><p><em>bKsKXCYxBlQjY2opFlBVGQQrnjzy67s6xFc/+GIVX9YeGakmzz/EXsNZlAUhF37Q8RjVBn3DRVJP94ncxGS+j1wu5dLo4RRXrKSIrZzceoqVZ2pvsx02Pyl3K5SW3Yf/nzt96To3KOxN5sQqJZkfH6+RWwc+KoTAmomW1FNVWhlwV9UqKuuLwEo5heFmSFgBSJYNztvAEzZ/8Ra1BWu9P1OzBbmx67W0/2DdDMAK31tX</em>”</p><p>This is extremely alarming. It’s clear immediately what is happening. Lazarus is trying to counter-exploit the Euler exploiter. If the Euler exploiter loses the funds to Lazarus they are gone forever. We respond as quickly as we can with a flurry of messages. The first <a href="https://etherscan.io/tx/0x054409f252ac293a0ed34108b25e5906476817c5489bd3e98a5d3e1ee0825020">message</a> we send out straight away reads:</p><p>“<em>Be very careful using that decryption tool. The simplest way out here is to return funds.</em>”</p><p>Shortly after we follow up with another <a href="https://etherscan.io/tx/0x1fd6d2e67a2ac4cf7c1718cc3058d5625171b95d66744801c97a4de54a41197b">message</a>:</p><p>“<em>Do not try to view that message under any circumstance. Do not enter your private key anywhere. Reminder that your machine may also be compromised.</em>”</p><p>And finally, after digging deeper, with yet another <a href="https://etherscan.io/tx/0xe1fff14e317968591a8dac40630ae572bea943a2758029a44ce5bdd28aa26635">message</a>:</p><p>“<em>Do NOT use the suggested decryption tool. It has an old version of ellyptic, which has a vulnerability:</em></p><p><a href="https://security.snyk.io/package/npm/elliptic/6.4.0"><em>https://security.snyk.io/package/npm/elliptic/6.4.0</em></a></p><p><em>“There is no check to confirm that the public key point passed into the derive function actually exists on the secp256k1 curve. This results in the potential for the private key used in this implementation to be revealed after a number of ECDH operations are performed.”</em>”</p><p>The drama of this is not lost on people watching events unfold on <a href="https://twitter.com/functi0nZer0/status/1638233004152594434">social media</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ujZNeKTV79mcthFE" /></figure><p>Moments later, a new <a href="https://etherscan.io/tx/0x47708ec86525944dc5d3085aa58d8164e6065b99d1fb88ba95762033c393c01a">message</a> is sent from <a href="https://etherscan.io/address/0xb66cd966670d962c227b3eaba30a872dbfb995db">Euler Finance Exploiter 2</a> to us:</p><p>“<em>We still want to do the right thing returning funds to the Euler team. Will communicate shortly.</em>”</p><p>Breakthrough! Or so we think.</p><h3><strong>March 22nd</strong></h3><h4><strong>Private communication attempt number 1 begins</strong></h4><p>Hours go by without any communication. It feels like another dead end. I could not be more tired having stayed up all night discussing the previous day’s events. Then finally, at 2:24 pm UTC on March 22nd, a new <a href="https://etherscan.io/tx/0xfe256e86a6d9f50b558e1c66a5174bbe8e79fc316e2ed75dfdc743bdd1c905d8">message</a> comes in from <a href="https://etherscan.io/address/0xb66cd966670d962c227b3eaba30a872dbfb995db">Euler Finance Exploiter 2</a>:</p><p>“<em>Euler: from INTACH3ZZ@PROTONMAIL.COM</em>”</p><p>After 9 days since the exploit, we appear to have a line of private communication. The attacker’s opening message is:</p><p>“<em>Dear Dr. Michael,</em></p><p><em>From this email address we should talk privately with you and the Euler Team. It is in our best interest to step out of this unfortunate situation as soon as possible. I hope that we can define a course of action in a few correspondences.</em></p><p><em>Thanks,</em></p><p><em>Jacob</em>”</p><p>Is this someone acting in good faith or just more games though? It’s interesting that the email refers to ‘us’ and ‘we’ and is signed from ‘Jacob’. Is the plural a bluff, or are we really dealing with a team here? Why did they address me specifically, and not the project more generally?</p><p>And what is the significance of the name Jacob? Clearly that is not the attacker’s real name. One possibility we explore is that it is a biblical reference. Jacob is a character in Genesis sometimes referred to as the ‘<a href="https://knowingscripture.com/articles/jacob-the-righteous-deceiver">righteous deceiver</a>’. In some bibles the name also apparently means ‘he cheats’.</p><p>Then we discover there is potentially a link back to the refund victim. Someone from the investigation points out:</p><p>“<em>fyi the santichez name on twitter is Santiago. which is Jacob. is a male Spanish name that derives from the Hebrew name Jacob. </em><a href="https://en.wikipedia.org/wiki/Santiago_(name)"><em>https://en.wikipedia.org/wiki/Santiago_(name)</em></a>“</p><p>We also explore if there is any further information to be gained from the email address itself. One of the sleuths comes back with an answer:</p><p>“errrrrrrrrrrrrrr what if he’s fucking with us, inta chez would translate to “you are gay””</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*swJGgppmrSIBKD8v" /></figure><p>Overall it still feels like this is still someone not taking things seriously. Nevertheless, we write a short email response and wait.</p><h3><strong>March 23rd</strong></h3><h4><strong>An eventful hospital trip</strong></h4><p>Meanwhile, at home, my eldest child is ill (later, we discover, with covid). With my wife looking after the newborn, I have been looking after my eldest as best I can during the night time on top of everything else. In the first few days after the exploit I had pretty much no sleep. That increased to 3–4 hours a night for a few days, but it dropped back to more or less zero with the new health issues at home. Obviously that isn’t a sustainable amount of sleep to be having, especially given everything else going on.</p><p>After a stressful start to the morning, sometime after lunch on March 23rd I suddenly start having pains in my chest and I’m struggling to breathe. My wife brings me to the hospital, where it could not be busier. As we enter the waiting room, at 1:45 pm UTC, a new email comes in from the attacker. I sit waiting for quite a while to be seen, responding to messages from our team as we explore options for replies.</p><p>Eventually I’m met by a doctor and told that I need an electrocardiogram to check my heart, which they are supposed to do very quickly for someone with my symptoms. But as anyone that has dealt with the NHS recently can attest, things rarely go smoothly. There are simply none of the machines available in the Accident and Emergency part of the hospital. So one of the doctors offers to walk me down to the nearby Resus (i.e. ‘resuscitation’) department where there is likely to be one free.</p><p>I kid you not, as we walk into the room, I hear the characteristic long beep as someone in a nearby bed goes into cardiac arrest. Alarms suddenly started going off everywhere and I was pushed out into the hallway. I could hear family members crying and doctors shouting. My anxiety hits a new high, but the experience helps keep things in perspective.</p><p>Over the course of these hours, I was conscious that we’d not replied to the attacker. That amount of delay is simply not ok when so much is on the line. So I sat among the other patients and crafted a response with our team while having blood tests drawn. After this, I promptly passed out from exhaustion.</p><p>After waking up and settling again in the waiting area with a dead phone and dying laptop, a few hours later I was told my symptoms were more likely the result of anxiety and a panic attack than a heart attack, and was sent home where I finally had a few hours sleep.</p><h3><strong>March 24th</strong></h3><p>A lot of investigative forensic work continued, much of which we can’t discuss in detail. The weekend is bearing down on us and we don’t want the attacker to have time off to think, but do we push them again? We decide against it, but continue our internal investigations.</p><h3><strong>March 25th</strong></h3><h4><strong>Almost 50% of stolen assets are returned</strong></h4><p>Then, on March 25th, at 3:08 pm UTC, 51,000 ETH (worth ~$90m) is suddenly returned by <a href="https://etherscan.io/address/0xb66cd966670d962c227b3eaba30a872dbfb995db">Euler Finance Exploiter 2</a> to Euler in a new <a href="https://etherscan.io/tx/0xb0308ee113c541e7c6f4623e833417524d68fd6267d23f43d9041f583c14343f">transaction</a>. That’s almost half of the assets returned now. Are they planning on returning all of them? Either way it’s a huge moment for everyone involved, especially Euler users. Even a 50% recovery from an attack like this is almost unheard of. Moments later a new <a href="https://etherscan.io/tx/0x1f19df917c30b3308eca319c28c593b6f088d8d113dd50aef98d6cfeccf23bf6">message</a> is sent on chain though:</p><p>“sheeps4music at xyzmailhub.com”</p><p>It seems like maybe the attacker wants to open a new line of private communication. What is wrong with <a href="/service/mailto:INTACH3ZZ@PROTONMAIL.COM">INTACH3ZZ@PROTONMAIL.COM</a> though? We quickly check and the latter email is longer operational. Then things go crazy again, as they always seem to do. Two steps forward one step back.</p><h4><strong>Prisoner’s dilemma or a bluff?</strong></h4><p>The attacker sends from <a href="https://etherscan.io/address/0xb66cd966670d962c227b3eaba30a872dbfb995db">Euler Finance Exploiter 2</a> 4 more <a href="https://etherscan.io/tx/0x79c10cf538667a0a7de40ce54d2444c9e9e17b5c62b321e739020df0015baeda">transactions</a> of ~7700 ETH each (worth ~$13.5M each), this time not back to Euler, but to four new attacker-controlled addresses: <a href="https://etherscan.io/address/0xa1b44d4b5b4c361f51e029b81bf2db9cf4d8e676">0xa1b44d…F4D8e676</a>, <a href="https://etherscan.io/address/0x46e0be2df97dac791fc8e30cf2b2e4f58c50cf55">0x46e0Be…8c50Cf55</a>, <a href="https://etherscan.io/address/0xc4e04ac48639ff077ebb36e7cfe0c4993b7b208e">0xC4e04A…3b7b208E</a>, and <a href="https://etherscan.io/address/0x8765a35394c98e81b9d56d44248e1199d8e38a4c">0x8765A3…D8E38A4c</a>. These addresses also subsequently each receive ~10.7M DAI from <a href="https://etherscan.io/address/0xb66cd966670d962c227b3eaba30a872dbfb995db">Euler Finance Exploiter 2</a> as well. This means each of the four addresses controls around $24M worth of the stolen assets (~$13.5M ETH + ~$10.7M DAI).</p><p>The last of these transactions is at 3:32 pm UTC. At this point, it looks like the exploiter has decided to keep more than 50% of the stolen funds. Why have they distributed the stolen assets among four addresses though? Are there four attackers?</p><p>A few minutes later though, at 3:38 pm UTC, address <a href="https://etherscan.io/address/0x46e0be2df97dac791fc8e30cf2b2e4f58c50cf55">0x46e0Be…8c50Cf55</a>, sends a <a href="https://etherscan.io/tx/0xc9641dceab1311d219523e5d3914df31f6a97986d5e331db45387037ea06a07c">transaction</a> of all their ~7700 ETH back to Euler, along with a cryptic message seemingly pointing to an email address for further communication:</p><p>“<em>x @ proton.me</em>”</p><p>Around 30 minutes later, at 4:08 pm UTC, they then send their DAI back to Euler too. Well, sort of. Of the 10.7M DAI they hold, they send ~1.23M DAI back to Euler in this <a href="https://etherscan.io/tx/0x9eb6836a0948e4d89cc20415181dc102dfe34a39c7a31f3eac077ae1e79e5103">transaction</a>. Then a flurry of peculiar messages follows. First, at 4:09 pm UTC, they <a href="https://etherscan.io/tx/0x9f2f0a75b8387ddd6b37ecf54e6dd9100aaab636dce52370bff52ac751feb6d8">message</a>:</p><p>“<em>email me ASAP will give up every fucking thing about hacker for 15%</em>”</p><p>Then, at 4:15 pm UTC, they bizarrely lower their offer with another <a href="https://etherscan.io/tx/0xc591cee9fbf98557dc98352f43c91bb2eaad3bcda20dfe8ba23eb3bf56509b1e">message</a>:</p><p>“<em>email me ASAP will give up every fucking thing about the hacker for 10% like offered.</em>”</p><p>And then at 5:07 pm UTC, they appear to drop negotiations entirely with yet another <a href="https://etherscan.io/tx/0xd3b7478a8409d4418ca56c82e1568eb5c76961f28764038b74a436a1eb81bef4">message</a>:</p><p>“<em>Euler exploiter 3 here.. please just email xxxyyy990@umail.edu.pl .. will reply with info ASAP.. dont care about buonty</em>”</p><p>We send emails to the two email addresses <a href="/service/mailto:x@proton.me"><em>x@proton.me</em></a><em> </em>and <a href="/service/mailto:xxxyyy990@umail.edu.pl"><em>xxxyyy990@umail.edu.pl</em></a><em> </em>but both seem to be dead ends. What on earth is happening in all this?</p><p>One interpretation is that the attacker is actually a group of four individuals, and they have decided to send ~50% of the funds back to Euler and then split the rest equally among themselves. But then, in a classic prisoner’s dilemma style standoff, one of the individuals has decided to break rank. Whoever controls <a href="https://etherscan.io/address/0x46e0be2df97dac791fc8e30cf2b2e4f58c50cf55">0x46e0Be…8c50Cf55</a> seems worried about being caught and is trying to lessen their future sentence by trying to return stolen assets voluntarily in a show of good faith.</p><p>At this point, however, the story is not compelling. We send an email to <a href="/service/mailto:sheeps4music@xyzmailhub.com">sheeps4music@xyzmailhub.com</a> calling the attacker’s bluff, making it clear that the time for games is up. Minutes later they give up the charade, transferring the ~9.5M DAI remaining in <a href="https://etherscan.io/address/0x46e0be2df97dac791fc8e30cf2b2e4f58c50cf55">0x46e0Be…8c50Cf55</a> to one of the other four attacker-controlled addresses in this <a href="https://etherscan.io/tx/0x79d5a1f873c52942cc1eb681ef8f6b1005e3fcfa48db5b66e63962b6696e4845">transaction</a>.</p><p>At 7:43 pm UTC the sleuths assisting the investigation notice a new <a href="https://etherscan.io/tx/0xd88d9e8e6055eb426ea234c4fed64a4d25b73c334d6d43640fc6c5cb85eca446">message</a> come through on chain from the attacker offering a new email address <a href="/service/mailto:sheeps4music@mail2tor.com">sheeps4music@mail2tor.com</a> to talk over. They ask what it is about (they were not privy to private communication over email) and I tell them we had received an email from that email address and had asked for confirmation on chain that it was genuine. The message they were seeing was simply a confirmation message. Meanwhile, over email, a new round of discussions are underway with the attacker, this time with a very different tone. At 8:45 pm UTC I message the sleuths:</p><p>The conversation with the attacker continues into the early hours of the next day. Our approach appears to be working.</p><h3><strong>March 26th</strong></h3><p>It’s a frustratingly quiet day on the communication front, but the team continues the forensic work at all hours. It is unclear if the response from the attacker was merely more trolling or an attempt to buy more time.</p><h3><strong>March 27th</strong></h3><p>On the following day, the pressure campaign begins to pay off and the attacker starts sending more of the stolen assets back.</p><p>First, at 6:13 pm UTC, a <a href="https://etherscan.io/tx/0xe3f67f8e50042f09a3d9b6873bd15c14fa8b8176cfa1069bc1d3ab71e4b3fd0d">transaction</a> from <a href="https://etherscan.io/address/0xa1b44d4b5b4c361f51e029b81bf2db9cf4d8e676">0xa1b44d…F4D8e676</a> sending ~7700 ETH (~$13M) back to Euler.</p><p>Quickly followed at 6:21 pm UTC by another <a href="https://etherscan.io/txs?a=0xee009faf00cf54c1b4387829af7a8dc5f0c8c8c5">transaction</a> from <a href="https://etherscan.io/address/0x8765a35394c98e81b9d56d44248e1199d8e38a4c">0x8765A3…D8E38A4c</a> sending its ~7700 ETH back.</p><p>And then another at 6:29 pm UTC from <a href="https://etherscan.io/address/0xc4e04ac48639ff077ebb36e7cfe0c4993b7b208e">0xC4e04A…3b7b208E</a> sending its ~7700 ETH back.</p><p>A few minutes later at 6:40 pm UTC the attacker <a href="https://etherscan.io/tx/0x32a56c42cc4e4750ee1e10121caaff3eee8162ea210c75795dec7bed8b77cdc1">sends</a> a further ~10.7m DAI back to Euler from <a href="https://etherscan.io/address/0x8765a35394c98e81b9d56d44248e1199d8e38a4c#tokentxns">0x8765A3…D8E38A4c</a>.</p><p>At this point it looks like they might be about to return <em>all </em>of the stolen assets, but as usual, they take pause.</p><p>At 6:58 pm UTC they send a <a href="https://etherscan.io/tx/0x3d0b3a04a7031841b44c94b4f9cccdc397b0f6e97f7cc2ecfcc3abe8732a995f">transaction</a> for 20M DAI from <a href="https://etherscan.io/token/0x6b175474e89094c44da98b954eedeac495271d0f?a=0xa1b44d4b5b4c361f51e029b81bf2db9cf4d8e676">0xa1b44d…F4D8e676</a> to a brand new attacker-controlled address <a href="https://etherscan.io/address/0x0d1b0c32b52583fd155ea6a2df10214270da9843#tokentxns">0x0d1B0c…70DA9843</a>. What are they planning to do with this? Are they going to try to keep 10% of the total stolen? It seems possible. That offer is no longer on the table though. It had long been withdrawn.</p><p>At 7:24 pm UTC they then send another <a href="https://etherscan.io/tx/0x1cce9b2fca807e53717f8867d1fceaee00a839b493aeab7931f0ff7699b482f8">transaction</a> for 3M DAI from this new address back to Euler, leaving 17M outstanding in the new wallet.</p><p>New emails are then exchanged over the course of the next few hours. The attacker mentions retaining hold of assets as a ‘safeguard’. We are pushing hard at this point.</p><h3><strong>March 28th</strong></h3><p>A few hours later, in the early hours of the 28th, they ask for forgiveness for the harm done to Euler’s reputation and the time taken away from me with my son. At 1:23 am UTC we reply:</p><p>“<em>I’m sitting with my wife and son right now typing this message. You’re right that you can’t change those first few days with my newborn. But you can change tomorrow for me. He’s two weeks old now. I would love to spend the day with him. I really do not care about winning or losing or the reputation of the protocol. None of that matters in the end. The same is true for you. The money, which you can never spend, is completely useless to you if you can’t live a full life after this.</em>”</p><p>A little while later several new messages are sent on chain.</p><p>First <a href="https://etherscan.io/tx/0xf69c53b82273764989cdecf75b6daabb0c0bd30b4e659bca080948126c1f992c">message</a> from the attacker at 1:56 am UTC:</p><p>“<em>The rest of the money will be returned ASAP. I only look after my safety, and that is the reason for the delay. I’m sorry for any misunderstanding. Please read my next message.</em>”</p><p>Second <a href="https://etherscan.io/tx/0xedd8102ca037abaeb75ce6a1afe951d2953258392d891ff23510276993a5437c">message</a> from the attacker at 1:57 am UTC:</p><p>“<em>Jacob here. I don’t think what I say will help me in any way but I still want to say it. I fucked up. I didn’t want to, but I messed with others’ money, others’ jobs, others’ lives. I really fucked up. I’m sorry. I didn’t mean all that. I really didn’t fucking mean all that. Forgive me.</em>”</p><p>Back on email the attacker requests to talk to me personally over a call or through voice messages to get reassurances. It’s 4:14 am UTC, and I’m beyond tired, but I agree to do it on the proviso that the remaining funds are returned. Sometime after, more funds are returned to Euler.</p><p>A <a href="https://etherscan.io/tx/0x92eefa6056aff0f27e29945a4e0d951fa5a1ade3138031b9c035a39018d057eb">transaction</a> at 4:51 am UTC sends a further 5M DAI back to Euler from <a href="https://etherscan.io/token/0x6b175474e89094c44da98b954eedeac495271d0f?a=0x0d1b0c32b52583fd155ea6a2df10214270da9843">0x0d1B0c…70DA9843</a>.</p><p>A few more hours go by, and then at 8:28 am UTC I receive my first direct message over a social media platform. This was clearly essential to engage with to continue to build trust and encourage the return of funds, but also extremely high risk. I knew that if I were to say the wrong thing the remaining assets might never be returned. I was very conscious that it could also have been a trap.</p><p>In the conversation I continue to press for the return of the remaining assets whilst also trying to build trust and keep things moving. I asked at one point whether he considered the bug bounty too small and why he didn’t consider taking that route instead of carrying out the exploit. He said it wasn’t something he really considered. His answer was that he wasn’t experienced enough to know about all the options he had available to him once he knew about how to carry out the exploit; the attack was apparently hypothetical for him until the last minute, and he wasn’t even sure it would work.</p><p>We talk for some time until the midwife arrives to see my wife and son. It feels like a natural point to end the conversation so I urge him to return the funds whilst our appointment is underway.</p><p>Then it all goes quiet again. Recovery stands at around 84% at this point. The pressure to say something publicly is enormous by this point, but we know that if we do and get it wrong, any progress we’ve made could quickly unravel.</p><h3><strong>March 29th</strong></h3><p>Following the private conversation our team has a lot to work on.</p><h3><strong>March 30th</strong></h3><p>We sense the attacker’s anxiety and fear they may have changed their mind. I replay the conversation we had over and over again in my head. That night I can barely sleep again. I send my wife this message at 1:01 am UTC:</p><p>I started experiencing this exploding head syndrome phenomenon most nights before I went to bed after this point. It’s apparently not that uncommon, but I had never experienced it before and it really shook me. Fortunately I haven’t had it in a long while.</p><h3><strong>March 31st</strong></h3><p>The next day starts slowly, though quickly picks up. In the early afternoon, a number of transactions come through. Are we done? Of course not.</p><p>Unfortunately the transactions all involve sending small amounts of dust back to Euler. There are still millions of dollars worth of assets unreturned. Are these dust transactions just more trolling? Or are they some kind of signal?</p><p>A <a href="https://etherscan.io/tx/0xcc02b5926752eb6a937e46c3b9917545825ef336ce9e7b22444f49e5d803d185">transaction</a> at 2:41 pm UTC sends dust ETH back to Euler from <a href="https://etherscan.io/address/0xc4e04ac48639ff077ebb36e7cfe0c4993b7b208e">0xC4e04A…3b7b208E</a>.</p><p>A <a href="https://etherscan.io/tx/0x0aa80b2f4e2828c14d5b129f17a02ffa4624fa342ff8cdca513b585ccfce469a">transaction</a> at 2:42 pm UTC sends dust ETH back to Euler from <a href="https://etherscan.io/address/0x46e0be2df97dac791fc8e30cf2b2e4f58c50cf55">0x46e0Be…8c50Cf55</a>.</p><p>A <a href="https://etherscan.io/tx/0x5c75312d5b697f6f1e10080000757249b32215a01ba7b81fef0fb4f19c5ff8df">transaction</a> at 2:43 pm UTC sends dust ETH back to Euler from <a href="https://etherscan.io/address/0x8765a35394c98e81b9d56d44248e1199d8e38a4c">0x8765A3…D8E38A4c</a>.</p><p>Shortly after, at 3:12 pm UTC a new cryptic <a href="https://etherscan.io/tx/0xea24b805ef563251169732569e161b8c376ef0022ba73b9718890d9c582e10ca">message</a> is sent from the attacker to a seemingly brand new address. It simply reads:</p><p><em>“Was asked for this</em>”</p><p>It looks like a confirmation message for someone the attacker is in private conversation with. We know it isn’t us who asked for it though. Who is it for? There is a lingering concern that he is in the process of making some kind of deal with another black hat to launder the remaining stolen assets.</p><p>A little while later we start to better understand what’s happening though. I received a message from none other than Laurence Day saying that someone has been trying to contact me. The message to him was from a member of the Euler community who claims to be the intended recipient of the ‘<em>was asked for this</em>’ message.</p><p>It turns out that starting March 29th, during the period of silence we have had with the attacker, they have forged direct contact with two Euler community members on social media. The motivation for doing this isn’t entirely clear. It’s hard to understand why the attacker hasn’t just returned the remaining assets. Is this more misdirection? Is it delaying tactics? Is it trolling? Can the community members be trusted? Clearly we need to continue to tread carefully.</p><p>From talking to one of the community members it seems the motivation of the attacker for reaching out to other people from the community is to get advice on reputation management and a second opinion on the best course of action next in terms of returning the remaining assets. They are also talking about taking out loans, which sounds concerning. The attacker also tells one of the community members they are waiting to meet someone later that evening to discuss their plans and help them manage their safety. Again, this sounds more than a little ominous.</p><h3><strong>April 1st</strong></h3><p>I ask one of the sleuths from the war room to reach out independently to the attacker over social media to bring a fresh impetus to things and reiterate the message that the best way out is to return the stolen assets as soon as possible. As with all communications that went out, it’s a carefully crafted message, deliberate and strategic.</p><h3><strong>April 2nd</strong></h3><p>By the evening of April 2nd things have once more become intolerable. The promise to return all assets has not been met and it seems like the attacker is once again not operating in good faith. We push more, taking a direct approach and sending them an email reminding them of what is at stake for them.</p><p>I’m starting to feel incredibly unwell by this point. Something about the symptoms reminded me of how I felt when I first caught covid, so I decided to take a test. Sure enough it was positive. When I spoke to my wife she too was feeling unwell and tested positive. It seems likely our eldest was patient 0. We assumed our newborn son would be fine since covid rarely affects babies.</p><p>Meanwhile our latest email has had the desired effect, and contact is reestablished just a few hours later. This time the attacker messages me again from a different social media account. I urge them to end things immediately. They request that things can be ended without resentment. At 11:49 pm UTC we offer reassurance:</p><p><em>“Not that kind of team. Everyone just wants to move on. Be great if it ends with a positive story.”</em></p><p>It seems like their conversation with the war room sleuth has also picked up, but as usual, things then go quiet. It’s 5 am local time by the time I can finally sleep.</p><h3><strong>April 3nd</strong></h3><p>Safe to say we’re all ready for this to be over at this point. At 8:02 am UTC the attacker sends me a new message saying funds will be back within the hour. I can’t allow myself to believe it. Sure enough, at 9:36 am UTC they say it is taking longer than expected. We ask them if it is guaranteed to be done by 2:00 pm UTC. They say it is.</p><p>At 12:56 pm UTC they ask where the remaining assets should be transferred to. We tell them to the DAO treasury address. This feels like it could be it. I message the Euler team a couple of minutes later:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/0*CuZTwPGq06RX1mSP" /></figure><p>Does it happen? No.</p><p>Minutes go by. And keep going by. Each one feels like an hour. At 1:50 pm UTC we nudge the attacker. They respond at 2:07 pm UTC saying there’s not much left to do. We demand an update. We then let the Euler team know things are still very uncertain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/0*JO-z6zFC1996JJ_h" /></figure><p>At 3:35 pm UTC we press the attacker again. A minute later they respond, making a request. We reject it and remind them it is important to return the funds before people think they have changed their mind.</p><p>At 4:13 pm UTC we ask what the delay is about.</p><p>At 5:52 pm UTC they message saying 30 more minutes.</p><p>At 7:03 pm UTC they message saying they are ready to go.</p><p>At 7:45 pm UTC they message saying they have emailed a list of requests. One of them asks me to:</p><p>“<em>organize a party for you and your team, with nice food and drinks, and beautiful girls, somewhere in the future</em>”</p><p>Are they trying to actually be nice or is this a joke? It certainly seems at this point like this could be just another game. I’m at the end of my tether. I would love nothing more than to scream back at this point. But there’s obviously little sense doing that. So we get to work crafting a response to the requests. We opt to hit each one with a straight bat.</p><p>At 9:14 pm UTC we reply to a direct message saying the email response is nearly ready. We end by saying:</p><p><em>“Has to be now though. Further delay is a red line.”</em></p><p>At 10:01 pm UTC the email response is sent.</p><p>Every question answered. Including the party one, to which we say simply:</p><p><em>“Respectfully, this is a time for humility and reflection and does not seem like the right time to think about a party.”</em></p><p>At 10:16 pm UTC they respond on direct message:</p><p>“Going for it”</p><p>There is another frustrating wait, and I’m trying not to lose my patience with them. Then, finally, a <a href="https://etherscan.io/tx/0x237309bd163e2f9b38d4a788d67d149c1f4e3016da33e790828b896295668ac4">transaction</a> at 10:49 pm UTC sends a further 12M DAI back to Euler from <a href="https://etherscan.io/token/0x6b175474e89094c44da98b954eedeac495271d0f?a=0x0d1b0c32b52583fd155ea6a2df10214270da9843">0x0d1B0c…70DA9843</a>.</p><p>At 10:51 pm UTC they send a message saying that they know I hate them. We reply:</p><p><em>“I don’t hate you. Really wish you hadn’t done it obviously, but everyone makes mistakes. Important thing is you’re making it right so that everyone can focus now on the future.”</em></p><p>Minutes later the remaining funds are returned. First a <a href="https://etherscan.io/tx/0xd2434db80a22daf270d50682eefb45611647d39a5aa6e3632cc8bdf58b78cb97">transaction</a> at 10:54 pm UTC sends all the remaining assets from <a href="https://etherscan.io/address/0xb2698c2d99ad2c302a95a8db26b08d17a77cedd4">Euler Finance Exploiter 1</a>, ~8080 ETH (~$14.6M) back to Euler. Then a <a href="https://etherscan.io/tx/0xd935879ad47f23b2a7c4eb4480dbd7d917a52ee679c305c308196c24da5982d5">transaction</a> at 10:59 pm UTC sends all remaining assets from <a href="https://etherscan.io/address/0xc66dfa84bc1b93df194bd964a41282da65d73c9a">Euler Finance Exploiter 4</a>, ~2500 ETH (~$4.5M) back to Euler.</p><p>It’s over. In the end, the strategy worked. There is much that cannot be disclosed, but the attacker was compelled for a number of reasons to return the funds.</p><p>At 11:07 am UTC we announce the news with a single <a href="https://x.com/eulerfinance/status/1643027386802270210?s=20">tweet</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aCEZMxQOMAJ7mCNv" /></figure><p>At 00:15 am UTC we write to the sleuths in the war room to thank them for their support.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MOjngy5bei6F-dOj" /></figure><h3><strong>April 4th</strong></h3><h4><strong>Covid setback creates communications challenges</strong></h4><p>The next morning there were lots of messages of congratulations, but I was feeling so rough that I could honestly barely feel anything about the outcome. Our team was exhausted, but were already hard at work handling the enormous challenges still ahead of us.</p><p>Meanwhile, my son was also getting quite ill. We ended up having to call an ambulance. Both him and my wife suffered complications from covid and spent several days in hospital.</p><p>During those days there were a lot of questions about what happened from journalists and questions about what the next steps would be from affected users. Given the health issues in my family it was hard to contribute to communications though and whilst many people were thankfully sympathetic to the situation, some grew a bit frustrated.</p><p>The challenge was that very few people actually knew what had happened or had information to share because we generally kept things incredibly tight-lipped during the recovery process. People in the broader Euler team and many in the war room had only a little more information than the general public.</p><p>Unfortunately, the information vacuum led people to speculate on what might have happened, and some on social media got quite creative with their ideas and came to the conclusion that it must have been us all along:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1ArwHwgZr7I1gRTW" /></figure><p>You got us, Chris!</p><p>The media also started speculating about what had happened. One article claimed to have interviewed a key Euler negotiator. Others speculated that Euler had been bailed out by influential partners. Seeing people who had played relatively minor roles — or no role at all — in the recovery story receive public adulation was quite disheartening for our team who had really given everything.</p><p>There was plenty of other misleading information floating around too, including about the attacker. So much so that the attacker even messaged us about some of the stories at one point, seemingly annoyed that our team had perhaps been briefing against him to the media. The reality was that we had not spoken to the media about the attacker. The only time we had done so was to seek corrections for misleading stories.</p><h3><strong>Rest of the year</strong></h3><p>At some point during this process my wife and I began to worry more about our home security. There were stories being published around the time of the exploit about people being <a href="https://www.dailymail.co.uk/news/article-11903219/Crypto-prodigy-23-abducted-TORTURED-scamming-investors-29M.html">tortured</a> in their homes over their crypto holdings. And here we had hostile messages, an active attacker, Lazarus involvement, potential organised crime links, a social media firestorm fueled by misinformation, among other things. Some of the hostility has been pretty relentless — the joys of being a public builder in crypto.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FUUM84M4j9O0aF44" /></figure><p>At home, we had additional security systems fitted and I began exploring better ways to secure my private keys. I wanted them sharded and records proving that they weren’t kept inside the house. I eventually found a solution and everything seemed to be fine. Then in November one of my hardware wallets developed a fault. Not a problem I thought, I’ve got the private key. Ultimately it turned out I didn’t though.</p><p>Somewhere in between the birth of my son, our exploit recovery efforts, personal and family illnesses, I made an error and it turns out that one of the private keys is no longer recoverable. This means that I’ve now lost a substantial percentage of the crypto assets I held in cold storage, accumulated over more than seven years, including the majority of the EUL allocated to me for participating in Euler governance (~4.4% of the total supply is now effectively removed from circulation).</p><p>In terms of my Euler allocation, I am currently considering my options and will likely make some form of proposal to the DAO at some point. My focus right now is entirely on the relaunch though. Ultimately I take responsibility for whatever happens next. I would have once found this outcome absolutely devastating, but the earlier events of the year really helped put the important things in life into perspective for me.</p><h4><strong>January 2024 Update</strong></h4><p>Good news! I have recovered my wallet. Thanks to everyone who supported me. Fingers crossed 2024 continues as it started.</p><h3><strong>Conclusion</strong></h3><p>So there it is. A turbulent tale, but one with a (mostly) happy ending. While many might have lost their resolve following an ordeal such as this, I couldn’t be prouder of the way the Euler Labs team came together to solve an almost insurmountable challenge. Even in the best of circumstances, a 100% recovery of assets is a rare outcome. With crypto, it’s almost unheard of.</p><p>We’re hugely grateful for all the support and warm wishes we received along the way. While the words above share my perspective, they represent the work of dozens of people on the Euler team and beyond, from all around the world. That same Euler team has been hard at work over the past year building a stronger, more powerful and modular V2 of the Euler platform which we’re excited to help rollout over the coming weeks and months.</p><p>The story doesn’t end here — the only way is forward.</p><p><strong>Disclaimer:</strong></p><p>This piece is provided by Euler Labs Ltd. for informational purposes only and should not be interpreted as investment, tax, legal, insurance, or business advice. Euler Labs Ltd. and The Euler Foundation are independent entities.</p><p>Neither Euler Labs Ltd., The Euler Foundation, nor any of their owners, members, directors, officers, employees, agents, independent contractors, or affiliates are registered as an investment advisor, broker-dealer, futures commission merchant, or commodity trading advisor or are members of any self-regulatory organization.</p><p>The information provided herein is not intended to be, and should not be construed in any manner whatsoever, as personalized advice or advice tailored to the needs of any specific person. Nothing on the Website should be construed as an offer to sell, a solicitation of an offer to buy, or a recommendation for any asset or transaction.</p><p>This post reflects the current opinions of the authors and is not made on behalf of Euler Labs, The Euler Foundation, or their affiliates and does not necessarily reflect the opinions of Euler Labs, The Euler Foundation, their affiliates, or individuals associated with Euler Labs or The Euler Foundation.</p><p>Euler Labs Ltd. and The Euler Foundation do not represent or speak for or on behalf of the users of Euler Finance. The commentary and opinions provided by Euler Labs Ltd. or The Euler Foundation are for general informational purposes only, are provided “AS IS,” and without any warranty of any kind. To the best of our knowledge and belief, all information contained herein is accurate and reliable and has been obtained from public sources believed to be accurate and reliable at the time of publication.</p><p>The information provided is presented only as of the date published or indicated and may be superseded by subsequent events or for other reasons. As events and markets change continuously, previously published information and data may not be current and should not be relied upon.</p><p>The opinions reflected herein are subject to change without being updated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab2670711175" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eulerfinance/war-peace-ab2670711175">War &amp; Peace</a> was originally published in <a href="https://medium.com/eulerfinance">Euler Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modularity, The Way Forward To Building DeFi Systems]]></title>
            <link>https://medium.com/eulerfinance/modularity-the-way-forward-to-building-defi-systems-35fa95f7329a?source=rss----26caa30240---4</link>
            <guid isPermaLink="false">https://medium.com/p/35fa95f7329a</guid>
            <category><![CDATA[modular-system-design]]></category>
            <category><![CDATA[defi]]></category>
            <dc:creator><![CDATA[Doug Hoyte]]></dc:creator>
            <pubDate>Tue, 12 Dec 2023 14:48:56 GMT</pubDate>
            <atom:updated>2024-05-22T16:07:30.579Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lmNGrO-oYPU-m2KlYzY1ow.png" /></figure><h3>Containing Complexity</h3><p>Engineering is largely about containing complexity. By creating well-defined interfaces, and enforcing that modules interact through these interfaces, each module can ignore the inner workings of the other modules and focus on its own implementation.</p><p>Consider engineers building a bridge. They don’t need to work out a new chemical composition of metal specific for their project. Instead, they will take an existing steel “off the shelf”. The steel is a module, and the interface is the desired properties, such as tensile strength, weight etc. If some new material came along with these same properties, it could be used for future bridges without requiring any new bridge-level redesigns.</p><p>In electronics, products are built out of reusable components such as microchips. These components were often designed without any knowledge of the final product they will be used in. In fact, they are usually designed to first be plugged into a testing fixture, during which they are called the “device under test”. Later on, when the end product is assembled, it too will be a device under test before it is finally shipped to customers. Treating components as modules that conform to interfaces tames the complexity.</p><h3>Leaky Abstractions</h3><p>That is the theory. As components themselves become more complicated, using them effectively requires understanding their inner design. In software engineering this is common enough to be given a name: <a href="https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-abstractions/">Leaky abstraction</a>.</p><p>Consider the simple case of numbers. Programmers can’t even treat <em>these</em> as pure modules. For example, you might assume that adding 1 to a number will always give you a new number that is greater than the original. In many programming systems, including Solidity, this is not so: a fixed amount of memory is allocated to store a number, and if you exceed this it will either throw an error or wrap back around to a lower number, as in a car odometer.</p><h3>Modularity in Finance</h3><p>Financial systems are also designed to be modular and standardised.</p><p>When you trade stocks, you will typically see them listed according to their ticker symbols, such as GOOG for Google. But underneath this, securities also have special numbers called CUSIPs. For instance, Google’s class A shares have code 38259P508. In a sense, you can think of these as equivalent to Ethereum addresses: They are unique identifiers that exchanges, brokers, etc., can use to ensure they (or their computers) are all talking about the same thing.</p><p>How do their computers talk to each other? Most often, it is over a protocol called FIX. This protocol specifies various fields that are common to different message types and gives them numeric tags. For example, CUSIP codes are stored in the SecurityID field, which is given tag 48. Since every company is speaking FIX, it is relatively easy to plug in new connections to existing systems.</p><p>That is the theory. In practice, the numbering system is a mess. Before using the SecurityID field, you need to also check IDSource (22). As well as CUSIPs, many other numbering standards are in common use: RIC, ISIN, ISO currency codes, exchange-specific numbers, and more. And this is just talking about the US. Most other countries have their own numbering standards, such as SEDOL in the UK.</p><p>The FIX protocol itself is only superficially compatible. Every different provider has their own custom variations of which FIX version they support, which fields they use, and the meanings of those fields. Each entity has its own bespoke interface documentation (often hundreds of pages long), and it is a significant engineering effort to integrate anything at all.</p><p>In my opinion, this is the true opportunity of DeFi: finally making good on the largely unfulfilled promise of FIX and the numbering authorities and creating a seamlessly interoperable international financial system.</p><h3>Smart Contracts</h3><p>On the blockchain, the primary unit of modularity is the smart contract. Smart contracts have their own internal storage, and other smart contracts cannot directly read this storage. Why is this? It is not so that contracts can store secret values: Everything on the blockchain is public information and can be read off-chain by anyone with access to a node.</p><p>This restriction is there to enforce modularity. Contracts have no way to interact with other contracts except through the interfaces that these other contracts choose to provide.</p><p>In the context of DeFi, sophisticated systems will typically be constructed as a constellation of contracts that communicate via well-defined interfaces. For example, rather than having a single lending contract, Compound uses special-purpose cToken contracts to hold each asset.</p><p>Building systems as intercommunicating contracts has the benefit that individual components can be accessed by external systems as well, as long as they conform to the exposed interfaces. Additionally, separation into contracts can be used to form trust boundaries between components to increase system security.</p><h3>Defect Containment</h3><p>In the original version of the Euler contracts, there was a module called the Swap module. This allowed users to swap their eTokens for other eTokens by effectively withdrawing them, swapping on a DEX like Uniswap, and then re-depositing them. Because all user funds were retained in a “singleton” contract, tokens never needed to transit any other wallet for a swap, and this operation was maximally gas efficient.</p><p>However, the Swap module had to be very carefully coded and audited because it ran in the context of the main contract. In other words, it was part of the <a href="https://cr.yp.to/qmail/qmailsec-20071101.pdf">trusted code base</a> (TCB).</p><p>To add an additional layer of defense, we created a new module called SwapHub that invoked “swap handlers” outside the TCB. Swap handlers are isolated contracts and are treated as though they could themselves be malicious actors. They are given the funds the customer wants to swap, and then are invoked. If they do not send back a sufficient amount of the desired token to meet the customer’s slippage checks, then the transaction is aborted. In this way, any defects in the swap handler — malicious or not — are fully isolated.</p><p>Based on decomposing how DeFi systems work today, our own experience, and some of the current thinking around intents-based systems, we have decided to take this concept much further. In the new system we’re designing at Euler Labs, we have created a flexible but minimal TCB, and have moved as much of the possible system outside of this trust boundary.</p><h3>Money Lego</h3><p>As the number of modules in a system increases, the number of possible interconnection pairs grows quadratically. Therefore, coding each contract to specifically interact with all other possible contracts is infeasible.</p><p>The way we solve this is with standardised interfaces: Every token-like contract exposes a balanceOf method, no matter what type of asset it is storing, or how it is implemented internally. ERC-20 is the basis for standard tokens on Ethereum. Even though it has several well-known shortcomings, all tokens are written to conform to it. This itself is proof of how powerful standards are: Any possible gain from improving the interface would be much smaller than the loss of breaking compatibility with the rest of the network.</p><p>Another standard is <a href="https://ethereum.org/en/developers/docs/standards/tokens/erc-4626/">ERC-4626</a>, the Tokenised Vault Standard. This standard is wisely backward-compatible with ERC-20, but adds new interfaces suitable for yield-bearing tokens.</p><p>At Euler Labs, we believe ERC-4626 will be a fundamental standard. In our interpretation, lending activity will involve multiple vault contracts working together: at least one as collateral and one as a liability. To make this work, we are building a meta-layer for vaults to interact with each other and generate interconnected liquidity, which will also benefit Euler v2. Powered by a modular design, these vaults will also be highly customisable: creators will be able to choose oracles, set LTV, risk managers, and take advantage of additional functionality such as batching, gasless transactions, simulations, and more. Ultimately, standardising modularity at this level will create an ecosystem that will eclipse isolated and bespoke lending markets.</p><p><strong>Disclaimer:</strong></p><p>This piece is provided by Euler Labs Ltd. for informational purposes only and should not be interpreted as investment, tax, legal, insurance, or business advice. Euler Labs Ltd. and The Euler Foundation are independent entities.</p><p>Neither Euler Labs Ltd., The Euler Foundation, nor any of their owners, members, directors, officers, employees, agents, independent contractors, or affiliates are registered as an investment advisor, broker-dealer, futures commission merchant, or commodity trading advisor or are members of any self-regulatory organization.</p><p>The information provided herein is not intended to be, and should not be construed in any manner whatsoever, as personalized advice or advice tailored to the needs of any specific person. Nothing on the Website should be construed as an offer to sell, a solicitation of an offer to buy, or a recommendation for any asset or transaction.</p><p>This post reflects the current opinions of the authors and is not made on behalf of Euler Labs, The Euler Foundation, or their affiliates and does not necessarily reflect the opinions of Euler Labs, The Euler Foundation, their affiliates, or individuals associated with Euler Labs or The Euler Foundation.</p><p>Euler Labs Ltd. and The Euler Foundation do not represent or speak for or on behalf of the users of Euler Finance. The commentary and opinions provided by Euler Labs Ltd. or The Euler Foundation are for general informational purposes only, are provided “AS IS,” and without any warranty of any kind. To the best of our knowledge and belief, all information contained herein is accurate and reliable and has been obtained from public sources believed to be accurate and reliable at the time of publication.</p><p>The information provided is presented only as of the date published or indicated and may be superseded by subsequent events or for other reasons. As events and markets change continuously, previously published information and data may not be current and should not be relied upon.</p><p>The opinions reflected herein are subject to change without being updated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35fa95f7329a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eulerfinance/modularity-the-way-forward-to-building-defi-systems-35fa95f7329a">Modularity, The Way Forward To Building DeFi Systems</a> was originally published in <a href="https://medium.com/eulerfinance">Euler Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Protocols vs Products]]></title>
            <link>https://medium.com/eulerfinance/protocols-vs-products-fa77bf095996?source=rss----26caa30240---4</link>
            <guid isPermaLink="false">https://medium.com/p/fa77bf095996</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[defi]]></category>
            <dc:creator><![CDATA[Michael Bentley]]></dc:creator>
            <pubDate>Fri, 10 Nov 2023 17:56:14 GMT</pubDate>
            <atom:updated>2024-05-22T16:07:52.055Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Which is better?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u_1xsQjl4VlHBFhjKCe86A@2x.png" /></figure><p>I recently saw this <a href="https://twitter.com/PaulFrambot/status/1696900204727791999?s=20">claim</a>: <em>“If a smart contract is feature-oriented, then it is a product, not a protocol.” </em>I thought this was an interesting distinction worth exploring in more detail, especially given the current trend of people advocating for the development of more primitive, base layer-type protocols.</p><p><a href="https://x.com/PaulFrambot/status/1696900204727791999?s=20">https://x.com/PaulFrambot/status/1696900204727791999?s=20</a></p><h4>Protocols and products</h4><p>The traditional definition of a protocol is a set of simple rules determining how information is transmitted between different parties or devices. The Internet (i.e. TCP/IP) is perhaps the best known set of protocols in existence today. Protocols can be extraordinarily valuable, but they seldom extract value. The Internet would not be what it is today, for example, if it had an in-built fee switch or tried to extract value from those who built on top of it. Protocols are usually unopinionated and minimalistic, targeting a broad user base, and designed to last for a long time.</p><p>The Internet stood the test of time because it didn’t try to build in complex features. If it had, most of those features would have quickly become out-of-date technical debt and it would have become obsolete. Protocols usually form the base layer of a stack on top of which more complex operations can be performed and more complex *products* can be built. The Internet became valuable because it targeted a broad user base and millions of people felt comfortable staking their future on it by building products on top of it.</p><p>In contrast to protocols, the best products are usually extremely opinionated and feature rich, have a very specific target audience in mind, and are not designed to last forever. They always seek to create and extract value from users too. Steve Jobs is the canonical master of building great products.</p><h4><strong>The rise of product-protocols</strong></h4><p>So, what are DeFi smart contracts? Protocols or products?<strong> </strong>I think there’s an argument DeFi has led to the creation of a new class entirely: the product-protocol.</p><p>DeFi smart contracts are definitely protocols, in the sense that they provide a strict set of rules determining how information is transmitted between different parties, but they are often feature-rich products too. Some protocols are closer to the original meaning. Others are more product-like. Is this good or bad?</p><p>Recently, a narrative has formed around the idea that feature-rich products are somehow inherently bad. I can’t agree. To be bearish on products is to be bearish on composability of protocols, and the entire premise of DeFi, for there’s not much point in building a protocol if it isn’t used to build great products on.</p><p>At the core of this narrative seems to be the view that simple protocols are <a href="https://x.com/delitzer/status/1661755779240841222?s=20">more secure</a> than products. At some level, this is trivially true. It’s easier to build something secure in itself if it only does a couple of small tasks. When it comes to writing secure code, the less complexity the better is a good rule of thumb. So, let’s all build simple protocols and stay away from complex products?</p><p>Well, no. Protocols are great for developers to build on, but ordinary end users typically don’t just want great protocols, they want great products. And if products are the desired end state, then you get them one way or another in a system over time, regardless of who builds in that complexity.</p><p>Protocol developers might be able to sleep better at night knowing that their protocol is so simple it can’t possibly fail. But as they push the risk and requisite skill required to design and bring to market products further up the stack, they should also be prepared to relinquish the rewards that development of those products brings. The Internet is incredibly valuable, but it was famously not that valuable to its developers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ugZdezLq6xztSPrdvkgjMQ.png" /><figcaption>Product-protocols</figcaption></figure><h4><strong>Modular product development</strong></h4><p>The security argument for protocols is really an argument for the benefits of modularity. Modules are simple and do a few things well, and nothing else. They are easy to understand and easy to test. In this regard, protocols can be thought of as base layer modules. Good products usually build on base layer modules and add further features and complexity in a modular fashion.</p><p>Whilst modularity may help with security, there are very different flavours of modularity. Consider the different ways that Mac and PC were originally brought to market. Both systems used modular design principles. However, whereas Mac famously opted to build all its modules in-house, PC famously opted to let anyone build products on top of it.</p><p>There was a stark difference in pace of growth, but also in the final product. PC grew rapidly, but ended up feeling like a jumbled mess, plagued by a proliferation of rent-seeking apps, inefficiencies and security issues. Mac grew much slower, but ended up feeling like a cohesive product, largely free from value extracting apps and security issues.</p><p>There’s an important lesson here for smart contract developers. Modularity per se is not enough to bring about great products in the long-term. You want *cohesive* modularity, not chaotic modularity. There’s a risk that the proliferation of DeFi primitive protocols, each with their own governance system and their own fee extraction mechanisms, is simply replacing middle-men with middle-protocols.</p><h4><strong>Example</strong></h4><p>Let’s consider an example. One of the most popular use-cases for lending protocols is to compose them with a DEX in order to build a leveraged long or short position. A user will borrow assets and swap them on the DEX, redeposit the swapped assets in the lending protocol, borrow more, swap again, and so on, up to their desired risk/reward tolerance.</p><p>There are many advantages to having the lending protocol and DEX built in a modular fashion by entirely different specialised teams. Indeed, the fact that two different protocols built by different developers from different parts of the world can be composed together inside a single transaction is one of the major benefits of DeFi over traditional finance. However, there are important downsides to this way of building things too.</p><p>If both lending protocol and DEX extract fees and demand governance by entirely different communities, each with their own interests, the end user experience could be suboptimal. The modularity might not be cohesive if the use-case didn’t have a tailor made solution. Furthermore, if the end user needs to pay UI fees and lending protocol fees and DEX fees and hook fees, and so on, is DeFi really living up to its disintermediated claims?</p><h4><strong>Conclusions</strong></h4><p>Overall, I broadly agree with claims that many DeFi projects today look more like products than protocols. I’m not sure this is a bad thing. There’s clearly some truth in the idea that simpler, more primitive, protocols are inherently more secure than complex products. But I’m sceptical of the idea that simply building lots of primitive protocols will result in a more secure decentralised finance ecosystem and better user experience in the long-run. I expressed a similar view in a <a href="https://x.com/euler_mab/status/1667190907161182210?s=20">thread</a> about oracle-free lending protocols a little while ago. Users want products, and this requires complexity at some level. If you’re only building primitives, don’t expect to be able to extract value from users at that level.</p><p>Stay tuned to see what we’re building at Euler Labs. Spoiler alert: both primitive and more feature-rich developments are on the roadmap. Cohesive modularity is the design goal.</p><h4><strong>References</strong></h4><p><a href="https://x.com/euler_mab/status/1667190907161182210?s=20">https://x.com/euler_mab/status/1667190907161182210?s=20</a></p><p><a href="https://x.com/delitzer/status/1661755779240841222?s=20">https://x.com/delitzer/status/1661755779240841222?s=20</a></p><p><a href="https://twitter.com/PaulFrambot/status/1696900204727791999?s=20">https://twitter.com/PaulFrambot/status/1696900204727791999?s=20</a></p><h3>Morpho Labs 🦋 on Twitter: &quot;1/ A new era for risk management?Historically, in DeFi, risk has been managed by a DAO, but the landscape is changing.Let&#39;s dive into the current state of risk management collateralized lending and what this change might look like 👀 / Twitter&quot;</h3><p>1/ A new era for risk management?Historically, in DeFi, risk has been managed by a DAO, but the landscape is changing.Let&#39;s dive into the current state of risk management collateralized lending and what this change might look like 👀</p><p><strong>Disclaimer:</strong></p><p>This piece is provided by Euler Labs Ltd. for informational purposes only and should not be interpreted as investment, tax, legal, insurance, or business advice. Euler Labs Ltd. and The Euler Foundation are independent entities.</p><p>Neither Euler Labs Ltd., The Euler Foundation, nor any of their owners, members, directors, officers, employees, agents, independent contractors, or affiliates are registered as an investment advisor, broker-dealer, futures commission merchant, or commodity trading advisor or are members of any self-regulatory organization.</p><p>The information provided herein is not intended to be, and should not be construed in any manner whatsoever, as personalized advice or advice tailored to the needs of any specific person. Nothing on the Website should be construed as an offer to sell, a solicitation of an offer to buy, or a recommendation for any asset or transaction.</p><p>This post reflects the current opinions of the authors and is not made on behalf of Euler Labs, The Euler Foundation, or their affiliates and does not necessarily reflect the opinions of Euler Labs, The Euler Foundation, their affiliates, or individuals associated with Euler Labs or The Euler Foundation.</p><p>Euler Labs Ltd. and The Euler Foundation do not represent or speak for or on behalf of the users of Euler Finance. The commentary and opinions provided by Euler Labs Ltd. or The Euler Foundation are for general informational purposes only, are provided “AS IS,” and without any warranty of any kind. To the best of our knowledge and belief, all information contained herein is accurate and reliable and has been obtained from public sources believed to be accurate and reliable at the time of publication.</p><p>The information provided is presented only as of the date published or indicated and may be superseded by subsequent events or for other reasons. As events and markets change continuously, previously published information and data may not be current and should not be relied upon.</p><p>The opinions reflected herein are subject to change without being updated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa77bf095996" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eulerfinance/protocols-vs-products-fa77bf095996">Protocols vs Products</a> was originally published in <a href="https://medium.com/eulerfinance">Euler Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Have you heard about this SSTORE quirk, anon?]]></title>
            <link>https://medium.com/eulerfinance/have-you-heard-about-this-sstore-quirk-anon-6a1ae870e57c?source=rss----26caa30240---4</link>
            <guid isPermaLink="false">https://medium.com/p/6a1ae870e57c</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[gas-optimization]]></category>
            <category><![CDATA[evm]]></category>
            <dc:creator><![CDATA[Kasper]]></dc:creator>
            <pubDate>Tue, 19 Sep 2023 20:41:59 GMT</pubDate>
            <atom:updated>2024-05-22T16:08:14.331Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3BPWjrG9nyT3FDOfLI_Usg.png" /></figure><p>tl;dr <em>SSTORE</em> is one of the most expensive EVM opcodes. A savvy developer always optimizes their smart contract to use <em>SSTORE</em> in the most efficient manner. However, there’s a catch buried in EIPs that nobody talks about. Or at least, I haven’t encountered any information about it until today.</p><p>tl;dr, Read the Conclusion.</p><h3>Background</h3><p>There are a ton of resources out there that can teach you how to reduce and optimize the gas consumption of your smart contract. Recently, I went through some of them to improve the smart contract I am working on. Like everyone, I was especially interested in storage optimization which can have a substantial impact on gas costs. Minimizing unnecessary storage modifications and utilizing packed data structures that optimize storage usage can help reduce gas consumption significantly. How surprised I was when I looked at the <a href="https://www.npmjs.com/package/hardhat-tracer"><em>hardhat-tracer</em></a> dump of <em>SLOAD</em>s and <em>SSTORE</em>s to find out that sometimes their gas cost might not be as one would expect after going through the resources. A direct deep dive into relevant EIPs was needed.</p><h3>EIP-2929</h3><h3>EIP-2929</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ygJTOshB2voF9RzQH4FNYA.png" /><figcaption>source: <a href="https://hackmd.io/@fvictorio/gas-costs-after-berlin">https://hackmd.io/@fvictorio/gas-costs-after-berlin</a></figcaption></figure><p>From the gas optimization point of view, the most important seems to be the fact that if the value was previously modified during the same transaction, all the subsequent <em>SSTORE</em>s cost 100. It means that if I have a storage variable and I want to change its value multiple times in one transaction, the first write should be the most expensive and all the subsequent ones should cost pennies.</p><h3>Unintuitive behaviuor</h3><p>Let’s use this simple example to explain the problem. Say you need to use a reentrancy guard in your smart contract. For that, you inherit from <a href="https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/ReentrancyGuard.sol"><em>ReentrancyGuard</em> from Open-Zeppelin</a>. The contract is as follows:</p><pre>// SPDX-License-Identifier: MIT<br>// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)<br><br>pragma solidity ^0.8.20;<br>/**<br> * @dev Contract module that helps prevent reentrant calls to a function.<br> *<br> * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier<br> * available, which can be applied to functions to make sure there are no nested<br> * (reentrant) calls to them.<br> *<br> * Note that because there is a single `nonReentrant` guard, functions marked as<br> * `nonReentrant` may not call one another. This can be worked around by making<br> * those functions `private`, and then adding `external` `nonReentrant` entry<br> * points to them.<br> *<br> * TIP: If you would like to learn more about reentrancy and alternative ways<br> * to protect against it, check out our blog post<br> * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].<br> */<br>abstract contract ReentrancyGuard {<br>    // Booleans are more expensive than uint256 or any type that takes up a full<br>    // word because each write operation emits an extra SLOAD to first read the<br>    // slot&#39;s contents, replace the bits taken up by the boolean, and then write<br>    // back. This is the compiler&#39;s defense against contract upgrades and<br>    // pointer aliasing, and it cannot be disabled.<br>    // The values being non-zero value makes deployment a bit more expensive,<br>    // but in exchange the refund on every call to nonReentrant will be lower in<br>    // amount. Since refunds are capped to a percentage of the total<br>    // transaction&#39;s gas, it is best to keep them low in cases like this one, to<br>    // increase the likelihood of the full refund coming into effect.<br>    uint256 private constant NOT_ENTERED = 1;<br>    uint256 private constant ENTERED = 2;<br>    uint256 private _status;<br>    /**<br>     * @dev Unauthorized reentrant call.<br>     */<br>    error ReentrancyGuardReentrantCall();<br>    constructor() {<br>        _status = NOT_ENTERED;<br>    }<br>    /**<br>     * @dev Prevents a contract from calling itself, directly or indirectly.<br>     * Calling a `nonReentrant` function from another `nonReentrant`<br>     * function is not supported. It is possible to prevent this from happening<br>     * by making the `nonReentrant` function external, and making it call a<br>     * `private` function that does the actual work.<br>     */<br>    modifier nonReentrant() {<br>        _nonReentrantBefore();<br>        _;<br>        _nonReentrantAfter();<br>    }<br>    function _nonReentrantBefore() private {<br>        // On the first call to nonReentrant, _status will be NOT_ENTERED<br>        if (_status == ENTERED) {<br>            revert ReentrancyGuardReentrantCall();<br>        }<br>        // Any calls to nonReentrant after this point will fail<br>        _status = ENTERED;<br>    }<br>    function _nonReentrantAfter() private {<br>        // By storing the original value once again, a refund is triggered (see<br>        // https://eips.ethereum.org/EIPS/eip-2200)<br>        _status = NOT_ENTERED;<br>    }<br>    /**<br>     * @dev Returns true if the reentrancy guard is currently set to &quot;entered&quot;, which indicates there is a<br>     * `nonReentrant` function in the call stack.<br>     */<br>    function _reentrancyGuardEntered() internal view returns (bool) {<br>        return _status == ENTERED;<br>    }<br>}</pre><p>First of all, the contract doesn’t use a <em>boolean</em>, but <em>uint</em>; it’s cheaper as per the comment in the code. Second, we set the <em>_status</em> to <em>1 </em>in the constructor (one-time gas cost of 20,000) so that later on it’s cheaper to make the <em>1-&gt;2</em> transition in the <em>nonReentrant()</em> modifier. Finally, the <em>_status</em> may be considered a transient variable as it should always be brought back to the initial value within the transaction (the reentrancy lock should always be released). Moreover, because of that final <em>2-&gt;1</em> transition, we should expect a gas refund which, due to <a href="https://eips.ethereum.org/EIPS/eip-3529">EIP-3529</a>, is capped at 20% of the total transaction’s gas. Hence, it’s best to keep the gas refunds low, otherwise, we may not get the full refund we would be entitled to.</p><p>I’ve just said that thanks to setting the <em>_status</em> to <em>1</em> in the constructor, it’s cheaper to use the <em>nonReentrant()</em> modifier, but how much gas exactly do we expect to spend using <em>nonReentrant()</em>? Taking into account what’s been considered so far, let’s write some comments in the code as we go:</p><pre>modifier nonReentrant() {<br>    // the first SLOAD should cost us 2100.<br>    // if we were to call this modifier again, we should pay 100 here<br>    if (_status == 2) {<br>        revert ReentrancyGuardReentrantCall();<br>    }<br><br>    // considering we already accessed this storage slot above,<br>    // we should pay 2900 here if it&#39;s the first call of the modifier.<br>    // if we were to call this modifier again, it would mean it&#39;s a<br>    // subsequent SSTORE hence we should pay 100 here<br>    _status = 2;<br><br>    _;<br><br>    // considering we already accessed this storage slot above <br>    // and the fact that it&#39;s always a subsequent SSTORE, we <br>    // should pay 100 here<br>    _status = 1;<br>}</pre><p>To sum up, if it’s the first call of the <em>nonReentrant()</em>, we expect to pay 5100 gas. If it’s a subsequent call in the same transaction, we expect to pay 300 gas. Sounds good, doesn’t it?</p><p><strong>If there’s a smart contract out there that integrates with ours and in one transaction it calls a couple of non-reentrant functions from our contract, each subsequent call should be cheaper than the first one. Thanks to that behaviour, our reentrancy protection should not be that costly!</strong></p><p>Well, that’s theory. In practice, things appear vastly different. To show that, let’s write two simple contracts and look at the <em>hardhat-tracer</em> dump.</p><pre>contract MyContract is ReentrancyGuard {<br>    // some non-reentrant function that does nothing but is protected<br>    function nonReentrantFunction() public nonReentrant {}<br>}<br><br>contract IntegrationContract {<br>    MyContract internal immutable myContract;<br><br>    constructor(MyContract _myContract) {<br>        myContract = _myContract;<br>    }<br>    <br>    // a function that calls the protected function twice.<br>    // we expect that the second call should be cheaper<br>    function test() external {<br>        myContract.nonReentrantFunction();<br>        myContract.nonReentrantFunction();<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rXO20nmqshX5d9EA9h6ANA.png" /></figure><p>We have the <em>MyContract</em> with a simple reentrancy-protected function and <em>IntegrationContract</em> that simply calls the <em>MyContract.nonReentrantFunction()</em> twice in its <em>test()</em> function. Do you see anything odd? We expected to pay 100 for the <em>1-&gt;2</em> transition in the second call, instead, we paid 2900. At the same time, we paid expectedly less for the second <em>SLOAD</em>. Why is that?</p><h3>EIP-2200</h3><p>When I shared my findings with the team members, some of them said it was illogical, some of them said it was inconsistency, and others claimed it must be a bug. I dived deeper and apparently, everything became clear.</p><p><a href="https://eips.ethereum.org/EIPS/eip-2200">EIP-2200</a> is heavily referred to by <a href="https://eips.ethereum.org/EIPS/eip-2929">EIP-2929</a> and pertains to the so-called Wei Tang’s approach to net gas metering. Its implementation predates <a href="https://eips.ethereum.org/EIPS/eip-2929">EIP-2929</a> and was introduced in the Istanbul hard fork. The idea behind it was to provide a structured definition of net gas metering changes for <em>SSTORE</em> opcode, enabling new usages for contract storage, and reducing excessive gas costs where it doesn’t match how most implementation works. It says: <em>“Usages that benefit from this EIP’s gas reduction scheme include: Subsequent storage write operations within the same call frame. This includes reentry locks, same-contract multi-send, etc.”</em>. As you can see, it explicitly mentions the reentrancy locks gas cost reduction, but has it done the job?</p><p>The gas calculation logic proposed by <a href="https://eips.ethereum.org/EIPS/eip-2200">EIP-2200</a> is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L4Thp164mTgYh1koDsVfKw.png" /><figcaption>source: <a href="https://eips.ethereum.org/EIPS/eip-1283">https://eips.ethereum.org/EIPS/eip-1283</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5RweUZWZdSkzUPlT2xTHvQ.png" /><figcaption>source: <a href="https://eips.ethereum.org/EIPS/eip-2200">https://eips.ethereum.org/EIPS/eip-2200</a></figcaption></figure><p>As you can see, the algorithm does not recognize the case in which the <em>original value</em> equals the <em>current value </em>now, but it had been previously set to some other value within the same call frame. It does not care whether the storage slot key was previously accessed. Therefore, when we set our <em>_status</em> variable from <em>1</em> to <em>2</em>, no matter if it’s the same or a subsequent call, we are exercising the same path and pay <em>SSTORE_RESET_GAS</em> for that, which happens to be 2900 after <a href="https://eips.ethereum.org/EIPS/eip-2929">EIP-2929</a>. Bye bye gas savings!</p><h3>Questionable rationale</h3><p><a href="https://eips.ethereum.org/EIPS/eip-2200">EIP-2200</a> offers a rationale for the above behaviour. It claims that the approach mostly achieves what transient storage tries to do (<a href="https://eips.ethereum.org/EIPS/eip-1087">EIP-1087</a> and <a href="https://eips.ethereum.org/EIPS/eip-1153">EIP-1153</a>) but without the complexity of introducing the concept of “dirty maps”, or an extra storage struct. Personally, I find this questionable. Controversial <a href="https://eips.ethereum.org/EIPS/eip-1153">EIP-1153</a> that introduces new opcodes for transient storage — <em>TLOAD</em> and <em>TSTORE</em> — would work far better here and in other scenarios. In cases like the above, each use of <em>nonReentrant()</em> modifier would cost 300 vs. 5100 (or 3100 in the subsequent calls). Moreover, although simplicity shall be praised and “dirty maps” implementation might be indeed tricky, it might sometimes lead to the implementation of ugly design patterns like the one I had to come up with myself. On the other hand, if nobody knows about the <em>SSTORE</em> quirk, nobody except me will implement any ugliness :)</p><h3>Ugly gas optimizations</h3><p>Imagine you have a function where reentrancy is allowed. Every time it happens you just increase the <em>callDepth</em> counter to be able to revert at some point. At the same time, you have a critical section that you want to protect from reentrancy, you use the <em>criticalLock</em> for that. The critical code should only be executed once when the call stack unwinds back to the top-level function call. You implement the smart contract as follows:</p><pre>// SPDX-License-Identifier: UNLICENSED<br>pragma solidity ^0.8.19;<br><br>contract UglyContract {<br>    error CriticalLockViolation();<br>    error CallDepthViolation();<br><br>    struct ContextStruct {<br>        bool criticalLock;<br>        uint8 callDepth;<br>        uint8 stamp;<br>        uint8 dummy;<br>    }<br><br>    ContextStruct internal context;<br>    <br>    constructor() {<br>        // set the storage slot to non-zero so that it&#39;s cheaper to alter it later<br>        context.dummy = 1;<br>    }<br><br>    // this modifier is used to protect critical sections of the code<br>    modifier critical() {<br>        if (context.criticalLock) {<br>            revert CriticalLockViolation();<br>        }<br>        _;<br>    }<br><br>    function prettyFunction(address target, address criticalTarget) external critical {<br>        uint8 callDepth = context.callDepth;<br><br>        if (callDepth &gt;= 5) {<br>            revert CallDepthViolation();<br>        }<br><br>        unchecked {<br>            context.callDepth = callDepth + 1;<br>        }<br><br>        // do something here: make external calls, allow reentrancy back into this function.<br>        // low-level call used to avoid compiler optimization and show the issue<br>        target.call(&quot;&quot;);<br><br>        context.callDepth = callDepth;<br><br>        if (callDepth == 0) {<br>            context.criticalLock = true;<br>            <br>            // do some critical stuff here: make external calls, but disallow reentrant callback into this function.<br>            // low-level call used to avoid compiler optimization and show the issue<br>            criticalTarget.call(&quot;&quot;);<br>            <br>            context.criticalLock = false;<br>        }<br>    }<br><br>    function uglyFunction(address target, address criticalTarget) external critical {<br>        uint8 callDepth = context.callDepth;<br><br>        if (callDepth &gt;= 5) {<br>            revert CallDepthViolation();<br>        }<br><br>        unchecked {<br>            context.callDepth = callDepth + 1;<br><br>            // gas optimization to keep the slot in altered state until the end of the uglyFunction<br>            context.stamp = 1;<br>        }<br><br>        // do something here: make external calls, allow reentrancy back into this function.<br>        // low-level call used to avoid compiler optimization and show the issue<br>        target.call(&quot;&quot;);<br><br>        context.callDepth = callDepth;<br><br>        if (callDepth == 0) {<br>            context.criticalLock = true;<br>            <br>            // do some critical stuff here: make external calls, but disallow reentrant callback into this function.<br>            // low-level call used to avoid compiler optimization and show the issue<br>            criticalTarget.call(&quot;&quot;);<br>            <br>            context.criticalLock = false;<br><br>            // bring the slot back to the original state<br>            context.stamp = 0;<br>        }<br>    }<br>}</pre><p>As you can see, we have two functions that do exactly the same thing. Gas optimized <em>uglyFunction()</em> and not optimized <em>prettyFunction()</em>. To avoid the user being charged additional gas, in the <em>uglyFunction()</em> the <em>stamp</em> field is set to <em>1</em> at the top and reset at the end of the transaction. Savings? 2800 for each call. Of course one can argue here that the final storage slot value will be equal to the original value hence gas refund is expected. In this case, you would be right, but it’s only because the <em>context</em> is transient in nature which does not have to be the case. Also, you should not rely on the gas refunds as they are capped at 20% of the total transaction’s gas as I already mentioned before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PzmYPEQsYoeo6eViJL6R4g.png" /></figure><h3>Conclusion</h3><p>It appears that due to <a href="https://eips.ethereum.org/EIPS/eip-2200">EIP-2200</a>, when it comes to the gas cost for the <em>SSTORE</em> opcode, within a transaction, the EVM only cares about the current vs. final value of the storage slot and not intermediate values. In scenarios when your smart contract sets the storage slot from <em>X</em> to <em>Y</em>, then back to <em>X,</em> and from <em>X</em> to <em>Z</em> you will not pay the reduced gas cost of 100 for changing the storage slot from <em>X</em> to <em>Z,</em> even if you’re within the same call frame. You will pay a full cost of 2900 or 20,000 if <em>X</em> is <em>0</em>. Amongst others, it has implications for reentrancy locks, toggled boolean flags, counters incremented and decremented within the same call frame, etc. Maybe after all controversial <a href="https://eips.ethereum.org/EIPS/eip-1153">EIP-1153</a> would be a good idea?</p><p><strong>Disclaimer:</strong></p><p>This piece is provided by Euler Labs Ltd. for informational purposes only and should not be interpreted as investment, tax, legal, insurance, or business advice. Euler Labs Ltd. and The Euler Foundation are independent entities.</p><p>Neither Euler Labs Ltd., The Euler Foundation, nor any of their owners, members, directors, officers, employees, agents, independent contractors, or affiliates are registered as an investment advisor, broker-dealer, futures commission merchant, or commodity trading advisor or are members of any self-regulatory organization.</p><p>The information provided herein is not intended to be, and should not be construed in any manner whatsoever, as personalized advice or advice tailored to the needs of any specific person. Nothing on the Website should be construed as an offer to sell, a solicitation of an offer to buy, or a recommendation for any asset or transaction.</p><p>This post reflects the current opinions of the authors and is not made on behalf of Euler Labs, The Euler Foundation, or their affiliates and does not necessarily reflect the opinions of Euler Labs, The Euler Foundation, their affiliates, or individuals associated with Euler Labs or The Euler Foundation.</p><p>Euler Labs Ltd. and The Euler Foundation do not represent or speak for or on behalf of the users of Euler Finance. The commentary and opinions provided by Euler Labs Ltd. or The Euler Foundation are for general informational purposes only, are provided “AS IS,” and without any warranty of any kind. To the best of our knowledge and belief, all information contained herein is accurate and reliable and has been obtained from public sources believed to be accurate and reliable at the time of publication.</p><p>The information provided is presented only as of the date published or indicated and may be superseded by subsequent events or for other reasons. As events and markets change continuously, previously published information and data may not be current and should not be relied upon.</p><p>The opinions reflected herein are subject to change without being updated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a1ae870e57c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eulerfinance/have-you-heard-about-this-sstore-quirk-anon-6a1ae870e57c">Have you heard about this SSTORE quirk, anon?</a> was originally published in <a href="https://medium.com/eulerfinance">Euler Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>