I propose an ERC-20 extension that prevents fresh tokens from being burned in the block in which they were minted. The tokens stay transferable and remain compatible with normal DeFi operations.
I think the pattern is worth sharing, but I am not sure this deserves its own ERC, so I am posting it here for feedback on the concept, the implementation, and whether it belongs in a standard.
The extension tracks a timelocked balance for each account. A mint increases the timelocked balance, a transfer can move part or all of it to another account, and a burn can use only the unlocked balance:
unlockedBalance = balanceOf(account) - timelockedBalanceOf(account)
Motivation
Consider ERC-20 tokens with permissionless minting and burning, such as LP tokens, vault shares, and liquid staking tokens. For these tokens, a mint → action → burn sequence in one block exposes a potential attack surface.
A naive solution could record the block of the last mint for each account and prevent that account from burning in the same block. However, it restricts older tokens in the same account, and a user can bypass it by transferring the new tokens to another account. Blocking transfers closes the bypass at the cost of DeFi interoperability and UX.
Another solution is to let the timelock follow the transfer, so that receiving fresh tokens taints the recipient for the rest of the block. Taint tracked at the account level creates a griefing problem: if Alice holds 1,000 old tokens and receives one fresh token, her account is tainted and she cannot burn any of the 1,001.
TransferableTimelock tracks the timelocked amount instead:
Alice:
balance 1,001
timelocked 1
unlocked 1,000
Alice can still burn her 1,000 old tokens. The new token remains transferable and carries the temporary timelock with it.
Fungibility
TransferableTimelock distinguishes between portions of an ERC-20 balance for the purpose of burning, so timelocked and unlocked tokens are technically not fully fungible.
Timelocked tokens can enter shared liquidity pools such as AMMs, vaults, and lending markets, which can later pass the timelock on to another user. Timelocked tokens can also be exchanged for unlocked tokens that already exist in the market.
For example, Alice can sell 100 timelocked tokens to an AMM and buy 100 back. If the AMM holds an older unlocked balance, she could receive unlocked tokens. I call this an inventory swap.
Alice before swap 1:
balance 100
timelocked 100
unlocked 0
Alice after swap 1:
balance 0
timelocked 0
unlocked 0
AMM:
+100 timelocked tokens
Alice after swap 2:
balance 100
timelocked 0
unlocked 100
Alice can now burn the 100 tokens she bought. The timelock did not disappear: the AMM still holds 100 timelocked tokens. Alice replaced timelocked tokens with older unlocked ones. Its feasibility depends on available unlocked liquidity and execution costs. The transfer order determines how unlocked liquidity can be accessed.
Transfer order: unlocked first
In the Unlocked First variant, a transfer MUST use the sender’s unlocked balance first, and move timelocked balance only for the remainder.
For a successful transfer of amount A between two distinct accounts, let U_s be the sender’s unlocked balance before the transfer. The amount of timelocked balance transferred, T_m, MUST be calculated as:
T_m = max(0, A - U_s)
The sender’s active timelocked balance MUST decrease by T_m, and the recipient’s active timelocked balance MUST increase by T_m.
A transfer MUST therefore preserve the aggregate timelocked supply.
Zero-value transfers and self-transfers MUST NOT change the active timelocked balance.
Assume Alice has:
balance 1,050
timelocked 50
unlocked 1,000
transfer(Bob, 600) sends 600 unlocked tokens. Alice keeps:
balance 450
timelocked 50
unlocked 400
If Alice instead transfers 1,020 tokens, the transfer consists of 1,000 unlocked and 20 timelocked tokens, and Bob receives 20 timelocked tokens.
Unlocked First limits the spread of timelocks. An AMM with a large unlocked balance and a small timelocked balance sends timelocked tokens only after it has used up its unlocked balance, reducing the likelihood that unrelated users receive them.
Why not timelocked first
The alternative moves as much timelocked balance as possible before any unlocked balance. It may appear to block inventory swaps, since an attacker who sells timelocked tokens to an AMM and buys back receives the same timelocked tokens. However, it can easily be bypassed by buying unlocked tokens before selling back the locked ones, or by sandwiching another account’s swap.
Timelocked First therefore increases timelock propagation to unrelated users without preventing inventory swaps.
Security property
TransferableTimelock does not guarantee that an account cannot mint and burn equal amounts in one block, and it does not preserve the provenance of a specific amount across an inventory swap. Its guarantees are a hard burnable supply cap and an economic cost, which limits the maximum attack size of mint->action->burn loops.
total burns during block N <= totalSupply at the start of block N
Economic cost. To mint and burn in the same block, a user must trade fresh supply for mature supply. That costs at least a round trip in fees and slippage, and the burn size is capped by the mature liquidity the user can reach.
These costs are not a security guarantee on their own. A profitable attack can justify them, and deep liquidity could reduce them.
Caveat: lending venues. If the token itself can be flash borrowed, the bypass cost drops to the flash loan fee. The user borrows mature tokens, mints, burns the borrowed tokens, and repays with timelocked ones. Listing the token on cheap flash loan venues weakens the economic deterrence.
To summarize:
TransferableTimelock prevents the simple
mint → transfer to another account → burn
bypass. Any other bypass requires access to older unlocked supply and pays for it.
Mint and burn
A mint increases balanceOf(account), totalSupply, and timelockedBalanceOf(account) by the same amount. A burn decreases balanceOf(account) and totalSupply.
A burn MUST use only unlocked balance, and therefore MUST NOT decrease the active timelocked balance. The implementation MUST reject a burn if:
amount > unlockedBalanceOf(account)
The following invariant MUST hold for every account:
timelockedBalanceOf(account) <= balanceOf(account)
A transfer to the zero address or to a dead address is a transfer, not a burn. It follows the transfer rules above.
The extension can define this error:
error ERC20InsufficientUnlockedBalance(
address account,
uint256 unlockedBalance,
uint256 requestedAmount
);
The extension SHOULD expose at least these functions:
interface IERC20TransferableTimelock {
function timelockedBalanceOf(address account)
external
view
returns (uint256);
function unlockedBalanceOf(address account)
external
view
returns (uint256);
}
Lazy expiry
The timelock does not need an unlock transaction. An implementation can store timelockedAmount and timelockedAtBlock. If timelockedAtBlock != block.number, then timelockedBalanceOf(account) == 0. Expired data does not need to be cleared.
A global lastMintBlock can reduce storage writes: if no mint occurred in the current block, transfer logic can skip timelock updates entirely.
Scope: current block.number only
TransferableTimelock applies only while block.number keeps the same value:
Tokens minted while the EVM
NUMBERopcode returnsNare timelocked untilNUMBERreturns a different value.
The extension does not support timelocks spanning multiple distinct values of block.number. A multi-block timelock needs several timelocked tranches with different expiry points, which requires accounting similar to ERC-7818.
Note: on some L2s such as Arbitrum, block.number approximates the L1 block number, so the timelock can span several L2 blocks.
ERC-4626 integration
ERC-4626 is an important use case, since withdraw and redeem burn vault shares.
A vault that implements TransferableTimelock MUST include the timelock in maxRedeem:
maxRedeem(owner) <= unlockedBalanceOf(owner)
If no other limit applies, maxRedeem(owner) == unlockedBalanceOf(owner). maxWithdraw(owner) MUST likewise reflect the assets redeemable with the unlocked share balance.
In accordance with ERC-4626, previewRedeem and previewWithdraw MUST NOT account for the timelock restriction.
Backwards compatibility
The extension preserves the ERC-20 interface but changes burn semantics. Most integrations are unaffected, yet integrations that attempt to burn tokens received during the current block may need to account for the timelocked balance, even if they did not participate in minting.
Conventional ERC-3156 flash minting cannot rely on burning the newly minted supply to repay the loan. Repayment through burning requires sufficient unlocked inventory.
Reference implementation
Full implementation, with fuzz and stateful invariant tests: yellowBirdy/TransferableTimelock
The core accounting runs in OpenZeppelin v5’s _update hook, after the parent update, so balance checks stay canonical and the logic reads post-operation balances:
function _update(address from, address to, uint256 value) internal virtual override {
super._update(from, to, value);
if (value == 0 || from == to) return;
// Mint: the minted amount becomes timelocked on the recipient.
if (from == address(0)) {
_increaseTimelock(to, value);
return;
}
uint256 fromTimelocked = timelockedBalanceOf(from);
uint256 fromBalance = balanceOf(from);
// The operation consumed timelocked balance.
if (fromBalance < fromTimelocked) {
uint256 touched = fromTimelocked - fromBalance;
// Burn: only unlocked balance may be consumed.
if (to == address(0)) {
revert ERC20InsufficientUnlockedBalance(from, value - touched, value);
}
// Transfer: unlocked first; the excess timelock follows the tokens.
_setTimelock(from, fromBalance);
_increaseTimelock(to, touched);
}
}
Related work
Conic Finance
Conic Finance’s LpToken used account-level taint, as described in the Motivation, to block minting and burning. MixBytes identified this as M-10, “LpToken taint griefing”: an attacker could transfer a small tainted amount to a holder and prevent that holder from minting or burning. MixBytes recommended allowing the holder to burn tokens received before the current taint. Their example explicitly states that a user with 1,000 older tokens who receives one tainted token should still be able to burn the original 1,000. (MixBytes audit report)
TransferableTimelock implements the same solution as the MixBytes recommendation by tracking the timelocked amount rather than tainting the account.
stkAAVE
Aave’s stkAAVE stored one amount-weighted cooldown timestamp per account, so an incoming transfer shifted the redemption timing of the recipient’s older balance. TransferableTimelock tracks the timelocked amount separately, so a new transfer never changes whether the recipient can burn older balance.
ERC-7818
ERC-7818 defines an Expirable ERC-20 and is useful prior work because it assigns temporal state to parts of an ERC-20 balance. An account can hold tokens from several epochs, so transfer(to, amount) cannot always subtract one homogeneous amount: it must select one or more epoch balances and preserve their expiry at the recipient. ERC-7818 also defines transferAtEpoch and transferFromAtEpoch, which let the caller select a specific tranche.
TransferableTimelock employs a similar concept in a simpler way, which preserves the standard ERC-20 interface.
ERC-3156
ERC-3156 is not the motivation for TransferableTimelock, but its Security Considerations describe attacks in which temporary minted supply interacts with lending, accounting, or redemption logic before the position closes. These are instances of the general mint → interaction → burn pattern, which can also occur without flash loans.
TransferableTimelock prevents a direct burn of the timelocked amount. It does not prevent a user from exchanging timelocked tokens for older unlocked tokens and burning those.
Questions for discussion
-
Security boundary: Is a hard burnable supply cap plus an economic bypass cost useful enough, given that a user can obtain replacement unlocked supply?
-
Introspection: Are
timelockedBalanceOfandunlockedBalanceOfsufficient? -
Naming: Does
TransferableTimelockclearly describe the behavior? -
Prior work: Are there other implementations that track a transferable current-block timelock at the amount level?
-
ERC or pattern: Does a shared
unlockedBalanceOfand a shared error give integrators enough value to justify a standard? Or domaxRedeemand a library extension cover the need?