<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>HyperByte</title>
  
  <subtitle>HyperByte</subtitle>
  <link href="http://example.com/rss.xml" rel="self"/>
  
  <link href="http://example.com/"/>
  <updated>2026-10-18T08:35:25.850Z</updated>
  <id>http://example.com/</id>
  
  <author>
    <name>Muhammatjan.Alim</name>
    
  </author>
  
  <generator uri="https://hexo.io/">Hexo</generator>
  
  <entry>
    <title>This is how flash loan arbitrages</title>
    <link href="http://example.com/2026/10/18/flushloan/"/>
    <id>http://example.com/2026/10/18/flushloan/</id>
    <published>2026-10-18T05:53:43.000Z</published>
    <updated>2026-10-18T08:35:25.850Z</updated>
    
    <content type="html"><![CDATA[<p>At first, a non-developer intuitively thought of a complete contract transaction as a single fast ‘action’, but indeed a contract  “transaction” actually wraps many “internal actions”, sometimes they’re hundreds. They’re all executed synchronously , one by one , in a single thread, before the transaction finishes.</p><p>That’s exactly what a flash loan is: doing multiple actions in sequence within one transaction to carry out a speculative trade.</p><p>When you hit “confirm” in your wallet and send a transaction, you’re not just submitting a simple action to Ethereum — you’re submitting an entire program execution.</p><hr><p>Now, with this in mind , here’s the break down of flash loan’s entire program:</p><ol><li>Call Aave’s <code>flashLoan()</code> function to borrow funds.</li><li>Once the funds arrive, Aave triggers the callback function in your contract (where you write your arbitrage logic).</li><li>Your contract buys on Uniswap.</li><li>Your contract sells on SushiSwap.</li><li>Your contract transfers the borrowed amount plus the fee back to Aave.</li><li>The transaction ends, and the final state is settled (packaged into a block).</li></ol><blockquote><p>In traditional finance, if you borrow $10 million with 10x leverage and lose $1 million after trading, and you can’t pay it back, the bank has to sue you and freeze your assets.</p></blockquote><p><strong>But in blockchain smart contracts, there’s only one fallback mechanism for all of this: revert.</strong></p><p>Powerful undo button.</p><p>Here is break down of lose money:</p><ol><li>Your contract sells on SushiSwap.</li><li>It turns out , didn’t just make no money, you actually lost 100k.</li><li>Program execute to the last step: <code>require(&#123;Repayment amount &gt; 10million&#125;,&quot;...&quot;);</code></li><li>You only have 9.9million left, <code>require</code> fails and triggers <strong>revert</strong>.</li><li>Miracle happens: it rolls back everything that happened in the transaction, 10million eventually gets back to Aave. Example of revert:<ul><li>Your account initially had 0 USDC</li><li>Aave pool’s total amount: 10million USDC</li><li>After losing money and require fails , atomicly reverts to original states: Aave(1000USDC) &amp; your account(0USDC).</li><li>The only loss is the gas fee.</li></ul></li></ol><hr><p>I’d call it money printing machine.</p>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;At first, a non-developer intuitively thought of a complete contract transaction as a single fast ‘action’, but indeed a contract  “trans</summary>
      
    
    
    
    
    <category term="tech" scheme="http://example.com/tags/tech/"/>
    
  </entry>
  
  <entry>
    <title>Smart contract security (I)</title>
    <link href="http://example.com/2026/10/15/smartContractSecurity/"/>
    <id>http://example.com/2026/10/15/smartContractSecurity/</id>
    <published>2026-10-15T06:19:39.000Z</published>
    <updated>2026-10-18T08:35:25.853Z</updated>
    
    <content type="html"><![CDATA[<p>Let’s review this piece of code and see what vulnerabilities might be hiding in there.</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #8b949e;">// SPDX-License-Identifier: MIT</span><span style="color: #ff7b72;">pragma</span> solidity <span style="color: #79c0ff;">^0.8.0</span>;<span style="color: #ff7b72;">interface</span> <span style="color: #ffa657;">IERC20</span> &#123;    <span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">approve</span>(<span style="color: #ff7b72;">address</span> spender, <span style="color: #ffa657;">uint256</span> amount) <span style="color: #ff7b72;">external</span> <span style="color: #ff7b72;">returns</span> (<span style="color: #ffa657;">bool</span>);    <span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">transferFrom</span>(<span style="color: #ff7b72;">address</span> from, <span style="color: #ff7b72;">address</span> to, <span style="color: #ffa657;">uint256</span> amount) <span style="color: #ff7b72;">external</span> <span style="color: #ff7b72;">returns</span> (<span style="color: #ffa657;">bool</span>);    <span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">transfer</span>(<span style="color: #ff7b72;">address</span> recipient, <span style="color: #ffa657;">uint256</span> amount) <span style="color: #ff7b72;">external</span> <span style="color: #ff7b72;">returns</span> (<span style="color: #ffa657;">bool</span>);&#125;<span style="color: #ff7b72;">interface</span> <span style="color: #ffa657;">IAaveLendingPool</span> &#123;    <span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">deposit</span>(<span style="color: #ff7b72;">address</span> asset, <span style="color: #ffa657;">uint256</span> amount, <span style="color: #ff7b72;">address</span> onBehalfOf, <span style="color: #ffa657;">uint16</span> referralCode) <span style="color: #ff7b72;">external</span>;&#125;<span style="color: #ff7b72;">contract</span> <span style="color: #ffa657;">YieldAggregator</span> &#123;    <span style="color: #ff7b72;">address</span> <span style="color: #ff7b72;">public</span> owner;    <span style="color: #ffa657;">IERC20</span> <span style="color: #ff7b72;">public</span> <span style="color: #ff7b72;">immutable</span> usdc;    <span style="color: #ffa657;">IAaveLendingPool</span> <span style="color: #ff7b72;">public</span> aave;    <span style="color: #ff7b72;">mapping</span>(<span style="color: #ff7b72;">address</span> =&gt; <span style="color: #ffa657;">uint256</span>) <span style="color: #ff7b72;">public</span> deposits;    <span style="color: #ff7b72;">constructor</span>(<span style="color: #ff7b72;">address</span> _usdc, <span style="color: #ff7b72;">address</span> _aave) &#123;        owner = msg.sender;        usdc = <span style="color: #ffa657;">IERC20</span>(_usdc);        aave = <span style="color: #ffa657;">IAaveLendingPool</span>(_aave);    &#125;    <span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">deposit</span>(<span style="color: #ffa657;">uint256</span> amount) <span style="color: #ff7b72;">external</span> &#123;        <span style="color: #ff7b72;">require</span>(amount &gt; 0, <span style="color: #a5d6ff;">"Amount must be &gt; 0"</span>);        usdc.<span style="color: #d2a8ff;">transferFrom</span>(msg.sender, <span style="color: #ff7b72;">address</span>(<span style="color: #ff7b72;">this</span>), amount);        usdc.<span style="color: #d2a8ff;">approve</span>(<span style="color: #ff7b72;">address</span>(aave), amount);        aave.<span style="color: #d2a8ff;">deposit</span>(<span style="color: #ff7b72;">address</span>(usdc), amount, msg.sender, 0);         deposits[msg.sender] += amount;    &#125;    <span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">setAave</span>(<span style="color: #ff7b72;">address</span> _aave) <span style="color: #ff7b72;">external</span> &#123;        <span style="color: #ff7b72;">require</span>(msg.sender == owner, <span style="color: #a5d6ff;">"Not owner"</span>);        aave = <span style="color: #ffa657;">IAaveLendingPool</span>(_aave);    &#125;    <span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">emergencyWithdraw</span>(<span style="color: #ff7b72;">address</span> token, <span style="color: #ffa657;">uint256</span> amount) <span style="color: #ff7b72;">external</span> &#123;        <span style="color: #ff7b72;">require</span>(msg.sender == owner, <span style="color: #a5d6ff;">"Not owner"</span>);        <span style="color: #ffa657;">IERC20</span>(token).<span style="color: #d2a8ff;">transfer</span>(owner, amount);    &#125;&#125;</code></pre></div><br><br><br><div style="display: flex; align-items: center; gap: 12px; max-width: 720px; margin: 24px auto; font-family: 'SF Mono', Consolas, monospace; font-size: 13px; color: #8b949e;">  <div style="flex: 1; border-top: 1px solid #30363d;"></div>  <span style="white-space: nowrap;">Time to think</span>  <div style="flex: 1; border-top: 1px solid #30363d;"></div></div><br><br><br><br><br><br><br><p>time’s up.</p><ul><li><p><strong>We usually pay special attention to external contract calls , for checking reentrancy vulnerabilities [★★★★★★]</strong></p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">deposit</span>(<span style="color: #ffa657;">uint256</span> amount) <span style="color: #ff7b72;">external</span> &#123;    <span style="color: #ff7b72;">require</span>(amount &gt; 0, <span style="color: #a5d6ff;">"Amount must be &gt; 0"</span>);    usdc.<span style="color: #d2a8ff;">transferFrom</span>(msg.sender, <span style="color: #ff7b72;">address</span>(<span style="color: #ff7b72;">this</span>), amount);  <span style="color: #8b949e;">// ← call externals</span>    usdc.<span style="color: #d2a8ff;">approve</span>(<span style="color: #ff7b72;">address</span>(aave), amount);    aave.<span style="color: #d2a8ff;">deposit</span>(<span style="color: #ff7b72;">address</span>(usdc), amount, msg.sender, 0);     <span style="color: #8b949e;">// ← call externals</span>deposits[msg.sender] += amount;  <span style="color: #8b949e;">// ← Status updates come last</span>&#125;</code></pre></div><blockquote><p>Why external contract calls could be exposed to reentrancy attacks?</p><p>EVM is single-threaded, and each call to external contracts runs synchronously. If the external contract is a bad guy, it calls the <code>deposit</code> function again when it is called by <code>transferFrom</code>, then we are getting back to the <code>deposit</code> function again, that’s causing <code>transferFrom</code> to run again, it’s transferring again and again and again… till it cleans up all of your money.</p></blockquote><p>So, this is the fix:</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">deposit</span>(<span style="color: #ffa657;">uint256</span> amount) <span style="color: #ff7b72;">external</span> <span style="color: #ff7b72;">nonReentrant</span> &#123;    <span style="color: #ff7b72;">require</span>(amount &gt; 0, <span style="color: #a5d6ff;">"Amount must be &gt; 0"</span>);    deposits[msg.sender] += amount;  <span style="color: #8b949e;">// ← Update the state first</span>    usdc.<span style="color: #d2a8ff;">transferFrom</span>(msg.sender, <span style="color: #ff7b72;">address</span>(<span style="color: #ff7b72;">this</span>), amount);    usdc.<span style="color: #d2a8ff;">approve</span>(<span style="color: #ff7b72;">address</span>(aave), amount);    aave.<span style="color: #d2a8ff;">deposit</span>(<span style="color: #ff7b72;">address</span>(usdc), amount, msg.sender, 0);&#125;</code></pre></div><p>Either add a <code>nonReentrant</code> modifier or swap these two line, we do both. (nonReentrant modifier requires _status != _ENTERED , to prevent reentrancy )</p></li></ul><br><ul><li><p><strong>Single point of failure (SPOF) [★★★★★★]</strong></p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">setAave</span>(<span style="color: #ff7b72;">address</span> _aave) <span style="color: #ff7b72;">external</span> &#123;    <span style="color: #ff7b72;">require</span>(msg.sender == owner, <span style="color: #a5d6ff;">"Not owner"</span>);    aave = <span style="color: #ffa657;">IAaveLendingPool</span>(_aave);  <span style="color: #8b949e;">// ← this can change address by owner alone</span>&#125;</code></pre></div><p>​The owner alone can change some critical variables ，better not to allow this.</p><p>​Advice: consider using multi-sig</p><br></li><li><p><strong>backdoor [★★★★★★]</strong></p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">emergencyWithdraw</span>(<span style="color: #ff7b72;">address</span> token, <span style="color: #ffa657;">uint256</span> amount) <span style="color: #ff7b72;">external</span> &#123;    <span style="color: #ff7b72;">require</span>(msg.sender == owner, <span style="color: #a5d6ff;">"Not owner"</span>);    <span style="color: #ffa657;">IERC20</span>(token).<span style="color: #d2a8ff;">transfer</span>(owner, amount);  <span style="color: #8b949e;">// ← rug pull</span>&#125;</code></pre></div><p>​</p><ol><li><p>It’s called an ‘emergency withdrawal’ , but it’s really a rug pull backdoor.</p></li><li><p>Users fully trust the owner, but they have no protection</p><p>Fix: Might add this line: <code>require(token != address(usdc), &quot;Cannot withdraw USDC&quot;);</code> to protect USDCs. Anyway, the fix always depends on the situation.</p></li></ol></li></ul><br><ul><li><p><strong>Compatibility [★★☆☆☆☆]</strong></p><ul><li><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px 24px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 14px; line-height: 1.8; box-shadow: 0 2px 12px rgba(0,0,0,0.4);"><pre style="margin: 0; white-space: pre-wrap;"><code><span style="color: #79c0ff;">usdc</span>.<span style="color: #d2a8ff;">transferFrom</span>(<span style="color: #ffa657;">msg.sender</span>, <span style="color: #ffa657;">address</span>(<span style="color: #79c0ff;">this</span>), <span style="color: #ffa657;">amount</span>);<span style="color: #8b949e;">// ← The return value of `transferFrom` isn't handled</span></code></pre></div><p>Some ERC-20 tokens don’t return a bool from <code>transferFrom</code>, and they won’t revert even if the transfer fails, for example the early USDT didn’t return a bool from <code>transfer</code> or <code>transferFrom</code> , recommend using SafeERC20 instead.</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #ff7b72;">using</span> <span style="color: #ffa657;">SafeERC20</span> <span style="color: #ff7b72;">for</span> <span style="color: #ffa657;">IERC20</span>;usdc.<span style="color: #d2a8ff;">safeTransferFrom</span>(msg.sender, <span style="color: #ff7b72;">address</span>(<span style="color: #ff7b72;">this</span>), amount);</code></pre></div></li></ul></li></ul><br><ul><li><p><strong>Design defect [★★☆☆☆☆]</strong></p><p>You’re only depositing money, and there are no withdrawals for users. I think this it is a design flaw.</p><p>We need to be sure to provide a solution to withdraw funds that got stock somewhere , that convinces users to trust the contract.</p></li></ul>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;Let’s review this piece of code and see what vulnerabilities might be hiding in there.&lt;/p&gt;
&lt;div style=&quot;font-family: &#39;SF Mono&#39;, Consolas, </summary>
      
    
    
    
    
    <category term="tech" scheme="http://example.com/tags/tech/"/>
    
  </entry>
  
  <entry>
    <title>Color and Light - from the Masnavi (Rumi)</title>
    <link href="http://example.com/2026/10/10/Mesnavi/"/>
    <id>http://example.com/2026/10/10/Mesnavi/</id>
    <published>2026-10-10T07:36:55.000Z</published>
    <updated>2026-10-18T08:35:25.850Z</updated>
    
    <content type="html"><![CDATA[<h3 style="text-align: center">رەڭ ۋە نۇر</h3><div style="text-align: center;">  قىزىل، يېشىل ۋە كۈلرەڭلەرنى يورۇقلۇقتا كۆرمىسەڭ كۆرەلمەيسەن<br>  ســەن رەڭلەرنــى كۆرگەنلىگىــڭ ئۈچــۈن، نــۇر ســەندىن رەڭگــە يوشــۇرۇنغان بولىدۇ<br>  قاراڭغــۇ چۈشســە رەڭلــەر يوشــۇرۇنىدۇ. دەل مانــا شــۇ چاغــدا، رەڭنــى كۆرسـەتكەننىڭ نـۇر ئىكەنلىكىنـى بىلىسـەن. نـۇر بولمىسـا رەڭنـى كۆرەلمەيسـەن. ئىچىمىزدىكــى رەڭلەرمــۇ ئەنــە شــۇنداق بىــر نۇرغــا مۇھتــاج<br>  ئاينىـڭ، قۇياشـنىڭ ۋە يۇلتۇزلارنىـڭ نـۇرى بولسـا بىزنىـڭ كۆزىمىـزدە زاھىـر بولغـان يورۇقلۇقتىـن ئىبـارەت<br>  ئىنساننىڭ ئىچىدىكى نۇر - پارلاق بىر نۇرنىڭ ئەكسىدۇر<br>  كۆز نۇرى كۆڭۈل نۇرىدۇر<br>  كۆڭۈل نۇرى ھەقنىڭ نۇرىدىن كېلىدۇر<br>  كەچتە نۇر بولمىغانلىقتىن، رەڭلەر كۆرۈنمەس<br>  رەڭ يورۇقلۇق بىلەن روشەن بولۇر<br>  تەڭـرى، "بـۇ زىتلىققـا ئاساسـەن خوشـاللىق مەيدانغـا كەلسـۇن" دەپ، غـەم-قايغۇنـى ياراتتى<br>  ھەر يوشۇرۇن شەيئىلەر زىتلىق ئارقىلىق ئوتتۇرىغا چىقتى<br>  ھەقنىڭ زتلىقى بولمىغانلىقى ئۈچۈن ئۇ كۆرۈنمىدى<br>  ئاۋال يورۇقلــۇق، ئاندىــن رەڭ كۆرۈنىــدۇ. چۈنكــى ئاق ۋە قــارا بىــر- بىرىگــە زىتتــۇر<br>  نۇرنىـڭ ئەكسـى سـاڭا نـۇر بەخـش ئەتتـى. ماددىدىكـى زىتلىق زىتلىقـى ئارقىلق كۆرۈندى<br>  ھــەق نۇرىنىــڭ زىتــى ئۈچــۈن، بىــر مەۋجــۇدات يوقتــۇر. ئۇنــى زىتــى بىلــەن كـۆرۈش ئىمكانى يوقتۇر<br>    بىزنىڭ ئەقلىمىز ئۇنىڭغا يەتمەيدۇ،  ئەمما، ئۇ بىزنىڭ سـىرلىرىمىزنى،  پۈتۈن ئەھۋالىمىزنى كۆرۈپ بىلىپ تۇرىدۇ<br></div><p> </p><h3 style="text-align: center">Color and Light</h3><div style="text-align: center;">(First) comes the seeing of light, then the seeing of colour, and this thou knowest immediately by the opposite of light (darkness).<br>  There is no vision of colour without the external light, even so it is with the colour of inward phantasy.<br>  This outward (light) is (derived) from the sun and from Suhá, while the inward (light) is from the reflexion of the beams of (Divine) Glory.<br>  The light which gives light to the eye is in truth the light of the heart: the light of the eye is produced by the light of hearts.<br>  Again, the light which gives light to the heart is the Light of God, which is pure and separate from the light of intellect and sense.<br>  At night there was no light and thou didst not see the colours, then it (the light) was made manifest by the opposite of light (by darkness).<br>  (First) comes the seeing of light, then the seeing of colour, and this thou knowest immediately by the opposite of light (darkness).<br>  God created pain and sorrow for the purpose that happiness might be made manifest by means of this opposite.<br>  Hidden things, then, are manifested by means of their opposite, since God hath no opposite, He is hidden.<br></div>]]></content>
    
    
      
      
    <summary type="html">&lt;h3 style=&quot;text-align: center&quot;&gt;رەڭ ۋە نۇر&lt;/h3&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
  قىزىل، يېشىل ۋە كۈلرەڭلەرنى يورۇقلۇقتا كۆرمىسەڭ كۆرەلمەيس</summary>
      
    
    
    
    
    <category term="thoughts" scheme="http://example.com/tags/thoughts/"/>
    
  </entry>
  
  <entry>
    <title>Uniswap-V3 after V2</title>
    <link href="http://example.com/2026/09/24/uniswap-v3/"/>
    <id>http://example.com/2026/09/24/uniswap-v3/</id>
    <published>2026-09-24T08:02:00.000Z</published>
    <updated>2026-10-18T08:35:25.853Z</updated>
    
    <content type="html"><![CDATA[<p><strong>Suppose</strong> the real-time price of the ETH/DAI trading pair is 1500 DAI/ETH.</p><p>Initial state: The pool holds 4,500 DAI and 3 ETH, with a price of 1,500 DAI/ETH.</p><p>After a price drop: ETH falls to 1,300 DAI/ETH, and arbitrageurs will buy ETH from the pool until the pool price also reaches 1,300.</p><p>Final state: The pool ends up with 4,192.54 DAI and 3.22 ETH.</p><blockquote><ul><li><p>The DAI balance in the pool decreased by 6.84%.</p></li><li><p>The ETH balance in the pool increased — from 3 to 3.22.</p></li></ul><p>If you’re an LP and you put your money in, then when ETH’s price drops, the pool will automatically “sell” some DAI to buy ETH. This process changes the composition of the assets you hold, and it usually results in <strong><a href="https://urayimahundihkan.github.io/2026/08/09/IL/">impermanent loss</a></strong>.</p></blockquote><p>[ Uniswap-V3 ]</p><p><strong>Uniswap V3 introduced concentrated liquidity, letting LPs choose their own price range. This gives them more control over their impermanent loss exposure — a narrower range means less IL risk, but requires more rebalancing.</strong></p><p>Scenerio:</p><p><strong>1. Create the pool (anyone can do this)</strong></p><ul><li>Pair: ETH/USDC</li><li>Fee tier: 0.3%</li><li>The pool starts with no liquidity</li></ul><p><strong>2. LP A adds liquidity</strong></p><ul><li>Picks the range [1500, 2500]</li><li>Deposits 1000 USDC + 0.5 ETH</li><li>Gets an ERC721</li></ul><p><strong>3. LP B adds liquidity</strong></p><ul><li>Picks a narrower range: [1800, 2200]</li><li>Deposits 500 USDC + 0.25 ETH</li><li>Gets another ERC721</li></ul><p><strong>4. LP C adds liquidity</strong></p><ul><li>Picks a wider range: [1500, 3000]</li><li>Deposits 2000 USDC + 1 ETH</li><li>Gets a third ERC721</li></ul><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; background: #0d1117; border-radius: 16px; padding: 28px 32px; max-width: 720px; color: #e6edf3; font-size: 14px; line-height: 1.6; box-shadow: 0 2px 12px rgba(0,0,0,0.4);">  <div style="margin-bottom: 12px; color: #e6edf3;">Price axis:</div>  <div style="position: relative; width: 70%; height: 20px; border-bottom: 1.5px solid #e6edf3; margin-bottom: 28px;">    <span style="position: absolute; right: -2px; bottom: -8px; font-size: 16px; line-height: 0; color: #e6edf3;">►</span>  </div>  <div style="position: relative; width: 70%; height: 20px; margin-bottom: 20px;">    <span style="position: absolute; left: 0%;   transform: translateX(-50%); color: #e6edf3;">1000</span>    <span style="position: absolute; left: 25%;  transform: translateX(-50%); color: #e6edf3;">1500</span>    <span style="position: absolute; left: 50%;  transform: translateX(-50%); color: #e6edf3;">2000</span>    <span style="position: absolute; left: 75%;  transform: translateX(-50%); color: #e6edf3;">2500</span>    <span style="position: absolute; left: 100%; transform: translateX(-50%); color: #e6edf3;">3000</span>  </div>  <div style="position: relative; width: 70%; height: 18px; margin-bottom: 12px;">    <span style="position: absolute; left: 25%;  transform: translateX(-50%); color: #e6edf3;">│</span>    <span style="position: absolute; left: 50%;  transform: translateX(-50%); color: #e6edf3;">│</span>    <span style="position: absolute; left: 75%;  transform: translateX(-50%); color: #e6edf3;">│</span>  </div>  <div style="position: relative; width: 70%; height: 28px; display: flex; align-items: center;">    <span style="position: absolute; left: -68px; width: 60px; text-align: right; color: #e6edf3;">LP A:</span>    <div style="position: absolute; left: 25%; width: 50%; display: flex; align-items: center; justify-content: space-between; color: #7ee787;">      <span>[</span>      <span style="flex: 1; border-top: 1.5px solid #7ee787; margin: 0 4px;"></span>      <span>1500~2500</span>      <span style="flex: 1; border-top: 1.5px solid #7ee787; margin: 0 4px;"></span>      <span>]</span>    </div>  </div>  <div style="position: relative; width: 70%; height: 28px; display: flex; align-items: center;">    <span style="position: absolute; left: -68px; width: 60px; text-align: right; color: #e6edf3;">LP B:</span>    <div style="position: absolute; left: 40%; width: 20%; display: flex; align-items: center; justify-content: center; gap: 6px; color: #79c0ff;">      <span>[</span>      <span>1800~2200</span>      <span>]</span>    </div>  </div>  <div style="position: relative; width: 70%; height: 28px; display: flex; align-items: center;">    <span style="position: absolute; left: -68px; width: 60px; text-align: right; color: #e6edf3;">LP C:</span>    <div style="position: absolute; left: 25%; width: 75%; display: flex; align-items: center; justify-content: space-between; color: #ffa657;">      <span>[</span>      <span style="flex: 1; border-top: 1.5px solid #ffa657; margin: 0 4px;"></span>      <span>1500~3000</span>      <span style="flex: 1; border-top: 1.5px solid #ffa657; margin: 0 4px;"></span>      <span>]</span>    </div>  </div></div><p>LP A,B,C, they only earn fees within their own range.</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; padding: 24px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 14px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4);">  <table style="width: 100%; border-collapse: collapse;">    <thead>      <tr style="border-bottom: 1.5px solid #e6edf3;">        <th style="text-align: center; padding: 8px 12px; font-weight: 600; color: #e6edf3;">Price range</th>        <th style="text-align: center; padding: 8px 12px; font-weight: 600; color: #e6edf3;">Live LP</th>        <th style="text-align: center; padding: 8px 12px; font-weight: 600; color: #e6edf3;">total liquidity</th>      </tr>    </thead>    <tbody>      <tr style="border-bottom: 1px solid #30363d;">        <td style="padding: 8px 12px; text-align: center; color: #e6edf3;">1000~1500</td>        <td style="padding: 8px 12px; text-align: center; color: #7ee787;">LP A</td>        <td style="padding: 8px 12px; text-align: center; color: #e6edf3;">100</td>      </tr>      <tr style="border-bottom: 1px solid #30363d;">        <td style="padding: 8px 12px; text-align: center; color: #e6edf3;">1500~1800</td>        <td style="padding: 8px 12px; text-align: center; color: #7ee787;">LP A + LP B</td>        <td style="padding: 8px 12px; text-align: center; color: #e6edf3;">300</td>      </tr>      <tr style="border-bottom: 1px solid #30363d;">        <td style="padding: 8px 12px; text-align: center; color: #e6edf3;">1800~2000</td>        <td style="padding: 8px 12px; text-align: center; color: #7ee787;">LP A + LP B + LP C</td>        <td style="padding: 8px 12px; text-align: center; color: #e6edf3;">600</td>      </tr>      <tr style="border-bottom: 1px solid #30363d;">        <td style="padding: 8px 12px; text-align: center; color: #e6edf3;">2000~2200</td>        <td style="padding: 8px 12px; text-align: center; color: #7ee787;">LP B + LP C</td>        <td style="padding: 8px 12px; text-align: center; color: #e6edf3;">500</td>      </tr>      <tr>        <td style="padding: 8px 12px; text-align: center; color: #e6edf3;">2200~2500</td>        <td style="padding: 8px 12px; text-align: center; color: #7ee787;">LP B</td>        <td style="padding: 8px 12px; text-align: center; color: #e6edf3;">200</td>      </tr>    </tbody>  </table></div><hr><p><strong>Tick</strong></p><ul><li>Another concept invented by V3, is Tick — price is discretized into ticks, and each tick corresponds to a specific price, during trading, the price moves between ticks. the formula is:</li></ul><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true"><svg style="vertical-align: -0.05ex;" xmlns="http://www.w3.org/2000/svg" width="17.686ex" height="2.094ex" role="img" focusable="false" viewBox="0 -903.7 7817.4 925.7"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="Price = 1.0001^{tick}"><g data-mml-node="mi" data-latex="P"><path data-c="1D443" d="M555 683L235 683C212 683 201 682 201 660C201 649 212 644 234 644C254 644 294 647 294 631C294 629 293 623 290 613L158 82C152 60 142 47 128 42C121 40 103 39 72 39C50 39 40 37 40 16C40 5 46 0 59 0L184 3L248 2C259 2 299 0 312 0C328 0 336 8 336 24C336 34 325 39 304 39C264 39 244 43 244 52C244 52 245 55 247 68L307 312L472 312C537 312 599 332 657 371C722 414 754 467 754 530C754 629 660 683 555 683M524 644C611 644 654 614 654 554C654 498 626 423 597 397C559 363 509 346 447 346L313 346L379 610C387 644 387 644 429 644Z"></path></g><g data-mml-node="mi" data-latex="r" transform="translate(754,0)"><path data-c="1D45F" d="M436 374C436 416 395 442 351 442C302 442 261 419 227 372C217 411 183 442 136 442C95 442 65 410 44 345C34 312 29 293 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C150 413 159 399 159 371C159 358 154 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 110-11C130-11 143-1 150 19L169 91C180 134 187 162 190 175L221 303C223 311 231 324 244 343C271 381 302 413 351 413C363 413 373 411 382 406C352 397 337 378 337 351C337 325 351 312 378 312C411 312 436 341 436 374Z"></path></g><g data-mml-node="mi" data-latex="i" transform="translate(1205,0)"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"></path></g><g data-mml-node="mi" data-latex="c" transform="translate(1550,0)"><path data-c="1D450" d="M328 325C328 300 341 287 368 287C404 287 427 318 427 354C427 410 368 442 308 442C239 442 176 412 122 353C68 294 41 229 41 159C41 61 106-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 121 53 121 122C121 184 150 274 174 317C198 361 249 413 308 413C346 413 372 402 386 381C355 378 328 358 328 325Z"></path></g><g data-mml-node="mi" data-latex="e" transform="translate(1983,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"></path></g><g data-mml-node="mo" data-latex="=" transform="translate(2726.8,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="msup" data-latex="1.0001^{t i c k}" transform="translate(3782.6,0)"><g data-mml-node="mn" data-latex="1.0001"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path><path data-c="2E" d="M192 53C192 82 168 106 139 106C110 106 86 82 86 53C86 24 110 0 139 0C168 0 192 24 192 53Z" transform="translate(500,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(778,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(1278,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(1778,0)"></path><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z" transform="translate(2278,0)"></path></g><g data-mml-node="TeXAtom" transform="translate(2811,413) scale(0.707)" data-latex="{t i c k}" data-mjx-texclass="ORD"><g data-mml-node="mi" data-latex="t"><path data-c="1D461" d="M330 419C330 428 320 433 299 433L218 433C244 537 257 591 257 595C257 616 246 626 225 626C202 626 188 613 182 587L145 433L56 433C34 433 23 432 23 411C23 400 33 395 54 395L135 395C86 200 62 97 62 84C62 28 100-11 156-11C194-11 227 6 256 41C280 70 297 98 308 125C312 136 314 142 314 145C314 154 309 159 299 159C291 159 285 154 281 143C247 60 206 19 157 19C140 19 131 33 131 60C131 75 133 91 137 107L208 395L297 395C323 395 330 397 330 419Z"></path></g><g data-mml-node="mi" data-latex="i" transform="translate(361,0)"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"></path></g><g data-mml-node="mi" data-latex="c" transform="translate(706,0)"><path data-c="1D450" d="M328 325C328 300 341 287 368 287C404 287 427 318 427 354C427 410 368 442 308 442C239 442 176 412 122 353C68 294 41 229 41 159C41 61 106-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 121 53 121 122C121 184 150 274 174 317C198 361 249 413 308 413C346 413 372 402 386 381C355 378 328 358 328 325Z"></path></g><g data-mml-node="mi" data-latex="k" transform="translate(1139,0)"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g></g></g></g></g></svg></mjx-container></p><p>​</p><blockquote><ul><li>tick = 0 → price = 1</li><li>tick = 1 → price = 1.0001</li><li>tick = 100 → price = 1.0001^100 ≈ 1.01005</li><li>tick = -100 → price = 1.0001^-100 ≈ 0.99005</li></ul><p>But, Why 0.0001 ?</p><p>​A 0.01% price change — that’s precise enough.</p><p>example:</p><ul><li>LP wants to provide liquidity in the range [1500, 2500]</li><li>Convert to ticks:<br>tickLower = tick(1500) ≈ -23028<br>tickUpper = tick(2500) ≈ 19570</li></ul></blockquote><ul><li>Each tick has its own liquidity</li></ul><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 28px 32px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 14px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4);">  <div style="margin-bottom: 12px; color: #e6edf3;">价格轴（从低到高）：</div>  <div style="position: relative; height: 20px; border-bottom: 1.5px solid #e6edf3; margin-bottom: 24px;">    <span style="position: absolute; right: -2px; bottom: -8px; font-size: 16px; line-height: 0; color: #e6edf3;">►</span>  </div>  <div style="display: flex; justify-content: space-around; align-items: flex-end;">    <div style="text-align: center;">      <div style="margin-bottom: 4px; color: #e6edf3;">tick A</div>      <div style="color: #e6edf3;">│</div>      <div style="color: #e6edf3;">▼</div>      <div style="display: inline-block; width: 36px; height: 60px; border: 1.5px solid #7ee787; border-radius: 4px; margin: 6px 0;"></div>      <div style="color: #7ee787;">100 USDC</div>    </div>    <div style="text-align: center;">      <div style="margin-bottom: 4px; color: #e6edf3;">tick B</div>      <div style="color: #e6edf3;">│</div>      <div style="color: #e6edf3;">▼</div>      <div style="display: inline-block; width: 36px; height: 60px; border: 1.5px solid #79c0ff; border-radius: 4px; margin: 6px 0;"></div>      <div style="color: #79c0ff;">500 USDC</div>    </div>    <div style="text-align: center;">      <div style="margin-bottom: 4px; color: #e6edf3;">tick C</div>      <div style="color: #e6edf3;">│</div>      <div style="color: #e6edf3;">▼</div>      <div style="display: inline-block; width: 36px; height: 60px; border: 1.5px solid #ffa657; border-radius: 4px; margin: 6px 0;"></div>      <div style="color: #ffa657;">200 USDC</div>    </div>    <div style="text-align: center;">      <div style="margin-bottom: 4px; color: #e6edf3;">tick D</div>      <div style="color: #e6edf3;">│</div>      <div style="color: #e6edf3;">▼</div>      <div style="display: inline-block; width: 36px; height: 60px; border: 1.5px solid #d2a8ff; border-radius: 4px; margin: 6px 0;"></div>      <div style="color: #d2a8ff;">800 USDC</div>    </div>  </div></div><div style="margin-top: 25px; padding: 15px; background: #2d3748; border-radius: 6px; border-left: 4px solid #4CAF50; font-size: 13px; color: #e2e8f0; text-align: left;">    <div style="font-weight: bold; margin-bottom: 10px; color: #ffffff; font-size: 14px;">Question：</div>    <div style="margin-bottom: 15px; padding: 10px; background: rgba(255,255,255,0.05); border-radius: 4px;">        Why does each tick need to record liquidity separately?    </div>    <div style="padding: 10px; background: rgba(76, 175, 80, 0.1); border-radius: 4px; border-left: 3px solid #4CAF50;">      Because price is discretized into ticks, and liquidity only changes at tick boundaries — so tracking liquidity per tick lets the pool know exactly how much active liquidity exists at any given price.    </div></div><p>Scenario of a real trade within V3:</p><ol><li>The current price is between tick 1800 and 2000<br>→ Active liquidity = 600</li><li>Someone buys ETH, and the price moves from 1900 to 2100<br>→ The price crosses tick 2000 (where LP A’s range ends)<br>→ Active liquidity = 600 - 100 = 500<br>→ Continue calculating with 500</li><li>The price keeps rising to 2300<br>→ It crosses tick 2200 (where LP C’s range ends)<br>→ Active liquidity = 500 - 300 = 200</li></ol><p>key takeaway: <strong>each tick records the change in liquidity.</strong></p>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;&lt;strong&gt;Suppose&lt;/strong&gt; the real-time price of the ETH/DAI trading pair is 1500 DAI/ETH.&lt;/p&gt;
&lt;p&gt;Initial state: The pool holds 4,500 DAI </summary>
      
    
    
    
    
    <category term="tech" scheme="http://example.com/tags/tech/"/>
    
  </entry>
  
  <entry>
    <title>A use case for multi-sign wallet</title>
    <link href="http://example.com/2026/08/27/multisignwallet/"/>
    <id>http://example.com/2026/08/27/multisignwallet/</id>
    <published>2026-08-27T13:37:20.000Z</published>
    <updated>2026-10-18T08:35:25.852Z</updated>
    
    <content type="html"><![CDATA[<p>Recently, I’ve developed an interesting business using multi-sign wallet.</p><p>This project, requires tokens(ERC20) can be only minted by someone who approved by multiple administrators. I decided to implement those multi-approvals by administrators using multi-sign wallet.</p><ol><li><p>First of all, there must be or we’re implementing a contarct for <code>CRUD</code>ing to minters.</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #ff7b72;">contract</span> <span style="color: #ffa657;">AddressPrivileges</span> &#123;    <span style="color: #8b949e;">...</span>    <span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">addMinter</span>(<span style="color: #ff7b72;">address</span> _addMinter) <span style="color: #ff7b72;">public</span> <span style="color: #ff7b72;">validCall</span> <span style="color: #ff7b72;">returns</span> (<span style="color: #ffa657;">bool</span>) &#123;<span style="color: #8b949e;">...</span>&#125;    <span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">delMinter</span>(<span style="color: #ff7b72;">address</span> _delMinter) <span style="color: #ff7b72;">public</span> <span style="color: #ff7b72;">validCall</span> <span style="color: #ff7b72;">returns</span> (<span style="color: #ffa657;">bool</span>) &#123;<span style="color: #8b949e;">...</span>&#125;    <span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">isMinter</span>(<span style="color: #ff7b72;">address</span> account) <span style="color: #ff7b72;">public</span> <span style="color: #ff7b72;">view</span> <span style="color: #ff7b72;">returns</span> (<span style="color: #ffa657;">bool</span>) &#123;<span style="color: #8b949e;">...</span>&#125;    <span style="color: #ff7b72;">modifier</span> <span style="color: #d2a8ff;">onlyMinter</span>() &#123;<span style="color: #8b949e;">...</span>&#125;    <span style="color: #8b949e;">...</span>&#125;</code></pre></div></li><li><p>Here is multiSignature.sol</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #ff7b72;">contract</span> <span style="color: #ffa657;">multiSignature</span> &#123;    <span style="color: #8b949e;">...</span>    <span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">createApplication</span>(<span style="color: #ff7b72;">address</span> to) <span style="color: #ff7b72;">external</span> <span style="color: #ff7b72;">returns</span>(<span style="color: #ffa657;">uint256</span>) &#123;        <span style="color: #ffa657;">bytes32</span> msghash = <span style="color: #d2a8ff;">getApplicationHash</span>(msg.sender, to);        <span style="color: #ffa657;">uint256</span> index = signatureMap[msghash].length;        signatureMap[msghash].<span style="color: #d2a8ff;">push</span>(<span style="color: #ffa657;">signatureInfo</span>(msg.sender, <span style="color: #ff7b72;">new</span> <span style="color: #ff7b72;">address</span>[](0)));        <span style="color: #ff7b72;">emit</span> <span style="color: #d2a8ff;">CreateApplication</span>(msg.sender, to, msghash);        <span style="color: #ff7b72;">return</span> index;    &#125;    <span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">signApplication</span>(<span style="color: #ffa657;">bytes32</span> msghash) <span style="color: #ff7b72;">external</span> <span style="color: #ff7b72;">onlyOwner</span> <span style="color: #ff7b72;">validIndex</span>(msghash, defaultIndex) &#123;    <span style="color: #ff7b72;">emit</span> <span style="color: #d2a8ff;">SignApplication</span>(msg.sender, msghash, defaultIndex);    signatureMap[msghash][defaultIndex].signatures.<span style="color: #d2a8ff;">addWhiteListAddress</span>(msg.sender);&#125;<span style="color: #8b949e;">...</span>&#125;</code></pre></div><p>When user clicks a button like <code>add minter</code> from FE, it calls <code>multiSignature.sol:createApplication</code> function first : <code>createApplication($&#123;address of AddressPrivileges contract&#125;)</code> to hashes the ${address of <code>AddressPrivileges</code>} and users address , put the hash into a signatureMap.</p><p>Then administrators can see these pending approvals in their end.</p><p>Once they all approved the request from their site, FE calls <code>signApplication</code> to add their address to the signatureMap.signatureInfo.signatures. (signatures[] is empty before <code>signApplication</code> function, it was a  signatureMap[msghash] [empty] )</p></li><li><p>After approved by multi-sign wallets , now it’s fine to call <code>addMinter</code> in <code>AddressPrivileges.sol</code>, bcz we can’t pass the <code>validCall</code> check til multi-sign approval.</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #ff7b72;">modifier</span> <span style="color: #d2a8ff;">validCall</span>() &#123;    <span style="color: #d2a8ff;">checkMultiSignature</span>();    <span style="color: #ff7b72;">_</span>;&#125;</code></pre></div></li></ol><p>I would not say too much to breakdown those source codes wrote in my style , it’s not important , for now the matter is to get the mind.</p><p>Cool.</p>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;Recently, I’ve developed an interesting business using multi-sign wallet.&lt;/p&gt;
&lt;p&gt;This project, requires tokens(ERC20) can be only minted </summary>
      
    
    
    
    
    <category term="tech" scheme="http://example.com/tags/tech/"/>
    
  </entry>
  
  <entry>
    <title>Impermanent Loss (IL)</title>
    <link href="http://example.com/2026/08/09/IL/"/>
    <id>http://example.com/2026/08/09/IL/</id>
    <published>2026-08-09T09:00:37.000Z</published>
    <updated>2026-10-18T08:35:25.850Z</updated>
    
    <content type="html"><![CDATA[<p>Once we do LP, impermanent loss (LP) is pretty much guaranteed, it’s not a matter of if, but how much.</p><p>There’s a vivid breakdown for much better understanding:</p><p>Scenerio 1:</p><ul><li>Suppose we got a pool with initial liquidity of 100DAI and 1ETH<ul><li>now the <code>LP's position value</code> is 200DAI (100DAI+1ETH)</li></ul></li><li>ETH goes up<ul><li>The bot keeps arbitraging until the price gap disappears, as a result, the amount of ETH in the pool had dropped from 1 to 0.83<ul><li>x·y=k,  100·1=120*0.83</li><li>PriceOfEth=120/0.83=144.58</li></ul></li><li>Now, <code>LP's position value</code> got<ul><li>120DAI + 0.83* 144.58DAI= 240DAI</li><li>we earned 240DAI-200DAI=40DAI</li><li>But, the position of not being LP’s value is 4DAI more:<ul><li>100DAI + 1*144.58DAI=244.58DAI</li></ul></li></ul></li></ul></li></ul><p><strong>Conclusion:</strong></p><blockquote><p>If ETH rises, it’s profitable but you don’t capture the full gain.</p></blockquote><hr><p>Scenario 2:</p><ul><li>Suppose we got a pool with initial liquidity of 100DAI and 1ETH<ul><li>now the <code>LP's position value</code> is 200DAI (100DAI+1ETH)</li></ul></li><li>ETH drops<ul><li>The bot keeps arbitraging until the price gap disappears, as a result, the amount of ETH in the pool had risen from 1 to 1.25<ul><li>x·y=k,  100·1=80*1.25</li><li>PriceOfEth=80/1.25=64</li></ul></li><li>Now, <code>LP's position value</code> got:<ul><li>80DAI + 1.25*64DAI=160DAI</li><li>we lost 200DAI-160DAI=40DAI</li><li>But, the position of not being LP’s value:<ul><li>100DAI + 64*1DAI = 164DAI</li></ul></li></ul></li></ul></li></ul><p><strong>Conclusion:</strong></p><blockquote><p>If ETH drops, we all lose money no matter whether you’re an LP or not, LP lose a bit more.</p></blockquote><hr>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;Once we do LP, impermanent loss (LP) is pretty much guaranteed, it’s not a matter of if, but how much.&lt;/p&gt;
&lt;p&gt;There’s a vivid breakdown f</summary>
      
    
    
    
    
    <category term="tech" scheme="http://example.com/tags/tech/"/>
    
  </entry>
  
  <entry>
    <title>How the fee calculated in uniswap-v2?</title>
    <link href="http://example.com/2026/07/30/uniswapv2/"/>
    <id>http://example.com/2026/07/30/uniswapv2/</id>
    <published>2026-07-30T08:37:36.000Z</published>
    <updated>2026-10-18T08:35:25.853Z</updated>
    
    <content type="html"><![CDATA[<p>Download uniswap whitepaper: <a href="https://app.uniswap.org/whitepaper.pdf">https://app.uniswap.org/whitepaper.pdf</a></p><p>it’s not very friendly to read, I learned so hard, then this is my summaries.</p><p>Origin AMM formula:</p><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true"><svg style="vertical-align: -1.927ex;" xmlns="http://www.w3.org/2000/svg" width="48.471ex" height="5.026ex" role="img" focusable="false" viewBox="0 -1370 21424.3 2221.6"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="(x_0 + \mathrm{d}x)(y_0 - \mathrm{d}y) = k = x_0 y_0\Longrightarrow \mathrm{d}y = \frac{\mathrm{d}x \cdot y_0}{x_0 + \mathrm{d}x}"><g data-mml-node="mo" data-latex="("><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"></path></g><g data-mml-node="msub" data-latex="x_0" transform="translate(389,0)"><g data-mml-node="mi" data-latex="x"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mn" transform="translate(605,-150) scale(0.707)" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path></g></g><g data-mml-node="mo" data-latex="+" transform="translate(1619.8,0)"><path data-c="2B" d="M698 274L413 274L413 559C413 575 405 583 389 583C373 583 365 575 365 559L365 274L80 274C64 274 56 266 56 250C56 234 64 226 80 226L365 226L365-59C365-75 373-83 389-83C405-83 413-75 413-59L413 226L698 226C714 226 722 234 722 250C722 263 711 274 698 274Z"></path></g><g data-mml-node="TeXAtom" data-latex="\mathrm{d}" data-mjx-texclass="ORD" transform="translate(2620,0)"><g data-mml-node="mi" data-latex="d"><path data-c="64" d="M374-11L527 0L527 38C491 38 470 40 462 46C454 52 450 67 450 90L450 694L301 683L301 645C336 645 358 642 366 636C374 630 377 616 377 593L377 390C345 427 305 445 257 445C195 445 142 423 99 378C56 333 34 279 34 216C34 155 54 102 95 57C136 12 186-11 247-11C298-11 341 8 374 47M261 415C304 415 339 396 364 358C371 347 374 336 374 323L374 121C374 108 371 97 364 86C336 41 298 19 251 19C210 19 177 39 151 80C133 110 124 155 124 215C124 324 161 415 261 415Z"></path></g></g><g data-mml-node="mi" data-latex="x" transform="translate(3176,0)"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mo" data-latex=")" transform="translate(3748,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"></path></g><g data-mml-node="mo" data-latex="(" transform="translate(4137,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"></path></g><g data-mml-node="msub" data-latex="y_0" transform="translate(4526,0)"><g data-mml-node="mi" data-latex="y"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><g data-mml-node="mn" transform="translate(523,-150) scale(0.707)" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path></g></g><g data-mml-node="mo" data-latex="-" transform="translate(5674.8,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="TeXAtom" data-latex="\mathrm{d}" data-mjx-texclass="ORD" transform="translate(6675,0)"><g data-mml-node="mi" data-latex="d"><path data-c="64" d="M374-11L527 0L527 38C491 38 470 40 462 46C454 52 450 67 450 90L450 694L301 683L301 645C336 645 358 642 366 636C374 630 377 616 377 593L377 390C345 427 305 445 257 445C195 445 142 423 99 378C56 333 34 279 34 216C34 155 54 102 95 57C136 12 186-11 247-11C298-11 341 8 374 47M261 415C304 415 339 396 364 358C371 347 374 336 374 323L374 121C374 108 371 97 364 86C336 41 298 19 251 19C210 19 177 39 151 80C133 110 124 155 124 215C124 324 161 415 261 415Z"></path></g></g><g data-mml-node="mi" data-latex="y" transform="translate(7231,0)"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><g data-mml-node="mo" data-latex=")" transform="translate(7721,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"></path></g><g data-mml-node="mo" data-latex="=" transform="translate(8387.8,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mi" data-latex="k" transform="translate(9443.6,0)"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mo" data-latex="=" transform="translate(10242.3,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="msub" data-latex="x_0" transform="translate(11298.1,0)"><g data-mml-node="mi" data-latex="x"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mn" transform="translate(605,-150) scale(0.707)" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path></g></g><g data-mml-node="msub" data-latex="y_0" transform="translate(12306.7,0)"><g data-mml-node="mi" data-latex="y"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><g data-mml-node="mn" transform="translate(523,-150) scale(0.707)" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path></g></g><g data-mml-node="mo" data-latex="\Longrightarrow" transform="translate(13511,0)"><path data-c="27F9" d="M1389 233C1397 237 1401 243 1401 250C1401 257 1397 263 1389 267C1327 283 1265 318 1204 371C1159 410 1124 455 1097 507C1093 516 1086 520 1076 520C1060 520 1052 512 1052 496C1052 494 1053 491 1054 486C1077 442 1105 403 1137 369L80 369C64 369 56 361 56 346C56 330 64 322 80 322L1189 322C1227 292 1268 268 1311 250C1268 232 1227 208 1189 178L80 178C64 178 56 170 56 154C56 139 64 131 80 131L1137 131C1105 97 1077 58 1054 14C1053 9 1052 6 1052 4C1052-12 1060-20 1076-20C1086-20 1093-16 1097-7C1124 45 1159 90 1204 129C1265 182 1327 217 1389 233Z"></path></g><g data-mml-node="TeXAtom" data-latex="\mathrm{d}" data-mjx-texclass="ORD" transform="translate(15245.8,0)"><g data-mml-node="mi" data-latex="d"><path data-c="64" d="M374-11L527 0L527 38C491 38 470 40 462 46C454 52 450 67 450 90L450 694L301 683L301 645C336 645 358 642 366 636C374 630 377 616 377 593L377 390C345 427 305 445 257 445C195 445 142 423 99 378C56 333 34 279 34 216C34 155 54 102 95 57C136 12 186-11 247-11C298-11 341 8 374 47M261 415C304 415 339 396 364 358C371 347 374 336 374 323L374 121C374 108 371 97 364 86C336 41 298 19 251 19C210 19 177 39 151 80C133 110 124 155 124 215C124 324 161 415 261 415Z"></path></g></g><g data-mml-node="mi" data-latex="y" transform="translate(15801.8,0)"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><g data-mml-node="mo" data-latex="=" transform="translate(16569.5,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mfrac" data-latex="\frac{\mathrm{d}x \cdot y_0}{x_0 + \mathrm{d}x}" transform="translate(17625.3,0)"><g data-mml-node="mrow" data-latex="\mathrm{d}x \cdot y_0" transform="translate(511,676)"><g data-mml-node="TeXAtom" data-latex="\mathrm{d}" data-mjx-texclass="ORD"><g data-mml-node="mi" data-latex="d"><path data-c="64" d="M374-11L527 0L527 38C491 38 470 40 462 46C454 52 450 67 450 90L450 694L301 683L301 645C336 645 358 642 366 636C374 630 377 616 377 593L377 390C345 427 305 445 257 445C195 445 142 423 99 378C56 333 34 279 34 216C34 155 54 102 95 57C136 12 186-11 247-11C298-11 341 8 374 47M261 415C304 415 339 396 364 358C371 347 374 336 374 323L374 121C374 108 371 97 364 86C336 41 298 19 251 19C210 19 177 39 151 80C133 110 124 155 124 215C124 324 161 415 261 415Z"></path></g></g><g data-mml-node="mi" data-latex="x" transform="translate(556,0)"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mo" data-latex="\cdot" transform="translate(1350.2,0)"><path data-c="22C5" d="M192 250C192 279 168 303 139 303C110 303 86 279 86 250C86 221 110 197 139 197C168 197 192 221 192 250Z"></path></g><g data-mml-node="msub" data-latex="y_0" transform="translate(1850.4,0)"><g data-mml-node="mi" data-latex="y"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><g data-mml-node="mn" transform="translate(523,-150) scale(0.707)" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path></g></g></g><g data-mml-node="mrow" data-latex="x_0  + \mathrm{d}x" transform="translate(220,-686)"><g data-mml-node="msub" data-latex="x_0"><g data-mml-node="mi" data-latex="x"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mn" transform="translate(605,-150) scale(0.707)" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path></g></g><g data-mml-node="mo" data-latex="+" transform="translate(1230.8,0)"><path data-c="2B" d="M698 274L413 274L413 559C413 575 405 583 389 583C373 583 365 575 365 559L365 274L80 274C64 274 56 266 56 250C56 234 64 226 80 226L365 226L365-59C365-75 373-83 389-83C405-83 413-75 413-59L413 226L698 226C714 226 722 234 722 250C722 263 711 274 698 274Z"></path></g><g data-mml-node="TeXAtom" data-latex="\mathrm{d}" data-mjx-texclass="ORD" transform="translate(2231,0)"><g data-mml-node="mi" data-latex="d"><path data-c="64" d="M374-11L527 0L527 38C491 38 470 40 462 46C454 52 450 67 450 90L450 694L301 683L301 645C336 645 358 642 366 636C374 630 377 616 377 593L377 390C345 427 305 445 257 445C195 445 142 423 99 378C56 333 34 279 34 216C34 155 54 102 95 57C136 12 186-11 247-11C298-11 341 8 374 47M261 415C304 415 339 396 364 358C371 347 374 336 374 323L374 121C374 108 371 97 364 86C336 41 298 19 251 19C210 19 177 39 151 80C133 110 124 155 124 215C124 324 161 415 261 415Z"></path></g></g><g data-mml-node="mi" data-latex="x" transform="translate(2787,0)"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g></g><rect width="3559" height="60" x="120" y="220"></rect></g></g></g></svg></mjx-container><br>Assume the fee is 0.3% (in uniswapv-v2, this is a fixed fee), dx is the token you’re trying to exchange, the fee will be charged on this dx, so we just change the dx of the formula above like list:<br><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true"><svg style="vertical-align: -2.172ex;" xmlns="http://www.w3.org/2000/svg" width="68.987ex" height="5.475ex" role="img" focusable="false" viewBox="0 -1460 30492.2 2420"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="[x_0 + (1 - 0.003)dx][y_0 - dy] = k = x_0 y_0\Rightarrow dy = \frac{[(1 - 0.003)dx] \cdot y_0}{x_0 + [(1 - 0.003)dx]}"><g data-mml-node="mo" data-latex="["><path data-c="5B" d="M233-202L159-202L159 702L233 702C248 702 256 710 256 726C256 742 248 750 233 750L114 750L114-250L233-250C248-250 256-242 256-226C256-214 245-202 233-202Z"></path></g><g data-mml-node="msub" data-latex="x_0" transform="translate(278,0)"><g data-mml-node="mi" data-latex="x"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mn" transform="translate(605,-150) scale(0.707)" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path></g></g><g data-mml-node="mo" data-latex="+" transform="translate(1508.8,0)"><path data-c="2B" d="M698 274L413 274L413 559C413 575 405 583 389 583C373 583 365 575 365 559L365 274L80 274C64 274 56 266 56 250C56 234 64 226 80 226L365 226L365-59C365-75 373-83 389-83C405-83 413-75 413-59L413 226L698 226C714 226 722 234 722 250C722 263 711 274 698 274Z"></path></g><g data-mml-node="mo" data-latex="(" transform="translate(2509,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"></path></g><g data-mml-node="mn" data-latex="1" transform="translate(2898,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g><g data-mml-node="mo" data-latex="-" transform="translate(3620.2,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="mn" data-latex="0.003" transform="translate(4620.4,0)"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path><path data-c="2E" d="M192 53C192 82 168 106 139 106C110 106 86 82 86 53C86 24 110 0 139 0C168 0 192 24 192 53Z" transform="translate(500,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(778,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(1278,0)"></path><path data-c="33" d="M303 353C369 378 431 441 431 526C431 569 410 604 369 631C333 654 292 666 246 666C201 666 162 654 127 631C88 605 68 571 68 528C68 495 90 472 122 472C154 472 176 495 176 527C176 560 157 578 119 580C145 615 186 633 242 633C302 633 332 598 332 527C332 485 324 450 309 421C282 373 245 364 183 364C171 362 165 357 165 348C165 333 172 333 192 333L235 333C310 333 348 280 348 173C348 88 317 14 241 14C176 14 128 36 99 80C134 79 160 105 160 139C160 173 135 198 101 198C62 198 42 178 42 137C42 88 64 49 108 18C147-9 193-22 244-22C301-22 350-3 393 34C436 71 457 117 457 173C457 267 383 332 303 353Z" transform="translate(1778,0)"></path></g><g data-mml-node="mo" data-latex=")" transform="translate(6898.4,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"></path></g><g data-mml-node="mi" data-latex="d" transform="translate(7287.4,0)"><path data-c="1D451" d="M429 632L370 389C349 426 320 445 281 445C216 445 159 412 109 345C63 283 40 218 40 151C40 63 91-11 175-11C218-11 260 12 300 59C311 21 345-11 392-11C461-11 483 71 498 145C498 154 493 159 483 159C474 159 468 152 465 138C445 59 421 19 394 19C377 19 368 33 368 60C368 75 370 91 374 107L516 679L516 683C513 690 507 694 499 694C476 694 434 690 374 683C363 682 357 674 357 660C357 650 366 645 384 645C403 645 429 646 429 632M341 376C351 355 356 341 356 332C355 328 354 323 353 316L304 122C301 111 294 99 285 87C248 42 212 19 177 19C138 19 118 49 118 108C118 132 124 168 136 216C157 301 187 359 224 390C244 407 263 415 282 415C309 415 329 402 341 376Z"></path></g><g data-mml-node="mi" data-latex="x" transform="translate(7807.4,0)"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mo" data-latex="]" transform="translate(8379.4,0)"><path data-c="5D" d="M45-250L164-250L164 750L45 750C30 750 22 742 22 726C22 710 30 702 45 702L119 702L119-202L45-202C30-202 22-210 22-226C22-242 30-250 45-250Z"></path></g><g data-mml-node="mo" data-latex="[" transform="translate(8657.4,0)"><path data-c="5B" d="M233-202L159-202L159 702L233 702C248 702 256 710 256 726C256 742 248 750 233 750L114 750L114-250L233-250C248-250 256-242 256-226C256-214 245-202 233-202Z"></path></g><g data-mml-node="msub" data-latex="y_0" transform="translate(8935.4,0)"><g data-mml-node="mi" data-latex="y"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><g data-mml-node="mn" transform="translate(523,-150) scale(0.707)" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path></g></g><g data-mml-node="mo" data-latex="-" transform="translate(10084.2,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="mi" data-latex="d" transform="translate(11084.4,0)"><path data-c="1D451" d="M429 632L370 389C349 426 320 445 281 445C216 445 159 412 109 345C63 283 40 218 40 151C40 63 91-11 175-11C218-11 260 12 300 59C311 21 345-11 392-11C461-11 483 71 498 145C498 154 493 159 483 159C474 159 468 152 465 138C445 59 421 19 394 19C377 19 368 33 368 60C368 75 370 91 374 107L516 679L516 683C513 690 507 694 499 694C476 694 434 690 374 683C363 682 357 674 357 660C357 650 366 645 384 645C403 645 429 646 429 632M341 376C351 355 356 341 356 332C355 328 354 323 353 316L304 122C301 111 294 99 285 87C248 42 212 19 177 19C138 19 118 49 118 108C118 132 124 168 136 216C157 301 187 359 224 390C244 407 263 415 282 415C309 415 329 402 341 376Z"></path></g><g data-mml-node="mi" data-latex="y" transform="translate(11604.4,0)"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><g data-mml-node="mo" data-latex="]" transform="translate(12094.4,0)"><path data-c="5D" d="M45-250L164-250L164 750L45 750C30 750 22 742 22 726C22 710 30 702 45 702L119 702L119-202L45-202C30-202 22-210 22-226C22-242 30-250 45-250Z"></path></g><g data-mml-node="mo" data-latex="=" transform="translate(12650.2,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mi" data-latex="k" transform="translate(13706,0)"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mo" data-latex="=" transform="translate(14504.8,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="msub" data-latex="x_0" transform="translate(15560.6,0)"><g data-mml-node="mi" data-latex="x"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mn" transform="translate(605,-150) scale(0.707)" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path></g></g><g data-mml-node="msub" data-latex="y_0" transform="translate(16569.1,0)"><g data-mml-node="mi" data-latex="y"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><g data-mml-node="mn" transform="translate(523,-150) scale(0.707)" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path></g></g><g data-mml-node="mo" data-latex="\Rightarrow" transform="translate(17773.4,0)"><path data-c="21D2" d="M927 233C935 237 939 243 939 250C939 257 935 263 927 267C866 283 804 318 742 371C697 410 662 455 636 507C632 516 625 520 615 520C599 520 591 512 591 496C591 494 592 491 593 486C616 442 644 403 676 369L84 369C68 369 60 361 60 346C60 330 68 322 84 322L728 322C765 292 806 268 849 250C806 232 765 208 728 178L84 178C68 178 60 170 60 154C60 139 68 131 84 131L676 131C644 97 616 58 593 14C592 9 591 6 591 4C591-12 599-20 615-20C625-20 632-16 636-7C662 45 697 90 742 129C804 182 866 217 927 233Z"></path></g><g data-mml-node="mi" data-latex="d" transform="translate(19051.2,0)"><path data-c="1D451" d="M429 632L370 389C349 426 320 445 281 445C216 445 159 412 109 345C63 283 40 218 40 151C40 63 91-11 175-11C218-11 260 12 300 59C311 21 345-11 392-11C461-11 483 71 498 145C498 154 493 159 483 159C474 159 468 152 465 138C445 59 421 19 394 19C377 19 368 33 368 60C368 75 370 91 374 107L516 679L516 683C513 690 507 694 499 694C476 694 434 690 374 683C363 682 357 674 357 660C357 650 366 645 384 645C403 645 429 646 429 632M341 376C351 355 356 341 356 332C355 328 354 323 353 316L304 122C301 111 294 99 285 87C248 42 212 19 177 19C138 19 118 49 118 108C118 132 124 168 136 216C157 301 187 359 224 390C244 407 263 415 282 415C309 415 329 402 341 376Z"></path></g><g data-mml-node="mi" data-latex="y" transform="translate(19571.2,0)"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><g data-mml-node="mo" data-latex="=" transform="translate(20339,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mfrac" data-latex="\frac{[(1 - 0.003)dx] \cdot y_0}{x_0 + [(1 - 0.003)dx]}" transform="translate(21394.8,0)"><g data-mml-node="mrow" data-latex="[(1 - 0.003)dx] \cdot y_0" transform="translate(511,710)"><g data-mml-node="mo" data-latex="["><path data-c="5B" d="M233-202L159-202L159 702L233 702C248 702 256 710 256 726C256 742 248 750 233 750L114 750L114-250L233-250C248-250 256-242 256-226C256-214 245-202 233-202Z"></path></g><g data-mml-node="mo" data-latex="(" transform="translate(278,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"></path></g><g data-mml-node="mn" data-latex="1" transform="translate(667,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g><g data-mml-node="mo" data-latex="-" transform="translate(1389.2,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="mn" data-latex="0.003" transform="translate(2389.4,0)"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path><path data-c="2E" d="M192 53C192 82 168 106 139 106C110 106 86 82 86 53C86 24 110 0 139 0C168 0 192 24 192 53Z" transform="translate(500,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(778,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(1278,0)"></path><path data-c="33" d="M303 353C369 378 431 441 431 526C431 569 410 604 369 631C333 654 292 666 246 666C201 666 162 654 127 631C88 605 68 571 68 528C68 495 90 472 122 472C154 472 176 495 176 527C176 560 157 578 119 580C145 615 186 633 242 633C302 633 332 598 332 527C332 485 324 450 309 421C282 373 245 364 183 364C171 362 165 357 165 348C165 333 172 333 192 333L235 333C310 333 348 280 348 173C348 88 317 14 241 14C176 14 128 36 99 80C134 79 160 105 160 139C160 173 135 198 101 198C62 198 42 178 42 137C42 88 64 49 108 18C147-9 193-22 244-22C301-22 350-3 393 34C436 71 457 117 457 173C457 267 383 332 303 353Z" transform="translate(1778,0)"></path></g><g data-mml-node="mo" data-latex=")" transform="translate(4667.4,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"></path></g><g data-mml-node="mi" data-latex="d" transform="translate(5056.4,0)"><path data-c="1D451" d="M429 632L370 389C349 426 320 445 281 445C216 445 159 412 109 345C63 283 40 218 40 151C40 63 91-11 175-11C218-11 260 12 300 59C311 21 345-11 392-11C461-11 483 71 498 145C498 154 493 159 483 159C474 159 468 152 465 138C445 59 421 19 394 19C377 19 368 33 368 60C368 75 370 91 374 107L516 679L516 683C513 690 507 694 499 694C476 694 434 690 374 683C363 682 357 674 357 660C357 650 366 645 384 645C403 645 429 646 429 632M341 376C351 355 356 341 356 332C355 328 354 323 353 316L304 122C301 111 294 99 285 87C248 42 212 19 177 19C138 19 118 49 118 108C118 132 124 168 136 216C157 301 187 359 224 390C244 407 263 415 282 415C309 415 329 402 341 376Z"></path></g><g data-mml-node="mi" data-latex="x" transform="translate(5576.4,0)"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mo" data-latex="]" transform="translate(6148.4,0)"><path data-c="5D" d="M45-250L164-250L164 750L45 750C30 750 22 742 22 726C22 710 30 702 45 702L119 702L119-202L45-202C30-202 22-210 22-226C22-242 30-250 45-250Z"></path></g><g data-mml-node="mo" data-latex="\cdot" transform="translate(6648.7,0)"><path data-c="22C5" d="M192 250C192 279 168 303 139 303C110 303 86 279 86 250C86 221 110 197 139 197C168 197 192 221 192 250Z"></path></g><g data-mml-node="msub" data-latex="y_0" transform="translate(7148.9,0)"><g data-mml-node="mi" data-latex="y"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><g data-mml-node="mn" transform="translate(523,-150) scale(0.707)" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path></g></g></g><g data-mml-node="mrow" data-latex="x_0  + [(1 - 0.003)dx]" transform="translate(220,-710)"><g data-mml-node="msub" data-latex="x_0"><g data-mml-node="mi" data-latex="x"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mn" transform="translate(605,-150) scale(0.707)" data-latex="0"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path></g></g><g data-mml-node="mo" data-latex="+" transform="translate(1230.8,0)"><path data-c="2B" d="M698 274L413 274L413 559C413 575 405 583 389 583C373 583 365 575 365 559L365 274L80 274C64 274 56 266 56 250C56 234 64 226 80 226L365 226L365-59C365-75 373-83 389-83C405-83 413-75 413-59L413 226L698 226C714 226 722 234 722 250C722 263 711 274 698 274Z"></path></g><g data-mml-node="mo" data-latex="[" transform="translate(2231,0)"><path data-c="5B" d="M233-202L159-202L159 702L233 702C248 702 256 710 256 726C256 742 248 750 233 750L114 750L114-250L233-250C248-250 256-242 256-226C256-214 245-202 233-202Z"></path></g><g data-mml-node="mo" data-latex="(" transform="translate(2509,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"></path></g><g data-mml-node="mn" data-latex="1" transform="translate(2898,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g><g data-mml-node="mo" data-latex="-" transform="translate(3620.2,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="mn" data-latex="0.003" transform="translate(4620.4,0)"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path><path data-c="2E" d="M192 53C192 82 168 106 139 106C110 106 86 82 86 53C86 24 110 0 139 0C168 0 192 24 192 53Z" transform="translate(500,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(778,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(1278,0)"></path><path data-c="33" d="M303 353C369 378 431 441 431 526C431 569 410 604 369 631C333 654 292 666 246 666C201 666 162 654 127 631C88 605 68 571 68 528C68 495 90 472 122 472C154 472 176 495 176 527C176 560 157 578 119 580C145 615 186 633 242 633C302 633 332 598 332 527C332 485 324 450 309 421C282 373 245 364 183 364C171 362 165 357 165 348C165 333 172 333 192 333L235 333C310 333 348 280 348 173C348 88 317 14 241 14C176 14 128 36 99 80C134 79 160 105 160 139C160 173 135 198 101 198C62 198 42 178 42 137C42 88 64 49 108 18C147-9 193-22 244-22C301-22 350-3 393 34C436 71 457 117 457 173C457 267 383 332 303 353Z" transform="translate(1778,0)"></path></g><g data-mml-node="mo" data-latex=")" transform="translate(6898.4,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"></path></g><g data-mml-node="mi" data-latex="d" transform="translate(7287.4,0)"><path data-c="1D451" d="M429 632L370 389C349 426 320 445 281 445C216 445 159 412 109 345C63 283 40 218 40 151C40 63 91-11 175-11C218-11 260 12 300 59C311 21 345-11 392-11C461-11 483 71 498 145C498 154 493 159 483 159C474 159 468 152 465 138C445 59 421 19 394 19C377 19 368 33 368 60C368 75 370 91 374 107L516 679L516 683C513 690 507 694 499 694C476 694 434 690 374 683C363 682 357 674 357 660C357 650 366 645 384 645C403 645 429 646 429 632M341 376C351 355 356 341 356 332C355 328 354 323 353 316L304 122C301 111 294 99 285 87C248 42 212 19 177 19C138 19 118 49 118 108C118 132 124 168 136 216C157 301 187 359 224 390C244 407 263 415 282 415C309 415 329 402 341 376Z"></path></g><g data-mml-node="mi" data-latex="x" transform="translate(7807.4,0)"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mo" data-latex="]" transform="translate(8379.4,0)"><path data-c="5D" d="M45-250L164-250L164 750L45 750C30 750 22 742 22 726C22 710 30 702 45 702L119 702L119-202L45-202C30-202 22-210 22-226C22-242 30-250 45-250Z"></path></g></g><rect width="8857.4" height="60" x="120" y="220"></rect></g></g></g></svg></mjx-container><br>this is the dy we correctly will get. And, this formula actually is what the <code>getAmountOut</code> function does, look:</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">getAmountOut</span>(<span style="color: #8b949e;">...</span>) {    <span style="color: #8b949e;">...</span>    <span style="color: #ffa657;">uint</span> amountInWithFee = amountIn.<span style="color: #d2a8ff;">mul</span>(<span style="color: #79c0ff;">997</span>);  <span style="color: #8b949e;">//1-0.003=0.997</span>    <span style="color: #8b949e;">...</span>}</code></pre></div><p>Once the fee is taken out, it flows into the pool, not to a specific account, so the liquidity will increase as swaps accumulate.</p><p>Here is the breakdown of the flow.</p><ul><li><p>Here is pool for USDT/DAI, initially their liquidity are: (100USDT and 100 DAI, they’re woth same)</p><figure class="highlight ceylon"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs ceylon">Liquidity(√k)<br>   ^<br>   |   <span class="hljs-number">100</span>   <span class="hljs-number">100</span><br>   |   ██      ██<br>   |   ██      ██<br>   |   ██      ██<br>   |   ██      ██<br>   +--+---+---+---+---&gt; token<br>       USDT    DAI    <br></code></pre></td></tr></table></figure></li><li><p>After some swaps, USDT got 104, DAI got 98.</p><figure class="highlight ceylon"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs ceylon">Liquidity(√k)<br>   ^<br>   |   <span class="hljs-number">104</span><br>   |   ██      <span class="hljs-number">98</span><br>   |   ██      ██<br>   |   ██      ██<br>   |   ██      ██<br>   +--+---+---+---+---&gt; token<br>       USDT    DAI    <br></code></pre></td></tr></table></figure></li><li><p>But immediately, they return back a balanced position. Bcz there usually are arbitrage bots are keep detecting whether there are an imbalance that can profit from , which brings the pool back to balance.</p><figure class="highlight ceylon"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><code class="hljs ceylon">Liquidity(√k)<br>   ^<br>   |   <span class="hljs-number">101</span>     <span class="hljs-number">101</span><br>   |   ██      ██<br>   |   ██      ██<br>   |   ██      ██<br>   |   ██      ██<br>   +--+---+---+---+---&gt; token<br>       USDT    DAI    <br></code></pre></td></tr></table></figure></li><li><p>Can easily see they’ve increased, say again: once the fee is taken out, it flows into the pool, not to a specific account, so the liquidity will increase as swaps accumulate.</p><p>​pool liquidity</p><ul><li><div style="display:flex; align-items:flex-end; height:230px; width: 350px; gap:50px; padding-left: 30px; border-left:2px solid #333; border-bottom:2px solid #333; background:rgba(33, 150, 243, 0.1);">  <div style="text-align:center;">    <div style="width:60px; height:100px; background:#2196F3; border-radius:4px 4px 0 0;"></div>  </div>  <div style="text-align:center;">→</div>  <div style="text-align:center;">    <div style="width:60px; height:50px; background:#FF9800; border:2px dashed #ffffff; border-radius:4px 4px 0 0;">    <span style="font-size: 10px;">increased liquidity</span>    </div>    <div style="width:60px; height:100px; background:#FF9800; border-radius:0;"></div>  </div></div>The growth in liquidity , that's exactly where LPs earn, as the pool growth , so do their profit. Amount of the profit just is equivalent to the `increased liquidity`, equivalent to sum of all gathered fees. <mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true"><svg style="vertical-align: -2.308ex;" xmlns="http://www.w3.org/2000/svg" width="35.119ex" height="5.872ex" role="img" focusable="false" viewBox="0 -1575.5 15522.7 2595.5"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="feeRate=\frac{\sqrt{k_2}-\sqrt{k_1}}{\sqrt{k_2}}=1-\frac{\sqrt{k_1}}{\sqrt{k_2}}"><g data-mml-node="mi" data-latex="f"><path data-c="1D453" d="M552 633C552 677 509 705 462 705C400 705 357 665 334 586C329 568 318 517 302 433L237 433C215 433 204 432 204 411C204 400 214 395 235 395L295 395L222 8C211-49 201-91 192-119C180-156 163-175 141-175C126-175 114-171 103-164C135-159 151-140 151-108C151-82 138-69 111-69C77-69 53-99 53-133C53-177 94-205 141-205C166-205 189-195 208-174C240-141 265-94 283-31C294 8 304 46 311 84L369 395L451 395C474 395 484 396 484 419C484 428 474 433 454 433L377 433C383 474 411 625 420 644C430 665 444 675 462 675C477 675 490 671 501 664C470 657 454 639 454 608C454 582 467 569 494 569C528 569 552 599 552 633Z"></path></g><g data-mml-node="mi" data-latex="e" transform="translate(552,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"></path></g><g data-mml-node="mi" data-latex="e" transform="translate(1018,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"></path></g><g data-mml-node="mi" data-latex="R" transform="translate(1484,0)"><path data-c="1D445" d="M739 531C739 582 713 621 662 649C621 672 572 683 517 683L235 683C212 683 202 682 202 659C202 652 205 647 211 646C221 645 229 644 234 644C264 643 281 641 286 640C291 639 294 636 294 631C294 629 293 623 290 613L158 82C153 60 143 46 128 41C121 39 103 38 72 38C50 38 41 37 41 15C41 4 47-1 59 0L183 3L309 0C325-1 333 8 333 23C333 33 322 38 301 38C261 38 241 43 241 52C241 52 242 54 244 68L308 327L423 327C492 327 527 298 527 241C527 232 522 210 513 174C502 132 497 104 497 89C497 13 556-22 632-22C660-22 687-9 714 16C741 41 755 68 755 96C755 106 750 111 739 111C732 111 726 106 723 95C712 64 698 41 682 28C666 15 651 8 636 8C613 8 601 27 601 64C601 88 604 125 611 176C614 197 615 212 615 223C615 276 587 315 531 339C625 362 739 429 739 531M609 616C629 603 639 581 639 550C639 530 635 507 626 480C599 398 531 357 422 357L316 357L379 610C384 631 392 642 403 643C408 644 428 644 463 644C528 644 566 642 609 616Z"></path></g><g data-mml-node="mi" data-latex="a" transform="translate(2243,0)"><path data-c="1D44E" d="M498 144C498 153 493 158 482 158C474 158 468 151 465 137C445 58 421 18 394 18C377 18 368 32 368 60C368 73 372 97 381 132L438 357C443 376 445 387 445 392C445 412 434 422 412 422C391 422 377 410 370 387C349 424 319 442 281 442C216 442 159 409 109 343C63 281 40 217 40 150C40 63 91-11 175-11C218-11 260 12 300 58C311 20 345-11 392-11C461-11 482 70 498 144M341 374C350 353 355 339 355 330C355 326 354 321 353 314L304 122C301 111 294 99 285 87C248 41 212 18 177 18C138 18 118 48 118 107C118 131 124 167 136 215C157 300 187 357 224 388C244 405 263 413 282 413C309 413 329 400 341 374Z"></path></g><g data-mml-node="mi" data-latex="t" transform="translate(2772,0)"><path data-c="1D461" d="M330 419C330 428 320 433 299 433L218 433C244 537 257 591 257 595C257 616 246 626 225 626C202 626 188 613 182 587L145 433L56 433C34 433 23 432 23 411C23 400 33 395 54 395L135 395C86 200 62 97 62 84C62 28 100-11 156-11C194-11 227 6 256 41C280 70 297 98 308 125C312 136 314 142 314 145C314 154 309 159 299 159C291 159 285 154 281 143C247 60 206 19 157 19C140 19 131 33 131 60C131 75 133 91 137 107L208 395L297 395C323 395 330 397 330 419Z"></path></g><g data-mml-node="mi" data-latex="e" transform="translate(3133,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"></path></g><g data-mml-node="mo" data-latex="=" transform="translate(3876.8,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mfrac" data-latex="\frac{\sqrt{k_2}-\sqrt{k_1}}{\sqrt{k_2}}" transform="translate(4932.6,0)"><g data-mml-node="mrow" data-latex="\sqrt{k_2}-\sqrt{k_1}" transform="translate(220,676)"><g data-mml-node="msqrt" data-latex="\sqrt{k_2}"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_2"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g><g data-mml-node="mo" data-latex="-" transform="translate(2032.8,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="msqrt" data-latex="\sqrt{k_1}" transform="translate(3033,0)"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_1"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g></g><g data-mml-node="msqrt" data-latex="\sqrt{k_2}" transform="translate(1736.5,-859.5)"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_2"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g><rect width="5043.6" height="60" x="120" y="220"></rect></g><g data-mml-node="mo" data-latex="=" transform="translate(10493.9,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mn" data-latex="1" transform="translate(11549.7,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g><g data-mml-node="mo" data-latex="-" transform="translate(12271.9,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="mfrac" data-latex="\frac{\sqrt{k_1}}{\sqrt{k_2}}" transform="translate(13272.1,0)"><g data-mml-node="msqrt" data-latex="\sqrt{k_1}" transform="translate(220,676)"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_1"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g><g data-mml-node="msqrt" data-latex="\sqrt{k_2}" transform="translate(220,-859.5)"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_2"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g><rect width="2010.6" height="60" x="120" y="220"></rect></g></g></g></svg></mjx-container>But, where does the project team who writes contracts benefit from?<ul><li><p>in uniswap-v2’s code project team doesn’t charge fee for themselves by default, can open it by giving an account address which receives fee to the <code>feeTo</code> variable in <code>UniswapV2Pair.sol</code>’s factory’:</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #ff7b72;">function</span> <span style="color: #d2a8ff;">_mintFee</span>(<span style="color: #8b949e;">...</span>) <span style="color: #ff7b72;">returns</span> (<span style="color: #ffa657;">bool</span> feeOn) {    <span style="color: #8b949e;">...</span>    <span style="color: #ff7b72;">address</span> feeTo = <span style="color: #ffa657;">IUniswapV2Factory</span>(factory).<span style="color: #d2a8ff;">feeTo</span>();    feeOn = feeTo != <span style="color: #ff7b72;">address</span>(0);  <span style="color: #8b949e;">// feeTo=0x0, feeOn=false, by default.</span>    <span style="color: #ff7b72;">if</span> (feeOn) {        <span style="color: #8b949e;">...</span>    }}</code></pre></div></li><li><p>If we set feeTo to an account address , what will that be?</p><ul><li><p>Obviously, according to the <code> _mintFee</code> function above, it will get into the <code>if</code> charges fee to the account.</p></li><li><p>there’s a φ=1/6 , means project team will take away 1/6 of the <code>increased liquidity</code>.</p><img src="https://pica.zhimg.com/80/v2-151d44d41b308c2415d16d05a06c49e4_1440w.webp" width="500"><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true"><svg style="vertical-align: -2.308ex;" xmlns="http://www.w3.org/2000/svg" width="27.326ex" height="5.945ex" role="img" focusable="false" viewBox="0 -1607.5 12077.9 2627.5"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="\frac{S_m}{S_m+S_1}=\frac{φ(\sqrt{k_2}-\sqrt{k_1})}{\sqrt{k_2}}"><g data-mml-node="mfrac" data-latex="\frac{S_m}{S_m+S_1}"><g data-mml-node="msub" data-latex="S_m" transform="translate(1356,676)"><g data-mml-node="mi" data-latex="S"><path data-c="1D446" d="M133 157C133 181 136 201 141 217C141 227 136 232 125 232C120 232 116 230 114 228C109 223 52 8 52-8C52-17 57-22 67-22C72-22 79-17 88-6L133 47C168 1 224-22 300-22C366-22 424 5 476 58C528 111 554 170 554 236C554 283 538 323 505 355C490 368 470 379 445 388C422 393 400 399 378 405L312 423C279 432 254 469 254 509C254 552 271 589 306 621C341 653 380 669 423 669C515 669 561 619 561 520C561 502 557 482 557 465L557 462C560 455 565 451 573 451C582 451 588 459 592 474L645 691C645 700 640 705 630 705C625 705 618 700 609 689L566 637C538 682 491 705 424 705C361 705 304 681 254 634C202 586 176 531 176 468C176 396 223 339 282 323L387 296C441 281 475 262 475 195C475 149 457 108 422 72C387 36 347 17 302 17C204 17 133 60 133 157Z"></path></g><g data-mml-node="mi" transform="translate(646,-150) scale(0.707)" data-latex="m"><path data-c="1D45A" d="M657 442C596 442 543 412 498 353C489 412 451 442 383 442C324 442 273 416 231 363C223 407 188 442 137 442C96 442 66 409 45 344C34 312 29 293 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 66 299C84 375 107 413 134 413C152 413 161 399 161 371C161 358 156 331 145 290L88 63C84 51 79 25 79 19C79-1 90-11 111-11C131-11 145-1 152 19C153 24 160 49 171 92L192 181L222 295C233 318 250 341 272 365C301 397 337 413 380 413C413 413 429 391 429 348C429 335 424 308 414 267L387 153C380 124 364 64 356 32C355 25 354 21 354 19C354-1 365-11 387-11C398-11 406-8 413-1C428 14 429 21 435 48L494 285C497 298 511 321 535 353C565 393 605 413 654 413C687 413 703 391 703 348C703 309 683 236 642 129C633 106 629 87 629 74C629 25 666-11 714-11C759-11 793 14 818 64C838 104 848 131 848 144C848 153 843 158 832 158C825 157 818 148 813 137C791 58 759 18 716 18C703 18 696 28 696 47C696 62 702 84 714 115C755 222 775 295 775 333C775 404 728 442 657 442Z"></path></g></g><g data-mml-node="mrow" data-latex="S_m+S_1" transform="translate(220,-686)"><g data-mml-node="msub" data-latex="S_m"><g data-mml-node="mi" data-latex="S"><path data-c="1D446" d="M133 157C133 181 136 201 141 217C141 227 136 232 125 232C120 232 116 230 114 228C109 223 52 8 52-8C52-17 57-22 67-22C72-22 79-17 88-6L133 47C168 1 224-22 300-22C366-22 424 5 476 58C528 111 554 170 554 236C554 283 538 323 505 355C490 368 470 379 445 388C422 393 400 399 378 405L312 423C279 432 254 469 254 509C254 552 271 589 306 621C341 653 380 669 423 669C515 669 561 619 561 520C561 502 557 482 557 465L557 462C560 455 565 451 573 451C582 451 588 459 592 474L645 691C645 700 640 705 630 705C625 705 618 700 609 689L566 637C538 682 491 705 424 705C361 705 304 681 254 634C202 586 176 531 176 468C176 396 223 339 282 323L387 296C441 281 475 262 475 195C475 149 457 108 422 72C387 36 347 17 302 17C204 17 133 60 133 157Z"></path></g><g data-mml-node="mi" transform="translate(646,-150) scale(0.707)" data-latex="m"><path data-c="1D45A" d="M657 442C596 442 543 412 498 353C489 412 451 442 383 442C324 442 273 416 231 363C223 407 188 442 137 442C96 442 66 409 45 344C34 312 29 293 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 66 299C84 375 107 413 134 413C152 413 161 399 161 371C161 358 156 331 145 290L88 63C84 51 79 25 79 19C79-1 90-11 111-11C131-11 145-1 152 19C153 24 160 49 171 92L192 181L222 295C233 318 250 341 272 365C301 397 337 413 380 413C413 413 429 391 429 348C429 335 424 308 414 267L387 153C380 124 364 64 356 32C355 25 354 21 354 19C354-1 365-11 387-11C398-11 406-8 413-1C428 14 429 21 435 48L494 285C497 298 511 321 535 353C565 393 605 413 654 413C687 413 703 391 703 348C703 309 683 236 642 129C633 106 629 87 629 74C629 25 666-11 714-11C759-11 793 14 818 64C838 104 848 131 848 144C848 153 843 158 832 158C825 157 818 148 813 137C791 58 759 18 716 18C703 18 696 28 696 47C696 62 702 84 714 115C755 222 775 295 775 333C775 404 728 442 657 442Z"></path></g></g><g data-mml-node="mo" data-latex="+" transform="translate(1539.1,0)"><path data-c="2B" d="M698 274L413 274L413 559C413 575 405 583 389 583C373 583 365 575 365 559L365 274L80 274C64 274 56 266 56 250C56 234 64 226 80 226L365 226L365-59C365-75 373-83 389-83C405-83 413-75 413-59L413 226L698 226C714 226 722 234 722 250C722 263 711 274 698 274Z"></path></g><g data-mml-node="msub" data-latex="S_1" transform="translate(2539.3,0)"><g data-mml-node="mi" data-latex="S"><path data-c="1D446" d="M133 157C133 181 136 201 141 217C141 227 136 232 125 232C120 232 116 230 114 228C109 223 52 8 52-8C52-17 57-22 67-22C72-22 79-17 88-6L133 47C168 1 224-22 300-22C366-22 424 5 476 58C528 111 554 170 554 236C554 283 538 323 505 355C490 368 470 379 445 388C422 393 400 399 378 405L312 423C279 432 254 469 254 509C254 552 271 589 306 621C341 653 380 669 423 669C515 669 561 619 561 520C561 502 557 482 557 465L557 462C560 455 565 451 573 451C582 451 588 459 592 474L645 691C645 700 640 705 630 705C625 705 618 700 609 689L566 637C538 682 491 705 424 705C361 705 304 681 254 634C202 586 176 531 176 468C176 396 223 339 282 323L387 296C441 281 475 262 475 195C475 149 457 108 422 72C387 36 347 17 302 17C204 17 133 60 133 157Z"></path></g><g data-mml-node="mn" transform="translate(646,-150) scale(0.707)" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g></g></g><rect width="3788.8" height="60" x="120" y="220"></rect></g><g data-mml-node="mo" data-latex="=" transform="translate(4306.6,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mfrac" data-latex="\frac{φ(\sqrt{k_2}-\sqrt{k_1})}{\sqrt{k_2}}" transform="translate(5362.4,0)"><g data-mml-node="mrow" data-latex="φ(\sqrt{k_2}-\sqrt{k_1})" transform="translate(220,708)"><g data-mml-node="mi" data-latex="φ"><path data-c="1D711" d="M503 442C486 442 471 439 456 434C393 413 349 351 324 294C282 201 270 163 239 58C136 79 84 126 84 200C84 267 131 364 164 402C170 409 173 414 173 417C173 426 168 431 157 431C140 431 118 402 91 344C64 286 50 234 50 189C50 85 129 19 220-3L169-165C165-176 163-183 163-186C163-207 174-218 196-218C215-218 228-208 236-189L270-12C281-13 290-13 299-13C381-13 454 19 520 83C586 147 619 220 619 302C619 380 578 442 503 442M583 280C583 217 553 162 492 115C435 73 374 52 308 52C302 52 296 52 291 53C285 53 282 53 282 52C297 131 306 178 310 192C333 271 401 377 493 377C549 377 583 337 583 280Z"></path></g><g data-mml-node="mo" data-latex="(" transform="translate(654,0)"><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"></path></g><g data-mml-node="msqrt" data-latex="\sqrt{k_2}" transform="translate(1043,0)"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_2"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g><g data-mml-node="mo" data-latex="-" transform="translate(3075.8,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="msqrt" data-latex="\sqrt{k_1}" transform="translate(4076,0)"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_1"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g><g data-mml-node="mo" data-latex=")" transform="translate(5886.6,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"></path></g></g><g data-mml-node="msqrt" data-latex="\sqrt{k_2}" transform="translate(2452.5,-859.5)"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_2"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g><rect width="6475.6" height="60" x="120" y="220"></rect></g></g></g></svg></mjx-container><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true"><svg style="vertical-align: -3.074ex;" xmlns="http://www.w3.org/2000/svg" width="29.658ex" height="6.638ex" role="img" focusable="false" viewBox="0 -1575.5 13108.8 2934.1"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="S_m=\frac{\sqrt{k_2}-\sqrt{k_1}}{(\frac{1}{φ}-1)\sqrt{k_2}+\sqrt{k_1}}·S_1"><g data-mml-node="msub" data-latex="S_m"><g data-mml-node="mi" data-latex="S"><path data-c="1D446" d="M133 157C133 181 136 201 141 217C141 227 136 232 125 232C120 232 116 230 114 228C109 223 52 8 52-8C52-17 57-22 67-22C72-22 79-17 88-6L133 47C168 1 224-22 300-22C366-22 424 5 476 58C528 111 554 170 554 236C554 283 538 323 505 355C490 368 470 379 445 388C422 393 400 399 378 405L312 423C279 432 254 469 254 509C254 552 271 589 306 621C341 653 380 669 423 669C515 669 561 619 561 520C561 502 557 482 557 465L557 462C560 455 565 451 573 451C582 451 588 459 592 474L645 691C645 700 640 705 630 705C625 705 618 700 609 689L566 637C538 682 491 705 424 705C361 705 304 681 254 634C202 586 176 531 176 468C176 396 223 339 282 323L387 296C441 281 475 262 475 195C475 149 457 108 422 72C387 36 347 17 302 17C204 17 133 60 133 157Z"></path></g><g data-mml-node="mi" transform="translate(646,-150) scale(0.707)" data-latex="m"><path data-c="1D45A" d="M657 442C596 442 543 412 498 353C489 412 451 442 383 442C324 442 273 416 231 363C223 407 188 442 137 442C96 442 66 409 45 344C34 312 29 293 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 66 299C84 375 107 413 134 413C152 413 161 399 161 371C161 358 156 331 145 290L88 63C84 51 79 25 79 19C79-1 90-11 111-11C131-11 145-1 152 19C153 24 160 49 171 92L192 181L222 295C233 318 250 341 272 365C301 397 337 413 380 413C413 413 429 391 429 348C429 335 424 308 414 267L387 153C380 124 364 64 356 32C355 25 354 21 354 19C354-1 365-11 387-11C398-11 406-8 413-1C428 14 429 21 435 48L494 285C497 298 511 321 535 353C565 393 605 413 654 413C687 413 703 391 703 348C703 309 683 236 642 129C633 106 629 87 629 74C629 25 666-11 714-11C759-11 793 14 818 64C838 104 848 131 848 144C848 153 843 158 832 158C825 157 818 148 813 137C791 58 759 18 716 18C703 18 696 28 696 47C696 62 702 84 714 115C755 222 775 295 775 333C775 404 728 442 657 442Z"></path></g></g><g data-mml-node="mo" data-latex="=" transform="translate(1594.6,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mfrac" data-latex="\frac{\sqrt{k_2}-\sqrt{k_1}}{(\frac{1}{φ}-1)\sqrt{k_2}+\sqrt{k_1}}" transform="translate(2650.4,0)"><g data-mml-node="mrow" data-latex="\sqrt{k_2}-\sqrt{k_1}" transform="translate(1921.4,676)"><g data-mml-node="msqrt" data-latex="\sqrt{k_2}"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_2"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g><g data-mml-node="mo" data-latex="-" transform="translate(2032.8,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="msqrt" data-latex="\sqrt{k_1}" transform="translate(3033,0)"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_1"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g></g><g data-mml-node="mrow" data-latex="(\frac{1}{φ}-1)\sqrt{k_2}+\sqrt{k_1}" transform="translate(220,-859.5)"><g data-mml-node="mo" data-latex="("><path data-c="28" d="M318-248C327-248 332-243 332-234C332-231 330-227 327-223C275-183 233-117 202-26C175 53 161 131 161 208L161 292C161 369 175 447 202 526C233 617 275 683 327 723C330 726 332 730 332 734C332 743 327 748 318 748C317 748 314 747 311 745C251 699 201 631 160 540C121 453 101 371 101 292L101 208C101 129 121 47 160-40C201-131 251-199 311-245C314-247 317-248 318-248Z"></path></g><g data-mml-node="mfrac" data-latex="\frac{1}{φ}" transform="translate(389,0)"><g data-mml-node="mn" transform="translate(274.4,394) scale(0.707)" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g><g data-mml-node="mi" transform="translate(220,-345) scale(0.707)" data-latex="φ"><path data-c="1D711" d="M503 442C486 442 471 439 456 434C393 413 349 351 324 294C282 201 270 163 239 58C136 79 84 126 84 200C84 267 131 364 164 402C170 409 173 414 173 417C173 426 168 431 157 431C140 431 118 402 91 344C64 286 50 234 50 189C50 85 129 19 220-3L169-165C165-176 163-183 163-186C163-207 174-218 196-218C215-218 228-208 236-189L270-12C281-13 290-13 299-13C381-13 454 19 520 83C586 147 619 220 619 302C619 380 578 442 503 442M583 280C583 217 553 162 492 115C435 73 374 52 308 52C302 52 296 52 291 53C285 53 282 53 282 52C297 131 306 178 310 192C333 271 401 377 493 377C549 377 583 337 583 280Z"></path></g><rect width="662.4" height="60" x="120" y="220"></rect></g><g data-mml-node="mo" data-latex="-" transform="translate(1513.7,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="mn" data-latex="1" transform="translate(2513.9,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g><g data-mml-node="mo" data-latex=")" transform="translate(3013.9,0)"><path data-c="29" d="M78-245C138-199 188-131 229-40C268 47 288 129 288 208L288 292C288 371 268 453 229 540C188 631 138 699 78 745C75 747 72 748 71 748C62 748 57 743 57 734C57 730 59 726 62 723C114 683 156 617 187 526C214 447 228 369 228 292L228 208C228 131 214 53 187-26C156-117 114-183 62-223C59-227 57-231 57-234C57-243 62-248 71-248C72-248 75-247 78-245Z"></path></g><g data-mml-node="msqrt" data-latex="\sqrt{k_2}" transform="translate(3402.9,0)"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_2"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g><g data-mml-node="mo" data-latex="+" transform="translate(5435.7,0)"><path data-c="2B" d="M698 274L413 274L413 559C413 575 405 583 389 583C373 583 365 575 365 559L365 274L80 274C64 274 56 266 56 250C56 234 64 226 80 226L365 226L365-59C365-75 373-83 389-83C405-83 413-75 413-59L413 226L698 226C714 226 722 234 722 250C722 263 711 274 698 274Z"></path></g><g data-mml-node="msqrt" data-latex="\sqrt{k_1}" transform="translate(6435.9,0)"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_1"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g></g><rect width="8446.4" height="60" x="120" y="220"></rect></g><g data-mml-node="mo" data-latex="·" transform="translate(11559.1,0)"><path data-c="B7" d="M192 250C192 279 168 303 139 303C110 303 86 279 86 250C86 221 110 197 139 197C168 197 192 221 192 250Z"></path></g><g data-mml-node="msub" data-latex="S_1" transform="translate(12059.3,0)"><g data-mml-node="mi" data-latex="S"><path data-c="1D446" d="M133 157C133 181 136 201 141 217C141 227 136 232 125 232C120 232 116 230 114 228C109 223 52 8 52-8C52-17 57-22 67-22C72-22 79-17 88-6L133 47C168 1 224-22 300-22C366-22 424 5 476 58C528 111 554 170 554 236C554 283 538 323 505 355C490 368 470 379 445 388C422 393 400 399 378 405L312 423C279 432 254 469 254 509C254 552 271 589 306 621C341 653 380 669 423 669C515 669 561 619 561 520C561 502 557 482 557 465L557 462C560 455 565 451 573 451C582 451 588 459 592 474L645 691C645 700 640 705 630 705C625 705 618 700 609 689L566 637C538 682 491 705 424 705C361 705 304 681 254 634C202 586 176 531 176 468C176 396 223 339 282 323L387 296C441 281 475 262 475 195C475 149 457 108 422 72C387 36 347 17 302 17C204 17 133 60 133 157Z"></path></g><g data-mml-node="mn" transform="translate(646,-150) scale(0.707)" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g></g></g></g></svg></mjx-container></p></li></ul></li></ul></li></ul></li></ul><p>​let φ=1/6,<br><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true"><svg style="vertical-align: -2.308ex;" xmlns="http://www.w3.org/2000/svg" width="23.09ex" height="5.872ex" role="img" focusable="false" viewBox="0 -1575.5 10205.9 2595.5"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="S_m=\frac{\sqrt{k_2}-\sqrt{k_1}}{5\sqrt{k_2}+\sqrt{k_1}}·S_1"><g data-mml-node="msub" data-latex="S_m"><g data-mml-node="mi" data-latex="S"><path data-c="1D446" d="M133 157C133 181 136 201 141 217C141 227 136 232 125 232C120 232 116 230 114 228C109 223 52 8 52-8C52-17 57-22 67-22C72-22 79-17 88-6L133 47C168 1 224-22 300-22C366-22 424 5 476 58C528 111 554 170 554 236C554 283 538 323 505 355C490 368 470 379 445 388C422 393 400 399 378 405L312 423C279 432 254 469 254 509C254 552 271 589 306 621C341 653 380 669 423 669C515 669 561 619 561 520C561 502 557 482 557 465L557 462C560 455 565 451 573 451C582 451 588 459 592 474L645 691C645 700 640 705 630 705C625 705 618 700 609 689L566 637C538 682 491 705 424 705C361 705 304 681 254 634C202 586 176 531 176 468C176 396 223 339 282 323L387 296C441 281 475 262 475 195C475 149 457 108 422 72C387 36 347 17 302 17C204 17 133 60 133 157Z"></path></g><g data-mml-node="mi" transform="translate(646,-150) scale(0.707)" data-latex="m"><path data-c="1D45A" d="M657 442C596 442 543 412 498 353C489 412 451 442 383 442C324 442 273 416 231 363C223 407 188 442 137 442C96 442 66 409 45 344C34 312 29 293 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 66 299C84 375 107 413 134 413C152 413 161 399 161 371C161 358 156 331 145 290L88 63C84 51 79 25 79 19C79-1 90-11 111-11C131-11 145-1 152 19C153 24 160 49 171 92L192 181L222 295C233 318 250 341 272 365C301 397 337 413 380 413C413 413 429 391 429 348C429 335 424 308 414 267L387 153C380 124 364 64 356 32C355 25 354 21 354 19C354-1 365-11 387-11C398-11 406-8 413-1C428 14 429 21 435 48L494 285C497 298 511 321 535 353C565 393 605 413 654 413C687 413 703 391 703 348C703 309 683 236 642 129C633 106 629 87 629 74C629 25 666-11 714-11C759-11 793 14 818 64C838 104 848 131 848 144C848 153 843 158 832 158C825 157 818 148 813 137C791 58 759 18 716 18C703 18 696 28 696 47C696 62 702 84 714 115C755 222 775 295 775 333C775 404 728 442 657 442Z"></path></g></g><g data-mml-node="mo" data-latex="=" transform="translate(1594.6,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mfrac" data-latex="\frac{\sqrt{k_2}-\sqrt{k_1}}{5\sqrt{k_2}+\sqrt{k_1}}" transform="translate(2650.4,0)"><g data-mml-node="mrow" data-latex="\sqrt{k_2}-\sqrt{k_1}" transform="translate(470,676)"><g data-mml-node="msqrt" data-latex="\sqrt{k_2}"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_2"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g><g data-mml-node="mo" data-latex="-" transform="translate(2032.8,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="msqrt" data-latex="\sqrt{k_1}" transform="translate(3033,0)"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_1"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g></g><g data-mml-node="mrow" data-latex="5\sqrt{k_2}+\sqrt{k_1}" transform="translate(220,-859.5)"><g data-mml-node="mn" data-latex="5"><path data-c="35" d="M118 315C123 315 129 319 134 326C164 371 205 393 257 393C292 393 319 373 337 332C348 305 354 264 354 209C354 146 346 102 331 76C306 35 272 14 229 14C162 14 109 62 91 114C94 113 96 114 100 114C130 114 155 137 155 167C155 198 130 219 100 219C65 219 50 200 50 163C50 63 131-22 231-22C292-22 344 0 386 44C428 88 449 141 449 202C449 260 432 310 398 353C361 400 315 423 259 423C212 423 171 408 138 378L138 556C165 548 191 544 218 544C264 544 304 555 338 578C369 597 390 616 402 634C408 642 411 648 411 651C411 661 406 666 396 666C341 645 294 634 256 634C211 634 168 643 127 662C122 664 118 665 114 665C105 665 100 656 100 637L100 345C100 324 100 315 118 315Z"></path></g><g data-mml-node="msqrt" data-latex="\sqrt{k_2}" transform="translate(500,0)"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_2"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g><g data-mml-node="mo" data-latex="+" transform="translate(2532.8,0)"><path data-c="2B" d="M698 274L413 274L413 559C413 575 405 583 389 583C373 583 365 575 365 559L365 274L80 274C64 274 56 266 56 250C56 234 64 226 80 226L365 226L365-59C365-75 373-83 389-83C405-83 413-75 413-59L413 226L698 226C714 226 722 234 722 250C722 263 711 274 698 274Z"></path></g><g data-mml-node="msqrt" data-latex="\sqrt{k_1}" transform="translate(3533,0)"><g data-mml-node="mo" transform="translate(0,799.5)"><path data-c="221A" d="M847-2C851 7 853 13 853 16C853 32 845 40 829 40C820 40 813 36 809 27C666-259 595-403 595-405L595-406C595-413 527-558 390-843L217-461C212-450 207-445 201-445C198-445 192-448 184-454L86-528C77-535 73-540 73-545C73-555 78-560 87-560C90-560 95-557 103-551L151-516L345-943C350-954 357-960 367-960C379-960 387-955 392-946Z"></path></g><g transform="translate(853,0)"><g data-mml-node="msub" data-latex="k_1"><g data-mml-node="mi" data-latex="k"><path data-c="1D458" d="M409 353C409 327 423 314 450 314C485 314 508 345 508 379C508 418 476 445 437 445C392 445 344 415 291 356C250 311 217 282 190 269L291 679C289 688 287 694 274 694C242 694 166 685 154 684C139 682 132 675 132 660C132 650 141 645 159 645C178 645 204 646 204 632L59 43C56 32 55 25 55 21C55 0 66-11 87-11C104-11 117-3 124 12C129 21 147 92 179 226C231 221 286 196 286 146C286 131 279 101 279 91C279 34 316-11 373-11C431-11 470 41 490 145C490 154 485 159 475 159C466 159 460 152 457 138C435 59 408 19 375 19C357 19 348 33 348 61C348 77 360 131 360 147C360 204 314 239 221 253C244 269 270 292 298 322C326 352 346 371 359 382C386 404 412 415 435 415C445 415 453 413 459 409C432 404 409 379 409 353Z"></path></g><g data-mml-node="mn" transform="translate(554,-150) scale(0.707)" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g></g></g><rect width="957.6" height="60" x="853" y="779.5"></rect></g></g><rect width="5543.6" height="60" x="120" y="220"></rect></g><g data-mml-node="mo" data-latex="·" transform="translate(8656.2,0)"><path data-c="B7" d="M192 250C192 279 168 303 139 303C110 303 86 279 86 250C86 221 110 197 139 197C168 197 192 221 192 250Z"></path></g><g data-mml-node="msub" data-latex="S_1" transform="translate(9156.4,0)"><g data-mml-node="mi" data-latex="S"><path data-c="1D446" d="M133 157C133 181 136 201 141 217C141 227 136 232 125 232C120 232 116 230 114 228C109 223 52 8 52-8C52-17 57-22 67-22C72-22 79-17 88-6L133 47C168 1 224-22 300-22C366-22 424 5 476 58C528 111 554 170 554 236C554 283 538 323 505 355C490 368 470 379 445 388C422 393 400 399 378 405L312 423C279 432 254 469 254 509C254 552 271 589 306 621C341 653 380 669 423 669C515 669 561 619 561 520C561 502 557 482 557 465L557 462C560 455 565 451 573 451C582 451 588 459 592 474L645 691C645 700 640 705 630 705C625 705 618 700 609 689L566 637C538 682 491 705 424 705C361 705 304 681 254 634C202 586 176 531 176 468C176 396 223 339 282 323L387 296C441 281 475 262 475 195C475 149 457 108 422 72C387 36 347 17 302 17C204 17 133 60 133 157Z"></path></g><g data-mml-node="mn" transform="translate(646,-150) scale(0.707)" data-latex="1"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path></g></g></g></g></svg></mjx-container><br><code>Sm</code> goes to project team, the rest goes to the LPs.</p>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;Download uniswap whitepaper: &lt;a href=&quot;https://app.uniswap.org/whitepaper.pdf&quot;&gt;https://app.uniswap.org/whitepaper.pdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;it’s not </summary>
      
    
    
    
    
    <category term="tech" scheme="http://example.com/tags/tech/"/>
    
  </entry>
  
  <entry>
    <title>How AMM module works? [x*y=k]</title>
    <link href="http://example.com/2026/07/20/amm/"/>
    <id>http://example.com/2026/07/20/amm/</id>
    <published>2026-07-20T11:07:51.000Z</published>
    <updated>2026-10-18T08:35:25.850Z</updated>
    
    <content type="html"><![CDATA[<p>All swapping pools between two currncies mostly base on the <strong>x·y=k</strong> equation. Usually, x: number of TokenA, y: number of TokenB. (Initial number of TokenA and TokenB are based on the exact price when the pool was created).</p><p>Here are two scenarios for buy and sell,</p><ol><li>User sells ETH for getting USDC:  (x+dx)·(y-dy)=k</li><li>User sells USDC for getting ETH:  (x-dx)·(y+dy)=k</li></ol><p>Let’s assume there is a pool, and there are 10ETH and 20,000USDC in it, then the k=10*20,000=200,000</p><ol><li><p>User sells 5 ETH for getting USDC:  (10+5)·(20,000-dy)=200,000  dy=6666.67USDC</p></li><li><p>User sells 10,000USDC for getting ETH: (10-dx)·(20000+10,000)=200,000  dx=3.33ETH</p></li><li><p>What if I am trying to sell 10,000ETH for USDC? Calculate it, for fun ^^</p><p>(10+10,000)·(20000-dy)=200,000 dy=19998USDC</p></li></ol><blockquote><ul><li><p>Sell 5ETH get 6666.67USDC , then 6666.67/5 = 1333.33 USDC/ETH</p></li><li><p>Sell 10,000ETH get 19998USDC , then 19998/10,000 = 2 USDC/ETH</p></li></ul><p>What is this?!! So, The bigger you try to swap , the worse the value you get. But don’t worry, usually for a pool that size, an everage ordinary trade barely moves the needle.</p></blockquote><div style="margin-top: 25px; padding: 15px; background: #2d3748; border-radius: 6px; border-left: 4px solid #4CAF50; font-size: 13px; color: #e2e8f0; text-align: left;">    <div style="font-weight: bold; margin-bottom: 10px; color: #ffffff; font-size: 14px;">Question：</div>    <div style="margin-bottom: 15px; padding: 10px; background: rgba(255,255,255,0.05); border-radius: 4px;">        • And what if the price fluctuates out of the pool?    </div>    <div style="padding: 10px; background: rgba(76, 175, 80, 0.1); border-radius: 4px; border-left: 3px solid #4CAF50;">      No worries, there usually is an arbitrage bot that monitors price differences between the pool and the outside world, once there's a price gap for speculation, the bot immediately sells the token which went up, this trick helps keep the pool price aligned with the broader market.    </div></div><hr><p><strong>Concepts</strong></p><ul><li><p><strong>Slippage</strong>: this is a concept about how much gap are there between expected price and buy-in price.</p><ul><li><p>buy-in price: 1333.33USDC/ETH (just the value we calculated base on x*y=k law)</p></li><li><p>expected price: current market price that we ususally query from chain network, assume it 1340</p><ul><li><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true"><svg style="vertical-align: -1.991ex;" xmlns="http://www.w3.org/2000/svg" width="50.021ex" height="5.09ex" role="img" focusable="false" viewBox="0 -1370 22109.4 2250"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="Slippage = \frac{BuyInPrice - ExpectedPrice}{ExpectedPrice}*100\text{％}"><g data-mml-node="mi" data-latex="S"><path data-c="1D446" d="M133 157C133 181 136 201 141 217C141 227 136 232 125 232C120 232 116 230 114 228C109 223 52 8 52-8C52-17 57-22 67-22C72-22 79-17 88-6L133 47C168 1 224-22 300-22C366-22 424 5 476 58C528 111 554 170 554 236C554 283 538 323 505 355C490 368 470 379 445 388C422 393 400 399 378 405L312 423C279 432 254 469 254 509C254 552 271 589 306 621C341 653 380 669 423 669C515 669 561 619 561 520C561 502 557 482 557 465L557 462C560 455 565 451 573 451C582 451 588 459 592 474L645 691C645 700 640 705 630 705C625 705 618 700 609 689L566 637C538 682 491 705 424 705C361 705 304 681 254 634C202 586 176 531 176 468C176 396 223 339 282 323L387 296C441 281 475 262 475 195C475 149 457 108 422 72C387 36 347 17 302 17C204 17 133 60 133 157Z"></path></g><g data-mml-node="mi" data-latex="l" transform="translate(645,0)"><path data-c="1D459" d="M173 632L49 119C46 105 44 93 44 84C44 31 83-11 136-11C185-11 220 41 241 145C241 154 236 159 225 159C217 159 211 152 208 138C188 59 165 19 138 19C121 19 113 33 113 60C113 75 115 91 119 107L258 679L258 683C255 690 249 694 242 694C210 694 136 685 124 684C109 682 102 674 102 659C102 650 111 645 130 645C147 645 173 645 173 632Z"></path></g><g data-mml-node="mi" data-latex="i" transform="translate(943,0)"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"></path></g><g data-mml-node="mi" data-latex="p" transform="translate(1288,0)"><path data-c="1D45D" d="M355 442C311 442 269 419 228 373C217 419 186 442 137 442C96 442 66 409 45 344C35 311 30 292 30 286C30 277 35 272 46 272C51 272 54 273 57 275C62 284 65 291 66 298C84 374 107 412 134 412C152 412 161 398 161 371C161 356 159 339 154 321L44-118C35-151 34-155-5-155C-23-155-32-163-32-178C-32-189-26-194-15-194C0-194 52-191 67-191C86-191 146-194 165-194C180-194 187-186 187-170C187-160 178-155 159-155C141-155 114-156 114-144C114-131 155 26 159 43C179 6 209-13 249-13C314-13 371 20 421 87C467 148 490 213 490 280C490 367 438 442 355 442M352 412C391 412 411 382 411 323C411 296 405 260 394 215C371 128 342 71 307 42C286 25 267 16 248 16C219 16 199 29 188 56C179 77 174 92 174 100L225 309C230 331 248 354 276 377C304 400 329 412 352 412Z"></path></g><g data-mml-node="mi" data-latex="p" transform="translate(1791,0)"><path data-c="1D45D" d="M355 442C311 442 269 419 228 373C217 419 186 442 137 442C96 442 66 409 45 344C35 311 30 292 30 286C30 277 35 272 46 272C51 272 54 273 57 275C62 284 65 291 66 298C84 374 107 412 134 412C152 412 161 398 161 371C161 356 159 339 154 321L44-118C35-151 34-155-5-155C-23-155-32-163-32-178C-32-189-26-194-15-194C0-194 52-191 67-191C86-191 146-194 165-194C180-194 187-186 187-170C187-160 178-155 159-155C141-155 114-156 114-144C114-131 155 26 159 43C179 6 209-13 249-13C314-13 371 20 421 87C467 148 490 213 490 280C490 367 438 442 355 442M352 412C391 412 411 382 411 323C411 296 405 260 394 215C371 128 342 71 307 42C286 25 267 16 248 16C219 16 199 29 188 56C179 77 174 92 174 100L225 309C230 331 248 354 276 377C304 400 329 412 352 412Z"></path></g><g data-mml-node="mi" data-latex="a" transform="translate(2294,0)"><path data-c="1D44E" d="M498 144C498 153 493 158 482 158C474 158 468 151 465 137C445 58 421 18 394 18C377 18 368 32 368 60C368 73 372 97 381 132L438 357C443 376 445 387 445 392C445 412 434 422 412 422C391 422 377 410 370 387C349 424 319 442 281 442C216 442 159 409 109 343C63 281 40 217 40 150C40 63 91-11 175-11C218-11 260 12 300 58C311 20 345-11 392-11C461-11 482 70 498 144M341 374C350 353 355 339 355 330C355 326 354 321 353 314L304 122C301 111 294 99 285 87C248 41 212 18 177 18C138 18 118 48 118 107C118 131 124 167 136 215C157 300 187 357 224 388C244 405 263 413 282 413C309 413 329 400 341 374Z"></path></g><g data-mml-node="mi" data-latex="g" transform="translate(2823,0)"><path data-c="1D454" d="M15-141C15-184 60-205 150-205C197-205 241-193 280-170C324-144 351-109 362-66L471 373C473 383 474 389 474 392C474 412 463 422 442 422C420 422 406 410 399 387C377 424 347 442 310 442C246 442 189 410 140 346C95 286 72 223 72 158C72 71 123-3 207-3C246-3 282 14 315 47L285-71C256-140 211-175 148-175C122-175 100-173 82-169C103-158 113-141 113-118C113-93 99-80 72-80C40-80 15-109 15-141M356 392C376 371 386 351 386 331C386 330 385 325 383 318L336 129C330 106 313 82 286 60C259 38 233 27 210 27C170 27 150 56 150 114C150 169 184 291 204 327C235 384 270 412 311 412C329 412 344 405 356 392Z"></path></g><g data-mml-node="mi" data-latex="e" transform="translate(3300,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"></path></g><g data-mml-node="mo" data-latex="=" transform="translate(4043.8,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mfrac" data-latex="\frac{BuyInPrice - ExpectedPrice}{ExpectedPrice}" transform="translate(5099.6,0)"><g data-mml-node="mrow" data-latex="BuyInPrice - ExpectedPrice" transform="translate(220,676)"><g data-mml-node="mi" data-latex="B"><path data-c="1D435" d="M756 543C756 634 666 683 568 683L236 683C213 683 203 682 203 659C203 643 223 644 235 644C265 643 283 641 288 640C293 639 295 636 295 631C295 629 294 623 291 613L159 82C154 60 144 47 129 42C122 40 104 39 73 39C52 39 42 31 42 15C42 5 52 0 73 0L426 0C491 0 551 20 608 59C671 102 703 155 703 217C703 296 638 344 567 358C655 379 756 446 756 543M554 644C623 644 658 612 658 547C658 496 638 454 596 420C554 386 507 370 456 370L317 370L377 610C385 644 385 644 427 644M582 299C596 276 603 253 603 228C603 176 583 131 542 94C501 57 455 39 402 39L267 39C257 39 250 39 246 40C240 40 237 42 237 45C237 46 237 49 238 53C269 180 293 276 309 340L493 340C536 340 565 326 582 299Z"></path></g><g data-mml-node="mi" data-latex="u" transform="translate(759,0)"><path data-c="1D462" d="M543 144C543 153 538 158 527 158C518 158 513 151 510 137C505 118 500 99 493 80C480 39 462 18 440 18C422 18 413 32 413 60C413 77 420 111 433 161L460 267C469 303 477 328 483 359L489 386C491 393 492 398 492 401C492 421 481 431 459 431C437 431 423 419 417 394L343 98C342 95 338 88 330 76C314 50 275 18 235 18C197 18 178 44 178 95C178 136 196 202 231 294C242 324 248 345 248 357C248 407 213 442 163 442C118 442 83 417 58 367C39 328 29 301 29 287C29 278 34 273 45 273C58 273 60 279 64 293C87 373 119 413 160 413C174 413 181 403 181 384C181 369 175 348 164 319C126 218 107 148 107 111C107 34 155-11 232-11C275-11 314 9 347 50C361 9 391-11 437-11C506-11 527 70 543 144Z"></path></g><g data-mml-node="mi" data-latex="y" transform="translate(1331,0)"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><g data-mml-node="mi" data-latex="I" transform="translate(1821,0)"><path data-c="1D43C" d="M497 667C497 678 491 683 478 683L349 680L218 683C202 684 194 676 194 659C194 649 205 644 226 644C269 644 290 639 290 630C290 625 289 620 288 615L155 82C150 60 140 47 125 42C118 40 100 39 69 39C44 39 34 38 34 15C34 5 40 0 53 0L181 3L313 0C329-1 337 7 337 23C337 39 325 39 303 39C264 39 240 37 240 53C240 58 241 65 244 75L376 602C381 623 391 636 406 641C413 643 431 644 462 644C486 644 497 645 497 667Z"></path></g><g data-mml-node="mi" data-latex="n" transform="translate(2318,0)"><path data-c="1D45B" d="M537 137C514 58 481 18 440 18C427 18 420 28 420 47C420 61 426 84 438 115C478 224 498 296 498 333C498 403 451 442 381 442C322 442 271 416 230 363C222 407 187 442 136 442C80 442 58 390 44 345C34 313 29 294 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C151 413 160 399 160 371C160 358 155 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 111-11C130-11 144-1 151 19C153 24 159 49 170 92L191 181L221 295C232 318 249 341 270 365C299 397 335 413 378 413C411 413 427 391 427 348C427 310 406 234 363 120C356 102 353 87 353 74C353 25 390-11 438-11C482-11 517 14 542 64C561 104 571 131 571 144C571 153 566 158 555 158C552 158 537 149 537 137Z"></path></g><g data-mml-node="mi" data-latex="P" transform="translate(2918,0)"><path data-c="1D443" d="M555 683L235 683C212 683 201 682 201 660C201 649 212 644 234 644C254 644 294 647 294 631C294 629 293 623 290 613L158 82C152 60 142 47 128 42C121 40 103 39 72 39C50 39 40 37 40 16C40 5 46 0 59 0L184 3L248 2C259 2 299 0 312 0C328 0 336 8 336 24C336 34 325 39 304 39C264 39 244 43 244 52C244 52 245 55 247 68L307 312L472 312C537 312 599 332 657 371C722 414 754 467 754 530C754 629 660 683 555 683M524 644C611 644 654 614 654 554C654 498 626 423 597 397C559 363 509 346 447 346L313 346L379 610C387 644 387 644 429 644Z"></path></g><g data-mml-node="mi" data-latex="r" transform="translate(3672,0)"><path data-c="1D45F" d="M436 374C436 416 395 442 351 442C302 442 261 419 227 372C217 411 183 442 136 442C95 442 65 410 44 345C34 312 29 293 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C150 413 159 399 159 371C159 358 154 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 110-11C130-11 143-1 150 19L169 91C180 134 187 162 190 175L221 303C223 311 231 324 244 343C271 381 302 413 351 413C363 413 373 411 382 406C352 397 337 378 337 351C337 325 351 312 378 312C411 312 436 341 436 374Z"></path></g><g data-mml-node="mi" data-latex="i" transform="translate(4123,0)"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"></path></g><g data-mml-node="mi" data-latex="c" transform="translate(4468,0)"><path data-c="1D450" d="M328 325C328 300 341 287 368 287C404 287 427 318 427 354C427 410 368 442 308 442C239 442 176 412 122 353C68 294 41 229 41 159C41 61 106-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 121 53 121 122C121 184 150 274 174 317C198 361 249 413 308 413C346 413 372 402 386 381C355 378 328 358 328 325Z"></path></g><g data-mml-node="mi" data-latex="e" transform="translate(4901,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"></path></g><g data-mml-node="mo" data-latex="-" transform="translate(5589.2,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="mi" data-latex="E" transform="translate(6589.4,0)"><path data-c="1D438" d="M199 656C199 646 210 641 231 641C271 641 291 637 291 628C291 625 289 618 286 605L156 82C151 60 141 47 126 42C119 40 101 39 70 39C48 39 38 37 38 16C38 5 49 0 70 0L583 0C607 0 609 2 617 19L657 109C684 171 703 217 714 248C712 257 709 263 698 263C691 263 685 258 681 249C656 190 632 145 608 113C568 59 509 39 415 39L270 39C260 39 253 39 249 40C243 40 240 42 240 45C240 47 242 54 245 67L311 334L406 334C453 334 478 328 483 315C485 310 486 303 486 293C486 280 484 264 479 245C477 240 476 236 476 233C476 223 482 218 493 218C502 218 508 226 512 241L568 473C568 483 563 488 552 488C544 488 538 481 535 467C525 428 512 403 495 391C478 379 450 373 409 373L321 373L379 606C387 640 387 641 429 641L568 641C619 641 654 636 673 626C701 611 715 581 715 536C715 519 714 501 711 484C711 482 711 479 710 475L710 466C710 455 715 450 725 450C735 450 741 459 743 478L763 649C766 677 759 680 732 680L233 680C210 680 199 679 199 656Z"></path></g><g data-mml-node="mi" data-latex="x" transform="translate(7355.4,0)"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mi" data-latex="p" transform="translate(7927.4,0)"><path data-c="1D45D" d="M355 442C311 442 269 419 228 373C217 419 186 442 137 442C96 442 66 409 45 344C35 311 30 292 30 286C30 277 35 272 46 272C51 272 54 273 57 275C62 284 65 291 66 298C84 374 107 412 134 412C152 412 161 398 161 371C161 356 159 339 154 321L44-118C35-151 34-155-5-155C-23-155-32-163-32-178C-32-189-26-194-15-194C0-194 52-191 67-191C86-191 146-194 165-194C180-194 187-186 187-170C187-160 178-155 159-155C141-155 114-156 114-144C114-131 155 26 159 43C179 6 209-13 249-13C314-13 371 20 421 87C467 148 490 213 490 280C490 367 438 442 355 442M352 412C391 412 411 382 411 323C411 296 405 260 394 215C371 128 342 71 307 42C286 25 267 16 248 16C219 16 199 29 188 56C179 77 174 92 174 100L225 309C230 331 248 354 276 377C304 400 329 412 352 412Z"></path></g><g data-mml-node="mi" data-latex="e" transform="translate(8430.4,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"></path></g><g data-mml-node="mi" data-latex="c" transform="translate(8896.4,0)"><path data-c="1D450" d="M328 325C328 300 341 287 368 287C404 287 427 318 427 354C427 410 368 442 308 442C239 442 176 412 122 353C68 294 41 229 41 159C41 61 106-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 121 53 121 122C121 184 150 274 174 317C198 361 249 413 308 413C346 413 372 402 386 381C355 378 328 358 328 325Z"></path></g><g data-mml-node="mi" data-latex="t" transform="translate(9329.4,0)"><path data-c="1D461" d="M330 419C330 428 320 433 299 433L218 433C244 537 257 591 257 595C257 616 246 626 225 626C202 626 188 613 182 587L145 433L56 433C34 433 23 432 23 411C23 400 33 395 54 395L135 395C86 200 62 97 62 84C62 28 100-11 156-11C194-11 227 6 256 41C280 70 297 98 308 125C312 136 314 142 314 145C314 154 309 159 299 159C291 159 285 154 281 143C247 60 206 19 157 19C140 19 131 33 131 60C131 75 133 91 137 107L208 395L297 395C323 395 330 397 330 419Z"></path></g><g data-mml-node="mi" data-latex="e" transform="translate(9690.4,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"></path></g><g data-mml-node="mi" data-latex="d" transform="translate(10156.4,0)"><path data-c="1D451" d="M429 632L370 389C349 426 320 445 281 445C216 445 159 412 109 345C63 283 40 218 40 151C40 63 91-11 175-11C218-11 260 12 300 59C311 21 345-11 392-11C461-11 483 71 498 145C498 154 493 159 483 159C474 159 468 152 465 138C445 59 421 19 394 19C377 19 368 33 368 60C368 75 370 91 374 107L516 679L516 683C513 690 507 694 499 694C476 694 434 690 374 683C363 682 357 674 357 660C357 650 366 645 384 645C403 645 429 646 429 632M341 376C351 355 356 341 356 332C355 328 354 323 353 316L304 122C301 111 294 99 285 87C248 42 212 19 177 19C138 19 118 49 118 108C118 132 124 168 136 216C157 301 187 359 224 390C244 407 263 415 282 415C309 415 329 402 341 376Z"></path></g><g data-mml-node="mi" data-latex="P" transform="translate(10676.4,0)"><path data-c="1D443" d="M555 683L235 683C212 683 201 682 201 660C201 649 212 644 234 644C254 644 294 647 294 631C294 629 293 623 290 613L158 82C152 60 142 47 128 42C121 40 103 39 72 39C50 39 40 37 40 16C40 5 46 0 59 0L184 3L248 2C259 2 299 0 312 0C328 0 336 8 336 24C336 34 325 39 304 39C264 39 244 43 244 52C244 52 245 55 247 68L307 312L472 312C537 312 599 332 657 371C722 414 754 467 754 530C754 629 660 683 555 683M524 644C611 644 654 614 654 554C654 498 626 423 597 397C559 363 509 346 447 346L313 346L379 610C387 644 387 644 429 644Z"></path></g><g data-mml-node="mi" data-latex="r" transform="translate(11430.4,0)"><path data-c="1D45F" d="M436 374C436 416 395 442 351 442C302 442 261 419 227 372C217 411 183 442 136 442C95 442 65 410 44 345C34 312 29 293 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C150 413 159 399 159 371C159 358 154 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 110-11C130-11 143-1 150 19L169 91C180 134 187 162 190 175L221 303C223 311 231 324 244 343C271 381 302 413 351 413C363 413 373 411 382 406C352 397 337 378 337 351C337 325 351 312 378 312C411 312 436 341 436 374Z"></path></g><g data-mml-node="mi" data-latex="i" transform="translate(11881.4,0)"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"></path></g><g data-mml-node="mi" data-latex="c" transform="translate(12226.4,0)"><path data-c="1D450" d="M328 325C328 300 341 287 368 287C404 287 427 318 427 354C427 410 368 442 308 442C239 442 176 412 122 353C68 294 41 229 41 159C41 61 106-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 121 53 121 122C121 184 150 274 174 317C198 361 249 413 308 413C346 413 372 402 386 381C355 378 328 358 328 325Z"></path></g><g data-mml-node="mi" data-latex="e" transform="translate(12659.4,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"></path></g></g><g data-mml-node="mrow" data-latex="ExpectedPrice" transform="translate(3514.7,-686)"><g data-mml-node="mi" data-latex="E"><path data-c="1D438" d="M199 656C199 646 210 641 231 641C271 641 291 637 291 628C291 625 289 618 286 605L156 82C151 60 141 47 126 42C119 40 101 39 70 39C48 39 38 37 38 16C38 5 49 0 70 0L583 0C607 0 609 2 617 19L657 109C684 171 703 217 714 248C712 257 709 263 698 263C691 263 685 258 681 249C656 190 632 145 608 113C568 59 509 39 415 39L270 39C260 39 253 39 249 40C243 40 240 42 240 45C240 47 242 54 245 67L311 334L406 334C453 334 478 328 483 315C485 310 486 303 486 293C486 280 484 264 479 245C477 240 476 236 476 233C476 223 482 218 493 218C502 218 508 226 512 241L568 473C568 483 563 488 552 488C544 488 538 481 535 467C525 428 512 403 495 391C478 379 450 373 409 373L321 373L379 606C387 640 387 641 429 641L568 641C619 641 654 636 673 626C701 611 715 581 715 536C715 519 714 501 711 484C711 482 711 479 710 475L710 466C710 455 715 450 725 450C735 450 741 459 743 478L763 649C766 677 759 680 732 680L233 680C210 680 199 679 199 656Z"></path></g><g data-mml-node="mi" data-latex="x" transform="translate(766,0)"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mi" data-latex="p" transform="translate(1338,0)"><path data-c="1D45D" d="M355 442C311 442 269 419 228 373C217 419 186 442 137 442C96 442 66 409 45 344C35 311 30 292 30 286C30 277 35 272 46 272C51 272 54 273 57 275C62 284 65 291 66 298C84 374 107 412 134 412C152 412 161 398 161 371C161 356 159 339 154 321L44-118C35-151 34-155-5-155C-23-155-32-163-32-178C-32-189-26-194-15-194C0-194 52-191 67-191C86-191 146-194 165-194C180-194 187-186 187-170C187-160 178-155 159-155C141-155 114-156 114-144C114-131 155 26 159 43C179 6 209-13 249-13C314-13 371 20 421 87C467 148 490 213 490 280C490 367 438 442 355 442M352 412C391 412 411 382 411 323C411 296 405 260 394 215C371 128 342 71 307 42C286 25 267 16 248 16C219 16 199 29 188 56C179 77 174 92 174 100L225 309C230 331 248 354 276 377C304 400 329 412 352 412Z"></path></g><g data-mml-node="mi" data-latex="e" transform="translate(1841,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"></path></g><g data-mml-node="mi" data-latex="c" transform="translate(2307,0)"><path data-c="1D450" d="M328 325C328 300 341 287 368 287C404 287 427 318 427 354C427 410 368 442 308 442C239 442 176 412 122 353C68 294 41 229 41 159C41 61 106-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 121 53 121 122C121 184 150 274 174 317C198 361 249 413 308 413C346 413 372 402 386 381C355 378 328 358 328 325Z"></path></g><g data-mml-node="mi" data-latex="t" transform="translate(2740,0)"><path data-c="1D461" d="M330 419C330 428 320 433 299 433L218 433C244 537 257 591 257 595C257 616 246 626 225 626C202 626 188 613 182 587L145 433L56 433C34 433 23 432 23 411C23 400 33 395 54 395L135 395C86 200 62 97 62 84C62 28 100-11 156-11C194-11 227 6 256 41C280 70 297 98 308 125C312 136 314 142 314 145C314 154 309 159 299 159C291 159 285 154 281 143C247 60 206 19 157 19C140 19 131 33 131 60C131 75 133 91 137 107L208 395L297 395C323 395 330 397 330 419Z"></path></g><g data-mml-node="mi" data-latex="e" transform="translate(3101,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"></path></g><g data-mml-node="mi" data-latex="d" transform="translate(3567,0)"><path data-c="1D451" d="M429 632L370 389C349 426 320 445 281 445C216 445 159 412 109 345C63 283 40 218 40 151C40 63 91-11 175-11C218-11 260 12 300 59C311 21 345-11 392-11C461-11 483 71 498 145C498 154 493 159 483 159C474 159 468 152 465 138C445 59 421 19 394 19C377 19 368 33 368 60C368 75 370 91 374 107L516 679L516 683C513 690 507 694 499 694C476 694 434 690 374 683C363 682 357 674 357 660C357 650 366 645 384 645C403 645 429 646 429 632M341 376C351 355 356 341 356 332C355 328 354 323 353 316L304 122C301 111 294 99 285 87C248 42 212 19 177 19C138 19 118 49 118 108C118 132 124 168 136 216C157 301 187 359 224 390C244 407 263 415 282 415C309 415 329 402 341 376Z"></path></g><g data-mml-node="mi" data-latex="P" transform="translate(4087,0)"><path data-c="1D443" d="M555 683L235 683C212 683 201 682 201 660C201 649 212 644 234 644C254 644 294 647 294 631C294 629 293 623 290 613L158 82C152 60 142 47 128 42C121 40 103 39 72 39C50 39 40 37 40 16C40 5 46 0 59 0L184 3L248 2C259 2 299 0 312 0C328 0 336 8 336 24C336 34 325 39 304 39C264 39 244 43 244 52C244 52 245 55 247 68L307 312L472 312C537 312 599 332 657 371C722 414 754 467 754 530C754 629 660 683 555 683M524 644C611 644 654 614 654 554C654 498 626 423 597 397C559 363 509 346 447 346L313 346L379 610C387 644 387 644 429 644Z"></path></g><g data-mml-node="mi" data-latex="r" transform="translate(4841,0)"><path data-c="1D45F" d="M436 374C436 416 395 442 351 442C302 442 261 419 227 372C217 411 183 442 136 442C95 442 65 410 44 345C34 312 29 293 29 287C29 278 34 273 45 273C50 273 53 274 56 276C61 285 64 292 65 299C83 375 106 413 133 413C150 413 159 399 159 371C159 358 154 331 144 290L87 63C84 50 78 24 78 19C78-1 89-11 110-11C130-11 143-1 150 19L169 91C180 134 187 162 190 175L221 303C223 311 231 324 244 343C271 381 302 413 351 413C363 413 373 411 382 406C352 397 337 378 337 351C337 325 351 312 378 312C411 312 436 341 436 374Z"></path></g><g data-mml-node="mi" data-latex="i" transform="translate(5292,0)"><path data-c="1D456" d="M284 621C284 648 271 661 244 661C216 661 188 633 188 605C188 578 202 565 229 565C257 565 284 593 284 621M259 138C237 59 205 19 164 19C151 19 144 28 144 47C144 64 173 150 232 306C240 329 244 347 244 360C244 409 210 445 161 445C118 445 84 420 59 369C39 328 29 301 29 288C29 279 34 275 45 275C58 275 60 281 64 295C87 375 118 415 158 415C171 415 178 406 178 387C178 373 175 357 168 338C145 275 121 208 101 155C86 115 78 88 78 74C78 25 114-11 162-11C205-11 239 14 264 64C283 103 293 130 293 145C293 154 288 159 277 159C274 159 259 150 259 138Z"></path></g><g data-mml-node="mi" data-latex="c" transform="translate(5637,0)"><path data-c="1D450" d="M328 325C328 300 341 287 368 287C404 287 427 318 427 354C427 410 368 442 308 442C239 442 176 412 122 353C68 294 41 229 41 159C41 61 106-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 121 53 121 122C121 184 150 274 174 317C198 361 249 413 308 413C346 413 372 402 386 381C355 378 328 358 328 325Z"></path></g><g data-mml-node="mi" data-latex="e" transform="translate(6070,0)"><path data-c="1D452" d="M124 129C124 153 129 186 139 227L188 227C253 227 303 235 339 250C372 264 394 284 405 309C412 326 415 342 415 355C415 410 363 442 307 442C268 442 229 432 190 412C113 372 46 281 46 171C46 69 105-11 204-11C257-11 304 2 345 27C379 48 404 69 420 90C427 99 430 106 430 109C430 120 425 126 414 126C409 126 404 122 398 114C365 70 324 42 277 30C246 22 223 18 206 18C149 18 124 72 124 129M375 355C375 289 311 256 182 256L147 256C166 322 194 366 232 387C262 404 287 413 307 413C343 413 375 391 375 355Z"></path></g></g><rect width="13325.4" height="60" x="120" y="220"></rect></g><g data-mml-node="mo" data-latex="*" transform="translate(18887.2,0)"><path data-c="2217" d="M404 372C397 372 390 370 385 366L267 279L282 425C285 445 269 462 250 462C231 462 215 445 218 425L233 279L115 366C110 370 103 372 96 372C78 372 63 357 63 339C63 325 70 315 83 309L217 250L83 191C70 185 63 175 63 161C63 143 78 128 96 128C103 128 110 130 115 134L233 221L218 75C215 55 231 39 250 39C269 39 285 55 282 75L267 221L385 134C390 130 397 128 404 128C415 128 424 133 431 142C446 162 435 183 417 191L283 250L417 309C430 315 437 325 437 339C437 357 422 372 404 372Z"></path></g><g data-mml-node="mn" data-latex="100" transform="translate(19609.4,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(500,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(1000,0)"></path></g><g data-mml-node="mtext" data-latex="\text{％}" transform="translate(21109.4,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">％</text></g></g></g></svg></mjx-container></li></ul><blockquote><ul><li><p>Slippage for 1st bought (1333.33USDC/ETH) :<br><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true"><svg style="vertical-align: -1.602ex;" xmlns="http://www.w3.org/2000/svg" width="33.426ex" height="4.663ex" role="img" focusable="false" viewBox="0 -1353 14774.4 2061"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="\frac{1333.33-1340}{1340}*100\text{％}= -0.5\text{％}"><g data-mml-node="mfrac" data-latex="\frac{1333.33-1340}{1340}"><g data-mml-node="mrow" data-latex="1333.33-1340" transform="translate(220,676)"><g data-mml-node="mn" data-latex="1333.33"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path><path data-c="33" d="M303 353C369 378 431 441 431 526C431 569 410 604 369 631C333 654 292 666 246 666C201 666 162 654 127 631C88 605 68 571 68 528C68 495 90 472 122 472C154 472 176 495 176 527C176 560 157 578 119 580C145 615 186 633 242 633C302 633 332 598 332 527C332 485 324 450 309 421C282 373 245 364 183 364C171 362 165 357 165 348C165 333 172 333 192 333L235 333C310 333 348 280 348 173C348 88 317 14 241 14C176 14 128 36 99 80C134 79 160 105 160 139C160 173 135 198 101 198C62 198 42 178 42 137C42 88 64 49 108 18C147-9 193-22 244-22C301-22 350-3 393 34C436 71 457 117 457 173C457 267 383 332 303 353Z" transform="translate(500,0)"></path><path data-c="33" d="M303 353C369 378 431 441 431 526C431 569 410 604 369 631C333 654 292 666 246 666C201 666 162 654 127 631C88 605 68 571 68 528C68 495 90 472 122 472C154 472 176 495 176 527C176 560 157 578 119 580C145 615 186 633 242 633C302 633 332 598 332 527C332 485 324 450 309 421C282 373 245 364 183 364C171 362 165 357 165 348C165 333 172 333 192 333L235 333C310 333 348 280 348 173C348 88 317 14 241 14C176 14 128 36 99 80C134 79 160 105 160 139C160 173 135 198 101 198C62 198 42 178 42 137C42 88 64 49 108 18C147-9 193-22 244-22C301-22 350-3 393 34C436 71 457 117 457 173C457 267 383 332 303 353Z" transform="translate(1000,0)"></path><path data-c="33" d="M303 353C369 378 431 441 431 526C431 569 410 604 369 631C333 654 292 666 246 666C201 666 162 654 127 631C88 605 68 571 68 528C68 495 90 472 122 472C154 472 176 495 176 527C176 560 157 578 119 580C145 615 186 633 242 633C302 633 332 598 332 527C332 485 324 450 309 421C282 373 245 364 183 364C171 362 165 357 165 348C165 333 172 333 192 333L235 333C310 333 348 280 348 173C348 88 317 14 241 14C176 14 128 36 99 80C134 79 160 105 160 139C160 173 135 198 101 198C62 198 42 178 42 137C42 88 64 49 108 18C147-9 193-22 244-22C301-22 350-3 393 34C436 71 457 117 457 173C457 267 383 332 303 353Z" transform="translate(1500,0)"></path><path data-c="2E" d="M192 53C192 82 168 106 139 106C110 106 86 82 86 53C86 24 110 0 139 0C168 0 192 24 192 53Z" transform="translate(2000,0)"></path><path data-c="33" d="M303 353C369 378 431 441 431 526C431 569 410 604 369 631C333 654 292 666 246 666C201 666 162 654 127 631C88 605 68 571 68 528C68 495 90 472 122 472C154 472 176 495 176 527C176 560 157 578 119 580C145 615 186 633 242 633C302 633 332 598 332 527C332 485 324 450 309 421C282 373 245 364 183 364C171 362 165 357 165 348C165 333 172 333 192 333L235 333C310 333 348 280 348 173C348 88 317 14 241 14C176 14 128 36 99 80C134 79 160 105 160 139C160 173 135 198 101 198C62 198 42 178 42 137C42 88 64 49 108 18C147-9 193-22 244-22C301-22 350-3 393 34C436 71 457 117 457 173C457 267 383 332 303 353Z" transform="translate(2278,0)"></path><path data-c="33" d="M303 353C369 378 431 441 431 526C431 569 410 604 369 631C333 654 292 666 246 666C201 666 162 654 127 631C88 605 68 571 68 528C68 495 90 472 122 472C154 472 176 495 176 527C176 560 157 578 119 580C145 615 186 633 242 633C302 633 332 598 332 527C332 485 324 450 309 421C282 373 245 364 183 364C171 362 165 357 165 348C165 333 172 333 192 333L235 333C310 333 348 280 348 173C348 88 317 14 241 14C176 14 128 36 99 80C134 79 160 105 160 139C160 173 135 198 101 198C62 198 42 178 42 137C42 88 64 49 108 18C147-9 193-22 244-22C301-22 350-3 393 34C436 71 457 117 457 173C457 267 383 332 303 353Z" transform="translate(2778,0)"></path></g><g data-mml-node="mo" data-latex="-" transform="translate(3500.2,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="mn" data-latex="1340" transform="translate(4500.4,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path><path data-c="33" d="M303 353C369 378 431 441 431 526C431 569 410 604 369 631C333 654 292 666 246 666C201 666 162 654 127 631C88 605 68 571 68 528C68 495 90 472 122 472C154 472 176 495 176 527C176 560 157 578 119 580C145 615 186 633 242 633C302 633 332 598 332 527C332 485 324 450 309 421C282 373 245 364 183 364C171 362 165 357 165 348C165 333 172 333 192 333L235 333C310 333 348 280 348 173C348 88 317 14 241 14C176 14 128 36 99 80C134 79 160 105 160 139C160 173 135 198 101 198C62 198 42 178 42 137C42 88 64 49 108 18C147-9 193-22 244-22C301-22 350-3 393 34C436 71 457 117 457 173C457 267 383 332 303 353Z" transform="translate(500,0)"></path><path data-c="34" d="M353 677C344 677 336 672 330 663L28 199L28 163L289 163L289 81C289 63 285 51 278 46C271 41 252 39 219 39L194 39L194 0C223 2 269 3 331 3C393 3 439 2 468 0L468 39L443 39C410 39 391 41 384 46C377 51 373 63 373 81L373 163L471 163L471 202L373 202L373 660C373 670 366 677 353 677M295 553L295 202L67 202Z" transform="translate(1000,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(1500,0)"></path></g></g><g data-mml-node="mn" data-latex="1340" transform="translate(2470.2,-686)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path><path data-c="33" d="M303 353C369 378 431 441 431 526C431 569 410 604 369 631C333 654 292 666 246 666C201 666 162 654 127 631C88 605 68 571 68 528C68 495 90 472 122 472C154 472 176 495 176 527C176 560 157 578 119 580C145 615 186 633 242 633C302 633 332 598 332 527C332 485 324 450 309 421C282 373 245 364 183 364C171 362 165 357 165 348C165 333 172 333 192 333L235 333C310 333 348 280 348 173C348 88 317 14 241 14C176 14 128 36 99 80C134 79 160 105 160 139C160 173 135 198 101 198C62 198 42 178 42 137C42 88 64 49 108 18C147-9 193-22 244-22C301-22 350-3 393 34C436 71 457 117 457 173C457 267 383 332 303 353Z" transform="translate(500,0)"></path><path data-c="34" d="M353 677C344 677 336 672 330 663L28 199L28 163L289 163L289 81C289 63 285 51 278 46C271 41 252 39 219 39L194 39L194 0C223 2 269 3 331 3C393 3 439 2 468 0L468 39L443 39C410 39 391 41 384 46C377 51 373 63 373 81L373 163L471 163L471 202L373 202L373 660C373 670 366 677 353 677M295 553L295 202L67 202Z" transform="translate(1000,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(1500,0)"></path></g><rect width="6700.4" height="60" x="120" y="220"></rect></g><g data-mml-node="mo" data-latex="*" transform="translate(7162.7,0)"><path data-c="2217" d="M404 372C397 372 390 370 385 366L267 279L282 425C285 445 269 462 250 462C231 462 215 445 218 425L233 279L115 366C110 370 103 372 96 372C78 372 63 357 63 339C63 325 70 315 83 309L217 250L83 191C70 185 63 175 63 161C63 143 78 128 96 128C103 128 110 130 115 134L233 221L218 75C215 55 231 39 250 39C269 39 285 55 282 75L267 221L385 134C390 130 397 128 404 128C415 128 424 133 431 142C446 162 435 183 417 191L283 250L417 309C430 315 437 325 437 339C437 357 422 372 404 372Z"></path></g><g data-mml-node="mn" data-latex="100" transform="translate(7884.9,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(500,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(1000,0)"></path></g><g data-mml-node="mtext" data-latex="\text{％}" transform="translate(9384.9,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">％</text></g><g data-mml-node="mo" data-latex="=" transform="translate(10662.7,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mo" data-latex="-" transform="translate(11718.4,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="mn" data-latex="0.5" transform="translate(12496.4,0)"><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z"></path><path data-c="2E" d="M192 53C192 82 168 106 139 106C110 106 86 82 86 53C86 24 110 0 139 0C168 0 192 24 192 53Z" transform="translate(500,0)"></path><path data-c="35" d="M118 315C123 315 129 319 134 326C164 371 205 393 257 393C292 393 319 373 337 332C348 305 354 264 354 209C354 146 346 102 331 76C306 35 272 14 229 14C162 14 109 62 91 114C94 113 96 114 100 114C130 114 155 137 155 167C155 198 130 219 100 219C65 219 50 200 50 163C50 63 131-22 231-22C292-22 344 0 386 44C428 88 449 141 449 202C449 260 432 310 398 353C361 400 315 423 259 423C212 423 171 408 138 378L138 556C165 548 191 544 218 544C264 544 304 555 338 578C369 597 390 616 402 634C408 642 411 648 411 651C411 661 406 666 396 666C341 645 294 634 256 634C211 634 168 643 127 662C122 664 118 665 114 665C105 665 100 656 100 637L100 345C100 324 100 315 118 315Z" transform="translate(778,0)"></path></g><g data-mml-node="mtext" data-latex="\text{％}" transform="translate(13774.4,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">％</text></g></g></g></svg></mjx-container></p></li><li><p>Slippage for 2nd bought (2USDC/ETH) :</p></li></ul><p><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true"><svg style="vertical-align: -1.602ex;" xmlns="http://www.w3.org/2000/svg" width="28.272ex" height="4.663ex" role="img" focusable="false" viewBox="0 -1353 12496.4 2061"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="\frac{2-1340}{1340} * 100\text{％}=-99.9\text{％}"><g data-mml-node="mfrac" data-latex="\frac{2-1340}{1340}"><g data-mml-node="mrow" data-latex="2-1340" transform="translate(220,676)"><g data-mml-node="mn" data-latex="2"><path data-c="32" d="M237 666C186 666 143 648 106 612C69 576 50 534 50 483C50 449 75 424 106 424C136 424 161 450 161 480C161 513 137 536 105 536C102 536 100 536 98 535C117 584 161 627 224 627C306 627 352 556 352 470C352 403 318 331 250 255L62 43C49 28 50 29 50 0L421 0L450 180L417 180C409 129 402 100 396 91C391 86 361 84 306 84L139 84L236 179C304 243 390 312 419 365C439 400 449 435 449 470C449 588 357 666 237 666Z"></path></g><g data-mml-node="mo" data-latex="-" transform="translate(722.2,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="mn" data-latex="1340" transform="translate(1722.4,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path><path data-c="33" d="M303 353C369 378 431 441 431 526C431 569 410 604 369 631C333 654 292 666 246 666C201 666 162 654 127 631C88 605 68 571 68 528C68 495 90 472 122 472C154 472 176 495 176 527C176 560 157 578 119 580C145 615 186 633 242 633C302 633 332 598 332 527C332 485 324 450 309 421C282 373 245 364 183 364C171 362 165 357 165 348C165 333 172 333 192 333L235 333C310 333 348 280 348 173C348 88 317 14 241 14C176 14 128 36 99 80C134 79 160 105 160 139C160 173 135 198 101 198C62 198 42 178 42 137C42 88 64 49 108 18C147-9 193-22 244-22C301-22 350-3 393 34C436 71 457 117 457 173C457 267 383 332 303 353Z" transform="translate(500,0)"></path><path data-c="34" d="M353 677C344 677 336 672 330 663L28 199L28 163L289 163L289 81C289 63 285 51 278 46C271 41 252 39 219 39L194 39L194 0C223 2 269 3 331 3C393 3 439 2 468 0L468 39L443 39C410 39 391 41 384 46C377 51 373 63 373 81L373 163L471 163L471 202L373 202L373 660C373 670 366 677 353 677M295 553L295 202L67 202Z" transform="translate(1000,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(1500,0)"></path></g></g><g data-mml-node="mn" data-latex="1340" transform="translate(1081.2,-686)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path><path data-c="33" d="M303 353C369 378 431 441 431 526C431 569 410 604 369 631C333 654 292 666 246 666C201 666 162 654 127 631C88 605 68 571 68 528C68 495 90 472 122 472C154 472 176 495 176 527C176 560 157 578 119 580C145 615 186 633 242 633C302 633 332 598 332 527C332 485 324 450 309 421C282 373 245 364 183 364C171 362 165 357 165 348C165 333 172 333 192 333L235 333C310 333 348 280 348 173C348 88 317 14 241 14C176 14 128 36 99 80C134 79 160 105 160 139C160 173 135 198 101 198C62 198 42 178 42 137C42 88 64 49 108 18C147-9 193-22 244-22C301-22 350-3 393 34C436 71 457 117 457 173C457 267 383 332 303 353Z" transform="translate(500,0)"></path><path data-c="34" d="M353 677C344 677 336 672 330 663L28 199L28 163L289 163L289 81C289 63 285 51 278 46C271 41 252 39 219 39L194 39L194 0C223 2 269 3 331 3C393 3 439 2 468 0L468 39L443 39C410 39 391 41 384 46C377 51 373 63 373 81L373 163L471 163L471 202L373 202L373 660C373 670 366 677 353 677M295 553L295 202L67 202Z" transform="translate(1000,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(1500,0)"></path></g><rect width="3922.4" height="60" x="120" y="220"></rect></g><g data-mml-node="mo" data-latex="*" transform="translate(4384.7,0)"><path data-c="2217" d="M404 372C397 372 390 370 385 366L267 279L282 425C285 445 269 462 250 462C231 462 215 445 218 425L233 279L115 366C110 370 103 372 96 372C78 372 63 357 63 339C63 325 70 315 83 309L217 250L83 191C70 185 63 175 63 161C63 143 78 128 96 128C103 128 110 130 115 134L233 221L218 75C215 55 231 39 250 39C269 39 285 55 282 75L267 221L385 134C390 130 397 128 404 128C415 128 424 133 431 142C446 162 435 183 417 191L283 250L417 309C430 315 437 325 437 339C437 357 422 372 404 372Z"></path></g><g data-mml-node="mn" data-latex="100" transform="translate(5106.9,0)"><path data-c="31" d="M269 666C228 624 168 603 89 603L89 564C141 564 184 572 217 588L217 82C217 64 213 52 204 47C195 42 170 39 130 39L95 39L95 0C120 2 174 3 257 3C340 3 394 2 419 0L419 39L384 39C343 39 318 42 310 47C302 52 297 64 297 82L297 636C297 660 295 666 269 666Z"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(500,0)"></path><path data-c="30" d="M249-22C390-22 460 92 460 320C460 473 428 575 365 625C330 652 291 666 250 666C109 666 39 551 39 320C39 136 88-22 249-22M361 524C368 489 371 425 371 332C371 240 367 172 360 128C347 48 310 8 249 8C226 8 203 17 182 34C155 57 139 104 132 176C129 201 128 253 128 332C128 419 131 480 136 513C145 568 163 603 191 618C213 630 232 636 249 636C314 636 350 583 361 524Z" transform="translate(1000,0)"></path></g><g data-mml-node="mtext" data-latex="\text{％}" transform="translate(6606.9,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">％</text></g><g data-mml-node="mo" data-latex="=" transform="translate(7884.7,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mo" data-latex="-" transform="translate(8940.4,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="mn" data-latex="99.9" transform="translate(9718.4,0)"><path data-c="39" d="M116 140C83 140 67 123 67 89C67 14 128-22 207-22C287-22 351 18 398 99C437 166 457 243 457 329C457 456 434 546 388 599C349 644 304 666 253 666C194 666 145 645 106 602C63 557 42 503 42 440C42 379 60 327 96 284C134 238 183 215 242 215C294 215 334 243 361 299L361 286C361 177 342 103 303 63C272 30 239 14 206 14C166 14 137 23 118 42C149 42 165 60 165 91C165 119 144 140 116 140M243 246C204 246 175 266 155 306C144 329 138 374 138 439C138 504 145 548 158 573C180 613 212 633 253 633C294 633 324 608 343 558C354 531 361 485 361 420C361 333 322 246 243 246Z"></path><path data-c="39" d="M116 140C83 140 67 123 67 89C67 14 128-22 207-22C287-22 351 18 398 99C437 166 457 243 457 329C457 456 434 546 388 599C349 644 304 666 253 666C194 666 145 645 106 602C63 557 42 503 42 440C42 379 60 327 96 284C134 238 183 215 242 215C294 215 334 243 361 299L361 286C361 177 342 103 303 63C272 30 239 14 206 14C166 14 137 23 118 42C149 42 165 60 165 91C165 119 144 140 116 140M243 246C204 246 175 266 155 306C144 329 138 374 138 439C138 504 145 548 158 573C180 613 212 633 253 633C294 633 324 608 343 558C354 531 361 485 361 420C361 333 322 246 243 246Z" transform="translate(500,0)"></path><path data-c="2E" d="M192 53C192 82 168 106 139 106C110 106 86 82 86 53C86 24 110 0 139 0C168 0 192 24 192 53Z" transform="translate(1000,0)"></path><path data-c="39" d="M116 140C83 140 67 123 67 89C67 14 128-22 207-22C287-22 351 18 398 99C437 166 457 243 457 329C457 456 434 546 388 599C349 644 304 666 253 666C194 666 145 645 106 602C63 557 42 503 42 440C42 379 60 327 96 284C134 238 183 215 242 215C294 215 334 243 361 299L361 286C361 177 342 103 303 63C272 30 239 14 206 14C166 14 137 23 118 42C149 42 165 60 165 91C165 119 144 140 116 140M243 246C204 246 175 266 155 306C144 329 138 374 138 439C138 504 145 548 158 573C180 613 212 633 253 633C294 633 324 608 343 558C354 531 361 485 361 420C361 333 322 246 243 246Z" transform="translate(1278,0)"></path></g><g data-mml-node="mtext" data-latex="\text{％}" transform="translate(11496.4,0)"><text data-variant="normal" transform="scale(1,-1)" font-size="884px" font-family="serif">％</text></g></g></g></svg></mjx-container></p></blockquote></li></ul><p>Slippage is a key matric that tells you how cost-effective the transaction is.</p></li><li><p><strong>Liquidity</strong></p><p>x·y=k, Liquidity=√k</p></li><li><p><strong>Liquidity provider (LP)</strong></p><p>Sometimes you may hear someone says “I earned a lot doing LP” , it means being a liquidity provider putting your tokens in pool for lending them to borrowers , you’ll get interest.</p><ul><li><p>Add liquidity</p><ul><li><p>First add: tokens’ price are got from chain-net</p></li><li><p>After first add: tokens’ price are not got from chain-net, price keep with equation<br><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true"><svg style="vertical-align: -2.016ex;" xmlns="http://www.w3.org/2000/svg" width="12.647ex" height="5.115ex" role="img" focusable="false" viewBox="0 -1370 5590 2261"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="\frac{x+dy}{y+dy}=\frac{x}{y}"><g data-mml-node="mfrac" data-latex="\frac{x+dy}{y+dy}"><g data-mml-node="mrow" data-latex="x+dy" transform="translate(220,676)"><g data-mml-node="mi" data-latex="x"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mo" data-latex="+" transform="translate(794.2,0)"><path data-c="2B" d="M698 274L413 274L413 559C413 575 405 583 389 583C373 583 365 575 365 559L365 274L80 274C64 274 56 266 56 250C56 234 64 226 80 226L365 226L365-59C365-75 373-83 389-83C405-83 413-75 413-59L413 226L698 226C714 226 722 234 722 250C722 263 711 274 698 274Z"></path></g><g data-mml-node="mi" data-latex="d" transform="translate(1794.4,0)"><path data-c="1D451" d="M429 632L370 389C349 426 320 445 281 445C216 445 159 412 109 345C63 283 40 218 40 151C40 63 91-11 175-11C218-11 260 12 300 59C311 21 345-11 392-11C461-11 483 71 498 145C498 154 493 159 483 159C474 159 468 152 465 138C445 59 421 19 394 19C377 19 368 33 368 60C368 75 370 91 374 107L516 679L516 683C513 690 507 694 499 694C476 694 434 690 374 683C363 682 357 674 357 660C357 650 366 645 384 645C403 645 429 646 429 632M341 376C351 355 356 341 356 332C355 328 354 323 353 316L304 122C301 111 294 99 285 87C248 42 212 19 177 19C138 19 118 49 118 108C118 132 124 168 136 216C157 301 187 359 224 390C244 407 263 415 282 415C309 415 329 402 341 376Z"></path></g><g data-mml-node="mi" data-latex="y" transform="translate(2314.4,0)"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g></g><g data-mml-node="mrow" data-latex="y+dy" transform="translate(261,-686)"><g data-mml-node="mi" data-latex="y"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><g data-mml-node="mo" data-latex="+" transform="translate(712.2,0)"><path data-c="2B" d="M698 274L413 274L413 559C413 575 405 583 389 583C373 583 365 575 365 559L365 274L80 274C64 274 56 266 56 250C56 234 64 226 80 226L365 226L365-59C365-75 373-83 389-83C405-83 413-75 413-59L413 226L698 226C714 226 722 234 722 250C722 263 711 274 698 274Z"></path></g><g data-mml-node="mi" data-latex="d" transform="translate(1712.4,0)"><path data-c="1D451" d="M429 632L370 389C349 426 320 445 281 445C216 445 159 412 109 345C63 283 40 218 40 151C40 63 91-11 175-11C218-11 260 12 300 59C311 21 345-11 392-11C461-11 483 71 498 145C498 154 493 159 483 159C474 159 468 152 465 138C445 59 421 19 394 19C377 19 368 33 368 60C368 75 370 91 374 107L516 679L516 683C513 690 507 694 499 694C476 694 434 690 374 683C363 682 357 674 357 660C357 650 366 645 384 645C403 645 429 646 429 632M341 376C351 355 356 341 356 332C355 328 354 323 353 316L304 122C301 111 294 99 285 87C248 42 212 19 177 19C138 19 118 49 118 108C118 132 124 168 136 216C157 301 187 359 224 390C244 407 263 415 282 415C309 415 329 402 341 376Z"></path></g><g data-mml-node="mi" data-latex="y" transform="translate(2232.4,0)"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g></g><rect width="3004.4" height="60" x="120" y="220"></rect></g><g data-mml-node="mo" data-latex="=" transform="translate(3522.2,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mfrac" data-latex="\frac{x}{y}" transform="translate(4578,0)"><g data-mml-node="mi" data-latex="x" transform="translate(220,676)"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mi" data-latex="y" transform="translate(261,-686)"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><rect width="772" height="60" x="120" y="220"></rect></g></g></g></svg></mjx-container></p></li></ul></li><li><p>Excess liquidity</p><ul><li>tokens’ price are not got from chain-net, price keep with equation<br><mjx-container class="MathJax" jax="SVG" overflow="overflow" display="true"><svg style="vertical-align: -2.016ex;" xmlns="http://www.w3.org/2000/svg" width="12.647ex" height="5.115ex" role="img" focusable="false" viewBox="0 -1370 5590 2261"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math" data-latex="\frac{x-dy}{y-dy}=\frac{x}{y}"><g data-mml-node="mfrac" data-latex="\frac{x-dy}{y-dy}"><g data-mml-node="mrow" data-latex="x-dy" transform="translate(220,676)"><g data-mml-node="mi" data-latex="x"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mo" data-latex="-" transform="translate(794.2,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="mi" data-latex="d" transform="translate(1794.4,0)"><path data-c="1D451" d="M429 632L370 389C349 426 320 445 281 445C216 445 159 412 109 345C63 283 40 218 40 151C40 63 91-11 175-11C218-11 260 12 300 59C311 21 345-11 392-11C461-11 483 71 498 145C498 154 493 159 483 159C474 159 468 152 465 138C445 59 421 19 394 19C377 19 368 33 368 60C368 75 370 91 374 107L516 679L516 683C513 690 507 694 499 694C476 694 434 690 374 683C363 682 357 674 357 660C357 650 366 645 384 645C403 645 429 646 429 632M341 376C351 355 356 341 356 332C355 328 354 323 353 316L304 122C301 111 294 99 285 87C248 42 212 19 177 19C138 19 118 49 118 108C118 132 124 168 136 216C157 301 187 359 224 390C244 407 263 415 282 415C309 415 329 402 341 376Z"></path></g><g data-mml-node="mi" data-latex="y" transform="translate(2314.4,0)"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g></g><g data-mml-node="mrow" data-latex="y-dy" transform="translate(261,-686)"><g data-mml-node="mi" data-latex="y"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><g data-mml-node="mo" data-latex="-" transform="translate(712.2,0)"><path data-c="2212" d="M698 270L80 270C64 270 56 263 56 250C56 237 64 230 80 230L698 230C714 230 722 237 722 250C722 262 710 270 698 270Z"></path></g><g data-mml-node="mi" data-latex="d" transform="translate(1712.4,0)"><path data-c="1D451" d="M429 632L370 389C349 426 320 445 281 445C216 445 159 412 109 345C63 283 40 218 40 151C40 63 91-11 175-11C218-11 260 12 300 59C311 21 345-11 392-11C461-11 483 71 498 145C498 154 493 159 483 159C474 159 468 152 465 138C445 59 421 19 394 19C377 19 368 33 368 60C368 75 370 91 374 107L516 679L516 683C513 690 507 694 499 694C476 694 434 690 374 683C363 682 357 674 357 660C357 650 366 645 384 645C403 645 429 646 429 632M341 376C351 355 356 341 356 332C355 328 354 323 353 316L304 122C301 111 294 99 285 87C248 42 212 19 177 19C138 19 118 49 118 108C118 132 124 168 136 216C157 301 187 359 224 390C244 407 263 415 282 415C309 415 329 402 341 376Z"></path></g><g data-mml-node="mi" data-latex="y" transform="translate(2232.4,0)"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g></g><rect width="3004.4" height="60" x="120" y="220"></rect></g><g data-mml-node="mo" data-latex="=" transform="translate(3522.2,0)"><path data-c="3D" d="M698 367L80 367C64 367 56 359 56 344C56 329 64 321 80 321L698 321C714 321 722 329 722 344C722 356 711 367 698 367M698 179L80 179C64 179 56 171 56 156C56 141 64 133 80 133L698 133C714 133 722 141 722 156C722 169 711 179 698 179Z"></path></g><g data-mml-node="mfrac" data-latex="\frac{x}{y}" transform="translate(4578,0)"><g data-mml-node="mi" data-latex="x" transform="translate(220,676)"><path data-c="1D465" d="M527 373C527 419 482 442 432 442C389 442 355 419 329 373C308 419 273 442 222 442C173 442 133 419 101 374C74 335 60 306 60 287C60 278 65 273 75 273C84 273 90 278 92 287C111 345 153 413 220 413C253 413 269 392 269 351C269 330 251 252 216 118C199 51 169 18 126 18C112 18 99 21 88 26C114 36 127 54 127 80C127 106 114 119 87 119C54 119 29 91 29 58C29 12 76-11 125-11C167-11 201 12 228 58C247 12 283-11 335-11C383-11 423 12 455 57C482 96 496 125 496 144C496 153 491 158 481 158C472 158 467 153 464 144C447 87 402 18 337 18C304 18 287 38 287 79C287 92 292 120 303 165L337 300C356 375 387 413 431 413C445 413 458 410 469 405C442 396 429 378 429 351C429 325 443 312 470 312C502 312 527 341 527 373Z"></path></g><g data-mml-node="mi" data-latex="y" transform="translate(261,-686)"><path data-c="1D466" d="M163 442C118 442 83 417 58 367C39 328 29 301 29 286C29 277 34 272 45 272C59 272 60 278 64 293C87 372 119 412 160 412C173 412 180 403 180 385C180 369 175 346 164 317C126 214 107 145 107 108C107 32 154-13 231-13C264-13 295-1 323 23C288-109 233-175 158-175C124-175 101-164 89-142C129-140 149-121 149-85C149-60 136-47 109-47C72-47 50-78 50-115C50-170 100-205 158-205C273-205 367-99 392-1L486 377C489 388 490 396 490 401C490 421 479 431 458 431C442 431 429 423 420 408C414 387 409 369 406 354L342 97C332 61 279 16 234 16C196 16 177 41 177 92C177 134 194 198 227 284C240 319 247 343 247 357C247 406 212 442 163 442Z"></path></g><rect width="772" height="60" x="120" y="220"></rect></g></g></g></svg></mjx-container></li></ul></li><li><blockquote><p>No matter add or excess, the key principle is to don’t affect the price in pool</p></blockquote></li></ul></li></ul><hr><p><strong>Advice for investors</strong></p><ol><li><p>Check the real‑time slippage first, then decide whether to trade</p></li><li><p>If you’re a whale, choose a larger pool</p></li></ol>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;All swapping pools between two currncies mostly base on the &lt;strong&gt;x·y=k&lt;/strong&gt; equation. Usually, x: number of TokenA, y: number of T</summary>
      
    
    
    
    
    <category term="tech" scheme="http://example.com/tags/tech/"/>
    
  </entry>
  
  <entry>
    <title>UUPS and transparent proxy</title>
    <link href="http://example.com/2026/04/14/TransparentUpgradeableProxy/"/>
    <id>http://example.com/2026/04/14/TransparentUpgradeableProxy/</id>
    <published>2026-04-14T08:12:32.000Z</published>
    <updated>2026-10-18T08:35:25.850Z</updated>
    
    <content type="html"><![CDATA[<p><strong>UUPS</strong></p><div style="text-align: center;">  <img src="https://pic1.zhimg.com/v2-df1a25fb069c7c31cc524f257c4e10d8_r.jpg" style="width: 70%; max-width: 600px; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.4);"></div><p>We chose UUPS over the transparent proxy because UUPS puts the upgrade logic in the implementation contract, which makes the proxy smaller and cheaper on gas. The tradeoff is that the implementation must inherit <code>UUPSUpgradeable</code> and implement <code>_authorizeUpgrade</code>.</p><hr><p><strong>transparent proxy</strong></p><div style="text-align: center;">  <img src="https://pic4.zhimg.com/v2-4d0596ffccfbb8475a387d5fcdc5add7_r.jpg" style="width: 70%; max-width: 600px; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.4);"></div>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;&lt;strong&gt;UUPS&lt;/strong&gt;&lt;/p&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
  &lt;img src=&quot;https://pic1.zhimg.com/v2-df1a25fb069c7c31cc524f257c4e10d8_r.jpg&quot;</summary>
      
    
    
    
    
    <category term="tech" scheme="http://example.com/tags/tech/"/>
    
  </entry>
  
  <entry>
    <title>Thought sparked by my friend Erpan</title>
    <link href="http://example.com/2026/04/04/2026-04-05/"/>
    <id>http://example.com/2026/04/04/2026-04-05/</id>
    <published>2026-04-04T16:00:00.000Z</published>
    <updated>2026-10-18T08:35:25.850Z</updated>
    
    <content type="html"><![CDATA[<p>I was confusing about some things happened recently, driving around but nowhere to go. I texted Erpan , a good buddy of mine. He said he drunk , then I drove to where he is and picked him up. This night, this alcoholic guy’s words blew my mind:</p><blockquote><p>我们还是要往前看，或许，还会如你所愿，或许，超乎你的预期。从一无所有到如今的如你希望，本身就是这道题的答案，事情只能还会更好，明天永远值得期待。</p></blockquote><p>Sure.</p>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;I was confusing about some things happened recently, driving around but nowhere to go. I texted Erpan , a good buddy of mine. He said he </summary>
      
    
    
    
    
    <category term="thoughts" scheme="http://example.com/tags/thoughts/"/>
    
  </entry>
  
  <entry>
    <title>MQ</title>
    <link href="http://example.com/2026/02/01/mq/"/>
    <id>http://example.com/2026/02/01/mq/</id>
    <published>2026-02-01T12:07:23.000Z</published>
    <updated>2026-10-18T08:35:25.850Z</updated>
    
    <content type="html"><![CDATA[<p>I think MQ is a genuis solution of non-real-time data requests between systems, especially in distributed systems for e-commerce, finance, big data. Here I am going to document some of my thoughts on MQ.</p><hr><p>Most of typical financial process systems, the first level system which directly access by user and submit their financial applications , the financing request goes through several systems will eventually reach to bank center to do payment / settlement – subtract / addition of account money,  between each of them, MQ plays a crucial role to ensure the reliability of the entire system via decoupling , traffic peaking, asynchronizing.</p><div style="max-width:800px;margin:auto">  <div style="display:flex;justify-content:center;align-items:center;margin-top:60px;background:#1a1a1a;padding:40px;border-radius:12px">    <div style="background:#3498db;color:white;width:180px;height:80px;border-radius:6px;display:flex;flex-direction:column;justify-content:center;align-items:center;box-shadow:0 3px 6px rgba(0,0,0,0.3);font-weight:bold">      <span style="font-size:14px;margin-top:5px;text-align:center">User TRade Financial Application</span>    </div>    <div style="font-size:14px;margin:0 20px;color:#cccccc">→<span style="font-size:14px;">MQ</span>→</div>    <div style="background:#f39c12;color:white;width:180px;height:80px;border-radius:6px;display:flex;flex-direction:column;justify-content:center;align-items:center;box-shadow:0 3px 6px rgba(0,0,0,0.3);font-weight:bold">      <span style="font-size:14px;margin-top:5px;text-align:center">Verification & Approving System</span>    </div>    <div style="font-size:14px;margin:0 20px;color:#cccccc">→<span style="font-size:14px;">MQ</span>→</div>    <div style="background:#2ecc71;color:white;width:180px;height:80px;border-radius:6px;display:flex;flex-direction:column;justify-content:center;align-items:center;box-shadow:0 3px 6px rgba(0,0,0,0.3);font-weight:bold">      <span style="font-size:14px;margin-top:5px;text-align:center">Bank Center System</span>    </div>  </div></div><p>In Apache RocketMQ, there are usually <strong>three message sending modes</strong> we are using:</p><ol><li><p>Synchronous send</p><p>the <code>producer.sendMessage()</code> code line wait there til the broker receives the message and returns a confirmation. This mode offers a good reliability.</p></li><li><p>Asynchronous send</p><p>the <code>producer.sendMessage()</code> code line won’t be blocked, means I just need to send the message out , and continue to run , don’t block. So there is always a callback, is provided to handle the send result (success or exception) asynchronously. Very applies to High-throughput scenarios where low-latency is needed , but delivery assurance is still important.</p></li><li><p>One-way send</p><p>just only to send out the message, but i don’t care about whether it received. Typical features : no return , no callback.</p></li><li><p>Ordered messages</p><p>If the consumer needs to receive messages as the order that they were sent, usually use the orderd message mode that implemented by sending only 1 message queue in a topic.</p></li><li><p>Delayed message</p><p>Send message after a certain time.</p></li><li><p>Transactional message</p><p>A bit complex, but it can be a very elegant and ingenious solution for handling time out orders without payment. (will write a essay to record if I got spare time)</p></li></ol><p>The above methods are relatively easy to be implemented, by an everage programmer. I prefer to dive into its design.</p><p><strong>This is the figure of Rocket-MQ :</strong></p><div align="center">  <img src="https://pic1.zhimg.com/80/v2-79d63a48746b81bed6fb20769f7cfecc_1440w.webp?source=d16d100b" width="80%"><div><p><strong>NameServer</strong>:  think of it as kind of DNS for producers and consumers , brokers register themselves with nameservers, producers query nameservers to find which brokers host which topics, usually we implement multiple nameservers and they don’t need to sync up each other (eventually consistent) .</p><p><strong>Broker</strong>:  imagine as a “post office” , producer send message from left side, consumer receive from right side. Broker persists messages to disk, maintains manages topics and their message queues.</p><blockquote style="text-align: left;">  <h3>How do they work together ?</h3>  1. Broker → Nameserver: "Hi, I'm Broker-A hosting Topic-1, Topic-2"<br>  2. Producer → Nameserver: "Where's Topic-1?"<br>  3. Nameserver → Producer: "Broker-A has it at 192.168.1.10:10911"<br>  4. Producer → Broker-A: Sends messages to Topic-1</blockquote>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;I think MQ is a genuis solution of non-real-time data requests between systems, especially in distributed systems for e-commerce, finance</summary>
      
    
    
    
    
    <category term="tech" scheme="http://example.com/tags/tech/"/>
    
  </entry>
  
  <entry>
    <title>A dramatic story of tech tinkering with DB performance</title>
    <link href="http://example.com/2026/01/28/practical-experience-DB/"/>
    <id>http://example.com/2026/01/28/practical-experience-DB/</id>
    <published>2026-01-28T02:41:01.000Z</published>
    <updated>2026-10-18T08:35:25.852Z</updated>
    
    <content type="html"><![CDATA[<p>A business originally starts with a smaller code project, usually with monolithic architecture. Through the ongoing maintenance over a time, SQLs uprises little by little, eventually，the main direction of queries are likely to incline a certain pattern or trend. for much better understanding, let me explain with a story.</p><hr><p>[ Jan 2026 ]</p><p>First release of the project went online, the product received positive feedback and users are increasing.</p><center>↓</center>  <p>[ Aug 2026 ]</p><p>A good news is, daily active users surpassed 300, users’ data in DB is growing exponentially.  The bed one is,  DB’s performance is declining. As the SQL monitor, following SQLs are the most frequently called:</p><table style="    border: 1px solid rgba(255, 255, 255, 0.3);    border-collapse: collapse;    background-color: rgba(255, 255, 255, 0.05);    backdrop-filter: blur(10px);    border-radius: 6px;    overflow: hidden;    min-width: 700px;">  <tr>    <td style="        border-right: 1px solid rgba(255, 255, 255, 0.3);        border-bottom: 1px solid rgba(255, 255, 255, 0.3);        padding: 12px 20px;        color: #79c0ff;        font-weight: 600;        font-size: 14px;        font-family: -apple-system, BlinkMacSystemFont, sans-serif;    ">        SQL    </td>    <td style="        border-right: 1px solid rgba(255, 255, 255, 0.3);        border-bottom: 1px solid rgba(255, 255, 255, 0.3);        padding: 12px 20px;        color: #3fb950;        font-weight: 600;        font-size: 14px;        font-family: -apple-system, BlinkMacSystemFont, sans-serif;        text-align: center;    ">        Time spend (ms)    </td>    <td style="        border-bottom: 1px solid rgba(255, 255, 255, 0.3);        padding: 12px 20px;        color: #ff7b72;        font-weight: 600;        font-size: 14px;        font-family: -apple-system, BlinkMacSystemFont, sans-serif;        text-align: center;    ">        query rate per day    </td>  </tr>  <tr>      <td style="          border-right: 1px solid rgba(255, 255, 255, 0.3);          padding: 20px;          color: #7ee787;          font-family: 'SF Mono', Monaco, monospace;          font-size: 13px;          line-height: 1.5;          vertical-align: top;      ">          <div style="color: #79c0ff;">select *</div>          <div style="margin-left: 20px;">from <span style="color: #ff7b72;">transaction</span></div>          <div style="margin-left: 20px;">where <span style="color: #79c0ff;">customer_ref</span> = #{custRef}</div>          <div style="margin-left: 40px;">and <span style="color: #79c0ff;">deleted</span> = 0;</div>      </td>      <td style="          border-right: 1px solid rgba(255, 255, 255, 0.3);          padding: 20px;          color: #e6edf3;          vertical-align: middle;          text-align: center;      ">          <div style="              font-size: 28px;               color: #3fb950;               font-weight: bold;          ">              980ms          </div>      </td>      <td style="          padding: 20px;          color: #e6edf3;          vertical-align: middle;          text-align: center;      ">          <div style="              font-size: 28px;               color: #ff7b72;               font-weight: bold;          ">              33%          </div>      </td>  </tr>  <tr>      <td style="          border-right: 1px solid rgba(255, 255, 255, 0.3);          padding: 20px;          color: #7ee787;          font-family: 'SF Mono', Monaco, monospace;          font-size: 13px;          line-height: 1.5;          vertical-align: top;      ">        <div style="color: #79c0ff;">select *</div>        <div style="margin-left: 20px;">from <span style="color: #ff7b72;">transaction</span></div>        <div style="margin-left: 20px;">where <span style="color: #79c0ff;">customer_ref</span> = #{custRef}</div>        <div style="margin-left: 40px;">and <span style="color: #79c0ff;">org</span> = #{org}</div>        <div style="margin-left: 40px;">and <span style="color: #79c0ff;">country </span>= #{country}</div>        <div style="margin-left: 40px;">and <span style="color: #79c0ff;">deleted</span> = 0;</div>      </td>      <td style="          border-right: 1px solid rgba(255, 255, 255, 0.3);          padding: 20px;          color: #e6edf3;          vertical-align: middle;          text-align: center;      ">          <div style="              font-size: 28px;               color: #3fb950;               font-weight: bold;          ">              1100ms          </div>      </td>      <td style="          padding: 20px;          color: #e6edf3;          vertical-align: middle;          text-align: center;      ">          <div style="              font-size: 28px;               color: #ff7b72;               font-weight: bold;          ">              18%          </div>      </td>  </tr></table>1st SQL seemingly is easy to optimize, give it an index can be enhanced a lot (the value of \`customer_ref\` sufficiently diverse, of high cardinality). But, this is only solution of 1st SQL, we also have to account for 2nd SQL. Over the business, a composite index would be more appropriate for this scenario. users only can query theirown transactions, org and country usually of course somehow can get if you have the customer ref, or it's usually available in login user's context, it's all depends on business design, okay then let's say that exactly is how our business logic works,  then the index should be composited by three fields : `idx_country_org_cust_ref`. Let both query use 2nd SQL, abosolutely can be sure to they both follow the Leftmost Prefix rule , execution time reduced to 50ms. <div style="margin-top: 25px; padding: 15px; background: #2d3748; border-radius: 6px; border-left: 4px solid #4CAF50; font-size: 13px; color: #e2e8f0; text-align: left;">    <div style="font-weight: bold; margin-bottom: 10px; color: #ffffff; font-size: 14px;">Question：</div>    <div style="margin-bottom: 15px; padding: 10px; background: rgba(255,255,255,0.05); border-radius: 4px;">        • Why don't add indexes `idx_country_org_cust_ref`, `idx_customer_ref` respectively ?    </div>    <div style="padding: 10px; background: rgba(76, 175, 80, 0.1); border-radius: 4px; border-left: 3px solid #4CAF50;">        We usually avoid this approach bcz it increases the overhead of update and insert , we should avoid maintaining multiple indexes for a single update or insert , whenever possible.    </div></div><p><br>The main idea is to handle over 80% queries via very less composited indexes , then use very less secondary indexes to cover the remaining non-typical queries as possible.</p><hr><center>↓</center>  <p>[ Nov 2026 ]</p><p>The date is now Nov 2026. slow SQLs mostly adjusted, we’ve done all we can do. Due to the exponentially growing user base and their visits , performance hit a bottleneck, again. Now SQL optimization is no longer a silver bullet as it used to be, then we consider <strong>read / write splitting</strong> to split the load.</p><div style="text-align: center; font-family: 'Segoe UI', system-ui, sans-serif; padding: 30px; background: #1a1d29; border-radius: 12px; max-width: 500px; margin: 0 auto; border: 1px solid #2d3748;">  <div style="margin-bottom: 15px;">    <div style="      display: inline-block;      background: linear-gradient(145deg, #2d3748, #1a202c);      border: 1.5px solid #48bb78;      border-radius: 10px;      padding: 8px 25px;      box-shadow: 0 8px 25px rgba(72, 187, 120, 0.15);    ">      <div style="font-size: 32px; color: #48bb78; margin-bottom: 10px;">      <svg width="24" height="24" viewBox="0 0 24 24" style="display: inline-block;">            <rect x="3" y="3" width="18" height="18" rx="2" fill="#4299e1" opacity="0.2"/>            <rect x="5" y="5" width="14" height="4" rx="1" fill="#4299e1"/>            <rect x="5" y="11" width="14" height="4" rx="1" fill="#4299e1"/>            <rect x="5" y="17" width="14" height="4" rx="1" fill="#4299e1"/>          </svg>      </div>      <div style="font-weight: bold; color: #48bb78; font-size: 15px;">MASTER</div>      <div style="font-size: 12px; color: #a0aec0; margin-top: 4px; letter-spacing: 0.5px;">Primary (Read/Write)</div>    </div>  </div>  <div style="margin: 0 auto 20px; width: 1.5px; height: 40px; background: linear-gradient(to bottom, #48bb78, #4299e1, #4299e1); position: relative;">    <div style="position: absolute; bottom: -8px; left: -4px; width: 10px; height: 10px; border-bottom: 2px solid #4299e1; border-right: 2px solid #4299e1; transform: rotate(45deg);"></div>  </div>  <div style="font-size: 11px; color: #718096; margin-bottom: 15px; letter-spacing: 1px; text-transform: uppercase;">Replication ↓</div>  <div style="display: flex; justify-content: center; gap: 70px;">    <div>      <div style="        background: linear-gradient(145deg, #2d3748, #1a202c);        border: 1.5px solid #4299e1;        border-radius: 8px;        padding: 8px 20px;        box-shadow: 0 6px 20px rgba(66, 153, 225, 0.12);        transition: transform 0.2s;      " onmouseover="this.style.transform='translateY(-3px)'" onmouseout="this.style.transform='translateY(0)'">        <div style="font-size: 26px; color: #4299e1; margin-bottom: 8px;">          <svg width="24" height="24" viewBox="0 0 24 24" style="display: inline-block;">            <rect x="3" y="3" width="18" height="18" rx="2" fill="#4299e1" opacity="0.2"/>            <rect x="5" y="5" width="14" height="4" rx="1" fill="#4299e1"/>            <rect x="5" y="11" width="14" height="4" rx="1" fill="#4299e1"/>            <rect x="5" y="17" width="14" height="4" rx="1" fill="#4299e1"/>          </svg>        </div>        <div style="font-weight: bold; color: #4299e1; font-size: 14px;">SLAVE 01</div>        <div style="font-size: 11px; color: #a0aec0; margin-top: 3px;">Read Replica</div>      </div>    </div>    <div>      <div style="        background: linear-gradient(145deg, #2d3748, #1a202c);        border: 1.5px solid #4299e1;        border-radius: 8px;        padding: 8px 20px;        box-shadow: 0 6px 20px rgba(66, 153, 225, 0.12);        transition: transform 0.2s;      " onmouseover="this.style.transform='translateY(-3px)'" onmouseout="this.style.transform='translateY(0)'">        <div style="font-size: 26px; color: #4299e1; margin-bottom: 8px;">        <svg width="24" height="24" viewBox="0 0 24 24" style="display: inline-block;">            <rect x="3" y="3" width="18" height="18" rx="2" fill="#4299e1" opacity="0.2"/>            <rect x="5" y="5" width="14" height="4" rx="1" fill="#4299e1"/>            <rect x="5" y="11" width="14" height="4" rx="1" fill="#4299e1"/>            <rect x="5" y="17" width="14" height="4" rx="1" fill="#4299e1"/>          </svg>        </div>        <div style="font-weight: bold; color: #4299e1; font-size: 14px;">SLAVE 02</div>        <div style="font-size: 11px; color: #a0aec0; margin-top: 3px;">Read Replica</div>      </div>    </div>  </div>  <div style="margin-top: 35px; display: flex; justify-content: center; gap: 20px; font-size: 12px;">    <div style="display: flex; align-items: center;">      <div style="width: 10px; height: 10px; background: #48bb78; border-radius: 50%; margin-right: 8px;"></div>      <span style="color: #cbd5e0;">Master Active</span>    </div>    <div style="display: flex; align-items: center;">      <div style="width: 10px; height: 10px; background: #4299e1; border-radius: 50%; margin-right: 8px;"></div>      <span style="color: #cbd5e0;">Slave Synced</span>    </div>  </div></div>We decided master-slaves architecture comprising 1 master and 2 slaves. Route all read traffic to slaves , and all write traffic to the master.<div style="margin-top: 25px; padding: 15px; background: #2d3748; border-radius: 6px; border-left: 4px solid #4CAF50; font-size: 13px; color: #e2e8f0; text-align: left;">    <div style="font-weight: bold; margin-bottom: 10px; color: #ffffff; font-size: 14px;">Access Control Pattern</div>    <div style="margin-bottom: 15px; padding: 10px; background: rgba(255,255,255,0.05); border-radius: 4px;">        • Why don't add indexes `idx_country_org_cust_ref`, `idx_customer_ref` respectively ?    </div>    <div style="padding: 10px; background: rgba(76, 175, 80, 0.1); border-radius: 4px; border-left: 3px solid #4CAF50;">        We usually avoid this approach bcz it increases the overhead of update and insert , we should avoid maintaining multiple indexes for a single update or insert , whenever possible.    </div>  <div style="margin-bottom: 15px; padding: 10px; background: rgba(255,255,255,0.05); border-radius: 4px;">        • Why don't add indexes `idx_country_org_cust_ref`, `idx_customer_ref` respectively ?    </div>    <div style="padding: 10px; background: rgba(76, 175, 80, 0.1); border-radius: 4px; border-left: 3px solid #4CAF50;">        We usually avoid this approach bcz it increases the overhead of update and insert , we should avoid maintaining multiple indexes for a single update or insert , whenever possible.    </div></div><p>As a result, the performance inhanced a lot , reads and writes got faster. That’s why we say “三个臭皮匠胜过一个诸葛亮” (Three heads are better than one).</p><p>Cool.</p><hr><center>↓</center>  <p>[ Jan 2027 ]</p><p>Data volume is continuously increasing, has now reached a massive scale. We have observed that some table like order table, already reached a skyrocketing count. We then adopted <strong>database sharding</strong>, sharding the table across multiple databases and tables.</p><div style="max-width:700px;margin:0 auto;background:#1a1a2e;padding:20px;border-radius:10px">    <div style="text-align:center;margin-bottom:20px">        <h2 style="color:#e6e6e6">Database Sharding</h2>        <p style="color:#a0a0a0">Splitting order table into multiple databases/tables</p>    </div>    <div style="display:flex;flex-direction:column;align-items:center;gap:20px">        <div style="background:#ffd166;padding:15px;border-radius:8px;border-left:4px solid#ef476f;width:300px">            <h4 style="margin:0 0 10px 0;color:#073b4c">Order Table</h4>            <p style="margin:5px 0;color:#073b4c">• Single database<br>• Large monolithic table<br>• Performance bottleneck</p>        </div>        <div style="color:#a0a0a0;font-size:24px">↓ sharding </div>        <div style="display:flex;gap:15px;flex-wrap:wrap;justify-content:center">            <div style="background:#06d6a0;padding:15px;border-radius:8px;border-left:4px solid#118ab2;min-width:180px">                <h4 style="margin:0 0 10px 0;color:#073b4c">Shard 0</h4>                <p style="margin:5px 0;color:#073b4c">DB: cluster_alpha<br>Table: order_000<br>Table: order_001<br>Table: order_...</p>            </div>            <div style="background:#118ab2;padding:15px;border-radius:8px;border-left:4px solid#06d6a0;min-width:180px">                <h4 style="margin:0 10px 0;color:#ffffff">Shard 1</h4>                <p style="margin:5px 0;color:#ffffff">DB: cluster_beta<br>Table: order_000<br>Table: order_001<br>Table: order_...</p>            </div>            <div style="background:#ef476f;padding:15px;border-radius:8px;border-left:4px solid#ffd166;min-width:180px">                <h4 style="margin:0 0 10px 0;color:#ffffff">Shard 2</h4>                <p style="margin:5px 0;color:#ffffff">DB: cluster_gamma<br>Table: order_000<br>Table: order_001<br>Table: order_...</p>            </div>        </div>    </div></div><p>Tech-stack: I prefer to sharding-jdbc if the language is JAVA.  Using sharding-jdbc, the design of splitting algorithm can be implemented by ourselves.</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-comment">// pseudocode</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">CoursePreciseDSShardingAlgorithm</span> <span class="hljs-keyword">implements</span> <span class="hljs-title class_">PreciseShardingAlgorithm</span>&lt;Long&gt; &#123;<br><br>    <span class="hljs-meta">@Override</span><br>    <span class="hljs-keyword">public</span> String <span class="hljs-title function_">doSharding</span><span class="hljs-params">(Collection&lt;String&gt; availableTables, PreciseShardingValue&lt;BigInteger&gt; snowflakeId)</span> &#123;<br><br>        <span class="hljs-comment">// let&#x27;s say there are 5 horizontal </span><br>        <span class="hljs-comment">// splitting tables in one sharding DB</span><br>        <span class="hljs-type">int</span> <span class="hljs-variable">tableNo</span> <span class="hljs-operator">=</span> snowflakeId % <span class="hljs-number">5</span>; <br>        <span class="hljs-keyword">if</span> (availableTables.contains(tableNo)) &#123;<br>            <span class="hljs-keyword">return</span> tableNo;<br>        &#125;<br>        <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">UnsupportedOperationException</span>(<span class="hljs-string">&quot;route to shard&quot;</span>+ shardNo +<span class="hljs-string">&quot;failed&quot;</span>);<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure><p>Above pseudocode is only for table level sharding , I haven’t implemented DB-level sharding before , honestly. but sharding-jdbc absolutely can do this. However, the sharding brings some other issues.</p><p>There is a SQL:</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs mysql">select * from order where order_id = #&#123;&#125;<br></code></pre></td></tr></table></figure><p>Through the above algorithm, query calls the correct DB shard and order_x table.</p><p>Another one:</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs mysql">select * from order where order_country = #&#123;&#125; and order_type = #&#123;&#125;<br></code></pre></td></tr></table></figure><p>Through the above algorithm, query calls <strong>all</strong>  DB shards and order_x tables , this is exactly what we don’t want to see.</p><p>Should make decisions based on the business requirements and existing database queries conditions, should proceed things with caution, how many DB and tables should be sharded? What are the sharding keys ? algorithm logic ?  and whether additional indexes should be added within the tables…</p><hr><p>If the business data evolved to here , that is not interesting , that means it is time to more hard work . I wish I won’t encounter such a tough tech situation , God bless ^^</p>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;A business originally starts with a smaller code project, usually with monolithic architecture. Through the ongoing maintenance over a ti</summary>
      
    
    
    
    
    <category term="tech" scheme="http://example.com/tags/tech/"/>
    
  </entry>
  
  <entry>
    <title>Eid Mubarak 2025</title>
    <link href="http://example.com/2025/06/06/eid2025/"/>
    <id>http://example.com/2025/06/06/eid2025/</id>
    <published>2025-06-06T09:18:33.000Z</published>
    <updated>2026-10-18T08:35:25.850Z</updated>
    
    <content type="html"><![CDATA[<p>这是一个倡导敬畏，巩固大爱，履行孝敬，主动担起社会责任，恩怨要相销的节日。</p><p>今天人们会重新开始规范自己的心灵和行为，我们相互分享最好食物，重新强调造物主的脚下没有谁贱谁贵，都去看望父母，也去看望那些离开我们的人。</p><p>我想，人不要麻木，千万不要做那种心灵僵化的人。不能像一颗CPU一样尽管跑人为的程序但从不感知自己的purpose，一定要知道1+1=2的背后为什么是正确无疑的0001+0001=0010。<br>我坚定不移的相信：真理，任何力量撼动不了的真理，还在那儿，从亚当夏娃到现在，即便无数次被人们偏离，无数次的被遵循。</p><hr><blockquote><p>愿土上的挚爱之人平安健康<br>愿土下的至亲之人安息永宁<br>祝我们节日快乐</p></blockquote>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;这是一个倡导敬畏，巩固大爱，履行孝敬，主动担起社会责任，恩怨要相销的节日。&lt;/p&gt;
&lt;p&gt;今天人们会重新开始规范自己的心灵和行为，我们相互分享最好食物，重新强调造物主的脚下没有谁贱谁贵，都去看望父母，也去看望那些离开我们的人。&lt;/p&gt;
&lt;p&gt;我想，人不要麻木，千万不要做那种</summary>
      
    
    
    
    
    <category term="thoughts" scheme="http://example.com/tags/thoughts/"/>
    
  </entry>
  
  <entry>
    <title>关于CPU缓存</title>
    <link href="http://example.com/2024/11/14/cpu-cache/"/>
    <id>http://example.com/2024/11/14/cpu-cache/</id>
    <published>2024-11-14T02:12:42.000Z</published>
    <updated>2026-10-18T08:35:25.850Z</updated>
    
    <content type="html"><![CDATA[<blockquote><p>cpu与内存简易关系</p></blockquote><p><img src="https://pica.zhimg.com/v2-7a6b29e7cca6a4f5ae665c543ad9f9d0_1440w.jpg" alt="img"></p><p><a href="https://zhida.zhihu.com/search?content_id=240951890&amp;content_type=Article&amp;match_order=1&amp;q=%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BB%84%E6%88%90%E5%8E%9F%E7%90%86&amp;zhida_source=entity">计算机组成原理</a>中，也可以简单认为cpu和内存是直接通信的，程序在运行时，将内存条中的01010010…指令读到cpu寄存器里寄存以及由ALU来计算，返回的结果写到寄存器或者写回到内存条里，成千上万个运算实现了代码的运行逻辑。</p><p>不过，真正实际的<a href="https://zhida.zhihu.com/search?content_id=240951890&amp;content_type=Article&amp;match_order=1&amp;q=%E5%B5%8C%E5%85%A5%E5%BC%8F%E8%AE%BE%E5%A4%87&amp;zhida_source=entity">嵌入式设备</a>或电脑主板上的内存和cpu中间还隔着缓存和<a href="https://zhida.zhihu.com/search?content_id=240951890&amp;content_type=Article&amp;match_order=1&amp;q=%E6%80%BB%E7%BA%BF&amp;zhida_source=entity">总线</a>(缓存在cpu芯片内部)。以4核cpu为例，像这样：</p><p><img src="https://pic1.zhimg.com/v2-c0094257ffe8173fd24d472a72ec8f40_1440w.jpg" alt="img"></p><p>L1是一级缓存，L2是二级缓存，L3是三级缓存，再到内存条。离cpu越近的读写越快，L1,L2,L3的一次IO速度大约是1ns,3ns,15ns。内存条的IO速度是60ns至80ns，再加上大约20ns的总线传输速度，cpu跟内存条之间起码需要80ns-100ns，跟L1,L2,L3缓存相比，可以说非常的拉胯。（这里的时间的数据是从美团技术团队的一个文章里面读到的留的印象，跟cpu的代数，架构，性能等硬件系数有关，不是绝对的）</p><p><a href="https://zhida.zhihu.com/search?content_id=240951890&amp;content_type=Article&amp;match_order=1&amp;q=%E7%BC%93%E5%AD%98%E6%8A%80%E6%9C%AF&amp;zhida_source=entity">缓存技术</a>可以很明显的提高机器的运行效率。记得大三的时候学习嵌入式系统移植，<a href="https://zhida.zhihu.com/search?content_id=240951890&amp;content_type=Article&amp;match_order=1&amp;q=jz2440&amp;zhida_source=entity">jz2440</a>从启动boot，加载linux内核，加载文件系统等，一开始大概花了15秒左右，当我们根据jz2440的芯片手册打开了它的 <a href="https://zhida.zhihu.com/search?content_id=240951890&amp;content_type=Article&amp;match_order=1&amp;q=I%2FD+cache&amp;zhida_source=entity">I/D cache</a>后启动时间降至5秒。</p><p>原因在于，程序在运行的时候，cpu会频繁访问某些变量，比如a++一百万次的代码访问a很频繁，激烈并发中cas操作读取AQS中的state变量也很频繁…, 在这种场景，如果有缓存的夹持，则CPU访问一个变量是先看一级缓存有没有，没有看二级，三级，还没有再看主内存，频繁变量经常出现在L1,L2,L3等缓存中，CPU可以1ns,3ns,15ns级别的读取它们，没必要耗那么多时间去内存条读，所以会快。</p><p><a href="https://zhida.zhihu.com/search?content_id=240951890&amp;content_type=Article&amp;match_order=1&amp;q=%E7%BC%93%E5%AD%98%E8%A1%8C&amp;zhida_source=entity">缓存行</a>是L1,L2,L3的缓存最小单位，大小为64Byte. 相当于long[8]，八个长度的long数组。</p><p>相邻的两个数据有极大的可能被cpu交替访问，或者说，前几个ns里cpu访问了内存中0xFFFF0123地址的a变量，紧接着过1ns后cpu又想访问0xFFFF0124地址的b变量，那么这个时候CPU需要从内存条中读取b吗？</p><p>大概率不用。因为缓存机制，极有可能将a,b同时放在了64Byte的缓存行里缓存起来了，b可以直接在缓存中读取。缓存数据范围是这样的：CPU想读a，CPU不会只缓存a，还会把a后面相邻的b,c,d…等也缓存进来刚好要凑满一个缓存行的大小。原因还是计算机在执行代码的时候的访问变量的特征，访问a紧接着还会访问隔壁的b，隔壁的c，索性只要访问第一个，那把其他几个也填满缓存行里，使在cpu最近的位置最快的获取b,c,d…</p><h3 id="demo">demo:</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">CacheLineTest</span> &#123;<br><br>    <span class="hljs-keyword">static</span> <span class="hljs-type">long</span>[][] arr;<br>    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">main</span><span class="hljs-params">(String[] args)</span> &#123;<br><br>        <span class="hljs-comment">/* 按64Byte装一个二维数组，每次读取64Byte子数组 充分利用cacheLine */</span><br>        arr = <span class="hljs-keyword">new</span> <span class="hljs-title class_">long</span>[<span class="hljs-number">1024</span> * <span class="hljs-number">1024</span>][];<br>        <span class="hljs-keyword">for</span> (<span class="hljs-type">int</span> <span class="hljs-variable">i</span> <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">1024</span> * <span class="hljs-number">1024</span>; i++) &#123;<br>            arr[i] = <span class="hljs-keyword">new</span> <span class="hljs-title class_">long</span>[<span class="hljs-number">8</span>];<br>            <span class="hljs-keyword">for</span> (<span class="hljs-type">int</span> <span class="hljs-variable">j</span> <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; j &lt; <span class="hljs-number">8</span>; j++) &#123;<br>                arr[i][j] = <span class="hljs-number">0L</span>;<br>            &#125;<br>        &#125;<br><br>        <span class="hljs-type">long</span> <span class="hljs-variable">sum</span> <span class="hljs-operator">=</span> <span class="hljs-number">0L</span>;<br>        <span class="hljs-type">long</span> <span class="hljs-variable">marked</span> <span class="hljs-operator">=</span> System.currentTimeMillis();<br>        <span class="hljs-keyword">for</span> (<span class="hljs-type">int</span> <span class="hljs-variable">i</span> <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">1024</span> * <span class="hljs-number">1024</span>; i++) &#123;<br>            <span class="hljs-keyword">for</span> (<span class="hljs-type">int</span> <span class="hljs-variable">j</span> <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; j &lt; <span class="hljs-number">8</span>; j++) &#123;<br>                sum = arr[i][j];<br>            &#125;<br>        &#125;<br><br>        System.out.println(<span class="hljs-string">&quot;Loop time: &quot;</span> + (System.currentTimeMillis() - marked) + <span class="hljs-string">&quot;ms&quot;</span>);<br><br>      <br>          <span class="hljs-comment">/* 故意不按相邻变量访问 */</span><br>        marked = System.currentTimeMillis();<br>        <span class="hljs-keyword">for</span> (<span class="hljs-type">int</span> <span class="hljs-variable">i</span> <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i &lt; <span class="hljs-number">8</span>; i++) &#123;<br>            <span class="hljs-keyword">for</span> (<span class="hljs-type">int</span> <span class="hljs-variable">j</span> <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; j &lt; <span class="hljs-number">1024</span> * <span class="hljs-number">1024</span>; j++) &#123;<br>                sum = arr[j][i];<br>            &#125;<br>        &#125;<br>        System.out.println(<span class="hljs-string">&quot;Loop time: &quot;</span> + (System.currentTimeMillis() - marked) + <span class="hljs-string">&quot;ms&quot;</span>);<br>    &#125;<br>&#125;<br><br><br><span class="hljs-comment">//结果</span><br>Loop time: 24ms<br>Loop time: 64ms<br></code></pre></td></tr></table></figure><p>AQS源码中的state为什么要volatile修饰的用意在这里。</p><p>CPU缓存的应用，是平庸和非凡工程作品的分水岭，只有master才能透视计算机内脏，掌握这里的“火候”。</p>]]></content>
    
    
      
      
    <summary type="html">&lt;blockquote&gt;
&lt;p&gt;cpu与内存简易关系&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src=&quot;https://pica.zhimg.com/v2-7a6b29e7cca6a4f5ae665c543ad9f9d0_1440w.jpg&quot; alt=&quot;img&quot;&gt;&lt;/</summary>
      
    
    
    
    
    <category term="tech" scheme="http://example.com/tags/tech/"/>
    
  </entry>
  
  <entry>
    <title>Code pattern design（一）</title>
    <link href="http://example.com/2024/09/22/code-design-1/"/>
    <id>http://example.com/2024/09/22/code-design-1/</id>
    <published>2024-09-22T02:45:15.000Z</published>
    <updated>2026-10-18T08:35:25.850Z</updated>
    
    <content type="html"><![CDATA[<p><strong>Business：</strong></p><p>As the diagram below shows, suppose we receive a requirement: listen to MySQL data changes via Canal, and sync those changes to other systems in real time — like Elasticsearch, MQ messages, or triggering business logic. What I’m trying to show is a solid, extensible base built with the right design patterns and strong open-closed compliance for all these scenarios.</p><p><img src="https://pica.zhimg.com/v2-074a1b61dd58c8b97c9256a675f6739c_1440w.jpg" alt="img"></p><p><strong>design：</strong></p><p>In this project, Spring Boot will definitely have a Listener as the main entry point. As soon as Canal detects even the slightest change in MySQL, we’ll be able to catch it in this Listener and take the appropriate action based on the event. Here’s the pseudocode:</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #8b949e;">/**Data change monitoring business* @param beforeColumns Data before the update* @param afterColumns Data after the update* @param tableName Table name* @param eventType Operation type [insert, update, delete]* @param timestamp Timestamp when the data changed */</span><span style="color: #ff7b72;">public class</span> <span style="color: #ffa657;">CanalListener</span> &#123;    <span style="color: #ff7b72;">public void</span> <span style="color: #d2a8ff;">listen</span>(<span style="color: #ffa657;">List</span>&lt;<span style="color: #ffa657;">CanalEntry.Column</span>&gt; beforeColumns, <span style="color: #ffa657;">List</span>&lt;<span style="color: #ffa657;">CanalEntry.Column</span>&gt; afterColumns, <span style="color: #ffa657;">String</span> tableName, <span style="color: #ffa657;">CanalEntry.EventType</span> eventType, <span style="color: #ff7b72;">long</span> timestamp) &#123;        <span style="color: #ff7b72;">if</span>(<span style="color: #a5d6ff;">"user_info"</span>.<span style="color: #d2a8ff;">equals</span>(tableName))  &#123;            <span style="color: #ff7b72;">if</span> (<span style="color: #ffa657;">CanalEntry.EventType.INSERT</span>.<span style="color: #d2a8ff;">equals</span>(eventType)) &#123;              <span style="color: #8b949e;">//todo for insert</span>            &#125; <span style="color: #ff7b72;">else if</span> (<span style="color: #ffa657;">CanalEntry.EventType.UPDATE</span>.<span style="color: #d2a8ff;">equals</span>(eventType)) &#123;              <span style="color: #8b949e;">//todo for update</span>            &#125; <span style="color: #ff7b72;">else if</span> (<span style="color: #ffa657;">CanalEntry.EventType.DELETE</span>.<span style="color: #d2a8ff;">equals</span>(eventType)) &#123;             <span style="color: #8b949e;">//todo for delete</span>            &#125;        &#125;    &#125;&#125;</code></pre></div><p>After reading it, you’ll notice a design problem: right now, we’re only handling the <code>user_info</code> table. But what if later iterations require listening to the <code>order</code> table too — do we just keep stacking logic on top? What if, three years later, there are another ten or twenty tables being maintained here? You’d end up with a situation where there are tons of <code>if</code>s, <code>if</code>s inside <code>if</code>s, and business logic buried inside those <code>if</code>s. By then, the code would definitely be “profound and great” — as the saying goes, “the ‘if’ gives birth to one, one gives birth to two, two gives birth to three, and three gives birth to all things,” and those “all things” are basically a crematorium.</p><p>So, instead of piling everything into the same place, it’s better to encapsulate a factory. The factory can give us a table-specific handler based on the table name. Inside the handler, we have methods for handling <code>update</code>, <code>insert</code>, and <code>delete</code> events. Then the Listener can be written like this (optimized pseudocode):</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #8b949e;">/** * Data change listener logic * @param beforeColumns The data before the update * @param afterColumns The data after the update * @param tableName The name of the table * @param eventType The operation type [insert, update, delete] * @param timestamp The timestamp when the data change occurred */</span><span style="color: #ff7b72;">public class</span> <span style="color: #ffa657;">CanalListener</span> &#123;    <span style="color: #ff7b72;">public void</span> <span style="color: #d2a8ff;">listen</span>(<span style="color: #ffa657;">List</span>&lt;<span style="color: #ffa657;">CanalEntry.Column</span>&gt; beforeColumns, <span style="color: #ffa657;">List</span>&lt;<span style="color: #ffa657;">CanalEntry.Column</span>&gt; afterColumns, <span style="color: #ffa657;">String</span> tableName, <span style="color: #ffa657;">CanalEntry.EventType</span> eventType, <span style="color: #ff7b72;">long</span> timestamp) &#123;        <span style="color: #8b949e;">//获取处理器</span>        <span style="color: #ffa657;">TableHandler</span> handler = <span style="color: #ffa657;">TableHandlerFactory</span>.<span style="color: #d2a8ff;">getHandler</span>(tableName);        <span style="color: #ff7b72;">if</span> (<span style="color: #ffa657;">ObjectUtil</span>.<span style="color: #d2a8ff;">isEmpty</span>(handler)) <span style="color: #ff7b72;">return</span>;        <span style="color: #8b949e;">//执行各自的业务</span>        <span style="color: #ffa657;">ListenEntity</span> listenEntity = <span style="color: #ff7b72;">new</span> <span style="color: #ffa657;">ListenEntity</span>(afterColumns, beforeColumns, timestamp); <span style="color: #8b949e;">//监听到的数据对象</span>        <span style="color: #ff7b72;">if</span> (<span style="color: #ffa657;">CanalEntry.EventType.INSERT</span>.<span style="color: #d2a8ff;">equals</span>(eventType)) &#123;            handler.<span style="color: #d2a8ff;">insert</span>(listenEntity);        &#125; <span style="color: #ff7b72;">else if</span> (<span style="color: #ffa657;">CanalEntry.EventType.UPDATE</span>.<span style="color: #d2a8ff;">equals</span>(eventType)) &#123;            handler.<span style="color: #d2a8ff;">update</span>(listenEntity);        &#125; <span style="color: #ff7b72;">else if</span> (<span style="color: #ffa657;">CanalEntry.EventType.DELETE</span>.<span style="color: #d2a8ff;">equals</span>(eventType)) &#123;            handler.<span style="color: #d2a8ff;">delete</span>(listenEntity);        &#125;    &#125;&#125;</code></pre></div><p>The core listener code is this small — short and clean. If you want to add a new table to listen to, you just implement the <code>insert</code>, <code>update</code>, and <code>delete</code> template methods based on <code>TableHandler</code>, and register it with the factory.</p><p>Here’s the implementation approach for the factory and handlers. First, the factory maintains a <code>HashMap</code>. When you get a handler from the factory by table name, it’s actually pulling it from the <code>HashMap</code>. Registering a handler is just a <code>put</code> operation on the <code>HashMap</code>.</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #8b949e;">// 工厂</span><span style="color: #ff7b72;">public class</span> <span style="color: #ffa657;">TableHandlerFactory</span> &#123;    <span style="color: #ff7b72;">public static</span> <span style="color: #ffa657;">Map</span>&lt;<span style="color: #ffa657;">String</span>, <span style="color: #ffa657;">TableHandler</span>&gt; tableNameHandlerMap = <span style="color: #ff7b72;">new</span> <span style="color: #ffa657;">HashMap</span>();    <span style="color: #8b949e;">// 把表handler注册到TableHandlerFactory中</span>    <span style="color: #ff7b72;">public static void</span> <span style="color: #d2a8ff;">register</span>(<span style="color: #ffa657;">String</span> tableName, <span style="color: #ffa657;">TableHandler</span> tableHandler) &#123;        <span style="color: #ff7b72;">if</span> (<span style="color: #ffa657;">StrUtil</span>.<span style="color: #d2a8ff;">isEmpty</span>(tableName)) &#123;            <span style="color: #ff7b72;">throw new</span> <span style="color: #ffa657;">IllegalArgumentException</span>(<span style="color: #a5d6ff;">"Registered tableName is empty"</span>);        &#125; <span style="color: #ff7b72;">else if</span> (<span style="color: #ffa657;">ObjectUtil</span>.<span style="color: #d2a8ff;">isEmpty</span>(tableHandler)) &#123;            <span style="color: #ff7b72;">throw new</span> <span style="color: #ffa657;">IllegalArgumentException</span>(<span style="color: #a5d6ff;">"Registered tableHandler is empty"</span>);        &#125;        tableNameHandlerMap.<span style="color: #d2a8ff;">put</span>(tableName, tableHandler);    &#125;    <span style="color: #8b949e;">// 根据表名获取处理器</span>    <span style="color: #ff7b72;">public static</span> <span style="color: #ffa657;">TableHandler</span> <span style="color: #d2a8ff;">getHandler</span>(<span style="color: #ffa657;">String</span> tableName) &#123;        <span style="color: #ff7b72;">if</span> (<span style="color: #ffa657;">StrUtil</span>.<span style="color: #d2a8ff;">isEmpty</span>(tableName)) &#123;            <span style="color: #ff7b72;">throw new</span> <span style="color: #ffa657;">IllegalArgumentException</span>(<span style="color: #a5d6ff;">"illegal input for get tableHandler,tableName is empty"</span>);        &#125;        <span style="color: #ff7b72;">return</span> tableNameHandlerMap.<span style="color: #d2a8ff;">get</span>(tableName);    &#125;&#125;</code></pre></div><p>Why did I use an abstract class for <code>TableHandler</code> instead of an interface? The benefit is that an abstract class can provide default implementations. If a handler doesn’t implement a certain method from the abstract class — say <code>delete</code> — but <code>delete</code> gets called in the business logic, it will throw an <code>UnsupportedOperationException</code> by default. Alternatively, we could also throw a <code>RuntimeException(&quot;This method has not been implemented&quot;)</code>;</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #ff7b72;">public abstract class</span> <span style="color: #ffa657;">TableHandler</span> <span style="color: #ff7b72;">implements</span> <span style="color: #ffa657;">InitializingBean</span> &#123;    <span style="color: #ff7b72;">public void</span> <span style="color: #d2a8ff;">insert</span>(<span style="color: #ffa657;">ListenEntity</span> listenEntity) &#123;        <span style="color: #ff7b72;">throw new</span> <span style="color: #ffa657;">UnsupportedOperationException</span>();    &#125;    <span style="color: #ff7b72;">public void</span> <span style="color: #d2a8ff;">update</span>(<span style="color: #ffa657;">ListenEntity</span> listenEntity) &#123;        <span style="color: #ff7b72;">throw new</span> <span style="color: #ffa657;">UnsupportedOperationException</span>();    &#125;    <span style="color: #ff7b72;">public void</span> <span style="color: #d2a8ff;">delete</span>(<span style="color: #ffa657;">ListenEntity</span> listenEntity) &#123;        <span style="color: #ff7b72;">throw new</span> <span style="color: #ffa657;">UnsupportedOperationException</span>();    &#125;&#125;</code></pre></div><p>Each table’s business logic is encapsulated in its handler.</p><div style="font-family: 'SF Mono', Consolas, 'Courier New', monospace; max-width: 720px; margin: 0 auto; padding: 20px; background: #0d1117; border-radius: 16px; color: #e6edf3; font-size: 13px; line-height: 1.7; box-shadow: 0 2px 12px rgba(0,0,0,0.4); overflow-x: auto;"><pre style="margin: 0;"><code><span style="color: #79c0ff;">@Component</span><span style="color: #ff7b72;">public class</span> <span style="color: #ffa657;">OrderTableHandler</span> <span style="color: #ff7b72;">extends</span> <span style="color: #ffa657;">TableHandler</span> &#123;    <span style="color: #ff7b72;">private</span> <span style="color: #ffa657;">String</span> tableName = <span style="color: #a5d6ff;">"t_order"</span>;    <span style="color: #79c0ff;">@Override</span>    <span style="color: #ff7b72;">public void</span> <span style="color: #d2a8ff;">insert</span>(<span style="color: #ffa657;">ListenEntity</span> listenEntity) &#123;        <span style="color: #8b949e;">//todo</span>    &#125;    <span style="color: #79c0ff;">@Override</span>    <span style="color: #ff7b72;">public void</span> <span style="color: #d2a8ff;">update</span>(<span style="color: #ffa657;">ListenEntity</span> listenEntity) &#123;        <span style="color: #8b949e;">//todo</span>    &#125;    <span style="color: #79c0ff;">@Override</span>    <span style="color: #ff7b72;">public void</span> <span style="color: #d2a8ff;">delete</span>(<span style="color: #ffa657;">ListenEntity</span> listenEntity) &#123;        <span style="color: #8b949e;">//todo</span>    &#125;    <span style="color: #8b949e;">// Spring启动时注册自己到Factory工厂</span>    <span style="color: #79c0ff;">@Override</span>    <span style="color: #ff7b72;">public void</span> <span style="color: #d2a8ff;">afterPropertiesSet</span>() <span style="color: #ff7b72;">throws</span> <span style="color: #ffa657;">Exception</span> &#123;        <span style="color: #ffa657;">TableHandlerFactory</span>.<span style="color: #d2a8ff;">register</span>(tableName, <span style="color: #ff7b72;">this</span>);    &#125;&#125;</code></pre></div><p>Surprise! that’s it.</p><p>Honestly, I can’t even clearly name which design patterns I used here. The way I see it, design patterns are about using the features of your language well — interfaces, abstract classes, regular classes, any kind of component — and combining them in a way that makes the business foundation work like magic. That’s my personal take on design. And design is flexible — the same thing can be designed in so many different ways, and everyone has their own style, so the implementation I showed is just one of many options.</p><p>Anyway, no brute force.</p>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;&lt;strong&gt;Business：&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;As the diagram below shows, suppose we receive a requirement: listen to MySQL data changes via Canal, a</summary>
      
    
    
    
    
    <category term="design" scheme="http://example.com/tags/design/"/>
    
  </entry>
  
  <entry>
    <title>到底数据量达到多少时要考虑分库分表?</title>
    <link href="http://example.com/2024/08/02/mysql-db-sharding/"/>
    <id>http://example.com/2024/08/02/mysql-db-sharding/</id>
    <published>2024-08-02T14:04:36.000Z</published>
    <updated>2026-10-18T08:35:25.852Z</updated>
    
    <content type="html"><![CDATA[<p>经常有人会说500w或两千万就应该考虑分表，但是实际工作中做决策时需要负责任的，需明察其理。</p><p>其实, 如果了解<a href="https://zhida.zhihu.com/search?content_id=238285156&amp;content_type=Article&amp;match_order=1&amp;q=B%2B%E6%A0%91&amp;zhida_source=entity">B+树</a>数据结构，我们自己就可以计算和预判数据量达到多少后数据库性能可能会下降，并且按业务现有的数据评估要不要分表。</p><p>首先复习一下B+树。一个<a href="https://zhida.zhihu.com/search?content_id=238285156&amp;content_type=Article&amp;match_order=1&amp;q=%E4%B8%BB%E9%94%AE%E7%B4%A2%E5%BC%95&amp;zhida_source=entity">主键索引</a>的B+树数据结构大概长这样：</p><p><img src="https://pic4.zhimg.com/v2-60dbb180e987238fc31afb9f14078711_1440w.jpg" alt="img"></p><p>如所见，这些大框(不是有数字的小框)都我们称之为节点或“页”，每页大小在<a href="https://zhida.zhihu.com/search?content_id=238285156&amp;content_type=Article&amp;match_order=1&amp;q=mysql&amp;zhida_source=entity">mysql</a>默认为16kb(官方说这是mysql做了大量的实验和调优后得出来的合适值)。请看第一页，假设索引的类型用的是bingint类型，那么&quot;50&quot;这一格大小为8byte，&quot;50&quot;隔壁的格存储的是&quot;50&quot;到&quot;70&quot;之间的数据页的地址，mysql给这个地址大小为6byte。<br>所以一个页可以存储:<br>16kb/(8byte+6byte)=1170(个bigint)<br>假设一行记录占1kb，在三层b+<a href="https://zhida.zhihu.com/search?content_id=238285156&amp;content_type=Article&amp;match_order=1&amp;q=%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95&amp;zhida_source=entity">聚簇索引</a>树中我们可以存1170 × 1170 × 16kb/1kb = 21902400(条记录)</p><p>很多建议两千多万分表这个说法来自于这里。</p><p>然而，不是每一张业务表的记录大小都等于1kb，1kb空间足以让线上大多数业务的一条数据撑死。<br>比如有这么一条记录，字段及类型长这样：</p><table><thead><tr><th>字段</th><th>id</th><th>name</th><th>age</th><th>gender</th></tr></thead><tbody><tr><td>类型</td><td>bigint</td><td>char(20)</td><td>int</td><td>tinyint</td></tr><tr><td>占用空间</td><td>8byte</td><td>21byte</td><td>4byte</td><td>1byte</td></tr></tbody></table><p>这条记录的大小粗略的等于34个字节，如果还是拿bigint类型的id索引算，那么这个三层B+树能存1170 × 1170 × 16kb/34byte = 659809800(条记录)</p><p>就这个表而言，可以认为数据增长到6.59亿条之前都不太会有性能上的问题。</p><p>因此在业务中面对那么多天马星空的表结构、索引的情况、单条数据平均大小，并不应该死认500w或者2000w，因为阿里开发手册上的建议是来自于阿里自己的数据，跟我们的未必一样。</p>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;经常有人会说500w或两千万就应该考虑分表，但是实际工作中做决策时需要负责任的，需明察其理。&lt;/p&gt;
&lt;p&gt;其实, 如果了解&lt;a href=&quot;https://zhida.zhihu.com/search?content_id=238285156&amp;amp;content_ty</summary>
      
    
    
    
    
  </entry>
  
  <entry>
    <title>Redis在拔掉电线后数据可以完好无损,能做到</title>
    <link href="http://example.com/2024/06/05/redis/"/>
    <id>http://example.com/2024/06/05/redis/</id>
    <published>2024-06-05T13:14:28.000Z</published>
    <updated>2026-10-18T08:35:25.853Z</updated>
    
    <content type="html"><![CDATA[<p>​去年得了一场大病，我现在不再那么执着于当架构师，多少年后我要做到什么title，挣多少钱，没有这样的想法，反而有了新的目标和计划, 不算太迷茫。</p><p>一直想记录一个关于redis相关的内容。</p><hr><p>​我很喜欢Redis的持久化机制，原因在于现在Redis发展到哪怕突然被人拔电线，重启后仍然能够快速恢复数据，掉电数据丢失率很低很低，目前持久化的机制还是很强的。</p><h5 id="Redis的持久化有三种模式：RDB-AOF-RDB-AOF">Redis的持久化有三种模式：RDB, AOF, RDB&amp;AOF</h5><h3 id="RDB模式">RDB模式</h3><p>​RDB模式下，redis会每隔一段时间，将内存中的该时刻的数据快照存到硬盘里，会在一个xxx.rdb文件里，宕机重新启动后从xxx.rdb恢复，RDB恢复很爽快，直接把rdb文件里的存的快照整个给内存贴过去完事。 在<a href="https://zhida.zhihu.com/search?content_id=252607039&amp;content_type=Article&amp;match_order=1&amp;q=redis.conf&amp;zhida_source=entity">redis.conf</a>配置文件里可以设置该模式的参数：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs sql">save <span class="hljs-number">60</span> <span class="hljs-number">1000</span>            <span class="hljs-operator">/</span><span class="hljs-operator">/</span> <span class="hljs-number">60</span> 秒内有至少有 <span class="hljs-number">1000</span> 个键被改动就存快照                                                                               <br></code></pre></td></tr></table></figure><p>这个模式，不好，它在隔时间地一段一段地在持久化数据，比如save 60 1000：假如距离上一次持久化已经过60秒了，键的改动次数没到1000个，就不触发持久化。在这个60秒段内任意一个时间截点拔电源，都会造成数据丢失，因为距离上一次持久化后内存中有增量的数据，它们没有被持久化保护。</p><h3 id="AOF模式">AOF模式</h3><p>​AOF模式下，来一行指令持久化一行指令到xxx.aof的一个文件里，宕机重新启动后从xxx.aof恢复，这样可以认为数据不再丢失了。xxx.aof文件里是这样一样一行记录的:</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs sql">指令 <span class="hljs-keyword">set</span> robert <span class="hljs-number">888</span> ex <span class="hljs-number">1000</span> 的aof文件记录大概是这样（不用看懂）：<br><span class="hljs-number">1</span> $<span class="hljs-number">3</span><br><span class="hljs-number">2</span> <span class="hljs-number">888</span><br><span class="hljs-number">3</span> <span class="hljs-operator">*</span><span class="hljs-number">3</span><br><span class="hljs-number">4</span> $<span class="hljs-number">9</span><br><span class="hljs-number">5</span> PEXPIREAT<br><span class="hljs-number">6</span> <span class="hljs-number">1000</span><br><span class="hljs-number">7</span> robert<br><span class="hljs-number">8</span> $<span class="hljs-number">13</span><br><span class="hljs-number">9</span> <span class="hljs-number">160424978630</span><br></code></pre></td></tr></table></figure><p>虽然这样一行一行的一个不落地记录能大大地降低数据丢失率，同时带来两个问题。</p><p>​第一，持久化是一个磁盘同步的操作，而redis操作是内存操作，现在aof要每次redis操作都要伴随着持久化，岂不是会有无数次磁盘IO累活？</p><p>AOF模式提供了三种解决方案:</p><blockquote><p>appendfsync always：每次有新命令追加到 AOF 文件时就执行一次 持久化 ，100%累赘，也非常安全。<br>appendfsync everysec：每秒持久化一次，足够快，并且在故障时只会丢失 1 秒钟的数据。<br>appendfsync no：从不持久化 ，将数据交给操作系统来处理。更快，也更不安全的选择。</p></blockquote><p>权衡后我估计选择第二种，根据访问量和磁盘的优秀度配置一个合适的参数，比如设置 每1s把增量的数据持久化进来，那可以保证最近1s以前的数据绝对安全。</p><p>​第二, AOF这个记录方式是不停地将所有历史数据向xxx.aof文件里堆加，随着时间文件会非常庞大，而aof的重启恢复的原理是把aof文件从0位置运行到宕机时的位置，这个时间好比把秦始皇到现代的时间走一遍。怎么加快恢复速度呢?</p><p>答案是AOF的重写。</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs mysql">在aof有一些指令像这样<br>set a 1;<br>...   <br>get a; <br>...   <br>del a;   <br></code></pre></td></tr></table></figure><blockquote><p>显然恢复中这些指令是浪费时间的，重写就是把这三个指令从aof中抹掉，这样一定程度上加快了恢复速度。</p></blockquote><p>AOF 其实还是差点儿意思，AOF只是在保证数据安全上比RDB好，而RDB在恢复数据上比AOF快。</p><h3 id="RDB-AOF混合持久化模式">RDB &amp; AOF混合持久化模式</h3><p>​结合RDB和AOF，结合优点，相消缺点。持久化会继续记录aof文件，底座是RDB快照，往上追加RDB持久化后增量的指令，如下：</p><p><img src="https://pic1.zhimg.com/v2-f7954199831a9d3770a88170e0f80fe2_r.jpg" alt="img"></p><ol><li>持久化<ul><li>每隔一段时间AOF文件会被RDB刷满</li><li>按照AOF模式，新增的指令往上追加</li></ul></li><li>恢复<ul><li>将RDB部分的快照装在进redis内存里</li><li>执行AOF部分的指令</li></ul></li></ol><h5 id="Conclusion">Conclusion</h5><p>​我认为Redis的机制选型不需要太客观，大部分的redis服务部署完后，不要犹豫，选第三种混合型持久化模式。</p><ul><li>恢复起来非常快</li><li>宕机那一刹那间小概率丢一两个数据，重启后排查，补上去就行。灾难级丢失是不会的，一大块儿丢失也是不会的。</li></ul>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;​	去年得了一场大病，我现在不再那么执着于当架构师，多少年后我要做到什么title，挣多少钱，没有这样的想法，反而有了新的目标和计划, 不算太迷茫。&lt;/p&gt;
&lt;p&gt;一直想记录一个关于redis相关的内容。&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;​	我很喜欢Redis的持久化机制，原因在于</summary>
      
    
    
    
    
    <category term="tech" scheme="http://example.com/tags/tech/"/>
    
  </entry>
  
  <entry>
    <title>有一点厉害的Usafe.class</title>
    <link href="http://example.com/2024/01/06/about-unsafe/"/>
    <id>http://example.com/2024/01/06/about-unsafe/</id>
    <published>2024-01-06T18:19:28.000Z</published>
    <updated>2026-10-18T08:35:25.850Z</updated>
    
    <content type="html"><![CDATA[<p>第一次知道Unsafe概念是在使用ReentrntLock和<a href="https://zhida.zhihu.com/search?content_id=241461290&amp;content_type=Article&amp;match_order=1&amp;q=CountDownLatch&amp;zhida_source=entity">CountDownLatch</a>。这两个都实现了<a href="https://zhida.zhihu.com/search?content_id=241461290&amp;content_type=Article&amp;match_order=1&amp;q=AQS&amp;zhida_source=entity">AQS</a>，AQS能够做到线程安全同步，关键在于AQS中通过查询state变量的值来知道当前资源有没有被锁，改变state变量的值来表示当前资源被锁，改变state是要保证<a href="https://zhida.zhihu.com/search?content_id=241461290&amp;content_type=Article&amp;match_order=1&amp;q=%E5%8E%9F%E5%AD%90%E6%80%A7&amp;zhida_source=entity">原子性</a>的，原子性保障由Unsafe中的CompareAntSwap支持。</p><p>从ReentrantLock的非公平锁开始看：</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * Sync object for non-fair locks</span><br><span class="hljs-comment"> */</span><br><span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">NonfairSync</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_">Sync</span> &#123;<br>    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> <span class="hljs-type">long</span> <span class="hljs-variable">serialVersionUID</span> <span class="hljs-operator">=</span> <span class="hljs-number">7316153563782823691L</span>;<br><br>    <span class="hljs-comment">/**</span><br><span class="hljs-comment">     * Performs lock.  Try immediate barge, backing up to normal</span><br><span class="hljs-comment">     * acquire on failure.</span><br><span class="hljs-comment">     */</span><br>    <span class="hljs-keyword">final</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">lock</span><span class="hljs-params">()</span> &#123;<br>        <span class="hljs-keyword">if</span> (compareAndSetState(<span class="hljs-number">0</span>, <span class="hljs-number">1</span>))<br>            setExclusiveOwnerThread(Thread.currentThread());<br>        <span class="hljs-keyword">else</span><br>            acquire(<span class="hljs-number">1</span>);<br>    &#125;<br><br>    <span class="hljs-keyword">protected</span> <span class="hljs-keyword">final</span> <span class="hljs-type">boolean</span> <span class="hljs-title function_">tryAcquire</span><span class="hljs-params">(<span class="hljs-type">int</span> acquires)</span> &#123;<br>        <span class="hljs-keyword">return</span> nonfairTryAcquire(acquires);<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure><p>lock方法主要是在compareAndSetState(0,1)成功后再让本线程进来执行任务。</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">protected</span> <span class="hljs-keyword">final</span> <span class="hljs-type">boolean</span> <span class="hljs-title function_">compareAndSetState</span><span class="hljs-params">(<span class="hljs-type">int</span> expect, <span class="hljs-type">int</span> update)</span> &#123;<br>        <span class="hljs-comment">// See below for intrinsics setup to support this</span><br>        <span class="hljs-keyword">return</span> unsafe.compareAndSwapInt(<span class="hljs-built_in">this</span>, stateOffset, expect, update);<br>    &#125;<br></code></pre></td></tr></table></figure><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-comment">// stateOffset是state的偏移量。 </span><br>stateOffset = unsafe.objectFieldOffset<br>            (AbstractQueuedSynchronizer.class.getDeclaredField(<span class="hljs-string">&quot;state&quot;</span>));<br></code></pre></td></tr></table></figure><p>所以，ReentrantLock在上锁时一直在维护一个state变量, 想获得锁必须做compareAndSwap比较与交换的操作。</p><p>这个&quot;比较与交换&quot;是用Unsafe实现的：</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">protected</span> <span class="hljs-keyword">final</span> <span class="hljs-type">boolean</span> <span class="hljs-title function_">compareAndSetState</span><span class="hljs-params">(<span class="hljs-type">int</span> expect, <span class="hljs-type">int</span> update)</span> &#123;<br>     <span class="hljs-comment">// See below for intrinsics setup to support this</span><br>     <span class="hljs-keyword">return</span> unsafe.compareAndSwapInt(<span class="hljs-built_in">this</span>, stateOffset, expect, update);<br> &#125;<br><br> <span class="hljs-comment">// 比较与交换的native方法 保证比较与交换的原子性</span><br> <span class="hljs-keyword">public</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">native</span> <span class="hljs-type">boolean</span> <span class="hljs-title function_">compareAndSwapInt</span><span class="hljs-params">(Object var1, <span class="hljs-type">long</span> var2, <span class="hljs-type">int</span> var4, <span class="hljs-type">int</span> var5)</span>;<br></code></pre></td></tr></table></figure><p>还想说一下，什么是原子性，compareAndSwap比较与交换有多个指令组成，这些指令中途不能被打断，整个一起执行完，这就是原子性。</p><p>上面是结合ReentrantLock的场景。</p><p>Unsafe类非常有意思:</p><ol><li>它是根据变量在对象中的偏移量来改变值的，非常底层，非常c语言指针的感觉，但由保证了原子性。</li><li>构造方法是private, 程序员不能new过来用, 只能由最底层的system级别的类加载器加载的类才可以通过getUnsafe()方法获取用。(加载器由三种：引导类加载器，ExtClassLoader，AppClassLoader。除了jdk自带的那些底层类，其他由开发者编写的类都被AppClassLoader加载，所以想调用getUnsafe获取unsafe做操作，那你必须是jdk自带的那些底层类) 以下是关键代码:</li></ol><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">private</span> <span class="hljs-title function_">Unsafe</span><span class="hljs-params">()</span> &#123;<br>    &#125;<br><br>    <span class="hljs-meta">@CallerSensitive</span><br>    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> Unsafe <span class="hljs-title function_">getUnsafe</span><span class="hljs-params">()</span> &#123;<br>        <span class="hljs-type">Class</span> <span class="hljs-variable">var0</span> <span class="hljs-operator">=</span> Reflection.getCallerClass();<br>        <span class="hljs-keyword">if</span> (!VM.isSystemDomainLoader(var0.getClassLoader())) &#123;<br>            <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">SecurityException</span>(<span class="hljs-string">&quot;Unsafe&quot;</span>);<br>        &#125; <span class="hljs-keyword">else</span> &#123;<br>            <span class="hljs-keyword">return</span> theUnsafe;<br>        &#125;<br>    &#125;<br></code></pre></td></tr></table></figure><ol start="3"><li>unsafe意味着危险，因为它操作内存的权限比较大，给底层开发jdk的人去用，实现这些concurrent里面的那些原子操作。</li></ol><p>当然我们也可以拿来做做实验体会一下，因为还可以通过反射机制来获取unsafe使用：</p><p>demo:</p><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * unsafe是一个强大的类，但是危险 他像c语言一样能访问内存</span><br><span class="hljs-comment"> * 但是构造方法是private，不给new的，他是一个饿汉式单例模式，static静态代码块里把自己初始化好了</span><br><span class="hljs-comment"> * Unsafe.getUnsafe()也不能拿到，调用这个方法的雷必须是有引导类加载器加载才能用这个方法拿到unsafe对象</span><br><span class="hljs-comment"> * 想用可以通过反射机制获取。</span><br><span class="hljs-comment"> */</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">UnsafeFactory</span> &#123;<br><br>    <span class="hljs-comment">//获取unsafe对象</span><br>    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> Unsafe <span class="hljs-title function_">getUnsafe</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> NoSuchFieldException, IllegalAccessException &#123;<br><br>        <span class="hljs-type">Field</span> <span class="hljs-variable">field</span> <span class="hljs-operator">=</span> Unsafe.class.getDeclaredField(<span class="hljs-string">&quot;theUnsafe&quot;</span>);<br>        field.setAccessible(<span class="hljs-literal">true</span>);<br>        <span class="hljs-keyword">return</span>  (Unsafe)field.get(<span class="hljs-literal">null</span>);<br>    &#125;<br><br>    <span class="hljs-comment">//获取变量的内存偏移量</span><br>    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-type">long</span> <span class="hljs-title function_">getFieldOffset</span><span class="hljs-params">(Unsafe unsafe, Field field)</span> &#123;<br>        <span class="hljs-type">long</span> <span class="hljs-variable">offset</span> <span class="hljs-operator">=</span> unsafe.objectFieldOffset(field);<br>        <span class="hljs-keyword">return</span> offset;<br>    &#125;<br>  <br>  <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">main</span><span class="hljs-params">(String[] args)</span> <span class="hljs-keyword">throws</span> NoSuchFieldException, IllegalAccessException &#123;<br><br>        <span class="hljs-type">Unsafe</span> <span class="hljs-variable">unsafe</span> <span class="hljs-operator">=</span> getUnsafe();<br><br>        <span class="hljs-type">Field</span> <span class="hljs-variable">num</span> <span class="hljs-operator">=</span> ThreadPlusPlusProblem.class.getDeclaredField(<span class="hljs-string">&quot;num&quot;</span>);<br><br><br>        <span class="hljs-type">long</span> <span class="hljs-variable">fieldOffset</span> <span class="hljs-operator">=</span> getFieldOffset(unsafe, num);<br><br>        System.out.println(<span class="hljs-string">&quot;num在ThreadPlusPlusProblem中的偏移量:&quot;</span>+fieldOffset);<br><br>        <span class="hljs-comment">//put置</span><br>        <span class="hljs-type">ThreadPlusPlusProblem</span> <span class="hljs-variable">threadPlusPlusProblem</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">ThreadPlusPlusProblem</span>();<br>        num.setAccessible(<span class="hljs-literal">true</span>);<br>        num.set(threadPlusPlusProblem,<span class="hljs-number">1</span>);<br>        System.out.println(JSON.toJSONString(threadPlusPlusProblem));<br><br>    &#125;<br>&#125;<br><br></code></pre></td></tr></table></figure><p>建议从ReentrantLock.lock()点进去看一下怎么通过unsafe来原子性的维护state变量来实现锁状态的查询和改变，一定要读AQS这里的源码，想一下AQS中的state用volatile修饰，这里的用意是很底层和比较cool。</p><p>希望你是非常喜欢自己的工作, 从中能找到意义和成就^^</p>]]></content>
    
    
      
      
    <summary type="html">&lt;p&gt;第一次知道Unsafe概念是在使用ReentrntLock和&lt;a href=&quot;https://zhida.zhihu.com/search?content_id=241461290&amp;amp;content_type=Article&amp;amp;match_order=1&amp;amp</summary>
      
    
    
    
    
    <category term="tech" scheme="http://example.com/tags/tech/"/>
    
  </entry>
  
</feed>
