<?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 Erin Koen on Medium]]></title>
        <description><![CDATA[Stories by Erin Koen on Medium]]></description>
        <link>https://medium.com/@erin-koen?source=rss-a9b8b55e667f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*BubWgxI-mDrHhJjq.</url>
            <title>Stories by Erin Koen on Medium</title>
            <link>https://medium.com/@erin-koen?source=rss-a9b8b55e667f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 00:33:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@erin-koen/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[Turning on the Uniswap Protocol Fee Switch]]></title>
            <link>https://erin-koen.medium.com/turning-on-the-uniswap-protocol-fee-switch-3642a042d1ba?source=rss-a9b8b55e667f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3642a042d1ba</guid>
            <dc:creator><![CDATA[Erin Koen]]></dc:creator>
            <pubDate>Fri, 07 Oct 2022 15:32:58 GMT</pubDate>
            <atom:updated>2022-10-07T15:32:58.797Z</atom:updated>
            <content:encoded><![CDATA[<p>A high-level technical overview and some questions to guide implementation</p><p>In August 2022, <a href="https://twitter.com/lay2000lbs">Leighton</a> made a proposal in the Uniswap governance forum to <a href="https://gov.uniswap.org/t/fee-switch-design-space-next-steps/17132">“turn on the fee switch”</a>. He framed the proposal as an experiment. Charging a protocol-level fee would directly impact liquidity provider economics. What effects would that have? Purposefully excluded from the proposal were questions about what the protocol DAO should do with its new revenue stream.</p><p>The proposal gained traction. Fees would be charged at the pool level, so there was substantive debate in the forums about which markets should be the subject of this experiment. Liquidity providers piped up and expressed their displeasure at the prospect, but ultimately opinion coalesced around three specific pools to test with the lowest possible protocol fee. While this conversation was happening, the proposal sailed through both a temperature check and a consensus check with overwhelming majorities.</p><p>“Turning on the fee switch” is phrase has been kicking around since Uniswap’s first deployment, and while the idea is simple in theory — the protocol should get paid a little for each trade it facilitates — in implementation it’s more complex than just pressing a button. In researching how Avantgarde should vote, I realised that I had no idea what the actual proposal would look like when it eventually got pushed onchain. The Uniswap docs are vague in this regard and I didn’t feel comfortable evaluating the downstream and second-order effects that a <strong>Yes</strong> vote might cause with incomplete information, so I went digging.</p><p>The results of my research are helpful in determining how I’ll vote when it eventually comes time to do so. They are also helpful in laying the groundwork for what happens after a successful experiment, and thinking about the work that would need to be done to roll out the fee switch for every market that Uniswap enables. I’ll recap below, starting with a quick primer on fees in general and then diving into protocol fees in particular.</p><h3><strong>A current overview of fees in Uniswap</strong></h3><p>A Uniswap pool is a smart contract that enables the exchange of one token for another. It’s trivial to create a pool, and anyone can do it by specifying three variables — the two tokens they want the pool to trade back and forth (let’s call them ABC and XYZ) and the fee, in basis points, that will be charged to do so (let’s say 30bps).</p><p>There are two types of potential user for every pool, Liquidity Providers and Swappers. Liquidity Providers deposit both tokens from the pair into the pool contract, allowing Swappers to exchange tokens from one side of the pair for tokens of the other. The Swapper pays the fee (in the token they’re selling) for the privilege, and the pool contract is smart enough to divvy the fee up pro rata between all liquidity providers who helped to make the trade happen.</p><p>Fees accrue in both of a pool’s tokens (assuming that there are trades in both directions) and are held separately from the liquidity provided to the pool. A Liquidity Provider can claim the fees they’re owed whenever they’d like, and send them wherever they like.</p><p>Taking the hypothetical ABC/XYZ pool above, I’ll walk through a transaction step by step:</p><p>Beginning Balances: <em>Swapper</em>: 2000 XYZ. <em>Liquidity Provider</em>: 10,000 ABC, 20,000 XYZ</p><ol><li>Spot ABCXYZ is 2. The Liquidity Provider deposits her 10,000 ABC and 20,000 XYZ to the pool in a single tick</li><li>The Swapper sees the available liquidity and sells his 2000 XYZ to the pool. The pool reserves the fee in the amount of 6 XYZ (0.003 * 2000). The balance of the sell order (1994 ABC) gets executed at 2.00 spot, and the swapper receives 997 ABC (1994 / 2)</li><li>The Liquidity Provider removes liquidity and claims fee. Fees can be claimed separately without removing liquidity, but this is useful in examining the impact of the fee on the total value of the Liquidity Provider’s holdings.</li></ol><p>Ending Balances: <em>Swapper: </em>997 ABC. <em>Liquidity Provider: </em>9,003 ABC and 21,994 XYZ from LP, 6 XYZ from fee</p><h3><strong>Carving out a protocol fee</strong></h3><p>By default, Liquidity Providers currently capture all fees paid by Swappers in a pool. However, each pool has a function that, if called by Uniswap Governance (specifically, setFeeProtocol, described <a href="https://github.com/Uniswap/v3-core/blob/412d9b236a1e75a98568d49b1aeb21e3a1430544/contracts/UniswapV3Pool.sol#L837">here</a>), slices off a fraction of every fee paid by a Swapper. This particular function is what has come to be known as the Fee Switch. The protocol fee is initialized to 0, but can be changed to any of the following values, each representing a percentage of the total fee: ¼, ⅕, ⅙, 1/7, ⅛, 1/9, or 1/10.</p><p>These slices are reserved for the protocol, and can only be claimed by Governance calling another <a href="https://github.com/Uniswap/v3-core/blob/412d9b236a1e75a98568d49b1aeb21e3a1430544/contracts/UniswapV3Pool.sol#L848">function</a> (collectProtocol) on the pool contract. This would require another distinct vote. In other words, it is a separate discussion and decision to determine how the fees will be used — they are not just streaming into some amorphous “Uniswap Treasury” contract.</p><p>Expanding on the example above, I’ll show the impact on Liquidity Provider economics if the lowest protocol fee setting (1/10) was enabled:</p><p>Beginning Balances: <em>Swapper</em>: 0 ABC, 2000 XYZ. <em>Liquidity Provider</em>: 10,000 ABC, 20,000 XYZ, <em>Uniswap:</em> 0 ABC, 0 XYZ.</p><ol><li>Spot ABCXYZ is 2. The Liquidity Provider deposits her 10,000 ABC and 20,000 XYZ to the pool in a single tick</li><li>The Swapper sees the available liquidity and sells his 2000 XYZ to the pool. The pool reserves the fee in the amount of 6 XYZ (0.003 * 2000). 1/10 of the fee (0.60 XYZ) is allocated to the protocol and the balance to the Liquidity Provider. The balance of the sell order (1994 ABC) gets executed at 2.00 spot, and the swapper receives 997 ABC (1994 / 2)</li><li>Liquidity Provider removes liquidity and claims fee</li><li>Uniswap Governance votes to claim fee from ABC/XYZ 30bps pool</li></ol><p>Ending Balances: <em>Swapper: </em>997 ABC, 0 XYZ. <em>Liquidity Provider: </em>9,003 ABC and 21,994 XYZ from LP, 5.40 XYZ from fee. <em>Uniswap:</em> 0 ABC, 0.60 XYZ</p><p>This design is what makes Leighton’s experiment so powerful. Pressing the fee switch button (I guess it is actually that easy) does one thing and one thing only. It changes the breakdown of fees in a particular liquidity pool. Any fees generated for the Protocol will remain totally inaccessible to the DAO without further work or votes. This is what allows us to witness the first-order effects of the fee switch (will Liquidity Providers flee en masse? Will spreads widen beyond repair?) without having to worry about most of the second order effects (What are we going to do with all this money????).</p><h3><strong>Looking Forward</strong></h3><p>In the event this experiment is successful, there will be some interesting technical problems to solve in the service of rolling out fees across the protocol. As we progress along that path, I’ll be thinking about the following:</p><ul><li>There are a huge number of Uniswap pool contracts in existence. I haven’t done the research, but I would wager that the vast majority of them do zero volume and spending the gas to change the setting would cost more than any potential future revenue. Should we whittle down the list of existing pools that collect a protocol fee? And going forward, how does governance change the pool deployer so that new pools default to a 1/10 protocol fee? (This is presumably fairly straightforward though I couldn’t find it in a quick scan of the contracts)</li><li>How do you collect fees from dozens, hundreds or eventually thousands of pools in a scalable manner? Each pool has its own distinct function to call. Assuming that fees would ideally be collected on a regular basis leads to the conclusion the current architecture would require numerous and frequent governance votes to collect fees, which would likely lead to extreme voter fatigue and eventually apathy.</li><li>How do you manage price exposure to the long tail of shitcoins? Should fees be collected directly in token form a la Paraswap or converted to USDC (or similar) upon collection a la 1Inch?</li><li>Where do the fees go? The collectProtocol function allows the caller to specify an address that will receive the collected balances. History has shown that sticking them in the Timelock and letting Governance decide how to spend them is suboptimal. How would these funds be managed transparently and trustlessly?</li></ul><p>I’m particularly looking forward to the <a href="https://www.alastor.ooo/">Alastor</a> report that the <a href="https://twitter.com/UniswapFND">UF</a> commissioned. Having chatted with the Jordan and Sam, they are building powerful, data-driven insights about how the protocol fee might change user behavior for the better. No spoilers here, but their initial findings and recommendations were not what I expected.</p><p>Uniswap was one of the very first integrations our team built for Enzyme (then Melon). It is a foundational protocol, and I am honored to be involved in helping to steer its future development both through Avantgarde’s work as a delegate and through our future cooperation with the Uniswap Foundation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3642a042d1ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Trading Bot on Enzyme]]></title>
            <link>https://medium.com/enzymefinance/building-a-trading-bot-on-enzyme-e002b6419b23?source=rss-a9b8b55e667f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e002b6419b23</guid>
            <category><![CDATA[enzyme]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[defi]]></category>
            <dc:creator><![CDATA[Erin Koen]]></dc:creator>
            <pubDate>Tue, 09 Mar 2021 14:28:36 GMT</pubDate>
            <atom:updated>2021-06-23T20:48:39.360Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-7QWOh8n_TS-07v3Fjg_cw@2x.jpeg" /></figure><p>Enzyme allows asset managers to develop and deploy proprietary strategies within the burgeoning DeFi ecosystem. The protocol connects natively to other leading projects to do a bunch of different things with a huge number of ERC-20 tokens including swapping them, lending them, staking them, and using them to provide liquidity.</p><p>The money-lego nature of DeFi means that opportunities for profit can come and go in the time it takes to mine a block. For those Enzyme managers looking to programmatically capture such opportunities, it might be worth building a bot that executes their strategy on behalf of their Enzyme product.</p><p>Luckily, the team at Avantgarde Finance has built a couple of tools that make this sort of programmatic execution achievable.</p><p>The first is an expansive subgraph. There has been a lot written about The Graph so I won’t rehash it here. But suffice it to say that it’s an incredible tool that captures and indexes contract event-level detail about what’s happening on Enzyme. We’ll use it to dynamically access boring stuff — token and contract addresses — but the amount of data you can generate from the Enzyme subgraph deserves its own post.</p><p>The second tool, and likely the reason you’re here, is the <a href="https://sdk.enzyme.finance/">EnzymeSDK</a>. It’s a TypeScript library that exports the Enzyme smart contracts as classes and exposes their various methods. When put together in the right order, you can use these methods to run your strategies automatically. In the example that follows, I’ll build a naive bot that regularly selects a random token and allocates all of an Enzyme vault’s funds to it. I shall name it *THE MINER’S DELIGHT*. In building such a stupid bot, I’m trying to showcase how you can use the smart contracts we’ve deployed, rather than providing any strategic or investment advice. Do not copy this code wholesale.</p><blockquote>The current release of EnzymeSDK is extremely low-level and requires the user to be very explicit. Future versions of this package will be more abstract and require less developer input.</blockquote><p>The third tool is a Kovan (testnet) deployment of Enzyme. We’ll set up the development environment to test the bot on Kovan to save you gas fees and error trades. It’s important to note that not all mainnet functionality is available on the Kovan deployment, but you can trade on a mock Uniswap contract, which is what the bot we’re building does. You can set up your own Kovan vault using the instructions <a href="https://www.notion.so/avantgardefinance/Opening-an-Enzyme-Vault-on-Kovan-a19bb6e38aaa4f0289b4220ccf551d23">here</a>.</p><p>Using those three tools, the bot I lay out below will perform a couple of functions that you may find useful:</p><ul><li>Check your Enzyme vault’s portfolio balances</li><li>Check token prices on Uniswap</li><li>Execute a trade on Uniswap</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F518701759%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F518701759&amp;image=http%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F1074239838_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/44363c6b44f80ce397a7457652bfe1c8/href">https://medium.com/media/44363c6b44f80ce397a7457652bfe1c8/href</a></iframe><h3>Housekeeping</h3><h4>Helpful Links</h4><ul><li><a href="https://github.com/avantgardefinance/enzyme-bot/">The Bot Repo</a></li><li><a href="https://docs.enzyme.finance/">Enzyme Protocol Documentation</a></li></ul><h4>Dependencies</h4><p>First we’ll start a project and install the necessary dependencies. Generally we’ll need tools to interact with the Ethereum blockchain, access the subgraph, and manage our environment variables.</p><ul><li>ethers to make contract calls, handle token math, etc</li><li>@uniswap/sdk to query current token pair pricing</li><li>@enzymefinance/protocol to access the Enzyme contracts</li><li>axios to get gas prices, if and when you need them</li><li>graphql and graphql-request to write queries and spin up a minimal graphql client through which to serve them</li><li>dotenv-extended to keep your secrets safe</li></ul><p>I’m writing this in TypeScript, and tossed in eslint and prettier out of habit. You can see I’ve also added some TypeScript-specific graphql dev dependencies as well.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8244b49a28c16a3be429cada5f052d05/href">https://medium.com/media/8244b49a28c16a3be429cada5f052d05/href</a></iframe><h4>Security Considerations</h4><p>In meatspace, signing and sending an Ethereum transaction requires a user to interact with some combination of a hardware wallet, browser extension, mobile app, et cetera. Since we’ll be building a bot that signs and sends transactions on our behalf, we need to give it access to the private key for the appropriate Ethereum account.</p><p>There are many schools of thought on how best to store and secure private keys for programatic access and it’s out of the scope of this article to discuss them. For simplicity’s sake, I’m storing my keys (for both Kovan and Mainnet) as environment variables and using dotenv-extended to access them. I’ve added .env files to my .gitignore, so there’s no chance of accidentally pushing these to a hosted repo for the world to see.</p><blockquote>As an additional precaution, you should permission a wallet to trade on behalf of your Enzyme vault that you have created for that express purpose. The wallet you permission will need ETH to pay for gas but you can otherwise leave it empty, decreasing your potential attack surface. More about the process for delegating trading responsibilities can be found <a href="https://userdocs.enzyme.finance/managers/customise-your-settings">here</a>.</blockquote><h4>Testnet and Mainnet</h4><p>Enzyme maintains deployed versions of its smart contracts on Kovan for testing purposes. Functionally, the bot will be identical on both networks. However, some wallet, node, and subgraph configuration variables differ between the two. We’ll use a pass a NETWORK argument to our Bot on instantiation to dynamically adjust those configuration variables.</p><p>Beyond the network-specific variables, we also need to store a couple of the Enzyme Vault contract addresses. Our Bot needs the vault’s Comptroller and Vault addresses. These are available in the Factsheet section at the bottom of the vault’s overview page at <a href="https://app.enzyme.finance/">app.enzyme.finance</a>.</p><p>When it’s all said and done, our environment variables look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b59d73b8a772fd387df19f201956cda/href">https://medium.com/media/8b59d73b8a772fd387df19f201956cda/href</a></iframe><h3>Fetching Subgraph Data</h3><p>To run this bot, we’ll need to instantiate JavaScript class representations of various Ethereum contracts. That instantiation requires an address pointing to where the contract lives onchain. We can fetch those addresses dynamically using the <a href="https://thegraph.com/explorer/subgraph/enzymefinance/enzyme">Enzyme subgraph</a>.</p><p>The first step to do so is to write a couple of graphql queries against the Enzyme subgraph’s schema. My preferred method for drafting these queries is in the <a href="https://thegraph.com/explorer/subgraph/enzymefinance/enzyme?query=Basic%20Assets%20Query">explorer</a>. Once you’ve the info you need there, you can copy it over to your project.</p><p>I’ve written two queries. One returns the addresses of the <a href="https://thegraph.com/explorer/subgraph/enzymefinance/enzyme?query=Mainnet%20Contract%20Addresses">Enzyme contracts</a> on the particular network that we’ve declared in our environment variables. The other returns information on the <a href="https://thegraph.com/explorer/subgraph/enzymefinance/enzyme?query=All%20Assets%20With%20Prices">various tokens</a> that are available in the Enzyme asset universe. You can have a look at the format of those queries <a href="https://github.com/avantgardefinance/enzyme-bot/tree/master/src/queries">here</a>.</p><p>Now we’ll need to do a bit of configuration to generate the correct graphql types based on the schema provided by the appropriate Enzyme subgraph. There’s a Kovan version as well as Mainnet and they’re accessible via different endpoints. You’ll need to specify which you are using in a codegen.yaml file. You’ll also declare where you’ve written the queries, and where you want graphql to put the generated code.</p><p>This is the only part in this tutorial where you’ll have to manually choose an environment variable. My codegen.yaml file looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97ff38766459693e4ceea5d95805611a/href">https://medium.com/media/97ff38766459693e4ceea5d95805611a/href</a></iframe><blockquote>When you switch from testing to mainnet, change your schema property to ${MAINNET_SUBGRAPH_ENDPOINT}.</blockquote><p>The codegen script in my package.json takes this file as a configuration parameter, and uses dotenv to load the appropriate environment variables before running the codegen function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c0cc13bb767a57bdc1100c2aeee316f/href">https://medium.com/media/4c0cc13bb767a57bdc1100c2aeee316f/href</a></iframe><p>At this point, you can run yarn codegen (or npm codegen whatever your little heart desires) and graphql works its magic to output a file loaded with types and other goodies (including a ready-to-use SDK that we’ll instantiate next).</p><p>For this implementation, I’ve written a function that, when passed the appropriate subgraph endpoint, returns the graphql-request SDK, upon which we can call the queries we’ve written above. You can check that code out <a href="https://github.com/avantgardefinance/enzyme-bot/blob/master/src/utils/subgraph/sdk.ts">here</a>.</p><p>Putting this all together, we can use the results returned from this object’s methods to inform our bot about the contracts it needs to call and the state of the vault on whose behalf it’s acting.</p><h3>Interacting with Your Enzyme Vault</h3><h4>Network Provider and Wallet Setup</h4><p>When you instantiate an Enzyme contract class in Javascript, you need to pass a Signer object to its constructor method. This Signer object, <a href="https://docs.ethers.io/v5/api/signer/">per Ethers</a>, is “an abstraction of an Ethereum Account which can be used to sign messages and transactions and send signed transactions to the Ethereum Network to execute state changing operations”.</p><p>I’ve included two helper functions in this repo to generate a Signer object. The first is <a href="https://github.com/avantgardefinance/enzyme-bot/blob/master/src/utils/getProvider.ts">getProvider()</a>, which returns a provider object that describes the app’s connection to the Ethereum network. One note here: I’d recommend signing up for a node provider api key. Ethers does provide a generic node connection, but it is throttled pretty tightly. They talk about that <a href="https://docs.ethers.io/v5/api/providers/">here</a>. If you just want to use the defaultProvider you can change the getProvider() helper function to ignore the …NODE_ENDPOINT environment variables and return a new providers.DefaultProvider(network.toLowerCase()) .</p><p>The second helper function is <a href="https://github.com/avantgardefinance/enzyme-bot/blob/master/src/utils/getWallet.ts">getWallet()</a> which takes that provider and your Ethereum account’s private key as arguments and returns a Wallet instance (which is a concrete subclass of Signer).</p><h4>Enyzme Bot Logic</h4><p>My bot’s strategy, as I mentioned, is fairly simple. However, the methods it uses to accomplish it can be instructive. On a regular cadence, the bot will:</p><ul><li>Call a function that returns a random asset from the Enzyme asset universe, or undefined</li><li>check your Enzyme vault’s current portfolio allocations</li><li>if the random asset you’ve generated is not undefined, swap your current largest position (by number of tokens held) for as much of the random asset as you can via Uniswap</li><li>repeat</li></ul><p>The bot will ensure that your Enzyme vault’s portfolio positions are essentially randomly constructed, and it will change those position arbitrarily and at a regular cadence. Again, you’re not here for trading advice.</p><h4>The Constructor</h4><p>Upon its creation, our bot will be endowed with the knowledge of which Ethereum network it’s operating on, as well as the addresses of <a href="https://github.com/avantgardefinance/enzyme-bot/blob/master/src/utils/getDeployment.ts">all the deployed Enzyme contracts</a> and <a href="https://github.com/avantgardefinance/enzyme-bot/blob/master/src/utils/getToken.ts">tokens in the Enzyme asset universe</a> on that network. Additionally, we’ll configure our <a href="https://github.com/avantgardefinance/enzyme-bot/blob/master/src/utils/getProvider.ts">Ethereum provider</a> and <a href="https://github.com/avantgardefinance/enzyme-bot/blob/master/src/utils/getWallet.ts">wallet</a> instance properties. And finally, we’ll need to reference the particular Enzyme vault’s comptroller and vault addresses in order to make calls on its behalf. You’ll recall I’ve stored those addresses in my environment variables. Everything else I mentioned above uses helper methods I wrote to make the source of this data more explicit. The end result looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54cb6bab8095c8a0e564928aa7a4d626/href">https://medium.com/media/54cb6bab8095c8a0e564928aa7a4d626/href</a></iframe><h4>The Bot Class’s Methods</h4><p>chooseRandomAsset() doesn’t deserve all that much description. It generates a random number between 0 and the length of our bot class’s tokens array and returns the asset at that index.</p><p>getHoldings() is our first opportunity to use an Enzyme contract in the wild. The VaultLib contract, when instantiated with a specific vault address and a valid Ethereum Signer, exposes a method that returns an array of the vault’s tracked asset addresses.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ec42fdb6eb8276ac7bc2bfae1969c88/href">https://medium.com/media/6ec42fdb6eb8276ac7bc2bfae1969c88/href</a></iframe><p>getPrice() takes the tokens being traded and the amount of the token being sold as arguments and passes them through to a <a href="https://github.com/avantgardefinance/enzyme-bot/blob/master/src/utils/uniswap/getTradeDetails.ts">getTradeDetails()</a> helper function. It returns the path a trade must take to get from the token being sold to the token being bought, a minimum incoming amount of the token being bought, and it passes through the amount of the token being sold.</p><p>On mainnet, the helper function offloads this work to the Uniswap SDK. There’s lots you can do in terms of path optimization, but I’ve made the assumption that the best price on Uniswap for any given token is that token vs WETH. So when getPrice() passes Token A and Token B to the helper function that incorporates the SDK, it returns a path that looks like Token A =&gt; WETH =&gt; Token B . How you manage that optimization is up to you; Uniswap’s got <a href="https://uniswap.org/docs/v2/javascript-SDK/quick-start">great docs</a>. Note that I’ve<a href="https://github.com/avantgardefinance/enzyme-bot/blob/90b5cf340087e3516939e68519b9f970e289c416/src/utils/uniswap/getTradeDetails.ts#L71"> also built a little bit (2%) of potential slippage</a> into the minIncomingAssetAmount that I return from the getTradeDetails() function.</p><p>On Kovan, the helper function just assembles the simplest path (Token A =&gt; Token B) and returns a very small value for minimumIncomingAmount .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/afad10e0914b4b7fc132c8222320e29d/href">https://medium.com/media/afad10e0914b4b7fc132c8222320e29d/href</a></iframe><p>swapTokens() takes the Uniswap trade data returned from the getPrice() function as a parameter and executes the trade via the ComptrollerLib contract. It also uses two helper functions exported from @enzyme/protocol .</p><p>swapTokens() highlights a few features of the new Enzyme architecture, an in-depth discussion of which can be found <a href="https://docs.enzyme.finance/architecture/release-architecture">here</a>. The ComptrollerLib contains the canonical logic for interacting with vaults on the protocol. It can talk to Extensions, which extend that logic. One such extension is the IntegrationManager, which allows the exchange of the fund’s assets for other assets via “adapters” to external DeFi protocols (Uniswap, in this case). In the swapTokens() function, I prepare the arguments necessary for the Uniswap Adapter to execute the trade (via the uniswapV2TakeOrderArgs() helper), then pass those arguments to the callOnIntegrationArgs() helper, which ultimately gets passed to the ComptrollerLib&#39;s callOnExtension() function. Note that both of these ...Args() helpers are converting arguments passed in various JavaScript primitives to bytecode that’s readable by the Solidity contracts with which we are interacting.</p><blockquote>Note that much of the logic above will be abstracted away in subsequent releases of EnzymeSDK</blockquote><p>swapTokens() returns a transaction object, which you can prepare with gas estimations and the like and then eventually execute.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc4bd2624cc666c233ad493013931b0c/href">https://medium.com/media/cc4bd2624cc666c233ad493013931b0c/href</a></iframe><p>tradeAlgorithmically() ties everything together by calling the functions we’ve laid out above. It:</p><ul><li>Chooses an asset from the Enzyme asset universe at random</li><li>Checks the Enzyme vault’s portfolio to determine which current holding it will sell to buy the random asset</li><li>Gets the necessary info to trade the current holding for the random asset</li><li>Calls the swapTokens function to start the transaction</li></ul><h4>Transaction Execution Logic</h4><p>index.ts will serve as our Bot’s entry point. The run function there holds the logic for when and how often the bot calls the tradeAlgorithmically() function and what to do with the transaction that function returns. You’ll notice I also added a couple of helper functions to check for gas prices on Mainnet and interpret revert errors from the blockchain.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbf63d4061c298dc80921c3220d2696c/href">https://medium.com/media/dbf63d4061c298dc80921c3220d2696c/href</a></iframe><h4>Conclusion</h4><p>This example of the EnzymeSDK is just a tiny portion of what you can do by programmatically calling the protocol’s contracts. It’s possible to build many types of tools for Vault managers and depositors. Future versions of the package will be abstracted and even easier to use. This post will be updated and expanded upon when those future versions become available.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e002b6419b23" width="1" height="1" alt=""><hr><p><a href="https://medium.com/enzymefinance/building-a-trading-bot-on-enzyme-e002b6419b23">Building a Trading Bot on Enzyme</a> was originally published in <a href="https://medium.com/enzymefinance">Enzyme</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a MelonBot]]></title>
            <link>https://medium.com/enzymefinance/building-a-melonbot-1cdea583fb88?source=rss-a9b8b55e667f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cdea583fb88</guid>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[melon]]></category>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[bots]]></category>
            <dc:creator><![CDATA[Erin Koen]]></dc:creator>
            <pubDate>Wed, 06 May 2020 13:35:23 GMT</pubDate>
            <atom:updated>2020-05-06T14:07:29.586Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using MelonJS to trade programmatically on behalf of a Melon fund</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TH_9fB-1WuWMuZlAIyt2sA.jpeg" /><figcaption>Make sure your bot buys low and sells high.</figcaption></figure><p>The Melon Protocol has been designed to automate and simplify the boring parts of asset management. For about $50 in Ethereum gas, you can spin up a fund that will perform all of its own accounting functions, manage investments and redemptions, and enforce compliance mandates programatically. And since all of these actions are performed on chain, it’s 100% transparent and able to be audited. As a manger you can build an immutable track record to show your prowess, and as an investor you can have full confidence in the fund where you’re parking your assets.</p><p>The fun part of an asset manager’s job, managing risk, has remained largely manual on Melon to date. To the best of our knowledge, trades have exclusively been made via the Melon Terminal. However, with the recent release of MelonJS, it’s possible to automate trading strategies that run in the background, without having to manually enter and execute trades.</p><p>This series of blog posts will be an evolving document, starting with outlining the most basic functions that a trading bot requires before moving on to deployment and potentially strategy.</p><p>To start, I’ll make the assumption that we’re building a very basic if this then that bot. In other words, it will monitor the markets for a certain condition (this), and when that condition is met, adjust the user&#39;s portfolio according to whatever rules the trader has put in place (that).</p><p>The this portion of this bot will be up to you. My example will be simple, bordering on stupid. It will only trade two tokens - WETH and MLN - and will be 100% allocated to one or the other at all times. It will make decisions about when and what to trade based on a pseudo-random condition. It will likely do better than my current Melon Fund.</p><p>I will, however, delve into the that portion by touching on the following topics in depth:</p><ul><li>How to check your Melon fund’s current balances</li><li>How to check asset prices on Uniswap</li><li>How to trade on Uniswap</li></ul><h3>Housekeeping</h3><h4>Helpful Links</h4><ul><li><a href="https://github.com/avantgardefinance/melonjs-trading-bot">The Bot Repo</a></li><li><a href="https://melonjs.melonprotocol.com/">MelonJS Documentation</a></li><li><a href="https://www.crowdcast.io/e/defi-discussions/24">A Melon Primer and Bot Building Discussion</a></li></ul><p>First we’ll start a project and install the necessary dependencies. For the three methods above, we’ll need a few web3 packages and MelonJS. Use yarn or npm to install @melonproject/melonjs, web3-core, web3-eth, web3-providers and web3-utils. Additionally, I&#39;m using bignumber.js to handle all numbers and token math, and dotenv-extended to access environment variables. I&#39;m also writing this in TypeScript, so I added that as a dev dependency. When you&#39;re done, your package.json should look something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6d6464a9d7b498ffc4c06a6aa829aca/href">https://medium.com/media/c6d6464a9d7b498ffc4c06a6aa829aca/href</a></iframe><p>We’ll also need the latest protocol deployment configurations to track various contract addresses. These configuration files are available in JSON form in various Melon repositories. I took them from <a href="https://github.com/avantgardefinance/melon-terminal/tree/master/deployments">here</a> since the Melon Terminal is very actively maintained and is highly likely to be the most current version. I added a couple of files to the tree to hold our various classes, methods, and utilities, so my directory now looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/211/1*sn2w2Wn4mdapLVDMPVGMrg.png" /><figcaption>A simple directory, so far.</figcaption></figure><h3>Utility Methods</h3><p>I’ve taken the liberty of appropriating some utility methods that show up throughout the Melon and Avantgarde codebases. Two work with token math and the other queries <a href="http://ethgasstation.io/">ethgasstation.io</a> to give us an appropriate gas price. I also stuck the function to create an environment (discussed below) in that folder.</p><h3>Wallet, Account, and Environment Setup</h3><p>Our final chore before we get to the fun part is to discuss private key management. In most cases, a user signs transactions using a browser extension or hardware wallet. In the case of this bot, we will automate the process of signing a transaction, so we need access to the wallet directly. This can be achieved through using the private key, or an encrypted JSON wallet file and password.</p><p>For simplicity’s sake, I’ll be storing mine as an environment variable and using dotenv-extended to access it. I have already added .env files to my .gitignore so there&#39;s no chance of accidentally pushing this to a hosted repo with keys intact for the world to see. There are a bunch of different ways of managing this interaction, and it&#39;s worth researching how you want to handle it. If you take one thing away from this paragraph, it should be:</p><blockquote><strong>Do not hardcode your private keys and do not store your private keys on Github</strong>.</blockquote><p>I know that’s two things. But they’re both important. Cover your ass here.</p><p>Per the <a href="https://melonjs.melonprotocol.com/">documentation</a>, the Melon protocol contracts all have a JavaScript class representation exported from MelonJS. These classes each require that an Environment variable is passed to their constructor method in order to provide the class with context about the network within which it is operating and the specific Ethereum account that&#39;s accessing it. We&#39;ll write a couple of methods to correctly configure that Environment variable, along with your Ethereum wallet information, in order to successfully use the Melon contracts exported by MelonJS. I’ve stuck those methods in the util directory, and they look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2589cd8e308b252d4e79f37c2e8e382/href">https://medium.com/media/b2589cd8e308b252d4e79f37c2e8e382/href</a></iframe><p>The first step is to create a function that returns a provider, which is a web3 object that represents a connection to an Ethereum node of your choosing. We call that function and pass the returned provider into the constructor for a new Eth class which we&#39;ll call client. The Eth class is exported from web3. We then create an account linked to our private key (which remember, I&#39;ve stored as an environment variable), and add that to our client. Note that as I mentioned above, this key must be to the account with which you&#39;ve created the Melon fund for which this bot will trade.</p><p>With that, you’ve now proven that you are the owner of the account in question. Create a new environment using the newly instantiated client and the deployment JSON I described above.</p><h3>The Bot Class</h3><p>Next, we’ll create a class that will contain all the methods our bot will need to run, as well as hold the variables necessary to execute them in state. More explicitly, using that state in combination with those methods, our bot should be able to:</p><ul><li>Query a fund’s token balances</li><li>Query a token’s price denominated in WETH or the price of WETH denominated in that token on Uniswap</li><li>Trade on Uniswap to adjust the fund’s balances of two distinct tokens tokens (in this case WETH and MLN)</li></ul><p>It’s worth noting that I’m taking the simplest route possible here. Though you can trade any one token for another on the current Uniswap release, in order to generate a token to token price, you need to go through WETH. In other words, you need to make two calls (Token 1 to WETH, WETH to Token 2) and subsequently interpolate how many of Token 1 get you a Token 2. I’m just going to trade WETH for MLN and back again. However, if you’d like to see this complexity handled in a fairly seamless manner, check out the Melon Terminal code <a href="https://github.com/avantgardefinance/melon-terminal/blob/d1fa98c86aed22469ef708fab6436abfa86c0ef3/src/components/Routes/Fund/FundTrade/FundUniswapTrading/FundUniswapTrading.tsx#L86">here</a>.</p><p>Throughout the code blocks below, I’ll be referencing class properties. That being the case, I’ll start out my discussion with a section on the parameters that we need to pass to the class’ constructor. The repo contains a fully-typed example class.</p><h3>Parameters</h3><p>All the relevant contracts addresses can be referenced using the fund’s hub (whose address is available at <a href="http://eek-capital.melon.fund/">your-fund-name.melon.fund</a>). We’ll use a factory pattern and the hub contract to find those addresses and store them in the state’s class when you call it. We’ll also instantiate the various JavaScript contract representations and store them in state. The result is that we need to pass only three variables to instantiate the class: the fund’s hubAddress and the the symbols of the two tokens you want the bot to trade.</p><p>Note also, we’ll need to import and call the createEnvironment method when the class is created.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e8626a6ae930097f71bb1c4e6297fb4/href">https://medium.com/media/0e8626a6ae930097f71bb1c4e6297fb4/href</a></iframe><h3>Fund Methods</h3><p>We’ll start by using the Accounting contract exported by MelonJS to see what your fund is currently holding.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3b417b0a0de6b455d772b641508ffac5/href">https://medium.com/media/3b417b0a0de6b455d772b641508ffac5/href</a></iframe><p>FundHolding is a type that&#39;s also exported from MelonJS. It is an object with the size of the holding and the token&#39;s address.</p><h3>Uniswap Methods</h3><p>We’ll use various contract classes related to Uniswap to query the current prices of the fund holdings that we just returned and then eventually to trade into and out of positions.</p><p>To check a price, the order of operations is as follows:</p><ul><li>figure out which token you’re trading against WETH (the base currency is that which is leaving your inventory, the quote currency is what you’re buying)</li><li>find the address of the Uniswap exchange contract for that token using the UniswapFactory we instantiated above</li><li>create a contract object for that exchange using UniswapExchange</li><li>call a function on that contract to return the rate (in the base currency) to trade an amount (of that base currency).</li></ul><p>In our case, we’re going to interpolate the size and rate for the quote currency side of the equation as well, since trading on Uniswap requires a parameters object with some of that information. The method ends up looking something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3102beb539722d960d27be58ad8fd862/href">https://medium.com/media/3102beb539722d960d27be58ad8fd862/href</a></iframe><p>MelonJS imports in that code block include UniswapFactory and UniswapExchange.</p><p>Creating a trade transaction is executed in a similar fashion. We’ll take the uniswapTradingAdapter that we instantiated with the class and call the takeOrder method on it. We’ll pass that method the manager’s address and an object of order arguments that we’ll construct from the result of the price query.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3e067d9cbc09eb81ed4fe0868f1098c/href">https://medium.com/media/d3e067d9cbc09eb81ed4fe0868f1098c/href</a></iframe><p>Worth noting here — I built a slippage variable into this method because if you pass an amount greater than is currently available on Uniswap, the transaction will be rejected. If you pass an amount that’s less than what’s currently available, Uniswap will execute at the best available price. I ballparked 3%; in reality my test trades have been so small that I’ve gotten almost the entire size quoted on every trade I’ve done. Slippage in the liquidity pools is similar to slippage in traditional exchanges — the bigger the size you’re trying to trade, the more there’s likely to be. This will be something you’ll have to optimize on your own.</p><p>Our trade function here returns a Promise of a Transaction. I’ve left it up to my execution script to handle that promise’s resolution.</p><h3>Pulling it All Together</h3><p>So far, we have a class that contains methods to check your funds token balances, check the prices of those tokens on Uniswap, and trade those tokens on Uniswap. What’s missing is the secret sauce that you’ll provide to inject some logic into the bot. How should it trade and when? It’s easy to envision a method that checks balances, then checks prices, then runs those prices through some sort of indicator algorithm, then trades if the indicator comes back positive. For me, that magic function looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a8560649842cf08cb1bfe1d43dd2694/href">https://medium.com/media/5a8560649842cf08cb1bfe1d43dd2694/href</a></iframe><p>I don’t have any of that secret sauce for you. This is where you can get creative — use your best TA or on-chain metrics or other voodoo. As I mentioned above, my strategy will be to trade at random. That being the case, I’ve written a script that calls itself recursively every 15 minutes, generates a random number between 0 and 1 and trades if that number is greater than .50. If it does trade, the script handles the transaction execution. There are a multitude of edge and corner cases that will make this implementation fail, many related to ethereum transaction logic.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6e4fc598e5187384668e4ea0d99846e/href">https://medium.com/media/e6e4fc598e5187384668e4ea0d99846e/href</a></iframe><p>It’s worth digging into web3’s p<a href="https://web3js.readthedocs.io/en/v1.2.0/callbacks-promises-events.html">romievents</a> to think about how you’ll handle any errors that occur, and that seems like it could be a good topic for me to cover in a future blog post. Other topics on my list include:</p><ul><li>managing more complex state and persisting it in a database</li><li>implementing an actual strategy using that complex state and various market metrics</li><li>checking all available trading venues and executing at the best possible rate</li><li>doing the devops work to run this bot indefinitely</li></ul><p>As it stands, my bot is operational and burning through gas, trading on my behalf. When I run it in my terminal, it looks like so:</p><pre><strong>➜ </strong>yarn dev</pre><pre><strong>yarn run v1.21.1</strong></pre><pre>$ cross-env NODE_ENV=development ts-node --require dotenv-extended/config --transpile-only src</pre><pre>INSTANTIATING ENVIRONMENT ==&gt;</pre><pre>FIRING UP THE BOT ==&gt;</pre><pre>CONSULTING THE ORACLE ==&gt;</pre><pre>NO TRADING BY ORDER OF THE ORACLE</pre><pre>Going to sleep.</pre><pre>INSTANTIATING ENVIRONMENT ==&gt;</pre><pre>FIRING UP THE BOT ==&gt;</pre><pre>CONSULTING THE ORACLE ==&gt;</pre><pre>THE ORACLE SAYS TO TRADE</pre><pre>Buying 26270323039658927422.53 MLN by selling 430703553862299497 WETH</pre><pre>Transaction successful.</pre><pre>blockHash: 0xe0a94b99ec8a3ca8d5ba2d7e71a2f4ca0301cd96764d3d5f0afe9db76f71204f</pre><pre>transactionHash: 0xaa0edecb4c741c58b44daf5742305abb5c055949028b913d18f84cdd260bec33</pre><pre>gasUsed: 684251</pre><pre>Going to sleep.</pre><h4>Helpful Links</h4><ul><li><a href="https://github.com/avantgardefinance/melonjs-trading-bot">The Bot Repo</a></li><li><a href="https://melonjs.melonprotocol.com/">MelonJS Documentation</a></li><li><a href="https://www.crowdcast.io/e/defi-discussions/24">A Melon Primer and Bot Building Discussion</a></li></ul><h4>Contact Info</h4><ul><li><a href="https://medium.com/u/c5ed2f36411c">Melonport</a></li><li><a href="https://medium.com/u/ab3ff5a7edf">Avantgarde Finance Ltd</a></li><li>erin@avantgarde.finance</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cdea583fb88" width="1" height="1" alt=""><hr><p><a href="https://medium.com/enzymefinance/building-a-melonbot-1cdea583fb88">Building a MelonBot</a> was originally published in <a href="https://medium.com/enzymefinance">Enzyme</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cellular Automata: Building the Game of Life]]></title>
            <link>https://erin-koen.medium.com/cellular-automata-building-the-game-of-life-d214b66eab96?source=rss-a9b8b55e667f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d214b66eab96</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Erin Koen]]></dc:creator>
            <pubDate>Fri, 19 Jul 2019 16:42:57 GMT</pubDate>
            <atom:updated>2019-07-19T16:42:57.175Z</atom:updated>
            <content:encoded><![CDATA[<p>As Lambda School is winding to a close, the format of the weekly sprint challenges testing our knowledge has quickly changed. There are no more heavily commented repos, no more step-by-step README.md files that lay out our path for the three hours of the challenge. Instead, the challenges pose a problem and give us free reign in interpreting it and writing code to solve it.</p><p>This week’s challenge was four and a half days long, and it’s the best example yet of this open-ended approach. On Monday, we forked and cloned the <a href="https://github.com/erin-koen/Conways-Life">repo</a> describing <a href="https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life">Conway’s Game of Life</a> with instructions to build a visual representation of that game using our primary language, including a couple of functional requirements. For me, this meant javaScript and React. In the next few sections, I’ll lay out how I applied Polya’s Problem Solving Technique to build an app that represents Conway’s Game of Life.</p><p><strong>STEP 1: Understand the Problem</strong></p><p>It seemed like there were two main pieces of the problem to dissect. First, what even is Conway’s Game of Life?</p><p>Turns out, it’s a grid-based simulation, in which cells in the grid can be either <strong>alive</strong> or <strong>dead</strong>. Their status is determined by a set of rules, which measure the status of each cell’s 8 neighbors (N, E, S, W, NE, NW, SE, SW), and make a wholesale change to every cell in the grid based on the following rules:</p><ol><li>The cell is living and has fewer than 2 live neighbors. In the next generation, this cell is dead. (Loneliness?)</li><li>The cell is living and has 2 or 3 live neighbors. In the next generation, this cell lives. (Goldilocks.)</li><li>The cell is living and has greater than 3 live neighbors. In the next generation, this cell dies. (Overcrowding.)</li><li>The cell is dead and has 3 live neighbors. In the next generation, this cell lives. (Lazarus!)</li></ol><p>So, the rules are four simple conditional statements. One generation is observed, the rules are applied, and cells’ statuses are changed accordingly when the next generation is displayed. I felt confident that I could write the logic for that, and put it on the back burner.</p><p>The second piece of the problem was more operational:</p><ul><li>I’d have to build an app that ran the simulation, and had multiple functions that would operate on the simulation. It also needed to display the generation — i.e. how many times cells had been evaluated and their fates decided.</li><li>I’d have to deploy that app to production somewhere</li></ul><p><strong>STEP 2: Devising a Plan</strong></p><p>So, how to display this thing? What even is React? I broke down my planning into a couple of steps.</p><ol><li>Figure out how to display a Grid. Then, how do you change the status of a cell in that Grid and re-render appropriately</li><li>Plan a double-buffer function to measure every cell in that grid against Conway’s rules, create a new Grid accordingly, then replace the old Grid with the new one.</li><li>What functionality does the Grid (and every component within it) need?</li><li>How do I deploy?</li></ol><p>For the first step, I started to think in terms of React components. Going from largest to smallest, I figured I would need three. A Grid, which was made up of Rows, which were each composed of Cells. The child components would be represented by an array (of arrays filled with boolean values)in Grid’s state. All functions would be held in the Grid Class component and passed down as props to the Row and Cell functional components. At this early stage, I imagined rendering each component as a &lt;div&gt;, the color of which would change based on whether it was alive or dead.</p><p>Next, I created a list of functions I thought I’d need:</p><ul><li>toggleCell — change the value of a cell from alive to dead manually</li><li>createGrid — take an integer (n) and create a grid array full of (n) row arrays full of (n) cell values (boolean false). This helper would come in handy in a couple of places</li><li>findNeighbors — evaluate each cell in an existing grid, find the number of live neighbors. This is O(1) — it gets called on a cell, then accesses 8 distinct cells to increment a count variable. It returns that count variable, and updateGrid measures the conditional statements against it.</li><li>updateGrid — Loop through the existing Grid and create a new Grid based on the evaluation of each cell in the existing grid. My first pass of this is O(n²). I have to loop through the outer array and consider each Row, and then loop through each Row, where I call findNeighbors on each cell. Based on the determination (i.e. this live cell has four live neighbors, kill it), I update the corresponding cell in the new blank grid. When every cell has been evaluated, I call setState on the Grid component to replace the old grid with the new one, and to increment the generation. All components then re-render based on the change to the props they’ve been passed. Nested loops, n² re-renders: I acknowledge this is a hacky first pass.</li><li>startGame — after a few cells have been toggled, call updateGrid on an interval of 25 ms</li><li>endGame — stop that interval</li><li>resetGrid — replace the existing grid, whatever’s in state, with a blank grid. Reset the generation counter to 0.-</li></ul><p>(Note: this is definitely not the fastest way to do this. I wanted to get an ugly version done and iterate from there.)</p><p>Finally — I decided to deploy using Firebase, and to stick this on <a href="http://erinkoen.com/projects/conways">a route in my portfolio page</a> (that at the moment you can’t get to from anywhere but direct URL entry).</p><p><strong>STEP 3: Carrying Out the Plan</strong></p><p>I… re-learned React. I like to think I kept things pretty tight. One class component, two functional components, a bunch of CSS. (Note, I do NOT like CSS. I might write about why later).</p><p><strong>STEP 4: Looking Back</strong></p><p>Three main notes:</p><p>My updateGrid algo is not especially performant (though it does work alright on grids &lt; 50 squares) for two reasons. My initial inclination is that it’s actually the React re-render calls that are slowing it down. My next step is refactoring with the html Canvas component, which I opted out of for the sake of job interviews this week. I believe that’ll speed things up immensely.</p><p>My next step will be honing the algo in search of the mythical O(n) solution. I started the week playing with a solution that used hash tables, which I might revisit.</p><p>Finally, I want to implement a randomizer to start the Game. At the moment you have to choose which squares are alive and which are dead. While I personally don’t mind playing cell god, it’s not immediately intuitive. I’ve actually got this partially built, so it’ll probably be the next iteration.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d214b66eab96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Crypto Carry Trade]]></title>
            <link>https://erin-koen.medium.com/the-crypto-carry-trade-c26c7d488c8f?source=rss-a9b8b55e667f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c26c7d488c8f</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[crypto]]></category>
            <dc:creator><![CDATA[Erin Koen]]></dc:creator>
            <pubDate>Tue, 02 Apr 2019 23:25:27 GMT</pubDate>
            <atom:updated>2019-04-02T23:36:24.815Z</atom:updated>
            <content:encoded><![CDATA[<h3>Matteo Leibowitz on Twitter</h3><p>it might possibly maybe be a good idea to borrow Dai @ 0.1% APR on @DharmaProtocol and lend Dai @ 37.19% APR on @getnuo 😶</p><p>I’ve been keeping a close eye on what’s happening at <a href="http://dharma.io/">Dharma</a> for a while now. I love the idea of programmatically managed debt issuances. I know there are issues — covenants and the <a href="https://twitter.com/WGMGpodcast/status/1110670086778564608?s=20">oracle problem</a>, for one — but I think that if and when those issues are solved, you could get creative with tokenized structured finance in ways that you couldn’t with traditional equity. I actually low-key pitched building a Dharma <a href="https://developer.dharma.io/primers/underwriters">underwriter</a> for oil and gas mezz debt and drillcos to a broker dealer with whom I was interviewing for a totally unrelated job in foreign exchange. They didn’t give me an outright no to the underwriter (they should have), but I didn’t get the job. (In retrospect, a great miss but that’s neither here nor there).</p><p>This is all to say that when the Dharma team announced <a href="https://www.dharmalever.com/">Lever</a> and a teaser rate to borrow DAI at 10 bps for a month, I was paying attention and signed up for the alpha waitlist. ETH was sitting around $130 and I figured I’d lever (smh)up a little just to take the platform for a spin. Unfortunately, I happened to see the above tweet the day I got off the waitlist, so instead of just buying more ETH, I thought I’d give the trustless carry trade a go.</p><p>And it worked. When you send it ETH, the Lever smart contract rewards you with DAI and asks that you return it in 28 days with a little bit of interest. As the value of ETH fluctuates, Dharma keeps you informed.You get emails whenever your collateralization ratio drops below their safety threshold (150%). My liquidation point was $113ish, so I sort of ignored these reminders.</p><p>Fresh DAI in my wallet, I signed up for an account at <a href="https://app.nuo.network/">Nuo</a> and sent it off as a ‘Reserve’, available to be borrowed at a rate their smart contract determines based on supply and demand. I was quoted around 22% (apr). A couple days later, I started to see interest accrue.</p><p>And that’s essentially it. I haven’t closed the position yet, but imagine it’ll four Metamask transactions and done. I’ll be slightly wealthier in DAI terms and my ETH position will be unchanged. Note: the economics of this trade are blown to bits by the overcollateralization on the Lever side of things. Just absolutely destroyed.</p><p>So, if it’s not going to make me rich, what did I get out of it?</p><p>One of the narratives that’s been kicking around since I started following crypto two years ago is this idea that once tools are built which abstract away the complexity of the underlying transactions, user growth for the asset class will go parabolic. Both Lever and Nuo are sleek. They are almost too sleek. There’s actually not a <strong>ton</strong> of information on either dashboard about what your loan or debt is doing on a daily basis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q0FlFtiQhxENdoua02s17A.png" /><figcaption>The Dharma dashboard.</figcaption></figure><p>I looked around and haven’t been able to find an explanation of what happens when you get liquidated on Dharma. I would assume it’s similar to a CDP, but who’s handling the process? I doubt it’s happened to anyone, as ETH hasn’t dropped below about $128 since the product launched. But the dynamics would be nice to understand ahead of time. I’ve reached out to them and will update accordingly.</p><p>You’ll also notice that interest isn’t explicitly broken out anywhere. Obviously it’s (amount outstanding - principal), but that amount outstanding number is generated on day 0. Does that mean interest doesn’t actually accrue daily? And if that’s the case, what happens if I close my loan early. Am I on the hook for the whole thing? Or just ((days borrowed/28) * 1.001 * principal)?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*myLmtmm-kOycIozuTQ-Ckw.png" /><figcaption>= just about .75% annualized cash on cash return. Likely less depending where you strike ETH. Is that good?</figcaption></figure><p>On the Nuo side of the spread, it was impossible to tell whether my reserve had actually been loaned out. I sat with $0.00 in gains for a couple of days. The loan dashboard shows a DAI price chart which… is sort of relevant, I guess. I’d at least like the option to see whatever factors the algorithm is taking into account to generate an interest rate displayed graphically.</p><p>So my takeaway from all this: directionally correct. Access to credit and the ability to provide it from one wallet is amazing. And the UI both of these platforms have provided are 100x easier to use than a bank. They’ve both stripped away almost all complexity. But I think they might be overshooting the mark there. Users who are thinking about this kind of thing and making decisions to borrow and lend want more information than either of these services currently provide. THAT SAID: it’s a great opportunity for developers (me, maybe?) to layer on analytics services as I would imagine both smart contracts are auditable. Sounds like a <a href="https://twitter.com/Austen/status/974513603452653569?s=20">Lambda Labs</a> project in the making.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c26c7d488c8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lambda Build Week II]]></title>
            <link>https://erin-koen.medium.com/lambda-build-week-ii-c0bbed1788e3?source=rss-a9b8b55e667f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0bbed1788e3</guid>
            <category><![CDATA[lambda-school]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Erin Koen]]></dc:creator>
            <pubDate>Thu, 14 Mar 2019 22:24:56 GMT</pubDate>
            <atom:updated>2019-03-14T22:26:43.214Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m finishing up my second build week at Lambda School. This time around, I used React and Redux to build an app that ingested data from a back end server my teammates wrote in node.js. It was provided to them by the Data Science members of our team, who pulled it from the Yelp API.</p><ul><li><a href="https://github.com/erin-koen/tacos-yelp/tree/master/tacos">erin-koen/tacos-yelp</a></li><li><a href="https://yelp-tacos.firebaseapp.com/signup">React App</a></li></ul><p>^^ sign up with any un/pw combo you like.</p><p>The MVP specs were:</p><ul><li>Data Science: do a sentiment analysis of every yelp review to arrive at a score for that review.</li><li>Front End: Build a React app that displayed the restaurants being reviewed, and could toggle between the adjusted score and real score for those restaurants. Route to reviews for individual restaurants. Build a login that stores a JWT token in local storage.</li><li>Back End: Connect data science and front-end. Deliver JWT token to front-end.</li></ul><p>I built an app that did just that, fetching data from the server and using redux to manage which components received what info. Even with just three pages, things get complicated. Redux makes it easy for each component to access a global state whenever they need it, but it’s tricky to figure out when to update that global state. I worked with dummy data and dialed everything in for the first four days of the week while data science worked their magic.</p><p>Right around Feature Freeze (think “pencils down”), I got the real dataset from my teammates. There was a minute difference in the way the objects were formatted — adjusted reviews were on a second data set — and it screwed up every component downstream of the GET request. As it was written, my app was useless in interpreting the data as it was provided. For demo, I’ll just be using the dummy data, which is a real let-down.</p><p>But there are some great things I took away from this week.</p><ol><li>Hammer down your file structure early. I spent four hours this afternoon working out kinks trying to deploy because build scripts were looking in the wrong folders for dependencies that I’d deleted two days ago. It’s easy to let this stuff spiral out of control (“Ohhhhhh, Material UI is pretty” *yarn add @material-ui/core* “Actually this will be more of a pain than it’s worth to refactor”).</li><li>Be more semantic in how you name components. I had ‘restaurant’ and ‘taco’ used interchangeably for a couple of days because I thought ‘taco’ was funny. It’s wasn’t. It was not funny at all. Pick a word that describes what you’re trying to build and use it consistently, and with modifiers that describe why they’re modifying it.</li><li>Building a UI around a data set <strong>requires</strong> that you know what that dataset is and is not going to provide. It <strong>requires</strong> that you have a clear understanding of how the data is going to be formatted, and what parts of that format are important.</li><li>I am BAD at making things pretty. I just lose interest in making design decisions beyond those that impact functionality.</li></ol><p>It’s an exhausting week, and it sucks to not have a finished product to show off. But I feel infinitely more comfortable in being able to navigate and manipulate complex states, and to use those states to dynamically change the UI of an app. And I guess that’s kind of the point.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0bbed1788e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Who Won the House?]]></title>
            <link>https://erin-koen.medium.com/who-won-the-house-7ee091623137?source=rss-a9b8b55e667f------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ee091623137</guid>
            <category><![CDATA[augur]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Erin Koen]]></dc:creator>
            <pubDate>Wed, 09 Jan 2019 15:31:48 GMT</pubDate>
            <atom:updated>2019-01-15T21:32:33.405Z</atom:updated>
            <content:encoded><![CDATA[<p>My First Experience with Augur</p><p>Apologies in advance — no pretty pictures or charts. And Medium is being a bit weird so no subtitle either. I’ll put a tl;dr up front to entice you instead.</p><p><strong>Conclusions:</strong></p><ul><li>If something seems too good to be true, it is. I was lucky to get out flat-ish.</li><li>Augur’s complex resolution process, coupled with its total lack of clarity via the UI, makes it really unpleasant to use and in my view, inefficient as a hedging tool. I think that without some major changes to both, it’s unlikely to ever gain anything more than a cult following.</li></ul><p>On November 13, 2018, I synced my Augur node, logged into Metamask, and bet 2.5 ETH (at the time, about $500) that the Democrats would win a majority in the United States House of Representatives in the 2018 mid-term elections. I paid 94%, meaning that if the outcome of the election was a Democrat majority, I would earn a 6% return (less fees, which were negligible). Of course, the elections had happened a week prior and the results were in. The Democrats had won soundly. This market persisted, however, and didn’t expire until December 10th.</p><p>I made my bet and waited till the expiry to follow up on it. Really, I just wanted to play with Augur and an easy money winner seemed like a good way to get my feet wet. I was interested to see the settlement process and delivery of winnings, how the service reported, and just generally what the operational flow was like. I can now say that it isn’t great.</p><p>The following leaves out a TON of subtlety around specific roles played by the market creator, designated reporter, and more. The reporting process is so complex that a simple mind such as mine can’t grasp how it could possibly align the incentives of all participants. Be that as it may…</p><p>The settlement process occurs in sequential 7-day <em>fee windows</em>, during which fees are collected in REP from those reporting on the event’s outcome. Those REP are distributed to the reporters who match the consensus, and seized from those who report a non-consensus outcome. When consensus is reached, those reporters are entitled to a proportion of the market’s transaction fees (in ETH) equal to their stake in the market’s total pool of REP.</p><p>Got that? If I was good at PowerPoint I’d draw you a flow diagram. Instead I’ll make a list.</p><ul><li>The Market’s event occurs.</li><li>During the <em>Designated Reporting</em> phase, the market’s designated reporter (specified at market creation) reports the outcome, which is labeled the <em>tentative outcome. </em>If the designated reporter doesn’t turn up, <em>3 </em>days elapse until they’re deemed a no-show.</li><li>If the designated reporter fails to show up, the market enters the <em>Open Reporting</em> phase, in which anyone can report the outcome. The first to do so collects a <em>no-show bond</em> from the market’s creator in the form of a stake on the reporters chosen outcome. In this case, the outcome reported by the first public reporter is now the <em>tentative outcome</em>.</li><li>At this point, the market is <em>Waiting for Next Fee Window to Begin</em>. This is equal to 7 days minus (however long the <em>designated reporting </em>phase was, plus however long the <em>open reporting</em> phase was).</li><li>The market enters the <em>dispute round</em> (another 7 day window), in which any holder of REP can stake REP on an outcome other than the tentative outcome. If the amount of REP staked on an alternative outcome is greater than the <em>dispute bond size</em> (predetermined by the market’s creator), the market has been successfully disputed and, at the end of this phase, enters a new dispute phase.</li><li>This process repeats itself <em>ad infinitum </em>until the amount of REP staked on either outcome exceeds a certain threshold (2.5%) of total REP outstanding. At that point, if there is still no consensus, the market enters the <em>Fork State</em>, which frankly I don’t have the inclination to really dig in to. I will say that the whitepaper describes it as a “method of last resort” and “very disruptive”. And it takes 60 days.</li><li>Eventually, when a market’s outcome is reported either via a dispute round in which the reporters reach a suitable consensus, or via the fork state, the market’s winners are paid out.</li></ul><p>So this is all quite convoluted. What it means in practice is that a minimum of 14 days will pass before winnings are distributed. Which in my mind makes this platform basically useless beyond the occasional recreational wager. No marketmaker or trader is going to want to manage an uncertain settlement process whose minimum time is two weeks, and whose maximum time is theoretically infinite (though practically i would imagine three months is about as long as it would go)(very hand wavy on my part there).</p><p>Bringing this back to real life, my position was long democrats at 94%, in a market that expired December 10th. The Democrats won the house in the midterm elections, but they didn’t take control until sworn in on January 3rd. The market didn’t specify a date for Democratic control. That being the case, it was technically asking who controlled the house on December 10th, which of course was the Republicans. <strong>GOTCHA!</strong></p><p>This nebulous market design enraged a huge number of people. (It was the most actively traded market in Augur’s history). So settlement was going to be a drawn out process. However, the UI never described ANY of what was happening behind the scenes, other than to say the market was “In Reporting”. Which, given the complexities of the reporting process, was an essentially useless tidbit of information.</p><p>On my most recent login, I noticed that the market was now 95.5%/97.5%. I hit the bid, locking in a .03 ETH loss thanks to fees. I’d rather those 2.47 ETH back in my control, rather than stuck in a smart contract dreamed up by a Reddit troll for the foreseeable future while endless 7 day reporting windows roll by.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ee091623137" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I’ll Read It For You, Vol. IV]]></title>
            <link>https://erin-koen.medium.com/ill-read-it-for-you-vol-iv-c7b0c2a2ae89?source=rss-a9b8b55e667f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7b0c2a2ae89</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[cryptoeconomics]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Erin Koen]]></dc:creator>
            <pubDate>Wed, 12 Dec 2018 16:58:37 GMT</pubDate>
            <atom:updated>2019-01-15T22:00:57.708Z</atom:updated>
            <content:encoded><![CDATA[<h4>Summarizing Chris Burniske’s “Bitcoin &amp; Ethereum: Prices are Down More than the Fundamentals”</h4><p>I’ve been meaning to take a trip into the hazy world of crypto network economics for a while now, and writing an I’ll Read It For You for <a href="https://medium.com/@cburniske/bitcoin-ethereum-prices-are-down-more-than-the-fundamentals-88fd18a86d14">the latest Chris Burniske post to make the rounds</a> seemed like a good place to start. My thought in writing these summaries is that distilling the information presented by the experts into a shorter, more accessible post will force clarity of thought on my part. In the case of crypto network economics, however, clarity is an illusion; data is opaque and definitions are fluid.</p><p>I left this essay with an additional 8 Medium tabs open and a notebook full of questions. In short, as I’ve mentioned before, when it comes to valuing and pricing crypto assets, no one has any idea what they’re doing. But that’s not reason enough not to try! As Burniske said (<a href="https://medium.com/@cburniske/theory-follows-price-follows-theory-304ef97d1b71">in a separate essay</a>), “Note that hundreds of years passed between the creation of the first stock market and the application of DCFs to value equities. I expect crypto to converge on its models of choice an order of magnitude faster, as markets, data, and number-crunchers are now ubiquitous.”</p><h3>The Network Activity / Network Value Ratio</h3><p>I’ll start this summary by noting that I believe the main source of confusion in the practice of valuing and pricing crypto networks is the total lack of consensus about what both the numerator and denominator in this ratio should be. Adding a further layer of complexity is the fact that clean and reliable data sources are elusive.</p><p>Be that as it may, it’s intuitive to believe that activity on a blockchain will influence the value of that blockchain’s native coin. The more use they’re seeing, the greater their value, right? Metcalfe’s Law is a commonly quoted maxim that says exactly this; posited by a guy (who invented ethernet, not a big deal) in the early 80s as a way to value telecom networks, it says that a network’s value is proportional to the square of its connected users. It’s tracked well with <a href="https://link.springer.com/article/10.1007%2Fs11390-015-1518-1">social networks</a> and has seemingly become accepted wisdom.</p><p>It could very well be that Metcalfe’s Law is a valuable tool to measure crypto network activity and relative value. In his essay, Burniske suggests a number of different proxies for activity: number of daily transactions; estimated daily transaction value (in USD and only for bitcoin)[1]; gas used (in ETH for ether); and Daily Unique Addresses Used; and total miner hash rate for each blockchain[2].</p><p>First, he plots Total Network Value (simply defined as coins outstanding*price) alongside each individual proxy for network activity from peak value to the present (December for BTC, January for ETH). This paints a simple picture but doesn’t give much insight into whether current asset prices are fair value.</p><p>He then goes on to measure the difference in each proxy as a percentage of the proxy at peak price (i.e. current daily ETH transactions are 48% of daily ETH transactions on January 13, 2018 when the Network Value peaked). Next, he then applies Metcalfe’s Law to that difference to imply the justified change in Network Value (i.e. 0.48² = 0.23, implying a 77% decrease in Network Value).</p><p>In all but one case (daily transaction value for BTC), the drop in Network Value between the all time highs and today was greater than Metcalfe’s Law would imply.</p><p>It’s worth noting that he couldn’t get numbers for daily active ETH wallets. Data below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*0-MfB0gPwZqqlHeLs_Eq4Q.png" /><figcaption>Anyone know how to put a table in a medium post? Data below.</figcaption></figure><p><a href="https://docs.google.com/spreadsheets/d/1Bjgpb1eYZ9UQjFwvuEmScPkNoRIXcn2tXO6XyURIaNk/edit#gid=0&amp;range=A1:G10">https://docs.google.com/spreadsheets/d/1Bjgpb1eYZ9UQjFwvuEmScPkNoRIXcn2tXO6XyURIaNk/edit#gid=0&amp;range=A1:G10</a></p><p>My high-level takeaway is that these limited sets of metrics imply that BTC and ETH <em>might</em> be oversold. It’s not going to change my weekly accumulation schedule, and it of course doesn’t take into account any of the more practical market dynamics, like I detailed in <a href="https://medium.com/@erin.koen/ill-read-it-for-you-a9fe4b653e8c">my last post</a>. This reading will, however, prompt me to think more about the following things:</p><ul><li>Metrics to evaluate network activity. How do they differ between networks and use cases? Is the a price to earnings ratio for crypto? (My gut says ‘No’.)</li><li>How to evaluate network value. Lots of attack vectors here — UTXO age, monetary policy wrt inflation and deflation schedules, velocity, etc. I’ll be starting with Nic Carter’s talk from Baltic Honeybadger and seeing where it goes.</li><li>Data integrity and availability. There’s a real opportunity for someone to be Bloomberg here, as Burniske notes in his piece. Lots of people doing good work (<a href="http://messari.io/">Messari</a>, <a href="http://coinmetrics.io/">Coinmetrics</a>, <a href="https://nomics.com/">Nomics</a>, etc..), I’m looking forward to see them develop.</li></ul><p>[1] I have a small issue with Daily Transaction Value as a predictive indicator of Network Value. Aren’t they circular? In other words, doesn’t Daily Transaction Value (measured in USD), drop linearly with price?</p><p>[2] My understanding of the relationship between miner hashrate and coin price has been highly influenced by the <a href="https://medium.com/coinshares/an-honest-explanation-of-price-hashrate-bitcoin-mining-network-dynamics-f820d6218bdf">CoinShares post from last month</a>. My reading is that hashrate is necessarily a lagging indicator of price and thus not useful for evaluating current relative value of a network. It’s also currently higher (by a lot) than at the respective market peaks. Burniske sort of shunts it off to the side in his piece to focus on the ‘demand-side’ metrics above.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7b0c2a2ae89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I’ll read it for you.]]></title>
            <link>https://erin-koen.medium.com/ill-read-it-for-you-a9fe4b653e8c?source=rss-a9b8b55e667f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9fe4b653e8c</guid>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[tldr]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Erin Koen]]></dc:creator>
            <pubDate>Mon, 26 Nov 2018 23:26:09 GMT</pubDate>
            <atom:updated>2018-11-30T17:02:16.686Z</atom:updated>
            <content:encoded><![CDATA[<h3>I’ll read it for you, Vol. III.</h3><h4>Summarizing Meltem Demirors’ “The Truth About the Crypto Crisis ’</h4><p><a href="https://twitter.com/Melt_Dem">Meltem</a> Demirors’ <a href="https://medium.com/coinshares/the-truth-about-the-crypto-crisis-7a38125983d5">post last week</a> was a nice snapshot of the crypto industry at a moment in time. ‘Nice’ is of course figurative; at this particular moment in time it’s difficult to describe the crypto industry in terms that aren’t apocalyptic. With that in mind, Demirors does a good job of explaining, from the point of view of both investors and operators, how we got to where we are, what’s currently happening, and what the outlook is for the future.</p><p><strong>How we got here:</strong></p><p>You’ve read the <a href="http://www.usv.com/blog/fat-protocols">fat protocol thesis</a>. You’ve likely read why f<a href="https://blog.coinfund.io/fat-protocols-are-not-an-investment-thesis-17c8837c2734">at protocols are not an investment thesis</a>. You follow Meltem, and the <a href="https://twitter.com/KyleSamani">Multicoin</a> <a href="https://twitter.com/TusharJain_">and</a> <a href="https://twitter.com/AriDavidPaul">Blocktower</a> and <a href="https://twitter.com/cburniske">Placeholder</a> guys. (Lots of guys, I know. I don’t love that, and would love suggestions of more women who are thinking about this kind of thing to follow on Twitter). So you know that there’s considerable debate about where value is going to accrue within cryptonetworks. There’s a lot of smart people spending a lot of energy to hypothesize and analogize and medium-ize. But what gets obfuscated in these hundreds of thousands of words is the fact that <strong>no one currently knows the answer</strong>. There’s a general understanding that cryptocurrencies and the blockchains they run will create value<em> somewhere</em>. But nobody knows how to invest in a systematic manner in the places where that value will be captured.</p><p>Demirors draws a comparison that’s been bandied about for a while now. In the dot com bubble, traditional business models and distribution networks were being overwritten by the internet, and investors who were used to valuing companies based on long-held assumptions about user acquisition costs and lifetime values were throwing money at businesses they didn’t understand because they didn’t want to be left out. They knew the internet was a good thing for most businesses, but they didn’t know exactly <em>why</em>. And even if they did have a pretty reasonable idea of <em>why</em>, it was impossible to guess at the <strong><em>magnitude</em></strong> of the effects that <em>why</em> would have.</p><p>18 years ago, the result was pantsthatzipintoshorts.com or whatever IPOing at a $12 billion valuation and being salvaged shortly thereafter for the copper wire in the warehouse walls and whatever excess zippers were in inventory. Why IPO in the first place? Because they could.</p><p>The recent analog to the pantsthatzipintoshorts.com IPO is any ICO. I mean that literally. Any of them. Pick one from this handy list I made:</p><p><a href="https://messari.io/onchainfx/view/72C2485E">Crypto News, Pricing, and Research</a></p><p>Projects ran ICOs in 2018 for the same basic reason terrible businesses IPOd in 2001. Because they could. And why not? In an ICO, the cost of capital to the project is essentially zero. It’s non-dilutive. There are no caveats: no ratchets to negotiate, no new board members to accommodate, no IR reports to disseminate. So, a bunch of operators raised a ton of money with no oversight and no rules about how they can spend it. What could go wrong, right?</p><p><strong>Where we are:</strong></p><p>Briefly, we are at the front edge of capitulation. I’ll shorten this part up a bit because everyone knows how bad it is out there.</p><p>Projects have to pay bills (salaries, lawyers, ops, you name it). The only thing of any value on many balance sheets is BTC or ETH raised in an ICO. That being the case, projects hit the bid and sell crypto for fiat, driving down crypto asset prices further. Death spirals abound.</p><p>Investors are in similar situations, where they have a book full of smoke and mirrors that they can’t sell. And in many cases it’s not just a case of “we can’t sell this all because it’ll move the market”, it’s a case of “there is literally not enough on the bid to get out of our current position”. Pomp did a good job of <a href="https://offthechain.substack.com/p/icos-and-crypto-fund-managers-are">painting this picture</a> in a recent newsletter. Meltem suggests that these managers just mark these positions down, sell whatever they can that’s liquid, and hunker down.</p><p>Besides chronicling the bloodshed, Demirors makes two interesting points that are worth highlighting:</p><ol><li>Some mid-cap cryptoassets have fared better through this bear market than the large caps (BTC, XRP, ETH). She postulates that “these are projects have grown up in the shadow of the large caps above; and have less “drama,” more (and better) comms and marketing; a loyal base of stakeholders, some recruited through airdrop or ICO; and a real focus on unique and specific implementations and use cases”. This all smells like better management to me, and indeed Demirors makes the argument that it’s through **centralization** that these projects have survived.</li><li>I wrote above that the cost of capital to the project for an ICO is zero. That might be technically true, but there is a psychological cost that’s harder to quantify. It doesn’t sit on a balance sheet or change with quarterly income statements. These projects raised money and built communities around a promise. Demirors points out that in large part, no one has shipped product that comes anywhere close to fulfilling that promise (I see you, Augur, stop raising your hand). And in all likelihood, thanks to the death spirals mentioned above, they never will. It remains to be seen what the cost of this technical debt will be. I have to believe that there will be reputational repercussions, and that history will not judge kindly those who raised hundreds of millions of dollars in funding and did materially nothing with it. As the asset class matures, and we get closer to understanding where value accrues, one has to imagine that investor diligence operations will surface these charlatans and they’ll be shunned. I’m setting up a reminder to revisit this in 5 years.</li></ol><p><strong>What we’re doing about it:</strong></p><p>I use ‘we’ in that subhead rather generously. I personally am learning to write code, writing this medium post, and accumulating as much bitcoin as possible (not financial advice etc etc). Demirors lays out four categories in which investors and operators are doing work to capture value on the next crypto upswing.</p><ol><li>Institutional investors are looking for exchange traded products and GPs to get exposure to the crypto-native assets themselves. Buying and holding a bitcoin is so far out of the operational expertise of traditional LPs that they’ll continue to pay a premium for “existing strategies that they can understand, report on, and easily manage with their existing infrastructure.”</li><li>Private companies will be focused on building tools for the speculative use case. She highlights the main players — Bitmex, Binance, Coinbase, Circle — and suggests they will continue building these tools both organically and through acquisitions.</li><li>Public companies won’t put a stop to ongoing crypto projects because of the downturn in prices. Demirors points out that planning cycles for these companies are necessarily longer and that projects set in motion when bitcoin was mid-parabola are likely still going, whether the purpose was to “(1) create new revenue streams; (2) play “innovation” theater; and (3) build enterprise value.”</li><li>Crypto funds and asset managers will suffer. However, Demirors posits that the good managers will find a way to profit on short-term price volatility while keeping true to their long term theses. I have a little trouble swallowing this one, as the complete lack of any derivatives market limits the strategies for short-term trading to essentially “buy bitcoin when it’s low and sell it when it’s a little bit higher”. It’s hard to make 2/20 trading spot without getting your eyes ripped out on Bitmex.</li></ol><p><strong>Where we’re going:</strong></p><p>Demirors finishes on a positive note. She points out that the community is larger and stronger now than it ever has been. Looking at talent flows into crypto, it’s hard to disagree. She also makes the point that a variety of macro factors are pushing traditional wealth creation and retention away from centralized points of failure, and towards decentralized financial systems. That being the case, those systems with battle-hardened governance processes will continue to gain adoption by the masses.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9fe4b653e8c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EEK’s Book Report: Privacy in Cryptocurrencies]]></title>
            <link>https://erin-koen.medium.com/eeks-book-report-privacy-in-cryptocurrencies-67092aef27d9?source=rss-a9b8b55e667f------2</link>
            <guid isPermaLink="false">https://medium.com/p/67092aef27d9</guid>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Erin Koen]]></dc:creator>
            <pubDate>Tue, 30 Oct 2018 20:29:36 GMT</pubDate>
            <atom:updated>2018-11-30T17:00:30.893Z</atom:updated>
            <content:encoded><![CDATA[<h3>I’ll Read It For You, Vol. II.</h3><h4>Yi Sun and Yang Zhan’s <em>Privacy in Cryptocurrencies</em></h4><p><a href="https://medium.com/@yi.sun/privacy-in-cryptocurrencies-d4b268157f6c">Privacy in Cryptocurrencies</a></p><p><a href="http://yisun.io/">Yi Sun</a> and <a href="https://yanxzhang.com/academic/">Yang Zhan</a> are both PhDs in Math from MIT. They are both currently teaching and researching in various capacities, and in general seem <strong>very</strong> smart. That shouldn’t discourage you from diving into this essay, however, as they write in a super approachable fashion. If you’re feeling lazy, this is my tl;dr —</p><p>Yi and Yang set out to define privacy in the context of cryptocurrencies and blockchains as a set of design tradeoffs that fall along three axes: <strong>Privacy of Identity </strong>(who owns the addresses specific to a transaction)<strong>, Privacy of Transaction Data </strong>(how much of a given crypto was sent from one address to another, and the very existence of the link between the two addresses)<strong>, and Privacy of State </strong>(how the ledger changed from one transaction to the next). They note that though cryptography can be used to obfuscate each one of these axes, “attackers who want to discover an attribute of the blockchain can combine disparate pieces of information to conclude or guess what they want to know”. Successful protocol design “reveal[s] as little information as possible about specific attributes” while still maintaining the functionality for which is was built.</p><p>This being the case, the authors try to use this essay to encourage specificity. They want you to stop saying, “Monero is more private than Bitcoin” and start saying “transaction amounts are private in Monero”.</p><p>Yi and Yang go into some detail along each axis, but I won’t do anyone any favors by regurgitating it here. You should read it though. I walked away with a more rigorous mental model for how to evaluate a given crypto’s privacy features.</p><p>The authors finish up with a brief overview of how second-layer solutions are helping to increase privacy along some axes, and an even briefer best practices rundown for enhancing your privacy. For the latter, you’re much better off listening in <a href="https://t.co/6TpIAfXsbd">here</a>.</p><p>One aspect I hoped for a bit more clarity on was the tradeoffs that must happen as design choices move along the privacy spectrum from totally transparent to totally opaque. Just for example, what did the designers of Monero sacrifice in order to obscure links between sending and receiving addresses? Any recommendations for readings there would be appreciated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67092aef27d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>