ETH Price: $3,549.24 (-0.48%)

Contract

0xa7995f71aa11525DB02Fc2473c37Dee5dbf55107
 

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Multicall205023972024-08-11 2:29:47114 days ago1723343387IN
Morpho: ETH Bundler
0.012 ETH0.000166411.29350033
Multicall204970222024-08-10 8:29:23115 days ago1723278563IN
Morpho: ETH Bundler
0.011 ETH0.00028242.1946471
Multicall203211812024-07-16 19:31:59139 days ago1721158319IN
Morpho: ETH Bundler
0 ETH0.0020184417.07261538
Multicall203211722024-07-16 19:30:11139 days ago1721158211IN
Morpho: ETH Bundler
1 ETH0.0017143913.30924603
Multicall199971932024-06-01 13:13:47185 days ago1717247627IN
Morpho: ETH Bundler
0 ETH0.001096499.44683808
Multicall199971762024-06-01 13:10:11185 days ago1717247411IN
Morpho: ETH Bundler
0.5 ETH0.001212749.42630251
Multicall199962022024-06-01 9:54:11185 days ago1717235651IN
Morpho: ETH Bundler
0.01 ETH0.000799076.2127604
Multicall198709822024-05-14 21:44:35202 days ago1715723075IN
Morpho: ETH Bundler
0 ETH0.003719965.76938799
Multicall198305022024-05-09 5:49:35208 days ago1715233775IN
Morpho: ETH Bundler
0.01002054 ETH0.000557264.0681869
Multicall196468822024-04-13 13:14:47234 days ago1713014087IN
Morpho: ETH Bundler
0 ETH0.0012739910.77472833
Multicall196304352024-04-11 5:55:59236 days ago1712814959IN
Morpho: ETH Bundler
0.01 ETH0.0015029111.66861406
Multicall196183282024-04-09 13:17:23238 days ago1712668643IN
Morpho: ETH Bundler
0 ETH0.0091026533.01975393
Multicall196183202024-04-09 13:15:47238 days ago1712668547IN
Morpho: ETH Bundler
0 ETH0.0048050138.17779687
Multicall196182902024-04-09 13:09:47238 days ago1712668187IN
Morpho: ETH Bundler
0 ETH0.0045560441.5133549
Multicall196182222024-04-09 12:56:11238 days ago1712667371IN
Morpho: ETH Bundler
0 ETH0.0036656829.12533832
Multicall196145812024-04-09 0:41:23238 days ago1712623283IN
Morpho: ETH Bundler
0 ETH0.003916820.45
Multicall196118302024-04-08 15:25:59239 days ago1712589959IN
Morpho: ETH Bundler
0 ETH0.0066952530.80729911
Multicall196118232024-04-08 15:24:23239 days ago1712589863IN
Morpho: ETH Bundler
0 ETH0.0057793929.54760314
Multicall196118172024-04-08 15:23:11239 days ago1712589791IN
Morpho: ETH Bundler
0 ETH0.0057372229.3320017
Multicall196118102024-04-08 15:21:47239 days ago1712589707IN
Morpho: ETH Bundler
0 ETH0.002876427.1338258
Multicall196118032024-04-08 15:20:23239 days ago1712589623IN
Morpho: ETH Bundler
0 ETH0.0015737125.68107067
Multicall196118032024-04-08 15:20:23239 days ago1712589623IN
Morpho: ETH Bundler
0 ETH0.0028181625.68107067
Multicall196118012024-04-08 15:19:59239 days ago1712589599IN
Morpho: ETH Bundler
0 ETH0.0054481227.20146508
Multicall196117892024-04-08 15:17:35239 days ago1712589455IN
Morpho: ETH Bundler
0 ETH0.0058786529.34923351
Multicall196117842024-04-08 15:16:35239 days ago1712589395IN
Morpho: ETH Bundler
0 ETH0.0082850729.29968157
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
212921932024-11-29 8:35:234 days ago1732869323
Morpho: ETH Bundler
0.10071925 ETH
212921932024-11-29 8:35:234 days ago1732869323
Morpho: ETH Bundler
0.10071925 ETH
205093792024-08-12 1:53:23113 days ago1723427603
Morpho: ETH Bundler
0.1 ETH
205093792024-08-12 1:53:23113 days ago1723427603
Morpho: ETH Bundler
0.1 ETH
205023972024-08-11 2:29:47114 days ago1723343387
Morpho: ETH Bundler
0.012 ETH
204970222024-08-10 8:29:23115 days ago1723278563
Morpho: ETH Bundler
0.011 ETH
203211812024-07-16 19:31:59139 days ago1721158319
Morpho: ETH Bundler
1.00000009 ETH
203211812024-07-16 19:31:59139 days ago1721158319
Morpho: ETH Bundler
1.00000009 ETH
203211722024-07-16 19:30:11139 days ago1721158211
Morpho: ETH Bundler
1 ETH
199971932024-06-01 13:13:47185 days ago1717247627
Morpho: ETH Bundler
0.50000168 ETH
199971932024-06-01 13:13:47185 days ago1717247627
Morpho: ETH Bundler
0.50000168 ETH
199971762024-06-01 13:10:11185 days ago1717247411
Morpho: ETH Bundler
0.5 ETH
199962022024-06-01 9:54:11185 days ago1717235651
Morpho: ETH Bundler
0.01 ETH
198305022024-05-09 5:49:35208 days ago1715233775
Morpho: ETH Bundler
0.000001 ETH
198305022024-05-09 5:49:35208 days ago1715233775
Morpho: ETH Bundler
0.000001 ETH
198305022024-05-09 5:49:35208 days ago1715233775
Morpho: ETH Bundler
0.01002054 ETH
196468822024-04-13 13:14:47234 days ago1713014087
Morpho: ETH Bundler
0.04013974 ETH
196468822024-04-13 13:14:47234 days ago1713014087
Morpho: ETH Bundler
0.04013974 ETH
196304352024-04-11 5:55:59236 days ago1712814959
Morpho: ETH Bundler
0.01 ETH
196115122024-04-08 14:21:23239 days ago1712586083
Morpho: ETH Bundler
50 ETH
196115122024-04-08 14:21:23239 days ago1712586083
Morpho: ETH Bundler
50 ETH
196112142024-04-08 13:21:23239 days ago1712582483
Morpho: ETH Bundler
250 ETH
196110782024-04-08 12:53:59239 days ago1712580839
Morpho: ETH Bundler
10.01621831 ETH
196110782024-04-08 12:53:59239 days ago1712580839
Morpho: ETH Bundler
10.01621831 ETH
196105542024-04-08 11:08:11239 days ago1712574491
Morpho: ETH Bundler
0.4 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
EthereumBundler

Compiler Version
v0.8.21+commit.d9974bed

Optimization Enabled:
Yes with 80000 runs

Other Settings:
paris EvmVersion
File 1 of 43 : EthereumBundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {MainnetLib} from "./libraries/MainnetLib.sol";

import {BaseBundler} from "../BaseBundler.sol";
import {TransferBundler} from "../TransferBundler.sol";
import {EthereumPermitBundler} from "./EthereumPermitBundler.sol";
import {Permit2Bundler} from "../Permit2Bundler.sol";
import {ERC4626Bundler} from "../ERC4626Bundler.sol";
import {WNativeBundler} from "../WNativeBundler.sol";
import {EthereumStEthBundler} from "./EthereumStEthBundler.sol";
import {UrdBundler} from "../UrdBundler.sol";
import {MorphoBundler} from "../MorphoBundler.sol";
import {ERC20WrapperBundler} from "../ERC20WrapperBundler.sol";

/// @title EthereumBundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Bundler contract specific to Ethereum.
contract EthereumBundler is
    TransferBundler,
    EthereumPermitBundler,
    Permit2Bundler,
    ERC4626Bundler,
    WNativeBundler,
    EthereumStEthBundler,
    UrdBundler,
    MorphoBundler,
    ERC20WrapperBundler
{
    /* CONSTRUCTOR */

    constructor(address morpho) WNativeBundler(MainnetLib.WETH) MorphoBundler(morpho) {}

    /* INTERNAL */

    /// @inheritdoc MorphoBundler
    function _isSenderAuthorized() internal view override(BaseBundler, MorphoBundler) returns (bool) {
        return MorphoBundler._isSenderAuthorized();
    }
}

File 2 of 43 : MainnetLib.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

library MainnetLib {
    /// @dev The address of the WETH contract on Ethereum.
    address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

    /// @dev The address of the wstETH contract on Ethereum.
    address internal constant WST_ETH = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0;

    /// @dev The address of DAI on Ethereum mainnet.
    address internal constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
}

File 3 of 43 : BaseBundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

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

import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {UNSET_INITIATOR} from "./libraries/ConstantsLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

/// @title BaseBundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Enables calling multiple functions in a single call to the same contract (self).
/// @dev Every bundler must inherit from this contract.
/// @dev Every bundler inheriting from this contract must have their external functions payable as they will be
/// delegate called by the `multicall` function (which is payable, and thus might pass a non-null ETH value). It is
/// recommended not to rely on `msg.value` as the same value can be reused for multiple calls.
abstract contract BaseBundler is IMulticall {
    using SafeTransferLib for ERC20;

    /* STORAGE */

    /// @notice Keeps track of the bundler's latest bundle initiator.
    /// @dev Also prevents interacting with the bundler outside of an initiated execution context.
    address private _initiator = UNSET_INITIATOR;

    /* MODIFIERS */

    /// @dev Prevents a function to be called outside an initiated `multicall` context and protects a function from
    /// being called by an unauthorized sender inside an initiated multicall context.
    modifier protected() {
        require(_initiator != UNSET_INITIATOR, ErrorsLib.UNINITIATED);
        require(_isSenderAuthorized(), ErrorsLib.UNAUTHORIZED_SENDER);

        _;
    }

    /* PUBLIC */

    /// @notice Returns the address of the initiator of the multicall transaction.
    /// @dev Specialized getter to prevent using `_initiator` directly.
    function initiator() public view returns (address) {
        return _initiator;
    }

    /* EXTERNAL */

    /// @notice Executes a series of delegate calls to the contract itself.
    /// @dev Locks the initiator so that the sender can uniquely be identified in callbacks.
    /// @dev All functions delegatecalled must be `payable` if `msg.value` is non-zero.
    function multicall(bytes[] memory data) external payable {
        require(_initiator == UNSET_INITIATOR, ErrorsLib.ALREADY_INITIATED);

        _initiator = msg.sender;

        _multicall(data);

        _initiator = UNSET_INITIATOR;
    }

    /* INTERNAL */

    /// @dev Executes a series of delegate calls to the contract itself.
    /// @dev All functions delegatecalled must be `payable` if `msg.value` is non-zero.
    function _multicall(bytes[] memory data) internal {
        for (uint256 i; i < data.length; ++i) {
            (bool success, bytes memory returnData) = address(this).delegatecall(data[i]);

            // No need to check that `address(this)` has code in case of success.
            if (!success) _revert(returnData);
        }
    }

    /// @dev Bubbles up the revert reason / custom error encoded in `returnData`.
    /// @dev Assumes `returnData` is the return data of any kind of failing CALL to a contract.
    function _revert(bytes memory returnData) internal pure {
        uint256 length = returnData.length;
        require(length > 0, ErrorsLib.CALL_FAILED);

        assembly ("memory-safe") {
            revert(add(32, returnData), length)
        }
    }

    /// @dev Returns whether the sender of the call is authorized.
    /// @dev Assumes to be inside a properly initiated `multicall` context.
    function _isSenderAuthorized() internal view virtual returns (bool) {
        return msg.sender == _initiator;
    }

    /// @dev Gives the max approval to `spender` to spend the given `asset` if not already approved.
    /// @dev Assumes that `type(uint256).max` is large enough to never have to increase the allowance again.
    function _approveMaxTo(address asset, address spender) internal {
        if (ERC20(asset).allowance(address(this), spender) == 0) {
            ERC20(asset).safeApprove(spender, type(uint256).max);
        }
    }
}

File 4 of 43 : TransferBundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

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

/// @title TransferBundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Enables transfer of ERC20 and native tokens.
/// @dev Assumes that any tokens left on the contract can be seized by anyone.
abstract contract TransferBundler is BaseBundler {
    using SafeTransferLib for ERC20;

    /* TRANSFER ACTIONS */

    /// @notice Transfers the minimum between the given `amount` and the bundler's balance of native asset from the
    /// bundler to `recipient`.
    /// @dev If the minimum happens to be zero, the transfer is silently skipped.
    /// @param recipient The address that will receive the native tokens.
    /// @param amount The amount of native tokens to transfer. Capped at the bundler's balance.
    function nativeTransfer(address recipient, uint256 amount) external payable protected {
        require(recipient != address(0), ErrorsLib.ZERO_ADDRESS);
        require(recipient != address(this), ErrorsLib.BUNDLER_ADDRESS);

        amount = Math.min(amount, address(this).balance);

        if (amount == 0) return;

        SafeTransferLib.safeTransferETH(recipient, amount);
    }

    /// @notice Transfers the minimum between the given `amount` and the bundler's balance of `asset` from the bundler
    /// to `recipient`.
    /// @dev If the minimum happens to be zero, the transfer is silently skipped.
    /// @param asset The address of the ERC20 token to transfer.
    /// @param recipient The address that will receive the tokens.
    /// @param amount The amount of `asset` to transfer. Capped at the bundler's balance.
    function erc20Transfer(address asset, address recipient, uint256 amount) external payable protected {
        require(recipient != address(0), ErrorsLib.ZERO_ADDRESS);
        require(recipient != address(this), ErrorsLib.BUNDLER_ADDRESS);

        amount = Math.min(amount, ERC20(asset).balanceOf(address(this)));

        if (amount == 0) return;

        ERC20(asset).safeTransfer(recipient, amount);
    }

    /// @notice Transfers the given `amount` of `asset` from sender to this contract via ERC20 transferFrom.
    /// @notice User must have given sufficient allowance to the Bundler to spend their tokens.
    /// @param asset The address of the ERC20 token to transfer.
    /// @param amount The amount of `asset` to transfer from the initiator. Capped at the initiator's balance.
    function erc20TransferFrom(address asset, uint256 amount) external payable protected {
        address _initiator = initiator();
        amount = Math.min(amount, ERC20(asset).balanceOf(_initiator));

        require(amount != 0, ErrorsLib.ZERO_AMOUNT);

        ERC20(asset).safeTransferFrom(_initiator, address(this), amount);
    }
}

File 5 of 43 : EthereumPermitBundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

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

import {MainnetLib} from "./libraries/MainnetLib.sol";

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

/// @title EthereumPermitBundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice PermitBundler contract specific to Ethereum, handling permit to DAI.
abstract contract EthereumPermitBundler is PermitBundler {
    /// @notice Permits DAI from sender to be spent by the bundler with the given `nonce`, `expiry` & EIP-712
    /// signature's `v`, `r` & `s`.
    /// @param nonce The nonce of the signed message.
    /// @param expiry The expiry of the signed message.
    /// @param allowed Whether the initiator gives the bundler infinite Dai approval or not.
    /// @param v The `v` component of a signature.
    /// @param r The `r` component of a signature.
    /// @param s The `s` component of a signature.
    /// @param skipRevert Whether to avoid reverting the call in case the signature is frontrunned.
    function permitDai(uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s, bool skipRevert)
        external
        payable
        protected
    {
        try IDaiPermit(MainnetLib.DAI).permit(initiator(), address(this), nonce, expiry, allowed, v, r, s) {}
        catch (bytes memory returnData) {
            if (!skipRevert) _revert(returnData);
        }
    }
}

File 6 of 43 : Permit2Bundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {IAllowanceTransfer} from "../lib/permit2/src/interfaces/IAllowanceTransfer.sol";

import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {Permit2Lib} from "../lib/permit2/src/libraries/Permit2Lib.sol";
import {SafeCast160} from "../lib/permit2/src/libraries/SafeCast160.sol";
import {ERC20} from "../lib/solmate/src/tokens/ERC20.sol";

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

/// @title Permit2Bundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Bundler contract managing interactions with Uniswap's Permit2.
abstract contract Permit2Bundler is BaseBundler {
    using SafeCast160 for uint256;

    /* ACTIONS */

    /// @notice Approves the given `amount` of `asset` from the initiator to be spent by `permitSingle.spender` via
    /// Permit2 with the given `deadline` & EIP-712 `signature`.
    /// @param permitSingle The `PermitSingle` struct.
    /// @param signature The signature, serialized.
    /// @param skipRevert Whether to avoid reverting the call in case the signature is frontrunned.
    function approve2(IAllowanceTransfer.PermitSingle calldata permitSingle, bytes calldata signature, bool skipRevert)
        external
        payable
        protected
    {
        try Permit2Lib.PERMIT2.permit(initiator(), permitSingle, signature) {}
        catch (bytes memory returnData) {
            if (!skipRevert) _revert(returnData);
        }
    }

    /// @notice Transfers the given `amount` of `asset` from the initiator to the bundler via Permit2.
    /// @param asset The address of the ERC20 token to transfer.
    /// @param amount The amount of `asset` to transfer from the initiator. Capped at the initiator's balance.
    function transferFrom2(address asset, uint256 amount) external payable protected {
        address _initiator = initiator();
        amount = Math.min(amount, ERC20(asset).balanceOf(_initiator));

        require(amount != 0, ErrorsLib.ZERO_AMOUNT);

        Permit2Lib.PERMIT2.transferFrom(_initiator, address(this), amount.toUint160(), asset);
    }
}

File 7 of 43 : ERC4626Bundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {IERC4626} from "../lib/openzeppelin-contracts/contracts/interfaces/IERC4626.sol";

import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

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

/// @title ERC4626Bundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Bundler contract managing interactions with ERC4626 compliant tokens.
abstract contract ERC4626Bundler is BaseBundler {
    using SafeTransferLib for ERC20;

    /* ACTIONS */

    /// @notice Mints the given amount of `shares` on the given ERC4626 `vault`, on behalf of `receiver`.
    /// @dev Initiator must have previously transferred their assets to the bundler.
    /// @dev Assumes the given `vault` implements EIP-4626.
    /// @param vault The address of the vault.
    /// @param shares The amount of shares to mint.
    /// @param maxAssets The maximum amount of assets to deposit in exchange for `shares`.
    /// @param receiver The address to which shares will be minted.
    function erc4626Mint(address vault, uint256 shares, uint256 maxAssets, address receiver)
        external
        payable
        protected
    {
        /// Do not check `receiver != address(this)` to allow the bundler to receive the vault's shares.
        require(receiver != address(0), ErrorsLib.ZERO_ADDRESS);
        require(shares != 0, ErrorsLib.ZERO_SHARES);

        _approveMaxTo(IERC4626(vault).asset(), vault);

        uint256 assets = IERC4626(vault).mint(shares, receiver);
        require(assets <= maxAssets, ErrorsLib.SLIPPAGE_EXCEEDED);
    }

    /// @notice Deposits the given amount of `assets` on the given ERC4626 `vault`, on behalf of `receiver`.
    /// @dev Initiator must have previously transferred their assets to the bundler.
    /// @dev Assumes the given `vault` implements EIP-4626.
    /// @param vault The address of the vault.
    /// @param assets The amount of assets to deposit. Capped at the bundler's assets.
    /// @param minShares The minimum amount of shares to mint in exchange for `assets`. This parameter is proportionally
    /// scaled down in case there are fewer assets than `assets` on the bundler.
    /// @param receiver The address to which shares will be minted.
    function erc4626Deposit(address vault, uint256 assets, uint256 minShares, address receiver)
        external
        payable
        protected
    {
        /// Do not check `receiver != address(this)` to allow the bundler to receive the vault's shares.
        require(receiver != address(0), ErrorsLib.ZERO_ADDRESS);

        uint256 initialAssets = assets;
        address asset = IERC4626(vault).asset();
        assets = Math.min(assets, ERC20(asset).balanceOf(address(this)));

        require(assets != 0, ErrorsLib.ZERO_AMOUNT);

        _approveMaxTo(asset, vault);

        uint256 shares = IERC4626(vault).deposit(assets, receiver);
        require(shares * initialAssets >= minShares * assets, ErrorsLib.SLIPPAGE_EXCEEDED);
    }

    /// @notice Withdraws the given amount of `assets` from the given ERC4626 `vault`, transferring assets to
    /// `receiver`.
    /// @dev Assumes the given `vault` implements EIP-4626.
    /// @param vault The address of the vault.
    /// @param assets The amount of assets to withdraw.
    /// @param maxShares The maximum amount of shares to redeem in exchange for `assets`.
    /// @param receiver The address that will receive the withdrawn assets.
    /// @param owner The address on behalf of which the assets are withdrawn. Can only be the bundler or the initiator.
    /// If `owner` is the initiator, they must have previously approved the bundler to spend their vault shares.
    /// Otherwise, they must have previously transferred their vault shares to the bundler.
    function erc4626Withdraw(address vault, uint256 assets, uint256 maxShares, address receiver, address owner)
        external
        payable
        protected
    {
        /// Do not check `receiver != address(this)` to allow the bundler to receive the underlying asset.
        require(receiver != address(0), ErrorsLib.ZERO_ADDRESS);
        require(owner == address(this) || owner == initiator(), ErrorsLib.UNEXPECTED_OWNER);
        require(assets != 0, ErrorsLib.ZERO_AMOUNT);

        uint256 shares = IERC4626(vault).withdraw(assets, receiver, owner);
        require(shares <= maxShares, ErrorsLib.SLIPPAGE_EXCEEDED);
    }

    /// @notice Redeems the given amount of `shares` from the given ERC4626 `vault`, transferring assets to `receiver`.
    /// @dev Assumes the given `vault` implements EIP-4626.
    /// @param vault The address of the vault.
    /// @param shares The amount of shares to redeem. Capped at the owner's shares.
    /// @param minAssets The minimum amount of assets to withdraw in exchange for `shares`. This parameter is
    /// proportionally scaled down in case the owner holds fewer shares than `shares`.
    /// @param receiver The address that will receive the withdrawn assets.
    /// @param owner The address on behalf of which the shares are redeemed. Can only be the bundler or the initiator.
    /// If `owner` is the initiator, they must have previously approved the bundler to spend their vault shares.
    /// Otherwise, they must have previously transferred their vault shares to the bundler.
    function erc4626Redeem(address vault, uint256 shares, uint256 minAssets, address receiver, address owner)
        external
        payable
        protected
    {
        /// Do not check `receiver != address(this)` to allow the bundler to receive the underlying asset.
        require(receiver != address(0), ErrorsLib.ZERO_ADDRESS);
        require(owner == address(this) || owner == initiator(), ErrorsLib.UNEXPECTED_OWNER);

        uint256 initialShares = shares;
        shares = Math.min(shares, IERC4626(vault).balanceOf(owner));

        require(shares != 0, ErrorsLib.ZERO_SHARES);

        uint256 assets = IERC4626(vault).redeem(shares, receiver, owner);
        require(assets * initialShares >= minAssets * shares, ErrorsLib.SLIPPAGE_EXCEEDED);
    }
}

File 8 of 43 : WNativeBundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

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

import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

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

/// @title WNativeBundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Bundler contract managing interactions with network's wrapped native token.
/// @notice "wrapped native" refers to forks of WETH.
abstract contract WNativeBundler is BaseBundler {
    using SafeTransferLib for ERC20;

    /* IMMUTABLES */

    /// @dev The address of the wrapped native token contract.
    address public immutable WRAPPED_NATIVE;

    /* CONSTRUCTOR */

    /// @dev Warning: assumes the given addresses are non-zero (they are not expected to be deployment arguments).
    /// @param wNative The address of the wNative token contract.
    constructor(address wNative) {
        require(wNative != address(0), ErrorsLib.ZERO_ADDRESS);

        WRAPPED_NATIVE = wNative;
    }

    /* FALLBACKS */

    /// @notice Native tokens are received by the bundler and should be used afterwards.
    /// @dev Allows the wrapped native contract to send native tokens to the bundler.
    receive() external payable {}

    /* ACTIONS */

    /// @notice Wraps the given `amount` of the native token to wNative.
    /// @notice Wrapped native tokens are received by the bundler and should be used afterwards.
    /// @dev Initiator must have previously transferred their native tokens to the bundler.
    /// @param amount The amount of native token to wrap. Capped at the bundler's native token balance.
    function wrapNative(uint256 amount) external payable protected {
        amount = Math.min(amount, address(this).balance);

        require(amount != 0, ErrorsLib.ZERO_AMOUNT);

        IWNative(WRAPPED_NATIVE).deposit{value: amount}();
    }

    /// @notice Unwraps the given `amount` of wNative to the native token.
    /// @notice Unwrapped native tokens are received by the bundler and should be used afterwards.
    /// @dev Initiator must have previously transferred their wrapped native tokens to the bundler.
    /// @param amount The amount of wrapped native token to unwrap. Capped at the bundler's wNative balance.
    function unwrapNative(uint256 amount) external payable protected {
        amount = Math.min(amount, ERC20(WRAPPED_NATIVE).balanceOf(address(this)));

        require(amount != 0, ErrorsLib.ZERO_AMOUNT);

        IWNative(WRAPPED_NATIVE).withdraw(amount);
    }
}

File 9 of 43 : EthereumStEthBundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {MainnetLib} from "./libraries/MainnetLib.sol";

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

/// @title EthereumStEthBundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice StEthBundler contract specific to Ethereum.
abstract contract EthereumStEthBundler is StEthBundler {
    /* CONSTRUCTOR */

    constructor() StEthBundler(MainnetLib.WST_ETH) {}
}

File 10 of 43 : UrdBundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {IUniversalRewardsDistributor} from
    "../lib/universal-rewards-distributor/src/interfaces/IUniversalRewardsDistributor.sol";

import {ErrorsLib} from "./libraries/ErrorsLib.sol";

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

/// @title UrdBundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Bundler that allows to claim token rewards on the Universal Rewards Distributor.
abstract contract UrdBundler is BaseBundler {
    /// @notice Claims `amount` of `reward` on behalf of `account` on the given rewards distributor, using `proof`.
    /// @dev Assumes the given distributor implements IUniversalRewardsDistributor.
    /// @param distributor The address of the reward distributor contract.
    /// @param account The address of the owner of the rewards (also the address that will receive the rewards).
    /// @param reward The address of the token reward.
    /// @param amount The amount of the reward token to claim.
    /// @param proof The proof.
    /// @param skipRevert Whether to avoid reverting the call in case the proof is frontrunned.
    function urdClaim(
        address distributor,
        address account,
        address reward,
        uint256 amount,
        bytes32[] calldata proof,
        bool skipRevert
    ) external payable protected {
        require(account != address(0), ErrorsLib.ZERO_ADDRESS);
        require(account != address(this), ErrorsLib.BUNDLER_ADDRESS);

        try IUniversalRewardsDistributor(distributor).claim(account, reward, amount, proof) {}
        catch (bytes memory returnData) {
            if (!skipRevert) _revert(returnData);
        }
    }
}

File 11 of 43 : MorphoBundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {IMorphoBundler} from "./interfaces/IMorphoBundler.sol";
import {MarketParams, Signature, Authorization, IMorpho} from "../lib/morpho-blue/src/interfaces/IMorpho.sol";

import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

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

/// @title MorphoBundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Bundler contract managing interactions with Morpho.
abstract contract MorphoBundler is BaseBundler, IMorphoBundler {
    using SafeTransferLib for ERC20;

    /* IMMUTABLES */

    /// @notice The Morpho contract address.
    IMorpho public immutable MORPHO;

    /* CONSTRUCTOR */

    constructor(address morpho) {
        require(morpho != address(0), ErrorsLib.ZERO_ADDRESS);

        MORPHO = IMorpho(morpho);
    }

    /* CALLBACKS */

    function onMorphoSupply(uint256, bytes calldata data) external {
        // Don't need to approve Morpho to pull tokens because it should already be approved max.
        _callback(data);
    }

    function onMorphoSupplyCollateral(uint256, bytes calldata data) external {
        // Don't need to approve Morpho to pull tokens because it should already be approved max.
        _callback(data);
    }

    function onMorphoRepay(uint256, bytes calldata data) external {
        // Don't need to approve Morpho to pull tokens because it should already be approved max.
        _callback(data);
    }

    function onMorphoFlashLoan(uint256, bytes calldata data) external {
        // Don't need to approve Morpho to pull tokens because it should already be approved max.
        _callback(data);
    }

    /* ACTIONS */

    /// @notice Approves `authorization.authorized` to manage `authorization.authorizer`'s position via EIP712
    /// `signature`.
    /// @param authorization The `Authorization` struct.
    /// @param signature The signature.
    /// @param skipRevert Whether to avoid reverting the call in case the signature is frontrunned.
    function morphoSetAuthorizationWithSig(
        Authorization calldata authorization,
        Signature calldata signature,
        bool skipRevert
    ) external payable protected {
        try MORPHO.setAuthorizationWithSig(authorization, signature) {}
        catch (bytes memory returnData) {
            if (!skipRevert) _revert(returnData);
        }
    }

    /// @notice Supplies `assets` of the loan asset on behalf of `onBehalf`.
    /// @notice The supplied assets cannot be used as collateral but is eligible to earn interest.
    /// @dev Either `assets` or `shares` should be zero. Most usecases should rely on `assets` as an input so the
    /// bundler is guaranteed to have `assets` tokens pulled from its balance, but the possibility to mint a specific
    /// amount of shares is given for full compatibility and precision.
    /// @dev Initiator must have previously transferred their assets to the bundler.
    /// @param marketParams The Morpho market to supply assets to.
    /// @param assets The amount of assets to supply. Pass `type(uint256).max` to supply the bundler's loan asset
    /// balance.
    /// @param shares The amount of shares to mint.
    /// @param slippageAmount The minimum amount of supply shares to mint in exchange for `assets` when it is used.
    /// The maximum amount of assets to deposit in exchange for `shares` otherwise.
    /// @param onBehalf The address that will own the increased supply position.
    /// @param data Arbitrary data to pass to the `onMorphoSupply` callback. Pass empty data if not needed.
    function morphoSupply(
        MarketParams calldata marketParams,
        uint256 assets,
        uint256 shares,
        uint256 slippageAmount,
        address onBehalf,
        bytes calldata data
    ) external payable protected {
        // Do not check `onBehalf` against the zero address as it's done at Morpho's level.
        require(onBehalf != address(this), ErrorsLib.BUNDLER_ADDRESS);

        // Don't always cap the assets to the bundler's balance because the liquidity can be transferred later
        // (via the `onMorphoSupply` callback).
        if (assets == type(uint256).max) assets = ERC20(marketParams.loanToken).balanceOf(address(this));

        _approveMaxTo(marketParams.loanToken, address(MORPHO));

        (uint256 suppliedAssets, uint256 suppliedShares) = MORPHO.supply(marketParams, assets, shares, onBehalf, data);

        if (assets > 0) require(suppliedShares >= slippageAmount, ErrorsLib.SLIPPAGE_EXCEEDED);
        else require(suppliedAssets <= slippageAmount, ErrorsLib.SLIPPAGE_EXCEEDED);
    }

    /// @notice Supplies `assets` of collateral on behalf of `onBehalf`.
    /// @dev Initiator must have previously transferred their assets to the bundler.
    /// @param marketParams The Morpho market to supply collateral to.
    /// @param assets The amount of collateral to supply. Pass `type(uint256).max` to supply the bundler's loan asset
    /// balance.
    /// @param onBehalf The address that will own the increased collateral position.
    /// @param data Arbitrary data to pass to the `onMorphoSupplyCollateral` callback. Pass empty data if not needed.
    function morphoSupplyCollateral(
        MarketParams calldata marketParams,
        uint256 assets,
        address onBehalf,
        bytes calldata data
    ) external payable protected {
        // Do not check `onBehalf` against the zero address as it's done at Morpho's level.
        require(onBehalf != address(this), ErrorsLib.BUNDLER_ADDRESS);

        // Don't always cap the assets to the bundler's balance because the liquidity can be transferred later
        // (via the `onMorphoSupplyCollateral` callback).
        if (assets == type(uint256).max) assets = ERC20(marketParams.collateralToken).balanceOf(address(this));

        _approveMaxTo(marketParams.collateralToken, address(MORPHO));

        MORPHO.supplyCollateral(marketParams, assets, onBehalf, data);
    }

    /// @notice Borrows `assets` of the loan asset on behalf of the initiator.
    /// @dev Either `assets` or `shares` should be zero. Most usecases should rely on `assets` as an input so the
    /// initiator is guaranteed to borrow `assets` tokens, but the possibility to mint a specific amount of shares is
    /// given for full compatibility and precision.
    /// @dev Initiator must have previously authorized the bundler to act on their behalf on Morpho.
    /// @param marketParams The Morpho market to borrow assets from.
    /// @param assets The amount of assets to borrow.
    /// @param shares The amount of shares to mint.
    /// @param slippageAmount The maximum amount of borrow shares to mint in exchange for `assets` when it is used.
    /// The minimum amount of assets to borrow in exchange for `shares` otherwise.
    /// @param receiver The address that will receive the borrowed assets.
    function morphoBorrow(
        MarketParams calldata marketParams,
        uint256 assets,
        uint256 shares,
        uint256 slippageAmount,
        address receiver
    ) external payable protected {
        (uint256 borrowedAssets, uint256 borrowedShares) =
            MORPHO.borrow(marketParams, assets, shares, initiator(), receiver);

        if (assets > 0) require(borrowedShares <= slippageAmount, ErrorsLib.SLIPPAGE_EXCEEDED);
        else require(borrowedAssets >= slippageAmount, ErrorsLib.SLIPPAGE_EXCEEDED);
    }

    /// @notice Repays `assets` of the loan asset on behalf of `onBehalf`.
    /// @dev Either `assets` or `shares` should be zero. Most usecases should rely on `assets` as an input so the
    /// bundler is guaranteed to have `assets` tokens pulled from its balance, but the possibility to burn a specific
    /// amount of shares is given for full compatibility and precision.
    /// @param marketParams The Morpho market to repay assets to.
    /// @param assets The amount of assets to repay. Pass `type(uint256).max` to repay the bundler's loan asset balance.
    /// @param shares The amount of shares to burn.
    /// @param slippageAmount The minimum amount of borrow shares to burn in exchange for `assets` when it is used.
    /// The maximum amount of assets to deposit in exchange for `shares` otherwise.
    /// @param onBehalf The address of the owner of the debt position.
    /// @param data Arbitrary data to pass to the `onMorphoRepay` callback. Pass empty data if not needed.
    function morphoRepay(
        MarketParams calldata marketParams,
        uint256 assets,
        uint256 shares,
        uint256 slippageAmount,
        address onBehalf,
        bytes calldata data
    ) external payable protected {
        // Do not check `onBehalf` against the zero address as it's done at Morpho's level.
        require(onBehalf != address(this), ErrorsLib.BUNDLER_ADDRESS);

        // Don't always cap the assets to the bundler's balance because the liquidity can be transferred later
        // (via the `onMorphoRepay` callback).
        if (assets == type(uint256).max) assets = ERC20(marketParams.loanToken).balanceOf(address(this));

        _approveMaxTo(marketParams.loanToken, address(MORPHO));

        (uint256 repaidAssets, uint256 repaidShares) = MORPHO.repay(marketParams, assets, shares, onBehalf, data);

        if (assets > 0) require(repaidShares >= slippageAmount, ErrorsLib.SLIPPAGE_EXCEEDED);
        else require(repaidAssets <= slippageAmount, ErrorsLib.SLIPPAGE_EXCEEDED);
    }

    /// @notice Withdraws `assets` of the loan asset on behalf of the initiator.
    /// @dev Either `assets` or `shares` should be zero. Most usecases should rely on `assets` as an input so the
    /// initiator is guaranteed to withdraw `assets` tokens, but the possibility to burn a specific amount of shares is
    /// given for full compatibility and precision.
    /// @dev Initiator must have previously authorized the bundler to act on their behalf on Morpho.
    /// @param marketParams The Morpho market to withdraw assets from.
    /// @param assets The amount of assets to withdraw.
    /// @param shares The amount of shares to burn.
    /// @param slippageAmount The maximum amount of supply shares to burn in exchange for `assets` when it is used.
    /// The minimum amount of assets to withdraw in exchange for `shares` otherwise.
    /// @param receiver The address that will receive the withdrawn assets.
    function morphoWithdraw(
        MarketParams calldata marketParams,
        uint256 assets,
        uint256 shares,
        uint256 slippageAmount,
        address receiver
    ) external payable protected {
        (uint256 withdrawnAssets, uint256 withdrawnShares) =
            MORPHO.withdraw(marketParams, assets, shares, initiator(), receiver);

        if (assets > 0) require(withdrawnShares <= slippageAmount, ErrorsLib.SLIPPAGE_EXCEEDED);
        else require(withdrawnAssets >= slippageAmount, ErrorsLib.SLIPPAGE_EXCEEDED);
    }

    /// @notice Withdraws `assets` of the collateral asset on behalf of the initiator.
    /// @dev Initiator must have previously authorized the bundler to act on their behalf on Morpho.
    /// @param marketParams The Morpho market to withdraw collateral from.
    /// @param assets The amount of collateral to withdraw.
    /// @param receiver The address that will receive the collateral assets.
    function morphoWithdrawCollateral(MarketParams calldata marketParams, uint256 assets, address receiver)
        external
        payable
        protected
    {
        MORPHO.withdrawCollateral(marketParams, assets, initiator(), receiver);
    }

    /// @notice Triggers a flash loan on Morpho.
    /// @param token The address of the token to flash loan.
    /// @param assets The amount of assets to flash loan.
    /// @param data Arbitrary data to pass to the `onMorphoFlashLoan` callback.
    function morphoFlashLoan(address token, uint256 assets, bytes calldata data) external payable protected {
        _approveMaxTo(token, address(MORPHO));

        MORPHO.flashLoan(token, assets, data);
    }

    /* INTERNAL */

    /// @dev Triggers `_multicall` logic during a callback.
    function _callback(bytes calldata data) internal {
        require(msg.sender == address(MORPHO), ErrorsLib.UNAUTHORIZED_SENDER);

        _multicall(abi.decode(data, (bytes[])));
    }

    /// @inheritdoc BaseBundler
    function _isSenderAuthorized() internal view virtual override returns (bool) {
        return super._isSenderAuthorized() || msg.sender == address(MORPHO);
    }
}

File 12 of 43 : ERC20WrapperBundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

import {BaseBundler} from "./BaseBundler.sol";
import {ERC20Wrapper} from "../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/ERC20Wrapper.sol";

/// @title ERC20WrapperBundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Enables the wrapping and unwrapping of ERC20 tokens. The largest usecase is to wrap permissionless tokens to
/// their permissioned counterparts and access permissioned markets on Morpho Blue. Permissioned tokens can be built
/// using: https://github.com/morpho-org/erc20-permissioned
abstract contract ERC20WrapperBundler is BaseBundler {
    using SafeTransferLib for ERC20;

    /* WRAPPER ACTIONS */

    /// @notice Deposits underlying tokens and mints the corresponding amount of wrapped tokens to the initiator.
    /// @dev Wraps tokens on behalf of the initiator to make sure they are able to receive and transfer wrapped tokens.
    /// @dev Wrapped tokens must be transferred to the bundler afterwards to perform additional actions.
    /// @dev Initiator must have previously transferred their tokens to the bundler.
    /// @dev Assumes that `wrapper` implements the `ERC20Wrapper` interface and that the `depositFor` function returns a
    /// boolean.
    /// @param wrapper The address of the ERC20 wrapper contract.
    /// @param amount The amount of underlying tokens to deposit. Capped at the bundler's balance.
    function erc20WrapperDepositFor(address wrapper, uint256 amount) external payable protected {
        ERC20 underlying = ERC20(address(ERC20Wrapper(wrapper).underlying()));

        amount = Math.min(amount, underlying.balanceOf(address(this)));

        require(amount != 0, ErrorsLib.ZERO_AMOUNT);

        _approveMaxTo(address(underlying), wrapper);

        require(ERC20Wrapper(wrapper).depositFor(initiator(), amount), ErrorsLib.DEPOSIT_FAILED);
    }

    /// @notice Burns a number of wrapped tokens and withdraws the corresponding number of underlying tokens.
    /// @dev Initiator must have previously transferred their wrapped tokens to the bundler.
    /// @dev Assumes that `wrapper` implements the `ERC20Wrapper` interface and that the `withdrawTo` function returns a
    /// boolean.
    /// @param wrapper The address of the ERC20 wrapper contract.
    /// @param account The address receiving the underlying tokens.
    /// @param amount The amount of wrapped tokens to burn. Capped at the bundler's balance.
    function erc20WrapperWithdrawTo(address wrapper, address account, uint256 amount) external payable protected {
        require(account != address(0), ErrorsLib.ZERO_ADDRESS);

        amount = Math.min(amount, ERC20(wrapper).balanceOf(address(this)));

        require(amount != 0, ErrorsLib.ZERO_AMOUNT);

        require(ERC20Wrapper(wrapper).withdrawTo(account, amount), ErrorsLib.WITHDRAW_FAILED);
    }
}

File 13 of 43 : IMulticall.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title IMulticall
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Interface of Multicall.
interface IMulticall {
    /// @notice Executes an ordered batch of delegatecalls to this contract.
    /// @param data The ordered array of calldata to execute.
    function multicall(bytes[] calldata data) external payable;
}

File 14 of 43 : ErrorsLib.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

/// @title ErrorsLib
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Library exposing error messages.
library ErrorsLib {
    /* STANDARD BUNDLERS */

    /// @dev Thrown when a call is attempted while the bundler is not in an initiated execution context.
    string internal constant UNINITIATED = "uninitiated";

    /// @dev Thrown when a multicall is attempted while the bundler in an initiated execution context.
    string internal constant ALREADY_INITIATED = "already initiated";

    /// @dev Thrown when a call is attempted from an unauthorized sender.
    string internal constant UNAUTHORIZED_SENDER = "unauthorized sender";

    /// @dev Thrown when a call is attempted with a zero address as input.
    string internal constant ZERO_ADDRESS = "zero address";

    /// @dev Thrown when a call is attempted with the bundler address as input.
    string internal constant BUNDLER_ADDRESS = "bundler address";

    /// @dev Thrown when a call is attempted with a zero amount as input.
    string internal constant ZERO_AMOUNT = "zero amount";

    /// @dev Thrown when a call is attempted with a zero shares as input.
    string internal constant ZERO_SHARES = "zero shares";

    /// @dev Thrown when a call reverted and wasn't allowed to revert.
    string internal constant CALL_FAILED = "call failed";

    /// @dev Thrown when the given owner is unexpected.
    string internal constant UNEXPECTED_OWNER = "unexpected owner";

    /// @dev Thrown when an action ends up minting/burning more shares than a given slippage.
    string internal constant SLIPPAGE_EXCEEDED = "slippage exceeded";

    /// @dev Thrown when a call to depositFor fails.
    string internal constant DEPOSIT_FAILED = "deposit failed";

    /// @dev Thrown when a call to withdrawTo fails.
    string internal constant WITHDRAW_FAILED = "withdraw failed";

    /* MIGRATION BUNDLERS */

    /// @dev Thrown when repaying a CompoundV2 debt returns an error code.
    string internal constant REPAY_ERROR = "repay error";

    /// @dev Thrown when redeeming CompoundV2 cTokens returns an error code.
    string internal constant REDEEM_ERROR = "redeem error";
}

File 15 of 43 : ConstantsLib.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

/// @dev The default value of the initiator of the multicall transaction is not the address zero to save gas.
address constant UNSET_INITIATOR = address(1);

File 16 of 43 : SafeTransferLib.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

import {ERC20} from "../tokens/ERC20.sol";

/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)
/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.
/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.
library SafeTransferLib {
    /*//////////////////////////////////////////////////////////////
                             ETH OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function safeTransferETH(address to, uint256 amount) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Transfer the ETH and store if it succeeded or not.
            success := call(gas(), to, amount, 0, 0, 0, 0)
        }

        require(success, "ETH_TRANSFER_FAILED");
    }

    /*//////////////////////////////////////////////////////////////
                            ERC20 OPERATIONS
    //////////////////////////////////////////////////////////////*/

    function safeTransferFrom(
        ERC20 token,
        address from,
        address to,
        uint256 amount
    ) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata into memory, beginning with the function selector.
            mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
            mstore(add(freeMemoryPointer, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "from" argument.
            mstore(add(freeMemoryPointer, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
            mstore(add(freeMemoryPointer, 68), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.

            success := and(
                // Set success to whether the call reverted, if not we check it either
                // returned exactly 1 (can't just be non-zero data), or had no return data.
                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                // Counterintuitively, this call must be positioned second to the or() call in the
                // surrounding and() call or else returndatasize() will be zero during the computation.
                call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)
            )
        }

        require(success, "TRANSFER_FROM_FAILED");
    }

    function safeTransfer(
        ERC20 token,
        address to,
        uint256 amount
    ) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata into memory, beginning with the function selector.
            mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
            mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
            mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.

            success := and(
                // Set success to whether the call reverted, if not we check it either
                // returned exactly 1 (can't just be non-zero data), or had no return data.
                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                // Counterintuitively, this call must be positioned second to the or() call in the
                // surrounding and() call or else returndatasize() will be zero during the computation.
                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
            )
        }

        require(success, "TRANSFER_FAILED");
    }

    function safeApprove(
        ERC20 token,
        address to,
        uint256 amount
    ) internal {
        bool success;

        /// @solidity memory-safe-assembly
        assembly {
            // Get a pointer to some free memory.
            let freeMemoryPointer := mload(0x40)

            // Write the abi-encoded calldata into memory, beginning with the function selector.
            mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
            mstore(add(freeMemoryPointer, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
            mstore(add(freeMemoryPointer, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.

            success := and(
                // Set success to whether the call reverted, if not we check it either
                // returned exactly 1 (can't just be non-zero data), or had no return data.
                or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
                // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
                // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                // Counterintuitively, this call must be positioned second to the or() call in the
                // surrounding and() call or else returndatasize() will be zero during the computation.
                call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)
            )
        }

        require(success, "APPROVE_FAILED");
    }
}

File 17 of 43 : Math.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.0;

/// @title Math Library.
/// @author Morpho Labs.
/// @custom:contact [email protected]
/// @dev Library to perform simple math manipulations.
library Math {
    function min(uint256 x, uint256 y) internal pure returns (uint256 z) {
        assembly {
            z := xor(x, mul(xor(x, y), lt(y, x)))
        }
    }

    function max(uint256 x, uint256 y) internal pure returns (uint256 z) {
        assembly {
            z := xor(x, mul(xor(x, y), gt(y, x)))
        }
    }

    /// @dev Returns max(x - y, 0).
    function zeroFloorSub(uint256 x, uint256 y) internal pure returns (uint256 z) {
        assembly {
            z := mul(gt(x, y), sub(x, y))
        }
    }

    /// @dev Returns x / y rounded up (x / y + boolAsInt(x % y > 0)).
    function divUp(uint256 x, uint256 y) internal pure returns (uint256 z) {
        // Division by 0 if
        //    y = 0
        assembly {
            if iszero(y) { revert(0, 0) }

            z := add(gt(mod(x, y), 0), div(x, y))
        }
    }

    /// @dev Returns the floor of log2(x) and returns 0 when x = 0.
    /// @dev Uses a method by dichotomy to find the highest bit set of x.
    function log2(uint256 x) internal pure returns (uint256 y) {
        assembly {
            // Finds if x has a 1 on the first 128 bits. If not then do nothing.
            // If that is the case then the result is more than 128.
            let z := shl(7, gt(x, 0xffffffffffffffffffffffffffffffff))
            y := z
            x := shr(z, x)

            // Using y as an accumulator, we can now focus on the last 128 bits of x.
            // Repeat this process to divide the number of bits to handle by 2 every time.
            z := shl(6, gt(x, 0xffffffffffffffff))
            y := add(y, z)
            x := shr(z, x)

            z := shl(5, gt(x, 0xffffffff))
            y := add(y, z)
            x := shr(z, x)

            z := shl(4, gt(x, 0xffff))
            y := add(y, z)
            x := shr(z, x)

            z := shl(3, gt(x, 0xff))
            y := add(y, z)
            x := shr(z, x)

            z := shl(2, gt(x, 0xf))
            y := add(y, z)
            x := shr(z, x)

            z := shl(1, gt(x, 3))
            y := add(add(y, z), gt(shr(z, x), 1))
        }
    }
}

File 18 of 43 : IDaiPermit.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

interface IDaiPermit {
    /// @param holder The address of the token owner.
    function nonces(address holder) external view returns (uint256);

    /// @param holder The address of the token owner.
    /// @param spender The address of the token spender.
    /// @param nonce The owner's nonce, increases at each call to permit.
    /// @param expiry The timestamp at which the permit is no longer valid.
    /// @param allowed Boolean that sets approval amount, true for type(uint256).max and false for 0.
    /// @param v Must produce valid secp256k1 signature from the owner along with r and s.
    /// @param r Must produce valid secp256k1 signature from the owner along with v and s.
    /// @param s Must produce valid secp256k1 signature from the owner along with r and v.
    function permit(
        address holder,
        address spender,
        uint256 nonce,
        uint256 expiry,
        bool allowed,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;
}

File 19 of 43 : PermitBundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {IERC20Permit} from "../lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol";

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

/// @title PermitBundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Bundler contract managing interactions with tokens implementing EIP-2612.
abstract contract PermitBundler is BaseBundler {
    /// @notice Permits the given `amount` of `asset` from sender to be spent by the bundler via EIP-2612 Permit with
    /// the given `deadline` & EIP-712 signature's `v`, `r` & `s`.
    /// @param asset The address of the token to be permitted.
    /// @param amount The amount of `asset` to be permitted.
    /// @param deadline The deadline of the approval.
    /// @param v The `v` component of a signature.
    /// @param r The `r` component of a signature.
    /// @param s The `s` component of a signature.
    /// @param skipRevert Whether to avoid reverting the call in case the signature is frontrunned.
    function permit(address asset, uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s, bool skipRevert)
        external
        payable
        protected
    {
        try IERC20Permit(asset).permit(initiator(), address(this), amount, deadline, v, r, s) {}
        catch (bytes memory returnData) {
            if (!skipRevert) _revert(returnData);
        }
    }
}

File 20 of 43 : IAllowanceTransfer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

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

/// @title AllowanceTransfer
/// @notice Handles ERC20 token permissions through signature based allowance setting and ERC20 token transfers by checking allowed amounts
/// @dev Requires user's token approval on the Permit2 contract
interface IAllowanceTransfer is IEIP712 {
    /// @notice Thrown when an allowance on a token has expired.
    /// @param deadline The timestamp at which the allowed amount is no longer valid
    error AllowanceExpired(uint256 deadline);

    /// @notice Thrown when an allowance on a token has been depleted.
    /// @param amount The maximum amount allowed
    error InsufficientAllowance(uint256 amount);

    /// @notice Thrown when too many nonces are invalidated.
    error ExcessiveInvalidation();

    /// @notice Emits an event when the owner successfully invalidates an ordered nonce.
    event NonceInvalidation(
        address indexed owner, address indexed token, address indexed spender, uint48 newNonce, uint48 oldNonce
    );

    /// @notice Emits an event when the owner successfully sets permissions on a token for the spender.
    event Approval(
        address indexed owner, address indexed token, address indexed spender, uint160 amount, uint48 expiration
    );

    /// @notice Emits an event when the owner successfully sets permissions using a permit signature on a token for the spender.
    event Permit(
        address indexed owner,
        address indexed token,
        address indexed spender,
        uint160 amount,
        uint48 expiration,
        uint48 nonce
    );

    /// @notice Emits an event when the owner sets the allowance back to 0 with the lockdown function.
    event Lockdown(address indexed owner, address token, address spender);

    /// @notice The permit data for a token
    struct PermitDetails {
        // ERC20 token address
        address token;
        // the maximum amount allowed to spend
        uint160 amount;
        // timestamp at which a spender's token allowances become invalid
        uint48 expiration;
        // an incrementing value indexed per owner,token,and spender for each signature
        uint48 nonce;
    }

    /// @notice The permit message signed for a single token allownce
    struct PermitSingle {
        // the permit data for a single token alownce
        PermitDetails details;
        // address permissioned on the allowed tokens
        address spender;
        // deadline on the permit signature
        uint256 sigDeadline;
    }

    /// @notice The permit message signed for multiple token allowances
    struct PermitBatch {
        // the permit data for multiple token allowances
        PermitDetails[] details;
        // address permissioned on the allowed tokens
        address spender;
        // deadline on the permit signature
        uint256 sigDeadline;
    }

    /// @notice The saved permissions
    /// @dev This info is saved per owner, per token, per spender and all signed over in the permit message
    /// @dev Setting amount to type(uint160).max sets an unlimited approval
    struct PackedAllowance {
        // amount allowed
        uint160 amount;
        // permission expiry
        uint48 expiration;
        // an incrementing value indexed per owner,token,and spender for each signature
        uint48 nonce;
    }

    /// @notice A token spender pair.
    struct TokenSpenderPair {
        // the token the spender is approved
        address token;
        // the spender address
        address spender;
    }

    /// @notice Details for a token transfer.
    struct AllowanceTransferDetails {
        // the owner of the token
        address from;
        // the recipient of the token
        address to;
        // the amount of the token
        uint160 amount;
        // the token to be transferred
        address token;
    }

    /// @notice A mapping from owner address to token address to spender address to PackedAllowance struct, which contains details and conditions of the approval.
    /// @notice The mapping is indexed in the above order see: allowance[ownerAddress][tokenAddress][spenderAddress]
    /// @dev The packed slot holds the allowed amount, expiration at which the allowed amount is no longer valid, and current nonce thats updated on any signature based approvals.
    function allowance(address user, address token, address spender)
        external
        view
        returns (uint160 amount, uint48 expiration, uint48 nonce);

    /// @notice Approves the spender to use up to amount of the specified token up until the expiration
    /// @param token The token to approve
    /// @param spender The spender address to approve
    /// @param amount The approved amount of the token
    /// @param expiration The timestamp at which the approval is no longer valid
    /// @dev The packed allowance also holds a nonce, which will stay unchanged in approve
    /// @dev Setting amount to type(uint160).max sets an unlimited approval
    function approve(address token, address spender, uint160 amount, uint48 expiration) external;

    /// @notice Permit a spender to a given amount of the owners token via the owner's EIP-712 signature
    /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce
    /// @param owner The owner of the tokens being approved
    /// @param permitSingle Data signed over by the owner specifying the terms of approval
    /// @param signature The owner's signature over the permit data
    function permit(address owner, PermitSingle memory permitSingle, bytes calldata signature) external;

    /// @notice Permit a spender to the signed amounts of the owners tokens via the owner's EIP-712 signature
    /// @dev May fail if the owner's nonce was invalidated in-flight by invalidateNonce
    /// @param owner The owner of the tokens being approved
    /// @param permitBatch Data signed over by the owner specifying the terms of approval
    /// @param signature The owner's signature over the permit data
    function permit(address owner, PermitBatch memory permitBatch, bytes calldata signature) external;

    /// @notice Transfer approved tokens from one address to another
    /// @param from The address to transfer from
    /// @param to The address of the recipient
    /// @param amount The amount of the token to transfer
    /// @param token The token address to transfer
    /// @dev Requires the from address to have approved at least the desired amount
    /// of tokens to msg.sender.
    function transferFrom(address from, address to, uint160 amount, address token) external;

    /// @notice Transfer approved tokens in a batch
    /// @param transferDetails Array of owners, recipients, amounts, and tokens for the transfers
    /// @dev Requires the from addresses to have approved at least the desired amount
    /// of tokens to msg.sender.
    function transferFrom(AllowanceTransferDetails[] calldata transferDetails) external;

    /// @notice Enables performing a "lockdown" of the sender's Permit2 identity
    /// by batch revoking approvals
    /// @param approvals Array of approvals to revoke.
    function lockdown(TokenSpenderPair[] calldata approvals) external;

    /// @notice Invalidate nonces for a given (token, spender) pair
    /// @param token The token to invalidate nonces for
    /// @param spender The spender to invalidate nonces for
    /// @param newNonce The new nonce to set. Invalidates all nonces less than it.
    /// @dev Can't invalidate more than 2**16 nonces per transaction.
    function invalidateNonces(address token, address spender, uint48 newNonce) external;
}

File 21 of 43 : Permit2Lib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {ERC20} from "solmate/src/tokens/ERC20.sol";

import {IDAIPermit} from "../interfaces/IDAIPermit.sol";
import {IAllowanceTransfer} from "../interfaces/IAllowanceTransfer.sol";
import {SafeCast160} from "./SafeCast160.sol";

/// @title Permit2Lib
/// @notice Enables efficient transfers and EIP-2612/DAI
/// permits for any token by falling back to Permit2.
library Permit2Lib {
    using SafeCast160 for uint256;
    /*//////////////////////////////////////////////////////////////
                                CONSTANTS
    //////////////////////////////////////////////////////////////*/

    /// @dev The unique EIP-712 domain domain separator for the DAI token contract.
    bytes32 internal constant DAI_DOMAIN_SEPARATOR = 0xdbb8cf42e1ecb028be3f3dbc922e1d878b963f411dc388ced501601c60f7c6f7;

    /// @dev The address for the WETH9 contract on Ethereum mainnet, encoded as a bytes32.
    bytes32 internal constant WETH9_ADDRESS = 0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2;

    /// @dev The address of the Permit2 contract the library will use.
    IAllowanceTransfer internal constant PERMIT2 =
        IAllowanceTransfer(address(0x000000000022D473030F116dDEE9F6B43aC78BA3));

    /// @notice Transfer a given amount of tokens from one user to another.
    /// @param token The token to transfer.
    /// @param from The user to transfer from.
    /// @param to The user to transfer to.
    /// @param amount The amount to transfer.
    function transferFrom2(ERC20 token, address from, address to, uint256 amount) internal {
        // Generate calldata for a standard transferFrom call.
        bytes memory inputData = abi.encodeCall(ERC20.transferFrom, (from, to, amount));

        bool success; // Call the token contract as normal, capturing whether it succeeded.
        assembly {
            success :=
                and(
                    // Set success to whether the call reverted, if not we check it either
                    // returned exactly 1 (can't just be non-zero data), or had no return data.
                    or(eq(mload(0), 1), iszero(returndatasize())),
                    // Counterintuitively, this call() must be positioned after the or() in the
                    // surrounding and() because and() evaluates its arguments from right to left.
                    // We use 0 and 32 to copy up to 32 bytes of return data into the first slot of scratch space.
                    call(gas(), token, 0, add(inputData, 32), mload(inputData), 0, 32)
                )
        }

        // We'll fall back to using Permit2 if calling transferFrom on the token directly reverted.
        if (!success) PERMIT2.transferFrom(from, to, amount.toUint160(), address(token));
    }

    /*//////////////////////////////////////////////////////////////
                              PERMIT LOGIC
    //////////////////////////////////////////////////////////////*/

    /// @notice Permit a user to spend a given amount of
    /// another user's tokens via native EIP-2612 permit if possible, falling
    /// back to Permit2 if native permit fails or is not implemented on the token.
    /// @param token The token to permit spending.
    /// @param owner The user to permit spending from.
    /// @param spender The user to permit spending to.
    /// @param amount The amount to permit spending.
    /// @param deadline  The timestamp after which the signature is no longer valid.
    /// @param v Must produce valid secp256k1 signature from the owner along with r and s.
    /// @param r Must produce valid secp256k1 signature from the owner along with v and s.
    /// @param s Must produce valid secp256k1 signature from the owner along with r and v.
    function permit2(
        ERC20 token,
        address owner,
        address spender,
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        // Generate calldata for a call to DOMAIN_SEPARATOR on the token.
        bytes memory inputData = abi.encodeWithSelector(ERC20.DOMAIN_SEPARATOR.selector);

        bool success; // Call the token contract as normal, capturing whether it succeeded.
        bytes32 domainSeparator; // If the call succeeded, we'll capture the return value here.

        assembly {
            // If the token is WETH9, we know it doesn't have a DOMAIN_SEPARATOR, and we'll skip this step.
            // We make sure to mask the token address as its higher order bits aren't guaranteed to be clean.
            if iszero(eq(and(token, 0xffffffffffffffffffffffffffffffffffffffff), WETH9_ADDRESS)) {
                success :=
                    and(
                        // Should resolve false if its not 32 bytes or its first word is 0.
                        and(iszero(iszero(mload(0))), eq(returndatasize(), 32)),
                        // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
                        // Counterintuitively, this call must be positioned second to the and() call in the
                        // surrounding and() call or else returndatasize() will be zero during the computation.
                        // We send a maximum of 5000 gas to prevent tokens with fallbacks from using a ton of gas.
                        // which should be plenty to allow tokens to fetch their DOMAIN_SEPARATOR from storage, etc.
                        staticcall(5000, token, add(inputData, 32), mload(inputData), 0, 32)
                    )

                domainSeparator := mload(0) // Copy the return value into the domainSeparator variable.
            }
        }

        // If the call to DOMAIN_SEPARATOR succeeded, try using permit on the token.
        if (success) {
            // We'll use DAI's special permit if it's DOMAIN_SEPARATOR matches,
            // otherwise we'll just encode a call to the standard permit function.
            inputData = domainSeparator == DAI_DOMAIN_SEPARATOR
                ? abi.encodeCall(IDAIPermit.permit, (owner, spender, token.nonces(owner), deadline, true, v, r, s))
                : abi.encodeCall(ERC20.permit, (owner, spender, amount, deadline, v, r, s));

            assembly {
                success := call(gas(), token, 0, add(inputData, 32), mload(inputData), 0, 0)
            }
        }

        if (!success) {
            // If the initial DOMAIN_SEPARATOR call on the token failed or a
            // subsequent call to permit failed, fall back to using Permit2.
            simplePermit2(token, owner, spender, amount, deadline, v, r, s);
        }
    }

    /// @notice Simple unlimited permit on the Permit2 contract.
    /// @param token The token to permit spending.
    /// @param owner The user to permit spending from.
    /// @param spender The user to permit spending to.
    /// @param amount The amount to permit spending.
    /// @param deadline  The timestamp after which the signature is no longer valid.
    /// @param v Must produce valid secp256k1 signature from the owner along with r and s.
    /// @param r Must produce valid secp256k1 signature from the owner along with v and s.
    /// @param s Must produce valid secp256k1 signature from the owner along with r and v.
    function simplePermit2(
        ERC20 token,
        address owner,
        address spender,
        uint256 amount,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        (,, uint48 nonce) = PERMIT2.allowance(owner, address(token), spender);

        PERMIT2.permit(
            owner,
            IAllowanceTransfer.PermitSingle({
                details: IAllowanceTransfer.PermitDetails({
                    token: address(token),
                    amount: amount.toUint160(),
                    // Use an unlimited expiration because it most
                    // closely mimics how a standard approval works.
                    expiration: type(uint48).max,
                    nonce: nonce
                }),
                spender: spender,
                sigDeadline: deadline
            }),
            bytes.concat(r, s, bytes1(v))
        );
    }
}

File 22 of 43 : SafeCast160.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

library SafeCast160 {
    /// @notice Thrown when a valude greater than type(uint160).max is cast to uint160
    error UnsafeCast();

    /// @notice Safely casts uint256 to uint160
    /// @param value The uint256 to be cast
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) revert UnsafeCast();
        return uint160(value);
    }
}

File 23 of 43 : ERC20.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event Transfer(address indexed from, address indexed to, uint256 amount);

    event Approval(address indexed owner, address indexed spender, uint256 amount);

    /*//////////////////////////////////////////////////////////////
                            METADATA STORAGE
    //////////////////////////////////////////////////////////////*/

    string public name;

    string public symbol;

    uint8 public immutable decimals;

    /*//////////////////////////////////////////////////////////////
                              ERC20 STORAGE
    //////////////////////////////////////////////////////////////*/

    uint256 public totalSupply;

    mapping(address => uint256) public balanceOf;

    mapping(address => mapping(address => uint256)) public allowance;

    /*//////////////////////////////////////////////////////////////
                            EIP-2612 STORAGE
    //////////////////////////////////////////////////////////////*/

    uint256 internal immutable INITIAL_CHAIN_ID;

    bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;

    mapping(address => uint256) public nonces;

    /*//////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor(
        string memory _name,
        string memory _symbol,
        uint8 _decimals
    ) {
        name = _name;
        symbol = _symbol;
        decimals = _decimals;

        INITIAL_CHAIN_ID = block.chainid;
        INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
    }

    /*//////////////////////////////////////////////////////////////
                               ERC20 LOGIC
    //////////////////////////////////////////////////////////////*/

    function approve(address spender, uint256 amount) public virtual returns (bool) {
        allowance[msg.sender][spender] = amount;

        emit Approval(msg.sender, spender, amount);

        return true;
    }

    function transfer(address to, uint256 amount) public virtual returns (bool) {
        balanceOf[msg.sender] -= amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(msg.sender, to, amount);

        return true;
    }

    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual returns (bool) {
        uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.

        if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;

        balanceOf[from] -= amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(from, to, amount);

        return true;
    }

    /*//////////////////////////////////////////////////////////////
                             EIP-2612 LOGIC
    //////////////////////////////////////////////////////////////*/

    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual {
        require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");

        // Unchecked because the only math done is incrementing
        // the owner's nonce which cannot realistically overflow.
        unchecked {
            address recoveredAddress = ecrecover(
                keccak256(
                    abi.encodePacked(
                        "\x19\x01",
                        DOMAIN_SEPARATOR(),
                        keccak256(
                            abi.encode(
                                keccak256(
                                    "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
                                ),
                                owner,
                                spender,
                                value,
                                nonces[owner]++,
                                deadline
                            )
                        )
                    )
                ),
                v,
                r,
                s
            );

            require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");

            allowance[recoveredAddress][spender] = value;
        }

        emit Approval(owner, spender, value);
    }

    function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
        return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
    }

    function computeDomainSeparator() internal view virtual returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
                    keccak256(bytes(name)),
                    keccak256("1"),
                    block.chainid,
                    address(this)
                )
            );
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL MINT/BURN LOGIC
    //////////////////////////////////////////////////////////////*/

    function _mint(address to, uint256 amount) internal virtual {
        totalSupply += amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(address(0), to, amount);
    }

    function _burn(address from, uint256 amount) internal virtual {
        balanceOf[from] -= amount;

        // Cannot underflow because a user's balance
        // will never be larger than the total supply.
        unchecked {
            totalSupply -= amount;
        }

        emit Transfer(from, address(0), amount);
    }
}

File 24 of 43 : IERC4626.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC4626.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/IERC20.sol";
import "../token/ERC20/extensions/IERC20Metadata.sol";

/**
 * @dev Interface of the ERC4626 "Tokenized Vault Standard", as defined in
 * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
 *
 * _Available since v4.7._
 */
interface IERC4626 is IERC20, IERC20Metadata {
    event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);

    event Withdraw(
        address indexed sender,
        address indexed receiver,
        address indexed owner,
        uint256 assets,
        uint256 shares
    );

    /**
     * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
     *
     * - MUST be an ERC-20 token contract.
     * - MUST NOT revert.
     */
    function asset() external view returns (address assetTokenAddress);

    /**
     * @dev Returns the total amount of the underlying asset that is “managed” by Vault.
     *
     * - SHOULD include any compounding that occurs from yield.
     * - MUST be inclusive of any fees that are charged against assets in the Vault.
     * - MUST NOT revert.
     */
    function totalAssets() external view returns (uint256 totalManagedAssets);

    /**
     * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
     * scenario where all the conditions are met.
     *
     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
     * - MUST NOT show any variations depending on the caller.
     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
     * - MUST NOT revert.
     *
     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
     * from.
     */
    function convertToShares(uint256 assets) external view returns (uint256 shares);

    /**
     * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
     * scenario where all the conditions are met.
     *
     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
     * - MUST NOT show any variations depending on the caller.
     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
     * - MUST NOT revert.
     *
     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
     * from.
     */
    function convertToAssets(uint256 shares) external view returns (uint256 assets);

    /**
     * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
     * through a deposit call.
     *
     * - MUST return a limited value if receiver is subject to some deposit limit.
     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
     * - MUST NOT revert.
     */
    function maxDeposit(address receiver) external view returns (uint256 maxAssets);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
     * current on-chain conditions.
     *
     * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
     *   call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
     *   in the same transaction.
     * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
     *   deposit would be accepted, regardless if the user has enough tokens approved, etc.
     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by depositing.
     */
    function previewDeposit(uint256 assets) external view returns (uint256 shares);

    /**
     * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
     *
     * - MUST emit the Deposit event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
     *   deposit execution, and are accounted for during deposit.
     * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
     *   approving enough underlying tokens to the Vault contract, etc).
     *
     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
     */
    function deposit(uint256 assets, address receiver) external returns (uint256 shares);

    /**
     * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
     * - MUST return a limited value if receiver is subject to some mint limit.
     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
     * - MUST NOT revert.
     */
    function maxMint(address receiver) external view returns (uint256 maxShares);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
     * current on-chain conditions.
     *
     * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
     *   in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
     *   same transaction.
     * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
     *   would be accepted, regardless if the user has enough tokens approved, etc.
     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by minting.
     */
    function previewMint(uint256 shares) external view returns (uint256 assets);

    /**
     * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
     *
     * - MUST emit the Deposit event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
     *   execution, and are accounted for during mint.
     * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
     *   approving enough underlying tokens to the Vault contract, etc).
     *
     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
     */
    function mint(uint256 shares, address receiver) external returns (uint256 assets);

    /**
     * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
     * Vault, through a withdraw call.
     *
     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
     * - MUST NOT revert.
     */
    function maxWithdraw(address owner) external view returns (uint256 maxAssets);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
     * given current on-chain conditions.
     *
     * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
     *   call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
     *   called
     *   in the same transaction.
     * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
     *   the withdrawal would be accepted, regardless if the user has enough shares, etc.
     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by depositing.
     */
    function previewWithdraw(uint256 assets) external view returns (uint256 shares);

    /**
     * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
     *
     * - MUST emit the Withdraw event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
     *   withdraw execution, and are accounted for during withdraw.
     * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
     *   not having enough shares, etc).
     *
     * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
     * Those methods should be performed separately.
     */
    function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);

    /**
     * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
     * through a redeem call.
     *
     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
     * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
     * - MUST NOT revert.
     */
    function maxRedeem(address owner) external view returns (uint256 maxShares);

    /**
     * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
     * given current on-chain conditions.
     *
     * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
     *   in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
     *   same transaction.
     * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
     *   redemption would be accepted, regardless if the user has enough shares, etc.
     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
     * - MUST NOT revert.
     *
     * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
     * share price or some other type of condition, meaning the depositor will lose assets by redeeming.
     */
    function previewRedeem(uint256 shares) external view returns (uint256 assets);

    /**
     * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
     *
     * - MUST emit the Withdraw event.
     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
     *   redeem execution, and are accounted for during redeem.
     * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
     *   not having enough shares, etc).
     *
     * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
     * Those methods should be performed separately.
     */
    function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
}

File 25 of 43 : IWNative.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

interface IWNative {
    function deposit() external payable;
    function withdraw(uint256 wad) external;
    function approve(address guy, uint256 wad) external returns (bool);
    function transferFrom(address src, address dst, uint256 wad) external returns (bool);
}

File 26 of 43 : StEthBundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;

import {IWstEth} from "./interfaces/IWstEth.sol";
import {IStEth} from "./interfaces/IStEth.sol";

import {Math} from "../lib/morpho-utils/src/math/Math.sol";
import {ErrorsLib} from "./libraries/ErrorsLib.sol";
import {SafeTransferLib, ERC20} from "../lib/solmate/src/utils/SafeTransferLib.sol";

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

/// @title StEthBundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Contract allowing to bundle multiple interactions with stETH together.
abstract contract StEthBundler is BaseBundler {
    using SafeTransferLib for ERC20;

    /* IMMUTABLES */

    /// @dev The address of the stETH contract.
    address public immutable ST_ETH;

    /// @dev The address of the wstETH contract.
    address public immutable WST_ETH;

    /* CONSTRUCTOR */

    /// @dev Warning: assumes the given addresses are non-zero (they are not expected to be deployment arguments).
    /// @param wstEth The address of the wstEth contract.
    constructor(address wstEth) {
        ST_ETH = IWstEth(wstEth).stETH();
        WST_ETH = wstEth;

        _approveMaxTo(ST_ETH, WST_ETH);
    }

    /* ACTIONS */

    /// @notice Stakes the given `amount` of ETH via Lido, using the `referral` id.
    /// @notice stETH tokens are received by the bundler and should be used afterwards.
    /// @dev Initiator must have previously transferred their ETH to the bundler.
    /// @param amount The amount of ETH to stake. Capped at the bundler's ETH balance.
    /// @param minShares The minimum amount of shares to mint in exchange for `amount`. This parameter is
    /// proportionally scaled down in case there is fewer ETH than `amount` on the bundler.
    /// @param referral The address of the referral regarding the Lido Rewards-Share Program.
    function stakeEth(uint256 amount, uint256 minShares, address referral) external payable protected {
        uint256 initialAmount = amount;
        amount = Math.min(amount, address(this).balance);

        require(amount != 0, ErrorsLib.ZERO_AMOUNT);

        uint256 shares = IStEth(ST_ETH).submit{value: amount}(referral);
        require(shares * initialAmount >= minShares * amount, ErrorsLib.SLIPPAGE_EXCEEDED);
    }

    /// @notice Wraps the given `amount` of stETH to wstETH.
    /// @notice wstETH tokens are received by the bundler and should be used afterwards.
    /// @dev Initiator must have previously transferred their stETH tokens to the bundler.
    /// @param amount The amount of stEth to wrap. Capped at the bundler's stETH balance.
    function wrapStEth(uint256 amount) external payable protected {
        amount = Math.min(amount, ERC20(ST_ETH).balanceOf(address(this)));

        require(amount != 0, ErrorsLib.ZERO_AMOUNT);

        IWstEth(WST_ETH).wrap(amount);
    }

    /// @notice Unwraps the given `amount` of wstETH to stETH.
    /// @notice stETH tokens are received by the bundler and should be used afterwards.
    /// @dev Initiator must have previously transferred their wstETH tokens to the bundler.
    /// @param amount The amount of wstEth to unwrap. Capped at the bundler's wstETH balance.
    function unwrapStEth(uint256 amount) external payable protected {
        amount = Math.min(amount, ERC20(WST_ETH).balanceOf(address(this)));

        require(amount != 0, ErrorsLib.ZERO_AMOUNT);

        IWstEth(WST_ETH).unwrap(amount);
    }
}

File 27 of 43 : IUniversalRewardsDistributor.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.4;

/// @notice The pending root struct for a merkle tree distribution during the timelock.
struct PendingRoot {
    /// @dev The timestamp of the block in which the pending root was submitted.
    uint256 submittedAt;
    /// @dev The submitted pending root.
    bytes32 root;
    /// @dev The optional ipfs hash containing metadata about the root (e.g. the merkle tree itself).
    bytes32 ipfsHash;
}

/// @title IUniversalRewardsDistributor
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice UniversalRewardsDistributor's interface.
interface IUniversalRewardsDistributor {
    function root() external view returns (bytes32);
    function owner() external view returns (address);
    function timelock() external view returns (uint256);
    function ipfsHash() external view returns (bytes32);
    function isUpdater(address) external view returns (bool);
    function pendingRoot() external view returns (uint256 submittedAt, bytes32 root, bytes32 ipfsHash);
    function claimed(address, address) external view returns (uint256);

    function acceptRoot() external;
    function setRoot(bytes32 newRoot, bytes32 newIpfsHash) external;
    function setTimelock(uint256 newTimelock) external;
    function setRootUpdater(address updater, bool active) external;
    function revokeRoot() external;
    function setOwner(address newOwner) external;

    function submitRoot(bytes32 newRoot, bytes32 ipfsHash) external;

    function claim(address account, address reward, uint256 claimable, bytes32[] memory proof)
        external
        returns (uint256 amount);
}

interface IPendingRoot {
    function pendingRoot() external view returns (PendingRoot memory);
}

File 28 of 43 : IMorphoBundler.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

import {
    IMorphoRepayCallback,
    IMorphoSupplyCallback,
    IMorphoSupplyCollateralCallback,
    IMorphoFlashLoanCallback
} from "../../lib/morpho-blue/src/interfaces/IMorphoCallbacks.sol";

/// @title IMorphoBundler
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @notice Interface of MorphoBundler.
interface IMorphoBundler is
    IMorphoSupplyCallback,
    IMorphoRepayCallback,
    IMorphoSupplyCollateralCallback,
    IMorphoFlashLoanCallback
{}

File 29 of 43 : IMorpho.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

type Id is bytes32;

struct MarketParams {
    address loanToken;
    address collateralToken;
    address oracle;
    address irm;
    uint256 lltv;
}

/// @dev Warning: For `feeRecipient`, `supplyShares` does not contain the accrued shares since the last interest
/// accrual.
struct Position {
    uint256 supplyShares;
    uint128 borrowShares;
    uint128 collateral;
}

/// @dev Warning: `totalSupplyAssets` does not contain the accrued interest since the last interest accrual.
/// @dev Warning: `totalBorrowAssets` does not contain the accrued interest since the last interest accrual.
/// @dev Warning: `totalSupplyShares` does not contain the additional shares accrued by `feeRecipient` since the last
/// interest accrual.
struct Market {
    uint128 totalSupplyAssets;
    uint128 totalSupplyShares;
    uint128 totalBorrowAssets;
    uint128 totalBorrowShares;
    uint128 lastUpdate;
    uint128 fee;
}

struct Authorization {
    address authorizer;
    address authorized;
    bool isAuthorized;
    uint256 nonce;
    uint256 deadline;
}

struct Signature {
    uint8 v;
    bytes32 r;
    bytes32 s;
}

/// @dev This interface is used for factorizing IMorphoStaticTyping and IMorpho.
/// @dev Consider using the IMorpho interface instead of this one.
interface IMorphoBase {
    /// @notice The EIP-712 domain separator.
    /// @dev Warning: Every EIP-712 signed message based on this domain separator can be reused on another chain sharing
    /// the same chain id because the domain separator would be the same.
    function DOMAIN_SEPARATOR() external view returns (bytes32);

    /// @notice The owner of the contract.
    /// @dev It has the power to change the owner.
    /// @dev It has the power to set fees on markets and set the fee recipient.
    /// @dev It has the power to enable but not disable IRMs and LLTVs.
    function owner() external view returns (address);

    /// @notice The fee recipient of all markets.
    /// @dev The recipient receives the fees of a given market through a supply position on that market.
    function feeRecipient() external view returns (address);

    /// @notice Whether the `irm` is enabled.
    function isIrmEnabled(address irm) external view returns (bool);

    /// @notice Whether the `lltv` is enabled.
    function isLltvEnabled(uint256 lltv) external view returns (bool);

    /// @notice Whether `authorized` is authorized to modify `authorizer`'s position on all markets.
    /// @dev Anyone is authorized to modify their own positions, regardless of this variable.
    function isAuthorized(address authorizer, address authorized) external view returns (bool);

    /// @notice The `authorizer`'s current nonce. Used to prevent replay attacks with EIP-712 signatures.
    function nonce(address authorizer) external view returns (uint256);

    /// @notice Sets `newOwner` as `owner` of the contract.
    /// @dev Warning: No two-step transfer ownership.
    /// @dev Warning: The owner can be set to the zero address.
    function setOwner(address newOwner) external;

    /// @notice Enables `irm` as a possible IRM for market creation.
    /// @dev Warning: It is not possible to disable an IRM.
    function enableIrm(address irm) external;

    /// @notice Enables `lltv` as a possible LLTV for market creation.
    /// @dev Warning: It is not possible to disable a LLTV.
    function enableLltv(uint256 lltv) external;

    /// @notice Sets the `newFee` for the given market `marketParams`.
    /// @param newFee The new fee, scaled by WAD.
    /// @dev Warning: The recipient can be the zero address.
    function setFee(MarketParams memory marketParams, uint256 newFee) external;

    /// @notice Sets `newFeeRecipient` as `feeRecipient` of the fee.
    /// @dev Warning: If the fee recipient is set to the zero address, fees will accrue there and will be lost.
    /// @dev Modifying the fee recipient will allow the new recipient to claim any pending fees not yet accrued. To
    /// ensure that the current recipient receives all due fees, accrue interest manually prior to making any changes.
    function setFeeRecipient(address newFeeRecipient) external;

    /// @notice Creates the market `marketParams`.
    /// @dev Here is the list of assumptions on the market's dependencies (tokens, IRM and oracle) that guarantees
    /// Morpho behaves as expected:
    /// - The token should be ERC-20 compliant, except that it can omit return values on `transfer` and `transferFrom`.
    /// - The token balance of Morpho should only decrease on `transfer` and `transferFrom`. In particular, tokens with
    /// burn functions are not supported.
    /// - The token should not re-enter Morpho on `transfer` nor `transferFrom`.
    /// - The token balance of the sender (resp. receiver) should decrease (resp. increase) by exactly the given amount
    /// on `transfer` and `transferFrom`. In particular, tokens with fees on transfer are not supported.
    /// - The IRM should not re-enter Morpho.
    /// - The oracle should return a price with the correct scaling.
    /// @dev Here is a list of properties on the market's dependencies that could break Morpho's liveness properties
    /// (funds could get stuck):
    /// - The token can revert on `transfer` and `transferFrom` for a reason other than an approval or balance issue.
    /// - A very high amount of assets (~1e35) supplied or borrowed can make the computation of `toSharesUp` and
    /// `toSharesDown` overflow.
    /// - The IRM can revert on `borrowRate`.
    /// - A very high borrow rate returned by the IRM can make the computation of `interest` in `_accrueInterest`
    /// overflow.
    /// - The oracle can revert on `price`. Note that this can be used to prevent `borrow`, `withdrawCollateral` and
    /// `liquidate` from being used under certain market conditions.
    /// - A very high price returned by the oracle can make the computation of `maxBorrow` in `_isHealthy` overflow, or
    /// the computation of `assetsRepaid` in `liquidate` overflow.
    /// @dev The borrow share price of a market with less than 1e4 assets borrowed can be decreased by manipulations, to
    /// the point where `totalBorrowShares` is very large and borrowing overflows.
    function createMarket(MarketParams memory marketParams) external;

    /// @notice Supplies `assets` or `shares` on behalf of `onBehalf`, optionally calling back the caller's
    /// `onMorphoSupply` function with the given `data`.
    /// @dev Either `assets` or `shares` should be zero. Most use cases should rely on `assets` as an input so the
    /// caller is guaranteed to have `assets` tokens pulled from their balance, but the possibility to mint a specific
    /// amount of shares is given for full compatibility and precision.
    /// @dev Supplying a large amount can revert for overflow.
    /// @dev Supplying an amount of shares may lead to supply more or fewer assets than expected due to slippage.
    /// Consider using the `assets` parameter to avoid this.
    /// @param marketParams The market to supply assets to.
    /// @param assets The amount of assets to supply.
    /// @param shares The amount of shares to mint.
    /// @param onBehalf The address that will own the increased supply position.
    /// @param data Arbitrary data to pass to the `onMorphoSupply` callback. Pass empty data if not needed.
    /// @return assetsSupplied The amount of assets supplied.
    /// @return sharesSupplied The amount of shares minted.
    function supply(
        MarketParams memory marketParams,
        uint256 assets,
        uint256 shares,
        address onBehalf,
        bytes memory data
    ) external returns (uint256 assetsSupplied, uint256 sharesSupplied);

    /// @notice Withdraws `assets` or `shares` on behalf of `onBehalf` and sends the assets to `receiver`.
    /// @dev Either `assets` or `shares` should be zero. To withdraw max, pass the `shares`'s balance of `onBehalf`.
    /// @dev `msg.sender` must be authorized to manage `onBehalf`'s positions.
    /// @dev Withdrawing an amount corresponding to more shares than supplied will revert for underflow.
    /// @dev It is advised to use the `shares` input when withdrawing the full position to avoid reverts due to
    /// conversion roundings between shares and assets.
    /// @param marketParams The market to withdraw assets from.
    /// @param assets The amount of assets to withdraw.
    /// @param shares The amount of shares to burn.
    /// @param onBehalf The address of the owner of the supply position.
    /// @param receiver The address that will receive the withdrawn assets.
    /// @return assetsWithdrawn The amount of assets withdrawn.
    /// @return sharesWithdrawn The amount of shares burned.
    function withdraw(
        MarketParams memory marketParams,
        uint256 assets,
        uint256 shares,
        address onBehalf,
        address receiver
    ) external returns (uint256 assetsWithdrawn, uint256 sharesWithdrawn);

    /// @notice Borrows `assets` or `shares` on behalf of `onBehalf` and sends the assets to `receiver`.
    /// @dev Either `assets` or `shares` should be zero. Most use cases should rely on `assets` as an input so the
    /// caller is guaranteed to borrow `assets` of tokens, but the possibility to mint a specific amount of shares is
    /// given for full compatibility and precision.
    /// @dev `msg.sender` must be authorized to manage `onBehalf`'s positions.
    /// @dev Borrowing a large amount can revert for overflow.
    /// @dev Borrowing an amount of shares may lead to borrow fewer assets than expected due to slippage.
    /// Consider using the `assets` parameter to avoid this.
    /// @param marketParams The market to borrow assets from.
    /// @param assets The amount of assets to borrow.
    /// @param shares The amount of shares to mint.
    /// @param onBehalf The address that will own the increased borrow position.
    /// @param receiver The address that will receive the borrowed assets.
    /// @return assetsBorrowed The amount of assets borrowed.
    /// @return sharesBorrowed The amount of shares minted.
    function borrow(
        MarketParams memory marketParams,
        uint256 assets,
        uint256 shares,
        address onBehalf,
        address receiver
    ) external returns (uint256 assetsBorrowed, uint256 sharesBorrowed);

    /// @notice Repays `assets` or `shares` on behalf of `onBehalf`, optionally calling back the caller's
    /// `onMorphoReplay` function with the given `data`.
    /// @dev Either `assets` or `shares` should be zero. To repay max, pass the `shares`'s balance of `onBehalf`.
    /// @dev Repaying an amount corresponding to more shares than borrowed will revert for underflow.
    /// @dev It is advised to use the `shares` input when repaying the full position to avoid reverts due to conversion
    /// roundings between shares and assets.
    /// @dev An attacker can front-run a repay with a small repay making the transaction revert for underflow.
    /// @param marketParams The market to repay assets to.
    /// @param assets The amount of assets to repay.
    /// @param shares The amount of shares to burn.
    /// @param onBehalf The address of the owner of the debt position.
    /// @param data Arbitrary data to pass to the `onMorphoRepay` callback. Pass empty data if not needed.
    /// @return assetsRepaid The amount of assets repaid.
    /// @return sharesRepaid The amount of shares burned.
    function repay(
        MarketParams memory marketParams,
        uint256 assets,
        uint256 shares,
        address onBehalf,
        bytes memory data
    ) external returns (uint256 assetsRepaid, uint256 sharesRepaid);

    /// @notice Supplies `assets` of collateral on behalf of `onBehalf`, optionally calling back the caller's
    /// `onMorphoSupplyCollateral` function with the given `data`.
    /// @dev Interest are not accrued since it's not required and it saves gas.
    /// @dev Supplying a large amount can revert for overflow.
    /// @param marketParams The market to supply collateral to.
    /// @param assets The amount of collateral to supply.
    /// @param onBehalf The address that will own the increased collateral position.
    /// @param data Arbitrary data to pass to the `onMorphoSupplyCollateral` callback. Pass empty data if not needed.
    function supplyCollateral(MarketParams memory marketParams, uint256 assets, address onBehalf, bytes memory data)
        external;

    /// @notice Withdraws `assets` of collateral on behalf of `onBehalf` and sends the assets to `receiver`.
    /// @dev `msg.sender` must be authorized to manage `onBehalf`'s positions.
    /// @dev Withdrawing an amount corresponding to more collateral than supplied will revert for underflow.
    /// @param marketParams The market to withdraw collateral from.
    /// @param assets The amount of collateral to withdraw.
    /// @param onBehalf The address of the owner of the collateral position.
    /// @param receiver The address that will receive the collateral assets.
    function withdrawCollateral(MarketParams memory marketParams, uint256 assets, address onBehalf, address receiver)
        external;

    /// @notice Liquidates the given `repaidShares` of debt asset or seize the given `seizedAssets` of collateral on the
    /// given market `marketParams` of the given `borrower`'s position, optionally calling back the caller's
    /// `onMorphoLiquidate` function with the given `data`.
    /// @dev Either `seizedAssets` or `repaidShares` should be zero.
    /// @dev Seizing more than the collateral balance will underflow and revert without any error message.
    /// @dev Repaying more than the borrow balance will underflow and revert without any error message.
    /// @dev An attacker can front-run a liquidation with a small repay making the transaction revert for underflow.
    /// @param marketParams The market of the position.
    /// @param borrower The owner of the position.
    /// @param seizedAssets The amount of collateral to seize.
    /// @param repaidShares The amount of shares to repay.
    /// @param data Arbitrary data to pass to the `onMorphoLiquidate` callback. Pass empty data if not needed.
    /// @return The amount of assets seized.
    /// @return The amount of assets repaid.
    function liquidate(
        MarketParams memory marketParams,
        address borrower,
        uint256 seizedAssets,
        uint256 repaidShares,
        bytes memory data
    ) external returns (uint256, uint256);

    /// @notice Executes a flash loan.
    /// @dev Flash loans have access to the whole balance of the contract (the liquidity and deposited collateral of all
    /// markets combined, plus donations).
    /// @dev Warning: Not ERC-3156 compliant but compatibility is easily reached:
    /// - `flashFee` is zero.
    /// - `maxFlashLoan` is the token's balance of this contract.
    /// - The receiver of `assets` is the caller.
    /// @param token The token to flash loan.
    /// @param assets The amount of assets to flash loan.
    /// @param data Arbitrary data to pass to the `onMorphoFlashLoan` callback.
    function flashLoan(address token, uint256 assets, bytes calldata data) external;

    /// @notice Sets the authorization for `authorized` to manage `msg.sender`'s positions.
    /// @param authorized The authorized address.
    /// @param newIsAuthorized The new authorization status.
    function setAuthorization(address authorized, bool newIsAuthorized) external;

    /// @notice Sets the authorization for `authorization.authorized` to manage `authorization.authorizer`'s positions.
    /// @dev Warning: Reverts if the signature has already been submitted.
    /// @dev The signature is malleable, but it has no impact on the security here.
    /// @dev The nonce is passed as argument to be able to revert with a different error message.
    /// @param authorization The `Authorization` struct.
    /// @param signature The signature.
    function setAuthorizationWithSig(Authorization calldata authorization, Signature calldata signature) external;

    /// @notice Accrues interest for the given market `marketParams`.
    function accrueInterest(MarketParams memory marketParams) external;

    /// @notice Returns the data stored on the different `slots`.
    function extSloads(bytes32[] memory slots) external view returns (bytes32[] memory);
}

/// @dev This interface is inherited by Morpho so that function signatures are checked by the compiler.
/// @dev Consider using the IMorpho interface instead of this one.
interface IMorphoStaticTyping is IMorphoBase {
    /// @notice The state of the position of `user` on the market corresponding to `id`.
    /// @dev Warning: For `feeRecipient`, `supplyShares` does not contain the accrued shares since the last interest
    /// accrual.
    function position(Id id, address user)
        external
        view
        returns (uint256 supplyShares, uint128 borrowShares, uint128 collateral);

    /// @notice The state of the market corresponding to `id`.
    /// @dev Warning: `totalSupplyAssets` does not contain the accrued interest since the last interest accrual.
    /// @dev Warning: `totalBorrowAssets` does not contain the accrued interest since the last interest accrual.
    /// @dev Warning: `totalSupplyShares` does not contain the accrued shares by `feeRecipient` since the last interest
    /// accrual.
    function market(Id id)
        external
        view
        returns (
            uint128 totalSupplyAssets,
            uint128 totalSupplyShares,
            uint128 totalBorrowAssets,
            uint128 totalBorrowShares,
            uint128 lastUpdate,
            uint128 fee
        );

    /// @notice The market params corresponding to `id`.
    /// @dev This mapping is not used in Morpho. It is there to enable reducing the cost associated to calldata on layer
    /// 2s by creating a wrapper contract with functions that take `id` as input instead of `marketParams`.
    function idToMarketParams(Id id)
        external
        view
        returns (address loanToken, address collateralToken, address oracle, address irm, uint256 lltv);
}

/// @title IMorpho
/// @author Morpho Labs
/// @custom:contact [email protected]
/// @dev Use this interface for Morpho to have access to all the functions with the appropriate function signatures.
interface IMorpho is IMorphoBase {
    /// @notice The state of the position of `user` on the market corresponding to `id`.
    /// @dev Warning: For `feeRecipient`, `p.supplyShares` does not contain the accrued shares since the last interest
    /// accrual.
    function position(Id id, address user) external view returns (Position memory p);

    /// @notice The state of the market corresponding to `id`.
    /// @dev Warning: `m.totalSupplyAssets` does not contain the accrued interest since the last interest accrual.
    /// @dev Warning: `m.totalBorrowAssets` does not contain the accrued interest since the last interest accrual.
    /// @dev Warning: `m.totalSupplyShares` does not contain the accrued shares by `feeRecipient` since the last
    /// interest accrual.
    function market(Id id) external view returns (Market memory m);

    /// @notice The market params corresponding to `id`.
    /// @dev This mapping is not used in Morpho. It is there to enable reducing the cost associated to calldata on layer
    /// 2s by creating a wrapper contract with functions that take `id` as input instead of `marketParams`.
    function idToMarketParams(Id id) external view returns (MarketParams memory);
}

File 30 of 43 : ERC20Wrapper.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/ERC20Wrapper.sol)

pragma solidity ^0.8.0;

import "../ERC20.sol";
import "../utils/SafeERC20.sol";

/**
 * @dev Extension of the ERC20 token contract to support token wrapping.
 *
 * Users can deposit and withdraw "underlying tokens" and receive a matching number of "wrapped tokens". This is useful
 * in conjunction with other modules. For example, combining this wrapping mechanism with {ERC20Votes} will allow the
 * wrapping of an existing "basic" ERC20 into a governance token.
 *
 * _Available since v4.2._
 */
abstract contract ERC20Wrapper is ERC20 {
    IERC20 private immutable _underlying;

    constructor(IERC20 underlyingToken) {
        require(underlyingToken != this, "ERC20Wrapper: cannot self wrap");
        _underlying = underlyingToken;
    }

    /**
     * @dev See {ERC20-decimals}.
     */
    function decimals() public view virtual override returns (uint8) {
        try IERC20Metadata(address(_underlying)).decimals() returns (uint8 value) {
            return value;
        } catch {
            return super.decimals();
        }
    }

    /**
     * @dev Returns the address of the underlying ERC-20 token that is being wrapped.
     */
    function underlying() public view returns (IERC20) {
        return _underlying;
    }

    /**
     * @dev Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens.
     */
    function depositFor(address account, uint256 amount) public virtual returns (bool) {
        address sender = _msgSender();
        require(sender != address(this), "ERC20Wrapper: wrapper can't deposit");
        SafeERC20.safeTransferFrom(_underlying, sender, address(this), amount);
        _mint(account, amount);
        return true;
    }

    /**
     * @dev Allow a user to burn a number of wrapped tokens and withdraw the corresponding number of underlying tokens.
     */
    function withdrawTo(address account, uint256 amount) public virtual returns (bool) {
        _burn(_msgSender(), amount);
        SafeERC20.safeTransfer(_underlying, account, amount);
        return true;
    }

    /**
     * @dev Mint wrapped token to cover any underlyingTokens that would have been transferred by mistake. Internal
     * function that can be exposed with access control if desired.
     */
    function _recover(address account) internal virtual returns (uint256) {
        uint256 value = _underlying.balanceOf(address(this)) - totalSupply();
        _mint(account, value);
        return value;
    }
}

File 31 of 43 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @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.
 */
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].
     */
    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 32 of 43 : IEIP712.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

interface IEIP712 {
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 33 of 43 : ERC20.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event Transfer(address indexed from, address indexed to, uint256 amount);

    event Approval(address indexed owner, address indexed spender, uint256 amount);

    /*//////////////////////////////////////////////////////////////
                            METADATA STORAGE
    //////////////////////////////////////////////////////////////*/

    string public name;

    string public symbol;

    uint8 public immutable decimals;

    /*//////////////////////////////////////////////////////////////
                              ERC20 STORAGE
    //////////////////////////////////////////////////////////////*/

    uint256 public totalSupply;

    mapping(address => uint256) public balanceOf;

    mapping(address => mapping(address => uint256)) public allowance;

    /*//////////////////////////////////////////////////////////////
                            EIP-2612 STORAGE
    //////////////////////////////////////////////////////////////*/

    uint256 internal immutable INITIAL_CHAIN_ID;

    bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;

    mapping(address => uint256) public nonces;

    /*//////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor(
        string memory _name,
        string memory _symbol,
        uint8 _decimals
    ) {
        name = _name;
        symbol = _symbol;
        decimals = _decimals;

        INITIAL_CHAIN_ID = block.chainid;
        INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
    }

    /*//////////////////////////////////////////////////////////////
                               ERC20 LOGIC
    //////////////////////////////////////////////////////////////*/

    function approve(address spender, uint256 amount) public virtual returns (bool) {
        allowance[msg.sender][spender] = amount;

        emit Approval(msg.sender, spender, amount);

        return true;
    }

    function transfer(address to, uint256 amount) public virtual returns (bool) {
        balanceOf[msg.sender] -= amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(msg.sender, to, amount);

        return true;
    }

    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual returns (bool) {
        uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.

        if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;

        balanceOf[from] -= amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(from, to, amount);

        return true;
    }

    /*//////////////////////////////////////////////////////////////
                             EIP-2612 LOGIC
    //////////////////////////////////////////////////////////////*/

    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual {
        require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");

        // Unchecked because the only math done is incrementing
        // the owner's nonce which cannot realistically overflow.
        unchecked {
            address recoveredAddress = ecrecover(
                keccak256(
                    abi.encodePacked(
                        "\x19\x01",
                        DOMAIN_SEPARATOR(),
                        keccak256(
                            abi.encode(
                                keccak256(
                                    "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
                                ),
                                owner,
                                spender,
                                value,
                                nonces[owner]++,
                                deadline
                            )
                        )
                    )
                ),
                v,
                r,
                s
            );

            require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");

            allowance[recoveredAddress][spender] = value;
        }

        emit Approval(owner, spender, value);
    }

    function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
        return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
    }

    function computeDomainSeparator() internal view virtual returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
                    keccak256(bytes(name)),
                    keccak256("1"),
                    block.chainid,
                    address(this)
                )
            );
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL MINT/BURN LOGIC
    //////////////////////////////////////////////////////////////*/

    function _mint(address to, uint256 amount) internal virtual {
        totalSupply += amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(address(0), to, amount);
    }

    function _burn(address from, uint256 amount) internal virtual {
        balanceOf[from] -= amount;

        // Cannot underflow because a user's balance
        // will never be larger than the total supply.
        unchecked {
            totalSupply -= amount;
        }

        emit Transfer(from, address(0), amount);
    }
}

File 34 of 43 : IDAIPermit.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

interface IDAIPermit {
    /// @param holder The address of the token owner.
    /// @param spender The address of the token spender.
    /// @param nonce The owner's nonce, increases at each call to permit.
    /// @param expiry The timestamp at which the permit is no longer valid.
    /// @param allowed Boolean that sets approval amount, true for type(uint256).max and false for 0.
    /// @param v Must produce valid secp256k1 signature from the owner along with r and s.
    /// @param r Must produce valid secp256k1 signature from the owner along with v and s.
    /// @param s Must produce valid secp256k1 signature from the owner along with r and v.
    function permit(
        address holder,
        address spender,
        uint256 nonce,
        uint256 expiry,
        bool allowed,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;
}

File 35 of 43 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @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 amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` 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 amount) external returns (bool);
}

File 36 of 43 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
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 37 of 43 : IWstEth.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

interface IWstEth {
    function DOMAIN_SEPARATOR() external view returns (bytes32);

    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function balanceOf(address account) external view returns (uint256);
    function decimals() external view returns (uint8);
    function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);
    function getStETHByWstETH(uint256 wstETHAmount) external view returns (uint256);
    function getWstETHByStETH(uint256 stETHAmount) external view returns (uint256);
    function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
    function name() external view returns (string memory);
    function nonces(address owner) external view returns (uint256);
    function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
        external;
    function stETH() external view returns (address);
    function stEthPerToken() external view returns (uint256);
    function symbol() external view returns (string memory);
    function tokensPerStEth() external view returns (uint256);
    function totalSupply() external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    function unwrap(uint256 wstETHAmount) external returns (uint256);
    function wrap(uint256 stETHAmount) external returns (uint256);
}

File 38 of 43 : IStEth.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

interface IStEth {
    function sharesOf(address _account) external view returns (uint256);

    function transferShares(address _recipient, uint256 _sharesAmount) external returns (uint256);

    function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256);

    function getSharesByPooledEth(uint256 _stEthAmount) external view returns (uint256);

    function getCurrentStakeLimit() external view returns (uint256);

    function submit(address _referral) external payable returns (uint256);
}

File 39 of 43 : IMorphoCallbacks.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

/// @title IMorphoLiquidateCallback
/// @notice Interface that liquidators willing to use `liquidate`'s callback must implement.
interface IMorphoLiquidateCallback {
    /// @notice Callback called when a liquidation occurs.
    /// @dev The callback is called only if data is not empty.
    /// @param repaidAssets The amount of repaid assets.
    /// @param data Arbitrary data passed to the `liquidate` function.
    function onMorphoLiquidate(uint256 repaidAssets, bytes calldata data) external;
}

/// @title IMorphoRepayCallback
/// @notice Interface that users willing to use `repay`'s callback must implement.
interface IMorphoRepayCallback {
    /// @notice Callback called when a repayment occurs.
    /// @dev The callback is called only if data is not empty.
    /// @param assets The amount of repaid assets.
    /// @param data Arbitrary data passed to the `repay` function.
    function onMorphoRepay(uint256 assets, bytes calldata data) external;
}

/// @title IMorphoSupplyCallback
/// @notice Interface that users willing to use `supply`'s callback must implement.
interface IMorphoSupplyCallback {
    /// @notice Callback called when a supply occurs.
    /// @dev The callback is called only if data is not empty.
    /// @param assets The amount of supplied assets.
    /// @param data Arbitrary data passed to the `supply` function.
    function onMorphoSupply(uint256 assets, bytes calldata data) external;
}

/// @title IMorphoSupplyCollateralCallback
/// @notice Interface that users willing to use `supplyCollateral`'s callback must implement.
interface IMorphoSupplyCollateralCallback {
    /// @notice Callback called when a supply of collateral occurs.
    /// @dev The callback is called only if data is not empty.
    /// @param assets The amount of supplied collateral.
    /// @param data Arbitrary data passed to the `supplyCollateral` function.
    function onMorphoSupplyCollateral(uint256 assets, bytes calldata data) external;
}

/// @title IMorphoFlashLoanCallback
/// @notice Interface that users willing to use `flashLoan`'s callback must implement.
interface IMorphoFlashLoanCallback {
    /// @notice Callback called when a flash loan occurs.
    /// @dev The callback is called only if data is not empty.
    /// @param assets The amount of assets that was flash loaned.
    /// @param data Arbitrary data passed to the `flashLoan` function.
    function onMorphoFlashLoan(uint256 assets, bytes calldata data) external;
}

File 40 of 43 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(address from, address to, uint256 amount) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _totalSupply -= amount;
        }

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
}

File 41 of 43 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../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 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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 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);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @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.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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, "SafeERC20: low-level call failed");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @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.isContract(address(token));
    }
}

File 42 of 43 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 43 of 43 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @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, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * 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.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @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`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);
        }
    }
}

Settings
{
  "remappings": [
    "solmate/=lib/permit2/lib/solmate/",
    "@aave/core-v3/=lib/morpho-utils/lib/aave-v3-core/",
    "aave-v3-core/=lib/morpho-utils/lib/aave-v3-core/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-gas-snapshot/=lib/permit2/lib/forge-gas-snapshot/src/",
    "forge-std/=lib/forge-std/src/",
    "morpho-blue-irm/=lib/morpho-blue-irm/src/",
    "morpho-blue/=lib/morpho-blue/",
    "morpho-utils/=lib/morpho-utils/src/",
    "murky/=lib/murky/",
    "openzeppelin-contracts-upgradeable/=lib/morpho-utils/lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "openzeppelin-upgradeable/=lib/morpho-utils/lib/openzeppelin-contracts-upgradeable/contracts/",
    "openzeppelin/=lib/openzeppelin-contracts/contracts/",
    "permit2/=lib/permit2/",
    "universal-rewards-distributor/=lib/universal-rewards-distributor/src/",
    "weird-erc20/=lib/universal-rewards-distributor/lib/solmate/lib/weird-erc20/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 80000
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "paris",
  "viaIR": true,
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"morpho","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"UnsafeCast","type":"error"},{"inputs":[],"name":"MORPHO","outputs":[{"internalType":"contract IMorpho","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ST_ETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WRAPPED_NATIVE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WST_ETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint160","name":"amount","type":"uint160"},{"internalType":"uint48","name":"expiration","type":"uint48"},{"internalType":"uint48","name":"nonce","type":"uint48"}],"internalType":"struct IAllowanceTransfer.PermitDetails","name":"details","type":"tuple"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"sigDeadline","type":"uint256"}],"internalType":"struct IAllowanceTransfer.PermitSingle","name":"permitSingle","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bool","name":"skipRevert","type":"bool"}],"name":"approve2","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"erc20Transfer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"erc20TransferFrom","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"wrapper","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"erc20WrapperDepositFor","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"wrapper","type":"address"},{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"erc20WrapperWithdrawTo","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"minShares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"erc4626Deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"maxAssets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"erc4626Mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"minAssets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"erc4626Redeem","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"maxShares","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"erc4626Withdraw","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"initiator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"loanToken","type":"address"},{"internalType":"address","name":"collateralToken","type":"address"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"address","name":"irm","type":"address"},{"internalType":"uint256","name":"lltv","type":"uint256"}],"internalType":"struct MarketParams","name":"marketParams","type":"tuple"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"slippageAmount","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"morphoBorrow","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"morphoFlashLoan","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"loanToken","type":"address"},{"internalType":"address","name":"collateralToken","type":"address"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"address","name":"irm","type":"address"},{"internalType":"uint256","name":"lltv","type":"uint256"}],"internalType":"struct MarketParams","name":"marketParams","type":"tuple"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"slippageAmount","type":"uint256"},{"internalType":"address","name":"onBehalf","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"morphoRepay","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"authorizer","type":"address"},{"internalType":"address","name":"authorized","type":"address"},{"internalType":"bool","name":"isAuthorized","type":"bool"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct Authorization","name":"authorization","type":"tuple"},{"components":[{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct Signature","name":"signature","type":"tuple"},{"internalType":"bool","name":"skipRevert","type":"bool"}],"name":"morphoSetAuthorizationWithSig","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"loanToken","type":"address"},{"internalType":"address","name":"collateralToken","type":"address"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"address","name":"irm","type":"address"},{"internalType":"uint256","name":"lltv","type":"uint256"}],"internalType":"struct MarketParams","name":"marketParams","type":"tuple"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"slippageAmount","type":"uint256"},{"internalType":"address","name":"onBehalf","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"morphoSupply","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"loanToken","type":"address"},{"internalType":"address","name":"collateralToken","type":"address"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"address","name":"irm","type":"address"},{"internalType":"uint256","name":"lltv","type":"uint256"}],"internalType":"struct MarketParams","name":"marketParams","type":"tuple"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"onBehalf","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"morphoSupplyCollateral","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"loanToken","type":"address"},{"internalType":"address","name":"collateralToken","type":"address"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"address","name":"irm","type":"address"},{"internalType":"uint256","name":"lltv","type":"uint256"}],"internalType":"struct MarketParams","name":"marketParams","type":"tuple"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"slippageAmount","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"morphoWithdraw","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"loanToken","type":"address"},{"internalType":"address","name":"collateralToken","type":"address"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"address","name":"irm","type":"address"},{"internalType":"uint256","name":"lltv","type":"uint256"}],"internalType":"struct MarketParams","name":"marketParams","type":"tuple"},{"internalType":"uint256","name":"assets","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"morphoWithdrawCollateral","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"nativeTransfer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onMorphoFlashLoan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onMorphoRepay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onMorphoSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onMorphoSupplyCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"bool","name":"skipRevert","type":"bool"}],"name":"permit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"bool","name":"allowed","type":"bool"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"bool","name":"skipRevert","type":"bool"}],"name":"permitDai","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"minShares","type":"uint256"},{"internalType":"address","name":"referral","type":"address"}],"name":"stakeEth","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom2","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unwrapNative","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unwrapStEth","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"distributor","type":"address"},{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"reward","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"bool","name":"skipRevert","type":"bool"}],"name":"urdClaim","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"wrapNative","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"wrapStEth","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]

610100604090808252346200030a57620000339062003f9780380380916200002882856200030f565b833981019062000349565b600080546001600160a01b031916600117815590620000516200036a565b5073c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2608052825163183fc7c960e31b8152602091737f39c581f595b53c5cb19bd0b3f8da6c935e2ca091908382600481865afa91821562000300578592620002ca575b5060a082905260c08390528551636eb1769f60e11b8152306004820152602481018490526044936001600160a01b039390919084169086818781855afa908115620002c05792889287928995859162000280575b50156200020d575b50505050501692620001156200036a565b908415620001b657858560e05251613bf39081620003a482396080518181816103e1015281816113020152612603015260a0518181816104cb01528181610b08015261274e015260c051818181610b910152818161201001526127d7015260e0518181816102db0152818161064d0152818161097d015281816113eb01528181611e5d015281816123a40152818161297201528181612d350152613b980152f35b9290855193849262461bcd60e51b8452806004850152825192836024860152825b848110620001f657505050828201840152601f01601f19168101030190fd5b8181018301518882018801528795508201620001d7565b8a5163095ea7b360e01b81526004810192909252600019602483015283905af13d15601f3d116001885114161716156200024c57838584388062000104565b855162461bcd60e51b815260048101859052600e60248201526d1054141493d59157d1905253115160921b81850152606490fd5b93505092509281813d8311620002b8575b6200029d81836200030f565b81010312620002b4578692889287925138620000fc565b8780fd5b503d62000291565b89513d8a823e3d90fd5b620002f0919250843d8611620002f8575b620002e781836200030f565b81019062000349565b9038620000a8565b503d620002db565b86513d87823e3d90fd5b600080fd5b601f909101601f19168101906001600160401b038211908210176200033357604052565b634e487b7160e01b600052604160045260246000fd5b908160209103126200030a57516001600160a01b03811681036200030a5790565b60408051919082016001600160401b038111838210176200033357604052600c82526b7a65726f206164647265737360a01b602083015256fe60406080815260049081361015610020575b5050361561001e57600080fd5b005b600091823560e01c90816305b4591c14610c2b57816312c0d70b14612a035781631af3bbc6146128f75781632075be0314610c2b578163240f78a31461277257816331f5707214610c2b578163338346d2146127035783826334b10a6d1461259f575081633790767d1461255a57816339029ab6146123c85781633acb562414612359578382634d5fcf68146121e65750816354c53ef0146120345781635664cb4814611fc5578382635b866db614611dba575081635c39fcc114611d695781636024440814611b705783826362577ad014611af6575081636b89026a146119415781636ef5eeae1461176657816370dc41fe146115955781637336bc6a146114845783826384d287ef1461136d5782639169d8331461128157508163a184a5a31461116a578163a7f6e60614610f6c578163ac9650d814610dba578163af50420214610c30578163b1022fdf14610c2b5783908263bc2a294c14610a71578263bea88fda146108d8578263c956570614610774578263ca46367314610567578263d27dd11e14610409578263d999984d14610396578263e29759121461024f57505063f2522bcd03610011577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261024c57610249610200612e51565b61022d600173ffffffffffffffffffffffffffffffffffffffff85541614156102276133a0565b906131f8565b610240610238613b6d565b6102276133d9565b60243590613931565b80f35b80fd5b91509160607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039257610284612e51565b60443567ffffffffffffffff811161038e576102a39036908501612c90565b939073ffffffffffffffffffffffffffffffffffffffff6102cd60018289541614156102276133a0565b6102d8610238613b6d565b807f000000000000000000000000000000000000000000000000000000000000000016916103068386613463565b823b1561038a57879461035e86928851998a97889687957fe0232b420000000000000000000000000000000000000000000000000000000087521690850152602435602485015260606044850152606484019161385f565b03925af190811561038157506103715750f35b61037a9061314d565b61024c5780f35b513d84823e3d90fd5b8780fd5b8480fd5b5050fd5b50823461040557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610405576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b5080fd5b839060607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261056357803561043f612eba565b91602073ffffffffffffffffffffffffffffffffffffffff61046a60018289541614156102276133a0565b610475610238613b6d565b60244785811090861802956104988787189761048f613412565b908814156131f8565b8683895196879586947fa1903eab00000000000000000000000000000000000000000000000000000000865216908401527f0000000000000000000000000000000000000000000000000000000000000000165af193841561055a57508493610520575b5061050d61051691610249946136b6565b916024356136b6565b111561022761367d565b92506020833d8211610552575b8161053a6020938361317d565b8101031261054d5791519161050d6104fc565b600080fd5b3d915061052d565b513d86823e3d90fd5b8280fd5b9150917ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36016101009081811261038e5760a01361076f5760a435926105ab612e74565b9060e43567ffffffffffffffff811161076b576105cb9036908301612c90565b73ffffffffffffffffffffffffffffffffffffffff926105f46001858b541614156102276133a0565b6105ff610238613b6d565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8489961698610639610630613702565b308c14156131f8565b146106d8575b61067461064a61373b565b947f0000000000000000000000000000000000000000000000000000000000000000168095613463565b833b156106d45761035e6106ba938a979388948a519b8c998a9889977f238d65790000000000000000000000000000000000000000000000000000000089528801613795565b60a487015260c486015260e485015261010484019161385f565b8880fd5b935060246020846106e761373b565b168851928380927f70a08231000000000000000000000000000000000000000000000000000000008252308a8301525afa90811561076157899161072d575b509361063f565b9850506020883d8211610759575b816107486020938361317d565b8101031261054d5788975138610726565b3d915061073b565b87513d8b823e3d90fd5b8680fd5b505050fd5b8382916020610782366130dd565b97909392919573ffffffffffffffffffffffffffffffffffffffff906107f3828454166107ba6107b06133a0565b60018314156131f8565b6107c5610238613b6d565b6107da6107d06135df565b858a1615156131f8565b838c16903082149182156108ce575b50506102276136c9565b6108066107fe613412565b8515156131f8565b61086789519a8b97889687947fb460af9400000000000000000000000000000000000000000000000000000000865285019160409194936060840195845273ffffffffffffffffffffffffffffffffffffffff809216602085015216910152565b0393165af19182156108c557508391610890575b610249925061088861367d565b9111156131f8565b90506020823d82116108bd575b816108aa6020938361317d565b8101031261054d5761024991519061087b565b3d915061089d565b513d85823e3d90fd5b1490508d806107e9565b83907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36016101208112610a6d5760a0136105635760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5c3601126105635761010480359283159384150361054d5773ffffffffffffffffffffffffffffffffffffffff61096f60018288541614156102276133a0565b61097a610238613b6d565b807f00000000000000000000000000000000000000000000000000000000000000001691823b1561076b5751937f8069218f000000000000000000000000000000000000000000000000000000008552816109d3612e51565b16908501526109e0612e97565b1660248401526109ee6130af565b151560448401526064356064840152608435608484015260a43560ff811680910361054d57859284848094829460a484015260c43560c484015260e43560e48401525af19182610a59575b5050610a5557610a47613294565b90610a50575080f35b613357565b5080f35b610a629061314d565b610563578284610a39565b8380fd5b8390602091827ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610a6d57813573ffffffffffffffffffffffffffffffffffffffff90610aca60018388541614156102276133a0565b610ad5610238613b6d565b8583517f70a0823100000000000000000000000000000000000000000000000000000000815230868201528681602481877f0000000000000000000000000000000000000000000000000000000000000000165afa908115610c21579082918895949391610beb575b5090818360249493109083180293610b60610b57613412565b868514156131f8565b865197889586947fea598cb000000000000000000000000000000000000000000000000000000000865218908401527f0000000000000000000000000000000000000000000000000000000000000000165af19081156108c55750610bc3578280f35b813d8311610be4575b610bd6818361317d565b8101031261054d5781808280f35b503d610bcc565b92948092508391503d8311610c1a575b610c05818361317d565b8101031261054d575185929087906024610b3e565b503d610bfb565b85513d84823e3d90fd5b612cbe565b9050610100367ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0181811261038e5760c013610a6d5760c43567ffffffffffffffff811161038e57610c859036908401612c90565b919060e4359485159586150361054d5773ffffffffffffffffffffffffffffffffffffffff9182885416610cba6107b06133a0565b610cc5610238613b6d565b6e22d473030f116ddee9f6b43ac78ba392833b15610db65751967f2b67b57000000000000000000000000000000000000000000000000000000000885287015282610d0e612e51565b1660248701526024358381168091036106d457604487015260443565ffffffffffff9081811680910361054d57606488015260643590811680910361054d57608487015260843592831680930361054d578786610d8a81959383988498849660a486015260a43560c486015260e485015261010484019161385f565b03925af19182610da2575050610a5557610a47613294565b610dab9061314d565b610563578238610a39565b8980fd5b8383602092837ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261054d57803567ffffffffffffffff9182821161054d573660238301121561054d578181013592602491818511610f3f57508360051b90855194610e2a8984018761317d565b855282888601928501019336851161054d57838101925b858410610ede5788600189610ed58a610ea88f7f616c726561647920696e697469617465640000000000000000000000000000008754955191610e8383613161565b601183528201528573ffffffffffffffffffffffffffffffffffffffff8616146131f8565b7fffffffffffffffffffffffff0000000000000000000000000000000000000000928316331785556132c4565b82541617815580f35b833583811161054d578201903660438301121561054d578582013590604492610f06836131be565b90610f138c51928361317d565b8382523685858301011161054d578d848196958296600094018386013783010152815201930192610e41565b604191507f4e487b7100000000000000000000000000000000000000000000000000000000600052526000fd5b919050610f78366130dd565b919492939073ffffffffffffffffffffffffffffffffffffffff8089541692610fac610fa26133a0565b60018614156131f8565b610fb7610238613b6d565b610fcc610fc26135df565b83851615156131f8565b610fe782861694308614908115611160575b506102276136c9565b168451927f70a0823100000000000000000000000000000000000000000000000000000000845288840152886020938481602481865afa90811561115657829161111f575b5098849392918a896110559c10908a180291828a189b8c9361104c613618565b908c14156131f8565b6110b68951988996879586947fba08765200000000000000000000000000000000000000000000000000000000865285019160409194936060840195845273ffffffffffffffffffffffffffffffffffffffff809216602085015216910152565b03925af1928315611116575086926110e2575b5050926110dc61051692610249956136b6565b926136b6565b9080959250813d831161110f575b6110fa818361317d565b8101031261054d5792516110dc6105166110c9565b503d6110f0565b513d88823e3d90fd5b8094939250858092503d831161114f575b61113a818361317d565b8101031261054d57915190919089908461102c565b503d611130565b87513d84823e3d90fd5b9050851438610fde565b91905060e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261056357826111a0612e51565b916111a96130cd565b926111b26130be565b9473ffffffffffffffffffffffffffffffffffffffff80855416926111d8610fa26133a0565b6111e3610238613b6d565b1690813b1561038e578460e49260ff82965198899687957fd505accf0000000000000000000000000000000000000000000000000000000087528601523060248601526024356044860152604435606486015216608484015260843560a484015260a43560c48401525af1918261126d575b5050610a5557611263613294565b9015610a50575080f35b6112769061314d565b610563578238611255565b80918460207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039257813573ffffffffffffffffffffffffffffffffffffffff6112d860018287541614156102276133a0565b6112e3610238613b6d565b4782811090831802906113006112f7613412565b838514156131f8565b7f00000000000000000000000000000000000000000000000000000000000000001693843b15611369578592845195869384927fd0e30db000000000000000000000000000000000000000000000000000000000845218905af190811561038157506103715750f35b8580fd5b9150918061137a3661304a565b919683959491986113e773ffffffffffffffffffffffffffffffffffffffff94858454166113a96107b06133a0565b6113b4610238613b6d565b88519b8c98899788967f5c2bea4900000000000000000000000000000000000000000000000000000000885287016138ea565b03927f0000000000000000000000000000000000000000000000000000000000000000165af192831561147a5785928694611447575b50501561143157506102499161088861367d565b90506102499161143f61367d565b9110156131f8565b809192945061146b9350903d10611473575b611463818361317d565b81019061377f565b91388061141d565b503d611459565b82513d87823e3d90fd5b905060e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261056357826114b96130af565b916114c26130cd565b906114cb6130be565b9473ffffffffffffffffffffffffffffffffffffffff8454166114ef6107b06133a0565b6114fa610238613b6d565b736b175474e89094c44da98b954eedeac495271d0f93843b1561136957859460ff86926101049551998a9788967f8fcbaf0c000000000000000000000000000000000000000000000000000000008852818801523060248801523560448701526024356064870152151560848601521660a484015260843560c484015260a43560e48401525af1918261126d575050610a5557611263613294565b9050817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610563576115c8612e51565b91602435908473ffffffffffffffffffffffffffffffffffffffff80825416956115fd6115f36133a0565b60018914156131f8565b611608610238613b6d565b16948251957f70a0823100000000000000000000000000000000000000000000000000000000875281868801526020948588602481855afa801561175c578697988597969791611721575b5091818386936064969510908218029061167761166e613412565b838314156131f8565b8851947f23b872dd0000000000000000000000000000000000000000000000000000000086528b8601523060248601521860448401525af13d15601f3d116001875114161716156116c6578380f35b6064935051917f08c379a0000000000000000000000000000000000000000000000000000000008352820152601460248201527f5452414e534645525f46524f4d5f4641494c45440000000000000000000000006044820152fd5b958092949395508691503d8311611755575b61173d818361317d565b8101031261054d579251859388939092909184611653565b503d611733565b85513d86823e3d90fd5b905061177136612f5e565b73ffffffffffffffffffffffffffffffffffffffff95929395949194906117a16001838a541614156102276133a0565b6117ac610238613b6d565b6117c16117b76135df565b83831615156131f8565b8187168451937f38d52e0f00000000000000000000000000000000000000000000000000000000855260209384868381865afa958615611903578b9661190d575b50846024918851928380927f70a0823100000000000000000000000000000000000000000000000000000000825230878301528a165afa908115611903579085949392918c916118d4575b5088811090891802958689189a8b97611864613412565b611870918c14156131f8565b61187991613463565b8a87518097819582947f6e553f650000000000000000000000000000000000000000000000000000000084528301916110b69290929173ffffffffffffffffffffffffffffffffffffffff6020916040840195845216910152565b85819692503d83116118fc575b6118eb818361317d565b8101031261054d578493513861184d565b503d6118e1565b87513d8d823e3d90fd5b60249196506119328691823d841161193a575b61192a818361317d565b810190613651565b969150611802565b503d611920565b905060c07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261056357611975612e51565b9161197e612e97565b92611987612eba565b9060843567ffffffffffffffff9586821161038a573660238301121561038a578186013596871161038a578660051b9336602486850101116106d45760a4359788159889150361054d5789927f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9273ffffffffffffffffffffffffffffffffffffffff98898093611a216001838a541614156102276133a0565b611a2c610238613b6d565b1690611a41611a396135df565b8315156131f8565b611a55611a4c613702565b308414156131f8565b519a7ffabed412000000000000000000000000000000000000000000000000000000008c528b01521660248901526064356044890152608060648901528060848901521161024c5760209460a4878681976024839701848401378101030193165af19081611acb575b50610a5557610a47613294565b602090813d8111611aef575b611ae1818361317d565b8101031261054d5738611abe565b503d611ad7565b91509180611b033661304a565b919683959491986113e773ffffffffffffffffffffffffffffffffffffffff9485845416611b326107b06133a0565b611b3d610238613b6d565b88519b8c98899788967f50d8cd4b00000000000000000000000000000000000000000000000000000000885287016138ea565b9050611b7b36612efe565b929173ffffffffffffffffffffffffffffffffffffffff90611ba660018389541614156102276133a0565b611bb1610238613b6d565b611bbc610fc26135df565b16908451917f70a082310000000000000000000000000000000000000000000000000000000083523084840152602094878685602481865afa8015611d5d5787958291611d2b575b508281109083180291611c21611c18613412565b848314156131f8565b611c7c8951978896879586947f205c2878000000000000000000000000000000000000000000000000000000008652189184016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03925af1908115611d1e5792610249938592611ccd575b507f7769746864726177206661696c65640000000000000000000000000000000000905192611cc184613161565b600f84528301526131f8565b7f7769746864726177206661696c65640000000000000000000000000000000000919250611d1090843d8611611d17575b611d08818361317d565b81019061344b565b9190611c93565b503d611cfe565b50505051903d90823e3d90fd5b958092508691503d8311611d56575b611d44818361317d565b8101031261054d578786945138611c04565b503d611d3a565b508751903d90823e3d90fd5b50503461040557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104055773ffffffffffffffffffffffffffffffffffffffff60209254169051908152f35b809184611dc636612fc2565b9073ffffffffffffffffffffffffffffffffffffffff99939998929596949895611df960018887541614156102276133a0565b611e04610238613b6d565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff88611e3c611e31613702565b308b861614156131f8565b14611f10575b88969492869492611eb792611e84611e5a8c9a61375e565b987f0000000000000000000000000000000000000000000000000000000000000000168099613463565b89519c8d998a9889977fa99aad89000000000000000000000000000000000000000000000000000000008952880161389e565b03925af192831561147a5785928694611eed575b505015611edf57506102499161143f61367d565b90506102499161088861367d565b8091929450611f089350903d1061147357611463818361317d565b918580611ecb565b94929095939160249a99989750602085611f298661375e565b1689519c8d80927f70a0823100000000000000000000000000000000000000000000000000000000825230878301525afa8015611fbb5788999a9b8499989991611f7f575b509794965092949193909291611e42565b97505091506020863d8211611fb3575b81611f9c6020938361317d565b8101031261054d57611eb78b928997519091611f6e565b3d9150611f8f565b88513d85823e3d90fd5b50503461040557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610405576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b8383807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261040557612067612e51565b906024359173ffffffffffffffffffffffffffffffffffffffff9081808654169161209d6120936133a0565b60018514156131f8565b6120a8610238613b6d565b1683517f70a082310000000000000000000000000000000000000000000000000000000081528288820152602081602481855afa80156121dc5787906121a9575b61210a9150868110908718029586811896612102613412565b9114156131f8565b8285116121815785966e22d473030f116ddee9f6b43ac78ba393843b1561038a57879460849386928851998a9788967f36c7851600000000000000000000000000000000000000000000000000000000885287015230602487015216604485015260648401525af190811561038157506103715750f35b8684517fc4bd89a9000000000000000000000000000000000000000000000000000000008152fd5b506020813d82116121d4575b816121c26020938361317d565b8101031261054d5761210a90516120e9565b3d91506121b5565b85513d89823e3d90fd5b8091846121f236612fc2565b9073ffffffffffffffffffffffffffffffffffffffff9993999892959694989561222560018887541614156102276133a0565b612230610238613b6d565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8861225d611e31613702565b146122ae575b88969492869492611eb79261227b611e5a8c9a61375e565b89519c8d998a9889977f20b76e81000000000000000000000000000000000000000000000000000000008952880161389e565b94929095939160249a999897506020856122c78661375e565b1689519c8d80927f70a0823100000000000000000000000000000000000000000000000000000000825230878301525afa8015611fbb5788999a9b849998999161231d575b509794965092949193909291612263565b97505091506020863d8211612351575b8161233a6020938361317d565b8101031261054d57611eb78b92899751909161230c565b3d915061232d565b50503461040557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610405576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b9190506123d436612f5e565b949092918673ffffffffffffffffffffffffffffffffffffffff61240160018284541614156102276133a0565b61240c610238613b6d565b6124216124176135df565b828a1615156131f8565b61243461242c613618565b8415156131f8565b8416928651947f38d52e0f00000000000000000000000000000000000000000000000000000000865260209586818481895afa9081156125505784926124e09b96949261248a928a999791612533575b50613463565b8851998a95869485937f94bf804d000000000000000000000000000000000000000000000000000000008552840190929173ffffffffffffffffffffffffffffffffffffffff6020916040840195845216910152565b03925af192831561055a57508492612501575b50610249925061088861367d565b90915082813d831161252c575b612518818361317d565b8101031261054d57610249915190386124f3565b503d61250e565b61254a9150893d8b1161193a5761192a818361317d565b38612484565b89513d86823e3d90fd5b8361024961256736612efe565b9161258f600173ffffffffffffffffffffffffffffffffffffffff87541614156102276133a0565b61259a610238613b6d565b6139f5565b80918460207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039257813573ffffffffffffffffffffffffffffffffffffffff6125f660018287541614156102276133a0565b612601610238613b6d565b7f00000000000000000000000000000000000000000000000000000000000000001682517f70a082310000000000000000000000000000000000000000000000000000000081523085820152602081602481855afa9081156126f95786916126c5575b5082811090831802906126786112f7613412565b803b1561136957859283602492865197889586947f2e1a7d4d00000000000000000000000000000000000000000000000000000000865218908401525af190811561038157506103715750f35b9550506020853d82116126f1575b816126e06020938361317d565b8101031261054d5785945187612664565b3d91506126d3565b84513d88823e3d90fd5b50503461040557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610405576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000168152f35b9050602091827ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610a6d57813573ffffffffffffffffffffffffffffffffffffffff6127ca60018288541614156102276133a0565b6127d5610238613b6d565b7f000000000000000000000000000000000000000000000000000000000000000016908583517f70a0823100000000000000000000000000000000000000000000000000000000815230868201528681602481875afa908115610c215790829188959493916128c1575b5090818360249493109083180293612858610b57613412565b865197889586947fde0e9a3e00000000000000000000000000000000000000000000000000000000865218908401525af19081156108c55750612899578280f35b813d83116128ba575b6128ac818361317d565b8101031261054d5738808280f35b503d6128a2565b92948092508391503d83116128f0575b6128db818361317d565b8101031261054d57518592908790602461283f565b503d6128d1565b9190507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360160e08112610a6d5760a0136105635782612935612e74565b73ffffffffffffffffffffffffffffffffffffffff808354169461296461295a6133a0565b60018814156131f8565b61296f610238613b6d565b817f00000000000000000000000000000000000000000000000000000000000000001692833b1561038e576129d5936101049386928851998a9788967f8720316d0000000000000000000000000000000000000000000000000000000088528701613795565b60a43560a487015260c48601521660e48401525af190811561038157506129fa575080f35b6102499061314d565b9050817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261056357612a36612e51565b906024359173ffffffffffffffffffffffffffffffffffffffff92612a6460018588541614156102276133a0565b612a6f610238613b6d565b8382168551947f6f307dc30000000000000000000000000000000000000000000000000000000086528760209687818881875afa8015612c865783918391612c4c575b5016918851957f70a0823100000000000000000000000000000000000000000000000000000000875230888801528887602481875afa8015612c425789978491612c0f575b50908187612b1e93109088180294612b19612b10613412565b878a14156131f8565b613463565b81541693612b7d8951978896879586947f2f4f21e2000000000000000000000000000000000000000000000000000000008652189184016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03925af1908115611d1e5792610249938592612bce575b507f6465706f736974206661696c6564000000000000000000000000000000000000905192612bc284613161565b600e84528301526131f8565b7f6465706f736974206661696c6564000000000000000000000000000000000000919250612c0890843d8611611d1757611d08818361317d565b9190612b94565b8881939992503d8311612c3b575b612c27818361317d565b810103126105635751889690612b1e612af7565b503d612c1d565b8a513d85823e3d90fd5b809250898092503d8311612c7f575b612c65818361317d565b810103126104055751828116810361040557829038612ab2565b503d612c5b565b89513d84823e3d90fd5b9181601f8401121561054d5782359167ffffffffffffffff831161054d576020838186019501011161054d57565b3461054d576040807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261054d5767ffffffffffffffff9060243582811161054d57612d10903690600401612c90565b612d5c612d1e9492946133d9565b73ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000001633146131f8565b830191602093848185031261054d5780359083821161054d57019183601f8401121561054d57823593818511612e22578460051b91835195612da08885018861317d565b865286808701938601019482861161054d57878101935b868510612dc75761001e886132c4565b843583811161054d57820184603f8201121561054d578981013591612deb836131be565b612df78951918261317d565b8381528689858501011161054d5760008c8581968c8397018386013783010152815201940193612db7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361054d57565b60c4359073ffffffffffffffffffffffffffffffffffffffff8216820361054d57565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361054d57565b6044359073ffffffffffffffffffffffffffffffffffffffff8216820361054d57565b359073ffffffffffffffffffffffffffffffffffffffff8216820361054d57565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc606091011261054d5773ffffffffffffffffffffffffffffffffffffffff90600435828116810361054d5791602435908116810361054d579060443590565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc608091011261054d5773ffffffffffffffffffffffffffffffffffffffff90600435828116810361054d57916024359160443591606435908116810361054d5790565b907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8201610140811261054d5760a01361054d5760049160a4359160c4359160e435916101043573ffffffffffffffffffffffffffffffffffffffff8116810361054d5791610124359067ffffffffffffffff821161054d57613046918801612c90565b9091565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc01610120811261054d5760a01361054d5760049060a4359060c4359060e435906101043573ffffffffffffffffffffffffffffffffffffffff8116810361054d5790565b60443590811515820361054d57565b60c43590811515820361054d57565b6064359060ff8216820361054d57565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc60a091011261054d5773ffffffffffffffffffffffffffffffffffffffff600435818116810361054d57916024359160443591606435828116810361054d5791608435908116810361054d5790565b67ffffffffffffffff8111612e2257604052565b6040810190811067ffffffffffffffff821117612e2257604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117612e2257604052565b67ffffffffffffffff8111612e2257601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b156132005750565b604051907f08c379a000000000000000000000000000000000000000000000000000000000825281602080600483015282519283602484015260005b84811061327d575050507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f836000604480968601015201168101030190fd5b81810183015186820160440152859350820161323c565b3d156132bf573d906132a5826131be565b916132b3604051938461317d565b82523d6000602084013e565b606090565b60005b8151811015613353576000806020808460051b860101519081519101305af46132ee613294565b9015610a5057507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114613324576001016132c7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5050565b80519061339b60405161336981613161565b600b81527f63616c6c206661696c656400000000000000000000000000000000000000000060208201528315156131f8565b602001fd5b604051906133ad82613161565b600b82527f756e696e697469617465640000000000000000000000000000000000000000006020830152565b604051906133e682613161565b601382527f756e617574686f72697a65642073656e646572000000000000000000000000006020830152565b6040519061341f82613161565b600b82527f7a65726f20616d6f756e740000000000000000000000000000000000000000006020830152565b9081602091031261054d5751801515810361054d5790565b73ffffffffffffffffffffffffffffffffffffffff80911690604051927fdd62ed3e000000000000000000000000000000000000000000000000000000008452306004850152168060248401526020928381604481865afa9081156135d3576000916135a6575b50156134d557505050565b6044600091828594604051927f095ea7b300000000000000000000000000000000000000000000000000000000845260048401527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60248401525af13d15601f3d11600160005114161716156135485750565b606490604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152600e60248201527f415050524f56455f4641494c45440000000000000000000000000000000000006044820152fd5b908482813d83116135cc575b6135bc818361317d565b8101031261024c575051386134ca565b503d6135b2565b6040513d6000823e3d90fd5b604051906135ec82613161565b600c82527f7a65726f206164647265737300000000000000000000000000000000000000006020830152565b6040519061362582613161565b600b82527f7a65726f207368617265730000000000000000000000000000000000000000006020830152565b9081602091031261054d575173ffffffffffffffffffffffffffffffffffffffff8116810361054d5790565b6040519061368a82613161565b601182527f736c6970706167652065786365656465640000000000000000000000000000006020830152565b8181029291811591840414171561332457565b604051906136d682613161565b601082527f756e6578706563746564206f776e6572000000000000000000000000000000006020830152565b6040519061370f82613161565b600f82527f62756e646c6572206164647265737300000000000000000000000000000000006020830152565b60243573ffffffffffffffffffffffffffffffffffffffff8116810361054d5790565b3573ffffffffffffffffffffffffffffffffffffffff8116810361054d5790565b919082604091031261054d576020825192015190565b60043573ffffffffffffffffffffffffffffffffffffffff9081811680910361054d57825260243581811680910361054d57602083015260443581811680910361054d57604083015260643590811680910361054d5760608201526080608435910152565b6080809173ffffffffffffffffffffffffffffffffffffffff8061381d83612edd565b1685528061382d60208401612edd565b1660208601528061384060408401612edd565b16604086015261385260608301612edd565b1660608501520135910152565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0938186528686013760008582860101520116010190565b919373ffffffffffffffffffffffffffffffffffffffff91936138e797956138c985610120976137fa565b60a085015260c08401521660e082015281610100820152019161385f565b90565b9391926101009396959196613904866101208101996137fa565b60a086015260c085015273ffffffffffffffffffffffffffffffffffffffff80921660e085015216910152565b61396f73ffffffffffffffffffffffffffffffffffffffff821661395e6139566135df565b8215156131f8565b613966613702565b903014156131f8565b47828110908318028083146139f05760009283928392839218905af11561399257565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4554485f5452414e534645525f4641494c4544000000000000000000000000006044820152fd5b505050565b919073ffffffffffffffffffffffffffffffffffffffff80911692613a1b6107fe6135df565b613a2f613a26613702565b308614156131f8565b16604051927f70a082310000000000000000000000000000000000000000000000000000000084523060048501526020938481602481865afa9081156135d357600091613b40575b508381109084180290818414613b3957600080936044938796604051947fa9059cbb00000000000000000000000000000000000000000000000000000000865260048601521860248401525af13d15601f3d1160016000511416171615613adb5750565b606490604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152600f60248201527f5452414e534645525f4641494c454400000000000000000000000000000000006044820152fd5b5050505050565b908582813d8311613b66575b613b56818361317d565b8101031261024c57505138613a77565b503d613b4c565b73ffffffffffffffffffffffffffffffffffffffff80600054163314908115613b94575090565b90507f00000000000000000000000000000000000000000000000000000000000000001633149056fea2646970667358221220611f1f5cdac39e68bbfbae326a8e21e85561cf3f4a4007db5dee8df8e90193cf64736f6c63430008150033000000000000000000000000bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb

Deployed Bytecode

0x60406080815260049081361015610020575b5050361561001e57600080fd5b005b600091823560e01c90816305b4591c14610c2b57816312c0d70b14612a035781631af3bbc6146128f75781632075be0314610c2b578163240f78a31461277257816331f5707214610c2b578163338346d2146127035783826334b10a6d1461259f575081633790767d1461255a57816339029ab6146123c85781633acb562414612359578382634d5fcf68146121e65750816354c53ef0146120345781635664cb4814611fc5578382635b866db614611dba575081635c39fcc114611d695781636024440814611b705783826362577ad014611af6575081636b89026a146119415781636ef5eeae1461176657816370dc41fe146115955781637336bc6a146114845783826384d287ef1461136d5782639169d8331461128157508163a184a5a31461116a578163a7f6e60614610f6c578163ac9650d814610dba578163af50420214610c30578163b1022fdf14610c2b5783908263bc2a294c14610a71578263bea88fda146108d8578263c956570614610774578263ca46367314610567578263d27dd11e14610409578263d999984d14610396578263e29759121461024f57505063f2522bcd03610011577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261024c57610249610200612e51565b61022d600173ffffffffffffffffffffffffffffffffffffffff85541614156102276133a0565b906131f8565b610240610238613b6d565b6102276133d9565b60243590613931565b80f35b80fd5b91509160607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039257610284612e51565b60443567ffffffffffffffff811161038e576102a39036908501612c90565b939073ffffffffffffffffffffffffffffffffffffffff6102cd60018289541614156102276133a0565b6102d8610238613b6d565b807f000000000000000000000000bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb16916103068386613463565b823b1561038a57879461035e86928851998a97889687957fe0232b420000000000000000000000000000000000000000000000000000000087521690850152602435602485015260606044850152606484019161385f565b03925af190811561038157506103715750f35b61037a9061314d565b61024c5780f35b513d84823e3d90fd5b8780fd5b8480fd5b5050fd5b50823461040557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610405576020905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2168152f35b5080fd5b839060607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261056357803561043f612eba565b91602073ffffffffffffffffffffffffffffffffffffffff61046a60018289541614156102276133a0565b610475610238613b6d565b60244785811090861802956104988787189761048f613412565b908814156131f8565b8683895196879586947fa1903eab00000000000000000000000000000000000000000000000000000000865216908401527f000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe84165af193841561055a57508493610520575b5061050d61051691610249946136b6565b916024356136b6565b111561022761367d565b92506020833d8211610552575b8161053a6020938361317d565b8101031261054d5791519161050d6104fc565b600080fd5b3d915061052d565b513d86823e3d90fd5b8280fd5b9150917ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36016101009081811261038e5760a01361076f5760a435926105ab612e74565b9060e43567ffffffffffffffff811161076b576105cb9036908301612c90565b73ffffffffffffffffffffffffffffffffffffffff926105f46001858b541614156102276133a0565b6105ff610238613b6d565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8489961698610639610630613702565b308c14156131f8565b146106d8575b61067461064a61373b565b947f000000000000000000000000bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb168095613463565b833b156106d45761035e6106ba938a979388948a519b8c998a9889977f238d65790000000000000000000000000000000000000000000000000000000089528801613795565b60a487015260c486015260e485015261010484019161385f565b8880fd5b935060246020846106e761373b565b168851928380927f70a08231000000000000000000000000000000000000000000000000000000008252308a8301525afa90811561076157899161072d575b509361063f565b9850506020883d8211610759575b816107486020938361317d565b8101031261054d5788975138610726565b3d915061073b565b87513d8b823e3d90fd5b8680fd5b505050fd5b8382916020610782366130dd565b97909392919573ffffffffffffffffffffffffffffffffffffffff906107f3828454166107ba6107b06133a0565b60018314156131f8565b6107c5610238613b6d565b6107da6107d06135df565b858a1615156131f8565b838c16903082149182156108ce575b50506102276136c9565b6108066107fe613412565b8515156131f8565b61086789519a8b97889687947fb460af9400000000000000000000000000000000000000000000000000000000865285019160409194936060840195845273ffffffffffffffffffffffffffffffffffffffff809216602085015216910152565b0393165af19182156108c557508391610890575b610249925061088861367d565b9111156131f8565b90506020823d82116108bd575b816108aa6020938361317d565b8101031261054d5761024991519061087b565b3d915061089d565b513d85823e3d90fd5b1490508d806107e9565b83907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36016101208112610a6d5760a0136105635760607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5c3601126105635761010480359283159384150361054d5773ffffffffffffffffffffffffffffffffffffffff61096f60018288541614156102276133a0565b61097a610238613b6d565b807f000000000000000000000000bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb1691823b1561076b5751937f8069218f000000000000000000000000000000000000000000000000000000008552816109d3612e51565b16908501526109e0612e97565b1660248401526109ee6130af565b151560448401526064356064840152608435608484015260a43560ff811680910361054d57859284848094829460a484015260c43560c484015260e43560e48401525af19182610a59575b5050610a5557610a47613294565b90610a50575080f35b613357565b5080f35b610a629061314d565b610563578284610a39565b8380fd5b8390602091827ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610a6d57813573ffffffffffffffffffffffffffffffffffffffff90610aca60018388541614156102276133a0565b610ad5610238613b6d565b8583517f70a0823100000000000000000000000000000000000000000000000000000000815230868201528681602481877f000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe84165afa908115610c21579082918895949391610beb575b5090818360249493109083180293610b60610b57613412565b868514156131f8565b865197889586947fea598cb000000000000000000000000000000000000000000000000000000000865218908401527f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0165af19081156108c55750610bc3578280f35b813d8311610be4575b610bd6818361317d565b8101031261054d5781808280f35b503d610bcc565b92948092508391503d8311610c1a575b610c05818361317d565b8101031261054d575185929087906024610b3e565b503d610bfb565b85513d84823e3d90fd5b612cbe565b9050610100367ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0181811261038e5760c013610a6d5760c43567ffffffffffffffff811161038e57610c859036908401612c90565b919060e4359485159586150361054d5773ffffffffffffffffffffffffffffffffffffffff9182885416610cba6107b06133a0565b610cc5610238613b6d565b6e22d473030f116ddee9f6b43ac78ba392833b15610db65751967f2b67b57000000000000000000000000000000000000000000000000000000000885287015282610d0e612e51565b1660248701526024358381168091036106d457604487015260443565ffffffffffff9081811680910361054d57606488015260643590811680910361054d57608487015260843592831680930361054d578786610d8a81959383988498849660a486015260a43560c486015260e485015261010484019161385f565b03925af19182610da2575050610a5557610a47613294565b610dab9061314d565b610563578238610a39565b8980fd5b8383602092837ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261054d57803567ffffffffffffffff9182821161054d573660238301121561054d578181013592602491818511610f3f57508360051b90855194610e2a8984018761317d565b855282888601928501019336851161054d57838101925b858410610ede5788600189610ed58a610ea88f7f616c726561647920696e697469617465640000000000000000000000000000008754955191610e8383613161565b601183528201528573ffffffffffffffffffffffffffffffffffffffff8616146131f8565b7fffffffffffffffffffffffff0000000000000000000000000000000000000000928316331785556132c4565b82541617815580f35b833583811161054d578201903660438301121561054d578582013590604492610f06836131be565b90610f138c51928361317d565b8382523685858301011161054d578d848196958296600094018386013783010152815201930192610e41565b604191507f4e487b7100000000000000000000000000000000000000000000000000000000600052526000fd5b919050610f78366130dd565b919492939073ffffffffffffffffffffffffffffffffffffffff8089541692610fac610fa26133a0565b60018614156131f8565b610fb7610238613b6d565b610fcc610fc26135df565b83851615156131f8565b610fe782861694308614908115611160575b506102276136c9565b168451927f70a0823100000000000000000000000000000000000000000000000000000000845288840152886020938481602481865afa90811561115657829161111f575b5098849392918a896110559c10908a180291828a189b8c9361104c613618565b908c14156131f8565b6110b68951988996879586947fba08765200000000000000000000000000000000000000000000000000000000865285019160409194936060840195845273ffffffffffffffffffffffffffffffffffffffff809216602085015216910152565b03925af1928315611116575086926110e2575b5050926110dc61051692610249956136b6565b926136b6565b9080959250813d831161110f575b6110fa818361317d565b8101031261054d5792516110dc6105166110c9565b503d6110f0565b513d88823e3d90fd5b8094939250858092503d831161114f575b61113a818361317d565b8101031261054d57915190919089908461102c565b503d611130565b87513d84823e3d90fd5b9050851438610fde565b91905060e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261056357826111a0612e51565b916111a96130cd565b926111b26130be565b9473ffffffffffffffffffffffffffffffffffffffff80855416926111d8610fa26133a0565b6111e3610238613b6d565b1690813b1561038e578460e49260ff82965198899687957fd505accf0000000000000000000000000000000000000000000000000000000087528601523060248601526024356044860152604435606486015216608484015260843560a484015260a43560c48401525af1918261126d575b5050610a5557611263613294565b9015610a50575080f35b6112769061314d565b610563578238611255565b80918460207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039257813573ffffffffffffffffffffffffffffffffffffffff6112d860018287541614156102276133a0565b6112e3610238613b6d565b4782811090831802906113006112f7613412565b838514156131f8565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21693843b15611369578592845195869384927fd0e30db000000000000000000000000000000000000000000000000000000000845218905af190811561038157506103715750f35b8580fd5b9150918061137a3661304a565b919683959491986113e773ffffffffffffffffffffffffffffffffffffffff94858454166113a96107b06133a0565b6113b4610238613b6d565b88519b8c98899788967f5c2bea4900000000000000000000000000000000000000000000000000000000885287016138ea565b03927f000000000000000000000000bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb165af192831561147a5785928694611447575b50501561143157506102499161088861367d565b90506102499161143f61367d565b9110156131f8565b809192945061146b9350903d10611473575b611463818361317d565b81019061377f565b91388061141d565b503d611459565b82513d87823e3d90fd5b905060e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261056357826114b96130af565b916114c26130cd565b906114cb6130be565b9473ffffffffffffffffffffffffffffffffffffffff8454166114ef6107b06133a0565b6114fa610238613b6d565b736b175474e89094c44da98b954eedeac495271d0f93843b1561136957859460ff86926101049551998a9788967f8fcbaf0c000000000000000000000000000000000000000000000000000000008852818801523060248801523560448701526024356064870152151560848601521660a484015260843560c484015260a43560e48401525af1918261126d575050610a5557611263613294565b9050817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610563576115c8612e51565b91602435908473ffffffffffffffffffffffffffffffffffffffff80825416956115fd6115f36133a0565b60018914156131f8565b611608610238613b6d565b16948251957f70a0823100000000000000000000000000000000000000000000000000000000875281868801526020948588602481855afa801561175c578697988597969791611721575b5091818386936064969510908218029061167761166e613412565b838314156131f8565b8851947f23b872dd0000000000000000000000000000000000000000000000000000000086528b8601523060248601521860448401525af13d15601f3d116001875114161716156116c6578380f35b6064935051917f08c379a0000000000000000000000000000000000000000000000000000000008352820152601460248201527f5452414e534645525f46524f4d5f4641494c45440000000000000000000000006044820152fd5b958092949395508691503d8311611755575b61173d818361317d565b8101031261054d579251859388939092909184611653565b503d611733565b85513d86823e3d90fd5b905061177136612f5e565b73ffffffffffffffffffffffffffffffffffffffff95929395949194906117a16001838a541614156102276133a0565b6117ac610238613b6d565b6117c16117b76135df565b83831615156131f8565b8187168451937f38d52e0f00000000000000000000000000000000000000000000000000000000855260209384868381865afa958615611903578b9661190d575b50846024918851928380927f70a0823100000000000000000000000000000000000000000000000000000000825230878301528a165afa908115611903579085949392918c916118d4575b5088811090891802958689189a8b97611864613412565b611870918c14156131f8565b61187991613463565b8a87518097819582947f6e553f650000000000000000000000000000000000000000000000000000000084528301916110b69290929173ffffffffffffffffffffffffffffffffffffffff6020916040840195845216910152565b85819692503d83116118fc575b6118eb818361317d565b8101031261054d578493513861184d565b503d6118e1565b87513d8d823e3d90fd5b60249196506119328691823d841161193a575b61192a818361317d565b810190613651565b969150611802565b503d611920565b905060c07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261056357611975612e51565b9161197e612e97565b92611987612eba565b9060843567ffffffffffffffff9586821161038a573660238301121561038a578186013596871161038a578660051b9336602486850101116106d45760a4359788159889150361054d5789927f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9273ffffffffffffffffffffffffffffffffffffffff98898093611a216001838a541614156102276133a0565b611a2c610238613b6d565b1690611a41611a396135df565b8315156131f8565b611a55611a4c613702565b308414156131f8565b519a7ffabed412000000000000000000000000000000000000000000000000000000008c528b01521660248901526064356044890152608060648901528060848901521161024c5760209460a4878681976024839701848401378101030193165af19081611acb575b50610a5557610a47613294565b602090813d8111611aef575b611ae1818361317d565b8101031261054d5738611abe565b503d611ad7565b91509180611b033661304a565b919683959491986113e773ffffffffffffffffffffffffffffffffffffffff9485845416611b326107b06133a0565b611b3d610238613b6d565b88519b8c98899788967f50d8cd4b00000000000000000000000000000000000000000000000000000000885287016138ea565b9050611b7b36612efe565b929173ffffffffffffffffffffffffffffffffffffffff90611ba660018389541614156102276133a0565b611bb1610238613b6d565b611bbc610fc26135df565b16908451917f70a082310000000000000000000000000000000000000000000000000000000083523084840152602094878685602481865afa8015611d5d5787958291611d2b575b508281109083180291611c21611c18613412565b848314156131f8565b611c7c8951978896879586947f205c2878000000000000000000000000000000000000000000000000000000008652189184016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03925af1908115611d1e5792610249938592611ccd575b507f7769746864726177206661696c65640000000000000000000000000000000000905192611cc184613161565b600f84528301526131f8565b7f7769746864726177206661696c65640000000000000000000000000000000000919250611d1090843d8611611d17575b611d08818361317d565b81019061344b565b9190611c93565b503d611cfe565b50505051903d90823e3d90fd5b958092508691503d8311611d56575b611d44818361317d565b8101031261054d578786945138611c04565b503d611d3a565b508751903d90823e3d90fd5b50503461040557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126104055773ffffffffffffffffffffffffffffffffffffffff60209254169051908152f35b809184611dc636612fc2565b9073ffffffffffffffffffffffffffffffffffffffff99939998929596949895611df960018887541614156102276133a0565b611e04610238613b6d565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff88611e3c611e31613702565b308b861614156131f8565b14611f10575b88969492869492611eb792611e84611e5a8c9a61375e565b987f000000000000000000000000bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb168099613463565b89519c8d998a9889977fa99aad89000000000000000000000000000000000000000000000000000000008952880161389e565b03925af192831561147a5785928694611eed575b505015611edf57506102499161143f61367d565b90506102499161088861367d565b8091929450611f089350903d1061147357611463818361317d565b918580611ecb565b94929095939160249a99989750602085611f298661375e565b1689519c8d80927f70a0823100000000000000000000000000000000000000000000000000000000825230878301525afa8015611fbb5788999a9b8499989991611f7f575b509794965092949193909291611e42565b97505091506020863d8211611fb3575b81611f9c6020938361317d565b8101031261054d57611eb78b928997519091611f6e565b3d9150611f8f565b88513d85823e3d90fd5b50503461040557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610405576020905173ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca0168152f35b8383807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261040557612067612e51565b906024359173ffffffffffffffffffffffffffffffffffffffff9081808654169161209d6120936133a0565b60018514156131f8565b6120a8610238613b6d565b1683517f70a082310000000000000000000000000000000000000000000000000000000081528288820152602081602481855afa80156121dc5787906121a9575b61210a9150868110908718029586811896612102613412565b9114156131f8565b8285116121815785966e22d473030f116ddee9f6b43ac78ba393843b1561038a57879460849386928851998a9788967f36c7851600000000000000000000000000000000000000000000000000000000885287015230602487015216604485015260648401525af190811561038157506103715750f35b8684517fc4bd89a9000000000000000000000000000000000000000000000000000000008152fd5b506020813d82116121d4575b816121c26020938361317d565b8101031261054d5761210a90516120e9565b3d91506121b5565b85513d89823e3d90fd5b8091846121f236612fc2565b9073ffffffffffffffffffffffffffffffffffffffff9993999892959694989561222560018887541614156102276133a0565b612230610238613b6d565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8861225d611e31613702565b146122ae575b88969492869492611eb79261227b611e5a8c9a61375e565b89519c8d998a9889977f20b76e81000000000000000000000000000000000000000000000000000000008952880161389e565b94929095939160249a999897506020856122c78661375e565b1689519c8d80927f70a0823100000000000000000000000000000000000000000000000000000000825230878301525afa8015611fbb5788999a9b849998999161231d575b509794965092949193909291612263565b97505091506020863d8211612351575b8161233a6020938361317d565b8101031261054d57611eb78b92899751909161230c565b3d915061232d565b50503461040557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610405576020905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb168152f35b9190506123d436612f5e565b949092918673ffffffffffffffffffffffffffffffffffffffff61240160018284541614156102276133a0565b61240c610238613b6d565b6124216124176135df565b828a1615156131f8565b61243461242c613618565b8415156131f8565b8416928651947f38d52e0f00000000000000000000000000000000000000000000000000000000865260209586818481895afa9081156125505784926124e09b96949261248a928a999791612533575b50613463565b8851998a95869485937f94bf804d000000000000000000000000000000000000000000000000000000008552840190929173ffffffffffffffffffffffffffffffffffffffff6020916040840195845216910152565b03925af192831561055a57508492612501575b50610249925061088861367d565b90915082813d831161252c575b612518818361317d565b8101031261054d57610249915190386124f3565b503d61250e565b61254a9150893d8b1161193a5761192a818361317d565b38612484565b89513d86823e3d90fd5b8361024961256736612efe565b9161258f600173ffffffffffffffffffffffffffffffffffffffff87541614156102276133a0565b61259a610238613b6d565b6139f5565b80918460207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261039257813573ffffffffffffffffffffffffffffffffffffffff6125f660018287541614156102276133a0565b612601610238613b6d565b7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc21682517f70a082310000000000000000000000000000000000000000000000000000000081523085820152602081602481855afa9081156126f95786916126c5575b5082811090831802906126786112f7613412565b803b1561136957859283602492865197889586947f2e1a7d4d00000000000000000000000000000000000000000000000000000000865218908401525af190811561038157506103715750f35b9550506020853d82116126f1575b816126e06020938361317d565b8101031261054d5785945187612664565b3d91506126d3565b84513d88823e3d90fd5b50503461040557817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610405576020905173ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ae7ab96520de3a18e5e111b5eaab095312d7fe84168152f35b9050602091827ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610a6d57813573ffffffffffffffffffffffffffffffffffffffff6127ca60018288541614156102276133a0565b6127d5610238613b6d565b7f0000000000000000000000007f39c581f595b53c5cb19bd0b3f8da6c935e2ca016908583517f70a0823100000000000000000000000000000000000000000000000000000000815230868201528681602481875afa908115610c215790829188959493916128c1575b5090818360249493109083180293612858610b57613412565b865197889586947fde0e9a3e00000000000000000000000000000000000000000000000000000000865218908401525af19081156108c55750612899578280f35b813d83116128ba575b6128ac818361317d565b8101031261054d5738808280f35b503d6128a2565b92948092508391503d83116128f0575b6128db818361317d565b8101031261054d57518592908790602461283f565b503d6128d1565b9190507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360160e08112610a6d5760a0136105635782612935612e74565b73ffffffffffffffffffffffffffffffffffffffff808354169461296461295a6133a0565b60018814156131f8565b61296f610238613b6d565b817f000000000000000000000000bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb1692833b1561038e576129d5936101049386928851998a9788967f8720316d0000000000000000000000000000000000000000000000000000000088528701613795565b60a43560a487015260c48601521660e48401525af190811561038157506129fa575080f35b6102499061314d565b9050817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261056357612a36612e51565b906024359173ffffffffffffffffffffffffffffffffffffffff92612a6460018588541614156102276133a0565b612a6f610238613b6d565b8382168551947f6f307dc30000000000000000000000000000000000000000000000000000000086528760209687818881875afa8015612c865783918391612c4c575b5016918851957f70a0823100000000000000000000000000000000000000000000000000000000875230888801528887602481875afa8015612c425789978491612c0f575b50908187612b1e93109088180294612b19612b10613412565b878a14156131f8565b613463565b81541693612b7d8951978896879586947f2f4f21e2000000000000000000000000000000000000000000000000000000008652189184016020909392919373ffffffffffffffffffffffffffffffffffffffff60408201951681520152565b03925af1908115611d1e5792610249938592612bce575b507f6465706f736974206661696c6564000000000000000000000000000000000000905192612bc284613161565b600e84528301526131f8565b7f6465706f736974206661696c6564000000000000000000000000000000000000919250612c0890843d8611611d1757611d08818361317d565b9190612b94565b8881939992503d8311612c3b575b612c27818361317d565b810103126105635751889690612b1e612af7565b503d612c1d565b8a513d85823e3d90fd5b809250898092503d8311612c7f575b612c65818361317d565b810103126104055751828116810361040557829038612ab2565b503d612c5b565b89513d84823e3d90fd5b9181601f8401121561054d5782359167ffffffffffffffff831161054d576020838186019501011161054d57565b3461054d576040807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261054d5767ffffffffffffffff9060243582811161054d57612d10903690600401612c90565b612d5c612d1e9492946133d9565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb1633146131f8565b830191602093848185031261054d5780359083821161054d57019183601f8401121561054d57823593818511612e22578460051b91835195612da08885018861317d565b865286808701938601019482861161054d57878101935b868510612dc75761001e886132c4565b843583811161054d57820184603f8201121561054d578981013591612deb836131be565b612df78951918261317d565b8381528689858501011161054d5760008c8581968c8397018386013783010152815201940193612db7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361054d57565b60c4359073ffffffffffffffffffffffffffffffffffffffff8216820361054d57565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361054d57565b6044359073ffffffffffffffffffffffffffffffffffffffff8216820361054d57565b359073ffffffffffffffffffffffffffffffffffffffff8216820361054d57565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc606091011261054d5773ffffffffffffffffffffffffffffffffffffffff90600435828116810361054d5791602435908116810361054d579060443590565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc608091011261054d5773ffffffffffffffffffffffffffffffffffffffff90600435828116810361054d57916024359160443591606435908116810361054d5790565b907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8201610140811261054d5760a01361054d5760049160a4359160c4359160e435916101043573ffffffffffffffffffffffffffffffffffffffff8116810361054d5791610124359067ffffffffffffffff821161054d57613046918801612c90565b9091565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc01610120811261054d5760a01361054d5760049060a4359060c4359060e435906101043573ffffffffffffffffffffffffffffffffffffffff8116810361054d5790565b60443590811515820361054d57565b60c43590811515820361054d57565b6064359060ff8216820361054d57565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc60a091011261054d5773ffffffffffffffffffffffffffffffffffffffff600435818116810361054d57916024359160443591606435828116810361054d5791608435908116810361054d5790565b67ffffffffffffffff8111612e2257604052565b6040810190811067ffffffffffffffff821117612e2257604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117612e2257604052565b67ffffffffffffffff8111612e2257601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b156132005750565b604051907f08c379a000000000000000000000000000000000000000000000000000000000825281602080600483015282519283602484015260005b84811061327d575050507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f836000604480968601015201168101030190fd5b81810183015186820160440152859350820161323c565b3d156132bf573d906132a5826131be565b916132b3604051938461317d565b82523d6000602084013e565b606090565b60005b8151811015613353576000806020808460051b860101519081519101305af46132ee613294565b9015610a5057507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114613324576001016132c7565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b5050565b80519061339b60405161336981613161565b600b81527f63616c6c206661696c656400000000000000000000000000000000000000000060208201528315156131f8565b602001fd5b604051906133ad82613161565b600b82527f756e696e697469617465640000000000000000000000000000000000000000006020830152565b604051906133e682613161565b601382527f756e617574686f72697a65642073656e646572000000000000000000000000006020830152565b6040519061341f82613161565b600b82527f7a65726f20616d6f756e740000000000000000000000000000000000000000006020830152565b9081602091031261054d5751801515810361054d5790565b73ffffffffffffffffffffffffffffffffffffffff80911690604051927fdd62ed3e000000000000000000000000000000000000000000000000000000008452306004850152168060248401526020928381604481865afa9081156135d3576000916135a6575b50156134d557505050565b6044600091828594604051927f095ea7b300000000000000000000000000000000000000000000000000000000845260048401527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60248401525af13d15601f3d11600160005114161716156135485750565b606490604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152600e60248201527f415050524f56455f4641494c45440000000000000000000000000000000000006044820152fd5b908482813d83116135cc575b6135bc818361317d565b8101031261024c575051386134ca565b503d6135b2565b6040513d6000823e3d90fd5b604051906135ec82613161565b600c82527f7a65726f206164647265737300000000000000000000000000000000000000006020830152565b6040519061362582613161565b600b82527f7a65726f207368617265730000000000000000000000000000000000000000006020830152565b9081602091031261054d575173ffffffffffffffffffffffffffffffffffffffff8116810361054d5790565b6040519061368a82613161565b601182527f736c6970706167652065786365656465640000000000000000000000000000006020830152565b8181029291811591840414171561332457565b604051906136d682613161565b601082527f756e6578706563746564206f776e6572000000000000000000000000000000006020830152565b6040519061370f82613161565b600f82527f62756e646c6572206164647265737300000000000000000000000000000000006020830152565b60243573ffffffffffffffffffffffffffffffffffffffff8116810361054d5790565b3573ffffffffffffffffffffffffffffffffffffffff8116810361054d5790565b919082604091031261054d576020825192015190565b60043573ffffffffffffffffffffffffffffffffffffffff9081811680910361054d57825260243581811680910361054d57602083015260443581811680910361054d57604083015260643590811680910361054d5760608201526080608435910152565b6080809173ffffffffffffffffffffffffffffffffffffffff8061381d83612edd565b1685528061382d60208401612edd565b1660208601528061384060408401612edd565b16604086015261385260608301612edd565b1660608501520135910152565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0938186528686013760008582860101520116010190565b919373ffffffffffffffffffffffffffffffffffffffff91936138e797956138c985610120976137fa565b60a085015260c08401521660e082015281610100820152019161385f565b90565b9391926101009396959196613904866101208101996137fa565b60a086015260c085015273ffffffffffffffffffffffffffffffffffffffff80921660e085015216910152565b61396f73ffffffffffffffffffffffffffffffffffffffff821661395e6139566135df565b8215156131f8565b613966613702565b903014156131f8565b47828110908318028083146139f05760009283928392839218905af11561399257565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f4554485f5452414e534645525f4641494c4544000000000000000000000000006044820152fd5b505050565b919073ffffffffffffffffffffffffffffffffffffffff80911692613a1b6107fe6135df565b613a2f613a26613702565b308614156131f8565b16604051927f70a082310000000000000000000000000000000000000000000000000000000084523060048501526020938481602481865afa9081156135d357600091613b40575b508381109084180290818414613b3957600080936044938796604051947fa9059cbb00000000000000000000000000000000000000000000000000000000865260048601521860248401525af13d15601f3d1160016000511416171615613adb5750565b606490604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152600f60248201527f5452414e534645525f4641494c454400000000000000000000000000000000006044820152fd5b5050505050565b908582813d8311613b66575b613b56818361317d565b8101031261024c57505138613a77565b503d613b4c565b73ffffffffffffffffffffffffffffffffffffffff80600054163314908115613b94575090565b90507f000000000000000000000000bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb1633149056fea2646970667358221220611f1f5cdac39e68bbfbae326a8e21e85561cf3f4a4007db5dee8df8e90193cf64736f6c63430008150033

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

000000000000000000000000bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb

-----Decoded View---------------
Arg [0] : morpho (address): 0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000bbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb


Block Transaction Difficulty 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
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.