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 🙏

© 2026 – Pkg Stats / Ryan Hefner

erc20-tax-token

v1.0.0

Published

Minimal and gas optimized implementations of ERC20 swap tax schemes.

Readme

erc20-tax-token

Minimal and gas optimized implementation of an ERC20 token with taxable swaps.

ERC20TaxSwap

ERC20TaxSwap - "Basic functionality for token that taxes swaps through a UniswapV2 pair"

Features

  • Taxes are taken on swaps to any router contracts
  • Taxes are accumulated in the contract until the contract balance > swapThreshold, at which point a swap to $ETH will be triggered during the next transfer or sale
  • Taxes are divided into three (optional) components
    • teamFee
    • protocolFee (e.g. revenue shares)
    • liquidityFee (distributed back into the LP)
  • The max the contract can swap at once is determined by the maxContractSwap variable

Deployment

A test contract is deployed on Goerli to:

0x8CD907A8502258CD7bb959B0BDEe179255B132F3

The fee breakdown is:

teamFee      = 1;
protocolFee  = 1;
liquidityFee = 1;

You can try interacting with it on Uniswap. Make sure to set slippage greater than 3%.

Configuration

A blacklist and transaction limits can be enabled in the constructor with limitsActive and blacklistActive arguments. Furthermore, various configuration parameters have been set to reasonable values, but can be updated (warning: misconfiguring these variables can cause problems):

// The balance at which the contract attempts to swap to ETH
swapThreshold = initialSupply.mulDiv(5, 10000); // 0.05%

// The max that can be swapped at once
maxContractSwap = initialSupply.mulDiv(50, 10000); // 0.5%

// If limits are active, the max size of a buy or sell
maxTransaction = initialSupply.mulDiv(100, 10000); // 1%

// If limits are active, the max wallet size
maxWallet = initialSupply.mulDiv(100, 10000); // 1%

Minting

By default, the initialSupply is minted in the constructor and the token is no longer mintable. To change this, you would need write a new function utilizing the ERC20 _mint(address to, uint amount) function.

Note: It's recommended to keep initialSupply as a hard cap and base the mint schedule around this hard cap. This way parameters like swapThreshold can be based around the initialSupply, whereas a tax token with a completely unpredictable supply would be hard to configure.

Testing

Add a .env file with a valid RPC endpoint as indicated in .env.example:

MAINNET_RPC_URL = https://mainnet.infura.io/v3/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Then run:

forge install
npm install
npm run build
npm run test

Note: the RPC endpoint must be Mainnet Ethereum (or Goerli), otherwise the V2 router address needs to be updated.

Safety

This is experimental software and is provided on an "as is" and "as available" basis.