ETH Price: $3,080.95 (-7.67%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Mass Harvest140228972022-01-17 11:58:211106 days ago1642420701IN
0xD05AbB72...c0912d850
0 ETH0.0096030770.59783651
Mass Harvest140228852022-01-17 11:56:091106 days ago1642420569IN
0xD05AbB72...c0912d850
0 ETH0.0153375880.30863585
Mass Harvest139973702022-01-13 13:17:061110 days ago1642079826IN
0xD05AbB72...c0912d850
0 ETH0.01455467107
Mass Harvest139916522022-01-12 16:01:461111 days ago1642003306IN
0xD05AbB72...c0912d850
0 ETH0.03806916174.11645062
Mass Harvest139514092022-01-06 10:52:081117 days ago1641466328IN
0xD05AbB72...c0912d850
0 ETH0.0161287171.645912
Mass Harvest139505462022-01-06 7:32:191117 days ago1641454339IN
0xD05AbB72...c0912d850
0 ETH0.01476581104
Mass Harvest139503812022-01-06 6:54:231117 days ago1641452063IN
0xD05AbB72...c0912d850
0 ETH0.0197799893
Mass Harvest139122012021-12-31 8:54:271123 days ago1640940867IN
0xD05AbB72...c0912d850
0 ETH0.0098389372.33180246
Mass Harvest139062072021-12-30 10:44:441124 days ago1640861084IN
0xD05AbB72...c0912d850
0 ETH0.0106251574.83608588
Mass Harvest139011872021-12-29 16:00:461125 days ago1640793646IN
0xD05AbB72...c0912d850
0 ETH0.03023228138.2730088
Mass Harvest138603052021-12-23 8:25:381131 days ago1640247938IN
0xD05AbB72...c0912d850
0 ETH0.007073352
Mass Harvest138599002021-12-23 6:49:371131 days ago1640242177IN
0xD05AbB72...c0912d850
0 ETH0.0082048168.99146861
Mass Harvest138559582021-12-22 16:01:361132 days ago1640188896IN
0xD05AbB72...c0912d850
0 ETH0.02265983106.54026288
Mass Harvest138154302021-12-16 9:31:471138 days ago1639647107IN
0xD05AbB72...c0912d850
0 ETH0.0079261966.64865663
Mass Harvest138108372021-12-15 16:36:341139 days ago1639586194IN
0xD05AbB72...c0912d850
0 ETH0.0090703665.09003609
Mass Harvest138106742021-12-15 16:00:371139 days ago1639584037IN
0xD05AbB72...c0912d850
0 ETH0.03588493166.12319272
Mass Harvest137770852021-12-10 11:20:301144 days ago1639135230IN
0xD05AbB72...c0912d850
0 ETH0.0066143843
Mass Harvest137659852021-12-08 17:01:431146 days ago1638982903IN
0xD05AbB72...c0912d850
0 ETH0.0109704671.64386163
Mass Harvest137657882021-12-08 16:16:411146 days ago1638980201IN
0xD05AbB72...c0912d850
0 ETH0.0092317467.86802259
Mass Harvest137657072021-12-08 16:00:291146 days ago1638979229IN
0xD05AbB72...c0912d850
0 ETH0.0229494592.69287464

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

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

Contract Name:
YieldFarm

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 2 runs

Other Settings:
default evmVersion, Apache-2.0 license
File 1 of 8 : YieldFarm.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./interfaces/IStaking.sol";

contract YieldFarm {
    using SafeERC20 for IERC20;

    struct TokenDetails {
        address addr;
        uint8 decimals;
    }

    TokenDetails[] public poolTokens;
    uint8 maxDecimals;

    IERC20 public rewardToken;

    address public communityVault;
    IStaking public staking;

    uint256 public totalDistributedAmount;
    uint256 public numberOfEpochs;
    uint128 public epochsDelayedFromStakingContract;

    uint256 public _totalAmountPerEpoch;
    uint128 public lastInitializedEpoch;

    uint256[] public epochPoolSizeCache;
    mapping(address => uint128) public lastEpochIdHarvested;

    uint256 public epochDuration; // init from staking contract
    uint256 public epochStart; // init from staking contract

    // events
    event MassHarvest(address indexed user, uint256 epochsHarvested, uint256 totalValue);
    event Harvest(address indexed user, uint128 indexed epochId, uint256 amount);

    // constructor
    constructor(
        address[] memory poolTokenAddresses,
        address rewardTokenAddress,
        address stakingAddress,
        address communityVaultAddress,
        uint256 distributedAmount,
        uint256 noOfEpochs,
        uint128 epochsDelayed
    ) {
        for (uint256 i = 0; i < poolTokenAddresses.length; i++) {
            address addr = poolTokenAddresses[i];
            require(addr != address(0), "invalid pool token address");

            uint8 decimals = IERC20Metadata(addr).decimals();
            poolTokens.push(TokenDetails(addr, decimals));

            if (maxDecimals < decimals) {
                maxDecimals = decimals;
            }
        }

        rewardToken = IERC20(rewardTokenAddress);

        staking = IStaking(stakingAddress);
        communityVault = communityVaultAddress;

        totalDistributedAmount = distributedAmount;
        numberOfEpochs = noOfEpochs;
        epochPoolSizeCache = new uint256[](numberOfEpochs + 1);
        epochsDelayedFromStakingContract = epochsDelayed;

        epochDuration = staking.epochDuration();
        epochStart = staking.epoch1Start() + epochDuration * epochsDelayedFromStakingContract;

        _totalAmountPerEpoch = totalDistributedAmount / numberOfEpochs;
    }

    // public methods
    // public method to harvest all the unharvested epochs until current epoch - 1
    function massHarvest() external returns (uint256){
        uint256 totalUserReward;
        uint256 epochId = _getEpochId() - 1; // fails in epoch 0

        // force max number of epochs
        if (epochId > numberOfEpochs) {
            epochId = numberOfEpochs;
        }

        uint128 userLastEpochHarvested = lastEpochIdHarvested[msg.sender];

        for (uint128 i = userLastEpochHarvested + 1; i <= epochId; i++) {
            // i = epochId
            // compute distributed Value and do one single transfer at the end
            totalUserReward += _harvest(i);
        }

        emit MassHarvest(msg.sender, epochId - userLastEpochHarvested, totalUserReward);

        if (totalUserReward > 0) {
            rewardToken.safeTransferFrom(communityVault, msg.sender, totalUserReward);
        }

        return totalUserReward;
    }

    function harvest(uint128 epochId) external returns (uint256){
        // checks for requested epoch
        require(_getEpochId() > epochId, "This epoch is in the future");
        require(epochId <= numberOfEpochs, "Maximum number of epochs is 25");
        require(lastEpochIdHarvested[msg.sender] + 1 == epochId, "Harvest in order");

        uint256 userReward = _harvest(epochId);
        if (userReward > 0) {
            rewardToken.safeTransferFrom(communityVault, msg.sender, userReward);
        }

        emit Harvest(msg.sender, epochId, userReward);

        return userReward;
    }

    // views
    // calls to the staking smart contract to retrieve the epoch total pool size
    function getPoolSize(uint128 epochId) external view returns (uint256) {
        return _getPoolSize(epochId);
    }

    function getPoolSizeByToken(address token, uint128 epochId) external view returns (uint256) {
        uint128 stakingEpochId = _stakingEpochId(epochId);

        return staking.getEpochPoolSize(token, stakingEpochId);
    }

    function getCurrentEpoch() external view returns (uint256) {
        return _getEpochId();
    }

    // calls to the staking smart contract to retrieve user balance for an epoch
    function getEpochStake(address userAddress, uint128 epochId) external view returns (uint256) {
        return _getUserBalancePerEpoch(userAddress, epochId);
    }

    function getEpochStakeByToken(address userAddress, address token, uint128 epochId) external view returns (uint256) {
        uint128 stakingEpochId = _stakingEpochId(epochId);

        return staking.getEpochUserBalance(userAddress, token, stakingEpochId);
    }

    function userLastEpochIdHarvested() external view returns (uint256){
        return lastEpochIdHarvested[msg.sender];
    }

    function getPoolTokens() external view returns (address[] memory tokens) {
        tokens = new address[](poolTokens.length);

        for (uint256 i = 0; i < poolTokens.length; i++) {
            tokens[i] = poolTokens[i].addr;
        }
    }

    // internal methods

    function _initEpoch(uint128 epochId) internal {
        require(lastInitializedEpoch + 1 == epochId, "Epoch can be init only in order");

        lastInitializedEpoch = epochId;
        // call the staking smart contract to init the epoch
        epochPoolSizeCache[epochId] = _getPoolSize(epochId);
    }

    function _harvest(uint128 epochId) internal returns (uint256) {
        // try to initialize an epoch. if it can't it fails
        // if it fails either user either a BarnBridge account will init not init epochs
        if (lastInitializedEpoch < epochId) {
            _initEpoch(epochId);
        }
        // Set user last harvested epoch
        lastEpochIdHarvested[msg.sender] = epochId;
        // compute and return user total reward. For optimization reasons the transfer have been moved to an upper layer (i.e. massHarvest needs to do a single transfer)

        // exit if there is no stake on the epoch
        if (epochPoolSizeCache[epochId] == 0) {
            return 0;
        }

        return _totalAmountPerEpoch * _getUserBalancePerEpoch(msg.sender, epochId) / epochPoolSizeCache[epochId];
    }

    function _getPoolSize(uint128 epochId) internal view returns (uint256) {
        uint128 stakingEpochId = _stakingEpochId(epochId);

        uint256 totalPoolSize;

        for (uint256 i = 0; i < poolTokens.length; i++) {
            totalPoolSize = totalPoolSize + staking.getEpochPoolSize(poolTokens[i].addr, stakingEpochId) * 10 ** (maxDecimals - poolTokens[i].decimals);
        }

        return totalPoolSize;
    }


    function _getUserBalancePerEpoch(address userAddress, uint128 epochId) internal view returns (uint256){
        uint128 stakingEpochId = _stakingEpochId(epochId);

        uint256 totalUserBalance;

        for (uint256 i = 0; i < poolTokens.length; i++) {
            totalUserBalance = totalUserBalance + staking.getEpochUserBalance(userAddress, poolTokens[i].addr, stakingEpochId) * 10 ** (maxDecimals - poolTokens[i].decimals);
        }

        return totalUserBalance;
    }

    // compute epoch id from block.timestamp and epochStart date
    function _getEpochId() internal view returns (uint128) {
        if (block.timestamp < epochStart) {
            return 0;
        }

        return uint128(
            (block.timestamp - epochStart) / epochDuration + 1
        );
    }

    // get the staking epoch
    function _stakingEpochId(uint128 epochId) internal view returns (uint128) {
        return epochId + epochsDelayedFromStakingContract;
    }
}

File 2 of 8 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _setOwner(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _setOwner(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 3 of 8 : 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 8 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";

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

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

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

File 5 of 8 : 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 6 of 8 : 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);
    }

    /**
     * @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

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

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

pragma solidity ^0.8.0;

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

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

File 8 of 8 : IStaking.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.10;

import "@openzeppelin/contracts/access/Ownable.sol";

interface IStaking {
    function getEpochId(uint256 timestamp) external view returns (uint256); // get epoch id
    function getEpochUserBalance(address user, address token, uint128 epoch) external view returns(uint256);
    function getEpochPoolSize(address token, uint128 epoch) external view returns (uint256);
    function epoch1Start() external view returns (uint256);
    function epochDuration() external view returns (uint256);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address[]","name":"poolTokenAddresses","type":"address[]"},{"internalType":"address","name":"rewardTokenAddress","type":"address"},{"internalType":"address","name":"stakingAddress","type":"address"},{"internalType":"address","name":"communityVaultAddress","type":"address"},{"internalType":"uint256","name":"distributedAmount","type":"uint256"},{"internalType":"uint256","name":"noOfEpochs","type":"uint256"},{"internalType":"uint128","name":"epochsDelayed","type":"uint128"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint128","name":"epochId","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Harvest","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"epochsHarvested","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalValue","type":"uint256"}],"name":"MassHarvest","type":"event"},{"inputs":[],"name":"_totalAmountPerEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"communityVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"epochPoolSizeCache","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"epochsDelayedFromStakingContract","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"uint128","name":"epochId","type":"uint128"}],"name":"getEpochStake","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint128","name":"epochId","type":"uint128"}],"name":"getEpochStakeByToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"epochId","type":"uint128"}],"name":"getPoolSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint128","name":"epochId","type":"uint128"}],"name":"getPoolSizeByToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPoolTokens","outputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"epochId","type":"uint128"}],"name":"harvest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastEpochIdHarvested","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastInitializedEpoch","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"massHarvest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"numberOfEpochs","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolTokens","outputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint8","name":"decimals","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"staking","outputs":[{"internalType":"contract IStaking","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDistributedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"userLastEpochIdHarvested","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101125760003560e01c806305441ff1146101175780630ab6ef4f1461014757806315b5a0291461015e57806315e5a1e5146101675780631736884114610170578063290e45441461017957806343312451146101815780634cf088d9146101945780634ff0876a146101bf57806353e97868146101c85780636c60cd9d146101db57806373eff2fd146101ee57806389c06568146102175780639c7ec8811461022c578063a1c130d41461023f578063a43564eb1461025d578063b97dd9e214610270578063ccca953314610278578063dced1a5a1461028b578063e8700c5a146102bf578063f7c618c1146102d2578063f7e251f8146102ea575b600080fd5b60065461012a906001600160801b031681565b6040516001600160801b0390911681526020015b60405180910390f35b61015060075481565b60405190815260200161013e565b61015060045481565b610150600c5481565b61015060055481565b6101506102fd565b61015061018f366004610ee0565b61040d565b6003546101a7906001600160a01b031681565b6040516001600160a01b03909116815260200161013e565b610150600b5481565b6002546101a7906001600160a01b031681565b6101506101e9366004610f13565b610422565b61012a6101fc366004610f56565b600a602052600090815260409020546001600160801b031681565b61021f6104af565b60405161013e9190610f71565b60085461012a906001600160801b031681565b336000908152600a60205260409020546001600160801b0316610150565b61015061026b366004610fbe565b610572565b610150610727565b610150610286366004610ee0565b61073f565b61029e610299366004610fd9565b6107c7565b604080516001600160a01b03909316835260ff90911660208301520161013e565b6101506102cd366004610fd9565b6107fc565b6001546101a79061010090046001600160a01b031681565b6101506102f8366004610fbe565b61081d565b6000806000600161030c610828565b6103169190611008565b6001600160801b0316905060055481111561033057506005545b336000908152600a60205260408120546001600160801b031690610355826001611030565b90505b82816001600160801b03161161038f5761037181610864565b61037b908561105b565b93508061038781611073565b915050610358565b50337fb68dafc1da13dc868096d0b87347c831d0bda92d178317eb1dec7f788444485c6103c56001600160801b0384168561109a565b60408051918252602082018790520160405180910390a2821561040557600254600154610405916001600160a01b03610100909204821691163386610929565b509092915050565b60006104198383610989565b90505b92915050565b60008061042e83610abf565b6003546040516308c028dd60e41b81529192506001600160a01b031690638c028dd090610463908890889086906004016110b1565b602060405180830381865afa158015610480573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104a491906110dd565b9150505b9392505050565b6000546060906001600160401b038111156104cc576104cc6110f6565b6040519080825280602002602001820160405280156104f5578160200160208202803683370190505b50905060005b60005481101561056e57600081815481106105185761051861110c565b60009182526020909120015482516001600160a01b03909116908390839081106105445761054461110c565b6001600160a01b03909216602092830291909101909101528061056681611122565b9150506104fb565b5090565b6000816001600160801b0316610586610828565b6001600160801b0316116105df5760405162461bcd60e51b815260206004820152601b60248201527a546869732065706f636820697320696e207468652066757475726560281b60448201526064015b60405180910390fd5b600554826001600160801b0316111561063a5760405162461bcd60e51b815260206004820152601e60248201527f4d6178696d756d206e756d626572206f662065706f636873206973203235000060448201526064016105d6565b336000908152600a60205260409020546001600160801b038084169161066291166001611030565b6001600160801b0316146106ab5760405162461bcd60e51b815260206004820152601060248201526f2430b93b32b9ba1034b71037b93232b960811b60448201526064016105d6565b60006106b683610864565b905080156106e1576002546001546106e1916001600160a01b03610100909204821691163384610929565b6040518181526001600160801b0384169033907f04ad45a69eeed9c390c3a678fed2d4b90bde98e742de9936d5e0915bf3d0ea4e9060200160405180910390a392915050565b6000610731610828565b6001600160801b0316905090565b60008061074b83610abf565b60035460405163165196bf60e11b81529192506001600160a01b031690632ca32d7e9061077e908790859060040161113d565b602060405180830381865afa15801561079b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107bf91906110dd565b949350505050565b600081815481106107d757600080fd5b6000918252602090912001546001600160a01b0381169150600160a01b900460ff1682565b6009818154811061080c57600080fd5b600091825260209091200154905081565b600061041c82610ad8565b6000600c5442101561083a5750600090565b600b54600c5461084a904261109a565b610854919061115f565b61085f90600161105b565b905090565b6008546000906001600160801b03808416911610156108865761088682610c0b565b336000908152600a6020526040902080546001600160801b0319166001600160801b0384169081179091556009805490919081106108c6576108c661110c565b9060005260206000200154600014156108e157506000919050565b6009826001600160801b0316815481106108fd576108fd61110c565b90600052602060002001546109123384610989565b60075461091f9190611181565b61041c919061115f565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052610983908590610ccb565b50505050565b60008061099583610abf565b90506000805b600054811015610ab657600081815481106109b8576109b861110c565b6000918252602090912001546001546109de9160ff600160a01b909104811691166111a0565b6109e990600a6112a7565b600354600080546001600160a01b0390921691638c028dd0918a9186908110610a1457610a1461110c565b6000918252602090912001546040516001600160e01b031960e085901b168152610a4d92916001600160a01b03169089906004016110b1565b602060405180830381865afa158015610a6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8e91906110dd565b610a989190611181565b610aa2908361105b565b915080610aae81611122565b91505061099b565b50949350505050565b60065460009061041c906001600160801b031683611030565b600080610ae483610abf565b90506000805b600054811015610c035760008181548110610b0757610b0761110c565b600091825260209091200154600154610b2d9160ff600160a01b909104811691166111a0565b610b3890600a6112a7565b600354600080546001600160a01b0390921691632ca32d7e919085908110610b6257610b6261110c565b6000918252602090912001546040516001600160e01b031960e084901b168152610b9a916001600160a01b031690889060040161113d565b602060405180830381865afa158015610bb7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bdb91906110dd565b610be59190611181565b610bef908361105b565b915080610bfb81611122565b915050610aea565b509392505050565b6008546001600160801b0380831691610c2691166001611030565b6001600160801b031614610c7c5760405162461bcd60e51b815260206004820152601f60248201527f45706f63682063616e20626520696e6974206f6e6c7920696e206f726465720060448201526064016105d6565b600880546001600160801b0319166001600160801b038316179055610ca081610ad8565b6009826001600160801b031681548110610cbc57610cbc61110c565b60009182526020909120015550565b6000610d20826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610da29092919063ffffffff16565b805190915015610d9d5780806020019051810190610d3e91906112b6565b610d9d5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105d6565b505050565b60606107bf848460008585843b610dfb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105d6565b600080866001600160a01b03168587604051610e179190611304565b60006040518083038185875af1925050503d8060008114610e54576040519150601f19603f3d011682016040523d82523d6000602084013e610e59565b606091505b5091509150610e69828286610e74565b979650505050505050565b60608315610e835750816104a8565b825115610e935782518084602001fd5b8160405162461bcd60e51b81526004016105d69190611320565b80356001600160a01b0381168114610ec457600080fd5b919050565b80356001600160801b0381168114610ec457600080fd5b60008060408385031215610ef357600080fd5b610efc83610ead565b9150610f0a60208401610ec9565b90509250929050565b600080600060608486031215610f2857600080fd5b610f3184610ead565b9250610f3f60208501610ead565b9150610f4d60408501610ec9565b90509250925092565b600060208284031215610f6857600080fd5b61041982610ead565b6020808252825182820181905260009190848201906040850190845b81811015610fb25783516001600160a01b031683529284019291840191600101610f8d565b50909695505050505050565b600060208284031215610fd057600080fd5b61041982610ec9565b600060208284031215610feb57600080fd5b5035919050565b634e487b7160e01b600052601160045260246000fd5b60006001600160801b038381169083168181101561102857611028610ff2565b039392505050565b60006001600160801b0382811684821680830382111561105257611052610ff2565b01949350505050565b6000821982111561106e5761106e610ff2565b500190565b60006001600160801b038281168082141561109057611090610ff2565b6001019392505050565b6000828210156110ac576110ac610ff2565b500390565b6001600160a01b0393841681529190921660208201526001600160801b03909116604082015260600190565b6000602082840312156110ef57600080fd5b5051919050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b600060001982141561113657611136610ff2565b5060010190565b6001600160a01b039290921682526001600160801b0316602082015260400190565b60008261117c57634e487b7160e01b600052601260045260246000fd5b500490565b600081600019048311821515161561119b5761119b610ff2565b500290565b600060ff821660ff8416808210156111ba576111ba610ff2565b90039392505050565b600181815b808511156111fe5781600019048211156111e4576111e4610ff2565b808516156111f157918102915b93841c93908002906111c8565b509250929050565b6000826112155750600161041c565b816112225750600061041c565b816001811461123857600281146112425761125e565b600191505061041c565b60ff84111561125357611253610ff2565b50506001821b61041c565b5060208310610133831016604e8410600b8410161715611281575081810a61041c565b61128b83836111c3565b806000190482111561129f5761129f610ff2565b029392505050565b600061041960ff841683611206565b6000602082840312156112c857600080fd5b815180151581146104a857600080fd5b60005b838110156112f35781810151838201526020016112db565b838111156109835750506000910152565b600082516113168184602087016112d8565b9190910192915050565b602081526000825180602084015261133f8160408501602087016112d8565b601f01601f1916919091016040019291505056fea2646970667358221220b810b53a410b78998a27989671701fb9c41f7e4551b17714de8359582026d64e64736f6c634300080a0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.