<?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 Adam Tyree Finch on Medium]]></title>
        <description><![CDATA[Stories by Adam Tyree Finch on Medium]]></description>
        <link>https://medium.com/@atyreefinch?source=rss-f46e2bcde9c6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3U_V1-OOPE0VSkSn.</url>
            <title>Stories by Adam Tyree Finch on Medium</title>
            <link>https://medium.com/@atyreefinch?source=rss-f46e2bcde9c6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 08:52:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@atyreefinch/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[Quick set-ups for  Lottie  with both React and React Native]]></title>
            <link>https://medium.com/@atyreefinch/quick-set-ups-for-lottie-with-both-react-and-react-native-85073df519f?source=rss-f46e2bcde9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/85073df519f</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[lottie]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Adam Tyree Finch]]></dc:creator>
            <pubDate>Fri, 20 Dec 2019 14:22:52 GMT</pubDate>
            <atom:updated>2019-12-20T14:22:52.251Z</atom:updated>
            <content:encoded><![CDATA[<h3>Quick set-ups for Lottie with both React and React Native</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*BXh2Vw3Jw1UinUjMpCL5rA.gif" /><figcaption>Animate SVGs with Ease thanks to Lottie and AE.</figcaption></figure><p>If you’re here you’ve probably already heard of Lottie. It’s great framework from the folks at AirBnB that makes it easy to build lightweight SVG animations in After Effects to be used for web apps and more.</p><p>Down to brass tacks, here’s how you can quickly set it up for both React and React Native, using the react-lottie and lottie-react-native libraries, respectively. There are other ways you can utilize Lottie, but we’ll just be focusing on those two libraries here.</p><p>This will not cover how to create Lottie animations in After Effects, but I’m happy to elaborate on that process if you have any questions about it — feel free to leave me a comment below or contact me on Twitter <a href="https://twitter.com/atyreefinch">@atyreefinch</a>. Even if you’re not interested in creating your own animations, you can also find some great Lottie animations for free from the great artists over at <a href="https://lottiefiles.com/">LottieFiles</a></p><p>Let’s go over Lottie for React first. In the terminal, npm install react-lottie (or yarn install if you prefer). Then, in the component you want to feature an animation, import as follows:</p><pre>import React from &#39;react&#39;<br>import Lottie from &#39;react-lottie&#39;<br>import animationData from &#39;path-to-your-lottie.json&#39;</pre><p>And here’s a set up for Rendering the Lottie Component. Lottie objects for react-lottie take one options prop as an object, and other props which control lotties playback.</p><pre>class ControlledLottie extends Component {<br>  state = {lottieStopped: false, <br>            lottiePaused: false}<br><br>  render(){<br>   <br>    const options = {<br>      loop: true,<br>      autoplay: true, <br>      animationData: animationData,<br>      rendererSettings: {<br>        preserveAspectRatio: &#39;xMidYMid slice&#39;<br>      }<br>    };<br><br>    return(<br>      &lt;div &gt;<br>        &lt;Lottie options={options}<br>              height={400}<br>              width={400}<br>              isStopped={this.state.lottieStopped}<br>              isPaused={this.state.lottiePaused}<br>        /&gt;<br>       &lt;/div&gt;<br>    )</pre><p>And you can extrapolate how you can control starting and stopping the animation from there. There area also other props to control for speed and other playback options. To change the speed, for example, you simply add the speed prop as follows:</p><pre>&lt;Lottie options={options}<br>              height={400}<br>              width={400}<br>              speed={2}<br>        /&gt;</pre><p>The speed at 2 will play the animation at 2x speed, and you can of course also change this value dynamically using state or props. You can even have an animation play in reverse with the speed prop, by setting it to equal to a negative value. You can learn more about react-lottie <a href="https://www.npmjs.com/package/react-lottie">here</a>, or alternatively check out the other React Lottie Library, <a href="https://www.npmjs.com/package/lottie-react-web">lottie-react-web</a>.</p><p>Now on to implementation of Lottie in React’s younger sibling, with lottie-react-native.</p><p>First open your project and npm install lottie-react-native. Again, you can also use Yarn here, or expo install lottie-react-native, if you’re using expo for development of your app.</p><p>Next, you’ll need imports as follows:</p><pre>import React from &#39;react&#39;;<br>import { View } from &#39;react-native&#39;;<br>import LottieView from &quot;lottie-react-native&quot;;</pre><p>And set up your component to look something like the following:</p><pre>export default class App extends React.Component {</pre><pre>playAnimation = () =&gt; {<br>    this.animation.play();<br>  };</pre><pre>render() {<br>    return (<br>      &lt;View&gt;<br>        &lt;LottieView<br>          ref={animation =&gt; {<br>            this.animation = animation;<br>          }}<br>          style={{<br>            width: 400,<br>            height: 400,<br>          }}<br>          source={require(&#39;YOUR-PATH-HERE.json&#39;)}<br>        /&gt;<br>          &lt;Button title=&quot;Play Animation&quot; onPress={this.playAnimation} /&gt;<br>      &lt;/View&gt;<br>    );<br>  }<br>}</pre><p>Note that instead of importing the animation like we did in react-lottie in this case we’ll use a require statement in our code as a source prop. You may be able to handle it differently in each framework if you prefer, but this tends to be the convention of most of the code you’ll come across for these frameworks. Like react-lottie&#39;s Lottie component, LottieView for lottie-react-native also takes other props like speed and a boolean for looping.</p><p>And that’s pretty much it! Woo for smooth, lightweight animations from After Effects to your phone or tablet apps in minutes!</p><p>Obviously, this is only a taste/intro but I hope they help you get up and running quickly with one one of these frameworks! Feel free to reach out any time if you have any Qs about the above.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85073df519f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LightSpeed Ahead: Using THREE.js’ Particle System to Render the Galaxy]]></title>
            <link>https://medium.com/@atyreefinch/lightspeed-ahead-using-three-js-particle-system-to-render-the-galaxy-aa89a3b7e1b9?source=rss-f46e2bcde9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa89a3b7e1b9</guid>
            <category><![CDATA[threejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Adam Tyree Finch]]></dc:creator>
            <pubDate>Thu, 21 Nov 2019 17:44:36 GMT</pubDate>
            <atom:updated>2019-11-21T18:17:12.769Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xo4G7Cozk8i7yrQJDfwn8g.png" /><figcaption>Stars! (See cooler animated version below), or also check it out <a href="https://atfmakes.com/numbercommander">here</a></figcaption></figure><p>Over the past couple of weeks <a href="https://medium.com/u/6623ac06e3fd">Graham Flaspoehler</a> and I prototyped and built <a href="https://atfmakes.com/numbercommander"><em>NumberCommander</em></a><em>, </em>a web game for elementary school kids to practice their math skills. While we were designing out our vision we both almost immediately knew that we wanted to have an effect where the ship was flying through space with stars buzzing by quickly. After drawing it out, I knew we had two options that we could use to get this to work:</p><ul><li>Animate the stars effect in After Effects, and render in the file as a looping 2D movie in THREE.js. Since the stars always need to render under the ship and “enemies” (the floating number cubes), you could pretty easily make this effect look pretty nice. OR we could:</li><li>Create a particle system programmatically using THREE.js’ particle emitter system (AKA <a href="https://threejs.org/docs/#api/en/objects/Points">THREE.points</a>), and animate those particles to look like stars flying by the ship.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fshimmeringeminenthound&amp;url=https%3A%2F%2Fgfycat.com%2Fshimmeringeminenthound&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FShimmeringEminentHound-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="2880" height="1800" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ae5773c2c49e3fa8180f79fe115988b/href">https://medium.com/media/7ae5773c2c49e3fa8180f79fe115988b/href</a></iframe><p>I have a bit of an animation background, so for me I knew the former approach would be easier at first, but harder if I wanted to make any changes to the stars quickly. The latter approach would be an uphill climb at first, but should allow us to be much more flexible with the stars moving forward, and allow us to do some cooler programatic effects with the stars down the line if we ever wanted. Here’s how we set it up!</p><pre>var particleGeom = new THREE.Geometry();</pre><pre>var particleMaterial = new THREE.PointsMaterial({<br>  color: &#39;rgb(255, 255, 255)&#39;,<br>  size: 0.3,<br>  map: new THREE.TextureLoader().load(&#39;./assets/particle.jpg&#39;),<br>  transparent: true,<br>  blending: THREE.AdditiveBlending,<br>});</pre><p>Let’s talk about some of the things that are going on in this code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*aHEiB5kn3N-yZ9VdtQPeXA.jpeg" /><figcaption>Particle Texture</figcaption></figure><p>First, we needed to create the particle geometry and material. The Geometry allows us to create an easy to use geometry that will work well with our particle system. For larger projects, you might want to use the more rendering efficient BufferGeometry, but will work great for our little game. The material’s texture is just a simple JPG image of a circle with soft gradient and a black background. We set the material to have transparency and additive blending to ensure it works well with our scene.</p><p>Next we’ll set some variables to easily control the amount of stars, as well as the distance between them, and we’ll push the particle into our particle geometry:</p><pre>let particleCount = 5800;<br>let particleDistance = 53;</pre><pre>for (var i=0; i&lt;particleCount; i++) {</pre><pre>  let posX = (Math.random() - 0.5) * particleDistance;<br>  let posY = (Math.random() - 0.5) * particleDistance;<br>  let posZ = (Math.random() - 0.5) * particleDistance;<br>  let particle = new THREE.Vector3(posX, posY, posZ);</pre><pre>particleGeom.vertices.push(particle);</pre><pre>}</pre><p>Lastly, we’ll just use the particle geometry and particle material to create our particle system, and add that particle system to the scene!</p><pre>let particleSys = new THREE.Points(particleGeom, particleMaterial);</pre><pre>particleSys.name = &#39;particleSys&#39;;</pre><pre>sceneTwo.add(particleSys);</pre><p>One thing you might notice about the above, is that I added the system to “sceneTwo” instead of the standard “scene” that you’ll see in most projects. This is because we want to render our stars below all other objects, so I rendered it on a separate canvas below the main canvas. There may be other ways to do this that are more performant, but this quickly got me the effect I needed</p><p>This gets us to the point where our stars our nicely positioned in our galaxy, now let’s animate them!</p><pre>rendererTwo.setAnimationLoop(()=&gt;{</pre><pre>  if (resize(rendererTwo)) {<br>  camera.aspect = canvas.clientWidth / canvas.clientHeight;<br>  camera.updateProjectionMatrix();<br>  }</pre><pre>  if (playing) {<br>  let particleSys = sceneTwo.getObjectByName(&#39;particleSys&#39;);<br>  particleSys.geometry.vertices.forEach(particle =&gt; {<br>    particle.z += 0.3;<br>    if (particle.z &gt;40) {<br>      particle.z = -10<br>      }<br>    })<br>  particleSys.geometry.verticesNeedUpdate = true;<br>  }<br>  <br>  rendererTwo.render(sceneTwo, camera);<br>});</pre><p>Playing is just a global I set up to control start/end of the game. So the stars are still when you start the game, but take off once the game starts and your ship goes on its number adventure! Right now it’s a bit jarring, but I’ll work to add some easing to it in the future as the ship takes off.</p><p>The particle by default travels at about 18 meters per second (particle.z+=0.3 , rendered 60 frames per second by the animation loop), and resets back to a position in front of the ship again after it passes behind the ship. I’ve also added a bit of fog to my star scene, so that you don’t see the star pop in in front of the ship, but instead it fades in from the distance as it gets closer to the ship and camera.</p><p>That about covers it for our sweet galaxy of stars! Feel free to ping me in the comments or on <a href="https://twitter.com/atyreefinch">Twitter</a> if you have any questions about or if you’d like to more about other effects in our game. Engage!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa89a3b7e1b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Metaverse On Demand: Using Google’s Poly API + AR.js to Search & Render Models Instantly in AR]]></title>
            <link>https://medium.com/@atyreefinch/metaverse-on-demand-using-googles-poly-api-ar-js-to-search-render-models-instantly-in-ar-e95b5145ed9e?source=rss-f46e2bcde9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e95b5145ed9e</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[arjs]]></category>
            <category><![CDATA[a-frame]]></category>
            <category><![CDATA[google-poly]]></category>
            <dc:creator><![CDATA[Adam Tyree Finch]]></dc:creator>
            <pubDate>Fri, 08 Nov 2019 19:11:23 GMT</pubDate>
            <atom:updated>2020-01-15T21:40:24.715Z</atom:updated>
            <content:encoded><![CDATA[<h3><em>Metaverse on Demand</em>: Using Google’s Poly API + AR.js to Search for AND Render Models Instantly in AR</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*-_KCVLyZCmle7tWzPIPq_g.jpeg" /><figcaption>AR.js ❤ Poly</figcaption></figure><p>Whenever someone asks me about AR/VR, I half-jokingly tell them that the reason I’m so passionate about these burgeoning areas of computing is because our current planet is clearly doomed, and I <em>kinda</em> think we have a better chance at plugging ourselves into new digital domains to continue civilization than NASA/Musk/Bezos have establishing robust civilizations on other planets. No disrespect to their efforts in trying to travel further into the stars of course! But if global warming does accelerate as much as some scientists suggest, I actually find it more likely my kid could continue to live on happily plugged in to some human generated universe than she could attempting to traverse the massive distances and and survive harsh environments of space. <em>That</em> stuff is legitimately just too hard… let’s just make our own damn universe instead!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K1aaGS62c0eyYLax5aXZLw.png" /><figcaption>Hologram all the things!</figcaption></figure><p>Macabre jokes aside, AR/VR has come incredibly far over just the past decade, and now we have a ton of amazing tools we can combine in new ways to make experience world building easier than ever. In this post, I’ll walk you through how I combined two of those tools (<a href="https://github.com/jeromeetienne/AR.js/blob/master/README.md">AR.js</a> and <a href="https://poly.google.com/">Google Poly</a>) to and experience where you can render thousands of different holograms on demand, from almost any mobile device.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgfycat.com%2Fifr%2Fcoolficklebird&amp;url=https%3A%2F%2Fgfycat.com%2Fcoolficklebird&amp;image=https%3A%2F%2Fthumbs.gfycat.com%2FCoolFickleBird-size_restricted.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=gfycat" width="720" height="1280" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b286a2d961f84103e478cf254bf93b4/href">https://medium.com/media/1b286a2d961f84103e478cf254bf93b4/href</a></iframe><p>Want to try it out? Just open this <a href="https://atfmakes.com/metaverseondemand">link</a> on your mobile device, and point it at this <a href="https://stemkoski.github.io/AR-Examples/markers/hiro.png">target</a>. By default, it is set to work with the target on a vertical computer screen, but you can also toggle to view on horizontally if you care to print the image target or maybe put it on a tablet.</p><p>Before we get into what’s actually going on in the code, let me just mention some pros and cons of the tools for my approach to help you decide if something similar is right for you.</p><h3><strong>AR.js</strong></h3><ul><li><strong>Pros: </strong>AR.js<strong> </strong>is incredibly lightweight, requires no installations for users whatsoever. and runs very well on even older hardware (60 FPS on older Android Phones).</li><li><strong>Cons</strong>: It requires image targets, and tracking is not as robust or effective as more fleshed out AR platforms like ARKit/AR Core/SparkAR etc.</li></ul><h3><strong>Google Poly</strong></h3><ul><li><strong>Pros: </strong>Thousands of free models for you to use, most with generous licenses that only require attribution to the creator.</li><li><strong>Cons: </strong>Models aren’t always of the highest quality, and the wide variety of formats and options on Poly can make the API a little tricky to work with.</li></ul><p>Also, less of a con and more of a general warning, but Google has a long history of making really cool products that niche audiences and developers love, before eventually discontinuing them because they aren’t profitable enough. Poly strikes me as one of those products that could eventually suffer a similar fate (I very much hope I’m wrong though)! With those caveats in mind, let’s get to the code, shall we?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4jPxIBsztcGluk2e0WvENw.jpeg" /></figure><h3><strong>The Code</strong></h3><p><em>Most </em>of this code was pretty easy. AR.js and A-Frame play together very nicely, <a href="https://aframe.io/blog/arjs/">and you can get a quick start with your own in just 10 lines of code</a>. Another developer has also already created a nice simple version of AR.js with Google Poly models <a href="https://github.com/hemchander23/webar-google-poly-example">here</a> that was good to learn from, but they didn’t do anything dynamic with the actual Poly API, which is what I was most interested in.</p><p>The JSON in the Poly API is… idiosyncratic. Not every object has every attribute, not all attributes are in the same place, the number of results inexplicably varies from page to page, and the nextPageToken system seems needlessly complicated. It is nevertheless somehow still quite endearing… Here’s how I navigated some of the issues.</p><p>For the sake of simplicity, I limited my query to only OBJs. Poly has GLTFs too, but unfortunately most of them are an older version of GLTF that doesn’t work as well with the latest version of A-Frame/AR.js. My search function looked like so:</p><pre>function searchPoly( e ) {</pre><pre>    e.preventDefault()<br>    searchForm = e.target;<br>    keywords = searchForm[0].value<br>    searchForm.reset()</pre><pre>    fetch(`https://poly.googleapis.com/v1/assets?keywords=${keywords}&amp;format=OBJ&amp;key=${API_KEY}`,<br>    {headers: {&#39;Access-Control-Allow-Origin&#39;:&#39;https://atfmakes.com&#39;,}})  <br>    .then(response =&gt; response.json())<br>    .then(saveObjResourcesLocally)</pre><pre>}</pre><p>After making the call, I grabbed what I needed from the API and put it in my own, simpler JSON object to make things a bit more manageable. Unfortunately, almost every object in the API has multiple file formats, but the location of the file formats is not reliable. .OBJ is <em>usually </em>in the first index of formats, but not always so first we needed to find and save the index of the OBJ file:</p><pre>function indexFinder(searchObj) {</pre><pre>    return searchObj.formats.findIndex(format =&gt; format.formatType === &quot;OBJ&quot;);</pre><pre>}</pre><p>Moreover, not every OBJ in the API comes with a .mtl file, so this also had to be accounted for with a bit of logic as well. <a href="https://github.com/polezo/MetaOnDemand">More details can be found on the code</a>, but for the sake of brevity I’ll just note it was a simple if/else statement to check if the resources existed. Now to the meet of the action, rendering the objects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XPaEbuMPR-HdL1vfc5k0xg.png" /><figcaption>Mmhm… that’s some good lookin’ renderin’</figcaption></figure><p>First, the RenderCurrentObj function destroy’s the current item on the page, then, it updates the DOM with a new object from search. It also adds a bit of spin to the object, and adds UI for the user to control the spin/change to next result/resize and other options.</p><p>And that’s pretty much the meat of it! There’s a lot of other <a href="https://github.com/polezo/MetaOnDemand/blob/master/index.js">code in the repo</a>, but most of it is pretty simple DOM manipulation that I don’t think should need much explanation. Happy to answer any Qs if you have them though! Feel free to reach out to me in the comments or @atyreefinch on Twitter any time. I’mma go party with Shortie, Skelly and some CrunchWraps in the mean time:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*k9Nn9UTKg5Ma0NFBoiJ2yQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e95b5145ed9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making an Instagram/FB AR Halloween Mask with Spark AR Studio and Javascript]]></title>
            <link>https://medium.com/@atyreefinch/making-an-instagram-fb-ar-halloween-mask-with-spark-ar-studio-and-javascript-218226942a81?source=rss-f46e2bcde9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/218226942a81</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[instagram-stories]]></category>
            <category><![CDATA[spark-ar]]></category>
            <category><![CDATA[instagram]]></category>
            <dc:creator><![CDATA[Adam Tyree Finch]]></dc:creator>
            <pubDate>Thu, 17 Oct 2019 13:05:53 GMT</pubDate>
            <atom:updated>2020-01-15T20:29:07.460Z</atom:updated>
            <content:encoded><![CDATA[<h3>Making an Interactive Instagram/FB AR Halloween Mask with Spark AR Studio and Javascript</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XywCzqEbJhlqdk3k.jpeg" /></figure><p>I’ve been noodling around with Spark AR Studio — the augmented reality program for Instagram and Facebook — for quite some time now. And, although I’d I’ve made some pretty cool visual stuff, I’ve never really made much interactive using the platform’s robust scripting tools. Making a cool new mask seems like the perfect time to change that, doesn’t it?</p><p>Like any good DIY project post, let’s have a look at our finished result first…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*SX-BZoOAYQhlTfF0baTv6w.gif" /><figcaption>It looks even cooler when it’s not a compressed gif</figcaption></figure><p>You can also try it yourself using <a href="https://www.instagram.com/a/r/?effect_id=978336665899146&amp;ch=MGNjNDQ4MDhjODAyMTQzZTNiNGY2YzYwOTBlNWJlY2M=">this link from your mobile device.</a></p><p>The filter slowly fades in flames around the user’s head as the they open their mouth, and when the mouth passes a threshold of about ~20% open, the user grows devil horns and turns into a demonic floating head.</p><p>Pretty spooky huh?Here’s how ya do it…</p><p>First, I had to source some assets. For the flames, I went to <a href="https://www.detonationfilms.com/UnitK-5.html">Detonation Films Unit K</a> (scroll down past the blood explosions, lol), and paid 7 dollars for the skull burning footage. (Bet you can’t find a better price for flaming skull footage! Love Detonation Films.) I then tweaked the color a bit in After Effects, made it into a simple loop, and exported it as a PNG sequence.</p><p>For the Horns, I turned to <a href="https://www.turbosquid.com/">TurboSquid</a> and browsed the free devil models, then took one of the horns I liked. After that it was time to jump into Spark AR.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n69TW7RIO8KR7ooTPGJ3Xg.png" /><figcaption>The Setup (scene panel to the left) and Code (center)</figcaption></figure><p>Arranging assets in Spark AR is pretty easy if you’re already comfortable with layering and blending from apps like Photoshop and After effects. For my effect, I had a black background on the lowest layer, the animated flames as a middle layer, and a “face mesh” and horns on the top most layer. Before the user has their mouth fully open, the face mesh and black background is hidden, so the flames burn on top of the users face at first as they fade in, then behind the users face when they become a floating demon head. I think it makes for a pretty nice effect that way.</p><p>Now the code. Spark AR Studio uses a unique flavor of JavaScript that with Reactive Programming modules. Most of you are probably a bit more familiar with Imperative Programing, which may mean you have to modify thinking as you work to build your solutions. <a href="https://developers.facebook.com/docs/ar-studio/scripting/reactive/">As Facebook puts it:</a></p><blockquote><a href="https://en.wikipedia.org/wiki/Imperative_programming">Imperative programming </a>is a model of programming that uses a sequence of statements to determine how to reach a certain goal. If you’ve scripted in an environment with the need for an update loop to update values, it’s likely you’ve been using imperative programming.</blockquote><blockquote>Transitioning from imperative to reactive programming requires you to shift the way that you think, because of how values are propagated throughout your program.</blockquote><p>Another way of thinking about this is, when you build your effects, instead of having to build function that regularly checks a condition during to update the effect, <em>the engine keeps that condition live until you tell it otherwise.</em> Pretty neat! Let’s jump in to using it.</p><p>First, we need to declare the modules we will require for our effect as constants:</p><pre>const Materials = require(&#39;Materials&#39;);<br>const Scene = require(&#39;Scene&#39;);<br>const FaceTracking = require(&#39;FaceTracking&#39;);<br>const Reactive = require(&#39;Reactive&#39;);</pre><p>This is all we need for our effect to work, but if you’re just starting out with Spark AR it’s probably a good idea to require ‘<a href="https://developers.facebook.com/docs/ar-studio/reference/classes/diagnosticsmodule">Diagnostics</a>’ as well, so you can get a better handle on how different methods and properties work. Let’s quickly break down why we need the above for this effect:</p><ul><li>Materials is required for us to change the opacity of the flame object in our scene. This is because although Spark AR has an option to toggle objects as visible/hidden, if you want more granular control of opacity like we do for our flames, you need to do it at the material level instead of the object level (like you would in a program like After Effects).</li><li>Scene allows us to easily select objects in our scene for manipulation (so we can grab our horns, background and face mesh).</li><li>Facetracking allows us to get the details of the face and how it changes, which means we can update our view based on the user’s mouth.</li><li>The Reactive module allows us to use math functions on our methods. This is necessary because reactive programming doesn’t play nicely with JS’s standard Math module, and we want to have a multiplier on our effect.</li></ul><p>Alright! Now let’s grab what we need from the scene and materials:</p><pre><em>//sets necessary scene and material constants</em></pre><pre>const face = Scene.root.find(&#39;faceMesh0&#39;);<br>const bg = Scene.root.find(&#39;background0&#39;);<br>const horns = Scene.root.find(&#39;horns&#39;);<br>const flameMat = Materials.get(&#39;SkullBurn_haloLayer&#39;);</pre><p>Most of this^ part should be pretty easy to understand, we’re just grabbing the assets we need to manipulate. root in this instance is just the lowest level of the scene view, and find can be used to select any child or grandchild of the root. Now that we have the assets, we can make the magic part!</p><pre><em>//measures degree of mouth openness</em></pre><pre>const mouthOpeness = FaceTracking.face(0).mouth.openness;</pre><pre><em>//hides horns, background, and facemesh until mouth is at least ~30% open</em></pre><pre>face.hidden = mouthOpeness.lt(0.3);<br>bg.hidden = face.hidden;<br>horns.hidden = face.hidden;</pre><pre><em>//sets multiplier to make flames fade in a bit less subtle</em></pre><pre>const mouthMultiplier = Reactive.mul(mouthOpeness,3.05);</pre><pre><em>//uses multiplied value to tie flame opacity to our multiplied mouth openess</em></pre><pre>flameMat.opacity = mouthMultiplier;</pre><p>Yay magic mouth controlled flaming demon head!</p><p>I think the comments in the code above should explain the code well enough. That being said, I recognize the majority of this blog post was a pretty high level tutorial, and you may have more questions. Please comment below or <a href="https://twitter.com/atyreefinch">ping me on Twitter</a> if you’d like to know any more about the After Effects work, or the Spark AR Studio portion, or anything else! I’d be happy to answer any Qs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=218226942a81" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design, DeFi and DAI — DDEX @ EthDenver]]></title>
            <link>https://medium.com/ddex/design-defi-and-dai-ddex-ethdenver-71e538eda180?source=rss-f46e2bcde9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/71e538eda180</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethdenver]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[ddex]]></category>
            <dc:creator><![CDATA[Adam Tyree Finch]]></dc:creator>
            <pubDate>Tue, 12 Mar 2019 14:49:53 GMT</pubDate>
            <atom:updated>2019-03-12T14:49:53.476Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*wskprcG548_HsIISn4WSHA.png" /></figure><h3><strong>Design, DeFi and DAI — DDEX @ EthDenver</strong></h3><p>Only in its second iteration, EthDenver is already becoming one of the most anticipated web 3 conferences of the year. With a great local developer scene, hundreds of great teams flying in from around the world, and beautiful mountains all around to enjoy it’s easy to see why.</p><p>This year, DDEX’s own Josh Rio was there to <em>Debunk Design Myths in Dapps</em> and help developer’s find their own Dapp’s happy paths. We think Josh’s design expertise is pretty damn invaluable (it touches almost every product at DDEX), so we wanted to make an effort to share it with more than just the folks who were able to make it to Denver this year. So here’s a recap of Josh’s talk, as well as some of the top takeaways we took from the event.</p><p>Want to watch Josh’s whole presentation? You can check it out below, and visit the EthDenver YouTube page for more Dappy goodness.</p><p><strong>Don’t Accept Dreadful Dapp Design</strong></p><p>The most important takeaway from Josh’s talk (and body of work) is that you should <em>not </em>accept bad design in your Dapp simply because this is the early days of the internet of value. There seems to be a common misconception here in the early days of web 3, that — <em>because</em> <em>it is</em> the early days of web 3 — it’s okay to have design that’s not up to web 2 standards and meant for experienced developers. Well we’re here to tell you no, that’s not okay!</p><p>We think bad design only hurts crypto adoption in the short run, and we’re eager to see the community grow together instead of drift into our own little rabbit holes of idiosyncratic design. Here’s a few tips from Josh’s talk on how you can improve your Dapp to help meet the expectation of your users:</p><ul><li><strong>Things Change. </strong>The regulations, best practices and technology available change daily so be sure to design your platform with an expectation that you may need to flip some of their elements on their head. Try and <strong>architect flexibility </strong>as much as you can, and never become too emotionally attached to any one feature or element that you like, only become attached to your users and what works for them.</li><li>Speaking of Users. <strong>Context is King! </strong>You need to be aware of how users are using your application not just in the application itself, but also in the context of the ecosystem around them. Are they using their phone with Wallet Connect to your platform, and are there any distractions they can find along the way? Are your users leveraging MakerDAO to get DAI for exchanging on your platform? If yes how can you make it easier for them? Never consider your Dapp in a vacuum.</li><li><strong>Beg, borrow and steal.</strong> If you see a feature that’s working well in another Dapp, don’t be afraid to emulate it. Everyone is still learning what works in this space, and trends will evolve over time, so there’s no shame in learning from others.</li><li><strong>Keep it simple.</strong> Don’t overthink it just because it’s web 3 technology! What works well in web 2 will frequently work great in web 3 as well.</li></ul><p>DDEX strives to be one of the easiest to use platforms for those new to crypto, day-traders, and API traders alike. We think it’s pretty crazy to suggest that just because it’s new technology we should accept bad design on top of it.</p><p>Interested in learning more about how you can improve your Dapp? Be sure to check out the full video of Josh’s workshop in the video below.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F0lYyu6PUJVI%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0lYyu6PUJVI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F0lYyu6PUJVI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9f66e61c7e0d4b2a547c5f44fb81fff/href">https://medium.com/media/e9f66e61c7e0d4b2a547c5f44fb81fff/href</a></iframe><p><strong>Other cool things we saw in Denver</strong></p><p>There’s almost too much to mention, but here’s just a quick bulleted list of some of our favorite projects and trends we saw in EthDenver. Be sure to check them out!</p><ul><li><a href="https://twitter.com/austingriffith?lang=en">Austin Griffith’s</a> xDAI wallet was even cooler <a href="https://www.coindesk.com/the-next-big-ethereum-conference-will-run-almost-entirely-on-blockchains">than anticipated</a>. It was fast, easy, a ton of vendors got paid in DAI over the course of the conference, and a lot of the <a href="https://medium.com/makerdao/people-xdai-burner-wallet-portable-giving-c8d52685d596">extra DAI went to charity</a>! Expect to hear more and more things from Austin and the MakerDAO team for years to come.</li><li>DeFi FTW — A good chunk of the finalist were unsurprisingly from the DeFi category of Dapps. With the <a href="https://kauri.io/article/c59dfaa3c1cb4ee2bcaeb8ff8a97397c/v2/delfi:-an-on-chain-oracle-you-can-reason-about">Delphi team</a> creating an impressive on-chain Eth/DAI oracle and teams like <a href="https://kauri.io/article/c590a19769d7414f99077b590a7ec218/v2/safe-cdp">Safe CDP</a> improving the experience of decentralized loans for everyone. DDEX is proud to be among the product leaders in this space and can’t wait to see what is built next.</li><li>Open source ❤ Bounties — we’re starting to see more and more projects embrace projects like GitCoin and take other initiatives to improve their platform through decentralized development. At EthDenver, several teams opened bounties to fill needs or niche’s for their platform and fairly pay the developers who helped improve their projects. We find it pretty exciting to see this economy naturally grow and evolve.</li></ul><p>Anything we missed? Feel free to post your own favorites from EthDenver in the comments below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71e538eda180" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ddex/design-defi-and-dai-ddex-ethdenver-71e538eda180">Design, DeFi and DAI — DDEX @ EthDenver</a> was originally published in <a href="https://medium.com/ddex">DDEX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intro to Decentralized Leveraged Trading Part 2: Leverage Boogaloo]]></title>
            <link>https://medium.com/ddex/intro-to-decentralized-leveraged-trading-part-2-leverage-boogaloo-1dd4775f6f22?source=rss-f46e2bcde9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1dd4775f6f22</guid>
            <category><![CDATA[makerdao]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[0xproject]]></category>
            <dc:creator><![CDATA[Adam Tyree Finch]]></dc:creator>
            <pubDate>Thu, 08 Nov 2018 14:01:01 GMT</pubDate>
            <atom:updated>2018-11-08T18:21:01.747Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*v1sErMJLCjoC-ADwsORN6g.png" /></figure><p>You may remember <a href="https://medium.com/ddex/ddex-makerdao-an-intro-to-decentralized-leveraged-trading-f76995fd9239">my post last week</a>, in which I walked you through the steps of getting a loan using <a href="https://dai.makerdao.com./">https://dai.makerdao.com</a>, and showed you how to use that loan to make leveraged trades on DDEX. Shortly after publishing our post, the MakerDAO team released <a href="https://medium.com/makerdao/introducing-the-new-cdp-portal-for-single-collateral-dai-eeec1c766fde">a new portal</a> that makes it even easier create a collateralized debt position (CDP), quickly acquire some DAI to leverage to your hearts desire.</p><p>With this week’s post, I thought I’d quickly walk you through the steps of using the new portal, and also take you through a few other ways DDEX and the rest of the DeFi ecosystem are creating revolutionary new leveraged trading opportunities. We love MakerDAO, but it’s not the only way you can get decentralized leverage for trading on DDEX, so I’d also like to take this time to introduce you to Dharma and dY/dX.</p><p>First though, let’s quickly walk through MakerDAO’s sexy new portal, shall we?</p><h3>CDP.MakerDAO.com</h3><p>At a base level, most of the rules of my <a href="https://medium.com/ddex/ddex-makerdao-an-intro-to-decentralized-leveraged-trading-f76995fd9239">old post</a> still apply. You still need some Eth and a plan to use your leverage, and pretty much everything that happens behind the scenes is the same. The main difference is that about 4–5 of the steps have been abstracted away, so everything is nice and easy and you can go from hitting the CDP portal to trading on DDEX in 5 steps instead of 9. You can also trade directly from your hardware wallet now too, so that’s a nice bonus of the new UI.</p><p>The last thing I’ll note before jumping into the steps is that, by abstracting away some of the process, the new portal costs slightly more gas to get a loan. So if you’re looking to be as efficient as possible — or if you just want to more fully understand everything that is going on in the MakerDAO CDP process — the old method is for you. For the vast majority of users who don’t mind paying a few extra cents for a simpler process, the new portal is the way to go. Here’s the way to do it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nlwl0oQLN8nzZ0OOV5m6OA.png" /><figcaption>The new MakerDAO Portal</figcaption></figure><ol><li>Visit <a href="https://cdp.makerdao.com/">https://cdp.makerdao.com</a></li><li>Select Metamask or the hardware wallet of choice, connect to your wallet and hit “Open CDP.”</li><li>You will see two fields. One with the amount of Eth you’d like to collateralize, one with the amount of DAI you’d like to generate. If you enter in the DAI first, it will tell you the minimum amount of Eth you need to make that loan. Again though I would recommend to use collateral well above the minimum requirement to lower your chance of liquidation.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*CU25nRnSABI9zmG1ja5ucg.png" /></figure><p>4. Click Collateralize and Generate DAI. Agree to the terms on the following page, and click finalize and create your position. You’ll then need to approve the transaction on your hardware wallet or in the Metamask interface. The Portal will then take your Eth through the process it needs to use it as collateral and generate DAI — this usually takes about 4–5 minutes, give or take.</p><p>5. Take your new DAI and go trade on DDEX!</p><p>6. Wait until your token of choice pumps, then return to the CDP portal to close your loan.</p><p>That’s it! As you can see, all of the wrapping and pooling and other actions that happened on the back end for the old MakerDAO portal have been abstracted away, and it makes for a much more user friendly overall process. Pretty cool huh?</p><p>But MakerDAO isn’t the only way you can get decentralized leverage for trading on DDEX. Now let’s have a look at a few of the other ways we can margin trade with Ethereum.</p><h3>Dharma</h3><p>Although with MakerDAO you can only use Eth as collateral (at this time), and you can only get your loans in DAI, with Dharma you can get a token loan for virtually any major asset on Ethereum <em>today</em>.</p><p>For example, on the Dharma powered relayer <a href="https://bloqboard.com/">Bloqboard </a>you can create loan opportunities backed by BAT, DAI, ETH, REP, ZIL and ZRX, and receive loans in any of the top 50 ERC-20 tokens. You can then use those assets for swing trading, market making or other profit opportunities on DDEX.</p><p>Other Dharma powered lending and leverage options are also on the way. From <a href="https://blog.dharma.io/introducing-dharma-lever-1bde1451e95c">Dharma Lever</a> to <a href="https://quickline.market/">Quickline</a> to still others yet to be announced, there’s lots of great ways to get funding for new opportunities on DDEX.</p><h3>dY/dX</h3><p><a href="https://dydx.exchange/">dYdX </a>has what is perhaps the most unique method for providing leverage to traders — it does so directly in the token itself.</p><p>Currently, there are 2 types of margin trading tokens powered by dY/dX — the Leveraged-Ethereum Token (or LETH) and the Short-Ethereum token (or SETH). The neat thing about these tokens is that they allow you to skip all the steps of creating loans or otherwise getting into position with CDPs.</p><p>The entire lending process is abstracted away just by owning the token. Loans still have to be repaid of course, so each margin token only lasts 28 days, and every token that is created expires on the 15th or 30th of each month. At the end of that period, all of the sourcing and repayment is done automatically. So if you have leveraged tokens in your wallet at the time of close, they will automatically be locked in value for the amount of Eth you gained or lost using leverage, minus interest. If you buy SETH, this is negatively correlated to ETH on roughly a 1-to-1 basis — i.e., for ever dollar lost in Eth you profit the equivalent amount. If you buy LETH, profits are positively correlated with the Eth price but with a higher ratio.</p><p>Pretty cool right? And guess what? <strong>dY/dX margin tokens are coming to DDEX! </strong>So soon you’ll be able to margin trade Eth with just a matter of clicks without even leaving our trading portal.</p><p>Whether it’s making bets with stable coins, sourcing loans for market making, or simply taking easy margin opportunities to long or short Eth, we think you can find thousands of great ways to make profits by trading on DDEX. So get out there and start planning your trades today!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1dd4775f6f22" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ddex/intro-to-decentralized-leveraged-trading-part-2-leverage-boogaloo-1dd4775f6f22">Intro to Decentralized Leveraged Trading Part 2: Leverage Boogaloo</a> was originally published in <a href="https://medium.com/ddex">DDEX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DDEX+MakerDAO, An Intro to Decentralized Leveraged Trading]]></title>
            <link>https://medium.com/ddex/ddex-makerdao-an-intro-to-decentralized-leveraged-trading-f76995fd9239?source=rss-f46e2bcde9c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f76995fd9239</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[0xproject]]></category>
            <category><![CDATA[makerdao]]></category>
            <dc:creator><![CDATA[Adam Tyree Finch]]></dc:creator>
            <pubDate>Tue, 30 Oct 2018 13:01:01 GMT</pubDate>
            <atom:updated>2018-10-30T15:56:12.591Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v1sErMJLCjoC-ADwsORN6g.png" /></figure><p>Here at DDEX, we’re super excited about all of the exciting work going on in the world of Decentralized Finance (#DeFi FTW!). From simple spot trading through the Hydro Swap widget, to derivatives on Market Protocol, to bundling tokens and creating indexes on Set Protocol, there’s just so damn many cool new tools that have emerged in 2018 and are enabling new types of financial transactions all over the world.</p><p>Today, we’re going to look at one of the fastest growing pieces of this ecosystem, MakerDAO and DAI. I’m going to show you how to use MakerDAO to create a decentralized loan and generate DAI, and then use that DAI to buy Eth or your favorite tokens on DDEX.</p><p>This is what is called “leveraged trading.” Normally, for traders to be able to do this they have to go through extensive sign-up processes and/or KYC. What’s more, unfortunately many of the centralized exchanges who offer leveraged trading in the crypto world don’t exactly have the best reputation. Fortunately, with the power of decentralized finance, you can do it without any sign-up, login or KYC, AND you can do it all directly from your Ethereum wallet without any fear of hacks or other issues associated with centralized, custodial exchanges. Even better, the current stability fee on a MakerDAO Collateralized Debt Position (CDP) is 2.5%, which is very competitive compared to most loan rates.</p><p>Sounds awesome, right? But before we get started, just let me quickly note that the below process is what you can expect with the current version of MakerDAO. With the incoming release of Muli-Collateral DAI, this process will change slightly — once it does, I’ll update this post with the new process. With that in mind, let’s get going.</p><p>What you’ll need to begin:</p><ul><li>Some Eth</li><li>The Metamask Browser Extension or a Mobile dApp Browser (like Coinbase Wallet or Trust Wallet)</li><li>A plan for using your sweet, sweet leverage (i.e. an idea of what assets you’re long on)</li></ul><p>I’ll be walking you through the steps on desktop, but they should be roughly the same if you’re using a mobile device. Still have questions after going through the process? Feel free to ask in the comments below or ping me @atyreefinch on Twitter any time.</p><p>Before we get too far in, let me make it clear that opening a loan with collateral — and <em>especially </em>collateral that is as volatile as crypto — always involves risk. If your loan ever gets close to it’s liquidation point (more on that later), you can always add more collateral to help protect it. But if you’re not watching closely or if you have no more Eth to add, there is absolutely a possibility that a big chunk of your funds can be lost.</p><p>With that in mind, let’s walk through the steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lk6kiJ7bJds4arUxvkozhg.png" /></figure><ol><li>Visit <a href="https://dai.makerdao.com/">https://dai.makerdao.com/</a> . You should see a dashboard that looks like the one above.</li><li>Wrap your Ether to get WETH, AKA Wrapped Eth. Just like trading on any 0x Relayer, WETH is required for to interact with MakerDAO’s smart contracts (and multiple other dApps in the DeFi ecosystem). It makes your Eth ERC-20 compliant and able to do some fun things.</li><li>Next, you’ll need to swap your WETH for PETH. PETH, AKA “Pooled Eth”. I won’t spend too much time on this, because the PETH requirement will be going away soon with Multi-Collateral DAI anyway. The main thing you need to know is that A) PETH helps keep the system stable, and B), in the event in a sudden “black swan” drop in the price of ETH, your PETH holding could be negatively impacted. There are some positive reasons to hold PETH too and if you’re interested in more information on the topic and how it will change with Multi Collateral DAI, I encourage you to read <a href="https://medium.com/makerdao/introducing-the-new-whitepaper-for-the-dai-stablecoin-system-e7c6caabcfc4">this post</a>.</li><li>Open a new CDP by hitting “Open Your CDP” button (in the lower left).</li><li>Once it is created you can now see it in your “My CDP” section. Before you can get that luscious leverage though, you’ll need to lock your PETH into your CDP.</li><li>After locking you can now “draw” the amount of DAI you would like to receive. This can be up to 2/3rds (66%) of you collateral, however I would personally never do anything more than 40% of my collateral to give myself some leeway and decrease risk of liquidation. I’m maybe a bit more risk averse than others though, feel free to create a loan that your comfortable with, you just need to know how to minimize your liquidation risk.<br>Your liquidation point is determined by the value of your collateral in USD. If it hits that point, your collateral is forced to rebuy DAI you’ve drawn from the CDP, and you may lose a good chunk of your assets in the process. Fortunately if things are going against you and the value of your collateral starts approaching its liquidation point, you can always add more collateral to prevent liquidation. With this in mind it is very important to always know when your collateral will be liquidated. Fortunately this is fairly easy to calculate — your CDP will be liquidated if the value of your collateral in USD hits 150% of the value of your loan.<br>For example, let’s say I took a $300 in DAI loan with 5 PETH as collateral and ETH is currently worth $200. 150% of $300=$450. In order for the value of my collateral of 5 Eth to drop down to $450, Eth would need to fall alllll the way down to $90 before I got liquidated. That seems pretty safe! So let’s move on.</li><li>Complete the CDP process by using the draw command and receive DAI. Congratulations! You’ve just gotten your first trustless loan! Now, let’s take it over to DDEX so we can turn that leverage into some sweet, sweet gainzzzzzz.</li><li>Head over to <a href="https://ddex.io/trade">https://DDEX.io/trade</a> and make that trade you’ve been planning on. If you’ve never traded on DDEX before, there’s a nice onboarding process that can walk you through the steps. If you have already traded on DDEX but haven’t traded with DAI yet, you may need to enable token allowance for the asset. After that, you can buy WETH, OMG, MKR, or ZRX directly with DAI, or convert to WETH and buy a number of other other of tokens.</li><li>Wait until your token pumps, sell a chunk of it into DAI so you can repay your loan. You will also need a small amount of MKR to close out your CDP and pay maintenance fees.</li><li>Head back to <a href="https://dai.makerdao.com/">https://dai.makerdao.com/</a> to close out your loan. You use the “wipe” function to wipe your debt by sending back DAI to the CDP, use the “free” function to get your PETH out, and then the “shut” function to close your CDP and pay the maintenance fee of 2.5% in MKR. You can now convert your PETH back to ETH.</li></ol><p>Wooooo! You just made some nice returns without needing to add any new FIAT to any centralized exchanges, and got all of your ETH back! Ain’t DeFi the greatest?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/104/1*fX3m6ec9Jb6H3L0-Klix5g.png" /></figure><p><strong>More About DDEX:</strong></p><p>Follow us on: <a href="https://www.facebook.com/ddex.io.exchange/">Facebook</a>, <a href="https://twitter.com/ddex_io">Twitter</a>, <a href="https://www.reddit.com/r/ddex/">Reddit</a>, <a href="https://discord.gg/g6C6jfB">Discord</a></p><p>Join our official chat group on: <a href="https://t.me/ddexio">Telegram</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f76995fd9239" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ddex/ddex-makerdao-an-intro-to-decentralized-leveraged-trading-f76995fd9239">DDEX+MakerDAO, An Intro to Decentralized Leveraged Trading</a> was originally published in <a href="https://medium.com/ddex">DDEX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>