Skip to content

Reduce reliance on underlying decimals in ERC4626 #3549

Description

@thedavidmeister

4626 uses _asset.decimals() to calculate initial share/asset conversions

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/ERC4626.sol#L167

EIP4626 states:

All ERC-4626 tokenized Vaults MUST implement ERC-20’s optional metadata extensions.

But EIP20 states for decimals:

OPTIONAL - This method can be used to improve usability, but interfaces and other contracts MUST NOT expect these values to be present.

So even if the vault exposes decimals for shares, the 20 spec says not to expect assets to expose decimals.

Even if both tokens expose decimals the method is for usability, not for onchain calculations.

Maybe a virtual _initialShareRatio() function could be exposed that implementing contracts can override without needing to override the entire conversion process

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions