Sub topic 13
Rug Pulls, Honeypots, and Other Technical Risks
This chapter assumes you know what an ERC-20 token is, how a liquidity pool prices trades with x * y = k, and how to read short Solidity snippets. It covers the ways a token's code and its liquidity can be used against buyers, and which of those risks you can check before you buy.
Why these risks cluster around memecoins and new tokens
Anyone can deploy an ERC-20 token for a few dollars and list it on an automated market maker (AMM), a pool-based exchange. No review happens before the token is tradable. A utility or governance token from an established project has audits, public teams, and a track record. A new memecoin often has none of these, so the buyer has to verify the contract and the liquidity themselves.
The risks fall into two groups:
- Liquidity risks: the money in the pool can be removed or made unreachable.
- Contract risks: the token's code treats some holders differently, or the owner can change the rules after you buy.
Rug pulls
A rug pull is a scam where the creators draw value out of a project and leave holders with a token nobody wants. There are three common forms.
Liquidity removal
A pool holds two assets, for example ETH and MEME. The deployer usually provides the first liquidity and receives LP (liquidity provider) tokens in return. LP tokens are a claim on the pool's reserves. If the deployer still holds them, they can redeem them at any time and withdraw most of the ETH that buyers deposited.
The chapter on liquidity pools showed how thin reserves cause price impact. A liquidity removal is the extreme case. Once the ETH side is gone, the pool still quotes a price, but selling even a small amount returns almost nothing.
Supply dumping
In this form the pool stays intact. The deployer or insiders hold a large share of the supply, often through many wallets, and sell it into the pool once buyers arrive. The constant-product formula guarantees that large sells drive the price down, and every buyer ends up holding a token worth a fraction of what they paid.
Hidden minting
Some contracts keep a mint function restricted to the owner. The owner creates new tokens and sells them. This is a rug pull through dilution. The fixed-supply MemeToken shown earlier in this tutorial has no mint function, so this attack is impossible for it. That is a property you can confirm by reading the code.
Honeypots
A honeypot is a token you can buy but cannot sell. The buy transaction succeeds, the balance appears in your wallet, and the price chart looks healthy. The contract blocks or sabotages the sell.
Honeypots work because ERC-20 lets a contract run arbitrary logic inside transfer and transferFrom. Selling to a pool is a transfer to the pool's address, so the contract can detect a sale and react to it.
Common mechanisms:
- Blocklist or allowlist: only addresses the owner approves can sell. Everyone else's sell reverts.
- Extreme sell tax: the contract takes 90% to 100% of the amount on sales. The transaction succeeds but you receive almost nothing.
- Trading switch: the owner can disable trading at any time with a flag, then re-enable it for themselves.
- Hidden conditions: sells fail unless some state is true, such as a timestamp, a maximum transaction size, or a cooldown the owner can set to an impossible value.
The following contract is a deliberately simplified example for study. It looks like an ordinary token. The sell restriction sits in one require.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract HoneypotExample is ERC20 {
address public immutable owner;
address public pair; // the AMM pool address
mapping(address => bool) public canSell;
constructor() ERC20("Bait", "BAIT") {
owner = msg.sender;
canSell[msg.sender] = true;
_mint(msg.sender, 1_000_000_000 * 10 ** decimals());
}
function setPair(address newPair) external {
require(msg.sender == owner, "not owner");
pair = newPair;
}
function _update(address from, address to, uint256 value) internal override {
// A transfer TO the pool is a sell.
if (to == pair && pair != address(0)) {
require(canSell[from], "sell blocked");
}
super._update(from, to, value);
}
}Nothing in the visible interface warns you. balanceOf and transfer between wallets work normally. Only a sale to pair fails, and only for addresses the owner never added to canSell.
Owner privileges that change the rules
Not every dangerous design is a pure scam. Many contracts keep powers that let the owner alter the token after launch. Treat each as a risk to weigh.
| Privilege | What it allows | What to check |
|---|---|---|
| Mint | Create new supply | Is there a `mint` function, and who can call it? |
| Pause | Stop all transfers | Who holds the pause role, and is it a timelock or a single key? |
| Blacklist | Freeze specific addresses | Can the owner block any holder? |
| Change fees | Raise buy or sell tax | Is there a maximum fee enforced in code? |
| Upgrade (proxy) | Replace the logic entirely | Who is the proxy admin? Is there a delay? |
| Ownership | Control all of the above | Has ownership been renounced or moved to a multisig? |
A proxy contract forwards calls to a separate logic contract that the admin can swap. This is a legitimate pattern for fixing bugs, but it means the code you audited today may not be the code running tomorrow. An upgradeable token with a single-key admin offers little protection against a rug pull, whatever the current code says.
Renouncing ownership is often advertised as proof of safety. It removes the owner's privileges only if the contract truly has no other path to them. A renounced token can still be a honeypot if the restriction was written into the logic from the start, as in the example above.
Other technical risks
Fee-on-transfer and rebasing tokens
Some honest tokens take a fee on every transfer, or change balances automatically. These break assumptions in other contracts. If a pool expects to receive 100 tokens and receives 95, its accounting can fail or be exploited. Many interfaces reject such tokens or require special handling.
Unlimited approvals
ERC-20 trading works through approve. You grant a spender permission to move your tokens, often with an "unlimited" allowance. If that spender is a malicious or later-compromised contract, it can drain the approved balance without any further signature from you. Review and revoke old allowances periodically.
Fake tokens and look-alikes
Contract addresses are unique, but names and symbols are not. Anyone can deploy a token called "USDC" or copy a popular memecoin's logo. Always take the contract address from the project's official source, never from a search result or a message.
Smart contract bugs
Honest code can still fail. Reentrancy, rounding errors, and broken access control have drained real protocols. An audit reduces this risk but does not remove it. It covers a specific code version at a specific time.
Concentrated holdings
Check the holder distribution on a block explorer. If the top ten wallets, excluding the pool and known locker contracts, hold a large share, a few sales can crush the price. Insiders also split holdings across wallets to hide this.
What you can verify before buying
Most of these checks need only a block explorer and a few minutes.
- Is the source code verified? Unverified bytecode cannot be reviewed. Treat it as a strong warning.
- Read the owner functions. Search for
mint,blacklist,pause,setFee,setTax, andonlyOwner. - Check who the owner is. An externally owned address, a multisig, a timelock, or the zero address each imply different risk.
- Check the liquidity. Who holds the LP tokens? If a locker contract holds them, read its unlock date. If the deployer's wallet holds them, the liquidity can leave at any time. Burned LP tokens, sent to a dead address, cannot be redeemed.
- Check holder distribution. Look at the share held by the top wallets and by the deployer.
- Simulate a sell. Free honeypot-detection tools simulate a buy and sell and report the effective tax. They can miss conditions that only trigger later, so a pass is not a guarantee.
- Test with a small amount. Buy a tiny amount and sell it back before committing more. This catches many honeypots, but not ones that activate after a delay.
Estimating the damage of a liquidity pull
The same constant-product math from the liquidity chapter shows how little a holder recovers after liquidity leaves. This script compares the sale of 100,000 MEME before and after the deployer withdraws 95% of the pool.
def swap_out(reserve_in, reserve_out, amount_in, fee=0.003):
after_fee = amount_in * (1 - fee)
return reserve_out * after_fee / (reserve_in + after_fee)
meme_reserve, eth_reserve = 1_000_000, 100
sell = 100_000
before = swap_out(meme_reserve, eth_reserve, sell)
# The deployer redeems LP tokens covering 95% of the pool
meme_after, eth_after = meme_reserve * 0.05, eth_reserve * 0.05
after = swap_out(meme_after, eth_after, sell)
print(f"Before the pull: {before:.2f} ETH")
print(f"After the pull: {after:.2f} ETH")Before the pull the sale returns about 9.06 ETH. After it, the pool holds only 5 ETH, so the same sale returns about 3.33 ETH at best, and the quoted price per token falls with it. A larger sale gets closer to the 5 ETH ceiling, which is all that remains in the pool.
Summary of the failure modes
Exercise
A new memecoin has verified source code, renounced ownership, and its LP tokens are held in a locker contract until next year. A buyer concludes it is safe. Name two risks that these three facts do not rule out.
Show answer
Renounced ownership and locked LP tokens do not rule out a honeypot, because a sell restriction such as a blocklist or an extreme tax can be written into the transfer logic from the start and need no later owner action. They also do not rule out concentrated holdings: the deployer and insiders may hold a large share of supply in other wallets and dump it into the pool. A proxy admin could also still exist separately from the token's owner role. The buyer should read the transfer logic, check holder distribution, and simulate a sell.
Exercise
In the Python example, a pool holds 1,000,000 MEME and 100 ETH. Why does the same 100,000 MEME sale return much less ETH after the deployer withdraws 95% of the pool, even though no one changed the token's code?
Show answer
The constant-product formula prices a trade relative to the reserves. After the withdrawal the pool holds only 50,000 MEME and 5 ETH. A sale of 100,000 MEME is now twice the MEME reserve, so it moves the price heavily, and the output can never exceed the 5 ETH left in the pool. The sale returns about 3.33 ETH instead of about 9.06 ETH.