Contract 0x1cF3e6f18223a1f2A445f2cD60538Af380e98074

 
 
Txn Hash
Method
Block
From
To
Value
0x3b3fbd9cf7b21fa64a37003482e19a94114a58117cbff8cd890544877e23f924Withdraw155320272022-09-14 8:50:4717 days 13 hrs agoENS Name jonybecc.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.00291611 6.02553897
0x83c14896aa8ac99e6ed8feacf4d0f9978d8d90f328e31f13ee5d3b79ddf065f8Rebalance139614712022-01-08 0:13:11266 days 21 hrs agoENS Name haydenshively.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0792150785
0x1e95d8bb152f8d8ddda0112265b75f0c0e335d02682c02390d5c23c3fc023b26Withdraw138700792021-12-24 20:33:58281 days 1 hr agoENS Name zychen.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.03985158 77.42426476
0x17d727385dad422b53dd165433162afc8e6fe38e8a76253ac3df092c4e66392cWithdraw138295072021-12-18 13:50:53287 days 8 hrs agoENS Name heavydextrader.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.02044115 39.7133854
0x2232e3dc796ebbefbaa34bc12a600bb7f4a4f19dbbf81a728d4300976f8c5305Withdraw135666342021-11-07 2:08:10328 days 19 hrs agoENS Name darkbluechain.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.04595886 97.9058491
0x0e7c1dd0334fa5bb8c2ddf4b040203757ab74bca1dff77475d5170004711112cWithdraw135492102021-11-04 8:42:29331 days 13 hrs agoENS Name haydenshively.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0469922100
0x9b857e12141b6acc9c1373ba4f233ce86afba35a9b9111aaf3320547fe12daa7Rebalance134844862021-10-25 4:36:08341 days 17 hrs ago0xfc7f3c4ffc89bce6bf518b41774e76e3147235e2 IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.06769469 67.98260183
0x7e28e4d3bffdf4dd4efbe7286bd4b405fc8dba46c17a2282e337d23e0f4bdb89Deposit134743752021-10-23 14:43:29343 days 7 hrs agoENS Name darkbluechain.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.01646259 55.66595488
0x9d64a8476bb82be03c410664624599f40f7eb068ff185fb50859a9a1ca09daadDeposit134647742021-10-22 2:18:59344 days 19 hrs agoENS Name haydenshively.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0221813275
0x1347c98df7edee17d42ba6ac90aed61d8e3c290367cb2d7bac910fb50cf6b246Deposit134596822021-10-21 7:31:42345 days 14 hrs agoENS Name zychen.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0240508 81.32111792
0x36398dcd447bcb302575f0f6ef1cec565320caad117df1d6ca7f2dec69fc9d81Withdraw134573382021-10-20 22:49:29345 days 23 hrs agoENS Name haydenshively.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0326773468.2
0x61af075bd70de88ccf9d24385037348ea63b7e2d5013b3eccc8ed33836c5fda4Deposit133904522021-10-10 10:44:26356 days 11 hrs agoENS Name tiagoacn.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0134672346
0x236373c7bf1b922104199dc4b1bd4e43ed1bcb8da3c3e1d1b54f290acdf3a356Deposit133901102021-10-10 9:29:08356 days 12 hrs agoENS Name miguelpmt.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.01814152 52.16304123
0x74c95883eff7b850893047ff191ac91e48b92019cbdc07d013c243e09518e984Rebalance133102592021-09-27 21:29:48369 days 36 mins agoENS Name haydenshively.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.097825395
0x9243f98a2b95f883427dbd04b9c79b980b18ac9a3bf33f0db240e9db4e33c066Withdraw132608272021-09-20 5:49:09376 days 16 hrs ago0x79b1a32ec97537486e75d99850bd56ecfa09d643 IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0265416456
0xd699238b2cc59d9656e015e7f6445f3099b802cc6c5172073c5eb9e7c3b7df96Withdraw132607862021-09-20 5:37:46376 days 16 hrs ago0x79b1a32ec97537486e75d99850bd56ecfa09d643 IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0357808570
0xad0832bc7dd5205f072e7c66dd42088050a248efa79a8b4c225b0dd147c232b7Deposit132221572021-09-14 6:18:57382 days 15 hrs ago0x79b1a32ec97537486e75d99850bd56ecfa09d643 IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0147794 47.87085666
0xa6dd7eb038c68a0d098c53419e37acbb56e804b92c0bdd66b1b89014648bd7d2Deposit132221522021-09-14 6:17:09382 days 15 hrs ago0x79b1a32ec97537486e75d99850bd56ecfa09d643 IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.01463783 42.47283589
0xec7684184b3e503cd76f2131711609da28c8c8e0a4f4fcb0985e7e0abd319bcbRebalance131809392021-09-07 20:58:30389 days 1 hr agoENS Name haydenshively.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.12063975125
0xfa9df07d556c6f0b92a291eca0ba0b494fd9cf1fe52d0a8613c38115ba7d15a1Deposit130768162021-08-22 18:43:11405 days 3 hrs agoENS Name jonybecc.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.01271765 39.73434211
0x5379127310ab5756261f809e3b35fbb858aa22b3eb6b0791e52c49a36fc315c2Rebalance130605932021-08-20 6:34:59407 days 15 hrs agoENS Name haydenshively.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0226386425.32828254
0x4b222349a625218d212e04b5c8b85f574e8d69da92dc4545adda5fc2acdf1835Deposit130424222021-08-17 11:25:24410 days 10 hrs agoENS Name philipp1.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0084592428
0xd32707f6c2bb63f7a193256040d62c13c5c6cab35367b3091164d8dc06ed9c32Deposit130231702021-08-14 12:01:28413 days 10 hrs agoENS Name heavydextrader.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0090645630
0x875a3ab6afab6c0177661dfdd6113cbc79c3b84d26cc9eef3a3b92d1e9095cabDeposit130127152021-08-12 21:08:57415 days 57 mins agoENS Name heavydextrader.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0142023645
0xf1a1343ba69fe3273c70dc5aac5c5a39d42da10311baf3ae56713d4a24a0a066Deposit130055492021-08-11 18:36:55416 days 3 hrs agoENS Name haydenshively.eth IN  0x1cf3e6f18223a1f2a445f2cd60538af380e980740 Ether0.0148735747.3
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x3b3fbd9cf7b21fa64a37003482e19a94114a58117cbff8cd890544877e23f924155320272022-09-14 8:50:4717 days 13 hrs ago 0x1cf3e6f18223a1f2a445f2cd60538af380e98074 Wrapped Ether0.01591356 Ether
0x3b3fbd9cf7b21fa64a37003482e19a94114a58117cbff8cd890544877e23f924155320272022-09-14 8:50:4717 days 13 hrs ago Compound: cETH Token 0x1cf3e6f18223a1f2a445f2cd60538af380e980740.01591356 Ether
0x83c14896aa8ac99e6ed8feacf4d0f9978d8d90f328e31f13ee5d3b79ddf065f8139614712022-01-08 0:13:11266 days 21 hrs ago 0x1cf3e6f18223a1f2a445f2cd60538af380e98074 Compound: cETH Token0.00145738 Ether
0x83c14896aa8ac99e6ed8feacf4d0f9978d8d90f328e31f13ee5d3b79ddf065f8139614712022-01-08 0:13:11266 days 21 hrs ago Wrapped Ether 0x1cf3e6f18223a1f2a445f2cd60538af380e980740.00145738 Ether
0x1e95d8bb152f8d8ddda0112265b75f0c0e335d02682c02390d5c23c3fc023b26138700792021-12-24 20:33:58281 days 1 hr ago 0x1cf3e6f18223a1f2a445f2cd60538af380e98074 Wrapped Ether0.30703364 Ether
0x1e95d8bb152f8d8ddda0112265b75f0c0e335d02682c02390d5c23c3fc023b26138700792021-12-24 20:33:58281 days 1 hr ago Compound: cETH Token 0x1cf3e6f18223a1f2a445f2cd60538af380e980740.30703364 Ether
0x17d727385dad422b53dd165433162afc8e6fe38e8a76253ac3df092c4e66392c138295072021-12-18 13:50:53287 days 8 hrs ago 0x1cf3e6f18223a1f2a445f2cd60538af380e98074 Wrapped Ether0.23447956 Ether
0x17d727385dad422b53dd165433162afc8e6fe38e8a76253ac3df092c4e66392c138295072021-12-18 13:50:53287 days 8 hrs ago Compound: cETH Token 0x1cf3e6f18223a1f2a445f2cd60538af380e980740.23447956 Ether
0x2232e3dc796ebbefbaa34bc12a600bb7f4a4f19dbbf81a728d4300976f8c5305135666342021-11-07 2:08:10328 days 19 hrs ago 0x1cf3e6f18223a1f2a445f2cd60538af380e98074 Wrapped Ether0.98096562 Ether
0x2232e3dc796ebbefbaa34bc12a600bb7f4a4f19dbbf81a728d4300976f8c5305135666342021-11-07 2:08:10328 days 19 hrs ago Compound: cETH Token 0x1cf3e6f18223a1f2a445f2cd60538af380e980740.98096562 Ether
0x0e7c1dd0334fa5bb8c2ddf4b040203757ab74bca1dff77475d5170004711112c135492102021-11-04 8:42:29331 days 13 hrs ago 0x1cf3e6f18223a1f2a445f2cd60538af380e98074 Wrapped Ether0.62408493 Ether
0x0e7c1dd0334fa5bb8c2ddf4b040203757ab74bca1dff77475d5170004711112c135492102021-11-04 8:42:29331 days 13 hrs ago Compound: cETH Token 0x1cf3e6f18223a1f2a445f2cd60538af380e980740.62408494 Ether
0x9b857e12141b6acc9c1373ba4f233ce86afba35a9b9111aaf3320547fe12daa7134844862021-10-25 4:36:08341 days 17 hrs ago 0x1cf3e6f18223a1f2a445f2cd60538af380e98074 Compound: cETH Token1.91818235 Ether
0x9b857e12141b6acc9c1373ba4f233ce86afba35a9b9111aaf3320547fe12daa7134844862021-10-25 4:36:08341 days 17 hrs ago Wrapped Ether 0x1cf3e6f18223a1f2a445f2cd60538af380e980741.91818235 Ether
0x36398dcd447bcb302575f0f6ef1cec565320caad117df1d6ca7f2dec69fc9d81134573382021-10-20 22:49:29345 days 23 hrs ago 0x1cf3e6f18223a1f2a445f2cd60538af380e98074 Wrapped Ether0.61200791 Ether
0x36398dcd447bcb302575f0f6ef1cec565320caad117df1d6ca7f2dec69fc9d81134573382021-10-20 22:49:29345 days 23 hrs ago Compound: cETH Token 0x1cf3e6f18223a1f2a445f2cd60538af380e980740.61200791 Ether
0x74c95883eff7b850893047ff191ac91e48b92019cbdc07d013c243e09518e984133102592021-09-27 21:29:48369 days 36 mins ago 0x1cf3e6f18223a1f2a445f2cd60538af380e98074 Compound: cETH Token0.30707667 Ether
0x74c95883eff7b850893047ff191ac91e48b92019cbdc07d013c243e09518e984133102592021-09-27 21:29:48369 days 36 mins ago Wrapped Ether 0x1cf3e6f18223a1f2a445f2cd60538af380e980740.30707667 Ether
0x9243f98a2b95f883427dbd04b9c79b980b18ac9a3bf33f0db240e9db4e33c066132608272021-09-20 5:49:09376 days 16 hrs ago 0x1cf3e6f18223a1f2a445f2cd60538af380e98074 Wrapped Ether0.21616986 Ether
0x9243f98a2b95f883427dbd04b9c79b980b18ac9a3bf33f0db240e9db4e33c066132608272021-09-20 5:49:09376 days 16 hrs ago Compound: cETH Token 0x1cf3e6f18223a1f2a445f2cd60538af380e980740.21616987 Ether
0xd699238b2cc59d9656e015e7f6445f3099b802cc6c5172073c5eb9e7c3b7df96132607862021-09-20 5:37:46376 days 16 hrs ago 0x1cf3e6f18223a1f2a445f2cd60538af380e98074 Wrapped Ether0.21616986 Ether
0xd699238b2cc59d9656e015e7f6445f3099b802cc6c5172073c5eb9e7c3b7df96132607862021-09-20 5:37:46376 days 16 hrs ago Compound: cETH Token 0x1cf3e6f18223a1f2a445f2cd60538af380e980740.21616986 Ether
0xec7684184b3e503cd76f2131711609da28c8c8e0a4f4fcb0985e7e0abd319bcb131809392021-09-07 20:58:30389 days 1 hr ago 0x1cf3e6f18223a1f2a445f2cd60538af380e98074 Wrapped Ether0.04555556 Ether
0xec7684184b3e503cd76f2131711609da28c8c8e0a4f4fcb0985e7e0abd319bcb131809392021-09-07 20:58:30389 days 1 hr ago Compound: cETH Token 0x1cf3e6f18223a1f2a445f2cd60538af380e980740.04555557 Ether
0x5379127310ab5756261f809e3b35fbb858aa22b3eb6b0791e52c49a36fc315c2130605932021-08-20 6:34:59407 days 15 hrs ago 0x1cf3e6f18223a1f2a445f2cd60538af380e98074 Compound: cETH Token0.85689753 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AloeBlendCapped

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 800 runs

Other Settings:
default evmVersion
File 1 of 38 : AloeBlendCapped.sol
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import "./AloeBlend.sol";

contract AloeBlendCapped is AloeBlend {
    using SafeERC20 for IERC20;

    address public immutable MULTISIG;
    uint256 public maxTotalSupply = 100000000000000000000;

    constructor(
        IUniswapV3Pool uniPool,
        address cToken0,
        address cToken1,
        address multisig
    ) AloeBlend(uniPool, cToken0, cToken1) {
        MULTISIG = multisig;
    }

    modifier restricted() {
        require(msg.sender == MULTISIG, "Not authorized");
        _;
    }

    function deposit(
        uint256 amount0Max,
        uint256 amount1Max,
        uint256 amount0Min,
        uint256 amount1Min
    )
        public
        override
        lock
        returns (
            uint256 shares,
            uint256 amount0,
            uint256 amount1
        )
    {
        (shares, amount0, amount1) = super.deposit(amount0Max, amount1Max, amount0Min, amount1Min);
        require(totalSupply() <= maxTotalSupply, "Aloe: Vault already full");
    }

    /**
     * @notice Removes tokens accidentally sent to this vault.
     */
    function sweep(
        IERC20 token,
        uint256 amount,
        address to
    ) external restricted {
        require(
            token != TOKEN0 && token != TOKEN1 && address(token) != silo0.cToken && address(token) != silo1.cToken,
            "Not sweepable"
        );
        token.safeTransfer(to, amount);
    }

    /**
     * @notice Used to change deposit cap for a guarded launch or to ensure
     * vault doesn't grow too large relative to the UNI_POOL. Cap is on total
     * supply rather than amounts of TOKEN0 and TOKEN1 as those amounts
     * fluctuate naturally over time.
     */
    function setMaxTotalSupply(uint256 _maxTotalSupply) external restricted {
        maxTotalSupply = _maxTotalSupply;
    }

    function setK(uint8 _K) external restricted {
        K = _K;
    }

    function setMaintenanceFee(uint256 _maintenanceFee) external restricted {
        maintenanceFee = _maintenanceFee;
    }
}

File 2 of 38 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @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);
}

File 3 of 38 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.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;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    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));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    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");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @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");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 4 of 38 : AloeBlend.sol
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import "./libraries/FullMath.sol";
import "./libraries/TickMath.sol";

import "./external/Compound.sol";
import "./external/Uniswap.sol";

import "./interfaces/IAloeBlend.sol";

import "./AloeBlendERC20.sol";
import "./UniswapMinter.sol";

/*
                                                                                                                        
                                                   #                                                                    
                                                  ###                                                                   
                                                  #####                                                                 
                               #                 #######                                *###*                           
                                ###             #########                         ########                              
                                #####         ###########                   ###########                                 
                                ########    ############               ############                                     
                                 ########    ###########         *##############                                        
                                ###########   ########      #################                                           
                                ############   ###      #################                                               
                                ############       ##################                                                   
                               #############    #################*         *#############*                              
                              ##############    #############      #####################################                
                             ###############   ####******      #######################*                                 
                           ################                                                                             
                         #################   *############################*                                             
                           ##############    ######################################                                     
                               ########    ################*                     **######*                              
                                   ###    ###                                                                           
                                                                                                                        
         ___       ___       ___       ___            ___       ___       ___       ___       ___       ___       ___   
        /\  \     /\__\     /\  \     /\  \          /\  \     /\  \     /\  \     /\  \     /\  \     /\  \     /\__\  
       /::\  \   /:/  /    /::\  \   /::\  \        /::\  \   /::\  \   /::\  \   _\:\  \    \:\  \   /::\  \   /:/  /  
      /::\:\__\ /:/__/    /:/\:\__\ /::\:\__\      /:/\:\__\ /::\:\__\ /::\:\__\ /\/::\__\   /::\__\ /::\:\__\ /:/__/   
      \/\::/  / \:\  \    \:\/:/  / \:\:\/  /      \:\ \/__/ \/\::/  / \/\::/  / \::/\/__/  /:/\/__/ \/\::/  / \:\  \   
        /:/  /   \:\__\    \::/  /   \:\/  /        \:\__\     /:/  /     \/__/   \:\__\    \/__/      /:/  /   \:\__\  
        \/__/     \/__/     \/__/     \/__/          \/__/     \/__/               \/__/               \/__/     \/__/  
*/

uint256 constant TWO_96 = 2**96;
uint256 constant TWO_144 = 2**144;

contract AloeBlend is AloeBlendERC20, UniswapMinter, IAloeBlend {
    using SafeERC20 for IERC20;
    using Uniswap for Uniswap.Position;
    using Compound for Compound.Market;

    /// @inheritdoc IAloeBlendImmutables
    uint8 public constant override DIVISOR_OF_REBALANCE_REWARD = 4;

    /// @inheritdoc IAloeBlendImmutables
    uint8 public constant override DIVISOR_OF_SHRINK_URGENCY = 2;

    /// @inheritdoc IAloeBlendImmutables
    uint24 public constant override MIN_WIDTH = 1000; // 1000 --> 2.5% of total inventory

    /// @inheritdoc IAloeBlendState
    uint8 public override K = 20;

    /// @inheritdoc IAloeBlendState
    uint256 public override maintenanceFee = 2500; // 2500 --> 25% of swap fees

    /// @inheritdoc IAloeBlendState
    uint256 public override maintenanceBudget0;

    /// @inheritdoc IAloeBlendState
    uint256 public override maintenanceBudget1;

    /// @inheritdoc IAloeBlendState
    Uniswap.Position public override combine;

    /// @inheritdoc IAloeBlendState
    Compound.Market public override silo0;

    /// @inheritdoc IAloeBlendState
    Compound.Market public override silo1;

    /// @dev For reentrancy check
    bool private locked;

    modifier lock() {
        require(!locked, "Aloe: Locked");
        locked = true;
        _;
        locked = false;
    }

    /// @dev Required for Compound library to work
    receive() external payable {
        require(msg.sender == address(WETH) || msg.sender == address(Compound.CETH));
    }

    constructor(
        IUniswapV3Pool uniPool,
        address cToken0,
        address cToken1
    ) AloeBlendERC20() UniswapMinter(uniPool) {
        combine.pool = uniPool;
        silo0.initialize(cToken0);
        silo1.initialize(cToken1);
    }

    /// @inheritdoc IAloeBlendDerivedState
    function getInventory() public view override returns (uint256 inventory0, uint256 inventory1) {
        // Everything in Uniswap
        (inventory0, inventory1) = combine.collectableAmountsAsOfLastPoke();
        // Everything in Compound
        inventory0 += silo0.getBalance();
        inventory1 += silo1.getBalance();
        // Everything in the contract, except maintenance budget
        inventory0 += _balance0();
        inventory1 += _balance1();
    }

    /// @inheritdoc IAloeBlendDerivedState
    function getRebalanceUrgency() public view override returns (uint16 urgency) {
        (uint24 width, int24 tickTWAP) = getNextPositionWidth();
        urgency = _computeRebalanceUrgency(combine, width, tickTWAP);
    }

    /// @inheritdoc IAloeBlendDerivedState
    function getNextPositionWidth() public view override returns (uint24 width, int24 tickTWAP) {
        uint176 mean;
        uint176 sigma;
        (mean, sigma, tickTWAP) = fetchPriceStatistics();
        width = uint24(
            TickMath.getTickAtSqrtRatio(uint160(TWO_96 + FullMath.mulDiv(TWO_96, uint176(K) * sigma, mean)))
        );
        if (width < MIN_WIDTH) width = MIN_WIDTH;
    }

    /// @inheritdoc IAloeBlendActions
    /// @dev LOCK MODIFIER IS APPLIED IN AloeBlendCapped!!!
    function deposit(
        uint256 amount0Max,
        uint256 amount1Max,
        uint256 amount0Min,
        uint256 amount1Min
    )
        public
        virtual
        override
        returns (
            uint256 shares,
            uint256 amount0,
            uint256 amount1
        )
    {
        require(amount0Max != 0 || amount1Max != 0, "Aloe: 0 deposit");

        combine.poke();
        silo0.poke();
        silo1.poke();

        (shares, amount0, amount1) = _computeLPShares(amount0Max, amount1Max);
        require(shares != 0, "Aloe: 0 shares");
        require(amount0 >= amount0Min, "Aloe: amount0 too low");
        require(amount1 >= amount1Min, "Aloe: amount1 too low");

        // Pull in tokens from sender
        if (amount0 != 0) TOKEN0.safeTransferFrom(msg.sender, address(this), amount0);
        if (amount1 != 0) TOKEN1.safeTransferFrom(msg.sender, address(this), amount1);

        // Mint shares
        _mint(msg.sender, shares);
        emit Deposit(msg.sender, shares, amount0, amount1);
    }

    /// @inheritdoc IAloeBlendActions
    function withdraw(
        uint256 shares,
        uint256 amount0Min,
        uint256 amount1Min
    ) external override lock returns (uint256 amount0, uint256 amount1) {
        require(shares != 0, "Aloe: 0 shares");
        uint256 totalSupply = totalSupply() + 1;
        uint256 temp0;
        uint256 temp1;

        // Portion from contract
        // NOTE: Must be done FIRST to ensure we don't double count things after exiting Uniswap/Compound
        amount0 = FullMath.mulDiv(_balance0(), shares, totalSupply);
        amount1 = FullMath.mulDiv(_balance1(), shares, totalSupply);

        // Portion from Uniswap
        (temp0, temp1) = _withdrawFractionFromCombine(shares, totalSupply);
        amount0 += temp0;
        amount1 += temp1;

        // Portion from Compound
        temp0 = FullMath.mulDiv(silo0.getBalance(), shares, totalSupply);
        temp1 = FullMath.mulDiv(silo1.getBalance(), shares, totalSupply);
        silo0.withdraw(temp0);
        silo1.withdraw(temp1);
        amount0 += temp0;
        amount1 += temp1;

        // Check constraints
        require(amount0 >= amount0Min, "Aloe: amount0 too low");
        require(amount1 >= amount1Min, "Aloe: amount1 too low");

        // Transfer tokens
        TOKEN0.safeTransfer(msg.sender, amount0);
        TOKEN1.safeTransfer(msg.sender, amount1);

        // Burn shares
        _burn(msg.sender, shares);
        emit Withdraw(msg.sender, shares, amount0, amount1);
    }

    struct RebalanceCache {
        uint160 sqrtPriceX96;
        uint96 magic;
        int24 tick;
        int24 tickTWAP;
        uint24 w;
        uint16 urgency;
        uint224 priceX96;
    }

    /// @inheritdoc IAloeBlendActions
    function rebalance(uint8 rewardMode) external override lock {
        Uniswap.Position memory _combine = combine;
        RebalanceCache memory cache;

        // Get current tick & price
        (cache.sqrtPriceX96, cache.tick, , , , , ) = _combine.pool.slot0();
        cache.priceX96 = uint224(FullMath.mulDiv(cache.sqrtPriceX96, cache.sqrtPriceX96, TWO_96));
        // Get new position width, urgency, and inventory usage fraction
        (cache.w, cache.tickTWAP) = getNextPositionWidth();
        cache.urgency = _computeRebalanceUrgency(_combine, cache.w, cache.tickTWAP);
        cache.w = cache.w >> 1;
        cache.magic = uint96(TWO_96 - TickMath.getSqrtRatioAtTick(-int24(cache.w)));

        // Exit current Uniswap position
        {
            (uint128 liquidity, , , , ) = _combine.info();
            (, , uint256 earned0, uint256 earned1) = _combine.withdraw(liquidity);
            _earmarkSomeForMaintenance(earned0, earned1);
        }

        // Compute amounts that should be placed in Uniswap position
        uint256 amount0;
        uint256 amount1;
        (uint256 inventory0, uint256 inventory1) = getInventory();
        if (FullMath.mulDiv(inventory0, cache.priceX96, TWO_96) > inventory1) {
            amount1 = FullMath.mulDiv(inventory1, cache.magic, TWO_96);
            amount0 = FullMath.mulDiv(amount1, TWO_96, cache.priceX96);
        } else {
            amount0 = FullMath.mulDiv(inventory0, cache.magic, TWO_96);
            amount1 = FullMath.mulDiv(amount0, cache.priceX96, TWO_96);
        }

        uint256 balance0 = _balance0();
        uint256 balance1 = _balance1();
        bool hasExcessToken0 = balance0 > amount0;
        bool hasExcessToken1 = balance1 > amount1;

        // Because of cToken exchangeRate rounding, we may withdraw too much
        // here. That's okay; dust will just sit in contract till next rebalance
        if (!hasExcessToken0) silo0.withdraw(amount0 - balance0);
        if (!hasExcessToken1) silo1.withdraw(amount1 - balance1);

        // Update combine's ticks
        _combine.lower = cache.tick - int24(cache.w);
        _combine.upper = cache.tick + int24(cache.w);
        _combine = _coerceTicksToSpacing(_combine);

        // Place some liquidity in Uniswap
        delete lastMintedAmount0;
        delete lastMintedAmount1;
        _combine.deposit(_combine.liquidityForAmounts(cache.sqrtPriceX96, amount0, amount1));
        combine.lower = _combine.lower;
        combine.upper = _combine.upper;

        // Place excess into Compound
        if (hasExcessToken0) silo0.deposit(balance0 - lastMintedAmount0);
        if (hasExcessToken1) silo1.deposit(balance1 - lastMintedAmount1);

        // Reward caller
        {
            uint256 _divisor = 10_000 * uint256(DIVISOR_OF_REBALANCE_REWARD);
            if (rewardMode % 2 == 0) {
                amount0 = FullMath.mulDiv(maintenanceBudget0, cache.urgency, _divisor);
                TOKEN0.safeTransfer(msg.sender, amount0);
                maintenanceBudget0 -= amount0;
            }
            if (rewardMode != 0) {
                amount1 = FullMath.mulDiv(maintenanceBudget1, cache.urgency, _divisor);
                TOKEN1.safeTransfer(msg.sender, amount1);
                maintenanceBudget1 -= amount1;
            }
        }

        emit Rebalance(_combine.lower, _combine.upper, cache.magic, cache.urgency, inventory0, inventory1);
    }

    /// @inheritdoc IAloeBlendDerivedState
    function fetchPriceStatistics()
        public
        view
        override
        returns (
            uint176 mean,
            uint176 sigma,
            int24 tickTWAP
        )
    {
        (int56[] memory tickCumulatives, ) = UNI_POOL.observe(selectedOracleTimetable());
        tickTWAP = int24((tickCumulatives[9] - tickCumulatives[8]) / 360);

        // Compute mean price over the entire 54 minute period
        mean = TickMath.getSqrtRatioAtTick(int24((tickCumulatives[9] - tickCumulatives[0]) / 3240));
        mean = uint176(FullMath.mulDiv(mean, mean, TWO_144));

        // `stat` variable will take on a few different statistical values
        // Here it's MAD (Mean Absolute Deviation), except not yet divided by number of samples
        uint184 stat;
        uint176 sample;

        for (uint8 i = 0; i < 9; i++) {
            // Compute mean price over a 6 minute period
            sample = TickMath.getSqrtRatioAtTick(int24((tickCumulatives[i + 1] - tickCumulatives[i]) / 360));
            sample = uint176(FullMath.mulDiv(sample, sample, TWO_144));

            // Accumulate
            stat += sample > mean ? sample - mean : mean - sample;
        }

        // MAD = stat / n, here n = 10
        // STDDEV = MAD * sqrt(2/pi) for a normal distribution
        sigma = uint176((uint256(stat) * 79788) / 1000000);
    }

    /// @inheritdoc IAloeBlendDerivedState
    function selectedOracleTimetable() public pure override returns (uint32[] memory secondsAgos) {
        secondsAgos = new uint32[](10);
        secondsAgos[0] = 3420;
        secondsAgos[1] = 3060;
        secondsAgos[2] = 2700;
        secondsAgos[3] = 2340;
        secondsAgos[4] = 1980;
        secondsAgos[5] = 1620;
        secondsAgos[6] = 1260;
        secondsAgos[7] = 900;
        secondsAgos[8] = 540;
        secondsAgos[9] = 180;
    }

    /// @dev Calculates the largest possible `amount0` and `amount1` such that
    /// they're in the same proportion as total amounts, but not greater than
    /// `amount0Max` and `amount1Max` respectively.
    function _computeLPShares(uint256 amount0Max, uint256 amount1Max)
        private
        view
        returns (
            uint256 shares,
            uint256 amount0,
            uint256 amount1
        )
    {
        uint256 totalSupply = totalSupply();
        (uint256 inventory0, uint256 inventory1) = getInventory();

        // If total supply > 0, pool can't be empty
        assert(totalSupply == 0 || inventory0 != 0 || inventory1 != 0);

        if (totalSupply == 0) {
            // For first deposit, enforce 50/50 ratio
            (uint160 sqrtPriceX96, , , , , , ) = UNI_POOL.slot0();
            uint224 priceX96 = uint224(FullMath.mulDiv(sqrtPriceX96, sqrtPriceX96, TWO_96));
            amount0 = FullMath.mulDiv(amount1Max, TWO_96, priceX96);

            if (amount0 < amount0Max) {
                amount1 = amount1Max;
                shares = amount1;
            } else {
                amount0 = amount0Max;
                amount1 = FullMath.mulDiv(amount0, priceX96, TWO_96);
                shares = amount0;
            }
        } else if (inventory0 == 0) {
            amount1 = amount1Max;
            shares = FullMath.mulDiv(amount1, totalSupply, inventory1);
        } else if (inventory1 == 0) {
            amount0 = amount0Max;
            shares = FullMath.mulDiv(amount0, totalSupply, inventory0);
        } else {
            amount0 = FullMath.mulDiv(amount1Max, inventory0, inventory1);

            if (amount0 < amount0Max) {
                amount1 = amount1Max;
                shares = FullMath.mulDiv(amount1, totalSupply, inventory1);
            } else {
                amount0 = amount0Max;
                amount1 = FullMath.mulDiv(amount0, inventory1, inventory0);
                shares = FullMath.mulDiv(amount0, totalSupply, inventory0);
            }
        }
    }

    /// @dev Withdraws fraction of liquidity from combine, but collects *all* fees from it
    function _withdrawFractionFromCombine(uint256 numerator, uint256 denominator)
        private
        returns (uint256 amount0, uint256 amount1)
    {
        assert(numerator < denominator);
        Uniswap.Position memory _combine = combine;

        (uint128 liquidity, , , , ) = _combine.info();
        liquidity = uint128(FullMath.mulDiv(liquidity, numerator, denominator));

        uint256 earned0;
        uint256 earned1;
        (amount0, amount1, earned0, earned1) = _combine.withdraw(liquidity);
        (earned0, earned1) = _earmarkSomeForMaintenance(earned0, earned1);

        // Add share of earned fees
        amount0 += FullMath.mulDiv(earned0, numerator, denominator);
        amount1 += FullMath.mulDiv(earned1, numerator, denominator);
    }

    /// @dev Earmark some earned fees for maintenance, according to `maintenanceFee`. Return what's leftover
    function _earmarkSomeForMaintenance(uint256 earned0, uint256 earned1) private returns (uint256, uint256) {
        uint256 _maintenanceFee = maintenanceFee;
        if (_maintenanceFee != 0) {
            uint256 toMaintenance;
            // Accrue token0
            toMaintenance = FullMath.mulDiv(earned0, _maintenanceFee, 10_000);
            earned0 -= toMaintenance;
            maintenanceBudget0 += toMaintenance;
            // Accrue token1
            toMaintenance = FullMath.mulDiv(earned1, _maintenanceFee, 10_000);
            earned1 -= toMaintenance;
            maintenanceBudget1 += toMaintenance;
        }
        return (earned0, earned1);
    }

    function _computeRebalanceUrgency(
        Uniswap.Position memory current,
        uint24 newW,
        int24 tickTWAP
    ) private pure returns (uint16) {
        unchecked {
            int48 diff = (current.lower + current.upper) / 2 - tickTWAP;
            uint24 w = uint24(current.upper - current.lower);
            if (w == 0) return 0;

            uint48 urgency = (40_000 * uint48(diff**2)) / uint48(w)**2;
            if (urgency > 10_000) {
                urgency = 10_000;
            } else if (newW < w) {
                uint24 shrinkUrgency = (10_000 - (10_000 * newW) / w) / uint24(DIVISOR_OF_SHRINK_URGENCY);
                urgency = urgency + shrinkUrgency - ((urgency * uint48(shrinkUrgency)) / 10_000);
            }
            return uint16(urgency);
        }
    }

    function _coerceTicksToSpacing(Uniswap.Position memory p) private view returns (Uniswap.Position memory) {
        int24 tickSpacing = TICK_SPACING;
        p.lower = p.lower - (p.lower < 0 ? tickSpacing + (p.lower % tickSpacing) : p.lower % tickSpacing);
        p.upper = p.upper + (p.upper < 0 ? -p.upper % tickSpacing : tickSpacing - (p.upper % tickSpacing));
        return p;
    }

    function _balance0() private view returns (uint256) {
        return TOKEN0.balanceOf(address(this)) - maintenanceBudget0;
    }

    function _balance1() private view returns (uint256) {
        return TOKEN1.balanceOf(address(this)) - maintenanceBudget1;
    }
}

File 5 of 38 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return _verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(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) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 6 of 38 : FullMath.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.0;

/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
    function mulDiv(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = a * b
            // Compute the product mod 2**256 and mod 2**256 - 1
            // then 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(a, b, not(0))
                prod0 := mul(a, b)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division
            if (prod1 == 0) {
                require(denominator > 0);
                assembly {
                    result := div(prod0, denominator)
                }
                return result;
            }

            // Make sure the result is less than 2**256.
            // Also prevents denominator == 0
            require(denominator > prod1);

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

            // Make division exact by subtracting the remainder from [prod1 prod0]
            // Compute remainder using mulmod
            uint256 remainder;
            assembly {
                remainder := mulmod(a, b, denominator)
            }
            // Subtract 256 bit number from 512 bit number
            assembly {
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator
            // Compute largest power of two divisor of denominator.
            // Always >= 1.
            // https://ethereum.stackexchange.com/a/96646
            uint256 twos = denominator & (~denominator + 1);
            // Divide denominator by power of two
            assembly {
                denominator := div(denominator, twos)
            }

            // Divide [prod1 prod0] by the factors of two
            assembly {
                prod0 := div(prod0, twos)
            }
            // Shift in bits from prod1 into prod0. For this we need
            // to flip `twos` such that it is 2**256 / twos.
            // If twos is zero, then it becomes one
            assembly {
                twos := add(div(sub(0, twos), twos), 1)
            }
            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
            // correct for four bits. That is, denominator * inv = 1 mod 2**4
            uint256 inv = (3 * denominator) ^ 2;
            // Now use 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.
            inv *= 2 - denominator * inv; // inverse mod 2**8
            inv *= 2 - denominator * inv; // inverse mod 2**16
            inv *= 2 - denominator * inv; // inverse mod 2**32
            inv *= 2 - denominator * inv; // inverse mod 2**64
            inv *= 2 - denominator * inv; // inverse mod 2**128
            inv *= 2 - denominator * inv; // 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 precoditions 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 * inv;
            return result;
        }
    }

    /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    function mulDivRoundingUp(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        result = mulDiv(a, b, denominator);
        if (mulmod(a, b, denominator) > 0) {
            require(result < type(uint256).max);
            result++;
        }
    }
}

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

/// @title Math library for computing sqrt prices from ticks and vice versa
/// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports
/// prices between 2**-128 and 2**128
library TickMath {
    /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128
    int24 internal constant MIN_TICK = -887272;
    /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128
    int24 internal constant MAX_TICK = -MIN_TICK;

    /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK)
    uint160 internal constant MIN_SQRT_RATIO = 4295128739;
    /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK)
    uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;

    /// @notice Calculates sqrt(1.0001^tick) * 2^96
    /// @dev Throws if |tick| > max tick
    /// @param tick The input tick for the above formula
    /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0)
    /// at the given tick
    function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) {
        uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick));
        require(absTick <= uint256(uint24(MAX_TICK)), "T");

        uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000;
        if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128;
        if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128;
        if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128;
        if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128;
        if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128;
        if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128;
        if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128;
        if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128;
        if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128;
        if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128;
        if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128;
        if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128;
        if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128;
        if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128;
        if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128;
        if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128;
        if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128;
        if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128;
        if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128;

        if (tick > 0) ratio = type(uint256).max / ratio;

        // this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96.
        // we then downcast because we know the result always fits within 160 bits due to our tick input constraint
        // we round up in the division so getTickAtSqrtRatio of the output price is always consistent
        sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1));
    }

    /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio
    /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may
    /// ever return.
    /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96
    /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio
    function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) {
        // second inequality must be < because the price can never reach the price at the max tick
        require(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO, "R");
        uint256 ratio = uint256(sqrtPriceX96) << 32;

        uint256 r = ratio;
        uint256 msb = 0;

        assembly {
            let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(5, gt(r, 0xFFFFFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(4, gt(r, 0xFFFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(3, gt(r, 0xFF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(2, gt(r, 0xF))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := shl(1, gt(r, 0x3))
            msb := or(msb, f)
            r := shr(f, r)
        }
        assembly {
            let f := gt(r, 0x1)
            msb := or(msb, f)
        }

        if (msb >= 128) r = ratio >> (msb - 127);
        else r = ratio << (127 - msb);

        int256 log_2 = (int256(msb) - 128) << 64;

        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(63, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(62, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(61, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(60, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(59, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(58, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(57, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(56, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(55, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(54, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(53, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(52, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(51, f))
            r := shr(f, r)
        }
        assembly {
            r := shr(127, mul(r, r))
            let f := shr(128, r)
            log_2 := or(log_2, shl(50, f))
        }

        int256 log_sqrt10001 = log_2 * 255738958999603826347141; // 128.128 number

        int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128);
        int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128);

        tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow;
    }
}

File 8 of 38 : Compound.sol
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import "../libraries/FullMath.sol";

import "./compound/CERC20.sol";
import "./compound/CEther.sol";
import "./WETH.sol";

library Compound {
    using SafeERC20 for IERC20;

    CEther public constant CETH = CEther(0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5);

    struct Market {
        address cToken;
        address uToken;
    }

    function initialize(Market storage market, address cToken) internal {
        if (cToken == address(CETH)) {
            market.cToken = cToken;
            delete market.uToken;
        } else {
            market.cToken = cToken;
            market.uToken = CERC20Storage(cToken).underlying();
        }
    }

    function poke(Market memory market) internal {
        CERC20(market.cToken).accrueInterest();
    }

    function deposit(Market memory market, uint256 amount) internal {
        if (amount == 0) return;
        if (market.cToken == address(CETH)) {
            WETH.withdraw(amount);
            CETH.mint{value: amount}();
        } else {
            _approve(market.uToken, address(market.cToken), amount);
            require(CERC20(market.cToken).mint(amount) == 0, "Compound: mint failed");
        }
    }

    function withdraw(Market memory market, uint256 amount) internal {
        if (amount == 0) return;
        uint256 cAmount = 1 + FullMath.mulDiv(amount, 1e18, CERC20(market.cToken).exchangeRateStored());

        if (market.cToken == address(CETH)) {
            require(CETH.redeem(cAmount) == 0, "Compound: redeem ETH failed");
            WETH.deposit{value: amount}();
        } else {
            require(CERC20(market.cToken).redeem(cAmount) == 0, "Compound: redeem failed");
        }
    }

    function getBalance(Market memory market) internal view returns (uint256 balance) {
        CERC20 cToken = CERC20(market.cToken);
        return FullMath.mulDiv(cToken.balanceOf(address(this)), cToken.exchangeRateStored(), 1e18);
    }

    function _approve(
        address token,
        address spender,
        uint256 amount
    ) private {
        // 200 gas to read uint256
        if (IERC20(token).allowance(address(this), spender) < amount) {
            // 20000 gas to write uint256 if changing from zero to non-zero
            // 5000  gas to write uint256 if changing from non-zero to non-zero
            IERC20(token).safeApprove(spender, type(uint256).max);
        }
    }
}

File 9 of 38 : Uniswap.sol
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3MintCallback.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";

import "../libraries/FullMath.sol";
import "../libraries/LiquidityAmounts.sol";
import "../libraries/TickMath.sol";

library Uniswap {
    using SafeERC20 for IERC20;

    struct Position {
        // The pool the position is in
        IUniswapV3Pool pool;
        // Lower tick of the position
        int24 lower;
        // Upper tick of the position
        int24 upper;
    }

    /// @dev Do zero-burns to poke the Uniswap pools so earned fees are updated
    function poke(Position memory position) internal {
        (uint128 liquidity, , , , ) = info(position);
        if (liquidity == 0) return;
        position.pool.burn(position.lower, position.upper, 0);
    }

    /// @dev Deposits liquidity in a range on the Uniswap pool.
    function deposit(Position memory position, uint128 liquidity) internal {
        if (liquidity == 0) return;
        position.pool.mint(address(this), position.lower, position.upper, liquidity, "");
    }

    /// @dev Withdraws all liquidity and collects all fees
    function withdraw(Position memory position, uint128 liquidity)
        internal
        returns (
            uint256 burned0,
            uint256 burned1,
            uint256 earned0,
            uint256 earned1
        )
    {
        if (liquidity != 0) {
            (burned0, burned1) = position.pool.burn(position.lower, position.upper, liquidity);
        }

        // Collect all owed tokens including earned fees
        (uint256 collected0, uint256 collected1) = position.pool.collect(
            address(this),
            position.lower,
            position.upper,
            type(uint128).max,
            type(uint128).max
        );

        earned0 = collected0 - burned0;
        earned1 = collected1 - burned1;
    }

    /**
     * @notice Amounts of TOKEN0 and TOKEN1 held in vault's position. Includes
     * owed fees, except those accrued since last poke.
     */
    function collectableAmountsAsOfLastPoke(Position memory position) internal view returns (uint256, uint256) {
        (uint128 liquidity, , , uint128 earnable0, uint128 earnable1) = info(position);
        (uint160 sqrtPriceX96, , , , , , ) = position.pool.slot0();
        (uint256 burnable0, uint256 burnable1) = amountsForLiquidity(position, sqrtPriceX96, liquidity);

        return (burnable0 + earnable0, burnable1 + earnable1);
    }

    /// @dev Wrapper around `IUniswapV3Pool.positions()`.
    function info(Position memory position)
        internal
        view
        returns (
            uint128, // liquidity
            uint256, // feeGrowthInside0LastX128
            uint256, // feeGrowthInside1LastX128
            uint128, // tokensOwed0
            uint128 // tokensOwed1
        )
    {
        return position.pool.positions(keccak256(abi.encodePacked(address(this), position.lower, position.upper)));
    }

    /// @dev Wrapper around `LiquidityAmounts.getAmountsForLiquidity()`.
    function amountsForLiquidity(
        Position memory position,
        uint160 sqrtPriceX96,
        uint128 liquidity
    ) internal pure returns (uint256, uint256) {
        return
            LiquidityAmounts.getAmountsForLiquidity(
                sqrtPriceX96,
                TickMath.getSqrtRatioAtTick(position.lower),
                TickMath.getSqrtRatioAtTick(position.upper),
                liquidity
            );
    }

    /// @dev Wrapper around `LiquidityAmounts.getLiquidityForAmounts()`.
    function liquidityForAmounts(
        Position memory position,
        uint160 sqrtPriceX96,
        uint256 amount0,
        uint256 amount1
    ) internal pure returns (uint128) {
        return
            LiquidityAmounts.getLiquidityForAmounts(
                sqrtPriceX96,
                TickMath.getSqrtRatioAtTick(position.lower),
                TickMath.getSqrtRatioAtTick(position.upper),
                amount0,
                amount1
            );
    }

    /// @dev Wrapper around `LiquidityAmounts.getLiquidityForAmount0()`.
    function liquidityForAmount0(Position memory position, uint256 amount0) internal pure returns (uint128) {
        return
            LiquidityAmounts.getLiquidityForAmount0(
                TickMath.getSqrtRatioAtTick(position.lower),
                TickMath.getSqrtRatioAtTick(position.upper),
                amount0
            );
    }

    /// @dev Wrapper around `LiquidityAmounts.getLiquidityForAmount1()`.
    function liquidityForAmount1(Position memory position, uint256 amount1) internal pure returns (uint128) {
        return
            LiquidityAmounts.getLiquidityForAmount1(
                TickMath.getSqrtRatioAtTick(position.lower),
                TickMath.getSqrtRatioAtTick(position.upper),
                amount1
            );
    }
}

File 10 of 38 : IAloeBlend.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IAloeBlendActions.sol";
import "./IAloeBlendDerivedState.sol";
import "./IAloeBlendEvents.sol";
import "./IAloeBlendImmutables.sol";
import "./IAloeBlendState.sol";

/// @title Aloe Blend vault interface
/// @dev The interface is broken up into many smaller pieces
interface IAloeBlend is
    IAloeBlendActions,
    IAloeBlendDerivedState,
    IAloeBlendEvents,
    IAloeBlendImmutables,
    IAloeBlendState
{

}

File 11 of 38 : AloeBlendERC20.sol
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";

contract AloeBlendERC20 is ERC20Permit {
    constructor() ERC20Permit("Aloe V1") ERC20("Aloe V1", "ALOE-V1") {}
}

File 12 of 38 : UniswapMinter.sol
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3MintCallback.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";

contract UniswapMinter is IUniswapV3MintCallback {
    using SafeERC20 for IERC20;

    IUniswapV3Pool public immutable UNI_POOL;

    IERC20 public immutable TOKEN0;

    IERC20 public immutable TOKEN1;

    int24 public immutable TICK_SPACING;

    uint256 internal lastMintedAmount0;

    uint256 internal lastMintedAmount1;

    constructor(IUniswapV3Pool uniPool) {
        UNI_POOL = uniPool;
        TICK_SPACING = uniPool.tickSpacing();
        TOKEN0 = IERC20(uniPool.token0());
        TOKEN1 = IERC20(uniPool.token1());
    }

    /// @dev Callback for Uniswap V3 pool.
    function uniswapV3MintCallback(
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    ) external override {
        require(msg.sender == address(UNI_POOL), "Fake callback");
        if (amount0 != 0) TOKEN0.safeTransfer(msg.sender, amount0);
        if (amount1 != 0) TOKEN1.safeTransfer(msg.sender, amount1);

        lastMintedAmount0 = amount0;
        lastMintedAmount1 = amount1;
    }
}

File 13 of 38 : CERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface CERC20 {
    function accrueInterest() external returns (uint256);

    function accrualBlockNumber() external view returns (uint256);

    function exchangeRateStored() external view returns (uint256);

    function exchangeRateCurrent() external returns (uint256);

    function mint(uint256 mintAmount) external returns (uint256);

    function redeem(uint256 redeemTokens) external returns (uint256);

    function redeemUnderlying(uint256 redeemAmount) external returns (uint256);

    function borrow(uint256 borrowAmount) external returns (uint256);

    function repayBorrow(uint256 repayAmount) external returns (uint256);

    function repayBorrowBehalf(address borrower, uint256 repayAmount) external returns (uint256);

    function liquidateBorrow(
        address borrower,
        uint256 repayAmount,
        address collateral
    ) external returns (uint256);

    function borrowBalanceCurrent(address account) external returns (uint256);

    function borrowBalanceStored(address account) external view returns (uint256);

    function balanceOf(address account) external view returns (uint256);

    function balanceOfUnderlying(address account) external returns (uint256);

    function getAccountSnapshot(address account)
        external
        view
        returns (
            uint256 error,
            uint256 cTokenBalance,
            uint256 borrowBalance,
            uint256 exchangeRateMantissa
        );

    function comptroller() external view returns (address);
}

interface CERC20Storage {
    function underlying() external view returns (address);
}

File 14 of 38 : CEther.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface CEther {
    function mint() external payable;

    function redeem(uint256 redeemTokens) external returns (uint256);

    function redeemUnderlying(uint256 redeemAmount) external returns (uint256);

    function borrow(uint256 borrowAmount) external returns (uint256);

    function repayBorrow() external payable;

    function repayBorrowBehalf(address borrower) external payable;

    function liquidateBorrow(address borrower, address cTokenCollateral) external payable;

    function balanceOfUnderlying(address account) external returns (uint256);
}

File 15 of 38 : WETH.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IWETH {
    function deposit() external payable;

    function withdraw(uint256) external;
}

IWETH constant WETH = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);

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

/// @title Callback for IUniswapV3PoolActions#mint
/// @notice Any contract that calls IUniswapV3PoolActions#mint must implement this interface
interface IUniswapV3MintCallback {
    /// @notice Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint.
    /// @dev In the implementation you must pay the pool tokens owed for the minted liquidity.
    /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
    /// @param amount0Owed The amount of token0 due to the pool for the minted liquidity
    /// @param amount1Owed The amount of token1 due to the pool for the minted liquidity
    /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#mint call
    function uniswapV3MintCallback(
        uint256 amount0Owed,
        uint256 amount1Owed,
        bytes calldata data
    ) external;
}

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

import './pool/IUniswapV3PoolImmutables.sol';
import './pool/IUniswapV3PoolState.sol';
import './pool/IUniswapV3PoolDerivedState.sol';
import './pool/IUniswapV3PoolActions.sol';
import './pool/IUniswapV3PoolOwnerActions.sol';
import './pool/IUniswapV3PoolEvents.sol';

/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
    IUniswapV3PoolImmutables,
    IUniswapV3PoolState,
    IUniswapV3PoolDerivedState,
    IUniswapV3PoolActions,
    IUniswapV3PoolOwnerActions,
    IUniswapV3PoolEvents
{

}

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

import "./FixedPoint96.sol";
import "./FullMath.sol";

/// @title Liquidity amount functions
/// @notice Provides functions for computing liquidity amounts from token amounts and prices
library LiquidityAmounts {
    /// @notice Downcasts uint256 to uint128
    /// @param x The uint258 to be downcasted
    /// @return y The passed value, downcasted to uint128
    function toUint128(uint256 x) private pure returns (uint128 y) {
        require((y = uint128(x)) == x);
    }

    /// @notice Computes the amount of liquidity received for a given amount of token0 and price range
    /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower))
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param amount0 The amount0 being sent in
    /// @return liquidity The amount of returned liquidity
    function getLiquidityForAmount0(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint256 amount0
    ) internal pure returns (uint128 liquidity) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
        uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96);
        return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96));
    }

    /// @notice Computes the amount of liquidity received for a given amount of token1 and price range
    /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)).
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param amount1 The amount1 being sent in
    /// @return liquidity The amount of returned liquidity
    function getLiquidityForAmount1(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint256 amount1
    ) internal pure returns (uint128 liquidity) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);
        return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96));
    }

    /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current
    /// pool prices and the prices at the tick boundaries
    /// @param sqrtRatioX96 A sqrt price representing the current pool prices
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param amount0 The amount of token0 being sent in
    /// @param amount1 The amount of token1 being sent in
    /// @return liquidity The maximum amount of liquidity received
    function getLiquidityForAmounts(
        uint160 sqrtRatioX96,
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint256 amount0,
        uint256 amount1
    ) internal pure returns (uint128 liquidity) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        if (sqrtRatioX96 <= sqrtRatioAX96) {
            liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0);
        } else if (sqrtRatioX96 < sqrtRatioBX96) {
            uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0);
            uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1);

            liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1;
        } else {
            liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1);
        }
    }

    /// @notice Computes the amount of token0 for a given amount of liquidity and a price range
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param liquidity The liquidity being valued
    /// @return amount0 The amount of token0
    function getAmount0ForLiquidity(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint128 liquidity
    ) internal pure returns (uint256 amount0) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        return
            FullMath.mulDiv(
                uint256(liquidity) << FixedPoint96.RESOLUTION,
                sqrtRatioBX96 - sqrtRatioAX96,
                sqrtRatioBX96
            ) / sqrtRatioAX96;
    }

    /// @notice Computes the amount of token1 for a given amount of liquidity and a price range
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param liquidity The liquidity being valued
    /// @return amount1 The amount of token1
    function getAmount1ForLiquidity(
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint128 liquidity
    ) internal pure returns (uint256 amount1) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96);
    }

    /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current
    /// pool prices and the prices at the tick boundaries
    /// @param sqrtRatioX96 A sqrt price representing the current pool prices
    /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary
    /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary
    /// @param liquidity The liquidity being valued
    /// @return amount0 The amount of token0
    /// @return amount1 The amount of token1
    function getAmountsForLiquidity(
        uint160 sqrtRatioX96,
        uint160 sqrtRatioAX96,
        uint160 sqrtRatioBX96,
        uint128 liquidity
    ) internal pure returns (uint256 amount0, uint256 amount1) {
        if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96);

        if (sqrtRatioX96 <= sqrtRatioAX96) {
            amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);
        } else if (sqrtRatioX96 < sqrtRatioBX96) {
            amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity);
            amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity);
        } else {
            amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity);
        }
    }
}

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

/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
    /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
    /// @return The contract address
    function factory() external view returns (address);

    /// @notice The first of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token0() external view returns (address);

    /// @notice The second of the two tokens of the pool, sorted by address
    /// @return The token contract address
    function token1() external view returns (address);

    /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
    /// @return The fee
    function fee() external view returns (uint24);

    /// @notice The pool tick spacing
    /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
    /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
    /// This value is an int24 to avoid casting even though it is always positive.
    /// @return The tick spacing
    function tickSpacing() external view returns (int24);

    /// @notice The maximum amount of position liquidity that can use any tick in the range
    /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
    /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
    /// @return The max amount of liquidity per tick
    function maxLiquidityPerTick() external view returns (uint128);
}

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

/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
    /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
    /// when accessed externally.
    /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
    /// tick The current tick of the pool, i.e. according to the last tick transition that was run.
    /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
    /// boundary.
    /// observationIndex The index of the last oracle observation that was written,
    /// observationCardinality The current maximum number of observations stored in the pool,
    /// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
    /// feeProtocol The protocol fee for both tokens of the pool.
    /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
    /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
    /// unlocked Whether the pool is currently locked to reentrancy
    function slot0()
        external
        view
        returns (
            uint160 sqrtPriceX96,
            int24 tick,
            uint16 observationIndex,
            uint16 observationCardinality,
            uint16 observationCardinalityNext,
            uint8 feeProtocol,
            bool unlocked
        );

    /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal0X128() external view returns (uint256);

    /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
    /// @dev This value can overflow the uint256
    function feeGrowthGlobal1X128() external view returns (uint256);

    /// @notice The amounts of token0 and token1 that are owed to the protocol
    /// @dev Protocol fees will never exceed uint128 max in either token
    function protocolFees() external view returns (uint128 token0, uint128 token1);

    /// @notice The currently in range liquidity available to the pool
    /// @dev This value has no relationship to the total liquidity across all ticks
    function liquidity() external view returns (uint128);

    /// @notice Look up information about a specific tick in the pool
    /// @param tick The tick to look up
    /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
    /// tick upper,
    /// liquidityNet how much liquidity changes when the pool price crosses the tick,
    /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
    /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
    /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
    /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
    /// secondsOutside the seconds spent on the other side of the tick from the current tick,
    /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
    /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
    /// In addition, these values are only relative and must be used only in comparison to previous snapshots for
    /// a specific position.
    function ticks(int24 tick)
        external
        view
        returns (
            uint128 liquidityGross,
            int128 liquidityNet,
            uint256 feeGrowthOutside0X128,
            uint256 feeGrowthOutside1X128,
            int56 tickCumulativeOutside,
            uint160 secondsPerLiquidityOutsideX128,
            uint32 secondsOutside,
            bool initialized
        );

    /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
    function tickBitmap(int16 wordPosition) external view returns (uint256);

    /// @notice Returns the information about a position by the position's key
    /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
    /// @return _liquidity The amount of liquidity in the position,
    /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
    /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
    /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
    /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
    function positions(bytes32 key)
        external
        view
        returns (
            uint128 _liquidity,
            uint256 feeGrowthInside0LastX128,
            uint256 feeGrowthInside1LastX128,
            uint128 tokensOwed0,
            uint128 tokensOwed1
        );

    /// @notice Returns data about a specific observation index
    /// @param index The element of the observations array to fetch
    /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
    /// ago, rather than at a specific index in the array.
    /// @return blockTimestamp The timestamp of the observation,
    /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
    /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
    /// Returns initialized whether the observation has been initialized and the values are safe to use
    function observations(uint256 index)
        external
        view
        returns (
            uint32 blockTimestamp,
            int56 tickCumulative,
            uint160 secondsPerLiquidityCumulativeX128,
            bool initialized
        );
}

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

/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IUniswapV3PoolDerivedState {
    /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
    /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
    /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
    /// you must call it with secondsAgos = [3600, 0].
    /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
    /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
    /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
    /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
    /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
    /// timestamp
    function observe(uint32[] calldata secondsAgos)
        external
        view
        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);

    /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
    /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
    /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
    /// snapshot is taken and the second snapshot is taken.
    /// @param tickLower The lower tick of the range
    /// @param tickUpper The upper tick of the range
    /// @return tickCumulativeInside The snapshot of the tick accumulator for the range
    /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
    /// @return secondsInside The snapshot of seconds per liquidity for the range
    function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
        external
        view
        returns (
            int56 tickCumulativeInside,
            uint160 secondsPerLiquidityInsideX128,
            uint32 secondsInside
        );
}

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

/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
    /// @notice Sets the initial price for the pool
    /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
    /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
    function initialize(uint160 sqrtPriceX96) external;

    /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
    /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
    /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
    /// on tickLower, tickUpper, the amount of liquidity, and the current price.
    /// @param recipient The address for which the liquidity will be created
    /// @param tickLower The lower tick of the position in which to add liquidity
    /// @param tickUpper The upper tick of the position in which to add liquidity
    /// @param amount The amount of liquidity to mint
    /// @param data Any data that should be passed through to the callback
    /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
    /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
    function mint(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount,
        bytes calldata data
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Collects tokens owed to a position
    /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
    /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
    /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
    /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
    /// @param recipient The address which should receive the fees collected
    /// @param tickLower The lower tick of the position for which to collect fees
    /// @param tickUpper The upper tick of the position for which to collect fees
    /// @param amount0Requested How much token0 should be withdrawn from the fees owed
    /// @param amount1Requested How much token1 should be withdrawn from the fees owed
    /// @return amount0 The amount of fees collected in token0
    /// @return amount1 The amount of fees collected in token1
    function collect(
        address recipient,
        int24 tickLower,
        int24 tickUpper,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);

    /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
    /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
    /// @dev Fees must be collected separately via a call to #collect
    /// @param tickLower The lower tick of the position for which to burn liquidity
    /// @param tickUpper The upper tick of the position for which to burn liquidity
    /// @param amount How much liquidity to burn
    /// @return amount0 The amount of token0 sent to the recipient
    /// @return amount1 The amount of token1 sent to the recipient
    function burn(
        int24 tickLower,
        int24 tickUpper,
        uint128 amount
    ) external returns (uint256 amount0, uint256 amount1);

    /// @notice Swap token0 for token1, or token1 for token0
    /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
    /// @param recipient The address to receive the output of the swap
    /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
    /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
    /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
    /// value after the swap. If one for zero, the price cannot be greater than this value after the swap
    /// @param data Any data to be passed through to the callback
    /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
    /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
    function swap(
        address recipient,
        bool zeroForOne,
        int256 amountSpecified,
        uint160 sqrtPriceLimitX96,
        bytes calldata data
    ) external returns (int256 amount0, int256 amount1);

    /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
    /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
    /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
    /// with 0 amount{0,1} and sending the donation amount(s) from the callback
    /// @param recipient The address which will receive the token0 and token1 amounts
    /// @param amount0 The amount of token0 to send
    /// @param amount1 The amount of token1 to send
    /// @param data Any data to be passed through to the callback
    function flash(
        address recipient,
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    ) external;

    /// @notice Increase the maximum number of price and liquidity observations that this pool will store
    /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
    /// the input observationCardinalityNext.
    /// @param observationCardinalityNext The desired minimum number of observations for the pool to store
    function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}

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

/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IUniswapV3PoolOwnerActions {
    /// @notice Set the denominator of the protocol's % share of the fees
    /// @param feeProtocol0 new protocol fee for token0 of the pool
    /// @param feeProtocol1 new protocol fee for token1 of the pool
    function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;

    /// @notice Collect the protocol fee accrued to the pool
    /// @param recipient The address to which collected protocol fees should be sent
    /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
    /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
    /// @return amount0 The protocol fee collected in token0
    /// @return amount1 The protocol fee collected in token1
    function collectProtocol(
        address recipient,
        uint128 amount0Requested,
        uint128 amount1Requested
    ) external returns (uint128 amount0, uint128 amount1);
}

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

/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolEvents {
    /// @notice Emitted exactly once by a pool when #initialize is first called on the pool
    /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
    /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
    /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
    event Initialize(uint160 sqrtPriceX96, int24 tick);

    /// @notice Emitted when liquidity is minted for a given position
    /// @param sender The address that minted the liquidity
    /// @param owner The owner of the position and recipient of any minted liquidity
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity minted to the position range
    /// @param amount0 How much token0 was required for the minted liquidity
    /// @param amount1 How much token1 was required for the minted liquidity
    event Mint(
        address sender,
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted when fees are collected by the owner of a position
    /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
    /// @param owner The owner of the position for which fees are collected
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount0 The amount of token0 fees collected
    /// @param amount1 The amount of token1 fees collected
    event Collect(
        address indexed owner,
        address recipient,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount0,
        uint128 amount1
    );

    /// @notice Emitted when a position's liquidity is removed
    /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
    /// @param owner The owner of the position for which liquidity is removed
    /// @param tickLower The lower tick of the position
    /// @param tickUpper The upper tick of the position
    /// @param amount The amount of liquidity to remove
    /// @param amount0 The amount of token0 withdrawn
    /// @param amount1 The amount of token1 withdrawn
    event Burn(
        address indexed owner,
        int24 indexed tickLower,
        int24 indexed tickUpper,
        uint128 amount,
        uint256 amount0,
        uint256 amount1
    );

    /// @notice Emitted by the pool for any swaps between token0 and token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the output of the swap
    /// @param amount0 The delta of the token0 balance of the pool
    /// @param amount1 The delta of the token1 balance of the pool
    /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
    /// @param liquidity The liquidity of the pool after the swap
    /// @param tick The log base 1.0001 of price of the pool after the swap
    event Swap(
        address indexed sender,
        address indexed recipient,
        int256 amount0,
        int256 amount1,
        uint160 sqrtPriceX96,
        uint128 liquidity,
        int24 tick
    );

    /// @notice Emitted by the pool for any flashes of token0/token1
    /// @param sender The address that initiated the swap call, and that received the callback
    /// @param recipient The address that received the tokens from flash
    /// @param amount0 The amount of token0 that was flashed
    /// @param amount1 The amount of token1 that was flashed
    /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
    /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
    event Flash(
        address indexed sender,
        address indexed recipient,
        uint256 amount0,
        uint256 amount1,
        uint256 paid0,
        uint256 paid1
    );

    /// @notice Emitted by the pool for increases to the number of observations that can be stored
    /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
    /// just before a mint/swap/burn.
    /// @param observationCardinalityNextOld The previous value of the next observation cardinality
    /// @param observationCardinalityNextNew The updated value of the next observation cardinality
    event IncreaseObservationCardinalityNext(
        uint16 observationCardinalityNextOld,
        uint16 observationCardinalityNextNew
    );

    /// @notice Emitted when the protocol fee is changed by the pool
    /// @param feeProtocol0Old The previous value of the token0 protocol fee
    /// @param feeProtocol1Old The previous value of the token1 protocol fee
    /// @param feeProtocol0New The updated value of the token0 protocol fee
    /// @param feeProtocol1New The updated value of the token1 protocol fee
    event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);

    /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
    /// @param sender The address that collects the protocol fees
    /// @param recipient The address that receives the collected protocol fees
    /// @param amount0 The amount of token0 protocol fees that is withdrawn
    /// @param amount0 The amount of token1 protocol fees that is withdrawn
    event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}

File 25 of 38 : FixedPoint96.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.4.0;

/// @title FixedPoint96
/// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format)
/// @dev Used in SqrtPriceMath.sol
library FixedPoint96 {
    uint8 internal constant RESOLUTION = 96;
    uint256 internal constant Q96 = 0x1000000000000000000000000;
}

File 26 of 38 : IAloeBlendActions.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IAloeBlendActions {
    /**
     * @notice Deposits tokens in proportion to the vault's current holdings
     * @dev These tokens sit in the vault and are not used as liquidity
     * until the next rebalance. Also note it's not necessary to check
     * if user manipulated price to deposit cheaper, as the value of range
     * orders can only by manipulated higher.
     * @param amount0Max Max amount of TOKEN0 to deposit
     * @param amount1Max Max amount of TOKEN1 to deposit
     * @param amount0Min Ensure `amount0` is greater than this
     * @param amount1Min Ensure `amount1` is greater than this
     * @return shares Number of shares minted
     * @return amount0 Amount of TOKEN0 deposited
     * @return amount1 Amount of TOKEN1 deposited
     */
    function deposit(
        uint256 amount0Max,
        uint256 amount1Max,
        uint256 amount0Min,
        uint256 amount1Min
    )
        external
        returns (
            uint256 shares,
            uint256 amount0,
            uint256 amount1
        );

    /**
     * @notice Withdraws tokens in proportion to the vault's current holdings
     * @param shares Shares burned by sender
     * @param amount0Min Revert if resulting `amount0` is smaller than this
     * @param amount1Min Revert if resulting `amount1` is smaller than this
     * @return amount0 Amount of token0 sent to recipient
     * @return amount1 Amount of token1 sent to recipient
     */
    function withdraw(
        uint256 shares,
        uint256 amount0Min,
        uint256 amount1Min
    ) external returns (uint256 amount0, uint256 amount1);

    /**
     * @notice Rebalances vault to maintain 50/50 inventory ratio
     * @param rewardMode Whether to denominate caller's reward in token0 (0), token1 (1), or both (2)
     */
    function rebalance(uint8 rewardMode) external;
}

File 27 of 38 : IAloeBlendDerivedState.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IAloeBlendDerivedState {
    /**
     * @notice Calculates the vault's total holdings - in other words, how much of each token
     * the vault would hold if it withdrew all its liquidity from Uniswap and Compound.
     * @return inventory0 The amount of token0, as of last pokes
     * @return inventory1 The amount of token1, as of last pokes
     */
    function getInventory() external view returns (uint256 inventory0, uint256 inventory1);

    /**
     * @notice Calculates a rebalance urgency level between 0 and 10000. Caller's reward is
     * proportional to this value.
     * @return urgency How badly the vault wants its `rebalance()` function to be called
     */
    function getRebalanceUrgency() external view returns (uint16 urgency);

    /**
     * @notice Calculates what the Uniswap position's width *should* be based on current volatility
     * @return width The width as a number of ticks
     * @return tickTWAP The geometric mean tick spanning 9 minutes ago -> 3 minutes ago
     */
    function getNextPositionWidth() external view returns (uint24 width, int24 tickTWAP);

    /**
     * @notice Fetches Uniswap prices over 10 discrete intervals in the past hour, then computes statistics
     * @return mean The mean of the samples
     * @return sigma The standard deviation of the samples
     * @return tickTWAP The geometric mean tick spanning 9 minutes ago -> 3 minutes ago
     */
    function fetchPriceStatistics() external view returns (uint176 mean, uint176 sigma, int24 tickTWAP);

    /**
     * @notice Builds a memory array that can be passed to Uniswap V3's `observe` function to specify
     * intervals over which mean prices should be fetched
     * @return secondsAgos From how long ago each cumulative tick and liquidity value should be returned
     */
    function selectedOracleTimetable() external pure returns (uint32[] memory secondsAgos);
}

File 28 of 38 : IAloeBlendEvents.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IAloeBlendEvents {
    event Deposit(address indexed sender, uint256 shares, uint256 amount0, uint256 amount1);

    event Withdraw(address indexed sender, uint256 shares, uint256 amount0, uint256 amount1);

    event Rebalance(int24 lower, int24 upper, uint96 magic, uint16 urgency, uint256 inventory0, uint256 inventory1);
}

File 29 of 38 : IAloeBlendImmutables.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IAloeBlendImmutables {
    /// @dev Indicates how much of `maintenanceBudget{0,1}` can be used in single rebalance
    function DIVISOR_OF_REBALANCE_REWARD() external view returns (uint8);

    /// @dev Indicates the priority given to shrinking the Uniswap position to account for
    /// decreased volatility. A value of 2 means that shrinking is half as important as
    /// sliding.
    function DIVISOR_OF_SHRINK_URGENCY() external view returns (uint8);

    /// @dev The minimum width (in ticks) of the Uniswap position
    function MIN_WIDTH() external view returns (uint24);
}

File 30 of 38 : IAloeBlendState.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../external/Compound.sol";
import "../external/Uniswap.sol";

interface IAloeBlendState {
    /// @dev The number of standard deviations to +/- from mean when setting Uniswap position
    function K() external view returns (uint8);

    /// @dev The portion of swap fees (in basis points) that goes toward maintenance
    function maintenanceFee() external view returns (uint256);

    /// @dev The size of the budget available for things like `rebalance()` rewards (token0)
    function maintenanceBudget0() external view returns (uint256);

    /// @dev The size of the budget available for things like `rebalance()` rewards (token1)
    function maintenanceBudget1() external view returns (uint256);

    /// @dev The Uniswap position harvesting fees in the combined token0-token1 pool
    function combine()
        external
        view
        returns (
            IUniswapV3Pool pool,
            int24 lower,
            int24 upper
        );

    /// @dev The Compound market where excess token0 is stored
    function silo0() external view returns (address cToken, address uToken);

    /// @dev The Compound market where excess token1 is stored
    function silo1() external view returns (address cToken, address uToken);
}

File 31 of 38 : draft-ERC20Permit.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./draft-IERC20Permit.sol";
import "../ERC20.sol";
import "../../../utils/cryptography/draft-EIP712.sol";
import "../../../utils/cryptography/ECDSA.sol";
import "../../../utils/Counters.sol";

/**
 * @dev Implementation 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.
 *
 * _Available since v3.4._
 */
abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712 {
    using Counters for Counters.Counter;

    mapping(address => Counters.Counter) private _nonces;

    // solhint-disable-next-line var-name-mixedcase
    bytes32 private immutable _PERMIT_TYPEHASH =
        keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");

    /**
     * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
     *
     * It's a good idea to use the same `name` that is defined as the ERC20 token name.
     */
    constructor(string memory name) EIP712(name, "1") {}

    /**
     * @dev See {IERC20Permit-permit}.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual override {
        require(block.timestamp <= deadline, "ERC20Permit: expired deadline");

        bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline));

        bytes32 hash = _hashTypedDataV4(structHash);

        address signer = ECDSA.recover(hash, v, r, s);
        require(signer == owner, "ERC20Permit: invalid signature");

        _approve(owner, spender, value);
    }

    /**
     * @dev See {IERC20Permit-nonces}.
     */
    function nonces(address owner) public view virtual override returns (uint256) {
        return _nonces[owner].current();
    }

    /**
     * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view override returns (bytes32) {
        return _domainSeparatorV4();
    }

    /**
     * @dev "Consume a nonce": return the current value and increment.
     *
     * _Available since v4.1._
     */
    function _useNonce(address owner) internal virtual returns (uint256 current) {
        Counters.Counter storage nonce = _nonces[owner];
        current = nonce.current();
        nonce.increment();
    }
}

File 32 of 38 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT

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 33 of 38 : ERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

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

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

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        unchecked {
            _approve(sender, _msgSender(), currentAllowance - amount);
        }

        return true;
    }

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

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

        return true;
    }

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

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[sender] = senderBalance - amount;
        }
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(sender, recipient, amount);
    }

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

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

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

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

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

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

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

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

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

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

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

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

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

File 34 of 38 : draft-EIP712.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./ECDSA.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * _Available since v3.4._
 */
abstract contract EIP712 {
    /* solhint-disable var-name-mixedcase */
    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
    uint256 private immutable _CACHED_CHAIN_ID;

    bytes32 private immutable _HASHED_NAME;
    bytes32 private immutable _HASHED_VERSION;
    bytes32 private immutable _TYPE_HASH;

    /* solhint-enable var-name-mixedcase */

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        bytes32 typeHash = keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
        _CACHED_CHAIN_ID = block.chainid;
        _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
        _TYPE_HASH = typeHash;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (block.chainid == _CACHED_CHAIN_ID) {
            return _CACHED_DOMAIN_SEPARATOR;
        } else {
            return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
        }
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash
    ) private view returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
    }
}

File 35 of 38 : ECDSA.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return recover(hash, v, r, s);
        } else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return recover(hash, r, vs);
        } else {
            revert("ECDSA: invalid signature length");
        }
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        bytes32 s;
        uint8 v;
        assembly {
            s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
            v := add(shr(255, vs), 27)
        }
        return recover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`, `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        require(
            uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,
            "ECDSA: invalid signature 's' value"
        );
        require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value");

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        require(signer != address(0), "ECDSA: invalid signature");

        return signer;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 36 of 38 : Counters.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library Counters {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

File 37 of 38 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 38 of 38 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 800
  },
  "metadata": {
    "bytecodeHash": "none"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IUniswapV3Pool","name":"uniPool","type":"address"},{"internalType":"address","name":"cToken0","type":"address"},{"internalType":"address","name":"cToken1","type":"address"},{"internalType":"address","name":"multisig","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"int24","name":"lower","type":"int24"},{"indexed":false,"internalType":"int24","name":"upper","type":"int24"},{"indexed":false,"internalType":"uint96","name":"magic","type":"uint96"},{"indexed":false,"internalType":"uint16","name":"urgency","type":"uint16"},{"indexed":false,"internalType":"uint256","name":"inventory0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"inventory1","type":"uint256"}],"name":"Rebalance","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"DIVISOR_OF_REBALANCE_REWARD","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DIVISOR_OF_SHRINK_URGENCY","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"K","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_WIDTH","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MULTISIG","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TICK_SPACING","outputs":[{"internalType":"int24","name":"","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN0","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN1","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNI_POOL","outputs":[{"internalType":"contract IUniswapV3Pool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"combine","outputs":[{"internalType":"contract IUniswapV3Pool","name":"pool","type":"address"},{"internalType":"int24","name":"lower","type":"int24"},{"internalType":"int24","name":"upper","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount0Max","type":"uint256"},{"internalType":"uint256","name":"amount1Max","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"}],"name":"deposit","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fetchPriceStatistics","outputs":[{"internalType":"uint176","name":"mean","type":"uint176"},{"internalType":"uint176","name":"sigma","type":"uint176"},{"internalType":"int24","name":"tickTWAP","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getInventory","outputs":[{"internalType":"uint256","name":"inventory0","type":"uint256"},{"internalType":"uint256","name":"inventory1","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNextPositionWidth","outputs":[{"internalType":"uint24","name":"width","type":"uint24"},{"internalType":"int24","name":"tickTWAP","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRebalanceUrgency","outputs":[{"internalType":"uint16","name":"urgency","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maintenanceBudget0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maintenanceBudget1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maintenanceFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"rewardMode","type":"uint8"}],"name":"rebalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"selectedOracleTimetable","outputs":[{"internalType":"uint32[]","name":"secondsAgos","type":"uint32[]"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint8","name":"_K","type":"uint8"}],"name":"setK","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maintenanceFee","type":"uint256"}],"name":"setMaintenanceFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxTotalSupply","type":"uint256"}],"name":"setMaxTotalSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"silo0","outputs":[{"internalType":"address","name":"cToken","type":"address"},{"internalType":"address","name":"uToken","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"silo1","outputs":[{"internalType":"address","name":"cToken","type":"address"},{"internalType":"address","name":"uToken","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uniswapV3MintCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

6101e06040527f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9610120526008805460ff191660141790556109c460095568056bc75e2d631000006012553480156200005757600080fd5b5060405162006479380380620064798339810160408190526200007a91620005a8565b8383838260405180604001604052806007815260200166416c6f6520563160c81b81525080604051806040016040528060018152602001603160f81b81525060405180604001604052806007815260200166416c6f6520563160c81b81525060405180604001604052806007815260200166414c4f452d563160c81b815250816003908051906020019062000111929190620004dc565b50805162000127906004906020840190620004dc565b5050825160209384012082519284019290922060c083815260e08290524660a0818152604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f818a0181905281830198909852606080820196909652608080820194909452308184015281518082039093018352938401808252825192890192909220909252610100959095529187901b6001600160601b031916610140526334324e9f60e21b909352516001600160a01b038616945063d0c93a7c9360c48085019491935090829003018186803b1580156200020557600080fd5b505afa1580156200021a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200024091906200060f565b60020b6101a08160020b60e81b81525050806001600160a01b0316630dfe16816040518163ffffffff1660e01b815260040160206040518083038186803b1580156200028b57600080fd5b505afa158015620002a0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620002c6919062000582565b6001600160a01b0316610160816001600160a01b031660601b81525050806001600160a01b031663d21220a76040518163ffffffff1660e01b815260040160206040518083038186803b1580156200031d57600080fd5b505afa15801562000332573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000358919062000582565b60601b6001600160601b0319166101805250600c80546001600160a01b0319166001600160a01b0385161790556200039e600d83620003d7602090811b6200239917901c565b620003b981600f620003d760201b620023991790919060201c565b50505060601b6001600160601b0319166101c0525062000688915050565b6001600160a01b038116734ddc2d193948926d02f9b1fe9e1daa0718270ed51415620004275781546001600160a01b0382166001600160a01b031991821617835560018301805490911690555050565b81546001600160a01b0319166001600160a01b038216908117835560408051636f307dc360e01b81529051636f307dc391600480820192602092909190829003018186803b1580156200047957600080fd5b505afa1580156200048e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620004b4919062000582565b6001830180546001600160a01b03929092166001600160a01b03199092169190911790555050565b828054620004ea9062000632565b90600052602060002090601f0160209004810192826200050e576000855562000559565b82601f106200052957805160ff191683800117855562000559565b8280016001018555821562000559579182015b82811115620005595782518255916020019190600101906200053c565b50620005679291506200056b565b5090565b5b808211156200056757600081556001016200056c565b60006020828403121562000594578081fd5b8151620005a1816200066f565b9392505050565b60008060008060808587031215620005be578283fd5b8451620005cb816200066f565b6020860151909450620005de816200066f565b6040860151909350620005f1816200066f565b606086015190925062000604816200066f565b939692955090935050565b60006020828403121562000621578081fd5b81518060020b8114620005a1578182fd5b600181811c908216806200064757607f821691505b602082108114156200066957634e487b7160e01b600052602260045260246000fd5b50919050565b6001600160a01b03811681146200068557600080fd5b50565b60805160a05160c05160e05161010051610120516101405160601c6101605160601c6101805160601c6101a05160e81c6101c05160601c615ccf620007aa600039600081816104d101528181610d0c0152818161113b015281816111c90152611ba60152600081816105f301526142c50152600081816106b7015281816114fb01528181611a0301528181611c43015281816122b401528181612e1601526136610152600081816105bf015281816114c7015281816119c901528181611c060152818161224801528181612ddb01526135b801526000818161080701528181610d770152818161194901526147ad01526000611a8b01526000612eeb01526000612f3a01526000612f1501526000612e9901526000612ec20152615ccf6000f3fe6080604052600436106102e05760003560e01c80635ee04d7811610184578063a9059cbb116100d6578063d34879971161008a578063dd62ed3e11610064578063dd62ed3e14610963578063e035814d146109a9578063f4ae1474146109d057600080fd5b8063d348799714610903578063d505accf14610923578063dc2c256f1461094357600080fd5b8063c3bd5945116100bb578063c3bd5945146108a3578063cdebf2ca146108b9578063d0c9bdb4146108db57600080fd5b8063a9059cbb14610869578063a932492f1461088957600080fd5b806381c93bfa116101385780639b147558116101125780639b147558146107f5578063a41fe49f14610829578063a457c2d71461084957600080fd5b806381c93bfa1461079657806383db382d146107b657806395d89b41146107e057600080fd5b806370a082311161016957806370a0823114610720578063747c5252146107565780637ecebe001461077657600080fd5b80635ee04d78146106a557806362d7d45e146106d957600080fd5b80632ab4d0521161023d57806341224f3c116101f15780634a736a78116101cb5780634a736a78146106285780634f5e1454146106665780635d7f850c1461067b57600080fd5b806341224f3c14610598578063443ec74d146105ad57806346ca626b146105e157600080fd5b80633644e515116102225780633644e5151461054357806339509351146105585780633f3e4c111461057857600080fd5b80632ab4d0521461050b578063313ce5671461052157600080fd5b80631304fd581161029457806323b872dd1161027957806323b872dd146104645780632505c3d9146104845780632530b145146104bf57600080fd5b80631304fd581461043957806318160ddd1461044f57600080fd5b8063095ea7b3116102c5578063095ea7b3146103755780630ce22d64146103a55780631005116c146103d857600080fd5b8063046604491461032a57806306fdde031461035357600080fd5b36610325573373c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2148061031a575033734ddc2d193948926d02f9b1fe9e1daa0718270ed5145b61032357600080fd5b005b600080fd5b34801561033657600080fd5b5061034060095481565b6040519081526020015b60405180910390f35b34801561035f57600080fd5b506103686109f0565b60405161034a9190615772565b34801561038157600080fd5b5061039561039036600461535b565b610a82565b604051901515815260200161034a565b3480156103b157600080fd5b506103ba610a98565b6040805162ffffff909316835260029190910b60208301520161034a565b3480156103e457600080fd5b50600c54610410906001600160a01b03811690600160a01b8104600290810b91600160b81b9004900b83565b604080516001600160a01b039094168452600292830b6020850152910b9082015260600161034a565b34801561044557600080fd5b50610340600a5481565b34801561045b57600080fd5b50600254610340565b34801561047057600080fd5b5061039561047f3660046152ab565b610b15565b34801561049057600080fd5b506104a461049f3660046156bf565b610bdb565b6040805193845260208401929092529082015260600161034a565b3480156104cb57600080fd5b506104f37f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161034a565b34801561051757600080fd5b5061034060125481565b34801561052d57600080fd5b5060125b60405160ff909116815260200161034a565b34801561054f57600080fd5b50610340610cb6565b34801561056457600080fd5b5061039561057336600461535b565b610cc5565b34801561058457600080fd5b506103236105933660046155c6565b610d01565b3480156105a457600080fd5b50610531600281565b3480156105b957600080fd5b506104f37f000000000000000000000000000000000000000000000000000000000000000081565b3480156105ed57600080fd5b506106157f000000000000000000000000000000000000000000000000000000000000000081565b60405160029190910b815260200161034a565b34801561063457600080fd5b5061063d610d6f565b604080516001600160b01b03948516815293909216602084015260020b9082015260600161034a565b34801561067257600080fd5b50610531600481565b34801561068757600080fd5b5061069061103d565b6040805192835260208301919091520161034a565b3480156106b157600080fd5b506104f37f000000000000000000000000000000000000000000000000000000000000000081565b3480156106e557600080fd5b50600d54600e54610700916001600160a01b03908116911682565b604080516001600160a01b0393841681529290911660208301520161034a565b34801561072c57600080fd5b5061034061073b36600461523b565b6001600160a01b031660009081526020819052604090205490565b34801561076257600080fd5b506103236107713660046155c6565b611130565b34801561078257600080fd5b5061034061079136600461523b565b61119e565b3480156107a257600080fd5b506103236107b13660046156f0565b6111be565b3480156107c257600080fd5b506107cc6103e881565b60405162ffffff909116815260200161034a565b3480156107ec57600080fd5b5061036861123d565b34801561080157600080fd5b506104f37f000000000000000000000000000000000000000000000000000000000000000081565b34801561083557600080fd5b50610690610844366004615694565b61124c565b34801561085557600080fd5b5061039561086436600461535b565b611586565b34801561087557600080fd5b5061039561088436600461535b565b611637565b34801561089557600080fd5b506008546105319060ff1681565b3480156108af57600080fd5b50610340600b5481565b3480156108c557600080fd5b506108ce611644565b60405161034a9190615728565b3480156108e757600080fd5b506108f06118d7565b60405161ffff909116815260200161034a565b34801561090f57600080fd5b5061032361091e366004615619565b61193e565b34801561092f57600080fd5b5061032361093e3660046152eb565b611a37565b34801561094f57600080fd5b5061032361095e36600461546b565b611b9b565b34801561096f57600080fd5b5061034061097e366004615273565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b3480156109b557600080fd5b50600f54601054610700916001600160a01b03908116911682565b3480156109dc57600080fd5b506103236109eb3660046156f0565b611d11565b6060600380546109ff90615b71565b80601f0160208091040260200160405190810160405280929190818152602001828054610a2b90615b71565b8015610a785780601f10610a4d57610100808354040283529160200191610a78565b820191906000526020600020905b815481529060010190602001808311610a5b57829003601f168201915b5050505050905090565b6000610a8f3384846124bf565b50600192915050565b600080600080610aa6610d6f565b6008549095509193509150610af890610ae590600160601b90610acd90859060ff166159cd565b6001600160b01b0316856001600160b01b03166125e3565b610af390600160601b6158bb565b612692565b93506103e862ffffff85161015610b0f576103e893505b50509091565b6000610b228484846129d9565b6001600160a01b038416600090815260016020908152604080832033845290915290205482811015610bc15760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206160448201527f6c6c6f77616e636500000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610bce85338584036124bf565b60019150505b9392505050565b6011546000908190819060ff1615610c245760405162461bcd60e51b815260206004820152600c60248201526b105b1bd94e88131bd8dad95960a21b6044820152606401610bb8565b6011805460ff19166001179055610c3d87878787612bd8565b6012549295509093509150610c5160025490565b1115610c9f5760405162461bcd60e51b815260206004820152601860248201527f416c6f653a205661756c7420616c72656164792066756c6c00000000000000006044820152606401610bb8565b6011805460ff191690559196909550909350915050565b6000610cc0612e95565b905090565b3360008181526001602090815260408083206001600160a01b03871684529091528120549091610a8f918590610cfc9086906158bb565b6124bf565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610d6a5760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b6044820152606401610bb8565b601255565b6000806000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663883bdbfd610dac611644565b6040518263ffffffff1660e01b8152600401610dc89190615728565b60006040518083038186803b158015610de057600080fd5b505afa158015610df4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610e1c9190810190615386565b50905061016881600881518110610e4357634e487b7160e01b600052603260045260246000fd5b602002602001015182600981518110610e6c57634e487b7160e01b600052603260045260246000fd5b6020026020010151610e7e9190615aa1565b610e8891906158f8565b9150610efb610ca882600081518110610eb157634e487b7160e01b600052603260045260246000fd5b602002602001015183600981518110610eda57634e487b7160e01b600052603260045260246000fd5b6020026020010151610eec9190615aa1565b610ef691906158f8565b612f88565b6001600160a01b03169350610f158480600160901b6125e3565b935060008060005b60098160ff161015610ffe57610f89610168858360ff1681518110610f5257634e487b7160e01b600052603260045260246000fd5b602002602001015186846001610f6891906158d3565b60ff1681518110610eda57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03169150610fa38280600160901b6125e3565b9150866001600160b01b0316826001600160b01b031611610fcd57610fc88288615b0e565b610fd7565b610fd78783615b0e565b610fea906001600160b01b031684615880565b925080610ff681615ba6565b915050610f1d565b50620f424061102976ffffffffffffffffffffffffffffffffffffffffffffff8416620137ac6159fc565b6110339190615936565b9450505050909192565b60408051606081018252600c546001600160a01b0381168252600160a01b8104600290810b810b810b6020840152600160b81b909104810b810b900b91810191909152600090819061108e906133b4565b60408051808201909152600d546001600160a01b039081168252600e5416602082015291935091506110bf90613494565b6110c990836158bb565b60408051808201909152600f546001600160a01b0390811682526010541660208201529092506110f890613494565b61110290826158bb565b905061110c613594565b61111690836158bb565b915061112061363d565b61112a90826158bb565b90509091565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146111995760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b6044820152606401610bb8565b600955565b6001600160a01b0381166000908152600560205260408120545b92915050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146112275760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b6044820152606401610bb8565b6008805460ff191660ff92909216919091179055565b6060600480546109ff90615b71565b601154600090819060ff16156112935760405162461bcd60e51b815260206004820152600c60248201526b105b1bd94e88131bd8dad95960a21b6044820152606401610bb8565b6011805460ff19166001179055846112de5760405162461bcd60e51b815260206004820152600e60248201526d416c6f653a20302073686172657360901b6044820152606401610bb8565b60006112e960025490565b6112f49060016158bb565b905060008061130b611304613594565b89856125e3565b945061131861130461363d565b93506113248884613690565b909250905061133382866158bb565b945061133f81856158bb565b60408051808201909152600d546001600160a01b039081168252600e541660208201529094506113729061130490613494565b60408051808201909152600f546001600160a01b0390811682526010541660208201529092506113a59061130490613494565b60408051808201909152600d546001600160a01b039081168252600e541660208201529091506113d59083613779565b60408051808201909152600f546001600160a01b0390811682526010541660208201526114029082613779565b61140c82866158bb565b945061141881856158bb565b93508685101561146a5760405162461bcd60e51b815260206004820152601560248201527f416c6f653a20616d6f756e743020746f6f206c6f7700000000000000000000006044820152606401610bb8565b858410156114ba5760405162461bcd60e51b815260206004820152601560248201527f416c6f653a20616d6f756e743120746f6f206c6f7700000000000000000000006044820152606401610bb8565b6114ee6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163387613a48565b6115226001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163386613a48565b61152c3389613ac3565b604080518981526020810187905290810185905233907f02f25270a4d87bea75db541cdfe559334a275b4a233520ed6c0a2429667cca949060600160405180910390a250506011805460ff19169055509094909350915050565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156116205760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760448201527f207a65726f0000000000000000000000000000000000000000000000000000006064820152608401610bb8565b61162d33858584036124bf565b5060019392505050565b6000610a8f3384846129d9565b60408051600a80825261016082019092526060916020820161014080368337019050509050610d5c8160008151811061168d57634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff1681525050610bf4816001815181106116cb57634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff1681525050610a8c8160028151811061170957634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff16815250506109248160038151811061174757634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff16815250506107bc8160048151811061178557634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff1681525050610654816005815181106117c357634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff16815250506104ec8160068151811061180157634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff16815250506103848160078151811061183f57634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff168152505061021c8160088151811061187d57634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff168152505060b4816009815181106118ba57634e487b7160e01b600052603260045260246000fd5b602002602001019063ffffffff16908163ffffffff168152505090565b60008060006118e4610a98565b60408051606081018252600c546001600160a01b0381168252600160a01b8104600290810b810b810b6020840152600160b81b909104810b810b900b918101919091529193509150611937908383613c11565b9250505090565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146119b65760405162461bcd60e51b815260206004820152600d60248201527f46616b652063616c6c6261636b000000000000000000000000000000000000006044820152606401610bb8565b83156119f0576119f06001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163386613a48565b8215611a2a57611a2a6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163385613a48565b5050600691909155600755565b83421115611a875760405162461bcd60e51b815260206004820152601d60248201527f45524332305065726d69743a206578706972656420646561646c696e650000006044820152606401610bb8565b60007f0000000000000000000000000000000000000000000000000000000000000000888888611ab68c613d68565b6040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000611b1182613d90565b90506000611b2182878787613dde565b9050896001600160a01b0316816001600160a01b031614611b845760405162461bcd60e51b815260206004820152601e60248201527f45524332305065726d69743a20696e76616c6964207369676e617475726500006044820152606401610bb8565b611b8f8a8a8a6124bf565b50505050505050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614611c045760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b6044820152606401610bb8565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b031614158015611c7857507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316836001600160a01b031614155b8015611c925750600d546001600160a01b03848116911614155b8015611cac5750600f546001600160a01b03848116911614155b611cf85760405162461bcd60e51b815260206004820152600d60248201527f4e6f7420737765657061626c65000000000000000000000000000000000000006044820152606401610bb8565b611d0c6001600160a01b0384168284613a48565b505050565b60115460ff1615611d535760405162461bcd60e51b815260206004820152600c60248201526b105b1bd94e88131bd8dad95960a21b6044820152606401610bb8565b6011805460ff191660011790556040805160608082018352600c546001600160a01b0381168352600160a01b8104600290810b810b810b602080860191909152600160b81b909204810b810b900b83850152835160e08101855260008082529181018290529384018190529083018190526080830181905260a0830181905260c08301529081600001516001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b158015611e1557600080fd5b505afa158015611e29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4d9190615534565b5050505050600290810b900b60408301526001600160a01b0316808252611e799080600160601b6125e3565b6001600160e01b031660c0820152611e8f610a98565b600290810b900b6060830181905262ffffff90911660808301819052611eb791849190613c11565b61ffff1660a082015260808101805160011c627fffff1690819052611edf90610ef690615c1e565b611ef6906001600160a01b0316600160601b615b2e565b6bffffffffffffffffffffffff1660208201526000611f1483613f87565b505050509050600080611f30838661408590919063ffffffff16565b935093505050611f408282614220565b5050505050600080600080611f5361103d565b9150915080611f74838760c001516001600160e01b0316600160601b6125e3565b1115611fc057611f9b8186602001516bffffffffffffffffffffffff16600160601b6125e3565b9250611fb983600160601b8760c001516001600160e01b03166125e3565b9350612002565b611fe18286602001516bffffffffffffffffffffffff16600160601b6125e3565b9350611fff848660c001516001600160e01b0316600160601b6125e3565b92505b600061200c613594565b9050600061201861363d565b90508582118582118161205b5761205b612032858a615b2e565b60408051808201909152600d546001600160a01b039081168252600e5416602082015290613779565b806120965761209661206d8489615b2e565b60408051808201909152600f546001600160a01b03908116825260105416602082015290613779565b886080015189604001516120aa9190615a1b565b600290810b900b60208b0152608089015160408a01516120ca91906157fa565b600290810b900b60408b01526120df8a6142a0565b600060068190556007558951909a50612106906120ff908c908b8b61439f565b8b906143c6565b60208a0151600c805460408d0151600290810b62ffffff908116600160b81b027fffffffffffff000000ffffffffffffffffffffffffffffffffffffffffffffff9590920b16600160a01b02939093167fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff9091161791909117905581156121c1576121c1600654856121989190615b2e565b60408051808201909152600d546001600160a01b039081168252600e541660208201529061448c565b801561220157612201600754846121d89190615b2e565b60408051808201909152600f546001600160a01b0390811682526010541660208201529061448c565b600061221060046127106159fc565b905061221d60028d615bfc565b60ff1661228757612239600a548b60a0015161ffff16836125e3565b985061226f6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016338b613a48565b88600a60008282546122819190615b2e565b90915550505b60ff8c16156122f3576122a5600b548b60a0015161ffff16836125e3565b97506122db6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016338a613a48565b87600b60008282546122ed9190615b2e565b90915550505b507f0ebf3c7399f49a81ae6814398548e82c23944b5fd9ce915ba7e5cd958b0984058a602001518b604001518b602001518c60a001518a8a60405161237a96959493929190600296870b81529490950b60208501526bffffffffffffffffffffffff92909216604084015261ffff166060830152608082015260a081019190915260c00190565b60405180910390a150506011805460ff19169055505050505050505050565b6001600160a01b038116734ddc2d193948926d02f9b1fe9e1daa0718270ed514156123f55781546001600160a01b03821673ffffffffffffffffffffffffffffffffffffffff1991821617835560018301805490911690555050565b815473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038216908117835560408051636f307dc360e01b81529051636f307dc391600480820192602092909190829003018186803b15801561245357600080fd5b505afa158015612467573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061248b9190615257565b60018301805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03929092169190911790555b5050565b6001600160a01b0383166125215760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610bb8565b6001600160a01b0382166125825760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610bb8565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60008080600019858709858702925082811083820303915050806000141561261d576000841161261257600080fd5b508290049050610bd4565b80841161262957600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b60006401000276a36001600160a01b038316108015906126ce575073fffd8963efd1fc6a506488495d951d5263988d266001600160a01b038316105b6126fe5760405162461bcd60e51b81526020600482015260016024820152602960f91b6044820152606401610bb8565b77ffffffffffffffffffffffffffffffffffffffff00000000602083901b166001600160801b03811160071b81811c67ffffffffffffffff811160061b90811c63ffffffff811160051b90811c61ffff811160041b90811c60ff8111600390811b91821c600f811160021b90811c918211600190811b92831c979088119617909417909217179091171717608081106127a65761279c607f82615b2e565b83901c91506127b7565b6127b181607f615b2e565b83901b91505b600060406127c6608084615a62565b901b9050828302607f1c92508260801c80603f1b8217915083811c935050828302607f1c92508260801c80603e1b8217915083811c935050828302607f1c92508260801c80603d1b8217915083811c935050828302607f1c92508260801c80603c1b8217915083811c935050828302607f1c92508260801c80603b1b8217915083811c935050828302607f1c92508260801c80603a1b8217915083811c935050828302607f1c92508260801c8060391b8217915083811c935050828302607f1c92508260801c8060381b8217915083811c935050828302607f1c92508260801c8060371b8217915083811c935050828302607f1c92508260801c8060361b8217915083811c935050828302607f1c92508260801c8060351b8217915083811c935050828302607f1c92508260801c8060341b8217915083811c935050828302607f1c92508260801c8060331b8217915083811c935050828302607f1c92508260801c8060321b8217915050600081693627a301d71055774c85612949919061594a565b9050600060806129696f028f6481ab7f045a5af012a19d003aaa84615a62565b901d90506000608061298b846fdb2df09e81959a81455e260799a0632f615840565b901d90508060020b8260020b146129ca57886001600160a01b03166129af82612f88565b6001600160a01b031611156129c457816129cc565b806129cc565b815b9998505050505050505050565b6001600160a01b038316612a555760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610bb8565b6001600160a01b038216612ab75760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610bb8565b6001600160a01b03831660009081526020819052604090205481811015612b465760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e742065786365656473206260448201527f616c616e636500000000000000000000000000000000000000000000000000006064820152608401610bb8565b6001600160a01b03808516600090815260208190526040808220858503905591851681529081208054849290612b7d9084906158bb565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051612bc991815260200190565b60405180910390a35b50505050565b6000808086151580612be957508515155b612c355760405162461bcd60e51b815260206004820152600f60248201527f416c6f653a2030206465706f73697400000000000000000000000000000000006044820152606401610bb8565b60408051606081018252600c546001600160a01b0381168252600160a01b8104600290810b810b810b6020840152600160b81b909104810b810b900b91810191909152612c8190614669565b60408051808201909152600d546001600160a01b039081168252600e54166020820152612cad906146db565b60408051808201909152600f546001600160a01b039081168252601054166020820152612cd9906146db565b612ce38787614752565b9194509250905082612d285760405162461bcd60e51b815260206004820152600e60248201526d416c6f653a20302073686172657360901b6044820152606401610bb8565b84821015612d785760405162461bcd60e51b815260206004820152601560248201527f416c6f653a20616d6f756e743020746f6f206c6f7700000000000000000000006044820152606401610bb8565b83811015612dc85760405162461bcd60e51b815260206004820152601560248201527f416c6f653a20616d6f756e743120746f6f206c6f7700000000000000000000006044820152606401610bb8565b8115612e0357612e036001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333085614936565b8015612e3e57612e3e6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333084614936565b612e48338461496e565b604080518481526020810184905290810182905233907f36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e9060600160405180910390a29450945094915050565b60007f0000000000000000000000000000000000000000000000000000000000000000461415612ee457507f000000000000000000000000000000000000000000000000000000000000000090565b50604080517f00000000000000000000000000000000000000000000000000000000000000006020808301919091527f0000000000000000000000000000000000000000000000000000000000000000828401527f000000000000000000000000000000000000000000000000000000000000000060608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b60008060008360020b12612f9f578260020b612fac565b8260020b612fac90615c3f565b9050612fbb620d89e719615c1e565b62ffffff16811115612ff35760405162461bcd60e51b81526020600482015260016024820152601560fa1b6044820152606401610bb8565b60006001821661301457700100000000000000000000000000000000613026565b6ffffcb933bd6fad37aa2d162d1a5940015b70ffffffffffffffffffffffffffffffffff1690506002821615613065576080613060826ffff97272373d413259a46990580e213a6159fc565b901c90505b600482161561308f57608061308a826ffff2e50f5f656932ef12357cf3c7fdcc6159fc565b901c90505b60088216156130b95760806130b4826fffe5caca7e10e4e61c3624eaa0941cd06159fc565b901c90505b60108216156130e35760806130de826fffcb9843d60f6159c9db58835c9266446159fc565b901c90505b602082161561310d576080613108826fff973b41fa98c081472e6896dfb254c06159fc565b901c90505b6040821615613137576080613132826fff2ea16466c96a3843ec78b326b528616159fc565b901c90505b608082161561316157608061315c826ffe5dee046a99a2a811c461f1969c30536159fc565b901c90505b61010082161561318c576080613187826ffcbe86c7900a88aedcffc83b479aa3a46159fc565b901c90505b6102008216156131b75760806131b2826ff987a7253ac413176f2b074cf7815e546159fc565b901c90505b6104008216156131e25760806131dd826ff3392b0822b70005940c7a398e4b70f36159fc565b901c90505b61080082161561320d576080613208826fe7159475a2c29b7443b29c7fa6e889d96159fc565b901c90505b611000821615613238576080613233826fd097f3bdfd2022b8845ad8f792aa58256159fc565b901c90505b61200082161561326357608061325e826fa9f746462d870fdf8a65dc1f90e061e56159fc565b901c90505b61400082161561328e576080613289826f70d869a156d2a1b890bb3df62baf32f76159fc565b901c90505b6180008216156132b95760806132b4826f31be135f97d08fd981231505542fcfa66159fc565b901c90505b620100008216156132e55760806132e0826f09aa508b5b7a84e1c677de54f3e99bc96159fc565b901c90505b6202000082161561331057608061330b826e5d6af8dedb81196699c329225ee6046159fc565b901c90505b6204000082161561333a576080613335826d2216e584f5fa1ea926041bedfe986159fc565b901c90505b6208000082161561336257608061335d826b048a170391f7dc42444e8fa26159fc565b901c90505b60008460020b131561337d5761337a81600019615936565b90505b61338c64010000000082615be8565b1561339857600161339b565b60005b6133ac9060ff16602083901c6158bb565b949350505050565b60008060008060006133c586613f87565b9450945050509250600086600001516001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561340c57600080fd5b505afa158015613420573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134449190615534565b505050505050905060008061345a898488614a4d565b90925090506134726001600160801b038616836158bb565b6134856001600160801b038616836158bb565b97509750505050505050915091565b80516040516370a0823160e01b815230600482015260009190610bd4906001600160a01b038316906370a082319060240160206040518083038186803b1580156134dd57600080fd5b505afa1580156134f1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061351591906155de565b826001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b15801561354e57600080fd5b505afa158015613562573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061358691906155de565b670de0b6b3a76400006125e3565b600a546040516370a0823160e01b8152306004820152600091906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a08231906024015b60206040518083038186803b1580156135fb57600080fd5b505afa15801561360f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061363391906155de565b610cc09190615b2e565b600b546040516370a0823160e01b8152306004820152600091906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a08231906024016135e3565b6000808284106136b057634e487b7160e01b600052600160045260246000fd5b60408051606081018252600c546001600160a01b0381168252600160a01b8104600290810b810b810b6020840152600160b81b909104810b810b900b9181019190915260006136fe82613f87565b505050509050613718816001600160801b031687876125e3565b90506000806137278484614085565b9298509096509250905061373b8282614220565b909250905061374b8289896125e3565b61375590876158bb565b95506137628189896125e3565b61376c90866158bb565b9450505050509250929050565b80613782575050565b600061380b82670de0b6b3a764000085600001516001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b1580156137ce57600080fd5b505afa1580156137e2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061380691906155de565b6125e3565b6138169060016158bb565b83519091506001600160a01b0316734ddc2d193948926d02f9b1fe9e1daa0718270ed5141561397e5760405163db006a7560e01b815260048101829052734ddc2d193948926d02f9b1fe9e1daa0718270ed59063db006a7590602401602060405180830381600087803b15801561388c57600080fd5b505af11580156138a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138c491906155de565b156139115760405162461bcd60e51b815260206004820152601b60248201527f436f6d706f756e643a2072656465656d20455448206661696c656400000000006044820152606401610bb8565b73c02aaa39b223fe8d0a0e5c4f27ead9083c756cc26001600160a01b031663d0e30db0836040518263ffffffff1660e01b81526004016000604051808303818588803b15801561396057600080fd5b505af1158015613974573d6000803e3d6000fd5b5050505050505050565b825160405163db006a7560e01b8152600481018390526001600160a01b039091169063db006a7590602401602060405180830381600087803b1580156139c357600080fd5b505af11580156139d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139fb91906155de565b15611d0c5760405162461bcd60e51b815260206004820152601760248201527f436f6d706f756e643a2072656465656d206661696c65640000000000000000006044820152606401610bb8565b6040516001600160a01b038316602482015260448101829052611d0c90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152614a80565b6001600160a01b038216613b235760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b6064820152608401610bb8565b6001600160a01b03821660009081526020819052604090205481811015613b975760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610bb8565b6001600160a01b0383166000908152602081905260408120838303905560028054849290613bc6908490615b2e565b90915550506040518281526000906001600160a01b038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a3505050565b600080826002866040015187602001510160020b81613c4057634e487b7160e01b600052601260045260246000fd5b050360020b90506000856020015186604001510390508062ffffff1660001415613c6f57600092505050610bd4565b600060028262ffffff1665ffffffffffff160a65ffffffffffff1660028460050b0a619c400265ffffffffffff1681613cb857634e487b7160e01b600052601260045260246000fd5b0490506127108165ffffffffffff161115613cd65750612710613d5e565b8162ffffff168662ffffff161015613d5e576000600262ffffff848116906127108a021681613d1557634e487b7160e01b600052601260045260246000fd5b046127100362ffffff1681613d3a57634e487b7160e01b600052601260045260246000fd5b04905061271065ffffffffffff62ffffff8316840216048162ffffff168301039150505b9695505050505050565b6001600160a01b03811660009081526005602052604090208054600181018255905b50919050565b60006111b8613d9d612e95565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0821115613e5b5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610bb8565b8360ff16601b1480613e7057508360ff16601c145b613ec75760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610bb8565b6040805160008082526020820180845288905260ff871692820192909252606081018590526080810184905260019060a0016020604051602081039080840390855afa158015613f1b573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116613f7e5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610bb8565b95945050505050565b600080600080600085600001516001600160a01b031663514ea4bf3088602001518960400151604051602001613fef9392919060609390931b6bffffffffffffffffffffffff19168352600291820b60e890811b6014850152910b901b6017820152601a0190565b604051602081830303815290604052805190602001206040518263ffffffff1660e01b815260040161402391815260200190565b60a06040518083038186803b15801561403b57600080fd5b505afa15801561404f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061407391906154de565b939a9299509097509550909350915050565b60008080806001600160801b0385161561413e5785516020870151604080890151905163a34123a760e01b8152600292830b6004820152910b60248201526001600160801b03871660448201526001600160a01b039091169063a34123a7906064016040805180830381600087803b15801561410057600080fd5b505af1158015614114573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061413891906155f6565b90945092505b8551602087015160408089015190516309e3d67b60e31b8152306004820152600292830b6024820152910b60448201526001600160801b0360648201819052608482015260009182916001600160a01b0390911690634f1eb3d89060a4016040805180830381600087803b1580156141b557600080fd5b505af11580156141c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906141ed91906154ac565b6001600160801b0391821693501690506142078683615b2e565b93506142138582615b2e565b9250505092959194509250565b6009546000908190801561429757600061423d86836127106125e3565b90506142498187615b2e565b955080600a600082825461425d91906158bb565b90915550614270905085836127106125e3565b905061427c8186615b2e565b945080600b600082825461429091906158bb565b9091555050505b50929391925050565b60408051606081018252600080825260208083018290529282018190529183015190917f00000000000000000000000000000000000000000000000000000000000000009160020b12614302578083602001516142fd9190615bc6565b61431c565b8083602001516143129190615bc6565b61431c90826157fa565b836020015161432b9190615a1b565b600290810b810b602085015260408401516000910b12614364578083604001516143559190615bc6565b61435f9082615a1b565b61437d565b80836040015161437390615c1e565b61437d9190615bc6565b836040015161438c91906157fa565b600290810b900b60408401525090919050565b6000613f7e846143b28760200151612f88565b6143bf8860400151612f88565b8686614b65565b6001600160801b0381166143d8575050565b815160208301516040808501519051633c8a7d8d60e01b8152306004820152600292830b6024820152910b60448201526001600160801b038316606482015260a06084820152600060a48201526001600160a01b0390911690633c8a7d8d9060c4015b6040805180830381600087803b15801561445457600080fd5b505af1158015614468573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bd291906155f6565b80614495575050565b81516001600160a01b0316734ddc2d193948926d02f9b1fe9e1daa0718270ed5141561458c57604051632e1a7d4d60e01b81526004810182905273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc290632e1a7d4d90602401600060405180830381600087803b15801561450857600080fd5b505af115801561451c573d6000803e3d6000fd5b50505050734ddc2d193948926d02f9b1fe9e1daa0718270ed56001600160a01b0316631249c58b826040518263ffffffff1660e01b81526004016000604051808303818588803b15801561456f57600080fd5b505af1158015614583573d6000803e3d6000fd5b50505050505050565b61459f8260200151836000015183614c1d565b815160405163140e25ad60e31b8152600481018390526001600160a01b039091169063a0712d6890602401602060405180830381600087803b1580156145e457600080fd5b505af11580156145f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061461c91906155de565b156124bb5760405162461bcd60e51b815260206004820152601560248201527f436f6d706f756e643a206d696e74206661696c656400000000000000000000006044820152606401610bb8565b600061467482613f87565b505050509050806001600160801b031660001415614690575050565b81516020830151604080850151905163a34123a760e01b8152600292830b6004820152910b6024820152600060448201526001600160a01b039091169063a34123a79060640161443b565b80600001516001600160a01b031663a6afed956040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561471a57600080fd5b505af115801561472e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124bb91906155de565b60008060008061476160025490565b905060008061476e61103d565b91509150826000148061478057508115155b8061478a57508015155b6147a457634e487b7160e01b600052600160045260246000fd5b826148be5760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e06040518083038186803b15801561480457600080fd5b505afa158015614818573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061483c9190615534565b50505050505090506000614867826001600160a01b0316836001600160a01b0316600160601b6125e3565b905061488189600160601b836001600160e01b03166125e3565b965089871015614896578895508597506148b7565b8996506148b187826001600160e01b0316600160601b6125e3565b95508697505b505061492c565b816148d8578693506148d18484836125e3565b955061492c565b806148eb578794506148d18584846125e3565b6148f68783836125e3565b94508785101561490e578693506148d18484836125e3565b87945061491c8582846125e3565b93506149298584846125e3565b95505b5050509250925092565b6040516001600160a01b0380851660248301528316604482015260648101829052612bd29085906323b872dd60e01b90608401613a74565b6001600160a01b0382166149c45760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610bb8565b80600260008282546149d691906158bb565b90915550506001600160a01b03821660009081526020819052604081208054839290614a039084906158bb565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b600080614a7484614a618760200151612f88565b614a6e8860400151612f88565b86614cbb565b91509150935093915050565b6000614ad5826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614d579092919063ffffffff16565b805190915015611d0c5780806020019051810190614af39190615451565b611d0c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610bb8565b6000836001600160a01b0316856001600160a01b03161115614b85579293925b846001600160a01b0316866001600160a01b031611614bb057614ba9858585614d66565b9050613f7e565b836001600160a01b0316866001600160a01b03161015614c12576000614bd7878686614d66565b90506000614be6878986614dd0565b9050806001600160801b0316826001600160801b031610614c075780614c09565b815b92505050613f7e565b613d5e858584614dd0565b604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015282919085169063dd62ed3e9060440160206040518083038186803b158015614c6757600080fd5b505afa158015614c7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614c9f91906155de565b1015611d0c57611d0c6001600160a01b03841683600019614e06565b600080836001600160a01b0316856001600160a01b03161115614cdc579293925b846001600160a01b0316866001600160a01b031611614d0757614d00858585614f31565b9150614d4e565b836001600160a01b0316866001600160a01b03161015614d4057614d2c868585614f31565b9150614d39858785614fad565b9050614d4e565b614d4b858585614fad565b90505b94509492505050565b60606133ac8484600085614ff7565b6000826001600160a01b0316846001600160a01b03161115614d86579192915b6000614da9856001600160a01b0316856001600160a01b0316600160601b6125e3565b9050613f7e614dcb8483614dbd8989615ae6565b6001600160a01b03166125e3565b615136565b6000826001600160a01b0316846001600160a01b03161115614df0579192915b6133ac614dcb83600160601b614dbd8888615ae6565b801580614e8f5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015614e5557600080fd5b505afa158015614e69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190614e8d91906155de565b155b614f015760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527f20746f206e6f6e2d7a65726f20616c6c6f77616e6365000000000000000000006064820152608401610bb8565b6040516001600160a01b038316602482015260448101829052611d0c90849063095ea7b360e01b90606401613a74565b6000826001600160a01b0316846001600160a01b03161115614f51579192915b6001600160a01b038416614fa37bffffffffffffffffffffffffffffffff000000000000000000000000606085901b16614f8b8787615ae6565b6001600160a01b0316866001600160a01b03166125e3565b6133ac9190615936565b6000826001600160a01b0316846001600160a01b03161115614fcd579192915b6133ac6001600160801b038316614fe48686615ae6565b6001600160a01b0316600160601b6125e3565b60608247101561506f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610bb8565b843b6150bd5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610bb8565b600080866001600160a01b031685876040516150d9919061570c565b60006040518083038185875af1925050503d8060008114615116576040519150601f19603f3d011682016040523d82523d6000602084013e61511b565b606091505b509150915061512b828286615151565b979650505050505050565b806001600160801b038116811461514c57600080fd5b919050565b60608315615160575081610bd4565b8251156151705782518084602001fd5b8160405162461bcd60e51b8152600401610bb89190615772565b600082601f83011261519a578081fd5b815160206151af6151aa836157d6565b6157a5565b80838252828201915082860187848660051b89010111156151ce578586fd5b855b858110156151f55781516151e381615c9b565b845292840192908401906001016151d0565b5090979650505050505050565b8051801515811461514c57600080fd5b80516001600160801b038116811461514c57600080fd5b805161ffff8116811461514c57600080fd5b60006020828403121561524c578081fd5b8135610bd481615c9b565b600060208284031215615268578081fd5b8151610bd481615c9b565b60008060408385031215615285578081fd5b823561529081615c9b565b915060208301356152a081615c9b565b809150509250929050565b6000806000606084860312156152bf578081fd5b83356152ca81615c9b565b925060208401356152da81615c9b565b929592945050506040919091013590565b600080600080600080600060e0888a031215615305578283fd5b873561531081615c9b565b9650602088013561532081615c9b565b95506040880135945060608801359350608088013561533e81615cb3565b9699959850939692959460a0840135945060c09093013592915050565b6000806040838503121561536d578182fd5b823561537881615c9b565b946020939093013593505050565b60008060408385031215615398578182fd5b825167ffffffffffffffff808211156153af578384fd5b818501915085601f8301126153c2578384fd5b815160206153d26151aa836157d6565b8083825282820191508286018a848660051b89010111156153f1578889fd5b8896505b848710156154215780518060060b811461540d57898afd5b8352600196909601959183019183016153f5565b509188015191965090935050508082111561543a578283fd5b506154478582860161518a565b9150509250929050565b600060208284031215615462578081fd5b610bd482615202565b60008060006060848603121561547f578081fd5b833561548a81615c9b565b92506020840135915060408401356154a181615c9b565b809150509250925092565b600080604083850312156154be578182fd5b6154c783615212565b91506154d560208401615212565b90509250929050565b600080600080600060a086880312156154f5578283fd5b6154fe86615212565b9450602086015193506040860151925061551a60608701615212565b915061552860808701615212565b90509295509295909350565b600080600080600080600060e0888a03121561554e578081fd5b875161555981615c9b565b8097505060208801518060020b8114615570578182fd5b955061557e60408901615229565b945061558c60608901615229565b935061559a60808901615229565b925060a08801516155aa81615cb3565b91506155b860c08901615202565b905092959891949750929550565b6000602082840312156155d7578081fd5b5035919050565b6000602082840312156155ef578081fd5b5051919050565b60008060408385031215615608578182fd5b505080516020909101519092909150565b6000806000806060858703121561562e578182fd5b8435935060208501359250604085013567ffffffffffffffff80821115615653578384fd5b818701915087601f830112615666578384fd5b813581811115615674578485fd5b886020828501011115615685578485fd5b95989497505060200194505050565b6000806000606084860312156156a8578081fd5b505081359360208301359350604090920135919050565b600080600080608085870312156156d4578182fd5b5050823594602084013594506040840135936060013592509050565b600060208284031215615701578081fd5b8135610bd481615cb3565b6000825161571e818460208701615b45565b9190910192915050565b6020808252825182820181905260009190848201906040850190845b8181101561576657835163ffffffff1683529284019291840191600101615744565b50909695505050505050565b6020815260008251806020840152615791816040850160208701615b45565b601f01601f19169190910160400192915050565b604051601f8201601f1916810167ffffffffffffffff811182821017156157ce576157ce615c85565b604052919050565b600067ffffffffffffffff8211156157f0576157f0615c85565b5060051b60200190565b60008160020b8360020b82821282627fffff0382138115161561581f5761581f615c59565b82627fffff1903821281161561583757615837615c59565b50019392505050565b6000808212826001600160ff1b030384138115161561586157615861615c59565b600160ff1b839003841281161561587a5761587a615c59565b50500190565b600076ffffffffffffffffffffffffffffffffffffffffffffff8083168185168083038211156158b2576158b2615c59565b01949350505050565b600082198211156158ce576158ce615c59565b500190565b600060ff821660ff84168060ff038211156158f0576158f0615c59565b019392505050565b60008160060b8360060b8061590f5761590f615c6f565b667fffffffffffff1982146000198214161561592d5761592d615c59565b90059392505050565b60008261594557615945615c6f565b500490565b60006001600160ff1b038184138284138583048511828216161561597057615970615c59565b600160ff1b8487128281168783058912161561598e5761598e615c59565b8587129250878205871284841616156159a9576159a9615c59565b878505871281841616156159bf576159bf615c59565b505050929093029392505050565b60006001600160b01b03808316818516818304811182151516156159f3576159f3615c59565b02949350505050565b6000816000190483118215151615615a1657615a16615c59565b500290565b60008160020b8360020b82811281627fffff1901831281151615615a4157615a41615c59565b81627fffff018313811615615a5857615a58615c59565b5090039392505050565b60008083128015600160ff1b850184121615615a8057615a80615c59565b836001600160ff1b03018313811615615a9b57615a9b615c59565b50500390565b60008160060b8360060b82811281667fffffffffffff1901831281151615615acb57615acb615c59565b81667fffffffffffff018313811615615a5857615a58615c59565b60006001600160a01b0383811690831681811015615b0657615b06615c59565b039392505050565b60006001600160b01b0383811690831681811015615b0657615b06615c59565b600082821015615b4057615b40615c59565b500390565b60005b83811015615b60578181015183820152602001615b48565b83811115612bd25750506000910152565b600181811c90821680615b8557607f821691505b60208210811415613d8a57634e487b7160e01b600052602260045260246000fd5b600060ff821660ff811415615bbd57615bbd615c59565b60010192915050565b60008260020b80615bd957615bd9615c6f565b808360020b0791505092915050565b600082615bf757615bf7615c6f565b500690565b600060ff831680615c0f57615c0f615c6f565b8060ff84160691505092915050565b60008160020b627fffff19811415615c3857615c38615c59565b9003919050565b6000600160ff1b821415615c5557615c55615c59565b0390565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114615cb057600080fd5b50565b60ff81168114615cb057600080fdfea164736f6c6343000804000a00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f564000000000000000000000000039aa39c021dfbae8fac545936693ac917d5e75630000000000000000000000004ddc2d193948926d02f9b1fe9e1daa0718270ed5000000000000000000000000f63ff43c9155f25e3272f2b092943333c3db6308

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

00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f564000000000000000000000000039aa39c021dfbae8fac545936693ac917d5e75630000000000000000000000004ddc2d193948926d02f9b1fe9e1daa0718270ed5000000000000000000000000f63ff43c9155f25e3272f2b092943333c3db6308

-----Decoded View---------------
Arg [0] : uniPool (address): 0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640
Arg [1] : cToken0 (address): 0x39AA39c021dfbaE8faC545936693aC917d5E7563
Arg [2] : cToken1 (address): 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5
Arg [3] : multisig (address): 0xf63ff43C9155F25E3272F2b092943333C3Db6308

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 00000000000000000000000088e6a0c2ddd26feeb64f039a2c41296fcb3f5640
Arg [1] : 00000000000000000000000039aa39c021dfbae8fac545936693ac917d5e7563
Arg [2] : 0000000000000000000000004ddc2d193948926d02f9b1fe9e1daa0718270ed5
Arg [3] : 000000000000000000000000f63ff43c9155f25e3272f2b092943333c3db6308


Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.

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.