ETH Price: $3,912.77 (-0.54%)

Contract

0x80497049b005Fd236591c3CD431DBD6E06eB1A31
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Withdraw213979362024-12-14 3:01:3531 mins ago1734145295IN
0x80497049...E06eB1A31
0 ETH0.002099559.0428499
Deposit213971422024-12-14 0:22:353 hrs ago1734135755IN
0x80497049...E06eB1A31
0 ETH0.0028329613.36941401
Withdraw213954762024-12-13 18:47:118 hrs ago1734115631IN
0x80497049...E06eB1A31
0 ETH0.0067691529.15500983
Withdraw213943232024-12-13 14:55:1112 hrs ago1734101711IN
0x80497049...E06eB1A31
0 ETH0.004131817.79493693
Withdraw213939772024-12-13 13:45:5913 hrs ago1734097559IN
0x80497049...E06eB1A31
0 ETH0.0037731216.25015891
Withdraw213897262024-12-12 23:31:2328 hrs ago1734046283IN
0x80497049...E06eB1A31
0 ETH0.003526916.39827084
Withdraw213890852024-12-12 21:22:2330 hrs ago1734038543IN
0x80497049...E06eB1A31
0 ETH0.0045067220.95392666
Deposit213887652024-12-12 20:18:2331 hrs ago1734034703IN
0x80497049...E06eB1A31
0 ETH0.0055236126.06426467
Deposit213857472024-12-12 10:11:5941 hrs ago1733998319IN
0x80497049...E06eB1A31
0 ETH0.0045379318.44126684
Deposit213818662024-12-11 21:12:232 days ago1733951543IN
0x80497049...E06eB1A31
0 ETH0.0052001524.56113547
Withdraw213805622024-12-11 16:49:232 days ago1733935763IN
0x80497049...E06eB1A31
0 ETH0.0059566926.19732076
Withdraw213800932024-12-11 15:14:592 days ago1733930099IN
0x80497049...E06eB1A31
0 ETH0.0073619731.70994612
Deposit213785752024-12-11 10:09:352 days ago1733911775IN
0x80497049...E06eB1A31
0 ETH0.0029397913.87278995
Withdraw213781482024-12-11 8:42:232 days ago1733906543IN
0x80497049...E06eB1A31
0 ETH0.0034026614.65465384
Withdraw213775262024-12-11 6:37:352 days ago1733899055IN
0x80497049...E06eB1A31
0 ETH0.0024469810.76117706
Withdraw213775142024-12-11 6:35:112 days ago1733898911IN
0x80497049...E06eB1A31
0 ETH0.0024828411.80678749
Withdraw213767432024-12-11 3:59:592 days ago1733889599IN
0x80497049...E06eB1A31
0 ETH0.0030944413.32788876
Withdraw213746612024-12-10 21:02:233 days ago1733864543IN
0x80497049...E06eB1A31
0 ETH0.0048943722.75628398
Withdraw213745172024-12-10 20:33:353 days ago1733862815IN
0x80497049...E06eB1A31
0 ETH0.0048987422.7765849
Deposit213735642024-12-10 17:22:113 days ago1733851331IN
0x80497049...E06eB1A31
0 ETH0.0098050139.83982704
Deposit213706512024-12-10 7:35:593 days ago1733816159IN
0x80497049...E06eB1A31
0 ETH0.0024519211.5711975
Deposit213705922024-12-10 7:23:593 days ago1733815439IN
0x80497049...E06eB1A31
0 ETH0.0035907914.31172005
Deposit213688612024-12-10 1:35:114 days ago1733794511IN
0x80497049...E06eB1A31
0 ETH0.0039799318.78009999
Withdraw213684852024-12-10 0:19:114 days ago1733789951IN
0x80497049...E06eB1A31
0 ETH0.0062736727.02097733
Withdraw213661522024-12-09 16:30:594 days ago1733761859IN
0x80497049...E06eB1A31
0 ETH0.0100423743.25293116
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block
From
To
213979362024-12-14 3:01:3531 mins ago1734145295
0x80497049...E06eB1A31
0 ETH
213979362024-12-14 3:01:3531 mins ago1734145295
0x80497049...E06eB1A31
0 ETH
213979362024-12-14 3:01:3531 mins ago1734145295
0x80497049...E06eB1A31
0 ETH
213971422024-12-14 0:22:353 hrs ago1734135755
0x80497049...E06eB1A31
0 ETH
213971422024-12-14 0:22:353 hrs ago1734135755
0x80497049...E06eB1A31
0 ETH
213971422024-12-14 0:22:353 hrs ago1734135755
0x80497049...E06eB1A31
0 ETH
213954762024-12-13 18:47:118 hrs ago1734115631
0x80497049...E06eB1A31
0 ETH
213954762024-12-13 18:47:118 hrs ago1734115631
0x80497049...E06eB1A31
0 ETH
213954762024-12-13 18:47:118 hrs ago1734115631
0x80497049...E06eB1A31
0 ETH
213943232024-12-13 14:55:1112 hrs ago1734101711
0x80497049...E06eB1A31
0 ETH
213943232024-12-13 14:55:1112 hrs ago1734101711
0x80497049...E06eB1A31
0 ETH
213943232024-12-13 14:55:1112 hrs ago1734101711
0x80497049...E06eB1A31
0 ETH
213939772024-12-13 13:45:5913 hrs ago1734097559
0x80497049...E06eB1A31
0 ETH
213939772024-12-13 13:45:5913 hrs ago1734097559
0x80497049...E06eB1A31
0 ETH
213939772024-12-13 13:45:5913 hrs ago1734097559
0x80497049...E06eB1A31
0 ETH
213897262024-12-12 23:31:2328 hrs ago1734046283
0x80497049...E06eB1A31
0 ETH
213897262024-12-12 23:31:2328 hrs ago1734046283
0x80497049...E06eB1A31
0 ETH
213897262024-12-12 23:31:2328 hrs ago1734046283
0x80497049...E06eB1A31
0 ETH
213890852024-12-12 21:22:2330 hrs ago1734038543
0x80497049...E06eB1A31
0 ETH
213890852024-12-12 21:22:2330 hrs ago1734038543
0x80497049...E06eB1A31
0 ETH
213890852024-12-12 21:22:2330 hrs ago1734038543
0x80497049...E06eB1A31
0 ETH
213887652024-12-12 20:18:2331 hrs ago1734034703
0x80497049...E06eB1A31
0 ETH
213887652024-12-12 20:18:2331 hrs ago1734034703
0x80497049...E06eB1A31
0 ETH
213887652024-12-12 20:18:2331 hrs ago1734034703
0x80497049...E06eB1A31
0 ETH
213857472024-12-12 10:11:5941 hrs ago1733998319
0x80497049...E06eB1A31
0 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Staking

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 12 : Staking.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.17;

// libraries
import "@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

// interfaces
import "./interfaces/IStaking.sol";

/**
 * @title Staking
 * @notice Implementation of an APY staking pool. Users can deposit SDEX for a share in the pool. New shares depend of
 * current shares supply and SDEX in the pool. Pool will receive SDEX rewards fees by external transfer from admin or
 * contract but also from farming pool. Each deposit/withdraw will harvest the user funds in the farming pool as well.
 */
contract Staking is IStaking, ERC20 {
    using SafeERC20 for IERC20;

    uint256 public constant CAMPAIGN_ID = 0;
    uint256 internal constant SHARES_FACTOR = 1e18;
    uint256 public constant MINIMUM_SHARES = 10 ** 3;

    IERC20 public immutable smardexToken;
    IFarmingRange public immutable farming;

    mapping(address => UserInfo) public userInfo;
    uint256 public totalShares;
    bool public farmingInitialized = false;

    modifier isFarmingInitialized() {
        require(farmingInitialized == true, "Staking::isFarmingInitialized::Farming campaign not initialized");
        _;
    }

    modifier checkUserBlock() {
        require(
            userInfo[msg.sender].lastBlockUpdate < block.number,
            "Staking::checkUserBlock::User already called deposit or withdraw this block"
        );
        userInfo[msg.sender].lastBlockUpdate = block.number;
        _;
    }

    constructor(IERC20 _smardexToken, IFarmingRange _farming) ERC20("Staked SmarDex Token", "stSDEX") {
        require(address(_smardexToken) != address(0), "Staking::constructor::Smardex token is not defined");
        require(address(_farming) != address(0), "Staking::constructor::Farming is not defined");
        smardexToken = _smardexToken;
        farming = _farming;
    }

    /// @inheritdoc IStaking
    function initializeFarming() external {
        require(farmingInitialized == false, "Staking::initializeFarming::Farming campaign already initialized");
        _approve(address(this), address(farming), 1 wei);
        _mint(address(this), 1 wei);
        farming.deposit(CAMPAIGN_ID, 1 wei);

        farmingInitialized = true;
    }

    /// @inheritdoc IStaking
    function deposit(uint256 _depositAmount) public isFarmingInitialized checkUserBlock {
        require(_depositAmount != 0, "Staking::deposit::can't deposit zero token");

        harvestFarming();

        uint256 _currentBalance = smardexToken.balanceOf(address(this));
        uint256 _newShares = _tokensToShares(_depositAmount, _currentBalance);

        uint256 _userNewShares;
        if (totalShares == 0) {
            _userNewShares = _newShares - MINIMUM_SHARES;
        } else {
            _userNewShares = _newShares;
        }
        require(_userNewShares != 0, "Staking::deposit::no new shares received");
        userInfo[msg.sender].shares += _userNewShares;
        totalShares += _newShares;

        smardexToken.safeTransferFrom(msg.sender, address(this), _depositAmount);

        emit Deposit(msg.sender, _depositAmount, _userNewShares);
    }

    /// @inheritdoc IStaking
    function depositWithPermit(
        uint256 _depositAmount,
        bool _approveMax,
        uint256 _deadline,
        uint8 _v,
        bytes32 _r,
        bytes32 _s
    ) external {
        SafeERC20.safePermit(
            IERC20Permit(address(smardexToken)),
            msg.sender,
            address(this),
            _approveMax ? type(uint256).max : _depositAmount,
            _deadline,
            _v,
            _r,
            _s
        );

        deposit(_depositAmount);
    }

    /// @inheritdoc IStaking
    function withdraw(address _to, uint256 _sharesAmount) external isFarmingInitialized checkUserBlock {
        require(
            _sharesAmount != 0 && userInfo[msg.sender].shares >= _sharesAmount,
            "Staking::withdraw::can't withdraw more than user shares or zero"
        );

        harvestFarming();

        uint256 _currentBalance = smardexToken.balanceOf(address(this));
        uint256 _tokensToWithdraw = _sharesToTokens(_sharesAmount, _currentBalance);

        userInfo[msg.sender].shares -= _sharesAmount;
        totalShares -= _sharesAmount;
        smardexToken.safeTransfer(_to, _tokensToWithdraw);

        emit Withdraw(msg.sender, _to, _tokensToWithdraw, _sharesAmount);
    }

    /// @inheritdoc IStaking
    function emergencyWithdraw(address _to) external isFarmingInitialized checkUserBlock {
        require(userInfo[msg.sender].shares != 0, "Staking::emergencyWithdraw::no shares to withdraw");

        uint256 _sharesAmount = userInfo[msg.sender].shares;
        uint256 _currentBalance = smardexToken.balanceOf(address(this));
        uint256 _tokensToWithdraw = _sharesToTokens(_sharesAmount, _currentBalance);

        totalShares -= _sharesAmount;
        userInfo[msg.sender].shares = 0;
        smardexToken.safeTransfer(_to, _tokensToWithdraw);

        emit EmergencyWithdraw(msg.sender, _to, _tokensToWithdraw, _sharesAmount);
    }

    /// @inheritdoc IStaking
    function harvestFarming() public {
        farming.withdraw(CAMPAIGN_ID, 0);
    }

    /// @inheritdoc IStaking
    function tokensToShares(uint256 _tokens) external view returns (uint256 shares_) {
        uint256 _currentBalance = smardexToken.balanceOf(address(this));
        _currentBalance += farming.pendingReward(CAMPAIGN_ID, address(this));

        shares_ = _tokensToShares(_tokens, _currentBalance);
    }

    /// @inheritdoc IStaking
    function sharesToTokens(uint256 _shares) external view returns (uint256 tokens_) {
        uint256 _currentBalance = smardexToken.balanceOf(address(this));
        _currentBalance += farming.pendingReward(CAMPAIGN_ID, address(this));

        tokens_ = _sharesToTokens(_shares, _currentBalance);
    }

    /**
     * @notice Calculate shares qty for an amount of sdex tokens
     * @param _tokens user qty of sdex to be converted to shares
     * @param _currentBalance contract balance sdex. _tokens <= _currentBalance
     * @return shares_ shares equivalent to the token amount. _shares <= totalShares
     */
    function _tokensToShares(uint256 _tokens, uint256 _currentBalance) internal view returns (uint256 shares_) {
        shares_ = totalShares != 0 ? (_tokens * totalShares) / _currentBalance : _tokens * SHARES_FACTOR;
    }

    /**
     * @notice Calculate shares values in sdex tokens
     * @param _shares amount of shares. _shares <= totalShares
     * @param _currentBalance contract balance in sdex
     * @return tokens_ qty of sdex token equivalent to the _shares. tokens_ <= _currentBalance
     */
    function _sharesToTokens(uint256 _shares, uint256 _currentBalance) internal view returns (uint256 tokens_) {
        tokens_ = totalShares != 0 ? (_shares * _currentBalance) / totalShares : _shares / SHARES_FACTOR;
    }
}

File 2 of 12 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/IERC20.sol";

File 3 of 12 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

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

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

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

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

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

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

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

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

        return true;
    }

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

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

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

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

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

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

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

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

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _totalSupply -= amount;
        }

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

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

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

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

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

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

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

File 4 of 12 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

// EIP-2612 is Final as of 2022-11-01. This file is deprecated.

import "./IERC20Permit.sol";

File 5 of 12 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

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 6 of 12 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/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 7 of 12 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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 8 of 12 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    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));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    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");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to
     * 0 before setting it to a non-zero value.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    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");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation 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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

File 9 of 12 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [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://consensys.net/diligence/blog/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.8.0/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 functionCallWithValue(target, data, 0, "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");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, 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) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or 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 {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // 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 10 of 12 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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 11 of 12 : IFarmingRange.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

// interfaces
import "@openzeppelin/contracts/interfaces/IERC20.sol";

interface IFarmingRange {
    /**
     * @notice Info of each user.
     * @param amount How many Staking tokens the user has provided.
     * @param rewardDebt We do some fancy math here. Basically, any point in time, the amount of reward
     *  entitled to a user but is pending to be distributed is:
     *
     *    pending reward = (user.amount * pool.accRewardPerShare) - user.rewardDebt
     *
     *  Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
     *    1. The pool's `accRewardPerShare` (and `lastRewardBlock`) gets updated.
     *    2. User receives the pending reward sent to his/her address.
     *    3. User's `amount` gets updated.
     *    4. User's `rewardDebt` gets updated.
     *
     * from: https://github.com/jazz-defi/contracts/blob/master/MasterChefV2.sol
     */
    struct UserInfo {
        uint256 amount;
        uint256 rewardDebt;
    }

    /**
     * @notice Info of each reward distribution campaign.
     * @param stakingToken address of Staking token contract.
     * @param rewardToken address of Reward token contract
     * @param startBlock start block of the campaign
     * @param lastRewardBlock last block number that Reward Token distribution occurs.
     * @param accRewardPerShare accumulated Reward Token per share, times 1e20.
     * @param totalStaked total staked amount each campaign's stake token, typically,
     * @param totalRewards total amount of reward to be distributed until the end of the last phase
     *
     * @dev each campaign has the same stake token, so no need to track it separetely
     */
    struct CampaignInfo {
        IERC20 stakingToken;
        IERC20 rewardToken;
        uint256 startBlock;
        uint256 lastRewardBlock;
        uint256 accRewardPerShare;
        uint256 totalStaked;
        uint256 totalRewards;
    }

    /**
     * @notice Info about a reward-phase
     * @param endBlock block number of the end of the phase
     * @param rewardPerBlock amount of reward to be distributed per block in this phase
     */
    struct RewardInfo {
        uint256 endBlock;
        uint256 rewardPerBlock;
    }

    /**
     * @notice emitted at each deposit
     * @param user address that deposit its funds
     * @param amount amount deposited
     * @param campaign campaingId on which the user has deposited funds
     */
    event Deposit(address indexed user, uint256 amount, uint256 campaign);

    /**
     * @notice emitted at each withdraw
     * @param user address that withdrawn its funds
     * @param amount amount withdrawn
     * @param campaign campaingId on which the user has withdrawn funds
     */
    event Withdraw(address indexed user, uint256 amount, uint256 campaign);

    /**
     * @notice emitted at each emergency withdraw
     * @param user address that emergency-withdrawn its funds
     * @param amount amount emergency-withdrawn
     * @param campaign campaingId on which the user has emergency-withdrawn funds
     */
    event EmergencyWithdraw(address indexed user, uint256 amount, uint256 campaign);

    /**
     * @notice emitted at each campaign added
     * @param campaignID new campaign id
     * @param stakingToken token address to be staked in this campaign
     * @param rewardToken token address of the rewards in this campaign
     * @param startBlock starting block of this campaign
     */
    event AddCampaignInfo(uint256 indexed campaignID, IERC20 stakingToken, IERC20 rewardToken, uint256 startBlock);

    /**
     * @notice emitted at each phase of reward added
     * @param campaignID campaign id on which rewards were added
     * @param phase number of the new phase added (latest at the moment of add)
     * @param endBlock number of the block that the phase stops (phase starts at the endblock of the previous phase's
     * endblock, and if it's the phase 0, it start at the startBlock of the campaign struct)
     * @param rewardPerBlock amount of reward distributed per block in this phase
     */
    event AddRewardInfo(uint256 indexed campaignID, uint256 indexed phase, uint256 endBlock, uint256 rewardPerBlock);

    /**
     * @notice emitted when a reward phase is updated
     * @param campaignID campaign id on which the rewards-phase is updated
     * @param phase id of phase updated
     * @param endBlock new endblock of the phase
     * @param rewardPerBlock new rewardPerBlock of the phase
     */
    event UpdateRewardInfo(uint256 indexed campaignID, uint256 indexed phase, uint256 endBlock, uint256 rewardPerBlock);

    /**
     * @notice emitted when a reward phase is removed
     * @param campaignID campaign id on which the rewards-phase is removed
     * @param phase id of phase removed (only the latest phase can be removed)
     */
    event RemoveRewardInfo(uint256 indexed campaignID, uint256 indexed phase);

    /**
     * @notice emitted when the rewardInfoLimit is updated
     * @param rewardInfoLimit new max phase amount per campaign
     */
    event SetRewardInfoLimit(uint256 rewardInfoLimit);

    /**
     * @notice set new reward info limit, defining how many phases are allowed
     * @param _updatedRewardInfoLimit new reward info limit
     */
    function setRewardInfoLimit(uint256 _updatedRewardInfoLimit) external;

    /**
     * @notice reward campaign, one campaign represent a pair of staking and reward token,
     * last reward Block and acc reward Per Share
     * @param _stakingToken staking token address
     * @param _rewardToken reward token address
     * @param _startBlock block number when the campaign will start
     */
    function addCampaignInfo(IERC20 _stakingToken, IERC20 _rewardToken, uint256 _startBlock) external;

    /**
     * @notice add a new reward info, when a new reward info is added, the reward
     * & its end block will be extended by the newly pushed reward info.
     * @param _campaignID id of the campaign
     * @param _endBlock end block of this reward info
     * @param _rewardPerBlock reward per block to distribute until the end
     */
    function addRewardInfo(uint256 _campaignID, uint256 _endBlock, uint256 _rewardPerBlock) external;

    /**
     * @notice add multiple reward Info into a campaign in one tx.
     * @param _campaignID id of the campaign
     * @param _endBlock array of end blocks
     * @param _rewardPerBlock array of reward per block
     */
    function addRewardInfoMultiple(
        uint256 _campaignID,
        uint256[] calldata _endBlock,
        uint256[] calldata _rewardPerBlock
    ) external;

    /**
     * @notice update one campaign reward info for a specified range index.
     * @param _campaignID id of the campaign
     * @param _rewardIndex index of the reward info
     * @param _endBlock end block of this reward info
     * @param _rewardPerBlock reward per block to distribute until the end
     */
    function updateRewardInfo(
        uint256 _campaignID,
        uint256 _rewardIndex,
        uint256 _endBlock,
        uint256 _rewardPerBlock
    ) external;

    /**
     * @notice update multiple campaign rewards info for all range index.
     * @param _campaignID id of the campaign
     * @param _rewardIndex array of reward info index
     * @param _endBlock array of end block
     * @param _rewardPerBlock array of rewardPerBlock
     */
    function updateRewardMultiple(
        uint256 _campaignID,
        uint256[] memory _rewardIndex,
        uint256[] memory _endBlock,
        uint256[] memory _rewardPerBlock
    ) external;

    /**
     * @notice update multiple campaigns and rewards info for all range index.
     * @param _campaignID array of campaign id
     * @param _rewardIndex multi dimensional array of reward info index
     * @param _endBlock multi dimensional array of end block
     * @param _rewardPerBlock multi dimensional array of rewardPerBlock
     */
    function updateCampaignsRewards(
        uint256[] calldata _campaignID,
        uint256[][] calldata _rewardIndex,
        uint256[][] calldata _endBlock,
        uint256[][] calldata _rewardPerBlock
    ) external;

    /**
     * @notice remove last reward info for specified campaign.
     * @param _campaignID campaign id
     */
    function removeLastRewardInfo(uint256 _campaignID) external;

    /**
     * @notice return the entries amount of reward info for one campaign.
     * @param _campaignID campaign id
     * @return reward info quantity
     */
    function rewardInfoLen(uint256 _campaignID) external view returns (uint256);

    /**
     * @notice return the number of campaigns.
     * @return campaign quantity
     */
    function campaignInfoLen() external view returns (uint256);

    /**
     * @notice return the end block of the current reward info for a given campaign.
     * @param _campaignID campaign id
     * @return reward info end block number
     */
    function currentEndBlock(uint256 _campaignID) external view returns (uint256);

    /**
     * @notice return the reward per block of the current reward info for a given campaign.
     * @param _campaignID campaign id
     * @return current reward per block
     */
    function currentRewardPerBlock(uint256 _campaignID) external view returns (uint256);

    /**
     * @notice Return reward multiplier over the given _from to _to block.
     * Reward multiplier is the amount of blocks between from and to
     * @param _from start block number
     * @param _to end block number
     * @param _endBlock end block number of the reward info
     * @return block distance
     */
    function getMultiplier(uint256 _from, uint256 _to, uint256 _endBlock) external returns (uint256);

    /**
     * @notice View function to retrieve pending Reward.
     * @param _campaignID pending reward of campaign id
     * @param _user address to retrieve pending reward
     * @return current pending reward
     */
    function pendingReward(uint256 _campaignID, address _user) external view returns (uint256);

    /**
     * @notice Update reward variables of the given campaign to be up-to-date.
     * @param _campaignID campaign id
     */
    function updateCampaign(uint256 _campaignID) external;

    /**
     * @notice Update reward variables for all campaigns. gas spending is HIGH in this method call, BE CAREFUL.
     */
    function massUpdateCampaigns() external;

    /**
     * @notice Deposit staking token in a campaign.
     * @param _campaignID campaign id
     * @param _amount amount to deposit
     */
    function deposit(uint256 _campaignID, uint256 _amount) external;

    /**
     * @notice Deposit staking token in a campaign with the EIP-2612 signature off chain
     * @param _campaignID campaign id
     * @param _amount amount to deposit
     * @param _approveMax Whether or not the approval amount in the signature is for liquidity or uint(-1).
     * @param _deadline Unix timestamp after which the transaction will revert.
     * @param _v The v component of the permit signature.
     * @param _r The r component of the permit signature.
     * @param _s The s component of the permit signature.
     */
    function depositWithPermit(
        uint256 _campaignID,
        uint256 _amount,
        bool _approveMax,
        uint256 _deadline,
        uint8 _v,
        bytes32 _r,
        bytes32 _s
    ) external;

    /**
     * @notice Withdraw staking token in a campaign. Also withdraw the current pending reward
     * @param _campaignID campaign id
     * @param _amount amount to withdraw
     */
    function withdraw(uint256 _campaignID, uint256 _amount) external;

    /**
     * @notice Harvest campaigns, will claim rewards token of every campaign ids in the array
     * @param _campaignIDs array of campaign id
     */
    function harvest(uint256[] calldata _campaignIDs) external;

    /**
     * @notice Withdraw without caring about rewards. EMERGENCY ONLY.
     * @param _campaignID campaign id
     */
    function emergencyWithdraw(uint256 _campaignID) external;

    /**
     * @notice get Reward info for a campaign ID and index, that is a set of {endBlock, rewardPerBlock}
     *  indexed by campaign ID
     * @param _campaignID campaign id
     * @param _rewardIndex index of the reward info
     * @return endBlock_ end block of this reward info
     * @return rewardPerBlock_ reward per block to distribute
     */
    function campaignRewardInfo(
        uint256 _campaignID,
        uint256 _rewardIndex
    ) external view returns (uint256 endBlock_, uint256 rewardPerBlock_);

    /**
     * @notice get a Campaign Reward info for a campaign ID
     * @param _campaignID campaign id
     * @return all params from CampaignInfo struct
     */
    function campaignInfo(
        uint256 _campaignID
    ) external view returns (IERC20, IERC20, uint256, uint256, uint256, uint256, uint256);

    /**
     * @notice get a User Reward info for a campaign ID and user address
     * @param _campaignID campaign id
     * @param _user user address
     * @return all params from UserInfo struct
     */
    function userInfo(uint256 _campaignID, address _user) external view returns (uint256, uint256);

    /**
     * @notice how many reward phases can be set for a campaign
     * @return rewards phases size limit
     */
    function rewardInfoLimit() external view returns (uint256);

    /**
     * @notice get reward Manager address holding rewards to distribute
     * @return address of reward manager
     */
    function rewardManager() external view returns (address);
}

File 12 of 12 : IStaking.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.17;

// interfaces
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./IFarmingRange.sol";

interface IStaking is IERC20 {
    /**
     * @notice info of each user
     * @param shares shares owned in the staking
     * @param lastBlockUpdate last block the user called deposit or withdraw
     */
    struct UserInfo {
        uint256 shares;
        uint256 lastBlockUpdate;
    }

    /**
     * @notice emitted at each deposit
     * @param from address that deposit its funds
     * @param depositAmount amount deposited
     * @param shares shares corresponding to the token amount deposited
     */
    event Deposit(address indexed from, uint256 depositAmount, uint256 shares);

    /**
     * @notice emitted at each withdraw
     * @param from address that calls the withdraw function, and of which the shares are withdrawn
     * @param to address that receives the funds
     * @param tokenReceived amount of token received by to
     * @param shares shares corresponding to the token amount withdrawn
     */
    event Withdraw(address indexed from, address indexed to, uint256 tokenReceived, uint256 shares);

    /**
     * @notice emitted when calling emergencyWithdraw
     * @param from address that calls the withdraw function, and of which the shares are withdrawn
     * @param to address that receives the funds
     * @param tokenReceived amount of token received by to
     * @param shares shares corresponding to the token amount withdrawn
     */
    event EmergencyWithdraw(address indexed from, address indexed to, uint256 tokenReceived, uint256 shares);

    /**
     * @notice Initialize staking connection with farming
     * Mint one token of stSDEX and then deposit in the staking farming pool
     * This contract should be the only participant of the staking farming pool
     */
    function initializeFarming() external;

    /**
     * @notice Send SDEX to get shares in the staking pool
     * @param _depositAmount The amount of SDEX to send
     */
    function deposit(uint256 _depositAmount) external;

    /**
     * @notice Send SDEX to get shares in the staking pool with the EIP-2612 signature off chain
     * @param _depositAmount The amount of SDEX to send
     * @param _approveMax Whether or not the approval amount in the signature is for liquidity or uint(-1).
     * @param _deadline Unix timestamp after which the transaction will revert.
     * @param _v The v component of the permit signature.
     * @param _r The r component of the permit signature.
     * @param _s The s component of the permit signature.
     */
    function depositWithPermit(
        uint256 _depositAmount,
        bool _approveMax,
        uint256 _deadline,
        uint8 _v,
        bytes32 _r,
        bytes32 _s
    ) external;

    /**
     * @notice Harvest and withdraw SDEX for the amount of shares defined
     * @param _to The address who will receive SDEX
     * @param _sharesAmount The amount of shares to use
     */
    function withdraw(address _to, uint256 _sharesAmount) external;

    /**
     * @notice Withdraw SDEX for all shares of the sender, will not harvest before. Only use this function in emergency
     *         WARNING: This function may result in a lower amount of SDEX being withdrawn because it bypasses potential
     *         SDEX earnings from farming.
     *         Only use this function if standard withdrawal does not work for unknown reasons.
     * @param _to The address who will receive SDEX
     */
    function emergencyWithdraw(address _to) external;

    /**
     * @notice Harvest the farming pool for the staking, will increase the SDEX
     */
    function harvestFarming() external;

    /**
     * @notice Calculate shares qty for an amount of sdex tokens
     * @param _tokens user qty of sdex to be converted to shares
     * @return shares_ shares equivalent to the token amount. _shares <= totalShares
     */
    function tokensToShares(uint256 _tokens) external view returns (uint256 shares_);

    /**
     * @notice Calculate shares values in sdex tokens
     * @param _shares amount of shares. _shares <= totalShares
     * @return tokens_ qty of sdex token equivalent to the _shares. tokens_ <= _currentBalance
     */
    function sharesToTokens(uint256 _shares) external view returns (uint256 tokens_);

    /**
     * @notice Campaign id for staking in the farming contract
     * @return ID of the campaign
     */
    function CAMPAIGN_ID() external view returns (uint256);

    /**
     * @notice get farming initialized status
     * @return boolean inititalized or not
     */
    function farmingInitialized() external view returns (bool);

    /**
     * @notice get smardex Token contract address
     * @return smardex contract (address or type for Solidity)
     */
    function smardexToken() external view returns (IERC20);

    /**
     * @notice get farming contract address
     * @return farming contract (address or type for Solidity)
     */
    function farming() external view returns (IFarmingRange);

    /**
     * @notice get user info for staking status
     * @param _user user address
     * @return shares amount for user
     * @return lastBlockUpdate last block the user called deposit or withdraw
     */
    function userInfo(address _user) external view returns (uint256, uint256);

    /**
     * @notice get total shares in the staking
     * @return total shares amount
     */
    function totalShares() external view returns (uint256);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract IERC20","name":"_smardexToken","type":"address"},{"internalType":"contract IFarmingRange","name":"_farming","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"depositAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenReceived","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenReceived","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"CAMPAIGN_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINIMUM_SHARES","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositAmount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_depositAmount","type":"uint256"},{"internalType":"bool","name":"_approveMax","type":"bool"},{"internalType":"uint256","name":"_deadline","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"depositWithPermit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"farming","outputs":[{"internalType":"contract IFarmingRange","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"farmingInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"harvestFarming","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initializeFarming","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"}],"name":"sharesToTokens","outputs":[{"internalType":"uint256","name":"tokens_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"smardexToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokens","type":"uint256"}],"name":"tokensToShares","outputs":[{"internalType":"uint256","name":"shares_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"},{"internalType":"uint256","name":"lastBlockUpdate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_sharesAmount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60c06040526007805460ff191690553480156200001b57600080fd5b5060405162002210380380620022108339810160408190526200003e91620001cb565b6040518060400160405280601481526020017f5374616b656420536d617244657820546f6b656e000000000000000000000000815250604051806040016040528060068152602001650e6e8a6888ab60d31b8152508160039081620000a49190620002af565b506004620000b38282620002af565b5050506001600160a01b0382166200012d5760405162461bcd60e51b815260206004820152603260248201527f5374616b696e673a3a636f6e7374727563746f723a3a536d617264657820746f6044820152711ad95b881a5cc81b9bdd081919599a5b995960721b60648201526084015b60405180910390fd5b6001600160a01b0381166200019a5760405162461bcd60e51b815260206004820152602c60248201527f5374616b696e673a3a636f6e7374727563746f723a3a4661726d696e6720697360448201526b081b9bdd081919599a5b995960a21b606482015260840162000124565b6001600160a01b039182166080521660a0526200037b565b6001600160a01b0381168114620001c857600080fd5b50565b60008060408385031215620001df57600080fd5b8251620001ec81620001b2565b6020840151909250620001ff81620001b2565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200023557607f821691505b6020821081036200025657634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620002aa57600081815260208120601f850160051c81016020861015620002855750805b601f850160051c820191505b81811015620002a65782815560010162000291565b5050505b505050565b81516001600160401b03811115620002cb57620002cb6200020a565b620002e381620002dc845462000220565b846200025c565b602080601f8311600181146200031b5760008415620003025750858301515b600019600386901b1c1916600185901b178555620002a6565b600085815260208120601f198616915b828110156200034c578886015182559484019460019091019084016200032b565b50858210156200036b5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60805160a051611e0d62000403600039600081816102800152818161054e01528181610c4401528181610c9201528181610ddc01526110db0152600081816102bf015281816104c4015281816106050152818161075e0152818161080501528181610a0901528181610b5a01528181610d5201528181610f8301526110540152611e0d6000f3fe608060405234801561001057600080fd5b506004361061018e5760003560e01c80636ff1c9bc116100de578063b6b55f2511610097578063eed06a6311610071578063eed06a6314610397578063f3044ac7146103a4578063f3fef3a3146103b7578063fe2ed8b0146103ca57600080fd5b8063b6b55f2514610369578063c0939f491461037c578063dd62ed3e1461038457600080fd5b80636ff1c9bc146102f657806370a082311461030957806395d89b4114610332578063a1a47d711461033a578063a457c2d714610343578063a9059cbb1461035657600080fd5b806327def4fd1161014b5780633a98ef39116101255780633a98ef39146102725780634e3ad80f1461027b578063670b3a0b146102ba5780636e28ee66146102e157600080fd5b806327def4fd1461023d578063313ce56714610250578063395093511461025f57600080fd5b806306fdde0314610193578063095ea7b3146101b157806318160ddd146101d45780631959a002146101e657806323b872dd1461022257806326c07fd714610235575b600080fd5b61019b6103d2565b6040516101a89190611aa2565b60405180910390f35b6101c46101bf366004611af1565b610464565b60405190151581526020016101a8565b6002545b6040519081526020016101a8565b61020d6101f4366004611b1b565b6005602052600090815260409020805460019091015482565b604080519283526020830191909152016101a8565b6101c4610230366004611b36565b61047e565b6101d8600081565b6101d861024b366004611b72565b6104a2565b604051601281526020016101a8565b6101c461026d366004611af1565b6105de565b6101d860065481565b6102a27f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101a8565b6102a27f000000000000000000000000000000000000000000000000000000000000000081565b6102f46102ef366004611b9c565b610600565b005b6102f4610304366004611b1b565b61064f565b6101d8610317366004611b1b565b6001600160a01b031660009081526020819052604090205490565b61019b610881565b6101d86103e881565b6101c4610351366004611af1565b610890565b6101c4610364366004611af1565b61090b565b6102f4610377366004611b72565b610919565b6102f4610bc3565b6101d8610392366004611bfe565b610d05565b6007546101c49060ff1681565b6101d86103b2366004611b72565b610d30565b6102f46103c5366004611af1565b610e65565b6102f46110be565b6060600380546103e190611c31565b80601f016020809104026020016040519081016040528092919081815260200182805461040d90611c31565b801561045a5780601f1061042f5761010080835404028352916020019161045a565b820191906000526020600020905b81548152906001019060200180831161043d57829003601f168201915b5050505050905090565b600033610472818585611141565b60019150505b92915050565b60003361048c858285611265565b6104978585856112d9565b506001949350505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa15801561050b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052f9190611c6b565b604051634c4b4f4160e11b8152600060048201523060248201529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906398969e8290604401602060405180830381865afa15801561059d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c19190611c6b565b6105cb9082611c9a565b90506105d7838261147d565b9392505050565b6000336104728185856105f18383610d05565b6105fb9190611c9a565b611141565b61063e7f00000000000000000000000000000000000000000000000000000000000000003330886106315789610635565b6000195b888888886114b7565b61064786610919565b505050505050565b60075460ff16151560011461067f5760405162461bcd60e51b815260040161067690611cad565b60405180910390fd5b3360009081526005602052604090206001015443116106b05760405162461bcd60e51b815260040161067690611d0a565b33600090815260056020526040812043600182015554900361072e5760405162461bcd60e51b815260206004820152603160248201527f5374616b696e673a3a656d657267656e637957697468647261773a3a6e6f2073604482015270686172657320746f20776974686472617760781b6064820152608401610676565b336000908152600560205260408082205490516370a0823160e01b81523060048201529091906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa1580156107a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c99190611c6b565b905060006107d7838361147d565b905082600660008282546107eb9190611d7b565b9091555050336000908152600560205260408120556108347f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316858361168d565b60408051828152602081018590526001600160a01b0386169133917f1401b6ff3b281e84fd77353369caed48ba7e787dd3821db05cc006437360820191015b60405180910390a350505050565b6060600480546103e190611c31565b6000338161089e8286610d05565b9050838110156108fe5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610676565b6104978286868403611141565b6000336104728185856112d9565b60075460ff1615156001146109405760405162461bcd60e51b815260040161067690611cad565b3360009081526005602052604090206001015443116109715760405162461bcd60e51b815260040161067690611d0a565b336000908152600560205260408120436001909101558190036109e95760405162461bcd60e51b815260206004820152602a60248201527f5374616b696e673a3a6465706f7369743a3a63616e2774206465706f736974206044820152693d32b937903a37b5b2b760b11b6064820152608401610676565b6109f16110be565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610a58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7c9190611c6b565b90506000610a8a83836116f5565b90506000600654600003610aab57610aa46103e883611d7b565b9050610aae565b50805b80600003610b0f5760405162461bcd60e51b815260206004820152602860248201527f5374616b696e673a3a6465706f7369743a3a6e6f206e657720736861726573206044820152671c9958d95a5d995960c21b6064820152608401610676565b3360009081526005602052604081208054839290610b2e908490611c9a565b925050819055508160066000828254610b479190611c9a565b90915550610b8290506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016333087611722565b604080518581526020810183905233917f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15910160405180910390a250505050565b60075460ff1615610c3e576040805162461bcd60e51b81526020600482015260248101919091527f5374616b696e673a3a696e697469616c697a654661726d696e673a3a4661726d60448201527f696e672063616d706169676e20616c726561647920696e697469616c697a65646064820152608401610676565b610c6a307f00000000000000000000000000000000000000000000000000000000000000006001611141565b610c7530600161175a565b604051631c57762b60e31b815260006004820152600160248201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e2bbb15890604401600060405180830381600087803b158015610cde57600080fd5b505af1158015610cf2573d6000803e3d6000fd5b50506007805460ff191660011790555050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6040516370a0823160e01b815230600482015260009081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906370a0823190602401602060405180830381865afa158015610d99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbd9190611c6b565b604051634c4b4f4160e11b8152600060048201523060248201529091507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906398969e8290604401602060405180830381865afa158015610e2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4f9190611c6b565b610e599082611c9a565b90506105d783826116f5565b60075460ff161515600114610e8c5760405162461bcd60e51b815260040161067690611cad565b336000908152600560205260409020600101544311610ebd5760405162461bcd60e51b815260040161067690611d0a565b336000908152600560205260409020436001909101558015801590610ef15750336000908152600560205260409020548111155b610f635760405162461bcd60e51b815260206004820152603f60248201527f5374616b696e673a3a77697468647261773a3a63616e2774207769746864726160448201527f77206d6f7265207468616e207573657220736861726573206f72207a65726f006064820152608401610676565b610f6b6110be565b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610fd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff69190611c6b565b90506000611004838361147d565b33600090815260056020526040812080549293508592909190611028908490611d7b565b9250508190555082600660008282546110419190611d7b565b9091555061107b90506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016858361168d565b60408051828152602081018590526001600160a01b0386169133917ff341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb5679101610873565b604051630441a3e760e41b815260006004820181905260248201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063441a3e7090604401600060405180830381600087803b15801561112757600080fd5b505af115801561113b573d6000803e3d6000fd5b50505050565b6001600160a01b0383166111a35760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610676565b6001600160a01b0382166112045760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610676565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006112718484610d05565b9050600019811461113b57818110156112cc5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610676565b61113b8484848403611141565b6001600160a01b03831661133d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610676565b6001600160a01b03821661139f5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610676565b6001600160a01b038316600090815260208190526040902054818110156114175760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610676565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a361113b565b60006006546000036114a05761149b670de0b6b3a764000084611d8e565b6105d7565b6006546114ad8385611db0565b6105d79190611d8e565b604051623f675f60e91b81526001600160a01b038881166004830152600091908a1690637ecebe0090602401602060405180830381865afa158015611500573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115249190611c6b565b60405163d505accf60e01b81526001600160a01b038a811660048301528981166024830152604482018990526064820188905260ff8716608483015260a4820186905260c48201859052919250908a169063d505accf9060e401600060405180830381600087803b15801561159857600080fd5b505af11580156115ac573d6000803e3d6000fd5b5050604051623f675f60e91b81526001600160a01b038b81166004830152600093508c169150637ecebe0090602401602060405180830381865afa1580156115f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061161c9190611c6b565b9050611629826001611c9a565b81146116815760405162461bcd60e51b815260206004820152602160248201527f5361666545524332303a207065726d697420646964206e6f74207375636365656044820152601960fa1b6064820152608401610676565b50505050505050505050565b6040516001600160a01b0383166024820152604481018290526116f090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611819565b505050565b60006006546000036117135761149b670de0b6b3a764000084611db0565b81600654846114ad9190611db0565b6040516001600160a01b038085166024830152831660448201526064810182905261113b9085906323b872dd60e01b906084016116b9565b6001600160a01b0382166117b05760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610676565b80600260008282546117c29190611c9a565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b600061186e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166118ee9092919063ffffffff16565b905080516000148061188f57508080602001905181019061188f9190611dc7565b6116f05760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610676565b60606118fd8484600085611905565b949350505050565b6060824710156119665760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610676565b600080866001600160a01b031685876040516119829190611de4565b60006040518083038185875af1925050503d80600081146119bf576040519150601f19603f3d011682016040523d82523d6000602084013e6119c4565b606091505b50915091506119d5878383876119e0565b979650505050505050565b60608315611a4f578251600003611a48576001600160a01b0385163b611a485760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610676565b50816118fd565b6118fd8383815115611a645781518083602001fd5b8060405162461bcd60e51b81526004016106769190611aa2565b60005b83811015611a99578181015183820152602001611a81565b50506000910152565b6020815260008251806020840152611ac1816040850160208701611a7e565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114611aec57600080fd5b919050565b60008060408385031215611b0457600080fd5b611b0d83611ad5565b946020939093013593505050565b600060208284031215611b2d57600080fd5b6105d782611ad5565b600080600060608486031215611b4b57600080fd5b611b5484611ad5565b9250611b6260208501611ad5565b9150604084013590509250925092565b600060208284031215611b8457600080fd5b5035919050565b8015158114611b9957600080fd5b50565b60008060008060008060c08789031215611bb557600080fd5b863595506020870135611bc781611b8b565b945060408701359350606087013560ff81168114611be457600080fd5b9598949750929560808101359460a0909101359350915050565b60008060408385031215611c1157600080fd5b611c1a83611ad5565b9150611c2860208401611ad5565b90509250929050565b600181811c90821680611c4557607f821691505b602082108103611c6557634e487b7160e01b600052602260045260246000fd5b50919050565b600060208284031215611c7d57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561047857610478611c84565b6020808252603f908201527f5374616b696e673a3a69734661726d696e67496e697469616c697a65643a3a4660408201527f61726d696e672063616d706169676e206e6f7420696e697469616c697a656400606082015260800190565b6020808252604b908201527f5374616b696e673a3a636865636b55736572426c6f636b3a3a5573657220616c60408201527f72656164792063616c6c6564206465706f736974206f7220776974686472617760608201526a207468697320626c6f636b60a81b608082015260a00190565b8181038181111561047857610478611c84565b600082611dab57634e487b7160e01b600052601260045260246000fd5b500490565b808202811582820484141761047857610478611c84565b600060208284031215611dd957600080fd5b81516105d781611b8b565b60008251611df6818460208701611a7e565b919091019291505056fea164736f6c6343000811000a0000000000000000000000005de8ab7e27f6e7a1fff3e5b337584aa43961beef0000000000000000000000007d85c0905a6e1ab5837a0b57cd94a419d3a77523

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061018e5760003560e01c80636ff1c9bc116100de578063b6b55f2511610097578063eed06a6311610071578063eed06a6314610397578063f3044ac7146103a4578063f3fef3a3146103b7578063fe2ed8b0146103ca57600080fd5b8063b6b55f2514610369578063c0939f491461037c578063dd62ed3e1461038457600080fd5b80636ff1c9bc146102f657806370a082311461030957806395d89b4114610332578063a1a47d711461033a578063a457c2d714610343578063a9059cbb1461035657600080fd5b806327def4fd1161014b5780633a98ef39116101255780633a98ef39146102725780634e3ad80f1461027b578063670b3a0b146102ba5780636e28ee66146102e157600080fd5b806327def4fd1461023d578063313ce56714610250578063395093511461025f57600080fd5b806306fdde0314610193578063095ea7b3146101b157806318160ddd146101d45780631959a002146101e657806323b872dd1461022257806326c07fd714610235575b600080fd5b61019b6103d2565b6040516101a89190611aa2565b60405180910390f35b6101c46101bf366004611af1565b610464565b60405190151581526020016101a8565b6002545b6040519081526020016101a8565b61020d6101f4366004611b1b565b6005602052600090815260409020805460019091015482565b604080519283526020830191909152016101a8565b6101c4610230366004611b36565b61047e565b6101d8600081565b6101d861024b366004611b72565b6104a2565b604051601281526020016101a8565b6101c461026d366004611af1565b6105de565b6101d860065481565b6102a27f0000000000000000000000007d85c0905a6e1ab5837a0b57cd94a419d3a7752381565b6040516001600160a01b0390911681526020016101a8565b6102a27f0000000000000000000000005de8ab7e27f6e7a1fff3e5b337584aa43961beef81565b6102f46102ef366004611b9c565b610600565b005b6102f4610304366004611b1b565b61064f565b6101d8610317366004611b1b565b6001600160a01b031660009081526020819052604090205490565b61019b610881565b6101d86103e881565b6101c4610351366004611af1565b610890565b6101c4610364366004611af1565b61090b565b6102f4610377366004611b72565b610919565b6102f4610bc3565b6101d8610392366004611bfe565b610d05565b6007546101c49060ff1681565b6101d86103b2366004611b72565b610d30565b6102f46103c5366004611af1565b610e65565b6102f46110be565b6060600380546103e190611c31565b80601f016020809104026020016040519081016040528092919081815260200182805461040d90611c31565b801561045a5780601f1061042f5761010080835404028352916020019161045a565b820191906000526020600020905b81548152906001019060200180831161043d57829003601f168201915b5050505050905090565b600033610472818585611141565b60019150505b92915050565b60003361048c858285611265565b6104978585856112d9565b506001949350505050565b6040516370a0823160e01b815230600482015260009081906001600160a01b037f0000000000000000000000005de8ab7e27f6e7a1fff3e5b337584aa43961beef16906370a0823190602401602060405180830381865afa15801561050b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061052f9190611c6b565b604051634c4b4f4160e11b8152600060048201523060248201529091507f0000000000000000000000007d85c0905a6e1ab5837a0b57cd94a419d3a775236001600160a01b0316906398969e8290604401602060405180830381865afa15801561059d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105c19190611c6b565b6105cb9082611c9a565b90506105d7838261147d565b9392505050565b6000336104728185856105f18383610d05565b6105fb9190611c9a565b611141565b61063e7f0000000000000000000000005de8ab7e27f6e7a1fff3e5b337584aa43961beef3330886106315789610635565b6000195b888888886114b7565b61064786610919565b505050505050565b60075460ff16151560011461067f5760405162461bcd60e51b815260040161067690611cad565b60405180910390fd5b3360009081526005602052604090206001015443116106b05760405162461bcd60e51b815260040161067690611d0a565b33600090815260056020526040812043600182015554900361072e5760405162461bcd60e51b815260206004820152603160248201527f5374616b696e673a3a656d657267656e637957697468647261773a3a6e6f2073604482015270686172657320746f20776974686472617760781b6064820152608401610676565b336000908152600560205260408082205490516370a0823160e01b81523060048201529091906001600160a01b037f0000000000000000000000005de8ab7e27f6e7a1fff3e5b337584aa43961beef16906370a0823190602401602060405180830381865afa1580156107a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107c99190611c6b565b905060006107d7838361147d565b905082600660008282546107eb9190611d7b565b9091555050336000908152600560205260408120556108347f0000000000000000000000005de8ab7e27f6e7a1fff3e5b337584aa43961beef6001600160a01b0316858361168d565b60408051828152602081018590526001600160a01b0386169133917f1401b6ff3b281e84fd77353369caed48ba7e787dd3821db05cc006437360820191015b60405180910390a350505050565b6060600480546103e190611c31565b6000338161089e8286610d05565b9050838110156108fe5760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610676565b6104978286868403611141565b6000336104728185856112d9565b60075460ff1615156001146109405760405162461bcd60e51b815260040161067690611cad565b3360009081526005602052604090206001015443116109715760405162461bcd60e51b815260040161067690611d0a565b336000908152600560205260408120436001909101558190036109e95760405162461bcd60e51b815260206004820152602a60248201527f5374616b696e673a3a6465706f7369743a3a63616e2774206465706f736974206044820152693d32b937903a37b5b2b760b11b6064820152608401610676565b6109f16110be565b6040516370a0823160e01b81523060048201526000907f0000000000000000000000005de8ab7e27f6e7a1fff3e5b337584aa43961beef6001600160a01b0316906370a0823190602401602060405180830381865afa158015610a58573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7c9190611c6b565b90506000610a8a83836116f5565b90506000600654600003610aab57610aa46103e883611d7b565b9050610aae565b50805b80600003610b0f5760405162461bcd60e51b815260206004820152602860248201527f5374616b696e673a3a6465706f7369743a3a6e6f206e657720736861726573206044820152671c9958d95a5d995960c21b6064820152608401610676565b3360009081526005602052604081208054839290610b2e908490611c9a565b925050819055508160066000828254610b479190611c9a565b90915550610b8290506001600160a01b037f0000000000000000000000005de8ab7e27f6e7a1fff3e5b337584aa43961beef16333087611722565b604080518581526020810183905233917f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a15910160405180910390a250505050565b60075460ff1615610c3e576040805162461bcd60e51b81526020600482015260248101919091527f5374616b696e673a3a696e697469616c697a654661726d696e673a3a4661726d60448201527f696e672063616d706169676e20616c726561647920696e697469616c697a65646064820152608401610676565b610c6a307f0000000000000000000000007d85c0905a6e1ab5837a0b57cd94a419d3a775236001611141565b610c7530600161175a565b604051631c57762b60e31b815260006004820152600160248201527f0000000000000000000000007d85c0905a6e1ab5837a0b57cd94a419d3a775236001600160a01b03169063e2bbb15890604401600060405180830381600087803b158015610cde57600080fd5b505af1158015610cf2573d6000803e3d6000fd5b50506007805460ff191660011790555050565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6040516370a0823160e01b815230600482015260009081906001600160a01b037f0000000000000000000000005de8ab7e27f6e7a1fff3e5b337584aa43961beef16906370a0823190602401602060405180830381865afa158015610d99573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbd9190611c6b565b604051634c4b4f4160e11b8152600060048201523060248201529091507f0000000000000000000000007d85c0905a6e1ab5837a0b57cd94a419d3a775236001600160a01b0316906398969e8290604401602060405180830381865afa158015610e2b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4f9190611c6b565b610e599082611c9a565b90506105d783826116f5565b60075460ff161515600114610e8c5760405162461bcd60e51b815260040161067690611cad565b336000908152600560205260409020600101544311610ebd5760405162461bcd60e51b815260040161067690611d0a565b336000908152600560205260409020436001909101558015801590610ef15750336000908152600560205260409020548111155b610f635760405162461bcd60e51b815260206004820152603f60248201527f5374616b696e673a3a77697468647261773a3a63616e2774207769746864726160448201527f77206d6f7265207468616e207573657220736861726573206f72207a65726f006064820152608401610676565b610f6b6110be565b6040516370a0823160e01b81523060048201526000907f0000000000000000000000005de8ab7e27f6e7a1fff3e5b337584aa43961beef6001600160a01b0316906370a0823190602401602060405180830381865afa158015610fd2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff69190611c6b565b90506000611004838361147d565b33600090815260056020526040812080549293508592909190611028908490611d7b565b9250508190555082600660008282546110419190611d7b565b9091555061107b90506001600160a01b037f0000000000000000000000005de8ab7e27f6e7a1fff3e5b337584aa43961beef16858361168d565b60408051828152602081018590526001600160a01b0386169133917ff341246adaac6f497bc2a656f546ab9e182111d630394f0c57c710a59a2cb5679101610873565b604051630441a3e760e41b815260006004820181905260248201527f0000000000000000000000007d85c0905a6e1ab5837a0b57cd94a419d3a775236001600160a01b03169063441a3e7090604401600060405180830381600087803b15801561112757600080fd5b505af115801561113b573d6000803e3d6000fd5b50505050565b6001600160a01b0383166111a35760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610676565b6001600160a01b0382166112045760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610676565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b60006112718484610d05565b9050600019811461113b57818110156112cc5760405162461bcd60e51b815260206004820152601d60248201527f45524332303a20696e73756666696369656e7420616c6c6f77616e63650000006044820152606401610676565b61113b8484848403611141565b6001600160a01b03831661133d5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610676565b6001600160a01b03821661139f5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610676565b6001600160a01b038316600090815260208190526040902054818110156114175760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610676565b6001600160a01b03848116600081815260208181526040808320878703905593871680835291849020805487019055925185815290927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a361113b565b60006006546000036114a05761149b670de0b6b3a764000084611d8e565b6105d7565b6006546114ad8385611db0565b6105d79190611d8e565b604051623f675f60e91b81526001600160a01b038881166004830152600091908a1690637ecebe0090602401602060405180830381865afa158015611500573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115249190611c6b565b60405163d505accf60e01b81526001600160a01b038a811660048301528981166024830152604482018990526064820188905260ff8716608483015260a4820186905260c48201859052919250908a169063d505accf9060e401600060405180830381600087803b15801561159857600080fd5b505af11580156115ac573d6000803e3d6000fd5b5050604051623f675f60e91b81526001600160a01b038b81166004830152600093508c169150637ecebe0090602401602060405180830381865afa1580156115f8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061161c9190611c6b565b9050611629826001611c9a565b81146116815760405162461bcd60e51b815260206004820152602160248201527f5361666545524332303a207065726d697420646964206e6f74207375636365656044820152601960fa1b6064820152608401610676565b50505050505050505050565b6040516001600160a01b0383166024820152604481018290526116f090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611819565b505050565b60006006546000036117135761149b670de0b6b3a764000084611db0565b81600654846114ad9190611db0565b6040516001600160a01b038085166024830152831660448201526064810182905261113b9085906323b872dd60e01b906084016116b9565b6001600160a01b0382166117b05760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f2061646472657373006044820152606401610676565b80600260008282546117c29190611c9a565b90915550506001600160a01b038216600081815260208181526040808320805486019055518481527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050565b600061186e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166118ee9092919063ffffffff16565b905080516000148061188f57508080602001905181019061188f9190611dc7565b6116f05760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610676565b60606118fd8484600085611905565b949350505050565b6060824710156119665760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610676565b600080866001600160a01b031685876040516119829190611de4565b60006040518083038185875af1925050503d80600081146119bf576040519150601f19603f3d011682016040523d82523d6000602084013e6119c4565b606091505b50915091506119d5878383876119e0565b979650505050505050565b60608315611a4f578251600003611a48576001600160a01b0385163b611a485760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610676565b50816118fd565b6118fd8383815115611a645781518083602001fd5b8060405162461bcd60e51b81526004016106769190611aa2565b60005b83811015611a99578181015183820152602001611a81565b50506000910152565b6020815260008251806020840152611ac1816040850160208701611a7e565b601f01601f19169190910160400192915050565b80356001600160a01b0381168114611aec57600080fd5b919050565b60008060408385031215611b0457600080fd5b611b0d83611ad5565b946020939093013593505050565b600060208284031215611b2d57600080fd5b6105d782611ad5565b600080600060608486031215611b4b57600080fd5b611b5484611ad5565b9250611b6260208501611ad5565b9150604084013590509250925092565b600060208284031215611b8457600080fd5b5035919050565b8015158114611b9957600080fd5b50565b60008060008060008060c08789031215611bb557600080fd5b863595506020870135611bc781611b8b565b945060408701359350606087013560ff81168114611be457600080fd5b9598949750929560808101359460a0909101359350915050565b60008060408385031215611c1157600080fd5b611c1a83611ad5565b9150611c2860208401611ad5565b90509250929050565b600181811c90821680611c4557607f821691505b602082108103611c6557634e487b7160e01b600052602260045260246000fd5b50919050565b600060208284031215611c7d57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561047857610478611c84565b6020808252603f908201527f5374616b696e673a3a69734661726d696e67496e697469616c697a65643a3a4660408201527f61726d696e672063616d706169676e206e6f7420696e697469616c697a656400606082015260800190565b6020808252604b908201527f5374616b696e673a3a636865636b55736572426c6f636b3a3a5573657220616c60408201527f72656164792063616c6c6564206465706f736974206f7220776974686472617760608201526a207468697320626c6f636b60a81b608082015260a00190565b8181038181111561047857610478611c84565b600082611dab57634e487b7160e01b600052601260045260246000fd5b500490565b808202811582820484141761047857610478611c84565b600060208284031215611dd957600080fd5b81516105d781611b8b565b60008251611df6818460208701611a7e565b919091019291505056fea164736f6c6343000811000a

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

0000000000000000000000005de8ab7e27f6e7a1fff3e5b337584aa43961beef0000000000000000000000007d85c0905a6e1ab5837a0b57cd94a419d3a77523

-----Decoded View---------------
Arg [0] : _smardexToken (address): 0x5DE8ab7E27f6E7A1fFf3E5B337584Aa43961BEeF
Arg [1] : _farming (address): 0x7d85C0905a6E1Ab5837a0b57cD94A419d3a77523

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000005de8ab7e27f6e7a1fff3e5b337584aa43961beef
Arg [1] : 0000000000000000000000007d85c0905a6e1ab5837a0b57cd94a419d3a77523


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.