Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wrapped-native

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.

What it does

  • 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).

The one invariant that matters

  • Fully backedaddress(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.

Notes (honest)

  • withdrawTo reverts (NativeTransferFailed) if the recipient rejects the native transfer — funds stay put, nothing is lost.
  • Reentrancy on withdraw is 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

About

Modern WETH: wrap native coin 1:1 into an ERC-20 with EIP-2612 permit (gasless approvals), fully-backed invariant (balance == totalSupply), no owner/fee

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages