A modern WETH: wrap the chain's native coin 1:1 into an ERC-20, with EIP-2612 permit (gasless
approvals) that the original WETH9 lacks. No owner, no fee, no admin — a pure 1:1 wrapper, fully backed
by construction. MIT.
deposit()(payable) — or just sending native coin to the contract — mints an equal amount of the token.withdraw(amount)/withdrawTo(to, amount)— burns tokens and returns the native coin 1:1 (CEI: burn before the transfer, so reentrancy can't extract more than the caller's own balance backs).- Standard ERC-20 +
permit/DOMAIN_SEPARATOR/nonces(EIP-2612).
- Fully backed —
address(this).balance == totalSupply()at all times, across any sequence of deposit / withdraw / transfer (fuzzed, 12,800 calls, 0 reverts, non-hollow). Every wrapped token is redeemable for exactly one unit of native coin. Mutation-checked: minting 2× per deposit breaks it.
withdrawToreverts (NativeTransferFailed) if the recipient rejects the native transfer — funds stay put, nothing is lost.- Reentrancy on
withdrawis safe by ERC-20 accounting (can't burn more than you hold) and proven by a nested-unwrap test; the backing invariant holds throughout. - Unaudited reference implementation.
forge test # 11 tests: wrap/unwrap, auto-wrap on receive, permit, reentrancy, backing invariant