ETH Price: $1,791.38 (+10.04%)

Contract

0x214d40dc973802859afcDa42333bA98Fa78e4E4a
 

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MoneyMarketHook

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 30 : MoneyMarketHook.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

import '../common/library/InitErrors.sol';
import '../common/library/UncheckedIncrement.sol';
import {UnderACM} from '../common/UnderACM.sol';
import {IInitCore} from '../interfaces/core/IInitCore.sol';
import {IMulticall} from '../interfaces/common/IMulticall.sol';
import {IPosManager} from '../interfaces/core/IPosManager.sol';
import {ILendingPool} from '../interfaces/lending_pool/ILendingPool.sol';
import {IWWETH, IERC20RebasingWrapper} from '../interfaces/wrapper/blast/IWWETH.sol';
import {IRebaseHelper} from '../interfaces/helper/rebase_helper/IRebaseHelper.sol';
import {IMoneyMarketHook} from '../interfaces/hook/IMoneyMarketHook.sol';

import {IERC20} from '@openzeppelin-contracts/token/ERC20/IERC20.sol';
import {IERC721} from '@openzeppelin-contracts/token/ERC721/IERC721.sol';
import {SafeERC20} from '@openzeppelin-contracts/token/ERC20/utils/SafeERC20.sol';
import {ERC721HolderUpgradeable} from
    '@openzeppelin-contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol';
import {ReentrancyGuardUpgradeable} from '@openzeppelin-contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol';
import {MathUpgradeable} from '@openzeppelin-contracts-upgradeable/utils/math/MathUpgradeable.sol';

// NOTE: only support normal money market actions (deposit, withdraw, borrow, repay, change position mode)
// doesn't support wLp
contract MoneyMarketHook is IMoneyMarketHook, ERC721HolderUpgradeable, ReentrancyGuardUpgradeable, UnderACM {
    using UncheckedIncrement for uint;
    using SafeERC20 for IERC20;

    // constants
    bytes32 private constant GUARDIAN = keccak256('guardian');

    // immutables
    /// @inheritdoc IMoneyMarketHook
    address public immutable CORE;
    /// @inheritdoc IMoneyMarketHook
    address public immutable POS_MANAGER;
    /// @inheritdoc IMoneyMarketHook
    address public immutable WWETH;
    /// @inheritdoc IMoneyMarketHook
    address public immutable WUSDB;

    // storages
    /// @inheritdoc IMoneyMarketHook
    mapping(address => uint) public lastPosIds;
    /// @inheritdoc IMoneyMarketHook
    mapping(address => mapping(uint => uint)) public initPosIds;
    /// @inheritdoc IMoneyMarketHook
    mapping(address => bool) public whitelistedHelpers;

    // modifiers
    modifier onlyGuardian() {
        ACM.checkRole(GUARDIAN, msg.sender);
        _;
    }

    // constructor
    constructor(address _initCore, address _wweth, address _wusdb, address _acm) UnderACM(_acm) {
        CORE = _initCore;
        POS_MANAGER = IInitCore(_initCore).POS_MANAGER();
        WWETH = _wweth;
        WUSDB = _wusdb;
        _disableInitializers();
    }

    // initialize
    /// @dev initialize the contract
    function initialize() external initializer {
        __ReentrancyGuard_init();
        address weth = IERC20RebasingWrapper(WWETH).underlyingToken();
        address usdb = IERC20RebasingWrapper(WUSDB).underlyingToken();
        IERC20(weth).safeApprove(WWETH, type(uint).max);
        IERC20(usdb).safeApprove(WUSDB, type(uint).max);
    }

    // functions
    /// @inheritdoc IMoneyMarketHook
    function execute(OperationParams calldata _params)
        external
        payable
        nonReentrant
        returns (uint posId, uint initPosId, bytes[] memory results)
    {
        // create position if not exist
        if (_params.posId == 0) {
            (posId, initPosId) = createPos(_params.mode, _params.viewer);
        } else {
            // for existing position, only owner can execute
            posId = _params.posId;
            initPosId = initPosIds[msg.sender][posId];
            _require(IERC721(POS_MANAGER).ownerOf(initPosId) == address(this), Errors.NOT_OWNER);
        }
        // NOTE: msg.value should be used for 1 operation only
        results = _handleMulticall(initPosId, _params);
        // check slippage
        _require(_params.minHealth_e18 <= IInitCore(CORE).getPosHealthCurrent_e18(initPosId), Errors.SLIPPAGE_CONTROL);
        // unwrap withdraw token if needed
        for (uint i; i < _params.withdrawParams.length; i = i.uinc()) {
            address helper = _params.withdrawParams[i].rebaseHelperParams.helper;
            if (helper != address(0)) IRebaseHelper(helper).unwrap(_params.withdrawParams[i].to);
        }
        // return usdb token
        uint WUSDBBal = IERC20(WUSDB).balanceOf(address(this));
        if (WUSDBBal != 0) {
            IERC20RebasingWrapper(WUSDB).unwrap(WUSDBBal);
            address usdb = IERC20RebasingWrapper(WUSDB).underlyingToken();
            uint usdbBal = IERC20(usdb).balanceOf(address(this));
            if (usdbBal != 0) IERC20(usdb).safeTransfer(msg.sender, usdbBal);
        }
        // return native token
        uint WWETHBal = IERC20(WWETH).balanceOf(address(this));
        if (WWETHBal != 0) {
            if (_params.returnNative) {
                // NOTE: no need receive function since we will use TransparentUpgradeableProxyBlastReceiveETH
                if (WWETHBal != 0) IWWETH(WWETH).unwrapNative(WWETHBal);
                uint nativeBal = address(this).balance;
                if (nativeBal != 0) {
                    (bool success,) = payable(msg.sender).call{value: address(this).balance}('');
                    _require(success, Errors.CALL_FAILED);
                }
            } else {
                IERC20RebasingWrapper(WWETH).unwrap(WWETHBal);
                address weth = IERC20RebasingWrapper(WWETH).underlyingToken();
                uint wethBal = IERC20(weth).balanceOf(address(this));
                if (wethBal != 0) IERC20(weth).safeTransfer(msg.sender, wethBal);
            }
        }
    }

    /// @inheritdoc IMoneyMarketHook
    function createPos(uint16 _mode, address _viewer) public returns (uint posId, uint initPosId) {
        posId = ++lastPosIds[msg.sender];
        initPosId = IInitCore(CORE).createPos(_mode, _viewer);
        initPosIds[msg.sender][posId] = initPosId;
    }

    /// @inheritdoc IMoneyMarketHook
    function setWhitelistedHelpers(address[] calldata _helpers, bool _status) external onlyGuardian {
        for (uint i; i < _helpers.length; i = i.uinc()) {
            whitelistedHelpers[_helpers[i]] = _status;
        }
        emit SetWhitelistedHelpers(_helpers, _status);
    }

    /// @dev approve token for init core if needed
    /// @param _token token address
    /// @param _amt token amount to spend
    function _ensureApprove(address _token, uint _amt) internal {
        if (IERC20(_token).allowance(address(this), CORE) < _amt) {
            IERC20(_token).safeApprove(CORE, type(uint).max);
        }
    }

    // @dev prepare and execute multicall
    // @param _initPosId init position id (nft id)
    // @param _params operation parameters
    // @return results results of multicall
    function _handleMulticall(uint _initPosId, OperationParams calldata _params)
        internal
        returns (bytes[] memory results)
    {
        // prepare data for multicall
        // 1. repay (if needed)
        // 2. withdraw (if needed)
        // 3. change position mode (if needed)
        // 4. borrow (if needed)
        // 5. deposit (if needed)
        bool changeMode = _params.mode != 0 && _params.mode != IPosManager(POS_MANAGER).getPosMode(_initPosId);
        bytes[] memory data;
        {
            uint dataLength = _params.repayParams.length + (2 * _params.withdrawParams.length) + (changeMode ? 1 : 0)
                + _params.borrowParams.length + (2 * _params.depositParams.length);
            data = new bytes[](dataLength);
        }
        uint offset;
        // 1. repay
        (offset, data) = _handleRepay(offset, data, _initPosId, _params.repayParams);
        // 2. withdraw
        (offset, data) = _handleWithdraw(offset, data, _initPosId, _params.withdrawParams, _params.returnNative);
        // 3. change position mode
        if (changeMode) {
            data[offset] = abi.encodeWithSelector(IInitCore.setPosMode.selector, _initPosId, _params.mode);
            offset = offset.uinc();
        }
        // 4. borrow
        (offset, data) = _handleBorrow(offset, data, _initPosId, _params.borrowParams, _params.returnNative);
        // 5. deposit
        (offset, data) = _handleDeposit(offset, data, _initPosId, _params.depositParams);
        // execute multicall
        results = IMulticall(CORE).multicall(data);
    }

    /// @dev generate repay data for multicall
    /// @param _offset offset of data
    /// @param _data multicall data
    /// @param _initPosId init position id (nft id)
    /// @param _params repay params
    /// @return offset new offset
    /// @return data new data
    function _handleRepay(uint _offset, bytes[] memory _data, uint _initPosId, RepayParams[] memory _params)
        internal
        returns (uint, bytes[] memory)
    {
        for (uint i; i < _params.length; i = i.uinc()) {
            address uToken = ILendingPool(_params[i].pool).underlyingToken();
            uint posDebtShares = IPosManager(POS_MANAGER).getPosDebtShares(_initPosId, _params[i].pool);
            uint repayShares = _params[i].shares <= posDebtShares ? _params[i].shares : posDebtShares;
            uint repayAmt = ILendingPool(_params[i].pool).debtShareToAmtCurrent(repayShares);
            _ensureApprove(uToken, repayAmt);
            if (uToken == WWETH) {
                uint amt;
                if (msg.value != 0) amt = IWWETH(WWETH).wrapNative{value: msg.value}();
                repayAmt = repayAmt > amt ? repayAmt - amt : 0; // calculate excess repay amt required
                // round up to ensure enough wusdb to repay
                uint wethAmt = IWWETH(WWETH).toAmt(repayAmt, MathUpgradeable.Rounding.Up);
                if (wethAmt != 0) {
                    // transfer excess amt in the form of weth
                    address weth = IERC20RebasingWrapper(WWETH).underlyingToken();
                    IERC20(weth).safeTransferFrom(msg.sender, address(this), wethAmt);
                    IERC20RebasingWrapper(WWETH).wrap(wethAmt);
                }
            } else if (uToken == WUSDB) {
                address usdb = IERC20RebasingWrapper(WUSDB).underlyingToken();
                // round up to ensure enough wusdb to repay
                uint usdbAmt = IERC20RebasingWrapper(WUSDB).toAmt(repayAmt, MathUpgradeable.Rounding.Up);
                if (usdbAmt != 0) {
                    // transfer excess amt in the form of usdb
                    IERC20(usdb).safeTransferFrom(msg.sender, address(this), usdbAmt);
                    IERC20RebasingWrapper(WUSDB).wrap(usdbAmt);
                }
            } else {
                IERC20(uToken).safeTransferFrom(msg.sender, address(this), repayAmt);
            }
            _data[_offset] =
                abi.encodeWithSelector(IInitCore.repay.selector, _params[i].pool, _params[i].shares, _initPosId);
            _offset = _offset.uinc();
        }
        return (_offset, _data);
    }

    /// @dev generate withdraw data for multicall
    /// @param _offset offset of data
    /// @param _data multicall data
    /// @param _initPosId init position id (nft id)
    /// @param _params withdraw params
    /// @return offset new offset
    /// @return data new data
    function _handleWithdraw(
        uint _offset,
        bytes[] memory _data,
        uint _initPosId,
        WithdrawParams[] calldata _params,
        bool // note: _returnNative is not used since we WWETH will alway returns to this contract
    ) internal view returns (uint, bytes[] memory) {
        for (uint i; i < _params.length; i = i.uinc()) {
            // decollateralize to pool
            _data[_offset] = abi.encodeWithSelector(
                IInitCore.decollateralize.selector, _initPosId, _params[i].pool, _params[i].shares, _params[i].pool
            );
            _offset = _offset.uinc();
            // burn collateral to underlying token
            address helper = _params[i].rebaseHelperParams.helper;
            address uToken = ILendingPool(_params[i].pool).underlyingToken();
            address uTokenReceiver = _params[i].to;
            // if using erc-rebasing token hook need to unwrap to rebase token
            if (uToken == WWETH || uToken == WUSDB) {
                uTokenReceiver = address(this);
            }
            // if need to unwrap to rebase token
            else if (helper != address(0)) {
                // check if the helper is whitelisted
                _require(whitelistedHelpers[helper], Errors.NOT_WHITELISTED);
                _require(
                    _params[i].rebaseHelperParams.tokenIn == uToken
                        && IRebaseHelper(helper).YIELD_BEARING_TOKEN() == uToken,
                    Errors.INVALID_TOKEN_IN
                );
                uTokenReceiver = helper;
            }
            _data[_offset] = abi.encodeWithSelector(IInitCore.burnTo.selector, _params[i].pool, uTokenReceiver);
            _offset = _offset.uinc();
        }
        return (_offset, _data);
    }

    /// @dev generate borrow data for multicall
    /// @param _offset offset of data
    /// @param _data multicall data
    /// @param _initPosId init position id (nft id)
    /// @param _params borrow params
    /// @return offset new offset
    /// @return data new data
    function _handleBorrow(
        uint _offset,
        bytes[] memory _data,
        uint _initPosId,
        BorrowParams[] calldata _params,
        bool // note: _returnNative is not used since we WWETH will alway returns to this contract
    ) internal view returns (uint, bytes[] memory) {
        for (uint i; i < _params.length; i = i.uinc()) {
            address uTokenReceiver = _params[i].to;
            address uToken = ILendingPool(_params[i].pool).underlyingToken();
            if (uToken == WWETH || uToken == WUSDB) uTokenReceiver = address(this);

            _data[_offset] = abi.encodeWithSelector(
                IInitCore.borrow.selector, _params[i].pool, _params[i].amt, _initPosId, uTokenReceiver
            );
            _offset = _offset.uinc();
        }
        return (_offset, _data);
    }

    /// @dev generate deposit data for multicall
    /// @param _offset offset of data
    /// @param _data multicall data
    /// @param _initPosId init position id (nft id)
    /// @param _params deposit params
    /// @return offset new offset
    /// @return data new data
    function _handleDeposit(uint _offset, bytes[] memory _data, uint _initPosId, DepositParams[] calldata _params)
        internal
        returns (uint, bytes[] memory)
    {
        for (uint i; i < _params.length; i = i.uinc()) {
            address pool = _params[i].pool;
            uint amt = _params[i].amt;
            address uToken = ILendingPool(pool).underlyingToken();
            address helper = _params[i].rebaseHelperParams.helper;
            // 1. deposit native token
            // NOTE: use msg.value for native token
            // amt > 0 mean user want to use WWETH too
            if (uToken == WWETH) {
                uint shares;
                if (msg.value != 0) {
                    shares = IWWETH(WWETH).wrapNative{value: msg.value}();
                }
                // transfer WETH to address(this) will user want to use WETH
                if (amt != 0) {
                    address wETH = IERC20RebasingWrapper(WWETH).underlyingToken();
                    IERC20(wETH).safeTransferFrom(msg.sender, address(this), amt);
                    shares += IERC20RebasingWrapper(WWETH).wrap(amt);
                }
                // transfer WWETH to pool
                IERC20(WWETH).safeTransfer(pool, shares);
            }
            // 2. wrap usdb token to WUSDB and deposit
            else if (uToken == WUSDB) {
                address usdb = IERC20RebasingWrapper(WUSDB).underlyingToken();
                IERC20(usdb).safeTransferFrom(msg.sender, address(this), amt);
                uint shares = IERC20RebasingWrapper(WUSDB).wrap(amt);
                // transfer WUSDB to pool
                IERC20(WUSDB).safeTransfer(pool, shares);
            }
            // 3. wrap rebase token to non-rebase token and deposit
            else if (helper != address(0)) {
                address tokenIn = _params[i].rebaseHelperParams.tokenIn;
                // check if the helper is whitelisted
                _require(whitelistedHelpers[helper], Errors.NOT_WHITELISTED);
                _require(IRebaseHelper(helper).REBASE_TOKEN() == tokenIn, Errors.INVALID_TOKEN_IN);
                _require(IRebaseHelper(helper).YIELD_BEARING_TOKEN() == uToken, Errors.INVALID_TOKEN_OUT);
                IERC20(tokenIn).safeTransferFrom(msg.sender, helper, amt);
                IRebaseHelper(helper).wrap(pool);
            }
            // 4. deposit normal erc20 token
            else {
                IERC20(uToken).safeTransferFrom(msg.sender, pool, amt);
            }
            // mint to position
            _data[_offset] = abi.encodeWithSelector(IInitCore.mintTo.selector, pool, POS_MANAGER);
            _offset = _offset.uinc();
            // collateralize
            _data[_offset] = abi.encodeWithSelector(IInitCore.collateralize.selector, _initPosId, pool);
            _offset = _offset.uinc();
        }
        return (_offset, _data);
    }
}

File 2 of 30 : InitErrors.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

/// @notice For maximum readability, error code must be a hex-encoded ASCII in the form {#DDD}.
/// @dev Reverts if the _condition is false.
/// @param _condition boolean condition required to be true.
/// @param _errorCode hex-encoded ASCII error code
function _require(bool _condition, uint32 _errorCode) pure {
    if (!_condition) revert(string(abi.encodePacked(_errorCode)));
}

library Errors {
    // Common
    uint32 internal constant ZERO_VALUE = 0x23313030; // hex-encoded ASCII of '#100'
    uint32 internal constant NOT_INIT_CORE = 0x23313031; // hex-encoded ASCII of '#101'
    uint32 internal constant SLIPPAGE_CONTROL = 0x23313032; // hex-encoded ASCII of '#102'
    uint32 internal constant CALL_FAILED = 0x23313033; // hex-encoded ASCII of '#103'
    uint32 internal constant NOT_OWNER = 0x23313034; // hex-encoded ASCII of '#104'
    uint32 internal constant NOT_WNATIVE = 0x23313035; // hex-encoded ASCII of '#105'
    uint32 internal constant ALREADY_SET = 0x23313036; // hex-encoded ASCII of '#106'
    uint32 internal constant NOT_WHITELISTED = 0x23313037; // hex-encoded ASCII of '#107'

    // Input
    uint32 internal constant ARRAY_LENGTH_MISMATCHED = 0x23323030; // hex-encoded ASCII of '#200'
    uint32 internal constant INPUT_TOO_LOW = 0x23323031; // hex-encoded ASCII of '#201'
    uint32 internal constant INPUT_TOO_HIGH = 0x23323032; // hex-encoded ASCII of '#202'
    uint32 internal constant INVALID_INPUT = 0x23323033; // hex-encoded ASCII of '#203'
    uint32 internal constant INVALID_TOKEN_IN = 0x23323034; // hex-encoded ASCII of '#204'
    uint32 internal constant INVALID_TOKEN_OUT = 0x23323035; // hex-encoded ASCII of '#205'
    uint32 internal constant NOT_SORTED_OR_DUPLICATED_INPUT = 0x23323036; // hex-encoded ASCII of '#206'

    // Core
    uint32 internal constant POSITION_NOT_HEALTHY = 0x23333030; // hex-encoded ASCII of '#300'
    uint32 internal constant POSITION_NOT_FOUND = 0x23333031; // hex-encoded ASCII of '#301'
    uint32 internal constant LOCKED_MULTICALL = 0x23333032; // hex-encoded ASCII of '#302'
    uint32 internal constant POSITION_HEALTHY = 0x23333033; // hex-encoded ASCII of '#303'
    uint32 internal constant INVALID_HEALTH_AFTER_LIQUIDATION = 0x23333034; // hex-encoded ASCII of '#304'
    uint32 internal constant FLASH_PAUSED = 0x23333035; // hex-encoded ASCII of '#305'
    uint32 internal constant INVALID_FLASHLOAN = 0x23333036; // hex-encoded ASCII of '#306'
    uint32 internal constant NOT_AUTHORIZED = 0x23333037; // hex-encoded ASCII of '#307'
    uint32 internal constant INVALID_CALLBACK_ADDRESS = 0x23333038; // hex-encoded ASCII of '#308'

    // Lending Pool
    uint32 internal constant MINT_PAUSED = 0x23343030; // hex-encoded ASCII of '#400'
    uint32 internal constant REDEEM_PAUSED = 0x23343031; // hex-encoded ASCII of '#401'
    uint32 internal constant BORROW_PAUSED = 0x23343032; // hex-encoded ASCII of '#402'
    uint32 internal constant REPAY_PAUSED = 0x23343033; // hex-encoded ASCII of '#403'
    uint32 internal constant NOT_ENOUGH_CASH = 0x23343034; // hex-encoded ASCII of '#404'
    uint32 internal constant INVALID_AMOUNT_TO_REPAY = 0x23343035; // hex-encoded ASCII of '#405'
    uint32 internal constant SUPPLY_CAP_REACHED = 0x23343036; // hex-encoded ASCII of '#406'
    uint32 internal constant BORROW_CAP_REACHED = 0x23343037; // hex-encoded ASCII of '#407'

    // Config
    uint32 internal constant INVALID_MODE = 0x23353030; // hex-encoded ASCII of '#500'
    uint32 internal constant TOKEN_NOT_WHITELISTED = 0x23353031; // hex-encoded ASCII of '#501'
    uint32 internal constant INVALID_FACTOR = 0x23353032; // hex-encoded ASCII of '#502'

    // Position Manager
    uint32 internal constant COLLATERALIZE_PAUSED = 0x23363030; // hex-encoded ASCII of '#600'
    uint32 internal constant DECOLLATERALIZE_PAUSED = 0x23363031; // hex-encoded ASCII of '#601'
    uint32 internal constant MAX_COLLATERAL_COUNT_REACHED = 0x23363032; // hex-encoded ASCII of '#602'
    uint32 internal constant NOT_CONTAIN = 0x23363033; // hex-encoded ASCII of '#603'
    uint32 internal constant ALREADY_COLLATERALIZED = 0x23363034; // hex-encoded ASCII of '#604'

    // Oracle
    uint32 internal constant NO_VALID_SOURCE = 0x23373030; // hex-encoded ASCII of '#700'
    uint32 internal constant TOO_MUCH_DEVIATION = 0x23373031; // hex-encoded ASCII of '#701'
    uint32 internal constant MAX_PRICE_DEVIATION_TOO_LOW = 0x23373032; // hex-encoded ASCII of '#702'
    uint32 internal constant NO_PRICE_ID = 0x23373033; // hex-encoded ASCII of '#703'
    uint32 internal constant PYTH_CONFIG_NOT_SET = 0x23373034; // hex-encoded ASCII of '#704'
    uint32 internal constant DATAFEED_ID_NOT_SET = 0x23373035; // hex-encoded ASCII of '#705'
    uint32 internal constant MAX_STALETIME_NOT_SET = 0x23373036; // hex-encoded ASCII of '#706'
    uint32 internal constant MAX_STALETIME_EXCEEDED = 0x23373037; // hex-encoded ASCII of '#707'
    uint32 internal constant PRIMARY_SOURCE_NOT_SET = 0x23373038; // hex-encoded ASCII of '#708'
    uint32 internal constant DATAFEED_PROXY_NOT_SET = 0x23373039; // hex-encoded ASCII of '#709'

    // Risk Manager
    uint32 internal constant DEBT_CEILING_EXCEEDED = 0x23383030; // hex-encoded ASCII of '#800'

    // Misc
    uint32 internal constant INCORRECT_PAIR = 0x23393030; // hex-encoded ASCII of '#900'
    uint32 internal constant UNIMPLEMENTED = 0x23393939; // hex-encoded ASCII of '#999'
}

File 3 of 30 : UncheckedIncrement.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

library UncheckedIncrement {
    function uinc(uint self) internal pure returns (uint) {
        unchecked {
            return self + 1;
        }
    }
}

File 4 of 30 : UnderACM.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

import './ClaimableGas.sol';

import {IAccessControlManager} from '../interfaces/common/IAccessControlManager.sol';

abstract contract UnderACM is ClaimableGas {
    // immutables
    IAccessControlManager public immutable ACM; // access control manager

    // constructor
    constructor(address _acm) {
        ACM = IAccessControlManager(_acm);
    }
}

File 5 of 30 : IInitCore.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

import './IConfig.sol';

/// @title InitCore Interface
interface IInitCore {
    event SetConfig(address indexed newConfig);
    event SetOracle(address indexed newOracle);
    event SetIncentiveCalculator(address indexed newIncentiveCalculator);
    event SetRiskManager(address indexed newRiskManager);
    event Borrow(address indexed pool, uint indexed posId, address indexed to, uint borrowAmt, uint shares);
    event Repay(address indexed pool, uint indexed posId, address indexed repayer, uint shares, uint amtToRepay);
    event CreatePosition(address indexed owner, uint indexed posId, uint16 mode, address viewer);
    event SetPositionMode(uint indexed posId, uint16 mode);
    event Collateralize(uint indexed posId, address indexed pool, uint amt);
    event Decollateralize(uint indexed posId, address indexed pool, address indexed to, uint amt);
    event CollateralizeWLp(uint indexed posId, address indexed wLp, uint indexed tokenId, uint amt);
    event DecollateralizeWLp(uint indexed posId, address indexed wLp, uint indexed tokenId, address to, uint amt);
    event Liquidate(uint indexed posId, address indexed liquidator, address poolOut, uint shares);
    event LiquidateWLp(uint indexed posId, address indexed liquidator, address wLpOut, uint tokenId, uint amt);

    struct LiquidateLocalVars {
        IConfig config;
        uint16 mode;
        uint health_e18;
        uint liqIncentive_e18;
        address collToken;
        address repayToken;
        uint repayAmt;
        uint repayAmtWithLiqIncentive;
    }

    /// @dev get position manager address
    function POS_MANAGER() external view returns (address);

    /// @dev get config address
    function config() external view returns (address);

    /// @dev get oracle address
    function oracle() external view returns (address);

    /// @dev get risk manager address
    function riskManager() external view returns (address);

    /// @dev get liquidation incentive calculator address
    function liqIncentiveCalculator() external view returns (address);

    /// @dev mint lending pool shares (using ∆balance in lending pool)
    /// @param _pool lending pool address
    /// @param _to address to receive share token
    /// @return shares amount of share tokens minted
    function mintTo(address _pool, address _to) external returns (uint shares);

    /// @dev burn lending pool share tokens to receive underlying (using ∆balance in lending pool)
    /// @param _pool lending pool address
    /// @param _to address to receive underlying
    /// @return amt amount of underlying to receive
    function burnTo(address _pool, address _to) external returns (uint amt);

    /// @dev borrow underlying from lending pool
    /// @param _pool lending pool address
    /// @param _amt amount of underlying to borrow
    /// @param _posId position id to account for the borrowing
    /// @param _to address to receive borrow underlying
    /// @return shares the amount of debt shares for the borrowing
    function borrow(address _pool, uint _amt, uint _posId, address _to) external returns (uint shares);

    /// @dev repay debt to the lending pool
    /// @param _pool address of lending pool
    /// @param _shares  debt shares to repay
    /// @param _posId position id to repay debt
    /// @return amt amount of underlying to repaid
    function repay(address _pool, uint _shares, uint _posId) external returns (uint amt);

    /// @dev create a new position
    /// @param _mode position mode
    /// @param _viewer position viewer address
    function createPos(uint16 _mode, address _viewer) external returns (uint posId);

    /// @dev change a position's mode
    /// @param _posId position id to change mode
    /// @param _mode position mode to change to
    function setPosMode(uint _posId, uint16 _mode) external;

    /// @dev collateralize lending pool share tokens to position
    /// @param _posId position id to collateralize to
    /// @param _pool lending pool address
    function collateralize(uint _posId, address _pool) external;

    /// @notice need to check the position's health after decollateralization
    /// @dev decollateralize lending pool share tokens from the position
    /// @param _posId position id to decollateral
    /// @param _pool lending pool address
    /// @param _shares amount of share tokens to decollateralize
    /// @param _to address to receive token
    function decollateralize(uint _posId, address _pool, uint _shares, address _to) external;

    /// @dev collateralize wlp to position
    /// @param _posId position id to collateralize to
    /// @param _wLp wlp token address
    /// @param _tokenId token id of wlp token to collateralize
    function collateralizeWLp(uint _posId, address _wLp, uint _tokenId) external;

    /// @notice need to check position's health after decollateralization
    /// @dev decollateralize wlp from the position
    /// @param _posId position id to decollateralize
    /// @param _wLp wlp token address
    /// @param _tokenId token id of wlp token to decollateralize
    /// @param _amt amount of wlp token to decollateralize
    function decollateralizeWLp(uint _posId, address _wLp, uint _tokenId, uint _amt, address _to) external;

    /// @notice need to check position's health before liquidate & limit health after liqudate
    /// @dev (partial) liquidate the position
    /// @param _posId position id to liquidate
    /// @param _poolToRepay address of lending pool to liquidate
    /// @param _repayShares debt shares to repay
    /// @param _tokenOut pool token to receive for the liquidation
    /// @param _minShares min amount of pool token to receive after liquidate (slippage control)
    /// @return amt the token amount out actually transferred out
    function liquidate(uint _posId, address _poolToRepay, uint _repayShares, address _tokenOut, uint _minShares)
        external
        returns (uint amt);

    /// @notice need to check position's health before liquidate & limit health after liqudate
    /// @dev (partial) liquidate the position
    /// @param _posId position id to liquidate
    /// @param _poolToRepay address of lending pool to liquidate
    /// @param _repayShares debt shares to liquidate
    /// @param _wLp wlp to unwrap for liquidation
    /// @param _tokenId wlp token id to burn for liquidation
    /// @param _minLpOut min amount of lp to receive for liquidation
    /// @return amt the token amount out actually transferred out
    function liquidateWLp(
        uint _posId,
        address _poolToRepay,
        uint _repayShares,
        address _wLp,
        uint _tokenId,
        uint _minLpOut
    ) external returns (uint amt);

    /// @notice caller must implement `flashCallback` function
    /// @dev flashloan underlying tokens from lending pool
    /// @param _pools lending pool address list to flashloan from
    /// @param _amts token amount list to flashloan
    /// @param _data data to execute in the callback function
    function flash(address[] calldata _pools, uint[] calldata _amts, bytes calldata _data) external;

    /// @dev make a callback to the target contract
    /// @param _to target address to receive callback
    /// @param _value msg.value to pass on to the callback
    /// @param _data data to execute callback function
    /// @return result callback result
    function callback(address _to, uint _value, bytes calldata _data) external payable returns (bytes memory result);

    /// @notice this is NOT a view function
    /// @dev get current position's collateral credit in 1e36 (interest accrued up to current timestamp)
    /// @param _posId position id to get collateral credit for
    /// @return credit current position collateral credit
    function getCollateralCreditCurrent_e36(uint _posId) external returns (uint credit);

    /// @dev get current position's borrow credit in 1e36 (interest accrued up to current timestamp)
    /// @param _posId position id to get borrow credit for
    /// @return credit current position borrow credit
    function getBorrowCreditCurrent_e36(uint _posId) external returns (uint credit);

    /// @dev get current position's health factor in 1e18 (interest accrued up to current timestamp)
    /// @param _posId position id to get health factor
    /// @return health current position health factor
    function getPosHealthCurrent_e18(uint _posId) external returns (uint health);

    /// @dev set new config
    function setConfig(address _config) external;

    /// @dev set new oracle
    function setOracle(address _oracle) external;

    /// @dev set new liquidation incentve calculator
    function setLiqIncentiveCalculator(address _liqIncentiveCalculator) external;

    /// @dev set new risk manager
    function setRiskManager(address _riskManager) external;

    /// @dev transfer token from msg.sender to the target address
    /// @param _token token address to transfer
    /// @param _to address to receive token
    /// @param _amt amount of token to transfer
    function transferToken(address _token, address _to, uint _amt) external;
}

File 6 of 30 : IMulticall.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

/// @title Multicall Interface
interface IMulticall {
    /// @dev Perform multiple calls according to the provided _data. Reverts with reason if any of the calls failed.
    /// @notice `msg.value` should not be trusted or used in the multicall data.
    /// @param _data The encoded function data for each subcall.
    /// @return results The call results, if success.
    function multicall(bytes[] calldata _data) external payable returns (bytes[] memory results);
}

File 7 of 30 : IPosManager.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

import {EnumerableSet} from '@openzeppelin-contracts/utils/structs/EnumerableSet.sol';

/// @title Position Interface
interface IPosManager {
    event SetMaxCollCount(uint maxCollCount);

    struct PosInfo {
        address viewer; // viewer address
        uint16 mode; // position mode
    }

    // NOTE: extra info for hooks (not used in core)
    struct PosBorrExtraInfo {
        uint128 totalInterest; // total accrued interest since the position is created
        uint128 lastDebtAmt; // position's debt amount after the last interaction
    }

    struct PosCollInfo {
        EnumerableSet.AddressSet collTokens; // enumerable set of collateral tokens
        mapping(address => uint) collAmts; // collateral token to collateral amts mapping
        EnumerableSet.AddressSet wLps; // enumerable set of collateral wlps
        mapping(address => EnumerableSet.UintSet) ids; // wlp address to enumerable set of ids mapping
        uint8 collCount; // current collateral count (erc20 + wlp)
        uint8 wLpCount; // current collateral count (wlp)
    }

    struct PosBorrInfo {
        EnumerableSet.AddressSet pools; // enumerable set of borrow tokens
        mapping(address => uint) debtShares; // debt token to debt shares mapping
        mapping(address => PosBorrExtraInfo) borrExtraInfos; // debt token to extra info mapping
    }

    /// @dev get the next nonce of the owner for calculating the next position id
    /// @param _owner the position owner
    /// @return nextNonce the next nonce of the position owner
    function nextNonces(address _owner) external view returns (uint nextNonce);

    /// @dev get core address
    function core() external view returns (address core);

    /// @dev get pending reward token amts for the pos id
    /// @param _posId pos id
    /// @param _rewardToken reward token
    /// @return amt reward token amt
    function pendingRewards(uint _posId, address _rewardToken) external view returns (uint amt);

    /// @dev get whether the wlp is already collateralized to a position
    /// @param _wLp wlp address
    /// @param _tokenId wlp token id
    /// @return whether the wlp is already collateralized to a position
    function isCollateralized(address _wLp, uint _tokenId) external view returns (bool);

    /// @dev get the position borrowed info (excluding the extra info)
    /// @param _posId position id
    /// @return pools the borrowed pool list
    ///         debtShares the debt shares list of the borrowed pools
    function getPosBorrInfo(uint _posId) external view returns (address[] memory pools, uint[] memory debtShares);

    /// @dev get the position borrowed extra info
    /// @param _posId position id
    /// @param _pool borrowed pool address
    /// @return totalInterest total accrued interest since the position is created
    ///         lastDebtAmt position's debt amount after the last interaction
    function getPosBorrExtraInfo(uint _posId, address _pool)
        external
        view
        returns (uint totalInterest, uint lastDebtAmt);

    /// @dev get the position collateral info
    /// @param _posId position id
    /// @return pools the collateral pool adddres list
    ///         amts collateral amts of the collateral pools
    ///         wLps the collateral wlp list
    ///         ids the ids of the collateral wlp list
    ///         wLpAmts the amounts of the collateral wlp list
    function getPosCollInfo(uint _posId)
        external
        view
        returns (
            address[] memory pools,
            uint[] memory amts,
            address[] memory wLps,
            uint[][] memory ids,
            uint[][] memory wLpAmts
        );

    /// @dev get pool's collateral amount for the position
    /// @param _posId position id
    /// @param _pool collateral pool address
    /// @return amt collateral amount
    function getCollAmt(uint _posId, address _pool) external view returns (uint amt);

    /// @dev get wrapped lp collateral amount for the position
    /// @param _posId position id
    /// @param _wLp collateral wlp address
    /// @param _tokenId collateral wlp token id
    /// @return amt collateral amount
    function getCollWLpAmt(uint _posId, address _wLp, uint _tokenId) external view returns (uint amt);

    /// @dev get position's collateral count
    /// @param _posId position id
    /// @return collCount position's collateral count
    function getPosCollCount(uint _posId) external view returns (uint8 collCount);

    /// @dev get position's wLp count
    /// @param _posId position id
    function getPosCollWLpCount(uint _posId) external view returns (uint8 wLpCount);

    /// @dev get position info
    /// @param _posId position id
    /// @return viewerAddress position's viewer address
    ///         mode position's mode
    function getPosInfo(uint _posId) external view returns (address viewerAddress, uint16 mode);

    /// @dev get position mode
    /// @param _posId position id
    /// @return mode position's mode
    function getPosMode(uint _posId) external view returns (uint16 mode);

    /// @dev get pool's debt shares for the position
    /// @param _posId position id
    /// @param _pool lending pool address
    /// @return debtShares debt shares
    function getPosDebtShares(uint _posId, address _pool) external view returns (uint debtShares);

    /// @dev get pos id at index corresponding to the viewer address (reverse mapping)
    /// @param _viewer viewer address
    /// @param _index index
    /// @return posId pos id
    function getViewerPosIdsAt(address _viewer, uint _index) external view returns (uint posId);

    /// @dev get pos id length corresponding to the viewer address (reverse mapping)
    /// @param _viewer viewer address
    /// @return length pos ids length
    function getViewerPosIdsLength(address _viewer) external view returns (uint length);

    /// @notice only core can call this function
    /// @dev update pool's debt share
    /// @param _posId position id
    /// @param _pool lending pool address
    /// @param _debtShares  new debt shares
    function updatePosDebtShares(uint _posId, address _pool, int _debtShares) external;

    /// @notice only core can call this function
    /// @dev update position mode
    /// @param _posId position id
    /// @param _mode new position mode to set to
    function updatePosMode(uint _posId, uint16 _mode) external;

    /// @notice only core can call this function
    /// @dev add lending pool share as collateral to the position
    /// @param _posId position id
    /// @param _pool lending pool address
    /// @return amtIn pool's share collateral amount added to the position
    function addCollateral(uint _posId, address _pool) external returns (uint amtIn);

    /// @notice only core can call this function
    /// @dev add wrapped lp share as collateral to the position
    /// @param _posId position id
    /// @param _wLp wlp address
    /// @param _tokenId wlp token id
    /// @return amtIn wlp collateral amount added to the position
    function addCollateralWLp(uint _posId, address _wLp, uint _tokenId) external returns (uint amtIn);

    /// @notice only core can call this function
    /// @dev remove lending pool share from the position
    /// @param _posId position id
    /// @param _pool lending pool address
    /// @param _receiver address to receive the shares
    /// @return amtOut pool's share collateral amount removed from the position
    function removeCollateralTo(uint _posId, address _pool, uint _shares, address _receiver)
        external
        returns (uint amtOut);

    /// @notice only core can call this function
    /// @dev remove wlp from the position
    /// @param _posId position id
    /// @param _wLp wlp address
    /// @param _tokenId wlp token id
    /// @param _amt wlp token amount to remove
    /// @return amtOut wlp collateral amount removed from the position
    function removeCollateralWLpTo(uint _posId, address _wLp, uint _tokenId, uint _amt, address _receiver)
        external
        returns (uint amtOut);

    /// @notice only core can call this function
    /// @dev create a new position
    /// @param _owner position owner
    /// @param _mode position mode
    /// @param _viewer position viewer
    /// @return posId position id
    function createPos(address _owner, uint16 _mode, address _viewer) external returns (uint posId);

    /// @dev harvest rewards from the wlp token
    /// @param _posId position id
    /// @param _wlp wlp address
    /// @param _tokenId id of the wlp token
    /// @param _to address to receive the rewards
    /// @return tokens token address list harvested
    ///         amts token amt list harvested
    function harvestTo(uint _posId, address _wlp, uint _tokenId, address _to)
        external
        returns (address[] memory tokens, uint[] memory amts);

    /// @notice When removing the wrapped LP collateral, the rewards are harvested to the position manager
    ///         before unwrapping the LP and sending it to the user
    /// @dev claim pending reward pending in the position manager
    /// @param _posId position id
    /// @param _tokens token address list to claim pending reward
    /// @param _to address to receive the pending rewards
    /// @return amts amount of each reward tokens claimed
    function claimPendingRewards(uint _posId, address[] calldata _tokens, address _to)
        external
        returns (uint[] memory amts);

    /// @notice authorized account could be the owner or approved addresses
    /// @dev check if the accoount is authorized for the position
    /// @param _account account address to check
    /// @param _posId position id
    /// @return whether the account is authorized to manage the position
    function isAuthorized(address _account, uint _posId) external view returns (bool);

    /// @notice only guardian can call this function
    /// @dev set the max number of the different collateral count (to avoid out-of-gas error)
    /// @param _maxCollCount new max collateral count
    function setMaxCollCount(uint8 _maxCollCount) external;

    /// @notice only position owner can call this function
    /// @dev set new position viewer for pos id
    /// @param _posId pos id
    /// @param _viewer new viewer address
    function setPosViewer(uint _posId, address _viewer) external;
}

File 8 of 30 : ILendingPool.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

/// @title Lending Pool Interface
/// @notice rebase token is not supported
interface ILendingPool {
    event SetIrm(address _irm);
    event SetReserveFactor_e18(uint _reserveFactor_e18);
    event SetTreasury(address _treasury);

    /// @dev get core address
    function core() external view returns (address core);

    /// @dev get the interest rate model address
    function irm() external view returns (address model);

    /// @dev get the reserve factor in 1e18 (1e18 = 100%)
    function reserveFactor_e18() external view returns (uint factor_e18);

    /// @dev get the pool's underlying token
    function underlyingToken() external view returns (address token);

    /// @notice total assets = cash + total debts
    function totalAssets() external view returns (uint amt);

    /// @dev get the pool total debt (underlying token)
    function totalDebt() external view returns (uint debt);

    /// @dev get the pool total debt shares
    function totalDebtShares() external view returns (uint shares);

    /// @dev calaculate the debt share from debt amount (without interest accrual)
    /// @param _amt the amount of debt
    /// @return shares amount of debt shares (rounded up)
    function debtAmtToShareStored(uint _amt) external view returns (uint shares);

    /// @dev calaculate the debt share from debt amount (with interest accrual)
    /// @param _amt the amount of debt
    /// @return shares current amount of debt shares (rounded up)
    function debtAmtToShareCurrent(uint _amt) external returns (uint shares);

    /// @dev calculate the corresponding debt amount from debt share (without interest accrual)
    /// @param _shares the amount of debt shares
    /// @return amt corresponding debt amount (rounded up)
    function debtShareToAmtStored(uint _shares) external view returns (uint amt);

    /// @notice this is NOT a view function
    /// @dev calculate the corresponding debt amount from debt share (with interest accrual)
    /// @param _shares the amount of debt shares
    /// @return amt corresponding current debt amount (rounded up)
    function debtShareToAmtCurrent(uint _shares) external returns (uint amt);

    /// @dev get current supply rate per sec in 1e18
    function getSupplyRate_e18() external view returns (uint supplyRate_e18);

    /// @dev get current borrow rate per sec in 1e18
    function getBorrowRate_e18() external view returns (uint borrowRate_e18);

    /// @dev get the pool total cash (underlying token)
    function cash() external view returns (uint amt);

    /// @dev get the latest timestamp of interest accrual
    /// @return lastAccruedTime last accrued time unix timestamp
    function lastAccruedTime() external view returns (uint lastAccruedTime);

    /// @dev get the treasury address
    function treasury() external view returns (address treasury);

    /// @notice only core can call this function
    /// @dev mint shares to the receiver from the transfered assets
    /// @param _receiver address to receive shares
    /// @return mintShares amount of shares minted
    function mint(address _receiver) external returns (uint mintShares);

    /// @notice only core can call this function
    /// @dev burn shares and send the underlying assets to the receiver
    /// @param _receiver address to receive the underlying tokens
    /// @return amt amount of underlying assets transferred
    function burn(address _receiver) external returns (uint amt);

    /// @notice only core can call this function
    /// @dev borrow the asset from the lending pool
    /// @param _receiver address to receive the borrowed asset
    /// @param _amt amount of asset to borrow
    /// @return debtShares debt shares amount recorded from borrowing
    function borrow(address _receiver, uint _amt) external returns (uint debtShares);

    /// @notice only core can call this function
    /// @dev repay the borrowed assets
    /// @param _shares the amount of debt shares to repay
    /// @return amt assets amount used for repay
    function repay(uint _shares) external returns (uint amt);

    /// @dev accrue interest from the last accrual
    function accrueInterest() external;

    /// @dev get the share amounts from underlying asset amt
    /// @param _amt the amount of asset to convert to shares
    /// @return shares amount of shares (rounded down)
    function toShares(uint _amt) external view returns (uint shares);

    /// @dev get the asset amount from shares
    /// @param _shares the amount of shares to convert to underlying asset amt
    /// @return amt amount of underlying asset (rounded down)
    function toAmt(uint _shares) external view returns (uint amt);

    /// @dev get the share amounts from underlying asset amt (with interest accrual)
    /// @param _amt the amount of asset to convert to shares
    /// @return shares current amount of shares (rounded down)
    function toSharesCurrent(uint _amt) external returns (uint shares);

    /// @dev get the asset amount from shares (with interest accrual)
    /// @param _shares the amount of shares to convert to underlying asset amt
    /// @return amt current amount of underlying asset (rounded down)
    function toAmtCurrent(uint _shares) external returns (uint amt);

    /// @dev set the interest rate model
    /// @param _irm new interest rate model address
    function setIrm(address _irm) external;

    /// @dev set the pool's reserve factor in 1e18
    /// @param _reserveFactor_e18 new reserver factor in 1e18
    function setReserveFactor_e18(uint _reserveFactor_e18) external;

    /// @dev set the pool's treasury address
    /// @param _treasury new treasury address
    function setTreasury(address _treasury) external;
}

File 9 of 30 : IWWETH.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

import {IERC20RebasingWrapper} from './IERC20RebasingWrapper.sol';

interface IWWETH is IERC20RebasingWrapper {
    function wrapNative() external payable returns (uint);

    function unwrapNative(uint _shares) external returns (uint);
}

File 10 of 30 : IRebaseHelper.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

interface IRebaseHelper {
    /// @dev non-rebase token (ex. wsteth)
    function YIELD_BEARING_TOKEN() external view returns (address);

    /// @dev rebase token (ex. steth)
    function REBASE_TOKEN() external view returns (address);

    /// @dev wrap the rebase token to yield bearing token then send to _to (ex. steth->wsteth)
    /// @param _to address to receive the wrapped token
    /// @return amtOut amount of token out
    function wrap(address _to) external returns (uint amtOut);

    /// @dev unwrap the yield bearing token to rebase token then send to _to (ex. wsteth->steth)
    /// @param _to address to receive the unwrapped token
    /// @return amtOut amount of token out
    function unwrap(address _to) external returns (uint amtOut);
}

File 11 of 30 : IMoneyMarketHook.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

interface IMoneyMarketHook {
    event SetWhitelistedHelpers(address[] _helpers, bool status);

    // struct
    struct RebaseHelperParams {
        address helper; // wrap helper address if address(0) then not wrap
        address tokenIn; // token to use in rebase helper
    }

    // NOTE: there is 3 types of deposit
    // 1. deposit native token use msg.value for native token
    // if amt > 0 mean user want to use wNative too
    // 2. deposit usdb token wrap to wUSDB and deposit
    // 3. wrap rebase token to non-rebase token and deposit (using rebase helper)
    // 4. deposit normal erc20 token
    struct DepositParams {
        address pool; // lending pool to deposit
        uint amt; // token amount to deposit
        RebaseHelperParams rebaseHelperParams; // wrap params
    }

    struct WithdrawParams {
        address pool; // lending pool to withdraw
        uint shares; // shares to withdraw
        RebaseHelperParams rebaseHelperParams; // wrap params
        address to; // receiver to receive withdraw tokens
    }

    struct RepayParams {
        address pool; // lending pool to repay
        uint shares; // shares to repay
        RebaseHelperParams rebaseHelperParams; // wrap params
    }

    struct BorrowParams {
        address pool; // lending pool to borrow
        uint amt; // token amount to borrow
        address to; // receiver to receive borrow tokens
    }

    struct OperationParams {
        uint posId; //  position id to execute (0 to create new position)
        address viewer; // address to view position
        uint16 mode; // position mode to be used
        DepositParams[] depositParams; // deposit parameters
        WithdrawParams[] withdrawParams; // withdraw parameters
        BorrowParams[] borrowParams; // borrow parameters
        RepayParams[] repayParams; // repay parameters
        uint minHealth_e18; // minimum health to maintain after execute
        bool returnNative; // return native token or not (using balanceOf(address(this)))
    }

    // function
    /// @dev get the core address
    function CORE() external view returns (address);

    /// @dev get the position manager address
    function POS_MANAGER() external view returns (address);

    /// @dev get wrapped token of weth rebasing token
    function WWETH() external view returns (address);

    /// @dev get wrapped token of usd rebasing token
    function WUSDB() external view returns (address);

    /// @dev get last user's position id
    /// @param _user user address
    /// @return posId last user's position id
    function lastPosIds(address _user) external view returns (uint posId);

    /// @dev get the init position id (nft id)
    /// @param _user user address
    /// @param _posId position id
    /// @return initPosId init position id (nft id)
    function initPosIds(address _user, uint _posId) external view returns (uint initPosId);

    /// @dev check if the helper is whitelisted.
    /// @param _helper helper address
    /// @return whether the helper is whitelisted.
    function whitelistedHelpers(address _helper) external view returns (bool);

    /// @notice USDB, WETH will use msg.sender as _to address
    /// @dev execute all position actions in one transaction via multicall (to avoid multiple health check)
    /// @param _params operation parameters
    /// @return posId hook position id
    /// @return initPosId init position id (nft id)
    /// @return results results of multicall
    function execute(OperationParams calldata _params)
        external
        payable
        returns (uint posId, uint initPosId, bytes[] memory results);

    /// @dev create new position
    /// @param _mode position mode to be used
    /// @param _viewer address to view position
    /// @return posId hook position id
    /// @return initPosId init position id (nft id)
    function createPos(uint16 _mode, address _viewer) external returns (uint posId, uint initPosId);

    /// @notice only guardian role can call
    /// @dev set whitelisted helper statuses
    /// @param _helpers helper list
    /// @param _status whitelisted status to set to
    function setWhitelistedHelpers(address[] calldata _helpers, bool _status) external;
}

File 12 of 30 : 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 13 of 30 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

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

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

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

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

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

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

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

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

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

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

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

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

File 14 of 30 : 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 15 of 30 : ERC721HolderUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.0;

import "../IERC721ReceiverUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC721Receiver} interface.
 *
 * Accepts all token transfers.
 * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
 */
contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable {
    function __ERC721Holder_init() internal onlyInitializing {
    }

    function __ERC721Holder_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 16 of 30 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

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

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

    uint256 private _status;

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

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

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

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

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

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 17 of 30 : MathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library MathUpgradeable {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

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

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

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

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

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

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

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

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

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

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

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

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

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

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

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

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

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

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);
        }
    }
}

File 18 of 30 : ClaimableGas.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

import {IBlast} from '../interfaces/common/blast/IBlast.sol';

abstract contract ClaimableGas {
    constructor() {
        IBlast blast = IBlast(0x4300000000000000000000000000000000000002);
        blast.configureClaimableGas();
        blast.configureGovernor(msg.sender);
    }
}

File 19 of 30 : IAccessControlManager.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

/// @title Access Control Manager Interface
interface IAccessControlManager {
    /// @dev check the role of the user, revert against an unauthorized user.
    /// @param _role keccak256 hash of role name
    /// @param _user user address to check for the role
    function checkRole(bytes32 _role, address _user) external;
}

File 20 of 30 : IConfig.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

import {EnumerableSet} from '@openzeppelin-contracts/utils/structs/EnumerableSet.sol';
// structs

struct TokenFactors {
    uint128 collFactor_e18; // collateral factor in 1e18 (1e18 = 100%)
    uint128 borrFactor_e18; // borrow factor in 1e18 (1e18 = 100%)
}

struct ModeConfig {
    EnumerableSet.AddressSet collTokens; // enumerable set of collateral tokens
    EnumerableSet.AddressSet borrTokens; // enumerable set of borrow tokens
    uint64 maxHealthAfterLiq_e18; // max health factor allowed after liquidation
    mapping(address => TokenFactors) factors; // token factors mapping
    ModeStatus status; // mode status
    uint8 maxCollWLpCount; // limit number of wLp to avoid out of gas
}

struct PoolConfig {
    uint128 supplyCap; // pool supply cap
    uint128 borrowCap; // pool borrow cap
    bool canMint; // pool mint status
    bool canBurn; // pool burn status
    bool canBorrow; // pool borrow status
    bool canRepay; // pool repay status
    bool canFlash; // pool flash status
}

struct ModeStatus {
    bool canCollateralize; // mode collateralize status
    bool canDecollateralize; // mode decollateralize status
    bool canBorrow; // mode borrow status
    bool canRepay; // mode repay status
}

/// @title Config Interface
/// @notice Configuration parameters for the protocol.
interface IConfig {
    event SetPoolConfig(address indexed pool, PoolConfig config);
    event SetCollFactors_e18(uint16 indexed mode, address[] tokens, uint128[] _factors);
    event SetBorrFactors_e18(uint16 indexed mode, address[] tokens, uint128[] factors);
    event SetMaxHealthAfterLiq_e18(uint16 indexed mode, uint64 maxHealthAfterLiq_e18);
    event SetWhitelistedWLps(address[] wLps, bool status);
    event SetModeStatus(uint16 mode, ModeStatus status);
    event SetMaxCollWLpCount(uint16 indexed mode, uint8 maxCollWLpCount);

    /// @dev check if the wrapped lp is whitelisted.
    /// @param _wlp wrapped lp address
    /// @return whether the wrapped lp is whitelisted.
    function whitelistedWLps(address _wlp) external view returns (bool);

    /// @dev get mode config
    /// @param _mode mode id
    /// @return collTokens collateral token list
    ///         borrTokens borrow token list
    ///         maxHealthAfterLiq_e18 max health factor allowed after liquidation
    ///         maxCollWLpCount // limit number of wLp to avoid out of gas
    function getModeConfig(uint16 _mode)
        external
        view
        returns (
            address[] memory collTokens,
            address[] memory borrTokens,
            uint maxHealthAfterLiq_e18,
            uint8 maxCollWLpCount
        );

    /// @dev get pool config
    /// @param _pool pool address
    /// @return poolConfig pool config
    function getPoolConfig(address _pool) external view returns (PoolConfig memory poolConfig);

    /// @dev check if the pool within the specified mode is allowed for borrowing.
    /// @param _mode mode id
    /// @param _pool lending pool address
    /// @return whether the pool within the mode is allowed for borrowing.
    function isAllowedForBorrow(uint16 _mode, address _pool) external view returns (bool);

    /// @dev check if the pool within the specified mode is allowed for collateralizing.
    /// @param _mode mode id
    /// @param _pool lending pool address
    /// @return whether the pool within the mode is allowed for collateralizing.
    function isAllowedForCollateral(uint16 _mode, address _pool) external view returns (bool);

    /// @dev get the token factors (collateral and borrow factors)
    /// @param _mode mode id
    /// @param _pool lending pool address
    /// @return tokenFactors token factors
    function getTokenFactors(uint16 _mode, address _pool) external view returns (TokenFactors memory tokenFactors);

    /// @notice if return the value of type(uint64).max, skip the health check after liquidation
    /// @dev get the mode max health allowed after liquidation
    /// @param _mode mode id
    /// @param maxHealthAfterLiq_e18 max allowed health factor after liquidation
    function getMaxHealthAfterLiq_e18(uint16 _mode) external view returns (uint maxHealthAfterLiq_e18);

    /// @dev get the current mode status
    /// @param _mode mode id
    /// @return modeStatus mode status (collateralize, decollateralize, borrow or repay)
    function getModeStatus(uint16 _mode) external view returns (ModeStatus memory modeStatus);

    /// @dev set pool config
    /// @param _pool lending pool address
    /// @param _config new pool config
    function setPoolConfig(address _pool, PoolConfig calldata _config) external;

    /// @dev set pool collateral factors
    /// @param _pools lending pool address list
    /// @param _factors new collateral factor list in 1e18 (1e18 = 100%)
    function setCollFactors_e18(uint16 _mode, address[] calldata _pools, uint128[] calldata _factors) external;

    /// @dev set pool borrow factors
    /// @param _pools lending pool address list
    /// @param _factors new borrow factor list in 1e18 (1e18 = 100%)
    function setBorrFactors_e18(uint16 _mode, address[] calldata _pools, uint128[] calldata _factors) external;

    /// @dev set mode status
    /// @param _status new mode status to set to (collateralize, decollateralize, borrow and repay)
    function setModeStatus(uint16 _mode, ModeStatus calldata _status) external;

    /// @notice only governor role can call
    /// @dev set whitelisted wrapped lp statuses
    /// @param _wLps wrapped lp list
    /// @param _status whitelisted status to set to
    function setWhitelistedWLps(address[] calldata _wLps, bool _status) external;

    /// @dev set max health after liquidation (type(uint64).max means infinite, or no check)
    /// @param _mode mode id
    /// @param _maxHealthAfterLiq_e18 new max allowed health factor after liquidation
    function setMaxHealthAfterLiq_e18(uint16 _mode, uint64 _maxHealthAfterLiq_e18) external;

    /// @dev set mode's max collateral wrapped lp count to avoid out of gas
    /// @param _mode mode id
    /// @param _maxCollWLpCount max collateral wrapped lp count
    function setMaxCollWLpCount(uint16 _mode, uint8 _maxCollWLpCount) external;

    /// @dev get mode's max collateral wlp count
    /// @param _mode mode id
    /// @return the mode's max collateral wlp count
    function getModeMaxCollWLpCount(uint16 _mode) external view returns (uint8);
}

File 21 of 30 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

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

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

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

        return result;
    }
}

File 22 of 30 : IERC20RebasingWrapper.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

import {MathUpgradeable} from '@openzeppelin-contracts-upgradeable/utils/math/MathUpgradeable.sol';

interface IERC20RebasingWrapper {
    /// @dev wrap underlying token to wrapped token
    /// @param _amt amount of underlying token to wrap
    /// @return shares amount of shares minted
    function wrap(uint _amt) external returns (uint shares);

    /// @dev unwrap wrapped token to underlying token
    /// @param _shares amount of wrapped token to unwrap
    /// @return amt amount of underlying token received
    function unwrap(uint _shares) external returns (uint amt);

    /// @dev claim pending interests from underlying token
    function accrueYield() external;

    /// @dev blast-erc20-rebasing token address
    function underlyingToken() external view returns (address);

    /// @notice no need to accruing interests since claimable amount is already included in totalAssets
    /// @dev convert amount of underlying token to shares
    function toShares(uint _amt) external view returns (uint);

    /// @dev convert amount of underlying token to shares
    function toShares(uint _amt, MathUpgradeable.Rounding _rounding) external view returns (uint);

    /// @notice no need to accruing interests since claimable amount is already included in totalAssets
    /// @dev convert amount of shares to underlying token
    function toAmt(uint _shares) external view returns (uint);

    /// @dev convert amount of shares to underlying token
    function toAmt(uint _shares, MathUpgradeable.Rounding _rounding) external view returns (uint);

    /// @notice no need to accruing interests since claimable amount is already included in totalAssets
    /// @dev total
    function totalAssets() external view returns (uint);
}

File 23 of 30 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 24 of 30 : 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 25 of 30 : 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);
        }
    }
}

File 26 of 30 : IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721ReceiverUpgradeable {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 27 of 30 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized != type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

File 28 of 30 : IBlast.sol
// SPDX-License-Identifier: None
import {GasMode} from './IGas.sol';

pragma solidity ^0.8.19;

enum YieldMode {
    AUTOMATIC,
    VOID,
    CLAIMABLE
}

interface IBlast {
    // configure
    function configureContract(address contractAddress, YieldMode _yield, GasMode gasMode, address governor) external;
    function configure(YieldMode _yield, GasMode gasMode, address governor) external;

    // base configuration options
    function configureClaimableYield() external;
    function configureClaimableYieldOnBehalf(address contractAddress) external;
    function configureAutomaticYield() external;
    function configureAutomaticYieldOnBehalf(address contractAddress) external;
    function configureVoidYield() external;
    function configureVoidYieldOnBehalf(address contractAddress) external;
    function configureClaimableGas() external;
    function configureClaimableGasOnBehalf(address contractAddress) external;
    function configureVoidGas() external;
    function configureVoidGasOnBehalf(address contractAddress) external;
    function configureGovernor(address _governor) external;
    function configureGovernorOnBehalf(address _newGovernor, address contractAddress) external;

    // claim yield
    function claimYield(address contractAddress, address recipientOfYield, uint amount) external returns (uint);
    function claimAllYield(address contractAddress, address recipientOfYield) external returns (uint);

    // claim gas
    function claimAllGas(address contractAddress, address recipientOfGas) external returns (uint);
    function claimGasAtMinClaimRate(address contractAddress, address recipientOfGas, uint minClaimRateBips)
        external
        returns (uint);
    function claimMaxGas(address contractAddress, address recipientOfGas) external returns (uint);
    function claimGas(address contractAddress, address recipientOfGas, uint gasToClaim, uint gasSecondsToConsume)
        external
        returns (uint);

    // read functions
    function readClaimableYield(address contractAddress) external view returns (uint);
    function readYieldConfiguration(address contractAddress) external view returns (uint8);
    function readGasParams(address contractAddress)
        external
        view
        returns (uint etherSeconds, uint etherBalance, uint lastUpdated, GasMode);
}

File 29 of 30 : AddressUpgradeable.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 AddressUpgradeable {
    /**
     * @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);
        }
    }
}

File 30 of 30 : IGas.sol
// SPDX-License-Identifier: None
pragma solidity ^0.8.19;

enum GasMode {
    VOID,
    CLAIMABLE
}

interface IGas {
    function readGasParams(address contractAddress) external view returns (uint, uint, uint, GasMode);
    function setGasMode(address contractAddress, GasMode mode) external;
    function claimGasAtMinClaimRate(address contractAddress, address recipient, uint minClaimRateBips)
        external
        returns (uint);
    function claimAll(address contractAddress, address recipient) external returns (uint);
    function claimMax(address contractAddress, address recipient) external returns (uint);
    function claim(address contractAddress, address recipient, uint gasToClaim, uint gasSecondsToConsume)
        external
        returns (uint);
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_initCore","type":"address"},{"internalType":"address","name":"_wweth","type":"address"},{"internalType":"address","name":"_wusdb","type":"address"},{"internalType":"address","name":"_acm","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"_helpers","type":"address[]"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"}],"name":"SetWhitelistedHelpers","type":"event"},{"inputs":[],"name":"ACM","outputs":[{"internalType":"contract IAccessControlManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CORE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"POS_MANAGER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WUSDB","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WWETH","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"_mode","type":"uint16"},{"internalType":"address","name":"_viewer","type":"address"}],"name":"createPos","outputs":[{"internalType":"uint256","name":"posId","type":"uint256"},{"internalType":"uint256","name":"initPosId","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"posId","type":"uint256"},{"internalType":"address","name":"viewer","type":"address"},{"internalType":"uint16","name":"mode","type":"uint16"},{"components":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"},{"components":[{"internalType":"address","name":"helper","type":"address"},{"internalType":"address","name":"tokenIn","type":"address"}],"internalType":"struct IMoneyMarketHook.RebaseHelperParams","name":"rebaseHelperParams","type":"tuple"}],"internalType":"struct IMoneyMarketHook.DepositParams[]","name":"depositParams","type":"tuple[]"},{"components":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"components":[{"internalType":"address","name":"helper","type":"address"},{"internalType":"address","name":"tokenIn","type":"address"}],"internalType":"struct IMoneyMarketHook.RebaseHelperParams","name":"rebaseHelperParams","type":"tuple"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct IMoneyMarketHook.WithdrawParams[]","name":"withdrawParams","type":"tuple[]"},{"components":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"amt","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"internalType":"struct IMoneyMarketHook.BorrowParams[]","name":"borrowParams","type":"tuple[]"},{"components":[{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"},{"components":[{"internalType":"address","name":"helper","type":"address"},{"internalType":"address","name":"tokenIn","type":"address"}],"internalType":"struct IMoneyMarketHook.RebaseHelperParams","name":"rebaseHelperParams","type":"tuple"}],"internalType":"struct IMoneyMarketHook.RepayParams[]","name":"repayParams","type":"tuple[]"},{"internalType":"uint256","name":"minHealth_e18","type":"uint256"},{"internalType":"bool","name":"returnNative","type":"bool"}],"internalType":"struct IMoneyMarketHook.OperationParams","name":"_params","type":"tuple"}],"name":"execute","outputs":[{"internalType":"uint256","name":"posId","type":"uint256"},{"internalType":"uint256","name":"initPosId","type":"uint256"},{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"initPosIds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastPosIds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_helpers","type":"address[]"},{"internalType":"bool","name":"_status","type":"bool"}],"name":"setWhitelistedHelpers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistedHelpers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

6101206040523480156200001257600080fd5b5060405162003d3e38038062003d3e833981016040819052620000359162000282565b8060007343000000000000000000000000000000000000029050806001600160a01b0316634e606c476040518163ffffffff1660e01b8152600401600060405180830381600087803b1580156200008b57600080fd5b505af1158015620000a0573d6000803e3d6000fd5b5050604051631d70c8d360e31b81523360048201526001600160a01b038416925063eb8646989150602401600060405180830381600087803b158015620000e657600080fd5b505af1158015620000fb573d6000803e3d6000fd5b5050506001600160a01b039283166080525050841660a08190526040805162278b6760e41b81529051630278b670916004808201926020929091908290030181865afa15801562000150573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001769190620002df565b6001600160a01b0390811660c05283811660e0528216610100526200019a620001a4565b5050505062000304565b600054610100900460ff1615620002115760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161462000263576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b80516001600160a01b03811681146200027d57600080fd5b919050565b600080600080608085870312156200029957600080fd5b620002a48562000265565b9350620002b46020860162000265565b9250620002c46040860162000265565b9150620002d46060860162000265565b905092959194509250565b600060208284031215620002f257600080fd5b620002fd8262000265565b9392505050565b60805160a05160c05160e051610100516138c9620004756000396000818161030c015281816106f8015281816107bf01528181610b1b01528181610bac01528181610c2601528181611c8701528181611cc201528181611d4801528181611e09015281816121b2015281816124ca0152818161291f0152818161295a01528181612a0a0152612a8e01526000818161026d015281816106720152818161078901528181610d4b01528181610df901528181610eee01528181610f68015281816119da01528181611a1b01528181611abf01528181611b5901528181611c06015281816121770152818161248f015281816126e201528181612723015281816127b30152818161286001526128f001526000818160d9015281816108bb015281816112de015281816118300152612c9c0152600081816102a1015281816103c301528181610969015281816115e001528181612de00152612e6b015260008181610340015261049501526138c96000f3fe6080604052600436106100c25760003560e01c80634f327fd81161007f5780638129fc1c116100595780638129fc1c146102c357806398d8abf0146102d8578063ad75d57c146102fa578063f9b80da11461032e57600080fd5b80634f327fd8146102395780635ad72a1c1461025b5780636b6c07741461028f57600080fd5b80630278b670146100c757806309be2638146101185780630a2f0bbd14610153578063127e12eb14610193578063150b7a02146101cb5780632fb4bf6414610204575b600080fd5b3480156100d357600080fd5b506100fb7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561012457600080fd5b5061014561013336600461305e565b60656020526000908152604090205481565b60405190815260200161010f565b34801561015f57600080fd5b5061018361016e36600461305e565b60676020526000908152604090205460ff1681565b604051901515815260200161010f565b34801561019f57600080fd5b506101456101ae366004613082565b606660209081526000928352604080842090915290825290205481565b3480156101d757600080fd5b506101eb6101e636600461311d565b610362565b6040516001600160e01b0319909116815260200161010f565b34801561021057600080fd5b5061022461021f3660046131dc565b610373565b6040805192835260208301919091520161010f565b34801561024557600080fd5b50610259610254366004613223565b61045a565b005b34801561026757600080fd5b506100fb7f000000000000000000000000000000000000000000000000000000000000000081565b34801561029b57600080fd5b506100fb7f000000000000000000000000000000000000000000000000000000000000000081565b3480156102cf57600080fd5b506102596105a1565b6102eb6102e63660046132a9565b610831565b60405161010f9392919061338a565b34801561030657600080fd5b506100fb7f000000000000000000000000000000000000000000000000000000000000000081565b34801561033a57600080fd5b506100fb7f000000000000000000000000000000000000000000000000000000000000000081565b630a85bd0160e11b5b949350505050565b33600090815260656020526040812080548291908290610392906133c8565b9182905550604051630bed2fd960e21b815261ffff861660048201526001600160a01b0385811660248301529193507f000000000000000000000000000000000000000000000000000000000000000090911690632fb4bf64906044016020604051808303816000875af115801561040e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061043291906133e1565b3360009081526066602090815260408083208684529091529020819055919491935090915050565b6040516312d9a6ad60e01b81527f8fbcb4375b910093bcf636b6b2f26b26eda2a29ef5a8ee7de44b5743c3bf9a2860048201523360248201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906312d9a6ad90604401600060405180830381600087803b1580156104e157600080fd5b505af11580156104f5573d6000803e3d6000fd5b5050505060005b8281101561056057816067600086868581811061051b5761051b6133fa565b9050602002016020810190610530919061305e565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790556001016104fc565b507f3a6fcf102feea447bad9bc18ed415c630a66c2a24498ba6c15e06e26a6fb8afa83838360405161059493929190613410565b60405180910390a1505050565b600054610100900460ff16158080156105c15750600054600160ff909116105b806105db5750303b1580156105db575060005460ff166001145b6106435760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015610666576000805461ff0019166101001790555b61066e611088565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f29190613469565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015610754573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107789190613469565b90506107b06001600160a01b0383167f00000000000000000000000000000000000000000000000000000000000000006000196110b9565b6107e66001600160a01b0382167f00000000000000000000000000000000000000000000000000000000000000006000196110b9565b5050801561082e576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b600080606061083e611206565b83356000036108745761086a61085a6060860160408701613486565b61021f604087016020880161305e565b909350915061093a565b33600090815260666020908152604080832087358085529252918290205491516331a9108f60e11b81526004810183905290945090925061093a9030906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636352211e90602401602060405180830381865afa158015610902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109269190613469565b6001600160a01b031614632331303461125f565b61094482856112a8565b60405163a72ca39b60e01b8152600481018490529091506109e7906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063a72ca39b906024016020604051808303816000875af11580156109b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d691906133e1565b8560e001351115632331303261125f565b60005b6109f760808601866134a3565b9050811015610b02576000610a0f60808701876134a3565b83818110610a1f57610a1f6133fa565b610a3892606060a090920201908101915060400161305e565b90506001600160a01b03811615610af9576001600160a01b0381166375f26e63610a6560808901896134a3565b85818110610a7557610a756133fa565b905060a002016080016020810190610a8d919061305e565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526024016020604051808303816000875af1158015610ad3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610af791906133e1565b505b506001016109ea565b506040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610b6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b8e91906133e1565b90508015610d3357604051636f074d1f60e11b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063de0e9a3e906024016020604051808303816000875af1158015610bfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2191906133e1565b5060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca69190613469565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610cf0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1491906133e1565b90508015610d3057610d306001600160a01b0383163383611666565b50505b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610d9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbe91906133e1565b9050801561107557610dd8610120870161010088016134f3565b15610ed8578015610e70576040516334b10a6d60e01b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906334b10a6d906024016020604051808303816000875af1158015610e4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6e91906133e1565b505b478015610ed257604051600090339047908381818185875af1925050503d8060008114610eb9576040519150601f19603f3d011682016040523d82523d6000602084013e610ebe565b606091505b50509050610ed081632331303361125f565b505b50611075565b604051636f074d1f60e11b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063de0e9a3e906024016020604051808303816000875af1158015610f3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6391906133e1565b5060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe89190613469565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611032573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061105691906133e1565b90508015611072576110726001600160a01b0383163383611666565b50505b50506110816001603355565b9193909250565b600054610100900460ff166110af5760405162461bcd60e51b815260040161063a90613510565b6110b761169d565b565b8015806111335750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561110d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061113191906133e1565b155b61119e5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161063a565b6040516001600160a01b03831660248201526044810182905261120190849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526116c4565b505050565b6002603354036112585760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161063a565b6002603355565b816112a4576040516001600160e01b031960e083901b16602082015260240160408051601f198184030181529082905262461bcd60e51b825261063a9160040161355b565b5050565b606060006112bb83830160408501613486565b61ffff161580159061136c5750604051633e4b135360e21b8152600481018590527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063f92c4d4c90602401602060405180830381865afa15801561132d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611351919061356e565b61ffff166113656060850160408601613486565b61ffff1614155b90506060600061137e8583018661358b565b61138a915060026135d5565b61139760a08701876135f2565b9050846113a55760006113a8565b60015b60ff166113b860808901896134a3565b6113c4915060026135d5565b6113d160c08a018a61358b565b6113dc92915061363b565b6113e6919061363b565b6113f0919061363b565b6113fa919061363b565b90508067ffffffffffffffff811115611415576114156130ae565b60405190808252806020026020018201604052801561144857816020015b60608152602001906001900390816114335790505b509150600090506114b881838861146260c08a018a61358b565b808060200260200160405190810160405280939291908181526020016000905b828210156114ae5761149f6080830286013681900381019061364e565b81526020019060010190611482565b5050505050611799565b925090506114e68183886114cf60808a018a6134a3565b6114e16101208c016101008d016134f3565b611f7f565b92509050821561157d57638802944160e01b866115096060880160408901613486565b604051602481019290925261ffff166044820152606401604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050828281518110611565576115656133fa565b602002602001018190525061157a8160010190565b90505b6115a781838861159060a08a018a6135f2565b6115a26101208c016101008d016134f3565b6123c3565b925090506115c38183886115be60608a018a61358b565b6125f0565b604051631592ca1b60e31b81529093509091506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063ac9650d890611615908590600401613703565b6000604051808303816000875af1158015611634573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261165c9190810190613716565b9695505050505050565b6040516001600160a01b03831660248201526044810182905261120190849063a9059cbb60e01b906064016111ca565b6001603355565b600054610100900460ff166116965760405162461bcd60e51b815260040161063a90613510565b6000611719826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612db49092919063ffffffff16565b905080516000148061173a57508080602001905181019061173a9190613815565b6112015760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161063a565b6000606060005b8351811015611f745760008482815181106117bd576117bd6133fa565b6020026020010151600001516001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015611806573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182a9190613469565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166310e28e7188888681518110611870576118706133fa565b6020026020010151600001516040518363ffffffff1660e01b81526004016118ab9291909182526001600160a01b0316602082015260400190565b602060405180830381865afa1580156118c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ec91906133e1565b9050600081878581518110611903576119036133fa565b602002602001015160200151111561191b578161193a565b86848151811061192d5761192d6133fa565b6020026020010151602001515b90506000878581518110611950576119506133fa565b6020026020010151600001516001600160a01b03166331a86fe1836040518263ffffffff1660e01b815260040161198991815260200190565b6020604051808303816000875af11580156119a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119cc91906133e1565b90506119d88482612dc3565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b031603611c855760003415611aa1577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636ad481f3346040518263ffffffff1660e01b815260040160206040518083038185885af1158015611a79573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611a9e91906133e1565b90505b808211611aaf576000611ab9565b611ab98183613832565b915060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630d331e198460016040518363ffffffff1660e01b8152600401611b0c929190613845565b602060405180830381865afa158015611b29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b4d91906133e1565b90508015611c7e5760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015611bb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd99190613469565b9050611bf06001600160a01b038216333085612e92565b604051630ea598cb60e41b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063ea598cb0906024016020604051808303816000875af1158015611c57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c7b91906133e1565b50505b5050611e9b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316846001600160a01b031603611e865760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d429190613469565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630d331e198460016040518363ffffffff1660e01b8152600401611d95929190613845565b602060405180830381865afa158015611db2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dd691906133e1565b90508015611c7e57611df36001600160a01b038316333084612e92565b604051630ea598cb60e41b8152600481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063ea598cb0906024016020604051808303816000875af1158015611e5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e7e91906133e1565b505050611e9b565b611e9b6001600160a01b038516333084612e92565b638cd2e0c760e01b888681518110611eb557611eb56133fa565b602002602001015160000151898781518110611ed357611ed36133fa565b60209081029190910181015101516040516001600160a01b0390921660248301526044820152606481018b9052608401604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050508a8c81518110611f4857611f486133fa565b6020026020010181905250611f5d8b60010190565b9a5050505050611f6d8160010190565b90506117a0565b509495939450505050565b6000606060005b848110156123b6576342d91bc360e01b87878784818110611fa957611fa96133fa565b611fbf92602060a090920201908101915061305e565b888885818110611fd157611fd16133fa565b905060a0020160200135898986818110611fed57611fed6133fa565b61200392602060a090920201908101915061305e565b60405160248101949094526001600160a01b039283166044850152606484019190915216608482015260a401604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050888a81518110612074576120746133fa565b60200260200101819052506120898960010190565b9850600086868381811061209f5761209f6133fa565b6120b892606060a090920201908101915060400161305e565b905060008787848181106120ce576120ce6133fa565b6120e492602060a090920201908101915061305e565b6001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015612121573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121459190613469565b9050600088888581811061215b5761215b6133fa565b905060a002016080016020810190612173919061305e565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031614806121e657507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b0316145b156121f25750306122f8565b6001600160a01b038316156122f8576001600160a01b03831660009081526067602052604090205461222b9060ff16632331303761125f565b6122f5826001600160a01b03168a8a8781811061224a5761224a6133fa565b61226392608060a090920201908101915060600161305e565b6001600160a01b03161480156122eb5750826001600160a01b0316846001600160a01b0316638812805d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e09190613469565b6001600160a01b0316145b632332303461125f565b50815b637fe6bc3d60e01b898986818110612312576123126133fa565b61232892602060a090920201908101915061305e565b6040516001600160a01b0391821660248201529083166044820152606401604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050508b8d8151811061238b5761238b6133fa565b60200260200101819052506123a08c60010190565b9b505050506123af8160010190565b9050611f86565b5096979596505050505050565b6000606060005b848110156123b65760008686838181106123e6576123e66133fa565b90506060020160400160208101906123fe919061305e565b90506000878784818110612414576124146133fa565b61242a926020606090920201908101915061305e565b6001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015612467573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248b9190613469565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b031614806124fe57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b0316145b15612507573091505b6308ba54eb60e21b888885818110612521576125216133fa565b612537926020606090920201908101915061305e565b898986818110612549576125496133fa565b6040516001600160a01b03948516602482015260206060909202939093010135604483015250606481018c9052908416608482015260a401604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050508a8c815181106125c6576125c66133fa565b60200260200101819052506125db8b60010190565b9a5050506125e98160010190565b90506123ca565b6000606060005b83811015612da8576000858583818110612613576126136133fa565b612629926020608090920201908101915061305e565b9050600086868481811061263f5761263f6133fa565b9050608002016020013590506000826001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa15801561268b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126af9190613469565b905060008888868181106126c5576126c56133fa565b6126de926060608090920201908101915060400161305e565b90507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b03160361291d57600034156127a9577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636ad481f3346040518263ffffffff1660e01b815260040160206040518083038185885af1158015612781573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906127a691906133e1565b90505b83156128e35760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa15801561280f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128339190613469565b905061284a6001600160a01b038216333088612e92565b604051630ea598cb60e41b8152600481018690527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063ea598cb0906024016020604051808303816000875af11580156128b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128d591906133e1565b6128df908361363b565b9150505b6129176001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168683611666565b50612c86565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316826001600160a01b031603612abc5760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129da9190613469565b90506129f16001600160a01b038216333087612e92565b604051630ea598cb60e41b8152600481018590526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063ea598cb0906024016020604051808303816000875af1158015612a5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7f91906133e1565b9050612ab56001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168783611666565b5050612c86565b6001600160a01b03811615612c71576000898987818110612adf57612adf6133fa565b612af692608091820201908101915060600161305e565b6001600160a01b038316600090815260676020526040902054909150612b239060ff16632331303761125f565b612b6e816001600160a01b0316836001600160a01b0316634abaf9216040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122bc573d6000803e3d6000fd5b612bf1836001600160a01b0316836001600160a01b0316638812805d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bdd9190613469565b6001600160a01b031614632332303561125f565b612c066001600160a01b038216338487612e92565b6040516223276f60e41b81526001600160a01b03868116600483015283169063023276f0906024016020604051808303816000875af1158015612c4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ab591906133e1565b612c866001600160a01b038316338686612e92565b604080516001600160a01b0386811660248301527f0000000000000000000000000000000000000000000000000000000000000000166044808301919091528251808303909101815260649091019091526020810180516001600160e01b0316634a8db60160e11b1790528b518c908e908110612d0557612d056133fa565b6020026020010181905250612d1a8c60010190565b60408051602481018d90526001600160a01b0387166044808301919091528251808303909101815260649091019091526020810180516001600160e01b031663abf4dd3960e01b1790528c51919d50908c908e908110612d7c57612d7c6133fa565b6020026020010181905250612d918c60010190565b9b5050505050612da18160010190565b90506125f7565b50959694955050505050565b606061036b8484600085612ed0565b604051636eb1769f60e11b81523060048201526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116602483015282919084169063dd62ed3e90604401602060405180830381865afa158015612e32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e5691906133e1565b10156112a4576112a46001600160a01b0383167f00000000000000000000000000000000000000000000000000000000000000006000196110b9565b6040516001600160a01b0380851660248301528316604482015260648101829052612eca9085906323b872dd60e01b906084016111ca565b50505050565b606082471015612f315760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161063a565b600080866001600160a01b03168587604051612f4d9190613877565b60006040518083038185875af1925050503d8060008114612f8a576040519150601f19603f3d011682016040523d82523d6000602084013e612f8f565b606091505b5091509150612fa087838387612fab565b979650505050505050565b6060831561301a578251600003613013576001600160a01b0385163b6130135760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161063a565b508161036b565b61036b838381511561302f5781518083602001fd5b8060405162461bcd60e51b815260040161063a919061355b565b6001600160a01b038116811461082e57600080fd5b60006020828403121561307057600080fd5b813561307b81613049565b9392505050565b6000806040838503121561309557600080fd5b82356130a081613049565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156130ed576130ed6130ae565b604052919050565b600067ffffffffffffffff82111561310f5761310f6130ae565b50601f01601f191660200190565b6000806000806080858703121561313357600080fd5b843561313e81613049565b9350602085013561314e81613049565b925060408501359150606085013567ffffffffffffffff81111561317157600080fd5b8501601f8101871361318257600080fd5b8035613195613190826130f5565b6130c4565b8181528860208385010111156131aa57600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b61ffff8116811461082e57600080fd5b600080604083850312156131ef57600080fd5b82356131fa816131cc565b9150602083013561320a81613049565b809150509250929050565b801515811461082e57600080fd5b60008060006040848603121561323857600080fd5b833567ffffffffffffffff8082111561325057600080fd5b818601915086601f83011261326457600080fd5b81358181111561327357600080fd5b8760208260051b850101111561328857600080fd5b6020928301955093505084013561329e81613215565b809150509250925092565b6000602082840312156132bb57600080fd5b813567ffffffffffffffff8111156132d257600080fd5b8201610120818503121561307b57600080fd5b60005b838110156133005781810151838201526020016132e8565b50506000910152565b600081518084526133218160208601602086016132e5565b601f01601f19169290920160200192915050565b600081518084526020808501808196508360051b8101915082860160005b8581101561337d57828403895261336b848351613309565b98850198935090840190600101613353565b5091979650505050505050565b8381528260208201526060604082015260006133a96060830184613335565b95945050505050565b634e487b7160e01b600052601160045260246000fd5b6000600182016133da576133da6133b2565b5060010190565b6000602082840312156133f357600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b6040808252810183905260008460608301825b8681101561345357823561343681613049565b6001600160a01b0316825260209283019290910190600101613423565b5080925050508215156020830152949350505050565b60006020828403121561347b57600080fd5b815161307b81613049565b60006020828403121561349857600080fd5b813561307b816131cc565b6000808335601e198436030181126134ba57600080fd5b83018035915067ffffffffffffffff8211156134d557600080fd5b602001915060a0810236038213156134ec57600080fd5b9250929050565b60006020828403121561350557600080fd5b813561307b81613215565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208152600061307b6020830184613309565b60006020828403121561358057600080fd5b815161307b816131cc565b6000808335601e198436030181126135a257600080fd5b83018035915067ffffffffffffffff8211156135bd57600080fd5b6020019150600781901b36038213156134ec57600080fd5b80820281158282048414176135ec576135ec6133b2565b92915050565b6000808335601e1984360301811261360957600080fd5b83018035915067ffffffffffffffff82111561362457600080fd5b60200191506060810236038213156134ec57600080fd5b808201808211156135ec576135ec6133b2565b6000818303608081121561366157600080fd5b604080516060810167ffffffffffffffff8282108183111715613686576136866130ae565b90835285359061369582613049565b8183526020870135602084015283603f19860112156136b357600080fd5b83519450838501915084821081831117156136d0576136d06130ae565b508252848201356136e081613049565b835260608501356136f081613049565b6020840152908101919091529392505050565b60208152600061307b6020830184613335565b6000602080838503121561372957600080fd5b825167ffffffffffffffff8082111561374157600080fd5b818501915085601f83011261375557600080fd5b815181811115613767576137676130ae565b8060051b6137768582016130c4565b918252838101850191858101908984111561379057600080fd5b86860192505b83831015613808578251858111156137ae5760008081fd5b8601603f81018b136137c05760008081fd5b8781015160406137d2613190836130f5565b8281528d828486010111156137e75760008081fd5b6137f6838c83018487016132e5565b85525050509186019190860190613796565b9998505050505050505050565b60006020828403121561382757600080fd5b815161307b81613215565b818103818111156135ec576135ec6133b2565b828152604081016003831061386a57634e487b7160e01b600052602160045260246000fd5b8260208301529392505050565b600082516138898184602087016132e5565b919091019291505056fea2646970667358221220f21d6079d31eb0315266e3b3c29363f9d7fcf901fa7fbcdf7ffe7153fe7fdea664736f6c63430008130033000000000000000000000000a7d36f2106b5a5d528a7e2e7a3f436d703113a10000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d210000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a000000000000000000000000265daa697489968aebd650c665f4fb241b560785

Deployed Bytecode

0x6080604052600436106100c25760003560e01c80634f327fd81161007f5780638129fc1c116100595780638129fc1c146102c357806398d8abf0146102d8578063ad75d57c146102fa578063f9b80da11461032e57600080fd5b80634f327fd8146102395780635ad72a1c1461025b5780636b6c07741461028f57600080fd5b80630278b670146100c757806309be2638146101185780630a2f0bbd14610153578063127e12eb14610193578063150b7a02146101cb5780632fb4bf6414610204575b600080fd5b3480156100d357600080fd5b506100fb7f000000000000000000000000a0e172f8bdc18854903959b8f7f73f0d332633fe81565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561012457600080fd5b5061014561013336600461305e565b60656020526000908152604090205481565b60405190815260200161010f565b34801561015f57600080fd5b5061018361016e36600461305e565b60676020526000908152604090205460ff1681565b604051901515815260200161010f565b34801561019f57600080fd5b506101456101ae366004613082565b606660209081526000928352604080842090915290825290205481565b3480156101d757600080fd5b506101eb6101e636600461311d565b610362565b6040516001600160e01b0319909116815260200161010f565b34801561021057600080fd5b5061022461021f3660046131dc565b610373565b6040805192835260208301919091520161010f565b34801561024557600080fd5b50610259610254366004613223565b61045a565b005b34801561026757600080fd5b506100fb7f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d2181565b34801561029b57600080fd5b506100fb7f000000000000000000000000a7d36f2106b5a5d528a7e2e7a3f436d703113a1081565b3480156102cf57600080fd5b506102596105a1565b6102eb6102e63660046132a9565b610831565b60405161010f9392919061338a565b34801561030657600080fd5b506100fb7f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a81565b34801561033a57600080fd5b506100fb7f000000000000000000000000265daa697489968aebd650c665f4fb241b56078581565b630a85bd0160e11b5b949350505050565b33600090815260656020526040812080548291908290610392906133c8565b9182905550604051630bed2fd960e21b815261ffff861660048201526001600160a01b0385811660248301529193507f000000000000000000000000a7d36f2106b5a5d528a7e2e7a3f436d703113a1090911690632fb4bf64906044016020604051808303816000875af115801561040e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061043291906133e1565b3360009081526066602090815260408083208684529091529020819055919491935090915050565b6040516312d9a6ad60e01b81527f8fbcb4375b910093bcf636b6b2f26b26eda2a29ef5a8ee7de44b5743c3bf9a2860048201523360248201527f000000000000000000000000265daa697489968aebd650c665f4fb241b5607856001600160a01b0316906312d9a6ad90604401600060405180830381600087803b1580156104e157600080fd5b505af11580156104f5573d6000803e3d6000fd5b5050505060005b8281101561056057816067600086868581811061051b5761051b6133fa565b9050602002016020810190610530919061305e565b6001600160a01b031681526020810191909152604001600020805460ff19169115159190911790556001016104fc565b507f3a6fcf102feea447bad9bc18ed415c630a66c2a24498ba6c15e06e26a6fb8afa83838360405161059493929190613410565b60405180910390a1505050565b600054610100900460ff16158080156105c15750600054600160ff909116105b806105db5750303b1580156105db575060005460ff166001145b6106435760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff191660011790558015610666576000805461ff0019166101001790555b61066e611088565b60007f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f29190613469565b905060007f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015610754573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107789190613469565b90506107b06001600160a01b0383167f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216000196110b9565b6107e66001600160a01b0382167f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6000196110b9565b5050801561082e576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b600080606061083e611206565b83356000036108745761086a61085a6060860160408701613486565b61021f604087016020880161305e565b909350915061093a565b33600090815260666020908152604080832087358085529252918290205491516331a9108f60e11b81526004810183905290945090925061093a9030906001600160a01b037f000000000000000000000000a0e172f8bdc18854903959b8f7f73f0d332633fe1690636352211e90602401602060405180830381865afa158015610902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109269190613469565b6001600160a01b031614632331303461125f565b61094482856112a8565b60405163a72ca39b60e01b8152600481018490529091506109e7906001600160a01b037f000000000000000000000000a7d36f2106b5a5d528a7e2e7a3f436d703113a10169063a72ca39b906024016020604051808303816000875af11580156109b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d691906133e1565b8560e001351115632331303261125f565b60005b6109f760808601866134a3565b9050811015610b02576000610a0f60808701876134a3565b83818110610a1f57610a1f6133fa565b610a3892606060a090920201908101915060400161305e565b90506001600160a01b03811615610af9576001600160a01b0381166375f26e63610a6560808901896134a3565b85818110610a7557610a756133fa565b905060a002016080016020810190610a8d919061305e565b6040516001600160e01b031960e084901b1681526001600160a01b0390911660048201526024016020604051808303816000875af1158015610ad3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610af791906133e1565b505b506001016109ea565b506040516370a0823160e01b81523060048201526000907f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6001600160a01b0316906370a0823190602401602060405180830381865afa158015610b6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b8e91906133e1565b90508015610d3357604051636f074d1f60e11b8152600481018290527f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6001600160a01b03169063de0e9a3e906024016020604051808303816000875af1158015610bfd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2191906133e1565b5060007f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c82573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca69190613469565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610cf0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d1491906133e1565b90508015610d3057610d306001600160a01b0383163383611666565b50505b6040516370a0823160e01b81523060048201526000907f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b0316906370a0823190602401602060405180830381865afa158015610d9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbe91906133e1565b9050801561107557610dd8610120870161010088016134f3565b15610ed8578015610e70576040516334b10a6d60e01b8152600481018290527f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b0316906334b10a6d906024016020604051808303816000875af1158015610e4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6e91906133e1565b505b478015610ed257604051600090339047908381818185875af1925050503d8060008114610eb9576040519150601f19603f3d011682016040523d82523d6000602084013e610ebe565b606091505b50509050610ed081632331303361125f565b505b50611075565b604051636f074d1f60e11b8152600481018290527f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b03169063de0e9a3e906024016020604051808303816000875af1158015610f3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6391906133e1565b5060007f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe89190613469565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611032573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061105691906133e1565b90508015611072576110726001600160a01b0383163383611666565b50505b50506110816001603355565b9193909250565b600054610100900460ff166110af5760405162461bcd60e51b815260040161063a90613510565b6110b761169d565b565b8015806111335750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa15801561110d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061113191906133e1565b155b61119e5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161063a565b6040516001600160a01b03831660248201526044810182905261120190849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526116c4565b505050565b6002603354036112585760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161063a565b6002603355565b816112a4576040516001600160e01b031960e083901b16602082015260240160408051601f198184030181529082905262461bcd60e51b825261063a9160040161355b565b5050565b606060006112bb83830160408501613486565b61ffff161580159061136c5750604051633e4b135360e21b8152600481018590527f000000000000000000000000a0e172f8bdc18854903959b8f7f73f0d332633fe6001600160a01b03169063f92c4d4c90602401602060405180830381865afa15801561132d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611351919061356e565b61ffff166113656060850160408601613486565b61ffff1614155b90506060600061137e8583018661358b565b61138a915060026135d5565b61139760a08701876135f2565b9050846113a55760006113a8565b60015b60ff166113b860808901896134a3565b6113c4915060026135d5565b6113d160c08a018a61358b565b6113dc92915061363b565b6113e6919061363b565b6113f0919061363b565b6113fa919061363b565b90508067ffffffffffffffff811115611415576114156130ae565b60405190808252806020026020018201604052801561144857816020015b60608152602001906001900390816114335790505b509150600090506114b881838861146260c08a018a61358b565b808060200260200160405190810160405280939291908181526020016000905b828210156114ae5761149f6080830286013681900381019061364e565b81526020019060010190611482565b5050505050611799565b925090506114e68183886114cf60808a018a6134a3565b6114e16101208c016101008d016134f3565b611f7f565b92509050821561157d57638802944160e01b866115096060880160408901613486565b604051602481019290925261ffff166044820152606401604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050828281518110611565576115656133fa565b602002602001018190525061157a8160010190565b90505b6115a781838861159060a08a018a6135f2565b6115a26101208c016101008d016134f3565b6123c3565b925090506115c38183886115be60608a018a61358b565b6125f0565b604051631592ca1b60e31b81529093509091506001600160a01b037f000000000000000000000000a7d36f2106b5a5d528a7e2e7a3f436d703113a10169063ac9650d890611615908590600401613703565b6000604051808303816000875af1158015611634573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261165c9190810190613716565b9695505050505050565b6040516001600160a01b03831660248201526044810182905261120190849063a9059cbb60e01b906064016111ca565b6001603355565b600054610100900460ff166116965760405162461bcd60e51b815260040161063a90613510565b6000611719826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612db49092919063ffffffff16565b905080516000148061173a57508080602001905181019061173a9190613815565b6112015760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161063a565b6000606060005b8351811015611f745760008482815181106117bd576117bd6133fa565b6020026020010151600001516001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015611806573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061182a9190613469565b905060007f000000000000000000000000a0e172f8bdc18854903959b8f7f73f0d332633fe6001600160a01b03166310e28e7188888681518110611870576118706133fa565b6020026020010151600001516040518363ffffffff1660e01b81526004016118ab9291909182526001600160a01b0316602082015260400190565b602060405180830381865afa1580156118c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118ec91906133e1565b9050600081878581518110611903576119036133fa565b602002602001015160200151111561191b578161193a565b86848151811061192d5761192d6133fa565b6020026020010151602001515b90506000878581518110611950576119506133fa565b6020026020010151600001516001600160a01b03166331a86fe1836040518263ffffffff1660e01b815260040161198991815260200190565b6020604051808303816000875af11580156119a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119cc91906133e1565b90506119d88482612dc3565b7f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b0316846001600160a01b031603611c855760003415611aa1577f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b0316636ad481f3346040518263ffffffff1660e01b815260040160206040518083038185885af1158015611a79573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190611a9e91906133e1565b90505b808211611aaf576000611ab9565b611ab98183613832565b915060007f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b0316630d331e198460016040518363ffffffff1660e01b8152600401611b0c929190613845565b602060405180830381865afa158015611b29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b4d91906133e1565b90508015611c7e5760007f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015611bb5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd99190613469565b9050611bf06001600160a01b038216333085612e92565b604051630ea598cb60e41b8152600481018390527f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b03169063ea598cb0906024016020604051808303816000875af1158015611c57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c7b91906133e1565b50505b5050611e9b565b7f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6001600160a01b0316846001600160a01b031603611e865760007f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d429190613469565b905060007f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6001600160a01b0316630d331e198460016040518363ffffffff1660e01b8152600401611d95929190613845565b602060405180830381865afa158015611db2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dd691906133e1565b90508015611c7e57611df36001600160a01b038316333084612e92565b604051630ea598cb60e41b8152600481018290527f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6001600160a01b03169063ea598cb0906024016020604051808303816000875af1158015611e5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e7e91906133e1565b505050611e9b565b611e9b6001600160a01b038516333084612e92565b638cd2e0c760e01b888681518110611eb557611eb56133fa565b602002602001015160000151898781518110611ed357611ed36133fa565b60209081029190910181015101516040516001600160a01b0390921660248301526044820152606481018b9052608401604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050508a8c81518110611f4857611f486133fa565b6020026020010181905250611f5d8b60010190565b9a5050505050611f6d8160010190565b90506117a0565b509495939450505050565b6000606060005b848110156123b6576342d91bc360e01b87878784818110611fa957611fa96133fa565b611fbf92602060a090920201908101915061305e565b888885818110611fd157611fd16133fa565b905060a0020160200135898986818110611fed57611fed6133fa565b61200392602060a090920201908101915061305e565b60405160248101949094526001600160a01b039283166044850152606484019190915216608482015260a401604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050888a81518110612074576120746133fa565b60200260200101819052506120898960010190565b9850600086868381811061209f5761209f6133fa565b6120b892606060a090920201908101915060400161305e565b905060008787848181106120ce576120ce6133fa565b6120e492602060a090920201908101915061305e565b6001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015612121573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121459190613469565b9050600088888581811061215b5761215b6133fa565b905060a002016080016020810190612173919061305e565b90507f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b0316826001600160a01b031614806121e657507f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6001600160a01b0316826001600160a01b0316145b156121f25750306122f8565b6001600160a01b038316156122f8576001600160a01b03831660009081526067602052604090205461222b9060ff16632331303761125f565b6122f5826001600160a01b03168a8a8781811061224a5761224a6133fa565b61226392608060a090920201908101915060600161305e565b6001600160a01b03161480156122eb5750826001600160a01b0316846001600160a01b0316638812805d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122e09190613469565b6001600160a01b0316145b632332303461125f565b50815b637fe6bc3d60e01b898986818110612312576123126133fa565b61232892602060a090920201908101915061305e565b6040516001600160a01b0391821660248201529083166044820152606401604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050508b8d8151811061238b5761238b6133fa565b60200260200101819052506123a08c60010190565b9b505050506123af8160010190565b9050611f86565b5096979596505050505050565b6000606060005b848110156123b65760008686838181106123e6576123e66133fa565b90506060020160400160208101906123fe919061305e565b90506000878784818110612414576124146133fa565b61242a926020606090920201908101915061305e565b6001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa158015612467573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248b9190613469565b90507f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b0316816001600160a01b031614806124fe57507f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6001600160a01b0316816001600160a01b0316145b15612507573091505b6308ba54eb60e21b888885818110612521576125216133fa565b612537926020606090920201908101915061305e565b898986818110612549576125496133fa565b6040516001600160a01b03948516602482015260206060909202939093010135604483015250606481018c9052908416608482015260a401604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050508a8c815181106125c6576125c66133fa565b60200260200101819052506125db8b60010190565b9a5050506125e98160010190565b90506123ca565b6000606060005b83811015612da8576000858583818110612613576126136133fa565b612629926020608090920201908101915061305e565b9050600086868481811061263f5761263f6133fa565b9050608002016020013590506000826001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa15801561268b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126af9190613469565b905060008888868181106126c5576126c56133fa565b6126de926060608090920201908101915060400161305e565b90507f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b0316826001600160a01b03160361291d57600034156127a9577f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b0316636ad481f3346040518263ffffffff1660e01b815260040160206040518083038185885af1158015612781573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906127a691906133e1565b90505b83156128e35760007f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa15801561280f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128339190613469565b905061284a6001600160a01b038216333088612e92565b604051630ea598cb60e41b8152600481018690527f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d216001600160a01b03169063ea598cb0906024016020604051808303816000875af11580156128b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128d591906133e1565b6128df908361363b565b9150505b6129176001600160a01b037f000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d21168683611666565b50612c86565b7f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6001600160a01b0316826001600160a01b031603612abc5760007f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6001600160a01b0316632495a5996040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129da9190613469565b90506129f16001600160a01b038216333087612e92565b604051630ea598cb60e41b8152600481018590526000907f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a6001600160a01b03169063ea598cb0906024016020604051808303816000875af1158015612a5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7f91906133e1565b9050612ab56001600160a01b037f0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a168783611666565b5050612c86565b6001600160a01b03811615612c71576000898987818110612adf57612adf6133fa565b612af692608091820201908101915060600161305e565b6001600160a01b038316600090815260676020526040902054909150612b239060ff16632331303761125f565b612b6e816001600160a01b0316836001600160a01b0316634abaf9216040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122bc573d6000803e3d6000fd5b612bf1836001600160a01b0316836001600160a01b0316638812805d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bdd9190613469565b6001600160a01b031614632332303561125f565b612c066001600160a01b038216338487612e92565b6040516223276f60e41b81526001600160a01b03868116600483015283169063023276f0906024016020604051808303816000875af1158015612c4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ab591906133e1565b612c866001600160a01b038316338686612e92565b604080516001600160a01b0386811660248301527f000000000000000000000000a0e172f8bdc18854903959b8f7f73f0d332633fe166044808301919091528251808303909101815260649091019091526020810180516001600160e01b0316634a8db60160e11b1790528b518c908e908110612d0557612d056133fa565b6020026020010181905250612d1a8c60010190565b60408051602481018d90526001600160a01b0387166044808301919091528251808303909101815260649091019091526020810180516001600160e01b031663abf4dd3960e01b1790528c51919d50908c908e908110612d7c57612d7c6133fa565b6020026020010181905250612d918c60010190565b9b5050505050612da18160010190565b90506125f7565b50959694955050505050565b606061036b8484600085612ed0565b604051636eb1769f60e11b81523060048201526001600160a01b037f000000000000000000000000a7d36f2106b5a5d528a7e2e7a3f436d703113a108116602483015282919084169063dd62ed3e90604401602060405180830381865afa158015612e32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e5691906133e1565b10156112a4576112a46001600160a01b0383167f000000000000000000000000a7d36f2106b5a5d528a7e2e7a3f436d703113a106000196110b9565b6040516001600160a01b0380851660248301528316604482015260648101829052612eca9085906323b872dd60e01b906084016111ca565b50505050565b606082471015612f315760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161063a565b600080866001600160a01b03168587604051612f4d9190613877565b60006040518083038185875af1925050503d8060008114612f8a576040519150601f19603f3d011682016040523d82523d6000602084013e612f8f565b606091505b5091509150612fa087838387612fab565b979650505050505050565b6060831561301a578251600003613013576001600160a01b0385163b6130135760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161063a565b508161036b565b61036b838381511561302f5781518083602001fd5b8060405162461bcd60e51b815260040161063a919061355b565b6001600160a01b038116811461082e57600080fd5b60006020828403121561307057600080fd5b813561307b81613049565b9392505050565b6000806040838503121561309557600080fd5b82356130a081613049565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff811182821017156130ed576130ed6130ae565b604052919050565b600067ffffffffffffffff82111561310f5761310f6130ae565b50601f01601f191660200190565b6000806000806080858703121561313357600080fd5b843561313e81613049565b9350602085013561314e81613049565b925060408501359150606085013567ffffffffffffffff81111561317157600080fd5b8501601f8101871361318257600080fd5b8035613195613190826130f5565b6130c4565b8181528860208385010111156131aa57600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b61ffff8116811461082e57600080fd5b600080604083850312156131ef57600080fd5b82356131fa816131cc565b9150602083013561320a81613049565b809150509250929050565b801515811461082e57600080fd5b60008060006040848603121561323857600080fd5b833567ffffffffffffffff8082111561325057600080fd5b818601915086601f83011261326457600080fd5b81358181111561327357600080fd5b8760208260051b850101111561328857600080fd5b6020928301955093505084013561329e81613215565b809150509250925092565b6000602082840312156132bb57600080fd5b813567ffffffffffffffff8111156132d257600080fd5b8201610120818503121561307b57600080fd5b60005b838110156133005781810151838201526020016132e8565b50506000910152565b600081518084526133218160208601602086016132e5565b601f01601f19169290920160200192915050565b600081518084526020808501808196508360051b8101915082860160005b8581101561337d57828403895261336b848351613309565b98850198935090840190600101613353565b5091979650505050505050565b8381528260208201526060604082015260006133a96060830184613335565b95945050505050565b634e487b7160e01b600052601160045260246000fd5b6000600182016133da576133da6133b2565b5060010190565b6000602082840312156133f357600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b6040808252810183905260008460608301825b8681101561345357823561343681613049565b6001600160a01b0316825260209283019290910190600101613423565b5080925050508215156020830152949350505050565b60006020828403121561347b57600080fd5b815161307b81613049565b60006020828403121561349857600080fd5b813561307b816131cc565b6000808335601e198436030181126134ba57600080fd5b83018035915067ffffffffffffffff8211156134d557600080fd5b602001915060a0810236038213156134ec57600080fd5b9250929050565b60006020828403121561350557600080fd5b813561307b81613215565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208152600061307b6020830184613309565b60006020828403121561358057600080fd5b815161307b816131cc565b6000808335601e198436030181126135a257600080fd5b83018035915067ffffffffffffffff8211156135bd57600080fd5b6020019150600781901b36038213156134ec57600080fd5b80820281158282048414176135ec576135ec6133b2565b92915050565b6000808335601e1984360301811261360957600080fd5b83018035915067ffffffffffffffff82111561362457600080fd5b60200191506060810236038213156134ec57600080fd5b808201808211156135ec576135ec6133b2565b6000818303608081121561366157600080fd5b604080516060810167ffffffffffffffff8282108183111715613686576136866130ae565b90835285359061369582613049565b8183526020870135602084015283603f19860112156136b357600080fd5b83519450838501915084821081831117156136d0576136d06130ae565b508252848201356136e081613049565b835260608501356136f081613049565b6020840152908101919091529392505050565b60208152600061307b6020830184613335565b6000602080838503121561372957600080fd5b825167ffffffffffffffff8082111561374157600080fd5b818501915085601f83011261375557600080fd5b815181811115613767576137676130ae565b8060051b6137768582016130c4565b918252838101850191858101908984111561379057600080fd5b86860192505b83831015613808578251858111156137ae5760008081fd5b8601603f81018b136137c05760008081fd5b8781015160406137d2613190836130f5565b8281528d828486010111156137e75760008081fd5b6137f6838c83018487016132e5565b85525050509186019190860190613796565b9998505050505050505050565b60006020828403121561382757600080fd5b815161307b81613215565b818103818111156135ec576135ec6133b2565b828152604081016003831061386a57634e487b7160e01b600052602160045260246000fd5b8260208301529392505050565b600082516138898184602087016132e5565b919091019291505056fea2646970667358221220f21d6079d31eb0315266e3b3c29363f9d7fcf901fa7fbcdf7ffe7153fe7fdea664736f6c63430008130033

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

000000000000000000000000a7d36f2106b5a5d528a7e2e7a3f436d703113a10000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d210000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a000000000000000000000000265daa697489968aebd650c665f4fb241b560785

-----Decoded View---------------
Arg [0] : _initCore (address): 0xa7d36f2106b5a5D528a7e2e7a3f436d703113A10
Arg [1] : _wweth (address): 0xf683Ce59521AA464066783d78e40CD9412f33D21
Arg [2] : _wusdb (address): 0x4B246c4C41c4e5eC1d4A8453c313cbc57Bf0993A
Arg [3] : _acm (address): 0x265DAA697489968AEbd650c665F4Fb241b560785

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000a7d36f2106b5a5d528a7e2e7a3f436d703113a10
Arg [1] : 000000000000000000000000f683ce59521aa464066783d78e40cd9412f33d21
Arg [2] : 0000000000000000000000004b246c4c41c4e5ec1d4a8453c313cbc57bf0993a
Arg [3] : 000000000000000000000000265daa697489968aebd650c665f4fb241b560785


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
Loading...
Loading

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.