Verified contractPartialBUSL-1.1
BurnRequestFeeFuse
Address0x415ec245a02b1bcf39db342d3e4693c60a2b6027
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.30
- Same code
Only this contract
Details
- Compiler
- solc 0.8.30+commit.73712a01
- Language
- solidity
- Optimization
- Yes, 1,000,000 runs
- EVM version
- cancun
- License
- BUSL-1.1
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,336,806
- Creation transaction
- 0x5fa9fd392e…de6ebc9801
8 files
- lib/ipor-fusion/contracts/fuses/burn_request_fee/BurnRequestFeeFuse.solmain7.97 KB
- lib/ipor-fusion/contracts/fuses/IFuse.sol353 B
- lib/ipor-fusion/contracts/fuses/IFuseCommon.sol277 B
- lib/ipor-fusion/contracts/interfaces/IPlasmaVaultBase.sol3.01 KB
- lib/ipor-fusion/contracts/libraries/PlasmaVaultStorageLib.sol51.7 KB
- lib/ipor-fusion/contracts/libraries/TypeConversionLib.sol3.56 KB
- lib/ipor-fusion/contracts/transient_storage/TransientStorageLib.sol8.82 KB
- lib/ipor-fusion/node_modules/@openzeppelin/contracts/utils/Address.sol6.26 KB
lib/ipor-fusion/contracts/fuses/burn_request_fee/BurnRequestFeeFuse.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.30;
import {IFuseCommon} from "../IFuse.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {PlasmaVaultStorageLib} from "../../libraries/PlasmaVaultStorageLib.sol";
import {TransientStorageLib} from "../../transient_storage/TransientStorageLib.sol";
import {TypeConversionLib} from "../../libraries/TypeConversionLib.sol";
import {IPlasmaVaultBase} from "../../interfaces/IPlasmaVaultBase.sol";
/// @dev Minimal interface for resolving the PlasmaVaultBase address on both new
/// and legacy PlasmaVault deployments. New vaults expose this getter via
/// `PlasmaVault.PLASMA_VAULT_BASE()` reading `PLASMA_VAULT_BASE_SLOT`;
/// legacy (pre-migration) vaults expose the same selector backed by an
/// `immutable` field baked into bytecode. Tracked in IL-7407.
interface IPlasmaVaultBaseGetter {
function PLASMA_VAULT_BASE() external view returns (address);
}
/**
* @title BurnRequestFeeFuse - Fuse for Burning Request Fee Shares
* @notice Specialized fuse contract for burning request fee shares from the PlasmaVault
* @dev Routes burn operations through PlasmaVaultBase.updateInternal to ensure proper hook execution
*
* Execution Context:
* - All fuse operations are executed via delegatecall from PlasmaVault
* - Storage operations affect PlasmaVault's state, not the fuse contract
* - msg.sender refers to the caller of PlasmaVault.execute
* - address(this) refers to PlasmaVault's address during execution
*
* Inheritance Structure:
* - IFuseCommon: Base fuse interface implementation
*
* Core Features:
* - Burns request fee shares collected by WithdrawManager
* - Routes through vault's _update pipeline for proper hook execution
* - Maintains version and market tracking
* - Implements fuse enter/exit pattern
*
* Share Burning System:
* - Uses delegatecall to PlasmaVaultBase.updateInternal for burn operations
* - Ensures voting checkpoints are updated via _transferVotingUnits
* - Maintains governance state consistency
* - Operates on WithdrawManager's collected fees
* - Reduces total supply through burning
* - Maintains protocol tokenomics
*
* Integration Points:
* - PlasmaVault: Main vault interaction (via delegatecall)
* - PlasmaVaultBase: Token state management (via nested delegatecall)
* - WithdrawManager: Fee source
* - Fuse System: Execution framework
*
* Security Considerations:
* - Burns route through vault's _update pipeline to maintain voting checkpoints
* - Access controlled operations
* - State consistency checks
* - Share burning validation
* - Version tracking for upgrades
* - Delegatecall security implications
*
*/
/// @notice Data structure for the enter function parameters
/// @dev Used to pass burning amount to the enter function
struct BurnRequestFeeDataEnter {
/// @notice Amount of shares to burn
uint256 amount;
}
/// @title BurnRequestFeeFuse
/// @notice Contract responsible for burning request fee shares from PlasmaVault
contract BurnRequestFeeFuse is IFuseCommon {
using Address for address;
/// @notice Thrown when WithdrawManager address is not set in either the
/// corrected (IL-6952) or legacy slot of PlasmaVault.
error BurnRequestFeeWithdrawManagerNotSet();
/// @notice Thrown when PlasmaVaultBase address resolved via the vault's
/// `PLASMA_VAULT_BASE()` getter is `address(0)` (IL-7407).
error BurnRequestFeePlasmaVaultBaseNotSet();
/// @notice Thrown when exit function is called (not implemented)
error BurnRequestFeeExitNotImplemented();
/// @notice Emitted when request fee shares are burned
/// @param version Address of the fuse contract version
/// @param amount Amount of shares burned
event BurnRequestFeeEnter(address version, uint256 amount);
/// @notice Address of this fuse contract version
/// @dev Immutable value set in constructor
address public immutable VERSION;
/// @notice Market ID this fuse operates on
/// @dev Immutable value set in constructor
uint256 public immutable MARKET_ID;
/// @notice Initializes the BurnRequestFeeFuse contract
/// @dev Sets up the fuse with market ID
/// @param marketId_ The market ID this fuse will operate on
constructor(uint256 marketId_) {
VERSION = address(this);
MARKET_ID = marketId_;
}
/// @notice Burns request fee shares from the WithdrawManager
/// @dev Routes through PlasmaVaultBase.updateInternal via delegatecall to ensure proper hook execution
///
/// Operation Flow:
/// - Verifies WithdrawManager is set
/// - Validates amount is non-zero
/// - Burns shares via delegatecall to PlasmaVaultBase.updateInternal
/// - Emits BurnRequestFeeEnter event
///
/// Security:
/// - Routes through vault's _update pipeline to maintain voting checkpoints
/// - Checks WithdrawManager existence
/// - Validates input parameters
/// - Uses nested delegatecall to PlasmaVaultBase for proper hook execution
///
/// @param data_ Struct containing the amount of shares to burn
/// @dev IMPORTANT: This fuse resolves vault addresses with backward-compat shims
/// so the same bytecode runs against new and legacy PlasmaVaults (IL-7407):
/// 1. WithdrawManager: read via PlasmaVaultStorageLib.getWithdrawManagerAddressWithLegacyFallback(),
/// which prefers the corrected WITHDRAW_MANAGER slot (IL-6952, audit R4H7) and
/// falls back to the legacy slot used by pre-IL-6952 deployments.
/// 2. PlasmaVaultBase: read by calling `PLASMA_VAULT_BASE()` on the vault itself
/// (delegatecall context ⇒ address(this) == PlasmaVault). New vaults serve the
/// value from `PLASMA_VAULT_BASE_SLOT`; legacy vaults (e.g. Clearstar) serve it
/// from a baked-in `immutable`. Both expose the same external selector, so the
/// fuse stays drop-in compatible without storage migration.
function enter(BurnRequestFeeDataEnter memory data_) public {
address withdrawManager = PlasmaVaultStorageLib.getWithdrawManagerAddressWithLegacyFallback();
if (withdrawManager == address(0)) {
revert BurnRequestFeeWithdrawManagerNotSet();
}
if (data_.amount == 0) {
return;
}
address plasmaVaultBase = IPlasmaVaultBaseGetter(address(this)).PLASMA_VAULT_BASE();
if (plasmaVaultBase == address(0)) {
revert BurnRequestFeePlasmaVaultBaseNotSet();
}
// Route burn through PlasmaVaultBase.updateInternal to ensure voting checkpoints
// and supply cap validations are properly executed. Using delegatecall ensures
// the vault's _update pipeline is used instead of bypassing it.
plasmaVaultBase.functionDelegateCall(
abi.encodeWithSelector(IPlasmaVaultBase.updateInternal.selector, withdrawManager, address(0), data_.amount)
);
emit BurnRequestFeeEnter(VERSION, data_.amount);
}
/// @notice Burns request fee shares using transient storage for input parameters
/// @dev Reads inputs from transient storage and calls enter(). No outputs are written to transient storage.
function enterTransient() external {
bytes32[] memory inputs = TransientStorageLib.getInputs(VERSION);
BurnRequestFeeDataEnter memory data = BurnRequestFeeDataEnter({amount: TypeConversionLib.toUint256(inputs[0])});
enter(data);
}
/// @notice Exit function (not implemented)
/// @dev Always reverts as this fuse only supports burning
function exit() external pure {
revert BurnRequestFeeExitNotImplemented();
}
/// @notice Exit function using transient storage (not implemented)
/// @dev Always reverts as this fuse only supports burning
function exitTransient() external pure {
revert BurnRequestFeeExitNotImplemented();
}
}
lib/ipor-fusion/contracts/fuses/IFuse.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.30;
import {IFuseCommon} from "./IFuseCommon.sol";
/// @title Interface for Fuses
interface IFuse is IFuseCommon {
/// @notice Enters to the Market
function enter(bytes calldata data_) external;
/// @notice Exits from the Market
function exit(bytes calldata data_) external;
}
lib/ipor-fusion/contracts/fuses/IFuseCommon.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.30;
/// @title Interface for Fuses Common functions
interface IFuseCommon {
/// @notice Market ID associated with the Fuse
//solhint-disable-next-line
function MARKET_ID() external view returns (uint256);
}
lib/ipor-fusion/contracts/interfaces/IPlasmaVaultBase.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.30;
/// @title Plasma Vault Base interface
interface IPlasmaVaultBase {
/// @notice Initializes the Plasma Vault
/// @dev Method is executed only once during the Plasma Vault construction in context of Plasma Vault (delegatecall used)
/// @param assetName_ The name of the asset
/// @param accessManager_ The address of the Ipor Fusion Access Manager
/// @param totalSupplyCap_ The total supply cap denominated in shares (not in underlying asset decimals)
function init(string memory assetName_, address accessManager_, uint256 totalSupplyCap_) external;
/// @notice When token are transferring, updates data in storage required for functionalities included in PlasmaVaultBase but in context of Plasma Vault (delegatecall used)
/// @param from_ The address from which the tokens are transferred
/// @param to_ The address to which the tokens are transferred
/// @param value_ The amount of tokens transferred
function updateInternal(address from_, address to_, uint256 value_) external;
/// @notice Transfers request fee tokens from user to withdraw manager
/// @dev This function is called during the withdraw request process to handle request fee transfers
///
/// Access Control:
/// - Restricted to TECH_WITHDRAW_MANAGER_ROLE only
/// - Cannot be called by any other role, including admin or owner
/// - System-level role assigned during initialization
/// - Technical role that cannot be reassigned during runtime
///
/// Fee System:
/// - Transfers request fee tokens from user to withdraw manager
/// - Part of the withdraw request flow
/// - Only callable by authorized contracts (restricted)
/// - Critical for fee collection mechanism
///
/// Integration Context:
/// - Called by WithdrawManager during requestShares
/// - Handles fee collection for withdrawal requests
/// - Maintains fee token balances
/// - Supports protocol revenue model
///
/// Security Features:
/// - Access controlled (restricted to TECH_WITHDRAW_MANAGER_ROLE)
/// - Atomic operation
/// - State consistency checks
/// - Integrated with vault permissions
///
/// Use Cases:
/// - Withdrawal request fee collection
/// - Protocol revenue generation
/// - Fee token management
/// - Automated fee handling
///
/// Related Components:
/// - WithdrawManager contract (must have TECH_WITHDRAW_MANAGER_ROLE)
/// - Fee management system
/// - Access control system
/// - Token operations
///
/// @param from_ The address from which to transfer the fee tokens
/// @param to_ The address to which the fee tokens should be transferred (usually withdraw manager)
/// @param amount_ The amount of fee tokens to transfer
/// @custom:access TECH_WITHDRAW_MANAGER_ROLE
function transferRequestSharesFee(address from_, address to_, uint256 amount_) external;
}
lib/ipor-fusion/contracts/libraries/PlasmaVaultStorageLib.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.30;
/**
* @title Plasma Vault Storage Library
* @notice Library managing storage layout and access for the PlasmaVault system using ERC-7201 namespaced storage pattern
* @dev This library is a core component of the PlasmaVault system that:
* 1. Defines and manages all storage structures using ERC-7201 namespaced storage pattern
* 2. Provides storage access functions for PlasmaVault.sol, PlasmaVaultBase.sol and PlasmaVaultGovernance.sol
* 3. Ensures storage safety for the upgradeable vault system
*
* Storage Components:
* - Core ERC4626 vault storage (asset, decimals)
* - Market management (assets, balances, substrates)
* - Fee system storage (performance, management fees)
* - Access control and execution state
* - Fuse system configuration
* - Price oracle and rewards management
*
* Key Integrations:
* - Used by PlasmaVault.sol for core vault operations and asset management
* - Used by PlasmaVaultGovernance.sol for configuration and admin functions
* - Used by PlasmaVaultBase.sol for ERC20 functionality and access control
*
* Security Considerations:
* - Uses ERC-7201 namespaced storage pattern to prevent storage collisions
* - Each storage struct has a unique namespace derived from its purpose
* - Critical for maintaining storage integrity in upgradeable contracts
* - Storage slots are carefully chosen and must not be modified
*
* @custom:security-contact [email protected]
*/
library PlasmaVaultStorageLib {
/**
* @dev Storage slot for ERC4626 vault configuration following ERC-7201 namespaced storage pattern
* @notice This storage location is used to store the core ERC4626 vault data (asset address and decimals)
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC4626")) - 1)) & ~bytes32(uint256(0xff))
*
* Important:
* - This value MUST NOT be changed as it's used by OpenZeppelin's ERC4626 implementation
* - Changing this value would break storage compatibility with existing deployments
* - Used by PlasmaVault.sol for core vault operations like deposit/withdraw
*
* Storage Layout:
* - Points to ERC4626Storage struct containing:
* - asset: address of the underlying token
* - underlyingDecimals: decimals of the underlying token
*/
bytes32 private constant ERC4626_STORAGE_LOCATION =
0x0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e00;
/**
* @dev Storage slot for ERC20Capped configuration following ERC-7201 namespaced storage pattern
* @notice This storage location manages the total supply cap functionality for the vault
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20Capped")) - 1)) & ~bytes32(uint256(0xff))
*
* Important:
* - This value MUST NOT be changed as it's used by OpenZeppelin's ERC20Capped implementation
* - Changing this value would break storage compatibility with existing deployments
* - Used by PlasmaVault.sol and PlasmaVaultBase.sol for supply cap enforcement
*
* Storage Layout:
* - Points to ERC20CappedStorage struct containing:
* - cap: maximum total supply denominated in shares (not in underlying asset decimals)
*
* Usage:
* - Enforces maximum supply limits during minting operations
* - Can be temporarily disabled for fee-related minting operations
* - Critical for maintaining vault supply control
*/
bytes32 private constant ERC20_CAPPED_STORAGE_LOCATION =
0x0f070392f17d5f958cc1ac31867dabecfc5c9758b4a419a200803226d7155d00;
/**
* @dev Storage slot for managing the ERC20 supply cap validation state
* @notice Controls whether total supply cap validation is active or temporarily disabled
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.Erc20CappedValidationFlag")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Provides a mechanism to temporarily disable supply cap checks
* - Essential for special minting operations like fee distribution
* - Used by PlasmaVault.sol during performance and management fee minting
*
* Storage Layout:
* - Points to ERC20CappedValidationFlag struct containing:
* - value: flag indicating if cap validation is enabled (0) or disabled (1)
*
* Usage Pattern:
* - Default state: Enabled (0) - enforces supply cap
* - Temporarily disabled (1) during:
* - Performance fee minting
* - Management fee minting
* - Always re-enabled after special minting operations
*
* Security Note:
* - Critical for maintaining controlled token supply
* - Only disabled briefly during authorized fee operations
* - Must be properly re-enabled to prevent unlimited minting
*/
bytes32 private constant ERC20_CAPPED_VALIDATION_FLAG =
0xaef487a7a52e82ae7bbc470b42be72a1d3c066fb83773bf99cce7e6a7df2f900;
/**
* @dev Storage slot for tracking total assets across all markets in the Plasma Vault
* @notice Maintains the global accounting of all assets managed by the vault
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.PlasmaVaultTotalAssetsInAllMarkets")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Tracks the total value of assets managed by the vault across all markets
* - Used for global vault accounting and share price calculations
* - Critical for ERC4626 compliance and vault operations
*
* Storage Layout:
* - Points to TotalAssets struct containing:
* - value: total assets in underlying token decimals
*
* Usage:
* - Updated during deposit/withdraw operations
* - Used in share price calculations
* - Referenced for fee calculations
* - Key component in asset distribution checks
*
* Integration Points:
* - PlasmaVault.sol: Used in totalAssets() calculations
* - Fee System: Used as base for fee calculations
* - Asset Protection: Used in distribution limit checks
*
* Security Considerations:
* - Must be accurately maintained for proper vault operation
* - Critical for share price accuracy
* - Any updates must consider all asset sources (markets, rewards, etc.)
*/
bytes32 private constant PLASMA_VAULT_TOTAL_ASSETS_IN_ALL_MARKETS =
0x24e02552e88772b8e8fd15f3e6699ba530635ffc6b52322da922b0b497a77300;
/**
* @dev Storage slot for tracking assets per individual market in the Plasma Vault
* @notice Maintains per-market asset accounting for the vault's distributed positions
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.PlasmaVaultTotalAssetsInMarket")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Tracks assets allocated to each market individually
* - Enables market-specific asset distribution control
* - Used for market balance validation and limits enforcement
*
* Storage Layout:
* - Points to MarketTotalAssets struct containing:
* - value: mapping(uint256 marketId => uint256 assets)
* - Assets stored in underlying token decimals
*
* Usage:
* - Updated during market operations via fuses
* - Used in market balance checks
* - Referenced for market limit validations
* - Key for asset distribution protection
*
* Integration Points:
* - Balance Fuses: Update market balances
* - Asset Distribution Protection: Enforce market limits
* - Withdrawal Logic: Check available assets per market
*
* Security Considerations:
* - Critical for market-specific asset limits
* - Must be synchronized with actual market positions
* - Updates protected by balance fuse system
*/
bytes32 private constant PLASMA_VAULT_TOTAL_ASSETS_IN_MARKET =
0x656f5ca8c676f20b936e991a840e1130bdd664385322f33b6642ec86729ee600;
/**
* @dev Storage slot for market substrates configuration in the Plasma Vault
* @notice Manages the configuration of supported assets and sub-markets for each market
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.CfgPlasmaVaultMarketSubstrates")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Defines which assets/sub-markets are supported in each market
* - Controls market-specific asset allowances
* - Essential for market integration configuration
*
* Storage Layout:
* - Points to MarketSubstrates struct containing:
* - value: mapping(uint256 marketId => MarketSubstratesStruct)
* where MarketSubstratesStruct contains:
* - substrateAllowances: mapping(bytes32 => uint256) for permission control
* - substrates: bytes32[] list of supported substrates
*
* Usage:
* - Configured by governance for each market
* - Referenced during market operations
* - Used by fuses to validate operations
* - Controls which assets can be used in each market
*
* Integration Points:
* - Fuse System: Validates allowed substrates
* - Market Operations: Controls available assets
* - Governance: Manages market configurations
*
* Security Considerations:
* - Critical for controlling market access
* - Only modifiable through governance
* - Impacts market operation permissions
*/
bytes32 private constant CFG_PLASMA_VAULT_MARKET_SUBSTRATES =
0x78e40624004925a4ef6749756748b1deddc674477302d5b7fe18e5335cde3900;
/**
* @dev Storage slot for pre-hooks configuration in the Plasma Vault
* @notice Manages function-specific pre-execution hooks and their implementations
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.CfgPlasmaVaultPreHooks")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Maps function selectors to their pre-execution hook implementations
* - Enables customizable pre-execution validation and logic
* - Provides extensible function-specific behavior
* - Coordinates cross-function state updates
*
* Storage Layout:
* - Points to PreHooksConfig struct containing:
* - hooksImplementation: mapping(bytes4 selector => address implementation)
* - selectors: bytes4[] array of registered function selectors
* - indexes: mapping(bytes4 selector => uint256 index) for O(1) selector lookup
*
* Usage Pattern:
* - Each function can have one designated pre-hook
* - Hooks execute before main function logic
* - Selector array enables efficient iteration over registered hooks
* - Index mapping provides quick hook existence checks
*
* Integration Points:
* - PlasmaVault.execute: Pre-execution hook invocation
* - PreHooksHandler: Hook execution coordination
* - PlasmaVaultGovernance: Hook configuration
* - Function-specific hooks: Custom validation logic
*
* Security Considerations:
* - Only modifiable through governance
* - Critical for function execution control
* - Must validate hook implementations
* - Requires careful state management
* - Key component of vault security layer
*/
bytes32 private constant CFG_PLASMA_VAULT_PRE_HOOKS =
0xd334d8b26e68f82b7df26f2f64b6ffd2aaae5e2fc0e8c144c4b3598dcddd4b00;
/**
* @dev Storage slot for balance fuses configuration in the Plasma Vault
* @notice Maps markets to their balance fuses and maintains an ordered list of active markets
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.CfgPlasmaVaultBalanceFuses")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Associates balance fuses with specific markets for asset tracking
* - Maintains ordered list of active markets for efficient iteration
* - Enables market balance validation and updates
* - Coordinates multi-market balance operations
*
* Storage Layout:
* - Points to BalanceFuses struct containing:
* - fuseAddresses: mapping(uint256 marketId => address fuseAddress)
* - marketIds: uint256[] array of active market IDs
* - indexes: Maps market IDs to their position+1 in marketIds array
*
* Usage Pattern:
* - Each market has one designated balance fuse
* - Market IDs array enables efficient iteration over active markets
* - Index mapping provides quick market existence checks
* - Used during balance updates and market operations
*
* Integration Points:
* - PlasmaVault._updateMarketsBalances: Market balance tracking
* - Balance Fuses: Market position management
* - PlasmaVaultGovernance: Fuse configuration
* - Asset Protection: Balance validation
*
* Security Considerations:
* - Only modifiable through governance
* - Critical for accurate asset tracking
* - Must maintain market list integrity
* - Requires proper fuse address validation
* - Key component of vault accounting
*/
bytes32 private constant CFG_PLASMA_VAULT_BALANCE_FUSES =
0x150144dd6af711bac4392499881ec6649090601bd196a5ece5174c1400b1f700;
/**
* @dev Storage slot for instant withdrawal fuses configuration
* @notice Stores ordered array of fuses that can be used for instant withdrawals
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.CfgPlasmaVaultInstantWithdrawalFusesArray")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Maintains list of fuses available for instant withdrawals
* - Defines order of withdrawal attempts
* - Enables efficient withdrawal path selection
*
* Storage Layout:
* - Points to InstantWithdrawalFuses struct containing:
* - value: address[] array of fuse addresses
* - Order of fuses in array determines withdrawal priority
*
* Usage:
* - Referenced during withdrawal operations
* - Used by PlasmaVault.sol in _withdrawFromMarkets
* - Determines withdrawal execution sequence
*
* Integration Points:
* - Withdrawal System: Defines available withdrawal paths
* - Fuse System: Lists supported instant withdrawal fuses
* - Governance: Manages withdrawal configuration
*
* Security Considerations:
* - Order of fuses is critical for optimal withdrawals
* - Same fuse can appear multiple times with different params
* - Must be carefully managed to ensure withdrawal efficiency
*/
bytes32 private constant CFG_PLASMA_VAULT_INSTANT_WITHDRAWAL_FUSES_ARRAY =
0xd243afa3da07e6bdec20fdd573a17f99411aa8a62ae64ca2c426d3a86ae0ac00;
/**
* @dev Storage slot for price oracle middleware configuration
* @notice Stores the address of the price oracle middleware used for asset price conversions
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.PriceOracleMiddleware")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Provides price feed access for asset valuations
* - Essential for market value calculations
* - Used in balance conversions and limit checks
*
* Storage Layout:
* - Points to PriceOracleMiddleware struct containing:
* - value: address of the price oracle middleware contract
*
* Usage:
* - Used during market balance updates
* - Required for USD value calculations
* - Critical for asset distribution checks
*
* Integration Points:
* - Balance Fuses: Asset value calculations
* - Market Operations: Price conversions
* - Asset Protection: Value-based limits
*
* Security Considerations:
* - Must point to a valid and secure price oracle
* - Critical for accurate vault valuations
* - Only updatable through governance
*/
bytes32 private constant PRICE_ORACLE_MIDDLEWARE =
0x0d761ae54d86fc3be4f1f2b44ade677efb1c84a85fc6bb1d087dc42f1e319a00;
/**
* @dev Storage slot for instant withdrawal fuse parameters configuration
* @notice Maps fuses to their specific withdrawal parameters for instant withdrawal execution
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.CfgPlasmaVaultInstantWithdrawalFusesParams")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Stores configuration parameters for each instant withdrawal fuse
* - Enables customized withdrawal behavior per fuse
* - Supports multiple parameter sets for the same fuse at different indices
*
* Storage Layout:
* - Points to InstantWithdrawalFusesParams struct containing:
* - value: mapping(bytes32 => bytes32[]) where:
* - key: keccak256(abi.encodePacked(fuse address, index))
* - value: array of parameters specific to the fuse
*
* Parameter Structure:
* - params[0]: Always represents withdrawal amount in underlying token
* - params[1+]: Fuse-specific parameters (e.g., slippage, path, market-specific data)
*
* Usage Pattern:
* - Referenced during instant withdrawal operations in PlasmaVault
* - Parameters are passed to fuse's instantWithdraw function
* - Supports multiple parameter sets for same fuse with different indices
*
* Integration Points:
* - PlasmaVault._withdrawFromMarkets: Uses params for withdrawal execution
* - PlasmaVaultGovernance: Manages parameter configuration
* - Fuse Contracts: Receive and interpret parameters during withdrawal
*
* Security Considerations:
* - Only modifiable through governance
* - Critical for controlling withdrawal behavior
* - Parameters must be carefully validated per fuse requirements
* - Order of parameters must match fuse expectations
*/
bytes32 private constant CFG_PLASMA_VAULT_INSTANT_WITHDRAWAL_FUSES_PARAMS =
0x45a704819a9dcb1bb5b8cff129eda642cf0e926a9ef104e27aa53f1d1fa47b00;
/**
* @dev Storage slot for fee configuration in the Plasma Vault
* @notice Manages the fee configuration including performance and management fees
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.CfgPlasmaVaultFeeConfig")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Stores comprehensive fee configuration for the vault
* - Manages both IPOR DAO and recipient-specific fee settings
* - Enables flexible fee distribution model
*
* Storage Layout:
* - Points to FeeConfig struct containing:
* - feeFactory: address of the FeeManagerFactory contract
* - iporDaoManagementFee: management fee percentage for IPOR DAO
* - iporDaoPerformanceFee: performance fee percentage for IPOR DAO
* - iporDaoFeeRecipientAddress: address receiving IPOR DAO fees
* - recipientManagementFees: array of management fee percentages for other recipients
* - recipientPerformanceFees: array of performance fee percentages for other recipients
*
* Fee Structure:
* - Management fees: Continuous time-based fees on AUM
* - Performance fees: Charged on positive vault performance
* - All fees in basis points (1/10000)
*
* Integration Points:
* - FeeManagerFactory: Deploys fee management contracts
* - FeeManager: Handles fee calculations and distributions
* - PlasmaVault: References for fee realizations
*
* Security Considerations:
* - Only modifiable through governance
* - Fee percentages must be within reasonable bounds
* - Critical for vault economics and sustainability
* - Must maintain proper recipient configurations
*/
bytes32 private constant CFG_PLASMA_VAULT_FEE_CONFIG =
0x78b5ce597bdb64d5aa30a201c7580beefe408ff13963b5d5f3dce2dc09e89c00;
/**
* @dev Storage slot for performance fee data in the Plasma Vault
* @notice Stores current performance fee configuration and recipient information
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.PlasmaVaultPerformanceFeeData")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Manages performance fee settings and collection
* - Tracks fee recipient address
* - Controls performance-based revenue sharing
*
* Storage Layout:
* - Points to PerformanceFeeData struct containing:
* - feeAccount: address receiving performance fees
* - feeInPercentage: current fee rate (basis points, 1/10000)
*
* Fee Mechanics:
* - Calculated on positive vault performance
* - Applied during execute() operations
* - Minted as new vault shares to fee recipient
* - Charged only on realized gains
*
* Integration Points:
* - PlasmaVault._addPerformanceFee: Fee calculation and minting
* - FeeManager: Fee configuration management
* - PlasmaVaultGovernance: Fee settings updates
*
* Security Considerations:
* - Only modifiable through governance
* - Fee percentage must be within defined limits
* - Critical for fair value distribution
* - Must maintain valid fee recipient address
* - Requires careful handling during share minting
*/
bytes32 private constant PLASMA_VAULT_PERFORMANCE_FEE_DATA =
0x9399757a27831a6cfb6cf4cd5c97a908a2f8f41e95a5952fbf83a04e05288400;
/**
* @notice Stores management fee configuration and time tracking data
* @dev Manages continuous fee collection with time-based accrual
* @custom:storage-location erc7201:io.ipor.PlasmaVaultManagementFeeData
*/
bytes32 private constant PLASMA_VAULT_MANAGEMENT_FEE_DATA =
0x239dd7e43331d2af55e2a25a6908f3bcec2957025f1459db97dcdc37c0003f00;
/**
* @dev Storage slot for rewards claim manager address
* @notice Stores the address of the contract managing external protocol rewards
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.RewardsClaimManagerAddress")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Manages external protocol reward claims
* - Tracks claimable rewards across integrated protocols
* - Centralizes reward collection logic
*
* Storage Layout:
* - Points to RewardsClaimManagerAddress struct containing:
* - value: address of the rewards claim manager contract
*
* Functionality:
* - Coordinates reward claims from multiple protocols
* - Tracks unclaimed rewards in underlying asset terms
* - Included in total assets calculations when active
* - Optional component (can be set to address(0))
*
* Integration Points:
* - PlasmaVault._getGrossTotalAssets: Includes rewards in total assets
* - PlasmaVault.claimRewards: Executes reward collection
* - External protocols: Source of claimable rewards
*
* Security Considerations:
* - Only modifiable through governance
* - Must handle protocol-specific claim logic safely
* - Critical for accurate reward accounting
* - Requires careful integration testing
* - Should handle failed claims gracefully
*/
bytes32 private constant REWARDS_CLAIM_MANAGER_ADDRESS =
0x08c469289c3f85d9b575f3ae9be6831541ff770a06ea135aa343a4de7c962d00;
/**
* @dev Storage slot for market allocation limits
* @notice Controls maximum asset allocation per market in the vault
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.MarketLimits")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Enforces market-specific allocation limits
* - Prevents over-concentration in single markets
* - Enables risk management through diversification
*
* Storage Layout:
* - Points to MarketLimits struct containing:
* - limitInPercentage: mapping(uint256 marketId => uint256 limit)
* - Limits stored in basis points (1e18 = 100%)
*
* Limit Mechanics:
* - Each market has independent allocation limit
* - Limits are percentage of total vault assets
* - Zero limit for marketId 0 deactivates all limits
* - Non-zero limit for marketId 0 activates limit system
*
* Integration Points:
* - AssetDistributionProtectionLib: Enforces limits
* - PlasmaVault._updateMarketsBalances: Checks limits
* - PlasmaVaultGovernance: Limit configuration
*
* Security Considerations:
* - Only modifiable through governance
* - Critical for risk management
* - Must handle percentage calculations carefully
* - Requires proper market balance tracking
* - Should prevent concentration risk
*/
bytes32 private constant MARKET_LIMITS = 0xc2733c187287f795e2e6e84d35552a190e774125367241c3e99e955f4babf000;
/**
* @dev Storage slot for market balance dependency relationships
* @notice Manages interconnected market balance update requirements
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.DependencyBalanceGraph")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Tracks dependencies between market balances
* - Ensures atomic balance updates across related markets
* - Maintains consistency in cross-market positions
*
* Storage Layout:
* - Points to DependencyBalanceGraph struct containing:
* - dependencyGraph: mapping(uint256 marketId => uint256[] marketIds)
* - Each market maps to array of dependent market IDs
*
* Dependency Mechanics:
* - Markets can depend on multiple other markets
* - When updating a market balance, all dependent markets must be updated
* - Dependencies are unidirectional (A->B doesn't imply B->A)
* - Empty dependency array means no dependencies
*
* Integration Points:
* - PlasmaVault._checkBalanceFusesDependencies: Resolves update order
* - PlasmaVault._updateMarketsBalances: Ensures complete updates
* - PlasmaVaultGovernance: Dependency configuration
*
* Security Considerations:
* - Only modifiable through governance
* - Must prevent circular dependencies
* - Critical for market balance integrity
* - Requires careful dependency chain validation
* - Should handle deep dependency trees efficiently
*/
bytes32 private constant DEPENDENCY_BALANCE_GRAPH =
0x82411e549329f2815579116a6c5e60bff72686c93ab5dba4d06242cfaf968900;
/**
* @dev Storage slot for tracking execution state of vault operations
* @notice Controls execution flow and prevents concurrent operations in the vault
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.executeRunning")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Prevents concurrent execution of vault operations
* - Enables callback handling during execution
* - Acts as a reentrancy guard for execute() operations
*
* Storage Layout:
* - Points to ExecuteState struct containing:
* - value: uint256 flag indicating execution state
* - 0: No execution in progress
* - 1: Execution in progress
*
* Usage Pattern:
* - Set to 1 at start of execute() operation
* - Checked during callback handling
* - Reset to 0 when execution completes
* - Used by PlasmaVault.execute() and callback system
*
* Integration Points:
* - PlasmaVault.execute: Sets/resets execution state
* - CallbackHandlerLib: Validates callbacks during execution
* - Fallback function: Routes callbacks during execution
*
* Security Considerations:
* - Critical for preventing concurrent operations
* - Must be properly reset after execution
* - Protects against malicious callbacks
* - Part of vault's security architecture
*/
bytes32 private constant EXECUTE_RUNNING = 0x054644eb87255c1c6a2d10801735f52fa3b9d6e4477dbed74914d03844ab6600;
/**
* @dev Storage slot for callback handler mapping in the Plasma Vault
* @notice Maps protocol-specific callbacks to their handler contracts
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.callbackHandler")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Routes protocol-specific callbacks to appropriate handlers
* - Enables dynamic callback handling during vault operations
* - Supports integration with external protocols
* - Manages protocol-specific callback logic
*
* Storage Layout:
* - Points to CallbackHandler struct containing:
* - callbackHandler: mapping(bytes32 => address)
* - key: keccak256(abi.encodePacked(sender, sig))
* - value: address of the handler contract
*
* Usage Pattern:
* - Callbacks received during execute() operations
* - Key generated from sender address and function signature
* - Handler contract processes protocol-specific logic
* - Only accessible when execution is in progress
*
* Integration Points:
* - PlasmaVault.fallback: Routes incoming callbacks
* - CallbackHandlerLib: Processes callback routing
* - Protocol-specific handlers: Implement callback logic
* - PlasmaVaultGovernance: Manages handler configuration
*
* Security Considerations:
* - Only callable during active execution
* - Handler addresses must be trusted
* - Prevents unauthorized callback processing
* - Critical for secure protocol integration
* - Must validate callback sources
*/
bytes32 private constant CALLBACK_HANDLER = 0xb37e8684757599da669b8aea811ee2b3693b2582d2c730fab3f4965fa2ec3e00;
/**
* @dev Storage slot for withdraw manager contract address
* @notice Manages withdrawal controls and permissions in the Plasma Vault
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("io.ipor.WithdrawManager")) - 1)) & ~bytes32(uint256(0xff))
*
* Purpose:
* - Controls withdrawal permissions and limits
* - Manages withdrawal schedules and timing
* - Enforces withdrawal restrictions
* - Coordinates withdrawal validation
*
* Storage Layout:
* - Points to WithdrawManager struct containing:
* - manager: address of the withdraw manager contract
* - Zero address indicates disabled withdrawal controls
*
* Usage Pattern:
* - Checked during withdraw() and redeem() operations
* - Validates withdrawal permissions
* - Enforces withdrawal schedules
* - Can be disabled by setting to address(0)
*
* Integration Points:
* - PlasmaVault.withdraw: Checks withdrawal permissions
* - PlasmaVault.redeem: Validates redemption requests
* - PlasmaVaultGovernance: Manager configuration
* - AccessManager: Permission coordination
*
* Security Considerations:
* - Critical for controlling asset outflows
* - Only modifiable through governance
* - Must maintain withdrawal restrictions
* - Coordinates with access control system
* - Key component of vault security
*/
bytes32 private constant WITHDRAW_MANAGER = 0x465d2ff0062318fe6f4c7e9ac78cfcd70bc86a1d992722875ef83a9770513100;
/**
* @dev Legacy storage slot for withdraw manager — pre-IL-6952 deployments.
* @notice Used as fallback when the corrected slot `WITHDRAW_MANAGER` returns address(0).
*
* Value differs from `CALLBACK_HANDLER` only in the last byte (`0x11` vs `0x00`) —
* both originate from the same `keccak256` preimage where the legacy slot was not
* masked by `& ~bytes32(uint256(0xff))` per ERC-7201. The value below is the raw
* constant that was deployed on legacy PlasmaVaults (e.g. Clearstar vault) and is
* pinned by `PlasmaVaultStorageLibSlotTest.testWithdrawManagerLegacySlot_pinsDeployedStateValue`.
*
* NEVER change this constant — it is a deployed-state value, not a recomputable slot.
*
* Tracked in IL-7407.
*/
bytes32 private constant WITHDRAW_MANAGER_LEGACY_SLOT =
0xb37e8684757599da669b8aea811ee2b3693b2582d2c730fab3f4965fa2ec3e11;
/**
* @dev Storage slot for plasma vault base address. Computed as:
* keccak256(abi.encode(uint256(keccak256("io.ipor.fusion.PlasmaVaultBase")) - 1)) & ~bytes32(uint256(0xff))
*/
bytes32 private constant PLASMA_VAULT_BASE_SLOT =
0x708fd1151214a098976e0893cd3883792c21aeb94a31cd7733c8947c13c23000;
/**
* @dev Storage slot for share scale multiplier. Computed as:
* keccak256(abi.encode(uint256(keccak256("io.ipor.fusion.param.ShareScaleMultiplier")) - 1)) & ~bytes32(uint256(0xff))
*/
bytes32 private constant SHARE_SCALE_MULTIPLIER_SLOT =
0x5bb34fc23414cfe7e422518e1d8590877bcc5dcacad5f8689bfd98e9a05ac600;
/**
* @dev Storage slot for PlasmaVaultVotesPlugin address. Computed as:
* keccak256(abi.encode(uint256(keccak256("io.ipor.fusion.PlasmaVaultVotesPlugin")) - 1)) & ~bytes32(uint256(0xff))
* @notice Stores address of PlasmaVaultVotesPlugin contract which provides optional ERC20Votes functionality
*/
bytes32 private constant PLASMA_VAULT_VOTES_PLUGIN_SLOT =
0x9a54c2c1797818ee85d1850742208f80368867ad13d3e45052e701201fa4af00;
/**
* @notice Maps callback signatures to their handler contracts
* @dev Stores routing information for protocol-specific callbacks
* @custom:storage-location erc7201:io.ipor.callbackHandler
*/
struct CallbackHandler {
/// @dev key: keccak256(abi.encodePacked(sender, sig)), value: handler address
mapping(bytes32 key => address handler) callbackHandler;
}
/**
* @notice Stores and manages per-market allocation limits for the vault
* @custom:storage-location erc7201:io.ipor.MarketLimits
*/
struct MarketLimits {
mapping(uint256 marketId => uint256 limit) limitInPercentage;
}
/**
* @notice Core storage for ERC4626 vault implementation
* @dev Value taken from OpenZeppelin's ERC4626 implementation - DO NOT MODIFY
* @custom:storage-location erc7201:openzeppelin.storage.ERC4626
*/
struct ERC4626Storage {
/// @dev underlying asset in Plasma Vault
address asset;
/// @dev underlying asset decimals in Plasma Vault
uint8 underlyingDecimals;
}
/// @dev Value taken from ERC20VotesUpgradeable contract, don't change it!
/// @custom:storage-location erc7201:openzeppelin.storage.ERC20Capped
struct ERC20CappedStorage {
/// @dev Maximum total supply cap denominated in shares (not in underlying asset decimals)
uint256 cap;
}
/// @notice ERC20CappedValidationFlag is used to enable or disable the total supply cap validation during execution
/// Required for situation when performance fee or management fee is minted for fee managers
/// @custom:storage-location erc7201:io.ipor.Erc20CappedValidationFlag
struct ERC20CappedValidationFlag {
uint256 value;
}
/**
* @notice Stores address of the contract managing protocol reward claims
* @dev Optional component - can be set to address(0) to disable rewards
* @custom:storage-location erc7201:io.ipor.RewardsClaimManagerAddress
*/
struct RewardsClaimManagerAddress {
/// @dev total assets in the Plasma Vault
address value;
}
/**
* @notice Tracks total assets across all markets in the vault
* @dev Used for global accounting and share price calculations
* @custom:storage-location erc7201:io.ipor.PlasmaVaultTotalAssetsInAllMarkets
*/
struct TotalAssets {
/// @dev total assets in the Plasma Vault
uint256 value;
}
/**
* @notice Tracks per-market asset balances in the vault
* @dev Used for market-specific accounting and limit enforcement
* @custom:storage-location erc7201:io.ipor.PlasmaVaultTotalAssetsInMarket
*/
struct MarketTotalAssets {
/// @dev marketId => total assets in the vault in the market
mapping(uint256 => uint256) value;
}
/**
* @notice Market Substrates configuration
* @dev Substrate - abstract item in the market, could be asset or sub market in the external protocol, it could be any item required to calculate balance in the market
* @custom:storage-location erc7201:io.ipor.CfgPlasmaVaultMarketSubstrates
*/
struct MarketSubstratesStruct {
/// @notice Define which substrates are allowed and supported in the market
/// @dev key can be specific asset or sub market in a specific external protocol (market), value - 1 - granted, otherwise - not granted
mapping(bytes32 => uint256) substrateAllowances;
/// @dev it could be list of assets or sub markets in a specific protocol or any other ids required to calculate balance in the market (external protocol)
bytes32[] substrates;
}
/**
* @notice Maps markets to their supported substrate configurations
* @dev Stores per-market substrate allowances and lists
* @custom:storage-location erc7201:io.ipor.CfgPlasmaVaultMarketSubstrates
*/
struct MarketSubstrates {
/// @dev marketId => MarketSubstratesStruct
mapping(uint256 => MarketSubstratesStruct) value;
}
/**
* @notice Manages market-to-fuse mappings and active market tracking
* @dev Provides efficient market lookup and iteration capabilities
* @custom:storage-location erc7201:io.ipor.CfgPlasmaVaultBalanceFuses
*
* Storage Components:
* - fuseAddresses: Maps each market to its designated balance fuse
* - marketIds: Maintains ordered list of active markets for iteration
* - indexes: Maps market IDs to their position+1 in marketIds array
*
* Key Features:
* - Efficient market-fuse relationship management
* - Fast market existence validation (index 0 means not present)
* - Optimized iteration over active markets
* - Maintains market list integrity
*
* Usage:
* - Market balance tracking and validation
* - Fuse assignment and management
* - Market activation/deactivation
* - Multi-market operations coordination
*
* Index Mapping Pattern:
* - Stored value = actual array index + 1
* - Value of 0 indicates market not present
* - To get array index, subtract 1 from stored value
* - Enables distinction between unset markets and first position
*
* Security Notes:
* - Market IDs must be unique
* - Index mapping must stay synchronized with array
* - Fuse addresses must be validated before assignment
* - Critical for vault's balance tracking system
*/
struct BalanceFuses {
/// @dev Maps market IDs to their corresponding balance fuse addresses
mapping(uint256 marketId => address fuseAddress) fuseAddresses;
/// @dev Ordered array of active market IDs for efficient iteration
uint256[] marketIds;
/// @dev Maps market IDs to their position+1 in the marketIds array (0 means not present)
mapping(uint256 marketId => uint256 index) indexes;
}
/**
* @notice Manages pre-execution hooks configuration for vault functions
* @dev Provides efficient hook lookup and management for function-specific pre-execution logic
* @custom:storage-location erc7201:io.ipor.CfgPlasmaVaultPreHooks
*
* Storage Components:
* - hooksImplementation: Maps function selectors to their hook implementation contracts
* - selectors: Maintains ordered list of registered function selectors
* - indexes: Enables O(1) selector existence checks and array access
*
* Key Features:
* - Efficient function-to-hook mapping management
* - Fast hook implementation lookup
* - Optimized iteration over registered hooks
* - Maintains hook registry integrity
*
* Usage:
* - Pre-execution validation and checks
* - Custom function-specific behavior
* - Hook registration and management
* - Cross-function state coordination
*
* Security Notes:
* - Function selectors must be unique
* - Index mapping must stay synchronized with array
* - Hook implementations must be validated before assignment
* - Critical for vault's execution security layer
*/
struct PreHooksConfig {
/// @dev Maps function selectors to their corresponding hook implementation addresses
mapping(bytes4 => address) hooksImplementation;
/// @dev Ordered array of registered function selectors for efficient iteration
bytes4[] selectors;
/// @dev Maps function selectors to their position in the selectors array for O(1) lookup
mapping(bytes4 selector => uint256 index) indexes;
/// @dev Maps function selectors and addresses to their corresponding substrate ids
/// @dev key is keccak256(abi.encodePacked(address, selector))
mapping(bytes32 key => bytes32[] substrates) substrates;
}
/**
* @notice Tracks dependencies between market balances for atomic updates
* @dev Maps markets to their dependent markets requiring simultaneous balance updates
* @custom:storage-location erc7201:io.ipor.BalanceDependenceGraph
*/
struct DependencyBalanceGraph {
mapping(uint256 marketId => uint256[] marketIds) dependencyGraph;
}
/**
* @notice Stores ordered list of fuses available for instant withdrawals
* @dev Order determines withdrawal attempt sequence, same fuse can appear multiple times
* @custom:storage-location erc7201:io.ipor.CfgPlasmaVaultInstantWithdrawalFusesArray
*/
struct InstantWithdrawalFuses {
/// @dev value is a Fuse address used for instant withdrawal
address[] value;
}
/**
* @notice Stores parameters for instant withdrawal fuse operations
* @dev Maps fuse+index pairs to their withdrawal configuration parameters
* @custom:storage-location erc7201:io.ipor.CfgPlasmaVaultInstantWithdrawalFusesParams
*/
struct InstantWithdrawalFusesParams {
/// @dev key: fuse address and index in InstantWithdrawalFuses array, value: list of parameters used for instant withdrawal
/// @dev first param always amount in underlying asset of PlasmaVault, second and next params are specific for the fuse and market
mapping(bytes32 => bytes32[]) value;
}
/**
* @notice Stores performance fee configuration and recipient data
* @dev Manages fee percentage and recipient account for performance-based fees
* @custom:storage-location erc7201:io.ipor.PlasmaVaultPerformanceFeeData
*/
struct PerformanceFeeData {
address feeAccount;
uint16 feeInPercentage;
}
/**
* @notice Stores management fee configuration and time tracking data
* @dev Manages continuous fee collection with time-based accrual
* @custom:storage-location erc7201:io.ipor.PlasmaVaultManagementFeeData
*/
struct ManagementFeeData {
address feeAccount;
uint16 feeInPercentage;
uint32 lastUpdateTimestamp;
}
/**
* @notice Stores address of price oracle middleware for asset valuations
* @dev Provides standardized price feed access for vault operations
* @custom:storage-location erc7201:io.ipor.PriceOracleMiddleware
*/
struct PriceOracleMiddleware {
address value;
}
/**
* @notice Tracks execution state of vault operations
* @dev Used as a flag to prevent concurrent execution and manage callbacks
* @custom:storage-location erc7201:io.ipor.executeRunning
*/
struct ExecuteState {
uint256 value;
}
/**
* @notice Stores address of the contract managing withdrawal controls
* @dev Handles withdrawal permissions, schedules and limits
* @custom:storage-location erc7201:io.ipor.WithdrawManager
*/
struct WithdrawManager {
address manager;
}
function getERC4626Storage() internal pure returns (ERC4626Storage storage $) {
assembly {
$.slot := ERC4626_STORAGE_LOCATION
}
}
function getERC20CappedStorage() internal pure returns (ERC20CappedStorage storage $) {
assembly {
$.slot := ERC20_CAPPED_STORAGE_LOCATION
}
}
function getERC20CappedValidationFlag() internal pure returns (ERC20CappedValidationFlag storage $) {
assembly {
$.slot := ERC20_CAPPED_VALIDATION_FLAG
}
}
function getTotalAssets() internal pure returns (TotalAssets storage totalAssets) {
assembly {
totalAssets.slot := PLASMA_VAULT_TOTAL_ASSETS_IN_ALL_MARKETS
}
}
function getExecutionState() internal pure returns (ExecuteState storage executeRunning) {
assembly {
executeRunning.slot := EXECUTE_RUNNING
}
}
function getCallbackHandler() internal pure returns (CallbackHandler storage handler) {
assembly {
handler.slot := CALLBACK_HANDLER
}
}
function getDependencyBalanceGraph() internal pure returns (DependencyBalanceGraph storage dependencyBalanceGraph) {
assembly {
dependencyBalanceGraph.slot := DEPENDENCY_BALANCE_GRAPH
}
}
function getMarketTotalAssets() internal pure returns (MarketTotalAssets storage marketTotalAssets) {
assembly {
marketTotalAssets.slot := PLASMA_VAULT_TOTAL_ASSETS_IN_MARKET
}
}
function getMarketSubstrates() internal pure returns (MarketSubstrates storage marketSubstrates) {
assembly {
marketSubstrates.slot := CFG_PLASMA_VAULT_MARKET_SUBSTRATES
}
}
function getBalanceFuses() internal pure returns (BalanceFuses storage balanceFuses) {
assembly {
balanceFuses.slot := CFG_PLASMA_VAULT_BALANCE_FUSES
}
}
function getPreHooksConfig() internal pure returns (PreHooksConfig storage preHooksConfig) {
assembly {
preHooksConfig.slot := CFG_PLASMA_VAULT_PRE_HOOKS
}
}
function getInstantWithdrawalFusesArray()
internal
pure
returns (InstantWithdrawalFuses storage instantWithdrawalFuses)
{
assembly {
instantWithdrawalFuses.slot := CFG_PLASMA_VAULT_INSTANT_WITHDRAWAL_FUSES_ARRAY
}
}
function getInstantWithdrawalFusesParams()
internal
pure
returns (InstantWithdrawalFusesParams storage instantWithdrawalFusesParams)
{
assembly {
instantWithdrawalFusesParams.slot := CFG_PLASMA_VAULT_INSTANT_WITHDRAWAL_FUSES_PARAMS
}
}
function getPriceOracleMiddleware() internal pure returns (PriceOracleMiddleware storage oracle) {
assembly {
oracle.slot := PRICE_ORACLE_MIDDLEWARE
}
}
function getPerformanceFeeData() internal pure returns (PerformanceFeeData storage performanceFeeData) {
assembly {
performanceFeeData.slot := PLASMA_VAULT_PERFORMANCE_FEE_DATA
}
}
function getManagementFeeData() internal pure returns (ManagementFeeData storage managementFeeData) {
assembly {
managementFeeData.slot := PLASMA_VAULT_MANAGEMENT_FEE_DATA
}
}
function getRewardsClaimManagerAddress()
internal
pure
returns (RewardsClaimManagerAddress storage rewardsClaimManagerAddress)
{
assembly {
rewardsClaimManagerAddress.slot := REWARDS_CLAIM_MANAGER_ADDRESS
}
}
function getMarketsLimits() internal pure returns (MarketLimits storage marketLimits) {
assembly {
marketLimits.slot := MARKET_LIMITS
}
}
/// @dev IMPORTANT: The WITHDRAW_MANAGER slot was corrected in IL-6952 (audit R4H7).
/// The previous slot value collided with CALLBACK_HANDLER at offset +0x11.
/// All fuses that read/write this slot via delegatecall must use the corrected PlasmaVaultStorageLib.
/// Affected fuses: BurnRequestFeeFuse, PlasmaVaultRequestSharesFuse, UpdateWithdrawManagerMaintenanceFuse.
function getWithdrawManager() internal pure returns (WithdrawManager storage withdrawManager) {
assembly {
withdrawManager.slot := WITHDRAW_MANAGER
}
}
/// @notice Reads withdraw-manager address with legacy-slot fallback (IL-7407).
/// @dev Returns the value of the corrected `WITHDRAW_MANAGER` slot (IL-6952).
/// If that slot is `address(0)`, falls back to the legacy slot
/// `WITHDRAW_MANAGER_LEGACY_SLOT` used by pre-IL-6952 PlasmaVault deployments.
/// Returns `address(0)` when neither slot is populated.
///
/// Intended exclusively for fuses that must run unchanged against both the
/// new and old PlasmaVault storage layouts (RequestFeeRefundFuse,
/// BurnRequestFeeFuse). New code MUST keep using `getWithdrawManager().manager`.
function getWithdrawManagerAddressWithLegacyFallback() internal view returns (address withdrawManager) {
withdrawManager = getWithdrawManager().manager;
if (withdrawManager == address(0)) {
assembly ("memory-safe") {
withdrawManager := sload(WITHDRAW_MANAGER_LEGACY_SLOT)
}
}
}
/// @notice Gets the plasma vault base address from storage
/// @return The address of the plasma vault base contract
function getPlasmaVaultBase() internal view returns (address) {
address base;
assembly {
base := sload(PLASMA_VAULT_BASE_SLOT)
}
return base;
}
/// @notice Sets the plasma vault base address in storage
/// @param base_ The address of the plasma vault base contract
function setPlasmaVaultBase(address base_) internal {
assembly {
sstore(PLASMA_VAULT_BASE_SLOT, base_)
}
}
/// @notice Gets the share scale multiplier from storage
/// @return The share scale multiplier value
function getShareScaleMultiplier() internal view returns (uint256) {
uint256 multiplier;
assembly {
multiplier := sload(SHARE_SCALE_MULTIPLIER_SLOT)
}
return multiplier;
}
/// @notice Sets the share scale multiplier in storage
/// @param multiplier_ The share scale multiplier value
function setShareScaleMultiplier(uint256 multiplier_) internal {
assembly {
sstore(SHARE_SCALE_MULTIPLIER_SLOT, multiplier_)
}
}
/// @notice Gets the PlasmaVaultVotesPlugin address from storage
/// @return The address of the PlasmaVaultVotesPlugin contract (optional ERC20Votes functionality)
function getPlasmaVaultVotesPlugin() internal view returns (address) {
address votesPlugin;
assembly {
votesPlugin := sload(PLASMA_VAULT_VOTES_PLUGIN_SLOT)
}
return votesPlugin;
}
/// @notice Sets the PlasmaVaultVotesPlugin address in storage
/// @param votesPlugin_ The address of the PlasmaVaultVotesPlugin contract
function setPlasmaVaultVotesPlugin(address votesPlugin_) internal {
assembly {
sstore(PLASMA_VAULT_VOTES_PLUGIN_SLOT, votesPlugin_)
}
}
}
lib/ipor-fusion/contracts/libraries/TypeConversionLib.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.30;
enum DataType {
UNKNOWN,
UINT256,
UINT128,
UINT64,
UINT32,
UINT16,
UINT8,
INT256,
INT128,
INT64,
INT32,
INT16,
INT8,
ADDRESS,
BOOL,
BYTES32
}
/// @title TypeConversionLib
/// @notice Library for converting between bytes32 and various Solidity types
/// @author IPOR Labs
library TypeConversionLib {
/// @notice Converts an address to bytes32
/// @param value_ The address to convert
/// @return The bytes32 representation
function toBytes32(address value_) internal pure returns (bytes32) {
return bytes32(uint256(uint160(value_)));
}
/// @notice Converts bytes32 to an address
/// @param value_ The bytes32 to convert
/// @return The address representation
function toAddress(bytes32 value_) internal pure returns (address) {
return address(uint160(uint256(value_)));
}
/// @notice Converts a uint256 to bytes32
/// @param value_ The uint256 to convert
/// @return The bytes32 representation
function toBytes32(uint256 value_) internal pure returns (bytes32) {
return bytes32(value_);
}
/// @notice Converts bytes32 to a uint256
/// @param value_ The bytes32 to convert
/// @return The uint256 representation
function toUint256(bytes32 value_) internal pure returns (uint256) {
return uint256(value_);
}
/// @notice Converts a bool to bytes32
/// @param value_ The bool to convert
/// @return The bytes32 representation (1 for true, 0 for false)
function toBytes32(bool value_) internal pure returns (bytes32) {
return bytes32(uint256(value_ ? 1 : 0));
}
/// @notice Converts bytes32 to a bool
/// @param value_ The bytes32 to convert
/// @return The bool representation
function toBool(bytes32 value_) internal pure returns (bool) {
return uint256(value_) != 0;
}
/// @notice Converts an int256 to bytes32
/// @param value_ The int256 to convert
/// @return The bytes32 representation
function toBytes32(int256 value_) internal pure returns (bytes32) {
return bytes32(uint256(value_));
}
/// @notice Converts bytes32 to an int256
/// @param value_ The bytes32 to convert
/// @return The int256 representation
function toInt256(bytes32 value_) internal pure returns (int256) {
return int256(uint256(value_));
}
/// @notice Converts bytes32 to bytes
/// @param value_ The bytes32 to convert
/// @return The bytes representation
function toBytes(bytes32 value_) internal pure returns (bytes memory) {
return abi.encodePacked(value_);
}
/// @notice Converts bytes to bytes32
/// @dev Reads up to the first 32 bytes of the input array, zero-padding if shorter. Returns 0 if empty.
/// @param value_ The bytes to convert
/// @return result The bytes32 representation (left-aligned, zero-padded on the right)
function toBytes32(bytes memory value_) internal pure returns (bytes32 result) {
if (value_.length == 0) return 0x0;
assembly {
result := mload(add(value_, 32))
let len := mload(value_)
// If input is shorter than 32 bytes, mask out the trailing bytes to prevent dirty memory leakage
if lt(len, 32) {
let shift := mul(8, sub(32, len))
let mask := not(sub(shl(shift, 1), 1))
result := and(result, mask)
}
}
}
}
lib/ipor-fusion/contracts/transient_storage/TransientStorageLib.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.30;
struct Data {
bytes32[] inputs;
bytes32[] outputs;
}
struct TransientStorage {
mapping(address => Data) data;
}
enum TransientStorageParamTypes {
UNKNOWN,
INPUTS_BY_FUSE,
OUTPUTS_BY_FUSE
}
/// @title TransientStorageLib
/// @notice Library for managing transient storage in the IPOR Fusion protocol
/// @author IPOR Labs
library TransientStorageLib {
/// @notice Error thrown when accessing an index outside the bounds of the array
/// @param index The index that was accessed
/// @param length The length of the array
error TransientStorageError(uint256 index, uint256 length);
/**
* @dev Storage slot for transient storage configuration following ERC-7201 namespaced storage pattern
* @notice This storage location is used to store the transient data
*
* Calculation:
* keccak256(abi.encode(uint256(keccak256("ipor.fusion.transient.storage")) - 1)) & ~bytes32(uint256(0xff))
*
* Storage Layout:
* - Points to TransientStorage struct containing:
* - data: mapping(address => Data)
*/
bytes32 internal constant TRANSIENT_STORAGE_SLOT =
0x52e2674580d1653ba0725afccd4b28629470cf627aaa13843c2f3e8867c3b900;
/// @notice Generic helper to store a value in transient storage
/// @param slot_ The storage slot to write to
/// @param value_ The value to write
function tstore(bytes32 slot_, bytes32 value_) internal {
assembly {
tstore(slot_, value_)
}
}
/// @notice Generic helper to load a value from transient storage
/// @param slot_ The storage slot to read from
/// @return value The value read from transient storage
function tload(bytes32 slot_) internal view returns (bytes32 value) {
assembly {
value := tload(slot_)
}
}
/// @notice Clears all input parameters for a specific account in transient storage
/// @param account_ The address of the account
function clearInputs(address account_) internal {
bytes32 inputsSlot = keccak256(abi.encode(account_, TRANSIENT_STORAGE_SLOT));
uint256 len = uint256(tload(inputsSlot));
if (len == 0) {
return;
}
tstore(inputsSlot, bytes32(0));
bytes32 dataStartSlot = keccak256(abi.encode(inputsSlot));
bytes32 elementSlot;
for (uint256 i; i < len; ++i) {
elementSlot = bytes32(uint256(dataStartSlot) + i);
tstore(elementSlot, bytes32(0));
}
}
/// @notice Sets input parameters for a specific account in transient storage
/// @param account_ The address of the account
/// @param inputs_ Array of input values
function setInputs(address account_, bytes32[] memory inputs_) internal {
clearInputs(account_);
// Data struct is at keccak256(account . TRANSIENT_STORAGE_SLOT)
// inputs array is at offset 0 of Data struct
bytes32 inputsSlot = keccak256(abi.encode(account_, TRANSIENT_STORAGE_SLOT));
// Store array length
tstore(inputsSlot, bytes32(inputs_.length));
// Store array elements at keccak256(inputsSlot) + index
bytes32 dataStartSlot = keccak256(abi.encode(inputsSlot));
for (uint256 i; i < inputs_.length; ++i) {
bytes32 elementSlot = bytes32(uint256(dataStartSlot) + i);
tstore(elementSlot, inputs_[i]);
}
}
/// @notice Sets a single input parameter for a specific account at a given index
/// @param account_ The address of the account
/// @param index_ The index of the input parameter
/// @param value_ The value to set
function setInput(address account_, uint256 index_, bytes32 value_) internal {
bytes32 inputsSlot = keccak256(abi.encode(account_, TRANSIENT_STORAGE_SLOT));
uint256 len = uint256(tload(inputsSlot));
if (index_ >= len) {
revert TransientStorageError(index_, len);
}
bytes32 dataStartSlot = keccak256(abi.encode(inputsSlot));
bytes32 elementSlot = bytes32(uint256(dataStartSlot) + index_);
tstore(elementSlot, value_);
}
/// @notice Retrieves a single input parameter for a specific account at a given index
/// @param account_ The address of the account
/// @param index_ The index of the input parameter
/// @return The input value at the specified index
function getInput(address account_, uint256 index_) internal view returns (bytes32) {
bytes32 inputsSlot = keccak256(abi.encode(account_, TRANSIENT_STORAGE_SLOT));
uint256 len = uint256(tload(inputsSlot));
if (index_ >= len) {
revert TransientStorageError(index_, len);
}
bytes32 dataStartSlot = keccak256(abi.encode(inputsSlot));
bytes32 elementSlot = bytes32(uint256(dataStartSlot) + index_);
return tload(elementSlot);
}
/// @notice Retrieves all input parameters for a specific account
/// @param account_ The address of the account
/// @return inputs Array of input values
function getInputs(address account_) internal view returns (bytes32[] memory inputs) {
bytes32 inputsSlot = keccak256(abi.encode(account_, TRANSIENT_STORAGE_SLOT));
uint256 len = uint256(tload(inputsSlot));
inputs = new bytes32[](len);
bytes32 dataStartSlot = keccak256(abi.encode(inputsSlot));
for (uint256 i; i < len; ++i) {
bytes32 elementSlot = bytes32(uint256(dataStartSlot) + i);
inputs[i] = tload(elementSlot);
}
}
/// @notice Sets output parameters for a specific account in transient storage
/// @param account_ The address of the account
/// @param outputs_ Array of output values
function setOutputs(address account_, bytes32[] memory outputs_) internal {
clearOutputs(account_);
// outputs array is at offset 1 of Data struct
bytes32 outputsSlot = bytes32(uint256(keccak256(abi.encode(account_, TRANSIENT_STORAGE_SLOT))) + 1);
uint256 len = outputs_.length;
tstore(outputsSlot, bytes32(outputs_.length));
bytes32 dataStartSlot = keccak256(abi.encode(outputsSlot));
bytes32 elementSlot;
for (uint256 i; i < len; ++i) {
elementSlot = bytes32(uint256(dataStartSlot) + i);
tstore(elementSlot, outputs_[i]);
}
}
/// @notice Retrieves a single output parameter for a specific account at a given index
/// @param account_ The address of the account
/// @param index_ The index of the output parameter
/// @return The output value at the specified index
function getOutput(address account_, uint256 index_) internal view returns (bytes32) {
bytes32 outputsSlot = bytes32(uint256(keccak256(abi.encode(account_, TRANSIENT_STORAGE_SLOT))) + 1);
uint256 len = uint256(tload(outputsSlot));
if (index_ >= len) {
revert TransientStorageError(index_, len);
}
bytes32 dataStartSlot = keccak256(abi.encode(outputsSlot));
bytes32 elementSlot = bytes32(uint256(dataStartSlot) + index_);
return tload(elementSlot);
}
/// @notice Retrieves all output parameters for a specific account
/// @param account_ The address of the account
/// @return outputs Array of output values
function getOutputs(address account_) internal view returns (bytes32[] memory outputs) {
bytes32 outputsSlot = bytes32(uint256(keccak256(abi.encode(account_, TRANSIENT_STORAGE_SLOT))) + 1);
uint256 len = uint256(tload(outputsSlot));
outputs = new bytes32[](len);
bytes32 dataStartSlot = keccak256(abi.encode(outputsSlot));
bytes32 elementSlot;
for (uint256 i; i < len; ++i) {
elementSlot = bytes32(uint256(dataStartSlot) + i);
outputs[i] = tload(elementSlot);
}
}
/// @notice Clears all output parameters for a specific account in transient storage
/// @param account_ The address of the account
function clearOutputs(address account_) internal {
// outputs array is at offset 1 of Data struct
bytes32 outputsSlot = bytes32(uint256(keccak256(abi.encode(account_, TRANSIENT_STORAGE_SLOT))) + 1);
// Get current length to clear elements
uint256 len = uint256(tload(outputsSlot));
// Clear length
tstore(outputsSlot, bytes32(0));
// Clear elements (optional but good practice for cleanliness)
bytes32 dataStartSlot = keccak256(abi.encode(outputsSlot));
bytes32 elementSlot;
for (uint256 i; i < len; ++i) {
elementSlot = bytes32(uint256(dataStartSlot) + i);
tstore(elementSlot, bytes32(0));
}
}
}
lib/ipor-fusion/node_modules/@openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"optimizer": {
"runs": 1000000,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"@openzeppelin/=lib/ipor-fusion/node_modules/@openzeppelin/",
"@chainlink/=lib/ipor-fusion/node_modules/@chainlink/",
"@uniswap/v4-core/=lib/ipor-fusion/node_modules/@uniswap/v4-core/",
"eth-gas-reporter/=node_modules/eth-gas-reporter/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"@ipor-protocol-deploy/=contracts/",
"@ipor-fusion/=lib/ipor-fusion/",
"@ipor-protocol/=lib/ipor-protocol/",
"scripts/=scripts/",
"@eth-optimism/=lib/ipor-fusion/node_modules/@eth-optimism/",
"@ethereum-vault-connector/=lib/ipor-fusion/node_modules/ethereum-vault-connector/",
"@morpho-org/=lib/ipor-fusion/node_modules/@morpho-org/",
"@pendle/=lib/ipor-fusion/node_modules/@pendle/",
"@prb/test/=lib/ipor-fusion/lib/foundry-random/lib/prb-test/src/",
"@scroll-tech/=lib/ipor-fusion/node_modules/@scroll-tech/",
"@uniswap/v3-core/=lib/ipor-fusion/node_modules/@uniswap/v3-core/",
"CramBit/=lib/ipor-fusion/lib/foundry-random/lib/CramBit/",
"abdk-libraries-solidity/=node_modules/abdk-libraries-solidity/",
"base64-sol/=lib/ipor-fusion/node_modules/base64-sol/",
"crambit/=lib/ipor-fusion/lib/foundry-random/lib/CramBit/src/",
"erc4626-tests/=lib/ipor-fusion/node_modules/@uniswap/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"ethereum-vault-connector/=lib/ipor-fusion/node_modules/ethereum-vault-connector/",
"foundry-random/=lib/ipor-fusion/lib/foundry-random/src/",
"hardhat-deploy/=node_modules/hardhat-deploy/",
"hardhat/=node_modules/hardhat/",
"ipor-fusion/=lib/ipor-fusion/contracts/",
"openzeppelin-contracts/=lib/ipor-fusion/node_modules/@uniswap/v4-core/lib/openzeppelin-contracts/",
"openzeppelin/=lib/ipor-fusion/node_modules/ethereum-vault-connector/lib/openzeppelin-contracts/contracts/",
"prb-test/=lib/ipor-fusion/lib/foundry-random/lib/prb-test/src/",
"solidity-bytes-utils/=lib/ipor-fusion/lib/foundry-random/lib/solidity-bytes-utils/contracts/",
"solmate/=lib/ipor-fusion/node_modules/@uniswap/v4-core/lib/solmate/",
"src/=lib/ipor-fusion/lib/foundry-random/src/",
"test/=lib/ipor-fusion/test/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.