ERC-4626: Tokenized Vault Standard Smart Contract Module in Bunzz

The Tokenized Vault Standard (ERC-4626) module allows the minting and burning of “shares” (represented using the ERC20 inheritance) in exchange for underlying “assets” through standardized {deposit}, {mint}, {redeem} and {burn} workflows. 

This contract extends the ERC20 standard. Any additional extensions included along it would affect the “shares” token represented by this contract and not the “assets” token which is an independent contract.

[CAUTION]

When the vault is empty or nearly empty, deposits are at high risk of being stolen through frontrunning with a “donation” to the vault that inflates the price of a share. This is variously known as a donation or inflation attack and is essentially a problem of slippage. 

Vault deployers can protect against this attack by making an initial deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may similarly be affected by slippage. 

Users can protect against this attack as well unexpected slippage in general by verifying the amount received is as expected, using a wrapper that performs these checks such as https://github.com/fei-protocol/ERC4626.

[Reference]

https://eips.ethereum.org/EIPS/eip-4626

You can access this Module and the code here: https://bit.ly/3TWuWSe

How to Use

All EIP-4626 Tokenized Vaults MUST implement EIP-20 to represent shares.

If a Vault is to be non-transferrable, it MAY revert on calls to transfer or transferFrom. The EIP-20 operations balanceOf, transfer, totalSupply, etc. operate on the Vault “shares” which represent a claim to ownership on a fraction of the Vault’s underlying holdings.

All EIP-4626 tokenized Vaults MUST implement EIP-20’s optional metadata extensions. The name and symbol functions SHOULD reflect the underlying token’s name and symbol in some way.

EIP-4626 tokenized Vaults MAY implement EIP-2612 to improve the UX of approving shares on various integrations.

Functions

#WRITE

  • deposit
  • mint
  • redeem
  • transfer
  • approve
  • transferFrom
  • increaseAllowance
  • withdraw
  • decreaseAllowance

#READ

  • asset
  • allowance
  • convertToShares
  • decimals
  • maxDeposit
  • maxRedeem
  • name
  • symbol
  • totalAssets
  • totalSupply
  • balanceOf
  • maxMint
  • maxWithdraw
  • previewDeposit
  • previewRedeem
  • previewWithdraw
  • previewMint
  • convertToAssets

You can access this Module and the code here: https://bit.ly/3TWuWSe

If you still haven’t signed up to Bunzz, what are you waiting for?

Sign up here https://app.bunzz.dev/signup and get your smart contracts deployed in 5 minutes through our great GUI.

Share this article:

Leave a Comment

Your email address will not be published. Required fields are marked *