Contract 0xd055b086180cB6dac888792C9307970Ed10CF137 4

 
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x792729efe612850c0e40f62219d39be606a4bccf2d4534a252378922e81e0fdaSet Conversion P...175846402021-08-03 19:43:37416 days 19 hrs agoTETU Reward: Deployer IN  Tetu: OLD Fee Reward Forwarder0 MATIC0.0009488886
0x75b391afeb3255dab3cf6dcd08e5968a1730c9c747ff3e3188d03d9153876be2Set Conversion P...175846352021-08-03 19:43:15416 days 19 hrs agoTETU Reward: Deployer IN  Tetu: OLD Fee Reward Forwarder0 MATIC0.001197816
0x1f7757580dccbeedd1a51b66f4ae0de858f7b703d24047f0789d20ad688bb9e9Set Conversion P...175841292021-08-03 19:23:39416 days 19 hrs agoTETU Reward: Deployer IN  Tetu: OLD Fee Reward Forwarder0 MATIC0.0009488886
0xf60fb46e85458b50467403f52eb5b94692d095e3099d8e757b0f4b73c168900cSet Conversion P...175841192021-08-03 19:23:15416 days 20 hrs agoTETU Reward: Deployer IN  Tetu: OLD Fee Reward Forwarder0 MATIC0.001197816
0x3f48746ea0cb600234018abc0b4a7698d497106ad8a5e3e6391a00625b714f13Set Conversion P...175841132021-08-03 19:23:03416 days 20 hrs agoTETU Reward: Deployer IN  Tetu: OLD Fee Reward Forwarder0 MATIC0.0003518886
0x12fbab49599c4808543706ca1f9c5395804bb0e3959ceed785b183e6e5fa03dcSet Conversion P...175841072021-08-03 19:22:51416 days 20 hrs agoTETU Reward: Deployer IN  Tetu: OLD Fee Reward Forwarder0 MATIC0.000362016
0x996089267140e0dbd50f9b40daec9a237a0226bdf506560bc3ecc4956bef06b9Set Conversion P...175840952021-08-03 19:22:27416 days 20 hrs agoTETU Reward: Deployer IN  Tetu: OLD Fee Reward Forwarder0 MATIC0.0003518886
0x46b8441475e12c473733a86c5bd6bc1efbcbdc1f1376638f51bb1ebf27716c7cSet Conversion P...175840842021-08-03 19:22:05416 days 20 hrs agoTETU Reward: Deployer IN  Tetu: OLD Fee Reward Forwarder0 MATIC0.000362016
0x7048c8f8a2b7f263aa929553fc2972c8bbb25f84732c16ebd05cb54f627e17f7Set Conversion P...174638142021-07-31 15:30:23419 days 23 hrs agoTETU Reward: Deployer IN  Tetu: OLD Fee Reward Forwarder0 MATIC0.0009488886
0xc049af22ca8d8ba007dcb91492ee9590de73c208a7b4ff8bfaa9f0083336dd48Set Conversion P...174638082021-07-31 15:29:59419 days 23 hrs agoTETU Reward: Deployer IN  Tetu: OLD Fee Reward Forwarder0 MATIC0.001197816
0x657065ddcd29930bd1468075f6ef7b93cb3059160a7e7e1c49cba89393ca432eSet Conversion P...174637982021-07-31 15:29:33419 days 23 hrs agoTETU Reward: Deployer IN  Tetu: OLD Fee Reward Forwarder0 MATIC0.0009488886
0xaf3ce618d7ea05c190149cad702e42256e07c21a36b49be4b7f6249a6b6cf33dSet Conversion P...174637872021-07-31 15:29:11419 days 23 hrs agoTETU Reward: Deployer IN  Tetu: OLD Fee Reward Forwarder0 MATIC0.001197816
0x8329df65c9298af9635dd8305db667d187a3fa7a101855a4198375aafb1a48710x60806040174623052021-07-31 14:33:59420 days 49 mins agoTETU Reward: Deployer IN  Create: FeeRewardForwarder0 MATIC0.0143201286
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FeeRewardForwarder

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 14 : FeeRewardForwarder.sol
// SPDX-License-Identifier: ISC
/**
* By using this software, you understand, acknowledge and accept that Tetu
* and/or the underlying software are provided “as is” and “as available”
* basis and without warranties or representations of any kind either expressed
* or implied. Any use of this open source software released under the ISC
* Internet Systems Consortium license is done at your own risk to the fullest
* extent permissible pursuant to applicable law any and all liability as well
* as all warranties, including any fitness for a particular purpose with respect
* to Tetu and/or the underlying software and the use thereof are disclaimed.
*/

pragma solidity 0.8.4;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "../interface/ISmartVault.sol";
import "../interface/IFeeRewardForwarder.sol";
import "../interface/IBookkeeper.sol";
import "./Controllable.sol";
import "../../third_party/uniswap/IUniswapV2Router02.sol";

/// @title Convert rewards from external projects to TETU and FundToken(USDC by default)
///        and send them to Profit Sharing pool, FundKeeper and vaults
///        After swap TETU tokens are deposited to the Profit Share pool and give xTETU tokens.
///        These tokens send to Vault as a reward for vesting (4 weeks).
///        If external rewards have a destination Profit Share pool
///        it is just sent to the contract as TETU tokens increasing share price.
/// @author belbix
contract FeeRewardForwarder is IFeeRewardForwarder, Controllable {
  using SafeERC20 for IERC20;
  using SafeMath for uint256;

  // ************ EVENTS **********************
  /// @notice Fee distributed to Profit Sharing pool
  event FeeMovedToPs(address indexed ps, address indexed token, uint256 amount);
  /// @notice Fee distributed to vault
  event FeeMovedToVault(address indexed vault, address indexed token, uint256 amount);
  /// @notice Fee distributed to FundKeeper
  event FeeMovedToFund(address indexed fund, address indexed token, uint256 amount);

  // ************ VARIABLES **********************
  /// @notice Version of the contract
  /// @dev Should be incremented when contract changed
  string public constant VERSION = "1.0.0";

  /// @notice Routes for token liquidations
  mapping(address => mapping(address => address[])) public routes;
  /// @notice Routers for token liquidations
  mapping(address => mapping(address => address[])) public routers;

  /// @notice Contract constructor
  /// @param _controller Controller address
  constructor(address _controller) {
    Controllable.initializeControllable(_controller);
  }

  // ***************** VIEW ************************

  /// @notice Return Profit Sharing pool address
  /// @return Profit Sharing pool address
  function psVault() public view returns (address) {
    return IController(controller()).psVault();
  }

  /// @notice Return FundKeeper address
  /// @return FundKeeper address
  function fund() public view returns (address) {
    return IController(controller()).fund();
  }

  /// @notice Return Target token (TETU) address
  /// @return Target token (TETU) address
  function targetToken() public view returns (address) {
    return IController(controller()).rewardToken();
  }

  /// @notice Return a token address used for FundKeeper (USDC by default)
  /// @return FundKeeper's main token address (USDC by default)
  function fundToken() public view returns (address) {
    return IController(controller()).fundToken();
  }

  /// @notice Check a rout path and return true if valid
  /// @param _token Start token
  /// @param _targetToken Final token
  /// @return True if all fine
  function hasValidRoute(address _token, address _targetToken) public view returns (bool){
    return routes[_token][_targetToken].length > 1 // we need to convert token to targetToken
    && routers[_token][_targetToken].length != 0;
    // and route exist
  }

  /// @notice Check a rout path and return true if it has multiple routers
  /// @param _token Start token
  /// @param _targetToken Final token
  /// @return True if more than 1 router
  function isMultiRouter(address _token, address _targetToken) public view returns (bool){
    require(routers[_token][_targetToken].length != 0, "invalid route");
    return routers[_token][_targetToken].length > 1;
  }

  // ************ GOVERNANCE ACTIONS **************************

  /// @notice Only Governance or Controller can call it.
  ///         Sets the path for swapping tokens to the Target/Fund token address
  /// @param _route Array with tokens that need to swap where first
  ///               is external project reward and final is Target/Fund token
  /// @param _routers Swap platform routers. 1 for each swap operation in the route
  function setConversionPath(address[] memory _route, address[] memory _routers)
  external onlyControllerOrGovernance {
    require(_routers.length == 1 ||
      (_route.length != 0 && _routers.length == _route.length.sub(1)), "wrong data");
    address from = _route[0];
    address to = _route[_route.length - 1];
    require(to == targetToken() || to == fundToken(), "wrong to");
    routes[from][to] = _route;
    routers[from][to] = _routers;
  }

  // ***************** EXTERNAL *******************************

  /// @notice Only Reward Distributor or Governance or Controller can call it.
  ///         Distribute rewards for given vault, move fees to PS and Fund
  ///         Under normal circumstances, sender is the strategy
  /// @param _amount Amount of tokens for distribute
  /// @param _token Token for distribute
  /// @param _vault Target vault
  /// @return Amount of distributed Target(TETU) tokens + FundKeeper fee (approx)
  function distribute(uint256 _amount, address _token, address _vault) external override onlyRewardDistribution returns (uint256){
    require(_amount != 0, "zero amount");

    uint256 profitSharingNumerator = IController(controller()).psNumerator();
    uint256 profitSharingDenominator = IController(controller()).psDenominator();

    uint256 toPsAmount = _amount.mul(profitSharingNumerator).div(profitSharingDenominator);
    uint256 toVaultAmount = _amount.sub(toPsAmount);

    uint256 targetTokenDistributed = 0;
    if (toPsAmount > 0) {
      targetTokenDistributed = targetTokenDistributed.add(
        notifyPsPool(_token, toPsAmount)
      );
    }
    if (toVaultAmount > 0) {
      targetTokenDistributed = targetTokenDistributed.add(
        notifyCustomPool(_token, _vault, toVaultAmount)
      );
    }

    return plusFundAmountToDistributedAmount(targetTokenDistributed);
  }

  /// @notice Liquidate the token amount and send to the Profit Sharing pool.
  ///         Under normal circumstances, sender is the strategy
  /// @param _token Token for liquidation
  /// @param _amount Amount of token for liquidation
  /// @return Amount of distributed Target(TETU) tokens
  function notifyPsPool(address _token, uint256 _amount) public override onlyRewardDistribution returns (uint256) {
    require(targetToken() != address(0), "target token is zero");

    uint256 toFund = toFundAmount(_amount);
    sendToFund(_token, toFund);
    uint256 toPs = _amount.sub(toFund);

    uint256 amountToSend = liquidateTokenForTargetToken(_token, toPs, targetToken());

    require(amountToSend > 0, "no liq path");

    IERC20(targetToken()).safeTransfer(psVault(), amountToSend);
    uint256 ppfs = ISmartVault(psVault()).getPricePerFullShare();
    IBookkeeper(IController(controller()).bookkeeper()).registerPpfsChange(psVault(), ppfs);
    emit FeeMovedToPs(psVault(), targetToken(), amountToSend);

    return amountToSend;
  }

  /// @notice Liquidate the token amount and send to the given vault.
  ///         Under normal circumstances, sender is the strategy
  /// @param _token Token for liquidation
  /// @param _amount Amount of token for liquidation
  /// @param _rewardPool Vault address
  /// @return Amount of distributed Target(TETU) tokens
  function notifyCustomPool(address _token, address _rewardPool, uint256 _amount)
  public override onlyRewardDistribution returns (uint256) {
    require(targetToken() != address(0), "target token is zero");

    address psToken = psVault();
    ISmartVault smartVault = ISmartVault(_rewardPool);
    require(smartVault.getRewardTokenIndex(psToken) != type(uint256).max, "psToken not added to vault");

    uint256 toFund = toFundAmount(_amount);
    sendToFund(_token, toFund);
    uint256 toVault = _amount.sub(toFund);

    // if liquidation path exist liquidate to the target token
    uint256 targetTokenBalance = liquidateTokenForTargetToken(_token, toVault, targetToken());

    require(targetTokenBalance > 0, "no liq path");

    IERC20(targetToken()).safeApprove(psVault(), targetTokenBalance);
    ISmartVault(psVault()).deposit(targetTokenBalance);
    uint256 amountToSend = IERC20(psToken).balanceOf(address(this));
    IERC20(psToken).safeApprove(_rewardPool, amountToSend);
    smartVault.notifyTargetRewardAmount(psToken, amountToSend);
    emit FeeMovedToVault(_rewardPool, psToken, amountToSend);
    return targetTokenBalance;
  }

  //************************* INTERNAL **************************

  /// @dev Sell given token for FunTOken and send to FundKeeper
  /// @param _token Token address
  /// @param _amount Token amount
  function sendToFund(address _token, uint256 _amount) internal {
    // no actions if we don't have a fee for fund
    if (_amount == 0) {
      return;
    }
    require(fundToken() != address(0), "fund token is zero");
    require(fund() != address(0), "fund is zero");

    uint256 amountToSend = liquidateTokenForTargetToken(_token, _amount, fundToken());

    require(amountToSend > 0, "no liq path for fund token");

    IERC20(fundToken()).safeTransfer(fund(), amountToSend);

    IBookkeeper(IController(controller()).bookkeeper())
    .registerFundKeeperEarned(fundToken(), amountToSend);
    emit FeeMovedToFund(fund(), fundToken(), amountToSend);
  }

  /// @dev Compute amount for FundKeeper based on Fund ratio from Controller
  /// @param _amount 100% Amount
  /// @return Percent of total amount
  function toFundAmount(uint256 _amount) internal view returns (uint256) {
    uint256 fundNumerator = IController(controller()).fundNumerator();
    uint256 fundDenominator = IController(controller()).fundDenominator();
    return _amount.mul(fundNumerator).div(fundDenominator);
  }

  /// @dev Compute Approximate Total amount normalized to TETU token
  /// @param _amount Amount of TETU token distributed to PS and Vault
  /// @return Approximate Total amount normalized to TETU token
  function plusFundAmountToDistributedAmount(uint256 _amount) internal view returns (uint256) {
    uint256 fundNumerator = IController(controller()).fundNumerator();
    uint256 fundDenominator = IController(controller()).fundDenominator();
    uint256 toDistributeNumerator = fundDenominator.sub(fundNumerator);
    return _amount.mul(toDistributeNumerator).div(fundDenominator);
  }

  /// @dev Sell given token for given Target token (TETU or Fund token)
  /// @param _token Token for liquidation
  /// @param _amount Amount for liquidation
  /// @param _targetToken Target token (TETU or Fund token)
  /// @return Target token balance after liquidation
  function liquidateTokenForTargetToken(address _token, uint256 _amount, address _targetToken)
  internal returns (uint256) {
    if (_token == _targetToken) {
      // this is already the right token
      // move reward to this contract
      IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
      return IERC20(_targetToken).balanceOf(address(this));
    } else if (hasValidRoute(_token, _targetToken)) {
      // move reward to this contract
      IERC20(_token).safeTransferFrom(msg.sender, address(this), _amount);
      // get balance for reason we can have manually sent reward tokens
      uint256 balanceToSwap = IERC20(_token).balanceOf(address(this));
      //liquidate depends on routers count
      if (isMultiRouter(_token, _targetToken)) {
        liquidateMultiRouter(_token, balanceToSwap, _targetToken);
      } else {
        liquidate(_token, balanceToSwap, _targetToken);
      }
      return IERC20(_targetToken).balanceOf(address(this));
    }
    // in case when it is unknown token and we don't have a router
    // don't transfer tokens to this contracts
    return 0;
  }

  /// @dev Choose liquidation path for `_from` token to `_targetToken` and make swap
  /// @param _from Start token
  /// @param balanceToSwap Amount for swapping
  /// @param _targetToken Final destination for swap
  function liquidate(address _from, uint256 balanceToSwap, address _targetToken) internal {
    if (balanceToSwap > 0) {
      address router = routers[_from][_targetToken][0];
      swap(router, routes[_from][_targetToken], balanceToSwap);
    }
  }

  /// @dev Choose liquidation path for `_from` token to `_targetToken` and make swap for each router
  /// @param _from Start token
  /// @param balanceToSwap Amount for swapping
  /// @param _targetToken Final destination for swap
  function liquidateMultiRouter(address _from, uint256 balanceToSwap, address _targetToken) internal {
    if (balanceToSwap > 0) {
      address[] memory _routers = routers[_from][_targetToken];
      address[] memory _route = routes[_from][_targetToken];
      for (uint256 i = 0; i < _routers.length; i++) {
        address router = _routers[i];
        address[] memory route = new address[](2);
        route[0] = _route[i];
        route[1] = _route[i + 1];
        uint256 amount = IERC20(route[0]).balanceOf(address(this));
        swap(router, route, amount);
      }
    }
  }

  /// @dev https://uniswap.org/docs/v2/smart-contracts/router02/#swapexacttokensfortokens
  ///      this function can get INSUFFICIENT_INPUT_AMOUNT if we have too low amount of reward
  ///      it is fine and should rollback the doHardWork call
  /// @param _router Uniswap router address
  /// @param _route Path for swap
  /// @param _amount Amount for swap
  function swap(address _router, address[] memory _route, uint256 _amount) internal {
    IERC20(_route[0]).safeApprove(_router, 0);
    IERC20(_route[0]).safeApprove(_router, _amount);
    //slither-disable-next-line unused-return
    IUniswapV2Router02(_router).swapExactTokensForTokens(
      _amount,
      0,
      _route,
      address(this),
      block.timestamp
    );
  }
}

File 2 of 14 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

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

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

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

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

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 3 of 14 : 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 4 of 14 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 5 of 14 : ISmartVault.sol
// SPDX-License-Identifier: ISC
/**
* By using this software, you understand, acknowledge and accept that Tetu
* and/or the underlying software are provided “as is” and “as available”
* basis and without warranties or representations of any kind either expressed
* or implied. Any use of this open source software released under the ISC
* Internet Systems Consortium license is done at your own risk to the fullest
* extent permissible pursuant to applicable law any and all liability as well
* as all warranties, including any fitness for a particular purpose with respect
* to Tetu and/or the underlying software and the use thereof are disclaimed.
*/

pragma solidity 0.8.4;

interface ISmartVault {

  function setStrategy(address _strategy) external;

  function changeActivityStatus(bool _active) external;

  function doHardWork() external;

  function notifyTargetRewardAmount(address _rewardToken, uint256 reward) external;

  function deposit(uint256 amount) external;

  function depositAndInvest(uint256 amount) external;

  function depositFor(uint256 amount, address holder) external;

  function withdraw(uint256 numberOfShares) external;

  function exit() external;

  function getAllRewards() external;

  function getReward(address rt) external;

  function underlying() external view returns (address);

  function strategy() external view returns (address);

  function getRewardTokenIndex(address rt) external view returns (uint256);

  function getPricePerFullShare() external view returns (uint256);

  function underlyingUnit() external view returns (uint256);

  function duration() external view returns (uint256);

  function underlyingBalanceInVault() external view returns (uint256);

  function underlyingBalanceWithInvestment() external view returns (uint256);

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

  function availableToInvestOut() external view returns (uint256);

  function earned(address rt, address account) external view returns (uint256);

  function rewardPerToken(address rt) external view returns (uint256);

  function lastTimeRewardApplicable(address rt) external view returns (uint256);

  function rewardTokensLength() external view returns (uint256);

  function active() external view returns (bool);

  function rewardTokens() external view returns (address[] memory);

  function periodFinishForToken(address _rt) external view returns (uint256);

  function rewardRateForToken(address _rt) external view returns (uint256);

  function lastUpdateTimeForToken(address _rt) external view returns (uint256);

  function rewardPerTokenStoredForToken(address _rt) external view returns (uint256);

  function userRewardPerTokenPaidForToken(address _rt, address account) external view returns (uint256);

  function rewardsForToken(address _rt, address account) external view returns (uint256);

  function userLastWithdrawTs(address _user) external returns (uint256);

  function addRewardToken(address rt) external;

  function removeRewardToken(address rt) external;
}

File 6 of 14 : IFeeRewardForwarder.sol
// SPDX-License-Identifier: ISC
/**
* By using this software, you understand, acknowledge and accept that Tetu
* and/or the underlying software are provided “as is” and “as available”
* basis and without warranties or representations of any kind either expressed
* or implied. Any use of this open source software released under the ISC
* Internet Systems Consortium license is done at your own risk to the fullest
* extent permissible pursuant to applicable law any and all liability as well
* as all warranties, including any fitness for a particular purpose with respect
* to Tetu and/or the underlying software and the use thereof are disclaimed.
*/

pragma solidity 0.8.4;

interface IFeeRewardForwarder {
  function distribute(uint256 _amount, address _token, address _vault) external returns (uint256);

  function notifyPsPool(address _token, uint256 _amount) external returns (uint256);

  function notifyCustomPool(address _token, address _rewardPool, uint256 _maxBuyback) external returns (uint256);
}

File 7 of 14 : IBookkeeper.sol
// SPDX-License-Identifier: ISC
/**
* By using this software, you understand, acknowledge and accept that Tetu
* and/or the underlying software are provided “as is” and “as available”
* basis and without warranties or representations of any kind either expressed
* or implied. Any use of this open source software released under the ISC
* Internet Systems Consortium license is done at your own risk to the fullest
* extent permissible pursuant to applicable law any and all liability as well
* as all warranties, including any fitness for a particular purpose with respect
* to Tetu and/or the underlying software and the use thereof are disclaimed.
*/

pragma solidity 0.8.4;

interface IBookkeeper {

  struct PpfsChange {
    address vault;
    uint256 block;
    uint256 time;
    uint256 value;
    uint256 oldBlock;
    uint256 oldTime;
    uint256 oldValue;
  }

  struct HardWork {
    address strategy;
    uint256 block;
    uint256 time;
    uint256 targetTokenAmount;
  }

  function addVault(address _vault) external;

  function addStrategy(address _strategy) external;

  function registerStrategyEarned(uint256 _targetTokenAmount) external;

  function registerFundKeeperEarned(address _token, uint256 _fundTokenAmount) external;

  function registerUserAction(address _user, uint256 _amount, bool _deposit) external;

  function registerVaultTransfer(address from, address to, uint256 amount) external;

  function registerUserEarned(address _user, address _vault, address _rt, uint256 _amount) external;

  function registerPpfsChange(address vault, uint256 value) external;

  function vaults() external view returns (address[] memory);

  function vaultsLength() external view returns (uint256);

  function strategies() external view returns (address[] memory);

  function strategiesLength() external view returns (uint256);

  function lastPpfsChange(address vault) external view returns (PpfsChange memory);

  /// @notice Return total earned TETU tokens for strategy
  /// @dev Should be incremented after strategy rewards distribution
  /// @param vault Strategy address
  /// @return Earned TETU tokens
  function targetTokenEarned(address vault) external view returns (uint256);

  /// @notice Return share(xToken) balance of given user
  /// @dev Should be calculated for each xToken transfer
  /// @param vault Vault address
  /// @param user User address
  /// @return User share (xToken) balance
  function vaultUsersBalances(address vault, address user) external view returns (uint256);

  /// @notice Return earned token amount for given token and user
  /// @dev Fills when user claim rewards
  /// @param user User address
  /// @param vault Vault address
  /// @param token Token address
  /// @return User's earned tokens amount
  function userEarned(address user, address vault, address token) external view returns (uint256);

  function lastHardWork(address vault) external view returns (HardWork memory);

  /// @notice Return users quantity for given Vault
  /// @dev Calculation based in Bookkeeper user balances
  /// @param vault Vault address
  /// @return Users quantity
  function vaultUsersQuantity(address vault) external view returns (uint256);
}

File 8 of 14 : Controllable.sol
// SPDX-License-Identifier: ISC
/**
* By using this software, you understand, acknowledge and accept that Tetu
* and/or the underlying software are provided “as is” and “as available”
* basis and without warranties or representations of any kind either expressed
* or implied. Any use of this open source software released under the ISC
* Internet Systems Consortium license is done at your own risk to the fullest
* extent permissible pursuant to applicable law any and all liability as well
* as all warranties, including any fitness for a particular purpose with respect
* to Tetu and/or the underlying software and the use thereof are disclaimed.
*/

pragma solidity 0.8.4;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../interface/IController.sol";
import "../interface/IControllable.sol";

/// @title Implement basic functionality for any contract that require strict control
/// @dev Can be used with upgradeable pattern.
///      Require call initializeControllable() in any case.
/// @author belbix
abstract contract Controllable is Initializable, IControllable {
  bytes32 internal constant _CONTROLLER_SLOT = 0x5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c3617;
  bytes32 internal constant _CREATED_SLOT = 0x6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8a;

  /// @notice Controller address changed
  event UpdateController(address oldValue, address newValue);

  constructor() {
    assert(_CONTROLLER_SLOT == bytes32(uint256(keccak256("eip1967.controllable.controller")) - 1));
    assert(_CREATED_SLOT == bytes32(uint256(keccak256("eip1967.controllable.created")) - 1));
  }

  /// @notice Initialize contract after setup it as proxy implementation
  ///         Save block.timestamp in the "created" variable
  /// @dev Use it only once after first logic setup
  /// @param _controller Controller address
  function initializeControllable(address _controller) public initializer {
    setController(_controller);
    setCreated(block.timestamp);
  }

  function isController(address _adr) public override view returns (bool) {
    return _adr == controller();
  }

  /// @notice Return true is given address is setup as governance in Controller
  /// @param _adr Address for check
  /// @return true if given address is governance
  function isGovernance(address _adr) public override view returns (bool) {
    return IController(controller()).governance() == _adr;
  }

  // ************ MODIFIERS **********************

  /// @dev Allow operation only for Controller
  modifier onlyController() {
    require(controller() == msg.sender, "not controller");
    _;
  }

  /// @dev Allow operation only for Controller or Governance
  modifier onlyControllerOrGovernance() {
    require(isController(msg.sender) || isGovernance(msg.sender), "not controller or gov");
    _;
  }

  /// @dev Only smart contracts will be affected by this modifier
  ///      If it is a contract it should be whitelisted
  modifier onlyAllowedUsers() {
    require(IController(controller()).isAllowedUser(msg.sender), "not allowed");
    _;
  }

  /// @dev Only Reward Distributor allowed. Governance is Reward Distributor by default.
  modifier onlyRewardDistribution() {
    require(IController(controller()).isRewardDistributor(msg.sender), "only distr");
    _;
  }

  // ************* SETTERS/GETTERS *******************

  /// @notice Return controller address saved in the contract slot
  /// @return adr Controller address
  function controller() public view returns (address adr) {
    bytes32 slot = _CONTROLLER_SLOT;
    assembly {
      adr := sload(slot)
    }
  }

  /// @dev Set a controller address to contract slot
  /// @param _newController Controller address
  function setController(address _newController) internal {
    require(_newController != address(0), "zero address");
    emit UpdateController(controller(), _newController);
    bytes32 slot = _CONTROLLER_SLOT;
    assembly {
      sstore(slot, _newController)
    }
  }

  /// @notice Return creation timestamp
  /// @return ts Creation timestamp
  function created() external view returns (uint256 ts) {
    bytes32 slot = _CREATED_SLOT;
    assembly {
      ts := sload(slot)
    }
  }

  /// @dev Filled only once when contract initialized
  /// @param _created block.timestamp
  function setCreated(uint256 _created) private {
    bytes32 slot = _CREATED_SLOT;
    assembly {
      sstore(slot, _created)
    }
  }

}

File 9 of 14 : IUniswapV2Router02.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.4;

import "./IUniswapV2Router01.sol";

interface IUniswapV2Router02 {
    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);

    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 10 of 14 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

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

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

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

    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

File 11 of 14 : Initializable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 12 of 14 : IController.sol
// SPDX-License-Identifier: ISC
/**
* By using this software, you understand, acknowledge and accept that Tetu
* and/or the underlying software are provided “as is” and “as available”
* basis and without warranties or representations of any kind either expressed
* or implied. Any use of this open source software released under the ISC
* Internet Systems Consortium license is done at your own risk to the fullest
* extent permissible pursuant to applicable law any and all liability as well
* as all warranties, including any fitness for a particular purpose with respect
* to Tetu and/or the underlying software and the use thereof are disclaimed.
*/

pragma solidity 0.8.4;

interface IController {

  function addVaultAndStrategy(address _vault, address _strategy) external;

  function addStrategy(address _strategy) external;

  function governance() external view returns (address);

  function dao() external view returns (address);

  function bookkeeper() external view returns (address);

  function feeRewardForwarder() external view returns (address);

  function mintHelper() external view returns (address);

  function rewardToken() external view returns (address);

  function fundToken() external view returns (address);

  function psVault() external view returns (address);

  function fund() external view returns (address);

  function announcer() external view returns (address);

  function whiteList(address _target) external view returns (bool);

  function vaults(address _target) external view returns (bool);

  function strategies(address _target) external view returns (bool);

  function psNumerator() external view returns (uint256);

  function psDenominator() external view returns (uint256);

  function fundNumerator() external view returns (uint256);

  function fundDenominator() external view returns (uint256);

  function isAllowedUser(address _adr) external view returns (bool);

  function isDao(address _adr) external view returns (bool);

  function isHardWorker(address _adr) external view returns (bool);

  function isRewardDistributor(address _adr) external view returns (bool);

  function isValidVault(address _vault) external view returns (bool);

  function isValidStrategy(address _strategy) external view returns (bool);

  // ************ DAO ACTIONS *************
  function setPSNumeratorDenominator(uint256 numerator, uint256 denominator) external;

  function setFundNumeratorDenominator(uint256 numerator, uint256 denominator) external;

  function addToWhiteListMulti(address[] calldata _targets) external;

  function addToWhiteList(address _target) external;

  function removeFromWhiteListMulti(address[] calldata _targets) external;

  function removeFromWhiteList(address _target) external;
}

File 13 of 14 : IControllable.sol
// SPDX-License-Identifier: ISC
/**
* By using this software, you understand, acknowledge and accept that Tetu
* and/or the underlying software are provided “as is” and “as available”
* basis and without warranties or representations of any kind either expressed
* or implied. Any use of this open source software released under the ISC
* Internet Systems Consortium license is done at your own risk to the fullest
* extent permissible pursuant to applicable law any and all liability as well
* as all warranties, including any fitness for a particular purpose with respect
* to Tetu and/or the underlying software and the use thereof are disclaimed.
*/

pragma solidity 0.8.4;

interface IControllable {

  function isController(address _contract) external view returns (bool);

  function isGovernance(address _contract) external view returns (bool);
}

File 14 of 14 : IUniswapV2Router01.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.4;

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_controller","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"fund","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeeMovedToFund","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"ps","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeeMovedToPs","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeeMovedToVault","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldValue","type":"address"},{"indexed":false,"internalType":"address","name":"newValue","type":"address"}],"name":"UpdateController","type":"event"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"controller","outputs":[{"internalType":"address","name":"adr","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"created","outputs":[{"internalType":"uint256","name":"ts","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_vault","type":"address"}],"name":"distribute","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fund","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fundToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_targetToken","type":"address"}],"name":"hasValidRoute","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_controller","type":"address"}],"name":"initializeControllable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_adr","type":"address"}],"name":"isController","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_adr","type":"address"}],"name":"isGovernance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_targetToken","type":"address"}],"name":"isMultiRouter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_rewardPool","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"notifyCustomPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"notifyPsPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"psVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"routers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"routes","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_route","type":"address[]"},{"internalType":"address[]","name":"_routers","type":"address[]"}],"name":"setConversionPath","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"targetToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

60806040523480156200001157600080fd5b5060405162002bfb38038062002bfb833981016040819052620000349162000298565b6200006160017f5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c3618620002c8565b60008051602062002bbb833981519152146200008d57634e487b7160e01b600052600160045260246000fd5b620000ba60017f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8b620002c8565b60008051602062002bdb83398151915214620000e657634e487b7160e01b600052600160045260246000fd5b620000fc816200010360201b620011dc1760201c565b50620002ec565b600054610100900460ff16806200011d575060005460ff16155b620001865760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b600054610100900460ff16158015620001a9576000805461ffff19166101011790555b620001b482620001e3565b620001cc4260008051602062002bdb83398151915255565b8015620001df576000805461ff00191690555b5050565b6001600160a01b0381166200022a5760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b60448201526064016200017d565b7f19b7d592cea0dfda222f6a4ea5c5a8d018ee9c6b1d0a917483a405de94eb26cd6200026360008051602062002bbb8339815191525490565b604080516001600160a01b03928316815291841660208301520160405180910390a160008051602062002bbb83398151915255565b600060208284031215620002aa578081fd5b81516001600160a01b0381168114620002c1578182fd5b9392505050565b600082821015620002e757634e487b7160e01b81526011600452602481fd5b500390565b6128bf80620002fc6000396000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c8063b429afeb116100a2578063dee1f0e411610071578063dee1f0e414610233578063e85ad6a914610246578063e945cdcd14610259578063f77c47911461026c578063ffa1ad741461027457600080fd5b8063b429afeb146101f0578063b4b803a114610203578063b60d428814610216578063c56864831461021e57600080fd5b8063451353f1116100e9578063451353f1146101a757806350adcdb7146101ba578063600c557d146101c25780636454c1af146101d557806395f9b3f5146101e857600080fd5b80632bbf306b1461011b578063325a19f114610143578063327107f7146101745780633ac739af14610194575b600080fd5b61012e610129366004612448565b6102a5565b60405190151581526020015b60405180910390f35b7f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8a545b60405190815260200161013a565b61017c610307565b6040516001600160a01b03909116815260200161013a565b6101666101a2366004612480565b610386565b6101666101b5366004612617565b6107b1565b61017c6109f5565b61017c6101d0366004612480565b610a37565b6101666101e33660046124c0565b610a7c565b61017c610dda565b61012e6101fe366004612410565b610e1c565b61012e610211366004612448565b610e41565b61017c610ed4565b61023161022c3660046124eb565b610f16565b005b61012e610241366004612410565b611120565b61017c610254366004612480565b6111b4565b610231610267366004612410565b6111dc565b61017c6112c1565b610298604051806040016040528060058152602001640312e302e360dc1b81525081565b60405161013a9190612674565b6001600160a01b038083166000908152600160208181526040808420948616845293905291812054909110801561030057506001600160a01b0380841660009081526002602090815260408083209386168352929052205415155b9392505050565b60006103116112c1565b6001600160a01b031663f7c618c16040518163ffffffff1660e01b815260040160206040518083038186803b15801561034957600080fd5b505afa15801561035d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610381919061242c565b905090565b60006103906112c1565b6040516316ed852560e01b81523360048201526001600160a01b0391909116906316ed85259060240160206040518083038186803b1580156103d157600080fd5b505afa1580156103e5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061040991906125df565b61042e5760405162461bcd60e51b8152600401610425906126a7565b60405180910390fd5b6000610438610307565b6001600160a01b031614156104865760405162461bcd60e51b815260206004820152601460248201527374617267657420746f6b656e206973207a65726f60601b6044820152606401610425565b6000610490610dda565b6040516301e34c6960e11b81526001600160a01b038083166004830152919250859160001991908316906303c698d29060240160206040518083038186803b1580156104db57600080fd5b505afa1580156104ef573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051391906125ff565b14156105615760405162461bcd60e51b815260206004820152601a60248201527f7073546f6b656e206e6f7420616464656420746f207661756c740000000000006044820152606401610425565b600061056c856112e6565b905061057887826113f5565b60006105848683611667565b9050600061059a8983610595610307565b611673565b9050600081116105da5760405162461bcd60e51b815260206004820152600b60248201526a0dcde40d8d2e240e0c2e8d60ab1b6044820152606401610425565b6105fe6105e5610dda565b826105ee610307565b6001600160a01b03169190611875565b610606610dda565b6001600160a01b031663b6b55f25826040518263ffffffff1660e01b815260040161063391815260200190565b600060405180830381600087803b15801561064d57600080fd5b505af1158015610661573d6000803e3d6000fd5b50506040516370a0823160e01b8152306004820152600092506001600160a01b03881691506370a082319060240160206040518083038186803b1580156106a757600080fd5b505afa1580156106bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106df91906125ff565b90506106f56001600160a01b0387168a83611875565b604051637092a06360e01b81526001600160a01b03878116600483015260248201839052861690637092a06390604401600060405180830381600087803b15801561073f57600080fd5b505af1158015610753573d6000803e3d6000fd5b50505050856001600160a01b0316896001600160a01b03167f60a1331130a4ba6d769854260cd79f35e2d3ae2c26d5421ba4dedf183c4b1ce68360405161079c91815260200190565b60405180910390a35098975050505050505050565b60006107bb6112c1565b6040516316ed852560e01b81523360048201526001600160a01b0391909116906316ed85259060240160206040518083038186803b1580156107fc57600080fd5b505afa158015610810573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083491906125df565b6108505760405162461bcd60e51b8152600401610425906126a7565b8361088b5760405162461bcd60e51b815260206004820152600b60248201526a1e995c9bc8185b5bdd5b9d60aa1b6044820152606401610425565b60006108956112c1565b6001600160a01b0316630a029fd76040518163ffffffff1660e01b815260040160206040518083038186803b1580156108cd57600080fd5b505afa1580156108e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061090591906125ff565b905060006109116112c1565b6001600160a01b031663a18778246040518163ffffffff1660e01b815260040160206040518083038186803b15801561094957600080fd5b505afa15801561095d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098191906125ff565b905060006109998261099389866119d1565b906119dd565b905060006109a78883611667565b9050600082156109c8576109c56109be8985610a7c565b82906119e9565b90505b81156109df576109dc6109be898985610386565b90505b6109e8816119f5565b9998505050505050505050565b60006109ff6112c1565b6001600160a01b03166350adcdb76040518163ffffffff1660e01b815260040160206040518083038186803b15801561034957600080fd5b60016020528260005260406000206020528160005260406000208181548110610a5f57600080fd5b6000918252602090912001546001600160a01b0316925083915050565b6000610a866112c1565b6040516316ed852560e01b81523360048201526001600160a01b0391909116906316ed85259060240160206040518083038186803b158015610ac757600080fd5b505afa158015610adb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aff91906125df565b610b1b5760405162461bcd60e51b8152600401610425906126a7565b6000610b25610307565b6001600160a01b03161415610b735760405162461bcd60e51b815260206004820152601460248201527374617267657420746f6b656e206973207a65726f60601b6044820152606401610425565b6000610b7e836112e6565b9050610b8a84826113f5565b6000610b968483611667565b90506000610ba78683610595610307565b905060008111610be75760405162461bcd60e51b815260206004820152600b60248201526a0dcde40d8d2e240e0c2e8d60ab1b6044820152606401610425565b610c0b610bf2610dda565b82610bfb610307565b6001600160a01b03169190611b13565b6000610c15610dda565b6001600160a01b03166377c7b8fc6040518163ffffffff1660e01b815260040160206040518083038186803b158015610c4d57600080fd5b505afa158015610c61573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8591906125ff565b9050610c8f6112c1565b6001600160a01b03166347b03bba6040518163ffffffff1660e01b815260040160206040518083038186803b158015610cc757600080fd5b505afa158015610cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cff919061242c565b6001600160a01b031663680cbe85610d15610dda565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b158015610d5d57600080fd5b505af1158015610d71573d6000803e3d6000fd5b50505050610d7d610307565b6001600160a01b0316610d8e610dda565b6001600160a01b03167f64d2f4df3d2f7945e236b4c2ed3f3c99b54f00822242d81f27aad65540d0b5ca84604051610dc891815260200190565b60405180910390a35095945050505050565b6000610de46112c1565b6001600160a01b03166395f9b3f56040518163ffffffff1660e01b815260040160206040518083038186803b15801561034957600080fd5b6000610e266112c1565b6001600160a01b0316826001600160a01b0316149050919050565b6001600160a01b038083166000908152600260209081526040808320938516835292905290812054610ea55760405162461bcd60e51b815260206004820152600d60248201526c696e76616c696420726f75746560981b6044820152606401610425565b506001600160a01b03918216600090815260026020908152604080832093909416825291909152205460011090565b6000610ede6112c1565b6001600160a01b031663b60d42886040518163ffffffff1660e01b815260040160206040518083038186803b15801561034957600080fd5b610f1f33610e1c565b80610f2e5750610f2e33611120565b610f725760405162461bcd60e51b81526020600482015260156024820152743737ba1031b7b73a3937b63632b91037b91033b7bb60591b6044820152606401610425565b805160011480610f995750815115801590610f9957508151610f95906001611667565b8151145b610fd25760405162461bcd60e51b815260206004820152600a60248201526977726f6e67206461746160b01b6044820152606401610425565b600082600081518110610ff557634e487b7160e01b600052603260045260246000fd5b602002602001015190506000836001855161101091906127e7565b8151811061102e57634e487b7160e01b600052603260045260246000fd5b60200260200101519050611040610307565b6001600160a01b0316816001600160a01b0316148061107757506110626109f5565b6001600160a01b0316816001600160a01b0316145b6110ae5760405162461bcd60e51b815260206004820152600860248201526777726f6e6720746f60c01b6044820152606401610425565b6001600160a01b038083166000908152600160209081526040808320938516835292815291902085516110e39287019061231e565b506001600160a01b038083166000908152600260209081526040808320938516835292815291902084516111199286019061231e565b5050505050565b6000816001600160a01b03166111346112c1565b6001600160a01b0316635aa6e6756040518163ffffffff1660e01b815260040160206040518083038186803b15801561116c57600080fd5b505afa158015611180573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a4919061242c565b6001600160a01b03161492915050565b60026020528260005260406000206020528160005260406000208181548110610a5f57600080fd5b600054610100900460ff16806111f5575060005460ff16155b6112585760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610425565b600054610100900460ff1615801561127a576000805461ffff19166101011790555b61128382611b43565b6112ab427f6f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8a55565b80156112bd576000805461ff00191690555b5050565b7f5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c36175490565b6000806112f16112c1565b6001600160a01b0316633734d80a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561132957600080fd5b505afa15801561133d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061136191906125ff565b9050600061136d6112c1565b6001600160a01b031663403575d06040518163ffffffff1660e01b815260040160206040518083038186803b1580156113a557600080fd5b505afa1580156113b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113dd91906125ff565b90506113ed8161099386856119d1565b949350505050565b806113fe575050565b60006114086109f5565b6001600160a01b031614156114545760405162461bcd60e51b815260206004820152601260248201527166756e6420746f6b656e206973207a65726f60701b6044820152606401610425565b600061145e610ed4565b6001600160a01b031614156114a45760405162461bcd60e51b815260206004820152600c60248201526b66756e64206973207a65726f60a01b6044820152606401610425565b60006114b383836105956109f5565b9050600081116115055760405162461bcd60e51b815260206004820152601a60248201527f6e6f206c6971207061746820666f722066756e6420746f6b656e0000000000006044820152606401610425565b611519611510610ed4565b82610bfb6109f5565b6115216112c1565b6001600160a01b03166347b03bba6040518163ffffffff1660e01b815260040160206040518083038186803b15801561155957600080fd5b505afa15801561156d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611591919061242c565b6001600160a01b03166380cda1536115a76109f5565b6040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260248101849052604401600060405180830381600087803b1580156115ef57600080fd5b505af1158015611603573d6000803e3d6000fd5b5050505061160f6109f5565b6001600160a01b0316611620610ed4565b6001600160a01b03167f27d513b24e416b55854d5887fdf3b4d7f464269e14ce8438f3d049947034d5938360405161165a91815260200190565b60405180910390a3505050565b600061030082846127e7565b6000816001600160a01b0316846001600160a01b03161415611722576116a46001600160a01b038516333086611bf7565b6040516370a0823160e01b81523060048201526001600160a01b038316906370a082319060240160206040518083038186803b1580156116e357600080fd5b505afa1580156116f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061171b91906125ff565b9050610300565b61172c84836102a5565b1561186b576117466001600160a01b038516333086611bf7565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a082319060240160206040518083038186803b15801561178857600080fd5b505afa15801561179c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c091906125ff565b90506117cc8584610e41565b156117e1576117dc858285611c35565b6117ec565b6117ec858285611f6a565b6040516370a0823160e01b81523060048201526001600160a01b038416906370a082319060240160206040518083038186803b15801561182b57600080fd5b505afa15801561183f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061186391906125ff565b915050610300565b5060009392505050565b8015806118fe5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b1580156118c457600080fd5b505afa1580156118d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118fc91906125ff565b155b6119695760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610425565b6040516001600160a01b0383166024820152604481018290526119cc90849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612049565b505050565b600061030082846127c8565b600061030082846127a8565b60006103008284612790565b600080611a006112c1565b6001600160a01b0316633734d80a6040518163ffffffff1660e01b815260040160206040518083038186803b158015611a3857600080fd5b505afa158015611a4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7091906125ff565b90506000611a7c6112c1565b6001600160a01b031663403575d06040518163ffffffff1660e01b815260040160206040518083038186803b158015611ab457600080fd5b505afa158015611ac8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aec91906125ff565b90506000611afa8284611667565b9050611b0a8261099387846119d1565b95945050505050565b6040516001600160a01b0383166024820152604481018290526119cc90849063a9059cbb60e01b90606401611995565b6001600160a01b038116611b885760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b6044820152606401610425565b7f19b7d592cea0dfda222f6a4ea5c5a8d018ee9c6b1d0a917483a405de94eb26cd611bb16112c1565b604080516001600160a01b03928316815291841660208301520160405180910390a17f5165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c361755565b6040516001600160a01b0380851660248301528316604482015260648101829052611c2f9085906323b872dd60e01b90608401611995565b50505050565b81156119cc576001600160a01b038084166000908152600260209081526040808320938516835292815282822080548451818402810184019095528085529293929091830182828015611cb157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611c93575b5050506001600160a01b038088166000908152600160209081526040808320938916835292815282822080548451818402810184019095528085529697509195929450909250830182828015611d3057602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611d12575b5050505050905060005b8251811015611f62576000838281518110611d6557634e487b7160e01b600052603260045260246000fd5b602002602001015190506000600267ffffffffffffffff811115611d9957634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611dc2578160200160208202803683370190505b509050838381518110611de557634e487b7160e01b600052603260045260246000fd5b602002602001015181600081518110611e0e57634e487b7160e01b600052603260045260246000fd5b6001600160a01b039092166020928302919091019091015283611e32846001612790565b81518110611e5057634e487b7160e01b600052603260045260246000fd5b602002602001015181600181518110611e7957634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050600081600081518110611ebc57634e487b7160e01b600052603260045260246000fd5b60209081029190910101516040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b158015611f0757600080fd5b505afa158015611f1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f3f91906125ff565b9050611f4c83838361211b565b5050508080611f5a9061282a565b915050611d3a565b505050505050565b81156119cc576001600160a01b038084166000908152600260209081526040808320938516835292905290812080548290611fb557634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b03878116845260018352604080852087831686528452938490208054855181860281018601909652808652919092169450611c2f9385939092919083018282801561203e57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612020575b50505050508561211b565b600061209e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166122139092919063ffffffff16565b8051909150156119cc57808060200190518101906120bc91906125df565b6119cc5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610425565b6121628360008460008151811061214257634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b03166118759092919063ffffffff16565b61218883828460008151811061214257634e487b7160e01b600052603260045260246000fd5b6040516338ed173960e01b81526001600160a01b038416906338ed1739906121bd9084906000908790309042906004016126cb565b600060405180830381600087803b1580156121d757600080fd5b505af11580156121eb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611c2f919081019061254c565b60606113ed848460008585843b61226c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610425565b600080866001600160a01b031685876040516122889190612658565b60006040518083038185875af1925050503d80600081146122c5576040519150601f19603f3d011682016040523d82523d6000602084013e6122ca565b606091505b50915091506122da8282866122e5565b979650505050505050565b606083156122f4575081610300565b8251156123045782518084602001fd5b8160405162461bcd60e51b81526004016104259190612674565b828054828255906000526020600020908101928215612373579160200282015b8281111561237357825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019061233e565b5061237f929150612383565b5090565b5b8082111561237f5760008155600101612384565b600082601f8301126123a8578081fd5b813560206123bd6123b88361276c565b61273b565b80838252828201915082860187848660051b89010111156123dc578586fd5b855b858110156124035781356123f181612871565b845292840192908401906001016123de565b5090979650505050505050565b600060208284031215612421578081fd5b813561030081612871565b60006020828403121561243d578081fd5b815161030081612871565b6000806040838503121561245a578081fd5b823561246581612871565b9150602083013561247581612871565b809150509250929050565b600080600060608486031215612494578081fd5b833561249f81612871565b925060208401356124af81612871565b929592945050506040919091013590565b600080604083850312156124d2578182fd5b82356124dd81612871565b946020939093013593505050565b600080604083850312156124fd578182fd5b823567ffffffffffffffff80821115612514578384fd5b61252086838701612398565b93506020850135915080821115612535578283fd5b5061254285828601612398565b9150509250929050565b6000602080838503121561255e578182fd5b825167ffffffffffffffff811115612574578283fd5b8301601f81018513612584578283fd5b80516125926123b88261276c565b80828252848201915084840188868560051b87010111156125b1578687fd5b8694505b838510156125d35780518352600194909401939185019185016125b5565b50979650505050505050565b6000602082840312156125f0578081fd5b81518015158114610300578182fd5b600060208284031215612610578081fd5b5051919050565b60008060006060848603121561262b578283fd5b83359250602084013561263d81612871565b9150604084013561264d81612871565b809150509250925092565b6000825161266a8184602087016127fe565b9190910192915050565b60208152600082518060208401526126938160408501602087016127fe565b601f01601f19169190910160400192915050565b6020808252600a908201526937b7363c903234b9ba3960b11b604082015260600190565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b8181101561271a5784516001600160a01b0316835293830193918301916001016126f5565b50506001600160a01b03969096166060850152505050608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156127645761276461285b565b604052919050565b600067ffffffffffffffff8211156127865761278661285b565b5060051b60200190565b600082198211156127a3576127a3612845565b500190565b6000826127c357634e487b7160e01b81526012600452602481fd5b500490565b60008160001904831182151516156127e2576127e2612845565b500290565b6000828210156127f9576127f9612845565b500390565b60005b83811015612819578181015183820152602001612801565b83811115611c2f5750506000910152565b600060001982141561283e5761283e612845565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461288657600080fd5b5056fea2646970667358221220a7c0f1f353709ee2e64ef66daec7d990dbe1914820755c97e995774773f232d064736f6c634300080400335165972ef41194f06c5007493031d0b927c20741adcb74403b954009fd2c36176f55f470bdc9cb5f04223fd822021061668e4dccb43e8727b295106dc9769c8a0000000000000000000000006678814c273d5088114b6e40cc49c8db04f9bc29

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

0000000000000000000000006678814c273d5088114b6e40cc49c8db04f9bc29

-----Decoded View---------------
Arg [0] : _controller (address): 0x6678814c273d5088114b6e40cc49c8db04f9bc29

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000006678814c273d5088114b6e40cc49c8db04f9bc29


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.