<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Arby</title>
        <link>https://paragraph.com/@nofacedev</link>
        <description>Arby

I want to build cool stuff. </description>
        <lastBuildDate>Sun, 16 Aug 2026 00:33:05 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>Arby</title>
            <url>https://storage.googleapis.com/papyrus_images/fa9931fb1f9e3672348de4c1b59a083e77c1d53cd3158fa9f126c34f76140923.jpg</url>
            <link>https://paragraph.com/@nofacedev</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[[DRAFT] Risk profiles of ERC721 non-fungible tokens as collateral within MCD]]></title>
            <link>https://paragraph.com/@nofacedev/draft-risk-profiles-of-erc721-non-fungible-tokens-as-collateral-within-mcd</link>
            <guid>pVBxKxWhCF26cCsb2sB2</guid>
            <pubDate>Wed, 24 Aug 2022 14:45:44 GMT</pubDate>
            <description><![CDATA[TLDROracle issues - Existing OSM structure allows for price manipulation attacks for certain collections due to NFT collections’ sizes and volatility. NFT pricing oracles have not been sufficiently proven yet (JPEG’d oracles seem to be the best at present). Liquidation counterparty issues - NFT transactions cannot be settled atomically in a proven and tested way (SudoSwap is still new but looks promising) ERC721 incompatibility issues - Metadata not being frozen and contracts being either own...]]></description>
            <content:encoded><![CDATA[<h2 id="h-tldr" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">TLDR</h2><p><strong>Oracle issues</strong> - Existing OSM structure allows for price manipulation attacks for certain collections due to NFT collections’ sizes and volatility. NFT pricing oracles have not been sufficiently proven yet (JPEG’d oracles seem to be the best at present).</p><p><strong>Liquidation counterparty issues</strong> - NFT transactions cannot be settled atomically in a proven and tested way (SudoSwap is still new but looks promising)</p><p><strong>ERC721 incompatibility issues</strong> - Metadata not being frozen and contracts being either ownable, infinitely mintable or easily rugged are common issues for PFP NFTs. Infrastructure is not in place for use of oracles with financial instrument NFTs yet. Maturity of the sector will lead to eventual solutions within this space.</p><h2 id="h-brief" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Brief</h2><p>Non-Fungible Token collateral as part of multi-collateral DAI is a popular idea and has been explored by MonetSupply <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://forum.makerdao.com/t/product-discussion-nfts-as-makerdao-collateral/12619">in a post from earlier this year</a>. Building on this idea, this post explores a hypothetical implementation of ERC721 NFT collateral within MCD, outlining challenges and potential solutions which are likely to arise.</p><h5 id="h-motivation" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Motivation</h5><p>As a recap of MonetSupply&apos;s post, motivations for MakerDAO implementing some form of NFT collateral largely revolved around strong demand, low competition and a large addressable market size. In the time since the original post, competitors have emerged, the market has decreased in size significantly and (importantly) distinctions between <em>types</em> of demand have been made apparent (more on this later).</p><p>As the implementation of ERC721 as a token specification becomes increasingly popular outside of the realm of &quot;JPEG tokens&quot;, it is instrumental that MakerDAO develops the ability to interact with these new collateral types in order to remain relevant and maintain an expanding addressable market outside of ERC20 tokens and RWA vaults.</p><h5 id="h-types-of-erc721-tokens" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Types of ERC721 tokens</h5><p>The two main types of ERC721 tokens as I have defined them are <strong>financial instrument tokens</strong> and <strong>digital collectible tokens</strong>. An example of a financial instrument token is a Uniswap v3 LP NFT while an example of a digital collectible token is a CryptoPunk or an XCOPY artwork. These two types of tokens carry different risk profiles and represent different implementation structures with different challenges.</p><h5 id="h-previous-work-nft-lending-frameworks" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Previous work - NFT lending frameworks</h5><p>MonetSupply explains that there are four main types of loans with NFT collateral exposure which Maker can serve, namely:</p><ul><li><p>Fractional token loans - <em>this does not involve ERC721 token interaction</em></p></li><li><p>Floor asset loans - <strong>lend against the token based on floor price</strong></p></li><li><p>Repurchase agreements - <strong>acquire the tokens for DAI with a repurchase option</strong></p></li><li><p>Loans to other NFT lending projects - <em>this is just &quot;lending to CeFi&quot;</em></p></li></ul><p>There are two viable strategies explored here:</p><p><em>Floor asset loans</em>, where ERC721 tokens are locked into a vault and DAI is drawn according to the floor price of the token&apos;s collection, and;</p><p><em>Repurchase agreements</em>, where Maker takes on the ERC721 tokens as collateral based on a significantly lower valuation than market price at time of loan issuance.</p><p>Both of these frameworks involve direct interaction with the ERC721 tokens and will be explored in this analysis.</p><h2 id="h-erc721-token-exposure" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">ERC721 Token exposure</h2><h5 id="h-erc721-token-standard-risk-profile" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">ERC721 token standard risk profile</h5><p>As a token standard, ERC721 tokens (sans metadata and other attributes) are significantly different to ERC20 tokens and therefore pose a threat to DSS contract security. In short:</p><blockquote><p><em>ERC721 tokens use</em> <code>onERC721Received</code> to allow for safe transfers, which could allow for reentrancy-style attacks on DSS contracts</p></blockquote><p>Currently, DSS contracts <em>exclusively</em> use ERC20 tokens as collateral, meaning that any potential interactions which could be caused by implementation of ERC721 collateral must be explored. Even under the assumption that previous audits and security analysis provides sufficient evidence that the existing system is safe, this will mean a lot of developers&apos; time spent combing through code to double-check.</p><p><em>This is a low severity risk</em></p><h5 id="h-erc721-collectibles-risk-profile" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">ERC721 collectibles risk profile</h5><p>Most digital collectible NFT collections (&quot;PFP&quot; sets) operate using an ownable minting contract and an API for metadata hosting. These two factors carry risks;</p><ol><li><p>The contract owner can mint additional NFTs beyond the supply cap through a <code>reserveTokens</code> function or similar. This would devalue all tokens in a collection and cause Maker&apos;s assessment of token value to be vastly inaccurate, leading to undercollateralised loans.</p></li><li><p><code>Upgradable</code> ERC721 contracts have the same vulnerabilities as outlined in (1) if the dev is malicious. This is probably going to be very rare, since a majority of ERC721 tokens are basically templates.</p></li><li><p>The contract owner of an established collection can change the <code>baseURI</code> value and rug token holders (which is very unlikely) or (far more likely) change the metadata values for certain tokens in a collection (if they are deemed to be stolen, for example) - causing them to drop to floor value - or censor a token outright (not serve metadata at all) causing near complete devaluation of the token.</p><p>While this is relatively rarely seen (usually this method is used to &apos;reroll&apos; tokens if a mint has been gamed), the potential for collections to do this is present in almost all tokens.</p></li></ol><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/0240fbb81a187d6ff0607181b8f9763c4924ece9e2740db44086562b43249c17.png" alt="CloneX serves their metadata exclusively through their API" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">CloneX serves their metadata exclusively through their API</figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4c0fefe7f896d0f5936ec71f9a74701e75675dc7ee2787a05aa998fbe4bca462.png" alt="Azuki serves their metadata using Pinata - the resulting metadata may be hosted on IPFS, but from a safety perspective this is no different to directly using an API" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Azuki serves their metadata using Pinata - the resulting metadata may be hosted on IPFS, but from a safety perspective this is no different to directly using an API</figcaption></figure><p>Collections like Bored Ape Yacht Club, which previously faced controversy relating to contract ownership have <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://etherscan.io/token/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d#readContract">renounced ownership</a> and now host their metadata directly on IPFS rather than serving it via an API. These collections represent a minority of ERC721 digital collectibles but present the least risk.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/f2cf2221896313633da7383abe972c24a5383bdc88fd78c021ec3cd4b01def3a.png" alt="BAYC serves their metadata directly from IPFS. This is the best option." blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">BAYC serves their metadata directly from IPFS. This is the best option.</figcaption></figure><p>While this risk seems low at a first glance, given Maker&apos;s permissionless nature, it stands to reason that depositing stolen ERC721 tokens (either directly stolen or &quot;blacklisted&quot; assets) exacerbate this risk significantly and are an eventuality. Implementations of the <em>floor asset loans</em> such as <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.benddao.xyz/">BendDAO</a> have already had &quot;questionably obtained&quot; NFTs used as collateral (which may be valued as less than floor price due to large marketplace exclusion).</p><p>Contracts being owned</p><p><em>This is a medium severity risk</em></p><h5 id="h-stolen-erc721-token-risk-profile" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Stolen ERC721 token risk profile</h5><p>Given the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://slate.com/technology/2022/06/bored-ape-yacht-club-thefts-nfts-cryptocurrency.html">absurd number of stolen Bored Apes</a> amongst other tokens, the non-technical risk element of offering permissionless collateralisation of stolen assets (and therefore attracting attention from law enforcement) poses risks for Maker as an entity rather than for the collateralisation of DAI itself. Using an NFT AMM such as SudoSwap for liquidations lessens this risk significantly.</p><p><em>This is a high severity risk</em></p><h2 id="h-floor-asset-loan-challenges" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Floor asset loan challenges</h2><p>Pricing of NFTs based on floor prices leads to a plethora of issues, based on a few fundamental truths:</p><ol><li><p>Floor prices do not represent open offers for &quot;any element of this collection&quot; but rather represent a value <em>above</em> what the market prices the collection&apos;s currently purchasable tokens at (i.e. slightly above &quot;market rate&quot;)</p></li></ol><p>By virtue of this, floor prices can actually be manipulated at scale - for example, in small collections, &quot;common&quot; tokens could remain unlisted if there was collusion by the token holders, leading to the floor price actually representing the value of tokens of &quot;uncommon&quot; rarity or higher. While in reality this collusion is nearly possible to execute when there are typically over 5000 common tokens in a PFP-style collection, if the collection was smaller (for example 1000 tokens) then this is possible and would allow for collateral depositors to borrow against their tokens at an inflated valuation.</p><p>In terms of selling assets instantly for floor price, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.sudoswap.xyz/">SudoSwap NFT AMM pools</a> offer a relatively new solution for disposal of assets.</p><ol><li><p>Floor prices can be manipulated easily in some cases.</p></li></ol><p>An example of this being easily possible is <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://opensea.io/assets?search%5Bquery%5D=mortal%20xcopy">XCOPY&apos;s <em>Mortal</em> series</a> which is comprised of 10 tokens. At date of writing, one token is for sale for 350 ETH, with two others having last sale prices of 12 and 32 ETH. Here, one of the owners of another <em>Mortal</em> piece could purchase the token for 350 ETH and instantly relist it at 3,500 ETH. Assuming that Maker vaults allowed collateralisation of <em>any of XCOPY&apos;s</em> selected works (which <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://etherscan.io/token/0xd652d2633cdbfd5f27f50cddb098e708fa8433f3">all use the same contract</a>) with floor prices taken from the <em>Mortal</em> sub-collection, this would allow for potentially infinite borrowing against a single token up to the debt ceiling. This is a high likelihood for tokens such as XCOPY artworks (which are considered to be blue chip by NFT collectors).</p><ol><li><p>Floor prices vary depending on market</p></li></ol><p>The floor prices on OpenSea and LooksRare are different since OpenSea delists / censors stolen or controversial assets. At the time of writing, the difference in floor prices for BAYC on <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://looksrare.org/collections/0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D">LooksRare</a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://opensea.io/collection/boredapeyachtclub">OpenSea</a> is 3.83%. Existing NFT collateral lending platforms such as BendDAO <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.benddao.xyz/portal/lending-protocol/oracle-price-feeding">use floor prices from OpenSea and LooksRare</a> with a TWAP mechanism.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/f1a1219d717a5b719e97195c97c6846e662d1b1e2025f28cba2372f76bc9268b.png" alt="The short answer to this question posed on their forum is &apos;no&apos;" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">The short answer to this question posed on their forum is &apos;no&apos;</figcaption></figure><p>While this appears to be a <em>reasonably</em> safe mechanism for their purposes, it is nowhere near what the MCD system currently implements in regards to ERC20 collateral. High volatility periods or downtime of OpenSea and/or LooksRare (or their hosting dependencies) could mean rapid liquidiation of NFT collateral backed loans without an OSM-like module. However an OSM module would face issues with regards to attacks presented in (1) and (2) and allow coordinated attacks if it is not designed with such attacks in mind (ERC20 OSM does not consider this a risk since it is a manifestation of non-fungibility and low supply or collusion).</p><ol><li><p>Oracle infrastructure is not yet available for these usecases</p></li></ol><p>Existing infrastructure used by BendDAO (which they call an &quot;Oracle Mechanism&quot;) is far from sufficient to replace the OSM and timelocks expose Maker to attacks (1) and (2) as outlined above.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/0afe19f01bab97ad3c1abdd490fc750219bdaef880b2447436b043fb839b79c7.png" alt="BendDAO&apos;s &quot;Oracle Mechanism&quot;" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">BendDAO&apos;s &quot;Oracle Mechanism&quot;</figcaption></figure><p>MonetSupply&apos;s proposed solution to the issue of pricing was as follows:</p><blockquote><p>*&quot;A team or set of teams within MakerDAO will carry out periodic appraisals of supported NFT collateral assets.&quot;</p></blockquote><p>While this can work, it would require a lot of additional work compared to the existing ERC20 OSM setup that exists. Additionally, a &apos;lagging price&apos; implemented through a timelock (as the OSM operates) allows for potential abuse (that, on paper, appears just as severe as for the existing ERC20 OSM) which due to NFT volatility may become more severe or frequent.</p><p>Current <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.jpegd.io/about-the-lending-protocol/the-lending-mechanics#the-oracle">Oracle solutions by JPEG&apos;d</a> offer the most appealing solution presented to date, however their documentation does not offer much by way of a technical description of how it operates. Incorporating recent purchases in valuations would prevent attacks of type (2), however a more complex solution would be needed to mitigate attacks as described in (1).</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/fcb994cac5ac7cd7d826e40fccc675c2516f7aff89d9d53d6626e1ead79b10d1.png" alt="JPEG&apos;d provides a solution for floor price manipulation attacks in some ways" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">JPEG&apos;d provides a solution for floor price manipulation attacks in some ways</figcaption></figure><p>The hypothetical ideal oracle would also uses a <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://raritytools.medium.com/ranking-rarity-understanding-rarity-calculation-methods-86ceaeb9b98c">&quot;rarity score&quot; based model</a> to prevent attacks as described in (1) above to prevent large scale collusion amongst token holders to only have purchasable tokens comprising floor be of intrinsically higher rarity or value than their own assets. This particularly applies to PFP-style collections where the collection size is small enough to allow such collusion. Ideally, team ownership stakes could be used to mitigate such attacks, however if there was enough buy pressure, even this could be overcome.</p><p>While this attack appears to be incredibly difficult to execute and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/fiveoutofnine/status/1558880403649593344">not very economically viable</a>, it represents a risk if PFP-style token adoption were to scale.</p><ol><li><p>Stolen NFTs</p></li></ol><p>Stolen NFTs can be used as collateral - this has been explored from the perspective of an existential risk to MakerDAO above. However, these tokens are also generally traded for prices under floor price. This means that lower collateralisation ratios would need to be used to ensure that liquidation auction purchasers are still incentivised to purchase the token (this is not a problem if the NFT is sold to a SudoSwap pool as it is also permissionless). Additionally, the collateral could be discounted to ensure a safety margin, however this would make Maker&apos;s offering less competitive (market lending rate is 30-40% of floor price).</p><ol><li><p>DAI peg changes</p></li></ol><p>Competitors issue USD-pegged stablecoins such as <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.jpegd.io/tokenomics/pusd">PUSd</a> or issue ETH loans. Both USD and ETH are common denomination units for NFTs - while the counterparty bears the depeg risk for PUSd and other stablecoins, at date of writing, the average NFT owner is likely to assume that DAI is pegged to 1 USD. This is more of a par/TRFM issue than one specific to ERC721 lending, however it may affect competitiveness of the proposed Maker implementation. NFT holders are considered to be less knowledgable regarding DeFi, hence the use of USD-pegged stables and ETH for loan issuance on existing platforms.</p><h2 id="h-repurchase-agreement-challenges" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Repurchase agreement challenges</h2><ol><li><p>Maker acts as a middleman for NFT transactions via collateral locking and loan issuance</p></li></ol><p>The primary risk associated here is that Maker is custodying the assets and since NFT theft is often more publicised than ERC20 token theft, it may draw unnecessary risk to Maker (outweighing the benefits in terms of accrued fees and collateral diversification).</p><ol><li><p>Maker may not be efficient in terms of rates</p></li></ol><p>The fees earned by Maker for repurchase would likely not outweigh the volatility risk given that the entire NFT asset class has seen wild fluctuations. MonetSupply suggests that the repurchase agreement method be used for 1 of 1 pieces and very high rarity tokens. In my view, even this is too high a risk for Maker to take on given the sector&apos;s volatile history; Maker would be better off investing in NFT investors.</p><ol><li><p>DAI peg changes</p></li></ol><p>DAI peg changes may disincentivise repurchases of tokens by the counterparty. This can be solved however is a problem worth mentioning.</p><h2 id="h-financial-instrument-token-challenges" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Financial instrument token challenges</h2><p>Financial instrument tokens such as Uni v3 LP NFTs can be priced in one of two ways:</p><ol><li><p>Reverse engineer the price calculation by replicating the protocol&apos;s NFT minting process, or;</p></li><li><p>Use an oracle of some kind to price the tokens</p></li></ol><p>Option (1) is dangerous given that an exploit in either Maker&apos;s pricing contract or the original contract (for example, allowing minting positions 10x the size they should be) would allow for attacks which can mint DAI up to the debt ceiling.</p><p>Option (2) has shortfalls in that Oracles may face difficulty pricing so many tokens. Considering that these tokens may be minted and burnt constantly, this is a difficult problem for oracles to solve.</p><p>Overall, the technology to <em>safely</em> price these tokens is yet to exist. A hypothetical solution would be an oracle which compares contract input and output estimate values during minting and burning of the financial instrument NFTs. No such solution exists at present and this sector is still maturing.</p><h2 id="h-overcoming-shortcomings" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Overcoming shortcomings</h2><h5 id="h-oracles" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Oracles</h5><p>Currently, no oracle exists which is safe enough to prevent all attack types with certainty. The JPEG&apos;d oracle appears to offer the best solution available at present and therefore should be explored.</p><h5 id="h-liquidation-counterparties" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Liquidation counterparties</h5><p>Previously, there was no atomic way of selling NFT collateral in the event of a liquidation. SudoSwap presents a novel technology which should be explored as an element of auction liquidations.</p><h5 id="h-fundamental-incompatibilities" class="text-lg font-header !mt-6 !mb-3 first:!mt-0 first:!mb-0">Fundamental incompatibilities</h5><p>Assuming for some reason that ERC721 tokens are fundamentally incompatible with MCD as an extension of the existing system (either temporarily until the technology becomes available or permanently), it is still possible to obtain collateral diversity through Fractional ERC20 token representations of NFTs.</p><h2 id="h-conclusion" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Conclusion</h2><p>The risks presented when considering inclusion of ERC721 collateral as part of MCD are broad and can be severe. Three main technologies present potentially viable options for facilitating ERC721 collateral within MCD and should be explored further:</p><ul><li><p>JPEG&apos;d price oracles <em>for use in DAI drawdown and initiating liquidations</em></p></li><li><p>SudoSwap NFT AMM pools <em>for use in facilitating NFT liquidations</em></p></li><li><p>Fractional NFTs as ERC20 tokens <em>for gaining ERC721 token exposure without ERC721 token use</em></p></li></ul>]]></content:encoded>
            <author>nofacedev@newsletter.paragraph.com (Arby)</author>
        </item>
        <item>
            <title><![CDATA[Designing a new Foundry logo]]></title>
            <link>https://paragraph.com/@nofacedev/designing-a-new-foundry-logo</link>
            <guid>ZNdtwKO3w4qNrLV7u7Vi</guid>
            <pubDate>Tue, 07 Jun 2022 14:21:26 GMT</pubDate>
            <description><![CDATA[I am a big advocate of Paradigm&apos;s Foundry. I really like a lot of things about it (particularly not having to switch between Javascript and Solidity when writing tests). However, while it&apos;s easy to find information about Foundry, there doesn&apos;t seem to be any branding for it at all. In my view, visual branding is super important for growing a product&apos;s userbase, even when it is a technical product. Products like Rust grow not only because of technical prowess, but also beca...]]></description>
            <content:encoded><![CDATA[<p>I am a big advocate of Paradigm&apos;s Foundry. I really like a lot of things about it (particularly not having to switch between Javascript and Solidity when writing tests).</p><p>However, while it&apos;s easy to find <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://book.getfoundry.sh/">information about Foundry</a>, there doesn&apos;t seem to be any branding for it at all. In my view, visual branding is super important for growing a product&apos;s userbase, even when it is a technical product. Products like Rust grow not only because of technical prowess, but also because of branding and a sense of identity and community.</p><p>As an aside, there is evidence that <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://journals.sagepub.com/doi/10.1016/j.intmar.2020.06.002">products using emojis increases engagement on Twitter</a> but you already knew that since you&apos;re probably a 🦀 <code>rustacean</code> 🦀 if you&apos;re reading this. I could also propose that the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://emojipedia.org/hammer-and-pick/">hammer and pick emoji</a> ( ⚒️) is used to represent Foundry developers - but that is for another time.</p><blockquote><p>Disclaimer: I am not a graphic designer.</p></blockquote><p>Let me show you what I came up with:</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/b45896dc20bcbb7d4147213325eb30e8331c51119bc7c1144a6042db9c559827.png" alt="My proposed logo as logotype " blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">My proposed logo as logotype</figcaption></figure><p>Now, let&apos;s dive into what the existing branding was and how I came to this result.</p><h3 id="h-what-is-the-existing-branding" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">What is the existing branding?</h3><p><em>This is the existing Foundry logo:</em></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/586f4bb0983b3df0f3e0807e6b664d23b86ebd278de9ebcf080311298680a2bd.png" alt="www dot free creative commons clip art mash up images dot com" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">www dot free creative commons clip art mash up images dot com</figcaption></figure><p>I personally think that it looks like a mashup of images from <em>free creative commons clip art images dot com</em> but that&apos;s just my opinion. The product is amazing and this doesn’t do it justice. I mean, they had to design a way to throttle chain queries since it was <em>too fast</em> and getting rate limited.</p><p><em>There is this cool graphic:</em></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/bdf01f3fffeccf0fb4f43ea43a6ab01edcbe43c2f15e739d65b9384b1a71f2af.png" alt="Do you even TDD bro?" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Do you even TDD bro?</figcaption></figure><p>I like this since:</p><ol><li><p>It is a cool graphic depicting the typical Foundry chad</p></li><li><p>It shows that the Foundry team likes the tongs as an image. I can work with that.</p></li></ol><p><em>This is the existing Paradigm logo:</em></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d45c9d04daa533e073f4dee1099f7ca70d693d3bb74ef13a460006309651ac61.png" alt="Very nice" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Very nice</figcaption></figure><p>I like the simplicity of the logo but also how it represents complexity arising from simplicity (the four triangles with truncated corners) which might be a fancy metaphor for web3 itself. I’m a big fan of this.</p><h3 id="h-lets-make-some-new-branding" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Let&apos;s make some new branding!</h3><p>Obviously the team had some ideas in mind when designing the original logo. Let&apos;s stick to things like dimensions and layout.</p><p><em>Firstly, let&apos;s make a hammer which roughly matches the dimensions of the hammer used in the old logo:</em></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ff0d5fba4e5bbaa4d01d41c49d5b47eb485306d2d04f1aad19c9689c211104a5.png" alt="The hammer" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">The hammer</figcaption></figure><p><em>Next, let&apos;s make an anvil:</em></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/b1dcb35ee71c8b74fb8898a25f8b891359bb07b872ac415399124896b261048e.png" alt="The anvil" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">The anvil</figcaption></figure><p>Here I chose to keep the motif of the &apos;truncated triangle&apos; that Paradigm uses to denote that it is a Paradigm product (and I think it fits the anvil look pretty well!).</p><p><em>Lastly, let&apos;s make a set of tongs:</em></p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/32818222d208345b35cb054eeca1070984c96e8485fc48945db407aadede6587.png" alt="The tongs" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">The tongs</figcaption></figure><p>Nice, let’s combine them and see how they look!</p><h3 id="h-lets-make-some-logos" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Let&apos;s make some logos!</h3><p>Let&apos;s put them all together now to create a new logos!</p><p>Here are a few I created:</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/63fb3ea62fc2b049d27b9f6b99f4726b01bc2bf2c627bb4bc6cf395deaa662f7.png" alt="Hammer and tongs" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Hammer and tongs</figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/515ffb7343faf1c993b46d57ccf99680decc88bd27d050baad2033cb248531f5.png" alt="Diagonal hammer" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Diagonal hammer</figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/05e9d61a19385ef58a0889edbd7cd92dae35cc35b6a3a129d6e7dcfad0b913bc.png" alt="Hammer and anvil" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Hammer and anvil</figcaption></figure><p>And finally, my proposed logo:</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ca18494acfd3dbd281f2c8806b9d78a864dfaa173fdb0c5ecdcfb531b59d7846.png" alt="The Foundry anvil" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">The Foundry anvil</figcaption></figure><p>Let&apos;s see what this looks like as logotype:</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/b45896dc20bcbb7d4147213325eb30e8331c51119bc7c1144a6042db9c559827.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>Yeah, I think it looks pretty cool!</p><p>Let me know what you guys think! I really think that it embodies the Paradigm look and feel! Paradigm is free to do whatever they want with this :)</p><p>Keep up the good work guys!</p><p>- Ulquiorra</p>]]></content:encoded>
            <author>nofacedev@newsletter.paragraph.com (Arby)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/cc12909afbd065d147a7fb3e6cb1c2b02c58208ac677758e3af2afac8f53bd96.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Roots.onion: A proposal for a long-form markdown publishing site for interaction with Lens Protocol's social graphs to facilitate censorship resistant journalism.]]></title>
            <link>https://paragraph.com/@nofacedev/roots-onion-a-proposal-for-a-long-form-markdown-publishing-site-for-interaction-with-lens-protocol-s-social-graphs-to-facilitate-censorship-resistant-journalism</link>
            <guid>20JQHpYKB3uDOr28yDpc</guid>
            <pubDate>Mon, 02 May 2022 13:25:03 GMT</pubDate>
            <description><![CDATA[IntroductionThis is a writeup on a theoretical site I propose for Lens Protocol to eventually introduce as part of their wider initiatives to create a distributed and varied social network. This product would provide a link between Tor (.onion) services and the social graph (the Lens plant). Both of these plants share roots as a component and the word root has been assigned meaning in technical fields over the years. I like the name roots. Nothing like this exists for Web2 technology at prese...]]></description>
            <content:encoded><![CDATA[<h3 id="h-introduction" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Introduction</h3><p>This is a writeup on a theoretical site I propose for Lens Protocol to eventually introduce as part of their wider initiatives to create a distributed and varied social network. This product would provide a link between Tor (.onion) services and the social graph (the Lens plant). Both of these plants share <strong>roots</strong> as a component and the word <code>root</code> has been assigned meaning in technical fields over the years. I like the name roots.</p><p>Nothing like this exists for Web2 technology at present. There is no &apos;bridge&apos; between darknet posters and clearnet readers. Perhaps this is for the best, however if we analyse this situtation from the perspective of journalism and censorship, this is a pretty big issue. Pastebin text dumps can only gain so much traction - hooking content into the wider <em>social network machine</em> is needed and there is no solution so far.</p><h3 id="h-what-is-rootsonion" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">What is Roots.onion?</h3><p>Roots is a theoretical interaction layer between darknet-only and clearnet-only users with the goal of facilitating censorship-resistant journalism and media. Roots consists of a frontend (website) which is hosted on a server (for example, a VPS) which will allow access via a <code>.onion</code> address. Roots would allow for individuals who fear censorship to publish posts in a truly anonymous manner (via Tor) with minimal risk to their privacy. Obviously the final URI would look much longer than <em>roots.onion</em> but it might look something like <code>rootslensbd7szmgncyruucpgfkqahzddi37ktceo3ah7ngmcopnpyyd.onion</code> (a Tor v3 onion address).</p><h3 id="h-the-roots-frontend" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">The Roots frontend</h3><p>The roots frontend could look somewhat similar to existing platforms like <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://mirror.xyz/">Mirror</a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/">Medium</a> or even <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://pastebin.com/">Pastebin</a>- all of which have seen adoption as methods of disseminating ideas via long-text-format.</p><p>The roots frontend be HTML based, with minimal JS interaction (as Tor is considered more secure with JS disabled) and no JS necessary for interaction with the backend.</p><p>As many tools (such as Ethers and Web3JS, which are commonly used to communicate with blockchains) are heavily JS reliant and bloated, the burden of operating JS can be shifted to the backend. This would allow for a simplistic yet functional frontend (ideally with a basic markdown edited like Mirror has implemented) which allows for long-form text-based content creation.</p><p><em>Couldn&apos;t Mirror.xyz just do this?</em></p><p>Maybe, but their site is so JS reliant right now that it won&apos;t even run properly on hardened Firefox, let alone Tor. Tor with JS is still private but not all privacy-conscious users will enable JS.</p><h3 id="h-the-roots-backend" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">The Roots backend</h3><p>The roots backend would be a basic VPS-hosted server which accepts requests from the frontend as well as a signed message (or perhaps the content itself could be signed?) verifying the authenticity of the author. The backend would check this and then post the information to the Lens Protocol social graph via the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.lens.dev/docs/publication">publication function</a>. Some sybil-attack resistance mechanisms may have to be implemented here to prevent network spam. A time delay for publication may also be implemented (customised by the user) to prevent time-analysis correlation attacks.</p><h3 id="h-privacy-considerations-of-lens" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Privacy considerations of Lens</h3><p>Of course, there are privacy considerations which users would need to consider when creating their lens profile NFT.</p><ul><li><p>EVM-compatible chains (such as Polygon, which Lens Protocol runs on) are not private by design, and no truly decentralised Monero-Polygon bridge exists. Options like Changelly exist but they have had issues in the past. This poses some user-adoption issues but if the users are already using Tor this shouldn&apos;t be too much of an issue.</p></li></ul><h3 id="h-bad-actors" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Bad actors</h3><p>Illegal or undesirable content can mostly be mitigated by only allowing image embeds and markdown (Mirror&apos;s approach). Responsibility for removing infringing content lies with IPFS or Arweave (the hosting service). Ideally this traffic would not go to AWS S3 given it is supposed to be as censorship-proof as possible.</p><p>Sybil attack mitigation can be achieved through basic mechanisms such as Captchas (employed by many onion sites) when submitting content.</p><h3 id="h-why-dont-you-go-and-make-it" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Why don&apos;t you go and make it?</h3><p>I have no experience working with VPS solutions, .onion hosting and to be honest I&apos;m more of a JS frontend dev and this requires HTML. The reason why I am a big fan of Lens is because this is possible - Twitter has launched their own .onion site but it doesn&apos;t prevent identification through the email and mobile number they collect. I don&apos;t want to build it right now and go after a grant so consider this idea open sourced.</p><p><strong>I do want to work at Lens though. Hit me up :)</strong></p>]]></content:encoded>
            <author>nofacedev@newsletter.paragraph.com (Arby)</author>
        </item>
        <item>
            <title><![CDATA[WTF is a reentrancy attack and how do I prevent it?]]></title>
            <link>https://paragraph.com/@nofacedev/wtf-is-a-reentrancy-attack-and-how-do-i-prevent-it</link>
            <guid>Rw9YrRsL3pnnBto4JODW</guid>
            <pubDate>Sun, 01 May 2022 05:09:18 GMT</pubDate>
            <description><![CDATA[They’re here and they’re here to stay, so let’s learn to design around them. WTF is a reentrancy attack? I agree that the name sounds kind of dumb, I would call it recursive call attacks if I could choose a name for it. Maybe recursive withdrawal attack? How about nested function call attack? Anyway, the name doesn&apos;t matter - let&apos;s talk about single function reentrancy and cross function reentrancy. I will not cover cross contract reentrancy yet as I lack the knowledge to cover it i...]]></description>
            <content:encoded><![CDATA[<p>They’re here and they’re here to stay, so let’s learn to design around them.</p><p><strong>WTF is a reentrancy attack?</strong></p><p>I agree that the name sounds kind of dumb, I would call it <em>recursive call</em> attacks if I could choose a name for it. Maybe <em>recursive withdrawal</em> attack? How about <em>nested function call</em> attack?</p><p>Anyway, the name doesn&apos;t matter - let&apos;s talk about <em>single function reentrancy</em> and <em>cross function reentrancy</em>. I will not cover <em>cross contract reentrancy</em> yet as I lack the knowledge to cover it in depth yet.</p><p><strong>Simple / single function reentrancy attacks</strong></p><p>Let&apos;s look at simple reentrancy:</p><pre data-type="codeBlock" text="//This will pay the zero address.
address payable user = address(0);
uint256 balance = 100;
function withdraw(uint256 amt_){
    require(balance&gt;0);
    user.transfer(amt_); //Send the user 1
    balance-=amt_;
}
"><code><span class="hljs-comment">//This will pay the zero address.</span>
<span class="hljs-keyword">address</span> <span class="hljs-keyword">payable</span> user <span class="hljs-operator">=</span> <span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>);
<span class="hljs-keyword">uint256</span> balance <span class="hljs-operator">=</span> <span class="hljs-number">100</span>;
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">withdraw</span>(<span class="hljs-params"><span class="hljs-keyword">uint256</span> amt_</span>)</span>{
    <span class="hljs-built_in">require</span>(balance<span class="hljs-operator">></span><span class="hljs-number">0</span>);
    user.<span class="hljs-built_in">transfer</span>(amt_); <span class="hljs-comment">//Send the user 1</span>
    balance<span class="hljs-operator">-</span><span class="hljs-operator">=</span>amt_;
}
</code></pre><p>Ignore syntax mistakes here, this is just to show you what something like this looks like.</p><p>Let&apos;s call this function 100 times.</p><p>In some cases, <code>user.transfer()</code> can occur multiple times before the balance is decreased (withdrawing twice from the contract). This example might be a bit poor because <code>transfer</code> has a fixed gas limit of 2300 which generally can&apos;t be abused by a contract which receives Eth, but <code>user.send()</code> could definitely have this effect. The receiving contract just needs to implement a fallback function which calls <code>withdraw()</code> again to abuse this. <em>This is called a simple reentrancy attack.</em></p><p><strong>Preventing this</strong></p><p>We can work towards preventing this in a variety of ways:</p><ol><li><p>Decrease the balance <em>before</em> we do the transfer. This is called the checks-effects-interactions design pattern</p></li></ol><pre data-type="codeBlock" text="//This will pay the zero address.
address payable user = address(0);
uint256 balance = 100;
function withdraw(uint256 amt_){
    require(balance&gt;0);
    balance-=amt_;
    user.transfer(amt_); //Send the user 1
}
"><code><span class="hljs-comment">//This will pay the zero address.</span>
<span class="hljs-keyword">address</span> <span class="hljs-keyword">payable</span> user <span class="hljs-operator">=</span> <span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>);
<span class="hljs-keyword">uint256</span> balance <span class="hljs-operator">=</span> <span class="hljs-number">100</span>;
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">withdraw</span>(<span class="hljs-params"><span class="hljs-keyword">uint256</span> amt_</span>)</span>{
    <span class="hljs-built_in">require</span>(balance<span class="hljs-operator">></span><span class="hljs-number">0</span>);
    balance<span class="hljs-operator">-</span><span class="hljs-operator">=</span>amt_;
    user.<span class="hljs-built_in">transfer</span>(amt_); <span class="hljs-comment">//Send the user 1</span>
}
</code></pre><ol><li><p>Add a <code>lock</code> (or <code>mutex</code> as the solidity docs refer to it) variable so that the function literally cannot be called concurrently during the same call. Let&apos;s implement the <code>noReentrancy</code> modifier that the Solidity docs uses.</p></li></ol><pre data-type="codeBlock" text="//This will prevent simple reentrancy attacks
bool locked;  
modifier noReentrancy() {  
    require(  
        !locked,  
        &quot;Reentrant call.&quot;  
    );  
    locked = true;  
    _;  
    locked = false;  
}

//This will pay the zero address.
address payable user = address(0);
uint256 balance = 100;
function withdraw(uint256 amt_) noReentrancy {
    require(balance&gt;0);
    balance-=amt_;
    user.transfer(amt_); //Send the user 1
}
"><code><span class="hljs-comment">//This will prevent simple reentrancy attacks</span>
<span class="hljs-keyword">bool</span> locked;  
<span class="hljs-function"><span class="hljs-keyword">modifier</span> <span class="hljs-title">noReentrancy</span>(<span class="hljs-params"></span>) </span>{  
    <span class="hljs-built_in">require</span>(  
        <span class="hljs-operator">!</span>locked,  
        <span class="hljs-string">"Reentrant call."</span>  
    );  
    locked <span class="hljs-operator">=</span> <span class="hljs-literal">true</span>;  
    <span class="hljs-keyword">_</span>;  
    locked <span class="hljs-operator">=</span> <span class="hljs-literal">false</span>;  
}

<span class="hljs-comment">//This will pay the zero address.</span>
<span class="hljs-keyword">address</span> <span class="hljs-keyword">payable</span> user <span class="hljs-operator">=</span> <span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>);
<span class="hljs-keyword">uint256</span> balance <span class="hljs-operator">=</span> <span class="hljs-number">100</span>;
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">withdraw</span>(<span class="hljs-params"><span class="hljs-keyword">uint256</span> amt_</span>) <span class="hljs-title">noReentrancy</span> </span>{
    <span class="hljs-built_in">require</span>(balance<span class="hljs-operator">></span><span class="hljs-number">0</span>);
    balance<span class="hljs-operator">-</span><span class="hljs-operator">=</span>amt_;
    user.<span class="hljs-built_in">transfer</span>(amt_); <span class="hljs-comment">//Send the user 1</span>
}
</code></pre><p>OpenZeppelin has an implementation of this called <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://docs.openzeppelin.com/contracts/4.x/api/security#ReentrancyGuard">ReentrancyGuard</a> which I would recommend using over trying to build your own implementation. <em>NoReentrant functions using this should be external.</em></p><p><strong>Aside: WTF does _; do?</strong></p><p>Good question. Solidity docs 0.8.13 doesn&apos;t really cover this in enough depth for my liking. Let me give you a tldr so you don&apos;t have to google it.</p><p>Modifier X calls function Y. <code>_;</code> is where function Y runs within the modifier X. Think of it like calling <code>Y();</code> but in a generic (non-name-specific) fashion.</p><ol><li><p><em>For extreme protection</em> we can implement a solution proposed by <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/ThomasBertani/status/1494724255153545219/photo/1">@ThomasBertani&apos;s </a>which disallow calling the function twice in the same call by comparing values of <code>gasleft()</code> (when the slot is warm, it cannot be called again). This is extreme since it means no implementation of your contract will be able to have anything with that modifier called twice. @transmissions11 does not recommend this for most cases but it seems to be the most comprehensive method to prevent simple reentrancy.</p></li></ol><p><strong>Cross-function reentrancy attacks</strong></p><p><em>NOTE: &quot;Cross reentrancy attack&quot; could refer to this or cross-contract</em></p><p><em>If stopping reentrancy is that simple, then why are attacks still working?</em></p><p>Let me introduce you to the cross reentrancy attack. <em>When two functions share the same state (a variable usually), this is possible</em>. Let&apos;s imagine a <code>withdrawEth()</code> function for one type of user (as is being implemented in my escrow contract) and a <code>withdrawEthWithDecision() </code>function (which is called under a different set of circumstances).</p><p>Hypothetically (and in reality) an attacking contract can invoke a change in state by calling one function (which is not reentrancy protected) which does not update the state in time for the other (concurrent) call to drain funds. All it takes is one function which shares state and isn&apos;t reentrancy protected properly.</p><p>Making sure that functions which affect state have proper protections against reentrancy is necessary to prevent this. <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/coinmonks/protect-your-solidity-smart-contracts-from-reentrancy-attacks-9972c3af7c21">Using a bunch of single-function reentrancy protections</a> to make sure that nested / recursive calls to a function which changes state can&apos;t be made is usually enough - the crux of these attacks is always the state not updating at the time the effects take place.</p><p>Where there are multiple functions, setting up a system for <em>untrusted</em> functions (which call unknown contracts) <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://consensys.net/blog/developers/ethereum-smart-contract-security-recommendations/">is good practise</a> (this is by Consensys, however note that Consensys have their own guidelines which suggest only using <code>call()</code> rather than <code>transfer()</code> or <code>send()</code>, however this is not for reentrancy prevention reasons and has more to do with the 2300 gas stipend not being enough for some fallback functions to execute fully after <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://eips.ethereum.org/EIPS/eip-1884">EIP-1884</a> which is a separate issue altogether).</p><p><strong>Cross-contract reentrancy</strong></p><p>This is like the cross-function reentrancy attack, but when state is shared across contracts. I am not informed enough yet to comment on ways to prevent this type of attack, so I will <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://inspexco.medium.com/cross-contract-reentrancy-attack-402d27a02a15">refer you to better resources.</a></p><p>More complexity in a system leads to more surface area for attacks. Keeping things simple is often better than a complex setup for the sake of it (which can get attacked in many ways).</p><p><strong>Transfer vs Send</strong></p><p>Solidity Docs actually recommend using <code>transfer()</code> over <code>send()</code> as a way of making sure that transfers failing does not expose your contract to abuse (or result in loss of funds).</p><p>The 2300 gas stipend is a good feature to try and prevent reentrancy attacks but it is not enough alone.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/b5a1e3682713c48edda874090adf0567505c0caa64f4261fc69ae7b658393ce0.png" alt="Solidity Docs" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Solidity Docs</figcaption></figure><p><em>My recommendation is literally not to use</em> <code>call()</code> unless <code>transfer()</code> or <code>send()</code> cannot accomplish the purpose of the action you&apos;re trying to perform. <code>call()</code> is super vulnerable since it forwards all remaining gas to the contract is calls but is often needed when the 2300 gas stipend isn&apos;t enough to execute fallback functions (or just for calls which needs more gas).</p><p><strong>Conclusion</strong></p><p>Although some will say that the check-effects-interactions design pattern alone is enough to prevent damage from reentrancy attacks, I am a believer in <code>mutex</code> and <code>lock</code> modifiers in addition to this.</p><p>Keep your code simple and easy to mentally follow and things should generally be fine - thinking as if you are an attacker while you develop is also a good way to avoid (human-error caused) design pitfalls which could be exploited later.</p><p><strong>Aside: do audits mean nothing?</strong></p><p>In my opinion, pretty much - when you dangle $10m in front of math and computer nerds, they&apos;re going to outperform a $25k audit given enough effort. If an auditor had code with reentrancy vulnerabilities in there at the time when they audited it and didn&apos;t catch it, they screwed up. Everyone has screwed up - <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://rekt.news/leaderboard/">Certik, Quantstamp, Peckshield and OpenZeppelin</a> have all had contracts they audited be exploited. Saddle Finance (who just got hit) <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/saddle-finance/saddle-audits">had three of those</a> companies audits completed.</p><p>The security industry doesn&apos;t expect pen testing to be secure over time as network and physical attacks evolve over time, though here we are talking about people&apos;s money. I am not a believer of audits being any better or worse than <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/llamapay_io/status/1520302594152927232">having your code reviewed by a developer</a>. I am not a believer of anything certified being hack-proof whatsoever. My heart goes out to Saddle and others who have been hit by these attacks - the fact that they paid for multiple audits by big name firms shows that their intentions are good and I hope that they recover. I am personally a fan of <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/code4rena">crowdsourced-style audits</a> which I feel give the same pool of attackers a chance to make some money (whereas giving a firm an audit contract limits who can earn money off it) but again nothing is perfect.</p><p><em>We can only try our best, there are no guarantees.</em></p>]]></content:encoded>
            <author>nofacedev@newsletter.paragraph.com (Arby)</author>
        </item>
        <item>
            <title><![CDATA[Preface: Setting up a working environment using Foundry]]></title>
            <link>https://paragraph.com/@nofacedev/preface-setting-up-a-working-environment-using-foundry</link>
            <guid>Om7HGZZnVbOlkCbnEtde</guid>
            <pubDate>Thu, 28 Apr 2022 07:52:39 GMT</pubDate>
            <description><![CDATA[This writeup is a continuation of my last post, where I go into how I am creating a full stack DApp within 30 days. This section will cover what I am using to build my DApp (specifically the Solidity parts). Software Requirements Let&apos;s go through what tools I&apos;m using for this:Solidity v0.8.13 The latest version of Solidity which will work with the tools I have installed.Foundry v0.2.0 Foundry (Forge) is an Ethereum development tool released by Paradigm. It is faster, more flexible a...]]></description>
            <content:encoded><![CDATA[<p><em>This writeup is a continuation of my last post, where I go into how I am creating a full stack DApp within 30 days.</em> <em>This section will cover what I am using to build my DApp (specifically the Solidity parts).</em></p><p><strong>Software Requirements</strong></p><p>Let&apos;s go through what tools I&apos;m using for this:</p><ul><li><p>Solidity v0.8.13</p><p>The latest version of Solidity which will work with the tools I have installed.</p></li><li><p>Foundry v0.2.0</p><p>Foundry (Forge) is an Ethereum development tool released by Paradigm. It is faster, more flexible and (in my view) superior to Hardhat, which I have used previously. Notable benefits of Foundry are that tests are written in Solidity rather than JavaScript, tests can be done using fuzzing to allow for more comprehensively tested code, it is faster than alternatives and is gaining a foothold within the Solidity dev community. You could probably do the same things I am doing using Hardhat (in fact, it may be better for complete beginners) but I am going to use Foundry. Read more <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.paradigm.xyz/2022/03/foundry-02#what-is-foundry">on Paradigm&apos;s website</a></p><p>I will also be using the forge standard library which you can read about <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/foundry-rs/forge-std/">here</a>. It contains useful tools for testing and learning how things work - I would consider it essential. GitHub</p><p>GitHub will host my code <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/NoFaceDev/Arbiter">at this repository</a>Version control is good practise, but I am the only dev involved here, so this is mainly to allow for workflow tracking and to keep everything nice and open source. I have stuff under a LGPL license (I just copied Sablier&apos;s license type) for now.</p></li><li><p>VSCodium IDE</p><p>I like VSCode. I don&apos;t like Microsoft sending telemetry when I use it. <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/VSCodium/vscodium">VSCodium exists for this reason.</a>I am using the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/contractshark/vscode-solidity-extenstion">Solidity Syntax extension by contractshark</a> since the most popular syntax highlighter highlights errors when I use it with Foundry.</p></li></ul><p>Later on I will be using ReactJS for the frontend, but for the Solidity aspects, this is all you need!</p><p><strong>Setup</strong></p><p>I created a repo, put it under the LGPL license and ran <code>forge init</code> to create a starter template.</p><p>We can run this sample template by running <code>forge test</code></p><p>Which produces the following output:</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/5503fddde03b683cb03c43610f79a8c8a1a1ddd3b307cf8d65c4de6b73d86371.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>Now we have this running, it&apos;s important to note that the Solidity for the smart contract is in the <code>src</code> folder whereas tests (Foundry also uses Solidity for tests) are in the <code>test</code> folder. A test file has the <code>.t.sol</code> file ending rather than <code>.sol</code> (which is for contracts).</p><p>I renamed the files and imports which used the word <em>Contract</em> within these files and then re-ran the demo test to make sure it all runs.</p><p>Adding <em>forge-std</em> was as simple as following <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/foundry-rs/forge-std/#install">the guide</a> and I ended up using <code>emit log_string()</code> as a version of JavaScript&apos;s <code>console.log()</code> function. You can also use <code>console2.log()</code>, in fact it is recommended, but I&apos;ve used <code>emit</code> to log before so I am more used to it.</p><p>Using the VM for writing tests is super useful, although that&apos;s for another time. At this stage you should be ready to start building out your smart contract and playing around with Solidity.</p>]]></content:encoded>
            <author>nofacedev@newsletter.paragraph.com (Arby)</author>
        </item>
        <item>
            <title><![CDATA[NoFaceDev's Markdown Resume]]></title>
            <link>https://paragraph.com/@nofacedev/nofacedev-s-markdown-resume</link>
            <guid>Hqb6rC87uPH8hezefn53</guid>
            <pubDate>Thu, 28 Apr 2022 04:24:40 GMT</pubDate>
            <description><![CDATA[NoFaceDev.ethThis resume was written using markdown. I am willing to reveal my identity as part of the hiring process if required.AboutI am a solidity and smart contract developer who has been working with Ethereum since 2020. Initially exposed to the world of DeFi and Ethereum through Web3JS and Ethers, I am passionate about building novel projects which I would like to use myself. I am looking for an environment where I can contribute meaningfully as part of a team while also working indepe...]]></description>
            <content:encoded><![CDATA[<h1 id="h-nofacedeveth" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">NoFaceDev.eth</h1><p><em>This resume was written using markdown. I am willing to reveal my identity as part of the hiring process if required.</em></p><h2 id="h-about" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">About</h2><p>I am a solidity and smart contract developer who has been working with Ethereum since 2020. Initially exposed to the world of DeFi and Ethereum through Web3JS and Ethers, I am passionate about building novel projects which I would like to use myself.</p><p>I am looking for an environment where I can contribute meaningfully as part of a team while also working independently to produce high quality code.</p><h2 id="h-three-notable-projects" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Three Notable Projects</h2><ul><li><p>DAO-resolved escrow smart contract <em>(Work in progress)</em> <em>Solidity</em></p></li></ul><p>Extending the capabilities of a basic escrow smart contract, this project aims to add ERC20, ERC721 and ERC1155 compatibility and allow a DAO to vote on escrow resolution results.</p><ul><li><p>Selenium DeFi swap tool / NodeJS CLI DeFi swap tool <em>Selenium, Python / Javascript</em></p></li></ul><p>Using Web3JS and Ethers to work with Ethereum in Javascript, I created a tool which allows users to swap on certain DEXes straight from the CLI. This aspect served as an inspiration for further work which involved Metamask interaction and performing swaps directly using a headless Gecko browser and Selenium webdriver.</p><ul><li><p>IPFS mass upload tool <em>Javascript</em></p></li></ul><p>A NodeJS program which upload and pins a directory of 10,000 or more images to IPFS to facilitate NFT project creation.</p><h2 id="h-experience" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Experience</h2><ul><li><p>Frontend Software Engineer @ Consulting Firm <em>Current employment</em></p></li></ul><p>I have been working at a consulting firm for over a year performing the duties of a frontend web developer. As a lead developer across engagements, I improved the primary codebase to allow a low-code modification approach for future prototyping, reducing prototyping costs by as much as 80% (per management&apos;s estimates).</p><ul><li><p>Founder @ Small Business <em>Previous employment</em></p></li></ul><p>I founded and ran a small business in the finance sector. My role was heavily client facing and I managed all aspects of the business until it ceased operating when I joined my software engineering role.</p><h2 id="h-contact" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Contact</h2><p><em>Twitter is easiest to reach me on.</em></p><ul><li><p>Protonmail <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="mailto:nofacedev@protonmail.com"><em>nofacedev@protonmail.com</em></a></p></li><li><p>Twitter <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/NoFaceDeveloper">@NoFaceDeveloper</a></p></li><li><p>Mirror <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://mirror.xyz/NoFaceDev.eth">NoFaceDev.eth</a></p></li><li><p>GitHub <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/NoFaceDev">NoFaceDev</a></p></li></ul>]]></content:encoded>
            <author>nofacedev@newsletter.paragraph.com (Arby)</author>
        </item>
    </channel>
</rss>