Skip to content
Verified contractPartialBUSL-1.1

MapleStrategyDeployer

Address0x5e9d93016b2f5a2920b56efdb784fba4099100cd
Balance

0 ETH

 

Transactions

19

 

Compiler

solc 0.8.34

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.34+commit.80d5c536
Language
solidity
Optimization
Yes, 200 runs
EVM version
prague
License
BUSL-1.1
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,205,259
Creation transaction
0xad136a2357…e45e007bd1

modules/strategy-manager/contracts/MapleStrategyDeployer.sol

// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.34;

import { ERC20Helper } from "../modules/erc20-helper/src/ERC20Helper.sol";

import { IMapleProxyFactory } from "../modules/maple-proxy-factory/contracts/interfaces/IMapleProxyFactory.sol";

import { IMapleStrategyDeployer } from "./interfaces/IMapleStrategyDeployer.sol";
import { IMapleStrategyManager } from "./interfaces/IMapleStrategyManager.sol";

import { IGlobalsLike, IStrategyLike, IUnderlyingStrategyLike } from "./interfaces/Interfaces.sol";

/*

   ███╗   ███╗ █████╗ ██████╗ ██╗     ███████╗
   ████╗ ████║██╔══██╗██╔══██╗██║     ██╔════╝
   ██╔████╔██║███████║██████╔╝██║     █████╗
   ██║╚██╔╝██║██╔══██║██╔═══╝ ██║     ██╔══╝
   ██║ ╚═╝ ██║██║  ██║██║     ███████╗███████╗
   ╚═╝     ╚═╝╚═╝  ╚═╝╚═╝     ╚══════╝╚══════╝

   ███████╗████████╗██████╗  █████╗ ████████╗███████╗ ██████╗██╗   ██╗    ██████╗ ███████╗██████╗ ██╗      ██████╗ ██╗   ██╗███████╗██████╗
   ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝██╔════╝██╔════╝╚██╗ ██╔╝    ██╔══██╗██╔════╝██╔══██╗██║     ██╔═══██╗╚██╗ ██╔╝██╔════╝██╔══██╗
   ███████╗   ██║   ██████╔╝███████║   ██║   █████╗  ██║  ███╗╚████╔╝     ██║  ██║█████╗  ██████╔╝██║     ██║   ██║ ╚████╔╝ █████╗  ██████╔╝
   ╚════██║   ██║   ██╔══██╗██╔══██║   ██║   ██╔══╝  ██║   ██║ ╚██╔╝      ██║  ██║██╔══╝  ██╔═══╝ ██║     ██║   ██║  ╚██╔╝  ██╔══╝  ██╔══██╗
   ███████║   ██║   ██║  ██║██║  ██║   ██║   ███████╗╚██████╔╝  ██║       ██████╔╝███████╗██║     ███████╗╚██████╔╝   ██║   ███████╗██║  ██║
   ╚══════╝   ╚═╝   ╚═╝  ╚═╝╚═╝  ╚═╝   ╚═╝   ╚══════╝ ╚═════╝   ╚═╝       ╚═════╝ ╚══════╝╚═╝     ╚══════╝ ╚═════╝    ╚═╝   ╚══════╝╚═╝  ╚═╝

*/

contract MapleStrategyDeployer is IMapleStrategyDeployer {

    address public immutable override globals;

    /**************************************************************************************************************************************/
    /*** Constructor                                                                                                                    ***/
    /**************************************************************************************************************************************/

    constructor(address globals_) {
        require(globals_ != address(0), "MSD:C:ZERO_GLOBALS");

        globals = globals_;
    }

    /**************************************************************************************************************************************/
    /*** Deployment Functions                                                                                                           ***/
    /**************************************************************************************************************************************/

    function deploy(
        address strategyManagerFactory_,
        address strategyFactory_,
        uint256 strategyLiquidityCap_,
        bytes calldata strategyDeploymentData_,
        bytes calldata bootstrapFundingData_
    )
        external
        override
        returns (address strategyManager_, address underlyingStrategy_)
    {
        address      strategyDelegate_ = msg.sender;
        bytes32      salt_             = keccak256(abi.encode(strategyDelegate_));
        IGlobalsLike globals_          = IGlobalsLike(globals);

        require(globals_.isStrategyDelegate(strategyDelegate_),                             "MSD:D:INVALID_SD");
        require(globals_.isInstanceOf("STRATEGY_MANAGER_FACTORY", strategyManagerFactory_), "MSD:D:INVALID_SM_FACTORY");
        require(globals_.isInstanceOf("UNDERLYING_STRATEGY_FACTORY", strategyFactory_),     "MSD:D:INVALID_STRATEGY_FACTORY");

        strategyManager_ = IMapleProxyFactory(strategyManagerFactory_).createInstance(abi.encode(strategyDelegate_), salt_);

        bytes memory fullStrategyDeploymentData_ = bytes.concat(abi.encode(strategyManager_), strategyDeploymentData_);

        address underlyingStrategyPredicted_ = IMapleProxyFactory(strategyFactory_).getInstanceAddress(fullStrategyDeploymentData_, salt_);

        IMapleStrategyManager(strategyManager_).setUnderlyingStrategy(underlyingStrategyPredicted_);

        underlyingStrategy_ = IMapleProxyFactory(strategyFactory_).createInstance(fullStrategyDeploymentData_, salt_);

        require(IMapleStrategyManager(strategyManager_).underlyingStrategy() == underlyingStrategy_, "MSD:D:INVALID_STRATEGY");
        require(IStrategyLike(underlyingStrategy_).strategyManager() == strategyManager_,            "MSD:D:INVALID_STRATEGY_MANAGER");

        address fundsAsset_      = IUnderlyingStrategyLike(underlyingStrategy_).fundsAsset();
        uint256 bootstrapAssets_ = globals_.bootstrapMint(fundsAsset_);

        if (bootstrapAssets_ != 0) {
            require(
                ERC20Helper.transferFrom(fundsAsset_, strategyDelegate_, underlyingStrategy_, bootstrapAssets_),
                "MSD:D:BOOTSTRAP_TRANSFER_FAILED"
            );
        }

        if (strategyLiquidityCap_ != 0) {
            IMapleStrategyManager(strategyManager_).setStrategyLiquidityCap(strategyLiquidityCap_);
        }

        IMapleStrategyManager(strategyManager_).completeConfiguration(bootstrapAssets_, bootstrapFundingData_);

        emit StrategyManagerDeployed(strategyDelegate_, strategyManager_, underlyingStrategy_);
    }

    /**************************************************************************************************************************************/
    /*** View Functions                                                                                                                 ***/
    /**************************************************************************************************************************************/

    function getDeploymentAddresses(
        address strategyDelegate_,
        address strategyManagerFactory_,
        address strategyFactory_,
        bytes calldata strategyDeploymentData_
    )
        external
        view
        override
        returns (address strategyManager_, address underlyingStrategy_)
    {
        bytes32 salt_ = keccak256(abi.encode(strategyDelegate_));

        strategyManager_ = IMapleProxyFactory(strategyManagerFactory_).getInstanceAddress(abi.encode(strategyDelegate_), salt_);

        bytes memory fullStrategyDeploymentData_ = bytes.concat(abi.encode(strategyManager_), strategyDeploymentData_);

        underlyingStrategy_ = IMapleProxyFactory(strategyFactory_).getInstanceAddress(fullStrategyDeploymentData_, salt_);
    }

}

modules/strategy-manager/contracts/interfaces/IMapleStrategyDeployer.sol

// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

/**
 *  @title Defines a contract that deploys Maple strategies.
 */
interface IMapleStrategyDeployer {

    /**
     *  @dev   Emitted when a new strategy manager and its underlying strategy are deployed.
     *  @param strategyDelegate   Address of the strategy delegate.
     *  @param strategyManager    Address of the deployed strategy manager.
     *  @param underlyingStrategy Address of the deployed underlying strategy.
     */
    event StrategyManagerDeployed(address indexed strategyDelegate, address indexed strategyManager, address indexed underlyingStrategy);

    /**
     *  @dev    Deploys a strategy manager and underlying strategy.
     *  @param  strategyManagerFactory Address of the strategy manager factory.
     *  @param  strategyFactory        Address of the underlying strategy factory.
     *  @param  strategyLiquidityCap   Maximum total asset position the strategy manager can hold. A value of zero is
     *                                 left unset and can be configured later by an admin.
     *  @param  strategyDeploymentData Strategy initialization data.
     *  @param  bootstrapFundingData   Data forwarded to the underlying strategy when funding the bootstrap assets.
     *  @return strategyManager        Address of the deployed strategy manager.
     *  @return underlyingStrategy     Address of the deployed underlying strategy.
     */
    function deploy(
        address strategyManagerFactory,
        address strategyFactory,
        uint256 strategyLiquidityCap,
        bytes calldata strategyDeploymentData,
        bytes calldata bootstrapFundingData
    )
        external
        returns (address strategyManager, address underlyingStrategy);

    /**
     *  @dev    Returns the address of the Maple globals contract.
     *  @return globals The address of the globals contract.
     */
    function globals() external view returns (address globals);

    /**
     *  @dev    Returns the addresses that would result from a deployment.
     *  @param  strategyDelegate       Address of the strategy delegate.
     *  @param  strategyManagerFactory Address of the strategy manager factory.
     *  @param  strategyFactory        Address of the underlying strategy factory.
     *  @param  strategyDeploymentData Strategy initialization data.
     *  @return strategyManager        Address of the strategy manager that will be deployed.
     *  @return underlyingStrategy     Address of the underlying strategy that will be deployed.
     */
    function getDeploymentAddresses(
        address strategyDelegate,
        address strategyManagerFactory,
        address strategyFactory,
        bytes calldata strategyDeploymentData
    )
        external
        view
        returns (address strategyManager, address underlyingStrategy);

}

modules/strategy-manager/contracts/interfaces/IMapleStrategyManager.sol

// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import { IMapleProxied } from "../../modules/maple-proxy-factory/contracts/interfaces/IMapleProxied.sol";

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

/**
 *  @title Defines a Maple strategy manager.
 */
interface IMapleStrategyManager is IMapleStrategyManagerStorage, IMapleProxied {

    /**************************************************************************************************************************************/
    /*** Events                                                                                                                         ***/
    /**************************************************************************************************************************************/

    /**
     *  @dev   Emitted when a pool manager's maximum asset position is set. Zero means no cap is set,
     *         and `type(uint256).max` means the pool manager is blocked entirely.
     *  @param poolManager Address of the pool manager whose cap was set.
     *  @param cap         The maximum asset position the pool manager is authorized to hold, with Zero meaning no cap is set
     *                     and type(uint256).max meaning the pool manager is completely blocked.
     */
    event PoolManagerCapSet(address indexed poolManager, uint256 cap);

    /**
     *  @dev   Emitted when the pending strategy delegate accepts the ownership transfer.
     *  @param previousStrategyDelegate Address of the previous strategy delegate.
     *  @param newStrategyDelegate      Address of the new strategy delegate.
     */
    event PendingStrategyDelegateAccepted(address indexed previousStrategyDelegate, address indexed newStrategyDelegate);

    /**
     *  @dev   Emitted when the pending strategy delegate is set.
     *  @param pendingStrategyDelegate Address of the pending strategy delegate.
     */
    event PendingStrategyDelegateSet(address indexed pendingStrategyDelegate);

    /**
     *  @dev   Emitted when a pending redemption is cancelled for a pool manager.
     *  @param poolManager     Address of the pool manager whose pending shares were reduced.
     *  @param sharesCancelled Number of pending shares cancelled.
     */
    event RedemptionCancelled(address indexed poolManager, uint256 sharesCancelled);

    /**
     *  @dev   Emitted when a pending redemption is processed for a pool manager.
     *  @param poolManager     Address of the pool manager whose shares were redeemed.
     *  @param sharesProcessed Number of shares processed for redemption.
     *  @param assetsWithdrawn  Number of assets withdrawn from the underlying strategy.
     */
    event RedemptionProcessed(address indexed poolManager, uint256 sharesProcessed, uint256 assetsWithdrawn);

    /**
     *  @dev   Emitted when a redemption is requested for a pool manager.
     *  @param poolManager     Address of the pool manager whose shares are being queued for redemption.
     *  @param sharesRequested Number of shares queued for redemption.
     */
    event RedemptionRequested(address indexed poolManager, uint256 sharesRequested);

    /**
     *  @dev   Emitted when the strategy manager is set to be active or inactive.
     *  @param active Whether the strategy manager is active.
     */
    event SetAsActive(bool active);

    /**
     *  @dev   Emitted when the strategy manager's maximum total asset position is set.
     *  @param cap The maximum total asset position the strategy manager is authorized to hold.
     */
    event StrategyLiquidityCapSet(uint256 cap);

    /**
     *  @dev   Emitted when the strategy manager configuration is marked as complete.
     */
    event StrategyManagerConfigurationComplete();

    /**
     *  @dev   Emitted when a pool manager funds the strategy manager.
     *  @param poolManager     Address of the pool manager that received shares.
     *  @param assetsIn        Amount of assets pulled from the pool.
     *  @param assetsDeposited Amount of assets deposited into the underlying strategy.
     *  @param sharesMinted    Number of shares credited to the pool manager.
     */
    event StrategyManagerFunded(address indexed poolManager, uint256 assetsIn, uint256 assetsDeposited, uint256 sharesMinted);

    /**
     *  @dev   Emitted when the underlying strategy is set.
     *  @param underlyingStrategy Address of the underlying strategy.
     */
    event UnderlyingStrategySet(address indexed underlyingStrategy);

    /**************************************************************************************************************************************/
    /*** Initial Configuration Functions                                                                                                ***/
    /**************************************************************************************************************************************/

    /**
     *  @dev   Complete the configuration.
     *  @param bootstrapAssets      Amount of assets to use to bootstrap the strategy manager.
     *  @param bootstrapFundingData Arbitrary data forwarded to the underlying strategy on `fundUnderlyingStrategy`.
     */
    function completeConfiguration(uint256 bootstrapAssets, bytes calldata bootstrapFundingData) external;

    /**
     *  @dev   Sets the underlying strategy during deployment before configuration is complete.
     *  @param underlyingStrategy Address of the underlying strategy.
     */
    function setUnderlyingStrategy(address underlyingStrategy) external;

    /**
     *  @dev   Sets the strategy manager to be active or inactive.
     *  @param active Whether the strategy manager is active.
     */
    function setActive(bool active) external;

    /**************************************************************************************************************************************/
    /*** Ownership Transfer Functions                                                                                                   ***/
    /**************************************************************************************************************************************/

    /**
     *  @dev Accepts the role of strategy delegate.
     */
    function acceptStrategyDelegate() external;

    /**
     *  @dev   Sets an address as the pending strategy delegate. Passing address(0) cancels a pending transfer.
     *  @param pendingStrategyDelegate Address of the new strategy delegate.
     */
    function setPendingStrategyDelegate(address pendingStrategyDelegate) external;

    /**************************************************************************************************************************************/
    /*** Liquidity Management Functions                                                                                                ***/
    /**************************************************************************************************************************************/

    /**
     *  @dev   Pulls assets from a pool manager into the underlying strategy and credits the pool manager with shares.
     *         If a non-zero cap is set for the pool manager (see `setPoolManagerCap`), the resulting asset position
     *         must not exceed it. A cap of zero is treated as unset and imposes no limit. A cap of `type(uint256).max`
     *         blocks the pool manager entirely, so any funding reverts.
     *  @param poolManager Address of the pool manager being funded.
     *  @param assetsIn    Amount of assets to pull from the pool.
     *  @param data        Arbitrary data forwarded to the underlying strategy on `fundUnderlyingStrategy`.
     */
    function fundStrategyManager(address poolManager, uint256 assetsIn, bytes calldata data) external;

    /**
     *  @dev   Requests a redemption of shares for a pool manager. Does not reduce the pool manager's share balance until
     *         the redemption is processed.
     *  @param poolManager Address of the pool manager requesting the redemption.
     *  @param shares      Number of shares to queue for redemption.
     */
    function requestRedeem(address poolManager, uint256 shares) external;

    /**
     *  @dev   Cancels a previously queued redemption, reducing the pool manager's pending shares.
     *  @param poolManager Address of the pool manager whose redemption is being cancelled.
     *  @param shares      Number of pending shares to cancel.
     */
    function cancelRedemption(address poolManager, uint256 shares) external;

    /**
     *  @dev    Process a pending redemption.
     *          Withdraws from underlying strategy and sends assets directly to pool.
     *  @param  poolManager Address of the pool manager whose redemption to process.
     *  @param  shares      Amount of shares to process.
     *  @param  data        Arbitrary data forwarded to the underlying strategy on `withdrawFromUnderlyingStrategy`.
     */
    function processRedemption(address poolManager, uint256 shares, bytes calldata data) external;

    /**************************************************************************************************************************************/
    /*** Administrative Functions                                                                                                       ***/
    /**************************************************************************************************************************************/

    /**
     *  @dev   Sets the maximum asset position a pool manager can have in the strategy manager.
     *         Setting the cap to zero unsets it, meaning the pool manager has no limit and funding
     *         is bounded only by the strategy liquidity cap. Setting the cap to `type(uint256).max`
     *         blocks the pool manager entirely.
     *  @param poolManager Address of the pool manager whose cap is being set.
     *  @param cap         Maximum asset position the pool manager can have in the strategy manager. Zero means no cap,
     *                     `type(uint256).max` means the pool manager is blocked.
     */
    function setPoolManagerCap(address poolManager, uint256 cap) external;

    /**
     *  @dev   Sets the maximum total asset position the strategy manager can have.
     *  @param cap Maximum total asset position the strategy manager can have.
     */
    function setStrategyLiquidityCap(uint256 cap) external;

    /**
     *  @dev   Allows EOAs to batch admin calls.
     *  @param data Array of calldata.
     */
    function multicall(bytes[] calldata data) external;

    /**************************************************************************************************************************************/
    /*** View Functions                                                                                                                 ***/
    /**************************************************************************************************************************************/

    /**
     *  @dev    Returns the assets that belong to a given pool manager based on its share of total shares.
     *  @param  poolManager Address of the pool manager.
     *  @return assets      Assets currently belonging to the pool manager.
     */
    function assetsOf(address poolManager) external view returns (uint256 assets);

    /**
     *  @dev    Returns the assets currently available to withdraw from the underlying strategy.
     *  @return availableToWithdraw Assets available to withdraw.
     */
    function availableToWithdraw() external view returns (uint256 availableToWithdraw);

    /**
     *  @dev    Returns the total assets currently under management by the underlying strategy.
     *  @return assetsUnderManagement The total assets under management.
     */
    function assetsUnderManagement() external view returns (uint256 assetsUnderManagement);

    /**
     *  @dev    Converts shares to assets based on the current total assets and total shares.
     *  @param  shares Number of shares to convert.
     *  @return assets Number of assets converted from shares.
     */
    function convertToAssets(uint256 shares) external view returns (uint256 assets);

    /**
     *  @dev    Converts assets to shares based on the current total assets and total shares.
     *  @param  assets Number of assets to convert.
     *  @return shares Number of shares converted from assets.
     */
    function convertToShares(uint256 assets) external view returns (uint256 shares);

    /**
     *  @dev    Returns the address of the Maple globals contract.
     *  @return globals Address of the Maple globals contract.
     */
    function globals() external view returns (address globals);

    /**
     *  @dev    Converts shares to assets using the exit rate, which subtracts unrealized losses from total assets.
     *  @param  shares Number of shares to convert.
     *  @return assets Number of exit assets converted from shares.
     */
    function convertToExitAssets(uint256 shares) external view returns (uint256 assets);

    /**
     *  @dev    Converts assets to shares using the exit rate, which subtracts unrealized losses from total assets.
     *  @param  assets Number of assets to convert.
     *  @return shares Number of shares converted from exit assets.
     */
    function convertToExitShares(uint256 assets) external view returns (uint256 shares);

    /**
     *  @dev    Returns whether the given asset is supported by the strategy manager.
     *  @param  asset       Address of the asset to query.
     *  @return isSupported True if the strategy manager supports `asset`.
     */
    function isAssetSupported(address asset) external view returns (bool isSupported);

    /**
     *  @dev    Returns the address of the security admin.
     *  @return securityAdmin Address of the security admin.
     */
    function securityAdmin() external view returns (address securityAdmin);

    /**
     *  @dev    Returns the total unrealized losses reported by the underlying strategy, clamped to assets under management.
     *  @return unrealizedLosses Total unrealized losses, capped at assets under management.
     */
    function unrealizedLosses() external view returns (uint256 unrealizedLosses);

    /**
     *  @dev    Returns the unrealized losses attributed to a given pool manager based on its share of total shares.
     *  @param  poolManager      Address of the pool manager.
     *  @return unrealizedLosses Unrealized losses attributed to the pool manager.
     */
    function unrealizedLossesOf(address poolManager) external view returns (uint256 unrealizedLosses);

}

modules/strategy-manager/contracts/interfaces/IMapleStrategyManagerStorage.sol

// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

/**
 *  @title Defines the storage layout of a Maple strategy manager.
 */
interface IMapleStrategyManagerStorage {

    /**
     *  @dev    Returns whether or not the strategy manager is active.
     *  @return active True if the strategy manager is active.
     */
    function active() external view returns (bool active);

    /**
     *  @dev    Returns whether or not the strategy manager is configured.
     *  @return configured True if the strategy manager is configured.
     */
    function configured() external view returns (bool configured);

    /**
     *  @dev    Returns the per-pool-manager maximum asset position for a given pool manager.
     *          A value of zero means no cap is set and the pool manager has no limit, and funding
     *          is bounded only by the strategy liquidity cap. A value of `type(uint256).max` means the
     *          pool manager is blocked entirely.
     *  @param  poolManager      Address of the pool manager.
     *  @return poolManagerCapOf The maximum asset position the pool manager is authorized to hold. Zero means no cap,
     *                           `type(uint256).max` means the pool manager is blocked.
     */
    function poolManagerCapOf(address poolManager) external view returns (uint256 poolManagerCapOf);

    /**
     *  @dev    Returns the address of the pending strategy delegate.
     *  @return pendingStrategyDelegate The address of the pending strategy delegate.
     */
    function pendingStrategyDelegate() external view returns (address pendingStrategyDelegate);

    /**
     *  @dev    Returns the number of pending redemption shares held by a given pool manager.
     *  @param  poolManager     Address of the pool manager.
     *  @return pendingSharesOf Number of shares the pool manager has requested to redeem but has not yet processed.
     */
    function pendingSharesOf(address poolManager) external view returns (uint256 pendingSharesOf);

    /**
     *  @dev    Returns the share balance held by a given pool manager.
     *  @param  poolManager Address of the pool manager.
     *  @return sharesOf    Number of shares owned by the pool manager.
     */
    function sharesOf(address poolManager) external view returns (uint256 sharesOf);

    /**
     *  @dev    Returns the address of the strategy delegate.
     *  @return strategyDelegate The address of the strategy delegate.
     */
    function strategyDelegate() external view returns (address strategyDelegate);

    /**
     *  @dev    Returns the maximum exposure to the strategy.
     *  @return strategyLiquidityCap The maximum total asset position the strategy manager is authorized to hold.
     */
    function strategyLiquidityCap() external view returns (uint256 strategyLiquidityCap);

    /**
     *  @dev    Returns the total number of pending redemption shares across all pool managers.
     *  @return totalPendingShares Sum of all pending redemption shares.
     */
    function totalPendingShares() external view returns (uint256 totalPendingShares);

    /**
     *  @dev    Returns the total number of shares issued by the strategy manager.
     *  @return totalShares Sum of all shares across pool managers.
     */
    function totalShares() external view returns (uint256 totalShares);

    /**
     *  @dev    Returns the address of the underlying strategy contract.
     *  @return underlyingStrategy Address of the underlying strategy.
     */
    function underlyingStrategy() external view returns (address underlyingStrategy);

}

modules/strategy-manager/contracts/interfaces/Interfaces.sol

// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

interface IGlobalsLike {

    function bootstrapMint(address asset) external view returns (uint256 bootstrapMint);

    function canDeploy(address caller) external view returns (bool);

    function governor() external view returns (address);

    function isFunctionPaused(bytes4 signature) external view returns (bool);

    function isInstanceOf(bytes32 instanceId, address instance) external view returns (bool isInstance);

    function isStrategyDelegate(address account) external view returns (bool isStrategyDelegate);

    function operationalAdmin() external view returns (address);

    function securityAdmin() external view returns (address);

    function transferOwnedStrategyManager(address fromStrategyDelegate, address toStrategyDelegate) external;

}

interface IERC20Like {

    function transferFrom(address owner, address recipient, uint256 amount) external returns (bool success);

}

interface IProxyFactoryLike {

    function isInstance(address instance) external view returns (bool isInstance);

    function mapleGlobals() external view returns (address);

    function upgradeInstance(uint256 version, bytes calldata arguments) external;

}

interface IPoolManagerLike {

    function factory() external view returns (address factory);

    function pool() external view returns (address pool);

    function poolDelegate() external view returns (address poolDelegate);

    function requestFunds(address destination, uint256 principal) external;

}

interface IStrategyLike {

    function strategyManager() external view returns (address strategyManager);

}

interface IStrategyManagerLike {

    function cancelRedemption(address poolManager, uint256 shares) external;

    function factory() external view returns (address factory);

    function fundStrategyManager(address poolManager, uint256 assetsIn, bytes calldata data) external;

    function processRedemption(address poolManager, uint256 shares, bytes calldata data) external;

    function requestRedeem(address poolManager, uint256 shares) external;

}

interface IUnderlyingStrategyLike {

    function availableToWithdraw() external view returns (uint256 availableToWithdraw);

    function assetsUnderManagement() external view returns (uint256 assetsUnderManagement);

    function factory() external view returns (address factory);

    function fundsAsset() external view returns (address fundsAsset);

    function fundUnderlyingStrategy(uint256 assets, bytes calldata data) external returns (uint256 amount);

    function impairedAssets() external view returns (uint256 impairedAssets);

    function unrealizedLosses() external view returns (uint256 unrealizedLosses);

    function withdrawFromUnderlyingStrategy(address destination, uint256 assets, bytes calldata data) external;

}

modules/strategy-manager/modules/erc20-helper/src/ERC20Helper.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.7;

import { IERC20Like } from "./interfaces/IERC20Like.sol";

/**
 * @title Small Library to standardize erc20 token interactions.
 */
library ERC20Helper {

    /**************************************************************************************************************************************/
    /*** Internal Functions                                                                                                             ***/
    /**************************************************************************************************************************************/

    function transfer(address token_, address to_, uint256 amount_) internal returns (bool success_) {
        return _call(token_, abi.encodeWithSelector(IERC20Like.transfer.selector, to_, amount_));
    }

    function transferFrom(address token_, address from_, address to_, uint256 amount_) internal returns (bool success_) {
        return _call(token_, abi.encodeWithSelector(IERC20Like.transferFrom.selector, from_, to_, amount_));
    }

    function approve(address token_, address spender_, uint256 amount_) internal returns (bool success_) {
        // If setting approval to zero fails, return false.
        if (!_call(token_, abi.encodeWithSelector(IERC20Like.approve.selector, spender_, uint256(0)))) return false;

        // If `amount_` is zero, return true as the previous step already did this.
        if (amount_ == uint256(0)) return true;

        // Return the result of setting the approval to `amount_`.
        return _call(token_, abi.encodeWithSelector(IERC20Like.approve.selector, spender_, amount_));
    }

    function _call(address token_, bytes memory data_) private returns (bool success_) {
        if (token_.code.length == uint256(0)) return false;

        bytes memory returnData;
        ( success_, returnData ) = token_.call(data_);

        return success_ && (returnData.length == uint256(0) || abi.decode(returnData, (bool)));
    }

}

modules/strategy-manager/modules/erc20-helper/src/interfaces/IERC20Like.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.7;

/// @title Interface of the ERC20 standard as needed by ERC20Helper.
interface IERC20Like {

    function approve(address spender_, uint256 amount_) external returns (bool success_);

    function transfer(address recipient_, uint256 amount_) external returns (bool success_);

    function transferFrom(address owner_, address recipient_, uint256 amount_) external returns (bool success_);

}

modules/strategy-manager/modules/maple-proxy-factory/contracts/interfaces/IMapleProxied.sol

// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.7;

import { IProxied } from "../../modules/proxy-factory/contracts/interfaces/IProxied.sol";

/// @title A Maple implementation that is to be proxied, must implement IMapleProxied.
interface IMapleProxied is IProxied {

    /**
     *  @dev   The instance was upgraded.
     *  @param toVersion_ The new version of the loan.
     *  @param arguments_ The upgrade arguments, if any.
     */
    event Upgraded(uint256 toVersion_, bytes arguments_);

    /**
     *  @dev   Upgrades a contract implementation to a specific version.
     *         Access control logic critical since caller can force a selfdestruct via a malicious `migrator_` which is delegatecalled.
     *  @param toVersion_ The version to upgrade to.
     *  @param arguments_ Some encoded arguments to use for the upgrade.
     */
    function upgrade(uint256 toVersion_, bytes calldata arguments_) external;

}

modules/strategy-manager/modules/maple-proxy-factory/contracts/interfaces/IMapleProxyFactory.sol

// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.7;

import { IDefaultImplementationBeacon } from "../../modules/proxy-factory/contracts/interfaces/IDefaultImplementationBeacon.sol";

/// @title A Maple factory for Proxy contracts that proxy MapleProxied implementations.
interface IMapleProxyFactory is IDefaultImplementationBeacon {

    /**************************************************************************************************************************************/
    /*** Events                                                                                                                         ***/
    /**************************************************************************************************************************************/

    /**
     *  @dev   A default version was set.
     *  @param version_ The default version.
     */
    event DefaultVersionSet(uint256 indexed version_);

    /**
     *  @dev   A version of an implementation, at some address, was registered, with an optional initializer.
     *  @param version_               The version registered.
     *  @param implementationAddress_ The address of the implementation.
     *  @param initializer_           The address of the initializer, if any.
     */
    event ImplementationRegistered(uint256 indexed version_, address indexed implementationAddress_, address indexed initializer_);

    /**
     *  @dev   A proxy contract was deployed with some initialization arguments.
     *  @param version_                 The version of the implementation being proxied by the deployed proxy contract.
     *  @param instance_                The address of the proxy contract deployed.
     *  @param initializationArguments_ The arguments used to initialize the proxy contract, if any.
     */
    event InstanceDeployed(uint256 indexed version_, address indexed instance_, bytes initializationArguments_);

    /**
     *  @dev   A instance has upgraded by proxying to a new implementation, with some migration arguments.
     *  @param instance_           The address of the proxy contract.
     *  @param fromVersion_        The initial implementation version being proxied.
     *  @param toVersion_          The new implementation version being proxied.
     *  @param migrationArguments_ The arguments used to migrate, if any.
     */
    event InstanceUpgraded(address indexed instance_, uint256 indexed fromVersion_, uint256 indexed toVersion_, bytes migrationArguments_);

    /**
     *  @dev   The MapleGlobals was set.
     *  @param mapleGlobals_ The address of a Maple Globals contract.
     */
    event MapleGlobalsSet(address indexed mapleGlobals_);

    /**
     *  @dev   An upgrade path was disabled, with an optional migrator contract.
     *  @param fromVersion_ The starting version of the upgrade path.
     *  @param toVersion_   The destination version of the upgrade path.
     */
    event UpgradePathDisabled(uint256 indexed fromVersion_, uint256 indexed toVersion_);

    /**
     *  @dev   An upgrade path was enabled, with an optional migrator contract.
     *  @param fromVersion_ The starting version of the upgrade path.
     *  @param toVersion_   The destination version of the upgrade path.
     *  @param migrator_    The address of the migrator, if any.
     */
    event UpgradePathEnabled(uint256 indexed fromVersion_, uint256 indexed toVersion_, address indexed migrator_);

    /**************************************************************************************************************************************/
    /*** State Variables                                                                                                                ***/
    /**************************************************************************************************************************************/

    /**
     *  @dev The default version.
     */
    function defaultVersion() external view returns (uint256 defaultVersion_);

    /**
     *  @dev The address of the MapleGlobals contract.
     */
    function mapleGlobals() external view returns (address mapleGlobals_);

    /**
     *  @dev    Whether the upgrade is enabled for a path from a version to another version.
     *  @param  toVersion_   The initial version.
     *  @param  fromVersion_ The destination version.
     *  @return allowed_     Whether the upgrade is enabled.
     */
    function upgradeEnabledForPath(uint256 toVersion_, uint256 fromVersion_) external view returns (bool allowed_);

    /**************************************************************************************************************************************/
    /*** State Changing Functions                                                                                                       ***/
    /**************************************************************************************************************************************/

    /**
     *  @dev    Deploys a new instance proxying the default implementation version, with some initialization arguments.
     *          Uses a nonce and `msg.sender` as a salt for the CREATE2 opcode during instantiation to produce deterministic addresses.
     *  @param  arguments_ The initialization arguments to use for the instance deployment, if any.
     *  @param  salt_      The salt to use in the contract creation process.
     *  @return instance_  The address of the deployed proxy contract.
     */
    function createInstance(bytes calldata arguments_, bytes32 salt_) external returns (address instance_);

    /**
     *  @dev   Enables upgrading from a version to a version of an implementation, with an optional migrator.
     *         Only the Governor can call this function.
     *  @param fromVersion_ The starting version of the upgrade path.
     *  @param toVersion_   The destination version of the upgrade path.
     *  @param migrator_    The address of the migrator, if any.
     */
    function enableUpgradePath(uint256 fromVersion_, uint256 toVersion_, address migrator_) external;

    /**
     *  @dev   Disables upgrading from a version to a version of a implementation.
     *         Only the Governor can call this function.
     *  @param fromVersion_ The starting version of the upgrade path.
     *  @param toVersion_   The destination version of the upgrade path.
     */
    function disableUpgradePath(uint256 fromVersion_, uint256 toVersion_) external;

    /**
     *  @dev   Registers the address of an implementation contract as a version, with an optional initializer.
     *         Only the Governor can call this function.
     *  @param version_               The version to register.
     *  @param implementationAddress_ The address of the implementation.
     *  @param initializer_           The address of the initializer, if any.
     */
    function registerImplementation(uint256 version_, address implementationAddress_, address initializer_) external;

    /**
     *  @dev   Sets the default version.
     *         Only the Governor can call this function.
     *  @param version_ The implementation version to set as the default.
     */
    function setDefaultVersion(uint256 version_) external;

    /**
     *  @dev   Sets the Maple Globals contract.
     *         Only the Governor can call this function.
     *  @param mapleGlobals_ The address of a Maple Globals contract.
     */
    function setGlobals(address mapleGlobals_) external;

    /**
     *  @dev   Upgrades the calling proxy contract's implementation, with some migration arguments.
     *  @param toVersion_ The implementation version to upgrade the proxy contract to.
     *  @param arguments_ The migration arguments, if any.
     */
    function upgradeInstance(uint256 toVersion_, bytes calldata arguments_) external;

    /**************************************************************************************************************************************/
    /*** View Functions                                                                                                                 ***/
    /**************************************************************************************************************************************/

    /**
     *  @dev    Returns the deterministic address of a potential proxy, given some arguments and salt.
     *  @param  arguments_       The initialization arguments to be used when deploying the proxy.
     *  @param  salt_            The salt to be used when deploying the proxy.
     *  @return instanceAddress_ The deterministic address of a potential proxy.
     */
    function getInstanceAddress(bytes calldata arguments_, bytes32 salt_) external view returns (address instanceAddress_);

    /**
     *  @dev    Returns the address of an implementation version.
     *  @param  version_        The implementation version.
     *  @return implementation_ The address of the implementation.
     */
    function implementationOf(uint256 version_) external view returns (address implementation_);

    /**
     *  @dev    Returns if a given address has been deployed by this factory/
     *  @param  instance_   The address to check.
     *  @return isInstance_ A boolean indication if the address has been deployed by this factory.
     */
    function isInstance(address instance_) external view returns (bool isInstance_);

    /**
     *  @dev    Returns the address of a migrator contract for a migration path (from version, to version).
     *          If oldVersion_ == newVersion_, the migrator is an initializer.
     *  @param  oldVersion_ The old version.
     *  @param  newVersion_ The new version.
     *  @return migrator_   The address of a migrator contract.
     */
    function migratorForPath(uint256 oldVersion_, uint256 newVersion_) external view returns (address migrator_);

    /**
     *  @dev    Returns the version of an implementation contract.
     *  @param  implementation_ The address of an implementation contract.
     *  @return version_        The version of the implementation contract.
     */
    function versionOf(address implementation_) external view returns (uint256 version_);

}

modules/strategy-manager/modules/maple-proxy-factory/modules/proxy-factory/contracts/interfaces/IDefaultImplementationBeacon.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.7;

/// @title An beacon that provides a default implementation for proxies, must implement IDefaultImplementationBeacon.
interface IDefaultImplementationBeacon {

    /// @dev The address of an implementation for proxies.
    function defaultImplementation() external view returns (address defaultImplementation_);

}

modules/strategy-manager/modules/maple-proxy-factory/modules/proxy-factory/contracts/interfaces/IProxied.sol

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.7;

/// @title An implementation that is to be proxied, must implement IProxied.
interface IProxied {

    /**
     *  @dev The address of the proxy factory.
     */
    function factory() external view returns (address factory_);

    /**
     *  @dev The address of the implementation contract being proxied.
     */
    function implementation() external view returns (address implementation_);

    /**
     *  @dev   Modifies the proxy's implementation address.
     *  @param newImplementation_ The address of an implementation contract.
     */
    function setImplementation(address newImplementation_) external;

    /**
     *  @dev   Modifies the proxy's storage by delegate-calling a migrator contract with some arguments.
     *         Access control logic critical since caller can force a selfdestruct via a malicious `migrator_` which is delegatecalled.
     *  @param migrator_  The address of a migrator contract.
     *  @param arguments_ Some encoded arguments to use for the migration.
     */
    function migrate(address migrator_, bytes calldata arguments_) external;

}
Compiler settingsShow
{
  "viaIR": false,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "prague",
  "remappings": [
    "modules/syrup-utils/modules/lite-psm/lib/dss-test/lib/forge-std/:ds-test/=modules/syrup-utils/modules/lite-psm/lib/dss-test/lib/forge-std/lib/ds-test/src/",
    "modules/syrup-utils/modules/lite-psm/lib/dss-test/lib/forge-std/:ds-test/=modules/syrup-utils/modules/lite-psm/lib/dss-test/lib/forge-std/lib/ds-test/src/",
    "modules/syrup-utils/modules/globals-v2/modules/forge-std/:ds-test/=modules/syrup-utils/modules/globals-v2/modules/forge-std/lib/ds-test/src/",
    "modules/syrup-utils/modules/globals-v2/modules/forge-std/:ds-test/=modules/syrup-utils/modules/globals-v2/modules/forge-std/lib/ds-test/src/",
    "modules/syrup-utils/modules/lite-psm/lib/dss-test/:forge-std/=modules/syrup-utils/modules/lite-psm/lib/dss-test/lib/forge-std/src/",
    "modules/syrup-utils/modules/lite-psm/lib/dss-test/:forge-std/=modules/syrup-utils/modules/lite-psm/lib/dss-test/lib/forge-std/src/",
    "modules/syrup-utils/modules/mpl-migration/modules/erc20-helper/:contract-test-utils/=modules/syrup-utils/modules/mpl-migration/modules/erc20-helper/lib/contract-test-utils/contracts/",
    "modules/syrup-utils/modules/mpl-migration/modules/erc20-helper/:contract-test-utils/=modules/syrup-utils/modules/mpl-migration/modules/erc20-helper/lib/contract-test-utils/contracts/",
    "modules/syrup-utils/modules/mpl-v2/modules/forge-std/:ds-test/=modules/syrup-utils/modules/mpl-v2/modules/forge-std/lib/ds-test/src/",
    "modules/syrup-utils/modules/mpl-v2/modules/forge-std/:ds-test/=modules/syrup-utils/modules/mpl-v2/modules/forge-std/lib/ds-test/src/",
    "modules/syrup-utils/modules/open-zeppelin/lib/forge-std/:ds-test/=modules/syrup-utils/modules/open-zeppelin/lib/forge-std/lib/ds-test/src/",
    "modules/syrup-utils/modules/open-zeppelin/lib/forge-std/:ds-test/=modules/syrup-utils/modules/open-zeppelin/lib/forge-std/lib/ds-test/src/",
    "modules/allocation-strategy/modules/erc20-helper/:contract-test-utils/=modules/allocation-strategy/modules/erc20-helper/lib/contract-test-utils/contracts/",
    "modules/allocation-strategy/modules/erc20-helper/:contract-test-utils/=modules/allocation-strategy/modules/erc20-helper/lib/contract-test-utils/contracts/",
    "modules/defi-strategies/modules/erc20-helper/:contract-test-utils/=modules/defi-strategies/modules/erc20-helper/lib/contract-test-utils/contracts/",
    "modules/defi-strategies/modules/erc20-helper/:contract-test-utils/=modules/defi-strategies/modules/erc20-helper/lib/contract-test-utils/contracts/",
    "modules/globals/modules/forge-std/:ds-test/=modules/globals/modules/forge-std/lib/ds-test/src/",
    "modules/globals/modules/forge-std/:ds-test/=modules/globals/modules/forge-std/lib/ds-test/src/",
    "modules/open-term-loan-manager/modules/forge-std/:ds-test/=modules/open-term-loan-manager/modules/forge-std/lib/ds-test/src/",
    "modules/open-term-loan-manager/modules/forge-std/:ds-test/=modules/open-term-loan-manager/modules/forge-std/lib/ds-test/src/",
    "modules/open-term-loan/modules/forge-std/:ds-test/=modules/open-term-loan/modules/forge-std/lib/ds-test/src/",
    "modules/open-term-loan/modules/forge-std/:ds-test/=modules/open-term-loan/modules/forge-std/lib/ds-test/src/",
    "modules/pool-permission-manager/modules/forge-std/:ds-test/=modules/pool-permission-manager/modules/forge-std/lib/ds-test/src/",
    "modules/pool-permission-manager/modules/forge-std/:ds-test/=modules/pool-permission-manager/modules/forge-std/lib/ds-test/src/",
    "modules/pool/modules/forge-std/:ds-test/=modules/pool/modules/forge-std/lib/ds-test/src/",
    "modules/pool/modules/forge-std/:ds-test/=modules/pool/modules/forge-std/lib/ds-test/src/",
    "modules/strategy-manager/modules/erc20-helper/:contract-test-utils/=modules/strategy-manager/modules/erc20-helper/lib/contract-test-utils/contracts/",
    "modules/strategy-manager/modules/erc20-helper/:contract-test-utils/=modules/strategy-manager/modules/erc20-helper/lib/contract-test-utils/contracts/",
    "modules/syrup-utils/modules/erc20-helper/:contract-test-utils/=modules/syrup-utils/modules/erc20-helper/lib/contract-test-utils/contracts/",
    "modules/syrup-utils/modules/erc20-helper/:contract-test-utils/=modules/syrup-utils/modules/erc20-helper/lib/contract-test-utils/contracts/",
    "modules/syrup-utils/modules/open-zeppelin/:forge-std/=modules/syrup-utils/modules/open-zeppelin/lib/forge-std/src/",
    "modules/syrup-utils/modules/open-zeppelin/:forge-std/=modules/syrup-utils/modules/open-zeppelin/lib/forge-std/src/",
    "modules/withdrawal-manager-cyclical/modules/forge-std/:ds-test/=modules/withdrawal-manager-cyclical/modules/forge-std/lib/ds-test/src/",
    "modules/withdrawal-manager-cyclical/modules/forge-std/:ds-test/=modules/withdrawal-manager-cyclical/modules/forge-std/lib/ds-test/src/",
    "modules/withdrawal-manager-queue/modules/forge-std/:ds-test/=modules/withdrawal-manager-queue/modules/forge-std/lib/ds-test/src/",
    "modules/withdrawal-manager-queue/modules/forge-std/:ds-test/=modules/withdrawal-manager-queue/modules/forge-std/lib/ds-test/src/",
    "modules/erc20-helper/:contract-test-utils/=modules/erc20-helper/lib/contract-test-utils/contracts/",
    "modules/erc20-helper/:contract-test-utils/=modules/erc20-helper/lib/contract-test-utils/contracts/",
    "@openzeppelin/contracts/=modules/syrup-utils/modules/open-zeppelin/contracts/",
    "address-registry/=modules/address-registry/contracts/",
    "allocation-strategy/=modules/allocation-strategy/",
    "contract-test-utils/=modules/erc20-helper/lib/contract-test-utils/contracts/",
    "defi-strategies/=modules/defi-strategies/",
    "ds-test/=modules/globals/modules/forge-std/lib/ds-test/src/",
    "dss-interfaces/=modules/syrup-utils/modules/lite-psm/lib/dss-test/lib/dss-interfaces/src/",
    "dss-test/=modules/syrup-utils/modules/lite-psm/lib/dss-test/src/",
    "erc20-helper/=modules/erc20-helper/src/",
    "erc20/=modules/erc20/",
    "erc4626-tests/=modules/syrup-utils/modules/open-zeppelin/lib/erc4626-tests/",
    "forge-std/=modules/forge-std/src/",
    "strategy-manager/=modules/strategy-manager/",
    "syrup-utils/=modules/syrup-utils/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.