{"_id":"@0xheyjo/uni-v2-artifacts","_rev":"2-b036fee7a4ba27b59387c6b74a6d2156","name":"@0xheyjo/uni-v2-artifacts","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@0xheyjo/uni-v2-artifacts","version":"1.0.0","_id":"@0xheyjo/uni-v2-artifacts@1.0.0","maintainers":[{"name":"0xheyjo","email":"sendmailtojoshi@gmail.com"}],"dist":{"shasum":"7b9a26a049c347d5715e5c9a690096bf6c1b0d95","tarball":"https://registry.npmjs.org/@0xheyjo/uni-v2-artifacts/-/uni-v2-artifacts-1.0.0.tgz","fileCount":13,"integrity":"sha512-DUFR/MlNuz+1rG7aDsul2j3MULA294bO9EJDv38Ckq/IkZ07Hx26XeSyZE3Wk5uhHIV25Y9LLtC/LNqhZYxlwg==","signatures":[{"sig":"MEQCIHaAtpDMlw+yNtTQIx6YxIFF/pr3hH/LxWuozn9VqbDfAiBoZ7uU3FTaIUg9+F10iXGX5dizXRRM19jEyNJlSAjUtQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":98138},"exports":{".":"./package.json","./abi/*":"./export/abi/*","./addresses/*":"./export/frontend/*"},"gitHead":"83ff29fc87548b2d839ce1515dc0acf11f12c109","scripts":{"prepublishOnly":"npm run build:artifacts","build:artifacts":"hardhat compile && hardhat run scripts/export-addresses.ts --network anvil"},"_npmUser":{"name":"0xheyjo","email":"sendmailtojoshi@gmail.com"},"_npmVersion":"10.9.2","description":"## [Uniswap v2 deep dive](./Uniswap.md)","directories":{},"sideEffects":false,"_nodeVersion":"22.17.0","dependencies":{"@uniswap/v2-core":"^1.0.1","@uniswap/v2-periphery":"^1.1.0-beta.0"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.5.0","ethers":"^6.15.0","hardhat":"^2.26.3","ts-node":"^10.9.2","typechain":"^8.3.2","typescript":"^5.9.2","@types/chai":"^4.3.20","@types/node":"^24.3.0","@types/mocha":"^10.0.10","patch-package":"^8.0.0","solidity-coverage":"^0.8.16","@typechain/hardhat":"^9.1.0","@typechain/ethers-v6":"^0.5.1","hardhat-abi-exporter":"^2.11.0","hardhat-gas-reporter":"^2.3.0","@nomicfoundation/hardhat-ethers":"^3.1.0","@nomicfoundation/hardhat-verify":"^2.1.1","@nomicfoundation/hardhat-toolbox":"^6.1.0","@nomicfoundation/hardhat-ignition":"^0.15.13","@nomicfoundation/hardhat-chai-matchers":"^2.1.0","@nomicfoundation/hardhat-ignition-ethers":"^0.15.14","@nomicfoundation/hardhat-network-helpers":"^1.1.0"},"_npmOperationalInternal":{"tmp":"tmp/uni-v2-artifacts_1.0.0_1755667889726_0.4340124500446916","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@0xheyjo/uni-v2-artifacts","version":"1.1.0","devDependencies":{"@nomicfoundation/hardhat-chai-matchers":"^2.1.0","@nomicfoundation/hardhat-ethers":"^3.1.0","@nomicfoundation/hardhat-ignition":"^0.15.13","@nomicfoundation/hardhat-ignition-ethers":"^0.15.14","@nomicfoundation/hardhat-network-helpers":"^1.1.0","@nomicfoundation/hardhat-toolbox":"^6.1.0","@nomicfoundation/hardhat-verify":"^2.1.1","@typechain/ethers-v6":"^0.5.1","@typechain/hardhat":"^9.1.0","@types/chai":"^4.3.20","@types/mocha":"^10.0.10","@types/node":"^24.3.0","chai":"^4.5.0","ethers":"^6.15.0","hardhat":"^2.26.3","hardhat-abi-exporter":"^2.11.0","hardhat-gas-reporter":"^2.3.0","patch-package":"^8.0.0","solidity-coverage":"^0.8.16","ts-node":"^10.9.2","typechain":"^8.3.2","typescript":"^5.9.2"},"dependencies":{"@uniswap/v2-core":"^1.0.1","@uniswap/v2-periphery":"^1.1.0-beta.0"},"exports":{".":"./package.json","./abi/*":"./export/abi/*","./addresses/*":"./export/frontend/*"},"sideEffects":false,"scripts":{"abi:build":"hardhat compile","deploy:dev":"npm run abi:build && hardhat ignition deploy ignition/modules/UniV2.ts --network anvil --reset","export:dev":"npm run abi:build && hardhat run scripts/export-addresses.ts --network anvil","build:artifacts:dev":"npm run deploy:dev && npm run export:dev","deploy:stage":"npm run abi:build && hardhat ignition deploy ignition/modules/UniV2.ts --network sepolia","export:stage":"npm run abi:build && hardhat run scripts/export-addresses.ts --network sepolia","build:artifacts:stage":"npm run export:stage","deploy:prod":"npm run abi:build && hardhat ignition deploy ignition/modules/UniV2.ts --network mainnet","export:prod":"npm run abi:build && hardhat run scripts/export-addresses.ts --network mainnet","build:artifacts":"npm run build:artifacts:dev","prepublishOnly":"npm run build:artifacts"},"_id":"@0xheyjo/uni-v2-artifacts@1.1.0","gitHead":"0eec6d00bd41112550954b8f0eea7b6c5e852e90","description":"## [Uniswap v2 deep dive](./Uniswap.md)","_nodeVersion":"22.17.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-U18Ty761LrGDSUR0gj+dbRz2sVmjQPMx9zhSXKZdXZLuYCZ7vuRVJ0eXEHyIBw7m6llMDbiONkNmfy83rVA/0w==","shasum":"a595220ad26638696fdd6ec42f47148b74689ff1","tarball":"https://registry.npmjs.org/@0xheyjo/uni-v2-artifacts/-/uni-v2-artifacts-1.1.0.tgz","fileCount":13,"unpackedSize":99199,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC3Asp1k6X7VsQENBM8DecO9XF7tjDKrruRgrg/YWz1XgIgVK+oB4QFtQ/BQ1eV/AOaEbrNvs76tOoaQOgs4xNGMak="}]},"_npmUser":{"name":"0xheyjo","email":"sendmailtojoshi@gmail.com"},"directories":{},"maintainers":[{"name":"0xheyjo","email":"sendmailtojoshi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/uni-v2-artifacts_1.1.0_1755825241407_0.08805405408599265"},"_hasShrinkwrap":false}},"time":{"created":"2025-08-20T05:31:29.604Z","modified":"2025-08-22T01:14:01.789Z","1.0.0":"2025-08-20T05:31:30.000Z","1.1.0":"2025-08-22T01:14:01.599Z"},"description":"## [Uniswap v2 deep dive](./Uniswap.md)","maintainers":[{"name":"0xheyjo","email":"sendmailtojoshi@gmail.com"}],"readme":"# Uniswap V2 playground\n\n## [Uniswap v2 deep dive](./Uniswap.md)  \n\nThis project deploys Uniswap V2 locally. I am running foundry anvil but hardhat local node can be used too.\n\n\n\n## Compiler version and hardhat settings \n- UniV2, Univ2periphery and my Token contracts has different compiler version\n- So hardhat.config.ts has settings for different versions\n- Also in order to import Uni contracts, I create two sol files ImportCore.sol and ImportPeriphery.sol\n- These imports have to be in different files as the compiler version is different for both\n\n\n## v2-core contracts\n\n1. UniswapV2Pair.sol (Main contract which has pairs, swap, update(TWAP) etc)\n2. UniswapV2Factory.sol (Main contract which creates pairs, and setsFee)\n3.UniswapV2Router02 (All najor operations are orchestrated from here, addLiquidity,removeLiquidity, swapforTokens,getAmountIn getAmountOut etc) \n4. UniswapV2Library.sol (getPairs(), hardcoded initcode as seen above, sortTokens() for deterministic ordering, getReserves etc )\n5. UniswapV2ERC20.sol (ERC 20 for LP tokens, have Permit functionality)  \n6. UniswapV2OracleLibrary (Helpers for TWAP calculation)\n7. UniswapV2Migrator (Migaret from v1 to v2)\n\n\n\n\n\n\n## A note on pairFor() method issues\n- In the UniswapV2Library.sol, initcode hash is hardcoded is the pairFor method 0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f\n- This is the hex of the constructor code for UniswapV2Pair.sol\n- My compiler could not produce the same hex as was hardcoded in Uniswap code. Not sure why. So I has to change the initcode to what my compiler was generating\n- with this you will get the pair corectly\n```shell\n    // calculates the CREATE2 address for a pair without making any external calls\n    // Create 2 formula address = keccak256(0xff + deployer + salt + bytecodeHash)[12:]\n    function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {\n        (address token0, address token1) = sortTokens(tokenA, tokenB);\n        pair = address(uint(keccak256(abi.encodePacked(\n                hex'ff', // CREATE2 prefix\n                factory, // Factory contract address\n                keccak256(abi.encodePacked(token0, token1)), // Salt\n                hex'e699c2c70a1e9ca16c58b40782745b5d609738b755845b6ee18a18d21352f753' // init code hash\n            ))));\n    }\n```\nwhere hex'e699c2c70a1e9ca16c58b40782745b5d609738b755845b6ee18a18d21352f753' is the bytecode of UniswapV2Pair.sol (the constructor part). \nThis might be different if you do this in future or with different compiler settings.\n\n\n- As I made changes in my Node Modules to make this work. These changes would not persist for someone who takes my code and does npm install, so I will persist these changes using patch-package\n```shell\nnpm i -D patch-package\nnpx patch-package @uniswap/v2-periphery\n```\n\n### Compiling the contracts which also generates typings\n```shell\n## clean artifacts, not needed everytime\nrm -rf cache artifacts typechain typechain-types\n## clean and compile, needed only if you added new contracts, probablu can just compile without cleaning\nnpx hardhat clean && npx hardhat compile    \n```\n\n### Running tests\n```shell\nnpx hardhat test ./test/AMM-v2.test.ts --network anvil  \n```\n\nYou can report gas in test if you want\n```\nREPORT_GAS=true npx hardhat test ./test/AMM-v2.test.ts --network anvil  \n```\n\nIf you want to use local hardhat node instead of anvil, if not SKIP\n```npx hardhat node```\n\n\n### Deploy to network of choice, i deploy to anvil\n\n```npx hardhat ignition deploy ignition/modules/UniV2.ts --network anvil```\n\n\n\n\n## Publish the contracts to npm for consumption by UI\n\nnpm run build:artifacts\nnpm pack          # sanity check tarball contents\nnpm publish --access public --ignore-scripts\n\n\n\nTo Update version\nnpm version patch (minor/major)","readmeFilename":"README.md"}