Mieszko Manijak

ERC-20 Transferable Timelock: Security Hardening Against Mint-Burn Loop Attacks

The ERC-20 transferable timelock protects DeFi tokens against mint-burn loop attacks without compromising interoperability or adding new trust assumptions.

Two blocks side by side. In block N, freshly minted tokens are transferable but not burnable, while older tokens are transferable and burnable. In block N+1 the timelock has expired, so those fresh tokens are burnable too.

What is the ERC-20 transferable timelock?

The ERC-20 transferable timelock protects DeFi tokens against mint-burn loop attacks without compromising interoperability or adding new trust assumptions. Newly minted tokens stay transferable but can’t be burned until the next block.

I recently posted an ERC-20 extension proposal to Ethereum Magicians for discussion. In this post I’m explaining the pattern behind it in plainer terms: what problem it addresses, how it works, and where its protection ends.

Many tokens can be permissionlessly minted and burned. LP tokens, vault shares and liquid staking tokens (LSTs) all convert to and from an underlying position at some rate. If someone can mint, do something that moves that rate, and burn again inside a single transaction (or block), they can extract value from the other holders. Flash loans made this sequence cheap, and a long list of exploits follows the same notorious mint → action → burn pattern.

An obvious defense would be to require a gap between creating supply and destroying it: Tokens minted in a block cannot be burned until the next block. While simple conceptually, implementing it without breaking transfers and without introducing substantial new risks turns out not to be trivial.

Why a per-account lock is not enough

A naive version records the block of each account’s last mint and refuses burns from that account in the same block. It comes with two serious problems:

  1. It locks the account’s older tokens too.
  2. Anyone can step around it by transferring the new tokens to a second account and burning from there, so it doesn’t work.

You can close that bypass by blocking transfers for the timelocked account. But that, in turn, breaks composability: (at least) the freshly minted token can no longer be deposited, swapped or lent in the same transaction that mints it.

That leads us to the next idea: let the lock follow the tokens. If the lock is still tracked per account, though, it becomes a griefing tool. Send someone a tiny fresh amount and their whole balance is locked for the block. There’s a good name for it: taint.

This can be seen in production Solidity contracts. Conic Finance’s LpToken tracked taint per account, and MixBytes reported it as M-10, “LpToken taint griefing” (report). Their recommendation was that a holder with 1,000 older tokens who receives one tainted token should still be able to burn the original 1,000. Conic’s answer was a minimum transfer size for taint. A threshold like that reopens the bypass for transfers below it.

Aave met a related problem with stkAAVE. Redeeming stkAAVE for AAVE requires a cooldown, and each account stores a single cooldown timestamp. When stkAAVE arrives by transfer, Aave blends the sender’s timing into the recipient’s timestamp, weighted by amount. A holder with 100 tokens cooling down since time 800 who receives 100 fresh tokens at time 1,000 ends up at 900, so the incoming transfer delays redemption of their older balance.

Both designs keep one piece of temporal state per account, and so both let a transfer change the treatment of tokens the recipient already held. Tracking the affected amount and the time variable separately avoids that: new tokens carry their own timelock, and the recipient’s older balance stays untainted.

How can it be done?

The fix is to track how much of each balance is timelocked, rather than whether an account is. Every account carries a timelocked amount next to its balance:

unlocked = balanceOf(account) - timelocked(account)

A mint adds to the recipient’s timelocked amount. A burn may only use the unlocked part. A transfer spends the sender’s unlocked tokens first, and only the excess carries its timelock to the recipient. Everything expires when block.number changes.

Take Alice with 1,000 old tokens. Someone sends her one freshly minted token:

Alice:
    balance        1,001
    timelocked         1
    unlocked       1,000

She can still burn her 1,000. The new token stays fully transferable. Only its amount is temporarily excluded from burns.

The transfer order matters more than it first appears. Spending unlocked tokens first keeps timelocks from spreading. An AMM holding a large unlocked balance and a small timelocked one hands out the timelocked tokens only after the unlocked ones run out, so ordinary traders rarely receive them.

The opposite rule, timelocked first, looks stricter. It seems to stop someone from parking fresh tokens in a pool and buying unlocked ones back. It doesn’t: the attacker simply buys first, mints, burns the unlocked tokens and sells the fresh ones afterwards, or sandwiches someone else’s swap. That costs the same round trip. Timelocked first only spreads timelocks to bystanders, so unlocked first wins outright.

Expiry needs no cleanup. Each account stores an amount and the block it was set in. If the stored block is not the current one, the timelocked amount reads as zero, and the next write overwrites the stale record.

What it guarantees, and what it doesn’t

It is worth being precise here, because the pattern is easy to oversell.

It does not guarantee that nobody can mint and burn equal amounts in one block. Fresh tokens can be swapped for mature ones, meaning older unlocked tokens: sell them into a pool, buy mature tokens back, and burn those. I call this an inventory swap. The timelock doesn’t vanish, since the pool now holds it, but the attacker has traded around it.

What it does guarantee is a hard cap on burnable supply:

total burns during block N <= totalSupply at the start of block N

Supply minted in a block can never fund burns in that same block. Timelocked amounts move between accounts but can’t be destroyed.

On top of that cap sits an economic cost. Getting around the lock means trading fresh supply for mature supply, which costs at least a round trip in fees and slippage. The burn size is limited by how much mature liquidity the attacker can reach. That is a cost, not a guarantee: a profitable enough attack pays it, and deep liquidity makes it small.

One caveat is serious. If the token itself can be flash borrowed at the cost of the flash loan fee. Borrow mature tokens, mint, burn the borrowed ones, repay with fresh ones. Protocols that list the token in venues offering cheap flash loans weaken the protection accordingly.

So the pattern kills the trivial mint → transfer → burn bypass, and makes every other bypass pay for access to older supply. I think that is a useful property. It is not a complete defence on its own.

In practice

Vaults. ERC-4626 is the natural home for this, since redeem and withdraw burn shares. A vault using the pattern reports the limit through the functions integrators already call: maxRedeem(owner) returns at most the unlocked share balance, and maxWithdraw follows from it. The preview functions stay account independent.

What breaks. The ERC-20 interface stays the same, but burn semantics change. Integrations that burn tokens received in the current block may need to account for the timelocked balance, even if they took no part in minting. Such flows are rare. The clear casualty is conventional ERC-3156 flash minting of the token itself: repaying by burning the minted supply fails unless the borrower holds enough unlocked inventory. Liquidations are mostly fine, because seized shares are usually old.

L2s. The lock lasts until the EVM NUMBER value changes. On Ethereum that is one block. On Arbitrum, block.number approximates the L1 block, so the lock spans several L2 blocks. Using NUMBER keeps the pattern portable, at the cost of a duration that varies by chain.

Code. The reference implementation comes in two versions. ERC20TransferableTimelock is a readable OpenZeppelin v5 extension that hooks _update, with fuzz tests and a stateful invariant suite checking that transfers conserve the total timelocked amount. ERC20TransferableTimelockOptimised is a gas-optimised Solady variant that packs the timelocked amount and its block number into a single storage slot.

Open questions

I’m not sure this deserves its own ERC. Vaults can already expose the limit through maxRedeem, and the accounting fits in a library extension. The case for a standard is that routers and aggregators would get one uniform way to ask how much an account can burn right now, instead of discovering it through reverts.

I’d also like to hear about prior implementations that track a transferable timelock at the amount level, and whether the security boundary above is worth the added state.

If you work on vaults, AMMs or token standards and have an opinion on any of this, please comment on the Ethereum Magicians thread. Criticism of the concept, the implementation, or the case for standardising it is all welcome there.