Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/periphery/UltraFrontendHelper.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.28;
import { IUltraVault } from "src/interfaces/IUltraVault.sol";
import { IUltraFrontendHelper } from "src/interfaces/IUltraFrontendHelper.sol";
import { Ownable2StepUpgradeable } from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
// keccak256(abi.encode(uint256(keccak256("ultrayield.storage.UltraFrontendHelper")) - 1)) & ~bytes32(uint256(0xff));
bytes32 constant ULTRA_FRONTEND_HELPER_STORAGE_LOCATION = 0xb0722828b3d7d54293138ffa77a01c09742cd65ca869b0919a7d833efbba8900;
contract UltraFrontendHelper is IUltraFrontendHelper, Ownable2StepUpgradeable, UUPSUpgradeable {
/////////////
// Storage //
/////////////
/// @custom:storage-location erc7201:ultrayield.storage.UltraFrontendHelper
struct Storage {
address vault;
address baseAsset;
address[] additionalAssets;
}
function _getStorage() private pure returns (Storage storage $) {
assembly {
$.slot := ULTRA_FRONTEND_HELPER_STORAGE_LOCATION
}
}
//////////
// Init //
//////////
constructor() {
_disableInitializers();
}
function initialize(address _vault, address _owner, address[] memory _additionalAssets) external initializer {
__Ownable_init(_owner);
__Ownable2Step_init();
__UUPSUpgradeable_init();
require(_vault != address(0), "Zero vault address");
Storage storage $ = _getStorage();
$.vault = _vault;
$.baseAsset = IUltraVault(_vault).asset();
$.additionalAssets = _additionalAssets;
}
////////////////////
// View Functions //
////////////////////
/// @inheritdoc IUltraFrontendHelper
function getVault() external view returns (address) {
Storage storage $ = _getStorage();
return $.vault;
}
/// @inheritdoc IUltraFrontendHelper
function getVaultState() external view returns (VaultState memory) {
IUltraVault vault = _getVault();
uint8 decimals = vault.decimals();
return VaultState({
totalAssets: vault.totalAssets(),
totalShares: vault.totalSupply(),
sharePrice: vault.convertToAssets(10 ** decimals)
});
}
/// @inheritdoc IUltraFrontendHelper
function previewDeposit(address asset, uint256 amount) external view returns (uint256) {
IUltraVault vault = _getVault();
uint256 baseAssets = vault.convertToUnderlying(asset, amount);
uint256 shares = vault.convertToShares(baseAssets);
return shares;
}
/// @inheritdoc IUltraFrontendHelper
function previewRedeem(address asset, uint256 shares) external view returns (uint256) {
IUltraVault vault = _getVault();
uint256 baseAssets = vault.convertToAssets(shares);
uint256 assets = vault.convertFromUnderlying(asset, baseAssets);
uint256 withdrawalFee = vault.calculateWithdrawalFee(assets);
return assets - withdrawalFee;
}
/// @inheritdoc IUltraFrontendHelper
function collectPendingRedeems(address[] calldata users) external view returns (Redeem[] memory redeems) {
IUltraVault vault = _getVault();
address[] memory assets = _getVaultAssets();
uint256 totalRedeems = 0;
for (uint256 i = 0; i < users.length; i++) {
address user = users[i];
for (uint256 j = 0; j < assets.length; j++) {
uint256 shares = vault.getPendingRedeemForAsset(assets[j], user).shares;
if (shares > 0) {
totalRedeems++;
}
}
}
if (totalRedeems == 0) {
return redeems;
}
redeems = new Redeem[](totalRedeems);
uint256 index = 0;
for (uint256 i = 0; i < users.length; i++) {
address user = users[i];
for (uint256 j = 0; j < assets.length; j++) {
address asset = assets[j];
uint256 shares = vault.getPendingRedeemForAsset(asset, user).shares;
if (shares > 0) {
redeems[index] = Redeem({ user: user, asset: asset, shares: shares });
index++;
}
}
}
return redeems;
}
/////////////////////
// Admin Functions //
/////////////////////
/// @inheritdoc IUltraFrontendHelper
function addAsset(address asset) external onlyOwner {
require(asset != address(0), "Zero asset address");
require(_getVault().rateProvider().isSupported(asset), "Asset not supported");
address[] memory assets = _getVaultAssets();
for (uint256 i = 0; i < assets.length; i++) {
require(assets[i] != asset, "Duplicate asset");
}
_getStorage().additionalAssets.push(asset);
emit AssetAdded(asset);
}
/// @inheritdoc IUltraFrontendHelper
function removeAsset(address asset) external onlyOwner {
Storage storage $ = _getStorage();
bool didRemove = false;
for (uint256 i = 0; i < $.additionalAssets.length; i++) {
if ($.additionalAssets[i] == asset) {
$.additionalAssets[i] = $.additionalAssets[$.additionalAssets.length - 1];
$.additionalAssets.pop();
didRemove = true;
break;
}
}
require(didRemove, "Asset not found");
emit AssetRemoved(asset);
}
//////////////////////
// Internal helpers //
//////////////////////
function _getVault() internal view returns (IUltraVault) {
Storage storage $ = _getStorage();
return IUltraVault($.vault);
}
function _getVaultAssets() internal view returns (address[] memory) {
Storage storage $ = _getStorage();
address[] memory assets = new address[]($.additionalAssets.length + 1);
assets[0] = $.baseAsset;
for (uint256 i = 0; i < $.additionalAssets.length; i++) {
assets[i + 1] = $.additionalAssets[i];
}
return assets;
}
//////////////////////
// UUPS Upgradeable //
//////////////////////
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
}
"
},
"src/interfaces/IUltraVault.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0;
import { IBaseVault, IBaseVaultEvents, IBaseVaultErrors } from "src/interfaces/IBaseVault.sol";
import { IPriceSource } from "src/interfaces/IPriceSource.sol";
/// @dev Vault fee configuration
struct Fees {
// Performance fee rate (100% = 1e18)
uint64 performanceFee;
// Management fee rate (100% = 1e18)
uint64 managementFee;
// Withdrawal fee rate (100% = 1e18)
uint64 withdrawalFee;
// Last fee update timestamp
uint64 lastUpdateTimestamp;
// High water mark for performance fees
uint256 highwaterMark;
}
interface IUltraVaultEvents {
event FundsHolderProposed(address indexed proposedFundsHolder);
event FundsHolderChanged(address indexed oldFundsHolder, address indexed newFundsHolder);
event OracleProposed(address indexed proposedOracle);
event OracleUpdated(address indexed oldOracle, address indexed newOracle);
event FeesRecipientUpdated(address oldRecipient, address newRecipient);
event FeesUpdated(Fees oldFees, Fees newFees);
event FeesCollected(uint256 shares, uint256 managementFee, uint256 performanceFee);
event WithdrawalFeeCollected(uint256 amount);
}
interface IUltraVaultErrors {
error ZeroFundsHolderAddress();
error ZeroOracleAddress();
error ZeroFeeRecipientAddress();
error NoPendingFundsHolderUpdate();
error ProposedFundsHolderMismatch();
error CannotAcceptFundsHolderYet();
error FundsHolderUpdateExpired();
error NoOracleProposed();
error ProposedOracleMismatch();
error CannotAcceptOracleYet();
error OracleUpdateExpired();
error CannotSetBalancesInNonEmptyVault();
error InvalidFees();
}
/// @title IUltraVault
/// @notice A simplified interface for use in other contracts
interface IUltraVault is IBaseVault, IUltraVaultEvents, IUltraVaultErrors {
////////////////////
// View Functions //
////////////////////
/// @notice Returns the funds holder address of the vault
/// @return fundsHolder The address of the funds holder
function fundsHolder() external view returns (address);
/// @notice Returns the oracle address of the vault
/// @return oracle The address of the oracle
function oracle() external view returns (IPriceSource);
/// @notice Returns the current fees configuration
/// @return fees The current fees configuration
function getFees() external view returns (Fees memory);
/// @notice Get vault fee recipient
function feeRecipient() external view returns (address);
/// @notice Get total accrued fees
function accruedFees() external view returns (uint256);
/// @notice Get accrued management fees
function accruedManagementFees() external view returns (uint256);
/// @notice Get accrued performance fees
function accruedPerformanceFees() external view returns (uint256);
/// @notice Get the withdrawal fee
function calculateWithdrawalFee(uint256 assets) external view returns (uint256);
/// @notice Get the proposed funds holder
function proposedFundsHolder() external view returns (address, uint256);
/// @notice Get the proposed oracle
function proposedOracle() external view returns (address, uint256);
/////////////////////
// Admin Functions //
/////////////////////
/// @notice Update vault's fee recipient
/// @param newFeeRecipient New fee recipient
function setFeeRecipient(address newFeeRecipient) external;
/// @notice Update vault fees
/// @param fees New fee configuration
function setFees(Fees memory fees) external;
/// @notice Mint fees as shares to fee recipient
function collectFees() external;
/// @notice Propose fundsHolder change, can be accepted after delay
/// @param newFundsHolder New fundsHolder address
/// @dev changing the holder should be used only in case of multisig upgrade after funds transfer
function proposeFundsHolder(address newFundsHolder) external;
/// @notice Accept proposed fundsHolder
/// @dev Pauses vault to ensure oracle setup and prevent deposits with faulty prices
/// @dev Oracle must be switched before unpausing
function acceptFundsHolder(address newFundsHolder) external;
/// @notice Propose new oracle for owner acceptance after delay
/// @param newOracle Address of the new oracle
function proposeOracle(address newOracle) external;
/// @notice Accept proposed oracle
/// @dev Pauses vault to ensure oracle setup and prevent deposits with faulty prices
/// @dev Oracle must be switched before unpausing
function acceptProposedOracle(address newOracle) external;
/// @notice Setup initial balances in the vault without depositing the funds
/// @notice We expect the funds to be separately sent to funds holder
/// @param users Array of users to setup balances
/// @param shares Shares of respective users
/// @dev Reverts if arrays length mismatch
function setupInitialBalances(
address[] memory users,
uint256[] memory shares
) external;
}
"
},
"src/interfaces/IUltraFrontendHelper.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0;
/// @title IUltraFrontendHelper
/// @notice Interface for the UltraFrontendHelper contract that provides helper functions for frontend integration
interface IUltraFrontendHelper {
////////////
// Events //
////////////
event AssetAdded(address indexed asset);
event AssetRemoved(address indexed asset);
/////////////
// Structs //
/////////////
/// @notice Struct describing the aggregated state of the vault
struct VaultState {
uint256 totalAssets;
uint256 totalShares;
uint256 sharePrice;
}
/// @notice Struct describing a pending redeem
struct Redeem {
address user;
address asset;
uint256 shares;
}
////////////////////
// View Functions //
////////////////////
/// @notice Get the vault address
/// @return vault The vault address
function getVault() external view returns (address);
/// @notice Get the vault state
/// @return vaultState State of the vault
function getVaultState() external view returns (VaultState memory);
/// @notice Preview the number of shares that will be received for a deposit
/// @param asset The asset to deposit
/// @param amount The amount of asset to deposit
/// @return shares The number of shares that will be received
function previewDeposit(address asset, uint256 amount) external view returns (uint256 shares);
/// @notice Preview the amount of assets that will be received for a redeem
/// @param asset The asset to receive
/// @param shares The number of shares to redeem
/// @return assets The amount of assets that will be received (after withdrawal fees)
function previewRedeem(address asset, uint256 shares) external view returns (uint256 assets);
/// @notice Collect all pending redeems for a list of users
/// @param users The list of users to collect pending redeems for
/// @return redeems Array of pending redeems
function collectPendingRedeems(address[] calldata users) external view returns (Redeem[] memory redeems);
/////////////////////
// Admin Functions //
/////////////////////
/// @notice Add an additional asset to track
/// @param asset The asset address to add
function addAsset(address asset) external;
/// @notice Remove an asset from tracking
/// @param asset The asset address to remove
function removeAsset(address asset) external;
}
"
},
"lib/openzeppelin-contracts-upgradeable/contracts/access/Ownable2StepUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {OwnableUpgradeable} from "./OwnableUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This extension of the {Ownable} contract includes a two-step mechanism to transfer
* ownership, where the new owner must call {acceptOwnership} in order to replace the
* old one. This can help prevent common mistakes, such as transfers of ownership to
* incorrect accounts, or to contracts that are unable to interact with the
* permission system.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable2Step
struct Ownable2StepStorage {
address _pendingOwner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable2Step")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant Ownable2StepStorageLocation = 0x237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00;
function _getOwnable2StepStorage() private pure returns (Ownable2StepStorage storage $) {
assembly {
$.slot := Ownable2StepStorageLocation
}
}
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
function __Ownable2Step_init() internal onlyInitializing {
}
function __Ownable2Step_init_unchained() internal onlyInitializing {
}
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
Ownable2StepStorage storage $ = _getOwnable2StepStorage();
return $._pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*
* Setting `newOwner` to the zero address is allowed; this can be used to cancel an initiated ownership transfer.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
Ownable2StepStorage storage $ = _getOwnable2StepStorage();
$._pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
Ownable2StepStorage storage $ = _getOwnable2StepStorage();
delete $._pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}
"
},
"lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address private immutable __self = address(this);
/**
* @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
* and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
* while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
* If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
* be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
* during an upgrade.
*/
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
/**
* @dev The call is from an unauthorized context.
*/
error UUPSUnauthorizedCallContext();
/**
* @dev The storage `slot` is unsupported as a UUID.
*/
error UUPSUnsupportedProxiableUUID(bytes32 slot);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC-1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC-1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
_checkProxy();
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC-1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual notDelegated returns (bytes32) {
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
/**
* @dev Reverts if the execution is not performed via delegatecall or the execution
* context is not of a proxy with an ERC-1967 compliant implementation pointing to self.
*/
function _checkProxy() internal view virtual {
if (
address(this) == __self || // Must be called through delegatecall
ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
) {
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Reverts if the execution is performed via delegatecall.
* See {notDelegated}.
*/
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
// Must not be called through delegatecall
revert UUPSUnauthorizedCallContext();
}
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
*
* As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
* is expected to be the implementation slot in ERC-1967.
*
* Emits an {IERC1967-Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
// The implementation is not UUPS
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}
"
},
"lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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);
}
"
},
"src/interfaces/IBaseVault.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0;
import { IPausable } from "src/interfaces/IPausable.sol";
import { IERC7540Operator } from "ERC-7540/interfaces/IERC7540.sol";
import { IRedeemAccounting } from "src/interfaces/IRedeemAccounting.sol";
import { IUltraVaultRateProvider } from "src/interfaces/IUltraVaultRateProvider.sol";
import { IAccessControlDefaultAdminRules } from "@openzeppelin/contracts/access/extensions/IAccessControlDefaultAdminRules.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC4626 } from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import { IERC165 } from "@openzeppelin/contracts/interfaces/IERC165.sol";
import { AddressUpdateProposal } from "src/utils/AddressUpdates.sol";
interface IBaseVaultErrors {
error NotOwner();
error AccessDenied();
error ZeroAssetAddress();
error ZeroRateProviderAddress();
error InputLengthMismatch();
error CannotPreviewWithdrawInAsyncVault();
error CannotPreviewRedeemInAsyncVault();
error EmptyDeposit();
error NothingToMint();
error NothingToRedeem();
error NothingToWithdraw();
error NoPendingRedeem();
error InsufficientBalance();
error AssetNotSupported();
error MissingRateProvider();
error NoRateProviderProposed();
error ProposedRateProviderMismatch();
error CannotAcceptRateProviderYet();
error RateProviderUpdateExpired();
}
interface IBaseVaultEvents {
event RateProviderProposed(address indexed proposedProvider);
event RateProviderUpdated(address indexed oldProvider, address indexed newProvider);
event RedeemRequestFulfilled(
address indexed controller,
address indexed fulfiller,
uint256 shares,
uint256 assets
);
event RedeemRequest(
address indexed controller,
address indexed owner,
uint256 indexed requestId,
address sender,
uint256 shares
);
event RedeemRequestCanceled(
address indexed controller,
address indexed receiver,
uint256 shares
);
event Referral(string indexed referralId, address indexed user, uint256 shares);
}
/// @title IBaseVault
/// @notice An interface of basic vault functionality for both UltraVault and UltraFeeder contracts
interface IBaseVault is
IBaseVaultEvents,
IBaseVaultErrors,
IERC20,
IERC165,
IERC4626,
IAccessControlDefaultAdminRules,
IPausable,
IERC7540Operator,
IRedeemAccounting
{
////////////////////
// View Functions //
////////////////////
/// @notice Returns the address of the share token
/// @return share The address of the share token
function share() external view returns (address);
/// @notice Returns the address of the rate provider
/// @return rateProvider The address of the rate provider
function rateProvider() external view returns (IUltraVaultRateProvider);
/// @notice Returns the proposed rate provider
/// @return proposedRateProvider The proposed rate provider
function proposedRateProvider() external view returns (AddressUpdateProposal memory);
/// @notice Converts assets to underlying
/// @param _asset The asset to convert
/// @param assets The amount of assets to convert
/// @return baseAssets The amount of underlying received
function convertToUnderlying(
address _asset,
uint256 assets
) external view returns (uint256 baseAssets);
/// @notice Converts underlying to assets
/// @param asset The asset to convert
/// @param baseAssets The amount of underlying to convert
/// @return assets The amount of assets received
function convertFromUnderlying(
address asset,
uint256 baseAssets
) external view returns (uint256 assets);
/////////////
// Deposit //
/////////////
/// @notice Get max assets for deposit
/// @return assets Maximum deposit amount
function maxDeposit(
address
) external view returns (uint256);
/// @notice Preview shares for deposit
/// @param assets Amount to deposit
/// @return shares Amount of shares received
function previewDeposit(
uint256 assets
) external view returns (uint256);
/// @notice Preview shares for deposit
/// @param asset Asset
/// @param assets Amount to deposit
/// @return shares Amount of shares received
function previewDepositForAsset(
address asset,
uint256 assets
) external view returns (uint256);
/// @notice Helper to deposit assets for msg.sender upon referral specifying receiver
/// @param assets Amount to deposit
/// @param receiver receiver of deposit
/// @param referralId id of referral
/// @return shares Amount of shares received
function depositWithReferral(
uint256 assets,
address receiver,
string calldata referralId
) external returns (uint256);
/// @notice Helper to deposit particular asset for msg.sender upon referral
/// @param asset Asset to deposit
/// @param assets Amount to deposit
/// @param receiver receiver of deposit
/// @param referralId id of referral
/// @return shares Amount of shares received
function depositAssetWithReferral(
address asset,
uint256 assets,
address receiver,
string calldata referralId
) external returns (uint256);
/// @notice Deposit exact number of assets in base asset and mint shares to receiver
/// @param assets Amount of assets to deposit
/// @param receiver Share receiver
/// @return shares Amount of shares received
function deposit(
uint256 assets,
address receiver
) external returns (uint256 shares);
/// @notice Deposit assets for receiver
/// @param asset Asset
/// @param assets Amount to deposit
/// @param receiver Share recipient
/// @return shares Amount of shares received
function depositAsset(
address asset,
uint256 assets,
address receiver
) external returns (uint256 shares);
//////////
// Mint //
//////////
/// @notice Get max shares for mint
/// @return shares Maximum mint amount
function maxMint(
address
) external view returns (uint256);
/// @notice Preview assets for mint
/// @param shares Amount to mint
/// @return assets Amount of assets required
function previewMint(
uint256 shares
) external view returns (uint256);
/// @notice Preview assets for mint
/// @param asset Asset to deposit in
/// @param shares Amount to mint
/// @return assets Amount of assets required
function previewMintForAsset(
address asset,
uint256 shares
) external view returns (uint256);
/// @notice Mint exact number of shares to receiver and deposit in base asset
/// @param shares Amount of shares to mint
/// @param receiver Share receiver
/// @return assets Amount of assets required
function mint(
uint256 shares,
address receiver
) external returns (uint256 assets);
/// @notice Mint shares for receiver with specific asset
/// @param asset Asset to mint with
/// @param shares Amount to mint
/// @param receiver Share recipient
/// @return assets Amount of assets required
function mintWithAsset(
address asset,
uint256 shares,
address receiver
) external returns (uint256 assets);
//////////////
// Withdraw //
//////////////
/// @notice Get max assets for withdraw
/// @param controller Controller address
/// @return assets Maximum withdraw amount
function maxWithdraw(address controller) external view returns (uint256);
/// @notice Get max assets for withdraw
/// @param asset Asset
/// @param controller Controller address
/// @return assets Maximum withdraw amount
function maxWithdrawForAsset(
address asset,
address controller
) external view returns (uint256);
/// @notice Withdraw assets from fulfilled redeem requests
/// @param assets Amount to withdraw
/// @param receiver Asset recipient
/// @param controller Controller address
/// @return shares Amount of shares burned
function withdraw(
uint256 assets,
address receiver,
address controller
) external returns (uint256 shares);
/// @notice Withdraw assets from fulfilled redeem requests
/// @param asset Asset
/// @param assets Amount to withdraw
/// @param receiver Asset recipient
/// @param controller Controller address
/// @return shares Amount of shares burned
function withdrawAsset(
address asset,
uint256 assets,
address receiver,
address controller
) external returns (uint256 shares);
////////////
// Redeem //
////////////
/// @notice Get max shares for redeem
/// @param controller Controller address
function maxRedeem(
address controller
) external view returns (uint256);
/// @notice Get max shares for redeem
/// @param asset Asset
/// @param controller Controller address
/// @return shares Maximum redeem amount
function maxRedeemForAsset(
address asset,
address controller
) external view returns (uint256);
/// @notice Redeem shares from fulfilled requests
/// @param shares Amount to redeem
/// @param receiver Asset recipient
/// @param controller Controller address
/// @return assets Amount of assets received
function redeem(
uint256 shares,
address receiver,
address controller
) external returns (uint256 assets);
/// @notice Redeem shares from fulfilled requests
/// @param asset Asset
/// @param shares Amount to redeem
/// @param receiver Asset recipient
/// @param controller Controller address
/// @return assets Amount of assets received
function redeemAsset(
address asset,
uint256 shares,
address receiver,
address controller
) external returns (uint256 assets);
/////////////////////
// Redeem requests //
/////////////////////
/// @notice Request redeem for msg.sender
/// @param shares Amount to redeem
/// @return requestId Request identifier
function requestRedeem(uint256 shares) external returns (uint256 requestId);
/// @notice Request redeem of shares
/// @param shares Amount to redeem
/// @param controller Share recipient
/// @param owner Share owner
/// @return requestId Request identifier
function requestRedeem(
uint256 shares,
address controller,
address owner
) external returns (uint256 requestId);
/// @notice Request redeem of shares
/// @param asset Asset
/// @param shares Amount to redeem
/// @param controller Share recipient
/// @param owner Share owner
/// @return requestId Request identifier
function requestRedeemOfAsset(
address asset,
uint256 shares,
address controller,
address owner
) external returns (uint256 requestId);
////////////////////////
// Redeem Fulfillment //
////////////////////////
/// @notice Fulfill redeem request
/// @param asset Asset
/// @param shares Amount to redeem
/// @param controller Controller address
/// @return assets Amount of claimable assets
function fulfillRedeem(
address asset,
uint256 shares,
address controller
) external returns (uint256);
/// @notice Fulfill multiple redeem requests
/// @param assets Array of assets
/// @param shares Array of share amounts
/// @param controllers Array of controllers
/// @return Array of fulfilled amounts in requested asset
function fulfillMultipleRedeems(
address[] memory assets,
uint256[] memory shares,
address[] memory controllers
) external returns (uint256[] memory);
////////////////////////
// Redeem Cancelation //
////////////////////////
/// @notice Cancel redeem request for controller
/// @param controller Controller address
/// @return shares Amount of shares canceled
function cancelRedeemRequest(address controller) external returns (uint256 shares);
/// @notice Cancel redeem request for controller
/// @param controller Controller address
/// @param receiver Share recipient
/// @return shares Amount of shares canceled
function cancelRedeemRequest(
address controller,
address receiver
) external returns (uint256 shares);
/// @notice Cancel redeem request for controller
/// @param asset Asset
/// @param controller Controller address
/// @param receiver Share recipient
/// @return shares Amount of shares canceled
function cancelRedeemRequestOfAsset(
address asset,
address controller,
address receiver
) external returns (uint256 shares);
/// @notice Cancel redeem request for controller partially, for a specific amount of shares
/// @param asset Asset
/// @param shares Amount of shares to cancel
/// @param controller Controller address
/// @param receiver Share recipient
function cancelRedeemRequestPartially(
address asset,
uint256 shares,
address controller,
address receiver
) external;
/////////////////////
// Admin Functions //
/////////////////////
/// @notice Propose new rate provider for owner acceptance after delay
/// @param newRateProvider Address of the new rate provider
function proposeRateProvider(address newRateProvider) external;
/// @notice Accept proposed rate provider
/// @param newRateProvider Address of the new rate provider
function acceptProposedRateProvider(address newRateProvider) external;
}
"
},
"src/interfaces/IPriceSource.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0;
interface IPriceSource {
/// @notice Get one-sided price quote
/// @param inAmount Amount of base token to convert
/// @param base Token being priced
/// @param quote Token used as unit of account
/// @return outAmount Amount of quote token equivalent to inAmount of base
/// @dev Assumes no price spread
function getQuote(
uint256 inAmount,
address base,
address quote
) external view returns (uint256 outAmount);
}
"
},
"lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
assembly {
$.slot := OwnableStorageLocation
}
}
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
OwnableStorage storage $ = _getOwnableStorage();
return $._owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
"
},
"lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reinitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.
*
* NOTE: Consider following the ERC-7201 formula to derive storage locations.
*/
function _initializableStorageSlot() internal pure virtual returns (bytes32) {
return INITIALIZABLE_STORAGE;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
bytes32 slot = _initializableStorageSlot();
assembly {
$.slot := slot
}
}
}
"
},
"lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/interfaces/draft-IERC1822.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC-1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822Proxiable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}
"
},
"lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Utils.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (proxy/ERC1967/ERC1967Utils.sol)
pragma solidity ^0.8.22;
import {IBeacon} from "../beacon/IBeacon.sol";
import {IERC1967} from "../../interfaces/IERC1967.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";
/**
* @dev This library provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[ERC-1967] slots.
*/
library ERC1967Utils {
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
/**
* @dev The `implementation` of the proxy is invalid.
*/
error ERC1967InvalidImplementation(address implementation);
/**
* @dev The `admin` of the proxy is invalid.
*/
error ERC1967InvalidAdmin(address admin);
/**
* @dev The `beacon` of the proxy is invalid.
*/
error ERC1967InvalidBeacon(address beacon);
/**
* @dev An upgrade function sees `msg.value > 0` that may be lost.
*/
error ERC1967NonPayable();
/**
* @dev Returns the current implementation address.
*/
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Performs implementation upgrade with additional setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-Upgraded} event.
*/
function upgradeToAndCall(address newImplementation, bytes memory data) internal {
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*
* TIP: To get this value clients can read directly from the storage slot shown below (specified by ERC-1967) using
* the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
*/
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the ERC-1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {IERC1967-AdminChanged} event.
*/
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
*/
// solhint-disable-next-line private-vars-leading-underscore
bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the ERC-1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
/**
* @dev Change the beacon and trigger a setup call if data is nonempty.
* This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
* to avoid stuck value in the contract.
*
* Emits an {IERC1967-BeaconUpgraded} event.
*
* CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
* it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
* efficiency.
*/
function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
_setBeacon(newBeacon);
emit IERC1967.BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
} else {
_checkNonPayable();
}
}
/**
* @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
* if an upgrade doesn't perform an initialization call.
*/
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}
"
},
"src/interfaces/IPausable.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0;
interface IPausable {
/// @notice Returns the paused status of the vault
/// @return paused The paused status of the vault
function paused() external view returns (bool);
/// @notice Pauses the contract
function pause() external;
/// @notice Unpauses the contract
function unpause() external;
}
"
},
"lib/ERC-7540-Reference/src/interfaces/IERC7540.sol": {
"cont
Submitted on: 2025-11-04 12:58:19
Comments
Log in to comment.
No comments yet.