Skip to content

Commit

Permalink
docs: Apply minor suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNeshi authored Dec 27, 2024
1 parent d7939ea commit 00274a9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 47 deletions.
5 changes: 0 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

-

### Added mulDiv to Math Util (Breaking)

- Add mulDiv to Math Util #465


## [v0.2.0-alpha.2] - 2024-12-18

### Added
Expand Down
67 changes: 26 additions & 41 deletions contracts/src/token/erc20/extensions/erc4626.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ use crate::{

/// ERC-4626 Tokenized Vault Standard Interface
pub trait IERC4626 {
/// Error type associated with the operations, convertible to a vector of
/// bytes.
/// The error type associated to this ERC-4626 trait implementation.
type Error: Into<alloc::vec::Vec<u8>>;

/// Returns the address of the underlying asset that the vault manages.
Expand Down Expand Up @@ -229,72 +228,58 @@ sol! {
}

sol! {
/// Indicates an error where a deposit operation failed
/// because the supplied `assets` exceeded the maximum allowed for the `receiver`.
/// Indicates an error where a deposit operation failed because the
/// supplied `assets` exceeded the maximum allowed for the `receiver`.
#[derive(Debug)]
#[allow(missing_docs)]
error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);

/// Indicates an error where a mint operation failed
/// because the supplied `shares` exceeded the maximum allowed for the `receiver`.
error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);
/// Indicates an error where a mint operation failed because the supplied
/// `shares` exceeded the maximum allowed for the `receiver`.
#[derive(Debug)]
#[allow(missing_docs)]
error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);

/// Indicates an error where a withdrawal operation failed
/// because the supplied `assets` exceeded the maximum allowed for the `owner`
/// Indicates an error where a withdrawal operation failed because the
/// supplied `assets` exceeded the maximum allowed for the `owner`.
#[derive(Debug)]
#[allow(missing_docs)]
error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);

/// Indicates an error where a redemption operation failed
/// because the supplied `shares` exceeded the maximum allowed for the `owner`.
/// Indicates an error where a redemption operation failed because the
/// supplied `shares` exceeded the maximum allowed for the `owner`.
#[derive(Debug)]
#[allow(missing_docs)]
error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);
}

/// Error type from [`Erc4626`] contract.
/// An [`Erc4626`] error.
#[derive(SolidityError, Debug)]
pub enum Error {
/// Indicates an error where a deposit operation failed
/// because the supplied `assets` exceeded the maximum allowed for the
/// `receiver`.
/// Error type from [`SafeErc20`] contract [`safe_erc20::Error`].
SafeErc20(safe_erc20::Error),
/// Indicates an error where a deposit operation failed because the
/// supplied `assets` exceeded the maximum allowed for the `receiver`.
ExceededMaxDeposit(ERC4626ExceededMaxDeposit),

/// Indicates an error where a mint operation failed
/// because the supplied `shares` exceeded the maximum allowed for the
/// `receiver`
/// Indicates an error where a mint operation failed because the supplied
/// `shares` exceeded the maximum allowed for the `receiver`.
ExceededMaxMint(ERC4626ExceededMaxMint),

/// Indicates an error where a withdrawal operation failed
/// because the supplied `assets` exceeded the maximum allowed for the
/// `owner`
/// Indicates an error where a withdrawal operation failed because the
/// supplied `assets` exceeded the maximum allowed for the `owner`.
ExceededMaxWithdraw(ERC4626ExceededMaxWithdraw),

/// Indicates an error where a redemption operation failed
/// because the supplied `shares` exceeded the maximum allowed for the
/// `owner`.
/// Indicates an error where a redemption operation failed because the
/// supplied `shares` exceeded the maximum allowed for the `owner`.
ExceededMaxRedeem(ERC4626ExceededMaxRedeem),

/// Error type from [`SafeErc20`] contract [`safe_erc20::Error`].
SafeErc20(safe_erc20::Error),

/// Error type from [`Erc20`] contract [`erc20::Error`].
Erc20(erc20::Error),
}

/// ERC4626 Contract.
/// State of an [`Erc4626`] token.
#[storage]
pub struct Erc4626 {
/// The ERC20 token
/// ERC-20 contract storage.
pub _asset: Erc20,

/// The SafeERC20 token
pub _safe_erc20: SafeErc20,

/// The underlying asset's decimals
/// The underlying asset's decimals.
pub _underlying_decimals: StorageU8,
/// [`SafeErc20`] contract.
pub _safe_erc20: SafeErc20,
}

/// NOTE: Implementation of [`TopLevelStorage`] to be able use `&mut self` when
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/erc20.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ Additionally, there are multiple custom extensions, including:

* xref:erc20-permit.adoc[ERC-20 Permit]: gasless approval of tokens (standardized as https://eips.ethereum.org/EIPS/eip-2612[`EIP-2612`]).

* xref:erc4262.adoc[ERC-4262]: standard interface for token vaults (standardized as https://eips.ethereum.org/EIPS/eip-4626[`EIP-4626`]).
* xref:erc4262.adoc[ERC-4262]: standard interface for tokenized vaults.

0 comments on commit 00274a9

Please sign in to comment.