<?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>RandomDude</title>
        <link>https://paragraph.com/@randomdude</link>
        <description>undefined</description>
        <lastBuildDate>Thu, 13 Aug 2026 09:23:31 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[Elliptic Curve Families]]></title>
            <link>https://paragraph.com/@randomdude/elliptic-curve-families</link>
            <guid>KepjcnFKX6yHciUNcWxG</guid>
            <pubDate>Sat, 03 Dec 2022 15:42:16 GMT</pubDate>
            <description><![CDATA[Title: Elliptic Curves Families Author: Written with the help of OpenAI Read: 20 min Description: Provide basic understanding of different elliptic curves families, which is commonly used in cryptography. Body: So here are some Elliptic curves:The NIST P-256 curve, which is defined by the equation y^2 = x^3 - 3x + b, where b = 41058363725152142129326129780047268409114441015993725554835256314039467401291.The NIST P-384 curve, which is defined by the equation y^2 = x^3 - 3x + b, where b = 39402...]]></description>
            <content:encoded><![CDATA[<p>Title: Elliptic Curves Families</p><p>Author: Written with the help of OpenAI</p><p>Read: 20 min</p><p>Description: Provide basic understanding of different elliptic curves families, which is commonly used in cryptography.</p><p>Body:</p><p>So here are some Elliptic curves:</p><ul><li><p>The NIST P-256 curve, which is defined by the equation y^2 = x^3 - 3x + b, where b = 41058363725152142129326129780047268409114441015993725554835256314039467401291.</p></li><li><p>The NIST P-384 curve, which is defined by the equation y^2 = x^3 - 3x + b, where b = 39402006196394479212279040100143613805079739270465446667948293404245721771496870329047266088258938001861606973112316.</p></li><li><p>The secp256k1 curve, which is defined by the equation y^2 = x^3 + 7, where a = 0 and b = 7.</p></li><li><p>The NIST P-521 curve, which is defined by the equation y^2 = x^3 - 3x + b, where b = 0x01FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF.</p></li><li><p>The Brainpool P-256r1 curve, which is defined by the equation y^2 = x^3 + ax + b, where a = -3 and b = 0x52036CEE2B6FFE738CC740797779E89800700A4D4141D8AB75EB4DCA135978A3E.</p></li><li><p>The secp192r1 curve, which is defined by the equation y^2 = x^3 + ax + b, where a = -3 and b = 0x64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1.</p></li></ul><p>And the differences between these curves:</p><ol><li><p>The main difference between the NIST P-256 and NIST P-384 elliptic curves is the size of the prime number that defines the curve. The P-256 curve is defined using a 256-bit prime, while the P-384 curve is defined using a 384-bit prime. This means that the P-384 curve provides a higher level of security than the P-256 curve, since it is more difficult to find the discrete logarithm of a point on the P-384 curve than on the P-256 curve. However, the increased security of the P-384 curve comes at the cost of slower performance, since operations on the P-384 curve are more computationally intensive than on the P-256 curve. Therefore, the choice of which curve to use depends on the specific security and performance requirements of the application.</p></li><li><p>The secp256k1 and NIST P-256 elliptic curves are both defined over the same field (the set of integers modulo a prime number), but they have different equations and different values for the constants in those equations. The secp256k1 curve is defined by the equation y^2 = x^3 + 7, while the NIST P-256 curve is defined by the equation y^2 = x^3 - 3x + b, where b = 4105836372515214212932612978004726840911444101599372555483525631403946740129.</p></li></ol><p>The main difference between these two curves is that the secp256k1 curve has a much simpler equation, which makes it more efficient to work with. This makes it well-suited for applications such as cryptocurrencies, where fast and efficient elliptic curve operations are important. On the other hand, the NIST P-256 curve provides a higher level of security than the secp256k1 curve, since it is more difficult to find the discrete logarithm of a point on the NIST P-256 curve than on the secp256k1 curve. Therefore, the choice of which curve to use depends on the specific security and performance requirements of the application.</p><p>The above curves are represented in the Weierstrass form, the most common form of representation when you Google ellipitc curve. There are also various other forms of elliptic curve representation, which can provide certain comptuational advantage under certain conditions.</p><ul><li><p>The Weierstrass model, which uses a standard cubic equation to define the curve and projective coordinates to represent points on the curve.</p></li><li><p>The Twisted Edwards model, which uses a quadratic equation to define the curve and affine coordinates to represent points on the curve.</p></li><li><p>The Montgomery model, which uses a quartic equation to define the curve and projective coordinates to represent points on the curve.</p></li><li><p>The Edwards model, which uses a quadratic equation to define the curve and projective coordinates to represent points on the curve.</p></li></ul><p>And here are some curves that uses the Twisted Edwards model:</p><ul><li><p>The ed25519 curve, which is defined by the equation -x^2 + y^2 = 1 + dx^2y^2, where d = -121665/121666. This curve is commonly used in applications such as digital signatures and key exchange.</p></li><li><p>The curve25519 curve, which is defined by the equation -x^2 + y^2 = 1 + dx^2y^2, where d = 37095705934669439343138083508754565189542113879843219016388785533085940283555. This curve is similar to the ed25519 curve, but is not a standard NIST curve.</p></li><li><p>The Ed448-Goldilocks curve, which is defined by the equation a = 39081 and b = c = 2000000000000000000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed. This curve is a variant of the Ed448 curve, which is defined by the equation a = -39081 and b = c = 2000000000000000000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed.</p></li></ul><p>Moving on from regular elliptic curves, there are also pairing-friendly elliptic curves. Pairing-friendly elliptic curves are a special type of elliptic curve that are well-suited for use in certain cryptographic protocols that involve a mathematical operation known as a &quot;pairing&quot;. There are many different types of pairing-friendly curves, and the specific curves used can depend on the specific requirements and preferences of the application. Some examples of pairing-friendly curves include:</p><ul><li><p>The Barreto-Naehrig (BN) curve, which is defined by the equation y^2 = x^3 + b, where b = 0x202FEB054934C0AEE7E84DCCFE1E7F9DF25CFDADF7E31E16A2360C1A39C6D3D588A3CC8B9F65784D2917F7042BBBE23E45A2E1D2CE03FE2E1F8F8A9CA46D191B.</p></li><li><p>The Barreto-Lynn-Scott (BLS) curve, which is defined by the equation y^2 = x^3 + b, where b = 0x2. This curve is commonly used in BLS signature schemes.</p></li><li><p>The Boneh-Franklin (BF) curve, which is defined by the equation y^2 = x^3 + b, where b = 0x12C9D9585769C049C5D5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5B5 And these curves can be used with various pairing functions such as:</p></li><li><p>The Tate pairing, which is a type of pairing that can be used with any elliptic curve.</p></li><li><p>The Weil pairing, which is another type of pairing that can be used with any elliptic curve.</p><p>Things work pretty much the same in pairing-friendly curves, just that they support the extra functionality of pairing. Pairing is a mathematical operation that takes two points on an elliptic curve and maps them to a specific value in a finite field. This operation has specific properties that make it useful for certain cryptographic protocols, such as those used in identity-based cryptography and attribute-based encryption.</p><p>To highlight the power of pairing, let&apos;s examine an example BLS aggregation signature protocol. The BLS aggregation signature protocol is a technique for combining multiple individual BLS signatures into a single signature that is smaller and more efficient to verify. This technique is useful in applications where many different parties need to sign a message or document, as it allows the signatures to be combined into a single signature that can be verified more efficiently. The specific steps involved in the BLS aggregation signature protocol can vary depending on the specific implementation and the specific requirements of the application. However, in general, the process for aggregating BLS signatures using the BLS aggregation signature protocol involves the following steps:</p></li></ul><ol><li><p>Each party who needs to sign the message or document generates a private key and a corresponding public key, using the BLS curve that is being used for the signatures.</p></li><li><p>Each party then signs the message or document using their private key, resulting in an individual BLS signature.</p></li><li><p>The individual BLS signatures are then combined into a single signature using a specific aggregation algorithm, such as the BLS threshold signature scheme. This algorithm allows the individual signatures to be combined into a single signature that is smaller and more efficient to verify.</p></li><li><p>The resulting aggregated signature is then verified using the individual public keys of the parties who signed the message or document. (And the only reason why this is possible, is because of pairing&apos;s property)</p></li></ol><p>Overall, the BLS aggregation signature protocol is a technique for combining multiple BLS signatures into a single signature that is more efficient to verify. This technique is useful in applications where many parties need to sign a message or document, as it allows the signatures to be combined into a single signature that can be verified more efficiently.</p><p>Another interesting fact is that for Elliptic curves such as BLS curves, there are also various families. As mentioned earlier, BLS is a family of pairing-friendly elliptic curves that are defined by the equation y^2 = x^3 + b, where b is a specific value. For example, the most famous family is the BLS12 curve family, which is a specific subfamily of BLS curves that are defined by the equation y^2 = x^3 + b, where b is chosen such that the resulting curve has specific properties that make it well-suited for use in cryptographic protocols that involve a pairing operation. There are other families of BLS curves besides the BLS12 family that are defined by the equation y^2 = x^3 + b, where b is a specific value. These other families of BLS curves may have different properties and may be well-suited for different applications than the BLS12 family of curves. Some examples of families of BLS curves that are not part of the BLS12 family include:</p><ul><li><p>BLS48: This is a family of BLS curves that are defined by the equation y^2 = x^3 + b, where b is chosen such that the resulting curve has specific properties that make it well-suited for use in protocols that require efficient scalar multiplication operations.</p></li><li><p>BLS48-581: This is a specific curve in the BLS48 family that is defined by the equation y^2 = x^3 + b, where b = 0x24AA2B2F08F0A91260805272DC51051C6E47AD4FA403B02B4510B647AE3D1770BAC0326A805BBEFD48056C8C121BDB8. It is commonly used in protocols that require efficient scalar multiplication operations.</p></li><li><p>BLS24: This is a family of BLS curves that are defined by the equation y^2 = x^3 + b, where b is chosen such that the resulting curve has specific properties that make it well-suited for use in protocols that require efficient pairing operations.</p></li><li><p>BLS24-377: This is a specific curve in the BLS24 family that is defined by the equation y^2 = x^3 + b, where b = 0x1A0111EA397FE69A4B1BA7B6434BACD764774B84F38512BF6730D2A0F6B0F6241EABFFFEB153FFFFB9FEFFFFFFFFAAAB. It is commonly used in protocols that require efficient pairing operations.</p></li></ul><p>In conclusion, elliptic curves are a mathematical concept that is used in many different fields, including number theory, algebraic geometry, and cryptography. In cryptography, elliptic curves are used to define specific curves that are well-suited for use in a variety of cryptographic protocols, such as public key cryptography and digital signatures. Elliptic curves are defined by equations of the form y^2 = x^3 + ax + b, where a and b are specific values. These equations have specific properties that make them useful for cryptographic applications, such as the ability to define a group structure on the points on the curve. There are many different types of elliptic curves that are used in cryptography, including Weierstrass curves, twisted Edward curves, and BLS curves. Each of these types of curves has specific properties that make it well-suited for different applications. Overall, elliptic curves are a powerful mathematical concept that is used in many different fields, including cryptography. These curves have specific properties that make them useful for cryptographic applications, and they are commonly used in a variety of cryptographic protocols.</p>]]></content:encoded>
            <author>randomdude@newsletter.paragraph.com (RandomDude)</author>
        </item>
        <item>
            <title><![CDATA[Move Ecosystem]]></title>
            <link>https://paragraph.com/@randomdude/move-ecosystem</link>
            <guid>NX39FVrdaTwI0FKGPaR7</guid>
            <pubDate>Wed, 07 Sep 2022 14:49:41 GMT</pubDate>
            <description><![CDATA[Title: Move Ecosystem Author: Not gonna tell u my name Last Modified: 26-07-22 Read: 8 min Description: Move is an executable bytecode language used to implement custom transactions and smart contracts designed by Meta Engineers (who had left to build Aptos & Sui). The Move ecosystem refers to any applications involving the Move Language, including Aptos, Pontem, Hippo Labs, Martian and more.TL;DRMove is a bytecode language used by several blockchains such as Diem, Aptos & SuiAptos is current...]]></description>
            <content:encoded><![CDATA[<p><strong>Title:</strong> Move Ecosystem</p><p><strong>Author:</strong> Not gonna tell u my name</p><p><strong>Last Modified:</strong> 26-07-22</p><p><strong>Read:</strong> 8 min</p><p><strong>Description:</strong></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://move-book.com/">Move</a> is an executable bytecode language used to implement custom transactions and smart contracts designed by Meta Engineers (who had left to build Aptos &amp; Sui). The Move ecosystem refers to any applications involving the Move Language, including Aptos, Pontem, Hippo Labs, Martian and more.</p><h2 id="h-tldr" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">TL;DR</h2><ul><li><p>Move is a bytecode language used by several blockchains such as Diem, Aptos &amp; Sui</p></li><li><p>Aptos is currently one of the fastest layer one blockchains out there, setting a record of 180k TPS, Solana only claimed 50k TPS and operated at ~5k TPS.</p></li></ul><h2 id="h-overview" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Overview</h2><p>To understand the Move Ecosystem, one should first take a look at the history of the Move Programming Language. Move Programming Language was initially developed within Meta (Facebook) for a blockchain project known as Libra. Libra later got rebranded to Diem on Dec 1st 2020, and sold to Silvergate in Jan 2022 after facing a lot of pressure from regulators. The developers of Diem also took off midway to create their own blockchain, known as Aptos, in order to put their ideas into motion, ditch bureaucratic red tape, and build an entirely new network from the ground up that brings them to fruition. Some developers also went on to create Sui, which is another blockchain that uses a slightly modified Move Programming Language, and another consensus algorithm. As of July 25th, Aptos has managed to raise $350 million (USD) prior to their mainnet launch, which is scheduled to happen at the end of September or later. And it is one of the record breaking chains in terms of technical performance and funds raised, and also the center of Move Ecosystem currently.</p><h2 id="h-google-trend" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Google Trend</h2><p>Before we dive into the numbers &amp; statistics of Aptos, let&apos;s first take a look at the three most popular cryptocurrency (excluding stablecoins &amp; memecoins)</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e35567cf30f8c0ff3bb9cfc9438c144eca1afa340ffaca2c0455cee5511c07a4.png" alt="Bitcoin in the lead, with Solana cutting very close to Ethereum" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Bitcoin in the lead, with Solana cutting very close to Ethereum</figcaption></figure><p>Bitcoin is still the most popular cryptocurrency, but what is interesting is that people are getting more &amp; more interested in Solana during the years of 2021-2022. While it is still hard to say if Solana will overtake Ethereum in the next bull run, Defi is definitely no longer limited to Ethereum and bleeding into other ecosystems.</p><p>Now let&apos;s take a look at some of the hot coins which Centralized Exchanges have listed this year. Surprisingly, Aptos is not the last and had comparable pre-launch attention.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/88f05672150ea5cde98b355de6da964ab520c1f205782a8acb45bc1a06dd3946.png" alt="Popularity of several cryptos launched this year" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Popularity of several cryptos launched this year</figcaption></figure><p>We can see that Aptos received the most attention when they first announced themselves to the world, and a sudden boost in attention again when they launched their incentivised testnet program.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ae3d1b3de06f0504394b8a7ee0fa26bd844d5b775b42f9ba22eb84f4d202d0cf.png" alt="Aptos popularity" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Aptos popularity</figcaption></figure><h2 id="h-twitter" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Twitter</h2><p>Let&apos;s take a look at various layer ones&apos; (L1) Twitter popularity. Twitter popularity often indicates general public interest in the blockchain. The key indicator over here would be the number of followers. Aptos is currently in the lead for chains that have yet to launch mainnet. And it does have the potential to grow into one of the largest L1s. <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/TheTIEIO/status/1551642881189896195">Using Apefluencer</a>, we can also see that Aptos is really popular within CT.</p><h3 id="h-chains-that-have-launched-mainnet" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Chains that have launched Mainnet</h3><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/fb6cc0cae26e9f069e0a7fa2f8263cd995c900b43bd33a1cb14ab234917e009d.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><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/09a281fdec40bcc84ba5b5cc03435e3615148eccccf5ea76dd9e63aa6f9d637d.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><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4af199d50d33549804d5ec13f060b89a191fd62f865c653528e0361414063d1e.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><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/dc5e09e2e5fb060fd22d388941e0692ba561625788e4112ffc5740818cb5bb00.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><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/8d2348ffa7061b1ca611c95c64870464bfd4eae57b1e798a751e102a54b82ed6.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><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/392b69f09f00e9ba2a291ef11540001fa648cddc861b55df81b9de576a1a9fe6.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><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/0029f927a4286c1401d4fe2fd8a3307c140b8b472ec026c726b1893566afba9b.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><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d91fed50248703f558d4d8a4e6ae0c5ca99c02cb226e8bcadaaed19d4d9a8874.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><h3 id="h-chains-that-have-yet-to-launch-mainnet" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Chains that have yet to launch Mainnet</h3><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/890c50521808b5eaa4414119811c5229eaa9084f72a7f8bc5831ceb1b81b36f8.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><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/a29d33e7ae56f1612f314b34b517ce55cc3edac4cd4ddf82422caa28a9fdc9a2.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><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1ec5c22ef1af78ca6f3746df20046c74bed61c5a252e34b863189f7290c12df6.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><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e25a9ee10274a2db9bf6740ced851e970734d754e2b17ead95226f5d6c66e828.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><h2 id="h-discord" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Discord</h2><p>Discord has always been a good indicator for developer &amp; degen activity on a blockchain. Aptos perform extremely well over here (more activity than Avalanche, Polygon, etc) and it is possible that Terra&apos;s crash has freed up a lot of Rust developers (Move is Rust based) into cryptospace.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d7deb05fae4db0c78ac6ddb262680d855c281cf59cb7318347a42ff75a20fa0d.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><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e159aa53ade2919ca66dda7b483e2429cf667488c23f3c84d972306e3ac5b315.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><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/b782285c00d64a06843aee1b5f66af3eeb34bdae18309b6b21caf796bf5b8304.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><h2 id="h-telegram" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Telegram</h2><p>Telegram best represents the amount of VCs and airdrop hunters which are detrimental to the price action of the cryptocurrency. However, Aptos has not announced any public rounds and seems to be fully funded by institutions. Tokenomics are still not known and it is hard to do an accurate measurement as of now.</p><h2 id="h-are-we-bullish" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Are we bullish?</h2><p>The initial interests surrounding Aptos seem to be positive; made by ex-Meta engineers, deep funding by <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://sg.finance.yahoo.com/news/aptos-raises-us-150-mln-035317158.html">reputable VCs</a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/TheTIEIO/status/1551642881189896195">sufficient interest in CT</a>, superior developer activity on discord. However, it is hard to say if it will last. But it&apos;s definitely worth investing in the Move Ecosystem. As mentioned, Move is based on Rust programming language, a widely used programming language for smart contracts. The skills will be portable to existing chains and relevant outside of crypto. There is no doubt Aptos will become the top 100 coins upon launch and supporting the infrastructure will prove valuable to companies such as ChainUp, which offer exchange software services.</p><h2 id="h-aptos-current-ecosystem" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Aptos current ecosystem</h2><p>Let&apos;s take a deep dive into the current <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.aptos.systems/">Aptos&apos;s Eocsystem</a> pre-launch.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d761bc0284ebc30b6a8098d5b2cdd2684fa4757e8dabe3394851ac39b62b5e17.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>We have Pontem Network which is a company building different kinds of applications on Aptos, including bridges, DEX-es, IDEs and more.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/3353f7ef9dbf052bcd370f5ed4d2d4d348e92eaaf496b37ce9b6eeb1d338d427.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>Plenty of candidates for wallet software and providing SDKs (image on the left). And lots of the Defi protocols (image on the right). It is rare to see developers building applications on top of a blockchain before launch (apart from EVM chains which are basically fork, rinse &amp; repeat), in a foreign runtime.</p><p>However, we do need to take note that despite seeing so many applications building on Aptos, many of these projects will struggle or fail to deliver. Expectations may not be met and unforeseen issues will happen. And ultimately, Aptos Ecosystem is still way smaller than mature ecosystems such as that of Ethereum.</p><h2 id="h-conclusion" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Conclusion</h2><p>The future of Move ecosystem is definitely bright &amp; exciting. While it is uncertain if Aptos will become a successful L1 blockchain, investing time &amp; resources on Move ecosystem can prove to be rewarding in the long run. It is advisable to participate in the current ecosystem (in Testnet) to familiarize oneself with Move and be equipped for the future of Web3.</p><h3 id="h-links" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Links</h3><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://aptoslabs.com/">https://aptoslabs.com/</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://aptoslabs.medium.com/">https://aptoslabs.medium.com/</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/AptosLabs">https://twitter.com/AptosLabs</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/aptos-labs">https://github.com/aptos-labs</a></p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://discord.gg/aptoslabs">http://discord.gg/aptoslabs</a></p><h3 id="h-disclaimer" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Disclaimer</h3><p>Do note that this article is written back in May. Circumstances may have change and no longer applicable today.</p>]]></content:encoded>
            <author>randomdude@newsletter.paragraph.com (RandomDude)</author>
        </item>
        <item>
            <title><![CDATA[MEV]]></title>
            <link>https://paragraph.com/@randomdude/mev</link>
            <guid>13aRrHeGF0orozvwGfV2</guid>
            <pubDate>Tue, 31 May 2022 08:20:12 GMT</pubDate>
            <description><![CDATA[IntroductionMiner extractable value (MEV) is a measure of the profit a miner can make through their ability to arbitrarily include, exclude, or re-order transactions within the blocks they produce. Ethereum is where most of the MEV action happens, while there are MEV to be earn by miners/validators on other types of blockchain, Ethereum is the father of Defi and has the most value to be extracted.FlashbotsFlashbots is a research and development organization working on mitigating the negative ...]]></description>
            <content:encoded><![CDATA[<h2 id="h-introduction" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Introduction</h2><p>Miner extractable value (MEV) is a measure of the profit a miner can make through their ability to arbitrarily include, exclude, or re-order transactions within the blocks they produce.</p><p>Ethereum is where most of the MEV action happens, while there are MEV to be earn by miners/validators on other types of blockchain, Ethereum is the father of Defi and has the most value to be extracted.</p><h2 id="h-flashbots" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Flashbots</h2><p>Flashbots is a research and development organization working on mitigating the negative externalities of current Maximal Extractable Value (from now on MEV) extraction techniques and avoiding the existential risks MEV could cause to state-rich blockchains like Ethereum.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/7a6d6f0458d72e68d26593184a9cd1653af00bf4337c31d4c39997f3e702b34c.png" alt="Simple technical architecture" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Simple technical architecture</figcaption></figure><p>And utilizing the network is easy, users just need to update their RPC endpoint to <code>rpc.flashbots.net</code></p><p>However, trivial transactions like approving and transferring cryptocurrency will not need flashbot network as there are practically no additional value to be extracted apart from the usual gas fees.</p><h2 id="h-real-utility-for-users" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Real utility for users</h2><p>The real utility &amp; power comes when users only need to pay when their transactions go through. And they do not even need to fund their transactions; they can pay directly from the profits they made from the transaction.</p><p>This involves requiring the transactions to have <code>block.coinbase.call</code> implemented so that users can pay directly from the contract. But not every contract out there on Ethereum will implement such a function, so how do users deal with contract calls that did not implement?</p><p>Luckily, there are public smart contracts out there designed to invoke any contract call and wrapping it with the payment function <code>block.coinbase.call</code> so that anyone can use it without worried about the contract implementation.</p><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://etherscan.io/address/0x0000feE6275DaB194Ab538A01dD8B18B02b20000#code">https://etherscan.io/address/0x0000feE6275DaB194Ab538A01dD8B18B02b20000#code</a></p><p>Since these contracts code are verified and open source, it will also imply that people can steal your alpha/strategy as people do stare at these contracts and analyze the transactions. Thus, professional searchers often deploy their own contracts to make it harder for people to observe and learn their strategy.</p><p>But what’s really awesome about all of this is that as long as you have a good strategy, you can make money out of thin air.</p><h2 id="h-miners" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Miners</h2><p>Miners extract these value from the transaction as users bid using Ether for their transactions to be included. This would mean that profits from obvious strategies like arbitraging will end up in the miner’s pocket and market makers (as the highest bidder wins). Users will need to come up with their own creative strategies to make money from transactions so that no one will outbid them.</p><p>Currently, Ethermine is also running their own flashbot relay, a different one from the public using this endpont <code>mev-relay.ethermine.org</code>.</p><p>However, Ethermine does some weird stuff and the winning bids does not necessary goes to the highest bidder. In the example shown below, we can see an arbitrage transaction is worth $4k and the user did not need to have their profits extracted by the miner at all! The user simply just paid the usual 1 Gwei gas fee as priority fees and easily made $4k.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/80f0109ac37f6911d685382c8cadb9ab150a8d75883e05c1d590f3f04d5cb720.png" alt="Black Magic?" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Black Magic?</figcaption></figure><p>The reason is simple, the block is mined by Ethermine itself and they own the account that made the profitable transaction. So while there are bidders who are willing to bid a higher price for the exact same transaction, Ethermine’s will prioritize their own one unless the bidder is willing to pay more than $4k.</p><p>And why can Ethermine afford to do these kind of stuff and get away with it? That is because they are the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://etherscan.io/topstat#Mining">largest miner on Ethereum</a> and mines about ~30% of the blocks. So they do get a say on how transactions should be ordered most of the time on Ethereum. This also allow Ethermine to pay the most competitive rate for people contributing to their mining network, solidifying their position as the number one miner.</p>]]></content:encoded>
            <author>randomdude@newsletter.paragraph.com (RandomDude)</author>
        </item>
        <item>
            <title><![CDATA[Terra's Big Meltdown]]></title>
            <link>https://paragraph.com/@randomdude/terra-s-big-meltdown</link>
            <guid>DVPCdV2UjfRwWH2faNbo</guid>
            <pubDate>Fri, 13 May 2022 06:46:10 GMT</pubDate>
            <description><![CDATA[The Terra’s ecosystem started to meltdown during the nights of 9th May 6pm UTC. UST begins to depeg from $1.00 USD to $0.90 USD during that hour. People quickly realize the opportunity and begin to perform arbitrage: Burn UST for Luna ($1 USD of Luna for 1 UST burned), sell Luna and buy more UST. However, arbitragers are more than happy to buy UST at a lower price to re-use the same liquidity for the next round of arbitraging. And this begins to spiral out of control as common investors decid...]]></description>
            <content:encoded><![CDATA[<p>The Terra’s ecosystem started to meltdown during the nights of 9th May 6pm UTC. UST begins to depeg from $1.00 USD to $0.90 USD during that hour. People quickly realize the opportunity and begin to perform arbitrage: Burn UST for Luna ($1 USD of Luna for 1 UST burned), sell Luna and buy more UST. However, arbitragers are more than happy to buy UST at a lower price to re-use the same liquidity for the next round of arbitraging.</p><p>And this begins to spiral out of control as common investors decide to also sell their UST at a lower price, fearing that UST will go to zero. As billions of Luna was sold, investors begin to fear even more as the demand of Luna is essentially what backs UST. And with the price action of Luna, it seems like there is suddenly no more demand for Luna.</p><p>The UST depegging event continued on and dipped all the way to $0.60 on that day.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d79531a5fecb20a46b28f262bfd7dcc2390b92081db949a6a7a32ad8de7d3ebb.png" alt="Binance UST/BUSD charts" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Binance UST/BUSD charts</figcaption></figure><p>However, that was not the end. @stablekwon, @LFG_org and other larger Terra players did not make any formal announcements on the measures to fix the depeg after the relief bounce and remained silent.</p><p>The fear quickly got to the investors again as they proceed to sell their UST at a loss when they see the price of Luna dropping.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/f993bb418af18f65ad2eab8915a81637af78e08bd869ff512121cfac699d515d.png" alt="Binance UST/BUSD charts" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Binance UST/BUSD charts</figcaption></figure><p>People were hoping for a solution from the Terra team. And when the announcement came, it was not what they <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/stablekwon/status/1524331171189956609">expected</a>:</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/a01ead4e7d03f08ff697c77e981fda48dad1947f03595d9c63b8db76d0899e7b.png" alt="Let it bleed! 🩸" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Let it bleed! 🩸</figcaption></figure><p>There was an immediate relief bounce after breaking the silence, but the resolution was to continue printing Luna to save UST. This solution was clearly not feasible anymore, all it took was 1 day for the mass public to join the Luna shorting fest as arbitragers toss Luna onto exchanges. Thus UST also began to decline.</p><p>On May 11th, centralized exchanges had to severely reduce their leverage on futures and margin trading pairs. But it wasn’t enough. Luna’s price continue to decline, and reached a dollar. And that wasn’t the end, Luna’s price continue to decline on May 12th to less than $0.000001 on many centralized exchanges by the end of the day. Binance had to delist all their Luna and UST trading pairs (including margin &amp; futures), leaving only LUNA/BUSD and LUNA/UST to prevent people from shorting further.</p><p>Throughout the entire event, UST continues to decline and reached an all time low of $0.03. The Terra blockchain also had to halt due to the transaction volume on the chain involving the minting of Terra.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/4aa9c62ed973b16fd5e17f4d20e3a5bad50cbdcb5371b8c5090e0404881d445a.png" alt="UST declines" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">UST declines</figcaption></figure><p>Terra then made an <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://twitter.com/terra_money/status/1524935730308456448">announcement</a> on May 13th to officially halt the chain permanently until a resolution despite a blockchain restart earlier.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/32bcefec48c717f7df172b8921cdc632f3f15c22c1ab13465af8e5f48d49b9fd.png" alt="Halting of the chain" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Halting of the chain</figcaption></figure><p>At this point, Luna cryptocurrency has officially become a meme coin where people were simply buying for the fun &amp; volatility, just like Doge &amp; Shiba.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/f3b48deb162569cf5bff34d3c2db18a4daf150d997df7341213f74db3570177e.png" alt="Degenerates trading" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Degenerates trading</figcaption></figure><p>Terra’s great meltdown has taught us a lot of things. Apart from doing your own research, always prepare for a black swan event and hedge your investments, be it crypto or traditional stocks.</p>]]></content:encoded>
            <author>randomdude@newsletter.paragraph.com (RandomDude)</author>
        </item>
        <item>
            <title><![CDATA[Lending Protocols]]></title>
            <link>https://paragraph.com/@randomdude/lending-protocols</link>
            <guid>qrqtOUrGe4RFS7rRwQnE</guid>
            <pubDate>Wed, 20 Apr 2022 09:15:22 GMT</pubDate>
            <description><![CDATA[Lending protocols aims to offer crypto loans in a trustless manner. There are several types of lending primitives with a variety of secondary protocols built on-top of it.Lending primitivesNon-custodial liquidity marketsLoanHow the protocol works is very simple. Depositor deposit crypto into the protocol to earn interests. Borrowers can borrow funds from the protocol and pay an interest when returning the loans. The liquidity of the borrowed funds will stem from the liquidity provided by the ...]]></description>
            <content:encoded><![CDATA[<p>Lending protocols aims to offer crypto loans in a trustless manner. There are several types of lending primitives with a variety of secondary protocols built on-top of it.</p><h2 id="h-lending-primitives" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Lending primitives</h2><h3 id="h-non-custodial-liquidity-markets" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Non-custodial liquidity markets</h3><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e9475d973af66dce6e78e7fea87a68dd7c7920007ff7acd4017fa3b71873e9a7.png" alt="Loan" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Loan</figcaption></figure><p>How the protocol works is very simple. Depositor deposit crypto into the protocol to earn interests. Borrowers can borrow funds from the protocol and pay an interest when returning the loans. The liquidity of the borrowed funds will stem from the liquidity provided by the depositors.</p><p>In order to ensure that the loans will be returned, borrowers typically need to put down a collateral that is of equal value as the loans. And if the loans are not repaid, the borrower’s collateral assets will be liquidated to cover the loss. These loans are therefore not the undercollateralized loans we typically see at traditional banks and are typically used for leveraging and opening short positions.</p><p>Nonetheless, from the depositor’s point of view, it still works the same way: deposit currency and earn interests. The interests will be determined by the utilization ratio, which is how much and how long the underlying asset is borrowed. This makes sense as the interests depositors earn comes from borrowers repaying their loans, and if the borrowers borrow more and for a longer period of time, the depositors should naturally earn more.</p><h3 id="h-flash-loan" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Flash loan</h3><p>Flash loan is a powerful tool &amp; interesting concept which does not exist in traditional finance. Borrowers do not need to deposit any form of collateral at all and it is a type of undercollateralized loans. Flash loans does sounds to good to be true, and hence there is a caveat. And that is flash loans needs to be return within one transaction block, else the loan never happened.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d0f0f3820e39535371f536b9526b68532bf4a1698e39959431c5c177e42a2474.png" alt="Loan repaid within the same transaction" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Loan repaid within the same transaction</figcaption></figure><p>In blockchains, transactions are bundled into a block and validated. Transactions that are not validated into blocks are simply pending transaction that has yet to happen. Therefore, from the protocol’s point of view, a flash loan is simply a special kind of loan where it is immediately return after borrowed. And in the event that the loan is not repaid, the earlier transaction that borrows the loan simply fails and does not get included in the block, which means the loan never took place!</p><p>However, flash loans does seem to have very little utility if it has to be repaid in a single transaction. Typical usage of flash loans is limited to moving liquidity such as arbitraging, collateral conversion, farm changing, etc. And in the case of profit opportunities, it will be even more limited as we are unlikely to see much price movement in a block duration. This is also the reason why flash loans are more popular on older blockchains that have longer block durations and deeper liquidity such as Ethereum.</p><h3 id="h-algorithmic-stablecoin-protocol" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Algorithmic Stablecoin Protocol</h3><p>Stablecoin protocol is another important aspect to lending primitives. Similar to lending protocols, depositors deposit collateral into the protocol, and in exchange they get to mint stablecoins based on the amount of their deposits. In the event the amount of collateral falls below the circulating value of stablecoin, the protocols has to buy back &amp; burn the stablecoins it has minted.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/f873fbe10fc623ba8d35c34102dd66371560a2593b7cd0dbcae94bf7f22da348.png" alt="Primitive stablecoin protocol like Anchor" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Primitive stablecoin protocol like Anchor</figcaption></figure><p>In the older models, stablecoins rely on arbitragers to maintain the stablecoin peg. Such examples are Terra, Acala, Maker where the peg hovers around $1 depending on the arbitragers. There are also variations such as Frax Finance and Ampleforth which takes on mixed approaches such as relying on other existing stablecoins and rebasing techniques.</p><p>This also led to invention of reserved currencies where the price of the asset is free floating despite the collateral backing underneath. The history, evolution &amp; drama of reserved currencies is noted to be the most exciting events in the world of crypto and we will discuss it in detail in another article.</p><h3 id="h-p2p-loans" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">P2P loans</h3><p>P2P loans protocol is essentially an inefficient application of non-custodial liquidity markets where the liquidity cannot be shared across borrowers and lenders. This can be beneficial when the assets is under-utilize where it would be more capital efficient for lenders to source higher interests. Although it would require effort to search for borrowers, lenders do not need to share their profits in the pooled liquidity.</p><p>With the rise of NFTs, P2P loans are becoming more popular as NFTs by itself is an illiquid asset. P2P loans allow NFT holders to hedge against their NFTs and bring liquidity to their assets.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/daaae38b1d6a8d0751022a19f249a575b809ffe22effa761f235575e1d1b063c.png" alt="P2P loans on NFTfi" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">P2P loans on NFTfi</figcaption></figure><p>NFTs are still in an infant phase at this stage and liquidity is still very fragmented. Hence, we would not be able to see well-defined APR at this point of time compared to mature lending markets.</p><h2 id="h-derivatives" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Derivatives</h2><p>With the existence of liquidation mechanism in lending primitives, it brings about the Cambrian explosion of financial derivatives. Margin trading, options, perpetuals, leveraged tokens all rely on the liquidation mechanism to achieve leverage, liquidation, funding and settlements.</p><p>Take for example auto-settlement of on-chain crypto options. During a call option expiry, the price of the underlying cryptocurrency will be compared against the strike price. If the strike price is lower than the price of the underlying asset, the option can be exercised automatically. A loan is first borrowed to exercised the option, upon receiving the underlying asset, the underlying asset is then sold and used to repay the loan. Any remaining excess will then be kept as profits for the option buyer.</p><p>There are of course also protocols that directly utilize the entire lending protocols to achieve leverage farming and all sorts of automated trading strategies.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d1d850ef7ba3483ce7b51f0c901b11aa5116f02c8a9e08ca1062b6bfe6c8156b.png" alt="Leveraged lending" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Leveraged lending</figcaption></figure><p>For example, with leveraged lending we can achieve pretty high APR of over 100% on initial launch of the protocol in a new chain. While it is not sustainable in the long run, it is still pretty generous compared to existing lending protocols on mainstream Defi on Ethereum.</p><p>And with Defi &amp; NFT space booming, we are bound to see more interesting derivatives becoming mainstream and the eventual phasing out of simple primitives.</p>]]></content:encoded>
            <author>randomdude@newsletter.paragraph.com (RandomDude)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/d55aed23095b9485c46f8b7bc33046bb64f4bd6ebc5ac3f38c0ca5b1d511ddef.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Terra smart contracts (cosmwasm)]]></title>
            <link>https://paragraph.com/@randomdude/terra-smart-contracts-cosmwasm</link>
            <guid>uIqf9zmn0jBFFJmU9Mkq</guid>
            <pubDate>Tue, 12 Apr 2022 09:37:17 GMT</pubDate>
            <description><![CDATA[Terra smart contracts are based on cosmwasm. However, Terra is not exactly up to date and compatible with the latest cosmwasm smart contracts and may not be able to compile and run on Terra&apos;s virtual machine.Design of cosmwasm smart contractsThe architecture of cosmwasm smart contracts is very different from Solidity. Solidity is extremely easy to use and we can treat it without any considerations of blockchain architecture. To put it simply, the style of Solidity is OOP-style. We can ad...]]></description>
            <content:encoded><![CDATA[<p>Terra smart contracts are based on <code>cosmwasm</code>. However, Terra is not exactly up to date and compatible with the latest <code>cosmwasm</code> smart contracts and may not be able to compile and run on Terra&apos;s virtual machine.</p><h2 id="h-design-of-cosmwasm-smart-contracts" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Design of cosmwasm smart contracts</h2><p>The architecture of <code>cosmwasm</code> smart contracts is very different from Solidity. Solidity is extremely easy to use and we can treat it without any considerations of blockchain architecture. To put it simply, the style of Solidity is OOP-style. We can adopt the same mindset of coding any object oriented language and treat smart contracts as classes/objects.</p><blockquote><p>While there are indeed more advanced ways to structure your Solidity smart contracts, we will not discuss it as normal people don&apos;t do that anyways.</p></blockquote><pre data-type="codeBlock" text="pragma solidity ^0.6.0;

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function allowance(address owner, address spender) external view returns (uint256);

    function transfer(address recipient, uint256 amount) external returns (bool);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);


    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}
"><code><span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.6.0;</span>

<span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">IERC20</span> </span>{
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">totalSupply</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title"><span class="hljs-keyword">view</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint256</span></span>)</span>;
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">balanceOf</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> account</span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title"><span class="hljs-keyword">view</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint256</span></span>)</span>;
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">allowance</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> owner, <span class="hljs-keyword">address</span> spender</span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title"><span class="hljs-keyword">view</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint256</span></span>)</span>;

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">transfer</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> recipient, <span class="hljs-keyword">uint256</span> amount</span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">bool</span></span>)</span>;
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">approve</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> spender, <span class="hljs-keyword">uint256</span> amount</span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">bool</span></span>)</span>;
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">transferFrom</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> sender, <span class="hljs-keyword">address</span> recipient, <span class="hljs-keyword">uint256</span> amount</span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">bool</span></span>)</span>;


    <span class="hljs-function"><span class="hljs-keyword">event</span> <span class="hljs-title">Transfer</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> <span class="hljs-keyword">indexed</span> <span class="hljs-keyword">from</span>, <span class="hljs-keyword">address</span> <span class="hljs-keyword">indexed</span> to, <span class="hljs-keyword">uint256</span> value</span>)</span>;
    <span class="hljs-function"><span class="hljs-keyword">event</span> <span class="hljs-title">Approval</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> <span class="hljs-keyword">indexed</span> owner, <span class="hljs-keyword">address</span> <span class="hljs-keyword">indexed</span> spender, <span class="hljs-keyword">uint256</span> value</span>)</span>;
}
</code></pre><p><code>cosmwasm</code> is not. <code>cosmwasm</code> contract is split into 4 portions:</p><ol><li><p>State (variables that you want to persist are defined here)</p></li><li><p>Query (query the state (variables) of the smart contract)</p></li><li><p>Execute (modify the state (variables) of the smart contract)</p></li><li><p>Instantiate (to initialized the smart contract) This leads to some inconvenience while coding, but also more flexibility &amp; upgradeability of the smart contract. For example, developers need to manually call &amp; access the state, unlike in Solidity where we can access it like an object.</p></li></ol><pre data-type="codeBlock" text="pragma solidity ^0.6.0;

contract Example {
    uint256 amount;
    
    function getAmount() returns (uint256) {
        return amount;
    }
    ...
}
"><code><span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> ^0.6.0;</span>

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Example</span> </span>{
    <span class="hljs-keyword">uint256</span> amount;
    
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getAmount</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">uint256</span></span>) </span>{
        <span class="hljs-keyword">return</span> amount;
    }
    ...
}
</code></pre><p>Solidity code</p><pre data-type="codeBlock" text="// Declare amount in state.rs
pub const AMOUNT: Item&lt;i32&gt; = Item::new(&quot;amount&quot;);

// Reading amount in query.rs
use crate::state::{AMOUNT}

pub fn get_amount(deps: DepsMut) --&gt; StdResult&lt;i32&gt; {
    CONFIG.load(deps.storage)?
}

// Declare wrapper for query&apos;s logic in contract.rs
// Recall contract is split into state, execute, query, instantiate
use ...

pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -&gt; StdResult&lt;Binary&gt; {
    match msg {
        QueryMsg::GetAmount {} =&gt; to_binary(&amp;get_amount(deps)?),
    }
}

// Declare message header in msg.rs
use ...

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = &quot;snake_case&quot;)]
pub enum QueryMsg {
    // GetCount returns the current count as a json-encoded number
    GetAmount {},
}
"><code><span class="hljs-comment">// Declare amount in state.rs</span>
pub const AMOUNT: Item<span class="hljs-operator">&#x3C;</span>i32<span class="hljs-operator">></span> <span class="hljs-operator">=</span> Item::<span class="hljs-keyword">new</span>(<span class="hljs-string">"amount"</span>);

<span class="hljs-comment">// Reading amount in query.rs</span>
use crate::state::{AMOUNT}

pub fn get_amount(deps: DepsMut) <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">></span> StdResult<span class="hljs-operator">&#x3C;</span>i32<span class="hljs-operator">></span> {
    CONFIG.load(deps.storage)?
}

<span class="hljs-comment">// Declare wrapper for query's logic in contract.rs</span>
<span class="hljs-comment">// Recall contract is split into state, execute, query, instantiate</span>
use ...

pub fn query(deps: Deps, _env: Env, <span class="hljs-built_in">msg</span>: QueryMsg) <span class="hljs-operator">-</span><span class="hljs-operator">></span> StdResult<span class="hljs-operator">&#x3C;</span>Binary<span class="hljs-operator">></span> {
    match <span class="hljs-built_in">msg</span> {
        QueryMsg::GetAmount {} <span class="hljs-operator">=</span><span class="hljs-operator">></span> to_binary(<span class="hljs-operator">&#x26;</span>get_amount(deps)?),
    }
}

<span class="hljs-comment">// Declare message header in msg.rs</span>
use ...

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all <span class="hljs-operator">=</span> <span class="hljs-string">"snake_case"</span>)]
pub <span class="hljs-keyword">enum</span> <span class="hljs-title">QueryMsg</span> {
    <span class="hljs-comment">// GetCount returns the current count as a json-encoded number</span>
    GetAmount {},
}
</code></pre><p>Rust Code (cosmwasm)</p><p>As you can see, in <code>cosmwasm</code>, there is a lot of organization and declaration that the developer needs to handle. In Solidity, this is all done automatically for the developer when they compile their code. However, it is worth noting that Solidity is specially designed and developed over a long time, allowing developers to enjoy the ease of coding today. Builders will continue building for <code>cosmwasm</code> and it is possible that these complexities can be abstracted one day.</p><h2 id="h-details" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Details</h2><p>Terra&apos;s smart contract is split into several portions usually:</p><ul><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://contract.rs">contract.rs</a> Entry point of the code</p><ul><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://execute.rs">execute.rs</a> Contract interaction that modifies the state (Cost gas fees)</p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://query.rs">query.rs</a> Contract interaction that reads the state (Does not cost gas fees)</p></li></ul></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://error.rs">error.rs</a> Define your error codes</p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://lib.rs">lib.rs</a> Linking your rust files</p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://test.rs">test.rs</a> QA&apos;s job</p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://state.rs">state.rs</a> Define your state, data you want to store in smart contracts</p></li><li><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="http://msg.rs">msg.rs</a> Define your method signature for contract interactions (execute, query, instantiate)</p></li></ul><h3 id="h-top-level" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Top level</h3><pre data-type="codeBlock" text="use ...

#[cfg_attr(not(feature = &quot;library&quot;), entry_point)]
pub fn instantiate(
    deps: DepsMut,
    _env: Env,
    info: MessageInfo,
    msg: InstantiateMsg,
) -&gt; Result&lt;Response, ContractError&gt; {
    let state = State {
        count: msg.count,
        owner: info.sender.clone(),
    };
    set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
    STATE.save(deps.storage, &amp;state)?;

    Ok(Response::new()
        .add_attribute(&quot;method&quot;, &quot;instantiate&quot;)
        .add_attribute(&quot;owner&quot;, info.sender)
        .add_attribute(&quot;count&quot;, msg.count.to_string()))
}

#[cfg_attr(not(feature = &quot;library&quot;), entry_point)]
pub fn execute(
    deps: DepsMut,
    _env: Env,
    info: MessageInfo,
    msg: ExecuteMsg,
) -&gt; Result&lt;Response, ContractError&gt; {
    match msg {
        ExecuteMsg::Increment {} =&gt; try_increment(deps),
        ExecuteMsg::Reset { count } =&gt; try_reset(deps, info, count),
    }
}

#[cfg_attr(not(feature = &quot;library&quot;), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -&gt; StdResult&lt;Binary&gt; {
    match msg {
        QueryMsg::GetCount {} =&gt; to_binary(&amp;query_count(deps)?),
    }
}
"><code>use ...

#[cfg_attr(not(feature <span class="hljs-operator">=</span> <span class="hljs-string">"library"</span>), entry_point)]
pub fn instantiate(
    deps: DepsMut,
    _env: Env,
    info: MessageInfo,
    <span class="hljs-built_in">msg</span>: InstantiateMsg,
) <span class="hljs-operator">-</span><span class="hljs-operator">></span> Result<span class="hljs-operator">&#x3C;</span>Response, ContractError<span class="hljs-operator">></span> {
    let state <span class="hljs-operator">=</span> State {
        count: <span class="hljs-built_in">msg</span>.count,
        owner: info.sender.clone(),
    };
    set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
    STATE.save(deps.storage, <span class="hljs-operator">&#x26;</span>state)?;

    Ok(Response::<span class="hljs-keyword">new</span>()
        .add_attribute(<span class="hljs-string">"method"</span>, <span class="hljs-string">"instantiate"</span>)
        .add_attribute(<span class="hljs-string">"owner"</span>, info.sender)
        .add_attribute(<span class="hljs-string">"count"</span>, <span class="hljs-built_in">msg</span>.count.to_string()))
}

#[cfg_attr(not(feature <span class="hljs-operator">=</span> <span class="hljs-string">"library"</span>), entry_point)]
pub fn execute(
    deps: DepsMut,
    _env: Env,
    info: MessageInfo,
    <span class="hljs-built_in">msg</span>: ExecuteMsg,
) <span class="hljs-operator">-</span><span class="hljs-operator">></span> Result<span class="hljs-operator">&#x3C;</span>Response, ContractError<span class="hljs-operator">></span> {
    match <span class="hljs-built_in">msg</span> {
        ExecuteMsg::Increment {} <span class="hljs-operator">=</span><span class="hljs-operator">></span> try_increment(deps),
        ExecuteMsg::Reset { count } <span class="hljs-operator">=</span><span class="hljs-operator">></span> try_reset(deps, info, count),
    }
}

#[cfg_attr(not(feature <span class="hljs-operator">=</span> <span class="hljs-string">"library"</span>), entry_point)]
pub fn query(deps: Deps, _env: Env, <span class="hljs-built_in">msg</span>: QueryMsg) <span class="hljs-operator">-</span><span class="hljs-operator">></span> StdResult<span class="hljs-operator">&#x3C;</span>Binary<span class="hljs-operator">></span> {
    match <span class="hljs-built_in">msg</span> {
        QueryMsg::GetCount {} <span class="hljs-operator">=</span><span class="hljs-operator">></span> to_binary(<span class="hljs-operator">&#x26;</span>query_count(deps)?),
    }
}
</code></pre><p><code>contract.rs</code></p><p>In <code>contract.rs</code> we can see what functions we can call on the smart contract. In this example, we can perform <code>get_count</code>, <code>increment</code>, <code>reset</code> on the smart contract. And of course instantiate the smart contract.</p><pre data-type="codeBlock" text="use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
    pub count: i32,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = &quot;snake_case&quot;)]
pub enum ExecuteMsg {
    Increment {},
    Reset { count: i32 },
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = &quot;snake_case&quot;)]
pub enum QueryMsg {
    // GetCount returns the current count as a json-encoded number
    GetCount {},
}

// We define a custom struct for each query response
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct CountResponse {
    pub count: i32,
}
"><code><span class="hljs-keyword">use</span> schemars::JsonSchema;
<span class="hljs-keyword">use</span> serde::{Deserialize, Serialize};

<span class="hljs-meta">#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]</span>
<span class="hljs-keyword">pub</span> <span class="hljs-keyword">struct</span> <span class="hljs-title class_">InstantiateMsg</span> {
    <span class="hljs-keyword">pub</span> count: <span class="hljs-type">i32</span>,
}

<span class="hljs-meta">#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]</span>
<span class="hljs-meta">#[serde(rename_all = <span class="hljs-string">"snake_case"</span>)]</span>
<span class="hljs-keyword">pub</span> <span class="hljs-keyword">enum</span> <span class="hljs-title class_">ExecuteMsg</span> {
    Increment {},
    Reset { count: <span class="hljs-type">i32</span> },
}

<span class="hljs-meta">#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]</span>
<span class="hljs-meta">#[serde(rename_all = <span class="hljs-string">"snake_case"</span>)]</span>
<span class="hljs-keyword">pub</span> <span class="hljs-keyword">enum</span> <span class="hljs-title class_">QueryMsg</span> {
    <span class="hljs-comment">// GetCount returns the current count as a json-encoded number</span>
    GetCount {},
}

<span class="hljs-comment">// We define a custom struct for each query response</span>
<span class="hljs-meta">#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]</span>
<span class="hljs-keyword">pub</span> <span class="hljs-keyword">struct</span> <span class="hljs-title class_">CountResponse</span> {
    <span class="hljs-keyword">pub</span> count: <span class="hljs-type">i32</span>,
}
</code></pre><p><code>msg.rs</code></p><p>In <code>msg.rs</code> we declare the method signature of the smart contracts, which we will also be using to generate the schema to interact with the smart contract. So, for example, we want to call the <code>reset</code> function in the smart contract, we do something like the following when broadcasting the txn:</p><pre data-type="codeBlock" text="{
    &quot;execute_msg&quot;: {
        &quot;reset&quot;: {
            &quot;count&quot;: 0
        }
    }
}
"><code><span class="hljs-punctuation">{</span>
    <span class="hljs-attr">"execute_msg"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
        <span class="hljs-attr">"reset"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span>
            <span class="hljs-attr">"count"</span><span class="hljs-punctuation">:</span> <span class="hljs-number">0</span>
        <span class="hljs-punctuation">}</span>
    <span class="hljs-punctuation">}</span>
<span class="hljs-punctuation">}</span>
</code></pre><p>But in reality, when dealing with <code>sdk</code> or executing the txn from browser, we do not need to specify whether a transaction belongs to instantiation, execution or query as there are specific APIs in place for all different scenarios.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/a2a4c47af449602501b8f17c6ce9f605fb4b6a0e94e825745d3a928f1331466d.png" alt="Execute on Terra Station" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Execute on Terra Station</figcaption></figure><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/7b037b15b23b987dbc76c9ecf47a355a072fcadf70de9a5f57d9c1660d0ca57f.png" alt="Instantiate on Terra Station" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Instantiate on Terra Station</figcaption></figure><h3 id="h-core" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Core</h3><pre data-type="codeBlock" text="use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use cosmwasm_std::Addr;
use cw_storage_plus::Item;

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct State {
    pub count: i32,
    pub owner: Addr,
}

pub const STATE: Item&lt;State&gt; = Item::new(&quot;state&quot;);
"><code><span class="hljs-keyword">use</span> schemars::JsonSchema;
<span class="hljs-keyword">use</span> serde::{Deserialize, Serialize};

<span class="hljs-keyword">use</span> cosmwasm_std::Addr;
<span class="hljs-keyword">use</span> cw_storage_plus::Item;

<span class="hljs-meta">#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]</span>
<span class="hljs-keyword">pub</span> <span class="hljs-keyword">struct</span> <span class="hljs-title class_">State</span> {
    <span class="hljs-keyword">pub</span> count: <span class="hljs-type">i32</span>,
    <span class="hljs-keyword">pub</span> owner: Addr,
}

<span class="hljs-keyword">pub</span> <span class="hljs-keyword">const</span> STATE: Item&#x3C;State> = Item::<span class="hljs-title function_ invoke__">new</span>(<span class="hljs-string">"state"</span>);
</code></pre><p><code>state.rs</code></p><p>This is where you declare all the variables you want to have in the smart contracts. It will be used to store information that you want to persist in smart contracts. In the above example, we want to keep track of a variable called <code>State</code> with members count and owner which is of <code>integer</code> and <code>address</code> type respectively.</p><pre data-type="codeBlock" text="pub fn try_increment(deps: DepsMut) -&gt; Result&lt;Response, ContractError&gt; {
    STATE.update(deps.storage, |mut state| -&gt; Result&lt;_, ContractError&gt; {
        state.count += 1;
        Ok(state)
    })?;

    Ok(Response::new().add_attribute(&quot;method&quot;, &quot;try_increment&quot;))
}

pub fn try_reset(deps: DepsMut, info: MessageInfo, count: i32) -&gt; Result&lt;Response, ContractError&gt; {
    STATE.update(deps.storage, |mut state| -&gt; Result&lt;_, ContractError&gt; {
        if info.sender != state.owner {
            return Err(ContractError::Unauthorized {});
        }
        state.count = count;
        Ok(state)
    })?;
    Ok(Response::new().add_attribute(&quot;method&quot;, &quot;reset&quot;))
}
"><code>pub fn try_increment(deps: DepsMut) <span class="hljs-operator">-</span><span class="hljs-operator">></span> Result<span class="hljs-operator">&#x3C;</span>Response, ContractError<span class="hljs-operator">></span> {
    STATE.update(deps.storage, <span class="hljs-operator">|</span>mut state<span class="hljs-operator">|</span> <span class="hljs-operator">-</span><span class="hljs-operator">></span> Result<span class="hljs-operator">&#x3C;</span><span class="hljs-keyword">_</span>, ContractError<span class="hljs-operator">></span> {
        state.count <span class="hljs-operator">+</span><span class="hljs-operator">=</span> <span class="hljs-number">1</span>;
        Ok(state)
    })?;

    Ok(Response::<span class="hljs-keyword">new</span>().add_attribute(<span class="hljs-string">"method"</span>, <span class="hljs-string">"try_increment"</span>))
}

pub fn try_reset(deps: DepsMut, info: MessageInfo, count: i32) <span class="hljs-operator">-</span><span class="hljs-operator">></span> Result<span class="hljs-operator">&#x3C;</span>Response, ContractError<span class="hljs-operator">></span> {
    STATE.update(deps.storage, <span class="hljs-operator">|</span>mut state<span class="hljs-operator">|</span> <span class="hljs-operator">-</span><span class="hljs-operator">></span> Result<span class="hljs-operator">&#x3C;</span><span class="hljs-keyword">_</span>, ContractError<span class="hljs-operator">></span> {
        <span class="hljs-keyword">if</span> info.sender <span class="hljs-operator">!</span><span class="hljs-operator">=</span> state.owner {
            <span class="hljs-keyword">return</span> Err(ContractError::Unauthorized {});
        }
        state.count <span class="hljs-operator">=</span> count;
        Ok(state)
    })?;
    Ok(Response::<span class="hljs-keyword">new</span>().add_attribute(<span class="hljs-string">"method"</span>, <span class="hljs-string">"reset"</span>))
}
</code></pre><p><code>execute.rs</code></p><p>In <code>execute.rs</code> is where we finally get into coding the logic out! And this is just your typical rust coding with the exception of retrieving and persisting the state through using the <code>deps</code> variable.</p><pre data-type="codeBlock" text="fn query_count(deps: Deps) -&gt; StdResult&lt;CountResponse&gt; {
    let state = STATE.load(deps.storage)?;
    Ok(CountResponse { count: state.count })
}
"><code>fn query_count(deps: Deps) <span class="hljs-operator">-</span><span class="hljs-operator">></span> StdResult<span class="hljs-operator">&#x3C;</span>CountResponse<span class="hljs-operator">></span> {
    let state <span class="hljs-operator">=</span> STATE.load(deps.storage)?;
    Ok(CountResponse { count: state.count })
}
</code></pre><p><code>query.rs</code></p><p><code>query.rs</code> is where we perform queries on various states about the smart contract. This is usually just <code>getter</code> functions unless we want something more complicated.</p><h3 id="h-fluff" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Fluff</h3><pre data-type="codeBlock" text="use cosmwasm_std::StdError;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ContractError {
    #[error(&quot;{0}&quot;)]
    Std(#[from] StdError),

    #[error(&quot;Unauthorized&quot;)]
    Unauthorized {},
    // Add any other custom errors you like here.
    // Look at https://docs.rs/thiserror/1.0.21/thiserror/ for details.
}
"><code><span class="hljs-keyword">use</span> cosmwasm_std::StdError;
<span class="hljs-keyword">use</span> thiserror::Error;

<span class="hljs-meta">#[derive(Error, Debug)]</span>
<span class="hljs-keyword">pub</span> <span class="hljs-keyword">enum</span> <span class="hljs-title class_">ContractError</span> {
    <span class="hljs-meta">#[error(<span class="hljs-string">"{0}"</span>)]</span>
    <span class="hljs-title function_ invoke__">Std</span>(<span class="hljs-meta">#[from]</span> StdError),

    <span class="hljs-meta">#[error(<span class="hljs-string">"Unauthorized"</span>)]</span>
    Unauthorized {},
    <span class="hljs-comment">// Add any other custom errors you like here.</span>
    <span class="hljs-comment">// Look at https://docs.rs/thiserror/1.0.21/thiserror/ for details.</span>
}
</code></pre><p><code>error.rs</code></p><pre data-type="codeBlock" text="pub mod contract;
mod error;
pub mod msg;
pub mod state;

pub use crate::error::ContractError;
"><code><span class="hljs-keyword">pub</span> <span class="hljs-keyword">mod</span> contract;
<span class="hljs-keyword">mod</span> error;
<span class="hljs-keyword">pub</span> <span class="hljs-keyword">mod</span> msg;
<span class="hljs-keyword">pub</span> <span class="hljs-keyword">mod</span> state;

<span class="hljs-keyword">pub</span> <span class="hljs-keyword">use</span> crate::error::ContractError;
</code></pre><p><code>lib.rs</code></p><p>These are just fluff stuff we need to put. I don&apos;t think we need to talk much about this.</p>]]></content:encoded>
            <author>randomdude@newsletter.paragraph.com (RandomDude)</author>
        </item>
        <item>
            <title><![CDATA[Brief History of Defi Trading]]></title>
            <link>https://paragraph.com/@randomdude/brief-history-of-defi-trading</link>
            <guid>y1JBgHfwTlh9HsD71HsW</guid>
            <pubDate>Wed, 06 Apr 2022 03:43:24 GMT</pubDate>
            <description><![CDATA[Automated market makerAutomated market makers (AMM) are decentralized exchanges that pool liquidity from users and price the assets within the pool using algorithms. Initially, it begins with X * Y = K formula where K is a constant, X and Y are the 2 respective assets. When someone wants to trade Qx amount of token X for token Y, he/she will receive Qy tokens such that the following equation is satisfied: (X + Qx) * (Y - Qy) = K = X * Y. The paper can be found here. However, AMM has evolved d...]]></description>
            <content:encoded><![CDATA[<h2 id="h-automated-market-maker" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Automated market maker</h2><p>Automated market makers (AMM) are decentralized exchanges that pool liquidity from users and price the assets within the pool using algorithms. Initially, it begins with <strong>X * Y = K</strong> formula where <strong>K</strong> is a constant, <strong>X</strong> and <strong>Y</strong> are the 2 respective assets. When someone wants to trade <strong>Qx</strong> amount of token <strong>X</strong> for token <strong>Y</strong>, he/she will receive <strong>Qy</strong> tokens such that the following equation is satisfied: <strong>(X + Qx) * (Y - Qy) = K = X * Y</strong>.</p><p>The paper can be found <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://github.com/runtimeverification/verified-smart-contracts/blob/uniswap/uniswap/x-y-k.pdf">here</a>.</p><p>However, AMM has evolved drastically over time. Basically, AMMs today are partitioned into smaller pools so that they can maximize trading fees and minimize potential losses. And there are a variety of strategies employed to design these AMMs such as Uniswap V3, Balancer, Curve.</p><p>Then came decentralized orderbooks which employ traditional strategies as today&apos;s market makers. The liquidity required for the orderbook can also be provided by AMMs such as the Serum orderbook on Solana. This is much more difficult to design as a smart contract compared to traditional AMMs due to limitation of blocktime and gas fees, especially on older blockchains like Ethereum, Polygon, Binance chain etc.</p><h2 id="h-trading-in-modern-defi" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Trading in Modern Defi</h2><p>Today, traders no longer use Decentralized Exchanges as it is. Users of Defi today use aggregators to perform their trades on-chain. For example, on Ethereum, users use Cowswap to perform their trades. Cowswap is an adoption of Gnosis Protocol v2 which offers trading with MEV protection on top of aggregation across both AMMs and traders.</p><p>This is achieved through the following:</p><ol><li><p>Transactions are first submitted and auction separately from the Ethereum chain.</p></li><li><p>If there are matching orders amongst the transactions, they can be matched directly. Remaining liquidity can be bundled and then trade against all the existing AMMs to ensure the best price possible.</p></li></ol><p>This prevents a myriad of issues. Sandwiching attack is not possible on these trades as transactions are not visible in the mempool and submitted in a bundle by the solvers. Gas fees can also be amortized across the trades and users need not pay transaction fees if the transaction does not go through (transactions are submitted to solvers as opposed to Ethereum nodes). How each individual AMMs/Orderbook works will not matter as it will simply pick the best price for the traders. And this does leads to an interesting result, AMMs/Orderbook liquidity optimization no longer matters, isolated DEX that can offer the best price will get the profits (provided they are not making a loss).</p><h2 id="h-oracle-driven-amms" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Oracle driven AMMs</h2><p>Newer models of AMMs on high performing blockchains today employ different strategies to maximize yield &amp; performance. AMMs today explore options on following oracle prices as opposed to relying on market forces to stabilize their price. While liquidity management within the AMM is still important to ensure that the pool doesn&apos;t lose money/have sufficient funds during volatility, the focus here is to provide the most competitive price (and also possibly perform the arbitrage themselves). This is evident within Solana ecosystem as there are performant enough oracles like Pyth Network which is able to fetch/aggregate the trading price of other cryptocurrencies fast enough from various data sources.</p><p>Examples of such AMMs are <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://lifinity.io/">Lifinity</a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.deltafi.ai/">DeltaFi</a>, especially Lifinity which dominates all other AMMs during aggregation when dealing with trading small amounts of liquidity. But their depth of liquidity is still small and larger trades will still involve the early market leading DEX-es.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/dc97d1744086ea38c1cb854497f8dd30ec8921fe7174b1e3f10a2f99157d114e.png" alt="Leading aggregator on Solana (Jupiter) using Lifinity for best trades" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Leading aggregator on Solana (Jupiter) using Lifinity for best trades</figcaption></figure><h2 id="h-beyond-single-chain" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Beyond Single Chain</h2><p>As more blockchains begin to have their own ecosystem, cross-chain swaps become a topic to explore. There are several existing cross-chain DEX-es that truly facilitate swaps (not Sushiswap kind of cross-chain where the DEX is available on different chains, but you still cannot cross those assets) across different chains such as <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://stargate.finance/">Stargate</a> and <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://thorchain.org/">Thorchain</a>. These are blockchains that enables swap between different blockchains/networks directly without dealing with bridges and their associated fees.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/547d38a6888a2c154925d0a1156437070c2ecfb1a4764c1d8dd56e4e9d7e6a2c.png" alt="Stargate with a TVL of 4 billion USD in just a few weeks" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Stargate with a TVL of 4 billion USD in just a few weeks</figcaption></figure><p>This can be achieved through an intermediary exchange of asset to their native token and back to the target asset. You can read more <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://thorchain.org/getting-started">here</a>.</p><h2 id="h-active-liquidity" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Active Liquidity</h2><p>Moving on, DEX-es today still do not fully utilize their liquidity well enough. Most DEX-es still use dual asset liquidity pools regardless of how much they optimize themselves. In reality, the same asset can be used to provision for multiple liquidity pools and earning trading fees from all of that. Such an example is Balancer in which liquidity is provided as a single asset, and then provision as modules to various pools such as the traditional dual-token liquidity pools or stablecoin pools. However, in this model, liquidity is ultimately still not shared amongst the different pools and depositors cannot truly maximize their gains.</p><p>Compossable Finance offers another model known as <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/composable-finance/active-liquidity-bots-allow-lping-to-keep-pace-with-the-cross-chain-expansion-of-defi-9c766841b9b">just-in-time liquidity</a>, where liquidity is provision <strong>only</strong> during the time of the swap. After the swap, the liquidity is removed and returned to the provider. There are people who have <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.coindesk.com/layer2/2022/02/02/just-in-time-liquidity-how-mev-can-enhance-defi-on-ethereum/">attempted</a> this concept on existing AMM like Uniswap V3 and could be very well profitable. Active liquidity allows the user to not only provision liquidity for multiple DEX-es simultaneously, it also allows user to provision liquidity for multiple assets at the same time. Of course, this is accompanied by the risk where the impermanent loss is amplified across the different pools (but of course this can be mitigated by only providing liquidity to only stablecoin pairs or when the trade favors the stablecoin asset).</p><p>And rewards can be further optimized by trading with derivative assets that compound yield such as <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/dare-to-be-better/what-is-liquid-staking-dee435dec14#:~:text=Liquid%20staking%20is%20the%20act,would%20be%20with%20PoS%20staking.">liquid staking</a>, vault shares or even sOhm derivatives if you are feeling degenerate.</p>]]></content:encoded>
            <author>randomdude@newsletter.paragraph.com (RandomDude)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/c115b3cd2270c5db371e4fbb11ede971eed6ad944f2e37dee5f05ae8dc991053.png" length="0" type="image/png"/>
        </item>
    </channel>
</rss>