Sub topic 2
Liquidity Removal, Hidden Minting, and Honeypots
This chapter assumes you know what a token is, how a wallet sends one, and what a liquidity pool does. You should also be able to read a short Solidity contract. The Python samples need Python 3.
Liquidity removal
A liquidity pool holds two assets, such as ETH and a token. The people who added the ETH usually hold LP (liquidity provider) tokens, which let them withdraw it. If the deployer removes most of the ETH, the price collapses and holders cannot sell at a fair price.
This script uses the constant-product formula found in Uniswap v2-style pools:
def amount_out(amount_in, reserve_in, reserve_out, fee=0.003):
amount_in_after_fee = amount_in * (1 - fee)
return reserve_out * amount_in_after_fee / (reserve_in + amount_in_after_fee)
eth_reserve = 100.0
token_reserve = 1_000_000.0
print(amount_out(100_000, token_reserve, eth_reserve))
print(amount_out(100_000, token_reserve * 0.1, eth_reserve * 0.1))The first call returns about 9.07 ETH. After 90% of the liquidity is withdrawn, the same 100,000 tokens return about 4.99 ETH.
Hidden minting
A mint function creates new tokens. Some legitimate tokens need one, but a hidden mint lets the owner add supply whenever they want. New tokens can then be sold into the market while the price is high.
Honeypots
A honeypot is a token that can be bought but not sold. The contract blocks transfers from ordinary holders while letting the owner trade freely.
| Pattern | What it does | Sign to look for |
|---|---|---|
| Blacklist | Owner blocks chosen addresses | A function such as `setBlocked` |
| Hidden mint | Owner creates new supply | A `mint` function the owner can call |
| Pause | Owner freezes all transfers | A `pause` function |
The contract below combines a blacklist with owner-only control:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// Simplified, not a full ERC-20. It shows a red-flag pattern.
contract RedFlagToken {
address public owner;
mapping(address => bool) public blocked;
mapping(address => uint256) public balanceOf;
constructor() {
owner = msg.sender;
}
function setBlocked(address account, bool value) external {
require(msg.sender == owner, "not owner");
blocked[account] = value;
}
function transfer(address to, uint256 amount) external returns (bool) {
require(!blocked[msg.sender], "blocked");
balanceOf[msg.sender] -= amount;
balanceOf[to] += amount;
return true;
}
}Measuring holder concentration
Concentration shows how much of the supply a few wallets control. Exclude pool and burn addresses, because they do not represent people who can sell.
def top_holder_share(balances, n=10, excluded=()):
held = {a: b for a, b in balances.items() if a not in excluded}
total = sum(held.values())
if total == 0:
return 0.0
top = sorted(held.values(), reverse=True)[:n]
return sum(top) / total
balances = {"0xA": 600, "0xB": 150, "0xC": 100, "0xPool": 500, "0xD": 50}
print(top_holder_share(balances, n=2, excluded={"0xPool"}))The script prints about 0.83. The two largest wallets hold 83% of the supply outside the pool.
Checking a token on a block explorer
Follow these steps on a block explorer such as Etherscan:
- Open the token contract address.
- Open the Holders tab and note the share held by the top wallets.
- Open the Contract tab and confirm the source code is verified. Search it for
mint,pause, andblacklist. - Find the LP token holder for the trading pair. Check whether the deployer holds it.
- Review the Transfers tab for large sales from the deployer address.
Exercise
Using the holder example above, what share does the largest wallet hold when 0xPool is excluded?
Show answer
600 / 900 = 0.67, so the largest wallet holds about 67% of the supply outside the pool.