<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by acyutaharidas on Medium]]></title>
        <description><![CDATA[Stories by acyutaharidas on Medium]]></description>
        <link>https://medium.com/@acyutaharidas?source=rss-d4e593fe1bf4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Stec10vDZ6LN14AL</url>
            <title>Stories by acyutaharidas on Medium</title>
            <link>https://medium.com/@acyutaharidas?source=rss-d4e593fe1bf4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 20:05:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@acyutaharidas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deploying ILShield: A Uniswap v4 Hook on Contract.dev Stagenet]]></title>
            <link>https://medium.com/@acyutaharidas/deploying-ilshield-a-uniswap-v4-hook-on-contract-dev-stagenet-1d8f247f09fa?source=rss-d4e593fe1bf4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d8f247f09fa</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[uniswap-v4]]></category>
            <category><![CDATA[uniswap]]></category>
            <category><![CDATA[defi]]></category>
            <dc:creator><![CDATA[acyutaharidas]]></dc:creator>
            <pubDate>Sun, 14 Jun 2026 15:59:53 GMT</pubDate>
            <atom:updated>2026-06-15T11:54:34.253Z</atom:updated>
            <content:encoded><![CDATA[<p>As part of Atrium Academy’s 9th Uniswap Hook Incubator cohort, I built ILShield — a Uniswap v4 hook designed to compensate liquidity providers for the impermanent loss.</p><p>ILShield embeds an insurance system directly inside a Uniswap v4 pool. Every zeroForOne swap contributes a small premium to a shared reserve. When an LP exits with impermanent loss, the hook compensates them automatically in the same transaction.</p><p>After getting the hook working locally with Foundry, I wanted to test it against mainnet-like production state. I used Stagenet by Contract.dev, which bridges the gap between Anvil where you control everything, and mainnet where mistakes cost money.</p><p>This article walks through the deployment process.</p><p>Note: I’m learning Uniswap v4 hooks, I wanted to see if I could deploy one on a Stagenet, here’s what I learned along the way.</p><h3>About Stagenets</h3><p>Stagenets are private testnets that replay mainnet with built-in contract simulations, analytics, and developer tools. They give you a persistent staging environment with production-like state.</p><p>And the faucet eliminates one of the most common testnet headaches. You can mint any amount of any token on demand. It’s another way Stagenets remove friction from the development workflow.</p><p>Read more here: <a href="https://docs.contract.dev/core-concepts/stagenets">https://docs.contract.dev/core-concepts/stagenets</a></p><h3>Setup</h3><p>Getting started takes only a few clicks:</p><p>login → create project → select a chain → import your GitHub repo</p><p>Once imported, the contract appears in your dashboard and the RPC endpoint is ready to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KXEP_I-pB4ca31k5JAGtsA.png" /><figcaption>Project Setup on Stagenets</figcaption></figure><h3>Hook Deployment</h3><p>With the project set up, the next step is writing a deployment script. Before that though, there is one important thing to understand about Uniswap v4 hooks.</p><p><strong>You cannot deploy a hook at a random address.</strong></p><p>When a pool is created, the PoolManager validates the hook address by inspecting specific bits that encode the hook’s declared permissions. If those bits don’t match, the transaction reverts with HookAddressNotValid.</p><p>The deployment process is therefore:</p><ol><li>Define the required hook permission flags</li><li>Use HookMiner to find a CREATE2 salt that produces a valid address</li><li>Deploy the hook using that salt</li><li>Verify the deployed address matches what HookMiner found</li></ol><h3>Hook Permissions</h3><p>ILShield uses four callback permissions:</p><pre>afterAddLiquidity         → 1 &lt;&lt; 10 = 0x0400<br>afterRemoveLiquidity      → 1 &lt;&lt; 8  = 0x0100<br>afterSwap                 → 1 &lt;&lt; 6  = 0x0040<br>afterSwapReturnsDelta     → 1 &lt;&lt; 2  = 0x0004<br>Combined:                            0x0544</pre><p>This means the 14 low bits of the deployed address must equal 0x0544. A standard forge create generates a random address that will almost certainly fail validation. CREATE2 with a mined salt is the standard way to deploy a hook to a valid address.</p><h3>HookMiner</h3><p>Uniswap provides a utility called HookMiner that searches for a CREATE2 salt capable of producing a valid hook address. You can find it in the <a href="https://github.com/Uniswap/v4-hooks-public/blob/main/test/utils/HookMiner.sol">v4-hooks-public repository</a>.</p><h3>Important Addresses</h3><p>Two addresses are needed in the deployment script.</p><p><strong>PoolManager</strong> (Ethereum mainnet, and mainnet forks):</p><pre>0x000000000004444c5dc75cB358380D2e3dE08A90</pre><p><strong>CREATE2 Deployer Proxy</strong> — in forge test, this is usually address(this). In forge script, use the canonical proxy:</p><pre>0x4e59b44847b379578588920cA78FbF26c0B4956C</pre><p>Reference: <a href="https://developers.uniswap.org/docs/protocols/v4/guides/hooks/hook-deployment#:~:text=)%3B-,Mine%20the%20address,-by%20finding%20a">Hook Deployment — Uniswap Developers</a></p><h3>The Deployment Script</h3><p>First, define the permission flags:</p><pre>uint160 FLAGS = uint160(<br>    Hooks.AFTER_ADD_LIQUIDITY_FLAG    |<br>    Hooks.AFTER_REMOVE_LIQUIDITY_FLAG |<br>    Hooks.AFTER_SWAP_FLAG             |<br>    Hooks.AFTER_SWAP_RETURNS_DELTA_FLAG<br>); // 0x0544</pre><p>Next, use HookMiner to find a salt that produces a matching address:</p><pre>bytes memory constructorArgs = abi.encode(POOL_MANAGER);<br>(address hookAddress, bytes32 salt) = HookMiner.find(<br>    CREATE2_DEPLOYER,<br>    FLAGS,<br>    type(ILShieldHook).creationCode,<br>    constructorArgs<br>);</pre><p>Then deploy using CREATE2 and verify:</p><pre>vm.broadcast();<br>ILShieldHook hook = new ILShieldHook{salt: salt}(IPoolManager(POOL_MANAGER));<br>require(address(hook) == hookAddress, &quot;ILShieldHookScript: hook address mismatch&quot;);</pre><p>The full script: <a href="https://github.com/acyutaharidas-gif/ilShield_uhi9/blob/main/script/DeployILShield.s.sol">Link</a></p><h3>Running the Script</h3><p>Create a .env file:</p><pre>STAGENET_RPC_URL=https://rpc.contract.dev/your-stagenet-id<br>PRIVATE_KEY=0x...</pre><p>Then deploy:</p><pre>source .env<br><br>forge script script/DeployILShield.s.sol \<br>  --rpc-url $STAGENET_RPC_URL \<br>  --private-key $PRIVATE_KEY \<br>  --broadcast -vvvv</pre><p>If everything succeeds, the hook will be deployed to a valid address 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4y54_wMPRXc0-JggWyWi0g.png" /><figcaption>hook deployed on stagenet</figcaption></figure><p>After deployment, the next steps depend on your specific contract. For ILShield, that meant creating a pool, initializing the hook config, and seeding the insurance reserve. The contract.dev dashboard also has tools to explore from here — tracking data over time, simulating contract activity, scheduling recurring transactions, and more.</p><p>The most interesting part of the process wasn’t the deployment itself, but Uniswap v4’s permission model. Because hook capabilities are encoded directly into the contract address, deployment becomes part of the application logic. HookMiner and CREATE2 solve that problem cleanly, and Stagenet provides a convenient environment to test the entire flow against mainnet state before touching production.</p><p><strong>ILShield</strong> — source and tests: <a href="https://github.com/acyutaharidas-gif/ilShield_uhi9">github.com/acyutaharidas-gif/ilShield_uhi9</a> Built during <a href="https://atrium.academy/">Atrium Academy</a> UHI9.</p><h3>Reference Links</h3><ul><li><a href="https://github.com/Uniswap/v4-hooks-public/blob/main/test/utils/HookMiner.sol">HookMiner utility</a></li><li><a href="https://developers.uniswap.org/docs/protocols/v4/guides/hooks/hook-deployment">Uniswap v4 Hook Deployment Guide</a></li><li><a href="https://developers.uniswap.org/docs/protocols/v4/deployments">Uniswap v4 Deployments</a></li><li><a href="https://docs.contract.dev/core-concepts/stagenets">Stagenets — contract.dev</a></li><li><a href="https://github.com/acyutaharidas-gif/ilShield_uhi9">ILShield GitHub</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d8f247f09fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>