S Price: $0.597282 (+15.25%)

Contract

0xee7751bF946Da4cbb39A76fd8dD99a8872871a7F

Overview

S Balance

Sonic LogoSonic LogoSonic Logo0 S

S Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Factory

Compiler Version
v0.8.23+commit.f704f362

Optimization Enabled:
Yes with 200 runs

Other Settings:
shanghai EvmVersion
File 1 of 41 : Factory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "./base/Controllable.sol";
import "./libs/CommonLib.sol";
import "./libs/VaultTypeLib.sol";
import "./libs/FactoryLib.sol";
import "./libs/FactoryNamingLib.sol";
import "./libs/DeployerLib.sol";
import "./libs/VaultStatusLib.sol";
import "../interfaces/IFactory.sol";
import "../interfaces/IVault.sol";
import "../interfaces/IVaultProxy.sol";
import "../interfaces/IStrategy.sol";
import "../interfaces/IStrategyProxy.sol";
import "../interfaces/IVaultManager.sol";
import "../interfaces/IStrategyLogic.sol";

/// @notice Platform factory assembling vaults. Stores vault settings, strategy logic, farms.
///         Provides the opportunity to upgrade vaults and strategies.
/// Changelog:
///   1.1.0: getDeploymentKey fix for not farming strategies, strategyAvailableInitParams
///   1.1.1: reduced factory size. moved upgradeStrategyProxy, upgradeVaultProxy logic to FactoryLib
/// @author Alien Deployer (https://github.com/a17)
/// @author Jude (https://github.com/iammrjude)
/// @author JodsMigel (https://github.com/JodsMigel)
/// @author HCrypto7 (https://github.com/hcrypto7)
contract Factory is Controllable, ReentrancyGuardUpgradeable, IFactory {
    using SafeERC20 for IERC20;
    using EnumerableSet for EnumerableSet.Bytes32Set;

    //region ----- Constants -----

    /// @inheritdoc IControllable
    string public constant VERSION = "1.2.0";

    uint internal constant _WEEK = 60 * 60 * 24 * 7;

    uint internal constant _PERMIT_PER_WEEK = 1;

    // keccak256(abi.encode(uint256(keccak256("erc7201:stability.Factory")) - 1)) & ~bytes32(uint256(0xff));
    bytes32 private constant FACTORY_STORAGE_LOCATION =
        0x94b53192a2415b53b438d03f0efa946204c0118192627e3d5ed4ba034c9a0300;

    //endregion -- Constants -----

    //region ----- Data types -----

    struct DeployVaultAndStrategyVars {
        VaultConfig vaultConfig;
        bytes32 strategyIdHash;
        address platform;
        address[] assets;
        string[] assetsSymbols;
        string name;
        string specificName;
        string symbol;
        bytes32 deploymentKey;
        address buildingPermitToken;
        address buildingPayPerVaultToken;
        bool permit;
        uint vaultManagerTokenId;
    }

    //endregion -- Data types -----

    //region ----- Init -----

    function initialize(address platform_) public initializer {
        __Controllable_init(platform_);
        __ReentrancyGuard_init();
    }

    //endregion -- Init -----

    //region ----- Restricted actions -----

    /// @inheritdoc IFactory
    function setVaultConfig(VaultConfig memory vaultConfig_) external onlyOperator {
        FactoryStorage storage $ = _getStorage();
        if (FactoryLib.setVaultConfig($, vaultConfig_)) {
            _requireGovernanceOrMultisig();
        }
    }

    /// @inheritdoc IFactory
    //slither-disable-next-line reentrancy-no-eth
    function setStrategyLogicConfig(
        StrategyLogicConfig memory config,
        address developer
    ) external onlyOperator nonReentrant {
        FactoryStorage storage $ = _getStorage();
        bytes32 strategyIdHash = keccak256(bytes(config.id));
        StrategyLogicConfig storage oldConfig = $.strategyLogicConfig[strategyIdHash];
        if (oldConfig.implementation == address(0)) {
            uint tokenId = IStrategyLogic(IPlatform(platform()).strategyLogic()).mint(developer, config.id);
            config.tokenId = tokenId;
        } else {
            config.tokenId = oldConfig.tokenId;
        }
        $.strategyLogicConfig[strategyIdHash] = config;
        bool newStrategy = $.strategyLogicIdHashes.add(strategyIdHash);
        if (!newStrategy) {
            _requireGovernanceOrMultisig();
        }
        emit StrategyLogicConfigChanged(
            config.id, config.implementation, config.deployAllowed, config.upgradeAllowed, newStrategy
        );
    }

    /// @inheritdoc IFactory
    function setVaultStatus(address[] memory vaults, uint[] memory statuses) external onlyGovernanceOrMultisig {
        FactoryStorage storage $ = _getStorage();
        uint len = vaults.length;
        for (uint i; i < len; ++i) {
            $.vaultStatus[vaults[i]] = statuses[i];
            emit VaultStatus(vaults[i], statuses[i]);
        }
    }

    /// @inheritdoc IFactory
    function addFarms(Farm[] memory farms_) external onlyOperator {
        FactoryStorage storage $ = _getStorage();
        uint len = farms_.length;
        // nosemgrep
        for (uint i = 0; i < len; ++i) {
            $.farms.push(farms_[i]);
        }
        emit NewFarm(farms_);
    }

    /// @inheritdoc IFactory
    function updateFarm(uint id, Farm memory farm_) external onlyOperator {
        FactoryStorage storage $ = _getStorage();
        $.farms[id] = farm_;
        emit UpdateFarm(id, farm_);
    }

    /// @inheritdoc IFactory
    function setStrategyAvailableInitParams(
        string memory id,
        StrategyAvailableInitParams memory initParams
    ) external onlyOperator {
        FactoryStorage storage $ = _getStorage();
        bytes32 idHash = keccak256(abi.encodePacked(id));
        $.strategyAvailableInitParams[idHash] = initParams;
        emit SetStrategyAvailableInitParams(id, initParams.initAddresses, initParams.initNums, initParams.initTicks);
    }

    //endregion -- Restricted actions ----

    //region ----- User actions -----

    /// @inheritdoc IFactory
    //slither-disable-next-line cyclomatic-complexity reentrancy-benign
    function deployVaultAndStrategy(
        string memory vaultType,
        string memory strategyId,
        address[] memory vaultInitAddresses,
        uint[] memory vaultInitNums,
        address[] memory strategyInitAddresses,
        uint[] memory strategyInitNums,
        int24[] memory strategyInitTicks
    ) external nonReentrant returns (address vault, address strategy) {
        FactoryStorage storage $ = _getStorage();
        //slither-disable-next-line uninitialized-local
        DeployVaultAndStrategyVars memory vars;
        vars.vaultConfig = $.vaultConfig[keccak256(abi.encodePacked(vaultType))];
        if (vars.vaultConfig.implementation == address(0)) {
            revert VaultImplementationIsNotAvailable();
        }
        if (!vars.vaultConfig.deployAllowed) {
            revert VaultNotAllowedToDeploy();
        }
        vars.strategyIdHash = keccak256(bytes(strategyId));
        vars.platform = platform();
        vars.buildingPermitToken = IPlatform(vars.platform).buildingPermitToken();
        vars.buildingPayPerVaultToken = IPlatform(vars.platform).buildingPayPerVaultToken();

        StrategyLogicConfig storage config = $.strategyLogicConfig[vars.strategyIdHash];
        if (config.implementation == address(0)) {
            revert StrategyImplementationIsNotAvailable();
        }
        if (!config.deployAllowed) {
            revert StrategyLogicNotAllowedToDeploy();
        }

        if (vars.buildingPermitToken != address(0)) {
            uint balance = IERC721Enumerable(vars.buildingPermitToken).balanceOf(msg.sender);
            // nosemgrep
            for (uint i; i < balance; ++i) {
                //slither-disable-next-line calls-loop
                uint tokenId = IERC721Enumerable(vars.buildingPermitToken).tokenOfOwnerByIndex(msg.sender, i);
                uint epoch = block.timestamp / _WEEK;
                uint builtThisWeek = $.vaultsBuiltByPermitTokenId[epoch][tokenId];
                if (builtThisWeek < _PERMIT_PER_WEEK) {
                    $.vaultsBuiltByPermitTokenId[epoch][tokenId] = builtThisWeek + 1;
                    vars.permit = true;
                    break;
                }
            }
        }

        if (!vars.permit) {
            uint userBalance = IERC20(vars.buildingPayPerVaultToken).balanceOf(msg.sender);
            if (userBalance < vars.vaultConfig.buildingPrice) {
                revert YouDontHaveEnoughTokens(
                    userBalance, vars.vaultConfig.buildingPrice, IPlatform(vars.platform).buildingPayPerVaultToken()
                );
            }
            IERC20(vars.buildingPayPerVaultToken).safeTransferFrom(
                msg.sender, IPlatform(vars.platform).multisig(), vars.vaultConfig.buildingPrice
            );
        }

        {
            IVaultProxy vaultProxy = IVaultProxy(DeployerLib.deployVaultProxy());
            vaultProxy.initProxy(vaultType);
            IStrategyProxy strategyProxy = IStrategyProxy(DeployerLib.deployStrategyProxy());
            strategyProxy.initStrategyProxy(strategyId);
            vault = address(vaultProxy);
            strategy = address(strategyProxy);
        }

        {
            uint addressesLength = strategyInitAddresses.length;
            address[] memory initStrategyAddresses = new address[](2 + addressesLength);
            initStrategyAddresses[0] = vars.platform;
            initStrategyAddresses[1] = vault;
            // nosemgrep
            for (uint i = 2; i < 2 + addressesLength; ++i) {
                initStrategyAddresses[i] = strategyInitAddresses[i - 2];
            }

            IStrategy(strategy).initialize(initStrategyAddresses, strategyInitNums, strategyInitTicks);

            // 3 addresses for not using exchangeAsset and other addresses in unique deployment key
            vars.deploymentKey = getDeploymentKey(
                vaultType,
                strategyId,
                vaultInitAddresses,
                vaultInitNums,
                strategyInitAddresses,
                strategyInitNums,
                strategyInitTicks
            );
            if ($.deploymentKey[vars.deploymentKey] != address(0)) {
                revert SuchVaultAlreadyDeployed(vars.deploymentKey);
            }
        }

        (, vars.assets, vars.assetsSymbols, vars.specificName, vars.symbol) =
            getStrategyData(vaultType, strategy, vaultInitAddresses.length > 0 ? vaultInitAddresses[0] : address(0));
        vars.name = FactoryLib.getName(
            vaultType, strategyId, CommonLib.implode(vars.assetsSymbols, "-"), vars.specificName, vaultInitAddresses
        );

        vars.vaultManagerTokenId = IVaultManager(IPlatform(vars.platform).vaultManager()).mint(msg.sender, vault);

        IVault(vault).initialize(
            IVault.VaultInitializationData({
                platform: vars.platform,
                strategy: strategy,
                name: vars.name,
                symbol: vars.symbol,
                tokenId: vars.vaultManagerTokenId,
                vaultInitAddresses: vaultInitAddresses,
                vaultInitNums: vaultInitNums
            })
        );

        $.deployedVaults.push(vault);
        $.vaultStatus[vault] = VaultStatusLib.ACTIVE;
        $.isStrategy[strategy] = true;
        $.deploymentKey[vars.deploymentKey] = vault;

        FactoryLib.vaultPostDeploy(vars.platform, vault, vaultType, vaultInitAddresses, vaultInitNums);

        emit VaultAndStrategy(
            msg.sender,
            vaultType,
            strategyId,
            vault,
            strategy,
            vars.name,
            vars.symbol,
            vars.assets,
            vars.deploymentKey,
            vars.vaultManagerTokenId
        );
    }

    /// @inheritdoc IFactory
    function upgradeVaultProxy(address vault) external nonReentrant {
        FactoryStorage storage $ = _getStorage();
        if ($.vaultStatus[vault] != VaultStatusLib.ACTIVE) {
            revert NotActiveVault();
        }
        FactoryLib.upgradeVaultProxy($, vault);
    }

    /// @inheritdoc IFactory
    function upgradeStrategyProxy(address strategyProxy) external nonReentrant {
        FactoryStorage storage $ = _getStorage();
        if (!$.isStrategy[strategyProxy]) {
            revert NotStrategy();
        }
        FactoryLib.upgradeStrategyProxy($, strategyProxy);
    }

    /// @inheritdoc IFactory
    function setAliasName(address tokenAddress_, string memory aliasName_) external {
        FactoryStorage storage $ = _getStorage();
        $.aliasNames[tokenAddress_] = aliasName_;
        emit IFactory.AliasNameChanged(msg.sender, tokenAddress_, $.aliasNames[tokenAddress_]);
    }

    //endregion -- User actions ----

    //region ----- View functions -----

    /// @inheritdoc IFactory
    //slither-disable-next-line calls-loop
    function vaultTypes()
        external
        view
        returns (
            string[] memory vaultType,
            address[] memory implementation,
            bool[] memory deployAllowed,
            bool[] memory upgradeAllowed,
            uint[] memory buildingPrice,
            bytes32[] memory extra
        )
    {
        FactoryStorage storage $ = _getStorage();
        bytes32[] memory hashes = $.vaultTypeHashes.values();
        uint len = hashes.length;
        vaultType = new string[](len);
        implementation = new address[](len);
        deployAllowed = new bool[](len);
        upgradeAllowed = new bool[](len);
        buildingPrice = new uint[](len);
        extra = new bytes32[](len);
        // nosemgrep
        for (uint i; i < len; ++i) {
            VaultConfig memory config = $.vaultConfig[hashes[i]];
            vaultType[i] = config.vaultType;
            implementation[i] = config.implementation;
            deployAllowed[i] = config.deployAllowed;
            upgradeAllowed[i] = config.upgradeAllowed;
            buildingPrice[i] = config.buildingPrice;
            extra[i] = IVault(config.implementation).extra();
        }
    }

    /// @inheritdoc IFactory
    //slither-disable-next-line calls-loop
    function strategies()
        external
        view
        returns (
            string[] memory id,
            bool[] memory deployAllowed,
            bool[] memory upgradeAllowed,
            bool[] memory farming,
            uint[] memory tokenId,
            string[] memory tokenURI,
            bytes32[] memory extra
        )
    {
        FactoryStorage storage $ = _getStorage();
        bytes32[] memory hashes = $.strategyLogicIdHashes.values();
        uint len = hashes.length;
        id = new string[](len);
        deployAllowed = new bool[](len);
        upgradeAllowed = new bool[](len);
        farming = new bool[](len);
        tokenId = new uint[](len);
        tokenURI = new string[](len);
        extra = new bytes32[](len);
        IStrategyLogic strategyLogicNft = IStrategyLogic(IPlatform(platform()).strategyLogic());
        // nosemgrep
        for (uint i; i < len; ++i) {
            StrategyLogicConfig memory config = $.strategyLogicConfig[hashes[i]];
            id[i] = config.id;
            deployAllowed[i] = config.deployAllowed;
            upgradeAllowed[i] = config.upgradeAllowed;
            farming[i] = config.farming;
            tokenId[i] = config.tokenId;
            tokenURI[i] = strategyLogicNft.tokenURI(config.tokenId);
            extra[i] = IStrategy(config.implementation).extra();
        }
    }

    /// @inheritdoc IFactory
    //slither-disable-next-line unused-return
    function whatToBuild()
        external
        view
        returns (
            string[] memory desc,
            string[] memory vaultType,
            string[] memory strategyId,
            uint[10][] memory initIndexes,
            address[] memory vaultInitAddresses,
            uint[] memory vaultInitNums,
            address[] memory strategyInitAddresses,
            uint[] memory strategyInitNums,
            int24[] memory strategyInitTicks
        )
    {
        return FactoryLib.whatToBuild(platform());
    }

    /// @inheritdoc IFactory
    function deployedVaultsLength() external view returns (uint) {
        FactoryStorage storage $ = _getStorage();
        return $.deployedVaults.length;
    }

    /// @inheritdoc IFactory
    function deployedVaults() external view returns (address[] memory) {
        FactoryStorage storage $ = _getStorage();
        return $.deployedVaults;
    }

    /// @inheritdoc IFactory
    function deployedVault(uint id) external view returns (address) {
        FactoryStorage storage $ = _getStorage();
        return $.deployedVaults[id];
    }

    /// @inheritdoc IFactory
    function farmsLength() external view returns (uint) {
        FactoryStorage storage $ = _getStorage();
        return $.farms.length;
    }

    /// @inheritdoc IFactory
    function farms() external view returns (Farm[] memory) {
        FactoryStorage storage $ = _getStorage();
        return $.farms;
    }

    /// @inheritdoc IFactory
    function strategyLogicIdHashes() external view returns (bytes32[] memory) {
        FactoryStorage storage $ = _getStorage();
        return $.strategyLogicIdHashes.values();
    }

    /// @inheritdoc IFactory
    function farm(uint id) external view returns (Farm memory) {
        FactoryStorage storage $ = _getStorage();
        return $.farms[id];
    }

    /// @inheritdoc IFactory
    function getStrategyData(
        string memory vaultType,
        address strategyAddress,
        address bbAsset
    )
        public
        view
        returns (
            string memory strategyId,
            address[] memory assets,
            string[] memory assetsSymbols,
            string memory specificName,
            string memory vaultSymbol
        )
    {
        //slither-disable-next-line unused-return
        return FactoryNamingLib.getStrategyData(vaultType, strategyAddress, bbAsset, platform());
    }

    /// @inheritdoc IFactory
    function getExchangeAssetIndex(address[] memory assets) external view returns (uint) {
        //slither-disable-next-line unused-return
        return FactoryLib.getExchangeAssetIndex(platform(), assets);
    }

    /// @inheritdoc IFactory
    function getDeploymentKey(
        string memory vaultType,
        string memory strategyId,
        address[] memory initVaultAddresses,
        uint[] memory initVaultNums,
        address[] memory initStrategyAddresses,
        uint[] memory initStrategyNums,
        int24[] memory initStrategyTicks
    ) public pure returns (bytes32) {
        //slither-disable-next-line unused-return
        return FactoryLib.getDeploymentKey(
            vaultType,
            strategyId,
            initVaultAddresses,
            initVaultNums,
            initStrategyAddresses,
            initStrategyNums,
            initStrategyTicks,
            [1, 0, 1, 1, 0]
        );
    }

    /// @inheritdoc IFactory
    function deploymentKey(bytes32 deploymentKey_) external view returns (address) {
        FactoryStorage storage $ = _getStorage();
        return $.deploymentKey[deploymentKey_];
    }

    /// @inheritdoc IFactory
    function strategyLogicConfig(bytes32 idHash) external view returns (StrategyLogicConfig memory config) {
        FactoryStorage storage $ = _getStorage();
        config = $.strategyLogicConfig[idHash];
    }

    /// @inheritdoc IFactory
    function vaultConfig(bytes32 typeHash)
        external
        view
        returns (
            string memory vaultType,
            address implementation,
            bool deployAllowed,
            bool upgradeAllowed,
            uint buildingPrice
        )
    {
        FactoryStorage storage $ = _getStorage();
        VaultConfig memory vaultConfig_ = $.vaultConfig[typeHash];
        (vaultType, implementation, deployAllowed, upgradeAllowed, buildingPrice) = (
            vaultConfig_.vaultType,
            vaultConfig_.implementation,
            vaultConfig_.deployAllowed,
            vaultConfig_.upgradeAllowed,
            vaultConfig_.buildingPrice
        );
    }

    /// @inheritdoc IFactory
    function vaultStatus(address vault) external view returns (uint status) {
        FactoryStorage storage $ = _getStorage();
        status = $.vaultStatus[vault];
    }

    /// @inheritdoc IFactory
    function isStrategy(address address_) external view returns (bool) {
        return _getStorage().isStrategy[address_];
    }

    /// @inheritdoc IFactory
    function vaultsBuiltByPermitTokenId(
        uint week,
        uint builderPermitTokenId
    ) external view returns (uint vaultsBuilt) {
        return _getStorage().vaultsBuiltByPermitTokenId[week][builderPermitTokenId];
    }

    /// @inheritdoc IFactory
    function strategyAvailableInitParams(bytes32 idHash) external view returns (StrategyAvailableInitParams memory) {
        FactoryStorage storage $ = _getStorage();
        return $.strategyAvailableInitParams[idHash];
    }

    /// @inheritdoc IFactory
    function getAliasName(address tokenAddress_) public view returns (string memory) {
        FactoryStorage storage $ = _getStorage();
        return $.aliasNames[tokenAddress_];
    }

    //endregion -- View functions -----

    //region ----- Internal logic -----

    function _getStorage() private pure returns (FactoryStorage storage $) {
        //slither-disable-next-line assembly
        assembly {
            $.slot := FACTORY_STORAGE_LOCATION
        }
    }

    //endregion -- Internal logic -----
}

File 2 of 41 : 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 3 of 41 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.20;

import {IERC721} from "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 4 of 41 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuardUpgradeable is Initializable {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard
    struct ReentrancyGuardStorage {
        uint256 _status;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;

    function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) {
        assembly {
            $.slot := ReentrancyGuardStorageLocation
        }
    }

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        $._status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if ($._status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        $._status = ENTERED;
    }

    function _nonReentrantAfter() private {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        $._status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage();
        return $._status == ENTERED;
    }
}

File 5 of 41 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```solidity
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position is the index of the value in the `values` array plus 1.
        // Position 0 is used to mean a value is not in the set.
        mapping(bytes32 value => uint256) _positions;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._positions[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We cache the value's position to prevent multiple reads from the same storage slot
        uint256 position = set._positions[value];

        if (position != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 valueIndex = position - 1;
            uint256 lastIndex = set._values.length - 1;

            if (valueIndex != lastIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the lastValue to the index where the value to delete is
                set._values[valueIndex] = lastValue;
                // Update the tracked position of the lastValue (that was just moved)
                set._positions[lastValue] = position;
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the tracked position for the deleted slot
            delete set._positions[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._positions[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 6 of 41 : Controllable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "../libs/SlotsLib.sol";
import "../../interfaces/IControllable.sol";
import "../../interfaces/IPlatform.sol";

/// @dev Base core contract.
///      It store an immutable platform proxy address in the storage and provides access control to inherited contracts.
/// @author Alien Deployer (https://github.com/a17)
/// @author 0xhokugava (https://github.com/0xhokugava)
abstract contract Controllable is Initializable, IControllable, ERC165 {
    using SlotsLib for bytes32;

    string public constant CONTROLLABLE_VERSION = "1.0.0";
    bytes32 internal constant _PLATFORM_SLOT = bytes32(uint(keccak256("eip1967.controllable.platform")) - 1);
    bytes32 internal constant _CREATED_BLOCK_SLOT = bytes32(uint(keccak256("eip1967.controllable.created_block")) - 1);

    /// @dev Prevent implementation init
    constructor() {
        _disableInitializers();
    }

    /// @notice Initialize contract after setup it as proxy implementation
    ///         Save block.timestamp in the "created" variable
    /// @dev Use it only once after first logic setup
    /// @param platform_ Platform address
    //slither-disable-next-line naming-convention
    function __Controllable_init(address platform_) internal onlyInitializing {
        if (platform_ == address(0) || IPlatform(platform_).multisig() == address(0)) {
            revert IncorrectZeroArgument();
        }
        SlotsLib.set(_PLATFORM_SLOT, platform_); // syntax for forge coverage
        _CREATED_BLOCK_SLOT.set(block.number);
        emit ContractInitialized(platform_, block.timestamp, block.number);
    }

    modifier onlyGovernance() {
        _requireGovernance();
        _;
    }

    modifier onlyMultisig() {
        _requireMultisig();
        _;
    }

    modifier onlyGovernanceOrMultisig() {
        _requireGovernanceOrMultisig();
        _;
    }

    modifier onlyOperator() {
        _requireOperator();
        _;
    }

    modifier onlyFactory() {
        _requireFactory();
        _;
    }

    // ************* SETTERS/GETTERS *******************

    /// @inheritdoc IControllable
    function platform() public view override returns (address) {
        return _PLATFORM_SLOT.getAddress();
    }

    /// @inheritdoc IControllable
    function createdBlock() external view override returns (uint) {
        return _CREATED_BLOCK_SLOT.getUint();
    }

    /// @inheritdoc IERC165
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IControllable).interfaceId || super.supportsInterface(interfaceId);
    }

    function _requireGovernance() internal view {
        if (IPlatform(platform()).governance() != msg.sender) {
            revert NotGovernance();
        }
    }

    function _requireMultisig() internal view {
        if (!IPlatform(platform()).isOperator(msg.sender)) {
            revert NotMultisig();
        }
    }

    function _requireGovernanceOrMultisig() internal view {
        IPlatform _platform = IPlatform(platform());
        // nosemgrep
        if (_platform.governance() != msg.sender && _platform.multisig() != msg.sender) {
            revert NotGovernanceAndNotMultisig();
        }
    }

    function _requireOperator() internal view {
        if (!IPlatform(platform()).isOperator(msg.sender)) {
            revert NotOperator();
        }
    }

    function _requireFactory() internal view {
        if (IPlatform(platform()).factory() != msg.sender) {
            revert NotFactory();
        }
    }
}

File 7 of 41 : CommonLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./ConstantsLib.sol";

library CommonLib {
    function filterAddresses(
        address[] memory addresses,
        address addressToRemove
    ) external pure returns (address[] memory filteredAddresses) {
        uint len = addresses.length;
        uint newLen;
        // nosemgrep
        for (uint i; i < len; ++i) {
            if (addresses[i] != addressToRemove) {
                ++newLen;
            }
        }
        filteredAddresses = new address[](newLen);
        uint k;
        // nosemgrep
        for (uint i; i < len; ++i) {
            if (addresses[i] != addressToRemove) {
                filteredAddresses[k] = addresses[i];
                ++k;
            }
        }
    }

    function formatUsdAmount(uint amount) external pure returns (string memory formattedPrice) {
        uint dollars = amount / 10 ** 18;
        string memory priceStr;
        if (dollars >= 1000) {
            uint kDollars = dollars / 1000;
            uint kDollarsFraction = (dollars - kDollars * 1000) / 10;
            string memory delimiter = ".";
            if (kDollarsFraction < 10) {
                delimiter = ".0";
            }
            priceStr = string.concat(Strings.toString(kDollars), delimiter, Strings.toString(kDollarsFraction), "k");
        } else if (dollars >= 100) {
            priceStr = Strings.toString(dollars);
        } else {
            uint dollarsFraction = (amount - dollars * 10 ** 18) / 10 ** 14;
            if (dollarsFraction > 0) {
                string memory dollarsFractionDelimiter = ".";
                if (dollarsFraction < 10) {
                    dollarsFractionDelimiter = ".000";
                } else if (dollarsFraction < 100) {
                    dollarsFractionDelimiter = ".00";
                } else if (dollarsFraction < 1000) {
                    dollarsFractionDelimiter = ".0";
                }
                priceStr = string.concat(
                    Strings.toString(dollars), dollarsFractionDelimiter, Strings.toString(dollarsFraction)
                );
            } else {
                priceStr = Strings.toString(dollars);
            }
        }

        formattedPrice = string.concat("$", priceStr);
    }

    function formatApr(uint apr) external pure returns (string memory formattedApr) {
        uint aprInt = apr * 100 / ConstantsLib.DENOMINATOR;
        uint aprFraction = (apr - aprInt * ConstantsLib.DENOMINATOR / 100) / 10;
        string memory delimiter = ".";
        if (aprFraction < 10) {
            delimiter = ".0";
        }
        formattedApr = string.concat(Strings.toString(aprInt), delimiter, Strings.toString(aprFraction), "%");
    }

    function implodeSymbols(
        address[] memory assets,
        string memory delimiter
    ) external view returns (string memory outString) {
        return implode(getSymbols(assets), delimiter);
    }

    function implode(string[] memory strings, string memory delimiter) public pure returns (string memory outString) {
        uint len = strings.length;
        if (len == 0) {
            return "";
        }
        outString = strings[0];
        // nosemgrep
        for (uint i = 1; i < len; ++i) {
            outString = string.concat(outString, delimiter, strings[i]);
        }
        return outString;
    }

    function getSymbols(address[] memory assets) public view returns (string[] memory symbols) {
        uint len = assets.length;
        symbols = new string[](len);
        // nosemgrep
        for (uint i; i < len; ++i) {
            symbols[i] = IERC20Metadata(assets[i]).symbol();
        }
    }

    function bytesToBytes32(bytes memory b) external pure returns (bytes32 out) {
        // nosemgrep
        for (uint i; i < b.length; ++i) {
            out |= bytes32(b[i] & 0xFF) >> (i * 8);
        }
        // return out;
    }

    function bToHex(bytes memory buffer) external pure returns (string memory) {
        // Fixed buffer size for hexadecimal convertion
        bytes memory converted = new bytes(buffer.length * 2);
        bytes memory _base = "0123456789abcdef";
        uint baseLength = _base.length;
        // nosemgrep
        for (uint i; i < buffer.length; ++i) {
            converted[i * 2] = _base[uint8(buffer[i]) / baseLength];
            converted[i * 2 + 1] = _base[uint8(buffer[i]) % baseLength];
        }
        return string(abi.encodePacked(converted));
    }

    function shortId(string memory id) external pure returns (string memory) {
        uint words = 1;
        bytes memory idBytes = bytes(id);
        uint idBytesLength = idBytes.length;
        // nosemgrep
        for (uint i; i < idBytesLength; ++i) {
            if (keccak256(bytes(abi.encodePacked(idBytes[i]))) == keccak256(bytes(" "))) {
                ++words;
            }
        }
        bytes memory _shortId = new bytes(words);
        uint k = 1;
        _shortId[0] = idBytes[0];
        // nosemgrep
        for (uint i = 1; i < idBytesLength; ++i) {
            if (keccak256(bytes(abi.encodePacked(idBytes[i]))) == keccak256(bytes(" "))) {
                if (keccak256(bytes(abi.encodePacked(idBytes[i + 1]))) == keccak256(bytes("0"))) {
                    _shortId[k] = idBytes[i + 3];
                } else {
                    _shortId[k] = idBytes[i + 1];
                }
                ++k;
            }
        }
        return string(abi.encodePacked(_shortId));
    }

    function eq(string memory a, string memory b) external pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }

    function u2s(uint num) external pure returns (string memory) {
        return Strings.toString(num);
    }

    function i2s(int num) external pure returns (string memory) {
        return Strings.toString(num > 0 ? uint(num) : uint(-num));
    }
}

File 8 of 41 : VaultTypeLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

library VaultTypeLib {
    string internal constant COMPOUNDING = "Compounding";
    string internal constant REWARDING = "Rewarding";
    string internal constant REWARDING_MANAGED = "Rewarding Managed";
    string internal constant SPLITTER_MANAGED = "Splitter Managed";
    string internal constant SPLITTER_AUTO = "Splitter Automatic";
}

File 9 of 41 : FactoryLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "./CommonLib.sol";
import "./VaultTypeLib.sol";
import "../../interfaces/IPlatform.sol";
import "../../interfaces/IStrategy.sol";
import "../../interfaces/ISwapper.sol";
import "../../interfaces/IFactory.sol";
import "../../interfaces/IPriceReader.sol";
import "../../interfaces/IVault.sol";
import "../../interfaces/IRVault.sol";
import "../../interfaces/IVaultProxy.sol";
import "../../interfaces/IStrategyProxy.sol";

library FactoryLib {
    using SafeERC20 for IERC20;
    using EnumerableSet for EnumerableSet.Bytes32Set;

    uint public constant BOOST_REWARD_DURATION = 86400 * 30;

    struct WhatToBuildVars {
        bytes32[] strategyIdHashes;
        uint strategyIdHashesLen;
        IFactory.Farm[] farms;
        uint farmsLen;
        string[] vaultTypes;
        uint vaultTypesLen;
        // getVaultInitParamsVariants returns
        string[] vaultType;
        uint[] usedAddresses;
        uint[] usedNums;
        address[] allVaultInitAddresses;
        uint[] allVaultInitNums;
        uint allVaultInitAddressesIndex;
        uint allVaultInitNumsIndex;
        // strategy initVariants returns
        string[] strategyVariantDesc;
        uint strategyVariantDescLen;
        address[] allStrategyInitAddresses;
        uint[] allStrategyInitNums;
        int24[] allStrategyInitTicks;
        uint allStrategyInitAddressesIndex;
        uint allStrategyInitNumsIndex;
        uint allStrategyInitTicksIndex;
        // target vault init params
        address[] vaultInitAddresses;
        uint[] vaultInitNums;
        // target strategy init params
        address[] strategyInitAddresses;
        uint[] strategyInitNums;
        int24[] strategyInitTicks;
        uint usedStrategyInitAddresses;
        uint usedStrategyInitNums;
        uint usedStrategyInitTicks;
        // total results, used for counters too
        uint total;
        uint totalVaultInitAddresses;
        uint totalVaultInitNums;
        uint totalStrategyInitAddresses;
        uint totalStrategyInitNums;
        uint totalStrategyInitTicks;
        // counters and length
        uint i;
        uint j;
        uint c;
    }

    struct VaultPostDeployVars {
        bool isRewardingVaultType;
        uint minInitialBoostDuration;
        uint minInitialBoostPerDay;
    }

    struct GetVaultInitParamsVariantsVars {
        string[] vaultTypes;
        uint total;
        uint totalVaultInitAddresses;
        uint totalVaultInitNums;
        uint len;
    }

    function whatToBuild(address platform)
        external
        view
        returns (
            string[] memory desc,
            string[] memory vaultType,
            string[] memory strategyId,
            uint[10][] memory initIndexes,
            address[] memory vaultInitAddresses,
            uint[] memory vaultInitNums,
            address[] memory strategyInitAddresses,
            uint[] memory strategyInitNums,
            int24[] memory strategyInitTicks
        )
    {
        WhatToBuildVars memory vars;

        IFactory factory = IFactory(IPlatform(platform).factory());
        vars.strategyIdHashes = factory.strategyLogicIdHashes();
        vars.strategyIdHashesLen = vars.strategyIdHashes.length;
        vars.farms = factory.farms();
        vars.farmsLen = vars.farms.length;

        for (; vars.i < vars.strategyIdHashesLen; ++vars.i) {
            IFactory.StrategyLogicConfig memory strategyConfig;
            //slither-disable-next-line unused-return
            strategyConfig = factory.strategyLogicConfig(vars.strategyIdHashes[vars.i]);

            if (strategyConfig.deployAllowed) {
                (vars.vaultType, vars.usedAddresses, vars.usedNums, vars.allVaultInitAddresses, vars.allVaultInitNums) =
                    _getVaultInitParamsVariants(platform, strategyConfig.implementation);
                // nosemgrep
                vars.vaultTypesLen = vars.vaultType.length;

                vars.allVaultInitAddressesIndex = 0;
                vars.allVaultInitNumsIndex = 0;
                // nosemgrep
                for (uint k; k < vars.vaultTypesLen; ++k) {
                    vars.vaultInitAddresses = new address[](vars.usedAddresses[k]);
                    vars.vaultInitNums = new uint[](vars.usedNums[k]);
                    // nosemgrep
                    for (uint j; j < vars.usedAddresses[k]; ++j) {
                        vars.vaultInitAddresses[j] = vars.allVaultInitAddresses[vars.allVaultInitAddressesIndex];
                        ++vars.allVaultInitAddressesIndex;
                    }
                    // nosemgrep
                    for (uint j; j < vars.usedNums[k]; ++j) {
                        vars.vaultInitNums[j] = vars.allVaultInitNums[vars.allVaultInitNumsIndex];
                        ++vars.allVaultInitNumsIndex;
                    }

                    (
                        vars.strategyVariantDesc,
                        vars.allStrategyInitAddresses,
                        vars.allStrategyInitNums,
                        vars.allStrategyInitTicks
                    ) = IStrategy(strategyConfig.implementation).initVariants(platform);
                    vars.allStrategyInitAddressesIndex = 0;
                    vars.allStrategyInitNumsIndex = 0;
                    vars.allStrategyInitTicksIndex = 0;
                    // nosemgrep
                    uint len = vars.strategyVariantDesc.length;
                    for (vars.j = 0; vars.j < len; ++vars.j) {
                        // nosemgrep
                        uint size = vars.allStrategyInitAddresses.length / len;
                        vars.usedStrategyInitAddresses = 0;
                        vars.usedStrategyInitNums = 0;
                        vars.usedStrategyInitTicks = 0;
                        vars.strategyInitAddresses = new address[](size);
                        // nosemgrep
                        for (uint c; c < size; ++c) {
                            vars.strategyInitAddresses[c] =
                                vars.allStrategyInitAddresses[vars.allStrategyInitAddressesIndex];
                            ++vars.allStrategyInitAddressesIndex;
                            ++vars.usedStrategyInitAddresses;
                        }
                        // nosemgrep
                        size = vars.allStrategyInitNums.length / len;
                        vars.strategyInitNums = new uint[](size);
                        // nosemgrep
                        for (uint c; c < size; ++c) {
                            vars.strategyInitNums[c] = vars.allStrategyInitNums[vars.allStrategyInitNumsIndex];
                            ++vars.allStrategyInitNumsIndex;
                            ++vars.usedStrategyInitNums;
                        }
                        // nosemgrep
                        size = vars.allStrategyInitTicks.length / len;
                        vars.strategyInitTicks = new int24[](size);
                        // nosemgrep
                        for (uint c; c < size; ++c) {
                            vars.strategyInitTicks[c] = vars.allStrategyInitTicks[vars.allStrategyInitTicksIndex];
                            ++vars.allStrategyInitTicksIndex;
                            ++vars.usedStrategyInitTicks;
                        }

                        bytes32 _deploymentKey = getDeploymentKey(
                            vars.vaultType[k],
                            strategyConfig.id,
                            vars.vaultInitAddresses,
                            vars.vaultInitNums,
                            vars.strategyInitAddresses,
                            vars.strategyInitNums,
                            vars.strategyInitTicks,
                            [1, 0, 1, 1, 0]
                        );

                        if (factory.deploymentKey(_deploymentKey) == address(0)) {
                            ++vars.total;
                            vars.totalVaultInitAddresses += vars.usedAddresses[k];
                            vars.totalVaultInitNums += vars.usedNums[k];
                            vars.totalStrategyInitAddresses += vars.usedStrategyInitAddresses;
                            vars.totalStrategyInitNums += vars.usedStrategyInitNums;
                            vars.totalStrategyInitTicks += vars.usedStrategyInitTicks;
                        }
                    }
                }
            }
        }

        desc = new string[](vars.total);
        vaultType = new string[](vars.total);
        strategyId = new string[](vars.total);
        initIndexes = new uint[10][](vars.total);
        vaultInitAddresses = new address[](vars.totalVaultInitAddresses);
        vaultInitNums = new uint[](vars.totalVaultInitNums);
        strategyInitAddresses = new address[](vars.totalStrategyInitAddresses);
        strategyInitNums = new uint[](vars.totalStrategyInitNums);
        strategyInitTicks = new int24[](vars.totalStrategyInitTicks);

        vars.total = 0;
        vars.totalVaultInitAddresses = 0;
        vars.totalVaultInitNums = 0;
        vars.totalStrategyInitAddresses = 0;
        vars.totalStrategyInitNums = 0;
        vars.totalStrategyInitTicks = 0;
        for (vars.i = 0; vars.i < vars.strategyIdHashesLen; ++vars.i) {
            IFactory.StrategyLogicConfig memory strategyConfig;
            //slither-disable-next-line unused-return
            strategyConfig = factory.strategyLogicConfig(vars.strategyIdHashes[vars.i]);
            if (strategyConfig.deployAllowed) {
                (vars.vaultType, vars.usedAddresses, vars.usedNums, vars.allVaultInitAddresses, vars.allVaultInitNums) =
                    _getVaultInitParamsVariants(platform, strategyConfig.implementation);
                // nosemgrep
                vars.vaultTypesLen = vars.vaultType.length;

                vars.allVaultInitAddressesIndex = 0;
                vars.allVaultInitNumsIndex = 0;
                // nosemgrep
                for (uint k; k < vars.vaultTypesLen; ++k) {
                    vars.vaultInitAddresses = new address[](vars.usedAddresses[k]);
                    vars.vaultInitNums = new uint[](vars.usedNums[k]);
                    // nosemgrep
                    for (uint j; j < vars.usedAddresses[k]; ++j) {
                        vars.vaultInitAddresses[j] = vars.allVaultInitAddresses[vars.allVaultInitAddressesIndex];
                        ++vars.allVaultInitAddressesIndex;
                    }
                    // nosemgrep
                    for (uint j; j < vars.usedNums[k]; ++j) {
                        vars.vaultInitNums[j] = vars.allVaultInitNums[vars.allVaultInitNumsIndex];
                        ++vars.allVaultInitNumsIndex;
                    }

                    (
                        vars.strategyVariantDesc,
                        vars.allStrategyInitAddresses,
                        vars.allStrategyInitNums,
                        vars.allStrategyInitTicks
                    ) = IStrategy(strategyConfig.implementation).initVariants(platform);
                    vars.allStrategyInitAddressesIndex = 0;
                    vars.allStrategyInitNumsIndex = 0;
                    vars.allStrategyInitTicksIndex = 0;
                    // nosemgrep
                    vars.strategyVariantDescLen = vars.strategyVariantDesc.length;
                    for (vars.j = 0; vars.j < vars.strategyVariantDescLen; ++vars.j) {
                        // nosemgrep
                        uint size = vars.allStrategyInitAddresses.length / vars.strategyVariantDescLen;
                        vars.usedStrategyInitAddresses = 0;
                        vars.usedStrategyInitNums = 0;
                        vars.usedStrategyInitTicks = 0;
                        vars.strategyInitAddresses = new address[](size);
                        // nosemgrep
                        for (uint c; c < size; ++c) {
                            vars.strategyInitAddresses[c] =
                                vars.allStrategyInitAddresses[vars.allStrategyInitAddressesIndex];
                            ++vars.allStrategyInitAddressesIndex;
                            ++vars.usedStrategyInitAddresses;
                        }
                        // nosemgrep
                        size = vars.allStrategyInitNums.length / vars.strategyVariantDescLen;
                        vars.strategyInitNums = new uint[](size);
                        // nosemgrep
                        for (uint c; c < size; ++c) {
                            vars.strategyInitNums[c] = vars.allStrategyInitNums[vars.allStrategyInitNumsIndex];
                            ++vars.allStrategyInitNumsIndex;
                            ++vars.usedStrategyInitNums;
                        }
                        // nosemgrep
                        size = vars.allStrategyInitTicks.length / vars.strategyVariantDescLen;
                        vars.strategyInitTicks = new int24[](size);
                        // nosemgrep
                        for (uint c; c < size; ++c) {
                            vars.strategyInitTicks[c] = vars.allStrategyInitTicks[vars.allStrategyInitTicksIndex];
                            ++vars.allStrategyInitTicksIndex;
                            ++vars.usedStrategyInitTicks;
                        }

                        bytes32 _deploymentKey = getDeploymentKey(
                            vars.vaultType[k],
                            strategyConfig.id,
                            vars.vaultInitAddresses,
                            vars.vaultInitNums,
                            vars.strategyInitAddresses,
                            vars.strategyInitNums,
                            vars.strategyInitTicks,
                            [1, 0, 1, 1, 0]
                        );

                        if (factory.deploymentKey(_deploymentKey) == address(0)) {
                            desc[vars.total] = vars.strategyVariantDesc[vars.j];
                            vaultType[vars.total] = vars.vaultType[k];
                            strategyId[vars.total] = strategyConfig.id;

                            initIndexes[vars.total][0] = vars.totalVaultInitAddresses;
                            initIndexes[vars.total][1] = vars.totalVaultInitAddresses + vars.usedAddresses[k];
                            initIndexes[vars.total][2] = vars.totalVaultInitNums;
                            initIndexes[vars.total][3] = vars.totalVaultInitNums + vars.usedNums[k];
                            initIndexes[vars.total][4] = vars.totalStrategyInitAddresses;
                            initIndexes[vars.total][5] =
                                vars.totalStrategyInitAddresses + vars.usedStrategyInitAddresses;
                            initIndexes[vars.total][6] = vars.totalStrategyInitNums;
                            initIndexes[vars.total][7] = vars.totalStrategyInitNums + vars.usedStrategyInitNums;
                            initIndexes[vars.total][8] = vars.totalStrategyInitTicks;
                            initIndexes[vars.total][9] = vars.totalStrategyInitTicks + vars.usedStrategyInitTicks;
                            // nosemgrep
                            for (uint c; c < vars.usedAddresses[k]; ++c) {
                                vaultInitAddresses[vars.totalVaultInitAddresses + c] = vars.vaultInitAddresses[c];
                            }
                            // nosemgrep
                            for (uint c; c < vars.usedNums[k]; ++c) {
                                vaultInitNums[vars.totalVaultInitNums + c] = vars.vaultInitNums[c];
                            }
                            // nosemgrep
                            for (uint c; c < vars.usedStrategyInitAddresses; ++c) {
                                strategyInitAddresses[vars.totalStrategyInitAddresses + c] =
                                    vars.strategyInitAddresses[c];
                            }
                            // nosemgrep
                            for (uint c; c < vars.usedStrategyInitNums; ++c) {
                                strategyInitNums[vars.totalStrategyInitNums + c] = vars.strategyInitNums[c];
                            }
                            // nosemgrep
                            for (uint c; c < vars.usedStrategyInitTicks; ++c) {
                                strategyInitTicks[vars.totalStrategyInitTicks + c] = vars.strategyInitTicks[c];
                            }

                            ++vars.total;
                            vars.totalVaultInitAddresses += vars.usedAddresses[k];
                            vars.totalVaultInitNums += vars.usedNums[k];
                            vars.totalStrategyInitAddresses += vars.usedStrategyInitAddresses;
                            vars.totalStrategyInitNums += vars.usedStrategyInitNums;
                            vars.totalStrategyInitTicks += vars.usedStrategyInitTicks;
                        }
                    }
                }
            }
        }
    }

    function _getVaultInitParamsVariants(
        address platform,
        address strategyImplementation
    )
        internal
        view
        returns (
            string[] memory vaultType,
            uint[] memory usedAddresses,
            uint[] memory usedNums,
            address[] memory allVaultInitAddresses,
            uint[] memory allVaultInitNums
        )
    {
        GetVaultInitParamsVariantsVars memory vars;
        vars.vaultTypes = IStrategy(strategyImplementation).supportedVaultTypes();
        vars.len = vars.vaultTypes.length;
        //slither-disable-next-line unused-return
        (address[] memory allowedBBTokens,) = IPlatform(platform).allowedBBTokenVaultsFiltered();
        uint allowedBBTokensLen = allowedBBTokens.length;
        // nosemgrep
        for (uint i; i < vars.len; ++i) {
            if (CommonLib.eq(vars.vaultTypes[i], VaultTypeLib.COMPOUNDING)) {
                ++vars.total;
            } else if (
                CommonLib.eq(vars.vaultTypes[i], VaultTypeLib.REWARDING)
                    || CommonLib.eq(vars.vaultTypes[i], VaultTypeLib.REWARDING_MANAGED)
            ) {
                vars.total += allowedBBTokensLen;
                vars.totalVaultInitAddresses += allowedBBTokensLen;
            }
        }
        vaultType = new string[](vars.total);
        usedAddresses = new uint[](vars.total);
        usedNums = new uint[](vars.total);
        allVaultInitAddresses = new address[](vars.totalVaultInitAddresses);
        allVaultInitNums = new uint[](vars.totalVaultInitNums); // now its always 0, but function can be upgraded without changing interface

        // vaultType index, allVaultInitAddresses index, allVaultInitNums index
        uint[3] memory indexes;
        // nosemgrep
        for (uint i; i < vars.len; ++i) {
            if (CommonLib.eq(vars.vaultTypes[i], VaultTypeLib.COMPOUNDING)) {
                vaultType[indexes[0]] = vars.vaultTypes[i];
                ++indexes[0];
            } else if (
                CommonLib.eq(vars.vaultTypes[i], VaultTypeLib.REWARDING)
                    || CommonLib.eq(vars.vaultTypes[i], VaultTypeLib.REWARDING_MANAGED)
            ) {
                // nosemgrep
                for (uint k; k < allowedBBTokensLen; ++k) {
                    vaultType[indexes[0]] = vars.vaultTypes[i];
                    allVaultInitAddresses[indexes[1]] = allowedBBTokens[k];
                    usedAddresses[indexes[0]] = 1;
                    ++indexes[0];
                    ++indexes[1];
                }
            }
        }
    }

    function getExchangeAssetIndex(
        address platform,
        address[] memory assets
    ) external view returns (uint exchangeAssetIndex) {
        address targetExchangeAsset = IPlatform(platform).targetExchangeAsset();
        uint len = assets.length;
        // nosemgrep
        for (uint i; i < len; ++i) {
            if (assets[i] == targetExchangeAsset) {
                return i;
            }
        }

        exchangeAssetIndex = type(uint).max;
        uint minRoutes = type(uint).max;
        ISwapper swapper = ISwapper(IPlatform(platform).swapper());
        // nosemgrep
        for (uint i; i < len; ++i) {
            //slither-disable-next-line unused-return
            (ISwapper.PoolData[] memory route,) = swapper.buildRoute(assets[i], targetExchangeAsset);
            // nosemgrep
            uint routeLength = route.length;
            if (routeLength < minRoutes) {
                minRoutes = routeLength;
                exchangeAssetIndex = i;
            }
        }
        if (exchangeAssetIndex == type(uint).max) {
            revert ISwapper.NoRouteFound();
        }
        if (exchangeAssetIndex > type(uint).max) revert ISwapper.NoRoutesForAssets();
    }

    function getName(
        string memory vaultType,
        string memory id,
        string memory symbols,
        string memory specificName,
        address[] memory vaultInitAddresses
    ) public view returns (string memory name) {
        name = string.concat("Stability ", symbols, " ", id);
        if (keccak256(bytes(specificName)) != keccak256(bytes(""))) {
            name = string.concat(name, " ", specificName);
        }
        if (keccak256(bytes(vaultType)) == keccak256(bytes(VaultTypeLib.REWARDING))) {
            name = string.concat(name, " ", IERC20Metadata(vaultInitAddresses[0]).symbol(), " reward");
        }
    }

    function getDeploymentKey(
        string memory vaultType,
        string memory strategyId,
        address[] memory initVaultAddresses,
        uint[] memory initVaultNums,
        address[] memory initStrategyAddresses,
        uint[] memory initStrategyNums,
        int24[] memory initStrategyTicks,
        uint8[5] memory usedValuesForKey
    ) public pure returns (bytes32) {
        uint key = uint(keccak256(abi.encodePacked(vaultType)));
        unchecked {
            key += uint(keccak256(abi.encodePacked(strategyId)));
        }

        uint i;
        uint len;

        // process initVaultAddresses
        len = initVaultAddresses.length;
        if (len > usedValuesForKey[0]) {
            len = usedValuesForKey[0];
        }
        for (; i < len; ++i) {
            unchecked {
                key += uint(uint160(initVaultAddresses[i]));
            }
        }

        // process initVaultNums
        len = initVaultNums.length;
        if (len > usedValuesForKey[1]) {
            len = usedValuesForKey[1];
        }
        for (i = 0; i < len; ++i) {
            unchecked {
                key += initVaultNums[i];
            }
        }

        // process initStrategyAddresses
        len = initStrategyAddresses.length;
        if (len > usedValuesForKey[2]) {
            len = usedValuesForKey[2];
        }
        for (i = 0; i < len; ++i) {
            unchecked {
                key += uint(uint160(initStrategyAddresses[i]));
            }
        }

        // process initStrategyNums
        len = initStrategyNums.length;
        if (len > usedValuesForKey[3]) {
            len = usedValuesForKey[3];
        }
        for (i = 0; i < len; ++i) {
            unchecked {
                key += initStrategyNums[i];
            }
        }

        // process initStrategyTicks
        len = initStrategyTicks.length;
        if (len > usedValuesForKey[4]) {
            len = usedValuesForKey[4];
        }
        for (i = 0; i < len; ++i) {
            unchecked {
                key += initStrategyTicks[i] >= 0 ? uint(int(initStrategyTicks[i])) : uint(-int(initStrategyTicks[i]));
            }
        }

        return bytes32(key);
    }

    function vaultPostDeploy(
        address platform,
        address vault,
        string memory vaultType,
        address[] memory vaultInitAddresses,
        uint[] memory vaultInitNums
    ) external {
        VaultPostDeployVars memory vars;
        vars.isRewardingVaultType = CommonLib.eq(vaultType, VaultTypeLib.REWARDING);
        if (vars.isRewardingVaultType || CommonLib.eq(vaultType, VaultTypeLib.REWARDING_MANAGED)) {
            IPlatform(platform).useAllowedBBTokenVault(vaultInitAddresses[0]);
            IPriceReader priceReader = IPriceReader(IPlatform(platform).priceReader());
            vars.minInitialBoostDuration = IPlatform(platform).minInitialBoostDuration();
            vars.minInitialBoostPerDay = IPlatform(platform).minInitialBoostPerDay();
            vaultInitAddresses = IRVault(vault).rewardTokens();
            uint boostTokensLen = vaultInitAddresses.length - 1;
            uint totalInitialBoostUsdPerDay;
            // nosemgrep
            for (uint i; i < boostTokensLen; ++i) {
                address token = vaultInitAddresses[1 + i];
                uint durationSeconds = vars.isRewardingVaultType ? BOOST_REWARD_DURATION : vaultInitNums[1 + i];
                if (durationSeconds < vars.minInitialBoostDuration) {
                    revert IFactory.BoostDurationTooLow();
                }
                uint initialNotifyAmount =
                    vars.isRewardingVaultType ? vaultInitNums[i] : vaultInitNums[1 + boostTokensLen + i];
                //slither-disable-next-line unused-return
                (uint price,) = priceReader.getPrice(token);
                totalInitialBoostUsdPerDay += (
                    ((((initialNotifyAmount * 1e18) / 10 ** IERC20Metadata(token).decimals()) * price) / 1e18) * 86400
                ) / durationSeconds;
                if (initialNotifyAmount > 0) {
                    IERC20(token).safeTransferFrom(msg.sender, address(this), initialNotifyAmount);
                    IERC20(token).forceApprove(vault, initialNotifyAmount);
                    IRVault(vault).notifyTargetRewardAmount(1 + i, initialNotifyAmount);
                }
            }
            if (totalInitialBoostUsdPerDay == 0) {
                revert IFactory.BoostAmountIsZero();
            }
            if (totalInitialBoostUsdPerDay < vars.minInitialBoostPerDay) {
                revert IFactory.BoostAmountTooLow();
            }
        }
    }

    function setVaultConfig(
        IFactory.FactoryStorage storage $,
        IFactory.VaultConfig memory vaultConfig_
    ) external returns (bool needGovOrMultisigAccess) {
        string memory type_ = vaultConfig_.vaultType;
        bytes32 typeHash = keccak256(abi.encodePacked(type_));
        $.vaultConfig[typeHash] = vaultConfig_;
        bool newVaultType = $.vaultTypeHashes.add(typeHash);
        if (!newVaultType) {
            needGovOrMultisigAccess = true;
        }
        emit IFactory.VaultConfigChanged(
            type_, vaultConfig_.implementation, vaultConfig_.deployAllowed, vaultConfig_.upgradeAllowed, newVaultType
        );
    }

    function upgradeVaultProxy(IFactory.FactoryStorage storage $, address vault) external {
        IVaultProxy proxy = IVaultProxy(vault);
        bytes32 vaultTypeHash = proxy.vaultTypeHash();
        address oldImplementation = proxy.implementation();
        IFactory.VaultConfig memory tempVaultConfig = $.vaultConfig[vaultTypeHash];
        address newImplementation = tempVaultConfig.implementation;
        if (!tempVaultConfig.upgradeAllowed) {
            revert IFactory.UpgradeDenied(vaultTypeHash);
        }
        if (oldImplementation == newImplementation) {
            revert IFactory.AlreadyLastVersion(vaultTypeHash);
        }
        proxy.upgrade();
        emit IFactory.VaultProxyUpgraded(vault, oldImplementation, newImplementation);
    }

    function upgradeStrategyProxy(IFactory.FactoryStorage storage $, address strategyProxy) external {
        IStrategyProxy proxy = IStrategyProxy(strategyProxy);
        bytes32 idHash = proxy.strategyImplementationLogicIdHash();
        IFactory.StrategyLogicConfig storage config = $.strategyLogicConfig[idHash];
        address oldImplementation = proxy.implementation();
        address newImplementation = config.implementation;
        if (!config.upgradeAllowed) {
            revert IFactory.UpgradeDenied(idHash);
        }
        if (oldImplementation == newImplementation) {
            revert IFactory.AlreadyLastVersion(idHash);
        }
        proxy.upgrade();
        emit IFactory.StrategyProxyUpgraded(strategyProxy, oldImplementation, newImplementation);
    }
}

File 10 of 41 : FactoryNamingLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "./CommonLib.sol";
import "./VaultTypeLib.sol";
import "../../interfaces/IPlatform.sol";
import "../../interfaces/IStrategy.sol";
import "../../interfaces/IFactory.sol";

library FactoryNamingLib {
    function getStrategyData(
        string memory vaultType,
        address strategyAddress,
        address bbAsset,
        address platform
    )
        public
        view
        returns (
            string memory strategyId,
            address[] memory assets,
            string[] memory assetsSymbols,
            string memory specificName,
            string memory vaultSymbol
        )
    {
        IFactory factory = IFactory(IPlatform(platform).factory());
        strategyId = IStrategy(strategyAddress).strategyLogicId();
        assets = IStrategy(strategyAddress).assets();

        // Determine the length of the assets array
        uint assetsLength = assets.length;

        // Initialize assetsSymbols based on the length of assets
        assetsSymbols = new string[](assetsLength);

        for (uint i = 0; i < assetsLength; ++i) {
            // Use a ternary operator to determine the symbol to use
            string memory symbol = assets.length == 1
                ? CommonLib.getSymbols(assets)[0]
                : (
                    bytes(factory.getAliasName(assets[i])).length != 0
                        ? factory.getAliasName(assets[i])
                        : IERC20Metadata(assets[i]).symbol()
                );
            assetsSymbols[i] = symbol;
        }
        bool showSpecificInSymbol;
        (specificName, showSpecificInSymbol) = IStrategy(strategyAddress).getSpecificName();

        string memory bbAssetSymbol = bbAsset == address(0) ? "" : IERC20Metadata(bbAsset).symbol();

        vaultSymbol = _getShortSymbol(
            vaultType,
            strategyId,
            CommonLib.implode(assetsSymbols, ""),
            showSpecificInSymbol ? specificName : "",
            bbAssetSymbol
        );
    }

    function _getShortSymbol(
        string memory vaultType,
        string memory strategyLogicId,
        string memory symbols,
        string memory specificName,
        string memory bbAssetSymbol
    ) internal pure returns (string memory) {
        bytes memory vaultTypeBytes = bytes(vaultType);
        string memory prefix = "v";
        if (vaultTypeBytes[0] == "C") {
            prefix = "C";
        }
        if (CommonLib.eq(vaultType, VaultTypeLib.REWARDING)) {
            prefix = "R";
        }
        if (CommonLib.eq(vaultType, VaultTypeLib.REWARDING_MANAGED)) {
            prefix = "M";
        }
        string memory bbAssetStr = bytes(bbAssetSymbol).length > 0 ? string.concat("-", bbAssetSymbol) : "";
        return string.concat(
            prefix,
            "-",
            symbols,
            bbAssetStr,
            "-",
            CommonLib.shortId(strategyLogicId),
            bytes(specificName).length > 0 ? CommonLib.shortId(specificName) : ""
        );
    }
}

File 11 of 41 : DeployerLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "../proxy/VaultProxy.sol";
import "../proxy/StrategyProxy.sol";

library DeployerLib {
    function deployVaultProxy() external returns (address) {
        return address(new VaultProxy());
    }

    function deployStrategyProxy() external returns (address) {
        return address(new StrategyProxy());
    }
}

File 12 of 41 : VaultStatusLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

library VaultStatusLib {
    uint internal constant NOT_EXIST = 0;
    uint internal constant ACTIVE = 1;
    uint internal constant DEPRECATED = 2;
    uint internal constant EMERGENCY_EXIT = 3;
    uint internal constant DISABLED = 4;
    uint internal constant DEPOSITS_UNAVAILABLE = 5;
}

File 13 of 41 : IFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

/// @notice Creating vaults, upgrading vaults and strategies, vault list, farms and strategy logics management
/// @author Alien Deployer (https://github.com/a17)
/// @author Jude (https://github.com/iammrjude)
/// @author JodsMigel (https://github.com/JodsMigel)
/// @author HCrypto7 (https://github.com/hcrypto7)
interface IFactory {
    //region ----- Custom Errors -----

    error VaultImplementationIsNotAvailable();
    error VaultNotAllowedToDeploy();
    error StrategyImplementationIsNotAvailable();
    error StrategyLogicNotAllowedToDeploy();
    error YouDontHaveEnoughTokens(uint userBalance, uint requireBalance, address payToken);
    error SuchVaultAlreadyDeployed(bytes32 key);
    error NotActiveVault();
    error UpgradeDenied(bytes32 _hash);
    error AlreadyLastVersion(bytes32 _hash);
    error NotStrategy();
    error BoostDurationTooLow();
    error BoostAmountTooLow();
    error BoostAmountIsZero();

    //endregion ----- Custom Errors -----

    //region ----- Events -----

    event VaultAndStrategy(
        address indexed deployer,
        string vaultType,
        string strategyId,
        address vault,
        address strategy,
        string name,
        string symbol,
        address[] assets,
        bytes32 deploymentKey,
        uint vaultManagerTokenId
    );
    event StrategyProxyUpgraded(address proxy, address oldImplementation, address newImplementation);
    event VaultProxyUpgraded(address proxy, address oldImplementation, address newImplementation);
    event VaultConfigChanged(
        string type_, address implementation, bool deployAllowed, bool upgradeAllowed, bool newVaultType
    );
    event StrategyLogicConfigChanged(
        string id, address implementation, bool deployAllowed, bool upgradeAllowed, bool newStrategy
    );
    event VaultStatus(address indexed vault, uint newStatus);
    event NewFarm(Farm[] farms);
    event UpdateFarm(uint id, Farm farm);
    event SetStrategyAvailableInitParams(string id, address[] initAddresses, uint[] initNums, int24[] initTicks);
    event AliasNameChanged(address indexed operator, address indexed tokenAddress, string newAliasName);

    //endregion -- Events -----

    //region ----- Data types -----

    /// @custom:storage-location erc7201:stability.Factory
    struct FactoryStorage {
        /// @inheritdoc IFactory
        mapping(bytes32 typeHash => VaultConfig) vaultConfig;
        /// @inheritdoc IFactory
        mapping(bytes32 idHash => StrategyLogicConfig) strategyLogicConfig;
        /// @inheritdoc IFactory
        mapping(bytes32 deploymentKey => address vaultProxy) deploymentKey;
        /// @inheritdoc IFactory
        mapping(address vault => uint status) vaultStatus;
        /// @inheritdoc IFactory
        mapping(address address_ => bool isStrategy_) isStrategy;
        EnumerableSet.Bytes32Set vaultTypeHashes;
        EnumerableSet.Bytes32Set strategyLogicIdHashes;
        mapping(uint week => mapping(uint builderPermitTokenId => uint vaultsBuilt)) vaultsBuiltByPermitTokenId;
        address[] deployedVaults;
        Farm[] farms;
        /// @inheritdoc IFactory
        mapping(bytes32 idHash => StrategyAvailableInitParams) strategyAvailableInitParams;
        mapping(address tokenAddress => string aliasName) aliasNames;
    }

    struct VaultConfig {
        string vaultType;
        address implementation;
        bool deployAllowed;
        bool upgradeAllowed;
        uint buildingPrice;
    }

    struct StrategyLogicConfig {
        string id;
        address implementation;
        bool deployAllowed;
        bool upgradeAllowed;
        bool farming;
        uint tokenId;
    }

    struct Farm {
        uint status;
        address pool;
        string strategyLogicId;
        address[] rewardAssets;
        address[] addresses;
        uint[] nums;
        int24[] ticks;
    }

    struct StrategyAvailableInitParams {
        address[] initAddresses;
        uint[] initNums;
        int24[] initTicks;
    }

    //endregion -- Data types -----

    //region ----- View functions -----

    /// @notice All vaults deployed by the factory
    /// @return Vault proxy addresses
    function deployedVaults() external view returns (address[] memory);

    /// @notice Total vaults deployed
    function deployedVaultsLength() external view returns (uint);

    /// @notice Get vault by VaultManager tokenId
    /// @param id Vault array index. Same as tokenId of VaultManager NFT
    /// @return Address of VaultProxy
    function deployedVault(uint id) external view returns (address);

    /// @notice All farms known by the factory in current network
    function farms() external view returns (Farm[] memory);

    /// @notice Total farms known by the factory in current network
    function farmsLength() external view returns (uint);

    /// @notice Farm data by farm index
    /// @param id Index of farm
    function farm(uint id) external view returns (Farm memory);

    /// @notice Strategy logic settings
    /// @param idHash keccak256 hash of strategy logic string ID
    /// @return config Strategy logic settings
    function strategyLogicConfig(bytes32 idHash) external view returns (StrategyLogicConfig memory config);

    /// @notice All known strategies
    /// @return Array of keccak256 hashes of strategy logic string ID
    function strategyLogicIdHashes() external view returns (bytes32[] memory);

    // todo remove, use new function without calculating vault symbol on the fly for not initialized vaults
    // factory required that special functionally only internally, not for interface
    function getStrategyData(
        string memory vaultType,
        address strategyAddress,
        address bbAsset
    )
        external
        view
        returns (
            string memory strategyId,
            address[] memory assets,
            string[] memory assetsSymbols,
            string memory specificName,
            string memory vaultSymbol
        );

    /// @dev Get best asset of assets to be strategy exchange asset
    function getExchangeAssetIndex(address[] memory assets) external view returns (uint);

    /// @notice Deployment key of created vault
    /// @param deploymentKey_ Hash of concatenated unique vault and strategy initialization parameters
    /// @return Address of deployed vault
    function deploymentKey(bytes32 deploymentKey_) external view returns (address);

    /// @notice Calculating deployment key based on unique vault and strategy initialization parameters
    /// @param vaultType Vault type string
    /// @param strategyId Strategy logic Id string
    /// @param vaultInitAddresses Vault initizlization addresses for deployVaultAndStrategy method
    /// @param vaultInitNums Vault initizlization uint numbers for deployVaultAndStrategy method
    /// @param strategyInitAddresses Strategy initizlization addresses for deployVaultAndStrategy method
    /// @param strategyInitNums Strategy initizlization uint numbers for deployVaultAndStrategy method
    /// @param strategyInitTicks Strategy initizlization int24 ticks for deployVaultAndStrategy method
    function getDeploymentKey(
        string memory vaultType,
        string memory strategyId,
        address[] memory vaultInitAddresses,
        uint[] memory vaultInitNums,
        address[] memory strategyInitAddresses,
        uint[] memory strategyInitNums,
        int24[] memory strategyInitTicks
    ) external returns (bytes32);

    /// @notice Available variants of new vault for creating.
    /// The structure of the function's output values is complex,
    /// but after parsing them, the front end has all the data to generate a list of vaults to create.
    /// @return desc Descriptions of the strategy for making money
    /// @return vaultType Vault type strings. Output values are matched by index with previous array.
    /// @return strategyId Strategy logic ID strings. Output values are matched by index with previous array.
    /// @return initIndexes Map of start and end indexes in next 5 arrays. Output values are matched by index with previous array.
    ///                 [0] Start index in vaultInitAddresses
    ///                 [1] End index in vaultInitAddresses
    ///                 [2] Start index in vaultInitNums
    ///                 [3] End index in vaultInitNums
    ///                 [4] Start index in strategyInitAddresses
    ///                 [5] End index in strategyInitAddresses
    ///                 [6] Start index in strategyInitNums
    ///                 [7] End index in strategyInitNums
    ///                 [8] Start index in strategyInitTicks
    ///                 [9] End index in strategyInitTicks
    /// @return vaultInitAddresses Vault initizlization addresses for deployVaultAndStrategy method for all building variants.
    /// @return vaultInitNums Vault initizlization uint numbers for deployVaultAndStrategy method for all building variants.
    /// @return strategyInitAddresses Strategy initizlization addresses for deployVaultAndStrategy method for all building variants.
    /// @return strategyInitNums Strategy initizlization uint numbers for deployVaultAndStrategy method for all building variants.
    /// @return strategyInitTicks Strategy initizlization int24 ticks for deployVaultAndStrategy method for all building variants.
    function whatToBuild()
        external
        view
        returns (
            string[] memory desc,
            string[] memory vaultType,
            string[] memory strategyId,
            uint[10][] memory initIndexes,
            address[] memory vaultInitAddresses,
            uint[] memory vaultInitNums,
            address[] memory strategyInitAddresses,
            uint[] memory strategyInitNums,
            int24[] memory strategyInitTicks
        );

    /// @notice Governance and multisig can set a vault status other than Active - the default status.
    /// HardWorker only works with active vaults.
    /// @return status Constant from VaultStatusLib
    function vaultStatus(address vault) external view returns (uint status);

    /// @notice Check that strategy proxy deployed by the Factory
    /// @param address_ Address of contract
    /// @return This address is our strategy proxy
    function isStrategy(address address_) external view returns (bool);

    /// @notice How much vaults was built by builderPermitToken NFT tokenId in week
    /// @param week Week index (timestamp / (86400 * 7))
    /// @param builderPermitTokenId Token ID of buildingPermitToken NFT
    /// @return vaultsBuilt Vaults built
    function vaultsBuiltByPermitTokenId(
        uint week,
        uint builderPermitTokenId
    ) external view returns (uint vaultsBuilt);

    /// @notice Data on all factory strategies.
    /// The output values are matched by index in the arrays.
    /// @return id Strategy logic ID strings
    /// @return deployAllowed New vaults can be deployed
    /// @return upgradeAllowed Strategy can be upgraded
    /// @return farming It is farming strategy (earns farming/gauge rewards)
    /// @return tokenId Token ID of StrategyLogic NFT
    /// @return tokenURI StrategyLogic NFT tokenId metadata and on-chain image
    /// @return extra Strategy color, background color and other extra data
    function strategies()
        external
        view
        returns (
            string[] memory id,
            bool[] memory deployAllowed,
            bool[] memory upgradeAllowed,
            bool[] memory farming,
            uint[] memory tokenId,
            string[] memory tokenURI,
            bytes32[] memory extra
        );

    /// @notice Get config of vault type
    /// @param typeHash Keccak256 hash of vault type string
    /// @return vaultType Vault type string
    /// @return implementation Vault implementation address
    /// @return deployAllowed New vaults can be deployed
    /// @return upgradeAllowed Vaults can be upgraded
    /// @return buildingPrice Price of building new vault
    function vaultConfig(bytes32 typeHash)
        external
        view
        returns (
            string memory vaultType,
            address implementation,
            bool deployAllowed,
            bool upgradeAllowed,
            uint buildingPrice
        );

    /// @notice Data on all factory vault types
    /// The output values are matched by index in the arrays.
    /// @return vaultType Vault type string
    /// @return implementation Address of vault implemented logic
    /// @return deployAllowed New vaults can be deployed
    /// @return upgradeAllowed Vaults can be upgraded
    /// @return buildingPrice  Price of building new vault
    /// @return extra Vault type color, background color and other extra data
    function vaultTypes()
        external
        view
        returns (
            string[] memory vaultType,
            address[] memory implementation,
            bool[] memory deployAllowed,
            bool[] memory upgradeAllowed,
            uint[] memory buildingPrice,
            bytes32[] memory extra
        );

    /// @notice Initialization strategy params store
    function strategyAvailableInitParams(bytes32 idHash) external view returns (StrategyAvailableInitParams memory);

    /// @notice Retrieves the alias name associated with a given address
    /// @param tokenAddress_ The address to query for its alias name
    /// @return The alias name associated with the provided address
    function getAliasName(address tokenAddress_) external view returns (string memory);

    //endregion -- View functions -----

    //region ----- Write functions -----

    /// @notice Main method of the Factory - new vault creation by user.
    /// @param vaultType Vault type ID string
    /// @param strategyId Strategy logic ID string
    /// Different types of vaults and strategies have different lengths of input arrays.
    /// @param vaultInitAddresses Addresses for vault initialization
    /// @param vaultInitNums Numbers for vault initialization
    /// @param strategyInitAddresses Addresses for strategy initialization
    /// @param strategyInitNums Numbers for strategy initialization
    /// @param strategyInitTicks Ticks for strategy initialization
    /// @return vault Deployed VaultProxy address
    /// @return strategy Deployed StrategyProxy address
    function deployVaultAndStrategy(
        string memory vaultType,
        string memory strategyId,
        address[] memory vaultInitAddresses,
        uint[] memory vaultInitNums,
        address[] memory strategyInitAddresses,
        uint[] memory strategyInitNums,
        int24[] memory strategyInitTicks
    ) external returns (address vault, address strategy);

    /// @notice Upgrade vault proxy. Can be called by any address.
    /// @param vault Address of vault proxy for upgrade
    function upgradeVaultProxy(address vault) external;

    /// @notice Upgrade strategy proxy. Can be called by any address.
    /// @param strategy Address of strategy proxy for upgrade
    function upgradeStrategyProxy(address strategy) external;

    /// @notice Add farm to factory
    /// @param farms_ Settings and data required to work with the farm.
    function addFarms(Farm[] memory farms_) external;

    /// @notice Update farm
    /// @param id Farm index
    /// @param farm_ Settings and data required to work with the farm.
    function updateFarm(uint id, Farm memory farm_) external;

    /// @notice Initial addition or change of vault type settings.
    /// Operator can add new vault type. Governance or multisig can change existing vault type config.
    /// @param vaultConfig_ Vault type settings
    function setVaultConfig(VaultConfig memory vaultConfig_) external;

    /// @notice Initial addition or change of strategy logic settings.
    /// Operator can add new strategy logic. Governance or multisig can change existing logic config.
    /// @param config Strategy logic settings
    /// @param developer Strategy developer is receiver of minted StrategyLogic NFT on initial addition
    function setStrategyLogicConfig(StrategyLogicConfig memory config, address developer) external;

    /// @notice Governance and multisig can set a vault status other than Active - the default status.
    /// @param vaults Addresses of vault proxy
    /// @param statuses New vault statuses. Constant from VaultStatusLib
    function setVaultStatus(address[] memory vaults, uint[] memory statuses) external;

    /// @notice Initial addition or change of strategy available init params
    /// @param id Strategy ID string
    /// @param initParams Init params variations that will be parsed by strategy
    function setStrategyAvailableInitParams(string memory id, StrategyAvailableInitParams memory initParams) external;

    /// @notice Assigns a new alias name to a specific address
    /// @dev This function may require certain permissions to be called successfully.
    /// @param tokenAddress_ The address to assign an alias name to
    /// @param aliasName_ The alias name to assign to the given address
    function setAliasName(address tokenAddress_, string memory aliasName_) external;

    //endregion -- Write functions -----
}

File 14 of 41 : IVault.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "./IStrategy.sol";

/// @notice Vault core interface.
/// Derived implementations can be effective for building tokenized vaults with single or multiple underlying liquidity mining position.
/// Fungible, static non-fungible and actively re-balancing liquidity is supported, as well as single token liquidity provided to lending protocols.
/// Vaults can be used for active concentrated liquidity management and market making.
/// @author Jude (https://github.com/iammrjude)
/// @author JodsMigel (https://github.com/JodsMigel)
interface IVault is IERC165 {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       CUSTOM ERRORS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    error NotEnoughBalanceToPay();
    error FuseTrigger();
    error ExceedSlippage(uint mintToUser, uint minToMint);
    error ExceedSlippageExactAsset(address asset, uint mintToUser, uint minToMint);
    error ExceedMaxSupply(uint maxSupply);
    error NotEnoughAmountToInitSupply(uint mintAmount, uint initialShares);
    error WaitAFewBlocks();
    error StrategyZeroDeposit();
    error NotSupported();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                           EVENTS                           */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    event DepositAssets(address indexed account, address[] assets, uint[] amounts, uint mintAmount);
    event WithdrawAssets(
        address indexed sender, address indexed owner, address[] assets, uint sharesAmount, uint[] amountsOut
    );
    event HardWorkGas(uint gasUsed, uint gasCost, bool compensated);
    event DoHardWorkOnDepositChanged(bool oldValue, bool newValue);
    event MaxSupply(uint maxShares);
    event VaultName(string newName);
    event VaultSymbol(string newSymbol);
    event MintFees(
        uint vaultManagerReceiverFee,
        uint strategyLogicReceiverFee,
        uint ecosystemRevenueReceiverFee,
        uint multisigReceiverFee
    );

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         DATA TYPES                         */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @custom:storage-location erc7201:stability.VaultBase
    struct VaultBaseStorage {
        /// @dev Prevents manipulations with deposit and withdraw in short time.
        ///      For simplification we are setup new withdraw request on each deposit/transfer.
        mapping(address msgSender => uint blockNumber) withdrawRequests;
        /// @inheritdoc IVault
        IStrategy strategy;
        /// @inheritdoc IVault
        uint maxSupply;
        /// @inheritdoc IVault
        uint tokenId;
        /// @inheritdoc IVault
        bool doHardWorkOnDeposit;
        /// @dev Immutable vault type ID
        string _type;
        /// @dev Changed ERC20 name
        string changedName;
        /// @dev Changed ERC20 symbol
        string changedSymbol;
    }

    /// @title Vault Initialization Data
    /// @notice Data structure containing parameters for initializing a new vault.
    /// @dev This struct is commonly used as a parameter for the `initialize` function in vault contracts.
    /// @param platform Platform address providing access control, infrastructure addresses, fee settings, and upgrade capability.
    /// @param strategy Immutable strategy proxy used by the vault.
    /// @param name ERC20 name for the vault token.
    /// @param symbol ERC20 symbol for the vault token.
    /// @param tokenId NFT ID associated with the VaultManager.
    /// @param vaultInitAddresses Array of addresses used during vault initialization.
    /// @param vaultInitNums Array of uint values corresponding to initialization parameters.
    struct VaultInitializationData {
        address platform;
        address strategy;
        string name;
        string symbol;
        uint tokenId;
        address[] vaultInitAddresses;
        uint[] vaultInitNums;
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       VIEW FUNCTIONS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @notice Immutable vault type ID
    function vaultType() external view returns (string memory);

    /// @return uniqueInitAddresses Return required unique init addresses
    /// @return uniqueInitNums Return required unique init nums
    function getUniqueInitParamLength() external view returns (uint uniqueInitAddresses, uint uniqueInitNums);

    /// @notice Vault type extra data
    /// @return Vault type color, background color and other extra data
    function extra() external view returns (bytes32);

    /// @notice Immutable strategy proxy used by the vault
    /// @return Linked strategy
    function strategy() external view returns (IStrategy);

    /// @notice Max supply of shares in the vault.
    /// Since the starting share price is $1, this ceiling can be considered as an approximate TVL limit.
    /// @return Max total supply of vault
    function maxSupply() external view returns (uint);

    /// @dev VaultManager token ID. This tokenId earn feeVaultManager provided by Platform.
    function tokenId() external view returns (uint);

    /// @dev Trigger doHardwork on invest action. Enabled by default.
    function doHardWorkOnDeposit() external view returns (bool);

    /// @dev USD price of share with 18 decimals.
    ///      ONLY FOR OFF-CHAIN USE.
    ///      Not trusted vault share price can be manipulated.
    /// @return price_ Price of 1e18 shares with 18 decimals precision
    /// @return trusted True means oracle price, false means AMM spot price
    function price() external view returns (uint price_, bool trusted);

    /// @dev USD price of assets managed by strategy with 18 decimals
    ///      ONLY FOR OFF-CHAIN USE.
    ///      Not trusted TVL can be manipulated.
    /// @return tvl_ Total USD value of final assets in vault
    /// @return trusted True means TVL calculated based only on oracle prices, false means AMM spot price was used.
    function tvl() external view returns (uint tvl_, bool trusted);

    /// @dev Calculation of consumed amounts, shares amount and liquidity/underlying value for provided available amounts of strategy assets
    /// @param assets_ Assets suitable for vault strategy. Can be strategy assets, underlying asset or specific set of assets depending on strategy logic.
    /// @param amountsMax Available amounts of assets_ that user wants to invest in vault
    /// @return amountsConsumed Amounts of strategy assets that can be deposited by providing amountsMax
    /// @return sharesOut Amount of vault shares that will be minted
    /// @return valueOut Liquidity value or underlying token amount that will be received by the strategy
    function previewDepositAssets(
        address[] memory assets_,
        uint[] memory amountsMax
    ) external view returns (uint[] memory amountsConsumed, uint sharesOut, uint valueOut);

    /// @notice All available data on the latest declared APR (annual percentage rate)
    /// @return totalApr Total APR of investing money to vault. 18 decimals: 1e18 - +100% per year.
    /// @return strategyApr Strategy investmnt APR declared on last HardWork.
    /// @return assetsWithApr Assets with underlying APR
    /// @return assetsAprs Underlying APR of asset
    function getApr()
        external
        view
        returns (uint totalApr, uint strategyApr, address[] memory assetsWithApr, uint[] memory assetsAprs);

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      WRITE FUNCTIONS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Mint fee shares callback
    /// @param revenueAssets Assets returned by _claimRevenue function that was earned during HardWork
    /// @param revenueAmounts Assets amounts returned from _claimRevenue function that was earned during HardWork
    /// Only strategy can call this
    function hardWorkMintFeeCallback(address[] memory revenueAssets, uint[] memory revenueAmounts) external;

    /// @dev Deposit final assets (pool assets) to the strategy and minting of vault shares.
    ///      If the strategy interacts with a pool or farms through an underlying token, then it will be minted.
    ///      Emits a {DepositAssets} event with consumed amounts.
    /// @param assets_ Assets suitable for the strategy. Can be strategy assets, underlying asset or specific set of assets depending on strategy logic.
    /// @param amountsMax Available amounts of assets_ that user wants to invest in vault
    /// @param minSharesOut Slippage tolerance. Minimal shares amount which must be received by user.
    /// @param receiver Receiver of deposit. If receiver is zero address, receiver is msg.sender.
    function depositAssets(
        address[] memory assets_,
        uint[] memory amountsMax,
        uint minSharesOut,
        address receiver
    ) external;

    /// @dev Burning shares of vault and obtaining strategy assets.
    /// @param assets_ Assets suitable for the strategy. Can be strategy assets, underlying asset or specific set of assets depending on strategy logic.
    /// @param amountShares Shares amount for burning
    /// @param minAssetAmountsOut Slippage tolerance. Minimal amounts of strategy assets that user must receive.
    /// @return Amount of assets for withdraw. It's related to assets_ one-by-one.
    function withdrawAssets(
        address[] memory assets_,
        uint amountShares,
        uint[] memory minAssetAmountsOut
    ) external returns (uint[] memory);

    /// @dev Burning shares of vault and obtaining strategy assets.
    /// @param assets_ Assets suitable for the strategy. Can be strategy assets, underlying asset or specific set of assets depending on strategy logic.
    /// @param amountShares Shares amount for burning
    /// @param minAssetAmountsOut Slippage tolerance. Minimal amounts of strategy assets that user must receive.
    /// @param receiver Receiver of assets
    /// @param owner Owner of vault shares
    /// @return Amount of assets for withdraw. It's related to assets_ one-by-one.
    function withdrawAssets(
        address[] memory assets_,
        uint amountShares,
        uint[] memory minAssetAmountsOut,
        address receiver,
        address owner
    ) external returns (uint[] memory);

    /// @dev Setting of vault capacity
    /// @param maxShares If totalSupply() exceeds this value, deposits will not be possible
    function setMaxSupply(uint maxShares) external;

    /// @dev If activated will call doHardWork on strategy on some deposit actions
    /// @param value HardWork on deposit is enabled
    function setDoHardWorkOnDeposit(bool value) external;

    /// @notice Initialization function for the vault.
    /// @dev This function is usually called by the Factory during the creation of a new vault.
    /// @param vaultInitializationData Data structure containing parameters for vault initialization.
    function initialize(VaultInitializationData memory vaultInitializationData) external;

    /// @dev Calling the strategy HardWork by operator with optional compensation for spent gas from the vault balance
    function doHardWork() external;

    /// @dev Changing ERC20 name of vault
    function setName(string calldata newName) external;

    /// @dev Changing ERC20 symbol of vault
    function setSymbol(string calldata newSymbol) external;
}

File 15 of 41 : IVaultProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

/// @dev Interface of proxy contract for a vault implementation
interface IVaultProxy {
    //region ----- Custom Errors -----
    error ProxyForbidden();
    //endregion -- Custom Errors -----

    /// @notice Initialize vault proxy by Factory
    /// @param type_ Vault type ID string
    function initProxy(string memory type_) external;

    /// @notice Upgrade vault implementation if available and allowed
    /// Anyone can execute vault upgrade
    function upgrade() external;

    /// @notice Current vault implementation
    /// @return Address of vault implementation contract
    function implementation() external view returns (address);

    /// @notice Vault type hash
    /// @return keccan256 hash of vault type ID string
    function vaultTypeHash() external view returns (bytes32);
}

File 16 of 41 : IStrategy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/// @dev Core interface of strategy logic
interface IStrategy is IERC165 {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                           EVENTS                           */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    event HardWork(
        uint apr, uint compoundApr, uint earned, uint tvl, uint duration, uint sharePrice, uint[] assetPrices
    );
    event ExtractFees(
        uint vaultManagerReceiverFee,
        uint strategyLogicReceiverFee,
        uint ecosystemRevenueReceiverFee,
        uint multisigReceiverFee
    );

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       CUSTOM ERRORS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    error NotReadyForHardWork();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         DATA TYPES                         */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @custom:storage-location erc7201:stability.StrategyBase
    struct StrategyBaseStorage {
        /// @inheritdoc IStrategy
        address vault;
        /// @inheritdoc IStrategy
        uint total;
        /// @inheritdoc IStrategy
        uint lastHardWork;
        /// @inheritdoc IStrategy
        uint lastApr;
        /// @inheritdoc IStrategy
        uint lastAprCompound;
        /// @inheritdoc IStrategy
        address[] _assets;
        /// @inheritdoc IStrategy
        address _underlying;
        string _id;
        uint _exchangeAssetIndex;
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       VIEW FUNCTIONS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Strategy logic string ID
    function strategyLogicId() external view returns (string memory);

    /// @dev Extra data
    /// @return 0-2 bytes - strategy color
    ///         3-5 bytes - strategy background color
    ///         6-31 bytes - free
    function extra() external view returns (bytes32);

    /// @dev Types of vault that supported by strategy implementation
    /// @return types Vault type ID strings
    function supportedVaultTypes() external view returns (string[] memory types);

    /// @dev Linked vault address
    function vault() external view returns (address);

    /// @dev Final assets that strategy invests
    function assets() external view returns (address[] memory);

    /// @notice Final assets and amounts that strategy manages
    function assetsAmounts() external view returns (address[] memory assets_, uint[] memory amounts_);

    /// @notice Priced invested assets proportions
    /// @return proportions Proportions of assets with 18 decimals. Min is 0, max is 1e18.
    function getAssetsProportions() external view returns (uint[] memory proportions);

    /// @notice Underlying token address
    /// @dev Can be used for liquidity farming strategies where AMM has fungible liquidity token (Solidly forks, etc),
    ///      for concentrated liquidity tokenized vaults (Gamma, G-UNI etc) and for other needs.
    /// @return Address of underlying token or zero address if no underlying in strategy
    function underlying() external view returns (address);

    /// @dev Balance of liquidity token or liquidity value
    function total() external view returns (uint);

    /// @dev Last HardWork time
    /// @return Timestamp
    function lastHardWork() external view returns (uint);

    /// @dev Last APR of earned USD amount registered by HardWork
    ///      ONLY FOR OFF-CHAIN USE.
    ///      Not trusted asset price can be manipulated.
    /// @return APR with 18 decimals. 1e18 - 100%.
    function lastApr() external view returns (uint);

    /// @dev Last APR of compounded assets registered by HardWork.
    ///      Can be used on-chain.
    /// @return APR with 18 decimals. 1e18 - 100%.
    function lastAprCompound() external view returns (uint);

    /// @notice Calculation of consumed amounts and liquidity/underlying value for provided strategy assets and amounts.
    /// @param assets_ Strategy assets or part of them, if necessary
    /// @param amountsMax Amounts of specified assets available for investing
    /// @return amountsConsumed Cosumed amounts of assets when investing
    /// @return value Liquidity value or underlying token amount minted when investing
    function previewDepositAssets(
        address[] memory assets_,
        uint[] memory amountsMax
    ) external view returns (uint[] memory amountsConsumed, uint value);

    /// @notice Write version of previewDepositAssets
    /// @param assets_ Strategy assets or part of them, if necessary
    /// @param amountsMax Amounts of specified assets available for investing
    /// @return amountsConsumed Cosumed amounts of assets when investing
    /// @return value Liquidity value or underlying token amount minted when investing
    function previewDepositAssetsWrite(
        address[] memory assets_,
        uint[] memory amountsMax
    ) external returns (uint[] memory amountsConsumed, uint value);

    /// @notice All strategy revenue (pool fees, farm rewards etc) that not claimed by strategy yet
    /// @return assets_ Revenue assets
    /// @return amounts Amounts. Index of asset same as in previous array.
    function getRevenue() external view returns (address[] memory assets_, uint[] memory amounts);

    /// @notice Optional specific name of investing strategy, underyling type, setup variation etc
    /// @return name Empty string or specific name
    /// @return showInVaultSymbol Show specific in linked vault symbol
    function getSpecificName() external view returns (string memory name, bool showInVaultSymbol);

    /// @notice Variants pf strategy initializations with description of money making mechanic.
    /// As example, if strategy need farm, then number of variations is number of available farms.
    /// If CAMM strategy have set of available widths (tick ranges), then number of variations is number of available farms.
    /// If both example conditions are met then total number or variations = total farms * total widths.
    /// @param platform_ Need this param because method called when strategy implementation is not initialized
    /// @return variants Descriptions of the strategy for making money
    /// @return addresses Init strategy addresses. Indexes for each variants depends of copmpared arrays lengths.
    /// @return nums Init strategy numbers. Indexes for each variants depends of copmpared arrays lengths.
    /// @return ticks Init strategy ticks. Indexes for each variants depends of copmpared arrays lengths.
    function initVariants(address platform_)
        external
        view
        returns (string[] memory variants, address[] memory addresses, uint[] memory nums, int24[] memory ticks);

    /// @notice How does the strategy make money?
    /// @return Description in free form
    function description() external view returns (string memory);

    /// @notice Is HardWork on vault deposits can be enabled
    function isHardWorkOnDepositAllowed() external view returns (bool);

    /// @notice Is HardWork can be executed
    function isReadyForHardWork() external view returns (bool);

    /// @notice Strategy not need to process revenue on HardWorks
    function autoCompoundingByUnderlyingProtocol() external view returns (bool);

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      WRITE FUNCTIONS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev A single universal initializer for all strategy implementations.
    /// @param addresses All addresses that strategy requires for initialization. Min array length is 2.
    ///        addresses[0]: platform (required)
    ///        addresses[1]: vault (required)
    ///        addresses[2]: initStrategyAddresses[0] (optional)
    ///        addresses[3]: initStrategyAddresses[1] (optional)
    ///        addresses[n]: initStrategyAddresses[n - 2] (optional)
    /// @param nums All uint values that strategy requires for initialization. Min array length is 0.
    /// @param ticks All int24 values that strategy requires for initialization. Min array length is 0.
    function initialize(address[] memory addresses, uint[] memory nums, int24[] memory ticks) external;

    /// @notice Invest strategy assets. Amounts of assets must be already on strategy contract balance.
    /// Only vault can call this.
    /// @param amounts Anounts of strategy assets
    /// @return value Liquidity value or underlying token amount
    function depositAssets(uint[] memory amounts) external returns (uint value);

    /// @notice Invest underlying asset. Asset must be already on strategy contract balance.
    /// Only vault can call this.
    /// @param amount Amount of underlying asset to invest
    /// @return amountsConsumed Cosumed amounts of invested assets
    function depositUnderlying(uint amount) external returns (uint[] memory amountsConsumed);

    /// @dev For specified amount of shares and assets_, withdraw strategy assets from farm/pool/staking and send to receiver if possible
    /// Only vault can call this.
    /// @param assets_ Here we give the user a choice of assets to withdraw if strategy support it
    /// @param value Part of strategy total value to withdraw
    /// @param receiver User address
    /// @return amountsOut Amounts of assets sent to user
    function withdrawAssets(
        address[] memory assets_,
        uint value,
        address receiver
    ) external returns (uint[] memory amountsOut);

    /// @notice Wothdraw underlying invested and send to receiver
    /// Only vault can call this.
    /// @param amount Ampunt of underlying asset to withdraw
    /// @param receiver User of vault which withdraw underlying from the vault
    function withdrawUnderlying(uint amount, address receiver) external;

    /// @dev For specified amount of shares, transfer strategy assets from contract balance and send to receiver if possible
    /// This method is called by vault w/o underlying on triggered fuse mode.
    /// Only vault can call this.
    /// @param amount Ampunt of liquidity value that user withdraw
    /// @param totalAmount Total amount of strategy liquidity
    /// @param receiver User of vault which withdraw assets
    /// @return amountsOut Amounts of strategy assets sent to user
    function transferAssets(
        uint amount,
        uint totalAmount,
        address receiver
    ) external returns (uint[] memory amountsOut);

    /// @notice Execute HardWork
    /// During HardWork strategy claiming revenue and processing it.
    /// Only vault can call this.
    function doHardWork() external;

    /// @notice Emergency stop investing by strategy, withdraw liquidity without rewards.
    /// This action triggers FUSE mode.
    /// Only governance or multisig can call this.
    function emergencyStopInvesting() external;
}

File 17 of 41 : IStrategyProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

/// @dev Interface of proxy contract for a strategy implementation
interface IStrategyProxy {
    /// @notice Initialize strategy proxy by Factory
    /// @param id Strategy logic ID string
    function initStrategyProxy(string memory id) external;

    /// @notice Upgrade strategy implementation if available and allowed
    /// Anyone can execute strategy upgrade
    function upgrade() external;

    /// @notice Current strategy implementation
    /// @return Address of strategy implementation contract
    function implementation() external view returns (address);

    /// @notice Strategy logic hash
    /// @return keccan256 hash of strategy logic ID string
    function strategyImplementationLogicIdHash() external view returns (bytes32);
}

File 18 of 41 : IVaultManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";

/// @notice The vaults are assembled at the factory by users through UI.
///         Deployment rights of a vault are tokenized in VaultManager NFT.
///         The holders of these tokens receive a share of the vault revenue and can manage vault if possible.
/// @dev Rewards transfers to token owner or revenue receiver address managed by token owner.
/// @author Alien Deployer (https://github.com/a17)
/// @author Jude (https://github.com/iammrjude)
/// @author JodsMigel (https://github.com/JodsMigel)
interface IVaultManager is IERC721Metadata {
    //region ----- Events -----
    event ChangeVaultParams(uint tokenId, address[] addresses, uint[] nums);
    event SetRevenueReceiver(uint tokenId, address receiver);
    //endregion -- Events -----

    struct VaultData {
        // vault
        uint tokenId;
        address vault;
        string vaultType;
        string name;
        string symbol;
        string[] assetsSymbols;
        string[] rewardAssetsSymbols;
        uint sharePrice;
        uint tvl;
        uint totalApr;
        bytes32 vaultExtra;
        // strategy
        uint strategyTokenId;
        string strategyId;
        string strategySpecific;
        uint strategyApr;
        bytes32 strategyExtra;
    }

    //region ----- View functions -----

    /// @notice Vault address managed by token
    /// @param tokenId ID of NFT. Starts from 0 and increments on mints.
    /// @return vault Address of vault proxy
    function tokenVault(uint tokenId) external view returns (address vault);

    /// @notice Receiver of token owner's platform revenue share
    /// @param tokenId ID of NFT
    /// @return receiver Address of vault manager fees receiver
    function getRevenueReceiver(uint tokenId) external view returns (address receiver);

    /// @notice All vaults data.
    /// The output values are matched by index in the arrays.
    /// @param vaultAddress Vault addresses
    /// @param name Vault name
    /// @param symbol Vault symbol
    /// @param vaultType Vault type ID string
    /// @param strategyId Strategy logic ID string
    /// @param sharePrice Current vault share price in USD. 18 decimals
    /// @param tvl Current vault TVL in USD. 18 decimals
    /// @param totalApr Last total vault APR. Denominator is 100_00.
    /// @param strategyApr Last strategy APR. Denominator is 100_00.
    /// @param strategySpecific Strategy specific name
    function vaults()
        external
        view
        returns (
            address[] memory vaultAddress,
            string[] memory name,
            string[] memory symbol,
            string[] memory vaultType,
            string[] memory strategyId,
            uint[] memory sharePrice,
            uint[] memory tvl,
            uint[] memory totalApr,
            uint[] memory strategyApr,
            string[] memory strategySpecific
        );

    /// @notice All deployed vault addresses
    /// @return vaultAddress Addresses of vault proxy
    function vaultAddresses() external view returns (address[] memory vaultAddress);

    /// @notice Vault extended info getter
    /// @param vault Address of vault proxy
    /// @return strategy
    /// @return strategyAssets
    /// @return underlying
    /// @return assetsWithApr Assets with underlying APRs that can be provided by AprOracle
    /// @return assetsAprs APRs of assets with APR. Matched by index wuth previous param.
    /// @return lastHardWork Last HardWork time
    function vaultInfo(address vault)
        external
        view
        returns (
            address strategy,
            address[] memory strategyAssets,
            address underlying,
            address[] memory assetsWithApr,
            uint[] memory assetsAprs,
            uint lastHardWork
        );

    //endregion -- View functions -----

    //region ----- Write functions -----

    /// @notice Changing managed vault init parameters by Vault Manager (owner of VaultManager NFT)
    /// @param tokenId ID of VaultManager NFT
    /// @param addresses Vault init addresses. Must contain also not changeable init addresses
    /// @param nums Vault init numbers. Must contant also not changeable init numbers
    function changeVaultParams(uint tokenId, address[] memory addresses, uint[] memory nums) external;

    /// @notice Minting of new token on deploying vault by Factory
    /// Only Factory can call this.
    /// @param to User which creates vault
    /// @param vault Address of vault proxy
    /// @return tokenId Minted token ID
    function mint(address to, address vault) external returns (uint tokenId);

    /// @notice Owner of token can change revenue reciever of platform fee share
    /// @param tokenId Owned token ID
    /// @param receiver New revenue receiver address
    function setRevenueReceiver(uint tokenId, address receiver) external;

    //endregion -- Write functions -----
}

File 19 of 41 : IStrategyLogic.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";

/// @dev Interface of developed strategy logic NFT
/// @author Alien Deployer (https://github.com/a17)
/// @author Jude (https://github.com/iammrjude)
/// @author JodsMigel (https://github.com/JodsMigel)
interface IStrategyLogic is IERC721Metadata {
    //region ----- Events -----
    event SetRevenueReceiver(uint tokenId, address receiver);
    //endregion -- Events -----

    struct StrategyData {
        uint strategyTokenId;
        string strategyId;
        bytes32 strategyExtra;
    }

    /// @notice Minting of new developed strategy by the factory
    /// @dev Parameters from StrategyDeveloperLib, StrategyIdLib.
    /// Only factory can call it.
    /// @param to Strategy developer address
    /// @param strategyLogicId Strategy logic ID string
    /// @return tokenId Minted token ID
    function mint(address to, string memory strategyLogicId) external returns (uint tokenId);

    /// @notice Owner of token can change address for receiving strategy logic revenue share
    /// Only owner of token can call it.
    /// @param tokenId Owned token ID
    /// @param receiver Address for receiving revenue
    function setRevenueReceiver(uint tokenId, address receiver) external;

    /// @notice Token ID to strategy logic ID map
    /// @param tokenId Owned token ID
    /// @return strategyLogicId Strategy logic ID string
    function tokenStrategyLogic(uint tokenId) external view returns (string memory strategyLogicId);

    /// @notice Current revenue reciever for token
    /// @param tokenId Token ID
    /// @return receiver Address for receiving revenue
    function getRevenueReceiver(uint tokenId) external view returns (address receiver);
}

File 20 of 41 : 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 21 of 41 : 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 22 of 41 : 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 23 of 41 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
     *   {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 24 of 41 : 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 25 of 41 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 26 of 41 : SlotsLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

/// @title Minimal library for setting / getting slot variables (used in upgradable proxy contracts)
library SlotsLib {
    /// @dev Gets a slot as an address
    function getAddress(bytes32 slot) internal view returns (address result) {
        assembly {
            result := sload(slot)
        }
    }

    /// @dev Gets a slot as uint256
    function getUint(bytes32 slot) internal view returns (uint result) {
        assembly {
            result := sload(slot)
        }
    }

    /// @dev Sets a slot with address
    /// @notice Check address for 0 at the setter
    function set(bytes32 slot, address value) internal {
        assembly {
            sstore(slot, value)
        }
    }

    /// @dev Sets a slot with uint
    function set(bytes32 slot, uint value) internal {
        assembly {
            sstore(slot, value)
        }
    }
}

File 27 of 41 : IControllable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

/// @dev Base core interface implemented by most platform contracts.
///      Inherited contracts store an immutable Platform proxy address in the storage,
///      which provides authorization capabilities and infrastructure contract addresses.
/// @author Alien Deployer (https://github.com/a17)
/// @author JodsMigel (https://github.com/JodsMigel)
interface IControllable {
    //region ----- Custom Errors -----
    error IncorrectZeroArgument();
    error IncorrectMsgSender();
    error NotGovernance();
    error NotMultisig();
    error NotGovernanceAndNotMultisig();
    error NotOperator();
    error NotFactory();
    error NotPlatform();
    error NotVault();
    error IncorrectArrayLength();
    error AlreadyExist();
    error NotExist();
    error NotTheOwner();
    error ETHTransferFailed();
    error IncorrectInitParams();
    //endregion -- Custom Errors -----

    event ContractInitialized(address platform, uint ts, uint block);

    /// @notice Stability Platform main contract address
    function platform() external view returns (address);

    /// @notice Version of contract implementation
    /// @dev SemVer scheme MAJOR.MINOR.PATCH
    //slither-disable-next-line naming-convention
    function VERSION() external view returns (string memory);

    /// @notice Block number when contract was initialized
    function createdBlock() external view returns (uint);
}

File 28 of 41 : IPlatform.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

/// @notice Interface of the main contract and entry point to the platform.
/// @author Alien Deployer (https://github.com/a17)
/// @author Jude (https://github.com/iammrjude)
/// @author JodsMigel (https://github.com/JodsMigel)
interface IPlatform {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       CUSTOM ERRORS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    error AlreadyAnnounced();
    error SameVersion();
    error NoNewVersion();
    error UpgradeTimerIsNotOver(uint TimerTimestamp);
    error IncorrectFee(uint minFee, uint maxFee);
    error NotEnoughAllowedBBToken();
    error TokenAlreadyExistsInSet(address token);
    error AggregatorNotExists(address dexAggRouter);

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                           EVENTS                           */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    event PlatformVersion(string version);
    event UpgradeAnnounce(
        string oldVersion, string newVersion, address[] proxies, address[] newImplementations, uint timelock
    );
    event CancelUpgrade(string oldVersion, string newVersion);
    event ProxyUpgraded(
        address indexed proxy, address implementation, string oldContractVersion, string newContractVersion
    );
    event Addresses(
        address multisig_,
        address factory_,
        address priceReader_,
        address swapper_,
        address buildingPermitToken_,
        address vaultManager_,
        address strategyLogic_,
        address aprOracle_,
        address hardWorker,
        address rebalancer,
        address zap,
        address bridge
    );
    event OperatorAdded(address operator);
    event OperatorRemoved(address operator);
    event FeesChanged(uint fee, uint feeShareVaultManager, uint feeShareStrategyLogic, uint feeShareEcosystem);
    event MinInitialBoostChanged(uint minInitialBoostPerDay, uint minInitialBoostDuration);
    event NewAmmAdapter(string id, address proxy);
    event EcosystemRevenueReceiver(address receiver);
    event SetAllowedBBTokenVaults(address bbToken, uint vaultsToBuild, bool firstSet);
    event RemoveAllowedBBToken(address bbToken);
    event AddAllowedBoostRewardToken(address token);
    event RemoveAllowedBoostRewardToken(address token);
    event AddDefaultBoostRewardToken(address token);
    event RemoveDefaultBoostRewardToken(address token);
    event AddBoostTokens(address[] allowedBoostRewardToken, address[] defaultBoostRewardToken);
    event AllowedBBTokenVaultUsed(address bbToken, uint vaultToUse);
    event AddDexAggregator(address router);
    event RemoveDexAggregator(address router);
    event MinTvlForFreeHardWorkChanged(uint oldValue, uint newValue);
    event CustomVaultFee(address vault, uint platformFee);
    event Rebalancer(address rebalancer_);
    event Bridge(address bridge_);

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         DATA TYPES                         */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    struct PlatformUpgrade {
        string newVersion;
        address[] proxies;
        address[] newImplementations;
    }

    struct PlatformSettings {
        string networkName;
        bytes32 networkExtra;
        uint fee;
        uint feeShareVaultManager;
        uint feeShareStrategyLogic;
        uint feeShareEcosystem;
        uint minInitialBoostPerDay;
        uint minInitialBoostDuration;
    }

    struct AmmAdapter {
        string id;
        address proxy;
    }

    struct SetupAddresses {
        address factory;
        address priceReader;
        address swapper;
        address buildingPermitToken;
        address buildingPayPerVaultToken;
        address vaultManager;
        address strategyLogic;
        address aprOracle;
        address targetExchangeAsset;
        address hardWorker;
        address zap;
        address bridge;
        address rebalancer;
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      VIEW FUNCTIONS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @notice Platform version in CalVer scheme: YY.MM.MINOR-tag. Updates on core contract upgrades.
    function platformVersion() external view returns (string memory);

    /// @notice Time delay for proxy upgrades of core contracts and changing important platform settings by multisig
    //slither-disable-next-line naming-convention
    function TIME_LOCK() external view returns (uint);

    /// @notice DAO governance
    function governance() external view returns (address);

    /// @notice Core team multi signature wallet. Development and operations fund
    function multisig() external view returns (address);

    /// @notice This NFT allow user to build limited number of vaults per week
    function buildingPermitToken() external view returns (address);

    /// @notice This ERC20 token is used as payment token for vault building
    function buildingPayPerVaultToken() external view returns (address);

    /// @notice Receiver of ecosystem revenue
    function ecosystemRevenueReceiver() external view returns (address);

    /// @dev The best asset in a network for swaps between strategy assets and farms rewards assets
    ///      The target exchange asset is used for finding the best strategy's exchange asset.
    ///      Rhe fewer routes needed to swap to the target exchange asset, the better.
    function targetExchangeAsset() external view returns (address);

    /// @notice Platform factory assembling vaults. Stores settings, strategy logic, farms.
    /// Provides the opportunity to upgrade vaults and strategies.
    /// @return Address of Factory proxy
    function factory() external view returns (address);

    /// @notice The holders of these NFT receive a share of the vault revenue
    /// @return Address of VaultManager proxy
    function vaultManager() external view returns (address);

    /// @notice The holders of these tokens receive a share of the revenue received in all vaults using this strategy logic.
    function strategyLogic() external view returns (address);

    /// @notice Combining oracle and DeX spot prices
    /// @return Address of PriceReader proxy
    function priceReader() external view returns (address);

    /// @notice Providing underlying assets APRs on-chain
    /// @return Address of AprOracle proxy
    function aprOracle() external view returns (address);

    /// @notice On-chain price quoter and swapper
    /// @return Address of Swapper proxy
    function swapper() external view returns (address);

    /// @notice HardWork resolver and caller
    /// @return Address of HardWorker proxy
    function hardWorker() external view returns (address);

    /// @notice Rebalance resolver
    /// @return Address of Rebalancer proxy
    function rebalancer() external view returns (address);

    /// @notice ZAP feature
    /// @return Address of Zap proxy
    function zap() external view returns (address);

    /// @notice Stability Bridge
    /// @return Address of Bridge proxy
    function bridge() external view returns (address);

    /// @notice Name of current EVM network
    function networkName() external view returns (string memory);

    /// @notice Minimal initial boost rewards per day USD amount which needs to create rewarding vault
    function minInitialBoostPerDay() external view returns (uint);

    /// @notice Minimal boost rewards vesting duration for initial boost
    function minInitialBoostDuration() external view returns (uint);

    /// @notice This function provides the timestamp of the platform upgrade timelock.
    /// @dev This function is an external view function, meaning it doesn't modify the state.
    /// @return uint representing the timestamp of the platform upgrade timelock.
    function platformUpgradeTimelock() external view returns (uint);

    /// @dev Extra network data
    /// @return 0-2 bytes - color
    ///         3-5 bytes - background color
    ///         6-31 bytes - free
    function networkExtra() external view returns (bytes32);

    /// @notice Pending platform upgrade data
    function pendingPlatformUpgrade() external view returns (PlatformUpgrade memory);

    /// @notice Get platform revenue fee settings
    /// @return fee Revenue fee % (between MIN_FEE - MAX_FEE) with DENOMINATOR precision.
    /// @return feeShareVaultManager Revenue fee share % of VaultManager tokenId owner
    /// @return feeShareStrategyLogic Revenue fee share % of StrategyLogic tokenId owner
    /// @return feeShareEcosystem Revenue fee share % of ecosystemFeeReceiver
    function getFees()
        external
        view
        returns (uint fee, uint feeShareVaultManager, uint feeShareStrategyLogic, uint feeShareEcosystem);

    /// @notice Get custom vault platform fee
    /// @return fee revenue fee % with DENOMINATOR precision
    function getCustomVaultFee(address vault) external view returns (uint fee);

    /// @notice Platform settings
    function getPlatformSettings() external view returns (PlatformSettings memory);

    /// @notice AMM adapters of the platform
    function getAmmAdapters() external view returns (string[] memory id, address[] memory proxy);

    /// @notice Get AMM adapter data by hash
    /// @param ammAdapterIdHash Keccak256 hash of adapter ID string
    /// @return ID string and proxy address of AMM adapter
    function ammAdapter(bytes32 ammAdapterIdHash) external view returns (AmmAdapter memory);

    /// @notice Allowed buy-back tokens for rewarding vaults
    function allowedBBTokens() external view returns (address[] memory);

    /// @notice Vaults building limit for buy-back token.
    /// This limit decrements when a vault for BB-token is built.
    /// @param token Allowed buy-back token
    /// @return vaultsLimit Number of vaults that can be built for BB-token
    function allowedBBTokenVaults(address token) external view returns (uint vaultsLimit);

    /// @notice Vaults building limits for allowed buy-back tokens.
    /// @return bbToken Allowed buy-back tokens
    /// @return vaultsLimit Number of vaults that can be built for BB-tokens
    function allowedBBTokenVaults() external view returns (address[] memory bbToken, uint[] memory vaultsLimit);

    /// @notice Non-zero vaults building limits for allowed buy-back tokens.
    /// @return bbToken Allowed buy-back tokens
    /// @return vaultsLimit Number of vaults that can be built for BB-tokens
    function allowedBBTokenVaultsFiltered()
        external
        view
        returns (address[] memory bbToken, uint[] memory vaultsLimit);

    /// @notice Check address for existance in operators list
    /// @param operator Address
    /// @return True if this address is Stability Operator
    function isOperator(address operator) external view returns (bool);

    /// @notice Tokens that can be used for boost rewards of rewarding vaults
    /// @return Addresses of tokens
    function allowedBoostRewardTokens() external view returns (address[] memory);

    /// @notice Allowed boost reward tokens that used for unmanaged rewarding vaults creation
    /// @return Addresses of tokens
    function defaultBoostRewardTokens() external view returns (address[] memory);

    /// @notice Allowed boost reward tokens that used for unmanaged rewarding vaults creation
    /// @param addressToRemove This address will be removed from default boost reward tokens
    /// @return Addresses of tokens
    function defaultBoostRewardTokensFiltered(address addressToRemove) external view returns (address[] memory);

    /// @notice Allowed DeX aggregators
    /// @return Addresses of DeX aggregator rounters
    function dexAggregators() external view returns (address[] memory);

    /// @notice DeX aggregator router address is allowed to be used in the platform
    /// @param dexAggRouter Address of DeX aggreagator router
    /// @return Can be used
    function isAllowedDexAggregatorRouter(address dexAggRouter) external view returns (bool);

    /// @notice Show minimum TVL for compensate if vault has not enough ETH
    /// @return Minimum TVL for compensate.
    function minTvlForFreeHardWork() external view returns (uint);

    /// @notice Front-end platform viewer
    /// @return platformAddresses Platform core addresses
    ///        platformAddresses[0] factory
    ///        platformAddresses[1] vaultManager
    ///        platformAddresses[2] strategyLogic
    ///        platformAddresses[3] buildingPermitToken
    ///        platformAddresses[4] buildingPayPerVaultToken
    ///        platformAddresses[5] governance
    ///        platformAddresses[6] multisig
    ///        platformAddresses[7] zap
    ///        platformAddresses[8] bridge
    /// @return bcAssets Blue chip token addresses
    /// @return dexAggregators_ DeX aggregators allowed to be used entire the platform
    /// @return vaultType Vault type ID strings
    /// @return vaultExtra Vault color, background color and other extra data. Index of vault same as in previous array.
    /// @return vaultBulldingPrice Price of creating new vault in buildingPayPerVaultToken. Index of vault same as in previous array.
    /// @return strategyId Strategy logic ID strings
    /// @return isFarmingStrategy True if strategy is farming strategy. Index of strategy same as in previous array.
    /// @return strategyTokenURI StrategyLogic NFT tokenId metadata and on-chain image. Index of strategy same as in previous array.
    /// @return strategyExtra Strategy color, background color and other extra data. Index of strategy same as in previous array.
    function getData()
        external
        view
        returns (
            address[] memory platformAddresses,
            address[] memory bcAssets,
            address[] memory dexAggregators_,
            string[] memory vaultType,
            bytes32[] memory vaultExtra,
            uint[] memory vaultBulldingPrice,
            string[] memory strategyId,
            bool[] memory isFarmingStrategy,
            string[] memory strategyTokenURI,
            bytes32[] memory strategyExtra
        );

    // todo add vaultSymbol, vaultName
    /// @notice Front-end balances, prices and vault list viewer
    /// @param yourAccount Address of account to query balances
    /// @return token Tokens supported by the platform
    /// @return tokenPrice USD price of token. Index of token same as in previous array.
    /// @return tokenUserBalance User balance of token. Index of token same as in previous array.
    /// @return vault Deployed vaults
    /// @return vaultSharePrice Price 1.0 vault share. Index of vault same as in previous array.
    /// @return vaultUserBalance User balance of vault. Index of vault same as in previous array.
    /// @return nft Ecosystem NFTs
    ///         nft[0] BuildingPermitToken
    ///         nft[1] VaultManager
    ///         nft[2] StrategyLogic
    /// @return nftUserBalance User balance of NFT. Index of NFT same as in previous array.
    /// @return buildingPayPerVaultTokenBalance User balance of vault creation paying token
    function getBalance(address yourAccount)
        external
        view
        returns (
            address[] memory token,
            uint[] memory tokenPrice,
            uint[] memory tokenUserBalance,
            address[] memory vault,
            uint[] memory vaultSharePrice,
            uint[] memory vaultUserBalance,
            address[] memory nft,
            uint[] memory nftUserBalance,
            uint buildingPayPerVaultTokenBalance
        );

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      WRITE FUNCTIONS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @notice Add platform operator.
    /// Only governance and multisig can add operator.
    /// @param operator Address of new operator
    function addOperator(address operator) external;

    /// @notice Remove platform operator.
    /// Only governance and multisig can remove operator.
    /// @param operator Address of operator to remove
    function removeOperator(address operator) external;

    /// @notice Announce upgrade of platform proxies implementations
    /// Only governance and multisig can announce platform upgrades.
    /// @param newVersion New platform version. Version must be changed when upgrading.
    /// @param proxies Addresses of core contract proxies
    /// @param newImplementations New implementation for proxy. Index of proxy same as in previous array.
    function announcePlatformUpgrade(
        string memory newVersion,
        address[] memory proxies,
        address[] memory newImplementations
    ) external;

    /// @notice Upgrade platform
    /// Only operator (multisig is operator too) can ececute pending platform upgrade
    function upgrade() external;

    /// @notice Cancel pending platform upgrade
    /// Only operator (multisig is operator too) can ececute pending platform upgrade
    function cancelUpgrade() external;

    /// @notice Register AMM adapter in platform
    /// @param id AMM adapter ID string from AmmAdapterIdLib
    /// @param proxy Address of AMM adapter proxy
    function addAmmAdapter(string memory id, address proxy) external;

    // todo Only governance and multisig can set allowed bb-token vaults building limit
    /// @notice Set new vaults building limit for buy-back token
    /// @param bbToken Address of allowed buy-back token
    /// @param vaultsToBuild Number of vaults that can be built for BB-token
    function setAllowedBBTokenVaults(address bbToken, uint vaultsToBuild) external;

    // todo Only governance and multisig can add allowed boost reward token
    /// @notice Add new allowed boost reward token
    /// @param token Address of token
    function addAllowedBoostRewardToken(address token) external;

    // todo Only governance and multisig can remove allowed boost reward token
    /// @notice Remove allowed boost reward token
    /// @param token Address of allowed boost reward token
    function removeAllowedBoostRewardToken(address token) external;

    // todo Only governance and multisig can add default boost reward token
    /// @notice Add default boost reward token
    /// @param token Address of default boost reward token
    function addDefaultBoostRewardToken(address token) external;

    // todo Only governance and multisig can remove default boost reward token
    /// @notice Remove default boost reward token
    /// @param token Address of allowed boost reward token
    function removeDefaultBoostRewardToken(address token) external;

    // todo Only governance and multisig can add allowed boost reward token
    // todo Only governance and multisig can add default boost reward token
    /// @notice Add new allowed boost reward token
    /// @notice Add default boost reward token
    /// @param allowedBoostRewardToken Address of allowed boost reward token
    /// @param defaultBoostRewardToken Address of default boost reward token
    function addBoostTokens(
        address[] memory allowedBoostRewardToken,
        address[] memory defaultBoostRewardToken
    ) external;

    /// @notice Decrease allowed BB-token vault building limit when vault is built
    /// Only Factory can do it.
    /// @param bbToken Address of allowed buy-back token
    function useAllowedBBTokenVault(address bbToken) external;

    /// @notice Allow DeX aggregator routers to be used in the platform
    /// @param dexAggRouter Addresses of DeX aggreagator routers
    function addDexAggregators(address[] memory dexAggRouter) external;

    /// @notice Remove allowed DeX aggregator router from the platform
    /// @param dexAggRouter Address of DeX aggreagator router
    function removeDexAggregator(address dexAggRouter) external;

    /// @notice Change initial boost rewards settings
    /// @param minInitialBoostPerDay_ Minimal initial boost rewards per day USD amount which needs to create rewarding vault
    /// @param minInitialBoostDuration_ Minimal boost rewards vesting duration for initial boost
    function setInitialBoost(uint minInitialBoostPerDay_, uint minInitialBoostDuration_) external;

    /// @notice Update new minimum TVL for compensate.
    /// @param value New minimum TVL for compensate.
    function setMinTvlForFreeHardWork(uint value) external;

    /// @notice Set custom platform fee for vault
    /// @param vault Vault address
    /// @param platformFee Custom platform fee
    function setCustomVaultFee(address vault, uint platformFee) external;

    /// @notice Setup Rebalancer.
    /// Only Goverannce or Multisig can do this when Rebalancer is not set.
    /// @param rebalancer_ Proxy address of Bridge
    function setupRebalancer(address rebalancer_) external;

    /// @notice Setup Bridge.
    /// Only Goverannce or Multisig can do this when Bridge is not set.
    /// @param bridge_ Proxy address of Bridge
    function setupBridge(address bridge_) external;
}

File 29 of 41 : 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 30 of 41 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant HEX_DIGITS = "0123456789abcdef";
    uint8 private constant ADDRESS_LENGTH = 20;

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toStringSigned(int256 value) internal pure returns (string memory) {
        return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        uint256 localValue = value;
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = HEX_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
     * representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

File 31 of 41 : ConstantsLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

library ConstantsLib {
    uint internal constant DENOMINATOR = 100_000;
    address internal constant DEAD_ADDRESS = 0xdEad000000000000000000000000000000000000;
}

File 32 of 41 : ISwapper.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

/// @notice On-chain price quoter and swapper by predefined routes
/// @author Alien Deployer (https://github.com/a17)
/// @author Jude (https://github.com/iammrjude)
/// @author JodsMigel (https://github.com/JodsMigel)
/// @author 0xhokugava (https://github.com/0xhokugava)
interface ISwapper {
    event Swap(address indexed tokenIn, address indexed tokenOut, uint amount);
    event PoolAdded(PoolData poolData, bool assetAdded);
    event PoolRemoved(address token);
    event BlueChipAdded(PoolData poolData);
    event ThresholdChanged(address[] tokenIn, uint[] thresholdAmount);
    event BlueChipPoolRemoved(address tokenIn, address tokenOut);

    //region ----- Custom Errors -----
    error UnknownAMMAdapter();
    error LessThenThreshold(uint minimumAmount);
    error NoRouteFound();
    error NoRoutesForAssets();
    //endregion -- Custom Errors -----

    struct PoolData {
        address pool;
        address ammAdapter;
        address tokenIn;
        address tokenOut;
    }

    struct AddPoolData {
        address pool;
        string ammAdapterId;
        address tokenIn;
        address tokenOut;
    }

    /// @notice All assets in pools added to Swapper
    /// @return Addresses of assets
    function assets() external view returns (address[] memory);

    /// @notice All blue chip assets in blue chip pools added to Swapper
    /// @return Addresses of blue chip assets
    function bcAssets() external view returns (address[] memory);

    /// @notice All assets in Swapper
    /// @return Addresses of assets and blue chip assets
    function allAssets() external view returns (address[] memory);

    /// @notice Add pools with largest TVL
    /// @param pools Largest pools with AMM adapter addresses
    /// @param rewrite Rewrite pool for tokenIn
    function addPools(PoolData[] memory pools, bool rewrite) external;

    /// @notice Add pools with largest TVL
    /// @param pools Largest pools with AMM adapter ID string
    /// @param rewrite Rewrite pool for tokenIn
    function addPools(AddPoolData[] memory pools, bool rewrite) external;

    /// @notice Add largest pools with the most popular tokens on the current network
    /// @param pools_ PoolData array with pool, tokens and AMM adapter address
    /// @param rewrite Change exist pool records
    function addBlueChipsPools(PoolData[] memory pools_, bool rewrite) external;

    /// @notice Add largest pools with the most popular tokens on the current network
    /// @param pools_ AddPoolData array with pool, tokens and AMM adapter string ID
    /// @param rewrite Change exist pool records
    function addBlueChipsPools(AddPoolData[] memory pools_, bool rewrite) external;

    /// @notice Retrieves pool data for a specified token swap in Blue Chip Pools.
    /// @dev This function provides information about the pool associated with the specified input and output tokens.
    /// @param tokenIn The input token address.
    /// @param tokenOut The output token address.
    /// @return poolData The data structure containing information about the Blue Chip Pool.
    /// @custom:opcodes view
    function blueChipsPools(address tokenIn, address tokenOut) external view returns (PoolData memory poolData);

    /// @notice Set swap threshold for token
    /// @dev Prevents dust swap.
    /// @param tokenIn Swap input token
    /// @param thresholdAmount Minimum amount of token for executing swap
    function setThresholds(address[] memory tokenIn, uint[] memory thresholdAmount) external;

    /// @notice Swap threshold for token
    /// @param token Swap input token
    /// @return threshold_ Minimum amount of token for executing swap
    function threshold(address token) external view returns (uint threshold_);

    /// @notice Price of given tokenIn against tokenOut
    /// @param tokenIn Swap input token
    /// @param tokenOut Swap output token
    /// @param amount Amount of tokenIn. If provide zero then amount is 1.0.
    /// @return Amount of tokenOut with decimals of tokenOut
    function getPrice(address tokenIn, address tokenOut, uint amount) external view returns (uint);

    /// @notice Return price the first poolData.tokenIn against the last poolData.tokenOut in decimals of tokenOut.
    /// @param route Array of pool address, swapper address tokenIn, tokenOut
    /// @param amount Amount of tokenIn. If provide zero then amount is 1.0.
    function getPriceForRoute(PoolData[] memory route, uint amount) external view returns (uint);

    /// @notice Check possibility of swap tokenIn for tokenOut
    /// @param tokenIn Swap input token
    /// @param tokenOut Swap output token
    /// @return Swap route exists
    function isRouteExist(address tokenIn, address tokenOut) external view returns (bool);

    /// @notice Build route for swap. No reverts inside.
    /// @param tokenIn Swap input token
    /// @param tokenOut Swap output token
    /// @return route Array of pools for swap tokenIn to tokenOut. Zero length indicate an error.
    /// @return errorMessage Possible reason why the route was not found. Empty for success routes.
    function buildRoute(
        address tokenIn,
        address tokenOut
    ) external view returns (PoolData[] memory route, string memory errorMessage);

    /// @notice Sell tokenIn for tokenOut
    /// @dev Assume approve on this contract exist
    /// @param tokenIn Swap input token
    /// @param tokenOut Swap output token
    /// @param amount Amount of tokenIn for swap.
    /// @param priceImpactTolerance Price impact tolerance. Must include fees at least. Denominator is 100_000.
    function swap(address tokenIn, address tokenOut, uint amount, uint priceImpactTolerance) external;

    /// @notice Swap by predefined route
    /// @param route Array of pool address, swapper address tokenIn, tokenOut.
    /// TokenIn from first item will be swaped to tokenOut of last .
    /// @param amount Amount of first item tokenIn.
    /// @param priceImpactTolerance Price impact tolerance. Must include fees at least. Denominator is 100_000.
    function swapWithRoute(PoolData[] memory route, uint amount, uint priceImpactTolerance) external;
}

File 33 of 41 : IPriceReader.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

/// @dev Combining oracle and DeX spot prices
/// @author Alien Deployer (https://github.com/a17)
/// @author Jude (https://github.com/iammrjude)
/// @author JodsMigel (https://github.com/JodsMigel)
interface IPriceReader {
    //region ----- Events -----
    event AdapterAdded(address adapter);
    event AdapterRemoved(address adapter);
    //endregion -- Events -----

    /// @notice Price of asset
    /// @dev Price of 1.0 amount of asset in USD
    /// @param asset Address of asset
    /// @return price USD price with 18 decimals
    /// @return trusted Price from oracle
    function getPrice(address asset) external view returns (uint price, bool trusted);

    /// @notice Get USD price of specified assets and amounts
    /// @param assets_ Addresses of assets
    /// @param amounts_ Amount of asset. Index of asset same as in previous parameter.
    /// @return total Total USD value with 18 decimals
    /// @return assetAmountPrice USD price of asset amount. Index of assetAmountPrice same as in assets_ parameters.
    /// @return assetPrice USD price of asset. Index of assetAmountPrice same as in assets_ parameters.
    /// @return trusted True if only oracle prices was used for calculation.
    function getAssetsPrice(
        address[] memory assets_,
        uint[] memory amounts_
    ) external view returns (uint total, uint[] memory assetAmountPrice, uint[] memory assetPrice, bool trusted);

    /// @notice Add oracle adapter to PriceReader
    /// Only operator (multisig is operator too) can add adapter
    /// @param adapter_ Address of price oracle proxy
    function addAdapter(address adapter_) external;
}

File 34 of 41 : IRVault.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "./IVault.sol";

/// @notice Interface of Rewarding Vault
/// @author Alien Deployer (https://github.com/a17)
/// @author JodsMigel (https://github.com/JodsMigel)
/// @author 0xhokugava (https://github.com/0xhokugava)
interface IRVault is IVault {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       CUSTOM ERRORS                        */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    error NotAllowed();
    error Overflow(uint maxAmount);
    error RTNotFound();
    error NoBBToken();
    error NotAllowedBBToken();
    error IncorrectNums();
    error ZeroToken();
    error ZeroVestingDuration();
    error TooHighCompoundRation();
    error RewardIsTooSmall();
    // error RewardIsTooBig();

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                           EVENTS                           */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    event RewardAdded(address rewardToken, uint reward);
    event RewardPaid(address indexed user, address rewardToken, uint reward);
    event SetRewardsRedirect(address owner, address receiver);
    event AddedRewardToken(address indexed token, uint indexed tokenIndex);
    event CompoundRatio(uint compoundRatio_);

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         DATA TYPES                         */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @custom:storage-location erc7201:stability.RVaultBase
    struct RVaultBaseStorage {
        /// @inheritdoc IRVault
        mapping(uint tokenIndex => address rewardToken) rewardToken;
        /// @inheritdoc IRVault
        mapping(uint tokenIndex => uint durationSeconds) duration;
        /// @inheritdoc IRVault
        mapping(address owner => address receiver) rewardsRedirect;
        /// @dev Timestamp value when current period of rewards will be ended
        mapping(uint tokenIndex => uint finishTimestamp) periodFinishForToken;
        /// @dev Reward rate in normal circumstances is distributed rewards divided on duration
        mapping(uint tokenIndex => uint rewardRate) rewardRateForToken;
        /// @dev Last rewards snapshot time. Updated on each share movements
        mapping(uint tokenIndex => uint lastUpdateTimestamp) lastUpdateTimeForToken;
        /// @dev Rewards snapshot calculated from rewardPerToken(rt). Updated on each share movements
        mapping(uint tokenIndex => uint rewardPerTokenStored) rewardPerTokenStoredForToken;
        /// @dev User personal reward rate snapshot. Updated on each share movements
        mapping(uint tokenIndex => mapping(address user => uint rewardPerTokenPaid)) userRewardPerTokenPaidForToken;
        /// @dev User personal earned reward snapshot. Updated on each share movements
        mapping(uint tokenIndex => mapping(address user => uint earned)) rewardsForToken;
        /// @inheritdoc IRVault
        uint rewardTokensTotal;
        /// @inheritdoc IRVault
        uint compoundRatio;
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                       VIEW FUNCTIONS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @notice All vault rewarding tokens
    /// @return Reward token addresses
    function rewardTokens() external view returns (address[] memory);

    /// @return Total of bbToken + boost reward tokens
    function rewardTokensTotal() external view returns (uint);

    /// @notice Immutable reward buy-back token with tokenIndex 0
    function bbToken() external view returns (address);

    /// @dev A mapping of reward tokens that able to be distributed to this contract.
    /// Token with index 0 always is bbToken.
    function rewardToken(uint tokenIndex) external view returns (address rewardToken_);

    /// @notice Re-investing ratio
    /// @dev Changeable ratio of revenue part for re-investing. Other part goes to rewarding by bbToken.
    /// @return Ratio of re-investing part of revenue. Denominator is 100_000.
    function compoundRatio() external view returns (uint);

    /// @notice Vesting period for distribution reward
    /// @param tokenIndex Index of rewarding token
    /// @return durationSeconds Duration for distributing of notified reward
    function duration(uint tokenIndex) external view returns (uint durationSeconds);

    /// @notice Return earned rewards for specific token and account
    ///         Accurate value returns only after updateRewards call
    ///         ((balanceOf(account)
    ///           * (rewardPerToken - userRewardPerTokenPaidForToken)) / 10**18) + rewardsForToken
    function earned(uint rewardTokenIndex, address account) external view returns (uint);

    /// @notice Return reward per token ratio by reward token address
    ///                rewardPerTokenStoredForToken + (
    ///                (lastTimeRewardApplicable - lastUpdateTimeForToken)
    ///                 * rewardRateForToken * 10**18 / totalSupply)
    /// @param rewardTokenIndex Index of reward token
    /// @return Return reward per token ratio by reward token address
    function rewardPerToken(uint rewardTokenIndex) external view returns (uint);

    /// @dev Receiver of rewards can be set by multisig when owner cant claim rewards himself
    /// @param owner Token owner address
    /// @return receiver Return reward's receiver
    function rewardsRedirect(address owner) external view returns (address receiver);

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                      WRITE FUNCTIONS                       */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @notice Filling vault with rewards
    /// @dev Update rewardRateForToken
    /// If period ended: reward / duration
    /// else add leftover to the reward amount and refresh the period
    /// (reward + ((periodFinishForToken - block.timestamp) * rewardRateForToken)) / duration
    /// @param tokenIndex Index of rewarding token
    /// @param amount Amount for rewarding
    function notifyTargetRewardAmount(uint tokenIndex, uint amount) external;

    /// @notice Update and Claim all rewards for caller
    function getAllRewards() external;

    /// @notice Update and Claim rewards for specific token
    /// @param rt Index of reward token
    function getReward(uint rt) external;

    /// @dev All rewards for given owner could be claimed for receiver address.
    /// @param owner Token owner address
    /// @param receiver New reward's receiver
    function setRewardsRedirect(address owner, address receiver) external;

    /// @notice Update and Claim all rewards for given owner address. Send them to predefined receiver.
    /// @param owner Token owner address
    function getAllRewardsAndRedirect(address owner) external;

    /// @notice Update and Claim all rewards for the given owner.
    ///         Sender should have allowance for push rewards for the owner.
    /// @param owner Token owner address
    function getAllRewardsFor(address owner) external;
}

File 35 of 41 : VaultProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "../../core/base/UpgradeableProxy.sol";
import "../../interfaces/IControllable.sol";
import "../../interfaces/IPlatform.sol";
import "../../interfaces/IFactory.sol";
import "../../interfaces/IVaultProxy.sol";

/// @title EIP1967 Upgradeable proxy implementation for built by factory vaults
/// @author Alien Deployer (https://github.com/a17)
contract VaultProxy is UpgradeableProxy, IVaultProxy {
    /// @dev Vault type ID
    bytes32 private constant _TYPE_SLOT = bytes32(uint(keccak256("eip1967.vaultProxy.type")) - 1);

    /// @inheritdoc IVaultProxy
    function initProxy(string memory type_) external {
        bytes32 typeHash = keccak256(abi.encodePacked(type_));
        //slither-disable-next-line unused-return
        (, address vaultImplementation,,,) = IFactory(msg.sender).vaultConfig(typeHash);
        _init(vaultImplementation);
        bytes32 slot = _TYPE_SLOT;
        //slither-disable-next-line assembly
        assembly {
            sstore(slot, typeHash)
        }
    }

    /// @inheritdoc IVaultProxy
    function upgrade() external {
        if (msg.sender != IPlatform(IControllable(address(this)).platform()).factory()) {
            revert ProxyForbidden();
        }
        bytes32 typeHash;
        bytes32 slot = _TYPE_SLOT;
        //slither-disable-next-line assembly
        assembly {
            typeHash := sload(slot)
        }
        //slither-disable-next-line unused-return
        (, address vaultImplementation,,,) = IFactory(msg.sender).vaultConfig(typeHash);
        _upgradeTo(vaultImplementation);
    }

    /// @inheritdoc IVaultProxy
    function implementation() external view returns (address) {
        return _implementation();
    }

    /// @inheritdoc IVaultProxy
    function vaultTypeHash() external view returns (bytes32) {
        bytes32 typeHash;
        bytes32 slot = _TYPE_SLOT;
        //slither-disable-next-line assembly
        assembly {
            typeHash := sload(slot)
        }
        return typeHash;
    }
}

File 36 of 41 : StrategyProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import "../../core/base/UpgradeableProxy.sol";
import "../../interfaces/IControllable.sol";
import "../../interfaces/IPlatform.sol";
import "../../interfaces/IFactory.sol";
import "../../interfaces/IStrategyProxy.sol";

/// @title EIP1967 Upgradeable proxy implementation for built by Factory strategies.
/// @author Alien Deployer (https://github.com/a17)
/// @author JodsMigel (https://github.com/JodsMigel)
/// @author Jude (https://github.com/iammrjude)
contract StrategyProxy is UpgradeableProxy, IStrategyProxy {
    /// @dev Strategy logic id
    bytes32 private constant _ID_SLOT = bytes32(uint(keccak256("eip1967.strategyProxy.id")) - 1);

    /// @inheritdoc IStrategyProxy
    function initStrategyProxy(string memory id) external {
        bytes32 strategyIdHash = keccak256(abi.encodePacked(id));
        //slither-disable-next-line unused-return
        IFactory.StrategyLogicConfig memory strategyConfig = IFactory(msg.sender).strategyLogicConfig(strategyIdHash);
        address strategyImplementation = strategyConfig.implementation;
        _init(strategyImplementation);
        bytes32 slot = _ID_SLOT;
        //slither-disable-next-line assembly
        assembly {
            sstore(slot, strategyIdHash)
        }
    }

    /// @inheritdoc IStrategyProxy
    function upgrade() external {
        if (IPlatform(IControllable(address(this)).platform()).factory() != msg.sender) {
            revert IControllable.NotFactory();
        }
        bytes32 strategyIdHash;
        bytes32 slot = _ID_SLOT;
        //slither-disable-next-line assembly
        assembly {
            strategyIdHash := sload(slot)
        }
        //slither-disable-next-line unused-return
        IFactory.StrategyLogicConfig memory strategyConfig = IFactory(msg.sender).strategyLogicConfig(strategyIdHash);
        address strategyImplementation = strategyConfig.implementation;
        _upgradeTo(strategyImplementation);
    }

    /// @inheritdoc IStrategyProxy
    function implementation() external view returns (address) {
        return _implementation();
    }

    /// @inheritdoc IStrategyProxy
    function strategyImplementationLogicIdHash() external view returns (bytes32) {
        bytes32 idHash;
        bytes32 slot = _ID_SLOT;
        //slither-disable-next-line assembly
        assembly {
            idHash := sload(slot)
        }
        return idHash;
    }
}

File 37 of 41 : 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 38 of 41 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.20;

import {IERC721} from "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 39 of 41 : 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 40 of 41 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

File 41 of 41 : UpgradeableProxy.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

/// @title Simple ERC-1967 upgradeable proxy implementation
abstract contract UpgradeableProxy {
    error ImplementationIsNotContract();

    /// @dev This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
    bytes32 private constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /// @dev Emitted when the implementation is upgraded.
    event Upgraded(address indexed implementation);

    constructor() {
        assert(_IMPLEMENTATION_SLOT == bytes32(uint(keccak256("eip1967.proxy.implementation")) - 1));
    }

    /// @dev Post deploy initialisation for compatability with EIP-1167 factory
    function _init(address _logic) internal {
        // nosemgrep
        require(_implementation() == address(0), "Already inited");
        _setImplementation(_logic);
    }

    /// @dev Returns the current implementation address.
    function _implementation() internal view virtual returns (address impl) {
        bytes32 slot = _IMPLEMENTATION_SLOT;
        // solhint-disable-next-line no-inline-assembly
        //slither-disable-next-line assembly
        assembly {
            impl := sload(slot)
        }
    }

    /// @dev Upgrades the proxy to a new implementation.
    function _upgradeTo(address newImplementation) internal virtual {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /// @dev Stores a new address in the EIP1967 implementation slot.
    function _setImplementation(address newImplementation) private {
        if (newImplementation.code.length == 0) revert ImplementationIsNotContract();
        bytes32 slot = _IMPLEMENTATION_SLOT;
        // solhint-disable-next-line no-inline-assembly
        //slither-disable-next-line assembly
        assembly {
            sstore(slot, newImplementation)
        }
    }

    /**
     * @dev Delegates the current call to `implementation`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _delegate(address implementation) internal virtual {
        //slither-disable-next-line assembly
        assembly {
            // Copy msg.data. We take full control of memory in this inline assembly
            // block because it will not return to Solidity code. We overwrite the
            // Solidity scratch pad at memory position 0.
            calldatacopy(0, 0, calldatasize())

            // Call the implementation.
            // out and outsize are 0 because we don't know the size yet.
            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)

            // Copy the returned data.
            returndatacopy(0, 0, returndatasize())

            switch result
            // delegatecall returns 0 on error.
            case 0 { revert(0, returndatasize()) }
            default { return(0, returndatasize()) }
        }
    }

    /**
     * @dev Delegates the current call to the address returned by `_implementation()`.
     *
     * This function does not return to its internal call site, it will return directly to the external caller.
     */
    function _fallback() internal virtual {
        _delegate(_implementation());
    }

    /// @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
    /// function in the contract matches the call data.
    //slither-disable-next-line locked-ether
    fallback() external payable virtual {
        _fallback();
    }

    /// @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
    /// is empty.
    //slither-disable-next-line locked-ether
    receive() external payable virtual {
        _fallback();
    }
}

Settings
{
  "remappings": [
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "@solady/=lib/solady/src/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "solady/=lib/solady/",
    "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": "shanghai",
  "viaIR": false,
  "libraries": {
    "src/core/libs/CommonLib.sol": {
      "CommonLib": "0x4f76ADd676c04ecA837130CeB58Bc173de8799dE"
    },
    "src/core/libs/DeployerLib.sol": {
      "DeployerLib": "0x29613385F8808A04E593163a2867f3F3D4a1BD8B"
    },
    "src/core/libs/FactoryLib.sol": {
      "FactoryLib": "0x06e0912b4f2E36cfcF9556478352AFC2d991919F"
    },
    "src/core/libs/FactoryNamingLib.sol": {
      "FactoryNamingLib": "0x3110a397362465b6Ad45703DE9DEa2CC2Ae6C3B3"
    },
    "src/core/libs/StrategyLogicLib.sol": {
      "StrategyLogicLib": "0xCA26bF5d5B610EB3E48041Dd7eb5Ce57475fB878"
    },
    "src/core/libs/VaultBaseLib.sol": {
      "VaultBaseLib": "0xD728c9C834985f583B1d0C29f84D80d1EF75A609"
    },
    "src/core/libs/VaultManagerLib.sol": {
      "VaultManagerLib": "0xE080ED61824494De0b191597e907Ee458F47c64b"
    },
    "src/strategies/libs/LPStrategyLib.sol": {
      "LPStrategyLib": "0xda05a4EC440C6E3A253d37652F1907118c06079a"
    },
    "src/strategies/libs/StrategyLib.sol": {
      "StrategyLib": "0xc2dE381a066FD7282aF33378664161a8fc180796"
    },
    "src/strategies/libs/UniswapV3MathLib.sol": {
      "UniswapV3MathLib": "0xbbc63ee4a06bf1F2432ccC4d70103e3D465fcA39"
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"AlreadyExist","type":"error"},{"inputs":[{"internalType":"bytes32","name":"_hash","type":"bytes32"}],"name":"AlreadyLastVersion","type":"error"},{"inputs":[],"name":"BoostAmountIsZero","type":"error"},{"inputs":[],"name":"BoostAmountTooLow","type":"error"},{"inputs":[],"name":"BoostDurationTooLow","type":"error"},{"inputs":[],"name":"ETHTransferFailed","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"IncorrectArrayLength","type":"error"},{"inputs":[],"name":"IncorrectInitParams","type":"error"},{"inputs":[],"name":"IncorrectMsgSender","type":"error"},{"inputs":[],"name":"IncorrectZeroArgument","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotActiveVault","type":"error"},{"inputs":[],"name":"NotExist","type":"error"},{"inputs":[],"name":"NotFactory","type":"error"},{"inputs":[],"name":"NotGovernance","type":"error"},{"inputs":[],"name":"NotGovernanceAndNotMultisig","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"NotMultisig","type":"error"},{"inputs":[],"name":"NotOperator","type":"error"},{"inputs":[],"name":"NotPlatform","type":"error"},{"inputs":[],"name":"NotStrategy","type":"error"},{"inputs":[],"name":"NotTheOwner","type":"error"},{"inputs":[],"name":"NotVault","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"StrategyImplementationIsNotAvailable","type":"error"},{"inputs":[],"name":"StrategyLogicNotAllowedToDeploy","type":"error"},{"inputs":[{"internalType":"bytes32","name":"key","type":"bytes32"}],"name":"SuchVaultAlreadyDeployed","type":"error"},{"inputs":[{"internalType":"bytes32","name":"_hash","type":"bytes32"}],"name":"UpgradeDenied","type":"error"},{"inputs":[],"name":"VaultImplementationIsNotAvailable","type":"error"},{"inputs":[],"name":"VaultNotAllowedToDeploy","type":"error"},{"inputs":[{"internalType":"uint256","name":"userBalance","type":"uint256"},{"internalType":"uint256","name":"requireBalance","type":"uint256"},{"internalType":"address","name":"payToken","type":"address"}],"name":"YouDontHaveEnoughTokens","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":false,"internalType":"string","name":"newAliasName","type":"string"}],"name":"AliasNameChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"platform","type":"address"},{"indexed":false,"internalType":"uint256","name":"ts","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"block","type":"uint256"}],"name":"ContractInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint256","name":"status","type":"uint256"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"string","name":"strategyLogicId","type":"string"},{"internalType":"address[]","name":"rewardAssets","type":"address[]"},{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"nums","type":"uint256[]"},{"internalType":"int24[]","name":"ticks","type":"int24[]"}],"indexed":false,"internalType":"struct IFactory.Farm[]","name":"farms","type":"tuple[]"}],"name":"NewFarm","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"id","type":"string"},{"indexed":false,"internalType":"address[]","name":"initAddresses","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"initNums","type":"uint256[]"},{"indexed":false,"internalType":"int24[]","name":"initTicks","type":"int24[]"}],"name":"SetStrategyAvailableInitParams","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"id","type":"string"},{"indexed":false,"internalType":"address","name":"implementation","type":"address"},{"indexed":false,"internalType":"bool","name":"deployAllowed","type":"bool"},{"indexed":false,"internalType":"bool","name":"upgradeAllowed","type":"bool"},{"indexed":false,"internalType":"bool","name":"newStrategy","type":"bool"}],"name":"StrategyLogicConfigChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"proxy","type":"address"},{"indexed":false,"internalType":"address","name":"oldImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newImplementation","type":"address"}],"name":"StrategyProxyUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"components":[{"internalType":"uint256","name":"status","type":"uint256"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"string","name":"strategyLogicId","type":"string"},{"internalType":"address[]","name":"rewardAssets","type":"address[]"},{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"nums","type":"uint256[]"},{"internalType":"int24[]","name":"ticks","type":"int24[]"}],"indexed":false,"internalType":"struct IFactory.Farm","name":"farm","type":"tuple"}],"name":"UpdateFarm","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"deployer","type":"address"},{"indexed":false,"internalType":"string","name":"vaultType","type":"string"},{"indexed":false,"internalType":"string","name":"strategyId","type":"string"},{"indexed":false,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"address","name":"strategy","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"address[]","name":"assets","type":"address[]"},{"indexed":false,"internalType":"bytes32","name":"deploymentKey","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"vaultManagerTokenId","type":"uint256"}],"name":"VaultAndStrategy","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"type_","type":"string"},{"indexed":false,"internalType":"address","name":"implementation","type":"address"},{"indexed":false,"internalType":"bool","name":"deployAllowed","type":"bool"},{"indexed":false,"internalType":"bool","name":"upgradeAllowed","type":"bool"},{"indexed":false,"internalType":"bool","name":"newVaultType","type":"bool"}],"name":"VaultConfigChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"proxy","type":"address"},{"indexed":false,"internalType":"address","name":"oldImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newImplementation","type":"address"}],"name":"VaultProxyUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":false,"internalType":"uint256","name":"newStatus","type":"uint256"}],"name":"VaultStatus","type":"event"},{"inputs":[],"name":"CONTROLLABLE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"status","type":"uint256"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"string","name":"strategyLogicId","type":"string"},{"internalType":"address[]","name":"rewardAssets","type":"address[]"},{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"nums","type":"uint256[]"},{"internalType":"int24[]","name":"ticks","type":"int24[]"}],"internalType":"struct IFactory.Farm[]","name":"farms_","type":"tuple[]"}],"name":"addFarms","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"createdBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"vaultType","type":"string"},{"internalType":"string","name":"strategyId","type":"string"},{"internalType":"address[]","name":"vaultInitAddresses","type":"address[]"},{"internalType":"uint256[]","name":"vaultInitNums","type":"uint256[]"},{"internalType":"address[]","name":"strategyInitAddresses","type":"address[]"},{"internalType":"uint256[]","name":"strategyInitNums","type":"uint256[]"},{"internalType":"int24[]","name":"strategyInitTicks","type":"int24[]"}],"name":"deployVaultAndStrategy","outputs":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"address","name":"strategy","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"deployedVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deployedVaults","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deployedVaultsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"deploymentKey_","type":"bytes32"}],"name":"deploymentKey","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"farm","outputs":[{"components":[{"internalType":"uint256","name":"status","type":"uint256"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"string","name":"strategyLogicId","type":"string"},{"internalType":"address[]","name":"rewardAssets","type":"address[]"},{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"nums","type":"uint256[]"},{"internalType":"int24[]","name":"ticks","type":"int24[]"}],"internalType":"struct IFactory.Farm","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"farms","outputs":[{"components":[{"internalType":"uint256","name":"status","type":"uint256"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"string","name":"strategyLogicId","type":"string"},{"internalType":"address[]","name":"rewardAssets","type":"address[]"},{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"nums","type":"uint256[]"},{"internalType":"int24[]","name":"ticks","type":"int24[]"}],"internalType":"struct IFactory.Farm[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"farmsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress_","type":"address"}],"name":"getAliasName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"vaultType","type":"string"},{"internalType":"string","name":"strategyId","type":"string"},{"internalType":"address[]","name":"initVaultAddresses","type":"address[]"},{"internalType":"uint256[]","name":"initVaultNums","type":"uint256[]"},{"internalType":"address[]","name":"initStrategyAddresses","type":"address[]"},{"internalType":"uint256[]","name":"initStrategyNums","type":"uint256[]"},{"internalType":"int24[]","name":"initStrategyTicks","type":"int24[]"}],"name":"getDeploymentKey","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address[]","name":"assets","type":"address[]"}],"name":"getExchangeAssetIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"vaultType","type":"string"},{"internalType":"address","name":"strategyAddress","type":"address"},{"internalType":"address","name":"bbAsset","type":"address"}],"name":"getStrategyData","outputs":[{"internalType":"string","name":"strategyId","type":"string"},{"internalType":"address[]","name":"assets","type":"address[]"},{"internalType":"string[]","name":"assetsSymbols","type":"string[]"},{"internalType":"string","name":"specificName","type":"string"},{"internalType":"string","name":"vaultSymbol","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"platform_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"address_","type":"address"}],"name":"isStrategy","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"platform","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress_","type":"address"},{"internalType":"string","name":"aliasName_","type":"string"}],"name":"setAliasName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"id","type":"string"},{"components":[{"internalType":"address[]","name":"initAddresses","type":"address[]"},{"internalType":"uint256[]","name":"initNums","type":"uint256[]"},{"internalType":"int24[]","name":"initTicks","type":"int24[]"}],"internalType":"struct IFactory.StrategyAvailableInitParams","name":"initParams","type":"tuple"}],"name":"setStrategyAvailableInitParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"id","type":"string"},{"internalType":"address","name":"implementation","type":"address"},{"internalType":"bool","name":"deployAllowed","type":"bool"},{"internalType":"bool","name":"upgradeAllowed","type":"bool"},{"internalType":"bool","name":"farming","type":"bool"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct IFactory.StrategyLogicConfig","name":"config","type":"tuple"},{"internalType":"address","name":"developer","type":"address"}],"name":"setStrategyLogicConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"vaultType","type":"string"},{"internalType":"address","name":"implementation","type":"address"},{"internalType":"bool","name":"deployAllowed","type":"bool"},{"internalType":"bool","name":"upgradeAllowed","type":"bool"},{"internalType":"uint256","name":"buildingPrice","type":"uint256"}],"internalType":"struct IFactory.VaultConfig","name":"vaultConfig_","type":"tuple"}],"name":"setVaultConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"vaults","type":"address[]"},{"internalType":"uint256[]","name":"statuses","type":"uint256[]"}],"name":"setVaultStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"strategies","outputs":[{"internalType":"string[]","name":"id","type":"string[]"},{"internalType":"bool[]","name":"deployAllowed","type":"bool[]"},{"internalType":"bool[]","name":"upgradeAllowed","type":"bool[]"},{"internalType":"bool[]","name":"farming","type":"bool[]"},{"internalType":"uint256[]","name":"tokenId","type":"uint256[]"},{"internalType":"string[]","name":"tokenURI","type":"string[]"},{"internalType":"bytes32[]","name":"extra","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"idHash","type":"bytes32"}],"name":"strategyAvailableInitParams","outputs":[{"components":[{"internalType":"address[]","name":"initAddresses","type":"address[]"},{"internalType":"uint256[]","name":"initNums","type":"uint256[]"},{"internalType":"int24[]","name":"initTicks","type":"int24[]"}],"internalType":"struct IFactory.StrategyAvailableInitParams","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"idHash","type":"bytes32"}],"name":"strategyLogicConfig","outputs":[{"components":[{"internalType":"string","name":"id","type":"string"},{"internalType":"address","name":"implementation","type":"address"},{"internalType":"bool","name":"deployAllowed","type":"bool"},{"internalType":"bool","name":"upgradeAllowed","type":"bool"},{"internalType":"bool","name":"farming","type":"bool"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct IFactory.StrategyLogicConfig","name":"config","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"strategyLogicIdHashes","outputs":[{"internalType":"bytes32[]","name":"","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"components":[{"internalType":"uint256","name":"status","type":"uint256"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"string","name":"strategyLogicId","type":"string"},{"internalType":"address[]","name":"rewardAssets","type":"address[]"},{"internalType":"address[]","name":"addresses","type":"address[]"},{"internalType":"uint256[]","name":"nums","type":"uint256[]"},{"internalType":"int24[]","name":"ticks","type":"int24[]"}],"internalType":"struct IFactory.Farm","name":"farm_","type":"tuple"}],"name":"updateFarm","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"strategyProxy","type":"address"}],"name":"upgradeStrategyProxy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"}],"name":"upgradeVaultProxy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"typeHash","type":"bytes32"}],"name":"vaultConfig","outputs":[{"internalType":"string","name":"vaultType","type":"string"},{"internalType":"address","name":"implementation","type":"address"},{"internalType":"bool","name":"deployAllowed","type":"bool"},{"internalType":"bool","name":"upgradeAllowed","type":"bool"},{"internalType":"uint256","name":"buildingPrice","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"}],"name":"vaultStatus","outputs":[{"internalType":"uint256","name":"status","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultTypes","outputs":[{"internalType":"string[]","name":"vaultType","type":"string[]"},{"internalType":"address[]","name":"implementation","type":"address[]"},{"internalType":"bool[]","name":"deployAllowed","type":"bool[]"},{"internalType":"bool[]","name":"upgradeAllowed","type":"bool[]"},{"internalType":"uint256[]","name":"buildingPrice","type":"uint256[]"},{"internalType":"bytes32[]","name":"extra","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"week","type":"uint256"},{"internalType":"uint256","name":"builderPermitTokenId","type":"uint256"}],"name":"vaultsBuiltByPermitTokenId","outputs":[{"internalType":"uint256","name":"vaultsBuilt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"whatToBuild","outputs":[{"internalType":"string[]","name":"desc","type":"string[]"},{"internalType":"string[]","name":"vaultType","type":"string[]"},{"internalType":"string[]","name":"strategyId","type":"string[]"},{"internalType":"uint256[10][]","name":"initIndexes","type":"uint256[10][]"},{"internalType":"address[]","name":"vaultInitAddresses","type":"address[]"},{"internalType":"uint256[]","name":"vaultInitNums","type":"uint256[]"},{"internalType":"address[]","name":"strategyInitAddresses","type":"address[]"},{"internalType":"uint256[]","name":"strategyInitNums","type":"uint256[]"},{"internalType":"int24[]","name":"strategyInitTicks","type":"int24[]"}],"stateMutability":"view","type":"function"}]

608060405234801562000010575f80fd5b506200001b62000021565b620000d5565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000725760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620000d25780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b615c4380620000e35f395ff3fe608060405234801561000f575f80fd5b506004361061021e575f3560e01c80637d474fa31161012a578063c56ebcd6116100b4578063dd7ff3db11610079578063dd7ff3db14610513578063e967f16b14610546578063f378d1d414610559578063f583734e14610561578063ffa1ad7414610585575f80fd5b8063c56ebcd61461049f578063d0cf0054146104bf578063d9f9027f146104d2578063db22d7a0146104ed578063dcc8051814610500575f80fd5b8063913b0870116100fa578063913b087014610416578063936725ec146104335780639ad87ce414610457578063b2d9688414610477578063c4d66de81461048c575f80fd5b80637d474fa3146103c8578063802779d0146103db578063871fd682146103ee57806389ec7a4114610403575f80fd5b80634593144c116101ab578063582a4d371161017b578063582a4d371461036957806358a2ab1c1461037c57806358e71ca21461038f5780636c2713a3146103a25780637031c482146103b5575f80fd5b80634593144c146103015780634ad97093146103095780634bde38c814610329578063538a85a114610349575f80fd5b806314e4380c116101f157806314e4380c146102885780632ad9ea9b146102ac5780632e8ebaae146102c157806336abf3dc146102d45780633adc774e146102ee575f80fd5b806301ffc9a714610222578063070d15671461024a5780630d9c8bcd1461026b5780630f038dcd14610273575b5f80fd5b610235610230366004613f19565b6105a9565b60405190151581526020015b60405180910390f35b61025d610258366004613f40565b6105df565b604051908152602001610241565b61025d610606565b61027b61061a565b6040516102419190613f9a565b61029b610296366004613fac565b610639565b604051610241959493929190614010565b6102bf6102ba3660046141f8565b61076c565b005b6102356102cf3660046142ae565b610809565b6102dc610836565b6040516102419695949392919061438a565b6102bf6102fc3660046142ae565b610c76565b61025d610d4d565b61031c6103173660046142ae565b610d85565b604051610241919061440b565b610331610e3c565b6040516001600160a01b039091168152602001610241565b61035c610357366004613fac565b610e6b565b60405161024191906144ef565b6102bf610377366004614753565b611146565b61025d61038a366004614796565b611270565b6102bf61039d3660046148a4565b611329565b6102bf6103b036600461497b565b611581565b6102bf6103c3366004614a4e565b61166b565b6103316103d6366004613fac565b61176b565b6102bf6103e9366004614aa3565b611792565b6103f661181a565b6040516102419190614ae5565b610331610411366004613fac565b611abf565b61041e611afb565b60405161024199989796959493929190614b47565b61031c604051806040016040528060058152602001640312e302e360dc1b81525081565b61046a610465366004613fac565b611bb0565b6040516102419190614c53565b61047f611d09565b6040516102419190614caa565b6102bf61049a3660046142ae565b611d72565b6104b26104ad366004613fac565b611e86565b6040516102419190614cbc565b61025d6104cd3660046142ae565b611fc6565b6104da611ff1565b6040516102419796959493929190614d23565b61025d6104fb366004614db9565b61257b565b6102bf61050e3660046142ae565b6125fb565b610526610521366004614796565b612690565b604080516001600160a01b03938416815292909116602083015201610241565b6102bf610554366004614df2565b61356d565b61025d6136b2565b61057461056f366004614e9b565b6136c6565b604051610241959493929190614efa565b61031c604051806040016040528060058152602001640312e322e360dc1b81525081565b5f6001600160e01b03198216630f1ec81f60e41b14806105d957506301ffc9a760e01b6001600160e01b03198316145b92915050565b5f6105e8613767565b5f938452600901602090815260408085209385529290525090205490565b5f80610610613767565b600a015492915050565b60605f610625613767565b90506106338160070161378b565b91505090565b60605f805f805f610648613767565b90505f815f015f8981526020019081526020015f206040518060a00160405290815f8201805461067790614f5a565b80601f01602080910402602001604051908101604052809291908181526020018280546106a390614f5a565b80156106ee5780601f106106c5576101008083540402835291602001916106ee565b820191905f5260205f20905b8154815290600101906020018083116106d157829003601f168201915b505050918352505060018201546001600160a01b03811660208084019190915260ff600160a01b830481161515604080860191909152600160a81b90930416151560608085019190915260029094015460809384015284519085015191850151938501519490920151919c909b509199509197509095509350505050565b61077461379e565b5f61077d613767565b6040516305091ded60e01b81529091507306e0912b4f2e36cfcf9556478352afc2d991919f906305091ded906107b99084908690600401614f92565b602060405180830381865af41580156107d4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107f89190614ff4565b156108055761080561382d565b5050565b5f610812613767565b6001600160a01b039092165f90815260049290920160205250604090205460ff1690565b6060806060806060805f610848613767565b90505f6108578260050161378b565b8051909150806001600160401b038111156108745761087461404f565b6040519080825280602002602001820160405280156108a757816020015b60608152602001906001900390816108925790505b509850806001600160401b038111156108c2576108c261404f565b6040519080825280602002602001820160405280156108eb578160200160208202803683370190505b509750806001600160401b038111156109065761090661404f565b60405190808252806020026020018201604052801561092f578160200160208202803683370190505b509650806001600160401b0381111561094a5761094a61404f565b604051908082528060200260200182016040528015610973578160200160208202803683370190505b509550806001600160401b0381111561098e5761098e61404f565b6040519080825280602002602001820160405280156109b7578160200160208202803683370190505b509450806001600160401b038111156109d2576109d261404f565b6040519080825280602002602001820160405280156109fb578160200160208202803683370190505b5093505f5b81811015610c6a575f845f015f858481518110610a1f57610a1f61500f565b602002602001015181526020019081526020015f206040518060a00160405290815f82018054610a4e90614f5a565b80601f0160208091040260200160405190810160405280929190818152602001828054610a7a90614f5a565b8015610ac55780601f10610a9c57610100808354040283529160200191610ac5565b820191905f5260205f20905b815481529060010190602001808311610aa857829003601f168201915b505050918352505060018201546001600160a01b038116602083015260ff600160a01b8204811615156040840152600160a81b909104161515606082015260029091015460809091015280518c51919250908c9084908110610b2957610b2961500f565b602002602001018190525080602001518a8381518110610b4b57610b4b61500f565b60200260200101906001600160a01b031690816001600160a01b0316815250508060400151898381518110610b8257610b8261500f565b6020026020010190151590811515815250508060600151888381518110610bab57610bab61500f565b6020026020010190151590811515815250508060800151878381518110610bd457610bd461500f565b60200260200101818152505080602001516001600160a01b031663190024e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c20573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c449190615023565b868381518110610c5657610c5661500f565b602090810291909101015250600101610a00565b50505050909192939495565b610c7e613948565b5f610c87613767565b6001600160a01b0383165f908152600382016020526040902054909150600114610cc457604051630d7abd6f60e31b815260040160405180910390fd5b604051637817605360e01b8152600481018290526001600160a01b03831660248201527306e0912b4f2e36cfcf9556478352afc2d991919f906378176053906044015b5f6040518083038186803b158015610d1d575f80fd5b505af4158015610d2f573d5f803e3d5ffd5b5050505050610d4a60015f80516020615bee83398151915255565b50565b5f610d80610d7c60017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f161504e565b5490565b905090565b60605f610d90613767565b6001600160a01b0384165f908152600d820160205260409020805491925090610db890614f5a565b80601f0160208091040260200160405190810160405280929190818152602001828054610de490614f5a565b8015610e2f5780601f10610e0657610100808354040283529160200191610e2f565b820191905f5260205f20905b815481529060010190602001808311610e1257829003601f168201915b5050505050915050919050565b5f610d80610d7c60017faa116a42804728f23983458454b6eb9c6ddf3011db9f9addaf3cd7508d85b0d661504e565b610eb26040518060e001604052805f81526020015f6001600160a01b0316815260200160608152602001606081526020016060815260200160608152602001606081525090565b5f610ebb613767565b905080600b018381548110610ed257610ed261500f565b905f5260205f2090600702016040518060e00160405290815f8201548152602001600182015f9054906101000a90046001600160a01b03166001600160a01b03166001600160a01b03168152602001600282018054610f3090614f5a565b80601f0160208091040260200160405190810160405280929190818152602001828054610f5c90614f5a565b8015610fa75780601f10610f7e57610100808354040283529160200191610fa7565b820191905f5260205f20905b815481529060010190602001808311610f8a57829003601f168201915b505050505081526020016003820180548060200260200160405190810160405280929190818152602001828054801561100757602002820191905f5260205f20905b81546001600160a01b03168152600190910190602001808311610fe9575b505050505081526020016004820180548060200260200160405190810160405280929190818152602001828054801561106757602002820191905f5260205f20905b81546001600160a01b03168152600190910190602001808311611049575b50505050508152602001600582018054806020026020016040519081016040528092919081815260200182805480156110bd57602002820191905f5260205f20905b8154815260200190600101908083116110a9575b505050505081526020016006820180548060200260200160405190810160405280929190818152602001828054801561113557602002820191905f5260205f20905f905b825461010083900a900460020b81526020600583018190049384019360010360039093019290920291018084116111015790505b505050505081525050915050919050565b61114e61379e565b5f611157613767565b90508181600b01848154811061116f5761116f61500f565b5f918252602091829020835160079290920201908155908201516001820180546001600160a01b0319166001600160a01b03909216919091179055604082015160028201906111be90826150a5565b50606082015180516111da916003840191602090910190613dc6565b50608082015180516111f6916004840191602090910190613dc6565b5060a08201518051611212916005840191602090910190613e29565b5060c0820151805161122e916006840191602090910190613e62565b509050507f4e8499c72391533d62e187d3f07fc288fbc1742c8e094f36b5e23b836bb29e898383604051611263929190615160565b60405180910390a1505050565b6040805160a08101825260018082525f602083018190528284018290526060830191909152608082018190529151636c309d4f60e11b81527306e0912b4f2e36cfcf9556478352afc2d991919f9163d8613a9e916112de918c918c918c918c918c918c918c9160040161519d565b602060405180830381865af41580156112f9573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061131d9190615023565b98975050505050505050565b61133161379e565b611339613948565b5f611342613767565b835180516020918201205f81815260018085019093526040902091820154929350916001600160a01b0316611455575f61137a610e3c565b6001600160a01b031663878571d76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113b5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113d99190615264565b865160405163d0def52160e01b81526001600160a01b03929092169163d0def5219161140a9189919060040161527f565b6020604051808303815f875af1158015611426573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061144a9190615023565b60a087015250611460565b600281015460a08601525b5f82815260018401602052604090208551869190819061148090826150a5565b5060208201516001820180546040850151606086015160808701511515600160b01b0260ff60b01b19911515600160a81b029190911661ffff60a81b19921515600160a01b026001600160a81b03199094166001600160a01b039096169590951792909217169290921791909117905560a0909101516002909101555f61150a6007850184613992565b9050806115195761151961382d565b7f1c1fdd0257172a2ae0d1ea8726dc737597d11e8c6739357cb5015e6d6921fb04865f01518760200151886040015189606001518560405161155f9594939291906152a2565b60405180910390a15050505061080560015f80516020615bee83398151915255565b61158961379e565b5f611592613767565b90505f836040516020016115a691906152e3565b60408051601f1981840301815291815281516020928301205f818152600c860184529190912085518051929450869391926115e49284920190613dc6565b5060208281015180516115fd9260018501920190613e29565b5060408201518051611619916002840191602090910190613e62565b509050507fba197f5223035cb2b7a0f09844df05667b65b529665865bd98232748de75970b84845f01518560200151866040015160405161165d94939291906152fe565b60405180910390a150505050565b61167361382d565b5f61167c613767565b83519091505f5b818110156117645783818151811061169d5761169d61500f565b6020026020010151836003015f8784815181106116bc576116bc61500f565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f20819055508481815181106116f9576116f961500f565b60200260200101516001600160a01b03167fd518071c0dca755922e3df4b2f1457ed64340814d52371e060a067edd0a9578a85838151811061173d5761173d61500f565b602002602001015160405161175491815260200190565b60405180910390a2600101611683565b5050505050565b5f80611775613767565b5f938452600201602052505060409020546001600160a01b031690565b5f61179b613767565b6001600160a01b0384165f908152600d8201602052604090209091506117c183826150a5565b506001600160a01b0383165f818152600d8301602052604090819020905133917ff49a01196694c79ef713003d9b31096f281da2dc63510685349a167d876235bd9161180d9190615355565b60405180910390a3505050565b60605f611825613767565b600b81018054604080516020808402820181019092528281529394505f9084015b82821015611ab5575f8481526020908190206040805160e081018252600786029092018054835260018101546001600160a01b0316938301939093526002830180549293929184019161189890614f5a565b80601f01602080910402602001604051908101604052809291908181526020018280546118c490614f5a565b801561190f5780601f106118e65761010080835404028352916020019161190f565b820191905f5260205f20905b8154815290600101906020018083116118f257829003601f168201915b505050505081526020016003820180548060200260200160405190810160405280929190818152602001828054801561196f57602002820191905f5260205f20905b81546001600160a01b03168152600190910190602001808311611951575b50505050508152602001600482018054806020026020016040519081016040528092919081815260200182805480156119cf57602002820191905f5260205f20905b81546001600160a01b031681526001909101906020018083116119b1575b5050505050815260200160058201805480602002602001604051908101604052809291908181526020018280548015611a2557602002820191905f5260205f20905b815481526020019060010190808311611a11575b5050505050815260200160068201805480602002602001604051908101604052809291908181526020018280548015611a9d57602002820191905f5260205f20905f905b825461010083900a900460020b8152602060058301819004938401936001036003909301929092029101808411611a695790505b50505050508152505081526020019060010190611846565b5050505091505090565b5f80611ac9613767565b905080600a018381548110611ae057611ae061500f565b5f918252602090912001546001600160a01b03169392505050565b60608060608060608060608060607306e0912b4f2e36cfcf9556478352afc2d991919f632c1172ae611b2b610e3c565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526024015f60405180830381865af4158015611b6c573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052611b939190810190615669565b985098509850985098509850985098509850909192939495969798565b611bd460405180606001604052806060815260200160608152602001606081525090565b5f611bdd613767565b5f848152600c8201602090815260409182902082518154608093810282018401909452606081018481529495509390928492849190840182828015611c4957602002820191905f5260205f20905b81546001600160a01b03168152600190910190602001808311611c2b575b5050505050815260200160018201805480602002602001604051908101604052809291908181526020018280548015611c9f57602002820191905f5260205f20905b815481526020019060010190808311611c8b575b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015611135575f918252602091829020805460020b8452908202830192909160039101808411611101579050505050505081525050915050919050565b60605f611d14613767565b600a8101805460408051602080840282018101909252828152939450830182828015611d6757602002820191905f5260205f20905b81546001600160a01b03168152600190910190602001808311611d49575b505050505091505090565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b03165f81158015611db65750825b90505f826001600160401b03166001148015611dd15750303b155b905081158015611ddf575080155b15611dfd5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315611e2757845460ff60401b1916600160401b1785555b611e308661399d565b611e38613af8565b8315611e7e57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b6040805160c08101825260608082525f6020830181905292820183905281018290526080810182905260a0810182905290611ebf613767565b9050806001015f8481526020019081526020015f206040518060c00160405290815f82018054611eee90614f5a565b80601f0160208091040260200160405190810160405280929190818152602001828054611f1a90614f5a565b8015611f655780601f10611f3c57610100808354040283529160200191611f65565b820191905f5260205f20905b815481529060010190602001808311611f4857829003601f168201915b505050918352505060018201546001600160a01b038116602083015260ff600160a01b8204811615156040840152600160a81b8204811615156060840152600160b01b909104161515608082015260029091015460a0909101529392505050565b5f80611fd0613767565b6001600160a01b039093165f90815260039093016020525050604090205490565b60608060608060608060605f612005613767565b90505f6120148260070161378b565b8051909150806001600160401b038111156120315761203161404f565b60405190808252806020026020018201604052801561206457816020015b606081526020019060019003908161204f5790505b509950806001600160401b0381111561207f5761207f61404f565b6040519080825280602002602001820160405280156120a8578160200160208202803683370190505b509850806001600160401b038111156120c3576120c361404f565b6040519080825280602002602001820160405280156120ec578160200160208202803683370190505b509750806001600160401b038111156121075761210761404f565b604051908082528060200260200182016040528015612130578160200160208202803683370190505b509650806001600160401b0381111561214b5761214b61404f565b604051908082528060200260200182016040528015612174578160200160208202803683370190505b509550806001600160401b0381111561218f5761218f61404f565b6040519080825280602002602001820160405280156121c257816020015b60608152602001906001900390816121ad5790505b509450806001600160401b038111156121dd576121dd61404f565b604051908082528060200260200182016040528015612206578160200160208202803683370190505b5093505f612212610e3c565b6001600160a01b031663878571d76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561224d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906122719190615264565b90505f5b8281101561256d575f856001015f8684815181106122955761229561500f565b602002602001015181526020019081526020015f206040518060c00160405290815f820180546122c490614f5a565b80601f01602080910402602001604051908101604052809291908181526020018280546122f090614f5a565b801561233b5780601f106123125761010080835404028352916020019161233b565b820191905f5260205f20905b81548152906001019060200180831161231e57829003601f168201915b505050918352505060018201546001600160a01b038116602083015260ff600160a01b8204811615156040840152600160a81b8204811615156060840152600160b01b909104161515608082015260029091015460a09091015280518e51919250908e90849081106123af576123af61500f565b602002602001018190525080604001518c83815181106123d1576123d161500f565b60200260200101901515908115158152505080606001518b83815181106123fa576123fa61500f565b60200260200101901515908115158152505080608001518a83815181106124235761242361500f565b6020026020010190151590811515815250508060a0015189838151811061244c5761244c61500f565b602090810291909101015260a081015160405163c87b56dd60e01b815260048101919091526001600160a01b0384169063c87b56dd906024015f60405180830381865afa15801561249f573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526124c691908101906157be565b8883815181106124d8576124d861500f565b602002602001018190525080602001516001600160a01b031663190024e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612523573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906125479190615023565b8783815181106125595761255961500f565b602090810291909101015250600101612275565b505050505090919293949596565b5f7306e0912b4f2e36cfcf9556478352afc2d991919f63e551e36a61259e610e3c565b846040518363ffffffff1660e01b81526004016125bc9291906157ef565b602060405180830381865af41580156125d7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105d99190615023565b612603613948565b5f61260c613767565b6001600160a01b0383165f90815260048201602052604090205490915060ff16612649576040516359935c8f60e11b815260040160405180910390fd5b604051630a1cb54360e41b8152600481018290526001600160a01b03831660248201527306e0912b4f2e36cfcf9556478352afc2d991919f9063a1cb543090604401610d07565b5f8061269a613948565b5f6126a3613767565b905061273c60408051610240810190915260606101a082019081525f6101c083018190526101e083018190526102008301819052610220830152819081525f602082018190526040820181905260608083018190526080830181905260a0830181905260c0830181905260e083015261010082018190526101208201819052610140820181905261016082018190526101809091015290565b815f015f8c60405160200161275191906152e3565b6040516020818303038152906040528051906020012081526020019081526020015f206040518060a00160405290815f8201805461278e90614f5a565b80601f01602080910402602001604051908101604052809291908181526020018280546127ba90614f5a565b80156128055780601f106127dc57610100808354040283529160200191612805565b820191905f5260205f20905b8154815290600101906020018083116127e857829003601f168201915b505050918352505060018201546001600160a01b0380821660208085019190915260ff600160a01b8404811615156040860152600160a81b9093049092161515606084015260029093015460809092019190915282845291909101511661287f57604051634b94d18160e11b815260040160405180910390fd5b8051604001516128a25760405163221da53360e21b815260040160405180910390fd5b89516020808c0191909120908201526128b9610e3c565b6001600160a01b031660408083018290528051630b3a3c4160e21b81529051632ce8f104916004808201926020929091908290030181865afa158015612901573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129259190615264565b8161012001906001600160a01b031690816001600160a01b03168152505080604001516001600160a01b0316636f460dc86040518163ffffffff1660e01b8152600401602060405180830381865afa158015612983573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129a79190615264565b6001600160a01b039081166101408301526020808301515f908152600180860190925260409020908101549091166129f2576040516303022b7560e11b815260040160405180910390fd5b6001810154600160a01b900460ff16612a1e5760405163e0eb421d60e01b815260040160405180910390fd5b6101208201516001600160a01b031615612ba0576101208201516040516370a0823160e01b81523360048201525f916001600160a01b0316906370a0823190602401602060405180830381865afa158015612a7b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612a9f9190615023565b90505f5b81811015612b9d57610120840151604051632f745c5960e01b8152336004820152602481018390525f916001600160a01b031690632f745c5990604401602060405180830381865afa158015612afb573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612b1f9190615023565b90505f612b2f62093a8042615812565b5f81815260098901602090815260408083208684529091529020549091506001811015612b8f57612b61816001615831565b5f92835260098901602090815260408085209585529490529290912091909155506001610160850152612b9d565b505050806001019050612aa3565b50505b816101600151612d53576101408201516040516370a0823160e01b81523360048201525f916001600160a01b0316906370a0823190602401602060405180830381865afa158015612bf3573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c179190615023565b835160800151909150811015612ccc5780835f01516080015184604001516001600160a01b0316636f460dc86040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c70573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c949190615264565b60405163417db01960e01b8152600481019390935260248301919091526001600160a01b031660448201526064015b60405180910390fd5b612d513384604001516001600160a01b0316634783c35b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d10573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612d349190615264565b8551608001516101408701516001600160a01b0316929190613b08565b505b5f7329613385f8808a04e593163a2867f3f3d4a1bd8b63500937666040518163ffffffff1660e01b8152600401602060405180830381865af4158015612d9b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612dbf9190615264565b9050806001600160a01b031663cc316e998e6040518263ffffffff1660e01b8152600401612ded919061440b565b5f604051808303815f87803b158015612e04575f80fd5b505af1158015612e16573d5f803e3d5ffd5b505050505f7329613385f8808a04e593163a2867f3f3d4a1bd8b63bcea050b6040518163ffffffff1660e01b8152600401602060405180830381865af4158015612e62573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612e869190615264565b9050806001600160a01b031663670855198e6040518263ffffffff1660e01b8152600401612eb4919061440b565b5f604051808303815f87803b158015612ecb575f80fd5b505af1158015612edd573d5f803e3d5ffd5b50508b519398509196505f9150612ef79050826002615831565b6001600160401b03811115612f0e57612f0e61404f565b604051908082528060200260200182016040528015612f37578160200160208202803683370190505b5090508360400151815f81518110612f5157612f5161500f565b60200260200101906001600160a01b031690816001600160a01b0316815250508681600181518110612f8557612f8561500f565b6001600160a01b039092166020928302919091019091015260025b612fab836002615831565b811015613008578a612fbe60028361504e565b81518110612fce57612fce61500f565b6020026020010151828281518110612fe857612fe861500f565b6001600160a01b0390921660209283029190910190910152600101612fa0565b50604051630835ffd760e31b81526001600160a01b038716906341affeb8906130399084908d908d90600401615844565b5f604051808303815f87803b158015613050575f80fd5b505af1158015613062573d5f803e3d5ffd5b505050506130758e8e8e8e8e8e8e611270565b61010085018190525f9081526002860160205260409020546001600160a01b0316156130bd5783610100015160405163db7e59bd60e01b8152600401612cc391815260200190565b50506130f18c855f8d51116130d2575f6136c6565b8c5f815181106130e4576130e461500f565b60200260200101516136c6565b60e087015260c08601526080850181905260608501919091526040516303bf572560e31b81527306e0912b4f2e36cfcf9556478352afc2d991919f925063d0d34fa4918f918f91734f76add676c04eca837130ceb58bc173de8799de91631dfab928916131609160040161587c565b5f60405180830381865af415801561317a573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526131a191908101906157be565b8660c001518f6040518663ffffffff1660e01b81526004016131c79594939291906158f9565b5f60405180830381865af41580156131e1573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261320891908101906157be565b8260a0018190525081604001516001600160a01b0316638a4adf246040518163ffffffff1660e01b8152600401602060405180830381865afa158015613250573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906132749190615264565b60405163ee1fe2ad60e01b81523360048201526001600160a01b038781166024830152919091169063ee1fe2ad906044016020604051808303815f875af11580156132c1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906132e59190615023565b61018083019081526040805160e08082018352828601516001600160a01b039081168352888116602084015260a080880151848601529187015160608401529351608083015281018d905260c081018c9052905163a50c8dd160e01b81529187169163a50c8dd19161335991600401615959565b5f604051808303815f87803b158015613370575f80fd5b505af1158015613382573d5f803e3d5ffd5b5050505082600a0185908060018154018082558091505060019003905f5260205f20015f9091909190916101000a8154816001600160a01b0302191690836001600160a01b031602179055506001836003015f876001600160a01b03166001600160a01b031681526020019081526020015f20819055506001836004015f866001600160a01b03166001600160a01b031681526020019081526020015f205f6101000a81548160ff02191690831515021790555084836002015f84610100015181526020019081526020015f205f6101000a8154816001600160a01b0302191690836001600160a01b031602179055507306e0912b4f2e36cfcf9556478352afc2d991919f631b4c3fdd8360400151878f8e8e6040518663ffffffff1660e01b81526004016134b5959493929190615a05565b5f6040518083038186803b1580156134cb575f80fd5b505af41580156134dd573d5f803e3d5ffd5b50505050336001600160a01b03167fe16a12ed0c6ee928f7ee5c5799175c728255adae06a81e8bec85c9d909af61338d8d88888760a001518860e0015189606001518a61010001518b610180015160405161354099989796959493929190615a56565b60405180910390a250505061356160015f80516020615bee83398151915255565b97509795505050505050565b61357561379e565b5f61357e613767565b82519091505f5b818110156136825782600b018482815181106135a3576135a361500f565b6020908102919091018101518254600180820185555f9485529383902082516007909202019081559181015192820180546001600160a01b0319166001600160a01b03909416939093179092556040820151600282019061360490826150a5565b5060608201518051613620916003840191602090910190613dc6565b506080820151805161363c916004840191602090910190613dc6565b5060a08201518051613658916005840191602090910190613e29565b5060c08201518051613674916006840191602090910190613e62565b505050806001019050613585565b507fad29862e9f0d865f275139a684250d15b3351b00a75fdfae159b837289c19bf5836040516112639190614ae5565b5f806136bc613767565b600b015492915050565b6060806060806060733110a397362465b6ad45703de9dea2cc2ae6c3b363046bcb508989896136f3610e3c565b6040518563ffffffff1660e01b81526004016137129493929190615aea565b5f60405180830381865af415801561372c573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526137539190810190615b25565b939c929b5090995097509095509350505050565b7f94b53192a2415b53b438d03f0efa946204c0118192627e3d5ed4ba034c9a030090565b60605f61379783613b68565b9392505050565b6137a6610e3c565b6040516336b87bd760e11b81523360048201526001600160a01b039190911690636d70f7ae90602401602060405180830381865afa1580156137ea573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061380e9190614ff4565b61382b57604051631f0853c160e21b815260040160405180910390fd5b565b5f613836610e3c565b9050336001600160a01b0316816001600160a01b0316635aa6e6756040518163ffffffff1660e01b8152600401602060405180830381865afa15801561387e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906138a29190615264565b6001600160a01b03161415801561392a5750336001600160a01b0316816001600160a01b0316634783c35b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156138fa573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061391e9190615264565b6001600160a01b031614155b15610d4a576040516354299b6f60e01b815260040160405180910390fd5b5f80516020615bee83398151915280546001190161397957604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b60015f80516020615bee83398151915255565b5f6137978383613bc1565b6139a5613c0d565b6001600160a01b0381161580613a2b57505f6001600160a01b0316816001600160a01b0316634783c35b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156139fc573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613a209190615264565b6001600160a01b0316145b15613a49576040516371c42ac360e01b815260040160405180910390fd5b613a7c613a7760017faa116a42804728f23983458454b6eb9c6ddf3011db9f9addaf3cd7508d85b0d661504e565b829055565b613aae43613aab60017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f161504e565b55565b604080516001600160a01b0383168152426020820152438183015290517f1a2dd071001ebf6e03174e3df5b305795a4ad5d41d8fdb9ba41dbbe2367134269181900360600190a150565b613b00613c0d565b61382b613c56565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052613b62908590613c5e565b50505050565b6060815f01805480602002602001604051908101604052809291908181526020018280548015613bb557602002820191905f5260205f20905b815481526020019060010190808311613ba1575b50505050509050919050565b5f818152600183016020526040812054613c0657508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556105d9565b505f6105d9565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661382b57604051631afcd79f60e31b815260040160405180910390fd5b61397f613c0d565b5f613c726001600160a01b03841683613cc4565b905080515f14158015613c96575080806020019051810190613c949190614ff4565b155b15613cbf57604051635274afe760e01b81526001600160a01b0384166004820152602401612cc3565b505050565b606061379783835f845f80856001600160a01b03168486604051613ce891906152e3565b5f6040518083038185875af1925050503d805f8114613d22576040519150601f19603f3d011682016040523d82523d5f602084013e613d27565b606091505b5091509150613d37868383613d41565b9695505050505050565b606082613d5657613d5182613d9d565b613797565b8151158015613d6d57506001600160a01b0384163b155b15613d9657604051639996b31560e01b81526001600160a01b0385166004820152602401612cc3565b5080613797565b805115613dad5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b828054828255905f5260205f20908101928215613e19579160200282015b82811115613e1957825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613de4565b50613e25929150613f05565b5090565b828054828255905f5260205f20908101928215613e19579160200282015b82811115613e19578251825591602001919060010190613e47565b828054828255905f5260205f2090600901600a90048101928215613e19579160200282015f5b83821115613ecd57835183826101000a81548162ffffff021916908360020b62ffffff1602179055509260200192600301602081600201049283019260010302613e88565b8015613efc5782816101000a81549062ffffff0219169055600301602081600201049283019260010302613ecd565b5050613e259291505b5b80821115613e25575f8155600101613f06565b5f60208284031215613f29575f80fd5b81356001600160e01b031981168114613797575f80fd5b5f8060408385031215613f51575f80fd5b50508035926020909101359150565b5f815180845260208085019450602084015f5b83811015613f8f57815187529582019590820190600101613f73565b509495945050505050565b602081525f6137976020830184613f60565b5f60208284031215613fbc575f80fd5b5035919050565b5f5b83811015613fdd578181015183820152602001613fc5565b50505f910152565b5f8151808452613ffc816020860160208601613fc3565b601f01601f19169290920160200192915050565b60a081525f61402260a0830188613fe5565b6001600160a01b039690961660208301525092151560408401529015156060830152608090910152919050565b634e487b7160e01b5f52604160045260245ffd5b60405160a081016001600160401b03811182821017156140855761408561404f565b60405290565b60405160e081016001600160401b03811182821017156140855761408561404f565b60405160c081016001600160401b03811182821017156140855761408561404f565b604051606081016001600160401b03811182821017156140855761408561404f565b60405161014081016001600160401b03811182821017156140855761408561404f565b604051601f8201601f191681016001600160401b038111828210171561413c5761413c61404f565b604052919050565b5f6001600160401b0382111561415c5761415c61404f565b50601f01601f191660200190565b5f82601f830112614179575f80fd5b813561418c61418782614144565b614114565b8181528460208386010111156141a0575f80fd5b816020850160208301375f918101602001919091529392505050565b6001600160a01b0381168114610d4a575f80fd5b80356141db816141bc565b919050565b8015158114610d4a575f80fd5b80356141db816141e0565b5f60208284031215614208575f80fd5b81356001600160401b038082111561421e575f80fd5b9083019060a08286031215614231575f80fd5b614239614063565b823582811115614247575f80fd5b6142538782860161416a565b82525060208301359150614266826141bc565b8160208201526040830135915061427c826141e0565b81604082015260608301359150614292826141e0565b8160608201526080830135608082015280935050505092915050565b5f602082840312156142be575f80fd5b8135613797816141bc565b5f8282518085526020808601955060208260051b840101602086015f5b8481101561431457601f19868403018952614302838351613fe5565b988401989250908301906001016142e6565b5090979650505050505050565b5f815180845260208085019450602084015f5b83811015613f8f5781516001600160a01b031687529582019590820190600101614334565b5f815180845260208085019450602084015f5b83811015613f8f57815115158752958201959082019060010161436c565b60c081525f61439c60c08301896142c9565b82810360208401526143ae8189614321565b905082810360408401526143c28188614359565b905082810360608401526143d68187614359565b905082810360808401526143ea8186613f60565b905082810360a08401526143fe8185613f60565b9998505050505050505050565b602081525f6137976020830184613fe5565b5f815180845260208085019450602084015f5b83811015613f8f57815160020b87529582019590820190600101614430565b8051825260018060a01b0360208201511660208301525f604082015160e0604085015261447f60e0850182613fe5565b9050606083015184820360608601526144988282614321565b915050608083015184820360808601526144b28282614321565b91505060a083015184820360a08601526144cc8282613f60565b91505060c083015184820360c08601526144e6828261441d565b95945050505050565b602081525f613797602083018461444f565b5f6001600160401b038211156145195761451961404f565b5060051b60200190565b5f82601f830112614532575f80fd5b8135602061454261418783614501565b8083825260208201915060208460051b870101935086841115614563575f80fd5b602086015b8481101561458857803561457b816141bc565b8352918301918301614568565b509695505050505050565b5f82601f8301126145a2575f80fd5b813560206145b261418783614501565b8083825260208201915060208460051b8701019350868411156145d3575f80fd5b602086015b8481101561458857803583529183019183016145d8565b8060020b8114610d4a575f80fd5b5f82601f83011261460c575f80fd5b8135602061461c61418783614501565b8083825260208201915060208460051b87010193508684111561463d575f80fd5b602086015b84811015614588578035614655816145ef565b8352918301918301614642565b5f60e08284031215614672575f80fd5b61467a61408b565b90508135815261468c602083016141d0565b602082015260408201356001600160401b03808211156146aa575f80fd5b6146b68583860161416a565b604084015260608401359150808211156146ce575f80fd5b6146da85838601614523565b606084015260808401359150808211156146f2575f80fd5b6146fe85838601614523565b608084015260a0840135915080821115614716575f80fd5b61472285838601614593565b60a084015260c084013591508082111561473a575f80fd5b50614747848285016145fd565b60c08301525092915050565b5f8060408385031215614764575f80fd5b8235915060208301356001600160401b03811115614780575f80fd5b61478c85828601614662565b9150509250929050565b5f805f805f805f60e0888a0312156147ac575f80fd5b87356001600160401b03808211156147c2575f80fd5b6147ce8b838c0161416a565b985060208a01359150808211156147e3575f80fd5b6147ef8b838c0161416a565b975060408a0135915080821115614804575f80fd5b6148108b838c01614523565b965060608a0135915080821115614825575f80fd5b6148318b838c01614593565b955060808a0135915080821115614846575f80fd5b6148528b838c01614523565b945060a08a0135915080821115614867575f80fd5b6148738b838c01614593565b935060c08a0135915080821115614888575f80fd5b506148958a828b016145fd565b91505092959891949750929550565b5f80604083850312156148b5575f80fd5b82356001600160401b03808211156148cb575f80fd5b9084019060c082870312156148de575f80fd5b6148e66140ad565b8235828111156148f4575f80fd5b6149008882860161416a565b82525060208301359150614913826141bc565b81602082015260408301359150614929826141e0565b8160408201526060830135915061493f826141e0565b816060820152614951608084016141ed565b608082015260a083013560a0820152809450505050614972602084016141d0565b90509250929050565b5f806040838503121561498c575f80fd5b82356001600160401b03808211156149a2575f80fd5b6149ae8683870161416a565b935060208501359150808211156149c3575f80fd5b90840190606082870312156149d6575f80fd5b6149de6140cf565b8235828111156149ec575f80fd5b6149f888828601614523565b825250602083013582811115614a0c575f80fd5b614a1888828601614593565b602083015250604083013582811115614a2f575f80fd5b614a3b888286016145fd565b6040830152508093505050509250929050565b5f8060408385031215614a5f575f80fd5b82356001600160401b0380821115614a75575f80fd5b614a8186838701614523565b93506020850135915080821115614a96575f80fd5b5061478c85828601614593565b5f8060408385031215614ab4575f80fd5b8235614abf816141bc565b915060208301356001600160401b03811115614ad9575f80fd5b61478c8582860161416a565b5f60208083016020845280855180835260408601915060408160051b8701019250602087015f5b82811015614b3a57603f19888603018452614b2885835161444f565b94509285019290850190600101614b0c565b5092979650505050505050565b5f610120808352614b5a8184018d6142c9565b9050602083820381850152614b6f828d6142c9565b91508382036040850152614b83828c6142c9565b84810360608601528a51808252828c019350908201905f5b81811015614bdc578451835f5b600a811015614bc557825182529186019190860190600101614ba8565b505050938301936101409290920191600101614b9b565b50508481036080860152614bf0818b614321565b9250505082810360a0840152614c068188613f60565b905082810360c0840152614c1a8187614321565b905082810360e0840152614c2e8186613f60565b9050828103610100840152614c43818561441d565b9c9b505050505050505050505050565b602081525f825160606020840152614c6e6080840182614321565b90506020840151601f1980858403016040860152614c8c8383613f60565b92506040860151915080858403016060860152506144e6828261441d565b602081525f6137976020830184614321565b602081525f825160c06020840152614cd760e0840182613fe5565b905060018060a01b0360208501511660408401526040840151151560608401526060840151151560808401526080840151151560a084015260a084015160c08401528091505092915050565b60e081525f614d3560e083018a6142c9565b8281036020840152614d47818a614359565b90508281036040840152614d5b8189614359565b90508281036060840152614d6f8188614359565b90508281036080840152614d838187613f60565b905082810360a0840152614d9781866142c9565b905082810360c0840152614dab8185613f60565b9a9950505050505050505050565b5f60208284031215614dc9575f80fd5b81356001600160401b03811115614dde575f80fd5b614dea84828501614523565b949350505050565b5f6020808385031215614e03575f80fd5b82356001600160401b0380821115614e19575f80fd5b818501915085601f830112614e2c575f80fd5b8135614e3a61418782614501565b81815260059190911b83018401908481019088831115614e58575f80fd5b8585015b83811015614e8e57803585811115614e72575f80fd5b614e808b89838a0101614662565b845250918601918601614e5c565b5098975050505050505050565b5f805f60608486031215614ead575f80fd5b83356001600160401b03811115614ec2575f80fd5b614ece8682870161416a565b9350506020840135614edf816141bc565b91506040840135614eef816141bc565b809150509250925092565b60a081525f614f0c60a0830188613fe5565b8281036020840152614f1e8188614321565b90508281036040840152614f3281876142c9565b90508281036060840152614f468186613fe5565b9050828103608084015261131d8185613fe5565b600181811c90821680614f6e57607f821691505b602082108103614f8c57634e487b7160e01b5f52602260045260245ffd5b50919050565b828152604060208201525f825160a06040840152614fb360e0840182613fe5565b905060018060a01b0360208501511660608401526040840151151560808401526060840151151560a0840152608084015160c0840152809150509392505050565b5f60208284031215615004575f80fd5b8151613797816141e0565b634e487b7160e01b5f52603260045260245ffd5b5f60208284031215615033575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b818103818111156105d9576105d961503a565b601f821115613cbf57805f5260205f20601f840160051c810160208510156150865750805b601f840160051c820191505b81811015611764575f8155600101615092565b81516001600160401b038111156150be576150be61404f565b6150d2816150cc8454614f5a565b84615061565b602080601f831160018114615105575f84156150ee5750858301515b5f19600386901b1c1916600185901b178555611e7e565b5f85815260208120601f198616915b8281101561513357888601518255948401946001909101908401615114565b508582101561515057878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b828152604060208201525f614dea604083018461444f565b805f5b6005811015613b6257815160ff1684526020938401939091019060010161517b565b5f6101808083526151b08184018c613fe5565b9050602083820360208501526151c6828c613fe5565b915083820360408501526151da828b614321565b915083820360608501526151ee828a613f60565b915083820360808501526152028289614321565b915083820360a08501526152168288613f60565b84810360c0860152865180825260208089019450909101905f5b8181101561524f57845160020b83529383019391830191600101615230565b50508093505050506143fe60e0830184615178565b5f60208284031215615274575f80fd5b8151613797816141bc565b6001600160a01b03831681526040602082018190525f90614dea90830184613fe5565b60a081525f6152b460a0830188613fe5565b6001600160a01b0396909616602083015250921515604084015290151560608301521515608090910152919050565b5f82516152f4818460208701613fc3565b9190910192915050565b608081525f6153106080830187613fe5565b82810360208401526153228187614321565b905082810360408401526153368186613f60565b9050828103606084015261534a818561441d565b979650505050505050565b5f60208083525f845461536781614f5a565b806020870152604060018084165f811461538857600181146153a4576153d1565b60ff19851660408a0152604084151560051b8a010195506153d1565b895f5260205f205f5b858110156153c85781548b82018601529083019088016153ad565b8a016040019650505b509398975050505050505050565b5f82601f8301126153ee575f80fd5b81516153fc61418782614144565b818152846020838601011115615410575f80fd5b614dea826020830160208701613fc3565b5f82601f830112615430575f80fd5b8151602061544061418783614501565b82815260059290921b8401810191818101908684111561545e575f80fd5b8286015b848110156145885780516001600160401b0381111561547f575f80fd5b61548d8986838b01016153df565b845250918301918301615462565b5f601f83601f8401126154ac575f80fd5b825160206154bc61418783614501565b82815261014092830286018201928282019190888511156154db575f80fd5b8388015b858110156155355789878201126154f4575f80fd5b6154fc6140f1565b808383018c81111561550c575f80fd5b835b81811015615525578051845292880192880161550e565b50508552509284019281016154df565b509098975050505050505050565b5f82601f830112615552575f80fd5b8151602061556261418783614501565b8083825260208201915060208460051b870101935086841115615583575f80fd5b602086015b8481101561458857805161559b816141bc565b8352918301918301615588565b5f82601f8301126155b7575f80fd5b815160206155c761418783614501565b8083825260208201915060208460051b8701019350868411156155e8575f80fd5b602086015b8481101561458857805183529183019183016155ed565b5f82601f830112615613575f80fd5b8151602061562361418783614501565b8083825260208201915060208460051b870101935086841115615644575f80fd5b602086015b8481101561458857805161565c816145ef565b8352918301918301615649565b5f805f805f805f805f6101208a8c031215615682575f80fd5b89516001600160401b0380821115615698575f80fd5b6156a48d838e01615421565b9a5060208c01519150808211156156b9575f80fd5b6156c58d838e01615421565b995060408c01519150808211156156da575f80fd5b6156e68d838e01615421565b985060608c01519150808211156156fb575f80fd5b6157078d838e0161549b565b975060808c015191508082111561571c575f80fd5b6157288d838e01615543565b965060a08c015191508082111561573d575f80fd5b6157498d838e016155a8565b955060c08c015191508082111561575e575f80fd5b61576a8d838e01615543565b945060e08c015191508082111561577f575f80fd5b61578b8d838e016155a8565b93506101008c01519150808211156157a1575f80fd5b506157ae8c828d01615604565b9150509295985092959850929598565b5f602082840312156157ce575f80fd5b81516001600160401b038111156157e3575f80fd5b614dea848285016153df565b6001600160a01b03831681526040602082018190525f90614dea90830184614321565b5f8261582c57634e487b7160e01b5f52601260045260245ffd5b500490565b808201808211156105d9576105d961503a565b606081525f6158566060830186614321565b82810360208401526158688186613f60565b90508281036040840152613d37818561441d565b5f604082016040835280845180835260608501915060608160051b860101925060208087015f5b838110156158d157605f198887030185526158bf868351613fe5565b955093820193908201906001016158a3565b5050505050828103602084015260018152602d60f81b60208201526040810191505092915050565b60a081525f61590b60a0830188613fe5565b828103602084015261591d8188613fe5565b905082810360408401526159318187613fe5565b905082810360608401526159458186613fe5565b9050828103608084015261131d8185614321565b602080825282516001600160a01b0316828201528201515f9061598760408401826001600160a01b03169052565b50604083015160e060608401526159a2610100840182613fe5565b90506060840151601f19808584030160808601526159c08383613fe5565b9250608086015160a086015260a08601519150808584030160c08601526159e78383614321565b925060c08601519150808584030160e0860152506144e68282613f60565b6001600160a01b0386811682528516602082015260a0604082018190525f90615a3090830186613fe5565b8281036060840152615a428186614321565b9050828103608084015261131d8185613f60565b5f610120808352615a698184018d613fe5565b90508281036020840152615a7d818c613fe5565b6001600160a01b038b811660408601528a16606085015283810360808501529050615aa88189613fe5565b905082810360a0840152615abc8188613fe5565b905082810360c0840152615ad08187614321565b60e084019590955250506101000152979650505050505050565b608081525f615afc6080830187613fe5565b6001600160a01b0395861660208401529385166040830152509216606090920191909152919050565b5f805f805f60a08688031215615b39575f80fd5b85516001600160401b0380821115615b4f575f80fd5b615b5b89838a016153df565b96506020880151915080821115615b70575f80fd5b615b7c89838a01615543565b95506040880151915080821115615b91575f80fd5b615b9d89838a01615421565b94506060880151915080821115615bb2575f80fd5b615bbe89838a016153df565b93506080880151915080821115615bd3575f80fd5b50615be0888289016153df565b915050929550929590935056fe9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a26469706673582212207240f6a2405c760166c83e72310fe7f40b7f79880d80cbd53d7193933b4368b364736f6c63430008170033

Deployed Bytecode

0x608060405234801561000f575f80fd5b506004361061021e575f3560e01c80637d474fa31161012a578063c56ebcd6116100b4578063dd7ff3db11610079578063dd7ff3db14610513578063e967f16b14610546578063f378d1d414610559578063f583734e14610561578063ffa1ad7414610585575f80fd5b8063c56ebcd61461049f578063d0cf0054146104bf578063d9f9027f146104d2578063db22d7a0146104ed578063dcc8051814610500575f80fd5b8063913b0870116100fa578063913b087014610416578063936725ec146104335780639ad87ce414610457578063b2d9688414610477578063c4d66de81461048c575f80fd5b80637d474fa3146103c8578063802779d0146103db578063871fd682146103ee57806389ec7a4114610403575f80fd5b80634593144c116101ab578063582a4d371161017b578063582a4d371461036957806358a2ab1c1461037c57806358e71ca21461038f5780636c2713a3146103a25780637031c482146103b5575f80fd5b80634593144c146103015780634ad97093146103095780634bde38c814610329578063538a85a114610349575f80fd5b806314e4380c116101f157806314e4380c146102885780632ad9ea9b146102ac5780632e8ebaae146102c157806336abf3dc146102d45780633adc774e146102ee575f80fd5b806301ffc9a714610222578063070d15671461024a5780630d9c8bcd1461026b5780630f038dcd14610273575b5f80fd5b610235610230366004613f19565b6105a9565b60405190151581526020015b60405180910390f35b61025d610258366004613f40565b6105df565b604051908152602001610241565b61025d610606565b61027b61061a565b6040516102419190613f9a565b61029b610296366004613fac565b610639565b604051610241959493929190614010565b6102bf6102ba3660046141f8565b61076c565b005b6102356102cf3660046142ae565b610809565b6102dc610836565b6040516102419695949392919061438a565b6102bf6102fc3660046142ae565b610c76565b61025d610d4d565b61031c6103173660046142ae565b610d85565b604051610241919061440b565b610331610e3c565b6040516001600160a01b039091168152602001610241565b61035c610357366004613fac565b610e6b565b60405161024191906144ef565b6102bf610377366004614753565b611146565b61025d61038a366004614796565b611270565b6102bf61039d3660046148a4565b611329565b6102bf6103b036600461497b565b611581565b6102bf6103c3366004614a4e565b61166b565b6103316103d6366004613fac565b61176b565b6102bf6103e9366004614aa3565b611792565b6103f661181a565b6040516102419190614ae5565b610331610411366004613fac565b611abf565b61041e611afb565b60405161024199989796959493929190614b47565b61031c604051806040016040528060058152602001640312e302e360dc1b81525081565b61046a610465366004613fac565b611bb0565b6040516102419190614c53565b61047f611d09565b6040516102419190614caa565b6102bf61049a3660046142ae565b611d72565b6104b26104ad366004613fac565b611e86565b6040516102419190614cbc565b61025d6104cd3660046142ae565b611fc6565b6104da611ff1565b6040516102419796959493929190614d23565b61025d6104fb366004614db9565b61257b565b6102bf61050e3660046142ae565b6125fb565b610526610521366004614796565b612690565b604080516001600160a01b03938416815292909116602083015201610241565b6102bf610554366004614df2565b61356d565b61025d6136b2565b61057461056f366004614e9b565b6136c6565b604051610241959493929190614efa565b61031c604051806040016040528060058152602001640312e322e360dc1b81525081565b5f6001600160e01b03198216630f1ec81f60e41b14806105d957506301ffc9a760e01b6001600160e01b03198316145b92915050565b5f6105e8613767565b5f938452600901602090815260408085209385529290525090205490565b5f80610610613767565b600a015492915050565b60605f610625613767565b90506106338160070161378b565b91505090565b60605f805f805f610648613767565b90505f815f015f8981526020019081526020015f206040518060a00160405290815f8201805461067790614f5a565b80601f01602080910402602001604051908101604052809291908181526020018280546106a390614f5a565b80156106ee5780601f106106c5576101008083540402835291602001916106ee565b820191905f5260205f20905b8154815290600101906020018083116106d157829003601f168201915b505050918352505060018201546001600160a01b03811660208084019190915260ff600160a01b830481161515604080860191909152600160a81b90930416151560608085019190915260029094015460809384015284519085015191850151938501519490920151919c909b509199509197509095509350505050565b61077461379e565b5f61077d613767565b6040516305091ded60e01b81529091507306e0912b4f2e36cfcf9556478352afc2d991919f906305091ded906107b99084908690600401614f92565b602060405180830381865af41580156107d4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107f89190614ff4565b156108055761080561382d565b5050565b5f610812613767565b6001600160a01b039092165f90815260049290920160205250604090205460ff1690565b6060806060806060805f610848613767565b90505f6108578260050161378b565b8051909150806001600160401b038111156108745761087461404f565b6040519080825280602002602001820160405280156108a757816020015b60608152602001906001900390816108925790505b509850806001600160401b038111156108c2576108c261404f565b6040519080825280602002602001820160405280156108eb578160200160208202803683370190505b509750806001600160401b038111156109065761090661404f565b60405190808252806020026020018201604052801561092f578160200160208202803683370190505b509650806001600160401b0381111561094a5761094a61404f565b604051908082528060200260200182016040528015610973578160200160208202803683370190505b509550806001600160401b0381111561098e5761098e61404f565b6040519080825280602002602001820160405280156109b7578160200160208202803683370190505b509450806001600160401b038111156109d2576109d261404f565b6040519080825280602002602001820160405280156109fb578160200160208202803683370190505b5093505f5b81811015610c6a575f845f015f858481518110610a1f57610a1f61500f565b602002602001015181526020019081526020015f206040518060a00160405290815f82018054610a4e90614f5a565b80601f0160208091040260200160405190810160405280929190818152602001828054610a7a90614f5a565b8015610ac55780601f10610a9c57610100808354040283529160200191610ac5565b820191905f5260205f20905b815481529060010190602001808311610aa857829003601f168201915b505050918352505060018201546001600160a01b038116602083015260ff600160a01b8204811615156040840152600160a81b909104161515606082015260029091015460809091015280518c51919250908c9084908110610b2957610b2961500f565b602002602001018190525080602001518a8381518110610b4b57610b4b61500f565b60200260200101906001600160a01b031690816001600160a01b0316815250508060400151898381518110610b8257610b8261500f565b6020026020010190151590811515815250508060600151888381518110610bab57610bab61500f565b6020026020010190151590811515815250508060800151878381518110610bd457610bd461500f565b60200260200101818152505080602001516001600160a01b031663190024e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c20573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c449190615023565b868381518110610c5657610c5661500f565b602090810291909101015250600101610a00565b50505050909192939495565b610c7e613948565b5f610c87613767565b6001600160a01b0383165f908152600382016020526040902054909150600114610cc457604051630d7abd6f60e31b815260040160405180910390fd5b604051637817605360e01b8152600481018290526001600160a01b03831660248201527306e0912b4f2e36cfcf9556478352afc2d991919f906378176053906044015b5f6040518083038186803b158015610d1d575f80fd5b505af4158015610d2f573d5f803e3d5ffd5b5050505050610d4a60015f80516020615bee83398151915255565b50565b5f610d80610d7c60017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f161504e565b5490565b905090565b60605f610d90613767565b6001600160a01b0384165f908152600d820160205260409020805491925090610db890614f5a565b80601f0160208091040260200160405190810160405280929190818152602001828054610de490614f5a565b8015610e2f5780601f10610e0657610100808354040283529160200191610e2f565b820191905f5260205f20905b815481529060010190602001808311610e1257829003601f168201915b5050505050915050919050565b5f610d80610d7c60017faa116a42804728f23983458454b6eb9c6ddf3011db9f9addaf3cd7508d85b0d661504e565b610eb26040518060e001604052805f81526020015f6001600160a01b0316815260200160608152602001606081526020016060815260200160608152602001606081525090565b5f610ebb613767565b905080600b018381548110610ed257610ed261500f565b905f5260205f2090600702016040518060e00160405290815f8201548152602001600182015f9054906101000a90046001600160a01b03166001600160a01b03166001600160a01b03168152602001600282018054610f3090614f5a565b80601f0160208091040260200160405190810160405280929190818152602001828054610f5c90614f5a565b8015610fa75780601f10610f7e57610100808354040283529160200191610fa7565b820191905f5260205f20905b815481529060010190602001808311610f8a57829003601f168201915b505050505081526020016003820180548060200260200160405190810160405280929190818152602001828054801561100757602002820191905f5260205f20905b81546001600160a01b03168152600190910190602001808311610fe9575b505050505081526020016004820180548060200260200160405190810160405280929190818152602001828054801561106757602002820191905f5260205f20905b81546001600160a01b03168152600190910190602001808311611049575b50505050508152602001600582018054806020026020016040519081016040528092919081815260200182805480156110bd57602002820191905f5260205f20905b8154815260200190600101908083116110a9575b505050505081526020016006820180548060200260200160405190810160405280929190818152602001828054801561113557602002820191905f5260205f20905f905b825461010083900a900460020b81526020600583018190049384019360010360039093019290920291018084116111015790505b505050505081525050915050919050565b61114e61379e565b5f611157613767565b90508181600b01848154811061116f5761116f61500f565b5f918252602091829020835160079290920201908155908201516001820180546001600160a01b0319166001600160a01b03909216919091179055604082015160028201906111be90826150a5565b50606082015180516111da916003840191602090910190613dc6565b50608082015180516111f6916004840191602090910190613dc6565b5060a08201518051611212916005840191602090910190613e29565b5060c0820151805161122e916006840191602090910190613e62565b509050507f4e8499c72391533d62e187d3f07fc288fbc1742c8e094f36b5e23b836bb29e898383604051611263929190615160565b60405180910390a1505050565b6040805160a08101825260018082525f602083018190528284018290526060830191909152608082018190529151636c309d4f60e11b81527306e0912b4f2e36cfcf9556478352afc2d991919f9163d8613a9e916112de918c918c918c918c918c918c918c9160040161519d565b602060405180830381865af41580156112f9573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061131d9190615023565b98975050505050505050565b61133161379e565b611339613948565b5f611342613767565b835180516020918201205f81815260018085019093526040902091820154929350916001600160a01b0316611455575f61137a610e3c565b6001600160a01b031663878571d76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156113b5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113d99190615264565b865160405163d0def52160e01b81526001600160a01b03929092169163d0def5219161140a9189919060040161527f565b6020604051808303815f875af1158015611426573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061144a9190615023565b60a087015250611460565b600281015460a08601525b5f82815260018401602052604090208551869190819061148090826150a5565b5060208201516001820180546040850151606086015160808701511515600160b01b0260ff60b01b19911515600160a81b029190911661ffff60a81b19921515600160a01b026001600160a81b03199094166001600160a01b039096169590951792909217169290921791909117905560a0909101516002909101555f61150a6007850184613992565b9050806115195761151961382d565b7f1c1fdd0257172a2ae0d1ea8726dc737597d11e8c6739357cb5015e6d6921fb04865f01518760200151886040015189606001518560405161155f9594939291906152a2565b60405180910390a15050505061080560015f80516020615bee83398151915255565b61158961379e565b5f611592613767565b90505f836040516020016115a691906152e3565b60408051601f1981840301815291815281516020928301205f818152600c860184529190912085518051929450869391926115e49284920190613dc6565b5060208281015180516115fd9260018501920190613e29565b5060408201518051611619916002840191602090910190613e62565b509050507fba197f5223035cb2b7a0f09844df05667b65b529665865bd98232748de75970b84845f01518560200151866040015160405161165d94939291906152fe565b60405180910390a150505050565b61167361382d565b5f61167c613767565b83519091505f5b818110156117645783818151811061169d5761169d61500f565b6020026020010151836003015f8784815181106116bc576116bc61500f565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020015f20819055508481815181106116f9576116f961500f565b60200260200101516001600160a01b03167fd518071c0dca755922e3df4b2f1457ed64340814d52371e060a067edd0a9578a85838151811061173d5761173d61500f565b602002602001015160405161175491815260200190565b60405180910390a2600101611683565b5050505050565b5f80611775613767565b5f938452600201602052505060409020546001600160a01b031690565b5f61179b613767565b6001600160a01b0384165f908152600d8201602052604090209091506117c183826150a5565b506001600160a01b0383165f818152600d8301602052604090819020905133917ff49a01196694c79ef713003d9b31096f281da2dc63510685349a167d876235bd9161180d9190615355565b60405180910390a3505050565b60605f611825613767565b600b81018054604080516020808402820181019092528281529394505f9084015b82821015611ab5575f8481526020908190206040805160e081018252600786029092018054835260018101546001600160a01b0316938301939093526002830180549293929184019161189890614f5a565b80601f01602080910402602001604051908101604052809291908181526020018280546118c490614f5a565b801561190f5780601f106118e65761010080835404028352916020019161190f565b820191905f5260205f20905b8154815290600101906020018083116118f257829003601f168201915b505050505081526020016003820180548060200260200160405190810160405280929190818152602001828054801561196f57602002820191905f5260205f20905b81546001600160a01b03168152600190910190602001808311611951575b50505050508152602001600482018054806020026020016040519081016040528092919081815260200182805480156119cf57602002820191905f5260205f20905b81546001600160a01b031681526001909101906020018083116119b1575b5050505050815260200160058201805480602002602001604051908101604052809291908181526020018280548015611a2557602002820191905f5260205f20905b815481526020019060010190808311611a11575b5050505050815260200160068201805480602002602001604051908101604052809291908181526020018280548015611a9d57602002820191905f5260205f20905f905b825461010083900a900460020b8152602060058301819004938401936001036003909301929092029101808411611a695790505b50505050508152505081526020019060010190611846565b5050505091505090565b5f80611ac9613767565b905080600a018381548110611ae057611ae061500f565b5f918252602090912001546001600160a01b03169392505050565b60608060608060608060608060607306e0912b4f2e36cfcf9556478352afc2d991919f632c1172ae611b2b610e3c565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526024015f60405180830381865af4158015611b6c573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f19168201604052611b939190810190615669565b985098509850985098509850985098509850909192939495969798565b611bd460405180606001604052806060815260200160608152602001606081525090565b5f611bdd613767565b5f848152600c8201602090815260409182902082518154608093810282018401909452606081018481529495509390928492849190840182828015611c4957602002820191905f5260205f20905b81546001600160a01b03168152600190910190602001808311611c2b575b5050505050815260200160018201805480602002602001604051908101604052809291908181526020018280548015611c9f57602002820191905f5260205f20905b815481526020019060010190808311611c8b575b5050505050815260200160028201805480602002602001604051908101604052809291908181526020018280548015611135575f918252602091829020805460020b8452908202830192909160039101808411611101579050505050505081525050915050919050565b60605f611d14613767565b600a8101805460408051602080840282018101909252828152939450830182828015611d6757602002820191905f5260205f20905b81546001600160a01b03168152600190910190602001808311611d49575b505050505091505090565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff1615906001600160401b03165f81158015611db65750825b90505f826001600160401b03166001148015611dd15750303b155b905081158015611ddf575080155b15611dfd5760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff191660011785558315611e2757845460ff60401b1916600160401b1785555b611e308661399d565b611e38613af8565b8315611e7e57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b6040805160c08101825260608082525f6020830181905292820183905281018290526080810182905260a0810182905290611ebf613767565b9050806001015f8481526020019081526020015f206040518060c00160405290815f82018054611eee90614f5a565b80601f0160208091040260200160405190810160405280929190818152602001828054611f1a90614f5a565b8015611f655780601f10611f3c57610100808354040283529160200191611f65565b820191905f5260205f20905b815481529060010190602001808311611f4857829003601f168201915b505050918352505060018201546001600160a01b038116602083015260ff600160a01b8204811615156040840152600160a81b8204811615156060840152600160b01b909104161515608082015260029091015460a0909101529392505050565b5f80611fd0613767565b6001600160a01b039093165f90815260039093016020525050604090205490565b60608060608060608060605f612005613767565b90505f6120148260070161378b565b8051909150806001600160401b038111156120315761203161404f565b60405190808252806020026020018201604052801561206457816020015b606081526020019060019003908161204f5790505b509950806001600160401b0381111561207f5761207f61404f565b6040519080825280602002602001820160405280156120a8578160200160208202803683370190505b509850806001600160401b038111156120c3576120c361404f565b6040519080825280602002602001820160405280156120ec578160200160208202803683370190505b509750806001600160401b038111156121075761210761404f565b604051908082528060200260200182016040528015612130578160200160208202803683370190505b509650806001600160401b0381111561214b5761214b61404f565b604051908082528060200260200182016040528015612174578160200160208202803683370190505b509550806001600160401b0381111561218f5761218f61404f565b6040519080825280602002602001820160405280156121c257816020015b60608152602001906001900390816121ad5790505b509450806001600160401b038111156121dd576121dd61404f565b604051908082528060200260200182016040528015612206578160200160208202803683370190505b5093505f612212610e3c565b6001600160a01b031663878571d76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561224d573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906122719190615264565b90505f5b8281101561256d575f856001015f8684815181106122955761229561500f565b602002602001015181526020019081526020015f206040518060c00160405290815f820180546122c490614f5a565b80601f01602080910402602001604051908101604052809291908181526020018280546122f090614f5a565b801561233b5780601f106123125761010080835404028352916020019161233b565b820191905f5260205f20905b81548152906001019060200180831161231e57829003601f168201915b505050918352505060018201546001600160a01b038116602083015260ff600160a01b8204811615156040840152600160a81b8204811615156060840152600160b01b909104161515608082015260029091015460a09091015280518e51919250908e90849081106123af576123af61500f565b602002602001018190525080604001518c83815181106123d1576123d161500f565b60200260200101901515908115158152505080606001518b83815181106123fa576123fa61500f565b60200260200101901515908115158152505080608001518a83815181106124235761242361500f565b6020026020010190151590811515815250508060a0015189838151811061244c5761244c61500f565b602090810291909101015260a081015160405163c87b56dd60e01b815260048101919091526001600160a01b0384169063c87b56dd906024015f60405180830381865afa15801561249f573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526124c691908101906157be565b8883815181106124d8576124d861500f565b602002602001018190525080602001516001600160a01b031663190024e06040518163ffffffff1660e01b8152600401602060405180830381865afa158015612523573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906125479190615023565b8783815181106125595761255961500f565b602090810291909101015250600101612275565b505050505090919293949596565b5f7306e0912b4f2e36cfcf9556478352afc2d991919f63e551e36a61259e610e3c565b846040518363ffffffff1660e01b81526004016125bc9291906157ef565b602060405180830381865af41580156125d7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105d99190615023565b612603613948565b5f61260c613767565b6001600160a01b0383165f90815260048201602052604090205490915060ff16612649576040516359935c8f60e11b815260040160405180910390fd5b604051630a1cb54360e41b8152600481018290526001600160a01b03831660248201527306e0912b4f2e36cfcf9556478352afc2d991919f9063a1cb543090604401610d07565b5f8061269a613948565b5f6126a3613767565b905061273c60408051610240810190915260606101a082019081525f6101c083018190526101e083018190526102008301819052610220830152819081525f602082018190526040820181905260608083018190526080830181905260a0830181905260c0830181905260e083015261010082018190526101208201819052610140820181905261016082018190526101809091015290565b815f015f8c60405160200161275191906152e3565b6040516020818303038152906040528051906020012081526020019081526020015f206040518060a00160405290815f8201805461278e90614f5a565b80601f01602080910402602001604051908101604052809291908181526020018280546127ba90614f5a565b80156128055780601f106127dc57610100808354040283529160200191612805565b820191905f5260205f20905b8154815290600101906020018083116127e857829003601f168201915b505050918352505060018201546001600160a01b0380821660208085019190915260ff600160a01b8404811615156040860152600160a81b9093049092161515606084015260029093015460809092019190915282845291909101511661287f57604051634b94d18160e11b815260040160405180910390fd5b8051604001516128a25760405163221da53360e21b815260040160405180910390fd5b89516020808c0191909120908201526128b9610e3c565b6001600160a01b031660408083018290528051630b3a3c4160e21b81529051632ce8f104916004808201926020929091908290030181865afa158015612901573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129259190615264565b8161012001906001600160a01b031690816001600160a01b03168152505080604001516001600160a01b0316636f460dc86040518163ffffffff1660e01b8152600401602060405180830381865afa158015612983573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906129a79190615264565b6001600160a01b039081166101408301526020808301515f908152600180860190925260409020908101549091166129f2576040516303022b7560e11b815260040160405180910390fd5b6001810154600160a01b900460ff16612a1e5760405163e0eb421d60e01b815260040160405180910390fd5b6101208201516001600160a01b031615612ba0576101208201516040516370a0823160e01b81523360048201525f916001600160a01b0316906370a0823190602401602060405180830381865afa158015612a7b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612a9f9190615023565b90505f5b81811015612b9d57610120840151604051632f745c5960e01b8152336004820152602481018390525f916001600160a01b031690632f745c5990604401602060405180830381865afa158015612afb573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612b1f9190615023565b90505f612b2f62093a8042615812565b5f81815260098901602090815260408083208684529091529020549091506001811015612b8f57612b61816001615831565b5f92835260098901602090815260408085209585529490529290912091909155506001610160850152612b9d565b505050806001019050612aa3565b50505b816101600151612d53576101408201516040516370a0823160e01b81523360048201525f916001600160a01b0316906370a0823190602401602060405180830381865afa158015612bf3573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c179190615023565b835160800151909150811015612ccc5780835f01516080015184604001516001600160a01b0316636f460dc86040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c70573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612c949190615264565b60405163417db01960e01b8152600481019390935260248301919091526001600160a01b031660448201526064015b60405180910390fd5b612d513384604001516001600160a01b0316634783c35b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d10573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612d349190615264565b8551608001516101408701516001600160a01b0316929190613b08565b505b5f7329613385f8808a04e593163a2867f3f3d4a1bd8b63500937666040518163ffffffff1660e01b8152600401602060405180830381865af4158015612d9b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612dbf9190615264565b9050806001600160a01b031663cc316e998e6040518263ffffffff1660e01b8152600401612ded919061440b565b5f604051808303815f87803b158015612e04575f80fd5b505af1158015612e16573d5f803e3d5ffd5b505050505f7329613385f8808a04e593163a2867f3f3d4a1bd8b63bcea050b6040518163ffffffff1660e01b8152600401602060405180830381865af4158015612e62573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612e869190615264565b9050806001600160a01b031663670855198e6040518263ffffffff1660e01b8152600401612eb4919061440b565b5f604051808303815f87803b158015612ecb575f80fd5b505af1158015612edd573d5f803e3d5ffd5b50508b519398509196505f9150612ef79050826002615831565b6001600160401b03811115612f0e57612f0e61404f565b604051908082528060200260200182016040528015612f37578160200160208202803683370190505b5090508360400151815f81518110612f5157612f5161500f565b60200260200101906001600160a01b031690816001600160a01b0316815250508681600181518110612f8557612f8561500f565b6001600160a01b039092166020928302919091019091015260025b612fab836002615831565b811015613008578a612fbe60028361504e565b81518110612fce57612fce61500f565b6020026020010151828281518110612fe857612fe861500f565b6001600160a01b0390921660209283029190910190910152600101612fa0565b50604051630835ffd760e31b81526001600160a01b038716906341affeb8906130399084908d908d90600401615844565b5f604051808303815f87803b158015613050575f80fd5b505af1158015613062573d5f803e3d5ffd5b505050506130758e8e8e8e8e8e8e611270565b61010085018190525f9081526002860160205260409020546001600160a01b0316156130bd5783610100015160405163db7e59bd60e01b8152600401612cc391815260200190565b50506130f18c855f8d51116130d2575f6136c6565b8c5f815181106130e4576130e461500f565b60200260200101516136c6565b60e087015260c08601526080850181905260608501919091526040516303bf572560e31b81527306e0912b4f2e36cfcf9556478352afc2d991919f925063d0d34fa4918f918f91734f76add676c04eca837130ceb58bc173de8799de91631dfab928916131609160040161587c565b5f60405180830381865af415801561317a573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526131a191908101906157be565b8660c001518f6040518663ffffffff1660e01b81526004016131c79594939291906158f9565b5f60405180830381865af41580156131e1573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261320891908101906157be565b8260a0018190525081604001516001600160a01b0316638a4adf246040518163ffffffff1660e01b8152600401602060405180830381865afa158015613250573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906132749190615264565b60405163ee1fe2ad60e01b81523360048201526001600160a01b038781166024830152919091169063ee1fe2ad906044016020604051808303815f875af11580156132c1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906132e59190615023565b61018083019081526040805160e08082018352828601516001600160a01b039081168352888116602084015260a080880151848601529187015160608401529351608083015281018d905260c081018c9052905163a50c8dd160e01b81529187169163a50c8dd19161335991600401615959565b5f604051808303815f87803b158015613370575f80fd5b505af1158015613382573d5f803e3d5ffd5b5050505082600a0185908060018154018082558091505060019003905f5260205f20015f9091909190916101000a8154816001600160a01b0302191690836001600160a01b031602179055506001836003015f876001600160a01b03166001600160a01b031681526020019081526020015f20819055506001836004015f866001600160a01b03166001600160a01b031681526020019081526020015f205f6101000a81548160ff02191690831515021790555084836002015f84610100015181526020019081526020015f205f6101000a8154816001600160a01b0302191690836001600160a01b031602179055507306e0912b4f2e36cfcf9556478352afc2d991919f631b4c3fdd8360400151878f8e8e6040518663ffffffff1660e01b81526004016134b5959493929190615a05565b5f6040518083038186803b1580156134cb575f80fd5b505af41580156134dd573d5f803e3d5ffd5b50505050336001600160a01b03167fe16a12ed0c6ee928f7ee5c5799175c728255adae06a81e8bec85c9d909af61338d8d88888760a001518860e0015189606001518a61010001518b610180015160405161354099989796959493929190615a56565b60405180910390a250505061356160015f80516020615bee83398151915255565b97509795505050505050565b61357561379e565b5f61357e613767565b82519091505f5b818110156136825782600b018482815181106135a3576135a361500f565b6020908102919091018101518254600180820185555f9485529383902082516007909202019081559181015192820180546001600160a01b0319166001600160a01b03909416939093179092556040820151600282019061360490826150a5565b5060608201518051613620916003840191602090910190613dc6565b506080820151805161363c916004840191602090910190613dc6565b5060a08201518051613658916005840191602090910190613e29565b5060c08201518051613674916006840191602090910190613e62565b505050806001019050613585565b507fad29862e9f0d865f275139a684250d15b3351b00a75fdfae159b837289c19bf5836040516112639190614ae5565b5f806136bc613767565b600b015492915050565b6060806060806060733110a397362465b6ad45703de9dea2cc2ae6c3b363046bcb508989896136f3610e3c565b6040518563ffffffff1660e01b81526004016137129493929190615aea565b5f60405180830381865af415801561372c573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f191682016040526137539190810190615b25565b939c929b5090995097509095509350505050565b7f94b53192a2415b53b438d03f0efa946204c0118192627e3d5ed4ba034c9a030090565b60605f61379783613b68565b9392505050565b6137a6610e3c565b6040516336b87bd760e11b81523360048201526001600160a01b039190911690636d70f7ae90602401602060405180830381865afa1580156137ea573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061380e9190614ff4565b61382b57604051631f0853c160e21b815260040160405180910390fd5b565b5f613836610e3c565b9050336001600160a01b0316816001600160a01b0316635aa6e6756040518163ffffffff1660e01b8152600401602060405180830381865afa15801561387e573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906138a29190615264565b6001600160a01b03161415801561392a5750336001600160a01b0316816001600160a01b0316634783c35b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156138fa573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061391e9190615264565b6001600160a01b031614155b15610d4a576040516354299b6f60e01b815260040160405180910390fd5b5f80516020615bee83398151915280546001190161397957604051633ee5aeb560e01b815260040160405180910390fd5b60029055565b60015f80516020615bee83398151915255565b5f6137978383613bc1565b6139a5613c0d565b6001600160a01b0381161580613a2b57505f6001600160a01b0316816001600160a01b0316634783c35b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156139fc573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190613a209190615264565b6001600160a01b0316145b15613a49576040516371c42ac360e01b815260040160405180910390fd5b613a7c613a7760017faa116a42804728f23983458454b6eb9c6ddf3011db9f9addaf3cd7508d85b0d661504e565b829055565b613aae43613aab60017f812a673dfca07956350df10f8a654925f561d7a0da09bdbe79e653939a14d9f161504e565b55565b604080516001600160a01b0383168152426020820152438183015290517f1a2dd071001ebf6e03174e3df5b305795a4ad5d41d8fdb9ba41dbbe2367134269181900360600190a150565b613b00613c0d565b61382b613c56565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052613b62908590613c5e565b50505050565b6060815f01805480602002602001604051908101604052809291908181526020018280548015613bb557602002820191905f5260205f20905b815481526020019060010190808311613ba1575b50505050509050919050565b5f818152600183016020526040812054613c0657508154600181810184555f8481526020808220909301849055845484825282860190935260409020919091556105d9565b505f6105d9565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054600160401b900460ff1661382b57604051631afcd79f60e31b815260040160405180910390fd5b61397f613c0d565b5f613c726001600160a01b03841683613cc4565b905080515f14158015613c96575080806020019051810190613c949190614ff4565b155b15613cbf57604051635274afe760e01b81526001600160a01b0384166004820152602401612cc3565b505050565b606061379783835f845f80856001600160a01b03168486604051613ce891906152e3565b5f6040518083038185875af1925050503d805f8114613d22576040519150601f19603f3d011682016040523d82523d5f602084013e613d27565b606091505b5091509150613d37868383613d41565b9695505050505050565b606082613d5657613d5182613d9d565b613797565b8151158015613d6d57506001600160a01b0384163b155b15613d9657604051639996b31560e01b81526001600160a01b0385166004820152602401612cc3565b5080613797565b805115613dad5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b828054828255905f5260205f20908101928215613e19579160200282015b82811115613e1957825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613de4565b50613e25929150613f05565b5090565b828054828255905f5260205f20908101928215613e19579160200282015b82811115613e19578251825591602001919060010190613e47565b828054828255905f5260205f2090600901600a90048101928215613e19579160200282015f5b83821115613ecd57835183826101000a81548162ffffff021916908360020b62ffffff1602179055509260200192600301602081600201049283019260010302613e88565b8015613efc5782816101000a81549062ffffff0219169055600301602081600201049283019260010302613ecd565b5050613e259291505b5b80821115613e25575f8155600101613f06565b5f60208284031215613f29575f80fd5b81356001600160e01b031981168114613797575f80fd5b5f8060408385031215613f51575f80fd5b50508035926020909101359150565b5f815180845260208085019450602084015f5b83811015613f8f57815187529582019590820190600101613f73565b509495945050505050565b602081525f6137976020830184613f60565b5f60208284031215613fbc575f80fd5b5035919050565b5f5b83811015613fdd578181015183820152602001613fc5565b50505f910152565b5f8151808452613ffc816020860160208601613fc3565b601f01601f19169290920160200192915050565b60a081525f61402260a0830188613fe5565b6001600160a01b039690961660208301525092151560408401529015156060830152608090910152919050565b634e487b7160e01b5f52604160045260245ffd5b60405160a081016001600160401b03811182821017156140855761408561404f565b60405290565b60405160e081016001600160401b03811182821017156140855761408561404f565b60405160c081016001600160401b03811182821017156140855761408561404f565b604051606081016001600160401b03811182821017156140855761408561404f565b60405161014081016001600160401b03811182821017156140855761408561404f565b604051601f8201601f191681016001600160401b038111828210171561413c5761413c61404f565b604052919050565b5f6001600160401b0382111561415c5761415c61404f565b50601f01601f191660200190565b5f82601f830112614179575f80fd5b813561418c61418782614144565b614114565b8181528460208386010111156141a0575f80fd5b816020850160208301375f918101602001919091529392505050565b6001600160a01b0381168114610d4a575f80fd5b80356141db816141bc565b919050565b8015158114610d4a575f80fd5b80356141db816141e0565b5f60208284031215614208575f80fd5b81356001600160401b038082111561421e575f80fd5b9083019060a08286031215614231575f80fd5b614239614063565b823582811115614247575f80fd5b6142538782860161416a565b82525060208301359150614266826141bc565b8160208201526040830135915061427c826141e0565b81604082015260608301359150614292826141e0565b8160608201526080830135608082015280935050505092915050565b5f602082840312156142be575f80fd5b8135613797816141bc565b5f8282518085526020808601955060208260051b840101602086015f5b8481101561431457601f19868403018952614302838351613fe5565b988401989250908301906001016142e6565b5090979650505050505050565b5f815180845260208085019450602084015f5b83811015613f8f5781516001600160a01b031687529582019590820190600101614334565b5f815180845260208085019450602084015f5b83811015613f8f57815115158752958201959082019060010161436c565b60c081525f61439c60c08301896142c9565b82810360208401526143ae8189614321565b905082810360408401526143c28188614359565b905082810360608401526143d68187614359565b905082810360808401526143ea8186613f60565b905082810360a08401526143fe8185613f60565b9998505050505050505050565b602081525f6137976020830184613fe5565b5f815180845260208085019450602084015f5b83811015613f8f57815160020b87529582019590820190600101614430565b8051825260018060a01b0360208201511660208301525f604082015160e0604085015261447f60e0850182613fe5565b9050606083015184820360608601526144988282614321565b915050608083015184820360808601526144b28282614321565b91505060a083015184820360a08601526144cc8282613f60565b91505060c083015184820360c08601526144e6828261441d565b95945050505050565b602081525f613797602083018461444f565b5f6001600160401b038211156145195761451961404f565b5060051b60200190565b5f82601f830112614532575f80fd5b8135602061454261418783614501565b8083825260208201915060208460051b870101935086841115614563575f80fd5b602086015b8481101561458857803561457b816141bc565b8352918301918301614568565b509695505050505050565b5f82601f8301126145a2575f80fd5b813560206145b261418783614501565b8083825260208201915060208460051b8701019350868411156145d3575f80fd5b602086015b8481101561458857803583529183019183016145d8565b8060020b8114610d4a575f80fd5b5f82601f83011261460c575f80fd5b8135602061461c61418783614501565b8083825260208201915060208460051b87010193508684111561463d575f80fd5b602086015b84811015614588578035614655816145ef565b8352918301918301614642565b5f60e08284031215614672575f80fd5b61467a61408b565b90508135815261468c602083016141d0565b602082015260408201356001600160401b03808211156146aa575f80fd5b6146b68583860161416a565b604084015260608401359150808211156146ce575f80fd5b6146da85838601614523565b606084015260808401359150808211156146f2575f80fd5b6146fe85838601614523565b608084015260a0840135915080821115614716575f80fd5b61472285838601614593565b60a084015260c084013591508082111561473a575f80fd5b50614747848285016145fd565b60c08301525092915050565b5f8060408385031215614764575f80fd5b8235915060208301356001600160401b03811115614780575f80fd5b61478c85828601614662565b9150509250929050565b5f805f805f805f60e0888a0312156147ac575f80fd5b87356001600160401b03808211156147c2575f80fd5b6147ce8b838c0161416a565b985060208a01359150808211156147e3575f80fd5b6147ef8b838c0161416a565b975060408a0135915080821115614804575f80fd5b6148108b838c01614523565b965060608a0135915080821115614825575f80fd5b6148318b838c01614593565b955060808a0135915080821115614846575f80fd5b6148528b838c01614523565b945060a08a0135915080821115614867575f80fd5b6148738b838c01614593565b935060c08a0135915080821115614888575f80fd5b506148958a828b016145fd565b91505092959891949750929550565b5f80604083850312156148b5575f80fd5b82356001600160401b03808211156148cb575f80fd5b9084019060c082870312156148de575f80fd5b6148e66140ad565b8235828111156148f4575f80fd5b6149008882860161416a565b82525060208301359150614913826141bc565b81602082015260408301359150614929826141e0565b8160408201526060830135915061493f826141e0565b816060820152614951608084016141ed565b608082015260a083013560a0820152809450505050614972602084016141d0565b90509250929050565b5f806040838503121561498c575f80fd5b82356001600160401b03808211156149a2575f80fd5b6149ae8683870161416a565b935060208501359150808211156149c3575f80fd5b90840190606082870312156149d6575f80fd5b6149de6140cf565b8235828111156149ec575f80fd5b6149f888828601614523565b825250602083013582811115614a0c575f80fd5b614a1888828601614593565b602083015250604083013582811115614a2f575f80fd5b614a3b888286016145fd565b6040830152508093505050509250929050565b5f8060408385031215614a5f575f80fd5b82356001600160401b0380821115614a75575f80fd5b614a8186838701614523565b93506020850135915080821115614a96575f80fd5b5061478c85828601614593565b5f8060408385031215614ab4575f80fd5b8235614abf816141bc565b915060208301356001600160401b03811115614ad9575f80fd5b61478c8582860161416a565b5f60208083016020845280855180835260408601915060408160051b8701019250602087015f5b82811015614b3a57603f19888603018452614b2885835161444f565b94509285019290850190600101614b0c565b5092979650505050505050565b5f610120808352614b5a8184018d6142c9565b9050602083820381850152614b6f828d6142c9565b91508382036040850152614b83828c6142c9565b84810360608601528a51808252828c019350908201905f5b81811015614bdc578451835f5b600a811015614bc557825182529186019190860190600101614ba8565b505050938301936101409290920191600101614b9b565b50508481036080860152614bf0818b614321565b9250505082810360a0840152614c068188613f60565b905082810360c0840152614c1a8187614321565b905082810360e0840152614c2e8186613f60565b9050828103610100840152614c43818561441d565b9c9b505050505050505050505050565b602081525f825160606020840152614c6e6080840182614321565b90506020840151601f1980858403016040860152614c8c8383613f60565b92506040860151915080858403016060860152506144e6828261441d565b602081525f6137976020830184614321565b602081525f825160c06020840152614cd760e0840182613fe5565b905060018060a01b0360208501511660408401526040840151151560608401526060840151151560808401526080840151151560a084015260a084015160c08401528091505092915050565b60e081525f614d3560e083018a6142c9565b8281036020840152614d47818a614359565b90508281036040840152614d5b8189614359565b90508281036060840152614d6f8188614359565b90508281036080840152614d838187613f60565b905082810360a0840152614d9781866142c9565b905082810360c0840152614dab8185613f60565b9a9950505050505050505050565b5f60208284031215614dc9575f80fd5b81356001600160401b03811115614dde575f80fd5b614dea84828501614523565b949350505050565b5f6020808385031215614e03575f80fd5b82356001600160401b0380821115614e19575f80fd5b818501915085601f830112614e2c575f80fd5b8135614e3a61418782614501565b81815260059190911b83018401908481019088831115614e58575f80fd5b8585015b83811015614e8e57803585811115614e72575f80fd5b614e808b89838a0101614662565b845250918601918601614e5c565b5098975050505050505050565b5f805f60608486031215614ead575f80fd5b83356001600160401b03811115614ec2575f80fd5b614ece8682870161416a565b9350506020840135614edf816141bc565b91506040840135614eef816141bc565b809150509250925092565b60a081525f614f0c60a0830188613fe5565b8281036020840152614f1e8188614321565b90508281036040840152614f3281876142c9565b90508281036060840152614f468186613fe5565b9050828103608084015261131d8185613fe5565b600181811c90821680614f6e57607f821691505b602082108103614f8c57634e487b7160e01b5f52602260045260245ffd5b50919050565b828152604060208201525f825160a06040840152614fb360e0840182613fe5565b905060018060a01b0360208501511660608401526040840151151560808401526060840151151560a0840152608084015160c0840152809150509392505050565b5f60208284031215615004575f80fd5b8151613797816141e0565b634e487b7160e01b5f52603260045260245ffd5b5f60208284031215615033575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b818103818111156105d9576105d961503a565b601f821115613cbf57805f5260205f20601f840160051c810160208510156150865750805b601f840160051c820191505b81811015611764575f8155600101615092565b81516001600160401b038111156150be576150be61404f565b6150d2816150cc8454614f5a565b84615061565b602080601f831160018114615105575f84156150ee5750858301515b5f19600386901b1c1916600185901b178555611e7e565b5f85815260208120601f198616915b8281101561513357888601518255948401946001909101908401615114565b508582101561515057878501515f19600388901b60f8161c191681555b5050505050600190811b01905550565b828152604060208201525f614dea604083018461444f565b805f5b6005811015613b6257815160ff1684526020938401939091019060010161517b565b5f6101808083526151b08184018c613fe5565b9050602083820360208501526151c6828c613fe5565b915083820360408501526151da828b614321565b915083820360608501526151ee828a613f60565b915083820360808501526152028289614321565b915083820360a08501526152168288613f60565b84810360c0860152865180825260208089019450909101905f5b8181101561524f57845160020b83529383019391830191600101615230565b50508093505050506143fe60e0830184615178565b5f60208284031215615274575f80fd5b8151613797816141bc565b6001600160a01b03831681526040602082018190525f90614dea90830184613fe5565b60a081525f6152b460a0830188613fe5565b6001600160a01b0396909616602083015250921515604084015290151560608301521515608090910152919050565b5f82516152f4818460208701613fc3565b9190910192915050565b608081525f6153106080830187613fe5565b82810360208401526153228187614321565b905082810360408401526153368186613f60565b9050828103606084015261534a818561441d565b979650505050505050565b5f60208083525f845461536781614f5a565b806020870152604060018084165f811461538857600181146153a4576153d1565b60ff19851660408a0152604084151560051b8a010195506153d1565b895f5260205f205f5b858110156153c85781548b82018601529083019088016153ad565b8a016040019650505b509398975050505050505050565b5f82601f8301126153ee575f80fd5b81516153fc61418782614144565b818152846020838601011115615410575f80fd5b614dea826020830160208701613fc3565b5f82601f830112615430575f80fd5b8151602061544061418783614501565b82815260059290921b8401810191818101908684111561545e575f80fd5b8286015b848110156145885780516001600160401b0381111561547f575f80fd5b61548d8986838b01016153df565b845250918301918301615462565b5f601f83601f8401126154ac575f80fd5b825160206154bc61418783614501565b82815261014092830286018201928282019190888511156154db575f80fd5b8388015b858110156155355789878201126154f4575f80fd5b6154fc6140f1565b808383018c81111561550c575f80fd5b835b81811015615525578051845292880192880161550e565b50508552509284019281016154df565b509098975050505050505050565b5f82601f830112615552575f80fd5b8151602061556261418783614501565b8083825260208201915060208460051b870101935086841115615583575f80fd5b602086015b8481101561458857805161559b816141bc565b8352918301918301615588565b5f82601f8301126155b7575f80fd5b815160206155c761418783614501565b8083825260208201915060208460051b8701019350868411156155e8575f80fd5b602086015b8481101561458857805183529183019183016155ed565b5f82601f830112615613575f80fd5b8151602061562361418783614501565b8083825260208201915060208460051b870101935086841115615644575f80fd5b602086015b8481101561458857805161565c816145ef565b8352918301918301615649565b5f805f805f805f805f6101208a8c031215615682575f80fd5b89516001600160401b0380821115615698575f80fd5b6156a48d838e01615421565b9a5060208c01519150808211156156b9575f80fd5b6156c58d838e01615421565b995060408c01519150808211156156da575f80fd5b6156e68d838e01615421565b985060608c01519150808211156156fb575f80fd5b6157078d838e0161549b565b975060808c015191508082111561571c575f80fd5b6157288d838e01615543565b965060a08c015191508082111561573d575f80fd5b6157498d838e016155a8565b955060c08c015191508082111561575e575f80fd5b61576a8d838e01615543565b945060e08c015191508082111561577f575f80fd5b61578b8d838e016155a8565b93506101008c01519150808211156157a1575f80fd5b506157ae8c828d01615604565b9150509295985092959850929598565b5f602082840312156157ce575f80fd5b81516001600160401b038111156157e3575f80fd5b614dea848285016153df565b6001600160a01b03831681526040602082018190525f90614dea90830184614321565b5f8261582c57634e487b7160e01b5f52601260045260245ffd5b500490565b808201808211156105d9576105d961503a565b606081525f6158566060830186614321565b82810360208401526158688186613f60565b90508281036040840152613d37818561441d565b5f604082016040835280845180835260608501915060608160051b860101925060208087015f5b838110156158d157605f198887030185526158bf868351613fe5565b955093820193908201906001016158a3565b5050505050828103602084015260018152602d60f81b60208201526040810191505092915050565b60a081525f61590b60a0830188613fe5565b828103602084015261591d8188613fe5565b905082810360408401526159318187613fe5565b905082810360608401526159458186613fe5565b9050828103608084015261131d8185614321565b602080825282516001600160a01b0316828201528201515f9061598760408401826001600160a01b03169052565b50604083015160e060608401526159a2610100840182613fe5565b90506060840151601f19808584030160808601526159c08383613fe5565b9250608086015160a086015260a08601519150808584030160c08601526159e78383614321565b925060c08601519150808584030160e0860152506144e68282613f60565b6001600160a01b0386811682528516602082015260a0604082018190525f90615a3090830186613fe5565b8281036060840152615a428186614321565b9050828103608084015261131d8185613f60565b5f610120808352615a698184018d613fe5565b90508281036020840152615a7d818c613fe5565b6001600160a01b038b811660408601528a16606085015283810360808501529050615aa88189613fe5565b905082810360a0840152615abc8188613fe5565b905082810360c0840152615ad08187614321565b60e084019590955250506101000152979650505050505050565b608081525f615afc6080830187613fe5565b6001600160a01b0395861660208401529385166040830152509216606090920191909152919050565b5f805f805f60a08688031215615b39575f80fd5b85516001600160401b0380821115615b4f575f80fd5b615b5b89838a016153df565b96506020880151915080821115615b70575f80fd5b615b7c89838a01615543565b95506040880151915080821115615b91575f80fd5b615b9d89838a01615421565b94506060880151915080821115615bb2575f80fd5b615bbe89838a016153df565b93506080880151915080821115615bd3575f80fd5b50615be0888289016153df565b915050929550929590935056fe9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00a26469706673582212207240f6a2405c760166c83e72310fe7f40b7f79880d80cbd53d7193933b4368b364736f6c63430008170033

Block Transaction Gas Used Reward
view all blocks produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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.