Holesky Testnet

Contract

0xE51F48bb09027B47f2f46B727426A0AeC4270b7c

Overview

ETH Balance

0 ETH

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Mint24026882024-09-25 0:36:1275 days ago1727224572IN
0xE51F48bb...eC4270b7c
0 ETH0.000038860.97

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ERC1155Vault

Compiler Version
v0.8.23+commit.f704f362

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 23 : ERC1155Vault.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/ERC4626.sol)

pragma solidity =0.8.23;

import {
    IERC20,
    IERC20Metadata,
    ERC20Upgradeable
} from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC1155} from "@openzeppelin/contracts/interfaces/IERC1155.sol";
import {IERC1155Receiver} from "@openzeppelin/contracts/interfaces/IERC1155Receiver.sol";
import {IERC4626} from "@openzeppelin/contracts/interfaces/IERC4626.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {IStakedMultiToken} from "./interfaces/IStakedMultiToken.sol";
import {RewardPoolSystem} from "./RewardPoolSystem.sol";
import {ZeroAddress, InvalidID} from "./Errors.sol";

/// @notice Utilizes a single reward token, ALT, capable of supporting multiple distribution mechanisms.
contract ERC1155Vault is RewardPoolSystem, ERC20Upgradeable, IERC4626, IERC1155Receiver {
    using Math for uint256;

    /**
     * @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);

    IERC20 public immutable altToken;
    IERC1155 public immutable erc1155StakedALT;
    uint256 public immutable erc1155TokenID;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor(IERC1155 erc1155StakedALT_, uint256 erc1155TokenID_, IERC20 altToken_) {
        if (address(erc1155StakedALT_) == address(0) || address(altToken_) == address(0)) {
            revert ZeroAddress();
        }
        if (erc1155TokenID_ == 0) {
            revert InvalidID();
        }
        erc1155StakedALT = erc1155StakedALT_;
        erc1155TokenID = erc1155TokenID_;
        altToken = altToken_;
        _disableInitializers();
    }

    function initialize(address initialOwner, string memory name_, string memory symbol_) external initializer {
        __Ownable_init(initialOwner);
        __ERC20_init(name_, symbol_);
    }

    /**
     * @notice Stakes all available alternative tokens into the staking contract.
     * @dev This function will approve and then stake the total balance of altTokens held by this vault.
     */
    function stake() public {
        address operator = address(uint160(erc1155TokenID));
        address thisVault = address(this);
        IStakedMultiToken stk = IStakedMultiToken(address(erc1155StakedALT));

        uint256 balance = altToken.balanceOf(thisVault);
        altToken.approve(address(stk), balance);
        stk.stake(thisVault, operator, balance);
    }

    /**
     * @notice Claims rewards from the staking contract.
     */
    function claim(uint16 distributionId) public {
        address operator = address(uint160(erc1155TokenID));
        address thisVault = address(this);
        IStakedMultiToken stk = IStakedMultiToken(address(erc1155StakedALT));
        stk.claimRewards(distributionId, thisVault, operator, type(uint256).max);
    }

    /**
     * @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) {
        return 18;
    }

    /**
     * @dev See {IERC4626-asset}.
     */
    function asset() public view virtual returns (address) {
        return address(erc1155StakedALT);
    }

    /**
     * @dev See {IERC4626-totalAssets}.
     */
    function totalAssets() public view virtual returns (uint256) {
        return erc1155StakedALT.balanceOf(address(this), erc1155TokenID);
    }

    /**
     * @dev See {IERC4626-convertToShares}.
     */
    function convertToShares(uint256 assets) public view virtual returns (uint256) {
        return _convertToShares(assets, Math.Rounding.Floor);
    }

    /**
     * @dev See {IERC4626-convertToAssets}.
     */
    function convertToAssets(uint256 shares) public view virtual returns (uint256) {
        return _convertToAssets(shares, Math.Rounding.Floor);
    }

    /**
     * @dev See {IERC4626-maxDeposit}.
     */
    function maxDeposit(address) public view virtual returns (uint256) {
        return type(uint256).max;
    }

    /**
     * @dev See {IERC4626-maxMint}.
     */
    function maxMint(address) public view virtual returns (uint256) {
        return type(uint256).max;
    }

    /**
     * @dev See {IERC4626-maxWithdraw}.
     */
    function maxWithdraw(address owner) public view virtual returns (uint256) {
        return _convertToAssets(balanceOf(owner), Math.Rounding.Floor);
    }

    /**
     * @dev See {IERC4626-maxRedeem}.
     */
    function maxRedeem(address owner) public view virtual returns (uint256) {
        return balanceOf(owner);
    }

    /**
     * @dev See {IERC4626-previewDeposit}.
     */
    function previewDeposit(uint256 assets) public view virtual returns (uint256) {
        return _convertToShares(assets, Math.Rounding.Floor);
    }

    /**
     * @dev See {IERC4626-previewMint}.
     */
    function previewMint(uint256 shares) public view virtual returns (uint256) {
        return _convertToAssets(shares, Math.Rounding.Ceil);
    }

    /**
     * @dev See {IERC4626-previewWithdraw}.
     */
    function previewWithdraw(uint256 assets) public view virtual returns (uint256) {
        return _convertToShares(assets, Math.Rounding.Ceil);
    }

    /**
     * @dev See {IERC4626-previewRedeem}.
     */
    function previewRedeem(uint256 shares) public view virtual returns (uint256) {
        return _convertToAssets(shares, Math.Rounding.Floor);
    }

    /**
     * @dev See {IERC4626-deposit}.
     */
    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;
    }

    /**
     * @dev See {IERC4626-mint}.
     *
     * As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero.
     * In this case, the shares will be minted without requiring any assets to be deposited.
     */
    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;
    }

    /**
     * @dev See {IERC4626-withdraw}.
     */
    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;
    }

    /**
     * @dev See {IERC4626-redeem}.
     */
    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;
    }

    function onERC1155Received(address, address, uint256, uint256, bytes memory) external pure returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory)
        external
        pure
        returns (bytes4)
    {
        return this.onERC1155BatchReceived.selector;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId;
    }

    /**
     * @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() + 1, 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() + 1, 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
        erc1155StakedALT.safeTransferFrom(caller, address(this), erc1155TokenID, 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 erc1155StakedALT 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);
        emit Withdraw(caller, receiver, owner, assets, shares);
        erc1155StakedALT.safeTransferFrom(address(this), receiver, erc1155TokenID, assets, "");
    }

    function _getBalance(address account) internal view override returns (uint256) {
        return balanceOf(account);
    }
}

File 2 of 23 : ERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.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 ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 */
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}.
     *
     * All two of these 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;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual returns (uint256) {
        ERC20Storage storage $ = _getERC20Storage();
        return $._totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    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;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    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}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * 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:
     * ```
     * 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);
            }
        }
    }
}

File 3 of 23 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 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 {
    using Address for address;

    /**
     * @dev An operation with an ERC20 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 Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    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.
     */
    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.
     */
    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 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).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            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 silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

File 4 of 23 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1155.sol)

pragma solidity ^0.8.20;

import {IERC1155} from "../token/ERC1155/IERC1155.sol";

File 5 of 23 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1155Receiver.sol)

pragma solidity ^0.8.20;

import {IERC1155Receiver} from "../token/ERC1155/IERC1155Receiver.sol";

File 6 of 23 : IERC4626.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.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 ERC4626 "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 redeemption 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);
}

File 7 of 23 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return 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.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     * @dev 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 {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0 = x * y; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 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 prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, 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 {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            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^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // 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^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice 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) {
        uint256 result = mulDiv(x, y, denominator);
        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice 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 + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @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 + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @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 + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @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 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @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 + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
        }
    }

    /**
     * @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;
    }
}

File 8 of 23 : IStakedMultiToken.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity =0.8.23;

/// @title IStakedMultiToken Interface
/// @notice Interface for the Staked MultiToken system, allowing for token staking, operator management, and reward distribution.
interface IStakedMultiToken {
    ////////////////
    // Events
    ////////////////

    event OperatorRegistered(address operator);
    event Stake(address indexed from, address indexed onBehalfOf, address operator, uint256 assets);

    event RewardsAccrued(address user, address operator, uint256 amount);
    event RewardsClaimed(address indexed from, address indexed to, address operator, uint256 amount);

    event CooldownToUnstake(address indexed user, address indexed operator, uint256 amount);
    event CooldownToUpdateProtocolFee(uint16 feeBPS, uint40 cooldownEndTimestamp);
    event CooldownToUpdateOperatorFee(address operator, uint16 feeBPS, uint40 cooldownEndTimestamp);

    event Unstake(address indexed from, address indexed to, address operator, uint256 assets);
    event SetOperatorFeeBPS(address operator, uint16 feeBPS);
    event SetProtocolFeeBPS(uint16 feeBPS);

    event SetMinVotingStake(uint256 minVotingStake);
    event SetCooldownSecForUnstaking(uint40 cooldownSeconds);
    event SetCooldownSecForOperatorFee(uint40 cooldownSeconds);
    event SetCooldownSecForProtocolFee(uint40 cooldownSeconds);
    event CollectFee(
        uint16 distributionId, address operator, uint256 protocolFee, uint256 operatorFee, uint256 userRewards
    );

    ////////////////
    // Functions
    ////////////////

    /// @notice Registers a new operator and sets their fee in basis points
    /// @param operator The address of the operator to register
    /// @param feeBPS The fee in basis points
    function registerOperator(address operator, uint16 feeBPS) external;

    /// @notice Freezes an operator, preventing them from performing certain actions
    /// @param operator The address of the operator to freeze
    function freezeOperator(address operator) external;

    /// @notice Gets the balance of a staker for a specific operator
    /// @param staker The address of the staker
    /// @param operator The address of the operator
    /// @return The balance of staked tokens
    function balanceOf(address staker, address operator) external view returns (uint256);

    /// @notice Gets the voting stake of a staker for a specific operator
    /// @param staker The address of the staker
    /// @param operator The address of the operator
    /// @return The voting stake amount
    function votingStake(address staker, address operator) external view returns (uint256);

    /// @notice Gets the total voting stake of a operator
    /// @param operator The address of the operator
    /// @return The total voting stake amount
    function totalVotingStake(address operator) external view returns (uint256);

    /// @notice Gets the total supply of staked tokens for a specific operator
    /// @param operator The address of the operator
    /// @return The total supply of staked tokens
    function totalSupply(address operator) external view returns (uint256);

    /// @notice Sets the minimum voting stake
    /// @param minVotingStake_ The minimum voting stake
    function setMinVotingStake(uint256 minVotingStake_) external;

    /// @notice Sets the cooldown seconds for operator fee updates
    /// @param cooldownSeconds_ The cooldown period in seconds
    function setCooldownSecForOperatorFee(uint40 cooldownSeconds_) external;

    /// @notice Sets the cooldown seconds for protocol fee updates
    /// @param cooldownSeconds_ The cooldown period in seconds
    function setCooldownSecForProtocolFee(uint40 cooldownSeconds_) external;

    /// @notice Sets the general cooldown period in seconds
    /// @param cooldownSeconds_ The cooldown period in seconds
    function setCooldownSecForUnstaking(uint40 cooldownSeconds_) external;

    /// @notice Initiates the cooldown period for protocol fee updates
    /// @param feeBPS The fee in basis points
    function cooldownToUpdateProtocolFee(uint16 feeBPS) external;

    /// @notice Initiates the cooldown period for operator fee updates
    /// @param feeBPS The fee in basis points
    function cooldownToUpdateOperatorFee(uint16 feeBPS) external;

    /// @notice Sets the protocol fee in basis points
    function setProtocolFeeBPS() external;

    /// @notice Sets the operator fee in basis points
    function setOperatorFeeBPS() external;

    /// @notice Claims accrued rewards for a staker
    /// @param distributionId The distribution ID
    /// @param to The address to send rewards to
    /// @param operator The address of the operator
    /// @param amount The amount of rewards to claim
    function claimRewards(uint16 distributionId, address to, address operator, uint256 amount) external;

    /// @notice Claims accrued rewards for multiple stakers in a single transaction.
    /// @param ids Array of distribution IDs for which rewards are being claimed.
    /// @param recipients Array of addresses to receive the claimed rewards, corresponding to each distribution ID.
    /// @param operators Array of operator addresses associated with each reward distribution, managing the distribution rules and potentially fees.
    /// @param amounts Array of amounts of rewards to be claimed for each distribution ID.
    function claimRewardsBatch(
        uint16[] calldata ids,
        address[] calldata recipients,
        address[] calldata operators,
        uint256[] calldata amounts
    ) external;

    /// @notice Stakes tokens on behalf of a user
    /// @param to The address on whose behalf tokens are being staked
    /// @param operator The address of the operator
    /// @param amount The amount of tokens to stake
    function stake(address to, address operator, uint256 amount) external;

    /// @notice Switches voting power from one operator to another for a specified amount.
    /// @param fromOperator The address of the current operator from which the voting power is being moved.
    /// @param toOperator The address of the new operator to which the voting power will be moved.
    /// @param amount The amount of voting power to transfer.
    function switchOperator(address fromOperator, address toOperator, uint256 amount) external;

    /// @notice Initiates the cooldown period for a user's staked tokens
    /// @param operator The address of the operator
    /// @param amountToAdd The amount of tokens to cooldown. This is additive.
    function cooldownToUnstake(address operator, uint256 amountToAdd) external;

    /// @notice Unstakes tokens and stops earning rewards
    /// @param to The address to unstake tokens to
    /// @param operator The address of the operator
    /// @param amount The amount of tokens to unstake
    function unstake(address to, address operator, uint256 amount) external;

    /// @notice Gets the accrued rewards for a staker within a specific distribution and operator context
    /// @param distributionId The distribution ID for which to query rewards
    /// @param staker The address of the staker
    /// @param operator The address of the operator
    /// @return The amount of accrued rewards
    function getAccruedRewards(uint16 distributionId, address staker, address operator)
        external
        view
        returns (uint256);

    /// @notice Gets the reward balance for a specific distribution, operator, and staker combination
    /// @param distributionId The ID of the distribution for which the reward balance is queried
    /// @param operator The address of the operator
    /// @param staker The address of the staker
    /// @return The amount of accrued rewards
    function rewardBalance(uint16 distributionId, address operator, address staker) external view returns (uint256);

    /// Gets operator fee information
    /// @param operator The address of the operator
    function operatorFee(address operator)
        external
        view
        returns (uint40 cooldownEndTimestamp, uint16 bps, uint16 pendingBPS);

    /// @notice Checks if an operator is active based on their total voting stake.
    /// @dev An operator is considered active if their total voting stake is at least the minimum required.
    /// @param operator The address of the operator to check.
    /// @return True if the operator's total voting stake is at least the minimum required, false otherwise.
    function isActiveOperator(address operator) external view returns (bool);

    /// @notice Counts the total number of active operators.
    /// @dev Iterates through all operators and counts those that are active.
    /// @return The total number of active operators.
    function totalActiveOperators() external view returns (uint256);

    /// @notice Calculates the activation threshold for alerts.
    /// @dev The activation threshold is determined as two-thirds of the total number of active operators.
    /// @return The calculated activation threshold.
    function activationThreshold() external view returns (uint256);

    /// @notice Determines if an alert is active based on the given vote count.
    /// @dev An alert is considered active if the vote count meets or exceeds the activation threshold.
    /// @param voteCount The number of votes to check against the activation threshold.
    /// @return True if the vote count meets or exceeds the activation threshold, false otherwise.
    function isActiveAlert(uint128 voteCount) external view returns (bool);

    /// @notice Generates a unique key for a reward balance based on distribution ID, operator, and staker
    /// @param distributionId The ID of the distribution
    /// @param operator The address of the operator
    /// @param staker The address of the staker
    /// @return A unique key for querying reward balances
    function rewardBalanceKey(uint16 distributionId, address operator, address staker)
        external
        pure
        returns (bytes32);

    /// @notice Converts an address to a `uint256` representation
    /// @param operator The address to convert
    /// @return The `uint256` representation of the address
    function addressToUint256(address operator) external pure returns (uint256);
}

File 9 of 23 : RewardPoolSystem.sol
// SPDX-License-Identifier: agpl-3.0
// Copyright (c) 2024, Alt Research Ltd.
pragma solidity =0.8.23;

import {Ownable2StepUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol";

import {IRewardPoolSystem} from "./interfaces/IRewardPoolSystem.sol";
import {
    InvalidID,
    ZeroShare,
    InvalidStartTime,
    InvalidEndTime,
    OptInPeriodNotStarted,
    OptInPeriodEnded
} from "./Errors.sol";

abstract contract RewardPoolSystem is IRewardPoolSystem, Ownable2StepUpgradeable {
    struct RewardPoolData {
        uint64 startTimestamp;
        uint64 endTimestamp;
        string name;
    }

    uint256 public totalRewardPools;
    mapping(uint256 => RewardPoolData) public RewardPools;
    mapping(uint256 => mapping(address => bool)) public optedInUsers;

    /// @inheritdoc IRewardPoolSystem
    function createRewardPool(uint64 startTimestamp_, uint64 endTimestamp_, string memory name_) external onlyOwner {
        if (block.timestamp > startTimestamp_) {
            revert InvalidStartTime();
        }
        if (startTimestamp_ >= endTimestamp_) {
            revert InvalidEndTime();
        }
        ++totalRewardPools;
        uint256 id = totalRewardPools;

        emit RewardPoolCreated(id, startTimestamp_, endTimestamp_, name_);
        _setRewardPool(id, startTimestamp_, endTimestamp_, name_);
    }

    /// @inheritdoc IRewardPoolSystem
    function updateRewardPool(uint256 id_, uint64 startTimestamp_, uint64 endTimestamp_, string memory name_)
        external
        onlyOwner
    {
        emit RewardPoolUpdated(id_, startTimestamp_, endTimestamp_, name_);
        _setRewardPool(id_, startTimestamp_, endTimestamp_, name_);
    }

    /// @inheritdoc IRewardPoolSystem
    function optIn(uint256 id) external {
        RewardPoolData memory rewardPoolData = RewardPools[id];

        // If the rewardPoolData is not initialized
        if (rewardPoolData.endTimestamp == 0) {
            // Note: When initialized, endTimestamp is greater than startTimestamp
            // Therefore. endTimestamp is always greater than 0.
            revert InvalidID();
        }

        if (block.timestamp < rewardPoolData.startTimestamp) {
            revert OptInPeriodNotStarted();
        }

        if (block.timestamp > rewardPoolData.endTimestamp) {
            revert OptInPeriodEnded();
        }

        address sender = _msgSender();

        if (_getBalance(sender) == 0) {
            revert ZeroShare();
        }

        optedInUsers[id][sender] = true;
        emit OptedIn(id, sender);
    }

    function _getBalance(address account) internal view virtual returns (uint256);

    function _setRewardPool(uint256 id_, uint64 startTimestamp_, uint64 endTimestamp_, string memory name_) internal {
        RewardPools[id_] = RewardPoolData({startTimestamp: startTimestamp_, endTimestamp: endTimestamp_, name: name_});
    }
}

File 10 of 23 : Errors.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity =0.8.23;

error OptInPeriodNotStarted();
error OptInPeriodEnded();
error ArrayLengthMismatch();
error FrozenOperator();
error InsufficientAmount();
error ZeroVotingStake();
error ZeroAddress();
error NotOperator();
error NodeKeyNotAuthenticated();
error LessThanMinStakeToVote();
error AlreadyVoted();
error AlreadyActiveAlert();
error InvalidExpiryDuration();
error OperatorMismatch();
error InvalidID();
error InvalidStartTime();
error InvalidEndTime();
error InvalidStartIndex();
error InvalidStakingStartTime();
error InvalidDistributionStartTime();
error InvalidDistributionEndTime();
error AlreadyRegistered();
error AlreadyAuthenticated();
error AlreadyRemoved();
error InvalidBPS();
error ZeroExchangeRate();
error ZeroAmount();
error ZeroShare();
error ZeroCooldownAmount();
error InvalidCooldownAmount();
error InsufficientCooldown();
error ZeroUnstakeable();
error InvalidDestination();
error GreaterThanMaxCooldownSec();
error StakingNotStartedYet();
error NotSlasher();
error NotSupported();

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

File 12 of 23 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.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 ERC20 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);
}

File 13 of 23 : ContextUpgradeable.sol
// 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;
    }
}

File 14 of 23 : draft-IERC6093.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 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 ERC721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-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 ERC1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 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);
}

File 15 of 23 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.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 reininitialization) 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 Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        assembly {
            $.slot := INITIALIZABLE_STORAGE
        }
    }
}

File 16 of 23 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 17 of 23 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}

File 18 of 23 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the value of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(
        address[] calldata accounts,
        uint256[] calldata ids
    ) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155Received} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `value` amount.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
     *
     * Requirements:
     *
     * - `ids` and `values` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external;
}

File 19 of 23 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Interface that must be implemented by smart contracts in order to receive
 * ERC-1155 token transfers.
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

File 20 of 23 : Ownable2StepUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

import {OwnableUpgradeable} from "./OwnableUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {
    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable2Step
    struct Ownable2StepStorage {
        address _pendingOwner;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable2Step")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant Ownable2StepStorageLocation = 0x237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00;

    function _getOwnable2StepStorage() private pure returns (Ownable2StepStorage storage $) {
        assembly {
            $.slot := Ownable2StepStorageLocation
        }
    }

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    function __Ownable2Step_init() internal onlyInitializing {
    }

    function __Ownable2Step_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        Ownable2StepStorage storage $ = _getOwnable2StepStorage();
        return $._pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        Ownable2StepStorage storage $ = _getOwnable2StepStorage();
        $._pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        Ownable2StepStorage storage $ = _getOwnable2StepStorage();
        delete $._pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}

File 21 of 23 : IRewardPoolSystem.sol
// SPDX-License-Identifier: agpl-3.0
// Copyright (c) 2024, Alt Research Ltd.
pragma solidity =0.8.23;

/// @title Interface for RewardPoolSystem
interface IRewardPoolSystem {
    ////////////////
    // Events
    ////////////////

    /// @notice Emitted when a user opts into an action or agreement.
    /// @param id The unique identifier of the opt-in action.
    /// @param user The address of the user who opted in.
    event OptedIn(uint256 indexed id, address user);

    /// @notice Emitted when a reward pool is created.
    /// @param id The unique identifier of the reward pool.
    /// @param startTimestamp_ The start timestamp of the reward pool.
    /// @param endTimestamp_ The end timestamp of the reward pool.
    /// @param name_ The name of the reward pool.
    event RewardPoolCreated(uint256 indexed id, uint64 startTimestamp_, uint64 endTimestamp_, string name_);

    /// @notice Emitted when a reward pool is updated.
    /// @param id The unique identifier of the reward pool.
    /// @param startTimestamp_ The new start timestamp of the reward pool.
    /// @param endTimestamp_ The new end timestamp of the reward pool.
    /// @param name_ The new name of the reward pool.
    event RewardPoolUpdated(uint256 indexed id, uint64 startTimestamp_, uint64 endTimestamp_, string name_);

    ////////////////
    // Functions
    ////////////////

    /// @notice Creates a new reward pool with the specified name, start, and end timestamps.
    /// @param startTimestamp_ The start timestamp of the reward pool.
    /// @param endTimestamp_ The end timestamp of the reward pool.
    /// @param name_ The name of the reward pool.
    /// @dev Only the contract owner can create a reward pool.
    function createRewardPool(uint64 startTimestamp_, uint64 endTimestamp_, string memory name_) external;

    /// @notice Updates an existing reward pool with the specified ID, name, start, and end timestamps.
    /// @param id_ The ID of the reward pool to set or update.
    /// @param startTimestamp_ The start timestamp of the reward pool.
    /// @param endTimestamp_ The end timestamp of the reward pool.
    /// @param name_ The name of the reward pool.
    /// @dev Only the contract owner can set or update a reward pool.
    function updateRewardPool(uint256 id_, uint64 startTimestamp_, uint64 endTimestamp_, string memory name_)
        external;

    /// @notice Allows a user to opt into a reward pool.
    /// @param id The identifier of the opt-in period.
    function optIn(uint256 id) external;
}

File 22 of 23 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * 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[EIP 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);
}

File 23 of 23 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable
    struct OwnableStorage {
        address _owner;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;

    function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
        assembly {
            $.slot := OwnableStorageLocation
        }
    }

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    function __Ownable_init(address initialOwner) internal onlyInitializing {
        __Ownable_init_unchained(initialOwner);
    }

    function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        OwnableStorage storage $ = _getOwnableStorage();
        return $._owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        OwnableStorage storage $ = _getOwnableStorage();
        address oldOwner = $._owner;
        $._owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

Settings
{
  "remappings": [
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "viaIR": false,
  "libraries": {}
}

Contract ABI

[{"inputs":[{"internalType":"contract IERC1155","name":"erc1155StakedALT_","type":"address"},{"internalType":"uint256","name":"erc1155TokenID_","type":"uint256"},{"internalType":"contract IERC20","name":"altToken_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxDeposit","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxMint","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxRedeem","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"ERC4626ExceededMaxWithdraw","type":"error"},{"inputs":[],"name":"InvalidEndTime","type":"error"},{"inputs":[],"name":"InvalidID","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidStartTime","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"OptInPeriodEnded","type":"error"},{"inputs":[],"name":"OptInPeriodNotStarted","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"inputs":[],"name":"ZeroShare","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"address","name":"user","type":"address"}],"name":"OptedIn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"startTimestamp_","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"endTimestamp_","type":"uint64"},{"indexed":false,"internalType":"string","name":"name_","type":"string"}],"name":"RewardPoolCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"startTimestamp_","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"endTimestamp_","type":"uint64"},{"indexed":false,"internalType":"string","name":"name_","type":"string"}],"name":"RewardPoolUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"RewardPools","outputs":[{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"uint64","name":"endTimestamp","type":"uint64"},{"internalType":"string","name":"name","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"altToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"asset","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"distributionId","type":"uint16"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"convertToAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"convertToShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"startTimestamp_","type":"uint64"},{"internalType":"uint64","name":"endTimestamp_","type":"uint64"},{"internalType":"string","name":"name_","type":"string"}],"name":"createRewardPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"erc1155StakedALT","outputs":[{"internalType":"contract IERC1155","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"erc1155TokenID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"initialOwner","type":"address"},{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"maxWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"mint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"optIn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"optedInUsers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewDeposit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"previewRedeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"previewWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalRewardPools","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"},{"internalType":"uint64","name":"startTimestamp_","type":"uint64"},{"internalType":"uint64","name":"endTimestamp_","type":"uint64"},{"internalType":"string","name":"name_","type":"string"}],"name":"updateRewardPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]

60e06040523480156200001157600080fd5b50604051620026f3380380620026f3833981016040819052620000349162000188565b6001600160a01b03831615806200005257506001600160a01b038116155b15620000715760405163d92e233d60e01b815260040160405180910390fd5b816000036200009357604051637ae9080f60e11b815260040160405180910390fd5b6001600160a01b0380841660a05260c08390528116608052620000b5620000be565b505050620001d0565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156200010f5760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146200016f5780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6001600160a01b03811681146200016f57600080fd5b6000806000606084860312156200019e57600080fd5b8351620001ab8162000172565b602085015160408601519194509250620001c58162000172565b809150509250925092565b60805160a05160c0516124986200025b600039600081816105e40152818161066701528181610a27015281816111ad0152818161142a01526116d60152600081816103b80152818161047d0152818161069001528181610a49015281816111df015281816113f901526116a50152600081816104a401528181610a6e0152610b0a01526124986000f3fe608060405234801561001057600080fd5b506004361061027f5760003560e01c80638c5d591e1161015c578063bc197c81116100ce578063de0fdeea11610087578063de0fdeea146105df578063e30c397814610606578063edac5f3e1461060e578063ef8b30f714610593578063f23a6e6114610621578063f2fde38b1461064057600080fd5b8063bc197c811461055b578063c63d75b6146103f8578063c6e6f59214610593578063ce96cb77146105a6578063d905777e146105b9578063dd62ed3e146105cc57600080fd5b806395d89b411161012057806395d89b41146104f4578063a3d93e55146104fc578063a9059cbb1461050f578063b3d7f6b914610522578063b460af9414610535578063ba0876521461054857600080fd5b80638c5d591e146104785780638cdf4f161461049f5780638da5cb5b146104c657806390657147146104ce57806394bf804d146104e157600080fd5b806336eff2ec116101f5578063548a65bf116101b9578063548a65bf1461040d5780636e553f651461042f57806370a0823114610442578063715018a61461045557806376e1fb7e1461045d57806379ba50971461047057600080fd5b806336eff2ec1461038857806338d52e0f146103b65780633a4b66f1146103f0578063402d267d146103f85780634cdad506146102e857600080fd5b80630a28a477116102475780630a28a4771461030e57806318160ddd146103215780632000d0bf1461034857806323b872dd14610351578063313ce5671461036457806336130f001461037357600080fd5b806301e1d1141461028457806301ffc9a71461029f57806306fdde03146102d357806307a2d13a146102e8578063095ea7b3146102fb575b600080fd5b61028c610653565b6040519081526020015b60405180910390f35b6102c36102ad366004611c27565b6001600160e01b031916630271189760e51b1490565b6040519015158152602001610296565b6102db610707565b6040516102969190611c97565b61028c6102f6366004611caa565b6107ca565b6102c3610309366004611cdf565b6107dd565b61028c61031c366004611caa565b6107f5565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025461028c565b61028c60005481565b6102c361035f366004611d09565b610802565b60405160128152602001610296565b610386610381366004611caa565b610828565b005b6102c3610396366004611d45565b600260209081526000928352604080842090915290825290205460ff1681565b7f00000000000000000000000000000000000000000000000000000000000000005b6040516001600160a01b039091168152602001610296565b610386610a10565b61028c610406366004611d71565b5060001990565b61042061041b366004611caa565b610beb565b60405161029693929190611d8c565b61028c61043d366004611d45565b610ca6565b61028c610450366004611d71565b610cda565b610386610d02565b61038661046b366004611e84565b610d16565b610386610d6c565b6103d87f000000000000000000000000000000000000000000000000000000000000000081565b6103d87f000000000000000000000000000000000000000000000000000000000000000081565b6103d8610db4565b6103866104dc366004611eeb565b610de9565b61028c6104ef366004611d45565b610f02565b6102db610f20565b61038661050a366004611f5e565b610f5f565b6102c361051d366004611cdf565b611022565b61028c610530366004611caa565b611030565b61028c610543366004611fb1565b61103d565b61028c610556366004611fb1565b611095565b61057a61056936600461206c565b63bc197c8160e01b95945050505050565b6040516001600160e01b03199091168152602001610296565b61028c6105a1366004611caa565b6110e4565b61028c6105b4366004611d71565b6110f1565b61028c6105c7366004611d71565b611106565b61028c6105da366004612115565b611111565b61028c7f000000000000000000000000000000000000000000000000000000000000000081565b6103d861115b565b61038661061c36600461213f565b611184565b61057a61062f366004612163565b63f23a6e6160e01b95945050505050565b61038661064e366004611d71565b611210565b604051627eeac760e11b81523060048201527f000000000000000000000000000000000000000000000000000000000000000060248201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169062fdd58e90604401602060405180830381865afa1580156106de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061070291906121c7565b905090565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace03805460609160008051602061244383398151915291610746906121e0565b80601f0160208091040260200160405190810160405280929190818152602001828054610772906121e0565b80156107bf5780601f10610794576101008083540402835291602001916107bf565b820191906000526020600020905b8154815290600101906020018083116107a257829003601f168201915b505050505091505090565b60006107d7826000611295565b92915050565b6000336107eb8185856112e4565b5060019392505050565b60006107d78260016112f6565b600033610810858285611336565b61081b858585611383565b60019150505b9392505050565b6000818152600160208181526040808420815160608101835281546001600160401b038082168352600160401b9091041693810193909352928301805492939291840191610875906121e0565b80601f01602080910402602001604051908101604052809291908181526020018280546108a1906121e0565b80156108ee5780601f106108c3576101008083540402835291602001916108ee565b820191906000526020600020905b8154815290600101906020018083116108d157829003601f168201915b505050505081525050905080602001516001600160401b031660000361092757604051637ae9080f60e11b815260040160405180910390fd5b80516001600160401b0316421015610952576040516379eb86a960e01b815260040160405180910390fd5b80602001516001600160401b03164211156109805760405163a4bf28db60e01b815260040160405180910390fd5b3361098a81611106565b6000036109aa5760405163fc6f967760e01b815260040160405180910390fd5b60008381526002602090815260408083206001600160a01b03851680855290835292819020805460ff191660011790555191825284917f14c49ee9310faeb1545e678feca92eeb5c55866c155b29be11fea2244f5ab09b910160405180910390a2505050565b6040516370a0823160e01b815230600482018190527f0000000000000000000000000000000000000000000000000000000000000000917f0000000000000000000000000000000000000000000000000000000000000000906000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610abd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae191906121c7565b60405163095ea7b360e01b81526001600160a01b038481166004830152602482018390529192507f00000000000000000000000000000000000000000000000000000000000000009091169063095ea7b3906044016020604051808303816000875af1158015610b55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b79919061221a565b5060405163bf6eac2f60e01b81526001600160a01b03848116600483015285811660248301526044820183905283169063bf6eac2f906064015b600060405180830381600087803b158015610bcd57600080fd5b505af1158015610be1573d6000803e3d6000fd5b5050505050505050565b6001602081905260009182526040909120805491810180546001600160401b0380851694600160401b900416929190610c23906121e0565b80601f0160208091040260200160405190810160405280929190818152602001828054610c4f906121e0565b8015610c9c5780601f10610c7157610100808354040283529160200191610c9c565b820191906000526020600020905b815481529060010190602001808311610c7f57829003601f168201915b5050505050905083565b6000600019610cb9565b60405180910390fd5b6000610cc4856110e4565b9050610cd2338587846113e2565b949350505050565b6001600160a01b03166000908152600080516020612443833981519152602052604090205490565b610d0a6114ec565b610d14600061151e565b565b610d1e6114ec565b837fd8d6f294be96a42e8f3d8b73934ef4204d9124f32d2a906891bf2782a0c3f424848484604051610d5293929190611d8c565b60405180910390a2610d668484848461155a565b50505050565b3380610d7661115b565b6001600160a01b031614610da85760405163118cdaa760e01b81526001600160a01b0382166004820152602401610cb0565b610db18161151e565b50565b6000807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005b546001600160a01b031692915050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b0316600081158015610e2e5750825b90506000826001600160401b03166001148015610e4a5750303b155b905081158015610e58575080155b15610e765760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610ea057845460ff60401b1916600160401b1785555b610ea9886115dd565b610eb387876115ee565b8315610be157845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050505050505050565b60006000196000610f1285611030565b9050610cd2338583886113e2565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace04805460609160008051602061244383398151915291610746906121e0565b610f676114ec565b826001600160401b0316421115610f9157604051632ca4094f60e21b815260040160405180910390fd5b816001600160401b0316836001600160401b031610610fc3576040516338af65f760e01b815260040160405180910390fd5b6000808154610fd190612273565b9091555060005460405181907fb86ac8ee844a183d8c2e43d3f9a629031e467ab9fd4a04e7b830e0d11c19cf1a9061100e90879087908790611d8c565b60405180910390a2610d668185858561155a565b6000336107eb818585611383565b60006107d7826001611295565b600080611049836110f1565b90508085111561107257828582604051633fa733bb60e21b8152600401610cb09392919061223c565b600061107d866107f5565b905061108c3386868985611600565b95945050505050565b6000806110a183611106565b9050808511156110ca57828582604051632e52afbb60e21b8152600401610cb09392919061223c565b60006110d5866107ca565b905061108c338686848a611600565b60006107d78260006112f6565b60006107d76110ff83610cda565b6000611295565b60006107d782610cda565b6001600160a01b0391821660009081527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace016020908152604080832093909416825291909152205490565b6000807f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00610dd9565b6040516314cbb82960e21b815261ffff8216600482015230602482018190526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081811660448501526000196064850152927f00000000000000000000000000000000000000000000000000000000000000009182169063532ee0a490608401610bb3565b6112186114ec565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b0319166001600160a01b038316908117825561125c610db4565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a35050565b60006108216112a2610653565b6112ad90600161228c565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace02545b6112db90600161228c565b85919085611739565b6112f18383836001611788565b505050565b60006108216113237f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025490565b61132e90600161228c565b6112d0610653565b60006113428484611111565b90506000198114610d66578181101561137457828183604051637dc7a0d960e11b8152600401610cb09392919061223c565b610d6684848484036000611788565b6001600160a01b0383166113ad57604051634b637e8f60e11b815260006004820152602401610cb0565b6001600160a01b0382166113d75760405163ec442f0560e01b815260006004820152602401610cb0565b6112f1838383611870565b604051637921219560e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063f242432a9061145490879030907f000000000000000000000000000000000000000000000000000000000000000090889060040161229f565b600060405180830381600087803b15801561146e57600080fd5b505af1158015611482573d6000803e3d6000fd5b50505050611490838261198d565b826001600160a01b0316846001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d784846040516114de929190918252602082015260400190565b60405180910390a350505050565b336114f5610db4565b6001600160a01b031614610d145760405163118cdaa760e01b8152336004820152602401610cb0565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b0319168155611556826119c3565b5050565b604080516060810182526001600160401b038086168252848116602080840191825283850186815260008a8152600192839052959095208451815493518516600160401b026fffffffffffffffffffffffffffffffff19909416941693909317919091178255925191929091908201906115d49082612327565b50505050505050565b6115e5611a34565b610db181611a7d565b6115f6611a34565b6115568282611aaf565b826001600160a01b0316856001600160a01b03161461162457611624838683611336565b61162e8382611b00565b826001600160a01b0316846001600160a01b0316866001600160a01b03167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db8585604051611686929190918252602082015260400190565b60405180910390a4604051637921219560e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063f242432a9061170090309088907f000000000000000000000000000000000000000000000000000000000000000090889060040161229f565b600060405180830381600087803b15801561171a57600080fd5b505af115801561172e573d6000803e3d6000fd5b505050505050505050565b600080611747868686611b36565b905061175283611bfa565b801561176e575060008480611769576117696123e6565b868809115b1561108c5761177e60018261228c565b9695505050505050565b6000805160206124438339815191526001600160a01b0385166117c15760405163e602df0560e01b815260006004820152602401610cb0565b6001600160a01b0384166117eb57604051634a1406b160e11b815260006004820152602401610cb0565b6001600160a01b0380861660009081526001830160209081526040808320938816835292905220839055811561186957836001600160a01b0316856001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258560405161186091815260200190565b60405180910390a35b5050505050565b6000805160206124438339815191526001600160a01b0384166118ac57818160020160008282546118a1919061228c565b9091555061190b9050565b6001600160a01b038416600090815260208290526040902054828110156118ec5784818460405163391434e360e21b8152600401610cb09392919061223c565b6001600160a01b03851660009081526020839052604090209083900390555b6001600160a01b038316611929576002810180548390039055611948565b6001600160a01b03831660009081526020829052604090208054830190555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516114de91815260200190565b6001600160a01b0382166119b75760405163ec442f0560e01b815260006004820152602401610cb0565b61155660008383611870565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16610d1457604051631afcd79f60e31b815260040160405180910390fd5b611a85611a34565b6001600160a01b038116610da857604051631e4fbdf760e01b815260006004820152602401610cb0565b611ab7611a34565b6000805160206124438339815191527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace03611af18482612327565b5060048101610d668382612327565b6001600160a01b038216611b2a57604051634b637e8f60e11b815260006004820152602401610cb0565b61155682600083611870565b6000838302816000198587098281108382030391505080600003611b6d57838281611b6357611b636123e6565b0492505050610821565b808411611b8d5760405163227bc15360e01b815260040160405180910390fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60006002826003811115611c1057611c106123fc565b611c1a9190612412565b60ff166001149050919050565b600060208284031215611c3957600080fd5b81356001600160e01b03198116811461082157600080fd5b6000815180845260005b81811015611c7757602081850181015186830182015201611c5b565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006108216020830184611c51565b600060208284031215611cbc57600080fd5b5035919050565b80356001600160a01b0381168114611cda57600080fd5b919050565b60008060408385031215611cf257600080fd5b611cfb83611cc3565b946020939093013593505050565b600080600060608486031215611d1e57600080fd5b611d2784611cc3565b9250611d3560208501611cc3565b9150604084013590509250925092565b60008060408385031215611d5857600080fd5b82359150611d6860208401611cc3565b90509250929050565b600060208284031215611d8357600080fd5b61082182611cc3565b60006001600160401b0380861683528085166020840152506060604083015261108c6060830184611c51565b80356001600160401b0381168114611cda57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715611e0d57611e0d611dcf565b604052919050565b600082601f830112611e2657600080fd5b81356001600160401b03811115611e3f57611e3f611dcf565b611e52601f8201601f1916602001611de5565b818152846020838601011115611e6757600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611e9a57600080fd5b84359350611eaa60208601611db8565b9250611eb860408601611db8565b915060608501356001600160401b03811115611ed357600080fd5b611edf87828801611e15565b91505092959194509250565b600080600060608486031215611f0057600080fd5b611f0984611cc3565b925060208401356001600160401b0380821115611f2557600080fd5b611f3187838801611e15565b93506040860135915080821115611f4757600080fd5b50611f5486828701611e15565b9150509250925092565b600080600060608486031215611f7357600080fd5b611f7c84611db8565b9250611f8a60208501611db8565b915060408401356001600160401b03811115611fa557600080fd5b611f5486828701611e15565b600080600060608486031215611fc657600080fd5b83359250611fd660208501611cc3565b9150611fe460408501611cc3565b90509250925092565b600082601f830112611ffe57600080fd5b813560206001600160401b0382111561201957612019611dcf565b8160051b612028828201611de5565b928352848101820192828101908785111561204257600080fd5b83870192505b8483101561206157823582529183019190830190612048565b979650505050505050565b600080600080600060a0868803121561208457600080fd5b61208d86611cc3565b945061209b60208701611cc3565b935060408601356001600160401b03808211156120b757600080fd5b6120c389838a01611fed565b945060608801359150808211156120d957600080fd5b6120e589838a01611fed565b935060808801359150808211156120fb57600080fd5b5061210888828901611e15565b9150509295509295909350565b6000806040838503121561212857600080fd5b61213183611cc3565b9150611d6860208401611cc3565b60006020828403121561215157600080fd5b813561ffff8116811461082157600080fd5b600080600080600060a0868803121561217b57600080fd5b61218486611cc3565b945061219260208701611cc3565b9350604086013592506060860135915060808601356001600160401b038111156121bb57600080fd5b61210888828901611e15565b6000602082840312156121d957600080fd5b5051919050565b600181811c908216806121f457607f821691505b60208210810361221457634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561222c57600080fd5b8151801515811461082157600080fd5b6001600160a01b039390931683526020830191909152604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000600182016122855761228561225d565b5060010190565b808201808211156107d7576107d761225d565b6001600160a01b0394851681529290931660208301526040820152606081019190915260a06080820181905260009082015260c00190565b601f8211156112f1576000816000526020600020601f850160051c810160208610156123005750805b601f850160051c820191505b8181101561231f5782815560010161230c565b505050505050565b81516001600160401b0381111561234057612340611dcf565b6123548161234e84546121e0565b846122d7565b602080601f83116001811461238957600084156123715750858301515b600019600386901b1c1916600185901b17855561231f565b600085815260208120601f198616915b828110156123b857888601518255948401946001909101908401612399565b50858210156123d65787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b600060ff83168061243357634e487b7160e01b600052601260045260246000fd5b8060ff8416069150509291505056fe52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00a2646970667358221220e092b0d7acfe7d529dd8765346daad093bfd0a8001b51f02a9aeef75308ad2a364736f6c634300081700330000000000000000000000002c35aaf868e1693b7429ba8a80c81e87c5f5616900000000000000000000000031cc55d177824193a5fa2bf34da8afafbd366111000000000000000000000000af5588a571b42c7e50bd440d80f9bf94a4db94ee

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061027f5760003560e01c80638c5d591e1161015c578063bc197c81116100ce578063de0fdeea11610087578063de0fdeea146105df578063e30c397814610606578063edac5f3e1461060e578063ef8b30f714610593578063f23a6e6114610621578063f2fde38b1461064057600080fd5b8063bc197c811461055b578063c63d75b6146103f8578063c6e6f59214610593578063ce96cb77146105a6578063d905777e146105b9578063dd62ed3e146105cc57600080fd5b806395d89b411161012057806395d89b41146104f4578063a3d93e55146104fc578063a9059cbb1461050f578063b3d7f6b914610522578063b460af9414610535578063ba0876521461054857600080fd5b80638c5d591e146104785780638cdf4f161461049f5780638da5cb5b146104c657806390657147146104ce57806394bf804d146104e157600080fd5b806336eff2ec116101f5578063548a65bf116101b9578063548a65bf1461040d5780636e553f651461042f57806370a0823114610442578063715018a61461045557806376e1fb7e1461045d57806379ba50971461047057600080fd5b806336eff2ec1461038857806338d52e0f146103b65780633a4b66f1146103f0578063402d267d146103f85780634cdad506146102e857600080fd5b80630a28a477116102475780630a28a4771461030e57806318160ddd146103215780632000d0bf1461034857806323b872dd14610351578063313ce5671461036457806336130f001461037357600080fd5b806301e1d1141461028457806301ffc9a71461029f57806306fdde03146102d357806307a2d13a146102e8578063095ea7b3146102fb575b600080fd5b61028c610653565b6040519081526020015b60405180910390f35b6102c36102ad366004611c27565b6001600160e01b031916630271189760e51b1490565b6040519015158152602001610296565b6102db610707565b6040516102969190611c97565b61028c6102f6366004611caa565b6107ca565b6102c3610309366004611cdf565b6107dd565b61028c61031c366004611caa565b6107f5565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025461028c565b61028c60005481565b6102c361035f366004611d09565b610802565b60405160128152602001610296565b610386610381366004611caa565b610828565b005b6102c3610396366004611d45565b600260209081526000928352604080842090915290825290205460ff1681565b7f0000000000000000000000002c35aaf868e1693b7429ba8a80c81e87c5f561695b6040516001600160a01b039091168152602001610296565b610386610a10565b61028c610406366004611d71565b5060001990565b61042061041b366004611caa565b610beb565b60405161029693929190611d8c565b61028c61043d366004611d45565b610ca6565b61028c610450366004611d71565b610cda565b610386610d02565b61038661046b366004611e84565b610d16565b610386610d6c565b6103d87f0000000000000000000000002c35aaf868e1693b7429ba8a80c81e87c5f5616981565b6103d87f000000000000000000000000af5588a571b42c7e50bd440d80f9bf94a4db94ee81565b6103d8610db4565b6103866104dc366004611eeb565b610de9565b61028c6104ef366004611d45565b610f02565b6102db610f20565b61038661050a366004611f5e565b610f5f565b6102c361051d366004611cdf565b611022565b61028c610530366004611caa565b611030565b61028c610543366004611fb1565b61103d565b61028c610556366004611fb1565b611095565b61057a61056936600461206c565b63bc197c8160e01b95945050505050565b6040516001600160e01b03199091168152602001610296565b61028c6105a1366004611caa565b6110e4565b61028c6105b4366004611d71565b6110f1565b61028c6105c7366004611d71565b611106565b61028c6105da366004612115565b611111565b61028c7f00000000000000000000000031cc55d177824193a5fa2bf34da8afafbd36611181565b6103d861115b565b61038661061c36600461213f565b611184565b61057a61062f366004612163565b63f23a6e6160e01b95945050505050565b61038661064e366004611d71565b611210565b604051627eeac760e11b81523060048201527f00000000000000000000000031cc55d177824193a5fa2bf34da8afafbd36611160248201526000907f0000000000000000000000002c35aaf868e1693b7429ba8a80c81e87c5f561696001600160a01b03169062fdd58e90604401602060405180830381865afa1580156106de573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061070291906121c7565b905090565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace03805460609160008051602061244383398151915291610746906121e0565b80601f0160208091040260200160405190810160405280929190818152602001828054610772906121e0565b80156107bf5780601f10610794576101008083540402835291602001916107bf565b820191906000526020600020905b8154815290600101906020018083116107a257829003601f168201915b505050505091505090565b60006107d7826000611295565b92915050565b6000336107eb8185856112e4565b5060019392505050565b60006107d78260016112f6565b600033610810858285611336565b61081b858585611383565b60019150505b9392505050565b6000818152600160208181526040808420815160608101835281546001600160401b038082168352600160401b9091041693810193909352928301805492939291840191610875906121e0565b80601f01602080910402602001604051908101604052809291908181526020018280546108a1906121e0565b80156108ee5780601f106108c3576101008083540402835291602001916108ee565b820191906000526020600020905b8154815290600101906020018083116108d157829003601f168201915b505050505081525050905080602001516001600160401b031660000361092757604051637ae9080f60e11b815260040160405180910390fd5b80516001600160401b0316421015610952576040516379eb86a960e01b815260040160405180910390fd5b80602001516001600160401b03164211156109805760405163a4bf28db60e01b815260040160405180910390fd5b3361098a81611106565b6000036109aa5760405163fc6f967760e01b815260040160405180910390fd5b60008381526002602090815260408083206001600160a01b03851680855290835292819020805460ff191660011790555191825284917f14c49ee9310faeb1545e678feca92eeb5c55866c155b29be11fea2244f5ab09b910160405180910390a2505050565b6040516370a0823160e01b815230600482018190527f00000000000000000000000031cc55d177824193a5fa2bf34da8afafbd366111917f0000000000000000000000002c35aaf868e1693b7429ba8a80c81e87c5f56169906000907f000000000000000000000000af5588a571b42c7e50bd440d80f9bf94a4db94ee6001600160a01b0316906370a0823190602401602060405180830381865afa158015610abd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae191906121c7565b60405163095ea7b360e01b81526001600160a01b038481166004830152602482018390529192507f000000000000000000000000af5588a571b42c7e50bd440d80f9bf94a4db94ee9091169063095ea7b3906044016020604051808303816000875af1158015610b55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b79919061221a565b5060405163bf6eac2f60e01b81526001600160a01b03848116600483015285811660248301526044820183905283169063bf6eac2f906064015b600060405180830381600087803b158015610bcd57600080fd5b505af1158015610be1573d6000803e3d6000fd5b5050505050505050565b6001602081905260009182526040909120805491810180546001600160401b0380851694600160401b900416929190610c23906121e0565b80601f0160208091040260200160405190810160405280929190818152602001828054610c4f906121e0565b8015610c9c5780601f10610c7157610100808354040283529160200191610c9c565b820191906000526020600020905b815481529060010190602001808311610c7f57829003601f168201915b5050505050905083565b6000600019610cb9565b60405180910390fd5b6000610cc4856110e4565b9050610cd2338587846113e2565b949350505050565b6001600160a01b03166000908152600080516020612443833981519152602052604090205490565b610d0a6114ec565b610d14600061151e565b565b610d1e6114ec565b837fd8d6f294be96a42e8f3d8b73934ef4204d9124f32d2a906891bf2782a0c3f424848484604051610d5293929190611d8c565b60405180910390a2610d668484848461155a565b50505050565b3380610d7661115b565b6001600160a01b031614610da85760405163118cdaa760e01b81526001600160a01b0382166004820152602401610cb0565b610db18161151e565b50565b6000807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005b546001600160a01b031692915050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b0316600081158015610e2e5750825b90506000826001600160401b03166001148015610e4a5750303b155b905081158015610e58575080155b15610e765760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610ea057845460ff60401b1916600160401b1785555b610ea9886115dd565b610eb387876115ee565b8315610be157845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15050505050505050565b60006000196000610f1285611030565b9050610cd2338583886113e2565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace04805460609160008051602061244383398151915291610746906121e0565b610f676114ec565b826001600160401b0316421115610f9157604051632ca4094f60e21b815260040160405180910390fd5b816001600160401b0316836001600160401b031610610fc3576040516338af65f760e01b815260040160405180910390fd5b6000808154610fd190612273565b9091555060005460405181907fb86ac8ee844a183d8c2e43d3f9a629031e467ab9fd4a04e7b830e0d11c19cf1a9061100e90879087908790611d8c565b60405180910390a2610d668185858561155a565b6000336107eb818585611383565b60006107d7826001611295565b600080611049836110f1565b90508085111561107257828582604051633fa733bb60e21b8152600401610cb09392919061223c565b600061107d866107f5565b905061108c3386868985611600565b95945050505050565b6000806110a183611106565b9050808511156110ca57828582604051632e52afbb60e21b8152600401610cb09392919061223c565b60006110d5866107ca565b905061108c338686848a611600565b60006107d78260006112f6565b60006107d76110ff83610cda565b6000611295565b60006107d782610cda565b6001600160a01b0391821660009081527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace016020908152604080832093909416825291909152205490565b6000807f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00610dd9565b6040516314cbb82960e21b815261ffff8216600482015230602482018190526001600160a01b037f00000000000000000000000031cc55d177824193a5fa2bf34da8afafbd36611181811660448501526000196064850152927f0000000000000000000000002c35aaf868e1693b7429ba8a80c81e87c5f561699182169063532ee0a490608401610bb3565b6112186114ec565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b0319166001600160a01b038316908117825561125c610db4565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a35050565b60006108216112a2610653565b6112ad90600161228c565b7f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace02545b6112db90600161228c565b85919085611739565b6112f18383836001611788565b505050565b60006108216113237f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace025490565b61132e90600161228c565b6112d0610653565b60006113428484611111565b90506000198114610d66578181101561137457828183604051637dc7a0d960e11b8152600401610cb09392919061223c565b610d6684848484036000611788565b6001600160a01b0383166113ad57604051634b637e8f60e11b815260006004820152602401610cb0565b6001600160a01b0382166113d75760405163ec442f0560e01b815260006004820152602401610cb0565b6112f1838383611870565b604051637921219560e11b81526001600160a01b037f0000000000000000000000002c35aaf868e1693b7429ba8a80c81e87c5f56169169063f242432a9061145490879030907f00000000000000000000000031cc55d177824193a5fa2bf34da8afafbd36611190889060040161229f565b600060405180830381600087803b15801561146e57600080fd5b505af1158015611482573d6000803e3d6000fd5b50505050611490838261198d565b826001600160a01b0316846001600160a01b03167fdcbc1c05240f31ff3ad067ef1ee35ce4997762752e3a095284754544f4c709d784846040516114de929190918252602082015260400190565b60405180910390a350505050565b336114f5610db4565b6001600160a01b031614610d145760405163118cdaa760e01b8152336004820152602401610cb0565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b0319168155611556826119c3565b5050565b604080516060810182526001600160401b038086168252848116602080840191825283850186815260008a8152600192839052959095208451815493518516600160401b026fffffffffffffffffffffffffffffffff19909416941693909317919091178255925191929091908201906115d49082612327565b50505050505050565b6115e5611a34565b610db181611a7d565b6115f6611a34565b6115568282611aaf565b826001600160a01b0316856001600160a01b03161461162457611624838683611336565b61162e8382611b00565b826001600160a01b0316846001600160a01b0316866001600160a01b03167ffbde797d201c681b91056529119e0b02407c7bb96a4a2c75c01fc9667232c8db8585604051611686929190918252602082015260400190565b60405180910390a4604051637921219560e11b81526001600160a01b037f0000000000000000000000002c35aaf868e1693b7429ba8a80c81e87c5f56169169063f242432a9061170090309088907f00000000000000000000000031cc55d177824193a5fa2bf34da8afafbd36611190889060040161229f565b600060405180830381600087803b15801561171a57600080fd5b505af115801561172e573d6000803e3d6000fd5b505050505050505050565b600080611747868686611b36565b905061175283611bfa565b801561176e575060008480611769576117696123e6565b868809115b1561108c5761177e60018261228c565b9695505050505050565b6000805160206124438339815191526001600160a01b0385166117c15760405163e602df0560e01b815260006004820152602401610cb0565b6001600160a01b0384166117eb57604051634a1406b160e11b815260006004820152602401610cb0565b6001600160a01b0380861660009081526001830160209081526040808320938816835292905220839055811561186957836001600160a01b0316856001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258560405161186091815260200190565b60405180910390a35b5050505050565b6000805160206124438339815191526001600160a01b0384166118ac57818160020160008282546118a1919061228c565b9091555061190b9050565b6001600160a01b038416600090815260208290526040902054828110156118ec5784818460405163391434e360e21b8152600401610cb09392919061223c565b6001600160a01b03851660009081526020839052604090209083900390555b6001600160a01b038316611929576002810180548390039055611948565b6001600160a01b03831660009081526020829052604090208054830190555b826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516114de91815260200190565b6001600160a01b0382166119b75760405163ec442f0560e01b815260006004820152602401610cb0565b61155660008383611870565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3505050565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff16610d1457604051631afcd79f60e31b815260040160405180910390fd5b611a85611a34565b6001600160a01b038116610da857604051631e4fbdf760e01b815260006004820152602401610cb0565b611ab7611a34565b6000805160206124438339815191527f52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace03611af18482612327565b5060048101610d668382612327565b6001600160a01b038216611b2a57604051634b637e8f60e11b815260006004820152602401610cb0565b61155682600083611870565b6000838302816000198587098281108382030391505080600003611b6d57838281611b6357611b636123e6565b0492505050610821565b808411611b8d5760405163227bc15360e01b815260040160405180910390fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150509392505050565b60006002826003811115611c1057611c106123fc565b611c1a9190612412565b60ff166001149050919050565b600060208284031215611c3957600080fd5b81356001600160e01b03198116811461082157600080fd5b6000815180845260005b81811015611c7757602081850181015186830182015201611c5b565b506000602082860101526020601f19601f83011685010191505092915050565b6020815260006108216020830184611c51565b600060208284031215611cbc57600080fd5b5035919050565b80356001600160a01b0381168114611cda57600080fd5b919050565b60008060408385031215611cf257600080fd5b611cfb83611cc3565b946020939093013593505050565b600080600060608486031215611d1e57600080fd5b611d2784611cc3565b9250611d3560208501611cc3565b9150604084013590509250925092565b60008060408385031215611d5857600080fd5b82359150611d6860208401611cc3565b90509250929050565b600060208284031215611d8357600080fd5b61082182611cc3565b60006001600160401b0380861683528085166020840152506060604083015261108c6060830184611c51565b80356001600160401b0381168114611cda57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715611e0d57611e0d611dcf565b604052919050565b600082601f830112611e2657600080fd5b81356001600160401b03811115611e3f57611e3f611dcf565b611e52601f8201601f1916602001611de5565b818152846020838601011115611e6757600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215611e9a57600080fd5b84359350611eaa60208601611db8565b9250611eb860408601611db8565b915060608501356001600160401b03811115611ed357600080fd5b611edf87828801611e15565b91505092959194509250565b600080600060608486031215611f0057600080fd5b611f0984611cc3565b925060208401356001600160401b0380821115611f2557600080fd5b611f3187838801611e15565b93506040860135915080821115611f4757600080fd5b50611f5486828701611e15565b9150509250925092565b600080600060608486031215611f7357600080fd5b611f7c84611db8565b9250611f8a60208501611db8565b915060408401356001600160401b03811115611fa557600080fd5b611f5486828701611e15565b600080600060608486031215611fc657600080fd5b83359250611fd660208501611cc3565b9150611fe460408501611cc3565b90509250925092565b600082601f830112611ffe57600080fd5b813560206001600160401b0382111561201957612019611dcf565b8160051b612028828201611de5565b928352848101820192828101908785111561204257600080fd5b83870192505b8483101561206157823582529183019190830190612048565b979650505050505050565b600080600080600060a0868803121561208457600080fd5b61208d86611cc3565b945061209b60208701611cc3565b935060408601356001600160401b03808211156120b757600080fd5b6120c389838a01611fed565b945060608801359150808211156120d957600080fd5b6120e589838a01611fed565b935060808801359150808211156120fb57600080fd5b5061210888828901611e15565b9150509295509295909350565b6000806040838503121561212857600080fd5b61213183611cc3565b9150611d6860208401611cc3565b60006020828403121561215157600080fd5b813561ffff8116811461082157600080fd5b600080600080600060a0868803121561217b57600080fd5b61218486611cc3565b945061219260208701611cc3565b9350604086013592506060860135915060808601356001600160401b038111156121bb57600080fd5b61210888828901611e15565b6000602082840312156121d957600080fd5b5051919050565b600181811c908216806121f457607f821691505b60208210810361221457634e487b7160e01b600052602260045260246000fd5b50919050565b60006020828403121561222c57600080fd5b8151801515811461082157600080fd5b6001600160a01b039390931683526020830191909152604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000600182016122855761228561225d565b5060010190565b808201808211156107d7576107d761225d565b6001600160a01b0394851681529290931660208301526040820152606081019190915260a06080820181905260009082015260c00190565b601f8211156112f1576000816000526020600020601f850160051c810160208610156123005750805b601f850160051c820191505b8181101561231f5782815560010161230c565b505050505050565b81516001600160401b0381111561234057612340611dcf565b6123548161234e84546121e0565b846122d7565b602080601f83116001811461238957600084156123715750858301515b600019600386901b1c1916600185901b17855561231f565b600085815260208120601f198616915b828110156123b857888601518255948401946001909101908401612399565b50858210156123d65787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b600060ff83168061243357634e487b7160e01b600052601260045260246000fd5b8060ff8416069150509291505056fe52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00a2646970667358221220e092b0d7acfe7d529dd8765346daad093bfd0a8001b51f02a9aeef75308ad2a364736f6c63430008170033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000002c35aaf868e1693b7429ba8a80c81e87c5f5616900000000000000000000000031cc55d177824193a5fa2bf34da8afafbd366111000000000000000000000000af5588a571b42c7e50bd440d80f9bf94a4db94ee

-----Decoded View---------------
Arg [0] : erc1155StakedALT_ (address): 0x2C35AaF868E1693B7429Ba8a80c81E87C5F56169
Arg [1] : erc1155TokenID_ (uint256): 284297375613041730049947272464508251158296813841
Arg [2] : altToken_ (address): 0xAf5588a571B42C7E50Bd440D80F9bF94a4Db94eE

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000002c35aaf868e1693b7429ba8a80c81e87c5f56169
Arg [1] : 00000000000000000000000031cc55d177824193a5fa2bf34da8afafbd366111
Arg [2] : 000000000000000000000000af5588a571b42c7e50bd440d80f9bf94a4db94ee


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

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.