fee-on-transfer
Skill36 starsChanged 5 months agoMITView on GitHub
Detect fee-on-transfer / deflationary / rebasing token accounting bugs — crediting the *passed amount* instead of the measured balance delta. Activate whenever code calls transfer/transferFrom and then credits, mints shares for, or records the literal amount argument, in deposits, AMM swaps, lending collateral, vaults, staking, or bridges — without measuring balanceAfter - balanceBefore.
In this repository44 other files it gives its agents.
- access-controlSkill
- approval-issuesSkill
- caching-and-incrementalSkill
- centralization-riskSkill
- confidence-scoringSkill
- cosmwasmSkill
- cross-chain-messagingSkill
- cross-contract-stateSkill
- delegatecall-risksSkill
- diamond-eip2535Skill
- dos-vectorsSkill
- erc1271-contract-signaturesSkill
- erc4337-account-abstractionSkill
- erc4626-inflationSkill
- false-positive-feedback-loopSkill
- flash-loan-attacksSkill
- initializationSkill
- inline-assemblySkill
- integer-issuesSkill
- intents-erc7683Skill
- known-good-comparisonSkill
- liquidation-cascadeSkill
- mev-frontrunningSkill
- mev-pbsSkill
- multi-pass-self-critiqueSkill
- oracle-manipulationSkill
- oracle-redundancySkill
- permit2-patternsSkill
- pragma-and-addressesSkill
- progress-and-streamingSkill
- reentrancySkill
- restaking-eigenlayerSkill
- selfdestruct-eip6780Skill
- signature-malleabilitySkill
- signature-replaySkill
- solana-anchorSkill
- storage-layoutSkill
- stylus-rustSkill
- token-compatibilitySkill
- tx-context-misuseSkill
- unchecked-callsSkill
- ve-lock-governanceSkill
- vyper-specificSkill
- zk-verifier-bugsSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 66
Read-only quoting that never credits balances is unaffected.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Fee-on-transfer token accounting detection
When this applies
Trigger on any of:
- Deposit/stake/
addLiquiditythat records theamountargument aftertransferFrom - Vault/ERC-4626
depositminting shares proportional to the requested assets, not received - AMM/router updating reserves with the input amount rather than actual receipt
- Lending protocols crediting collateral by passed amount
- Bridges locking/burning
amountthen minting the same amount on the far side - Any flow assuming
received == amountfor arbitrary ERC-20s
Detection patterns
Credit passed amount, not delta (HIGH)
function deposit(uint256 amount) external {
token.transferFrom(msg.sender, address(this), amount);
balanceOf[msg.sender] += amount; // ← amount, but FoT token delivered less
totalDeposited += amount;
}Signal: the contract believes it holds more than it does. On a fee-on-transfer token (USDT with fee switch enabled, PAXG, many meme tokens), totalDeposited exceeds the real balance — last withdrawers are insolvent, or an attacker mints excess shares/LP.
AMM reserve desync (HIGH)
Router records input amountIn into reserves but the pair received amountIn - fee. k invariant is computed on phantom reserves, mispricing the swap and letting an attacker drain the shortfall over time (the Uniswap-V2-style "supports FoT" *SupportingFeeOnTransferTokens functions exist precisely because of this).
Rebasing double-count (MEDIUM / HIGH)
uint256 shares = amount * totalShares / totalAssets; // totalAssets from stored varSignal: stored totalAssets vs live token.balanceOf(this) diverge as a positive-rebasing token (stETH, aTokens, OHM) grows. Crediting against the stale stored figure under- or over-mints shares; an attacker times deposits around rebase.
Bridge mint mismatch (CRITICAL)
Lock amount on chain A, emit message, mint amount on chain B — but only amount - fee was locked. Repeated deposits accumulate an unbacked mint surplus that can be withdrawn on A by honest users, draining the lockbox.
Severity rubric
| Pattern | Severity | Notes |
| Bridge mints unbacked surplus | Critical | Cross-chain insolvency |
| Vault/LP shares minted on phantom amount | High | Direct over-mint, fund loss |
| AMM reserve recorded as passed amount | High | Mispricing, drainable shortfall |
| Lending collateral over-credited | High | Under-collateralized borrow |
Rebasing stored-vs-live totalAssets drift | Medium | Timing-dependent |
| FoT token on a hard whitelist of non-FoT tokens | Info | Surface closed by policy |
Remediation patterns
- Measure the delta:
uint256 before = token.balanceOf(address(this)); token.transferFrom(...); uint256 received = token.balanceOf(address(this)) - before;and creditreceived. - Reject FoT on entry — if
received != amount, revert (OpenZeppelinSafeERC20does not do this for you). - Use live balance, not stored totals, for rebasing tokens, or wrap them (wstETH) so balances are non-rebasing.
- Token allowlist for assets known not to take a transfer fee; document the assumption.
- On bridges, lock the measured received amount and mint exactly that.
False-positive notes
- A protocol that only ever handles a fixed, audited, non-FoT token (e.g. a WETH-only vault) is safe — note the assumption rather than flagging High.
*SupportingFeeOnTransferTokensrouter variants already measure deltas — don't flag.- Read-only quoting that never credits balances is unaffected.
Related
- [[token-compatibility]] — broader weird-ERC20 behaviors (no return value, blocklists)
- [[erc4626-inflation]] — share-mint math interacts with miscounted assets
- [[cross-chain-messaging]] — bridge mint/lock mismatch surface
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

