ETH Price: $3,178.64 (-2.76%)

Contract

0x8B3AC0f18Eae871b83b9212345E736735e6604d6
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Rebalance140793332022-01-26 5:18:021089 days ago1643174282IN
0x8B3AC0f1...35e6604d6
0 ETH0.0313259786.4706327
Rebalance140306222022-01-18 16:34:091096 days ago1642523649IN
0x8B3AC0f1...35e6604d6
0 ETH0.0256370274.13916385
Rebalance140102942022-01-15 13:28:181099 days ago1642253298IN
0x8B3AC0f1...35e6604d6
0 ETH0.0313338490.61368133
Rebalance139900652022-01-12 10:03:331102 days ago1641981813IN
0x8B3AC0f1...35e6604d6
0 ETH0.04166442120.48845916
Rebalance139652822022-01-08 14:25:031106 days ago1641651903IN
0x8B3AC0f1...35e6604d6
0 ETH0.0196445755.11914561
Rebalance139436512022-01-05 5:45:311110 days ago1641361531IN
0x8B3AC0f1...35e6604d6
0 ETH0.0249489270.00221146
Rebalance139239332022-01-02 4:40:381113 days ago1641098438IN
0x8B3AC0f1...35e6604d6
0 ETH0.0214868961.61186561
Rebalance139018382021-12-29 18:21:461116 days ago1640802106IN
0x8B3AC0f1...35e6604d6
0 ETH0.0295055783.51163136
Rebalance138816662021-12-26 15:36:401119 days ago1640533000IN
0x8B3AC0f1...35e6604d6
0 ETH0.0154141243.61022371
Rebalance138619912021-12-23 14:31:331122 days ago1640269893IN
0x8B3AC0f1...35e6604d6
0 ETH0.0177810251.42056926
Rebalance138401592021-12-20 5:22:081126 days ago1639977728IN
0x8B3AC0f1...35e6604d6
0 ETH0.0157536244.58855476
Rebalance138204532021-12-17 4:22:441129 days ago1639714964IN
0x8B3AC0f1...35e6604d6
0 ETH0.0225269465.14519955
Rebalance138011712021-12-14 4:26:121132 days ago1639455972IN
0x8B3AC0f1...35e6604d6
0 ETH0.0195059955.20912234
Rebalance137817042021-12-11 4:23:051135 days ago1639196585IN
0x8B3AC0f1...35e6604d6
0 ETH0.0170206649.22168522
Rebalance137624312021-12-08 3:22:341138 days ago1638933754IN
0x8B3AC0f1...35e6604d6
0 ETH0.025134272.68507179
Rebalance137411052021-12-04 17:24:481141 days ago1638638688IN
0x8B3AC0f1...35e6604d6
0 ETH0.0275735378.04323901
Rebalance137225002021-12-01 17:59:081144 days ago1638381548IN
0x8B3AC0f1...35e6604d6
0 ETH0.04626924127.5
Update Fee Colle...137157102021-11-30 16:02:211145 days ago1638288141IN
0x8B3AC0f1...35e6604d6
0 ETH0.00559402135.14426307
Rebalance137044752021-11-28 20:25:321147 days ago1638131132IN
0x8B3AC0f1...35e6604d6
0 ETH0.04716228148.76799705
Rebalance136820762021-11-25 7:06:141151 days ago1637823974IN
0x8B3AC0f1...35e6604d6
0 ETH0.03233593102
Rebalance136780452021-11-24 15:44:481151 days ago1637768688IN
0x8B3AC0f1...35e6604d6
0 ETH0.04388515126.91052885
Rebalance136728972021-11-23 20:15:471152 days ago1637698547IN
0x8B3AC0f1...35e6604d6
0 ETH0.03930105103.42491375
Add Keeper136709522021-11-23 12:54:001152 days ago1637672040IN
0x8B3AC0f1...35e6604d6
0 ETH0.0107673692.21077708
Rebalance136666912021-11-22 20:44:531153 days ago1637613893IN
0x8B3AC0f1...35e6604d6
0 ETH0.0358732100.55108304
Add Keeper136472412021-11-19 18:51:361156 days ago1637347896IN
0x8B3AC0f1...35e6604d6
0 ETH0.01284459110
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xf4BB5824...B3dB53786
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
RariFuseStrategy

Compiler Version
v0.8.3+commit.8d00100c

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license
File 1 of 17 : RariFuseStrategy.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;

import "../compound/CompoundStrategy.sol";
import "../../interfaces/rari-fuse/IComptroller.sol";
import "../../interfaces/rari-fuse/IFusePoolDirectory.sol";

/// @title This strategy will deposit collateral token in a Rari Fuse Pool and earn interest.
contract RariFuseStrategy is CompoundStrategy {
    using SafeERC20 for IERC20;
    string public constant NAME = "RariFuse-Strategy";
    string public constant VERSION = "3.0.13";
    uint256 public fusePoolId;
    address private constant FUSE_POOL_DIRECTORY = 0x835482FE0532f169024d5E9410199369aAD5C77E;
    event FusePoolChanged(uint256 indexed newFusePoolId, address indexed oldCToken, address indexed newCToken);

    constructor(
        address _pool,
        address _swapManager,
        uint256 _fusePoolId
    ) CompoundStrategy(_pool, _swapManager, _cTokenByUnderlying(_fusePoolId, address(IVesperPool(_pool).token()))) {
        fusePoolId = _fusePoolId;
    }

    // solhint-enable no-empty-blocks

    /**
     * @notice Calculate total value using underlying token
     * @dev Report total value in collateral token
     */
    function totalValue() public view override returns (uint256 _totalValue) {
        _totalValue = _convertToCollateral(cToken.balanceOf(address(this)));
    }

    /**
     * @notice Changes the underlying Fuse Pool to a new one
     * @dev Redeems cTokens from current fuse pool and mints cTokens of new Fuse Pool
     * @param _newPoolId Fuse Pool ID
     */
    function migrateFusePool(uint256 _newPoolId) external virtual onlyGovernor {
        address _newCToken = _cTokenByUnderlying(_newPoolId, address(collateralToken));
        require(address(cToken) != _newCToken, "same-fuse-pool");
        require(cToken.redeem(cToken.balanceOf(address(this))) == 0, "withdraw-from-fuse-pool-failed");
        collateralToken.safeApprove(address(cToken), 0);
        // We usually do infinite approval via approveToken() any way
        collateralToken.safeApprove(_newCToken, MAX_UINT_VALUE);
        require(CToken(_newCToken).mint(collateralToken.balanceOf(address(this))) == 0, "deposit-to-fuse-pool-failed");
        emit FusePoolChanged(_newPoolId, address(cToken), _newCToken);
        cToken = CToken(_newCToken);
        receiptToken = _newCToken;
        fusePoolId = _newPoolId;
    }

    function isReservedToken(address _token) public view override returns (bool) {
        return _token == address(cToken);
    }

    /**
     * @notice Gets the cToken to mint for a Fuse Pool
     * @param _poolId Fuse Pool ID
     * @param _collateralToken address of the collateralToken
     */
    function _cTokenByUnderlying(uint256 _poolId, address _collateralToken) internal view returns (address) {
        (, , address _comptroller, , ) = IFusePoolDirectory(FUSE_POOL_DIRECTORY).pools(_poolId);
        require(_comptroller != address(0), "rari-fuse-invalid-comptroller");
        if (_collateralToken == WETH) {
            // cETH is mapped with 0x0
            _collateralToken = address(0x0);
        }
        address _cToken = IComptroller(_comptroller).cTokensByUnderlying(_collateralToken);
        require(_cToken != address(0), "rari-fuse-invalid-ctoken");
        return _cToken;
    }

    // solhint-disable-next-line
    function _beforeMigration(address _newStrategy) internal override {}

    /**
     * @notice Calculate earning and withdraw it from Rari Fuse
     * @dev If somehow we got some collateral token in strategy then we want to
     *  include those in profit. That's why we used 'return' outside 'if' condition.
     * @param _totalDebt Total collateral debt of this strategy
     * @return profit in collateral token
     */
    function _realizeProfit(uint256 _totalDebt) internal virtual override returns (uint256) {
        uint256 _collateralBalance = _convertToCollateral(cToken.balanceOf(address(this)));

        if (_collateralBalance > _totalDebt) {
            _withdrawHere(_collateralBalance - _totalDebt);
        }
        return collateralToken.balanceOf(address(this));
    }
}

File 2 of 17 : 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 17 : 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'
        // solhint-disable-next-line max-line-length
        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
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 4 of 17 : 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;
        // solhint-disable-next-line no-inline-assembly
        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");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 5 of 17 : 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) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 6 of 17 : IUniswapV2Router01.sol
pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

File 7 of 17 : IUniswapV2Router02.sol
pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

File 8 of 17 : IAddressList.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;

interface IAddressList {
    function add(address a) external returns (bool);

    function addValue(address a, uint256 v) external returns (bool);

    function addMulti(address[] calldata addrs) external returns (uint256);

    function addValueMulti(address[] calldata addrs, uint256[] calldata values) external returns (uint256);

    function remove(address a) external returns (bool);

    function removeMulti(address[] calldata addrs) external returns (uint256);

    function get(address a) external view returns (uint256);

    function contains(address a) external view returns (bool);

    function at(uint256 index) external view returns (address, uint256);

    function length() external view returns (uint256);
}

File 9 of 17 : IAddressListFactory.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;

interface IAddressListFactory {
    function ours(address a) external view returns (bool);

    function listCount() external view returns (uint256);

    function listAt(uint256 idx) external view returns (address);

    function createList() external returns (address listaddr);
}

File 10 of 17 : ISwapManager.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;

/* solhint-disable func-name-mixedcase */

import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";

interface ISwapManager {
    event OracleCreated(address indexed _sender, address indexed _newOracle, uint256 _period);

    function N_DEX() external view returns (uint256);

    function ROUTERS(uint256 i) external view returns (IUniswapV2Router02);

    function bestOutputFixedInput(
        address _from,
        address _to,
        uint256 _amountIn
    )
        external
        view
        returns (
            address[] memory path,
            uint256 amountOut,
            uint256 rIdx
        );

    function bestPathFixedInput(
        address _from,
        address _to,
        uint256 _amountIn,
        uint256 _i
    ) external view returns (address[] memory path, uint256 amountOut);

    function bestInputFixedOutput(
        address _from,
        address _to,
        uint256 _amountOut
    )
        external
        view
        returns (
            address[] memory path,
            uint256 amountIn,
            uint256 rIdx
        );

    function bestPathFixedOutput(
        address _from,
        address _to,
        uint256 _amountOut,
        uint256 _i
    ) external view returns (address[] memory path, uint256 amountIn);

    function safeGetAmountsOut(
        uint256 _amountIn,
        address[] memory _path,
        uint256 _i
    ) external view returns (uint256[] memory result);

    function unsafeGetAmountsOut(
        uint256 _amountIn,
        address[] memory _path,
        uint256 _i
    ) external view returns (uint256[] memory result);

    function safeGetAmountsIn(
        uint256 _amountOut,
        address[] memory _path,
        uint256 _i
    ) external view returns (uint256[] memory result);

    function unsafeGetAmountsIn(
        uint256 _amountOut,
        address[] memory _path,
        uint256 _i
    ) external view returns (uint256[] memory result);

    function comparePathsFixedInput(
        address[] memory pathA,
        address[] memory pathB,
        uint256 _amountIn,
        uint256 _i
    ) external view returns (address[] memory path, uint256 amountOut);

    function comparePathsFixedOutput(
        address[] memory pathA,
        address[] memory pathB,
        uint256 _amountOut,
        uint256 _i
    ) external view returns (address[] memory path, uint256 amountIn);

    function ours(address a) external view returns (bool);

    function oracleCount() external view returns (uint256);

    function oracleAt(uint256 idx) external view returns (address);

    function getOracle(
        address _tokenA,
        address _tokenB,
        uint256 _period,
        uint256 _i
    ) external view returns (address);

    function createOrUpdateOracle(
        address _tokenA,
        address _tokenB,
        uint256 _period,
        uint256 _i
    ) external returns (address oracleAddr);

    function consultForFree(
        address _from,
        address _to,
        uint256 _amountIn,
        uint256 _period,
        uint256 _i
    ) external view returns (uint256 amountOut, uint256 lastUpdatedAt);

    /// get the data we want and pay the gas to update
    function consult(
        address _from,
        address _to,
        uint256 _amountIn,
        uint256 _period,
        uint256 _i
    )
        external
        returns (
            uint256 amountOut,
            uint256 lastUpdatedAt,
            bool updated
        );

    function updateOracles() external returns (uint256 updated, uint256 expected);

    function updateOracles(address[] memory _oracleAddrs) external returns (uint256 updated, uint256 expected);
}

File 11 of 17 : ICompound.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;

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

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

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

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

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

    function exchangeRateCurrent() external returns (uint256);

    function exchangeRateStored() external view returns (uint256);

    function getAccountSnapshot(address account)
        external
        view
        returns (
            uint256,
            uint256,
            uint256,
            uint256
        );

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

    function mint() external payable; // For ETH

    function mint(uint256 mintAmount) external returns (uint256); // For ERC20

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

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

    function repayBorrow() external payable; // For ETH

    function repayBorrow(uint256 repayAmount) external returns (uint256); // For ERC20

    function transfer(address user, uint256 amount) external returns (bool);

    function getCash() external view returns (uint256);

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

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

interface Comptroller {
    function claimComp(address holder, address[] memory) external;

    function enterMarkets(address[] memory cTokens) external returns (uint256[] memory);

    function exitMarket(address cToken) external returns (uint256);

    function compAccrued(address holder) external view returns (uint256);

    function getAccountLiquidity(address account)
        external
        view
        returns (
            uint256,
            uint256,
            uint256
        );

    function markets(address market)
        external
        view
        returns (
            bool isListed,
            uint256 collateralFactorMantissa,
            bool isCompted
        );
}

File 12 of 17 : IComptroller.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;

interface IComptroller {
    function cTokensByUnderlying(address) external view returns (address cToken);
}

File 13 of 17 : IFusePoolDirectory.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;

interface IFusePoolDirectory {
    function pools(uint256)
        external
        view
        returns (
            string memory name,
            address creator,
            address comptroller,
            uint256 blockPosted,
            uint256 timestampPosted
        );
}

File 14 of 17 : IStrategy.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;
import "../bloq/IAddressList.sol";

interface IStrategy {
    function rebalance() external;

    function sweepERC20(address _fromToken) external;

    function withdraw(uint256 _amount) external;

    function feeCollector() external view returns (address);

    function isReservedToken(address _token) external view returns (bool);

    function keepers() external view returns (IAddressList);

    function migrate(address _newStrategy) external;

    function token() external view returns (address);

    function totalValue() external view returns (uint256);

    function totalValueCurrent() external returns (uint256);

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

File 15 of 17 : IVesperPool.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../bloq/IAddressList.sol";

interface IVesperPool is IERC20 {
    function deposit() external payable;

    function deposit(uint256 _share) external;

    function multiTransfer(address[] memory _recipients, uint256[] memory _amounts) external returns (bool);

    function excessDebt(address _strategy) external view returns (uint256);

    function permit(
        address,
        address,
        uint256,
        uint256,
        uint8,
        bytes32,
        bytes32
    ) external;

    function poolRewards() external returns (address);

    function reportEarning(
        uint256 _profit,
        uint256 _loss,
        uint256 _payback
    ) external;

    function reportLoss(uint256 _loss) external;

    function resetApproval() external;

    function sweepERC20(address _fromToken) external;

    function withdraw(uint256 _amount) external;

    function withdrawETH(uint256 _amount) external;

    function whitelistedWithdraw(uint256 _amount) external;

    function governor() external view returns (address);

    function keepers() external view returns (IAddressList);

    function maintainers() external view returns (IAddressList);

    function feeCollector() external view returns (address);

    function pricePerShare() external view returns (uint256);

    function strategy(address _strategy)
        external
        view
        returns (
            bool _active,
            uint256 _interestFee,
            uint256 _debtRate,
            uint256 _lastRebalance,
            uint256 _totalDebt,
            uint256 _totalLoss,
            uint256 _totalProfit,
            uint256 _debtRatio
        );

    function stopEverything() external view returns (bool);

    function token() external view returns (IERC20);

    function tokensHere() external view returns (uint256);

    function totalDebtOf(address _strategy) external view returns (uint256);

    function totalValue() external view returns (uint256);

    function withdrawFee() external view returns (uint256);
}

File 16 of 17 : Strategy.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "../interfaces/bloq/ISwapManager.sol";
import "../interfaces/bloq/IAddressList.sol";
import "../interfaces/bloq/IAddressListFactory.sol";
import "../interfaces/vesper/IStrategy.sol";
import "../interfaces/vesper/IVesperPool.sol";

abstract contract Strategy is IStrategy, Context {
    using SafeERC20 for IERC20;

    IERC20 public immutable collateralToken;
    address public receiptToken;
    address public immutable override pool;
    IAddressList public override keepers;
    address public override feeCollector;
    ISwapManager public swapManager;

    uint256 public oraclePeriod = 3600; // 1h
    uint256 public oracleRouterIdx = 0; // Uniswap V2
    uint256 public swapSlippage = 10000; // 100% Don't use oracles by default

    address internal constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
    address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
    uint256 internal constant MAX_UINT_VALUE = type(uint256).max;

    event UpdatedFeeCollector(address indexed previousFeeCollector, address indexed newFeeCollector);
    event UpdatedSwapManager(address indexed previousSwapManager, address indexed newSwapManager);
    event UpdatedSwapSlippage(uint256 oldSwapSlippage, uint256 newSwapSlippage);
    event UpdatedOracleConfig(uint256 oldPeriod, uint256 newPeriod, uint256 oldRouterIdx, uint256 newRouterIdx);

    constructor(
        address _pool,
        address _swapManager,
        address _receiptToken
    ) {
        require(_pool != address(0), "pool-address-is-zero");
        require(_swapManager != address(0), "sm-address-is-zero");
        swapManager = ISwapManager(_swapManager);
        pool = _pool;
        collateralToken = IVesperPool(_pool).token();
        receiptToken = _receiptToken;
    }

    modifier onlyGovernor {
        require(_msgSender() == IVesperPool(pool).governor(), "caller-is-not-the-governor");
        _;
    }

    modifier onlyKeeper() {
        require(keepers.contains(_msgSender()), "caller-is-not-a-keeper");
        _;
    }

    modifier onlyPool() {
        require(_msgSender() == pool, "caller-is-not-vesper-pool");
        _;
    }

    /**
     * @notice Add given address in keepers list.
     * @param _keeperAddress keeper address to add.
     */
    function addKeeper(address _keeperAddress) external onlyGovernor {
        require(keepers.add(_keeperAddress), "add-keeper-failed");
    }

    /**
     * @notice Create keeper list
     * NOTE: Any function with onlyKeeper modifier will not work until this function is called.
     * NOTE: Due to gas constraint this function cannot be called in constructor.
     * @param _addressListFactory To support same code in eth side chain, user _addressListFactory as param
     * mainnet - 0xded8217De022706A191eE7Ee0Dc9df1185Fb5dA3
     * polygon - 0xD10D5696A350D65A9AA15FE8B258caB4ab1bF291
     * avalanche - 0xc5CdF8CBE886FC5c1EF5CD4fdd599C975eC6BB54
     */
    function init(address _addressListFactory) external onlyGovernor {
        require(address(keepers) == address(0), "keeper-list-already-created");
        // Prepare keeper list
        IAddressListFactory _factory = IAddressListFactory(_addressListFactory);
        keepers = IAddressList(_factory.createList());
        require(keepers.add(_msgSender()), "add-keeper-failed");
    }

    /**
     * @notice Migrate all asset and vault ownership,if any, to new strategy
     * @dev _beforeMigration hook can be implemented in child strategy to do extra steps.
     * @param _newStrategy Address of new strategy
     */
    function migrate(address _newStrategy) external virtual override onlyPool {
        require(_newStrategy != address(0), "new-strategy-address-is-zero");
        require(IStrategy(_newStrategy).pool() == pool, "not-valid-new-strategy");
        _beforeMigration(_newStrategy);
        IERC20(receiptToken).safeTransfer(_newStrategy, IERC20(receiptToken).balanceOf(address(this)));
        collateralToken.safeTransfer(_newStrategy, collateralToken.balanceOf(address(this)));
    }

    /**
     * @notice Remove given address from keepers list.
     * @param _keeperAddress keeper address to remove.
     */
    function removeKeeper(address _keeperAddress) external onlyGovernor {
        require(keepers.remove(_keeperAddress), "remove-keeper-failed");
    }

    /**
     * @notice Update fee collector
     * @param _feeCollector fee collector address
     */
    function updateFeeCollector(address _feeCollector) external onlyGovernor {
        require(_feeCollector != address(0), "fee-collector-address-is-zero");
        require(_feeCollector != feeCollector, "fee-collector-is-same");
        emit UpdatedFeeCollector(feeCollector, _feeCollector);
        feeCollector = _feeCollector;
    }

    /**
     * @notice Update swap manager address
     * @param _swapManager swap manager address
     */
    function updateSwapManager(address _swapManager) external onlyGovernor {
        require(_swapManager != address(0), "sm-address-is-zero");
        require(_swapManager != address(swapManager), "sm-is-same");
        emit UpdatedSwapManager(address(swapManager), _swapManager);
        swapManager = ISwapManager(_swapManager);
    }

    function updateSwapSlippage(uint256 _newSwapSlippage) external onlyGovernor {
        require(_newSwapSlippage <= 10000, "invalid-slippage-value");
        emit UpdatedSwapSlippage(swapSlippage, _newSwapSlippage);
        swapSlippage = _newSwapSlippage;
    }

    function updateOracleConfig(uint256 _newPeriod, uint256 _newRouterIdx) external onlyGovernor {
        require(_newRouterIdx < swapManager.N_DEX(), "invalid-router-index");
        if (_newPeriod == 0) _newPeriod = oraclePeriod;
        require(_newPeriod > 59, "invalid-oracle-period");
        emit UpdatedOracleConfig(oraclePeriod, _newPeriod, oracleRouterIdx, _newRouterIdx);
        oraclePeriod = _newPeriod;
        oracleRouterIdx = _newRouterIdx;
    }

    /// @dev Approve all required tokens
    function approveToken() external onlyKeeper {
        _approveToken(0);
        _approveToken(MAX_UINT_VALUE);
    }

    function setupOracles() external onlyKeeper {
        _setupOracles();
    }

    /**
     * @dev Withdraw collateral token from lending pool.
     * @param _amount Amount of collateral token
     */
    function withdraw(uint256 _amount) external override onlyPool {
        _withdraw(_amount);
    }

    /**
     * @dev Rebalance profit, loss and investment of this strategy
     */
    function rebalance() external virtual override onlyKeeper {
        (uint256 _profit, uint256 _loss, uint256 _payback) = _generateReport();
        IVesperPool(pool).reportEarning(_profit, _loss, _payback);
        _reinvest();
    }

    /**
     * @dev sweep given token to feeCollector of strategy
     * @param _fromToken token address to sweep
     */
    function sweepERC20(address _fromToken) external override onlyKeeper {
        require(feeCollector != address(0), "fee-collector-not-set");
        require(_fromToken != address(collateralToken), "not-allowed-to-sweep-collateral");
        require(!isReservedToken(_fromToken), "not-allowed-to-sweep");
        if (_fromToken == ETH) {
            Address.sendValue(payable(feeCollector), address(this).balance);
        } else {
            uint256 _amount = IERC20(_fromToken).balanceOf(address(this));
            IERC20(_fromToken).safeTransfer(feeCollector, _amount);
        }
    }

    /// @notice Returns address of token correspond to collateral token
    function token() external view override returns (address) {
        return receiptToken;
    }

    /**
     * @notice Calculate total value of asset under management
     * @dev Report total value in collateral token
     */
    function totalValue() public view virtual override returns (uint256 _value);

    /**
     * @notice Calculate total value of asset under management (in real-time)
     * @dev Report total value in collateral token
     */
    function totalValueCurrent() external virtual override returns (uint256) {
        return totalValue();
    }

    /// @notice Check whether given token is reserved or not. Reserved tokens are not allowed to sweep.
    function isReservedToken(address _token) public view virtual override returns (bool);

    /**
     * @notice some strategy may want to prepare before doing migration. 
        Example In Maker old strategy want to give vault ownership to new strategy
     * @param _newStrategy .
     */
    function _beforeMigration(address _newStrategy) internal virtual;

    /**
     *  @notice Generate report for current profit and loss. Also liquidate asset to payback
     * excess debt, if any.
     * @return _profit Calculate any realized profit and convert it to collateral, if not already.
     * @return _loss Calculate any loss that strategy has made on investment. Convert into collateral token.
     * @return _payback If strategy has any excess debt, we have to liquidate asset to payback excess debt.
     */
    function _generateReport()
        internal
        virtual
        returns (
            uint256 _profit,
            uint256 _loss,
            uint256 _payback
        )
    {
        uint256 _excessDebt = IVesperPool(pool).excessDebt(address(this));
        uint256 _totalDebt = IVesperPool(pool).totalDebtOf(address(this));
        _profit = _realizeProfit(_totalDebt);
        _loss = _realizeLoss(_totalDebt);
        _payback = _liquidate(_excessDebt);
    }

    function _calcAmtOutAfterSlippage(uint256 _amount, uint256 _slippage) internal pure returns (uint256) {
        return (_amount * (10000 - _slippage)) / (10000);
    }

    function _simpleOraclePath(address _from, address _to) internal pure returns (address[] memory path) {
        if (_from == WETH || _to == WETH) {
            path = new address[](2);
            path[0] = _from;
            path[1] = _to;
        } else {
            path = new address[](3);
            path[0] = _from;
            path[1] = WETH;
            path[2] = _to;
        }
    }

    function _consultOracle(
        address _from,
        address _to,
        uint256 _amt
    ) internal returns (uint256, bool) {
        // from, to, amountIn, period, router
        (uint256 rate, uint256 lastUpdate, ) = swapManager.consult(_from, _to, _amt, oraclePeriod, oracleRouterIdx);
        // We're looking at a TWAP ORACLE with a 1 hr Period that has been updated within the last hour
        if ((lastUpdate > (block.timestamp - oraclePeriod)) && (rate != 0)) return (rate, true);
        return (0, false);
    }

    function _getOracleRate(address[] memory path, uint256 _amountIn) internal returns (uint256 amountOut) {
        require(path.length > 1, "invalid-oracle-path");
        amountOut = _amountIn;
        bool isValid;
        for (uint256 i = 0; i < path.length - 1; i++) {
            (amountOut, isValid) = _consultOracle(path[i], path[i + 1], amountOut);
            require(isValid, "invalid-oracle-rate");
        }
    }

    /**
     * @notice Safe swap via Uniswap / Sushiswap (better rate of the two)
     * @dev There are many scenarios when token swap via Uniswap can fail, so this
     * method will wrap Uniswap call in a 'try catch' to make it fail safe.
     * however, this method will throw minAmountOut is not met
     * @param _from address of from token
     * @param _to address of to token
     * @param _amountIn Amount to be swapped
     * @param _minAmountOut minimum amount out
     */
    function _safeSwap(
        address _from,
        address _to,
        uint256 _amountIn,
        uint256 _minAmountOut
    ) internal {
        (address[] memory path, uint256 amountOut, uint256 rIdx) =
            swapManager.bestOutputFixedInput(_from, _to, _amountIn);
        if (_minAmountOut == 0) _minAmountOut = 1;
        if (amountOut != 0) {
            swapManager.ROUTERS(rIdx).swapExactTokensForTokens(
                _amountIn,
                _minAmountOut,
                path,
                address(this),
                block.timestamp
            );
        }
    }

    // These methods can be implemented by the inheriting strategy.
    /* solhint-disable no-empty-blocks */
    function _claimRewardsAndConvertTo(address _toToken) internal virtual {}

    /**
     * @notice Set up any oracles that are needed for this strategy.
     */
    function _setupOracles() internal virtual {}

    /* solhint-enable */

    // These methods must be implemented by the inheriting strategy
    function _withdraw(uint256 _amount) internal virtual;

    function _approveToken(uint256 _amount) internal virtual;

    /**
     * @notice Withdraw collateral to payback excess debt in pool.
     * @param _excessDebt Excess debt of strategy in collateral token
     * @return _payback amount in collateral token. Usually it is equal to excess debt.
     */
    function _liquidate(uint256 _excessDebt) internal virtual returns (uint256 _payback);

    /**
     * @notice Calculate earning and withdraw/convert it into collateral token.
     * @param _totalDebt Total collateral debt of this strategy
     * @return _profit Profit in collateral token
     */
    function _realizeProfit(uint256 _totalDebt) internal virtual returns (uint256 _profit);

    /**
     * @notice Calculate loss
     * @param _totalDebt Total collateral debt of this strategy
     * @return _loss Realized loss in collateral token
     */
    function _realizeLoss(uint256 _totalDebt) internal virtual returns (uint256 _loss);

    /**
     * @notice Reinvest collateral.
     * @dev Once we file report back in pool, we might have some collateral in hand
     * which we want to reinvest aka deposit in lender/provider.
     */
    function _reinvest() internal virtual;
}

File 17 of 17 : CompoundStrategy.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.8.3;

import "../Strategy.sol";
import "../../interfaces/compound/ICompound.sol";

/// @title This strategy will deposit collateral token in Compound and earn interest.
abstract contract CompoundStrategy is Strategy {
    using SafeERC20 for IERC20;

    CToken internal cToken;
    address internal constant COMP = 0xc00e94Cb662C3520282E6f5717214004A7f26888;
    Comptroller internal constant COMPTROLLER = Comptroller(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B);

    constructor(
        address _pool,
        address _swapManager,
        address _receiptToken
    ) Strategy(_pool, _swapManager, _receiptToken) {
        require(_receiptToken != address(0), "cToken-address-is-zero");
        cToken = CToken(_receiptToken);
        swapSlippage = 10000; // disable oracles on reward swaps by default
    }

    /**
     * @notice Calculate total value using COMP accrued and cToken
     * @dev Report total value in collateral token
     */
    function totalValue() public view virtual override returns (uint256 _totalValue) {
        _totalValue = _calculateTotalValue(COMPTROLLER.compAccrued(address(this)));
    }

    function totalValueCurrent() external virtual override returns (uint256 _totalValue) {
        _claimComp();
        _totalValue = _calculateTotalValue(IERC20(COMP).balanceOf(address(this)));
    }

    function _calculateTotalValue(uint256 _compAccrued) internal view returns (uint256 _totalValue) {
        if (_compAccrued != 0) {
            (, _totalValue) = swapManager.bestPathFixedInput(COMP, address(collateralToken), _compAccrued, 0);
        }
        _totalValue += _convertToCollateral(cToken.balanceOf(address(this)));
    }

    function isReservedToken(address _token) public view virtual override returns (bool) {
        return _token == address(cToken) || _token == COMP;
    }

    /// @notice Approve all required tokens
    function _approveToken(uint256 _amount) internal virtual override {
        collateralToken.safeApprove(pool, _amount);
        collateralToken.safeApprove(address(cToken), _amount);
        for (uint256 i = 0; i < swapManager.N_DEX(); i++) {
            IERC20(COMP).safeApprove(address(swapManager.ROUTERS(i)), _amount);
        }
    }

    /**
     * @notice Claim COMP and transfer to new strategy
     * @param _newStrategy Address of new strategy.
     */
    function _beforeMigration(address _newStrategy) internal virtual override {
        _claimComp();
        IERC20(COMP).safeTransfer(_newStrategy, IERC20(COMP).balanceOf(address(this)));
    }

    /// @notice Claim comp
    function _claimComp() internal {
        address[] memory _markets = new address[](1);
        _markets[0] = address(cToken);
        COMPTROLLER.claimComp(address(this), _markets);
    }

    /// @notice Claim COMP and convert COMP into collateral token.
    function _claimRewardsAndConvertTo(address _toToken) internal virtual override {
        _claimComp();
        uint256 _compAmount = IERC20(COMP).balanceOf(address(this));
        if (_compAmount != 0) {
            uint256 minAmtOut =
                (swapSlippage != 10000)
                    ? _calcAmtOutAfterSlippage(
                        _getOracleRate(_simpleOraclePath(COMP, _toToken), _compAmount),
                        swapSlippage
                    )
                    : 1;
            _safeSwap(COMP, _toToken, _compAmount, minAmtOut);
        }
    }

    /// @notice Withdraw collateral to payback excess debt
    function _liquidate(uint256 _excessDebt) internal override returns (uint256 _payback) {
        if (_excessDebt != 0) {
            _payback = _safeWithdraw(_excessDebt);
        }
    }

    /**
     * @notice Calculate earning and withdraw it from Compound.
     * @dev Claim COMP and convert into collateral
     * @dev If somehow we got some collateral token in strategy then we want to
     *  include those in profit. That's why we used 'return' outside 'if' condition.
     * @param _totalDebt Total collateral debt of this strategy
     * @return profit in collateral token
     */
    function _realizeProfit(uint256 _totalDebt) internal virtual override returns (uint256) {
        _claimRewardsAndConvertTo(address(collateralToken));
        uint256 _collateralBalance = _convertToCollateral(cToken.balanceOf(address(this)));
        if (_collateralBalance > _totalDebt) {
            _withdrawHere(_collateralBalance - _totalDebt);
        }
        return collateralToken.balanceOf(address(this));
    }

    /**
     * @notice Calculate realized loss.
     * @return _loss Realized loss in collateral token
     */
    function _realizeLoss(uint256 _totalDebt) internal view override returns (uint256 _loss) {
        uint256 _collateralBalance = _convertToCollateral(cToken.balanceOf(address(this)));
        if (_collateralBalance < _totalDebt) {
            _loss = _totalDebt - _collateralBalance;
        }
    }

    /// @notice Deposit collateral in Compound
    function _reinvest() internal virtual override {
        uint256 _collateralBalance = collateralToken.balanceOf(address(this));
        if (_collateralBalance != 0) {
            require(cToken.mint(_collateralBalance) == 0, "deposit-to-compound-failed");
        }
    }

    /// @dev Withdraw collateral and transfer it to pool
    function _withdraw(uint256 _amount) internal override {
        _safeWithdraw(_amount);
        collateralToken.safeTransfer(pool, collateralToken.balanceOf(address(this)));
    }

    /**
     * @notice Safe withdraw will make sure to check asking amount against available amount.
     * @param _amount Amount of collateral to withdraw.
     * @return Actual collateral withdrawn
     */
    function _safeWithdraw(uint256 _amount) internal returns (uint256) {
        uint256 _collateralBalance = _convertToCollateral(cToken.balanceOf(address(this)));
        // Get available liquidity from Compound
        uint256 _availableLiquidity = cToken.getCash();
        // Get minimum of _amount and _avaialbleLiquidity
        uint256 _withdrawAmount = _amount < _availableLiquidity ? _amount : _availableLiquidity;
        // Get minimum of _withdrawAmount and _collateralBalance
        return _withdrawHere(_withdrawAmount < _collateralBalance ? _withdrawAmount : _collateralBalance);
    }

    /// @dev Withdraw collateral here. Do not transfer to pool
    function _withdrawHere(uint256 _amount) internal returns (uint256) {
        if (_amount != 0) {
            require(cToken.redeemUnderlying(_amount) == 0, "withdraw-from-compound-failed");
            _afterRedeem();
        }
        return _amount;
    }

    function _setupOracles() internal virtual override {
        swapManager.createOrUpdateOracle(COMP, WETH, oraclePeriod, oracleRouterIdx);
        if (address(collateralToken) != WETH) {
            swapManager.createOrUpdateOracle(WETH, address(collateralToken), oraclePeriod, oracleRouterIdx);
        }
    }

    /**
     * @dev Compound support ETH as collateral not WETH. This hook will take
     * care of conversion from WETH to ETH and vice versa.
     * @dev This will be used in ETH strategy only, hence empty implementation
     */
    //solhint-disable-next-line no-empty-blocks
    function _afterRedeem() internal virtual {}

    function _convertToCollateral(uint256 _cTokenAmount) internal view returns (uint256) {
        return (_cTokenAmount * cToken.exchangeRateStored()) / 1e18;
    }
}

Settings
{
  "evmVersion": "istanbul",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"address","name":"_swapManager","type":"address"},{"internalType":"uint256","name":"_fusePoolId","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"newFusePoolId","type":"uint256"},{"indexed":true,"internalType":"address","name":"oldCToken","type":"address"},{"indexed":true,"internalType":"address","name":"newCToken","type":"address"}],"name":"FusePoolChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousFeeCollector","type":"address"},{"indexed":true,"internalType":"address","name":"newFeeCollector","type":"address"}],"name":"UpdatedFeeCollector","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newPeriod","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldRouterIdx","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newRouterIdx","type":"uint256"}],"name":"UpdatedOracleConfig","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousSwapManager","type":"address"},{"indexed":true,"internalType":"address","name":"newSwapManager","type":"address"}],"name":"UpdatedSwapManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldSwapSlippage","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newSwapSlippage","type":"uint256"}],"name":"UpdatedSwapSlippage","type":"event"},{"inputs":[],"name":"NAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_keeperAddress","type":"address"}],"name":"addKeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approveToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collateralToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fusePoolId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_addressListFactory","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"isReservedToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"keepers","outputs":[{"internalType":"contract IAddressList","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newStrategy","type":"address"}],"name":"migrate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newPoolId","type":"uint256"}],"name":"migrateFusePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"oraclePeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracleRouterIdx","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebalance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"receiptToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_keeperAddress","type":"address"}],"name":"removeKeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setupOracles","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapManager","outputs":[{"internalType":"contract ISwapManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapSlippage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_fromToken","type":"address"}],"name":"sweepERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalValue","outputs":[{"internalType":"uint256","name":"_totalValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalValueCurrent","outputs":[{"internalType":"uint256","name":"_totalValue","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeCollector","type":"address"}],"name":"updateFeeCollector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newPeriod","type":"uint256"},{"internalType":"uint256","name":"_newRouterIdx","type":"uint256"}],"name":"updateOracleConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_swapManager","type":"address"}],"name":"updateSwapManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newSwapSlippage","type":"uint256"}],"name":"updateSwapSlippage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101da5760003560e01c80639b0db5d011610104578063ce5494bb116100a2578063e645c20211610071578063e645c20214610408578063ec78e83214610410578063fc0c546a14610423578063ffa1ad7414610434576101da565b8063ce5494bb146103c7578063d2c35ce8146103da578063d4c3eea0146103ed578063e00af4a7146103f5576101da565b8063aa101886116100de578063aa1018861461037c578063b2016bd414610384578063c415b95c146103ab578063cd2d7ebe146103be576101da565b80639b0db5d014610323578063a3f4df7e1461032c578063a923b2a614610369576101da565b8063440d72481161017c578063709d039d1161014b578063709d039d146102ed5780637d7c2a1c14610300578063951dc22c1461030857806399b71d5c1461031b576101da565b8063440d7248146102915780634c36fad7146102b45780634dda5222146102c757806367f5e4b8146102da576101da565b80631aedeabe116101b85780631aedeabe1461024b5780632e1a7d4d146102625780634032b72b1461027557806342189c8f14610288576101da565b806314ae9f2e146101df57806316f0115b146101f457806319ab453c14610238575b600080fd5b6101f26101ed3660046132a9565b610459565b005b61021b7f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db2581565b6040516001600160a01b0390911681526020015b60405180910390f35b6101f26102463660046132a9565b6105e8565b61025460065481565b60405190815260200161022f565b6101f2610270366004613482565b610862565b6101f26102833660046132a9565b6108df565b61025460045481565b6102a461029f3660046132a9565b610a5f565b604051901515815260200161022f565b6101f26102c23660046132a9565b610a76565b6101f26102d5366004613482565b610c29565b6101f26102e8366004613482565b6110e2565b60035461021b906001600160a01b031681565b6101f261122e565b60015461021b906001600160a01b031681565b6101f261137d565b61025460085481565b61035c6040518060400160405280601181526020017052617269467573652d537472617465677960781b81525081565b60405161022f9190613574565b6101f26103773660046134b2565b611439565b6101f261166e565b61021b7f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e981565b60025461021b906001600160a01b031681565b61025460055481565b6101f26103d53660046132a9565b61171b565b6101f26103e83660046132a9565b611a32565b610254611bfb565b6101f26104033660046132a9565b611c88565b610254611f23565b60005461021b906001600160a01b031681565b6000546001600160a01b031661021b565b61035c60405180604001604052806006815260200165332e302e313360d01b81525081565b7f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db256001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b1580156104b257600080fd5b505afa1580156104c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104ea91906132c5565b6001600160a01b0316336001600160a01b0316146105235760405162461bcd60e51b815260040161051a906135d7565b60405180910390fd5b600154604051631484968760e11b81526001600160a01b038381166004830152909116906329092d0e90602401602060405180830381600087803b15801561056a57600080fd5b505af115801561057e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a2919061339d565b6105e55760405162461bcd60e51b81526020600482015260146024820152731c995b5bdd994b5ad9595c195c8b59985a5b195960621b604482015260640161051a565b50565b7f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db256001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b15801561064157600080fd5b505afa158015610655573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067991906132c5565b6001600160a01b0316336001600160a01b0316146106a95760405162461bcd60e51b815260040161051a906135d7565b6001546001600160a01b0316156107025760405162461bcd60e51b815260206004820152601b60248201527f6b65657065722d6c6973742d616c72656164792d637265617465640000000000604482015260640161051a565b6000819050806001600160a01b0316630fab4d256040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561074257600080fd5b505af1158015610756573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061077a91906132c5565b600180546001600160a01b0319166001600160a01b03929092169182179055630a3b0a4f6107a53390565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381600087803b1580156107e657600080fd5b505af11580156107fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061081e919061339d565b61085e5760405162461bcd60e51b81526020600482015260116024820152701859190b5ad9595c195c8b59985a5b1959607a1b604482015260640161051a565b5050565b337f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db256001600160a01b0316146108d65760405162461bcd60e51b815260206004820152601960248201527818d85b1b195c8b5a5ccb5b9bdd0b5d995cdc195c8b5c1bdbdb603a1b604482015260640161051a565b6105e581611fb8565b7f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db256001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b15801561093857600080fd5b505afa15801561094c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097091906132c5565b6001600160a01b0316336001600160a01b0316146109a05760405162461bcd60e51b815260040161051a906135d7565b600154604051630a3b0a4f60e01b81526001600160a01b03838116600483015290911690630a3b0a4f90602401602060405180830381600087803b1580156109e757600080fd5b505af11580156109fb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a1f919061339d565b6105e55760405162461bcd60e51b81526020600482015260116024820152701859190b5ad9595c195c8b59985a5b1959607a1b604482015260640161051a565b6007546001600160a01b038281169116145b919050565b7f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db256001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b158015610acf57600080fd5b505afa158015610ae3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0791906132c5565b6001600160a01b0316336001600160a01b031614610b375760405162461bcd60e51b815260040161051a906135d7565b6001600160a01b038116610b825760405162461bcd60e51b8152602060048201526012602482015271736d2d616464726573732d69732d7a65726f60701b604482015260640161051a565b6003546001600160a01b0382811691161415610bcd5760405162461bcd60e51b815260206004820152600a602482015269736d2d69732d73616d6560b01b604482015260640161051a565b6003546040516001600160a01b038084169216907f2d19927e7cac08ceb98b38898a4fdff6da6a27295b9a2d62fe250408ebe044e190600090a3600380546001600160a01b0319166001600160a01b0392909216919091179055565b7f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db256001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b158015610c8257600080fd5b505afa158015610c96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cba91906132c5565b6001600160a01b0316336001600160a01b031614610cea5760405162461bcd60e51b815260040161051a906135d7565b6000610d16827f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e9612034565b6007549091506001600160a01b0380831691161415610d685760405162461bcd60e51b815260206004820152600e60248201526d1cd85b594b599d5cd94b5c1bdbdb60921b604482015260640161051a565b6007546040516370a0823160e01b81523060048201526001600160a01b039091169063db006a759082906370a082319060240160206040518083038186803b158015610db357600080fd5b505afa158015610dc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610deb919061349a565b6040518263ffffffff1660e01b8152600401610e0991815260200190565b602060405180830381600087803b158015610e2357600080fd5b505af1158015610e37573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5b919061349a565b15610ea85760405162461bcd60e51b815260206004820152601e60248201527f77697468647261772d66726f6d2d667573652d706f6f6c2d6661696c65640000604482015260640161051a565b600754610ee3906001600160a01b037f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e9811691166000612224565b610f196001600160a01b037f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e91682600019612224565b6040516370a0823160e01b81523060048201526001600160a01b038083169163a0712d68917f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e916906370a082319060240160206040518083038186803b158015610f8257600080fd5b505afa158015610f96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fba919061349a565b6040518263ffffffff1660e01b8152600401610fd891815260200190565b602060405180830381600087803b158015610ff257600080fd5b505af1158015611006573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061102a919061349a565b156110775760405162461bcd60e51b815260206004820152601b60248201527f6465706f7369742d746f2d667573652d706f6f6c2d6661696c65640000000000604482015260640161051a565b6007546040516001600160a01b0380841692169084907f7725294be69fa7d941c001b388e2086daa9acdf58fbbc7aef3fd8cce3c316b6e90600090a4600780546001600160a01b039092166001600160a01b0319928316811790915560008054909216179055600855565b7f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db256001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b15801561113b57600080fd5b505afa15801561114f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061117391906132c5565b6001600160a01b0316336001600160a01b0316146111a35760405162461bcd60e51b815260040161051a906135d7565b6127108111156111ee5760405162461bcd60e51b8152602060048201526016602482015275696e76616c69642d736c6970706167652d76616c756560501b604482015260640161051a565b60065460408051918252602082018390527ef1c5db862c7598b3b6765552ca951f498611e06412c2d57f8d0b58f82e7f82910160405180910390a1600655565b6001546001600160a01b0316635dbe47e8336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b15801561127f57600080fd5b505afa158015611293573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112b7919061339d565b6112d35760405162461bcd60e51b815260040161051a906135a7565b60008060006112e061237b565b6040516302df682360e11b815260048101849052602481018390526044810182905292955090935091506001600160a01b037f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db2516906305bed04690606401600060405180830381600087803b15801561135857600080fd5b505af115801561136c573d6000803e3d6000fd5b505050506113786124e2565b505050565b6001546001600160a01b0316635dbe47e8336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b1580156113ce57600080fd5b505afa1580156113e2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611406919061339d565b6114225760405162461bcd60e51b815260040161051a906135a7565b61142c600061264f565b61143760001961264f565b565b7f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db256001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b15801561149257600080fd5b505afa1580156114a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114ca91906132c5565b6001600160a01b0316336001600160a01b0316146114fa5760405162461bcd60e51b815260040161051a906135d7565b600360009054906101000a90046001600160a01b03166001600160a01b031663c2fba6676040518163ffffffff1660e01b815260040160206040518083038186803b15801561154857600080fd5b505afa15801561155c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611580919061349a565b81106115c55760405162461bcd60e51b81526020600482015260146024820152730d2dcecc2d8d2c85ae4deeae8cae45ad2dcc8caf60631b604482015260640161051a565b816115d05760045491505b603b82116116185760405162461bcd60e51b81526020600482015260156024820152741a5b9d985b1a590b5bdc9858db194b5c195c9a5bd9605a1b604482015260640161051a565b6004546005546040805192835260208301859052820152606081018290527f83bc5ab8030537fcf1d29c2334f6d22c26c82dcbe5ff03923d2cff5c692c0a7f9060800160405180910390a1600491909155600555565b6001546001600160a01b0316635dbe47e8336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b1580156116bf57600080fd5b505afa1580156116d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f7919061339d565b6117135760405162461bcd60e51b815260040161051a906135a7565b611437612819565b337f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db256001600160a01b03161461178f5760405162461bcd60e51b815260206004820152601960248201527818d85b1b195c8b5a5ccb5b9bdd0b5d995cdc195c8b5c1bdbdb603a1b604482015260640161051a565b6001600160a01b0381166117e55760405162461bcd60e51b815260206004820152601c60248201527f6e65772d73747261746567792d616464726573732d69732d7a65726f00000000604482015260640161051a565b7f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db256001600160a01b0316816001600160a01b03166316f0115b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561184857600080fd5b505afa15801561185c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061188091906132c5565b6001600160a01b0316146118cf5760405162461bcd60e51b81526020600482015260166024820152756e6f742d76616c69642d6e65772d737472617465677960501b604482015260640161051a565b6000546040516370a0823160e01b81523060048201526119639183916001600160a01b03909116906370a082319060240160206040518083038186803b15801561191857600080fd5b505afa15801561192c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611950919061349a565b6000546001600160a01b031691906129d4565b6040516370a0823160e01b81523060048201526105e59082906001600160a01b037f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e916906370a08231906024015b60206040518083038186803b1580156119c957600080fd5b505afa1580156119dd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a01919061349a565b6001600160a01b037f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e91691906129d4565b7f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db256001600160a01b0316630c340a246040518163ffffffff1660e01b815260040160206040518083038186803b158015611a8b57600080fd5b505afa158015611a9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ac391906132c5565b6001600160a01b0316336001600160a01b031614611af35760405162461bcd60e51b815260040161051a906135d7565b6001600160a01b038116611b495760405162461bcd60e51b815260206004820152601d60248201527f6665652d636f6c6c6563746f722d616464726573732d69732d7a65726f000000604482015260640161051a565b6002546001600160a01b0382811691161415611b9f5760405162461bcd60e51b81526020600482015260156024820152746665652d636f6c6c6563746f722d69732d73616d6560581b604482015260640161051a565b6002546040516001600160a01b038084169216907f0f06062680f9bd68e786e9980d9bb03d73d5620fc3b345e417b6eacb310b970690600090a3600280546001600160a01b0319166001600160a01b0392909216919091179055565b6007546040516370a0823160e01b8152306004820152600091611c83916001600160a01b03909116906370a08231906024015b60206040518083038186803b158015611c4657600080fd5b505afa158015611c5a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c7e919061349a565b612a04565b905090565b6001546001600160a01b0316635dbe47e8336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b158015611cd957600080fd5b505afa158015611ced573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d11919061339d565b611d2d5760405162461bcd60e51b815260040161051a906135a7565b6002546001600160a01b0316611d7d5760405162461bcd60e51b81526020600482015260156024820152741999594b58dbdb1b1958dd1bdc8b5b9bdd0b5cd95d605a1b604482015260640161051a565b7f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e96001600160a01b0316816001600160a01b03161415611dff5760405162461bcd60e51b815260206004820152601f60248201527f6e6f742d616c6c6f7765642d746f2d73776565702d636f6c6c61746572616c00604482015260640161051a565b611e0881610a5f565b15611e4c5760405162461bcd60e51b815260206004820152601460248201527306e6f742d616c6c6f7765642d746f2d73776565760641b604482015260640161051a565b6001600160a01b03811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415611e8c57600254611e87906001600160a01b031647612aaf565b6105e5565b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a082319060240160206040518083038186803b158015611ece57600080fd5b505afa158015611ee2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f06919061349a565b60025490915061085e906001600160a01b038481169116836129d4565b6000611f2d612bc8565b6040516370a0823160e01b8152306004820152611c839073c00e94cb662c3520282e6f5717214004a7f26888906370a082319060240160206040518083038186803b158015611f7b57600080fd5b505afa158015611f8f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fb3919061349a565b612c9d565b611fc181612da4565b506040516370a0823160e01b81523060048201526105e5907f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db25906001600160a01b037f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e916906370a08231906024016119b1565b6040516315895f4760e31b815260048101839052600090819073835482fe0532f169024d5e9410199369aad5c77e9063ac4afa389060240160006040518083038186803b15801561208457600080fd5b505afa158015612098573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526120c091908101906133bd565b509093505050506001600160a01b03811661211d5760405162461bcd60e51b815260206004820152601d60248201527f726172692d667573652d696e76616c69642d636f6d7074726f6c6c6572000000604482015260640161051a565b6001600160a01b03831673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2141561214757600092505b6040516318ffa3fd60e11b81526001600160a01b038481166004830152600091908316906331ff47fa9060240160206040518083038186803b15801561218c57600080fd5b505afa1580156121a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121c491906132c5565b90506001600160a01b03811661221c5760405162461bcd60e51b815260206004820152601860248201527f726172692d667573652d696e76616c69642d63746f6b656e0000000000000000604482015260640161051a565b949350505050565b8015806122ad5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b15801561227357600080fd5b505afa158015612287573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ab919061349a565b155b6123185760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161051a565b6040516001600160a01b03831660248201526044810182905261137890849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612e9a565b604051636a9eee1360e11b81523060048201526000908190819081906001600160a01b037f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db25169063d53ddc269060240160206040518083038186803b1580156123e357600080fd5b505afa1580156123f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061241b919061349a565b604051639f2b283360e01b81523060048201529091506000906001600160a01b037f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db251690639f2b28339060240160206040518083038186803b15801561248057600080fd5b505afa158015612494573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124b8919061349a565b90506124c381612f6c565b94506124ce8161305a565b93506124d9826130ab565b92505050909192565b6040516370a0823160e01b81523060048201526000907f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e96001600160a01b0316906370a082319060240160206040518083038186803b15801561254457600080fd5b505afa158015612558573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061257c919061349a565b905080156105e55760075460405163140e25ad60e31b8152600481018390526001600160a01b039091169063a0712d6890602401602060405180830381600087803b1580156125ca57600080fd5b505af11580156125de573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612602919061349a565b156105e55760405162461bcd60e51b815260206004820152601a60248201527f6465706f7369742d746f2d636f6d706f756e642d6661696c6564000000000000604482015260640161051a565b6126a36001600160a01b037f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e9167f0000000000000000000000008bcdd6a8168d658dfa19721eab7470e43398db2583612224565b6007546126dd906001600160a01b037f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e98116911683612224565b60005b600360009054906101000a90046001600160a01b03166001600160a01b031663c2fba6676040518163ffffffff1660e01b815260040160206040518083038186803b15801561272e57600080fd5b505afa158015612742573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612766919061349a565b81101561085e57600354604051636e74a6f760e01b815260048101839052612807916001600160a01b031690636e74a6f79060240160206040518083038186803b1580156127b357600080fd5b505afa1580156127c7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127eb91906132c5565b73c00e94cb662c3520282e6f5717214004a7f268889084612224565b80612811816136dd565b9150506126e0565b60035460048054600554604051630f30f2d360e21b81526001600160a01b0390941693633cc3cb4c9361287c9373c00e94cb662c3520282e6f5717214004a7f268889373c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29391929091016134ef565b602060405180830381600087803b15801561289657600080fd5b505af11580156128aa573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ce91906132c5565b507f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e96001600160a01b031673c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2146114375760035460048054600554604051630f30f2d360e21b81526001600160a01b0390941693633cc3cb4c936129829373c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2937f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e99391929091016134ef565b602060405180830381600087803b15801561299c57600080fd5b505af11580156129b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105e591906132c5565b6040516001600160a01b03831660248201526044810182905261137890849063a9059cbb60e01b90606401612344565b6000670de0b6b3a7640000600760009054906101000a90046001600160a01b03166001600160a01b031663182df0f56040518163ffffffff1660e01b815260040160206040518083038186803b158015612a5d57600080fd5b505afa158015612a71573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a95919061349a565b612a9f9084613677565b612aa99190613657565b92915050565b80471015612aff5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640161051a565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612b4c576040519150601f19603f3d011682016040523d82523d6000602084013e612b51565b606091505b50509050806113785760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840161051a565b60408051600180825281830190925260009160208083019080368337505060075482519293506001600160a01b031691839150600090612c1857634e487b7160e01b600052603260045260246000fd5b6001600160a01b039092166020928302919091019091015260405162e1ed9760e51b8152733d9819210a31b4961b30ef54be2aed79b9c9cd3b90631c3db2e090612c689030908590600401613518565b600060405180830381600087803b158015612c8257600080fd5b505af1158015612c96573d6000803e3d6000fd5b5050505050565b60008115612d68576003546040516340b4c54560e11b81526001600160a01b03909116906381698a8a90612d109073c00e94cb662c3520282e6f5717214004a7f26888907f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e99087906000906004016134ef565b60006040518083038186803b158015612d2857600080fd5b505afa158015612d3c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612d6491908101906132e1565b9150505b6007546040516370a0823160e01b8152306004820152612d9a916001600160a01b0316906370a0823190602401611c2e565b612aa9908261363f565b6007546040516370a0823160e01b81523060048201526000918291612ddb916001600160a01b0316906370a0823190602401611c2e565b90506000600760009054906101000a90046001600160a01b03166001600160a01b0316633b1d21a26040518163ffffffff1660e01b815260040160206040518083038186803b158015612e2d57600080fd5b505afa158015612e41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e65919061349a565b90506000818510612e765781612e78565b845b9050612e91838210612e8a5783612e8c565b815b6130bc565b95945050505050565b6000612eef826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166131939092919063ffffffff16565b8051909150156113785780806020019051810190612f0d919061339d565b6113785760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161051a565b6007546040516370a0823160e01b81523060048201526000918291612fa3916001600160a01b0316906370a0823190602401611c2e565b905082811115612fbc57612fba612e8c8483613696565b505b6040516370a0823160e01b81523060048201527f000000000000000000000000bc6da0fe9ad5f3b0d58160288917aa56653660e96001600160a01b0316906370a082319060240160206040518083038186803b15801561301b57600080fd5b505afa15801561302f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613053919061349a565b9392505050565b6007546040516370a0823160e01b81523060048201526000918291613091916001600160a01b0316906370a0823190602401611c2e565b9050828110156130a5576130538184613696565b50919050565b60008115610a7157612aa982612da4565b6000811561318f5760075460405163852a12e360e01b8152600481018490526001600160a01b039091169063852a12e390602401602060405180830381600087803b15801561310a57600080fd5b505af115801561311e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613142919061349a565b1561318f5760405162461bcd60e51b815260206004820152601d60248201527f77697468647261772d66726f6d2d636f6d706f756e642d6661696c6564000000604482015260640161051a565b5090565b606061221c848460008585843b6131ec5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161051a565b600080866001600160a01b0316858760405161320891906134d3565b60006040518083038185875af1925050503d8060008114613245576040519150601f19603f3d011682016040523d82523d6000602084013e61324a565b606091505b509150915061325a828286613265565b979650505050505050565b60608315613274575081613053565b8251156132845782518084602001fd5b8160405162461bcd60e51b815260040161051a9190613574565b8051610a7181613724565b6000602082840312156132ba578081fd5b813561305381613724565b6000602082840312156132d6578081fd5b815161305381613724565b600080604083850312156132f3578081fd5b825167ffffffffffffffff8082111561330a578283fd5b818501915085601f83011261331d578283fd5b81516020828211156133315761333161370e565b8160051b925061334281840161360e565b8281528181019085830185870184018b101561335c578788fd5b8796505b8487101561338a578051955061337586613724565b85835260019690960195918301918301613360565b5097909101519698969750505050505050565b6000602082840312156133ae578081fd5b81518015158114613053578182fd5b600080600080600060a086880312156133d4578081fd5b855167ffffffffffffffff808211156133eb578283fd5b818801915088601f8301126133fe578283fd5b8151818111156134105761341061370e565b613423601f8201601f191660200161360e565b9150808252896020828501011115613439578384fd5b61344a8160208401602086016136ad565b50955061345b90506020870161329e565b93506134696040870161329e565b6060870151608090970151959894975095949392505050565b600060208284031215613493578081fd5b5035919050565b6000602082840312156134ab578081fd5b5051919050565b600080604083850312156134c4578182fd5b50508035926020909101359150565b600082516134e58184602087016136ad565b9190910192915050565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b6001600160a01b038381168252604060208084018290528451918401829052600092858201929091906060860190855b81811015613566578551851683529483019491830191600101613548565b509098975050505050505050565b60006020825282518060208401526135938160408501602087016136ad565b601f01601f19169190910160400192915050565b60208082526016908201527531b0b63632b916b4b996b737ba16b096b5b2b2b832b960511b604082015260600190565b6020808252601a908201527f63616c6c65722d69732d6e6f742d7468652d676f7665726e6f72000000000000604082015260600190565b604051601f8201601f1916810167ffffffffffffffff811182821017156136375761363761370e565b604052919050565b60008219821115613652576136526136f8565b500190565b60008261367257634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615613691576136916136f8565b500290565b6000828210156136a8576136a86136f8565b500390565b60005b838110156136c85781810151838201526020016136b0565b838111156136d7576000848401525b50505050565b60006000198214156136f1576136f16136f8565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146105e557600080fdfea264697066735822122053a9296daf5040fc014b9221e616dc1dfad44f3c5b29174f1f0529e73b976cb664736f6c63430008030033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

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.