npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jgensler8_2/hardhat-swapper-utils-ts

v0.0.8

Published

Hardhat TypeScript plugin boilerplate

Downloads

3

Readme

hardhat-swapper-util-ts

recompiles various UniswapV2 contracts.

Note: this differs from the existing hardhat-plugin-deploy-v3 in that it completely recompiles the Uniswap V2 contracts. As the Uniswap periphery library depends on a hash of the V2Pair contract, I have also build a package to compensate for the hardcoded hash (link).

Installation

  1. Install: npm install --save-dev @jgensler8_2/hardhat-swapper-util-ts .
  • Note: this has several common peer dependencies and might cause errors if you already have those as devDependencies.
  1. Install contract dependencies: npx hardhat run install-deps .
  1. Update your hardhat config:
// file: hardhat.config.js

// 3.1 import 
const swapper_utils = require('@jgensler8_2/hardhat-swapper-utils-ts');

{
// 3.2: uniswap depends on older version of compilers, use ones exposed by this package
  solidity: {
    compilers: [
      ...swapper_utils.compilers
    ],
  },
// 3.3: recompiling uniswap leads to larger bytecode
  networks: {
    hardhat: {
      allowUnlimitedContractSize: true,
    }
  },
}
  1. Access Swapper utils via HRE:
// file: your-script.js

const hre = require("hardhat");

async function main() {
    let su = hre.su
    let state = su.defaultState()
    // deploy all at once
    state = await su.autoDeployAll(state)
    /*
    // or deploy manually
    state = await su.autoDeployTokens(state)
    state = await su.autoDeployUniswapV2Factory(state)
    state = await su.autoDeployUniswapV2Pairs(state)
    state = await su.autoDeployUniswapV2Router(state)
    state = await su.autoDripAndInitializePools(state)
    */

    const amountAIn = 10000
    const tokenA = state.tokens["TOKA"]
    const tokenB = state.tokens["TOKB"]
    let amounts = await state.uniswapV2Router02.getAmountsOut(amountAIn, [tokenA.address, tokenB.address])

    console.log(`amounts: ${amounts}`)
}

main()
    .then(() => process.exit(0))
    .catch(error => {
        console.error(error);
        process.exit(1);
    });
  1. Finally, run your script:
$ npx hardhat run your-script.js
amounts: 10000,906

Testing

Running npm run test will run every test located in the test/ folder. They use mocha and chai, but you can customize them.

Linting and autoformat

All of Hardhat projects use prettier and tslint.

You can check if your code style is correct by running npm run lint, and fix it with npm run lint:fix.

Building the project

Just run npm run build ️👷