Honeypot shield.
If you can't sell it, you can't buy it. Right after your buy, the router really sells 1% of it back in a sub-call that always reverts, then decides from the result.
The revert-probe
- 01Buy
The router executes your buy legs. The tokens are held by the router for the rest of the transaction.
- 02Probe
It calls
this.probeSell(leg, token, amount)insidetry/catch, with 1% of the amount you bought, through the pool that filled most of the last hop. - 03Real sell
probeSellperforms a real sell of that 1% from the router's address and measures what comes out. - 04Always revert
probeSellthen always reverts withProbeResult(amountOut, ok). The revert undoes the test-sell, so your full amount is still there. - 05Decode and decide
The router compares what the 1% sold for with what it cost in your buy. That round-trip cost is the measured tax. At or below your
maxSellTaxBps: deliver. Above it, or if the sell failed: revert everything withShieldBlocked.
What gets blocked
The whole swap reverts, and you lose only gas, if:
- the test-sell fails: the token or pool reverts on a sell from the router right now (a hard honeypot, a sell blacklist that covers the router, a sell switch that is already off),
- the round-trip cost of buying and immediately selling the 1% is above your
maxSellTaxBps(default 10%). It includes pool fees, buy and sell tax and any hook fee, and leaves out your own price impact.
In Solidity
uint256 public constant PROBE_BPS = 100; // test-sell 1% of the bought amount
error ProbeResult(uint256 amountOut, bool ok);
error ShieldBlocked(address token, uint256 taxBps); // 10_000 = the sell failed
/// Only callable by the router itself. ALWAYS reverts with ProbeResult.
function probeSell(Leg calldata leg, address token, uint256 amount) external {
if (msg.sender != address(this)) revert Unauthorized();
uint256 out;
bool ok;
try this.probeExec(leg, token, amount) returns (uint256 o) { out = o; ok = true; } catch {}
revert ProbeResult(out, ok); // token / pool revert data never escapes
}
/// leg = the leg that filled most of the last hop; legSpent / legOut = what that leg paid and got.
function _shield(Leg memory leg, address token, uint256 legSpent, uint256 legOut, uint256 maxTaxBps) internal {
uint256 q = legOut * PROBE_BPS / 10_000;
uint256 taxBps = 10_000;
try this.probeSell(leg, token, q) {} catch (bytes memory r) {
if (r.length == 68 && bytes4(r) == ProbeResult.selector) {
(uint256 out, bool ok) = abi.decode(_tail(r), (uint256, bool));
uint256 expected = q * legSpent / legOut; // the buy's own average price
if (ok) taxBps = out >= expected ? 0 : (expected - out) * 10_000 / expected;
}
}
if (taxBps > maxTaxBps) revert ShieldBlocked(token, taxBps);
}
Extra static checks (app side)
The app and the Scanner run cheaper checks over RPC before you even quote. They inform the verdict but do not replace the probe:
| Check | How |
|---|---|
| Owner / renounced | owner() read; zero address means renounced |
| Mint function | Mint selectors present in the bytecode |
| Proxy / upgradeable | EIP-1967 implementation slot, proxy patterns in bytecode |
| Pausable | Pause selectors in the bytecode |
| Blacklist | Blacklist / blocklist selectors in the bytecode |
| Buy and sell tax | eth_call buy-then-sell with state overrides |
| LP lock | Where the pool's liquidity tokens sit, when detectable |
| Holder concentration | Top holders' share, built from on-chain transfer logs |
What it catches, and what it doesn't
The probe proves one thing: right now, the router can sell 1% of this buy through this pool at an acceptable cost. Tokens built to pass that test still pass it. Plainly, the shield does not catch:
- Tokens that whitelist the router. The test-sell comes from the router's address. A token that lets the router sell but blocks your wallet passes the probe.
- Sells blocked later. A token that allows sells now and flips a switch later (owner-controlled tax, a timed blacklist, a trading pause) passes the probe.
- Sells blocked above a size. The probe sells only 1%. A max-sell or max-transaction limit that only bites on larger sells passes it.
- Per-wallet rules. Limits keyed to your wallet (cooldowns, max-wallet, per-holder blacklists) are not exercised by a sell from the router.
- Multi-pool traps. The probe sells through the single pool that filled most of the last hop. A token that only traps sells on other pools passes it.
- A later rug. A dev pulling liquidity tomorrow is a different risk. Watchtower and the launch feed flag liquidity moves and dev sells.