Skip to content
Verified contractExactMIT

AssetsVault

Address0xf985e2c73d74beff3c8c16efc4fa5ab4cfb62294
Balance

4.858167 ETH

 

Transactions

1

 

Compiler

solc 0.8.21

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.21+commit.d9974bed
Language
solidity
Optimization
Yes, 200 runs
EVM version
shanghai
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
19,869,596
Creation transaction
0x5d0d987a1d…68bc178b58

src/AssetsVault.sol

// SPDX-License-Identifier: MIT
pragma solidity =0.8.21;

import {TransferHelper} from "v3-periphery/libraries/TransferHelper.sol";

error AssetsVault__ZeroAddress();
error AssetsVault__NotPermit();
error AssetsVault__InvalidAmount();

/**
 * @title ReETH Assets Vault
 * @author Mavvverick
 * @notice The ReETH Assets Vault is a secure smart contract designed to hold ETH deposits
 * in exchange for issuing ReETH tokens for the re.al Chain network. Users can deposit ETH into the real Vault,
 * which securely stores it in this vault until they choose to redeem it for ReETH tokens.
 * These tokens represent a claim to the underlying ETH assets and yield held within the Vault.
 */
contract AssetsVault {
    address public realVault;
    address public immutable strategyManager;

    event VaultUpdated(address oldRealVault, address newRealVault);

    /**
     * @dev Modifier to restrict access to only permitted addresses.
     * Only the real vault and strategy manager are permitted to execute certain functions.
     */
    modifier onlyPermit() {
        if (realVault != msg.sender && strategyManager != msg.sender) revert AssetsVault__NotPermit();
        _;
    }

    /**
     * @param _realVault Address of the real vault contract.
     * @param _strategyManager Address of the strategy manager contract.
     */
    constructor(address _realVault, address _strategyManager) {
        if (_realVault == address(0) || _strategyManager == address(0)) revert AssetsVault__ZeroAddress();

        realVault = _realVault;
        strategyManager = _strategyManager;
    }

    /**
     * @dev Deposit function to accept incoming Ether.
     */
    function deposit() external payable {
        if (msg.value == 0) revert AssetsVault__InvalidAmount();
    }

    /**
     * @dev Withdraw function to transfer Ether to a specified address.
     * Only permitted addresses can execute this function.
     * @param _to Address to which Ether will be transferred.
     * @param _amount Amount of Ether to transfer.
     */
    function withdraw(address _to, uint256 _amount) external onlyPermit {
        TransferHelper.safeTransferETH(_to, _amount);
    }

    /**
     * @dev Function to set a new vault address.
     * Only permitted addresses can execute this function.
     * @param _vault Address of the new vault contract.
     */
    function setNewVault(address _vault) external onlyPermit {
        if (_vault == address(0)) revert AssetsVault__ZeroAddress();
        emit VaultUpdated(realVault, _vault);
        realVault = _vault;
    }

    /**
     * @dev Function to get the balance of Ether held by the contract.
     * @return amount The balance of Ether held by the contract.
     */
    function getBalance() external view returns (uint256 amount) {
        amount = address(this).balance;
    }

    /**
     * @dev Fallback function to receive Ether.
     */
    receive() external payable {}
}

lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

lib/v3-periphery/contracts/libraries/TransferHelper.sol

// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';

library TransferHelper {
    /// @notice Transfers tokens from the targeted address to the given destination
    /// @notice Errors with 'STF' if transfer fails
    /// @param token The contract address of the token to be transferred
    /// @param from The originating address from which the tokens will be transferred
    /// @param to The destination address of the transfer
    /// @param value The amount to be transferred
    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) =
            token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
    }

    /// @notice Transfers tokens from msg.sender to a recipient
    /// @dev Errors with ST if transfer fails
    /// @param token The contract address of the token which will be transferred
    /// @param to The recipient of the transfer
    /// @param value The value of the transfer
    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
    }

    /// @notice Approves the stipulated contract to spend the given allowance in the given token
    /// @dev Errors with 'SA' if transfer fails
    /// @param token The contract address of the token to be approved
    /// @param to The target of the approval
    /// @param value The amount of the given token the target will be allowed to spend
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');
    }

    /// @notice Transfers ETH to the recipient address
    /// @dev Fails with `STE`
    /// @param to The destination of the transfer
    /// @param value The value to be transferred
    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'STE');
    }
}
Compiler settingsShow
{
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "shanghai",
  "remappings": [
    ":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    ":@uniswap/v3-core/=lib/v3-core/",
    ":ds-test/=lib/forge-std/lib/ds-test/src/",
    ":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    ":forge-std/=lib/forge-std/src/",
    ":openzeppelin-contracts/=lib/openzeppelin-contracts/",
    ":oz/=lib/openzeppelin-contracts/contracts/",
    ":src/=src/",
    ":v3-core-0.8/=lib/v3-core-0.8/contracts/",
    ":v3-core/=lib/v3-core/",
    ":v3-periphery/=lib/v3-periphery/contracts/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.