<?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 Dheeraj Kumar on Medium]]></title>
        <description><![CDATA[Stories by Dheeraj Kumar on Medium]]></description>
        <link>https://medium.com/@imdheeraj28?source=rss-2df8ab87fa29------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FYOX0Yju7mw9nfMibIRjtg.jpeg</url>
            <title>Stories by Dheeraj Kumar on Medium</title>
            <link>https://medium.com/@imdheeraj28?source=rss-2df8ab87fa29------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 20:55:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@imdheeraj28/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[Writing Smart Contract using Huff]]></title>
            <link>https://medium.com/coinmonks/writing-smart-constract-using-huff-ced6a094c124?source=rss-2df8ab87fa29------2</link>
            <guid isPermaLink="false">https://medium.com/p/ced6a094c124</guid>
            <category><![CDATA[opcodes]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[huff]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Dheeraj Kumar]]></dc:creator>
            <pubDate>Sun, 01 Dec 2024 13:52:51 GMT</pubDate>
            <atom:updated>2024-12-07T06:51:46.112Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s write our first smart contract using Huff.</p><h4>About Huff</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B19SgtIoIYAdBxd_Nk0Z_g.jpeg" /></figure><p>Huff is a low-level programming language designed for developing highly optimized smart contracts that run on the Ethereum Virtual Machine (EVM). Huff does not hide the inner workings of the EVM and instead exposes its programming stack to the developer for manual manipulation.</p><p>The contract is a simple storage contract that has a variable of type uint256. There is a function to update the value and one to read it.</p><p><strong>Solidity Code:</strong></p><pre>// SPDX-License-Identifier: MIT<br>pragma solidity 0.8.26;<br><br>contract SimpleStorage {<br>    uint256 public value;<br><br>    function setValue(uint256 newValue) external {<br>        value = newValue;<br>    }<br><br>    function getValue() external view returns (uint256) {<br>        return value;<br>    }<br>}</pre><h4>Writing in Huff</h4><p>In a transaction, we basically have a calldata that is being sent to the blockchain.<br>Ex:</p><pre>0x552410770000000000000000000000000000000000000000000000000000000000000001</pre><p>This consists of:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ph-HwBVhLv1YKcsSQdc4DQ.png" /></figure><p>Now, we need to get the <em>function_selector</em> (starting 4 bytes) from above calldata.</p><p>But how??</p><p>RIGHT SHIFTING THE CALLDATA. (&gt;&gt;&gt;&gt;)<br><strong>SHR opcode</strong>: shift given bits to the right.<br>But how many bits to shift?? total size-32 bytes, function_selector — 4 bytes<br>So, if we shift it right by 32–4 = 28 bytes (or 28 * 8 = 224 bits), we get the function selector.</p><pre>0x55241077</pre><p>The Huff code till here looks like:</p><pre>#define macro MAIN() = takes(0) returns (0) {<br>  0x00            // Stack: [0]<br>  calldataload    // [calldata]<br>  0xe0            // [calldata(32 bytes), 0xe0]<br>  shr             // [function_selector]<br>}</pre><p>Now we got the function selector.<br>We’ll try to match the function_selector we got with different function selectors we have here (setValue() and getValue()).</p><p>Function_selectors:</p><pre>cast sig &quot;setValue(uint256)&quot;<br>&gt; 0x55241077<br>cast sig &quot;getValue()&quot;<br>&gt; 0x20965255</pre><p><em>setValue(uint256)</em> -&gt; 0x55241077<br><em>getValue()</em> -&gt; 0x20965255</p><p>So, we’ll match the function selector obtained from calldata with the above two and call the matched function.</p><p>We can define interfaces in Huff in the following way:</p><pre>/*Huff interfaces*/<br>#define function setValue(uint256) nonpayable returns()<br>#define function getValue() view returns(uint256)</pre><p>Let’s use the above defined function selectors to try match them with the one obtained from the calldata.</p><pre>/* Huff interfaces */<br>#define macro MAIN() = takes(0) returns(0) {<br>  ...<br>  // Stack [function_selector]<br>  __FUNC_SIG(setValue) // [function_selector, 0x55241077]<br>  // 0x55241077 -&gt; function selector for setValue()<br>  eq                   // [true/false (if top two function selectors match)]<br>  <br>}</pre><p>So, if the function selector from calldata matches with that of “setValue(uint256)”, the program counter should jump to setValue() function and it should be executed. Else it will check for “getValue()” and read the value. If no option matches, it should revert.</p><pre>#define macro MAIN() = takes(0) returns(0) {<br>  ...<br>  // If true (function selectors equal) -&gt; jump to setValue<br>  setJump  // program counter(PC) for setValue() function<br>  jumpi    // jump to &quot;setJump&quot; PC<br>  <br>  ...<br>  <br>  setJump:<br>    SET_VALUE()<br>}<br><br>#define macro SET_VALUE() = takes(0) returns(0) {}</pre><p>Also, if any of the function selector matches, we need to skip the order of instructions and jump to that function. Let’s write the case to check for “readValue” function.</p><pre>#define macro MAIN() = takes(0) returns(0) {<br>  ...<br>  // If false (function selectors not equal) -&gt; check if it matches with getValue<br>  __FUNC_SIG(getValue)<br>  eq       // Stack: [true if function selectors matches]<br>  getJump  // program counter(PC) for getValue() function<br>  // Stack: [true if function selectors matches, getJump(PC)]<br>  jumpi    // jump to &quot;getJump&quot; PC, Stack: []<br> <br>  ...<br>  <br>  getJump:<br>    GET_VALUE()<br>}<br><br>#define macro GET_VALUE() = takes(0) returns(0) {}</pre><p>If no function selector matches with the one from the calldata, it should revert. We can use revert opcode to halt execution and reverting any state changes made.</p><p>The code till now looks like:</p><pre>/*Huff interfaces*/<br>#define function setValue(uint256) nonpayable returns()<br>#define function getValue() view returns(uint256)<br><br>#define macro MAIN() = takes(0) returns(0) {<br>  0x00            // Stack: [0]<br>  calldataload    // [calldata]<br>  0xe0            // [calldata(32 bytes), 0xe0]<br>  shr             // [function_selector]<br>  dup1           // [function_selector, function_selector]<br><br>  // Stack [function_selector]<br>  __FUNC_SIG(setValue) // [function_selector, 0x55241077]<br>  // 0x55241077 -&gt; function selector for setValue()<br>  eq                   // [true/false (if top two function selectors match)]<br><br>  // If true (function selectors equal) -&gt; jump to setValue<br>  setJump  // program counter(PC) for setValue() function<br>  jumpi    // jump to &quot;setJump&quot; PC<br>  <br>  // If false (function selectors not equal) -&gt; check if it matches with getValue<br>  __FUNC_SIG(getValue)<br>  eq       // Stack: [true if function selectors matches]<br>  getJump  // program counter(PC) for getValue() function<br>  // Stack: [true if function selectors matches, getJump(PC)]<br>  jumpi    // jump to &quot;getJump&quot; PC, Stack: []<br>  <br>  revert<br>  <br>  setJump:<br>    SET_VALUE()<br>  <br>  getJump:<br>    GET_VALUE()<br>}<br><br>#define macro SET_VALUE() = takes(0) returns(0) {}<br>#define macro GET_VALUE() = takes(0) returns(0) {}</pre><p>Now let’s try to understand what would happen if the function selector matches with that of <em>setValue()</em>.</p><p>When <em>SET_VALUE </em>macro is called, it should take the input value and update the variable. But how does it update the storage?</p><ul><li>Firstly, get a storage slot</li><li>Read the new value from the calldata</li><li>Use <em>sstore </em>opcode to update the storage</li></ul><p>We have something called as FREE_STORAGE_POINTER() that points to currently available storage slot.</p><pre>#define constant VALUE_STORAGE_SLOT = FREE_STORAGE_POINTER();<br><br>#define macro SET_VALUE() = takes(0) returns(0) {<br>  0x04                 // [4]-bytes offset(need to remove fn_selector to get input)<br>  calldataload         // [calldata - func_selector(or value)]<br>  [VALUE_STORAGE_SLOT] // [value, 0 (or ptr)]<br>  sstore<br>  stop<br>}</pre><p>Now let’s see how <em>getValue() </em>works. To read a value:</p><ul><li>Get the storage slot</li><li>Load the value to memory</li><li>Return value</li></ul><pre>#define macro GET_VALUE() = takes(0) returns(0) {<br>  [VALUE_STORAGE_SLOT]   // [KEY]<br>  sload                  // [VALUE]<br>  0x00                   // [VALUE, 0]<br>  mstore                 // Stack: [], Memory: [VALUE]<br>  return                 // Stack: [], Memory: []<br>}</pre><p><strong>Final Code:</strong></p><pre>#define function setValue(uint256) nonpayable returns()<br>#define function getValue() view returns (uint256)<br><br>#define constant VALUE_STORAGE_SLOT = FREE_STORAGE_POINTER()<br><br>#define macro MAIN = takes(0) returns(0) {<br>    0x00  calldataload  0xe0  shr<br>    <br>    dup1  __FUNC_SIG(setValue)  eq  setValueJump  jumpi<br>    <br>    __FUNC_SIG(getValue)  eq getValueJump jumpi<br>    <br>    revert<br>    <br>    setValueJump:<br>       SET_VALUE()<br>    <br>    getValueJump():<br>        GET_VALUE()<br>    <br>    <br>}<br><br>#define macro SET_VALUE = takes(0) returns(0) {<br>    0x04<br>    calldataload<br>    [VALUE_STORAGE_SLOT]<br>    sstore<br>    stop<br><br>}<br><br># define macro GET_VALUE = takes(0) returns (0) {<br>    [VALUE_STORAGE_SLOT]<br>    sload<br>    0x00<br>    mstore<br>    return<br>}</pre><p>Github: <a href="https://github.com/dheerajkumardk/horseStore">https://github.com/dheerajkumardk/horseStore</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ced6a094c124" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/writing-smart-constract-using-huff-ced6a094c124">Writing Smart Contract using Huff</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Path-Dependent Options and Monte-Carlo Simulations]]></title>
            <link>https://medium.com/@imdheeraj28/path-dependent-options-and-monte-carlo-simulations-be16bfcdc424?source=rss-2df8ab87fa29------2</link>
            <guid isPermaLink="false">https://medium.com/p/be16bfcdc424</guid>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[derivatives]]></category>
            <category><![CDATA[asian-options]]></category>
            <category><![CDATA[options]]></category>
            <category><![CDATA[monte-carlo-simulation]]></category>
            <dc:creator><![CDATA[Dheeraj Kumar]]></dc:creator>
            <pubDate>Mon, 05 Aug 2024 03:42:39 GMT</pubDate>
            <atom:updated>2024-08-05T03:42:39.940Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we’ll discuss Asian options, a type of path-dependent option that relies on the average price of the underlying asset over time. We’ll explore the unique aspects of these options and the challenges in pricing them. To address these complexities, we’ll introduce the Monte Carlo simulation method and demonstrate its application through a Python function for calculating the price of an Asian call option.</p><p>Options are of varying types. The one which we’ll discuss in this article is Asian Options.</p><p>The payoff of Asian options depends on the arithmetic average of the stock prices of the path followed.</p><p>Let’s understand this with the help of an example.</p><p>Suppose an Asian call option.</p><p>So = 100, K = 90, T = 1, r = 0%, u = 1.2, d = 0.8, N = 2, p = 0.5</p><p>The Binomial Tree diagram for the evolution of the underlying price would be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*cyOWqtk8LEJrpXRSgvWUlg.png" /><figcaption>Binomial Tree</figcaption></figure><p>At t=0, the stock has two possible movements: an upside and a downside.</p><p>At t=1, it has further two movements possible</p><p>So, for the 2-step binomial tree, the stock has 4 possible paths. These are {u,u}, {u,d}, {d,u} and {d,d}.</p><p>It’s worth noting that the paths {u,d} and {d,u} reach the same terminal price, but their paths differ. And since Asian options are path-dependent, this brings in a big difference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*rXgOA8HtM14tKFxpMvQj0w.png" /><figcaption>Asian call option payoff</figcaption></figure><p>Now since we got the option payoff at the Maturity, let’s calculate the call option prices at step 1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*J4FrsiDjaEbSSIt3THWHog.png" /><figcaption>Call option price at T=1</figcaption></figure><p>Now let’s calculate the value of the call option at step 0. This value will be the price of the option today.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*iRZOrHWe9b-ZWCBaS3JiXA.png" /><figcaption>Call option price at T=0</figcaption></figure><p>So, the price of the Asian call option today comes out to be $ 12.165</p><p>The key takeaways from the Asian options are:</p><ul><li>The number of terminal prices doesn’t necessarily equal the number of option prices. They are path-dependent. Multiple paths could lead to the same terminal price. However, each of their payoffs may vary subject to the path they followed.</li><li>To calculate the price of the option today, we need to compute all possible paths, which equals 2 ^ N, where N = Number of steps in the binomial tree</li><li>Computing a large number of paths would add to the computational cost.</li></ul><p>Ex: For N=50, we need to compute 2⁵⁰ paths.</p><h3>Monte Carlo Methods</h3><p>Monte Carlo methods use simulations and random sampling to approximate solutions to problems, particularly those with a probabilistic nature. The basic idea is that by randomly simulating a large number of outcomes from the same distribution as the underlying process, we can approximate a solution close to the actual one. The accuracy of these methods improves with more simulations. However, there’s always a trade-off between computational cost and accuracy.</p><p>Let’s write a function to run a Monte Carlo simulation to calculate the price of an Asian option.</p><p>Instead of computing all possible paths, we’ll simulate multiple scenarios by running the function for M different simulations. Each simulation represents a unique path that the underlying asset’s price might follow.</p><p>Given that Monte Carlo methods involve randomness, we’ll model the underlying asset’s price movements using a binomial distribution, as it captures the two possible outcomes: the price can either go up or down.</p><p>The below expression is used to generate a sequence of outcomes for the underlying price over time.</p><pre>np.random.binomial(1, p, N + 1)</pre><ul><li><strong>1 (number of trials):</strong> This parameter indicates that for each time step, we are simulating a single trial, representing one possible movement in the asset&#39;s price.</li><li><strong>p (probability of success):</strong> This represents the probability of the asset&#39;s price moving up. The probability of the price moving down is then 1 - p.</li><li><strong>N + 1 (number of time steps):</strong> This parameter specifies the total number of time steps we are simulating, including the initial price. Here, N represents the number of time steps, so N + 1 includes the starting point.</li></ul><p>To compute the option payoff, we first average the asset prices over the simulated path and then subtract the strike price. We discount the resulting payoff to find the option price today.</p><p>This process is repeated for M simulations. The more simulations we run, the closer we get to an accurate estimate of the option’s value.</p><p>Below is the complete function to compute an Asian option’s payoff.</p><pre>def asian_option_mc(S_ini, K, T, r, sigma, N, M):<br>    dt = T/N<br>    u = np.exp(sigma * np.sqrt(dt))<br>    d = np.exp(-sigma * np.sqrt(dt))<br>    p = (np.exp(r * dt) - d) / (u - d)<br>    Asian = np.zeros([M])<br>    S = np.zeros([M, N+1])<br>    S[:,0] = S_ini<br><br>    for j in range(M):<br>        random = np.random.binomial(1, p, N+1)<br>        Total = S_ini<br>        for i in range(1,N+1):<br>            if random[i] == 1:<br>                S[j,i] = S[j,i-1] * u<br>                Total = Total + S[j,i]<br>            else:<br>                S[j,i] = S[j,i-1] * d<br>                Total = Total + S[j,i]<br>                <br>        Asian[j] = np.exp(-r * T) * max(Total / (N + 1)- K, 0)<br>    return S, Asian</pre><p><strong>Conclusion:</strong></p><p>In this article, we delved into the concept of path-dependent options, with a particular focus on Asian options. We explored the unique characteristics of these options, which differ from standard European and American options by relying on the average price of the underlying asset over a certain period rather than the price at a single point in time. Specifically, we examined how to calculate the price of an Asian call option and discussed the complexities involved in its valuation due to the averaging feature.</p><p>To address these complexities, we introduced the Monte Carlo simulation method, a powerful computational tool that allows us to model and estimate the price of an Asian call option by simulating numerous possible price paths for the underlying asset. We demonstrated this technique by writing a Python function to compute the option’s price, highlighting the steps involved and the considerations needed to ensure accurate and reliable results.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be16bfcdc424" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pricing and Hedging Vanilla Options with Binomial Tree — II]]></title>
            <link>https://medium.com/@imdheeraj28/pricing-and-hedging-vanilla-options-with-binomial-tree-ii-d4bdbe009380?source=rss-2df8ab87fa29------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4bdbe009380</guid>
            <category><![CDATA[binomial-tree]]></category>
            <category><![CDATA[derivatives]]></category>
            <category><![CDATA[european-option]]></category>
            <category><![CDATA[derivatives-pricing]]></category>
            <category><![CDATA[financial-markets]]></category>
            <dc:creator><![CDATA[Dheeraj Kumar]]></dc:creator>
            <pubDate>Fri, 26 Jul 2024 16:29:11 GMT</pubDate>
            <atom:updated>2024-07-26T16:29:11.616Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pricing and Hedging Vanilla Options with Binomial Tree — II</h3><p>In the second part of pricing options using a binomial tree, we’ll learn about self-financing strategy, put-call parity, and delta.</p><p>A self-financing strategy is a concept in portfolio theory where, over a certain period, no extra funds are added to or withdrawn from the portfolio. The change in the portfolio value is solely due to changes in the price of the assets. Selling some portfolio assets facilitates the purchase of other assets, with no inflow of extra funds.</p><p>Let’s create a portfolio by borrowing money and invest that money in such a way that the portfolio yields the same payoff as the option.</p><p>An option (call or put) can be replicated with a self-financed portfolio combining:</p><ul><li>a position (long or short) in shares</li><li>a position in a risk-free bond (lend or borrow)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*mYPC9cMctdo75vA-MXSVpw.png" /></figure><p>Let our portfolio be X numbers of shares and B amount in the risk-free bond, assume r = 0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*2q8fKMEw0sNjWg1s2EwJag.png" /></figure><p>At t=0, we would borrow $60 and invest $75 in the stock.</p><p>This would yield the same payoff as the call option.</p><p>The part of the portfolio financed is $60, which is borrowed at rate, r.</p><p>Part of portfolio non-financed = $15</p><p>Thus, the initial cost of option = $15</p><h4>Replication portfolios for put option:</h4><p>Let’s try to replicate a similar portfolio using put option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*9dZt8Z1edyL2ErpZ2du7rQ.png" /></figure><p>We’ll need to have short position on 0.25 of underlying asset and lend $30.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*aKF9zBt5D4Jv81Mo5Ny-Iw.png" /></figure><h4>Put-Call Parity</h4><p>Let’s explore the relationship between value of call and put options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*ubHbLyPLOeVDrwSdD9SYKg.png" /></figure><p>In condition of no-arbitrage, it is required for put-call parity to hold true.</p><p>If it does not holds, there is an arbitrage opportunity.</p><h4>DELTA</h4><p>Delta measures change in the price of the option w.r.t. the change in the price of the underlying asset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*w4sI8JHjduDIgKe4JyH9XQ.png" /></figure><p>Let’s calculate delta at different step of the binomial tree, N=2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*vFO-7J9epLZEgzeiEfePqQ.png" /></figure><p>Delta measures option price sensitivity to change in the price of the underlying.</p><p>One important application is to construct replicating portfolios that are risk-free.</p><p>We can use delta as a measure to hedge the exposure of our portfolio to the underlying price changes. This concept is known as Delta HEDGING.</p><p>Using the concept of delta heading, we need to hold certain amounts of shares as depicted by the delta.</p><p>At t=0, we need to hold 0.675 of the share.</p><p>At t=1, if the price of the stock rises to 120, we need to hold 1 stock. That means, we add 0.325 shares more.</p><p>If the price of the stock falls to 80, we hold 0.1875 amounts of shares. So, we’ll sell the difference i.e. 0.675–0.1875 = 0.4875 amounts of shares to achieve delta of 0.1875</p><p>The total cost of hedging at the end comes out to be the cost of the option.</p><h4>Real-world vs Risk-neutral measures</h4><p>The two worlds are different. We saw risk-neutral probabilities to price options, that implies irrelevance of actual stock returns, discount rates for valuation. For risk-neutral, we just need the risk-free rate to discount.</p><p>When we move between the two worlds, the volatility of the underlying remains the same.</p><p>However, the discount rate and the probability changes.</p><p>We need to select upward movement, u and downward movement, d such that the it matches the volatility of the underlying asset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*8TVFCd8-Hi9zWfbBnuLhvA.png" /></figure><p>So, that was about calculation of delta, put-call parity and risk-neutral probabilities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4bdbe009380" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pricing and Hedging Options with Binomial Tree — I]]></title>
            <link>https://medium.com/@imdheeraj28/pricing-and-hedging-options-with-binomial-tree-i-bca5a4ce7a56?source=rss-2df8ab87fa29------2</link>
            <guid isPermaLink="false">https://medium.com/p/bca5a4ce7a56</guid>
            <category><![CDATA[derivatives]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[financial-markets]]></category>
            <category><![CDATA[derivatives-pricing]]></category>
            <category><![CDATA[options]]></category>
            <dc:creator><![CDATA[Dheeraj Kumar]]></dc:creator>
            <pubDate>Wed, 24 Jul 2024 13:00:50 GMT</pubDate>
            <atom:updated>2024-07-24T13:00:50.592Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pricing and Hedging Options with Binomial Tree — I</h3><p>Call Options: Options contracts are another example of derivatives. These contracts provide its holder a choice to trade a security in the future at a specific price.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*rhRiBVQM4Q7bKNn6gjAchg.png" /></figure><h4>Modeling Underlying Assets</h4><p>The essential characteristic of a derivative is that its payoff depends on the evolution of the underlying asset. Thus, a key aspect of pricing is to model the future evolution of the underlying.</p><p><strong>Binomial Tree:</strong> is a technique used to model underlying stock price evolution.</p><p>Let’s assume that the stock, at any point in time could make an upward movement or a downward movement denoted by <em>u</em> and <em>d</em> respectively.</p><p>For example, if the current stock price is 100 and it has upward potential, u = 1.2 and downward movement, d= 0.8.<br>This means, that the stock can move to an upside of [100 * 1.2 = 120] and a downside of [100 * 0.8 = 80].</p><p>1-step Binomial tree, N=1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*_bTKyiYUNJbW88bcKIGLvA.png" /></figure><p>2-step Binomial tree, N=2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*G5QbvV_zQgbh0CJFuSdkCQ.png" /></figure><p><em>Filtration</em>: It is generally the path taken by the underlying price to reach the node.</p><p>For example, the Current price is 100. Now let’s find filtration for S_ud = 96</p><p>First, the price moved up, so from 100, it is now (100 * 1.2 = 120)</p><p>Now the price descended by 20% to (120 * 0.8 = 96)</p><p>So for S_t = 96, filtration = {u,d}</p><h4>Binomial Tree and call Option</h4><p>The first step was to get an idea about the underlying price evolution. Now since we got the price evolution using the Binomial Tree method, it will be easy to get the payoff of any simple option.</p><p>Let’s consider a European call option, with the strike, K=90, maturity = 1 year, and N=1 (1-step Tree)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*DMGQ4J0LogSefIA3W0GH_w.png" /></figure><p>In the first case, the underlying price rises above the strike, thus the option will be exercised, and payoff = 30.</p><p>In case of a price decrease below the strike, the option will not be exercised, and the payoff = 0.</p><p>General financial intuition in this case gives insights about the option price. The fair value of such an option is just the present value of the expected payoff.</p><p>But here are two questions now:</p><p>i. For certain expected payoffs, what are the real-world probabilities of u and d happening?</p><p>ii. What is the discount rate that we should use to discount the expected payoff to the present value?</p><h4>RISK NEUTRAL VALUATION</h4><p>One of the components of risk-neutral valuation is the No-Arbitrage Argument.</p><p><em>No-Arbitrage Argument</em>: The idea of the no-arbitrage argument is to construct a portfolio that always earns the same positive payoff, irrespective of what happens to the underlying asset’s price.</p><p>Let’s consider a portfolio with X amounts of shares of the underlying and a short position in the call option. The current price of the stock is 100 and the strike rate is K=90</p><p>Call payoff moves by $30</p><p>Underlying price moves by $40</p><p>Here, hedge ratio = 0.75</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*DtIg_s0f-pbV6NQXYvtgYw.png" /></figure><p>Thus, we need to hold 0.75 shares of the underlying to be exposed to future movements like the call option.</p><p>Portfolio value at time T=1</p><p><em>Case 1</em>: If the stock climbs to $120, we have a ‘u’ scenario,</p><p>stock value = 0.75 * 120 = $90</p><p>option payoff = -(120–90) = — $30</p><p>Since we are option sellers, the increase in underlying price would motivate the option buyer to exercise the option and we are obliged to do that.</p><p>So, net portfolio value = 90 + (-30) = $60</p><p><em>Case 2</em>: If the stock drops to $80, we have a ‘d’ scenario,</p><p>stock value = 0.75 * 80 = $60</p><p>option payoff = 0</p><p>The option won’t be exercised in this case. Hence, payoff = 0.</p><p>Net portfolio value = $60</p><p>In both cases, the net portfolio value comes out to be $60.</p><p>Initial investment amount = 0.75 * 100 — X</p><p>= 75 — X [ X, received as option premium since we are option seller]</p><p>$60 is the value of our portfolio 1 year from now. Since it is a risk-less portfolio, we can discount it at risk-free rate.</p><p>Let risk-free rate, r = 10% p.a.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*8KEYpTtCBDBNZqKaLQqIlg.png" /></figure><p>Under the condition of no-arbitrage, if the stock price = $100, then the call option price today (Co) will be worth:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*Imv0GjC8n_x4-mE75bHUYA.png" /></figure><p>Now, this provides us with two important results for with respect to option pricing:</p><ul><li>We can price an option as part of a riskless portfolio using risk-free discount rate.</li><li>Under these conditions, we can obtain implied probabilities.</li></ul><h4>Risk-neutral probabilities</h4><p>Risk-neutral probabilities or risk-neutral measures is a probability measure under which the present value of future cash flows when discounted at the risk-free rate, is equal to their current market value.</p><p>For case ‘u’ when there is upward movement,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*gpglHDFsAKeU4Fw5D8UKNg.png" /></figure><p>Ex: for u=1.2, d=0.8, and risk-free rate, r = 10%</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/205/1*luVsDSR4HM3wyyglqlvCZA.png" /><figcaption>p — risk-neutral probability</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*ofqmlZCaORLd-LV7Cy8zxA.png" /></figure><p>p — risk-neutral probability measure, is the probability for an upward movement.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bca5a4ce7a56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Derivatives -I: The Case of Lakhan and His Sugarcane Harvest]]></title>
            <link>https://medium.com/@imdheeraj28/understanding-derivatives-i-the-case-of-lakhan-and-his-sugarcane-harvest-62370c2f94e9?source=rss-2df8ab87fa29------2</link>
            <guid isPermaLink="false">https://medium.com/p/62370c2f94e9</guid>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[financial-markets]]></category>
            <category><![CDATA[futures-contract]]></category>
            <category><![CDATA[derivatives]]></category>
            <dc:creator><![CDATA[Dheeraj Kumar]]></dc:creator>
            <pubDate>Sun, 21 Jul 2024 15:36:22 GMT</pubDate>
            <atom:updated>2024-07-21T15:36:22.058Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A2nASy28ztYQRwTQ" /><figcaption>Photo by <a href="https://unsplash.com/@allisonsaeng?utm_source=medium&amp;utm_medium=referral">Allison Saeng</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong>Introduction</strong></p><p>Derivatives are financial instruments whose value is derived from the value of an underlying asset. A common type of derivative is a futures contract, which allows parties to buy or sell an asset at a predetermined future date and price. This helps manage risk associated with price fluctuations. To illustrate how a futures contract works, let’s consider the example of a farmer named Lakhan.</p><p><strong>The Scenario</strong></p><p>Lakhan is a dedicated farmer who owns a plot of land where he cultivates sugarcane. As the planting season approaches, Lakhan is optimistic about a bountiful harvest. However, he is also aware that the market price of sugarcane can be quite volatile, influenced by various factors such as the demand from sugar mills and the overall supply in the market.</p><p><strong>Lakhan’s Concerns</strong></p><p>Lakhan’s primary concern is the uncertainty surrounding the price of sugarcane at the time of harvest. If the market price drops significantly, he might not earn enough to cover his costs or make a profit. On the other hand, a good market price would ensure a profitable season for him. To mitigate this risk, Lakhan decides to enter into a futures contract.</p><p><strong>The Futures Contract</strong></p><p>A futures contract is an agreement between two parties to buy or sell an asset at a predetermined price at a specified future date. In Lakhan’s case, he enters into a futures contract with a sugar mill.</p><ul><li><strong>The Agreement</strong>: Lakhan agrees to sell a certain quantity of sugarcane to the sugar mill at a fixed price of $50 per ton, to be delivered in six months.</li></ul><p><strong>Benefits for Lakhan</strong></p><ol><li><strong>Price Security</strong>: By locking in a price of $50 per ton, Lakhan secures a guaranteed revenue for his harvest, regardless of future market price fluctuations.</li><li><strong>Risk Mitigation</strong>: The futures contract protects Lakhan from potential price drops. Even if the market price falls to $40 per ton at the time of harvest, he will still receive $50 per ton as per the contract.</li><li><strong>Planning and Budgeting</strong>: With a known future price, Lakhan can better plan his finances, manage his expenses, and ensure that his farming operations are sustainable.</li></ol><p><strong>Benefits for the Sugar Mill</strong></p><ol><li><strong>Supply Assurance</strong>: The sugar mill is assured of receiving a certain quantity of sugarcane at a fixed price, which helps in their production planning and cost management.</li><li><strong>Hedging Against Price Increases</strong>: If the market price of sugarcane rises to $60 per ton, the sugar mill still pays only $50 per ton, as agreed in the contract, saving them money.</li></ol><p><strong>Possible Outcomes</strong></p><ul><li><strong>Market Price Higher than Contract Price</strong>: If the market price rises to $60 per ton, Lakhan might feel he missed out on higher profits. However, he still benefits from the security and risk mitigation the futures contract provided.</li><li><strong>Market Price Lower than Contract Price</strong>: If the market price falls to $40 per ton, Lakhan benefits from the futures contract as he still receives the agreed price of $50 per ton, protecting him from the adverse price drop.</li></ul><p><strong>Conclusion</strong></p><p>Futures contracts, as a type of derivative, provide a mechanism for farmers like Lakhan to manage the risks associated with price volatility in agricultural markets. By entering into a futures contract, Lakhan ensures a stable income and can focus on maximizing his sugarcane yield without worrying about unpredictable market prices. Similarly, the sugar mill secures its supply at a predictable cost, enabling efficient business operations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62370c2f94e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s Get Foundry]]></title>
            <link>https://medium.com/coinmonks/lets-get-foundry-05cac67b2632?source=rss-2df8ab87fa29------2</link>
            <guid isPermaLink="false">https://medium.com/p/05cac67b2632</guid>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[smart-contract-blockchain]]></category>
            <category><![CDATA[foundry]]></category>
            <dc:creator><![CDATA[Dheeraj Kumar]]></dc:creator>
            <pubDate>Tue, 19 Mar 2024 10:16:03 GMT</pubDate>
            <atom:updated>2024-03-19T10:16:03.208Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LqhOsdwpKmWvvcp-8unlRQ.png" /><figcaption>foundry banner</figcaption></figure><p>Foundry is a smart contract development toolchain.</p><p>Foundry manages your dependencies, compiles your project, runs tests, deploys, and lets you interact with the chain from the command-line and via Solidity scripts.</p><p>Now you can write tests and scripts for your contracts in the smart contract language itself, i.e. Solidity.</p><p>Follow the steps for a basic guide to using foundry:</p><p>To initialize your first foundry project, open the terminal and type in</p><pre>forge init first_project_foundry</pre><p>This would initialize your project. You could see several folders once you open the project. These includes:</p><ul><li>lib</li><li>script</li><li>src</li><li>test</li></ul><p>and many other files. We’ll discuss each of the things in later articles.</p><p><em>lib </em>folder consists of the all libraries that the project requires. This includes forge-std by default. If suppose we use open-zeppelin’s contracts or the ones’ from chainlink, we’ll install them<em>. </em>The<em> src</em> folder contains all the contracts of the project, <em>script</em> folder has the scripts for the project and <em>test</em> consists of all the tests written for the smart contracts in the src folder. The tests and scripts in foundry are written in Solidity.</p><h3>Let’s start with the contract.</h3><p>The smart contract for this tutorial will be a basic one. It’ll store a number and have certain basic operations like increment the number and increase it by adding a certain number, say 5. Let the contract have another state variable that stores a greeting. We’ll have a function that takes in name of a person and then greets them.</p><p>Suppose if you pass name as “Dheeraj”, it should return “Namaskaar, Dheeraj!”.</p><p>In the src folder, create a file “SimpleStorage.sol”. This is our main contract.</p><pre>// SPDX-License-Identifier: MIT<br><br>pragma solidity ^0.8.18;<br><br>contract SimpleStorage {<br>    // our favouriteNumber<br>    uint256 public favouriteNumber = 7;<br>    // greeting<br>    string public greeting = &quot;Namaskaar&quot;;<br><br>    // increments the favouriteNumber by 1<br>    function incrementNumber() public {<br>        favouriteNumber++;<br>    }<br><br>    // adds given number to our favouriteNumber<br>    function jumpNumberBy(uint256 jumpBy) public {<br>        favouriteNumber = favouriteNumber + jumpBy;<br>    }<br><br>    // sets greeting to the given greeting<br>    function setGreeting(string memory _greeting) public {<br>        greeting = _greeting;<br>    }<br><br>    // greets the user<br>    function greet(string memory name) public view returns(string memory) {<br>        string memory greetingMessage = string.concat(greeting, name);<br>        return greetingMessage;<br>    }<br>}</pre><p>To compile the contract above, run below commands:</p><pre>forge build<br>or<br>forge compile</pre><p>Now, let’s write some tests for the above contract to ensure the contract functionalities works as desired.</p><p>Create a file in test folder and name it “SimpleStorage.t.sol”.</p><ul><li>setUp(): This is the function which runs before each test case executes. This generally includes creating contract instance and setting state variables.</li></ul><pre>// SPDX-License-Identifier: MIT<br><br>pragma solidity ^0.8.18;<br><br>import {Test} from &quot;forge-std/Test.sol&quot;;<br>import {SimpleStorage} from &quot;../src/SimpleStorage.sol&quot;;<br><br>contract SimpleStorageTest is Test {<br>    SimpleStorage simpleStorage;<br><br>    function setUp() public {<br>        simpleStorage = new SimpleStorage();<br>    }<br><br>    function test_ReadStorageVariables() public view {<br>        // I have set favouriteNumber to 7, the jersey number of MSD, let&#39;s check that<br>        assertEq(simpleStorage.favouriteNumber(), 7);<br><br>        assertEq(simpleStorage.greeting(), &quot;Namaskaar&quot;);<br>    }<br><br>    function test_IncrementNumber() public {<br>        // this should increase the value by 1, at first, it was set to 7<br>        simpleStorage.incrementNumber();<br>        assertEq(simpleStorage.favouriteNumber(), 8);<br>    }<br><br>    function test_JumpNumberBy() public {<br>        uint256 jumpBy = 5;<br>        simpleStorage.jumpNumberBy(jumpBy);<br>        assertEq(simpleStorage.favouriteNumber(), 12);<br>    }<br><br>    function test_SetGreeting() public {<br>        string memory newGreeting = &quot;Jai Shree Ram&quot;;<br>        simpleStorage.setGreeting(newGreeting);<br><br>        assertEq(simpleStorage.greeting(), newGreeting);<br>    }<br><br>    function test_Greet() public view {<br>        string memory name = &quot;Dheeraj&quot;;<br>        string memory greetMessage = string.concat(simpleStorage.greeting(), name);<br><br>        assertEq(simpleStorage.greet(name), greetMessage);<br><br>    }<br>    <br>}</pre><p>Run your tests with the below command:</p><pre>forge test</pre><p>It’ll show if the tests passes or fails, then we debug if something fails.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*tnsDZWZvLDMnbwPaiSoaEg.png" /><figcaption>running the tests</figcaption></figure><p>There are multiple ways in which we test in foundry. We can run forge test with (-vv or -vvv or -vvvv) and each of them has different utilities.</p><ul><li><strong>Level 2 (</strong><strong>-vv)</strong>: Logs emitted during tests are also displayed.</li><li><strong>Level 3 (</strong><strong>-vvv)</strong>: Stack traces for failing tests are also displayed.</li><li><strong>Level 4 (</strong><strong>-vvvv)</strong>: Stack traces for all tests are displayed, and setup traces for failing tests are displayed.</li><li><strong>Level 5 (</strong><strong>-vvvvv)</strong>: Stack traces and setup traces are always displayed.</li></ul><p>Don’t forget to play around yourself with them.</p><p>Below attached is a screenshot, where you can see the stack traces for the tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*EvVxuwiHgobRkGj4p9jJRw.png" /><figcaption>tests stack traces</figcaption></figure><h4>Checking coverage:</h4><p>Coverage simply means how much have you covered. While writing smart contracts, you need not to have 100% coverage always, but you must ensure that each of the functionalities and edge-cases have been tested well.</p><p>By running the below command, it gives the coverage of the smart contracts.</p><pre>forge coverage</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*CWt_eJ0oZ9RP_kVL_F2T6A.png" /></figure><p>So far, we have written an amazing contract and tested it with the help of our old friend, Solidity. He’s much more capable now. That was all in the scope for this article.</p><p>Source code: <a href="https://github.com/dheerajkumardk/foundry_firstproject/tree/master">https://github.com/dheerajkumardk/foundry_firstproject/tree/master</a></p><h4>References:</h4><p><a href="https://book.getfoundry.sh/">https://book.getfoundry.sh/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05cac67b2632" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/lets-get-foundry-05cac67b2632">Let’s Get Foundry</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A dive into Substrate’s Consensus Mechanism]]></title>
            <link>https://medium.com/coinmonks/a-dive-into-substrates-consensus-mechanism-30366a4a4213?source=rss-2df8ab87fa29------2</link>
            <guid isPermaLink="false">https://medium.com/p/30366a4a4213</guid>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[polkadot]]></category>
            <category><![CDATA[consensus]]></category>
            <category><![CDATA[substrate-blockchain]]></category>
            <dc:creator><![CDATA[Dheeraj Kumar]]></dc:creator>
            <pubDate>Sat, 11 Mar 2023 05:43:49 GMT</pubDate>
            <atom:updated>2023-03-11T13:58:33.243Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V5QkIA_vdCrM2P-9.jpg" /><figcaption>Consensus</figcaption></figure><p>The consensus mechanism used by the Substrate framework is not fixed or predetermined. Instead, the Substrate framework provides a modular architecture that allows developers to easily create and customize their own blockchain networks and applications. This includes the ability to choose and implement their own consensus algorithm, depending <br> on the specific requirements and goals of the network. Therefore, the consensus mechanism used by a Substrate-based blockchain will depend on the specific implementation of the network.<br> <br>The consensus process here is split into two phases:<br><strong>Block authoring</strong> is the process nodes use to create new blocks.<br><strong>Block finalization</strong> is the process used to handle forks and choose the canonical chain.</p><p><strong>Block authoring:</strong><br>To reach a consensus, nodes in the blockchain network are required to produce blocks. So there must be a way to choose which nodes are authorized to produce blocks. Since it is a decentralized network without any trusted nodes, an algorithm must select the block author at each block height.</p><p>For a substrate-based chain, one can choose the following block authoring algorithms or create one’s custom.<br>Aura: Authority-based round-robin scheduling<br>BABE: Blind assignment of blockchain extension slot-based scheduling<br>Proof of work computation-based scheduling</p><p><strong><em>Aura</em></strong><em>:<br></em>In aura, a known set of authorities are allowed to produce blocks. The authorities must be chosen before block production begins. Time is divided into fixed-length slots. During each slot, one block is produced, and the authorities take turns producing blocks in order as per round robin algorithm.</p><p><strong><em>Babe:</em></strong><br>Like Aura, it is a slot-based consensus algorithm with a known set of validators. In addition, each validator is assigned a weight which must be assigned before block production begins. Unlike Aura, the authorities don’t take turns in order. Instead, during each round, each authority generates a pseudorandom number using a VRF. If the random number is lower than <br>their weight, they are allowed to produce a block.</p><p><strong><em>Proof of Work:</em></strong><br>This mechanism does not have a known authority set, neither it is slot-based. In proof of work, anyone can produce a block at any time, as long as they manage to solve a computationally challenging problem. The difficulty of this problem can be tuned to provide a statistical target<br>block time.</p><p><strong>Finalization:</strong><br>Blocks that are produced contain a header and transactions. Each block header contains a reference to its parent block, so you can trace the chain back to genesis. Now, there could be more than one block that refers to the same parent. Block finalization is a mechanism aimed to resolve forks so that only the canonical chain exists. We can use the GRANDPA protocol for it or code our own.</p><p><strong><em>Grandpa:</em></strong><br>Grandpa provides block finalization. Grandpa does not author blocks, it just listens in the network about the newly produced blocks. In the GRANDPA protocol, the longest chain rule simply says that the best chain is the longest chain. Grandpa validators participate in two rounds of voting on blocks. Once 2/3rd of the grandpa authorities have voted for a particular block, it is considered finalized.</p><blockquote><em>New to trading? Try </em><a href="https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a"><em>crypto trading bots</em></a><em> or </em><a href="https://medium.com/coinmonks/top-10-crypto-copy-trading-platforms-for-beginners-d0c37c7d698c"><em>copy trading</em></a><em> on </em><a href="https://medium.com/coinmonks/crypto-exchange-dd2f9d6f3769"><em>best crypto exchanges</em></a></blockquote><blockquote>Join Coinmonks<a href="https://t.me/coincodecap"> Telegram Channel</a> and<a href="https://www.youtube.com/c/coinmonks/videos"> Youtube Channel</a> get daily <a href="http://coincodecap.com/">Crypto News</a></blockquote><h3>Also, Read</h3><ul><li><a href="https://medium.com/coinmonks/free-crypto-signals-48b25e61a8da">Free Crypto Signals</a> | <a href="https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a">Crypto Trading Bots</a></li><li>An ultimate guide to <a href="https://medium.com/coinmonks/leveraged-token-3f5257808b22">Leveraged Token</a></li><li><a href="https://medium.com/coinmonks/top-17-folding-electric-bikes-5e296f0918cb">16 Best Folding Electric Bikes</a></li><li><a href="https://medium.com/coinmonks/the-28-best-electric-bikes-review-and-buying-guide-in-2023-7bb3146cb403">28 Best Electric Bikes Review</a></li><li>Top 3 <a href="https://medium.com/coinmonks/top-3-binance-futures-trading-bots-e6031f84b3f9">Binance Futures Trading Bots</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30366a4a4213" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/a-dive-into-substrates-consensus-mechanism-30366a4a4213">A dive into Substrate’s Consensus Mechanism</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Blockchain Oracle to you!]]></title>
            <link>https://medium.com/coinmonks/introducing-blockchain-oracle-to-you-52da65725502?source=rss-2df8ab87fa29------2</link>
            <guid isPermaLink="false">https://medium.com/p/52da65725502</guid>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[blockchain-oracle]]></category>
            <dc:creator><![CDATA[Dheeraj Kumar]]></dc:creator>
            <pubDate>Sat, 04 Mar 2023 05:48:50 GMT</pubDate>
            <atom:updated>2023-03-06T19:33:37.650Z</atom:updated>
            <content:encoded><![CDATA[<p>This article is about Blockchain Oracles, something you will come across when you’ll have to feed real-world data which isn’t available in the blockchain.</p><p>Smart contracts in the blockchain powers a wide range of application, from financial services and supply chain management to gaming and voting systems. However, in order to interact with the real world, smart contracts need access to real-world data, such as prices, weather information, and events. Blockchain oracles serve as a bridge between the blockchain and the external world by providing smart contracts with the necessary data. By doing so, blockchain oracles enable the creation of trustless and decentralized applications that can automate various business processes and interactions without the need for intermediaries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*c-FuLsrHGkpJHzhQcdUMCw.png" /></figure><p><strong>So, what actually is this oracle?</strong></p><p>A blockchain oracle is a service or mechanism that allows smart contracts on a blockchain to interact with data and systems that exist outside the blockchain. It acts as a bridge between the blockchain and external data sources, enabling smart contracts to access and process real-world information.</p><p>Oracles provide critical information to smart contracts, such as stock prices, weather data, and other real-time information, that can be used to trigger the execution of certain actions within the smart contract. They essentially help to make smart contracts more flexible and dynamic by enabling them to respond to real-world events and conditions.</p><p>Oracles can be centralized or decentralized, depending on the implementation. Centralized oracles rely on a single trusted source to provide data to the blockchain, while decentralized oracles use a consensus mechanism to gather and verify data from multiple sources before delivering it to the smart contract.</p><p>Blockchain oracles are becoming increasingly important as more and more use cases for blockchain technology emerge, particularly in industries such as finance, insurance, and supply chain management.</p><p><em>That’s cool, Right?</em></p><p><em>Go on reading…</em></p><p>We need blockchain oracles because they enable smart contracts to interact with external data and systems, which is necessary for many blockchain use cases. Smart contracts are essentially self-executing contracts that can automatically trigger certain actions based on predefined conditions. However, these conditions often depend on real-world data that is not available on the blockchain itself.</p><p>For example, a smart contract that triggers a payment when a certain condition is met might require access to external data sources such as stock prices, weather data, or exchange rates. Oracles provide a way for smart contracts to access this information and trigger the payment automatically, without the need for manual intervention.</p><p>In addition to providing access to external data sources, oracles can also enable smart contracts to interact with other blockchain networks or off-chain systems, such as payment gateways or IoT devices. This makes smart contracts more versatile and flexible, and enables them to support a wider range of use cases.</p><p>Overall, blockchain oracles play a critical role in enabling blockchain-based applications to interact with the real world, and are essential for unlocking the full potential of blockchain technology.</p><p><strong>Sounds awesome!! But how to use them?</strong></p><p>Oracles can be used in blockchain in a variety of ways, depending on the specific use case and implementation. Here are some examples:</p><ol><li>Smart contracts: Oracles can be used to provide external data to smart contracts, which can then use this information to trigger certain actions. For example, a smart contract might be programmed to automatically execute a payment when a certain condition is met, such as when the price of a commodity reaches a certain level. Oracles can provide the necessary data to make this possible.</li><li>Supply chain management: Oracles can be used to track goods and products as they move through the supply chain, providing real-time information on their location, condition, and other relevant data. This information can be stored on the blockchain, enabling stakeholders to track the entire journey of the product from start to finish.</li><li>Insurance: Oracles can be used to provide real-time data on events such as natural disasters or accidents, which can be used to trigger insurance payouts automatically. For example, an insurance policy might be programmed to pay out automatically if a natural disaster is confirmed by a trusted data source, such as a government agency.</li><li>Gaming: Oracles can be used to provide real-time data on the outcome of events in games, such as the roll of a dice or the outcome of a sports match. This information can be used to determine the outcome of bets or other types of transactions on the blockchain.</li></ol><p>Overall, oracles provide a way for blockchain-based applications to interact with the real world, enabling them to support a wide range of use cases and applications.</p><p><strong>References:<br></strong><a href="https://www.linkedin.com/pulse/what-oracles-why-do-we-need-them-blockchain-concepts-beginners/">https://www.linkedin.com/pulse/what-oracles-why-do-we-need-them-blockchain-concepts-beginners/</a></p><blockquote><em>New to trading? Try </em><a href="https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a"><em>crypto trading bots</em></a><em> or </em><a href="https://medium.com/coinmonks/top-10-crypto-copy-trading-platforms-for-beginners-d0c37c7d698c"><em>copy trading</em></a><em> on </em><a href="https://medium.com/coinmonks/crypto-exchange-dd2f9d6f3769"><em>best crypto exchanges</em></a></blockquote><blockquote>Join Coinmonks<a href="https://t.me/coincodecap"> Telegram Channel</a> and<a href="https://www.youtube.com/c/coinmonks/videos"> Youtube Channel</a> get daily <a href="http://coincodecap.com/">Crypto News</a></blockquote><h3>Also, Read</h3><ul><li><a href="https://medium.com/coinmonks/free-crypto-signals-48b25e61a8da">Free Crypto Signals</a> | <a href="https://medium.com/coinmonks/crypto-trading-bot-c2ffce8acb2a">Crypto Trading Bots</a></li><li>An ultimate guide to <a href="https://medium.com/coinmonks/leveraged-token-3f5257808b22">Leveraged Token</a></li><li><a href="https://medium.com/coinmonks/top-17-folding-electric-bikes-5e296f0918cb">16 Best Folding Electric Bikes</a></li><li><a href="https://medium.com/coinmonks/the-28-best-electric-bikes-review-and-buying-guide-in-2023-7bb3146cb403">28 Best Electric Bikes Review</a></li><li>Top 3 <a href="https://medium.com/coinmonks/top-3-binance-futures-trading-bots-e6031f84b3f9">Binance Futures Trading Bots</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52da65725502" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/introducing-blockchain-oracle-to-you-52da65725502">Introducing Blockchain Oracle to you!</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rug Pull — A DeFi Attack]]></title>
            <link>https://medium.com/@imdheeraj28/rug-pull-a-defi-attack-100f906b41ca?source=rss-2df8ab87fa29------2</link>
            <guid isPermaLink="false">https://medium.com/p/100f906b41ca</guid>
            <category><![CDATA[rugpull]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[decentralized-finance]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[crypto]]></category>
            <dc:creator><![CDATA[Dheeraj Kumar]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 14:42:09 GMT</pubDate>
            <atom:updated>2022-06-28T14:42:09.710Z</atom:updated>
            <content:encoded><![CDATA[<h3>Rug Pull — A DeFi Attack</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*CzIkwW_7z2gVWer_GdWlNQ.jpeg" /></figure><p>Decentralized Finance has been one of the biggest gamechangers in the blockchain space we had come across in recent years. This had the potential to disrupt the traditional finance completely thus, connecting individuals to all norms of finance when they are left untouched by banks and financial bodies even till date. DeFi makes it available to each one of us despite age, gender, color, race, religion, language, geographical area, or anything else. It’s our own financial system of the new time built on top of the most disruptive technology of the decade, i.e. Blockchain.<br>Massive improvements have been brought in the field of finance ever since the inception of decentralized finance, but still there’s something holding it back. There are some old barriers that have slowed down the pace of adoption of DeFi. Some old attacks keep repeating in this space and we’re yet onto the process of making secure, non-vulnerable decentralized applications.<br>According to Defi Llama, the total value locked in DeFi protocols as of 2nd June, 2022 is estimated at around $107 Billions.</p><p><strong>Decentralized Finance:<br><em>What is DeFi</em></strong><em><br></em>Decentralized finance or DeFi, is an emerging financial technology which is based on system of secure distributed ledgers, the ones that powers the cryptocurrencies.</p><blockquote>The attracting features of DeFi are:<br>* It completely eradicates the control banks and institutions have on money and financial services.<br>* It eliminates the fees charged by banks and financial institutes for availing their services or financial products.<br>* One doesn’t need any documents to be eligible to use these services. All you need is an smartphone with an internet connection.<br>* Money transfer happens across the world within a matter of seconds and without paying any charges to international bodies and banks.</blockquote><p><strong>Current Scenario<br></strong>According to reports, more than $1.6 billion have been exploited from DeFi so far in 2022. This amount beats the combined total of 2020 and 2021. As per the analysis from blockchain security firm CertiK, the month of March have the most value stolen at around $719.2 million, which is around $200 million more than what was stolen in all of 2020.</p><p><strong>Types of DeFi Attacks<br></strong>There are several kinds of DeFi attacks which includes re-entrancy attack, flash loan attack, rug pull, price oracle manipulation, etc.<br>In this article, our focus is on Rug Pull. We’ll discuss about other attacks in the coming articles.</p><p><strong>Rug Pull<br></strong>Rug pulls are a lucrative scam in which a crypto developer promotes a new project — usually a new token, to investors through social media, twitter handles, website, etc. and creates a situation of FOMO which attracts investors and later disappears with the investor’s funds.<br>In this scam, the malicious team deletes all their digital traces from the internet including websites, social media handles promoting the project, and other linked accounts. They do this first after abandoning the project. Rug pulls usually happens on decentralized exchanges (DEXs), where these malicious developers create their own token, list them on DEX and pair it with some popular cryptocurrency like Bitcoin, Ethereum, BNB.</p><p><strong><em>What happens in a Rug Pull?</em></strong><em><br></em>When any new DeFi project is introduced or launched, their token usually aren’t listed on Centralized Exchanges, thus the DEX is the only source of liquidity. So, like whenever any DeFi project is launched, they would have their own token and provide some amount as liquidity to the DEX. What they basically do is, pair this token with leading cryptocurrency like ETH, BTC, BNB, or whatsoever. They got this liquidity pool created now.</p><p>What they do next is they create a hype around this token so as to gain investor’s confidence. They advertise through websites, Telegram, Twitter, Facebook and other social media channels to inject a substantial amount of liquidity. They make promises of a higher Annual Percentage Yield (APY) returns to retail investors, generally yield farmers. They basically create a FOMO (Fear Of Missing Out) situation. FOMO, along with their big promises succeeds in gaining investor’s confidence and the investors end up putting most of their money into these projects in belief of higher returns.</p><p>Once they are able to create a good hype about their project and gaining enough liquidity, they have two main options. Either they sell their tokens at a higher price and remove all the liquidity they provided or use backdoors in smart contracts to steal the investor’s funds. So when they remove their liquidity, the price of the DeFi token will be driven to zero. Thus, leaving the investor with a worthless token.<br>There is another kind of rug pull in which investors could just lock-in their funds into the liquidity pool, but they could not withdraw it. Squid Game Crypto Scam is that kind of rug pull. I have covered this scam in another article. The link is attached in references.</p><p><strong><em>Why Rug Pull happens?</em></strong><em><br></em>Rug Pulls are common in Decentralized Finance as creating a token and listing it on any DEX is very easy. Anyone can set up a liquidity pool. Most of such projects are anonymous. So, it paves the way for developers and the team behind such attacks to rug pull without revealing their identity.</p><p><strong>Case Studies:<br></strong><em>Squid Game Scam:<br></em>In November 2021, a crypto token called “Squid Game Token” was launched which was associated with the then popular hit series “Squid Game”. This project took full benefit of the Netflix’s series popularity and paved way to earn investor’s interest. Investors can invest in this pool created for Squid Token but there was no way out to withdraw their shares.</p><p><em>Meerkat Finance:<br></em>Meerkat Finance is a yield farming protocol built on Binance Smart Chain. It was rugged within a day after it had gone live in March 2021. It costs around 13 million BUSD and 73,000 BNB, which counts to around $31M USD. After the rug pull, the protocol’s website and Twitter account were both taken down. It was found that the team had got their contracts upgraded and had grant themselves the ability to retrieve assets from the pool.</p><p><strong><em>How to identify a Rug Pull?</em></strong><em><br></em>Most common sign of a rug pull includes a sky-rocketing token price within very short amount of time. If the project owner/team removes their liquidity shortly after the project launch, there are high chances of a rug pull to occur soon. The developers would be creating a huge hype about the project through websites, advertisements, telegram, twitter and other social media platforms.</p><p><strong><em>How to avoid Rug Pull?</em></strong><em><br></em>To protect oneself from rug pull, one needs to conduct thorough research about the project before putting in any amount of money. Try to get through the team’s credibility with who backs the team, the core developers, project owners, investors. Also, you could check about the token holders on block explorers to get an idea about how many people holds the tokens. If there are less wallets holding the token, possibility for exit scam increases.<br>Don’t fall victim to FOMO. Wait for any new project to get some time into the market. The longer the project exists in the market, the more is its credibility.</p><p><strong><em>References: </em><br></strong>https://coinmarketcap.com/alexandria/glossary/rug-pull<br>https://academy.binance.com/en/glossary/rug-pull<br>https://cointelegraph.com/explained/crypto-rug-pulls-what-is-a-rug-pull-in-crypto-and-6-ways-to-spot-it<br>https://economictimes.indiatimes.com/news/how-to/how-to-avoid-rug-pulls-the-latest-cryptocurrency-scam/articleshow/91499147.cms?from=mdr<br>https://economictimes.indiatimes.com/industry/banking/finance/rug-pulls-avoiding-the-cryptocurrency-scam/what-is-rug-pull/slideshow/91563115.cms<br>https://fortune.com/2022/03/02/crypto-scam-rug-pull-what-is-it/<br>https://www.pcmag.com/encyclopedia/term/nft-rug-pull<br>https://finematics.com/history-of-defi-explained/<br>https://blog.1inch.io/types-of-defi-their-pros-and-cons-c5ec2f18ff11<br>https://academy.moralis.io/blog/defi-deep-dive-explaining-defi-attack-vectors-and-prevention<br>https://assets.ctfassets.net/hfgyig42jimx/2l90zr21hmUG2aL7eK02Cl/ccb091f0c5247abaed4984bc3c286782/Attacks_and_Exploits_in_DeFi.pdf<br>https://www.investopedia.com/decentralized-finance-defi-5113835<br>https://chain.link/education/defi<br>https://defillama.com/<br>https://cointelegraph.com/news/more-than-1-6-billion-exploited-from-defi-so-far-in-2022<br>https://medium.com/@imdheeraj28/squid-game-crypto-scam-a-case-study-d5a306e7b462</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=100f906b41ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Squid Game Crypto Scam — A Case Study]]></title>
            <link>https://medium.com/@imdheeraj28/squid-game-crypto-scam-a-case-study-d5a306e7b462?source=rss-2df8ab87fa29------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5a306e7b462</guid>
            <category><![CDATA[squid-game]]></category>
            <category><![CDATA[crypto-scam]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[investing]]></category>
            <dc:creator><![CDATA[Dheeraj Kumar]]></dc:creator>
            <pubDate>Sat, 06 Nov 2021 08:50:39 GMT</pubDate>
            <atom:updated>2021-11-06T08:50:39.447Z</atom:updated>
            <content:encoded><![CDATA[<h3>Squid Game Crypto Scam — A Case Study</h3><p>This blog is about the most famous and hit Netflix show — Squid Game and the meme token launched on its name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*7VruPVZvLvYoMzgipKM5Uw.jpeg" /><figcaption>Squid Game has become Netflix’s popular shows.</figcaption></figure><p><strong>What is Squid Game?</strong></p><p>Squid Game is the South Korean drama series streaming on Netflix that has captured the interest of audience globally. The thriller series has become one of the most watched shows on Netflix within days of its release. It’s been on the mouth of viewers and one of the favorite things for meme creators.</p><p>Squid Game is a fictional survival series which requires people to participate in games that children might play. Either they win at life in Squid Game, or end up their lives trying.</p><p><strong>The SQUID GAME TOKEN</strong></p><p>Following the massive craze of the series since its release on streaming giant Netflix, it paved the way for the launch of a digital token named “Squid”. The token Squid, marketed itself as a “play-to-earn-cryptocurrency” has seen its price to soar within days of its launch — surging by thousands of per cent.</p><p>A “Play-to-earn” cryptocurrency is one where people buy tokens to use them in online games and can earn more tokens and later on exchange them for other cryptocurrencies or national currencies through exchanges.</p><p>Earlier this Tuesday, it was trading at around 1 cent and within a week its, its price had jumped to over $2856. Its value plummeted by 99.99% according to CoinMarketCap just after the developers withdrew the entire invested money. The scam is estimated to be worth around $3.38 million.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*bfmGwI9Wle8v3On_vY5K1A.png" /><figcaption>Squid Token price chart in USD. (Source : CoinMarketCap)</figcaption></figure><p>Squid was promoted as a token that could be used for a new online game similar to the one shown in the series — which tells the story of a group of people forced to play deadly children’s game for money. The game was supposed to be live within a month.</p><p>However, crypto experts had warned of several signs which made us think of Squid as a scam.</p><p>Most of the people who bought the Squid Tokens were unable to sell them. It was invest only kind of thing.</p><p>Some critics also highlighted that its website contained many spelling mistakes and grammatical errors. The website and social media handles promoting the Squid tokens are no more accessible.</p><p>It’s a kind of “rug pull” scam. This kind of scam includes the stoppage of trading activity after drawing in the buyers, and then the developer of the digital coin takes off with the money raised by selling the token.</p><p><strong>What next in Squid Token Scam ?</strong></p><p>The Squid Token was developed on Binance Smart Chain which is an open network. It was not in hands of Binance to know the actual utility of every project that runs on its network. But as a goodwill gesture, the cryptocurrency exchange Binance will now investigate the scam. The exchange has also announced ways in which it will prohibit accounts linked to the scam from its network.</p><p>In a note to CoinDesk, Binance explains that it will use blockchain analytics to identify the bad actors and will blacklist all addresses linked to them. Also, it will share all the information from its investigation to the appropriate law enforcement agency.</p><h3><strong>Lessons for the early Investors from this scam</strong></h3><ul><li>Never run for FOMO. Anything that has been popular necessarily won’t carry significant value.</li><li>Keep yourself away from projects that have very high price swings.</li><li>Always do a primary research before investing in any project. Look for the developers team behind the project, utility of the token, technology superiority, its performance over time, etc.</li><li>Never ever trust new cryptos early. Check if they are listed for trade on famous centralized crypto exchanges.</li><li>Always look for its future use cases.</li><li>Never follow the craze and always do your own research.</li><li>One should not just put all your life’s earnings in such projects. Even if the projects seems promising, invest only a little because cryptos are highly volatile.</li></ul><h4>Reference:</h4><p>BBC , Blockonomist, Livemint, IndiaToday, Hindustan Times.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5a306e7b462" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>