<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alexander John Lee on Medium]]></title>
        <description><![CDATA[Stories by Alexander John Lee on Medium]]></description>
        <link>https://medium.com/@alexanderjohnlee?source=rss-561e038a8df3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JOSPRL_fKZuI2MHQo4Ey-g.jpeg</url>
            <title>Stories by Alexander John Lee on Medium</title>
            <link>https://medium.com/@alexanderjohnlee?source=rss-561e038a8df3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 20:31:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alexanderjohnlee/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Decentralized Privacy Preserving Order Book Exchange on Polygon Miden]]></title>
            <link>https://alexanderjohnlee.medium.com/building-a-decentralized-privacy-preserving-order-book-exchange-on-polygon-miden-f4502a550cc5?source=rss-561e038a8df3------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4502a550cc5</guid>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[ethereum-blockchain]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <category><![CDATA[polygon-miden]]></category>
            <dc:creator><![CDATA[Alexander John Lee]]></dc:creator>
            <pubDate>Mon, 24 Jun 2024 17:02:52 GMT</pubDate>
            <atom:updated>2024-06-24T17:05:18.889Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LtT55ag9rllLEBxR" /></figure><h4><strong>Introduction</strong></h4><p>Over the past several weeks, I’ve had the opportunity to work full-time learning how to build smart contracts on <a href="https://polygon.technology/polygon-miden">Polygon Miden</a>, a ZK-STARK-based Virtual Machine that will be a layer two rollup for Ethereum.</p><p><em>Why have I been learning how to write smart contracts and UTXO scripts (Miden Notes) on Miden?</em> Because I am working on building Spark, a decentralized privacy preserving order book exchange on the Miden blockchain!</p><p>Before I explain how I built an order book exchange in Miden Assembly and Rust, let me give you a brief introduction to why the Polygon Miden blockchain is so cool.</p><h3><strong>Why Polygon Miden?</strong></h3><p>Polygon Miden addresses several significant issues faced by Ethereum, particularly scalability and native privacy.</p><p>By integrating key concepts such as unspent transaction outputs (UTXOs) from Bitcoin and highly programmable expressive smart contracts from Ethereum, Polygon Miden creates a highly performant, privacy-preserving, smart-contract-enabled blockchain.</p><p><em>Super cool right?</em></p><h4><strong>Scalability</strong></h4><p>Ethereum stores all transaction data on-chain permanently, which is not scalable for onboarding billions of users in decentralized finance. Miden mitigates Ethereum’s state bloat problem through ZK-STARKs (Zero-Knowledge Scalable Transparent Arguments of Knowledge).</p><p>Instead of storing all transaction data as does Ethereum, Miden can reduce any smart contract or account to just its hash and store only that (account abstraction is supported by default on Miden). This means that even a huge smart contract with gigabytes of data can be represented on the Miden blockchain with just 32 bytes.</p><p>The Miden blockchain can either store:</p><ul><li>The entire data of an account or smart contract on chain, like on Ethereum (for public accounts and notes)</li><li>Only commitments to that data (for private accounts and notes)</li></ul><p>Additionally, Miden supports client-side proving, allowing users to generate transaction proofs locally before submitting them on-chain, further reducing load on nodes in the Miden network. This capability also enables concurrent transaction processing on Miden, unlike Ethereum, where transactions on L1 are essentially thread-blocking, leading to scalability issues.</p><p>Miden’s ability to handle transaction concurrency is comparable to other high-performance blockchains such as Solana and Sei. However, Miden’s support for local proof generation, and privacy-preserving transactions sets it apart.</p><p>As a bonus, because Miden’s core cryptography is based on ZK-STARKs, which are quantum secure, it is theoretically future-proof against quantum attacks.</p><h4><strong>Privacy</strong></h4><p>By default, all Ethereum transactions are public. As a result, privacy preserving projects like Tornado Cash have faced backlash from governments and even some web3 companies.</p><p>Miden offers users the choice of transaction privacy at the blockchain level. Initially, Miden will provide a level of privacy comparable to that of web2 platforms like PayPal, meaning the Miden operator will still see all transaction data for the first year after the mainnet launch. However, in the future, Miden aims to offer a whole new level of privacy, where, in theory, transaction notes won’t even need to have a sender.</p><p>While several privacy-preserving blockchains exist, few support expressive Turing-complete smart contracts.</p><p>Client-side proving, parallelized transactions, and native privacy make Miden a promising platform for privacy-preserving decentralized financial applications.</p><h4><strong>Differences From Ethereum</strong></h4><p>Although Miden and Ethereum both support smart contracts, Miden’s architecture diverges significantly with the concept of “notes”. Notes are unspent transaction outputs that contain a script, which defines the conditions from which a user can consume the note. Notes can contain assets or data. To create a note, an account must first generate a proof that the note was created.</p><p>I like to think of Miden Notes as <strong><em>cryptographic cashier’s checks</em></strong>. When someone writes a cashier’s check, the person depositing the check knows it won’t bounce.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YY66sP4ETUa-dZLw" /><figcaption>Midjourney’s interpretation of a “cryptographic cashier’s check on Miden”</figcaption></figure><p>The same with Miden notes, the smart contract consuming the note knows the data inside of the note is valid.</p><p>The ability to pass data between smart contracts and for the smart contracts to be cryptographically certain that the data contained in the note was not tampered with is a feature of Miden that sets it apart from other blockchain projects. In a sense, Miden enables verifiable computation at the transaction level.</p><p>Currently, smart contracts and notes on Miden are written in an assembly language known as Miden Assembly (MASM).</p><h3><strong>Building an Order Book Exchange on Miden</strong></h3><p>An order book is a ubiquitous piece of financial architecture used in trading platforms to facilitate the buying and selling of assets. It records the buy and sell orders of traders, specifying the quantity and price of an asset.</p><p>The orders are sorted by price, allowing other traders to fill them based on their market strategies. In this context, the traders who create orders in the order book are known as “Makers,” while those who fill these orders are referred to as “Takers.”</p><h4>Partially Fillable SWAP notes (SWAPp)</h4><p>To implement the core functionality of an order book exchange, we need to create a mechanism for buy/sell orders using Miden notes. The SWAPp note can be thought of as cryptographic cashier’s check that allows partial deposits of the offered liquidity, contingent upon the trader “depositing” the cashier’s check issuing <em>two new cashier’s checks:</em></p><ol><li>A cashier’s check with the amount of the requested asset for the SWAPp creator (P2ID note).</li><li>A new buy/sell order cashier’s check (SWAPp note) with the remaining liquidity of the offered asset and the updated amount of the requested asset.</li></ol><h4>Example Scenario</h4><ol><li>Consider Trader 1, who wants to exchange 10 tokens of Asset A for 10 tokens of Asset B.</li><li>Trader 2 finds the price attractive but lacks sufficient tokens B to buy all of Trader 1’s tokens A.</li><li>Trader 1 is satisfied if they receive tokens B at the specified price, regardless of the amount.</li></ol><p>This is where the Partially Fillable Swap Note (SWAPp) comes into play. Here’s a schema of how the SWAPp note works:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*g6_hH3nDp4L2pr_6" /></figure><ol><li>Trader 1 creates a SWAPp note with 10 tokens A and specifies a request for 10 tokens B.</li><li>Trader 2 consumes the SWAPp note, creates a note with tokens B for Trader 1, deposits 8 tokens A into their wallet, and creates a new SWAPp note with the remaining liquidity of Trader 1.</li><li>This process continues until the liquidity of Trader 1 is fully consumed.</li></ol><h3>Order Book Depth and Buy/Sell Limit Orders</h3><p>The SWAPp note architecture inherently supports buy/sell limit orders.</p><ul><li><strong>Buy Limit Order:</strong> Placed when a trader believes the asset price will fall, specifying a price at which they wish to purchase the asset.</li><li><strong>Sell Limit Order:</strong> Placed when a trader believes the asset price will rise, specifying a price at which they wish to sell the asset.</li></ul><p>SWAPp notes can be aggregated and sorted by price, revealing the order book depth chart.</p><h4>Example</h4><p>Assume the spot price is 1:1 for tokens A and B.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6_WuQrxl_7YjtIJh" /></figure><p>To create a buy limit order, if the spot price is 1:1, a trader, Bob, would specify in their SWAPp script that they are offering 10 tokens B, for 12 tokens A. This implies that trader Bob thinks the value of token A will decrease, and the token A to token B exchange rate will drop to 0.83 B/A.</p><p>After being created, this buy limit order will not be consumed by rational market participants since the spot price is still 1:1.</p><p>Market participants who want to buy tokens B see that there are other orders with more favorable exchange rates, meaning a rational market participant would be incentivized to consume the SWAPp notes that have more favorable rates first, before consuming Bob’s open buy limit order. However, if the spot price declines to Bob’s specified exchange rate, Bob’s buy limit order will get filled.</p><h3>Handling Fixed Point Precision Math in Miden Assembly</h3><p>Below is a Miden Assembly procedure that calculates the amount of tokens A a SWAPp note will give if the consuming account sends a quantity of tokens B to the note creator. This calculation is akin to the x * y = k automated market maker formula but without slippage.</p><p>In Python, the SWAPp invariant formula looks like this:</p><pre>def calculate_tokens_a_for_b(tokens_a, tokens_b, requested_tokens_b):<br>    # Scaling factor<br>    scaling_factor = 10**5<br>    <br>    # Check if tokens_a is smaller than tokens_b<br>    if tokens_a &lt; tokens_b:<br>        # Scale the inverse ratio<br>        scaled_ratio = (tokens_b * scaling_factor) // tokens_a<br>        <br>        # Calculate the amout of tokens A out using integer arithmetic<br>        tokens_a_out = (requested_tokens_b * scaling_factor) // scaled_ratio<br>    else:<br>        # Scale the ratio<br>        scaled_ratio = (tokens_a * scaling_factor) // tokens_b<br><br>        # Calculate the amout of tokens A out using integer arithmetic<br>        tokens_a_out = (scaled_ratio * requested_tokens_b) // scaling_factor<br>    <br>    return tokens_a_out</pre><p>In Miden Assembly, the equivalent procedure is as follows:</p><pre>use.std::math::u64<br><br>const.AMT_TOKENS_A=0x0064<br>const.AMT_TOKENS_B=0x0065<br>const.AMT_TOKENS_B_IN=0x0066<br>const.RATIO=0x0067<br>  <br>const.FACTOR=0x000186A0 # 1e5<br>const.MAX_U32=0x0000000100000000<br>  <br>#! Inputs: [tokens_a, tokens_b, tokens_b_in]<br>#! Output: [tokens_a_out]<br>proc.calculate_tokens_a_for_b<br>  mem_store.AMT_TOKENS_A <br>  mem_store.AMT_TOKENS_B <br>  mem_store.AMT_TOKENS_B_IN <br><br>  mem_load.AMT_TOKENS_B mem_load.AMT_TOKENS_A<br><br>  gt<br>  if.true<br>    mem_load.AMT_TOKENS_B<br>    u32split<br><br>    push.FACTOR<br>    u32split<br>            <br>    exec.u64::wrapping_mul<br><br>    mem_load.AMT_TOKENS_A<br>    u32split<br><br>    exec.u64::div<br>    push.MAX_U32 mul add<br><br>    mem_store.RATIO<br><br>    mem_load.AMT_TOKENS_B_IN<br>    u32split<br><br>    push.FACTOR<br>    u32split<br><br>    exec.u64::wrapping_mul<br><br>    mem_load.RATIO<br>    u32split<br><br>    exec.u64::div<br><br>    push.MAX_U32 mul add          <br><br>  else<br>    mem_load.AMT_TOKENS_A<br>    u32split<br><br>    push.FACTOR<br>    u32split<br>            <br>    exec.u64::wrapping_mul<br><br>    mem_load.AMT_TOKENS_B<br>    u32split<br><br>    exec.u64::div<br><br>    mem_load.AMT_TOKENS_B_IN<br>    u32split<br><br>    exec.u64::wrapping_mul<br><br>    push.FACTOR<br>    u32split<br><br>    exec.u64::div<br>    push.MAX_U32 mul add          <br><br>  end<br>end</pre><p>The core of the calculate_tokens_a_for_b calculation is a straightforward division:</p><p><strong><em>c = a / b</em></strong></p><p><em>simple right?</em></p><p>However, to achieve fixed-point precision, the formula is adjusted to:</p><p><strong>c = a * 10⁵ / b</strong></p><p>To avoid overflow, particularly when <strong><em>a &lt; b</em></strong>, the formula is modified as follows:</p><p><strong>c1 = b * 10⁵ / a</strong></p><p><strong>c = 10⁵ / c1</strong></p><p>Given that the maximum value within a stack element in the Miden VM is 2⁶⁴ — 2³², there is a limitation on the largest value a user can swap using the current implementation of the SWAPp note. Currently, the upper bound for values that the calculate_tokens_a_for_b procedure can handle is approximately 1,844,674 for a token with 8 decimal points or 184,467,440 for a token with 6 decimal points.</p><p>The plan is to implement the calculate_tokens_a_for_b procedure using u256 integers, which will effectively remove the current limitation on the maximum number of tokens a user can swap and will increase the fixed point decimal precision of the procedure.</p><h3>Implementing the Partial SWAP (SWAPp) Note in Miden Assembly</h3><p><em>This is where things start to get a bit technical, feel free to skip this part if you don’t care for the technical details :)</em></p><p>At a high level, these are the steps required to implement the partially fillable SWAP note (SWAPp) in Miden assembly.</p><p>The SWAPp note has the same number of inputs as the standard SWAP note in the miden-base repository. This means there are nine stack elements as inputs to the SWAPp note.</p><p><em>In the context of Miden, when describing the stack, capitalized words represent four stack elements. Four stack elements are referred to as words.</em></p><p><strong>SWAPp note inputs:</strong></p><pre>Inputs: [PAYBACK_RECIPIENT, REQUESTED_ASSET, SWAPp_tag]</pre><p>The PAYBACK_RECIPIENT is the RECIPIENT digest of the <a href="https://github.com/0xPolygonMiden/miden-base/blob/main/miden-lib/asm/note_scripts/P2ID.masm">P2ID note</a> addressed to the creator of the SWAPp note.</p><p>The RECIPIENT digest for all Miden notes is defined as:</p><pre>hash(hash(hash(serial_num, [0; 4]), script_hash), input_hash)</pre><ol><li>Where, the serial_num is a unique number comprised of four stack elements.</li><li>Where, the script_hash is the <a href="https://academy.bit2me.com/en/que-es-mast/">Merkelized Abstract Syntax Tree</a> (MAST) root of the given note script.</li><li>Where, the input_hash is the hash of the inputs to the note. The input to the P2ID note is the account id of the account that is allowed to consume the P2ID note.</li></ol><p>We hash these values together to compute thePAYBACK_RECIPIENT which is the hash digest of the P2ID note.</p><p>For the SWAPp note inputs, theREQUESTED_ASSET is the faucet id and amount of the asset requested, and the SWAPp_tag is a value used to improve the discoverability of notes on the Miden blockchain.</p><p>In the steps below, “token A” refers to the offered asset, and “token B” refers to the requested asset in the SWAP note.</p><ol><li>Push the amount_token_a contained as liquidity in the note to the stack.</li><li>Push the requested amount_token_b to the stack.</li><li>Push the amount of token B the consuming account wants to send to the SWAPp note creator, amount_token_b_in.</li><li>Using amount_token_b_in, calculate amount_token_a_out to send to the consuming account, using the calculate_tokens_a_for_b procedure.</li><li>Send amount_token_b_in to the SWAPp note creator via a P2ID note.</li><li>Send amount_token_a_out to the consuming account by calling the receive_asset procedure.</li><li>Update the amount of requested tokens B, amount_token_b’ for the new SWAPp note.</li><li>Create the new SWAPp note and add the remaining liquidity of token A, amount_token_a’.</li></ol><p>Additionally, the SWAPp note checks if the currently consuming account is the original creator of the SWAPp note, and if so, the liquidity contained in the SWAPp note is sent to the owner. This is so that the original SWAPp note creator can reclaim their order after creation of the note.</p><p>In future implementations of the SWAPp note, the note will have an expiration time if not consumed within a certain time after being created.</p><p><em>You can check out the full implementation of the SWAPp note here: </em><a href="https://github.com/compolabs/spark-miden-v1/blob/main/src/notes/SWAPp.masm"><em>https://github.com/compolabs/spark-miden-v1</em></a></p><h3><strong>Mitigating Race Conditions</strong></h3><p>Currently, any user aware of a created SWAPp note can consume it. However, this can lead to potential issues, as multiple users may compete to generate and submit the proof first to the Miden node, resulting in a computational race. Addressing race conditions is challenging because initial solutions might inadvertently be exploited to exclude certain market participants from accessing the order book exchange.</p><p>I am currently researching potential strategies to mitigate the negative effects of race conditions. Notably, the issue of race conditions on Polygon Miden is analogous to the concept of miner extractable value (MEV) on Ethereum.</p><h3><strong>Conclusion</strong></h3><p>A decentralized privacy-preserving order book exchange on Polygon Miden is one of several DeFi applications that can take full advantage of the scalability, privacy, and expressive smart contracts that Polygon Miden enables.</p><p>By utilizing ZK-STARKs, Polygon Miden enables efficient transaction processing, significantly reduces on-chain data load, and enhances scalability through client-side proving.</p><p>The Spark order book exchange on Miden not only highlights the innovative architecture of Miden, but also paves the way for more advanced decentralized financial applications, addressing both scalability and privacy concerns in the DeFi space.</p><h4><strong>Further reading for learning Polygon Miden</strong></h4><p>If you want to learn more about Polygon Miden, how to write notes and accounts on Polygon Miden, here are a few of my favorite resources:</p><ol><li><strong>Miden Research Repository.</strong> <em>This is a repository I built to get up to speed learning how to write smart contracts on Polygon Miden:</em> <a href="https://github.com/compolabs/miden-research">https://github.com/compolabs/miden-research</a></li><li><strong>Spark-Miden-v1.</strong> <em>This is the current implementation of the Spark Order Book exchange on Polygon Miden, and contains the implementation of the SWAPp note:</em> <a href="https://github.com/compolabs/miden-research">https://github.com/compolabs/miden-research</a></li><li><strong>Miden VM Documentation.</strong> This documentation is extremely useful for learning how to write scripts in Miden assembly: <a href="https://0xpolygonmiden.github.io/miden-vm/intro/main.html">https://0xpolygonmiden.github.io/miden-vm/intro/main.html</a></li><li><strong>Miden Transaction Procedures Documentation. </strong><em>This is useful documentation for learning how to use transaction procedures and has a basic demo of how to use the Miden testnet:</em> <a href="https://docs.polygon.technology/miden/miden-base/architecture/transactions/procedures/">https://docs.polygon.technology/miden/miden-base/architecture/transactions/procedures/</a></li><li><strong>Miden Assembly Playground. </strong><em>This is extremely useful for learning how to write basic pure functions in Miden Assembly. </em><a href="https://0xpolygonmiden.github.io/examples/">https://0xpolygonmiden.github.io/examples/</a></li></ol><p><em>About the author: Alexander John Lee is a researcher and engineer at Composability Labs researching and implementing high performance, privacy preserving, decentralized financial applications.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4502a550cc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Russian Gold Price and the Value of the Russian Ruble]]></title>
            <link>https://alexanderjohnlee.medium.com/russian-gold-price-and-the-value-of-the-russian-ruble-1cc201a33ba6?source=rss-561e038a8df3------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cc201a33ba6</guid>
            <category><![CDATA[macroeconomics]]></category>
            <category><![CDATA[gold]]></category>
            <category><![CDATA[russia]]></category>
            <category><![CDATA[economics]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Alexander John Lee]]></dc:creator>
            <pubDate>Wed, 29 May 2024 04:28:24 GMT</pubDate>
            <atom:updated>2024-05-29T04:31:23.335Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*6jDUXkiViCopzGYtcyOzvQ.jpeg" /><figcaption>As of May 2024, Russian Gold is priced 6% lower than the global spot price</figcaption></figure><p>Gold, a timeless symbol of wealth and stability, has always held significant importance in the global economy. Most people think the price of gold is universal; however, the price of gold can vary significantly depending on where it’s purchased, especially during times of political tension. Political tension creates inefficiencies in the market, allowing certain investors to capitalize on these market inefficiencies<em> (not investment advice)</em>.</p><h3>The Russian Gold Market and the Ruble</h3><p>One of the tools of any central bank is to sell gold reserves at a price lower than the global spot price to create demand for the central bank’s respective currency. Currently, this macroeconomic tactic is being used by the Russian Central Bank to strengthen the value of the Russian Ruble. But how does selling gold at a lower price than the global spot price increase the value of the Russian Ruble?</p><p>To buy gold in Russia, a trader must first purchase Russian rubles, selling their respective native currency, thus creating an inherent demand for the Ruble. By ensuring that gold is cheaper within Russia than abroad, the central bank creates demand for the Ruble. Foreign investors and traders looking to exploit the price difference must first purchase Rubles to buy gold on the Russian market, thus attracting buyers and ensuring demand for the Russian ruble.</p><p>In March of 2022, the Russian government scrapped the 20% VAT on individuals buying gold to lower Russian retail demand on the US Dollar as a hedge against the volatility of the Russian ruble.</p><h3>A Comparative Analysis: Russian vs. Global Gold Prices</h3><p>Let’s explore the price differences through a Python script designed to scrape gold prices from a VTB bank and JM Bullion:</p><pre>from selenium import webdriver<br>from selenium.webdriver.chrome.service import Service<br>from webdriver_manager.chrome import ChromeDriverManager<br>from selenium.webdriver.common.by import By<br>import time<br>import requests<br><br># Setup ChromeDriver<br>service = Service(ChromeDriverManager().install())<br>driver = webdriver.Chrome(service=service)<br><br># URL of the page to scrape<br>url = &#39;https://www.vtb.ru/personal/vklady-i-scheta/obezlichennyj-metallicheskij-schet/&#39;<br><br>sell_price_ru_rub = 0<br>buy_price_ru_rub = 0<br><br>try:<br>    # Navigate to the page<br>    driver.get(url)<br>    time.sleep(15)<br>    price_elements = driver.find_elements(By.CSS_SELECTOR, &#39;p.typographystyles__Box-foundation-kit__sc-14qzghz-0.jEFSaq.numbersstyles__TypographyTitle-foundation-kit__sc-1xhbrzd-4.haHdlc&#39;)<br>    <br>    if len(price_elements) &gt;= 2:<br>        sell_price_ru_rub = price_elements[0].text.replace(&quot; &quot;, &quot;&quot;).replace(&quot;,&quot;, &quot;.&quot;)<br>        buy_price_ru_rub = price_elements[1].text.replace(&quot; &quot;, &quot;&quot;).replace(&quot;,&quot;, &quot;.&quot;)<br>finally:<br>    driver.quit()<br><br>service = Service(ChromeDriverManager().install())<br>driver = webdriver.Chrome(service=service)<br><br>url = &#39;https://bullionexchanges.com/sell-to-us/bars&#39;<br><br>buy_price_usa = 0<br>sell_price_usa = 0<br><br>try:<br>    driver.get(url)<br>    time.sleep(10)<br>    price_elements = driver.find_elements(By.CLASS_NAME, &#39;price-alZZ&#39;)<br>    <br>    if len(price_elements) &gt;= 2:<br>        buy_price_usa = price_elements[0].text.replace(&quot;$&quot;, &quot;&quot;).replace(&quot;,&quot;, &quot;&quot;)<br>        sell_price_usa = price_elements[1].text.replace(&quot;$&quot;, &quot;&quot;).replace(&quot;,&quot;, &quot;&quot;)<br>finally:<br>    driver.quit()<br><br># Conversion factor from ounces to grams<br>oz_to_grams = 28.3495<br><br>buy_price_usa = float(buy_price_usa)<br>sell_price_usa = float(sell_price_usa)<br><br>def convert_price_oz_to_gram(price_per_oz):<br>    return price_per_oz / oz_to_grams<br><br>buy_price_usa_gram_usd = convert_price_oz_to_gram(buy_price_usa)<br>sell_price_usa_gram_usd = convert_price_oz_to_gram(sell_price_usa)<br><br>def get_usd_rub_exchange_rate():<br>    url = &quot;https://api.exchangerate-api.com/v4/latest/USD&quot;<br>    response = requests.get(url)<br>    data = response.json()<br>    usd_to_rub = data[&#39;rates&#39;][&#39;RUB&#39;]<br>    return usd_to_rub<br><br>exchange_rate = get_usd_rub_exchange_rate()<br>buy_price_ru_rub_normalized = float(buy_price_ru_rub)<br>cost_in_usd = buy_price_ru_rub_normalized / exchange_rate<br>profit_per_gram_usd = buy_price_usa_gram_usd - cost_in_usd<br><br>print(&quot;Price per gram AU in Russia:&quot;, &quot;{:.2f}&quot;.format(buy_price_ru_rub_normalized))<br>print(&quot;Price per gram AU in USA:&quot;, &quot;${:.2f}&quot;.format(sell_price_usa_gram_usd))<br>print(&quot;Profit per gram in USD:&quot;, &quot;${:.2f}&quot;.format(profit_per_gram_usd))</pre><p><strong><em>Outputs (as of May 29, 2024):</em></strong></p><p><em>Price per gram AU in Russia: 6898.90 Rubles</em></p><p><em>Price per gram AU in USA: $83.48</em></p><p><em>Profit per gram in USD: $5.16</em></p><h3>How Gold Prices Prop Up the Ruble</h3><p>This script reveals that, as of May 28, 2024, the price of gold in Russia, sold by VTB Bank, is approximately $5.16 less per gram than the price on JM Bullion in the US, or 6% less. This discrepancy provides an opportunity for arbitrage, but it also highlights how the Russian central bank props up the Ruble’s value. An arbitrage opportunity of 6% for an asset as liquid as gold is honestly quite shocking. However, currently, <a href="https://ofac.treasury.gov/faqs/1029#:~:text=U.S.%20persons%20are%20prohibited%20from,to%20Directive%204%20under%20E.O.">US citizens are prohibited from buying Russian gold</a> according to the US Office of Foreign Assets Control.</p><h3>Russian Central Bank Gold Reserves</h3><p>Despite the price of gold in Russia being at a lower price than the global spot price, the <a href="https://www.cbr.ru/hd_base/mrrf/mrrf_7d/?UniDbQuery.Posted=True&amp;UniDbQuery.From=01.2000&amp;UniDbQuery.To=05.2024">amount of gold held in reserves at the Russian Central Bank</a> is at a relative all-time high since the early 2000s. Despite this, it is apparent that the gold reserves did decline after the start of the war in Ukraine in 2022, but since then, the amount of gold reserves has increased once again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7J9ZmUg_80-HF3CEKPdseQ.png" /></figure><h3>The Nature of Gold and Inflation</h3><p>While gold is often considered a hedge against inflation, it’s not entirely non-inflationary. The <a href="https://www.gold.org/goldhub/research/gold-demand-trends/gold-demand-trends-full-year-2023/supply">gold supply increases at a rate of approximately 3% per year</a>, subtly inflating its supply. This rate is significantly lower than most fiat currencies, which is why gold remains a popular store of value.</p><h3>Conclusion</h3><p>An arbitrage opportunity of 6% in an asset as large as gold is massive, but only on paper. In reality, executing such a trade would be difficult due to logistical challenges and legal restrictions, especially for US citizens. It’s essential to recognize these complexities before considering any financial moves based on such opportunities.</p><p>For those interested in exploring the data and running the jupyter notebook themselves, the entire source code is available on my <a href="https://github.com/partylikeits1983/russian-gold-arbitrage">GitHub</a>.</p><p><em>Disclaimer: The content of this article is not intended to constitute investment advice. Readers are advised to conduct their own independent research and seek the counsel of professional financial advisors and legal counsel prior to making any investment decisions. Any actions taken that do not comply with the Office of Foreign Assets Control (OFAC) regulations are at the reader’s own risk.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cc201a33ba6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Blockchain Innovators or Cowards?]]></title>
            <link>https://alexanderjohnlee.medium.com/blockchain-innovators-or-cowards-107879709632?source=rss-561e038a8df3------2</link>
            <guid isPermaLink="false">https://medium.com/p/107879709632</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[world-economic-forum]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Alexander John Lee]]></dc:creator>
            <pubDate>Mon, 12 Feb 2024 12:04:19 GMT</pubDate>
            <atom:updated>2024-02-12T12:14:38.290Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Innovators or Cowards? Drawing Parallels Between Today’s Blockchain “Innovators” and Bulgakov’s Masterpiece, Master and Margarita</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SKCb6Y6os4yeB0cdOIkdHA.png" /><figcaption>What Midjourney thinks the World Economic Forum in Davos, Switzerland looks like</figcaption></figure><p>I recently saw the new cinematic adaptation of Mikhail Bulgakov’s <a href="https://ru.wikipedia.org/wiki/%D0%9C%D0%B0%D1%81%D1%82%D0%B5%D1%80_%D0%B8_%D0%9C%D0%B0%D1%80%D0%B3%D0%B0%D1%80%D0%B8%D1%82%D0%B0_(%D1%84%D0%B8%D0%BB%D1%8C%D0%BC,_2024)">“Master and Margarita</a>”, where I was honestly blown away by the cinematography and the production quality of the film.</p><p>This experience reignited my interest in Bulgakov’s novel, a work I first delved into during my freshman year in college. Due to its complexity and non-linear narrative structure, the core essence of the book remained elusive to me until the film illuminated to me its central themes and philosophical foundations.</p><p><strong>The film’s portrayal of Bulgakov’s work led me to draw an unexpected connection to the current era of cryptocurrency and blockchain “innovators,” such as the leaders of 1inch, </strong><a href="https://x.com/LefterisJP/status/1354731906496081923?s=20"><strong>a closed source “decentralized exchange”</strong></a><strong>, and Circle, the leading “</strong><a href="https://cointelegraph.com/news/usdc-depegs-as-circle-confirms-3-3b-stuck-with-silicon-valley-bank"><strong>probably stable</strong></a><strong>” stablecoin issuer.</strong> Despite proclaiming their mission to liberate society from the confines of traditional financial systems, they paradoxically found themselves mingling with the very architects of these systems at the World Economic Forum in Davos, Switzerland, this year.</p><p>Maybe it’s a lack of knowledge or naiveté that makes many blockchain startup founders to flock to an event where the organizers openly state to the public “<a href="https://www.youtube.com/watch?v=SqzepGBatWo">you’ll own nothing and you’ll be happy</a>” in promotional videos regarding how they wish to see the future of society. Of course it won’t be the World Economic Forum organizers that don’t own anything, they’ll own everything and tell you to be happy.</p><p>Naiveté or not, I bet any ounce of cognitive dissonance these “leading blockchain innovators” might have felt at Davos was swiftly quelled by the flowing champagne and the DJs’ loud music at many of the afterparties.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tcEl1Ri9At9d5n_wlUGW2A.png" /><figcaption>Sipping Margaritas with the Devil at the World Economic Forum</figcaption></figure><p><em>If you can stand the cringe, you can watch the entire Davos crypto afterparty video on </em><a href="https://www.linkedin.com/posts/1inch_1inchparty-davos-1inch-activity-7158528189802168320-hxlN?utm_source=share&amp;utm_medium=member_desktop"><em>LinkedIn.</em></a></p><p>This juxtaposition led me to ponder the true nature of innovation in the context of societal and economic structures — prompting questions about the genuine intent and moral integrity behind the facade of disruption and progress.</p><p>For those who don’t know, “The Master and Margarita” is a novel by Mikhail Bulgakov, written between 1928 and 1940, but not published in book form until 1967. The novel is considered one of the masterpieces of 20th-century Russian literature. It weaves together two primary storylines, one set in Moscow during the 1930s and the other in Jerusalem during the time of Pontius Pilate, the Roman leader who allowed the execution of Jesus Christ.</p><p>The novel begins in Moscow in the spring of 1933, where the Devil, in human form disguised as a German man named Woland, arrives at <a href="https://maps.app.goo.gl/SDepzH5u9VAeRRFz8">Patriarch’s Ponds</a>, a well-known posh area in Moscow, and interrupts the discussion of two writers, discussing the nonexistence of Jesus Christ and the materialist interpretation of history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F2LT2DQFdFoB3pBAidCumQ.jpeg" /><figcaption>Patriarch Ponds in Moscow</figcaption></figure><p>During the book, the Devil creates all sorts of fantastical events to point out the hypocrisy of soviet ideology. One of the final acts of Devil is to hijack a play based on the future of the Soviet Union, and to instead have a demonstration of “black magic”.</p><p>During the performance, the Devil invites volunteers to come forward so he can transform their attire into luxurious designer outfits. Initially, the soviet audience is reluctant, but after witnessing the Devil magically change one woman’s outfit into a lavish and expensive dress, the crowd becomes frenzied, eagerly wanting to also be adorned in similarly extravagant fashion.</p><p>At the finale of the performance, the Devil makes money fall from the ceiling. As the money begins to fall, the initially astonished audience quickly succumbs to their greed, scrambling to catch as much as they can.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*_889dj-AfE3QdE1B00lUDg.jpeg" /><figcaption>Raining money during the Devil’s “black magic” show</figcaption></figure><p>This chaotic scramble for the falling currency highlights the crowd’s materialistic desires and the lengths to which they will go to acquire wealth, even in the face of unexplained, supernatural phenomena.</p><p>The scene serves as a powerful visual metaphor for Soviet society’s underlying hypocrisy and greed, despite its professed ideals of equality and communal sharing.</p><p>Despite the official promotion of communist ideals emphasizing equality, sharing, and the abolition of private property, the characters in the novel continue to exhibit traditional human desires and weaknesses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*2PxSsyvieE5fqwhSHYUnzw.jpeg" /><figcaption>An idealistic vision of soviet society</figcaption></figure><p>Through Woland’s interactions and the unfolding events in “The Master and Margarita,” Mikhail Bulgakov subtly critiques Soviet ideology and the reality of its implementation, suggesting that it serves as an idealistic cover-up for deeper human vices such as greed, materialism, and hypocrisy.</p><p>Bulgakov uses the Devil’s presence and actions as a mirror to society, revealing the contradictions and moral failings of those who outwardly profess to live by communist principles but inwardly pursue their selfish interests.</p><p>The novel also highlights the fear of dissent against authority within Soviet society. Through the absurd and often surreal punishments that Woland and his retinue inflict on Moscow’s citizens, Bulgakov showcases the consequences of a society where fear stifles genuine expression and criticism.</p><p>The widespread fear of deviating from the party line, of being seen as not fully embracing Soviet ideals, is a theme that runs throughout the book, with characters often more concerned with appearances and their own safety than with any ideological conviction.</p><p>The novel suggests that beneath the surface of the Soviet ideal of creating a new kind of human being — free from selfish desires and capitalist tendencies — lies the unalterable nature of humanity, with all its flaws and complexities.</p><h4><strong>Cowardice</strong></h4><p>The theme of cowardice and reluctance to challenge authoritarianism is a significant undercurrent in the novel. This theme manifests through various characters and plotlines, most notably in the figures of Pontius Pilate and the contemporary Moscow literary elite.</p><p>Bulgakov employs these characters to delve into the moral and ethical repercussions of yielding to authority from a standpoint of fear or self-preservation, and the ramifications of not defending one’s beliefs and convictions.</p><p>In the Moscow narrative of the book, the literary and theatrical elite — comprising critics, writers, and bureaucrats — frequently exhibit cowardice through their uncritical acceptance of the dominant Soviet ideology.</p><p>Their fear of reprisal leads them to reject anything that deviates from the official party line. This fear of authority ensures their complicity in a system that suppresses free thought and creativity, illustrating the personal and societal costs of cowardice in the face of authoritarianism.</p><p>The members of the literary elite are portrayed as more concerned with their safety and status than with the truth or artistic integrity, reflecting Bulgakov’s critique of Soviet censorship and the lack of moral courage among those who enforce or abide by it.</p><p>The storyline of Pontius Pilate in “The Master and Margarita” serves as a historical parallel to the modern-day Moscow narrative, further exploring the theme of cowardice. Pilate, despite his powerful position as the prefect of Judea, exhibits his own form of cowardice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*LKmVfK1E1SUrVLD_JeMiFA.jpeg" /><figcaption>Pontius Pilate and Jesus</figcaption></figure><p>Pontius Pilate recognizes the innocence and wisdom of Yeshua Ha-Notsri (Jesus) but chooses to condemn him to death to appease the crowd and maintain political stability. Pilate’s internal conflict and his eventual regret underscore the moral and spiritual costs of his failure to act according to his conscience, ultimately leading him to succumb to the pressures that can metaphorically be seen as yielding to the Devil’s influence.</p><p>Pilate’s story is a poignant exploration of the consequences of yielding to authority and public opinion at the expense of justice and personal integrity.</p><h4><strong>The Cowardice of “Blockchain Innovators” and Proponents of DeFi</strong></h4><p>Upon revisiting the complex themes of Mikhail Bulgakov’s “The Master and Margarita,” it becomes strikingly apparent how the narratives of today’s leading figures in the blockchain and DeFi sectors mirror those depicted in the novel.</p><p>Much like Bulgakov’s portrayal of characters who mask their underlying motives with a facade of virtue, a number of today’s blockchain “innovators” seem to cloak their greed and reluctance to challenge the status quo under the guise of promoting decentralized finance — a movement heralded for its potential to democratize financial systems and empower individuals with control over their financial assets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6hTv6JLFU01D5hsfR7fEjg.png" /><figcaption>Chained by the cowardice of failing to employ blockchain technology to challenge the status quo.</figcaption></figure><p>However, there is a palpable tension between the revolutionary ideals these leaders profess and their actions, particularly in how they navigate the regulatory landscapes. The very individuals who champion the cause of DeFi, promising a future where financial sovereignty and autonomy are within everyone’s grasp, are often found in the company of people whose actions and beliefs starkly contrast the foundational principles of decentralization and blockchain technology.</p><p>The same individuals who position themselves as pioneers in blockchain technology often associate in their leisure with advocates of stringent pandemic lockdowns, <a href="https://www.clubofrome.org/events/davos-2023/">supporters of significant population control measures</a>, and environmental activists who, despite their stance, paradoxically increase carbon emissions by flying private jets to elite events such as Davos.</p><p>This juxtaposition becomes starkly evident when these blockchain innovators, who voice support for the developers of <a href="https://www.coindesk.com/policy/2023/08/23/tornado-cash-devs-arrested-on-money-laundering-sanctions-violation-grounds-over-alleged-1b-moved/">Tornado Cash</a> — a privacy-enhancing protocol on Ethereum Virtual Machine (EVM) chains — also accept financial backing from traditional banking institutions. These are the very institutions that follow OFAC guidelines who label the Tornado Cash developers as “<a href="https://home.treasury.gov/news/press-releases/jy0916">criminals</a>”.</p><p>The contradiction here is stark: advocating for a technology that enhances privacy and financial sovereignty, while simultaneously aligning with entities that embody the centralization and surveillance DeFi seeks to dismantle.</p><p>The question then arises: How can one genuinely advocate for decentralized finance while engaging with and supporting the mechanisms and figures of traditional power structures, such as those convening in Davos? This scenario reveals a level of hypocrisy reminiscent of Bulgakov’s characters, who navigate a world rife with contradictions, performing a delicate dance between their ideals and the realities imposed by societal and political pressures.</p><p>In this light, the narrative of “The Master and Margarita” serves not only as a critique of the Soviet regime of Bulgakov’s time but also as a timeless reflection on the human condition, challenging today’s DeFi leaders to introspect on the authenticity of their commitment to the principles of decentralization and financial sovereignty.</p><p>The novel beckons us to question whether the pursuit of innovation and change can truly coexist with the compromises made in the face of regulatory and societal constraints, or if these compromises betray the very essence of the revolution they aim to lead.</p><h4><strong>Cowardice as the gravest sin</strong></h4><p>In the landscape of Mikhail Bulgakov’s “The Master and Margarita,” cowardice emerges not merely as a flaw but as the gravest of sins — an act of betrayal against one’s integrity and the truth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6cX7HiJlpWezEUn1ghKl-A.png" /><figcaption>Once a talented software engineer, now a white collar executive who is controlled by his WEF financial backers</figcaption></figure><p>This thematic undercurrent resonates deeply within the narrative, illustrating how the failure to stand by one’s convictions under the weight of authoritarian scrutiny or societal pressure leads to spiritual and moral bankruptcy. The characters who exhibit cowardice, who fail to confront or challenge the prevailing currents of their time, suffer profound consequences, underscoring Bulgakov’s critique of the Soviet society’s suppression of dissent and the individual’s complicity through silence or conformity.</p><p>This notion of cowardice as the paramount sin finds a compelling parallel in today’s world of blockchain “innovators” and the DeFi space, where the ideals of decentralization and financial sovereignty often clash with the realities of regulatory frameworks and societal norms.</p><p>The reluctance to push against these regulations, for fear of reprisal or loss of status or capital, echoes the cowardice Bulgakov depicted. It reveals a tension between the revolutionary potential of blockchain technology and the compromises its proponents make when faced with the mechanisms of traditional power structures.</p><h4>Manuscripts don’t burn</h4><p>The novel’s climax brings us to Woland’s (the Devil’s) profound assertion that “manuscripts don’t burn.” This statement transcends its literal meaning to symbolize the indestructibility of ideas, of truth, despite attempts to suppress or destroy them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UZjzKyEha5DUWVXRfQFNlw.jpeg" /><figcaption>Мanuscripts don’t burn.</figcaption></figure><p>In the context of blockchain and DeFi, smart contracts and blockchain ledgers can be seen as the modern “manuscript” — immutable, distributed across countless nodes, resisting censorship or alteration.</p><p>Just as Bulgakov’s manuscripts held the power to challenge oppressive regimes and convey immutable truths, smart contract code embodies the resilience of innovation against attempts to curtail its potential.</p><p>Code, like manuscripts, carries ideas that cannot be unthought, offering new ways of organizing society and finance that persist beyond the attempts to regulate or suppress them.</p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity ^0.8.0;<br><br>contract Manuscript {<br>    function stateTruth() public pure returns (string memory) {<br>        return &quot;Manuscripts don&#39;t burn&quot;;<br>    }<br>}</pre><p>The parallel between Bulgakov’s manuscripts and today’s blockchain tech-stack underscores a timeless struggle between innovation and authority, between the courage to uphold one’s ideals and the cowardice of concession.</p><p>This dynamic is further illuminated by the frequent inquiries I receive about the legality of the code I write. It’s puzzling and somewhat disheartening that the initial reaction of some is to question its legality. Code is merely text on a screen, compiled into bytecode — how can the first concern be its legality?</p><p>This reflex perhaps reveals a deeper societal apprehension towards innovation, an instinctive tendency to confine new ideas within the rigid frameworks of existing laws and norms, rather than exploring their potential to reshape society for the better.</p><p>The enduring message of “The Master and Margarita” reminds us that true innovation — whether in the form of literary masterpieces or groundbreaking technology — possesses an inherent resilience. It challenges us to consider the value of steadfastness in the pursuit of change, and the role of integrity in the face of adversity.</p><p>As we navigate the complexities of the modern financial revolution, the Devil’s assertion that “manuscripts don’t burn” shines as a guiding light, stating that despite ideas being disputed, suppressed, or even vilified, they persist as unerasable and powerful agents of change, much like smart contracts and the underlying code of blockchain technology.</p><p>If you enjoyed this article, please like and share it.</p><p>You can follow the “fireproof” code that I write by following me on GitHub: <a href="https://github.com/partylikeits1983">https://github.com/partylikeits1983</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=107879709632" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Proof of Concept Automated Market Maker in Solidity]]></title>
            <link>https://alexanderjohnlee.medium.com/building-a-proof-of-concept-automated-market-maker-in-solidity-8503cac82b17?source=rss-561e038a8df3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8503cac82b17</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[uniswap]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[defi]]></category>
            <dc:creator><![CDATA[Alexander John Lee]]></dc:creator>
            <pubDate>Wed, 11 Jan 2023 08:38:02 GMT</pubDate>
            <atom:updated>2023-01-11T08:38:02.600Z</atom:updated>
            <content:encoded><![CDATA[<h4>An introduction to building a decentralized exchange</h4><p>Decentralized exchanges such as Uniswap, Curve, GMX, and dYdX, have revolutionized the way people exchange assets.</p><p>There are two main approaches to building a decentralized asset exchange:</p><p>The first approach is to follow the principle of a constant product automated market maker.</p><p>Constant product automated market makers use the constant product formula to calculate how much of one asset to exchange for another. They are called <em>“constant product”</em> exchanges because the exchange rates of assets are determined by following a constant product rule. The simplest constant product rule is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/122/1*AJ0oM49kA7vSznJbjP9cNg.png" /></figure><p>where<em> </em><strong><em>x</em></strong> is the amount of token x, <strong><em>y</em></strong> is the amount of token y, and <strong><em>k</em></strong> is a constant.</p><p>They are called <em>“automated market makers”</em> because users who provide liquidity function as <a href="https://en.wikipedia.org/wiki/Market_maker">market makers</a>, by buying and selling within a certain price range. Although they follow different architectures, Uniswap and Curve are both examples of constant product automated market makers. One of the main benefits of constant product exchanges is that users can exchange different assets without the need of finding a counterparty.</p><p>Let’s go back to the second approach. The second approach is to follow the principle of a decentralized limit order book. Given this architecture, users write to the state of the smart contract on the blockchain, then a server off-chain matches the buy order of one user to the sell order of another user. GMX and dYdX are two examples of decentralized exchanges that follow this principle.</p><h4>Building a Constant Product Automated Market Maker Exchange</h4><p>At their core, constant product exchanges use a mathematical formula in order to calculate how much of an asset to send to a user, given the input of another asset.</p><p>For this example, we will be building the simplest constant product exchange possible. By doing so, you will better understand the limitations of the constant product formula <strong><em>x * y = k </em></strong>and better appreciate the technical feats of projects such as Uniswap V3 and Curve.</p><p>Firstly, how do you calculate how much of token y to give in exchange for token x using the constant product formula?</p><p><strong>Using the formula:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/122/1*AJ0oM49kA7vSznJbjP9cNg.png" /></figure><p><em>All we are saying with this formula is amount of token x multiplied by amount of token y is equal to some constant k.</em></p><p><strong>We can create the following formula:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*luPpK5-bFcFCDWc2dEWaVw.png" /></figure><p><em>Essentially we are saying that: amount of token x plus some increment dx, multiplied by amount of token y plus some increment dy, is equal to some constant k.</em></p><p><strong>Using the formula above, we can deduce that <em>dy</em>:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/207/1*sTJ6i5EvUJaWap9j6DsaYg.png" /></figure><p><em>The function above tells us how much of token y we will give for a certain increment (dx) of token x.</em></p><p><strong>Let’s say we have the following scenario:</strong></p><p>A user, Bob, comes along and they want to give us 1 of token X in exchange for some amount of token Y. In our smart contract, we have 5 tokens X in our contract and 10 tokens Y in our contract (x = 5, y = 10).</p><p>This is how we calculate the amount of tokens Y to give to our user Bob in our smart contact:</p><pre>uint amountOutY = (amountInX * amountY) / (amountInX + amountX);</pre><p><em>We omit the negative sign in our code since we will be sending amountOutY to Bob.</em></p><p>Knowing the following, we can calculate how much of token Y to send to our user, Bob.</p><pre>amountInX = 1<br>amountY = 10<br>amountX = 5<br><br>amountOutY = (1 * 10) / (1 + 5)<br>amountOutY = 1.66</pre><p>Bob sends 1 of token X and gets 1.66 of token Y in return. For Bob, this is fine, but not ideal since he experienced a slippage of <em>17%.</em></p><p><em>slippage = (Expected Entry Price — Actual Execution Price) / Expected Entry Price</em></p><p><em>slippage = (2–1.66) / 2</em></p><p>Now our smart contract has a total of 6 of tokens X and 8.33 tokens Y, meaning that the new exchange rate of token X to token Y is 1.38. Bob’s trade pushed the exchange rate of token X to token Y down from 2 to 1.38, a price drop of 31% for token X.</p><p><strong>Let’s take another example:</strong></p><p>Another user, Alice, wants to exchange 100 tokens X for some amount of token Y. Our smart contract contains 100,000 tokens X and 50,000 tokens Y. The current exchange rate is 0.5 tokens X for 1 token Y.</p><p>Swapping 100 tokens X yields Alice 49.95 of tokens Y. Alice experiences a slippage of less than 0.01%. Not bad for Alice. However, this is only because the size of Alice’s trade was small compared to the value deposited in the pool. The new exchange rate is 0.499 tokens X for 1 token Y.</p><h4>Constant Product Function Visualized</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J9SJzUZDl0vlRsKRcNgsVA.png" /></figure><p>The chart above is a visualization of the constant product function that we implemented in our smart contract. As you can see, a larger change in token X results in a larger change in token Y, and vice versa.</p><p>The exchange rate in an a constant product function exchange is the ratio of tokens X to tokens Y.</p><h4>Testing Our Solidity Smart Contract</h4><p>To follow along, clone the simpleAMM repository from <a href="https://github.com/partylikeits1983">my GitHub</a>:</p><p><a href="https://github.com/partylikeits1983/simpleAMM">GitHub - partylikeits1983/simpleAMM: AMM proof of concept</a></p><p>To run the tests you will need to have foundry installed. You can install it here: <a href="https://github.com/foundry-rs/foundry">https://github.com/foundry-rs/foundry</a></p><p>After installing foundry and cloning the simpleAMM repository, you run the tests by typing:</p><pre>forge test -vv</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*0EumJJ-32wzi5O9HcvfBgg.png" /><figcaption>Tests on Foundry are blazingly fast…</figcaption></figure><h4><strong>Impermanent Loss and Limitations of Constant Product Exchanges</strong></h4><p>Users who decide to serve as market makers by providing liquidity to a constant product exchange are exposed to what is known as impermanent loss.</p><p>Exposure to impermanent loss increases as the price of the asset at the time of deposit deviates from the current market price. Impermanent loss is only “<em>impermanent</em>” if the price of the asset at the time of withdrawal is equal to the price of the asset at the time of deposit. Impermanent loss is very “permanent” if the asset price at time of deposit deviates from the asset price at the time of withdrawal.</p><p>However, liquidity providers are incentivized to provide liquidity as they earn fees from the percentage of volume exchanged in the asset pair. In many ways, providing liquidity to a constant product exchange can be seen as a way of shorting volatility. If a trader expects low volatility of an asset pair in a given period, they can deposit their liquidity to a constant product exchange, and in return earn fees from the volume.</p><p>The constant product automated market maker that we built is very similar in design to Uniswap V2 since it follows the same constant product function.</p><p>One of the biggest disadvantages of Uniswap V2 is the amount of slippage experienced when exchanging assets. Uniswap V3 allows liquidity providers to select a price range in which they will function as a market maker. This feature has the added benefit of significantly decreasing slippage even on larger trades.</p><p><strong>Concentrated Liquidity on Uniswap V3</strong></p><p>Concentrated liquidity on Uniswap V3 leads to an interesting and <a href="https://arxiv.org/pdf/2106.12033.pdf">very complicated math problem</a> for liquidity providers. The smaller the price range a liquidity provider sets for a given asset pair leads to the liquidity provider earning more fees. However, the tighter the price range of a liquidity position, the more the position is exposed to potential impermanent loss.</p><p>On the surface this seems to be a classic machine learning optimization problem. However, this problem becomes more complex when you factor in the liquidity depth at each <a href="https://docs.uniswap.org/contracts/v3/reference/core/libraries/Tick">price tick</a> in the Uniswap V3 smart contract. Additionally, it is challenging to parse historical data on liquidity depth and range per asset for different EVM chains. This problem is currently considered the cutting edge of defi research, and solving it would result in a trading strategy worth millions.</p><h4><strong>Conclusion</strong></h4><p>Constant product automated market maker exchanges have revolutionized the world of decentralized finance. In 2022, decentralized exchanges processed <a href="https://dune.com/hagaetc/dex-metrics">$788 billion in volume</a> and had over <a href="https://dune.com/queries/14138/28323">5.7 million users</a>.</p><p>Although these novel exchanges still process a fraction of the volume of traditional centralized exchanges, they have proven themselves to be the cornerstone of the decentralized finance world.</p><p>I look forward to seeing future innovations of decentralized exchanges and how software engineers and researchers tackle new challenges such as mitigating impermanent loss.</p><p><em>What do you think about decentralized exchanges? Are they cutting-edge technology that will bring financial sovereignty to their users, or gen-z’s version of a snake oil salesman pyramid scheme?</em></p><p><em>If you liked this article, be sure to share it!</em></p><h4><strong>Cool and Useful Links:</strong></h4><p>Dune Analytics DEX Metrics: <a href="https://dune.com/hagaetc/dex-metrics">https://dune.com/hagaetc/dex-metrics</a></p><p>Uniswap Analytics: <a href="https://info.uniswap.org/#/">https://info.uniswap.org/</a></p><p>Uniswap V3 Fee Calculator: <a href="https://uniswap.fish/?network=ethereum">https://uniswap.fish/?network=ethereum</a></p><p>Impermanent Loss Desmos Calculator: <a href="https://www.desmos.com/calculator/i8h0wzqaci">https://www.desmos.com/calculator/i8h0wzqaci</a></p><p>Strategic Liquidity Provision in Uniswap v3: <a href="https://arxiv.org/pdf/2106.12033.pdf">https://arxiv.org/pdf/2106.12033.pdf</a></p><p><em>Note to reader: The code snippets in this article were labeled as being javascript since medium still doesn’t have solidity as a display option.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8503cac82b17" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NFT Marketplaces: decentralized creativity or 1990s e-commerce?]]></title>
            <link>https://medium.com/crypto-investment-insights-from-br-capital/nft-marketplaces-decentralized-creativity-or-1990s-e-commerce-27fe224b9eaa?source=rss-561e038a8df3------2</link>
            <guid isPermaLink="false">https://medium.com/p/27fe224b9eaa</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[nft]]></category>
            <category><![CDATA[solidity]]></category>
            <dc:creator><![CDATA[Alexander John Lee]]></dc:creator>
            <pubDate>Mon, 23 Aug 2021 10:00:23 GMT</pubDate>
            <atom:updated>2021-08-23T10:04:23.472Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SpiIkNG6MCV0asT1tr57Dg.jpeg" /><figcaption>How I feel when browsing NFTs on Foundation.</figcaption></figure><h3>If NFTs are such a revolution, why are artists still paying 15% commission?</h3><p><strong><em>Update: The NFT artist we originally interviewed for this article felt that our criticism of high NFT commissions might cause problems with admins at the marketplace where they sell their work. We temporarily removed and then re-published this redacted version of the article in order to protect the anonymity of the artist and avoid potential financial repercussions. (And yes, in a truly decentralized marketplace, such worries should not exist.)</em></strong></p><p>NFTs are supposed to represent a revolution for artists and collectors, but the marketplaces which sell these NFTs rarely seem revolutionary at all.</p><p>That’s probably because most NFT marketplaces follow the same ol’ Web2.0 business model: centralized platforms that charge sellers a high commission in return for bringing traffic to their product listings, while the platform also extracts value in the form of customer and transaction data, giving it a privileged role in the marketplace.</p><p>Considering that the code to mint an NFT and bring it to life as a transferable asset on a blockchain is very simple, it makes you ask the question: <em>“Why is the artist sacrificing their profit for this?”</em></p><h3>The reality of NFT commissions</h3><p>Edward Snowden recently sold an NFT on Foundation named <a href="https://foundation.app/@Snowden/stay-free-edward-snowden-2021-24437">“Stay Free (Edward Snowden, 2021)”</a> for 2,224ETH. However, since Foundation charges a whopping 15% commission, Edward Snowden could have been 15% “freer” had he chosen a different NFT marketplace.</p><p>Why is it that technologies like NFTs can do away with the “middleman” in terms of trust (e.g., proof of authenticity), but not in terms of commerce? Why does there still need to be an agent of some sort to connect buyer and seller? And why does this agent need to be so expensive?</p><p>I recently had the opportunity to discuss these things with a successful NFT artist. (They’d rather not be named, so I’ll refer to them s “the artist” or “my contact.”) This person got started in the blockchain space after experiencing the inefficiencies of our current global financial system. When working remotely and billing their clients, the artist discovered that it was easier to transfer Bitcoin internationally than through a traditional bank wire.</p><p>It was a natural next step for the artist to sell their work using NFTs directly on the blockchain. Early efforts to sell artwork on SuperRare failed because admins there did not approve the submissions. However, the artist was eventually accepted at a different marketplace that charged 15%, after submitting work under a pseudonym. Though high compared to some other NFT marketplaces, 15% seemed like a fair commission when compared to traditional brick and mortar art galleries that would charge up to 50%.</p><h3>The ideal marketplace</h3><p>After interviewing the artist, it became clear that money isn’t their primary consideration. They told me:</p><blockquote>“<strong>The ideal marketplace is one that is open to all artists”</strong></blockquote><p>This comment made me look at the NFT landscape in a different light. Just when the dominant business model of major NFTs marketplaces like Foundation, SuperRare, and Rarible was starting to feel a bit 1990s, I realized that some NFT marketplaces are doing things right — or at least <em>more right</em> — than others.</p><p>Here are the top three examples I could find:</p><h3>1. Zora, the zero-commission option</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*PhMKQq9oVyas6scq1jfZxg.jpeg" /></figure><p><a href="https://zora.co/">Zora</a> is an NFT marketplace with a clean UI, where users can create, bid on, and sell NFTs. What makes Zora great is that there are no fees associated with selling your NFTs, because the Zora protocol effectively creates a unique market for each work, allowing the artist to take market commissions from onward sales. The only cost required to post your media on Zora is the gas fee.</p><p>When comparing Zora’s NFT and marketplace smart contracts to those of other NFT marketplaces, it becomes clear that Zora’s smart contracts practically have no administrative privileges written into them. Most other NFT marketplaces have smart contracts with significant administrative privileges that could potentially cause a loss of value for users of those platforms.</p><p>Additionally, the Zora NFT smart contract also allows owners of NFTs to update the IPFS link of the NFTs that they own. This means that if the IPFS link of your NFT were to fail or get corrupted, your NFT would not become worthless.</p><p>Now you might be wondering, what if the owner of the NFT decides to edit or completely change the IPFS link that is written into the NFT? Don’t worry, the devs at Zora already thought of this.</p><p>The owner of an NFT can’t change the IPFS link from the original artwork to something else without it being obvious. This is because a <a href="https://en.wikipedia.org/wiki/Cryptographic_hash_function">cryptographic hash</a> of the initial file uploaded to IPFS is written into the NFT itself. If the IPFS link were to fail, and if the file that the owner of the NFT uploads to IPFS doesn’t exactly match the original, the cryptographic hash will be completely different, signalling that the re-uploaded work does not match the original.</p><p>This is a big deal because other NFT marketplace smart contracts do not have such functionality built-in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VZFbul5ECiQH_G1nn-zULQ.png" /><figcaption>Cryptographic hash functions are the backbone of all blockchains and are used in <a href="https://github.com/ourzora/zdk/blob/master/docs/utils.md">Zora’s protocol</a>.</figcaption></figure><p>Currently, the only issue with selling your NFTs on Zora is that there is not as much volume as there is on other platforms. However, this is bound to change. Zora is the only truly Web3.0 NFT marketplace on the list. If you want to be free from the <em>predatory economic practices</em> that other NFT marketplaces use to keep users locked into their platforms, Zora is the answer.</p><p>Zora’s codebase is completely open-source: <a href="https://github.com/ourzora">https://github.com/ourzora</a></p><p><strong>Fees: 0%</strong></p><p><a href="https://etherscan.io/address/0xabEFBc9fD2F806065b4f3C237d4b59D9A97Bcac7#readContract"><strong>Zora NFT Smart Contract</strong></a><strong> on Etherscan.io</strong></p><p><a href="https://etherscan.io/address/0xE5BFAB544ecA83849c53464F85B7164375Bdaac1#readContract"><strong>Zora Market Smart Contract</strong></a><strong> on Etherscan.io</strong></p><p><a href="https://docs.zora.co/zoraos/dev/smart-contracts"><strong>All Zora smart contracts</strong></a><strong> on testnets and Polygon</strong></p><h3>2. Hic et Nunc, the avant-garde alternative</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*uuUXKe_h0pTT65Uj9VnbMQ.jpeg" /></figure><p><a href="https://www.hicetnunc.xyz/">Hic et Nunc</a> (meaning “Here and Now” in Latin) is an NFT marketplace built on the Tezos blockchain. Gas fees for deploying an NFT on Hic et Nunc are much lower than on the Ethereum blockchain — as little as a few cents. The commission is also much lower, at just 2.5% paid by the buyer.</p><p>Although Hic et Nunc has less traffic than Foundation, it is strongly recommended by my anonymous contact (who also sells his work there) as there is a diverse and active artist community on the platform. This is partly because there are no gatekeepers to accept or reject submissions, and artists can stay anonymous if they wish — a sign of greater acceptance of the philosophy of decentralization.</p><p>However, given that the market capitalization of the Ethereum blockchain is currently 100x larger than the market capitalization of the Tezos blockchain, this means that NFTs minted on the Ethereum blockchain are simply more liquid.</p><p><a href="https://medium.com/r?url=https%3A%2F%2Fmatheussiq8.medium.com%2Fhic-et-nunc-the-story-facts-suppositions-and-ideas-june-2021-19927f9106ad"><strong><em>Excellent Medium article to learn more about Hic et Nunc</em></strong></a></p><p><strong>Fees: 2.5% paid by buyer</strong></p><h3>3. OpenSea, the mainstream option that deserves its name</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*R-gkhml65JpeB2VF0Sga1Q.png" /></figure><p><a href="https://opensea.io/">OpenSea</a> is currently the largest NFT marketplace by active users. Founded in December 2017, OpenSea is the most established NFT marketplace.</p><p>What’s unique about OpenSea compared to other NFT marketplaces is that if you have your own ERC721 smart contract (i.e., one you deployed yourself), you can use OpenSea’s storefront and auction smart contract to sell the NFTs to a large audience. This is probably why you see NFTs created using other NFT marketplace smart contracts for sale on OpenSea because sellers are trying to avoid paying the high fees of those other marketplaces.</p><p>For each sale, OpenSea charges 2.5%, however, the fact that they allow users to use their own ERC721 smart contracts means users can have more control over their NFTs.</p><p><strong>Fees: 2.5% (from buyer or seller)</strong></p><p><a href="https://etherscan.io/address/0x7be8076f4ea4a4ad08075c2508e481d6c946d12b#readContract"><strong>OpenSea Smart Contract</strong></a><strong> on Etherscan.io</strong></p><p><a href="https://etherscan.io/address/0x7be8076f4ea4a4ad08075c2508e481d6c946d12b#analytics"><strong>OpenSea Transaction Volume</strong></a><strong> on Etherscan.io</strong></p><h3>What’s next for NFT marketplaces?</h3><p>A future in which artists both mint and sell<em> </em>their own NFTs, by dealing directly with the blockchain to sell in a truly p2p fashion, is still probably some way off <em>(although Zora is pretty darn close)</em>. Although it’s not technically difficult to deploy your own ERC-721 smart contract, which would protect an artist from future marketplace policy changes (including changes in fees), it’s currently too difficult to find an audience that way — unless perhaps you’re already famous in the NFT world.</p><p>In the meantime, most artists will continue to use some form of marketplace, and competition among those marketplaces will heat up. Sites that feel too Web2.0 today, like Foundation and Rarible, will have to evolve to survive.</p><p>Interestingly, SuperRare has recently introduced more <a href="https://fadmagazine.com/2021/08/19/superrare-goes-full-on-for-community-in-superrare-2-0/">decentralized art curation</a> through its RARE governance token, which is a step in the right direction and a sign that marketplaces are beginning to react to the shift in expectations. But even SuperRare still a long way away from its own stated objective of becoming a truly decentralized organisation (DAO).</p><p>Ultimately, unless there’s some compelling reason to stay (e.g. a uniquely large audience or amazing curation), users will simply drift to more decentralized options that offer low or zero fees, like the examples I listed above. Indeed, this drift is already starting to happen.</p><p>If you want to see how to deploy your own ERC-721 NFT smart contract on the Ethereum blockchain, head on over to my <a href="https://github.com/partylikeits1983/ERC-721">Github</a>!</p><p>If you enjoyed this article please subscribe to Crypto Insights by BR Capital.</p><p><em>What do you think about the NFT space and what do you think it says about an NFT marketplace such as Foundation if an artist is afraid to be associated with criticism of their platform?</em></p><p><em>Feel free to leave your thoughts below! Don’t worry, we won’t censor you :)</em></p><p><a href="https://medium.com/crypto-investment-insights-from-br-capital?source=post_sidebar--------------------------post_sidebar-----------">Crypto insights from BR Capital</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27fe224b9eaa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/crypto-investment-insights-from-br-capital/nft-marketplaces-decentralized-creativity-or-1990s-e-commerce-27fe224b9eaa">NFT Marketplaces: decentralized creativity or 1990s e-commerce?</a> was originally published in <a href="https://medium.com/crypto-investment-insights-from-br-capital">Crypto insights from BR Capital</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bitcoin is too volatile, but that’s the price of it being open and fair]]></title>
            <link>https://medium.com/crypto-investment-insights-from-br-capital/bitcoin-is-too-volatile-but-the-alternative-is-worse-bc946df491f7?source=rss-561e038a8df3------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc946df491f7</guid>
            <category><![CDATA[leverage]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[volatility]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Alexander John Lee]]></dc:creator>
            <pubDate>Thu, 22 Jul 2021 16:11:37 GMT</pubDate>
            <atom:updated>2021-07-22T17:16:05.866Z</atom:updated>
            <content:encoded><![CDATA[<p>The recent BTC price drops, though huge and highly publicized, are nothing new in the history of bitcoin.</p><p>Looking at the past 5 years of price data for bitcoin, you can see that price has remained quite volatile despite growing several orders of magnitude in market capitalization over the same period.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J8posZHssc3DO-FlSyIWww.jpeg" /><figcaption><a href="https://colab.research.google.com/drive/1-ut-AmKUP4nZeBygGz-uvZjRQBcRFmjF?usp=sharing"><em>Google Colab link to charts</em></a></figcaption></figure><p>It’s interesting to read old Quora and Reddit threads from 2014–2017, where many observers said they expected volatility to reduce as bitcoin market cap and daily trading volume grew. This expectation was logical, yet it hasn’t transpired — why not? And does continuing volatility reveal a flaw in bitcoin itself?</p><p>To answer this question, let’s look at a quick comparison of volatility in the regular stock market.</p><h4><strong>An antiquated model for controlling volatility</strong></h4><p>In traditional markets, regulators spend a vast amount of time, money, and energy limiting the amount of volatility. This is for good reason, as large price swings can destroy the portfolios of everyday investors (which is<em> </em>bad for<em> all participants </em>in the long term).</p><p>On the NYSE, circuit breakers can be triggered after a 7%, 13%, or 20% intraday move. However, these circuit breakers are more often than not triggered when the price moves to the downside <em>(or on the upside when a large wall street institution is stuck in a short squeeze).</em></p><p><a href="https://www.nyse.com/publicdocs/nyse/NYSE_MWCB_FAQ.pdf"><em>NYSE Circuit Breakers</em></a><em>:</em></p><p><em>Level 1 halt (7%)</em></p><ul><li><em>Trading will halt for 15 minutes if drop occurs before 3:25 p.m.</em></li><li><em>At or after 3:25 p.m. — trading shall continue, unless there is a Level 3 halt.</em></li></ul><p><em>Level 2 halt (13%)</em></p><ul><li><em>Trading will halt for 15 minutes if drop occurs before 3:25 p.m.</em></li><li><em>At or after 3:25 p.m. — trading shall continue, unless there is a Level 3 halt.</em></li></ul><p><em>Level 3 halt (20%)</em></p><ul><li><em>At any time during the trading day — trading shall halt for the remainder of the trading day.</em></li></ul><p>NYSE trade halts historical data can be found <a href="https://www.nyse.com/trade-halt-historical">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P6mB2ry-9ypc2FQ0kFAhSg.jpeg" /><figcaption>If Bitcoin were traded on the NYSE, a circuit breaker would be triggered each time the daily percent change is &lt;= -7% (the red line on the chart), i.e., many times per year.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rjH5MdZGDGPH60cmZlMTDQ.jpeg" /><figcaption>Here’s the same chart for the S&amp;P500 for comparison. Circuit breakers were triggered on March 9th and March 12th, 2020.</figcaption></figure><p>Looking at the red line, the S&amp;P500 is a much safer place to be than bitcoin, right?</p><p>Well, maybe and maybe not.</p><h4><strong>A cost of stability is a lack of fairness</strong></h4><p>Most of the methods of controlling price volatility employed by traditional exchanges are not necessarily there to protect individual investors as much as institutional investors. The arbitrary focus on 3.25pm as a cut-off point (very convenient for American participants who’ve come back from their lunch break) gives a hint of this, but the recent Gamestop saga provides a more detailed illustration.</p><p>On January 22, Robinhood froze Gamestop (<a href="https://www.tradingview.com/symbols/NYSE-GME/">GME</a>) stock purchases on their platform and then later limited the amount of shares users could buy. AMC Entertainment (<a href="https://www.tradingview.com/symbols/NYSE-AMC/">AMC</a>), BlackBerry (<a href="https://www.tradingview.com/symbols/NYSE-BB/">BB</a>) Nokia (<a href="https://www.tradingview.com/symbols/NYSE-NOK/">NOK</a>), and several other stocks that were part of the Wall Street Bets short squeeze were also affected.</p><p>At one point Robinhood only allowed investors to sell their stock in Gamestop and limited purchases to one share per user. Quite a strange thing to do for a company that claims to enable “investing for all”.</p><p>Apparently lofty claims about democratizing investing don’t apply when Robinhood’s largest customer, Melvin Capital, is stuck in a short position in GME during a short squeeze, such that any large purchasing of GME shares would make its situation worse.</p><p>The Gamestop story is just one illustration of how investing in traditional markets is broken for individual or non-pro traders. There’s simply too much arbitrary regulation, too many middlemen, and far from enough decentralization.</p><p>If this is what volatility control looks like, <em>then we do not want it</em>.</p><p>(Note: I’m deliberately not covering stablecoins in this article, the most mainstream of which — USDT and USDC — only achieve stability at the cost of relying on centralized and off-chain collateralization to a fiat currency that is itself centralized and off-chain, which is totally different to how bitcoin works.)</p><h4><strong>A cost of freedom is easy access to excessive leverage</strong></h4><p>Although also imperfect and guided by incentives that do not align with those of private investors, centralized cryptocurrency exchanges are a step in the right direction towards leveling the playing field between everyday investors and large financial institutions — simply due to the fact that they’re trading in cryptocurrencies rather than fiat ones.</p><p>What makes centralized cryptocurrency exchanges great is that they are generally open 24/7, have relatively low fees, and thanks to the decentralized nature of cryptocurrencies, no one can halt the trading of a cryptocurrency. Implementing a circuit breaker on a cryptocurrency exchange would go against the financial incentives of the exchange, and would potentially open up arbitrage opportunities for traders on other exchanges.</p><p>On the other hand, cryptocurrency exchanges do play a role in amplifying or increasing volatility — perhaps artificially — and this is because of margin trading (aka, leveraged trading, or placing bets with borrowed money).</p><p>The issue of margin trading is core to cryptocurrencies themselves, as it connects back to their lack of supervision. And it begs the question: <em>is excessive volatility due to bitcoin users straying from the principles which led to the creation of bitcoin in the first place?</em></p><h4><strong>What would Satoshi think of all this hyper-leveraged trading?</strong></h4><p>In Bitcoin’s genesis block, Satoshi encoded a message that references <em>The Times</em> article, <a href="https://www.thetimes.co.uk/article/chancellor-alistair-darling-on-brink-of-second-bailout-for-banks-n9l382mn62h">Chancellor on brink of second bailout for banks</a>.</p><p>The financial crisis of 2007–08 was exacerbated by <a href="https://hbr.org/2009/09/lessons-from-lehman.html">too much leverage in the banking sector</a>. When a correction came, triggered by bad financial derivatives based on sub-prime mortgages, over-leverage created a domino effect that turned this correction into a crash. Many banks failed, while others received vast government bailouts. Ordinary people are still paying the price for this today.</p><p>It was from the depths of the 2008 financial crisis that the first blockchain-based digital currency, bitcoin, was born. At its core, bitcoin was designed to act as a fairer alternative to fiat currency in which ordinary people’s wealth could be better protected from processes outside of their control — hence that embedded historical reference to the bailout.</p><p>An excellent tweet by Naval:</p><h3>Naval on Twitter: &quot;Bitcoin is a tool for freeing humanity from oligarchs and tyrants, dressed up as a get-rich-quick scheme. / Twitter&quot;</h3><p>Bitcoin is a tool for freeing humanity from oligarchs and tyrants, dressed up as a get-rich-quick scheme.</p><p>Centralized cryptocurrency exchanges have capitalized on the idea of cryptocurrencies as a “get rich quick” scheme by allowing investors to maximize their profits <em>(or losses) </em>by trading on margin — in other words, doing exactly what the banks did in the run-up to the financial crisis.</p><p>This of course overlooks the more long term (and safer) reason for investing via crypto exchanges, which is to use your spare capital support blockchain projects you think will do well and grow in value.</p><p>Some centralized exchanges allow users to trade up to 75X, 100X, and even 125X margin. This is almost begging for a cycle of boom and bust, because leveraged trading, especially coming from the retail side, accentuates price volatility in cryptocurrency markets.</p><p>The recent large price drop of bitcoin wasn’t necessarily the fault of Elon Musk saying that Tesla would stop taking Bitcoin as a form of payment, or the news of China cracking down on cryptocurrencies, but the two events were instead the first set of dominoes to set off a mass liquidation event of investors trading on highly leveraged positions.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FxqcxzxMK9UM6Y%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fphysics-domino-dominos-xqcxzxMK9UM6Y&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2FxqcxzxMK9UM6Y%2F200.gif%3Fcid%3D790b76119ada3cc1607e38e512c64de2a9f7bacf34c746eb%26rid%3D200.gif%26ct%3Dg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="245" frameborder="0" scrolling="no"><a href="https://medium.com/media/05b4e3645446ae9a58b22359fb893932/href">https://medium.com/media/05b4e3645446ae9a58b22359fb893932/href</a></iframe><p>Remember, for centralized exchanges, large liquidation events are when they make the most profit. This warped system of incentives is one mechanism that drives large price movements in cryptocurrency markets. These large price movements can hurt not only those risk-taking margin traders but also regular HODLers who never used leveraged positions. Not very fair, right? On the other hand, without all the margin trading, the bitcoin price might not have risen so high in the first place.</p><h4><strong>We have to learn to live with volatility, because it comes from us</strong></h4><p><em>The upshot: </em>Volatility in cryptocurrencies can be seen as intrinsic to the space, as it reflects the absence of the controls and arbitrary rules that make traditional investing so unfair. At its best, volatility is <em>useful </em>for at least some crypto users — otherwise everyone would have switched to stable coins instead. At its worst, volatility is an unfortunate byproduct of over-leveraged trading and therefore a price we must all pay to be free of government monetary control.</p><p>It’s ironic that a community that so often criticizes the traditional financial industry for not being able to use leverage responsibly is similarly unable to show restraint. Clearly, this is something that stems more from human nature rather than from any fundamental problem with traditional markets, and bitcoin is certainly no antidote to it.</p><p>At BR Capital and our trading arm T-Digital, we use leveraged positions as a matter of course. *However,* we have a team of &gt;30 people, backed by machine learning and other algorithms, who are constantly working towards getting the correct balance of maximizing returns while managing risk (and there is plenty of risk). The idea of retail investors making highly leveraged bets without this support is something we find quite scary. This is one reason why we’re investing in derivatives exchanges, such as <a href="https://www.delta.exchange/">Delta Exchange</a>, that can help all crypto users to better insure themselves against volatility.</p><p>If you enjoyed this article please subscribe to Crypto Insights by BR Capital.</p><p><em>What do you think about the role of centralized exchanges and margin trading in price volatility? Feel free to leave your thoughts below.</em></p><p><em>All charts in this article can be found </em><a href="https://colab.research.google.com/drive/1-ut-AmKUP4nZeBygGz-uvZjRQBcRFmjF?usp=sharing"><em>here</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc946df491f7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/crypto-investment-insights-from-br-capital/bitcoin-is-too-volatile-but-the-alternative-is-worse-bc946df491f7">Bitcoin is too volatile, but that’s the price of it being open and fair</a> was originally published in <a href="https://medium.com/crypto-investment-insights-from-br-capital">Crypto insights from BR Capital</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Decentralized Autonomous Organizations (DAOs) Will Transform The Way People Invest]]></title>
            <link>https://medium.com/crypto-investment-insights-from-br-capital/why-decentralized-autonomous-organizations-daos-will-transform-the-way-people-invest-13bf869450d2?source=rss-561e038a8df3------2</link>
            <guid isPermaLink="false">https://medium.com/p/13bf869450d2</guid>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[decentralized-finance]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Alexander John Lee]]></dc:creator>
            <pubDate>Thu, 27 May 2021 15:32:10 GMT</pubDate>
            <atom:updated>2021-05-27T19:35:21.973Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XMATGlTv-6cGH3JiITdR5Q.png" /><figcaption>This is not what the future of finance looks like.</figcaption></figure><p>We are entering an era where all capital will be able to move throughout the global economy with far fewer barriers or restrictions. However, blockchain technology has many more use cases than simply providing an efficient means of capital transfer.</p><p>The purpose of this article is to highlight one of those “other” use cases of blockchain: The ability to create and deploy smart contracts (self-executing chunks of code) that cement and execute agreements made between individuals, allowing them to cooperate around investing in new ways. To better understand how this could change the financial landscape, let’s take a look at a few examples.</p><p>Berkshire Hathaway is one of the most famous traditional investment funds, with over $270 billion worth of assets under management (AUM). Berkshire Hathaway owns outright GEICO, Duracell, NetJets, and an entire list of other companies. For the most part, there isn’t a company that Berkshire Hathaway could not buy outright if they wanted to<em> (they might have to liquidate a portion of their assets, but you get what I’m saying)</em>.</p><p>However the same cannot be said for the average private investor.</p><p>This is how decentralized autonomous organizations (DAOs) can fundamentally change the financial industry.</p><p><strong><em>Wait, so what is a DAO?</em></strong></p><p>A DAO is essentially a framework of smart contracts on the blockchain designed to facilitate the decision-making of a group by executing a predetermined function once a certain set of criteria have been met.</p><p>There are many other use cases of DAOs that have nothing to do with the financial world, but that is a topic for another article.</p><p>DAOs can function as hedge funds or venture capital funds, making investments or providing liquidity to tech startups. Eventually, DAOs could have more AUM than even the largest hedge funds and will be able to find promising tech startups faster than any venture capital fund could.</p><p><strong><em>Why will DAOs take over the financial industry?</em></strong></p><ol><li>They are <em>permissionless</em>.</li></ol><p>This means anyone can create a DAO and deploy its smart contract code to the blockchain. There is almost no barrier to creating a DAO. All you need is an internet connection, and enough ether (or other protocol currency) to pay for the gas fees to deploy it.</p><p>2. They are <em>trustless</em>.</p><p>This means that once set up and running on the blockchain, a DAO will execute a predefined function once certain criteria are met, without outside intervention.</p><p>Since smart contract state and any information stored in the blockchain is visible to all observers outside of the blockchain, individuals can get a good sense of how the deployed smart contract will function, even if they do not have access to the solidity source code itself.</p><p>3. DAOs are <em>fundamentally more efficient</em>.</p><p>The members of a DAO don’t have to even know each other, live in the same country, operate under the same legal jurisdiction, or even speak the same language. This means that the members of the DAO as a whole have greater access to information than any traditional hedge fund, operate with greater autonomy from legal regulation, and can look for investment opportunities where traditional funds wouldn’t even know where to look.</p><p>Although skeptical of democracy, even Aristotle acknowledged that “the whole is greater than the sum of its parts”. Philosophers in subsequent eras have also to some extent agreed that the many turn out to be greater than the virtuous few when they come together, even if the many may be inferior when considered individually. A well-known theory in political science that addresses this phenomenon is Condorcet’s <a href="https://en.wikipedia.org/wiki/Condorcet%27s_jury_theorem">jury theorem</a>.</p><p>This is why members of a DAO can potentially make better investment decisions than if they would have invested their funds individually.</p><p>Additionally, members of a DAO can pool their funds together and can make investments that they would not have been able to otherwise.</p><p>We sort of saw this occur on the subreddit, <a href="https://www.reddit.com/r/wallstreetbets/">Wall Street Bets</a>, albeit with the participants of the group coordinating their investment decisions in unison as a sort of proto-DAO, not as an actual on-chain DAO.</p><p>Less well-known, but just as important, are the examples of great DAOs that are increasingly moving towards on-chain governance: The LAO, Flamingo, MetaCartel, Badger DAO, and more. No longer far-flung ideas, these DAOs are now sought after investors — we know of startups that would prefer to have a strategically aligned DAO among the list of their backers than to have a traditional investment fund. BadgerDAO’s recent <a href="https://cryptopanic.com/news/11708629/Join-Badger-and-0Confirmation-for-an-open-forum-AMA-to-discuss-the-proposed-investment-through-the-Annexe-as-outli">$1million investment in 0confirmation</a> is a great example of this.</p><p>It’s also worth mentioning that several existing DeFi projects also have active treasury spending procedures to fund core protocol development.</p><p>For example, the Uniswap Grants Program, the first Uniswap governance proposal to meet quorum, seeks to fund certain projects and developers who are working to improve the Uniswap ecosystem.</p><p><strong><em>So, how does a DAO make decisions?</em></strong></p><p>The decision-making of a DAO can be done in many ways, ranging from simple to complex, however, most DAOs make decisions through some form of decentralized governance. This means that the individual members of a DAO are given the ability to make and vote on various proposals.</p><p>Usually voting in a DAO is handled with the use of a governance token. In this case, the weight of a member’s vote corresponds to the percentage of how many governance tokens they own, to how many governance tokens are in circulation. Essentially, the more governance tokens a DAO member owns, the more voting power they have.</p><p>A great place to explore various proposals or take part in DAO governance is on <a href="https://www.withtally.com/">Tally</a>. Tally enables users to explore the types of governance of various DAOs, review past proposals, and cast votes on active proposals.</p><p>Tally seeks to become a platform where members of a DAO can come together to vote on various proposals to decide which investments the DAO makes.</p><p>To better understand how DAO voting works, let’s take a look at some actual solidity code. Solidity is the programming language used to create smart contracts that run on the Ethereum blockchain.</p><p>One of the best metaphors for a smart contract, as described by Nick Szabo, is a <a href="https://www.fon.hum.uva.nl/rob/Courses/InformationInSpeech/CDROM/Literature/LOTwinterschool2006/szabo.best.vwh.net/idea.html">vending machine</a>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FFPpTEGx7OlNbxRgpKd%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FFPpTEGx7OlNbxRgpKd%2Fgiphy.mp4&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FFPpTEGx7OlNbxRgpKd%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/3cb67d61ccb2cd8f3c092af9b1d9b362/href">https://medium.com/media/3cb67d61ccb2cd8f3c092af9b1d9b362/href</a></iframe><p>Essentially the logic of a vending machine is as follows:</p><pre><strong>money + snack selection = snack dispensed</strong></pre><p>You insert a dollar into the machine, you specify which drink or candy bar you would like, and the vending machine spits out the item you specified.</p><p>Here’s an example of a simple solidity smart contract that functions exactly like a vending machine on the blockchain:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f28369bf430e3840ee71cb5e02c9ca9c/href">https://medium.com/media/f28369bf430e3840ee71cb5e02c9ca9c/href</a></iframe><p>With the smart contract above, instead of inserting a dollar like a physical vending machine, you send the vending machine ether, and in return, it gives you a “digital cupcake”.</p><p>To explore further how a DAO might interact with the vending machine smart contract as compared to an individual, let’s take a look at the following schema:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*utoJBFB5RvUBn9dfN4t6WQ.png" /></figure><p>As you can see above, an individual can directly interact with the vending machine smart contract to buy a cupcake.</p><p>But let’s say for whatever reason, several individuals cannot buy an entire cupcake on their own, so instead, they decide to pool their funds together to be able to purchase a cupcake from the vending machine. If the majority of the DAO participants vote “yes”, then the DAO buys a cupcake from the vending machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KvONYyxrYKGGtuc33G19Sg.png" /><figcaption>This is the <a href="https://docs.soliditylang.org/en/v0.4.24/abi-spec.html">ABI</a> of the DAO solidity smart contract</figcaption></figure><p>To run the DAO solidity contract above as well as the vending machine code, head on over to <a href="https://remix.ethereum.org/">Remix IDE</a> and follow the instructions on my <a href="https://github.com/partylikeits1983/simpleDAO">GitHub</a>.</p><p>This is a very simple example, but I hope you understand where I am going with this analogy. The cupcake is simply an abstraction of any type of asset that the DAO would receive in return for its investment.</p><p><strong><em>So why is this relevant?</em></strong></p><p>No matter how much I go on about how efficient DAOs are for organizing human energy and capital, or how impactful they could be in democratizing investment or bringing greater diversity of thought into investment decisions, nothing in the blockchain space is inevitable. There are plenty of forces stacked up in favor of traditional investment cliques (like the one in the header image) and it could be a while before DAOs overtake regular hedge and VC funds in terms of AUM.</p><p>However, by investing in every link in the chain <em>(no pun intended)</em>, from DAOs themselves, down to DAO infrastructure and tooling (such as voting tools like Snapshot, easy setup tools like DORA Factory, etc.), BR Capital hopes to play our part in bringing DAO-based investment to life.</p><p>If you’d like to read more no-jargon explainers like this, please follow Crypto Insights by BR Capital.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13bf869450d2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/crypto-investment-insights-from-br-capital/why-decentralized-autonomous-organizations-daos-will-transform-the-way-people-invest-13bf869450d2">Why Decentralized Autonomous Organizations (DAOs) Will Transform The Way People Invest</a> was originally published in <a href="https://medium.com/crypto-investment-insights-from-br-capital">Crypto insights from BR Capital</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>