Contract 0x77D89ed6c6279B100B01d1669068D1fDfbE93029

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xaff008d7d012928179af11ddacc218b01eba32c6c99f8b5ab7a6de1cdfec23b9Create Farm Boos...581247382023-03-22 11:58:091 day 8 hrs ago0xc43815bdc7effeb98765ed6574bfb0f8beafef9c IN  0x77d89ed6c6279b100b01d1669068d1fdfbe930290 FTM0.042638068576
0xe2c98cc011536d2f4c761fe6ca56b77e0dc5ece7c8c4c30af6bcac74e3b5b4200x60e06040578667462023-03-18 18:19:445 days 2 hrs ago0xc43815bdc7effeb98765ed6574bfb0f8beafef9c IN  Create: FarmBoosterProxyFactory0 FTM0.244672633753
[ Download CSV Export 
Latest 2 internal transactions
Parent Txn Hash Block From To Value
0xaff008d7d012928179af11ddacc218b01eba32c6c99f8b5ab7a6de1cdfec23b9581247382023-03-22 11:58:091 day 8 hrs ago 0x77d89ed6c6279b100b01d1669068d1fdfbe93029  Contract Creation0 FTM
0xe2c98cc011536d2f4c761fe6ca56b77e0dc5ece7c8c4c30af6bcac74e3b5b420578667462023-03-18 18:19:445 days 2 hrs ago 0xc43815bdc7effeb98765ed6574bfb0f8beafef9c  Contract Creation0 FTM
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FarmBoosterProxyFactory

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity)

/**
 *Submitted for verification at FtmScan.com on 2023-03-18
*/

// SPDX-License-Identifier: MIT
// File: FarmFactory/interfaces/IMasterChef.sol

pragma solidity ^0.8.0;

interface IMasterChef {
    function deposit(
        uint256 _pid,
        uint256 _amount,
        address _referrer
    ) external;

    function withdraw(uint256 _pid, uint256 _amount) external;

    function pendingBar(uint256 _pid, address _user)
        external
        view
        returns (uint256);

    function userInfo(uint256 _pid, address _user)
        external
        view
        returns (
            uint256,
            uint256,
            uint256
        );

    function emergencyWithdraw(uint256 _pid) external;

    function lpToken(uint256 _pid) external view returns (address);

    function poolLength() external view returns (uint256 pools);

    function getBoostMultiplier(address _user, uint256 _pid)
        external
        view
        returns (uint256);

    function updateBoostMultiplier(
        address _user,
        uint256 _pid,
        uint256 _newMultiplier
    ) external;
}
// File: FarmFactory/contracts/security/ReentrancyGuard.sol

// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
// File: FarmFactory/contracts/utils/Address.sol


// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://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);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
// File: FarmFactory/contracts/token/ERC20/extensions/draft-IERC20Permit.sol


// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}
// File: FarmFactory/contracts/token/ERC20/IERC20.sol


// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}
// File: FarmFactory/contracts/token/ERC20/utils/SafeERC20.sol


// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;




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

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

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

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


pragma solidity ^0.8.0;

interface IFarmBooster {
    function onBarPoolUpdate(
        address _user,
        uint256 _lockedAmount,
        uint256 _lockedDuration,
        uint256 _totalLockedAmount,
        uint256 _maxLockDuration
    ) external;

    function updatePoolBoostMultiplier(address _user, uint256 _pid) external;

    function setProxy(address _user, address _proxy) external;

    function isBoosterPool(address _user, uint256 _pid)
        external
        view
        returns (bool);
}
// File: FarmFactory/FarmBoosterProxy.sol


pragma solidity ^0.8.0;





contract FarmBoosterProxy is ReentrancyGuard {
    using SafeERC20 for IERC20;

    // The address of the farm booster proxy factory
    address public immutable FARM_BOOSTER_PROXY_FACTORY;
    IMasterChef public masterchef;
    IERC20 public barToken;
    IFarmBooster public farmBooster;

    address public admin;
    // Whether it is initialized
    bool public isInitialized;
    // Record whether lp was approved
    mapping(address => bool) public lpApproved;

    event DepositByProxy(
        address indexed user,
        address indexed proxy,
        uint256 indexed pid,
        uint256 amount
    );
    event WithdrawByProxy(
        address indexed user,
        address indexed proxy,
        uint256 indexed pid,
        uint256 amount
    );
    event EmergencyWithdrawByProxy(
        address indexed user,
        address indexed proxy,
        uint256 indexed pid
    );

    /**
     * @notice Constructor
     */
    constructor() {
        FARM_BOOSTER_PROXY_FACTORY = msg.sender;
    }

    /**
     * @notice Checks if the msg.sender is the admin address.
     */
    modifier onlyAdmin() {
        require(msg.sender == admin, "admin: wut?");
        _;
    }

    /**
     * @notice It initializes the contract
     * @dev It can only be called once.
     * @param _admin: the admin address
     * @param _farmBooster: the farm booster address
     * @param _masterchef: the address of the Masterchef V2
     * @param _barToken: the address of the bar token
     */
    function initialize(
        address _admin,
        address _farmBooster,
        address _masterchef,
        address _barToken
    ) external {
        require(!isInitialized, "Operations: Already initialized");
        require(
            msg.sender == FARM_BOOSTER_PROXY_FACTORY,
            "Operations: Not factory"
        );

        // Make this contract initialized
        isInitialized = true;
        admin = _admin;
        farmBooster = IFarmBooster(_farmBooster);
        masterchef = IMasterChef(_masterchef);
        barToken = IERC20(_barToken);
    }

    /**
     * @notice Deposit LP tokens to pool.
     * @dev It can only be called by admin.
     * @param _pid The id of the pool.
     * @param _amount Amount of LP tokens to deposit.
     * @param _referrer Referrer.
     */
    function deposit(
        uint256 _pid,
        uint256 _amount,
        address _referrer
    ) external nonReentrant onlyAdmin {
        uint256 poolLength = masterchef.poolLength();
        require(_pid < poolLength, "Pool is not exist");
        address lpAddress = masterchef.lpToken(_pid);
        IERC20(lpAddress).safeTransferFrom(msg.sender, address(this), _amount);
        if (!lpApproved[lpAddress]) {
            IERC20(lpAddress).approve(address(masterchef), type(uint256).max);
            lpApproved[lpAddress] = true;
        }
        masterchef.deposit(_pid, _amount, _referrer);
        harvestBar();
        farmBooster.updatePoolBoostMultiplier(msg.sender, _pid);
        emit DepositByProxy(msg.sender, address(this), _pid, _amount);
    }

    /**
     * @notice Withdraw LP tokens from pool.
     * @dev It can only be called by admin.
     * @param _pid The id of the pool.
     * @param _amount Amount of LP tokens to withdraw.
     */
    function withdraw(uint256 _pid, uint256 _amount)
        external
        nonReentrant
        onlyAdmin
    {
        uint256 poolLength = masterchef.poolLength();
        require(_pid < poolLength, "Pool is not exist");
        masterchef.withdraw(_pid, _amount);
        address lpAddress = masterchef.lpToken(_pid);
        IERC20(lpAddress).safeTransfer(msg.sender, _amount);
        harvestBar();
        farmBooster.updatePoolBoostMultiplier(msg.sender, _pid);
        emit WithdrawByProxy(msg.sender, address(this), _pid, _amount);
    }

    /**
     * @notice Withdraw without caring about the rewards. EMERGENCY ONLY.
     * @dev It can only be called by admin.
     * @param _pid The id of the pool.
     */
    function emergencyWithdraw(uint256 _pid) external nonReentrant onlyAdmin {
        uint256 poolLength = masterchef.poolLength();
        require(_pid < poolLength, "Pool is not exist");
        masterchef.emergencyWithdraw(_pid);
        address lpAddress = masterchef.lpToken(_pid);
        IERC20(lpAddress).safeTransfer(
            msg.sender,
            IERC20(lpAddress).balanceOf(address(this))
        );
        harvestBar();
        farmBooster.updatePoolBoostMultiplier(msg.sender, _pid);
        emit EmergencyWithdrawByProxy(msg.sender, address(this), _pid);
    }

    function harvestBar() internal {
        uint256 barBalance = barToken.balanceOf(address(this));
        if (barBalance > 0) {
            barToken.safeTransfer(msg.sender, barBalance);
        }
    }
}
// File: FarmFactory/FarmBoosterProxyFactory.sol



pragma solidity ^0.8.0;



contract FarmBoosterProxyFactory {
    address public immutable Farm_Booster;
    address public immutable masterchef;
    address public immutable barToken;
    // Record the user proxy contract address
    mapping(address => address) public proxyContract;
    // Record the user address corresponding to the proxy
    mapping(address => address) public proxyUser;
    event NewFarmBoosterProxyContract(address indexed farmBoosterProxyAddress);

    /**
     * @notice Constructor
     * @param _farmBooster: the address of the farm booster
     * @param _masterchef: the address of the Masterchef
     * @param _barToken: the address of the bar token
     */
    constructor(
        address _farmBooster,
        address _masterchef,
        address _barToken
    ) {
        Farm_Booster = _farmBooster;
        masterchef = _masterchef;
        barToken = _barToken;
    }

    /**
     * @notice It creates the farm booster Proxy contract and initializes the contract.
     */
    function createFarmBoosterProxy() external {
        require(
            proxyContract[msg.sender] == address(0),
            "The current user already has a proxy"
        );
        bytes memory bytecode = type(FarmBoosterProxy).creationCode;
        bytes32 salt = keccak256(
            abi.encodePacked(block.timestamp, block.number, msg.sender)
        );
        address farmBoosterProxyAddress;

        assembly {
            farmBoosterProxyAddress := create2(
                0,
                add(bytecode, 32),
                mload(bytecode),
                salt
            )
        }
        require(
            proxyUser[farmBoosterProxyAddress] == address(0),
            "Proxy already exists"
        );

        proxyContract[msg.sender] = farmBoosterProxyAddress;
        proxyUser[farmBoosterProxyAddress] = msg.sender;

        FarmBoosterProxy(farmBoosterProxyAddress).initialize(
            msg.sender,
            Farm_Booster,
            masterchef,
            barToken
        );
        IFarmBooster(Farm_Booster).setProxy(
            msg.sender,
            farmBoosterProxyAddress
        );

        emit NewFarmBoosterProxyContract(farmBoosterProxyAddress);
    }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_farmBooster","type":"address"},{"internalType":"address","name":"_masterchef","type":"address"},{"internalType":"address","name":"_barToken","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"farmBoosterProxyAddress","type":"address"}],"name":"NewFarmBoosterProxyContract","type":"event"},{"inputs":[],"name":"Farm_Booster","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"barToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"createFarmBoosterProxy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"masterchef","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"proxyContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"proxyUser","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

60e060405234801561001057600080fd5b5060405161185838038061185883398101604081905261002f91610072565b6001600160601b0319606093841b811660805291831b821660a05290911b1660c0526100b4565b80516001600160a01b038116811461006d57600080fd5b919050565b600080600060608486031215610086578283fd5b61008f84610056565b925061009d60208501610056565b91506100ab60408501610056565b90509250925092565b60805160601c60a05160601c60c05160601c6117526101066000396000818160bb015261034f015260008181610132015261032701526000818160e2015281816102ff01526103d301526117526000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c806311a5f6bb14610067578063803f18dc14610071578063c05e50df146100b6578063d5f3e96b146100dd578063f9d2543714610104578063fb1db2781461012d575b600080fd5b61006f610154565b005b61009a61007f366004610477565b6000602081905290815260409020546001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b61009a7f000000000000000000000000000000000000000000000000000000000000000081565b61009a7f000000000000000000000000000000000000000000000000000000000000000081565b61009a610112366004610477565b6001602052600090815260409020546001600160a01b031681565b61009a7f000000000000000000000000000000000000000000000000000000000000000081565b336000908152602081905260409020546001600160a01b0316156101cb5760405162461bcd60e51b8152602060048201526024808201527f5468652063757272656e74207573657220616c72656164792068617320612070604482015263726f787960e01b60648201526084015b60405180910390fd5b6000604051806020016101dd9061046a565b818103601f199081018352601f909101166040818152426020830152439082015233606090811b6bffffffffffffffffffffffff1916908201529091506000906074016040516020818303038152906040528051906020012090506000818351602085016000f56001600160a01b0380821660009081526001602052604090205491925016156102a65760405162461bcd60e51b815260206004820152601460248201527350726f787920616c72656164792065786973747360601b60448201526064016101c2565b3360008181526020818152604080832080546001600160a01b038781166001600160a01b031992831681179093558286526001909452938290208054909416851790935551637c643b2f60e11b815260048101939093527f0000000000000000000000000000000000000000000000000000000000000000811660248401527f0000000000000000000000000000000000000000000000000000000000000000811660448401527f00000000000000000000000000000000000000000000000000000000000000001660648301529063f8c8765e90608401600060405180830381600087803b15801561039857600080fd5b505af11580156103ac573d6000803e3d6000fd5b5050604051632a7518c360e21b81523360048201526001600160a01b0384811660248301527f000000000000000000000000000000000000000000000000000000000000000016925063a9d4630c9150604401600060405180830381600087803b15801561041957600080fd5b505af115801561042d573d6000803e3d6000fd5b50506040516001600160a01b03841692507ff85bdc0fe80e0f017a407160865fb16be386816f96c7d7fb8a034105abb7c8e59150600090a2505050565b611277806104a683390190565b600060208284031215610488578081fd5b81356001600160a01b038116811461049e578182fd5b939250505056fe60a060405234801561001057600080fd5b5060016000553360601b60805260805160601c6112356100426000396000818161011c0152610b4c01526112356000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c80638dbdbe6d116100715780638dbdbe6d14610151578063c05e50df14610164578063f851a44014610177578063f8c8765e1461018a578063fb1db2781461019d578063fbcdbd0e146101b057600080fd5b80630643aae1146100ae578063392e53cd146100de578063441a3e701461010257806351035703146101175780635312ea8e1461013e575b600080fd5b6003546100c1906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6004546100f290600160a01b900460ff1681565b60405190151581526020016100d5565b61011561011036600461108f565b6101d3565b005b6100c17f000000000000000000000000000000000000000000000000000000000000000081565b61011561014c36600461105f565b610476565b61011561015f3660046110b0565b610779565b6002546100c1906001600160a01b031681565b6004546100c1906001600160a01b031681565b610115610198366004610fe4565b610ae7565b6001546100c1906001600160a01b031681565b6100f26101be366004610fac565b60056020526000908152604090205460ff1681565b600260005414156101ff5760405162461bcd60e51b81526004016101f690611187565b60405180910390fd5b60026000556004546001600160a01b0316331461022e5760405162461bcd60e51b81526004016101f690611137565b6001546040805163040f1f6d60e11b815290516000926001600160a01b03169163081e3eda916004808301926020929190829003018186803b15801561027357600080fd5b505afa158015610287573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ab9190611077565b90508083106102cc5760405162461bcd60e51b81526004016101f69061115c565b600154604051630441a3e760e41b815260048101859052602481018490526001600160a01b039091169063441a3e7090604401600060405180830381600087803b15801561031957600080fd5b505af115801561032d573d6000803e3d6000fd5b50506001546040516378ed5d1f60e01b815260048101879052600093506001600160a01b0390911691506378ed5d1f9060240160206040518083038186803b15801561037857600080fd5b505afa15801561038c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103b09190610fc8565b90506103c66001600160a01b0382163385610c13565b6103ce610c7b565b600354604051630bd6db7760e11b8152336004820152602481018690526001600160a01b03909116906317adb6ee90604401600060405180830381600087803b15801561041a57600080fd5b505af115801561042e573d6000803e3d6000fd5b505060405185815286925030915033907fa8c1f92a8228d8f30d30e0539f7256c2847eaf35775bdc0a5a9c0a5a066f31d39060200160405180910390a4505060016000555050565b600260005414156104995760405162461bcd60e51b81526004016101f690611187565b60026000556004546001600160a01b031633146104c85760405162461bcd60e51b81526004016101f690611137565b6001546040805163040f1f6d60e11b815290516000926001600160a01b03169163081e3eda916004808301926020929190829003018186803b15801561050d57600080fd5b505afa158015610521573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105459190611077565b90508082106105665760405162461bcd60e51b81526004016101f69061115c565b600154604051632989754760e11b8152600481018490526001600160a01b0390911690635312ea8e90602401600060405180830381600087803b1580156105ac57600080fd5b505af11580156105c0573d6000803e3d6000fd5b50506001546040516378ed5d1f60e01b815260048101869052600093506001600160a01b0390911691506378ed5d1f9060240160206040518083038186803b15801561060b57600080fd5b505afa15801561061f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106439190610fc8565b6040516370a0823160e01b81523060048201529091506106d49033906001600160a01b038416906370a082319060240160206040518083038186803b15801561068b57600080fd5b505afa15801561069f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c39190611077565b6001600160a01b0384169190610c13565b6106dc610c7b565b600354604051630bd6db7760e11b8152336004820152602481018590526001600160a01b03909116906317adb6ee90604401600060405180830381600087803b15801561072857600080fd5b505af115801561073c573d6000803e3d6000fd5b505060405185925030915033907f238154946c0c149f8f44d71bfa79cf891af27a2567d540447b44c7c532529e3290600090a45050600160005550565b6002600054141561079c5760405162461bcd60e51b81526004016101f690611187565b60026000556004546001600160a01b031633146107cb5760405162461bcd60e51b81526004016101f690611137565b6001546040805163040f1f6d60e11b815290516000926001600160a01b03169163081e3eda916004808301926020929190829003018186803b15801561081057600080fd5b505afa158015610824573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108489190611077565b90508084106108695760405162461bcd60e51b81526004016101f69061115c565b6001546040516378ed5d1f60e01b8152600481018690526000916001600160a01b0316906378ed5d1f9060240160206040518083038186803b1580156108ae57600080fd5b505afa1580156108c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108e69190610fc8565b90506108fd6001600160a01b038216333087610d19565b6001600160a01b03811660009081526005602052604090205460ff166109c95760015460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529082169063095ea7b390604401602060405180830381600087803b15801561096c57600080fd5b505af1158015610980573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a4919061103f565b506001600160a01b0381166000908152600560205260409020805460ff191660011790555b600154604051638dbdbe6d60e01b815260048101879052602481018690526001600160a01b03858116604483015290911690638dbdbe6d90606401600060405180830381600087803b158015610a1e57600080fd5b505af1158015610a32573d6000803e3d6000fd5b50505050610a3e610c7b565b600354604051630bd6db7760e11b8152336004820152602481018790526001600160a01b03909116906317adb6ee90604401600060405180830381600087803b158015610a8a57600080fd5b505af1158015610a9e573d6000803e3d6000fd5b505060405186815287925030915033907f138d30356a982952b65b72a90f5ee823874132ec8dd8b2fa5c42499228670fa69060200160405180910390a450506001600055505050565b600454600160a01b900460ff1615610b415760405162461bcd60e51b815260206004820152601f60248201527f4f7065726174696f6e733a20416c726561647920696e697469616c697a65640060448201526064016101f6565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610bb95760405162461bcd60e51b815260206004820152601760248201527f4f7065726174696f6e733a204e6f7420666163746f727900000000000000000060448201526064016101f6565b600480546001600160a01b039586166001600160a81b031990911617600160a01b179055600380549385166001600160a01b0319948516179055600180549285169284169290921790915560028054919093169116179055565b6040516001600160a01b038316602482015260448101829052610c7690849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610d57565b505050565b6002546040516370a0823160e01b81523060048201526000916001600160a01b0316906370a082319060240160206040518083038186803b158015610cbf57600080fd5b505afa158015610cd3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cf79190611077565b90508015610d1657600254610d16906001600160a01b03163383610c13565b50565b6040516001600160a01b0380851660248301528316604482015260648101829052610d519085906323b872dd60e01b90608401610c3f565b50505050565b6000610dac826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610e299092919063ffffffff16565b805190915015610c765780806020019051810190610dca919061103f565b610c765760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016101f6565b6060610e388484600085610e42565b90505b9392505050565b606082471015610ea35760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016101f6565b6001600160a01b0385163b610efa5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016101f6565b600080866001600160a01b03168587604051610f1691906110e8565b60006040518083038185875af1925050503d8060008114610f53576040519150601f19603f3d011682016040523d82523d6000602084013e610f58565b606091505b5091509150610f68828286610f73565b979650505050505050565b60608315610f82575081610e3b565b825115610f925782518084602001fd5b8160405162461bcd60e51b81526004016101f69190611104565b600060208284031215610fbd578081fd5b8135610e3b816111ea565b600060208284031215610fd9578081fd5b8151610e3b816111ea565b60008060008060808587031215610ff9578283fd5b8435611004816111ea565b93506020850135611014816111ea565b92506040850135611024816111ea565b91506060850135611034816111ea565b939692955090935050565b600060208284031215611050578081fd5b81518015158114610e3b578182fd5b600060208284031215611070578081fd5b5035919050565b600060208284031215611088578081fd5b5051919050565b600080604083850312156110a1578182fd5b50508035926020909101359150565b6000806000606084860312156110c4578283fd5b833592506020840135915060408401356110dd816111ea565b809150509250925092565b600082516110fa8184602087016111be565b9190910192915050565b60208152600082518060208401526111238160408501602087016111be565b601f01601f19169190910160400192915050565b6020808252600b908201526a61646d696e3a207775743f60a81b604082015260600190565b602080825260119082015270141bdbdb081a5cc81b9bdd08195e1a5cdd607a1b604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60005b838110156111d95781810151838201526020016111c1565b83811115610d515750506000910152565b6001600160a01b0381168114610d1657600080fdfea264697066735822122059616aa5a1d68bc6beb0dcdee16c494fee11cd9fb03365b53e887cb682c50ae364736f6c63430008040033a2646970667358221220b26f37f9df3209f14ffe2e857f27e9de331d7535e834f8067d8234f5bea02eb664736f6c634300080400330000000000000000000000003cd1ced5583d8a0fd411d728f461386ef2a2cb5b00000000000000000000000053948b7d375739e746a17c35d5883d51c649603c0000000000000000000000006adea0efc8df952ac683680d860a1f4db69a9425

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

0000000000000000000000003cd1ced5583d8a0fd411d728f461386ef2a2cb5b00000000000000000000000053948b7d375739e746a17c35d5883d51c649603c0000000000000000000000006adea0efc8df952ac683680d860a1f4db69a9425

-----Decoded View---------------
Arg [0] : _farmBooster (address): 0x3cd1ced5583d8a0fd411d728f461386ef2a2cb5b
Arg [1] : _masterchef (address): 0x53948b7d375739e746a17c35d5883d51c649603c
Arg [2] : _barToken (address): 0x6adea0efc8df952ac683680d860a1f4db69a9425

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000003cd1ced5583d8a0fd411d728f461386ef2a2cb5b
Arg [1] : 00000000000000000000000053948b7d375739e746a17c35d5883d51c649603c
Arg [2] : 0000000000000000000000006adea0efc8df952ac683680d860a1f4db69a9425


Deployed ByteCode Sourcemap

27798:2264:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;28814:1245;;;:::i;:::-;;28011:48;;;;;;:::i;:::-;;;;;;;;;;;;;-1:-1:-1;;;;;28011:48:0;;;;;;-1:-1:-1;;;;;853:32:1;;;835:51;;823:2;808:18;28011:48:0;;;;;;;27924:33;;;;;27838:37;;;;;28125:44;;;;;;:::i;:::-;;;;;;;;;;;;-1:-1:-1;;;;;28125:44:0;;;27882:35;;;;;28814:1245;28904:10;28927:1;28890:25;;;;;;;;;;;-1:-1:-1;;;;;28890:25:0;:39;28868:125;;;;-1:-1:-1;;;28868:125:0;;1878:2:1;28868:125:0;;;1860:21:1;1917:2;1897:18;;;1890:30;1956:34;1936:18;;;1929:62;-1:-1:-1;;;2007:18:1;;;2000:34;2051:19;;28868:125:0;;;;;;;;;29004:21;29028:35;;;;;;;;:::i;:::-;;;;-1:-1:-1;;29028:35:0;;;;;;;;;;;;;;29130:15;29028:35;29113:59;;510:19:1;29147:12:0;545::1;;;538:28;29161:10:0;604:2:1;600:15;;;-1:-1:-1;;596:53:1;582:12;;;575:75;29028:35:0;;-1:-1:-1;;;666:12:1;;29113:59:0;;;;;;;;;;;;29089:94;;;;;;29074:109;;29194:31;29405:4;29377:8;29371:15;29349:2;29339:8;29335:17;29315:1;29289:135;-1:-1:-1;;;;;29467:34:0;;;29513:1;29467:34;;;:9;:34;;;;;;29262:162;;-1:-1:-1;29467:34:0;:48;29445:118;;;;-1:-1:-1;;;29445:118:0;;2283:2:1;29445:118:0;;;2265:21:1;2322:2;2302:18;;;2295:30;-1:-1:-1;;;2341:18:1;;;2334:50;2401:18;;29445:118:0;2255:170:1;29445:118:0;29590:10;29576:13;:25;;;;;;;;;;;:51;;-1:-1:-1;;;;;29576:51:0;;;-1:-1:-1;;;;;;29576:51:0;;;;;;;;29638:34;;;-1:-1:-1;29638:34:0;;;;;;;:47;;;;;;;;;;29698:163;-1:-1:-1;;;29698:163:0;;;;;1475:34:1;;;;29790:12:0;1545:15:1;;1525:18;;;1518:43;29817:10:0;1597:15:1;;1577:18;;;1570:43;29842:8:0;1649:15:1;1629:18;;;1622:43;29576:51:0;29698:52;;1409:19:1;;29698:163:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;29872:109:0;;-1:-1:-1;;;29872:109:0;;29922:10;29872:109;;;1109:34:1;-1:-1:-1;;;;;1179:15:1;;;1159:18;;;1152:43;29885:12:0;29872:35;;-1:-1:-1;29872:35:0;;-1:-1:-1;1044:18:1;;29872:109:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;29999:52:0;;-1:-1:-1;;;;;29999:52:0;;;-1:-1:-1;29999:52:0;;-1:-1:-1;29999:52:0;;;28814:1245;;;:::o;-1:-1:-1:-;;;;;;;;:::o;14:306:1:-;73:6;126:2;114:9;105:7;101:23;97:32;94:2;;;147:6;139;132:22;94:2;178:23;;-1:-1:-1;;;;;230:31:1;;220:42;;210:2;;281:6;273;266:22;210:2;309:5;84:236;-1:-1:-1;;;84:236:1:o

Swarm Source

ipfs://b26f37f9df3209f14ffe2e857f27e9de331d7535e834f8067d8234f5bea02eb6
Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Validator ID :
0 FTM

Amount Staked
0

Amount Delegated
0

Staking Total
0

Staking Start Epoch
0

Staking Start Time
0

Proof of Importance
0

Origination Score
0

Validation Score
0

Active
0

Online
0

Downtime
0 s
Address Amount claimed Rewards Created On Epoch Created On
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.