creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "contracts/persistent/smart-accounts/share-price-throttled-asset-manager/SharePriceThrottledAssetManagerFactory.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\n\n/*\n    This file is part of the Enzyme Protocol.\n\n    (c) Enzyme Council <council@enzyme.finance>\n\n    For the full license information, please view the LICENSE\n    file that was distributed with this source code.\n*/\n\npragma solidity 0.8.19;\n\nimport {NonUpgradableProxy} from \"../../../utils/0.8.19/NonUpgradableProxy.sol\";\nimport {ISharePriceThrottledAssetManagerLib} from \"./ISharePriceThrottledAssetManagerLib.sol\";\n\n/// @title SharePriceThrottledAssetManagerFactory Contract\n/// @author Enzyme Council <security@enzyme.finance>\n/// @notice A factory for SharePriceThrottledAssetManager proxy instances\ncontract SharePriceThrottledAssetManagerFactory {\n    event ProxyDeployed(\n        address indexed deployer,\n        address proxyAddress,\n        address indexed owner,\n        address indexed vaultProxy,\n        uint64 lossTolerance,\n        uint32 lossTolerancePeriodDuration,\n        address shutDowner\n    );\n\n    address internal immutable LIB_ADDRESS;\n\n    constructor(address _libAddress) {\n        LIB_ADDRESS = _libAddress;\n    }\n\n    /// @notice Deploys a new SharePriceThrottledAssetManager proxy instance\n    /// @param _owner The owner (signer) of the instance\n    /// @param _vaultProxyAddress The VaultProxy that the instance will be associated with\n    /// @param _lossTolerance The cumulative percentage loss tolerated (1e18 is 100%)\n    /// @param _lossTolerancePeriodDuration The length of the period (in seconds) used in cumulative loss tolerance calculations\n    /// @param _shutdowner The admin who can shut down the smart account\n    /// @return proxyAddress_ The newly-deployed instance\n    function deployProxy(\n        address _owner,\n        address _vaultProxyAddress,\n        uint64 _lossTolerance,\n        uint32 _lossTolerancePeriodDuration,\n        address _shutdowner\n    ) external returns (address proxyAddress_) {\n        bytes memory constructData = abi.encodeWithSelector(\n            ISharePriceThrottledAssetManagerLib.init.selector,\n            _owner,\n            _vaultProxyAddress,\n            _lossTolerance,\n            _lossTolerancePeriodDuration,\n            _shutdowner\n        );\n\n        proxyAddress_ = address(new NonUpgradableProxy({_constructData: constructData, _contractLogic: LIB_ADDRESS}));\n\n        emit ProxyDeployed(\n            msg.sender,\n            proxyAddress_,\n            _owner,\n            _vaultProxyAddress,\n            _lossTolerance,\n            _lossTolerancePeriodDuration,\n            _shutdowner\n        );\n\n        return proxyAddress_;\n    }\n}\n"
      },
      "contracts/utils/0.8.19/NonUpgradableProxy.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\n\n/*\n    This file is part of the Enzyme Protocol.\n\n    (c) Enzyme Council <council@enzyme.finance>\n\n    For the full license information, please view the LICENSE\n    file that was distributed with this source code.\n*/\n\npragma solidity 0.8.19;\n\n/// @title NonUpgradableProxy Contract\n/// @author Enzyme Council <security@enzyme.finance>\n/// @notice A proxy contract for use with non-upgradable libs\n/// @dev The recommended constructor-fallback pattern of a proxy in EIP-1822, updated for solc 0.8.19,\n/// and using an immutable lib value to save on gas (since not upgradable).\n/// The EIP-1967 storage slot for the lib is still assigned,\n/// for ease of referring to UIs that understand the pattern, i.e., Etherscan.\ncontract NonUpgradableProxy {\n    address private immutable CONTRACT_LOGIC;\n\n    constructor(bytes memory _constructData, address _contractLogic) {\n        CONTRACT_LOGIC = _contractLogic;\n\n        assembly {\n            // EIP-1967 slot: `bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)`\n            sstore(0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc, _contractLogic)\n        }\n        if (_constructData.length > 0) {\n            (bool success, bytes memory returnData) = _contractLogic.delegatecall(_constructData);\n            require(success, string(returnData));\n        }\n    }\n\n    // solhint-disable-next-line no-complex-fallback\n    fallback() external payable {\n        address contractLogic = CONTRACT_LOGIC;\n\n        assembly {\n            calldatacopy(0x0, 0x0, calldatasize())\n            let success := delegatecall(sub(gas(), 10000), contractLogic, 0x0, calldatasize(), 0, 0)\n            let retSz := returndatasize()\n            returndatacopy(0, 0, retSz)\n            switch success\n            case 0 { revert(0, retSz) }\n            default { return(0, retSz) }\n        }\n    }\n}\n"
      },
      "contracts/persistent/smart-accounts/share-price-throttled-asset-manager/ISharePriceThrottledAssetManagerLib.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\n\n/*\n    This file is part of the Enzyme Protocol.\n\n    (c) Enzyme Council <council@enzyme.finance>\n\n    For the full license information, please view the LICENSE\n    file that was distributed with this source code.\n*/\n\npragma solidity >=0.6.0 <0.9.0;\n\n/// @title ISharePriceThrottledAssetManagerLib Interface\n/// @author Enzyme Council <security@enzyme.finance>\ninterface ISharePriceThrottledAssetManagerLib {\n    struct Throttle {\n        // `cumulativeLoss`: the cumulative loss to the fund's share price, as a percentage,\n        // after previous losses were replenished according to `lossTolerancePeriodDuration`\n        uint64 cumulativeLoss;\n        // `lastLossTimestamp`: the timestamp of the last loss to the fund's share price,\n        // and thus also the last time `cumulativeLoss` was updated\n        uint64 lastLossTimestamp;\n    }\n\n    function init(\n        address _owner,\n        address _vaultProxyAddress,\n        uint64 _lossTolerance,\n        uint32 _lossTolerancePeriodDuration,\n        address _shutdowner\n    ) external;\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "@openzeppelin/contracts/=lib/openzeppelin-solc-0.6/contracts/",
        "@uniswap/v3-core/=lib/uniswap-v3-core/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "forge-std/=lib/forge-std/src/",
        "openzeppelin-solc-0.6/=lib/openzeppelin-solc-0.6/contracts/",
        "openzeppelin-solc-0.7/=lib/openzeppelin-solc-0.7/contracts/",
        "openzeppelin-solc-0.8/=lib/openzeppelin-solc-0.8/contracts/",
        "uniswap-v3-core/=lib/uniswap-v3-core/",
        "uniswap-v3-core-0.8/=lib/uniswap-v3-core-0.8/",
        "uniswap-v3-periphery/=lib/uniswap-v3-periphery/contracts/",
        "uniswap-v3-periphery-0.8/=lib/uniswap-v3-periphery-0.8/contracts/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 200,
        "details": {
          "yul": false
        }
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "none",
        "appendCBOR": false
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "paris",
      "viaIR": false,
      "libraries": {}
    }
  }}