Source Code
| Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
Advanced mode: Intended for advanced users or developers and will display all Internal Transactions including zero value transfers.
Latest 25 internal transactions (View All)
Advanced mode:
| Parent Transaction Hash | Block | From | To | ||||
|---|---|---|---|---|---|---|---|
| 49834427 | 6 days ago | 0 MON | |||||
| 49834427 | 6 days ago | 0 MON | |||||
| 49834427 | 6 days ago | 0 MON | |||||
| 47683350 | 16 days ago | 0 MON | |||||
| 47683350 | 16 days ago | 0 MON | |||||
| 47683350 | 16 days ago | 0 MON | |||||
| 47611598 | 16 days ago | 0 MON | |||||
| 47611598 | 16 days ago | 0 MON | |||||
| 47611598 | 16 days ago | 0 MON | |||||
| 47539858 | 17 days ago | 0 MON | |||||
| 47539858 | 17 days ago | 0 MON | |||||
| 47539858 | 17 days ago | 0 MON | |||||
| 47467998 | 17 days ago | 0 MON | |||||
| 47467998 | 17 days ago | 0 MON | |||||
| 47467998 | 17 days ago | 0 MON | |||||
| 47396233 | 17 days ago | 0 MON | |||||
| 47396233 | 17 days ago | 0 MON | |||||
| 47396233 | 17 days ago | 0 MON | |||||
| 47360686 | 18 days ago | 0 MON | |||||
| 47360686 | 18 days ago | 0 MON | |||||
| 47360686 | 18 days ago | 0 MON | |||||
| 47360686 | 18 days ago | 0 MON | |||||
| 47360686 | 18 days ago | 0 MON | |||||
| 47360686 | 18 days ago | 0 MON | |||||
| 47358814 | 18 days ago | 0 MON |
Loading...
Loading
Contract Name:
VaultFundManager
Compiler Version
v0.8.30+commit.73712a01
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import { MultipliVault } from "../vault/MultipliVault.sol";
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import { console } from "forge-std/console.sol";
/**
* @title VaultFundManager
* @notice A helper contract for managing vault fund operations including fund transfers and redemption fulfillment
* @dev This contract acts as an intermediary for vault operations that require careful balance management.
* All functions are designed to be called through the vault's `manage` function,
* ensuring proper authorization (except `flashRedeem()`)
*
* Key responsibilities:
* - Remove funds from vault while maintaining total asset consistency
* - Update underlying balance aggregations from strategies / exchanges.
* - Facilitate redemption fulfillment with proper balance adjustments
* - Handle flash redemptions for unwinding leveraged positions
*
* Security model: Access control is enforced by requiring calls to originate from the vault contract,
* which means they must go through the vault's `manage` function with proper authorization.
* Exception: `flashRedeem()`. For flashRedeem, the user and operator has to be added
* to the allowlist (`whitelistedUserOperator`)
*/
contract VaultFundManager is ReentrancyGuard {
using SafeERC20 for IERC20;
using Math for uint256;
//============================== Structs ===============================
/**
* @notice Structure to capture vault state for validation
* @dev Used to ensure state consistency before and after flash redemption operations
* @param lastPricePerShare The last recorded price per share from vault (`vault.lastPricePerShare()`)
* @param priceOfOneShare Current price of one share calculated from convertToAssets (`vault.convertToAssets(1e6)`)
* @param totalAssets Total assets managed by the vault
* @param totalSupply Total supply of vault shares
* @param tokenBalance Current token balance held by the vault
* @param aggregatedUnderlyingBalances Aggregated balances across external strategies
*/
struct StateCheckVars {
uint256 lastPricePerShare;
uint256 priceOfOneShare;
uint256 totalAssets;
uint256 totalSupply;
uint256 tokenBalance;
uint256 aggregatedUnderlyingBalances;
}
//============================== ERRORS ===============================
/// @notice Thrown when an unauthorized address attempts to call a function
error UnauthorizedCaller();
/// @notice Thrown when the requested amount exceeds available balance
error InsufficientBalance();
/// @notice Thrown when the requested amount exceeds available balance
error InsufficientAggregateUnderlyingBalance();
/// @notice Thrown when total assets don't match before and after an operation
error TotalAssetsMismatch();
/// @notice Thrown when total assets don't match before and after an operation
error TotalSupplyMismatch();
/// @notice Thrown when a zero address is provided where it's not allowed
error ZeroAddress();
/// @notice Thrown when a zero amount is provided where it's not allowed
error ZeroAmount();
//============================== EVENTS ===============================
/**
* @notice Emitted when funds are removed from the vault
* @param recipient The address receiving the funds
* @param amount The amount of assets transferred
* @param newAggregatedBalance The updated aggregated underlying balance
*/
event FundsRemovedFromVault(
address indexed recipient, uint256 amount, uint256 newAggregatedBalance
);
/**
* @notice Emitted when underlying balance is updated
* @param oldBalance The previous aggregated underlying balance
* @param newBalance The updated aggregated underlying balance
*/
event UnderlyingBalanceUpdated(uint256 oldBalance, uint256 newBalance);
/**
* @notice Emitted when funds are added and redemption is fulfilled
* @param receiver The address receiving the redeemed assets
* @param shares The amount of shares being redeemed
* @param assetsWithFee The amount of assets transferred including fees
* @param newAggregatedBalance The updated aggregated underlying balance
*/
event FundsAddedAndRedemptionFulfilled(
address indexed receiver,
uint256 shares,
uint256 assetsWithFee,
uint256 newAggregatedBalance
);
/**
* @notice Emitted when funds are added and redemption is fulfilled
* @param initiator The address initiating the request
* @param operator The address of the operator (responsible for paying back)
* @param shares The amount of shares that were redeemed
* @param assetsWithFee The amount that corresponds to the shares
* @param newAggregatedBalance The updated aggregated underlying balance
*/
event FundsAddedAndFlashRedemptionFulfilled(
address indexed initiator,
address indexed operator,
uint256 shares,
uint256 assetsWithFee,
uint256 newAggregatedBalance
);
/**
* @notice Emitted when an user operator whitelist is updated
* @param user The address of the user
* @param operator The address of the operator contract
* @param enabled true/false -> specifies if the user is whitelisted or not.
*/
event UpdateOperatorWhitelist(address user, address operator, bool enabled);
/**
* @notice Emitted when ERC20 assets are removed from the contract
* @param to The address that received the funds
* @param amount The amount of assets transferred
*/
event RemoveFunds(address indexed to, uint256 amount);
/**
* @notice Emitted when native assets (ETH/AVAX) are removed from the contract
* @param to The address that received the native funds
* @param amount The amount of native assets transferred
*/
event RemoveFundsNative(address indexed to, uint256 amount);
//============================== STATE VARIABLES ===============================
/// @notice The vault contract this manager is associated with
MultipliVault public immutable vault;
/// @notice The underlying asset managed by the vault
address public immutable asset;
/// @notice The mapping specifies if an address is a user is associated with an operator
mapping(address user => mapping(address operator => bool enabled)) public
whitelistedUserOperator;
uint256 internal constant DENOMINATOR = 1e18;
//============================== CONSTRUCTOR ===============================
/**
* @notice Initializes the VaultFundManager with the specified vault
* @param _vaultAddr The address of the MultipliVault contract
* @dev The vault address cannot be zero and must be a valid MultipliVault contract
*/
constructor(address payable _vaultAddr) {
if (_vaultAddr == address(0)) {
revert ZeroAddress();
}
vault = MultipliVault(_vaultAddr);
asset = vault.asset();
}
//============================== MODIFIERS ===============================
/**
* @notice Ensures the function is called only through the vault's manage function
* @dev This provides access control by leveraging the vault's authorization system
*/
modifier onlyVault() {
if (msg.sender != address(vault)) {
revert UnauthorizedCaller();
}
_;
}
/**
* @notice Ensures the user-operator combination is whitelisted
* @param user The user address to check
* @param operator The operator address to check
* @dev Prevents unauthorized operators from being used by users
*/
modifier isWhitelisted(address user, address operator) {
if (!whitelistedUserOperator[user][operator]) {
revert UnauthorizedCaller();
}
_;
}
//============================== EXTERNAL FUNCTIONS ===============================
/**
* @notice Updates the whitelist status for a user-operator combination
* @param user The user address
* @param operator The operator contract address
* @param enable True to enable, false to disable the combination
* @dev Can only be called through the vault's manage function
* @custom:throws ZeroAddress if user or operator is address(0)
*/
function updateUserOperatorWhitelist(
address user,
address operator,
bool enable
)
external
onlyVault
{
if (user == address(0) || operator == address(0)) {
revert ZeroAddress();
}
whitelistedUserOperator[user][operator] = enable;
emit UpdateOperatorWhitelist(user, operator, enable);
}
/**
* @notice Removes funds from the vault while maintaining total asset consistency
* @dev This function transfers assets from the vault to a recipient and updates the aggregated
* underlying balances to maintain the same total asset value. This is typically used when
* moving funds to exchange wallet.
*
* The operation maintains the invariant: totalAssets(before) == totalAssets(after)
*
* @param recipient The address to receive the funds (must be whitelisted in vault)
* @param amount The amount of assets to transfer
*
* @custom:throws ZeroAddress if recipient is address(0)
* @custom:throws ZeroAmount if amount is 0
* @custom:throws InsufficientBalance if amount exceeds vault balance
* @custom:throws TotalAssetsMismatch if total assets change after operation
*
* Requirements:
* - Can only be called through vault's manage function
* - Amount must not exceed vault's asset balance
* - Recipient must be whitelisted in the vault for fund transfers
* - Total assets must remain constant after operation
*/
function removeFundsFromVault(
address recipient,
uint256 amount
)
external
nonReentrant
onlyVault
{
if (recipient == address(0)) {
revert ZeroAddress();
}
if (amount == 0) {
revert ZeroAmount();
}
uint256 balance = IERC20(asset).balanceOf(address(vault));
if (amount > balance) {
revert InsufficientBalance();
}
uint256 oldAggregatedUnderlyingBalances = vault.aggregatedUnderlyingBalances();
uint256 oldTotalAssetsValue = vault.totalAssets();
uint256 oldTotalSupplyValue = vault.totalSupply();
// Remove funds from vault and update aggregated balance to maintain total assets
vault.removeFunds(amount, recipient);
uint256 newAggregatedBalance = oldAggregatedUnderlyingBalances + amount;
vault.onUnderlyingBalanceUpdate(newAggregatedBalance);
// Verify total assets remain unchanged
if (oldTotalAssetsValue != vault.totalAssets()) {
revert TotalAssetsMismatch();
}
// sanity check: total number of shares must remain unchanged
if (oldTotalSupplyValue != vault.totalSupply()) {
revert TotalSupplyMismatch();
}
emit FundsRemovedFromVault(recipient, amount, newAggregatedBalance);
}
/**
* @notice Updates the aggregated underlying balance with new values from external strategies
* @dev This function is called periodically to update the vault's understanding of assets
* held in external strategies. The newAggregatedBalance should include both
* principal and any yield generated.
*
* @param newAggregatedBalance The new total balance across all external strategies (principal + yield)
*
* @custom:throws ZeroAmount if newAggregatedBalance is 0 and there should be underlying balances
*
* Requirements:
* - Can only be called through vault's manage function
* - Should be called periodically by authorized operators to reflect current external balances
*/
function updateUnderlyingBalance(uint256 newAggregatedBalance)
external
nonReentrant
onlyVault
{
uint256 oldBalance = vault.aggregatedUnderlyingBalances();
vault.onUnderlyingBalanceUpdate(newAggregatedBalance);
emit UnderlyingBalanceUpdated(oldBalance, newAggregatedBalance);
}
/**
* @notice Adds funds to the vault and fulfills a pending redemption request
* @dev This function facilitates redemption by first transferring the required assets to the vault,
* updating the aggregated balance to account for the asset movement, and then fulfilling
* the redemption request. This three-step process ensures price stability and prevents
* sandwich attacks.
*
* The operation flow:
* 1. Transfer assets from this contract to the vault
* 2. Update aggregated balance to reflect the asset movement from external strategies
* 3. Fulfill the redemption request
*
* This maintains the share price consistency throughout the operation.
*
* @param receiver The address that will receive the redeemed assets
* @param shares The number of shares being redeemed
* @param assetsWithFee The amount of assets to transfer (including any applicable fees)
*
* @custom:throws ZeroAddress if receiver is address(0)
* @custom:throws ZeroAmount if shares or assetsWithFee is 0
* @custom:throws InsufficientBalance if this contract doesn't have enough assets
*
* Requirements:
* - Can only be called through vault's manage function
* - This contract must hold sufficient assets for the transfer
* - The receiver must have a valid pending redemption request in the vault
* - Shares and assetsWithFee must match the pending redemption request
*/
function addFundsAndFulfillRedeem(
address receiver,
uint256 shares,
uint256 assetsWithFee
)
external
nonReentrant
onlyVault
{
if (receiver == address(0)) {
revert ZeroAddress();
}
if (shares == 0 || assetsWithFee == 0) {
revert ZeroAmount();
}
uint256 contractBalance = IERC20(asset).balanceOf(address(this));
if (assetsWithFee > contractBalance) {
revert InsufficientBalance();
}
uint256 oldAggregatedUnderlyingBalances = vault.aggregatedUnderlyingBalances();
if (assetsWithFee > oldAggregatedUnderlyingBalances) {
revert InsufficientAggregateUnderlyingBalance();
}
// Step 1: Transfer the required assets from this contract to the vault
IERC20(asset).safeTransfer(address(vault), assetsWithFee);
// Step 2: Fulfill the redemption request
vault.fulfillRedeem(receiver, shares, assetsWithFee);
// Step 3: Update the aggregated balance to reflect assets moved from external strategies
uint256 newAggregatedBalance = oldAggregatedUnderlyingBalances - assetsWithFee;
vault.onUnderlyingBalanceUpdate(newAggregatedBalance);
emit FundsAddedAndRedemptionFulfilled(receiver, shares, assetsWithFee, newAggregatedBalance);
}
/**
* @notice Executes a flash redemption for unwinding leveraged positions
* @param operator The operator contract that will handle position unwinding
* @param shares The number of shares to redeem via flash redemption
* @param data Additional data to pass to the operator callback
* @dev This function enables users to unwind leveraged positions by providing temporary
* liquidity to close positions on external protocols (like Euler). The operator
* receives USDC upfront and must return the equivalent vault shares.
*
* Process:
* 1. Validate user-operator whitelist
* 2. Transfer USDC to vault
* 3. Update underlying balance
* 4. Call vault's flashRedeem which callbacks to operator
* 5. Validate state changes within acceptable slippage
*
* @custom:throws ZeroAddress if operator is address(0)
* @custom:throws ZeroAmount if shares or assetsWithFee is 0
* @custom:throws InsufficientBalance if contract doesn't have enough assets
* @custom:throws UnauthorizedCaller if user-operator combination not whitelisted
*
* Requirements:
* - User-operator combination must be whitelisted
* - Contract must have sufficient USDC balance
* - Aggregated underlying balance must be sufficient
* - State changes must be within 0.5% slippage tolerance
*/
function flashRedeem(
address operator,
uint256 shares,
bytes calldata data
)
external
nonReentrant
isWhitelisted(msg.sender, operator)
{
StateCheckVars memory initialStateVars;
StateCheckVars memory finalStateVars;
address initiator = msg.sender;
if (operator == address(0)) {
revert ZeroAddress();
}
uint256 assetsWithFee = vault.convertToAssets(shares);
if (shares == 0 || assetsWithFee == 0) {
revert ZeroAmount();
}
uint256 contractBalance = IERC20(asset).balanceOf(address(this));
if (assetsWithFee > contractBalance) {
revert InsufficientBalance();
}
// record the snapshot of the necessary state variables
initialStateVars = _captureCurrentStateInformation();
// When this happens, this means the vault is new (`onUnderlyingBalanceUpdate` has not been called) or
// when the value of `onUnderlyingBalanceUpdate` was set as 0 which means the vault has lost all it's value
// Adding it here, so we fail fast. As part of step2: we deduct the totalAssets() value by calling `onUnderlyingBalanceUpdate`
require(
initialStateVars.aggregatedUnderlyingBalances != 0
&& initialStateVars.aggregatedUnderlyingBalances >= assetsWithFee,
"INVARIANT: InvalidCurrentAggregateBalance"
);
// Step 1: Transfer the required assets from this contract to the vault
IERC20(asset).safeTransfer(address(vault), assetsWithFee);
// Step 2: Update the aggregated balance to reflect assets moved from external strategies
uint256 newAggregatedBalance = initialStateVars.aggregatedUnderlyingBalances - assetsWithFee;
vault.onUnderlyingBalanceUpdate(newAggregatedBalance);
// Step 3: Fulfill the redemption request
vault.flashRedeem({
initiator: initiator,
operator: operator,
receiver: operator,
shares: shares,
data: data
});
emit FundsAddedAndFlashRedemptionFulfilled(
initiator, operator, shares, assetsWithFee, newAggregatedBalance
);
finalStateVars = _captureCurrentStateInformation();
_validateStateChanges(initialStateVars, finalStateVars, assetsWithFee, shares);
}
/**
* @notice Removes ERC20 assets from the contract and transfers them to a specified address
* @dev This function can only be called by the vault contract through the manage function.
* It's typically used to move funds to exchanges for delta neutral strategies or to
* whitelisted addresses for operational purposes. The initiator parameter allows
* tracking which authorized operator initiated the fund movement for audit purposes.
*
* @param to The address to receive the funds
* @param amount The amount of assets to transfer
*
* @custom:throws ZeroAddress if `to` is the zero address
* @custom:throws ZeroAmount if `amount` is zero
*
* Requirements:
* - Can only be called by the vault contract
* - `to` address must not be zero
* - `amount` must be greater than zero
* - Contract must have sufficient balance of the asset
* - `to` address must be whitelisted by the vault for fund transfers
*
* @custom:emits RemoveFunds
*/
function removeFunds(address to, uint256 amount) external onlyVault {
if (to == address(0)) {
revert ZeroAddress();
}
if (amount == 0) {
revert ZeroAmount();
}
uint256 balance = IERC20(asset).balanceOf(address(this));
if (balance < amount) {
revert InsufficientBalance();
}
IERC20(asset).safeTransfer(to, amount);
emit RemoveFunds(to, amount);
}
/**
* @notice Removes native assets (ETH/AVAX) from the contract and transfers them to a specified address
* @dev This function can only be called by the vault contract through the manage function.
* It's used to transfer native blockchain assets
* for operational purposes such as paying gas fees or moving native assets to exchanges.
*
* Note: This function uses a low-level call which does not revert on failure.
* Consider adding return value checking if needed for your use case.
*
* @param to The address to receive the native funds (must be whitelisted by the vault)
* @param amount The amount of native assets to transfer (in wei)
*
* @custom:throws ZeroAddress if `to` is the zero address
* @custom:throws ZeroAmount if `amount` is zero
*
* Requirements:
* - Can only be called by the vault contract
* - `to` address must not be zero
* - `amount` must be greater than zero
* - Contract must have sufficient native asset balance
* - `to` address must be whitelisted by the vault for fund transfers
*
* @custom:security Consider adding return value checking for the low-level call
* @custom:emits RemoveFundsNative
*/
function removeFundsNative(address to, uint256 amount) external onlyVault {
if (to == address(0)) {
revert ZeroAddress();
}
if (amount == 0) {
revert ZeroAmount();
}
uint256 balance = address(this).balance;
if (balance < amount) {
revert InsufficientBalance();
}
(bool success,) = to.call{ value: amount }("");
require(success, "Transfer failed");
emit RemoveFundsNative(to, amount);
}
//============================== VIEW FUNCTIONS ===============================
/**
* @notice Returns the current asset balance held by this contract
* @return balance The amount of assets currently held by this contract
*/
function getContractAssetBalance() external view returns (uint256 balance) {
return IERC20(asset).balanceOf(address(this));
}
/**
* @notice Returns the current aggregated underlying balances from the vault
* @return aggregatedBalance The current aggregated underlying balances
*/
function getAggregatedUnderlyingBalances() external view returns (uint256 aggregatedBalance) {
return vault.aggregatedUnderlyingBalances();
}
/**
* @notice Returns the total assets managed by the vault
* @return totalAssets The total assets (vault balance + aggregated underlying balances)
*/
function getTotalAssets() external view returns (uint256 totalAssets) {
return vault.totalAssets();
}
/**
* @notice Calculate the percentage change between two prices
* @param oldPrice The previous price
* @param newPrice The new price
* @return The percentage change (1e18 = 100%)
* @dev Used to detect excessive price volatility and trigger emergency pause
*/
function _calculatePercentageChange(
uint256 oldPrice,
uint256 newPrice
)
private
pure
returns (uint256)
{
if (oldPrice == 0) {
return 0;
}
uint256 diff = newPrice > oldPrice ? newPrice - oldPrice : oldPrice - newPrice;
return diff.mulDiv(DENOMINATOR, oldPrice, Math.Rounding.Ceil);
}
/**
* @notice Captures current vault state information for validation
* @return stateVars Struct containing current state variables
* @dev Used to ensure state consistency before and after flash redemption operations
*/
function _captureCurrentStateInformation()
private
view
returns (StateCheckVars memory stateVars)
{
uint256 decimals = vault.decimals();
// store the values before initiating the operation
stateVars.lastPricePerShare = vault.lastPricePerShare();
stateVars.priceOfOneShare = vault.convertToAssets(10 ** decimals); // Ideally, lastPricePerShareBefore = priceOfOneShareBefore
stateVars.totalAssets = vault.totalAssets();
stateVars.totalSupply = vault.totalSupply();
stateVars.tokenBalance = IERC20(asset).balanceOf(address(vault));
stateVars.aggregatedUnderlyingBalances = vault.aggregatedUnderlyingBalances();
return stateVars;
}
/**
* @notice Validates state changes after flash redemption operations
* @param initialState The state before the operation
* @param finalState The state after the operation
* @param assetsWithFee The amount of assets involved in the operation
* @param shares The amount of shares involved in the operation
* @dev Ensures that state changes are within acceptable tolerance (0.5% slippage)
* and that invariants are maintained
*
* Requirements:
* - Price per share slippage must be < 0.5%
* - Total assets must not decrease unexpectedly
* - Total supply must not decrease unexpectedly
* - Token balance must not decrease
* - Underlying balance changes must match expected amounts
*/
function _validateStateChanges(
StateCheckVars memory initialState,
StateCheckVars memory finalState,
uint256 assetsWithFee,
uint256 shares
)
private
pure
{
// 5e15 => 0.5%
require(
_calculatePercentageChange(initialState.lastPricePerShare, finalState.lastPricePerShare)
< 5e15,
"FUND_MANAGER: lastPricePerShare:SlippageGreaterThanThreshold"
);
require(
_calculatePercentageChange(initialState.priceOfOneShare, finalState.priceOfOneShare)
< 5e15,
"FUND_MANAGER: priceOfOneShare:SlippageGreaterThanThreshold"
);
require(
initialState.totalAssets - assetsWithFee <= finalState.totalAssets,
"FUND_MANAGER: totalAssets:LessThanExpected"
);
require(
initialState.totalSupply - shares <= finalState.totalSupply,
"FUND_MANAGER: totalSupply:LessThanExpected"
);
// `tokenBalanceBefore` will always be equal to `tokenBalanceAfter`. But the operator can decide to send in additional `assets` to the vault
require(
initialState.tokenBalance <= finalState.tokenBalance,
"FUND_MANAGER: AssetBalanceMismatch"
);
require(
initialState.aggregatedUnderlyingBalances
== finalState.aggregatedUnderlyingBalances + assetsWithFee,
"FUND_MANAGER: UnderlyingBalanceMismatch"
);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import { Errors } from "../libraries/Errors.sol";
import { IMultipliVault } from "../interfaces/IMultipliVault.sol";
import { IVariableVaultFee } from "../interfaces/IVariableVaultFee.sol";
import { IMultipliVaultCallee } from "../interfaces/IMultipliVaultCallee.sol";
import { VaultFeeUpgradeable } from "../base/VaultFeeUpgradeable.sol";
import { AuthUpgradeable, Authority } from "../base/AuthUpgradeable.sol";
import { FundMovementHelperUpgradeable } from "../base/FundMovementHelperUpgradeable.sol";
import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { ERC4626Upgradeable } from
"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC4626Upgradeable.sol";
import { PausableUpgradeable } from
"@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import { ReentrancyGuardUpgradeable } from
"@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import { UUPSUpgradeable } from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";
/**
* @title MultipliVault
* @author Multipli Team
* @notice A vault contract that enables an operator to manage vault assets asynchronously
* @dev Implements the ERC4626 standard with Auth contract for access control and ERC-7201 storage pattern
*
* The contract provides a redeem request mechanism that allows users to initiate a redeem request,
* and the operator to fulfill it at a later time. This mechanism is particularly useful for scenarios
* where the operator needs to move assets across chains or to different strategies before settling
* the user's redemption request. Upon fulfillment, assets are transferred to the vault, and the request
* is marked as complete.
*
* @custom:security-contact [email protected]
*/
contract MultipliVault is
UUPSUpgradeable,
ERC4626Upgradeable,
IMultipliVault,
AuthUpgradeable,
PausableUpgradeable,
VaultFeeUpgradeable,
FundMovementHelperUpgradeable,
ReentrancyGuardUpgradeable
{
using Math for uint256;
using Address for address;
using SafeERC20 for IERC20;
//============================== TYPES ===============================
/**
* @notice Enum defining different types of redemption requests
* @dev Used to handle different redemption flows with varying fee structures and processing methods
*/
enum RedeemType {
NORMAL, // Standard redemption with regular fees
INSTANT // Fast-forward redemption with higher fees
}
/**
* @notice Internal struct for request parameters
* @dev Used to pass redemption request data between functions
* @param shares The amount of shares to redeem
* @param receiver The address that will receive the assets
* @param owner The address that owns the shares
* @param redeemType The type of redemption (NORMAL or INSTANT)
*/
struct RedeemParams {
uint256 shares;
address receiver;
address owner;
RedeemType redeemType;
}
/**
* @notice Internal struct for fulfillment parameters
* @dev Used to pass fulfillment data between functions
* @param receiver The address that will receive the assets
* @param shares The amount of shares being fulfilled
* @param assetsWithFee The amount of assets including fees
* @param redeemType The type of redemption being fulfilled
*/
struct FulfillParams {
address receiver;
uint256 shares;
uint256 assetsWithFee;
RedeemType redeemType;
}
/**
* @custom:storage-location erc7201:multipli.storage.MultipliVaultStorage
* @dev Structure to hold MultipliVault storage data following ERC-7201 standard
*/
struct MultipliVaultStorage {
/// @dev The aggregated underlying balances across all strategies/chains, reported by an oracle
uint256 aggregatedUnderlyingBalances;
/// @dev The last block number when the aggregated underlying balances were updated
uint256 lastBlockUpdated;
/// @dev The last price per share calculated after the aggregated underlying balances are reported
uint256 lastPricePerShare;
/// @dev The total amount of assets that are pending redemption
uint256 totalPendingAssets;
/// @dev The maximum percentage change allowed before the vault is paused
uint256 maxPercentageChange;
/// @dev Minimum deposit amount required for deposits and mints
uint256 minDepositAmount;
/// @dev Mapping to store pending redemption requests for each user
mapping(address user => PendingRedeem redeem) pendingRedeem;
}
//============================== CONSTANTS ===============================
/// @dev Assume requests are non-fungible and all have ID = 0, so we can differentiate between a request ID and the assets amount
uint256 internal constant REQUEST_ID = 0;
/// @dev The denominator used for precision calculations (1e18 = 100%)
uint256 internal constant DENOMINATOR = 1e18;
/// @dev The maximum percentage that can be set as a threshold for the percentage change (1e17 = 10%)
uint256 internal constant MAX_PERCENTAGE_THRESHOLD = 1e17;
//============================== STORAGE ===============================
// Storage slot for the MultipliVaultStorage struct.
// keccak256(abi.encode(uint256(keccak256("multipli.storage.MultipliVaultStorage")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant MULTIPLI_VAULT_STORAGE_LOCATION =
0x5c514b81e93a4e64ed3b3d78d8355319d5f0f527b3964e825d59f3a9d74af900;
//============================== CONSTRUCTOR ===============================
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
//============================== INITIALIZER ===============================
/**
* @notice Initializes the MultipliVault contract
* @param _asset The underlying ERC20 asset for the vault
* @param _owner The initial owner of the vault
* @param _name The name of the vault token
* @param _symbol The symbol of the vault token
*/
function initialize(
IERC20 _asset,
address _owner,
string memory _name,
string memory _symbol
)
public
initializer
{
__MultipliVault_init(_asset, _owner, _name, _symbol);
}
/**
* @notice Initializes the MultipliVault contract
* @dev This function should be called during contract initialization
* @param _asset The underlying ERC20 asset for the vault
* @param _owner The initial owner of the vault
* @param _name The name of the vault token
* @param _symbol The symbol of the vault token
*/
function __MultipliVault_init(
IERC20 _asset,
address _owner,
string memory _name,
string memory _symbol
)
internal
onlyInitializing
{
__ERC20_init(_name, _symbol);
__ERC4626_init(_asset);
__Auth_init(_owner, Authority(address(0)));
__Pausable_init();
__VaultFeeUpgreadable_init(IVariableVaultFee(address(0)));
__FundMovementHelper_init();
__ReentrancyGuard_init();
__MultipliVault_init_unchained();
}
/**
* @notice Unchained initializer for MultipliVault
* @dev Contains the actual initialization logic for MultipliVault-specific storage
*/
/// @custom:oz-upgrades-unsafe-allow missing-initializer-call
// reference: https://forum.openzeppelin.com/t/potential-false-positive-missing-initializer-calls-for-one-or-more-parent-contracts/43911/3
function __MultipliVault_init_unchained() internal onlyInitializing {
MultipliVaultStorage storage $ = _getMultipliVaultStorage();
$.maxPercentageChange = 1e16; // 1%
$.minDepositAmount = 0;
}
//============================== PUBLIC FUNCTIONS ===============================
/**
* @notice Allows the vault operator to manage the vault by calling external contracts
* @param target The target contract to make a call to
* @param data The data to send to the target contract
* @param value The amount of native assets to send with the call
* @return result The return data from the external call
* @dev Requires authorization and target method must be authorized by the authority
*/
function manage(
address target,
bytes calldata data,
uint256 value
)
external
requiresAuth
returns (bytes memory result)
{
bytes4 functionSig = bytes4(data);
require(
authority().canCall(msg.sender, target, functionSig),
Errors.TargetMethodNotAuthorized(target, functionSig)
);
result = target.functionCallWithValue(data, value);
}
/**
* @notice Same as `manage` but allows for multiple calls in a single transaction
* @param targets The target contracts to make calls to
* @param data The data to send to the target contracts
* @param values The amounts of native assets to send with the calls
* @return results Array of return data from the external calls
* @dev Requires authorization and all target methods must be authorized by the authority
*/
function manage(
address[] calldata targets,
bytes[] calldata data,
uint256[] calldata values
)
external
requiresAuth
returns (bytes[] memory results)
{
uint256 targetsLength = targets.length;
require(
targetsLength == data.length && data.length == values.length,
"Array lengths must match"
);
results = new bytes[](targetsLength);
for (uint256 i; i < targetsLength; ++i) {
bytes4 functionSig = bytes4(data[i]);
require(
authority().canCall(msg.sender, targets[i], functionSig),
Errors.TargetMethodNotAuthorized(targets[i], functionSig)
);
results[i] = targets[i].functionCallWithValue(data[i], values[i]);
}
}
/**
* @notice Pause the contract to prevent any further deposits, withdrawals, or transfers
* @dev Can only be called by authorized users
*/
function pause() public requiresAuth {
_pause();
}
/**
* @notice Unpause the contract to allow deposits, withdrawals, and transfers
* @dev Can only be called by authorized users
*/
function unpause() public requiresAuth {
_unpause();
}
/**
* @notice Whitelist or remove a user from the fund transfer recipient list
* @param user The address to update whitelist status for
* @param status True to whitelist, false to remove from whitelist
* @dev Can only be called by authorized users
*/
function whitelistFundTransferRecipient(address user, bool status) public requiresAuth {
_whitelistFundTransferRecipient(user, status);
}
/**
* @notice Remove funds from the vault to a whitelisted recipient
* @param amount The amount of assets to transfer
* @param to The address to receive the funds (must be whitelisted)
* @dev Can only be called by authorized users
*/
function removeFunds(uint256 amount, address to) public requiresAuth {
_removeFunds(asset(), amount, to);
}
/**
* @notice Request a standard redemption of shares
* @param shares The amount of shares to redeem
* @param receiver The address that will receive the assets
* @param owner The address that owns the shares
* @return requestId The ID of the request (always 0)
* @dev Transfers shares to the vault and stores the request for later fulfillment
*/
function requestRedeem(
uint256 shares,
address receiver,
address owner
)
external
whenNotPaused
returns (uint256)
{
return _processRedeemRequest(RedeemParams(shares, receiver, owner, RedeemType.NORMAL));
}
/**
* @notice Request an instant redemption of shares (requires authorization)
* @param shares The amount of shares to redeem instantly
* @param receiver The address that will receive the assets
* @param owner The address that owns the shares
* @return requestId The ID of the request (always 0)
* @dev Only authorized users (external curators) can call this function
*/
function requestInstantRedeem(
uint256 shares,
address receiver,
address owner
)
external
whenNotPaused
requiresAuth
returns (uint256)
{
return _processRedeemRequest(RedeemParams(shares, receiver, owner, RedeemType.INSTANT));
}
/**
* @notice Fulfill a standard redemption request
* @param receiver The address that will receive the assets
* @param shares The amount of shares to fulfill
* @param assetsWithFee The amount of assets to transfer (including fees)
* @dev Can only be called by authorized operators
*/
function fulfillRedeem(
address receiver,
uint256 shares,
uint256 assetsWithFee
)
external
requiresAuth
{
_processFulfillment(FulfillParams(receiver, shares, assetsWithFee, RedeemType.NORMAL));
}
/**
* @notice Fulfill an instant redemption request
* @param receiver The address that will receive the assets
* @param shares The amount of shares to fulfill
* @param assetsWithFee The amount of assets to transfer (including fees)
* @dev Can only be called by authorized operators
*/
function fulfillInstantRedeem(
address receiver,
uint256 shares,
uint256 assetsWithFee
)
external
requiresAuth
{
_processFulfillment(FulfillParams(receiver, shares, assetsWithFee, RedeemType.INSTANT));
}
/**
* @notice Flash redemption for unwinding leveraged positions
* @dev Provides USDC upfront, expects equivalent xUSDC shares back after external operator call
* @param initiator The address that originally initiated the request
* @param operator The contract that will handle position unwinding on Euler
* @param receiver The address that will receive the USDC (usually the user)
* @param shares The amount of shares to redeem (total position size)
* @param data Additional data for the operator callback
*/
function flashRedeem(
address initiator,
address operator,
address receiver,
uint256 shares,
bytes calldata data
)
external
whenNotPaused
requiresAuth
nonReentrant
{
// Input validation
require(shares > 0, Errors.SharesAmountZero());
require(receiver != address(0), Errors.InvalidReceiverAddress());
require(operator != address(0), Errors.InvalidOperatorAddress());
address token = asset();
// Calculate assets and fees
uint256 assetsWithFee = convertToAssets(shares);
uint256 fee = _feeOnTotalFlashWithdrawal(token, assetsWithFee); // Use flash Redeem withdrawal fee
uint256 assetsWithoutFee = assetsWithFee - fee;
// Check vault has sufficient liquidity
uint256 vaultBalance = IERC20(token).balanceOf(address(this));
require(vaultBalance >= assetsWithFee, Errors.InvalidAssetsAmount());
uint256 shareBalanceBefore = balanceOf(address(this));
uint256 totalSupplyBefore = totalSupply();
// Transfer USDC to receiver pre-emptively
IERC20(token).safeTransfer(receiver, assetsWithoutFee);
// Invoke the operator to transfer the shares back to the vault
IMultipliVaultCallee(operator).onRedemptionFlashLoan(
initiator, address(this), token, shares, assetsWithoutFee, data
);
{
// Verify the operator returned the required shares
uint256 shareBalanceAfter = balanceOf(address(this));
require(shareBalanceAfter >= shareBalanceBefore + shares, Errors.SharesNotReturned());
}
// Burn the returned shares (completing the redemption)
_burn(address(this), shares);
{
// note: totalSupply check was added before re-entrancy
// guard was added to `flashRedeem` method, is this still required?
// Verify total supply decreased correctly
require(totalSupply() == totalSupplyBefore - shares, Errors.TotalSupplyMismatch());
// Verify the `asset` balance after redemption
uint256 tokenBalanceAfter = IERC20(token).balanceOf(address(this));
require(
vaultBalance - assetsWithFee <= tokenBalanceAfter, Errors.AssetBalanceMismatch()
);
}
// Transfer fee to fee recipient
address feeRecipient = _getFeeRecipient(token);
if (fee > 0 && feeRecipient != address(0)) {
IERC20(token).safeTransfer(feeRecipient, fee);
}
emit FlashRedeemFulfilled(initiator, operator, receiver, shares, assetsWithoutFee, fee);
}
/**
* @notice Cancel a redemption request in case of a black swan event.
* @param receiver The address that had the pending request.
* @param shares The amount of shares to cancel.
* @param assetsWithFee The amount of assets to cancel (including fees)
* @dev Returns shares back to the receiver and updates pending amounts
*/
function cancelRedeem(
address receiver,
uint256 shares,
uint256 assetsWithFee
)
external
requiresAuth
{
MultipliVaultStorage storage $ = _getMultipliVaultStorage();
PendingRedeem storage pending = $.pendingRedeem[receiver];
require(pending.shares != 0 && shares <= pending.shares, Errors.InvalidSharesAmount());
require(
pending.assets != 0 && assetsWithFee <= pending.assets, Errors.InvalidAssetsAmount()
);
pending.shares -= shares;
pending.assets -= assetsWithFee;
$.totalPendingAssets -= assetsWithFee;
emit RequestCancelled(receiver, shares, assetsWithFee);
// Transfer the shares back to the receiver
IERC20(address(this)).safeTransfer(receiver, shares);
}
/**
* @notice Update the aggregated underlying balances across all strategies/chains
* @param newAggregatedBalance The new aggregated underlying balances
* @dev Can be called only once per block to prevent oracle abuse and flash loan attacks
* @dev Automatically pauses the vault if price change exceeds the maximum threshold
*/
function onUnderlyingBalanceUpdate(uint256 newAggregatedBalance) external requiresAuth {
MultipliVaultStorage storage $ = _getMultipliVaultStorage();
// Fail fast - ensure this is the first update in this block
require(block.number > $.lastBlockUpdated, Errors.UpdateAlreadyCompletedInThisBlock());
emit UnderlyingBalanceUpdated($.aggregatedUnderlyingBalances, newAggregatedBalance);
$.aggregatedUnderlyingBalances = newAggregatedBalance;
// Calculate new price per share and check for excessive volatility
// todo: should this be replaced with `convertToAssets(1e6)`?
uint256 newPricePerShare = totalAssets().mulDiv(DENOMINATOR, totalSupply());
uint256 percentageChange = _calculatePercentageChange($.lastPricePerShare, newPricePerShare);
// Pause the vault if the percentage change exceeds the threshold (works in both directions)
if (percentageChange > $.maxPercentageChange) {
_pause();
}
$.lastPricePerShare = newPricePerShare;
$.lastBlockUpdated = block.number;
}
/**
* @notice Set the fee contract for the vault
* @param _feeContract The new fee contract address
* @dev Overrides the base implementation to add authorization requirement
*/
function setFeeContract(IVariableVaultFee _feeContract) public override requiresAuth {
super.setFeeContract(_feeContract);
}
/**
* @notice Get the fee recipient address for the vault's asset
* @return The address that receives fees
*/
function getFeeRecipient() public view returns (address) {
return _getFeeRecipient(asset());
}
/**
* @notice Update the maximum percentage change allowed before the vault is paused
* @param newMaxPercentageChange The new maximum percentage change (max value is 1e17 = 10%)
* @dev Used to protect against oracle manipulation and excessive volatility
*/
function updateMaxPercentageChange(uint256 newMaxPercentageChange) external requiresAuth {
require(newMaxPercentageChange < MAX_PERCENTAGE_THRESHOLD, Errors.InvalidMaxPercentage());
MultipliVaultStorage storage $ = _getMultipliVaultStorage();
emit MaxPercentageUpdated($.maxPercentageChange, newMaxPercentageChange);
$.maxPercentageChange = newMaxPercentageChange;
}
/**
* @notice Update the minimum deposit amount required for deposits and mints
* @param newMinDepositAmount The new minimum deposit amount
* @dev Used to prevent dust deposits and ensure economic viability
*/
function updateMinDepositAmount(uint256 newMinDepositAmount) external requiresAuth {
MultipliVaultStorage storage $ = _getMultipliVaultStorage();
emit MinDepositAmountUpdated($.minDepositAmount, newMinDepositAmount);
$.minDepositAmount = newMinDepositAmount;
}
//============================== VIEW FUNCTIONS ===============================
/**
* @notice Get the pending redemption request details for a user
* @param user The address to check
* @return assets The amount of assets pending redemption
* @return pendingShares The amount of shares pending redemption
*/
function pendingRedeemRequest(address user)
public
view
returns (uint256 assets, uint256 pendingShares)
{
MultipliVaultStorage storage $ = _getMultipliVaultStorage();
return ($.pendingRedeem[user].assets, $.pendingRedeem[user].shares);
}
/**
* @notice Get the aggregated underlying balances across all strategies
* @return The total underlying balances
*/
function aggregatedUnderlyingBalances() public view returns (uint256) {
return _getMultipliVaultStorage().aggregatedUnderlyingBalances;
}
/**
* @notice Get the last block number when underlying balances were updated
* @return The last update block number
*/
function lastBlockUpdated() public view returns (uint256) {
return _getMultipliVaultStorage().lastBlockUpdated;
}
/**
* @notice Get the last calculated price per share
* @return The last price per share
*/
function lastPricePerShare() public view returns (uint256) {
return _getMultipliVaultStorage().lastPricePerShare;
}
/**
* @notice Get the total amount of assets pending redemption
* @return The total pending assets
*/
function totalPendingAssets() public view returns (uint256) {
return _getMultipliVaultStorage().totalPendingAssets;
}
/**
* @notice Get the maximum percentage change allowed before pausing
* @return The maximum percentage change threshold
*/
function maxPercentageChange() public view returns (uint256) {
return _getMultipliVaultStorage().maxPercentageChange;
}
/**
* @notice Get the minimum deposit amount required
* @return The minimum deposit amount
*/
function minDepositAmount() public view returns (uint256) {
return _getMultipliVaultStorage().minDepositAmount;
}
//============================== OVERRIDES ===============================
/**
* @notice Override the default `totalAssets` function to include aggregated underlying balances
* @return The total assets held by the vault and across all strategies
*/
function totalAssets() public view override returns (uint256) {
MultipliVaultStorage storage $ = _getMultipliVaultStorage();
return IERC20(asset()).balanceOf(address(this)) + $.aggregatedUnderlyingBalances;
}
/**
* @notice Override the default `deposit` function with additional checks
* @param assets The amount of assets to deposit
* @param receiver The address that will receive the shares
* @return shares The amount of shares minted
* @dev Adds pause protection and minimum deposit amount validation
*/
function deposit(
uint256 assets,
address receiver
)
public
override
whenNotPaused
nonReentrant
returns (uint256)
{
uint256 maxAssets = maxDeposit(receiver);
if (assets > maxAssets) {
revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets);
}
MultipliVaultStorage storage $ = _getMultipliVaultStorage();
uint256 currentMinDepositAmount = $.minDepositAmount;
if (assets < currentMinDepositAmount) {
revert Errors.DepositAmountLessThanThreshold(assets, currentMinDepositAmount);
}
uint256 shares = previewDeposit(assets);
_deposit(_msgSender(), receiver, assets, shares);
return shares;
}
/**
* @notice Deposit assets with slippage protection (ERC-5143 compatible)
* @dev This function extends the standard ERC-4626 deposit function with slippage protection
* as specified in ERC-5143: Slippage Protection for Tokenized Vault and introduces additional checks.
* Reverts if the number of shares received is less than the minimum expected.
* @param assets The amount of assets to deposit
* @param receiver The address that will receive the vault shares
* @param minShares The minimum number of shares the caller is willing to accept
* @return shares The actual number of shares minted to the receiver
* @custom:security Protects against MEV attacks and exchange rate manipulation
*/
function deposit(
uint256 assets,
address receiver,
uint256 minShares
)
public
whenNotPaused
returns (uint256)
{
uint256 shares = deposit(assets, receiver);
if (shares < minShares) {
revert Errors.InsufficientSharesReceived(shares, minShares);
}
return shares;
}
/**
* @notice Override the default `mint` function with additional checks
* @param shares The amount of shares to mint
* @param receiver The address that will receive the shares
* @return assets The amount of assets required
* @dev Adds pause protection and minimum deposit amount validation
*/
function mint(
uint256 shares,
address receiver
)
public
override
whenNotPaused
nonReentrant
returns (uint256)
{
uint256 maxShares = maxMint(receiver);
if (shares > maxShares) {
revert ERC4626ExceededMaxMint(receiver, shares, maxShares);
}
uint256 assets = previewMint(shares);
MultipliVaultStorage storage $ = _getMultipliVaultStorage();
uint256 currentMinDepositAmount = $.minDepositAmount;
if (assets < currentMinDepositAmount) {
revert Errors.DepositAmountLessThanThreshold(assets, currentMinDepositAmount);
}
_deposit(_msgSender(), receiver, assets, shares);
return assets;
}
/**
* @notice Mint shares with slippage protection (ERC-5143 compatible)
* @dev This function extends the standard ERC-4626 mint function with slippage protection
* as specified in ERC-5143: Slippage Protection for Tokenized Vault.
* Reverts if the number of assets required exceeds the maximum the caller is willing to pay.
* @param shares The exact number of shares to mint
* @param receiver The address that will receive the vault shares
* @param maxAssets The maximum number of assets the caller is willing to pay
* @return assets The actual number of assets transferred from the caller
* @custom:security Protects against MEV attacks and exchange rate manipulation
*/
function mint(
uint256 shares,
address receiver,
uint256 maxAssets
)
public
whenNotPaused
returns (uint256)
{
uint256 assets = mint(shares, receiver);
if (assets > maxAssets) {
revert Errors.ExcessiveAssetsRequired(assets, maxAssets);
}
return assets;
}
/**
* @notice Disabled - use requestRedeem instead
* @dev This function is disabled to enforce the asynchronous redemption flow
*/
function withdraw(uint256, address, address) public override whenNotPaused returns (uint256) {
revert Errors.UseRequestRedeem();
}
/**
* @notice Disabled - use requestRedeem instead
* @dev This function is disabled to enforce the asynchronous redemption flow
*/
function redeem(uint256, address, address) public override whenNotPaused returns (uint256) {
revert Errors.UseRequestRedeem();
}
/**
* @notice Override the default `_update` function to add pause protection
* @dev The _update function is called on all transfers, mints and burns
*/
function _update(address from, address to, uint256 value) internal override whenNotPaused {
super._update(from, to, value);
}
/**
* @notice Preview the shares received for a deposit after fees
* @param assets The amount of assets to deposit
* @return The amount of shares that would be received
*/
function previewDeposit(uint256 assets) public view virtual override returns (uint256) {
uint256 fee = _feeOnTotalDeposit(asset(), assets);
return super.previewDeposit(assets - fee);
}
/**
* @notice Preview the assets required for minting shares including fees
* @param shares The amount of shares to mint
* @return The amount of assets required
*/
function previewMint(uint256 shares) public view virtual override returns (uint256) {
uint256 assets = super.previewMint(shares);
return assets + _feeOnRawDeposit(asset(), assets);
}
/**
* @notice Preview the shares required for withdrawing assets including fees
* @param assets The amount of assets to withdraw
* @return The amount of shares required
*/
function previewWithdraw(uint256 assets) public view virtual override returns (uint256) {
uint256 fee = _feeOnRawWithdrawal(asset(), assets);
return super.previewWithdraw(assets + fee);
}
/**
* @notice Preview the assets received for redeeming shares after fees
* @param shares The amount of shares to redeem
* @return The amount of assets that would be received
*/
function previewRedeem(uint256 shares) public view virtual override returns (uint256) {
uint256 assets = super.previewRedeem(shares);
return assets - _feeOnTotalWithdrawal(asset(), assets);
}
/**
* @notice Preview the assets received for instant redeeming shares after fees
* @param shares The amount of shares to redeem instantly
* @return The amount of assets that would be received
*/
function previewInstantRedeem(uint256 shares) public view virtual returns (uint256) {
uint256 assets = super.previewRedeem(shares);
return assets - _feeOnTotalInstantWithdrawal(asset(), assets);
}
/**
* @notice Preview the assets received for flash redeeming shares after fees
* @param shares The amount of shares to redeem instantly
* @return The amount of assets that would be received
*/
function previewFlashRedeem(uint256 shares) public view virtual returns (uint256) {
uint256 assets = convertToAssets(shares);
return assets - _feeOnTotalFlashWithdrawal(asset(), assets);
}
//============================== INTERNAL FUNCTIONS ===============================
/**
* @notice Internal deposit function with fee handling
* @param caller The address calling the deposit
* @param receiver The address receiving the shares
* @param assets The amount of assets being deposited
* @param shares The amount of shares being minted
* @dev Handles fee collection and transfer to fee recipient
*/
function _deposit(
address caller,
address receiver,
uint256 assets,
uint256 shares
)
internal
override
{
address token = asset();
uint256 feeAmount = _feeOnTotalDeposit(token, assets);
address recipient = _getFeeRecipient(token);
super._deposit(caller, receiver, assets, shares);
if (feeAmount > 0 && recipient != address(0)) {
IERC20(token).safeTransfer(recipient, feeAmount);
}
}
/**
* @notice Internal function to handle redeem request logic for all redeem types
* @param params The redemption parameters
* @return requestId The request ID (always 0)
* @dev Validates ownership, transfers shares to vault, and stores pending request
*/
function _processRedeemRequest(RedeemParams memory params) internal virtual returns (uint256) {
require(params.shares > 0, Errors.SharesAmountZero());
require(params.owner == msg.sender, Errors.NotSharesOwner());
require(balanceOf(params.owner) >= params.shares, Errors.InsufficientShares());
uint256 assetsWithFee = super.previewRedeem(params.shares);
// Emit appropriate event based on redemption type
_emitRedeemRequestEvent(
params.receiver, params.owner, assetsWithFee, params.shares, params.redeemType
);
// Store the redemption request
MultipliVaultStorage storage $ = _getMultipliVaultStorage();
_transfer(params.owner, address(this), params.shares);
$.totalPendingAssets += assetsWithFee;
$.pendingRedeem[params.receiver] = PendingRedeem({
shares: $.pendingRedeem[params.receiver].shares + params.shares,
assets: $.pendingRedeem[params.receiver].assets + assetsWithFee
});
return REQUEST_ID;
}
/**
* @notice Internal function to emit appropriate events based on redeem type
* @param receiver The address that will receive the assets
* @param owner The address that owns the shares
* @param assetsWithFee The amount of assets including fees
* @param shares The amount of shares being redeemed
* @param redeemType The type of redemption
*/
function _emitRedeemRequestEvent(
address receiver,
address owner,
uint256 assetsWithFee,
uint256 shares,
RedeemType redeemType
)
internal
{
if (redeemType == RedeemType.NORMAL) {
emit RedeemRequest(receiver, owner, assetsWithFee, shares);
} else if (redeemType == RedeemType.INSTANT) {
emit InstantRedeemRequest(receiver, owner, assetsWithFee, shares);
} else {
revert Errors.UnsupportedRedeemType(uint8(redeemType));
}
}
/**
* @notice Internal function to emit fulfillment events
* @param receiver The address receiving the assets
* @param shares The amount of shares being fulfilled
* @param assetsWithFee The amount of assets including fees
* @param redeemType The type of redemption being fulfilled
*/
function _emitFulfillmentEvent(
address receiver,
uint256 shares,
uint256 assetsWithFee,
RedeemType redeemType
)
internal
{
if (redeemType == RedeemType.NORMAL) {
emit RequestFulfilled(receiver, shares, assetsWithFee);
} else if (redeemType == RedeemType.INSTANT) {
emit InstantRequestFulfilled(receiver, shares, assetsWithFee);
} else {
revert Errors.UnsupportedRedeemType(uint8(redeemType));
}
}
/**
* @notice Internal function to handle fulfillment logic for all redeem types
* @param params The fulfillment parameters
* @dev Validates pending request, updates state, and executes withdrawal
*/
function _processFulfillment(FulfillParams memory params) internal {
MultipliVaultStorage storage $ = _getMultipliVaultStorage();
PendingRedeem storage pending = $.pendingRedeem[params.receiver];
require(
pending.shares != 0 && params.shares <= pending.shares, Errors.InvalidSharesAmount()
);
require(
pending.assets != 0 && params.assetsWithFee <= pending.assets,
Errors.InvalidAssetsAmount()
);
pending.shares -= params.shares;
pending.assets -= params.assetsWithFee;
$.totalPendingAssets -= params.assetsWithFee;
// Emit appropriate event based on redemption type
_emitFulfillmentEvent(
params.receiver, params.shares, params.assetsWithFee, params.redeemType
);
// Execute the withdrawal with appropriate fee handling
_executeWithdrawal(params.receiver, params.assetsWithFee, params.shares, params.redeemType);
}
/**
* @notice Internal function to execute withdrawal with fee handling
* @param receiver The address receiving the assets
* @param assetsWithFee The total amount of assets including fees
* @param shares The amount of shares being burned
* @param redeemType The type of redemption (affects fee calculation)
* @dev Calculates fees based on redemption type and transfers assets to receiver
*/
function _executeWithdrawal(
address receiver,
uint256 assetsWithFee,
uint256 shares,
RedeemType redeemType
)
internal
{
address token = asset();
uint256 feeAmount;
// Calculate fee based on redemption type
if (redeemType == RedeemType.NORMAL) {
feeAmount = _feeOnTotalWithdrawal(token, assetsWithFee);
} else if (redeemType == RedeemType.INSTANT) {
feeAmount = _feeOnTotalInstantWithdrawal(token, assetsWithFee);
} else {
revert Errors.UnsupportedRedeemType(uint8(redeemType));
}
uint256 assets = assetsWithFee - feeAmount;
address recipient = _getFeeRecipient(token);
// Execute the withdrawal
super._withdraw(address(this), receiver, address(this), assets, shares);
// Transfer fees to fee recipient if applicable
if (feeAmount > 0 && recipient != address(0)) {
IERC20(token).safeTransfer(recipient, feeAmount);
}
}
//============================== PRIVATE FUNCTIONS ===============================
/**
* @notice Calculate the percentage change between two prices
* @param oldPrice The previous price
* @param newPrice The new price
* @return The percentage change (1e18 = 100%)
* @dev Used to detect excessive price volatility and trigger emergency pause
*/
function _calculatePercentageChange(
uint256 oldPrice,
uint256 newPrice
)
private
pure
returns (uint256)
{
if (oldPrice == 0) {
return 0;
}
uint256 diff = newPrice > oldPrice ? newPrice - oldPrice : oldPrice - newPrice;
return diff.mulDiv(DENOMINATOR, oldPrice, Math.Rounding.Ceil);
}
/**
* @notice Returns a reference to the MultipliVaultStorage struct
* @return $ Reference to the MultipliVaultStorage struct
* @dev Uses ERC-7201 storage pattern to prevent storage collisions
*/
function _getMultipliVaultStorage() private pure returns (MultipliVaultStorage storage $) {
assembly {
$.slot := MULTIPLI_VAULT_STORAGE_LOCATION
}
}
/**
* @notice Authorize contract upgrades (UUPS pattern)
* @dev Only owner or authorized roles can upgrade the implementation
* @param newImplementation The new implementation contract address
* @custom:security Prevents unauthorized upgrades that could compromise the protocol
*/
function _authorizeUpgrade(address newImplementation) internal virtual override requiresAuth { }
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Return the 512-bit addition of two uint256.
*
* The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
*/
function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
assembly ("memory-safe") {
low := add(a, b)
high := lt(low, a)
}
}
/**
* @dev Return the 512-bit multiplication of two uint256.
*
* The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
*/
function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
// 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
// the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = high * 2²⁵⁶ + low.
assembly ("memory-safe") {
let mm := mulmod(a, b, not(0))
low := mul(a, b)
high := sub(sub(mm, low), lt(mm, low))
}
}
/**
* @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a + b;
success = c >= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a - b;
success = c <= a;
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
uint256 c = a * b;
assembly ("memory-safe") {
// Only true when the multiplication doesn't overflow
// (c / a == b) || (a == 0)
success := or(eq(div(c, a), b), iszero(a))
}
// equivalent to: success ? c : 0
result = c * SafeCast.toUint(success);
}
}
/**
* @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `DIV` opcode returns zero when the denominator is 0.
result := div(a, b)
}
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
unchecked {
success = b > 0;
assembly ("memory-safe") {
// The `MOD` opcode returns zero when the denominator is 0.
result := mod(a, b)
}
}
}
/**
* @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryAdd(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
*/
function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
(, uint256 result) = trySub(a, b);
return result;
}
/**
* @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
*/
function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
(bool success, uint256 result) = tryMul(a, b);
return ternary(success, result, type(uint256).max);
}
/**
* @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
*
* IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
* However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
* one branch when needed, making this function more expensive.
*/
function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
unchecked {
// branchless ternary works because:
// b ^ (a ^ b) == a
// b ^ 0 == b
return b ^ ((a ^ b) * SafeCast.toUint(condition));
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a > b, a, b);
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return ternary(a < b, a, b);
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
Panic.panic(Panic.DIVISION_BY_ZERO);
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
}
}
/**
* @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
*
* Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
// Handle non-overflow cases, 256 by 256 division.
if (high == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return low / denominator;
}
// Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
if (denominator <= high) {
Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [high low].
uint256 remainder;
assembly ("memory-safe") {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
high := sub(high, gt(remainder, low))
low := sub(low, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly ("memory-safe") {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [high low] by twos.
low := div(low, twos)
// Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from high into low.
low |= high * twos;
// Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such
// that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv ≡ 1 mod 2⁴.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2⁸
inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
inverse *= 2 - denominator * inverse; // inverse mod 2³²
inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is
// less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and high
// is no longer required.
result = low * inverse;
return result;
}
}
/**
* @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
}
/**
* @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
*/
function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
unchecked {
(uint256 high, uint256 low) = mul512(x, y);
if (high >= 1 << n) {
Panic.panic(Panic.UNDER_OVERFLOW);
}
return (high << (256 - n)) | (low >> n);
}
}
/**
* @dev Calculates x * y >> n with full precision, following the selected rounding direction.
*/
function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);
}
/**
* @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
*
* If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
* If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
*
* If the input value is not inversible, 0 is returned.
*
* NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
* inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
*/
function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
unchecked {
if (n == 0) return 0;
// The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
// Used to compute integers x and y such that: ax + ny = gcd(a, n).
// When the gcd is 1, then the inverse of a modulo n exists and it's x.
// ax + ny = 1
// ax = 1 + (-y)n
// ax ≡ 1 (mod n) # x is the inverse of a modulo n
// If the remainder is 0 the gcd is n right away.
uint256 remainder = a % n;
uint256 gcd = n;
// Therefore the initial coefficients are:
// ax + ny = gcd(a, n) = n
// 0a + 1n = n
int256 x = 0;
int256 y = 1;
while (remainder != 0) {
uint256 quotient = gcd / remainder;
(gcd, remainder) = (
// The old remainder is the next gcd to try.
remainder,
// Compute the next remainder.
// Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
// where gcd is at most n (capped to type(uint256).max)
gcd - remainder * quotient
);
(x, y) = (
// Increment the coefficient of a.
y,
// Decrement the coefficient of n.
// Can overflow, but the result is casted to uint256 so that the
// next value of y is "wrapped around" to a value between 0 and n - 1.
x - y * int256(quotient)
);
}
if (gcd != 1) return 0; // No inverse exists.
return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
}
}
/**
* @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
*
* From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
* prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
* `a**(p-2)` is the modular multiplicative inverse of a in Fp.
*
* NOTE: this function does NOT check that `p` is a prime greater than `2`.
*/
function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
unchecked {
return Math.modExp(a, p - 2, p);
}
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
*
* Requirements:
* - modulus can't be zero
* - underlying staticcall to precompile must succeed
*
* IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
* sure the chain you're using it on supports the precompiled contract for modular exponentiation
* at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
* the underlying function will succeed given the lack of a revert, but the result may be incorrectly
* interpreted as 0.
*/
function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
(bool success, uint256 result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
* It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
* to operate modulo 0 or if the underlying precompile reverted.
*
* IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
* you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
* https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
* of a revert, but the result may be incorrectly interpreted as 0.
*/
function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
if (m == 0) return (false, 0);
assembly ("memory-safe") {
let ptr := mload(0x40)
// | Offset | Content | Content (Hex) |
// |-----------|------------|--------------------------------------------------------------------|
// | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 |
// | 0x60:0x7f | value of b | 0x<.............................................................b> |
// | 0x80:0x9f | value of e | 0x<.............................................................e> |
// | 0xa0:0xbf | value of m | 0x<.............................................................m> |
mstore(ptr, 0x20)
mstore(add(ptr, 0x20), 0x20)
mstore(add(ptr, 0x40), 0x20)
mstore(add(ptr, 0x60), b)
mstore(add(ptr, 0x80), e)
mstore(add(ptr, 0xa0), m)
// Given the result < m, it's guaranteed to fit in 32 bytes,
// so we can use the memory scratch space located at offset 0.
success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
result := mload(0x00)
}
}
/**
* @dev Variant of {modExp} that supports inputs of arbitrary length.
*/
function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
(bool success, bytes memory result) = tryModExp(b, e, m);
if (!success) {
Panic.panic(Panic.DIVISION_BY_ZERO);
}
return result;
}
/**
* @dev Variant of {tryModExp} that supports inputs of arbitrary length.
*/
function tryModExp(
bytes memory b,
bytes memory e,
bytes memory m
) internal view returns (bool success, bytes memory result) {
if (_zeroBytes(m)) return (false, new bytes(0));
uint256 mLen = m.length;
// Encode call args in result and move the free memory pointer
result = abi.encodePacked(b.length, e.length, mLen, b, e, m);
assembly ("memory-safe") {
let dataPtr := add(result, 0x20)
// Write result on top of args to avoid allocating extra memory.
success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
// Overwrite the length.
// result.length > returndatasize() is guaranteed because returndatasize() == m.length
mstore(result, mLen)
// Set the memory pointer after the returned data.
mstore(0x40, add(dataPtr, mLen))
}
}
/**
* @dev Returns whether the provided byte array is zero.
*/
function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
for (uint256 i = 0; i < byteArray.length; ++i) {
if (byteArray[i] != 0) {
return false;
}
}
return true;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* This method is based on Newton's method for computing square roots; the algorithm is restricted to only
* using integer operations.
*/
function sqrt(uint256 a) internal pure returns (uint256) {
unchecked {
// Take care of easy edge cases when a == 0 or a == 1
if (a <= 1) {
return a;
}
// In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
// sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
// the current value as `ε_n = | x_n - sqrt(a) |`.
//
// For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
// of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
// bigger than any uint256.
//
// By noticing that
// `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
// we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
// to the msb function.
uint256 aa = a;
uint256 xn = 1;
if (aa >= (1 << 128)) {
aa >>= 128;
xn <<= 64;
}
if (aa >= (1 << 64)) {
aa >>= 64;
xn <<= 32;
}
if (aa >= (1 << 32)) {
aa >>= 32;
xn <<= 16;
}
if (aa >= (1 << 16)) {
aa >>= 16;
xn <<= 8;
}
if (aa >= (1 << 8)) {
aa >>= 8;
xn <<= 4;
}
if (aa >= (1 << 4)) {
aa >>= 4;
xn <<= 2;
}
if (aa >= (1 << 2)) {
xn <<= 1;
}
// We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
//
// We can refine our estimation by noticing that the middle of that interval minimizes the error.
// If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
// This is going to be our x_0 (and ε_0)
xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)
// From here, Newton's method give us:
// x_{n+1} = (x_n + a / x_n) / 2
//
// One should note that:
// x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
// = ((x_n² + a) / (2 * x_n))² - a
// = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
// = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
// = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
// = (x_n² - a)² / (2 * x_n)²
// = ((x_n² - a) / (2 * x_n))²
// ≥ 0
// Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
//
// This gives us the proof of quadratic convergence of the sequence:
// ε_{n+1} = | x_{n+1} - sqrt(a) |
// = | (x_n + a / x_n) / 2 - sqrt(a) |
// = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
// = | (x_n - sqrt(a))² / (2 * x_n) |
// = | ε_n² / (2 * x_n) |
// = ε_n² / | (2 * x_n) |
//
// For the first iteration, we have a special case where x_0 is known:
// ε_1 = ε_0² / | (2 * x_0) |
// ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
// ≤ 2**(2*e-4) / (3 * 2**(e-1))
// ≤ 2**(e-3) / 3
// ≤ 2**(e-3-log2(3))
// ≤ 2**(e-4.5)
//
// For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
// ε_{n+1} = ε_n² / | (2 * x_n) |
// ≤ (2**(e-k))² / (2 * 2**(e-1))
// ≤ 2**(2*e-2*k) / 2**e
// ≤ 2**(e-2*k)
xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above
xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5
xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9
xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18
xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36
xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72
// Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
// ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
// sqrt(a) or sqrt(a) + 1.
return xn - SafeCast.toUint(xn > a / xn);
}
}
/**
* @dev Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// If upper 8 bits of 16-bit half set, add 8 to result
r |= SafeCast.toUint((x >> r) > 0xff) << 3;
// If upper 4 bits of 8-bit half set, add 4 to result
r |= SafeCast.toUint((x >> r) > 0xf) << 2;
// Shifts value right by the current result and use it as an index into this lookup table:
//
// | x (4 bits) | index | table[index] = MSB position |
// |------------|---------|-----------------------------|
// | 0000 | 0 | table[0] = 0 |
// | 0001 | 1 | table[1] = 0 |
// | 0010 | 2 | table[2] = 1 |
// | 0011 | 3 | table[3] = 1 |
// | 0100 | 4 | table[4] = 2 |
// | 0101 | 5 | table[5] = 2 |
// | 0110 | 6 | table[6] = 2 |
// | 0111 | 7 | table[7] = 2 |
// | 1000 | 8 | table[8] = 3 |
// | 1001 | 9 | table[9] = 3 |
// | 1010 | 10 | table[10] = 3 |
// | 1011 | 11 | table[11] = 3 |
// | 1100 | 12 | table[12] = 3 |
// | 1101 | 13 | table[13] = 3 |
// | 1110 | 14 | table[14] = 3 |
// | 1111 | 15 | table[15] = 3 |
//
// The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
assembly ("memory-safe") {
r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
}
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 x) internal pure returns (uint256 r) {
// If value has upper 128 bits set, log2 result is at least 128
r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
// If upper 64 bits of 128-bit half set, add 64 to result
r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
// If upper 32 bits of 64-bit half set, add 32 to result
r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
// If upper 16 bits of 32-bit half set, add 16 to result
r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
// Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
library console {
address constant CONSOLE_ADDRESS =
0x000000000000000000636F6e736F6c652e6c6f67;
function _sendLogPayloadImplementation(bytes memory payload) internal view {
address consoleAddress = CONSOLE_ADDRESS;
/// @solidity memory-safe-assembly
assembly {
pop(
staticcall(
gas(),
consoleAddress,
add(payload, 32),
mload(payload),
0,
0
)
)
}
}
function _castToPure(
function(bytes memory) internal view fnIn
) internal pure returns (function(bytes memory) pure fnOut) {
assembly {
fnOut := fnIn
}
}
function _sendLogPayload(bytes memory payload) internal pure {
_castToPure(_sendLogPayloadImplementation)(payload);
}
function log() internal pure {
_sendLogPayload(abi.encodeWithSignature("log()"));
}
function logInt(int256 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(int256)", p0));
}
function logUint(uint256 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256)", p0));
}
function logString(string memory p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string)", p0));
}
function logBool(bool p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool)", p0));
}
function logAddress(address p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address)", p0));
}
function logBytes(bytes memory p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes)", p0));
}
function logBytes1(bytes1 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0));
}
function logBytes2(bytes2 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0));
}
function logBytes3(bytes3 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0));
}
function logBytes4(bytes4 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0));
}
function logBytes5(bytes5 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0));
}
function logBytes6(bytes6 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0));
}
function logBytes7(bytes7 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0));
}
function logBytes8(bytes8 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0));
}
function logBytes9(bytes9 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0));
}
function logBytes10(bytes10 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0));
}
function logBytes11(bytes11 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0));
}
function logBytes12(bytes12 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0));
}
function logBytes13(bytes13 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0));
}
function logBytes14(bytes14 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0));
}
function logBytes15(bytes15 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0));
}
function logBytes16(bytes16 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0));
}
function logBytes17(bytes17 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0));
}
function logBytes18(bytes18 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0));
}
function logBytes19(bytes19 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0));
}
function logBytes20(bytes20 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0));
}
function logBytes21(bytes21 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0));
}
function logBytes22(bytes22 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0));
}
function logBytes23(bytes23 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0));
}
function logBytes24(bytes24 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0));
}
function logBytes25(bytes25 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0));
}
function logBytes26(bytes26 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0));
}
function logBytes27(bytes27 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0));
}
function logBytes28(bytes28 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0));
}
function logBytes29(bytes29 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0));
}
function logBytes30(bytes30 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0));
}
function logBytes31(bytes31 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0));
}
function logBytes32(bytes32 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0));
}
function log(uint256 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256)", p0));
}
function log(int256 p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(int256)", p0));
}
function log(string memory p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string)", p0));
}
function log(bool p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool)", p0));
}
function log(address p0) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address)", p0));
}
function log(uint256 p0, uint256 p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256)", p0, p1));
}
function log(uint256 p0, string memory p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string)", p0, p1));
}
function log(uint256 p0, bool p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool)", p0, p1));
}
function log(uint256 p0, address p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address)", p0, p1));
}
function log(string memory p0, uint256 p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256)", p0, p1));
}
function log(string memory p0, int256 p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,int256)", p0, p1));
}
function log(string memory p0, string memory p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1));
}
function log(string memory p0, bool p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1));
}
function log(string memory p0, address p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1));
}
function log(bool p0, uint256 p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256)", p0, p1));
}
function log(bool p0, string memory p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1));
}
function log(bool p0, bool p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1));
}
function log(bool p0, address p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1));
}
function log(address p0, uint256 p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256)", p0, p1));
}
function log(address p0, string memory p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1));
}
function log(address p0, bool p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1));
}
function log(address p0, address p1) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1));
}
function log(uint256 p0, uint256 p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256)", p0, p1, p2));
}
function log(uint256 p0, uint256 p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string)", p0, p1, p2));
}
function log(uint256 p0, uint256 p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool)", p0, p1, p2));
}
function log(uint256 p0, uint256 p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address)", p0, p1, p2));
}
function log(uint256 p0, string memory p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256)", p0, p1, p2));
}
function log(uint256 p0, string memory p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,string)", p0, p1, p2));
}
function log(uint256 p0, string memory p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool)", p0, p1, p2));
}
function log(uint256 p0, string memory p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,address)", p0, p1, p2));
}
function log(uint256 p0, bool p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256)", p0, p1, p2));
}
function log(uint256 p0, bool p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string)", p0, p1, p2));
}
function log(uint256 p0, bool p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool)", p0, p1, p2));
}
function log(uint256 p0, bool p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address)", p0, p1, p2));
}
function log(uint256 p0, address p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256)", p0, p1, p2));
}
function log(uint256 p0, address p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,string)", p0, p1, p2));
}
function log(uint256 p0, address p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool)", p0, p1, p2));
}
function log(uint256 p0, address p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,address)", p0, p1, p2));
}
function log(string memory p0, uint256 p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256)", p0, p1, p2));
}
function log(string memory p0, uint256 p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,string)", p0, p1, p2));
}
function log(string memory p0, uint256 p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool)", p0, p1, p2));
}
function log(string memory p0, uint256 p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,address)", p0, p1, p2));
}
function log(string memory p0, string memory p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint256)", p0, p1, p2));
}
function log(string memory p0, string memory p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2));
}
function log(string memory p0, string memory p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2));
}
function log(string memory p0, string memory p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2));
}
function log(string memory p0, bool p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256)", p0, p1, p2));
}
function log(string memory p0, bool p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2));
}
function log(string memory p0, bool p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2));
}
function log(string memory p0, bool p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2));
}
function log(string memory p0, address p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint256)", p0, p1, p2));
}
function log(string memory p0, address p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2));
}
function log(string memory p0, address p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2));
}
function log(string memory p0, address p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2));
}
function log(bool p0, uint256 p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256)", p0, p1, p2));
}
function log(bool p0, uint256 p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string)", p0, p1, p2));
}
function log(bool p0, uint256 p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool)", p0, p1, p2));
}
function log(bool p0, uint256 p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address)", p0, p1, p2));
}
function log(bool p0, string memory p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256)", p0, p1, p2));
}
function log(bool p0, string memory p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2));
}
function log(bool p0, string memory p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2));
}
function log(bool p0, string memory p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2));
}
function log(bool p0, bool p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256)", p0, p1, p2));
}
function log(bool p0, bool p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2));
}
function log(bool p0, bool p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2));
}
function log(bool p0, bool p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2));
}
function log(bool p0, address p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256)", p0, p1, p2));
}
function log(bool p0, address p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2));
}
function log(bool p0, address p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2));
}
function log(bool p0, address p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2));
}
function log(address p0, uint256 p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256)", p0, p1, p2));
}
function log(address p0, uint256 p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,string)", p0, p1, p2));
}
function log(address p0, uint256 p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool)", p0, p1, p2));
}
function log(address p0, uint256 p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,address)", p0, p1, p2));
}
function log(address p0, string memory p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint256)", p0, p1, p2));
}
function log(address p0, string memory p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2));
}
function log(address p0, string memory p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2));
}
function log(address p0, string memory p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2));
}
function log(address p0, bool p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256)", p0, p1, p2));
}
function log(address p0, bool p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2));
}
function log(address p0, bool p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2));
}
function log(address p0, bool p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2));
}
function log(address p0, address p1, uint256 p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint256)", p0, p1, p2));
}
function log(address p0, address p1, string memory p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2));
}
function log(address p0, address p1, bool p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2));
}
function log(address p0, address p1, address p2) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2));
}
function log(uint256 p0, uint256 p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,string)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,uint256,address)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,string)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,string,address)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,string)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,bool,address)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,string)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, uint256 p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,uint256,address,address)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,string)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,uint256,address)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,string)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,string,address)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,string)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,bool,address)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,string)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, string memory p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,string,address,address)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,string)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,uint256,address)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,string)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,string,address)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,string)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,bool,address)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,string)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, bool p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,bool,address,address)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,string)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,uint256,address)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,string)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,string,address)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,string)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,bool,address)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,uint256)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,string)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,bool)", p0, p1, p2, p3));
}
function log(uint256 p0, address p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(uint256,address,address,address)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,string)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,bool)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,uint256,address)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,string)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,bool)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,string,address)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,string)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,bool)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,bool,address)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,string)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,bool)", p0, p1, p2, p3));
}
function log(string memory p0, uint256 p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,uint256,address,address)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,string)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,bool)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint256,address)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,string)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,bool)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint256,address)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,string)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,bool)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint256,address)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint256)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,uint256)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,string)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,bool)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,uint256,address)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,uint256)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,string)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,bool)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,string,address)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,uint256)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,string)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,bool)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,bool,address)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,uint256)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,string)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,bool)", p0, p1, p2, p3));
}
function log(bool p0, uint256 p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint256,address,address)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,uint256)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,string)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,bool)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint256,address)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint256)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint256)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint256)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,uint256)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,string)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,bool)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint256,address)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint256)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint256)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint256)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3));
}
function log(bool p0, address p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,uint256)", p0, p1, p2, p3));
}
function log(bool p0, address p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,string)", p0, p1, p2, p3));
}
function log(bool p0, address p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,bool)", p0, p1, p2, p3));
}
function log(bool p0, address p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint256,address)", p0, p1, p2, p3));
}
function log(bool p0, address p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint256)", p0, p1, p2, p3));
}
function log(bool p0, address p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3));
}
function log(bool p0, address p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3));
}
function log(bool p0, address p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3));
}
function log(bool p0, address p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint256)", p0, p1, p2, p3));
}
function log(bool p0, address p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3));
}
function log(bool p0, address p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3));
}
function log(bool p0, address p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3));
}
function log(bool p0, address p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint256)", p0, p1, p2, p3));
}
function log(bool p0, address p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3));
}
function log(bool p0, address p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3));
}
function log(bool p0, address p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,uint256)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,string)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,bool)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,uint256,address)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,uint256)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,string)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,bool)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,string,address)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,uint256)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,string)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,bool)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,bool,address)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,uint256)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,string)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,bool)", p0, p1, p2, p3));
}
function log(address p0, uint256 p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,uint256,address,address)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,uint256)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,string)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,bool)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint256,address)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint256)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint256)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint256)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3));
}
function log(address p0, bool p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,uint256)", p0, p1, p2, p3));
}
function log(address p0, bool p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,string)", p0, p1, p2, p3));
}
function log(address p0, bool p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,bool)", p0, p1, p2, p3));
}
function log(address p0, bool p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint256,address)", p0, p1, p2, p3));
}
function log(address p0, bool p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint256)", p0, p1, p2, p3));
}
function log(address p0, bool p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3));
}
function log(address p0, bool p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3));
}
function log(address p0, bool p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3));
}
function log(address p0, bool p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint256)", p0, p1, p2, p3));
}
function log(address p0, bool p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3));
}
function log(address p0, bool p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3));
}
function log(address p0, bool p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3));
}
function log(address p0, bool p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint256)", p0, p1, p2, p3));
}
function log(address p0, bool p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3));
}
function log(address p0, bool p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3));
}
function log(address p0, bool p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3));
}
function log(address p0, address p1, uint256 p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,uint256)", p0, p1, p2, p3));
}
function log(address p0, address p1, uint256 p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,string)", p0, p1, p2, p3));
}
function log(address p0, address p1, uint256 p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,bool)", p0, p1, p2, p3));
}
function log(address p0, address p1, uint256 p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint256,address)", p0, p1, p2, p3));
}
function log(address p0, address p1, string memory p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint256)", p0, p1, p2, p3));
}
function log(address p0, address p1, string memory p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3));
}
function log(address p0, address p1, string memory p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3));
}
function log(address p0, address p1, string memory p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3));
}
function log(address p0, address p1, bool p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint256)", p0, p1, p2, p3));
}
function log(address p0, address p1, bool p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3));
}
function log(address p0, address p1, bool p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3));
}
function log(address p0, address p1, bool p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3));
}
function log(address p0, address p1, address p2, uint256 p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint256)", p0, p1, p2, p3));
}
function log(address p0, address p1, address p2, string memory p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3));
}
function log(address p0, address p1, address p2, bool p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3));
}
function log(address p0, address p1, address p2, address p3) internal pure {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3));
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
/**
* @title Errors
* @notice Defines custom error types for various contract operations.
* @dev This library provides reusable error messages for share operations, authorization checks, and vault interactions.
*/
library Errors {
//============================== GENERICS ===============================
/**
* @notice Thrown when an unauthorized method to a target is called.
* @dev The method must be authorized by setUserRole and setRoleCapability from RolesAuthority.
* @param target The target address.
* @param functionSig The function signature being called.
*/
error TargetMethodNotAuthorized(address target, bytes4 functionSig);
/**
* @notice Thrown when insufficient shares balance is available to complete the operation.
*/
error InsufficientShares();
/**
* @notice Thrown when the operation is called by a user that is not the owner of the shares.
*/
error NotSharesOwner();
/**
* @notice Thrown when the input shares amount is zero.
*/
error SharesAmountZero();
/**
* @notice Thrown when a claim request is fulfilled with an invalid shares amount.
*/
error InvalidSharesAmount();
/**
* @notice Thrown receiver is invalid.
*/
error InvalidReceiverAddress();
/**
* @notice Thrown receiver is invalid.
*/
error InvalidOperatorAddress();
/**
* @notice Thrown owner is invalid.
*/
error InvalidOwnerAddress();
/**
* @notice Thrown shares are not returned during flashRedeem
*/
error SharesNotReturned();
/**
* @notice Thrown when the actual shares received is less than the minimum expected
* @param actualShares The number of shares actually received
* @param minShares The minimum number of shares expected
*/
error InsufficientSharesReceived(uint256 actualShares, uint256 minShares);
/**
* @notice Thrown when the assets required exceeds the maximum the caller is willing to pay
* @param actualAssets The number of assets actually required
* @param maxAssets The maximum number of assets the caller is willing to pay
*/
error ExcessiveAssetsRequired(uint256 actualAssets, uint256 maxAssets);
/**
* @notice Thrown there is a mismatch in Total Supply
*/
error TotalSupplyMismatch();
/**
* @notice Thrown there is a asset balance mismatch in Vault
*/
error AssetBalanceMismatch();
/**
* @notice Thrown when a withdraw is attempted with an amount different than the claimable assets.
*/
error InvalidAssetsAmount();
/**
* @notice Thrown when the new max percentage is greater than the current max percentage.
*/
error InvalidMaxPercentage();
/**
* @notice Thrown when the new fee is greater than the max allowed fee.
*/
error InvalidFee();
/**
* @notice Thrown when the underlying balance has already been updated in the current block.
*/
error UpdateAlreadyCompletedInThisBlock();
/**
* @notice Thrown when redeem() or withdraw() is called.
*/
error UseRequestRedeem();
/**
* @notice Thrown when deposit / mint is with assets < minimum deposit amount
*/
error DepositAmountLessThanThreshold(uint256 amount, uint256 minDepositAmount);
/**
* @notice Thrown when deposit / mint is with assets < minimum deposit amount
*/
error UnsupportedRedeemType(uint8 redeemType);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
/**
* @title MultipliVault
* @notice Interface for the Multipli vault
* @dev Defines events and functions related to redeem requests, fee updates, and balance tracking.
*/
interface IMultipliVault {
/**
* @dev Structure to store pending redeem requests.
* @param assets The amount of assets to be redeemed.
* @param shares The amount of shares to be redeemed.
*/
struct PendingRedeem {
uint256 assets;
uint256 shares;
}
/**
* @notice Emitted when the withdraw fee is updated.
* @param lastFee The previous fee value.
* @param newFee The new fee value.
*/
event WithdrawFeeUpdated(uint256 lastFee, uint256 newFee);
/**
* @notice Emitted when the deposit fee is updated.
* @param lastFee The previous fee value.
* @param newFee The new fee value.
*/
event DepositFeeUpdated(uint256 lastFee, uint256 newFee);
/**
* @notice Emitted when the fee recipient is updated.
* @param lastFeeRecipient The previous fee recipient address.
* @param newFeeRecipient The new fee recipient address.
*/
event FeeRecipientUpdated(address lastFeeRecipient, address newFeeRecipient);
/**
* @notice Emitted when the max percentage is updated.
* @param lastMaxPercentage The previous max percentage.
* @param newMaxPercentage The new max percentage.
*/
event MaxPercentageUpdated(uint256 lastMaxPercentage, uint256 newMaxPercentage);
event MinDepositAmountUpdated(uint256 minDepositAmount, uint256 newMinDepositAmount);
/**
* @notice Emitted when the underlying balance is updated by the oracle.
* @param lastUnderlyingBalance The previous underlying balance.
* @param newUnderlyingBalance The new underlying balance.
*/
event UnderlyingBalanceUpdated(uint256 lastUnderlyingBalance, uint256 newUnderlyingBalance);
/**
* @notice Emitted when a new redeem request is created.
* @param receiver The receiving address.
* @param owner The owner address.
* @param assets The assets amount.
* @param shares The shares amount.
*/
event RedeemRequest(
address indexed receiver, address indexed owner, uint256 assets, uint256 shares
);
/**
* @notice Emitted when a new instant redeem request is created.
* @param receiver The receiving address.
* @param owner The owner address.
* @param assets The assets amount.
* @param shares The shares amount.
*/
event InstantRedeemRequest(
address indexed receiver, address indexed owner, uint256 assets, uint256 shares
);
/**
* @notice Emitted when a redeem request is fulfilled.
* @param receiver The receiving address.
* @param shares The shares amount.
* @param assets The assets amount.
*/
event RequestFulfilled(address indexed receiver, uint256 shares, uint256 assets);
/**
* @notice Emitted when a instant redeem request is fulfilled.
* @param receiver The receiving address.
* @param shares The shares amount.
* @param assets The assets amount.
*/
event InstantRequestFulfilled(address indexed receiver, uint256 shares, uint256 assets);
/**
* @notice Emitted when a flash redeem request is fulfilled.
* @param initiator The address that originally initiated the flashRedeem request
* @param operator The contract that is responsible for paying back the shares
* @param receiver The address that will receive the assets (usdc, wbtc, etc)
* @param shares The amount of shares to redeem (total position size)
* @param assetsWithoutFee The amount of assets excluding fee
* @param fee The amount of assets paid as fee
*/
event FlashRedeemFulfilled(
address indexed initiator,
address indexed operator,
address indexed receiver,
uint256 shares,
uint256 assetsWithoutFee,
uint256 fee
);
/**
* @notice Emitted when a redeem request is cancelled.
* @param receiver The receiving address.
* @param shares The shares amount.
* @param assets The assets amount.
*/
event RequestCancelled(address indexed receiver, uint256 shares, uint256 assets);
/**
* @notice Requests a redeem operation for the specified shares.
* @param shares The number of shares to redeem.
* @param receiver The address to receive the assets.
* @param owner The address of the owner of the shares.
* @return requestId The ID of the created redeem request.
*/
function requestRedeem(
uint256 shares,
address receiver,
address owner
)
external
returns (uint256 requestId);
/**
* @notice Request an instant redemption of shares (requires authorization)
* @param shares The amount of shares to redeem instantly
* @param receiver The address that will receive the assets
* @param owner The address that owns the shares
* @return requestId The ID of the request (always 0)
* @dev Only authorized users (external curators) can call this function
*/
function requestInstantRedeem(
uint256 shares,
address receiver,
address owner
)
external
returns (uint256);
/**
* @notice Flash redemption for unwinding leveraged positions
* @dev Provides USDC upfront, expects equivalent xUSDC shares back after external operator call
* @param initiator The address that originally initiated the request
* @param operator The contract that will handle position unwinding on Euler
* @param receiver The address that will receive the USDC (usually the user)
* @param shares The amount of shares to redeem (total position size)
* @param data Additional data for the operator callback
*/
function flashRedeem(
address initiator,
address operator,
address receiver,
uint256 shares,
bytes calldata data
)
external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
/**
* @title IVariableVaultFee
* @notice Interface for managing variable fees on vault operations
* @dev Supports both flat and percentage-based fees for deposits and withdrawals
*/
interface IVariableVaultFee {
// Enums
enum FeeType {
FLAT,
PERCENTAGE
}
enum FeeOperation {
DEPOSIT,
WITHDRAWAL,
INSTANT_WITHDRAWAL,
FLASH_REDEEM
}
// Structs
struct FeeConfig {
FeeType feeType;
uint256 feeAmount; // Either percentage (1e17 = 10%) or flat amount (e.g., 100e18)
}
struct AssetFeeConfig {
FeeConfig withdrawalFee;
FeeConfig depositFee;
FeeConfig instantWithdrawalFee;
FeeConfig flashRedeemFee;
address feeRecipient;
}
// Events
event RegisterAsset(address indexed user, address indexed asset, AssetFeeConfig config);
event DeregisterAsset(address indexed user, address indexed asset);
event UpdateAssetFeeConfig(
address indexed user,
address indexed asset,
AssetFeeConfig oldConfig,
AssetFeeConfig newConfig
);
// Errors
/// @notice Thrown when an invalid asset address is provided or asset is not registered
error InvalidAsset();
/// @notice Thrown when asset configuration parameters are invalid
error InvalidAssetConfig();
/// @notice Thrown when attempting to register an asset that is already registered
error AssetAlreadyRegistered();
/// @notice Thrown when amount is insufficient for the operation
error ZeroAmount();
/// @notice Thrown when amount is insufficient for the operation
error InsufficientAmount();
// View Functions
/**
* @notice Calculate fee on raw amount (amount without fees included)
* @param asset The asset address
* @param amount The raw amount
* @param operation The fee operation type (deposit/withdrawal)
* @return The fee amount to be added
*/
function feeOnRaw(
address asset,
uint256 amount,
FeeOperation operation
)
external
view
returns (uint256);
/**
* @notice Calculate fee on total amount (amount with fees already included)
* @param asset The asset address
* @param amount The total amount including fees
* @param operation The fee operation type (deposit/withdrawal)
* @return The fee portion of the total amount
*/
function feeOnTotal(
address asset,
uint256 amount,
FeeOperation operation
)
external
view
returns (uint256);
/**
* @notice Return the Fee Recipient
* @param asset The asset address
* @return The address to which the fee should be sent
*/
function getFeeRecipient(address asset) external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
interface IMultipliVaultCallee {
/// @notice This function is called by the Multipli vault, which sends in flash
/// loaned amount beforehand. The Multipli vault expects the specified shares
/// to be returned by the contract at the end of the call.
/// @param _initiator The address that initiated the flashRedeem request
/// @param _asset The asset to return to Multipli.
/// @param _underlyingAsset The underlying asset sent by Multipli in the flash loan.
/// @param _shares The amount of asset to return.
/// @param _underlyingAmount The amount of flash loaned underlying asset sent by
/// Multipli.
/// @param _additionalData Any additional data for the flash loan.
function onRedemptionFlashLoan(
address _initiator,
address _asset,
address _underlyingAsset,
uint256 _shares,
uint256 _underlyingAmount,
bytes memory _additionalData
)
external;
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import { IVariableVaultFee } from "../interfaces/IVariableVaultFee.sol";
import { Authority } from "@solmate/auth/Auth.sol";
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
/**
* @title VaultFeeUpgradeable
*/
abstract contract VaultFeeUpgradeable is Initializable {
/**
* @notice Emitted when the fee contract is updated.
* @param user The address initiating the update.
* @param oldFeeContract The previous fee contract.
* @param newFeeContract The new fee contract.
*/
event FeeContractUpdated(address indexed user, address oldFeeContract, address newFeeContract);
error ConfiguredIncorrectly(bytes4 msgSig);
/**
* @custom:storage-location erc7201:multipli.storage.vaultfee
* @dev Structure to hold Vault fee contract data
*/
struct VaultFeeStorage {
IVariableVaultFee feeContract;
}
// Storage slot for the VaultFeeStorageLocation struct.
// keccak256(abi.encode(uint256(keccak256("multipli.storage.vaultfeeV1")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant VaultFeeStorageLocation =
0x4e0114f5bb788bf295d0ab17f602045fbe9841605d1e05a2674fbfa584e94700;
/**
* @dev Returns a reference to the VaultFeeStorage struct.
* @return $ Reference to the VaultFeeStorage struct.
*/
function _getVaultFeeStorage() private pure returns (VaultFeeStorage storage $) {
assembly {
$.slot := VaultFeeStorageLocation
}
}
/**
* @notice Initializes the contract with the vault fee contract.
* @param _feeContract The initial fee contract.
* @dev This function can only be called during contract initialization.
*/
function __VaultFeeUpgreadable_init(IVariableVaultFee _feeContract) internal onlyInitializing {
__VaultFeeUpgreadable_init_unchained(_feeContract);
}
function __VaultFeeUpgreadable_init_unchained(IVariableVaultFee _feeContract)
internal
onlyInitializing
{
VaultFeeStorage storage $ = _getVaultFeeStorage();
$.feeContract = _feeContract;
emit FeeContractUpdated(msg.sender, address(0), address(_feeContract));
}
/**
* @notice Gets the current fee contract.
* @return The current fee contract address.
*/
function feeContract() public view virtual returns (IVariableVaultFee) {
return _getVaultFeeStorage().feeContract;
}
/**
* @notice Updates the fee contract. Developers are expected to add access control for this method.
* @param _feeContract The new fee contract.
*/
function setFeeContract(IVariableVaultFee _feeContract) public virtual {
VaultFeeStorage storage $ = _getVaultFeeStorage();
IVariableVaultFee oldFeeContract = feeContract();
$.feeContract = _feeContract;
emit FeeContractUpdated(msg.sender, address(oldFeeContract), address(_feeContract));
}
function _getFeeRecipient(address asset) internal view virtual returns (address) {
IVariableVaultFee feeContractAddr = feeContract();
return feeContractAddr.getFeeRecipient(asset);
}
/**
* @notice Internal function to calculate fees for operations.
* @dev Refactored common logic for all fee calculation methods.
* @param asset The asset address.
* @param amount The amount to calculate fees for.
* @param operation The fee operation type.
* @param isRawAmount Whether the amount is raw (true) or total (false).
* @return The calculated fee amount.
*/
function _calculateFee(
address asset,
uint256 amount,
IVariableVaultFee.FeeOperation operation,
bool isRawAmount
)
internal
view
virtual
returns (uint256)
{
IVariableVaultFee feeContractAddr = feeContract();
if (address(feeContractAddr) == address(0)) {
revert ConfiguredIncorrectly(msg.sig);
}
if (isRawAmount) {
return feeContractAddr.feeOnRaw(asset, amount, operation);
} else {
return feeContractAddr.feeOnTotal(asset, amount, operation);
}
}
/**
* @notice Calculate fee on raw deposit amount.
* @param asset The asset address.
* @param amount The raw deposit amount.
* @return The fee amount.
*/
function _feeOnRawDeposit(
address asset,
uint256 amount
)
internal
view
virtual
returns (uint256)
{
return _calculateFee(asset, amount, IVariableVaultFee.FeeOperation.DEPOSIT, true);
}
/**
* @notice Calculate fee on raw withdrawal amount.
* @param asset The asset address.
* @param amount The raw withdrawal amount.
* @return The fee amount.
*/
function _feeOnRawWithdrawal(
address asset,
uint256 amount
)
internal
view
virtual
returns (uint256)
{
return _calculateFee(asset, amount, IVariableVaultFee.FeeOperation.WITHDRAWAL, true);
}
/**
* @notice Calculate fee on raw instant withdrawal amount.
* @param asset The asset address.
* @param amount The raw withdrawal amount.
* @return The fee amount.
*/
function _feeOnRawInstantWithdrawal(
address asset,
uint256 amount
)
internal
view
virtual
returns (uint256)
{
return _calculateFee(asset, amount, IVariableVaultFee.FeeOperation.INSTANT_WITHDRAWAL, true);
}
/**
* @notice Calculate fee on total deposit amount.
* @param asset The asset address.
* @param amount The total deposit amount.
* @return The fee amount.
*/
function _feeOnTotalDeposit(
address asset,
uint256 amount
)
internal
view
virtual
returns (uint256)
{
return _calculateFee(asset, amount, IVariableVaultFee.FeeOperation.DEPOSIT, false);
}
/**
* @notice Calculate fee on total withdrawal amount.
* @param asset The asset address.
* @param amount The total withdrawal amount.
* @return The fee amount.
*/
function _feeOnTotalWithdrawal(
address asset,
uint256 amount
)
internal
view
virtual
returns (uint256)
{
return _calculateFee(asset, amount, IVariableVaultFee.FeeOperation.WITHDRAWAL, false);
}
/**
* @notice Calculate fee on total instant withdrawal amount.
* @param asset The asset address.
* @param amount The total withdrawal amount.
* @return The fee amount.
*/
function _feeOnTotalInstantWithdrawal(
address asset,
uint256 amount
)
internal
view
virtual
returns (uint256)
{
return
_calculateFee(asset, amount, IVariableVaultFee.FeeOperation.INSTANT_WITHDRAWAL, false);
}
/**
* @notice Calculate fee on total instant withdrawal amount.
* @param asset The asset address.
* @param amount The total withdrawal amount.
* @return The fee amount.
*/
function _feeOnTotalFlashWithdrawal(
address asset,
uint256 amount
)
internal
view
virtual
returns (uint256)
{
// todo: create a new redemption type
// temporarily using INSTANT_WITHDRAWAL fee
return _calculateFee(asset, amount, IVariableVaultFee.FeeOperation.FLASH_REDEEM, false);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import { Authority } from "@solmate/auth/Auth.sol";
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
/**
* @title AuthUpgradeable
* @notice Upgradable fork of https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol
* @dev Provides role-based authorization mechanism with upgradeability support.
*/
abstract contract AuthUpgradeable is Initializable {
/**
* @notice Emitted when ownership is transferred.
* @param user The address of the old owner.
* @param newOwner The address receiving ownership.
*/
event OwnershipTransferred(address indexed user, address indexed newOwner);
/**
* @notice Emitted when the authority contract is updated.
* @param user The address initiating the update.
* @param newAuthority The new authority contract.
*/
event AuthorityUpdated(address indexed user, Authority indexed newAuthority);
/**
* @custom:storage-location erc7201:auth.storage
* @dev Structure to hold authorization data.
*/
struct AuthStorage {
address owner;
Authority authority;
}
// Storage slot for the AuthStorage struct.
// keccak256(abi.encode(uint256(keccak256("auth.storage")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant AuthStorageLocation =
0xdd3fd67aef415aded9493b31ad20a02d2991d4bb2760431cc729821271eaea00;
/**
* @dev Returns a reference to the AuthStorage struct.
* @return $ Reference to the AuthStorage struct.
*/
function _getAuthStorage() private pure returns (AuthStorage storage $) {
assembly {
$.slot := AuthStorageLocation
}
}
/**
* @notice Initializes the contract with the specified owner and authority.
* @param _owner The address of the initial owner.
* @param _authority The initial authority contract.
* @dev This function can only be called during contract initialization.
*/
function __Auth_init(address _owner, Authority _authority) internal onlyInitializing {
__Auth_init_unchained(_owner, _authority);
}
function __Auth_init_unchained(
address _owner,
Authority _authority
)
internal
onlyInitializing
{
AuthStorage storage $ = _getAuthStorage();
$.owner = _owner;
$.authority = _authority;
emit OwnershipTransferred(msg.sender, _owner);
emit AuthorityUpdated(msg.sender, _authority);
}
/**
* @notice Modifier to restrict access to authorized users.
*/
modifier requiresAuth() virtual {
require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED");
_;
}
/**
* @notice Checks if a user is authorized to call a specific function.
* @param user The address of the user.
* @param functionSig The function signature being called.
* @return bool True if authorized, false otherwise.
*/
function isAuthorized(address user, bytes4 functionSig) public view virtual returns (bool) {
AuthStorage storage $ = _getAuthStorage();
Authority auth = $.authority;
return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig))
|| user == $.owner;
}
/**
* @notice Gets the address of the owner.
* @return The address of the current owner.
*/
function owner() public view virtual returns (address) {
return _getAuthStorage().owner;
}
/**
* @notice Gets the current authority contract.
* @return The current authority contract address.
*/
function authority() public view virtual returns (Authority) {
return _getAuthStorage().authority;
}
/**
* @notice Updates the authority contract.
* @param newAuthority The new authority contract.
* @dev Can only be called by the owner or current authority.
*/
function setAuthority(Authority newAuthority) public virtual {
AuthStorage storage $ = _getAuthStorage();
require(
msg.sender == $.owner || $.authority.canCall(msg.sender, address(this), msg.sig),
"UNAUTHORIZED"
);
$.authority = newAuthority;
emit AuthorityUpdated(msg.sender, newAuthority);
}
/**
* @notice Transfers ownership to a new address.
* @param newOwner The address to receive ownership.
* @dev Can only be called by an authorized user.
*/
function transferOwnership(address newOwner) public virtual requiresAuth {
AuthStorage storage $ = _getAuthStorage();
$.owner = newOwner;
emit OwnershipTransferred(msg.sender, newOwner);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.30;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
/**
* @title FundMovementHelperUpgradeable
* @notice Abstract contract providing fund transfer functionality with recipient whitelisting
* @dev This contract implements a whitelist-based fund transfer system for upgradeable contracts.
* It allows authorized users to transfer funds only to pre-approved recipients.
*
* Key features:
* - Recipient whitelisting mechanism
* - Safe ERC20 token transfers
* - Upgradeable storage pattern using ERC-7201
* - Event emission for transparency
*
* @custom:security-contact [email protected]
*/
abstract contract FundMovementHelperUpgradeable is Initializable {
using SafeERC20 for IERC20;
//============================== ERRORS ===============================
/// @notice Thrown when attempting to set the same whitelist status for a user
error NoChangeInWhitelistStatus();
/// @notice Thrown when attempting to transfer zero amount
error AmountZero();
/// @notice Thrown when attempting to transfer to a non-whitelisted recipient
error RecipientNotWhitelisted();
/// @notice Thrown when address is 0 (address(0))
error AddressZero();
//============================== EVENTS ===============================
/**
* @notice Emitted when funds are removed from the contract
* @param initiator The address that initiated the fund removal
* @param asset The address of the asset being transferred
* @param amount The amount of assets transferred
* @param recipient The address receiving the funds
*/
event FundsRemoved(
address indexed initiator, address indexed asset, uint256 amount, address indexed recipient
);
/**
* @notice Emitted when a user's whitelist status is updated
* @param initiator The address that initiated the whitelist update
* @param recipient The address whose whitelist status was updated
* @param isWhitelisted The new whitelist status (true = whitelisted, false = removed)
*/
event WhitelistUpdated(
address indexed initiator, address indexed recipient, bool isWhitelisted
);
//============================== STORAGE ===============================
/// @custom:storage-location erc7201:multipli.storage.FundMovementHelperStorage
struct FundMovementHelperStorage {
/// @dev Mapping to track whitelisted fund transfer recipients
mapping(address => bool) whitelistedRecipients;
}
// Storage slot for the FundMovementHelperStorage struct.
// keccak256(abi.encode(uint256(keccak256("multipli.storage.FundMovementHelperStorage")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant FUND_MOVEMENT_STORAGE_LOCATION =
0x2bbdf87c296f0fc445d947563c77d7b805fc738a2e220084769a264d45deaf00;
//============================== INITIALIZER ===============================
/**
* @notice Initializes the FundMovementHelper contract
* @dev This function should be called during contract initialization
*/
function __FundMovementHelper_init() internal onlyInitializing {
__FundMovementHelper_init_unchained();
}
/**
* @notice Unchained initializer for FundMovementHelper
* @dev Contains the actual initialization logic
*/
function __FundMovementHelper_init_unchained() internal onlyInitializing {
// No initialization logic needed currently
}
//============================== VIEW FUNCTIONS ===============================
/**
* @notice Checks if a user is whitelisted as a fund transfer recipient
* @param user The address to check
* @return isWhitelisted True if the user is whitelisted, false otherwise
*/
function isRecipientWhitelisted(address user) public view returns (bool isWhitelisted) {
FundMovementHelperStorage storage $ = _getFundMovementHelperStorage();
return $.whitelistedRecipients[user];
}
//============================== INTERNAL FUNCTIONS ===============================
/**
* @notice Updates the whitelist status of a fund transfer recipient
* @dev This method is expected to be called from the inheriting contract with proper access controls
* @param user The address to update whitelist status for
* @param isWhitelisted True to whitelist the user, false to remove from whitelist
*/
function _whitelistFundTransferRecipient(address user, bool isWhitelisted) internal virtual {
FundMovementHelperStorage storage $ = _getFundMovementHelperStorage();
if (user == address(0)) {
revert AddressZero();
}
if ($.whitelistedRecipients[user] == isWhitelisted) {
revert NoChangeInWhitelistStatus();
}
$.whitelistedRecipients[user] = isWhitelisted;
emit WhitelistUpdated(msg.sender, user, isWhitelisted);
}
/**
* @notice Removes funds from the contract and transfers them to a whitelisted recipient
* @dev This method should be called from the inheriting contract with proper access controls
* @param asset The address of the ERC20 token to transfer
* @param amount The amount of tokens to transfer
* @param recipient The address to receive the funds (must be whitelisted)
*/
function _removeFunds(address asset, uint256 amount, address recipient) internal virtual {
if (amount == 0) {
revert AmountZero();
}
if (!isRecipientWhitelisted(recipient)) {
revert RecipientNotWhitelisted();
}
IERC20(asset).safeTransfer(recipient, amount);
emit FundsRemoved(msg.sender, asset, amount, recipient);
}
//============================== PRIVATE FUNCTIONS ===============================
/**
* @dev Returns a reference to the FundMovementHelperStorage struct
* @return $ Reference to the FundMovementHelperStorage struct
*/
function _getFundMovementHelperStorage()
private
pure
returns (FundMovementHelperStorage storage $)
{
assembly {
$.slot := FUND_MOVEMENT_STORAGE_LOCATION
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @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 Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, bytes memory returndata) = recipient.call{value: amount}("");
if (!success) {
_revert(returndata);
}
}
/**
* @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
* {Errors.FailedCall} 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 Errors.InsufficientBalance(address(this).balance, value);
}
(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 {Errors.FailedCall}) 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 {Errors.FailedCall} 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 {Errors.FailedCall}.
*/
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
assembly ("memory-safe") {
revert(add(returndata, 0x20), mload(returndata))
}
} else {
revert Errors.FailedCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* Both values are immutable: they can only be set once during construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/// @inheritdoc IERC20
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/// @inheritdoc IERC20
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/// @inheritdoc IERC20
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner`'s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner`'s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance < type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/extensions/ERC4626.sol)
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {ERC20Upgradeable} from "../ERC20Upgradeable.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {Initializable} from "../../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the ERC-4626 "Tokenized Vault Standard" as defined in
* https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
*
* This extension allows the minting and burning of "shares" (represented using the ERC-20 inheritance) in exchange for
* underlying "assets" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends
* the ERC-20 standard. Any additional extensions included along it would affect the "shares" token represented by this
* contract and not the "assets" token which is an independent contract.
*
* [CAUTION]
* ====
* In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning
* with a "donation" to the vault that inflates the price of a share. This is variously known as a donation or inflation
* attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial
* deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may
* similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by
* verifying the amount received is as expected, using a wrapper that performs these checks such as
* https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].
*
* Since v4.9, this implementation introduces configurable virtual assets and shares to help developers mitigate that risk.
* The `_decimalsOffset()` corresponds to an offset in the decimal representation between the underlying asset's decimals
* and the vault decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which
* itself determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default
* offset (0) makes it non-profitable even if an attacker is able to capture value from multiple user deposits, as a result
* of the value being captured by the virtual shares (out of the attacker's donation) matching the attacker's expected gains.
* With a larger offset, the attack becomes orders of magnitude more expensive than it is profitable. More details about the
* underlying math can be found xref:ROOT:erc4626.adoc#inflation-attack[here].
*
* The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued
* to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets
* will cause the first user to exit to experience reduced losses in detriment to the last users that will experience
* bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the
* `_convertToShares` and `_convertToAssets` functions.
*
* To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].
* ====
*/
abstract contract ERC4626Upgradeable is Initializable, ERC20Upgradeable, IERC4626 {
using Math for uint256;
/// @custom:storage-location erc7201:openzeppelin.storage.ERC4626
struct ERC4626Storage {
IERC20 _asset;
uint8 _underlyingDecimals;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC4626")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ERC4626StorageLocation = 0x0773e532dfede91f04b12a73d3d2acd361424f41f76b4fb79f090161e36b4e00;
function _getERC4626Storage() private pure returns (ERC4626Storage storage $) {
assembly {
$.slot := ERC4626StorageLocation
}
}
/**
* @dev Attempted to deposit more assets than the max amount for `receiver`.
*/
error ERC4626ExceededMaxDeposit(address receiver, uint256 assets, uint256 max);
/**
* @dev Attempted to mint more shares than the max amount for `receiver`.
*/
error ERC4626ExceededMaxMint(address receiver, uint256 shares, uint256 max);
/**
* @dev Attempted to withdraw more assets than the max amount for `receiver`.
*/
error ERC4626ExceededMaxWithdraw(address owner, uint256 assets, uint256 max);
/**
* @dev Attempted to redeem more shares than the max amount for `receiver`.
*/
error ERC4626ExceededMaxRedeem(address owner, uint256 shares, uint256 max);
/**
* @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC-20 or ERC-777).
*/
function __ERC4626_init(IERC20 asset_) internal onlyInitializing {
__ERC4626_init_unchained(asset_);
}
function __ERC4626_init_unchained(IERC20 asset_) internal onlyInitializing {
ERC4626Storage storage $ = _getERC4626Storage();
(bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);
$._underlyingDecimals = success ? assetDecimals : 18;
$._asset = asset_;
}
/**
* @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.
*/
function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool ok, uint8 assetDecimals) {
(bool success, bytes memory encodedDecimals) = address(asset_).staticcall(
abi.encodeCall(IERC20Metadata.decimals, ())
);
if (success && encodedDecimals.length >= 32) {
uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));
if (returnedDecimals <= type(uint8).max) {
return (true, uint8(returnedDecimals));
}
}
return (false, 0);
}
/**
* @dev Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This
* "original" value is cached during construction of the vault contract. If this read operation fails (e.g., the
* asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals.
*
* See {IERC20Metadata-decimals}.
*/
function decimals() public view virtual override(IERC20Metadata, ERC20Upgradeable) returns (uint8) {
ERC4626Storage storage $ = _getERC4626Storage();
return $._underlyingDecimals + _decimalsOffset();
}
/// @inheritdoc IERC4626
function asset() public view virtual returns (address) {
ERC4626Storage storage $ = _getERC4626Storage();
return address($._asset);
}
/// @inheritdoc IERC4626
function totalAssets() public view virtual returns (uint256) {
return IERC20(asset()).balanceOf(address(this));
}
/// @inheritdoc IERC4626
function convertToShares(uint256 assets) public view virtual returns (uint256) {
return _convertToShares(assets, Math.Rounding.Floor);
}
/// @inheritdoc IERC4626
function convertToAssets(uint256 shares) public view virtual returns (uint256) {
return _convertToAssets(shares, Math.Rounding.Floor);
}
/// @inheritdoc IERC4626
function maxDeposit(address) public view virtual returns (uint256) {
return type(uint256).max;
}
/// @inheritdoc IERC4626
function maxMint(address) public view virtual returns (uint256) {
return type(uint256).max;
}
/// @inheritdoc IERC4626
function maxWithdraw(address owner) public view virtual returns (uint256) {
return _convertToAssets(balanceOf(owner), Math.Rounding.Floor);
}
/// @inheritdoc IERC4626
function maxRedeem(address owner) public view virtual returns (uint256) {
return balanceOf(owner);
}
/// @inheritdoc IERC4626
function previewDeposit(uint256 assets) public view virtual returns (uint256) {
return _convertToShares(assets, Math.Rounding.Floor);
}
/// @inheritdoc IERC4626
function previewMint(uint256 shares) public view virtual returns (uint256) {
return _convertToAssets(shares, Math.Rounding.Ceil);
}
/// @inheritdoc IERC4626
function previewWithdraw(uint256 assets) public view virtual returns (uint256) {
return _convertToShares(assets, Math.Rounding.Ceil);
}
/// @inheritdoc IERC4626
function previewRedeem(uint256 shares) public view virtual returns (uint256) {
return _convertToAssets(shares, Math.Rounding.Floor);
}
/// @inheritdoc IERC4626
function deposit(uint256 assets, address receiver) public virtual returns (uint256) {
uint256 maxAssets = maxDeposit(receiver);
if (assets > maxAssets) {
revert ERC4626ExceededMaxDeposit(receiver, assets, maxAssets);
}
uint256 shares = previewDeposit(assets);
_deposit(_msgSender(), receiver, assets, shares);
return shares;
}
/// @inheritdoc IERC4626
function mint(uint256 shares, address receiver) public virtual returns (uint256) {
uint256 maxShares = maxMint(receiver);
if (shares > maxShares) {
revert ERC4626ExceededMaxMint(receiver, shares, maxShares);
}
uint256 assets = previewMint(shares);
_deposit(_msgSender(), receiver, assets, shares);
return assets;
}
/// @inheritdoc IERC4626
function withdraw(uint256 assets, address receiver, address owner) public virtual returns (uint256) {
uint256 maxAssets = maxWithdraw(owner);
if (assets > maxAssets) {
revert ERC4626ExceededMaxWithdraw(owner, assets, maxAssets);
}
uint256 shares = previewWithdraw(assets);
_withdraw(_msgSender(), receiver, owner, assets, shares);
return shares;
}
/// @inheritdoc IERC4626
function redeem(uint256 shares, address receiver, address owner) public virtual returns (uint256) {
uint256 maxShares = maxRedeem(owner);
if (shares > maxShares) {
revert ERC4626ExceededMaxRedeem(owner, shares, maxShares);
}
uint256 assets = previewRedeem(shares);
_withdraw(_msgSender(), receiver, owner, assets, shares);
return assets;
}
/**
* @dev Internal conversion function (from assets to shares) with support for rounding direction.
*/
function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) {
return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding);
}
/**
* @dev Internal conversion function (from shares to assets) with support for rounding direction.
*/
function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) {
return shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding);
}
/**
* @dev Deposit/mint common workflow.
*/
function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual {
// If asset() is ERC-777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the
// `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,
// calls the vault, which is assumed not malicious.
//
// Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the
// assets are transferred and before the shares are minted, which is a valid state.
// slither-disable-next-line reentrancy-no-eth
SafeERC20.safeTransferFrom(IERC20(asset()), caller, address(this), assets);
_mint(receiver, shares);
emit Deposit(caller, receiver, assets, shares);
}
/**
* @dev Withdraw/redeem common workflow.
*/
function _withdraw(
address caller,
address receiver,
address owner,
uint256 assets,
uint256 shares
) internal virtual {
if (caller != owner) {
_spendAllowance(owner, caller, shares);
}
// If asset() is ERC-777, `transfer` can trigger a reentrancy AFTER the transfer happens through the
// `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,
// calls the vault, which is assumed not malicious.
//
// Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the
// shares are burned and after the assets are transferred, which is a valid state.
_burn(owner, shares);
SafeERC20.safeTransfer(IERC20(asset()), receiver, assets);
emit Withdraw(caller, receiver, owner, assets, shares);
}
function _decimalsOffset() internal view virtual returns (uint8) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Pausable
struct PausableStorage {
bool _paused;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;
function _getPausableStorage() private pure returns (PausableStorage storage $) {
assembly {
$.slot := PausableStorageLocation
}
}
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
function __Pausable_init() internal onlyInitializing {
}
function __Pausable_init_unchained() internal onlyInitializing {
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
PausableStorage storage $ = _getPausableStorage();
return $._paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
emit Unpaused(_msgSender());
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
/// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
struct ReentrancyGuardStorage {
uint256 _status;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;
function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
assembly {
$.slot := ReentrancyGuardStorageLocation
}
}
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
$._status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// On the first call to nonReentrant, _status will be NOT_ENTERED
if ($._status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
$._status = ENTERED;
}
function _nonReentrantAfter() private {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
$._status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
return $._status == ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.22;
import {IERC1822Proxiable} from "../../interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "../ERC1967/ERC1967Utils.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 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();
_;
}
/**
* @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);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)
pragma solidity ^0.8.20;
/**
* @dev Helper library for emitting standardized panic codes.
*
* ```solidity
* contract Example {
* using Panic for uint256;
*
* // Use any of the declared internal constants
* function foo() { Panic.GENERIC.panic(); }
*
* // Alternatively
* function foo() { Panic.panic(Panic.GENERIC); }
* }
* ```
*
* Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
*
* _Available since v5.1._
*/
// slither-disable-next-line unused-state
library Panic {
/// @dev generic / unspecified error
uint256 internal constant GENERIC = 0x00;
/// @dev used by the assert() builtin
uint256 internal constant ASSERT = 0x01;
/// @dev arithmetic underflow or overflow
uint256 internal constant UNDER_OVERFLOW = 0x11;
/// @dev division or modulo by zero
uint256 internal constant DIVISION_BY_ZERO = 0x12;
/// @dev enum conversion error
uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
/// @dev invalid encoding in storage
uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
/// @dev empty array pop
uint256 internal constant EMPTY_ARRAY_POP = 0x31;
/// @dev array out of bounds access
uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
/// @dev resource error (too large allocation or too large array)
uint256 internal constant RESOURCE_ERROR = 0x41;
/// @dev calling invalid internal function
uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;
/// @dev Reverts with a panic code. Recommended to use with
/// the internal constants with predefined codes.
function panic(uint256 code) internal pure {
assembly ("memory-safe") {
mstore(0x00, 0x4e487b71)
mstore(0x20, code)
revert(0x1c, 0x24)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)
/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)
abstract contract Auth {
event OwnershipTransferred(address indexed user, address indexed newOwner);
event AuthorityUpdated(address indexed user, Authority indexed newAuthority);
address public owner;
Authority public authority;
constructor(address _owner, Authority _authority) {
owner = _owner;
authority = _authority;
emit OwnershipTransferred(msg.sender, _owner);
emit AuthorityUpdated(msg.sender, _authority);
}
modifier requiresAuth() virtual {
require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED");
_;
}
function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {
Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.
// Checking if the caller is the owner only after calling the authority saves gas in most cases, but be
// aware that this makes protected functions uncallable even to the owner if the authority is out of order.
return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;
}
function setAuthority(Authority newAuthority) public virtual {
// We check if the caller is the owner first because we want to ensure they can
// always swap out the authority even if it's reverting or using up a lot of gas.
require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));
authority = newAuthority;
emit AuthorityUpdated(msg.sender, newAuthority);
}
function transferOwnership(address newOwner) public virtual requiresAuth {
owner = newOwner;
emit OwnershipTransferred(msg.sender, newOwner);
}
}
/// @notice A generic interface for a contract which provides authorization data to an Auth instance.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/auth/Auth.sol)
/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)
interface Authority {
function canCall(
address user,
address target,
bytes4 functionSig
) external view returns (bool);
}// 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
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC-20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {ContextUpgradeable} from "../../utils/ContextUpgradeable.sol";
import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*/
abstract contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20, IERC20Metadata, IERC20Errors {
/// @custom:storage-location erc7201:openzeppelin.storage.ERC20
struct ERC20Storage {
mapping(address account => uint256) _balances;
mapping(address account => mapping(address spender => uint256)) _allowances;
uint256 _totalSupply;
string _name;
string _symbol;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ERC20")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ERC20StorageLocation = 0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00;
function _getERC20Storage() private pure returns (ERC20Storage storage $) {
assembly {
$.slot := ERC20StorageLocation
}
}
/**
* @dev Sets the values for {name} and {symbol}.
*
* Both values are immutable: they can only be set once during construction.
*/
function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
ERC20Storage storage $ = _getERC20Storage();
$._name = name_;
$._symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
ERC20Storage storage $ = _getERC20Storage();
return $._name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
ERC20Storage storage $ = _getERC20Storage();
return $._symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/// @inheritdoc IERC20
function totalSupply() public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._totalSupply;
}
/// @inheritdoc IERC20
function balanceOf(address account) public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/// @inheritdoc IERC20
function allowance(address owner, address spender) public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Skips emitting an {Approval} event indicating an allowance update. This is not
* required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
ERC20Storage storage $ = _getERC20Storage();
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
$._totalSupply += value;
} else {
uint256 fromBalance = $._balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
$._balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
$._totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
$._balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner`'s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
*
* ```solidity
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
ERC20Storage storage $ = _getERC20Storage();
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
$._allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner`'s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance < type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (interfaces/IERC4626.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
import {IERC20Metadata} from "../token/ERC20/extensions/IERC20Metadata.sol";
/**
* @dev Interface of the ERC-4626 "Tokenized Vault Standard", as defined in
* https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
*/
interface IERC4626 is IERC20, IERC20Metadata {
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
event Withdraw(
address indexed sender,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
/**
* @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
*
* - MUST be an ERC-20 token contract.
* - MUST NOT revert.
*/
function asset() external view returns (address assetTokenAddress);
/**
* @dev Returns the total amount of the underlying asset that is “managed” by Vault.
*
* - SHOULD include any compounding that occurs from yield.
* - MUST be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT revert.
*/
function totalAssets() external view returns (uint256 totalManagedAssets);
/**
* @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToShares(uint256 assets) external view returns (uint256 shares);
/**
* @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToAssets(uint256 shares) external view returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
* through a deposit call.
*
* - MUST return a limited value if receiver is subject to some deposit limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
* - MUST NOT revert.
*/
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
* call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
* in the same transaction.
* - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
* deposit would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewDeposit(uint256 assets) external view returns (uint256 shares);
/**
* @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* deposit execution, and are accounted for during deposit.
* - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
* - MUST return a limited value if receiver is subject to some mint limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
* - MUST NOT revert.
*/
function maxMint(address receiver) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
* in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
* same transaction.
* - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
* would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by minting.
*/
function previewMint(uint256 shares) external view returns (uint256 assets);
/**
* @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
* execution, and are accounted for during mint.
* - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function mint(uint256 shares, address receiver) external returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
* Vault, through a withdraw call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
* call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
* called
* in the same transaction.
* - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
* the withdrawal would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
/**
* @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* withdraw execution, and are accounted for during withdraw.
* - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
* through a redeem call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxRedeem(address owner) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their redemption at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
* in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
* same transaction.
* - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
* redemption would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by redeeming.
*/
function previewRedeem(uint256 shares) external view returns (uint256 assets);
/**
* @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* redeem execution, and are accounted for during redeem.
* - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// 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);
}// 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();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.20;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeacon {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {UpgradeableBeacon} will check that this address is a contract.
*/
function implementation() external view returns (address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.20;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*/
interface IERC1967 {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.20;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC-1967 implementation slot:
* ```solidity
* contract ERC1967 {
* // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(newImplementation.code.length > 0);
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* TIP: Consider using this library along with {SlotDerivation}.
*/
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `Int256Slot` with member `value` located at `slot`.
*/
function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns a `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
/**
* @dev Returns a `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
assembly ("memory-safe") {
r.slot := store.slot
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}{
"remappings": [
"@openzeppelin/contracts/=lib/multipli-vault/lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/multipli-vault/lib/openzeppelin-contracts-upgradeable/contracts/",
"@solmate/=lib/multipli-vault/lib/solmate/src/",
"@multipli-vault/=lib/Multipli-Vault/",
"forge-std/=lib/multipli-vault/lib/forge-std/src/",
"Multipli-Vault/=lib/Multipli-Vault/",
"ds-test/=lib/Multipli-Vault/lib/solmate/lib/ds-test/src/",
"erc4626-tests/=lib/Multipli-Vault/lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/Multipli-Vault/lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts-upgradeable/=lib/Multipli-Vault/lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/Multipli-Vault/lib/openzeppelin-contracts/",
"openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/src/",
"script/=lib/Multipli-Vault/script/",
"solmate/=lib/Multipli-Vault/lib/solmate/src/",
"test/=lib/Multipli-Vault/test/"
],
"optimizer": {
"enabled": true,
"runs": 8000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": false
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address payable","name":"_vaultAddr","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InsufficientAggregateUnderlyingBalance","type":"error"},{"inputs":[],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"TotalAssetsMismatch","type":"error"},{"inputs":[],"name":"TotalSupplyMismatch","type":"error"},{"inputs":[],"name":"UnauthorizedCaller","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"initiator","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetsWithFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newAggregatedBalance","type":"uint256"}],"name":"FundsAddedAndFlashRedemptionFulfilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetsWithFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newAggregatedBalance","type":"uint256"}],"name":"FundsAddedAndRedemptionFulfilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newAggregatedBalance","type":"uint256"}],"name":"FundsRemovedFromVault","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RemoveFunds","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RemoveFundsNative","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBalance","type":"uint256"}],"name":"UnderlyingBalanceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"UpdateOperatorWhitelist","type":"event"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"assetsWithFee","type":"uint256"}],"name":"addFundsAndFulfillRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"flashRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAggregatedUnderlyingBalances","outputs":[{"internalType":"uint256","name":"aggregatedBalance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getContractAssetBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalAssets","outputs":[{"internalType":"uint256","name":"totalAssets","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"removeFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"removeFundsFromVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"removeFundsNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newAggregatedBalance","type":"uint256"}],"name":"updateUnderlyingBalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"updateUserOperatorWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"contract MultipliVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"whitelistedUserOperator","outputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60c060405234801561000f575f5ffd5b50604051612cf6380380612cf683398101604081905261002e916100ee565b60015f556001600160a01b0381166100595760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b0381166080819052604080516338d52e0f60e01b815290516338d52e0f916004808201926020929091908290030181865afa1580156100a1573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100c591906100ee565b6001600160a01b031660a05250610110565b6001600160a01b03811681146100eb575f5ffd5b50565b5f602082840312156100fe575f5ffd5b8151610109816100d7565b9392505050565b60805160a051612a9f6102575f395f8181610126015281816106f90152818161086101528181610b6501528181610c1f01528181610dcb0152818161147701528181611800015281816119770152611ed801525f81816102110152818161023e015281816104530152818161061401528181610883015281816108eb0152818161094c01528181610a6501528181610ca101528181610da101528181610e7501528181610ef801528181610f7b0152818161103b015281816110d301528181611134015281816111ec01528181611303015281816114c7015281816115340152818161158e0152818161163e015281816116f7015281816118b00152818161199901528181611a0401528181611a9a01528181611bcd01528181611c5201528181611cdc01528181611d7401528181611dfd01528181611eb00152611f4c0152612a9f5ff3fe608060405234801561000f575f5ffd5b50600436106100da575f3560e01c806360a7624911610088578063798bb3b211610063578063798bb3b2146101a957806381212b71146101bc578063a6d5e98a146101cf578063fbfa77cf1461020c575f5ffd5b806360a76249146101865780636808ec3b146101995780636e07302b146101a1575f5ffd5b806338d52e0f116100b857806338d52e0f1461012157806350d6368c1461016057806355d80f3714610173575f5ffd5b8063143531c0146100de5780631784b5cc146100f357806319f3400d1461010e575b5f5ffd5b6100f16100ec366004612663565b610233565b005b6100fb610450565b6040519081526020015b60405180910390f35b6100f161011c36600461268b565b6104d6565b6101487f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610105565b6100f161016e366004612663565b610a5a565b6100f1610181366004612663565b610c8e565b6100f161019436600461270e565b6112f8565b6100fb611447565b6100fb6114c4565b6100f16101b7366004612756565b611521565b6100f16101ca36600461276d565b6116e4565b6101fc6101dd36600461279d565b600160209081525f928352604080842090915290825290205460ff1681565b6040519015158152602001610105565b6101487f000000000000000000000000000000000000000000000000000000000000000081565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610295576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0382166102d5576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805f0361030e576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4781811015610349576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f836001600160a01b0316836040515f6040518083038185875af1925050503d805f8114610392576040519150601f19603f3d011682016040523d82523d5f602084013e610397565b606091505b5050905080610407576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c6564000000000000000000000000000000000060448201526064015b60405180910390fd5b836001600160a01b03167fc3d4a334e77f1f98ac1b8c79440884ed36044644945933a6d892ff916e403c958460405161044291815260200190565b60405180910390a250505050565b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166303d4113b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104ad573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104d191906127ce565b905090565b6104de611b56565b335f8181526001602090815260408083206001600160a01b0389168452909152902054859060ff1661053c576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61056f6040518060c001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b6105a26040518060c001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b336001600160a01b0389166105e3576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f07a2d13a000000000000000000000000000000000000000000000000000000008152600481018990525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906307a2d13a90602401602060405180830381865afa158015610661573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061068591906127ce565b9050881580610692575080155b156106c9576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610746573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061076a91906127ce565b9050808211156107a6576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6107ae611b97565b94508460a001515f141580156107c85750818560a0015110155b610854576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f494e56415249414e543a20496e76616c696443757272656e744167677265676160448201527f746542616c616e6365000000000000000000000000000000000000000000000060648201526084016103fe565b6108a86001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000084611fd3565b5f828660a001516108b99190612812565b6040517fe3d00c5e000000000000000000000000000000000000000000000000000000008152600481018290529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e3d00c5e906024015f604051808303815f87803b158015610934575f5ffd5b505af1158015610946573d5f5f3e3d5ffd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663757815e1858e8f8f8f8f6040518763ffffffff1660e01b81526004016109a096959493929190612825565b5f604051808303815f87803b1580156109b7575f5ffd5b505af11580156109c9573d5f5f3e3d5ffd5b505050508b6001600160a01b0316846001600160a01b03167fbdb63c6d1d5025e0cd6b168889c4dd2722020e7b36fd99ad108fc0cf01efea3d8d8685604051610a25939291909283526020830191909152604082015260600190565b60405180910390a3610a35611b97565b9450610a438686858e612053565b5050505050505050610a5460015f55565b50505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610abc576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038216610afc576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805f03610b35576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610bb2573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610bd691906127ce565b905081811015610c12576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c466001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168484611fd3565b826001600160a01b03167f691dc7659f4baf8dfed5eb922c437cd483647e77b5e6b4d5c826a02da07689f683604051610c8191815260200190565b60405180910390a2505050565b610c96611b56565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610cf8576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038216610d38576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805f03610d71576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301525f917f0000000000000000000000000000000000000000000000000000000000000000909116906370a0823190602401602060405180830381865afa158015610e12573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e3691906127ce565b905080821115610e72576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166303d4113b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ecf573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ef391906127ce565b90505f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f52573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f7691906127ce565b90505f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fd5573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ff991906127ce565b6040517f3e4d9912000000000000000000000000000000000000000000000000000000008152600481018790526001600160a01b0388811660248301529192507f000000000000000000000000000000000000000000000000000000000000000090911690633e4d9912906044015f604051808303815f87803b15801561107e575f5ffd5b505af1158015611090573d5f5f3e3d5ffd5b505050505f85846110a191906128a8565b6040517fe3d00c5e000000000000000000000000000000000000000000000000000000008152600481018290529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e3d00c5e906024015f604051808303815f87803b15801561111c575f5ffd5b505af115801561112e573d5f5f3e3d5ffd5b505050507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa15801561118e573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111b291906127ce565b83146111ea576040517fa5a129c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611246573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061126a91906127ce565b82146112a2576040517f596a843700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051878152602081018390526001600160a01b038916917f13a8ef3c5b08ce30d0939aecdf7f86fedca7686c48b981a1951ddda919674551910160405180910390a250505050506112f460015f55565b5050565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461135a576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038316158061137757506001600160a01b038216155b156113ae576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038381165f8181526001602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168615159081179091558251938452908301939093528101919091527ff4ec649a8b593d84f417952cbaec916a51a5b5ef74f187b708b82723fb9d17a89060600160405180910390a1505050565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156104ad573d5f5f3e3d5ffd5b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104ad573d5f5f3e3d5ffd5b611529611b56565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461158b576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166303d4113b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115e8573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061160c91906127ce565b6040517fe3d00c5e000000000000000000000000000000000000000000000000000000008152600481018490529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e3d00c5e906024015f604051808303815f87803b158015611687575f5ffd5b505af1158015611699573d5f5f3e3d5ffd5b505060408051848152602081018690527f06829c36c32a24a199e4c4c18e4cf08af24d8301c3e4e500c08ae1dbc28498fe935001905060405180910390a1506116e160015f55565b50565b6116ec611b56565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461174e576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03831661178e576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b811580611799575080155b156117d0576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa15801561184d573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061187191906127ce565b9050808211156118ad576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166303d4113b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561190a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061192e91906127ce565b90508083111561196a576040517fc75e76ee00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119be6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000167f000000000000000000000000000000000000000000000000000000000000000085611fd3565b6040517f6442b2ba0000000000000000000000000000000000000000000000000000000081526001600160a01b03868116600483015260248201869052604482018590527f00000000000000000000000000000000000000000000000000000000000000001690636442b2ba906064015f604051808303815f87803b158015611a45575f5ffd5b505af1158015611a57573d5f5f3e3d5ffd5b505050505f8382611a689190612812565b6040517fe3d00c5e000000000000000000000000000000000000000000000000000000008152600481018290529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e3d00c5e906024015f604051808303815f87803b158015611ae3575f5ffd5b505af1158015611af5573d5f5f3e3d5ffd5b505060408051888152602081018890529081018490526001600160a01b03891692507f564507fbc1d5830234346767b08fbbc9728eaa50e163cbd0eab39d62da9612bd915060600160405180910390a2505050611b5160015f55565b505050565b60025f5403611b91576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f55565b611bca6040518060c001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b5f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c27573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c4b91906128bb565b60ff1690507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ac9dc9e86040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cac573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611cd091906127ce565b82526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166307a2d13a611d0c83600a6129be565b6040518263ffffffff1660e01b8152600401611d2a91815260200190565b602060405180830381865afa158015611d45573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d6991906127ce565b8260200181815250507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015611dce573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611df291906127ce565b8260400181815250507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e57573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e7b91906127ce565b60608301526040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811660048301527f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015611f1d573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f4191906127ce565b8260800181815250507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166303d4113b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fa6573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611fca91906127ce565b60a08301525090565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052611b5190849061241d565b835183516611c37937e0800091612069916124a2565b106120f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603c60248201527f46554e445f4d414e414745523a206c617374507269636550657253686172653a60448201527f536c697070616765477265617465725468616e5468726573686f6c640000000060648201526084016103fe565b6611c37937e08000612110856020015185602001516124a2565b1061219d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603a60248201527f46554e445f4d414e414745523a2070726963654f664f6e6553686172653a536c60448201527f697070616765477265617465725468616e5468726573686f6c6400000000000060648201526084016103fe565b82604001518285604001516121b29190612812565b1115612240576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f46554e445f4d414e414745523a20746f74616c4173736574733a4c657373546860448201527f616e45787065637465640000000000000000000000000000000000000000000060648201526084016103fe565b82606001518185606001516122559190612812565b11156122e3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f46554e445f4d414e414745523a20746f74616c537570706c793a4c657373546860448201527f616e45787065637465640000000000000000000000000000000000000000000060648201526084016103fe565b82608001518460800151111561237b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f46554e445f4d414e414745523a20417373657442616c616e63654d69736d617460448201527f636800000000000000000000000000000000000000000000000000000000000060648201526084016103fe565b818360a0015161238b91906128a8565b8460a0015114610a54576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f46554e445f4d414e414745523a20556e6465726c79696e6742616c616e63654d60448201527f69736d617463680000000000000000000000000000000000000000000000000060648201526084016103fe565b5f5f60205f8451602086015f885af18061243c576040513d5f823e3d81fd5b50505f513d91508115612453578060011415612460565b6001600160a01b0384163b155b15610a54576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b03851660048201526024016103fe565b5f825f036124b157505f6124ed565b5f8383116124c8576124c38385612812565b6124d2565b6124d28484612812565b90506124e981670de0b6b3a76400008660016124f3565b9150505b92915050565b5f6125206125008361253e565b801561251b57505f8480612516576125166129c9565b868809115b151590565b61252b86868661256a565b61253591906128a8565b95945050505050565b5f6002826003811115612553576125536129f6565b61255d9190612a23565b60ff166001149050919050565b5f5f5f612577868661261b565b91509150815f0361259b57838181612591576125916129c9565b0492505050612614565b8184116125b2576125b26003851502601118612637565b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010185841190960395909502919093039390930492909217029150505b9392505050565b5f805f1983850993909202808410938190039390930393915050565b634e487b715f52806020526024601cfd5b80356001600160a01b038116811461265e575f5ffd5b919050565b5f5f60408385031215612674575f5ffd5b61267d83612648565b946020939093013593505050565b5f5f5f5f6060858703121561269e575f5ffd5b6126a785612648565b935060208501359250604085013567ffffffffffffffff8111156126c9575f5ffd5b8501601f810187136126d9575f5ffd5b803567ffffffffffffffff8111156126ef575f5ffd5b876020828401011115612700575f5ffd5b949793965060200194505050565b5f5f5f60608486031215612720575f5ffd5b61272984612648565b925061273760208501612648565b91506040840135801515811461274b575f5ffd5b809150509250925092565b5f60208284031215612766575f5ffd5b5035919050565b5f5f5f6060848603121561277f575f5ffd5b61278884612648565b95602085013595506040909401359392505050565b5f5f604083850312156127ae575f5ffd5b6127b783612648565b91506127c560208401612648565b90509250929050565b5f602082840312156127de575f5ffd5b5051919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b818103818111156124ed576124ed6127e5565b6001600160a01b03871681526001600160a01b03861660208201526001600160a01b038516604082015283606082015260a060808201528160a0820152818360c08301375f81830160c090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016010195945050505050565b808201808211156124ed576124ed6127e5565b5f602082840312156128cb575f5ffd5b815160ff81168114612614575f5ffd5b6001815b6001841115612916578085048111156128fa576128fa6127e5565b600184161561290857908102905b60019390931c9280026128df565b935093915050565b5f8261292c575060016124ed565b8161293857505f6124ed565b816001811461294e576002811461295857612974565b60019150506124ed565b60ff841115612969576129696127e5565b50506001821b6124ed565b5060208310610133831016604e8410600b8410161715612997575081810a6124ed565b6129a35f1984846128db565b805f19048211156129b6576129b66127e5565b029392505050565b5f612614838361291e565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b5f60ff831680612a5a577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b8060ff8416069150509291505056fea264697066735822122057ee11070eadf52ab5a4dff4c98fffc2d6d06e4817fe8e1e107eee9fd6dff08a64736f6c634300081e0033000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a0019009
Deployed Bytecode
0x608060405234801561000f575f5ffd5b50600436106100da575f3560e01c806360a7624911610088578063798bb3b211610063578063798bb3b2146101a957806381212b71146101bc578063a6d5e98a146101cf578063fbfa77cf1461020c575f5ffd5b806360a76249146101865780636808ec3b146101995780636e07302b146101a1575f5ffd5b806338d52e0f116100b857806338d52e0f1461012157806350d6368c1461016057806355d80f3714610173575f5ffd5b8063143531c0146100de5780631784b5cc146100f357806319f3400d1461010e575b5f5ffd5b6100f16100ec366004612663565b610233565b005b6100fb610450565b6040519081526020015b60405180910390f35b6100f161011c36600461268b565b6104d6565b6101487f000000000000000000000000754704bc059f8c67012fed69bc8a327a5aafb60381565b6040516001600160a01b039091168152602001610105565b6100f161016e366004612663565b610a5a565b6100f1610181366004612663565b610c8e565b6100f161019436600461270e565b6112f8565b6100fb611447565b6100fb6114c4565b6100f16101b7366004612756565b611521565b6100f16101ca36600461276d565b6116e4565b6101fc6101dd36600461279d565b600160209081525f928352604080842090915290825290205460ff1681565b6040519015158152602001610105565b6101487f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a001900981565b336001600160a01b037f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190091614610295576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0382166102d5576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805f0361030e576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b4781811015610349576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f836001600160a01b0316836040515f6040518083038185875af1925050503d805f8114610392576040519150601f19603f3d011682016040523d82523d5f602084013e610397565b606091505b5050905080610407576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f5472616e73666572206661696c6564000000000000000000000000000000000060448201526064015b60405180910390fd5b836001600160a01b03167fc3d4a334e77f1f98ac1b8c79440884ed36044644945933a6d892ff916e403c958460405161044291815260200190565b60405180910390a250505050565b5f7f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03166303d4113b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104ad573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906104d191906127ce565b905090565b6104de611b56565b335f8181526001602090815260408083206001600160a01b0389168452909152902054859060ff1661053c576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61056f6040518060c001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b6105a26040518060c001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b336001600160a01b0389166105e3576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f07a2d13a000000000000000000000000000000000000000000000000000000008152600481018990525f907f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b0316906307a2d13a90602401602060405180830381865afa158015610661573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061068591906127ce565b9050881580610692575080155b156106c9576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201525f907f000000000000000000000000754704bc059f8c67012fed69bc8a327a5aafb6036001600160a01b0316906370a0823190602401602060405180830381865afa158015610746573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061076a91906127ce565b9050808211156107a6576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6107ae611b97565b94508460a001515f141580156107c85750818560a0015110155b610854576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f494e56415249414e543a20496e76616c696443757272656e744167677265676160448201527f746542616c616e6365000000000000000000000000000000000000000000000060648201526084016103fe565b6108a86001600160a01b037f000000000000000000000000754704bc059f8c67012fed69bc8a327a5aafb603167f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a001900984611fd3565b5f828660a001516108b99190612812565b6040517fe3d00c5e000000000000000000000000000000000000000000000000000000008152600481018290529091507f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03169063e3d00c5e906024015f604051808303815f87803b158015610934575f5ffd5b505af1158015610946573d5f5f3e3d5ffd5b505050507f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b031663757815e1858e8f8f8f8f6040518763ffffffff1660e01b81526004016109a096959493929190612825565b5f604051808303815f87803b1580156109b7575f5ffd5b505af11580156109c9573d5f5f3e3d5ffd5b505050508b6001600160a01b0316846001600160a01b03167fbdb63c6d1d5025e0cd6b168889c4dd2722020e7b36fd99ad108fc0cf01efea3d8d8685604051610a25939291909283526020830191909152604082015260600190565b60405180910390a3610a35611b97565b9450610a438686858e612053565b5050505050505050610a5460015f55565b50505050565b336001600160a01b037f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190091614610abc576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038216610afc576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805f03610b35576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201525f907f000000000000000000000000754704bc059f8c67012fed69bc8a327a5aafb6036001600160a01b0316906370a0823190602401602060405180830381865afa158015610bb2573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610bd691906127ce565b905081811015610c12576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c466001600160a01b037f000000000000000000000000754704bc059f8c67012fed69bc8a327a5aafb603168484611fd3565b826001600160a01b03167f691dc7659f4baf8dfed5eb922c437cd483647e77b5e6b4d5c826a02da07689f683604051610c8191815260200190565b60405180910390a2505050565b610c96611b56565b336001600160a01b037f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190091614610cf8576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038216610d38576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805f03610d71576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a0019009811660048301525f917f000000000000000000000000754704bc059f8c67012fed69bc8a327a5aafb603909116906370a0823190602401602060405180830381865afa158015610e12573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e3691906127ce565b905080821115610e72576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03166303d4113b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ecf573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ef391906127ce565b90505f7f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f52573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f7691906127ce565b90505f7f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fd5573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610ff991906127ce565b6040517f3e4d9912000000000000000000000000000000000000000000000000000000008152600481018790526001600160a01b0388811660248301529192507f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a001900990911690633e4d9912906044015f604051808303815f87803b15801561107e575f5ffd5b505af1158015611090573d5f5f3e3d5ffd5b505050505f85846110a191906128a8565b6040517fe3d00c5e000000000000000000000000000000000000000000000000000000008152600481018290529091507f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03169063e3d00c5e906024015f604051808303815f87803b15801561111c575f5ffd5b505af115801561112e573d5f5f3e3d5ffd5b505050507f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa15801561118e573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111b291906127ce565b83146111ea576040517fa5a129c600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611246573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061126a91906127ce565b82146112a2576040517f596a843700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051878152602081018390526001600160a01b038916917f13a8ef3c5b08ce30d0939aecdf7f86fedca7686c48b981a1951ddda919674551910160405180910390a250505050506112f460015f55565b5050565b336001600160a01b037f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a0019009161461135a576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038316158061137757506001600160a01b038216155b156113ae576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038381165f8181526001602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168615159081179091558251938452908301939093528101919091527ff4ec649a8b593d84f417952cbaec916a51a5b5ef74f187b708b82723fb9d17a89060600160405180910390a1505050565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201525f907f000000000000000000000000754704bc059f8c67012fed69bc8a327a5aafb6036001600160a01b0316906370a0823190602401602060405180830381865afa1580156104ad573d5f5f3e3d5ffd5b5f7f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104ad573d5f5f3e3d5ffd5b611529611b56565b336001600160a01b037f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a0019009161461158b576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03166303d4113b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115e8573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061160c91906127ce565b6040517fe3d00c5e000000000000000000000000000000000000000000000000000000008152600481018490529091507f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03169063e3d00c5e906024015f604051808303815f87803b158015611687575f5ffd5b505af1158015611699573d5f5f3e3d5ffd5b505060408051848152602081018690527f06829c36c32a24a199e4c4c18e4cf08af24d8301c3e4e500c08ae1dbc28498fe935001905060405180910390a1506116e160015f55565b50565b6116ec611b56565b336001600160a01b037f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a0019009161461174e576040517f5c427cd900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b03831661178e576040517fd92e233d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b811580611799575080155b156117d0576040517f1f2a200500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201525f907f000000000000000000000000754704bc059f8c67012fed69bc8a327a5aafb6036001600160a01b0316906370a0823190602401602060405180830381865afa15801561184d573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061187191906127ce565b9050808211156118ad576040517ff4d678b800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f7f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03166303d4113b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561190a573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061192e91906127ce565b90508083111561196a576040517fc75e76ee00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6119be6001600160a01b037f000000000000000000000000754704bc059f8c67012fed69bc8a327a5aafb603167f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a001900985611fd3565b6040517f6442b2ba0000000000000000000000000000000000000000000000000000000081526001600160a01b03868116600483015260248201869052604482018590527f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190091690636442b2ba906064015f604051808303815f87803b158015611a45575f5ffd5b505af1158015611a57573d5f5f3e3d5ffd5b505050505f8382611a689190612812565b6040517fe3d00c5e000000000000000000000000000000000000000000000000000000008152600481018290529091507f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03169063e3d00c5e906024015f604051808303815f87803b158015611ae3575f5ffd5b505af1158015611af5573d5f5f3e3d5ffd5b505060408051888152602081018890529081018490526001600160a01b03891692507f564507fbc1d5830234346767b08fbbc9728eaa50e163cbd0eab39d62da9612bd915060600160405180910390a2505050611b5160015f55565b505050565b60025f5403611b91576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f55565b611bca6040518060c001604052805f81526020015f81526020015f81526020015f81526020015f81526020015f81525090565b5f7f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611c27573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c4b91906128bb565b60ff1690507f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b031663ac9dc9e86040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cac573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611cd091906127ce565b82526001600160a01b037f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a0019009166307a2d13a611d0c83600a6129be565b6040518263ffffffff1660e01b8152600401611d2a91815260200190565b602060405180830381865afa158015611d45573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d6991906127ce565b8260200181815250507f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03166301e1d1146040518163ffffffff1660e01b8152600401602060405180830381865afa158015611dce573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611df291906127ce565b8260400181815250507f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e57573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e7b91906127ce565b60608301526040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b037f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a0019009811660048301527f000000000000000000000000754704bc059f8c67012fed69bc8a327a5aafb60316906370a0823190602401602060405180830381865afa158015611f1d573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611f4191906127ce565b8260800181815250507f000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a00190096001600160a01b03166303d4113b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fa6573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611fca91906127ce565b60a08301525090565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052611b5190849061241d565b835183516611c37937e0800091612069916124a2565b106120f6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603c60248201527f46554e445f4d414e414745523a206c617374507269636550657253686172653a60448201527f536c697070616765477265617465725468616e5468726573686f6c640000000060648201526084016103fe565b6611c37937e08000612110856020015185602001516124a2565b1061219d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603a60248201527f46554e445f4d414e414745523a2070726963654f664f6e6553686172653a536c60448201527f697070616765477265617465725468616e5468726573686f6c6400000000000060648201526084016103fe565b82604001518285604001516121b29190612812565b1115612240576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f46554e445f4d414e414745523a20746f74616c4173736574733a4c657373546860448201527f616e45787065637465640000000000000000000000000000000000000000000060648201526084016103fe565b82606001518185606001516122559190612812565b11156122e3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f46554e445f4d414e414745523a20746f74616c537570706c793a4c657373546860448201527f616e45787065637465640000000000000000000000000000000000000000000060648201526084016103fe565b82608001518460800151111561237b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f46554e445f4d414e414745523a20417373657442616c616e63654d69736d617460448201527f636800000000000000000000000000000000000000000000000000000000000060648201526084016103fe565b818360a0015161238b91906128a8565b8460a0015114610a54576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602760248201527f46554e445f4d414e414745523a20556e6465726c79696e6742616c616e63654d60448201527f69736d617463680000000000000000000000000000000000000000000000000060648201526084016103fe565b5f5f60205f8451602086015f885af18061243c576040513d5f823e3d81fd5b50505f513d91508115612453578060011415612460565b6001600160a01b0384163b155b15610a54576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b03851660048201526024016103fe565b5f825f036124b157505f6124ed565b5f8383116124c8576124c38385612812565b6124d2565b6124d28484612812565b90506124e981670de0b6b3a76400008660016124f3565b9150505b92915050565b5f6125206125008361253e565b801561251b57505f8480612516576125166129c9565b868809115b151590565b61252b86868661256a565b61253591906128a8565b95945050505050565b5f6002826003811115612553576125536129f6565b61255d9190612a23565b60ff166001149050919050565b5f5f5f612577868661261b565b91509150815f0361259b57838181612591576125916129c9565b0492505050612614565b8184116125b2576125b26003851502601118612637565b5f848688095f868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010185841190960395909502919093039390930492909217029150505b9392505050565b5f805f1983850993909202808410938190039390930393915050565b634e487b715f52806020526024601cfd5b80356001600160a01b038116811461265e575f5ffd5b919050565b5f5f60408385031215612674575f5ffd5b61267d83612648565b946020939093013593505050565b5f5f5f5f6060858703121561269e575f5ffd5b6126a785612648565b935060208501359250604085013567ffffffffffffffff8111156126c9575f5ffd5b8501601f810187136126d9575f5ffd5b803567ffffffffffffffff8111156126ef575f5ffd5b876020828401011115612700575f5ffd5b949793965060200194505050565b5f5f5f60608486031215612720575f5ffd5b61272984612648565b925061273760208501612648565b91506040840135801515811461274b575f5ffd5b809150509250925092565b5f60208284031215612766575f5ffd5b5035919050565b5f5f5f6060848603121561277f575f5ffd5b61278884612648565b95602085013595506040909401359392505050565b5f5f604083850312156127ae575f5ffd5b6127b783612648565b91506127c560208401612648565b90509250929050565b5f602082840312156127de575f5ffd5b5051919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b818103818111156124ed576124ed6127e5565b6001600160a01b03871681526001600160a01b03861660208201526001600160a01b038516604082015283606082015260a060808201528160a0820152818360c08301375f81830160c090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016010195945050505050565b808201808211156124ed576124ed6127e5565b5f602082840312156128cb575f5ffd5b815160ff81168114612614575f5ffd5b6001815b6001841115612916578085048111156128fa576128fa6127e5565b600184161561290857908102905b60019390931c9280026128df565b935093915050565b5f8261292c575060016124ed565b8161293857505f6124ed565b816001811461294e576002811461295857612974565b60019150506124ed565b60ff841115612969576129696127e5565b50506001821b6124ed565b5060208310610133831016604e8410600b8410161715612997575081810a6124ed565b6129a35f1984846128db565b805f19048211156129b6576129b66127e5565b029392505050565b5f612614838361291e565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b5f60ff831680612a5a577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b8060ff8416069150509291505056fea264697066735822122057ee11070eadf52ab5a4dff4c98fffc2d6d06e4817fe8e1e107eee9fd6dff08a64736f6c634300081e0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a0019009
-----Decoded View---------------
Arg [0] : _vaultAddr (address): 0xd74FB32112b1eF5b4C428Fead8dA8d85A0019009
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000d74fb32112b1ef5b4c428fead8da8d85a0019009
Deployed Bytecode Sourcemap
1576:26195:7:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;22295:507;;;;;;:::i;:::-;;:::i;:::-;;23371:153;;;:::i;:::-;;;666:25:40;;;654:2;639:18;23371:153:7;;;;;;;;17090:2408;;;;;;:::i;:::-;;:::i;6623:30::-;;;;;;;;-1:-1:-1;;;;;1645:55:40;;;1627:74;;1615:2;1600:18;6623:30:7;1481:226:40;20560:460:7;;;;;;:::i;:::-;;:::i;10305:1365::-;;;;;;:::i;:::-;;:::i;8777:383::-;;;;;;:::i;:::-;;:::i;23055:137::-;;;:::i;23700:113::-;;;:::i;12430:335::-;;;;;;:::i;:::-;;:::i;14291:1374::-;;;;;;:::i;:::-;;:::i;6753:105::-;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3224:14:40;;3217:22;3199:41;;3187:2;3172:18;6753:105:7;3059:187:40;6522:36:7;;;;;22295:507;7760:10;-1:-1:-1;;;;;7782:5:7;7760:28;;7756:86;;7811:20;;;;;;;;;;;;;;7756:86;-1:-1:-1;;;;;22383:16:7;::::1;22379:67;;22422:13;;;;;;;;;;;;;;22379:67;22460:6;22470:1;22460:11:::0;22456:61:::1;;22494:12;;;;;;;;;;;;;;22456:61;22544:21;22579:16:::0;;::::1;22575:75;;;22618:21;;;;;;;;;;;;;;22575:75;22660:12;22677:2;-1:-1:-1::0;;;;;22677:7:7::1;22693:6;22677:28;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;22659:46;;;22723:7;22715:35;;;::::0;::::1;::::0;;3916:2:40;22715:35:7::1;::::0;::::1;3898:21:40::0;3955:2;3935:18;;;3928:30;3994:17;3974:18;;;3967:45;4029:18;;22715:35:7::1;;;;;;;;;22784:2;-1:-1:-1::0;;;;;22766:29:7::1;;22788:6;22766:29;;;;666:25:40::0;;654:2;639:18;;520:177;22766:29:7::1;;;;;;;;22369:433;;22295:507:::0;;:::o;23371:153::-;23437:25;23481:5;-1:-1:-1;;;;;23481:34:7;;:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;23474:43;;23371:153;:::o;17090:2408::-;2500:21:34;:19;:21::i;:::-;17256:10:7::1;8186:29;::::0;;;:23:::1;:29;::::0;;;;;;;-1:-1:-1;;;;;8186:39:7;::::1;::::0;;;;;;;;17268:8;;8186:39:::1;;8181:98;;8248:20;;;;;;;;;;;;;;8181:98;17292:38:::2;-1:-1:-1::0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;17292:38:7::2;17340:36;-1:-1:-1::0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;17340:36:7::2;17407:10;-1:-1:-1::0;;;;;17432:22:7;::::2;17428:73;;17477:13;;;;;;;;;;;;;;17428:73;17535:29;::::0;;;;::::2;::::0;::::2;666:25:40::0;;;17511:21:7::2;::::0;17535:5:::2;-1:-1:-1::0;;;;;17535:21:7::2;::::0;::::2;::::0;639:18:40;;17535:29:7::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;17511:53:::0;-1:-1:-1;17578:11:7;;;:33:::2;;-1:-1:-1::0;17593:18:7;;17578:33:::2;17574:83;;;17634:12;;;;;;;;;;;;;;17574:83;17693:38;::::0;;;;17725:4:::2;17693:38;::::0;::::2;1627:74:40::0;17667:23:7::2;::::0;17700:5:::2;-1:-1:-1::0;;;;;17693:23:7::2;::::0;::::2;::::0;1600:18:40;;17693:38:7::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;17667:64;;17761:15;17745:13;:31;17741:90;;;17799:21;;;;;;;;;;;;;;17741:90;17923:33;:31;:33::i;:::-;17904:52;;18350:16;:45;;;18399:1;18350:50;;:132;;;;;18469:13;18420:16;:45;;;:62;;18350:132;18329:220;;;::::0;::::2;::::0;;4449:2:40;18329:220:7::2;::::0;::::2;4431:21:40::0;4488:2;4468:18;;;4461:30;4527:34;4507:18;;;4500:62;4598:11;4578:18;;;4571:39;4627:19;;18329:220:7::2;4247:405:40::0;18329:220:7::2;18640:57;-1:-1:-1::0;;;;;18647:5:7::2;18640:26;18675:5;18683:13:::0;18640:26:::2;:57::i;:::-;18806:28;18885:13;18837:16;:45;;;:61;;;;:::i;:::-;18908:53;::::0;;;;::::2;::::0;::::2;666:25:40::0;;;18806:92:7;;-1:-1:-1;18908:5:7::2;-1:-1:-1::0;;;;;18908:31:7::2;::::0;::::2;::::0;639:18:40;;18908:53:7::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;19022:5;-1:-1:-1::0;;;;;19022:17:7::2;;19065:9;19098:8;19130;19160:6;19186:4;;19022:179;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;19279:8;-1:-1:-1::0;;;;;19217:125:7::2;19268:9;-1:-1:-1::0;;;;;19217:125:7::2;;19289:6;19297:13;19312:20;19217:125;;;;;;;6070:25:40::0;;;6126:2;6111:18;;6104:34;;;;6169:2;6154:18;;6147:34;6058:2;6043:18;;5868:319;19217:125:7::2;;;;;;;;19370:33;:31;:33::i;:::-;19353:50;;19413:78;19435:16;19453:14;19469:13;19484:6;19413:21;:78::i;:::-;17282:2216;;;;;;2531:1:34::1;;2542:20:::0;1857:1;3068:7;:21;2888:208;2542:20;17090:2408:7;;;;:::o;20560:460::-;7760:10;-1:-1:-1;;;;;7782:5:7;7760:28;;7756:86;;7811:20;;;;;;;;;;;;;;7756:86;-1:-1:-1;;;;;20642:16:7;::::1;20638:67;;20681:13;;;;;;;;;;;;;;20638:67;20719:6;20729:1;20719:11:::0;20715:61:::1;;20753:12;;;;;;;;;;;;;;20715:61;20804:38;::::0;;;;20836:4:::1;20804:38;::::0;::::1;1627:74:40::0;20786:15:7::1;::::0;20811:5:::1;-1:-1:-1::0;;;;;20804:23:7::1;::::0;::::1;::::0;1600:18:40;;20804:38:7::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;20786:56;;20866:6;20856:7;:16;20852:75;;;20895:21;;;;;;;;;;;;;;20852:75;20937:38;-1:-1:-1::0;;;;;20944:5:7::1;20937:26;20964:2:::0;20968:6;20937:26:::1;:38::i;:::-;21002:2;-1:-1:-1::0;;;;;20990:23:7::1;;21006:6;20990:23;;;;666:25:40::0;;654:2;639:18;;520:177;20990:23:7::1;;;;;;;;20628:392;20560:460:::0;;:::o;10305:1365::-;2500:21:34;:19;:21::i;:::-;7760:10:7::1;-1:-1:-1::0;;;;;7782:5:7::1;7760:28;;7756:86;;7811:20;;;;;;;;;;;;;;7756:86;-1:-1:-1::0;;;;;10466:23:7;::::2;10462:74;;10512:13;;;;;;;;;;;;;;10462:74;10549:6;10559:1;10549:11:::0;10545:61:::2;;10583:12;;;;;;;;;;;;;;10545:61;10634:39;::::0;;;;-1:-1:-1;;;;;10666:5:7::2;1645:55:40::0;;10634:39:7::2;::::0;::::2;1627:74:40::0;-1:-1:-1;;10641:5:7::2;10634:23:::0;;::::2;::::0;::::2;::::0;1600:18:40;;10634:39:7::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10616:57;;10696:7;10687:6;:16;10683:75;;;10726:21;;;;;;;;;;;;;;10683:75;10768:39;10810:5;-1:-1:-1::0;;;;;10810:34:7::2;;:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10768:78;;10856:27;10886:5;-1:-1:-1::0;;;;;10886:17:7::2;;:19;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;10856:49;;10915:27;10945:5;-1:-1:-1::0;;;;;10945:17:7::2;;:19;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;11065:36;::::0;;;;::::2;::::0;::::2;6366:25:40::0;;;-1:-1:-1;;;;;6427:55:40;;;6407:18;;;6400:83;10915:49:7;;-1:-1:-1;11065:5:7::2;:17:::0;;::::2;::::0;::::2;::::0;6339:18:40;;11065:36:7::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;11111:28;11176:6;11142:31;:40;;;;:::i;:::-;11192:53;::::0;;;;::::2;::::0;::::2;666:25:40::0;;;11111:71:7;;-1:-1:-1;11192:5:7::2;-1:-1:-1::0;;;;;11192:31:7::2;::::0;::::2;::::0;639:18:40;;11192:53:7::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;11331:5;-1:-1:-1::0;;;;;11331:17:7::2;;:19;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;11308;:42;11304:101;;11373:21;;;;;;;;;;;;;;11304:101;11512:5;-1:-1:-1::0;;;;;11512:17:7::2;;:19;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;11489;:42;11485:101;;11554:21;;;;;;;;;;;;;;11485:101;11601:62;::::0;;6798:25:40;;;6854:2;6839:18;;6832:34;;;-1:-1:-1;;;;;11601:62:7;::::2;::::0;::::2;::::0;6771:18:40;11601:62:7::2;;;;;;;10452:1218;;;;;2542:20:34::0;1857:1;3068:7;:21;2888:208;2542:20;10305:1365:7;;:::o;8777:383::-;7760:10;-1:-1:-1;;;;;7782:5:7;7760:28;;7756:86;;7811:20;;;;;;;;;;;;;;7756:86;-1:-1:-1;;;;;8942:18:7;::::1;::::0;;:44:::1;;-1:-1:-1::0;;;;;;8964:22:7;::::1;::::0;8942:44:::1;8938:95;;;9009:13;;;;;;;;;;;;;;8938:95;-1:-1:-1::0;;;;;9043:29:7;;::::1;;::::0;;;:23:::1;:29;::::0;;;;;;;:39;;::::1;::::0;;;;;;;;;;:48;;;::::1;::::0;::::1;;::::0;;::::1;::::0;;;9106:47;;7073:74:40;;;7163:18;;;7156:83;;;;7255:18;;7248:50;;;;9106:47:7::1;::::0;7061:2:40;7046:18;9106:47:7::1;;;;;;;8777:383:::0;;;:::o;23055:137::-;23147:38;;;;;23179:4;23147:38;;;1627:74:40;23113:15:7;;23154:5;-1:-1:-1;;;;;23147:23:7;;;;1600:18:40;;23147:38:7;;;;;;;;;;;;;;;;;;;;;;23700:113;23749:19;23787:5;-1:-1:-1;;;;;23787:17:7;;:19;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;12430:335;2500:21:34;:19;:21::i;:::-;7760:10:7::1;-1:-1:-1::0;;;;;7782:5:7::1;7760:28;;7756:86;;7811:20;;;;;;;;;;;;;;7756:86;12563:18:::2;12584:5;-1:-1:-1::0;;;;;12584:34:7::2;;:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;12631:53;::::0;;;;::::2;::::0;::::2;666:25:40::0;;;12563:57:7;;-1:-1:-1;12631:5:7::2;-1:-1:-1::0;;;;;12631:31:7::2;::::0;::::2;::::0;639:18:40;;12631:53:7::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1::0;;12700:58:7::2;::::0;;6798:25:40;;;6854:2;6839:18;;6832:34;;;12700:58:7::2;::::0;-1:-1:-1;6771:18:40;;-1:-1:-1;12700:58:7::2;;;;;;;12553:212;2542:20:34::0;1857:1;3068:7;:21;2888:208;2542:20;12430:335:7;:::o;14291:1374::-;2500:21:34;:19;:21::i;:::-;7760:10:7::1;-1:-1:-1::0;;;;;7782:5:7::1;7760:28;;7756:86;;7811:20;;;;;;;;;;;;;;7756:86;-1:-1:-1::0;;;;;14486:22:7;::::2;14482:73;;14531:13;;;;;;;;;;;;;;14482:73;14568:11:::0;;;:33:::2;;-1:-1:-1::0;14583:18:7;;14568:33:::2;14564:83;;;14624:12;;;;;;;;;;;;;;14564:83;14683:38;::::0;;;;14715:4:::2;14683:38;::::0;::::2;1627:74:40::0;14657:23:7::2;::::0;14690:5:::2;-1:-1:-1::0;;;;;14683:23:7::2;::::0;::::2;::::0;1600:18:40;;14683:38:7::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;14657:64;;14751:15;14735:13;:31;14731:90;;;14789:21;;;;;;;;;;;;;;14731:90;14831:39;14873:5;-1:-1:-1::0;;;;;14873:34:7::2;;:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;14831:78;;14940:31;14924:13;:47;14920:125;;;14994:40;;;;;;;;;;;;;;14920:125;15135:57;-1:-1:-1::0;;;;;15142:5:7::2;15135:26;15170:5;15178:13:::0;15135:26:::2;:57::i;:::-;15253:52;::::0;;;;-1:-1:-1;;;;;7529:55:40;;;15253:52:7::2;::::0;::::2;7511:74:40::0;7601:18;;;7594:34;;;7644:18;;;7637:34;;;15253:5:7::2;:19;::::0;::::2;::::0;7484:18:40;;15253:52:7::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;15414:28;15479:13;15445:31;:47;;;;:::i;:::-;15502:53;::::0;;;;::::2;::::0;::::2;666:25:40::0;;;15414:78:7;;-1:-1:-1;15502:5:7::2;-1:-1:-1::0;;;;;15502:31:7::2;::::0;::::2;::::0;639:18:40;;15502:53:7::2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1::0;;15571:87:7::2;::::0;;6070:25:40;;;6126:2;6111:18;;6104:34;;;6154:18;;;6147:34;;;-1:-1:-1;;;;;15571:87:7;::::2;::::0;-1:-1:-1;15571:87:7::2;::::0;-1:-1:-1;6058:2:40;6043:18;15571:87:7::2;;;;;;;14472:1193;;;2542:20:34::0;1857:1;3068:7;:21;2888:208;2542:20;14291:1374:7;;;:::o;2575:307:34:-;1899:1;2702:7;;:18;2698:86;;2743:30;;;;;;;;;;;;;;2698:86;1899:1;2858:7;:17;2575:307::o;24743:732:7:-;24832:31;-1:-1:-1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;24832:31:7;24879:16;24898:5;-1:-1:-1;;;;;24898:14:7;;:16;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;24879:35;;;;25015:5;-1:-1:-1;;;;;25015:23:7;;:25;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;24985:55;;-1:-1:-1;;;;;25078:5:7;:21;;25100:14;25106:8;25100:2;:14;:::i;:::-;25078:37;;;;;;;;;;;;;666:25:40;;654:2;639:18;;520:177;25078:37:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;25050:9;:25;;:65;;;;;25209:5;-1:-1:-1;;;;;25209:17:7;;:19;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;25185:9;:21;;:43;;;;;25262:5;-1:-1:-1;;;;;25262:17:7;;:19;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;25238:21;;;:43;25316:39;;;;;-1:-1:-1;;;;;25348:5:7;1645:55:40;;25316:39:7;;;1627:74:40;25323:5:7;25316:23;;;;1600:18:40;;25316:39:7;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;25291:9;:22;;:64;;;;;25406:5;-1:-1:-1;;;;;25406:34:7;;:36;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;25365:38;;;:77;-1:-1:-1;25365:9:7;24743:732::o;1219:160:29:-;1328:43;;;-1:-1:-1;;;;;9695:55:40;;1328:43:29;;;9677:74:40;9767:18;;;;9760:34;;;1328:43:29;;;;;;;;;;9650:18:40;;;;1328:43:29;;;;;;;;;;;;;;1301:71;;1321:5;;1301:19;:71::i;26248:1521:7:-;26541:30;;26573:28;;26621:4;;26514:88;;:26;:88::i;:::-;:111;26493:218;;;;;;;10007:2:40;26493:218:7;;;9989:21:40;10046:2;10026:18;;;10019:30;10085:34;10065:18;;;10058:62;10156:30;10136:18;;;10129:58;10204:19;;26493:218:7;9805:424:40;26493:218:7;26846:4;26743:84;26770:12;:28;;;26800:10;:26;;;26743;:84::i;:::-;:107;26722:212;;;;;;;10436:2:40;26722:212:7;;;10418:21:40;10475:2;10455:18;;;10448:30;10514:34;10494:18;;;10487:62;10585:28;10565:18;;;10558:56;10631:19;;26722:212:7;10234:422:40;26722:212:7;27010:10;:22;;;26993:13;26966:12;:24;;;:40;;;;:::i;:::-;:66;;26945:155;;;;;;;10863:2:40;26945:155:7;;;10845:21:40;10902:2;10882:18;;;10875:30;10941:34;10921:18;;;10914:62;11012:12;10992:18;;;10985:40;11042:19;;26945:155:7;10661:406:40;26945:155:7;27168:10;:22;;;27158:6;27131:12;:24;;;:33;;;;:::i;:::-;:59;;27110:148;;;;;;;11274:2:40;27110:148:7;;;11256:21:40;11313:2;11293:18;;;11286:30;11352:34;11332:18;;;11325:62;11423:12;11403:18;;;11396:40;11453:19;;27110:148:7;11072:406:40;27110:148:7;27467:10;:23;;;27438:12;:25;;;:52;;27417:133;;;;;;;11685:2:40;27417:133:7;;;11667:21:40;11724:2;11704:18;;;11697:30;11763:34;11743:18;;;11736:62;11834:4;11814:18;;;11807:32;11856:19;;27417:133:7;11483:398:40;27417:133:7;27684:13;27642:10;:39;;;:55;;;;:::i;:::-;27581:12;:41;;;:116;27560:202;;;;;;;12088:2:40;27560:202:7;;;12070:21:40;12127:2;12107:18;;;12100:30;12166:34;12146:18;;;12139:62;12237:9;12217:18;;;12210:37;12264:19;;27560:202:7;11886:403:40;8370:720:29;8450:18;8478:19;8616:4;8613:1;8606:4;8600:11;8593:4;8587;8583:15;8580:1;8573:5;8566;8561:60;8673:7;8663:176;;8717:4;8711:11;8762:16;8759:1;8754:3;8739:40;8808:16;8803:3;8796:29;8663:176;-1:-1:-1;;8916:1:29;8910:8;8866:16;;-1:-1:-1;8942:15:29;;:68;;8994:11;9009:1;8994:16;;8942:68;;;-1:-1:-1;;;;;8960:26:29;;;:31;8942:68;8938:146;;;9033:40;;;;;-1:-1:-1;;;;;1645:55:40;;9033:40:29;;;1627:74:40;1600:18;;9033:40:29;1481:226:40;24113:380:7;24253:7;24280:8;24292:1;24280:13;24276:52;;-1:-1:-1;24316:1:7;24309:8;;24276:52;24337:12;24363:8;24352;:19;:63;;24396:19;24407:8;24396;:19;:::i;:::-;24352:63;;;24374:19;24385:8;24374;:19;:::i;:::-;24337:78;-1:-1:-1;24432:54:7;24337:78;6905:4;24457:8;24467:18;24432:11;:54::i;:::-;24425:61;;;24113:380;;;;;:::o;11054:238:37:-;11155:7;11209:76;11225:26;11242:8;11225:16;:26::i;:::-;:59;;;;;11283:1;11268:11;11255:25;;;;;:::i;:::-;11265:1;11262;11255:25;:29;11225:59;34914:9:38;34907:17;;34795:145;11209:76:37;11181:25;11188:1;11191;11194:11;11181:6;:25::i;:::-;:104;;;;:::i;:::-;11174:111;11054:238;-1:-1:-1;;;;;11054:238:37:o;32020:122::-;32088:4;32129:1;32117:8;32111:15;;;;;;;;:::i;:::-;:19;;;;:::i;:::-;:24;;32134:1;32111:24;32104:31;;32020:122;;;:::o;7242:3683::-;7324:14;7375:12;7389:11;7404:12;7411:1;7414;7404:6;:12::i;:::-;7374:42;;;;7498:4;7506:1;7498:9;7494:365;;7833:11;7827:3;:17;;;;;:::i;:::-;;7820:24;;;;;;7494:365;7984:4;7969:11;:19;7965:142;;8008:84;5312:5;8028:16;;5311:36;940:4:33;5306:42:37;8008:11;:84::i;:::-;8359:17;8510:11;8507:1;8504;8497:25;8902:12;8932:15;;;8917:31;;9067:22;;;;;9800:1;9781;:15;;9780:21;;10033;;;10029:25;;10018:36;10103:21;;;10099:25;;10088:36;10175:21;;;10171:25;;10160:36;10246:21;;;10242:25;;10231:36;10319:21;;;10315:25;;10304:36;10393:21;;;10389:25;;;10378:36;9309:12;;;;9305:23;;;9330:1;9301:31;8622:18;;;8612:29;;;9416:11;;;;8665:19;;;;9160:14;;;;9409:18;;;;10868:13;;-1:-1:-1;;7242:3683:37;;;;;;:::o;1027:550::-;1088:12;;-1:-1:-1;;1471:1:37;1468;1461:20;1501:9;;;;1549:11;;;1535:12;;;;1531:30;;;;;1027:550;-1:-1:-1;;1027:550:37:o;1776:194:33:-;1881:10;1875:4;1868:24;1918:4;1912;1905:18;1949:4;1943;1936:18;14:196:40;82:20;;-1:-1:-1;;;;;131:54:40;;121:65;;111:93;;200:1;197;190:12;111:93;14:196;;;:::o;215:300::-;283:6;291;344:2;332:9;323:7;319:23;315:32;312:52;;;360:1;357;350:12;312:52;383:29;402:9;383:29;:::i;:::-;373:39;481:2;466:18;;;;453:32;;-1:-1:-1;;;215:300:40:o;702:774::-;790:6;798;806;814;867:2;855:9;846:7;842:23;838:32;835:52;;;883:1;880;873:12;835:52;906:29;925:9;906:29;:::i;:::-;896:39;-1:-1:-1;1004:2:40;989:18;;976:32;;-1:-1:-1;1083:2:40;1068:18;;1055:32;1110:18;1099:30;;1096:50;;;1142:1;1139;1132:12;1096:50;1165:22;;1218:4;1210:13;;1206:27;-1:-1:-1;1196:55:40;;1247:1;1244;1237:12;1196:55;1287:2;1274:16;1313:18;1305:6;1302:30;1299:50;;;1345:1;1342;1335:12;1299:50;1390:7;1385:2;1376:6;1372:2;1368:15;1364:24;1361:37;1358:57;;;1411:1;1408;1401:12;1358:57;702:774;;;;-1:-1:-1;1442:2:40;1434:11;;-1:-1:-1;;;702:774:40:o;1712:421::-;1786:6;1794;1802;1855:2;1843:9;1834:7;1830:23;1826:32;1823:52;;;1871:1;1868;1861:12;1823:52;1894:29;1913:9;1894:29;:::i;:::-;1884:39;;1942:38;1976:2;1965:9;1961:18;1942:38;:::i;:::-;1932:48;;2030:2;2019:9;2015:18;2002:32;2077:5;2070:13;2063:21;2056:5;2053:32;2043:60;;2099:1;2096;2089:12;2043:60;2122:5;2112:15;;;1712:421;;;;;:::o;2138:226::-;2197:6;2250:2;2238:9;2229:7;2225:23;2221:32;2218:52;;;2266:1;2263;2256:12;2218:52;-1:-1:-1;2311:23:40;;2138:226;-1:-1:-1;2138:226:40:o;2369:420::-;2446:6;2454;2462;2515:2;2503:9;2494:7;2490:23;2486:32;2483:52;;;2531:1;2528;2521:12;2483:52;2554:29;2573:9;2554:29;:::i;:::-;2544:39;2652:2;2637:18;;2624:32;;-1:-1:-1;2753:2:40;2738:18;;;2725:32;;2369:420;-1:-1:-1;;;2369:420:40:o;2794:260::-;2862:6;2870;2923:2;2911:9;2902:7;2898:23;2894:32;2891:52;;;2939:1;2936;2929:12;2891:52;2962:29;2981:9;2962:29;:::i;:::-;2952:39;;3010:38;3044:2;3033:9;3029:18;3010:38;:::i;:::-;3000:48;;2794:260;;;;;:::o;4058:184::-;4128:6;4181:2;4169:9;4160:7;4156:23;4152:32;4149:52;;;4197:1;4194;4187:12;4149:52;-1:-1:-1;4220:16:40;;4058:184;-1:-1:-1;4058:184:40:o;4657:::-;4709:77;4706:1;4699:88;4806:4;4803:1;4796:15;4830:4;4827:1;4820:15;4846:128;4913:9;;;4934:11;;;4931:37;;;4948:18;;:::i;4979:884::-;-1:-1:-1;;;;;5252:6:40;5248:55;5237:9;5230:74;-1:-1:-1;;;;;5344:6:40;5340:55;5335:2;5324:9;5320:18;5313:83;-1:-1:-1;;;;;5436:6:40;5432:55;5427:2;5416:9;5412:18;5405:83;5524:6;5519:2;5508:9;5504:18;5497:34;5568:3;5562;5551:9;5547:19;5540:32;5609:6;5603:3;5592:9;5588:19;5581:35;5667:6;5659;5653:3;5642:9;5638:19;5625:49;5724:1;5694:22;;;5718:3;5690:32;;;5683:43;;;;5778:2;5766:15;;;5783:66;5762:88;5747:104;5743:114;;4979:884;-1:-1:-1;;;;;4979:884:40:o;6494:125::-;6559:9;;;6580:10;;;6577:36;;;6593:18;;:::i;7682:273::-;7750:6;7803:2;7791:9;7782:7;7778:23;7774:32;7771:52;;;7819:1;7816;7809:12;7771:52;7851:9;7845:16;7901:4;7894:5;7890:16;7883:5;7880:27;7870:55;;7921:1;7918;7911:12;7960:375;8048:1;8066:5;8080:249;8101:1;8091:8;8088:15;8080:249;;;8151:4;8146:3;8142:14;8136:4;8133:24;8130:50;;;8160:18;;:::i;:::-;8210:1;8200:8;8196:16;8193:49;;;8224:16;;;;8193:49;8307:1;8303:16;;;;;8263:15;;8080:249;;;7960:375;;;;;;:::o;8340:1022::-;8389:5;8419:8;8409:80;;-1:-1:-1;8460:1:40;8474:5;;8409:80;8508:4;8498:76;;-1:-1:-1;8545:1:40;8559:5;;8498:76;8590:4;8608:1;8603:59;;;;8676:1;8671:174;;;;8583:262;;8603:59;8633:1;8624:10;;8647:5;;;8671:174;8708:3;8698:8;8695:17;8692:43;;;8715:18;;:::i;:::-;-1:-1:-1;;8771:1:40;8757:16;;8830:5;;8583:262;;8929:2;8919:8;8916:16;8910:3;8904:4;8901:13;8897:36;8891:2;8881:8;8878:16;8873:2;8867:4;8864:12;8860:35;8857:77;8854:203;;;-1:-1:-1;8966:19:40;;;9042:5;;8854:203;9089:102;-1:-1:-1;;9114:8:40;9108:4;9089:102;:::i;:::-;9287:6;-1:-1:-1;;9215:79:40;9206:7;9203:92;9200:118;;;9298:18;;:::i;:::-;9336:20;;8340:1022;-1:-1:-1;;;8340:1022:40:o;9367:131::-;9427:5;9456:36;9483:8;9477:4;9456:36;:::i;12294:184::-;12346:77;12343:1;12336:88;12443:4;12440:1;12433:15;12467:4;12464:1;12457:15;12483:184;12535:77;12532:1;12525:88;12632:4;12629:1;12622:15;12656:4;12653:1;12646:15;12672:311;12702:1;12736:4;12733:1;12729:12;12760:3;12750:191;;12797:77;12794:1;12787:88;12898:4;12895:1;12888:15;12926:4;12923:1;12916:15;12750:191;12973:3;12966:4;12963:1;12959:12;12955:22;12950:27;;;12672:311;;;;:::o
Swarm Source
ipfs://57ee11070eadf52ab5a4dff4c98fffc2d6d06e4817fe8e1e107eee9fd6dff08a
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$23.67
Net Worth in MON
Token Allocations
USDC
100.00%
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|---|---|---|---|---|
| MONAD | 100.00% | $0.999682 | 23.6772 | $23.67 |
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.