ETH Price: $3,462.34 (+2.11%)
Gas: 6 Gwei

Contract

0x278dC748edA1d8eFEf1aDFB518542612b49Fcd34
 
Transaction Hash
Method
Block
From
To
Value
Distribute Rewar...202103352024-07-01 8:00:115 hrs ago1719820811IN
0x278dC748...2b49Fcd34
0 ETH0.000629942.92728298
Distribute Rewar...202077992024-06-30 23:30:1113 hrs ago1719790211IN
0x278dC748...2b49Fcd34
0 ETH0.00054632.53859371
Distribute Rewar...202034672024-06-30 9:00:2328 hrs ago1719738023IN
0x278dC748...2b49Fcd34
0 ETH0.000670263.11463836
Distribute Rewar...202030182024-06-30 7:30:1129 hrs ago1719732611IN
0x278dC748...2b49Fcd34
0 ETH0.000345672.06721061
Distribute Rewar...202024202024-06-30 5:30:1131 hrs ago1719725411IN
0x278dC748...2b49Fcd34
0 ETH0.000402181.86891392
Distribute Rewar...202009332024-06-30 0:30:1136 hrs ago1719707411IN
0x278dC748...2b49Fcd34
0 ETH0.000504221.85672658
Distribute Rewar...202006342024-06-29 23:30:2337 hrs ago1719703823IN
0x278dC748...2b49Fcd34
0 ETH0.000311.44052902
Distribute Rewar...201989912024-06-29 18:00:1143 hrs ago1719684011IN
0x278dC748...2b49Fcd34
0 ETH0.000371242.22011825
Distribute Rewar...201980942024-06-29 15:00:1146 hrs ago1719673211IN
0x278dC748...2b49Fcd34
0 ETH0.000820443.81251
Distribute Rewar...201963102024-06-29 9:00:352 days ago1719651635IN
0x278dC748...2b49Fcd34
0 ETH0.00054842.54836935
Distribute Rewar...201963082024-06-29 9:00:112 days ago1719651611IN
0x278dC748...2b49Fcd34
0 ETH0.000555912.58326736
Distribute Rewar...201921342024-06-28 19:00:112 days ago1719601211IN
0x278dC748...2b49Fcd34
0 ETH0.0009124.23819706
Distribute Rewar...201885512024-06-28 7:00:113 days ago1719558011IN
0x278dC748...2b49Fcd34
0 ETH0.000631932.93649188
Distribute Rewar...201867612024-06-28 1:00:113 days ago1719536411IN
0x278dC748...2b49Fcd34
0 ETH0.000945735.65568422
Distribute Rewar...201860242024-06-27 22:31:353 days ago1719527495IN
0x278dC748...2b49Fcd34
0 ETH0.001221275.67508575
Distribute Rewar...201860222024-06-27 22:31:113 days ago1719527471IN
0x278dC748...2b49Fcd34
0 ETH0.001169585.43488362
Distribute Rewar...201860192024-06-27 22:30:353 days ago1719527435IN
0x278dC748...2b49Fcd34
0 ETH0.001219585.66722966
Distribute Rewar...201860172024-06-27 22:30:113 days ago1719527411IN
0x278dC748...2b49Fcd34
0 ETH0.001102335.12240744
Distribute Rewar...201854272024-06-27 20:31:113 days ago1719520271IN
0x278dC748...2b49Fcd34
0 ETH0.001466766.81585916
Distribute Rewar...201854242024-06-27 20:30:353 days ago1719520235IN
0x278dC748...2b49Fcd34
0 ETH0.001465116.8082064
Distribute Rewar...201854222024-06-27 20:30:113 days ago1719520211IN
0x278dC748...2b49Fcd34
0 ETH0.001441896.70029798
Distribute Rewar...201852732024-06-27 20:00:113 days ago1719518411IN
0x278dC748...2b49Fcd34
0 ETH0.001732598.05112791
Distribute Rewar...201851232024-06-27 19:30:113 days ago1719516611IN
0x278dC748...2b49Fcd34
0 ETH0.0017114910.23505913
Distribute Rewar...201848252024-06-27 18:30:113 days ago1719513011IN
0x278dC748...2b49Fcd34
0 ETH0.0036043210.71602336
Distribute Rewar...201846762024-06-27 18:00:113 days ago1719511211IN
0x278dC748...2b49Fcd34
0 ETH0.004649621.60607873
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FraxGaugeFXSRewardsDistributor

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 100000 runs

Other Settings:
default evmVersion
File 1 of 14 : FraxGaugeFXSRewardsDistributor.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.11;

// ====================================================================
// |     ______                   _______                             |
// |    / _____________ __  __   / ____(_____  ____ _____  ________   |
// |   / /_  / ___/ __ `| |/_/  / /_  / / __ \/ __ `/ __ \/ ___/ _ \  |
// |  / __/ / /  / /_/ _>  <   / __/ / / / / / /_/ / / / / /__/  __/  |
// | /_/   /_/   \__,_/_/|_|  /_/   /_/_/ /_/\__,_/_/ /_/\___/\___/   |
// |                                                                  |
// ====================================================================
// ================== FraxGaugeFXSRewardsDistributor ==================
// ====================================================================
// Looks at the gauge controller contract and pushes out FXS rewards once
// a week to the gauges (farms)

// Frax Finance: https://github.com/FraxFinance

// Primary Author(s)
// Travis Moore: https://github.com/FortisFortuna

// Reviewer(s) / Contributor(s)
// Jason Huan: https://github.com/jasonhuan
// Sam Kazemian: https://github.com/samkazemian

import "../Math/Math.sol";
import "../Math/SafeMath.sol";
import "../ERC20/ERC20.sol";
import "../ERC20/SafeERC20.sol";
import "./IFraxGaugeController.sol";
import "./FraxMiddlemanGauge.sol";
import '../Uniswap/TransferHelper.sol';
import "../Staking/Owned.sol";

contract FraxGaugeFXSRewardsDistributor is Owned {
    using SafeMath for uint256;
    using SafeERC20 for ERC20;

    /* ========== STATE VARIABLES ========== */

    // Instances and addresses
    address private reward_token_address;
    IFraxGaugeController private gauge_controller;

    // Admin addresses
    address public timelock_address;
    address public curator_address;

    // Constants
    uint256 private constant MULTIPLIER_PRECISION = 1e18;
    uint256 private constant ONE_WEEK = 604800;

    // Gauge controller related
    mapping(address => bool) public gauge_whitelist;
    mapping(address => bool) public is_middleman; // For cross-chain farms, use a middleman contract to push to a bridge
    mapping(address => uint256) public last_time_gauge_paid;

    // Booleans
    bool public distributionsOn;

    /* ========== MODIFIERS ========== */

    modifier onlyByOwnerOrGovernance() {
        require(msg.sender == owner || msg.sender == timelock_address, "Not owner or timelock");
        _;
    }

    modifier onlyByOwnerOrCuratorOrGovernance() {
        require(msg.sender == owner || msg.sender == curator_address || msg.sender == timelock_address, "Not owner, curator, or timelock");
        _;
    }

    modifier isDistributing() {
        require(distributionsOn == true, "Distributions are off");
        _;
    }

    /* ========== CONSTRUCTOR ========== */

    constructor(
        address _owner,
        address _timelock_address,
        address _curator_address,
        address _reward_token_address,
        address _gauge_controller_address
    ) Owned(_owner) {
        curator_address = _curator_address;
        timelock_address = _timelock_address;

        reward_token_address = _reward_token_address;
        gauge_controller = IFraxGaugeController(_gauge_controller_address);

        distributionsOn = true;

    }

    /* ========== VIEWS ========== */

    // Current weekly reward amount
    function currentReward(address gauge_address) public view returns (uint256 reward_amount) {
        uint256 rel_weight = gauge_controller.gauge_relative_weight(gauge_address, block.timestamp);
        uint256 rwd_rate = (gauge_controller.global_emission_rate()).mul(rel_weight).div(1e18);
        reward_amount = rwd_rate.mul(ONE_WEEK);
    }

    /* ========== MUTATIVE FUNCTIONS ========== */

    // Callable by anyone
    function distributeReward(address gauge_address) public isDistributing returns (uint256 weeks_elapsed, uint256 reward_tally) {
        require(gauge_whitelist[gauge_address], "Gauge not whitelisted");
        
        // Calculate the elapsed time in weeks. Truncation desired
        uint256 last_time_paid = last_time_gauge_paid[gauge_address];

        // Edge case for first reward for this gauge
        if (last_time_paid == 0){
            weeks_elapsed = 1;
        }
        else {
            weeks_elapsed = (block.timestamp).sub(last_time_gauge_paid[gauge_address]) / ONE_WEEK;

            // Return early here for 0 weeks instead of throwing, as it could have bad effects in other contracts
            if (weeks_elapsed == 0) {
                return (0, 0);
            }
        }

        // NOTE: This will always use the current global_emission_rate()
        reward_tally = 0;
        for (uint i = 0; i < (weeks_elapsed); i++){ 
            uint256 rel_weight_at_week;
            if (i == 0) {
                // Mutative, for the current week. Makes sure the weight is checkpointed. Also returns the weight.
                rel_weight_at_week = gauge_controller.gauge_relative_weight_write(gauge_address, block.timestamp);
            }
            else {
                // View
                rel_weight_at_week = gauge_controller.gauge_relative_weight(gauge_address, (block.timestamp).sub(ONE_WEEK * i));
            }
            uint256 rwd_rate_at_week = (gauge_controller.global_emission_rate()).mul(rel_weight_at_week).div(1e18);
            reward_tally = reward_tally.add(rwd_rate_at_week.mul(ONE_WEEK));
        }

        // Update the last time paid
        last_time_gauge_paid[gauge_address] = block.timestamp;

        if (is_middleman[gauge_address]){
            // Cross chain: Pay out the rewards to the middleman contract
            // Approve for the middleman first
            ERC20(reward_token_address).approve(gauge_address, reward_tally);

            // Trigger the middleman
            FraxMiddlemanGauge(gauge_address).pullAndBridge(reward_tally);
        }
        else {
            // Mainnet: Pay out the rewards directly to the gauge
            TransferHelper.safeTransfer(reward_token_address, gauge_address, reward_tally);
        }


        emit RewardDistributed(gauge_address, reward_tally);
    }

    /* ========== RESTRICTED FUNCTIONS - Curator / migrator callable ========== */

    // For emergency situations
    function toggleDistributions() external onlyByOwnerOrCuratorOrGovernance {
        distributionsOn = !distributionsOn;

        emit DistributionsToggled(distributionsOn);
    }

    /* ========== RESTRICTED FUNCTIONS - Owner or timelock only ========== */
    
    // Added to support recovering LP Rewards and other mistaken tokens from other systems to be distributed to holders
    function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnerOrGovernance {
        // Only the owner address can ever receive the recovery withdrawal
        TransferHelper.safeTransfer(tokenAddress, owner, tokenAmount);
        emit RecoveredERC20(tokenAddress, tokenAmount);
    }

    function setGaugeState(address _gauge_address, bool _is_middleman, bool _is_active) external onlyByOwnerOrGovernance {
        is_middleman[_gauge_address] = _is_middleman;
        gauge_whitelist[_gauge_address] = _is_active;

        emit GaugeStateChanged(_gauge_address, _is_middleman, _is_active);
    }

    function setTimelock(address _new_timelock) external onlyByOwnerOrGovernance {
        timelock_address = _new_timelock;
    }

    function setCurator(address _new_curator_address) external onlyByOwnerOrGovernance {
        curator_address = _new_curator_address;
    }

    function setGaugeController(address _gauge_controller_address) external onlyByOwnerOrGovernance {
        gauge_controller = IFraxGaugeController(_gauge_controller_address);
    }

    /* ========== EVENTS ========== */

    event RewardDistributed(address indexed gauge_address, uint256 reward_amount);
    event RecoveredERC20(address token, uint256 amount);
    event GaugeStateChanged(address gauge_address, bool is_middleman, bool is_active);
    event DistributionsToggled(bool distibutions_state);
}

File 2 of 14 : Math.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.11;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow, so we distribute
        return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
    }

    // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
    function sqrt(uint y) internal pure returns (uint z) {
        if (y > 3) {
            z = y;
            uint x = y / 2 + 1;
            while (x < z) {
                z = x;
                x = (y / x + x) / 2;
            }
        } else if (y != 0) {
            z = 1;
        }
    }
}

File 3 of 14 : SafeMath.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.11;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

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

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

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

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

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

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 4 of 14 : ERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.11;

import "../Common/Context.sol";
import "./IERC20.sol";
import "../Math/SafeMath.sol";
import "../Utils/Address.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 {ERC20Mintable}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of 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 {
    using SafeMath for uint256;

    mapping (address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;
    
    /**
     * @dev Sets the values for {name} and {symbol}, initializes {decimals} with
     * a default value of 18.
     *
     * To select a different value for {decimals}, use {_setupDecimals}.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor (string memory __name, string memory __symbol) public {
        _name = __name;
        _symbol = __symbol;
        _decimals = 18;
    }

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

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view 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 value {ERC20} uses, unless {_setupDecimals} is
     * called.
     *
     * 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 returns (uint8) {
        return _decimals;
    }

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

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

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, 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}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.approve(address spender, uint256 amount)
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), 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};
     *
     * Requirements:
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for `sender`'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        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) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(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) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is 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:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, 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
     *
     * - `to` 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 = _totalSupply.add(amount);
        _balances[account] = _balances[account].add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for `accounts`'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");

        _approve(account, _msgSender(), decreasedAllowance);
        _burn(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);

        _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
        _totalSupply = _totalSupply.sub(amount);
        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
     *
     * This is 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 Destroys `amount` tokens from `account`.`amount` is then deducted
     * from the caller's allowance.
     *
     * See {_burn} and {_approve}.
     */
    function _burnFrom(address account, uint256 amount) internal virtual {
        _burn(account, amount);
        _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
    }

    /**
     * @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 to 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:using-hooks.adoc[Using Hooks].
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}

File 5 of 14 : SafeERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.11;

import "./IERC20.sol";
import "../Math/SafeMath.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 SafeMath for uint256;
    using Address for address;

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

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

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

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

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

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

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

File 6 of 14 : IFraxGaugeController.sol
pragma solidity >=0.6.11;

// https://github.com/swervefi/swerve/edit/master/packages/swerve-contracts/interfaces/IGaugeController.sol

interface IFraxGaugeController {
    struct Point {
        uint256 bias;
        uint256 slope;
    }

    struct VotedSlope {
        uint256 slope;
        uint256 power;
        uint256 end;
    }

    // Public variables
    function admin() external view returns (address);
    function future_admin() external view returns (address);
    function token() external view returns (address);
    function voting_escrow() external view returns (address);
    function n_gauge_types() external view returns (int128);
    function n_gauges() external view returns (int128);
    function gauge_type_names(int128) external view returns (string memory);
    function gauges(uint256) external view returns (address);
    function vote_user_slopes(address, address)
        external
        view
        returns (VotedSlope memory);
    function vote_user_power(address) external view returns (uint256);
    function last_user_vote(address, address) external view returns (uint256);
    function points_weight(address, uint256)
        external
        view
        returns (Point memory);
    function time_weight(address) external view returns (uint256);
    function points_sum(int128, uint256) external view returns (Point memory);
    function time_sum(uint256) external view returns (uint256);
    function points_total(uint256) external view returns (uint256);
    function time_total() external view returns (uint256);
    function points_type_weight(int128, uint256)
        external
        view
        returns (uint256);
    function time_type_weight(uint256) external view returns (uint256);

    // Getter functions
    function gauge_types(address) external view returns (int128);
    function gauge_relative_weight(address, uint256)
        external
        view
        returns (uint256);
    function get_gauge_weight(address) external view returns (uint256);
    function get_type_weight(int128) external view returns (uint256);
    function get_total_weight() external view returns (uint256);
    function get_weights_sum_per_type(int128) external view returns (uint256);

    // External functions
    function commit_transfer_ownership(address) external;
    function apply_transfer_ownership() external;
    function add_gauge(
        address,
        int128,
        uint256
    ) external;
    function checkpoint() external;
    function checkpoint_gauge(address) external;
    function global_emission_rate() external view returns (uint256);
    function gauge_relative_weight_write(address, uint256)
        external
        returns (uint256);
    function add_type(string memory, uint256) external;
    function change_type_weight(int128, uint256) external;
    function change_gauge_weight(address, uint256) external;
    function change_global_emission_rate(uint256) external;
    function vote_for_gauge_weights(address, uint256) external;
}

File 7 of 14 : FraxMiddlemanGauge.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.11;

// ====================================================================
// |     ______                   _______                             |
// |    / _____________ __  __   / ____(_____  ____ _____  ________   |
// |   / /_  / ___/ __ `| |/_/  / /_  / / __ \/ __ `/ __ \/ ___/ _ \  |
// |  / __/ / /  / /_/ _>  <   / __/ / / / / / /_/ / / / / /__/  __/  |
// | /_/   /_/   \__,_/_/|_|  /_/   /_/_/ /_/\__,_/_/ /_/\___/\___/   |
// |                                                                  |
// ====================================================================
// ======================== FraxMiddlemanGauge ========================
// ====================================================================
// Looks at the gauge controller contract and pushes out FXS rewards once
// a week to the gauges (farms).
// This contract is what gets added to the gauge as a 'slice'

// Frax Finance: https://github.com/FraxFinance

// Primary Author(s)
// Travis Moore: https://github.com/FortisFortuna

// Reviewer(s) / Contributor(s)
// Jason Huan: https://github.com/jasonhuan
// Sam Kazemian: https://github.com/samkazemian

import "../Math/Math.sol";
import "../Math/SafeMath.sol";
import "../ERC20/ERC20.sol";
import "../ERC20/SafeERC20.sol";
import "./FraxGaugeFXSRewardsDistributor.sol";
import "../Misc_AMOs/polygon/IRootChainManager.sol";
import "../Misc_AMOs/solana/IWormhole.sol";
import '../Uniswap/TransferHelper.sol';
import "../Staking/Owned.sol";

contract FraxMiddlemanGauge is Owned {
    using SafeMath for uint256;
    using SafeERC20 for ERC20;

    /* ========== STATE VARIABLES ========== */

    // Instances and addresses
    address public reward_token_address = 0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0; // FXS
    address public rewards_distributor_address;

    // Informational
    string public name;

    // Admin addresses
    address public timelock_address;

    // Gauge-related
    address public bridge_address;
    uint256 public bridge_type;
    address public destination_address_override;
    string public non_evm_destination_address;

    // Tracking
    uint32 public fake_nonce;

    /* ========== MODIFIERS ========== */

    modifier onlyByOwnerOrGovernance() {
        require(msg.sender == owner || msg.sender == timelock_address, "Not owner or timelock");
        _;
    }

    modifier onlyRewardsDistributor() {
        require(msg.sender == rewards_distributor_address, "Not rewards distributor");
        _;
    }

    /* ========== CONSTRUCTOR ========== */

    constructor(
        address _owner,
        address _timelock_address,
        address _rewards_distributor_address,
        address _bridge_address,
        uint256 _bridge_type,
        address _destination_address_override,
        string memory _non_evm_destination_address,
        string memory _name
    ) Owned(_owner) {
        timelock_address = _timelock_address;

        rewards_distributor_address = _rewards_distributor_address;

        bridge_address = _bridge_address;
        bridge_type = _bridge_type;
        destination_address_override = _destination_address_override;
        non_evm_destination_address = _non_evm_destination_address;

        name = _name;

        fake_nonce = 0;
    }

    /* ========== MUTATIVE FUNCTIONS ========== */

    // Callable only by the rewards distributor
    function pullAndBridge(uint256 reward_amount) external onlyRewardsDistributor {
        require(bridge_address != address(0), "Invalid bridge address");

        // Pull in the rewards from the rewards distributor
        TransferHelper.safeTransferFrom(reward_token_address, rewards_distributor_address, address(this), reward_amount);

        address address_to_send_to = address(this);
        if (destination_address_override != address(0)) address_to_send_to = destination_address_override;

        if (bridge_type == 0) {
            // Avalanche [Anyswap]
            TransferHelper.safeTransfer(reward_token_address, address_to_send_to, reward_amount);
        }
        else if (bridge_type == 1) {
            // BSC
            TransferHelper.safeTransfer(reward_token_address, address_to_send_to, reward_amount);
        }
        else if (bridge_type == 2) {
            // Fantom [Anyswap]
            TransferHelper.safeTransfer(reward_token_address, address_to_send_to, reward_amount);
        }
        else if (bridge_type == 3) {
            // Polygon
            // Bridge is 0xA0c68C638235ee32657e8f720a23ceC1bFc77C77
            // Interesting info https://blog.cryption.network/cryption-network-launches-cross-chain-staking-6cf000c25477

            // Approve
            IRootChainManager rootChainMgr = IRootChainManager(bridge_address);
            bytes32 tokenType = rootChainMgr.tokenToType(reward_token_address);
            address predicate = rootChainMgr.typeToPredicate(tokenType);
            ERC20(reward_token_address).approve(predicate, reward_amount);
            
            // DepositFor
            bytes memory depositData = abi.encode(reward_amount);
            rootChainMgr.depositFor(address_to_send_to, reward_token_address, depositData);
        }
        else if (bridge_type == 4) {
            // Solana
            // Wormhole Bridge is 0xf92cD566Ea4864356C5491c177A430C222d7e678

            revert("Not supported yet");

            // // Approve
            // ERC20(reward_token_address).approve(bridge_address, reward_amount);

            // // lockAssets
            // require(non_evm_destination_address != 0, "Invalid destination");
            // // non_evm_destination_address = base58 -> hex
            // // https://www.appdevtools.com/base58-encoder-decoder
            // IWormhole(bridge_address).lockAssets(
            //     reward_token_address,
            //     reward_amount,
            //     non_evm_destination_address,
            //     1,
            //     fake_nonce,
            //     false
            // );
        }

        fake_nonce += 1;
    }

    /* ========== RESTRICTED FUNCTIONS - Owner or timelock only ========== */
    
    // Added to support recovering LP Rewards and other mistaken tokens from other systems to be distributed to holders
    function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnerOrGovernance {
        // Only the owner address can ever receive the recovery withdrawal
        TransferHelper.safeTransfer(tokenAddress, owner, tokenAmount);
        emit RecoveredERC20(tokenAddress, tokenAmount);
    }

    function setTimelock(address _new_timelock) external onlyByOwnerOrGovernance {
        timelock_address = _new_timelock;
    }

    function setBridgeInfo(address _bridge_address, uint256 _bridge_type, address _destination_address_override, string memory _non_evm_destination_address) external onlyByOwnerOrGovernance {
        _bridge_address = bridge_address;
        
        // 0: Avalanche
        // 1: BSC
        // 2: Fantom
        // 3: Polygon
        // 4: Solana
        bridge_type = _bridge_type;

        // Overridden cross-chain destination address
        destination_address_override = _destination_address_override;

        // Set bytes32 / non-EVM address on the other chain, if applicable
        non_evm_destination_address = _non_evm_destination_address;
        
        emit BridgeInfoChanged(_bridge_address, _bridge_type, _destination_address_override, _non_evm_destination_address);
    }

    function setRewardsDistributor(address _rewards_distributor_address) external onlyByOwnerOrGovernance {
        rewards_distributor_address = _rewards_distributor_address;
    }

    /* ========== EVENTS ========== */

    event RecoveredERC20(address token, uint256 amount);
    event BridgeInfoChanged(address bridge_address, uint256 bridge_type, address destination_address_override, string non_evm_destination_address);
}

File 8 of 14 : TransferHelper.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.11;

// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
    function safeApprove(address token, address to, uint value) internal {
        // bytes4(keccak256(bytes('approve(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: APPROVE_FAILED');
    }

    function safeTransfer(address token, address to, uint value) internal {
        // bytes4(keccak256(bytes('transfer(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FAILED');
    }

    function safeTransferFrom(address token, address from, address to, uint value) internal {
        // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED');
    }

    function safeTransferETH(address to, uint value) internal {
        (bool success,) = to.call{value:value}(new bytes(0));
        require(success, 'TransferHelper: ETH_TRANSFER_FAILED');
    }
}

File 9 of 14 : Owned.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.11;

// https://docs.synthetix.io/contracts/Owned
contract Owned {
    address public owner;
    address public nominatedOwner;

    constructor(address _owner) public {
        require(_owner != address(0), "Owner address cannot be 0");
        owner = _owner;
        emit OwnerChanged(address(0), _owner);
    }

    function nominateNewOwner(address _owner) external onlyOwner {
        nominatedOwner = _owner;
        emit OwnerNominated(_owner);
    }

    function acceptOwnership() external {
        require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
        emit OwnerChanged(owner, nominatedOwner);
        owner = nominatedOwner;
        nominatedOwner = address(0);
    }

    modifier onlyOwner {
        require(msg.sender == owner, "Only the contract owner may perform this action");
        _;
    }

    event OwnerNominated(address newOwner);
    event OwnerChanged(address oldOwner, address newOwner);
}

File 10 of 14 : Context.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.11;

/*
 * @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 GSN 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 payable) {
        return payable(msg.sender);
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 11 of 14 : IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.11;

import "../Common/Context.sol";
import "../Math/SafeMath.sol";

/**
 * @dev Interface of the ERC20 standard as defined in the EIP. Does not include
 * the optional functions; to access them see {ERC20Detailed}.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 12 of 14 : Address.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.11 <0.9.0;

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

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

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

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

File 13 of 14 : IRootChainManager.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.11;
pragma experimental ABIEncoderV2;

interface IRootChainManager {
  function depositFor (address user, address rootToken, bytes memory depositData) external;
  function tokenToType (address) external view returns (bytes32);
  function typeToPredicate (bytes32) external view returns (address);

}

// interface GeneratedInterface {
//   function DEFAULT_ADMIN_ROLE (  ) external view returns ( bytes32 );
//   function DEPOSIT (  ) external view returns ( bytes32 );
//   function ERC712_VERSION (  ) external view returns ( string );
//   function ETHER_ADDRESS (  ) external view returns ( address );
//   function MAPPER_ROLE (  ) external view returns ( bytes32 );
//   function MAP_TOKEN (  ) external view returns ( bytes32 );
//   function checkpointManagerAddress (  ) external view returns ( address );
//   function childChainManagerAddress (  ) external view returns ( address );
//   function childToRootToken ( address ) external view returns ( address );
//   function cleanMapToken ( address rootToken, address childToken ) external;
//   function depositEtherFor ( address user ) external;
//   function depositFor ( address user, address rootToken, bytes depositData ) external;
//   function executeMetaTransaction ( address userAddress, bytes functionSignature, bytes32 sigR, bytes32 sigS, uint8 sigV ) external returns ( bytes );
//   function exit ( bytes inputData ) external;
//   function getChainId (  ) external pure returns ( uint256 );
//   function getDomainSeperator (  ) external view returns ( bytes32 );
//   function getNonce ( address user ) external view returns ( uint256 nonce );
//   function getRoleAdmin ( bytes32 role ) external view returns ( bytes32 );
//   function getRoleMember ( bytes32 role, uint256 index ) external view returns ( address );
//   function getRoleMemberCount ( bytes32 role ) external view returns ( uint256 );
//   function grantRole ( bytes32 role, address account ) external;
//   function hasRole ( bytes32 role, address account ) external view returns ( bool );
//   function initialize ( address _owner ) external;
//   function initializeEIP712 (  ) external;
//   function mapToken ( address rootToken, address childToken, bytes32 tokenType ) external;
//   function processedExits ( bytes32 ) external view returns ( bool );
//   function registerPredicate ( bytes32 tokenType, address predicateAddress ) external;
//   function remapToken ( address rootToken, address childToken, bytes32 tokenType ) external;
//   function renounceRole ( bytes32 role, address account ) external;
//   function revokeRole ( bytes32 role, address account ) external;
//   function rootToChildToken ( address ) external view returns ( address );
//   function setCheckpointManager ( address newCheckpointManager ) external;
//   function setChildChainManagerAddress ( address newChildChainManager ) external;
//   function setStateSender ( address newStateSender ) external;
//   function setupContractId (  ) external;
//   function stateSenderAddress (  ) external view returns ( address );
//   function tokenToType ( address ) external view returns ( bytes32 );
//   function typeToPredicate ( bytes32 ) external view returns ( address );
// }

File 14 of 14 : IWormhole.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.11;
pragma experimental ABIEncoderV2;

interface IWormhole {
  function guardian_set_expirity () external view returns (uint32);
  function guardian_set_index () external view returns (uint32);
  function guardian_sets (uint32) external view returns (uint32 expiration_time);
  function isWrappedAsset (address) external view returns (bool);
  function lockAssets (address asset, uint256 amount, bytes32 recipient, uint8 target_chain, uint32 nonce, bool refund_dust) external;
  function lockETH (bytes32 recipient, uint8 target_chain, uint32 nonce) external;
  function wrappedAssetMaster () external view returns (address);
  function wrappedAssets (bytes32) external view returns (address);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_timelock_address","type":"address"},{"internalType":"address","name":"_curator_address","type":"address"},{"internalType":"address","name":"_reward_token_address","type":"address"},{"internalType":"address","name":"_gauge_controller_address","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"distibutions_state","type":"bool"}],"name":"DistributionsToggled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"gauge_address","type":"address"},{"indexed":false,"internalType":"bool","name":"is_middleman","type":"bool"},{"indexed":false,"internalType":"bool","name":"is_active","type":"bool"}],"name":"GaugeStateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RecoveredERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"gauge_address","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward_amount","type":"uint256"}],"name":"RewardDistributed","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"curator_address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"gauge_address","type":"address"}],"name":"currentReward","outputs":[{"internalType":"uint256","name":"reward_amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"gauge_address","type":"address"}],"name":"distributeReward","outputs":[{"internalType":"uint256","name":"weeks_elapsed","type":"uint256"},{"internalType":"uint256","name":"reward_tally","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distributionsOn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"gauge_whitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"is_middleman","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"last_time_gauge_paid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"recoverERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_new_curator_address","type":"address"}],"name":"setCurator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gauge_controller_address","type":"address"}],"name":"setGaugeController","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gauge_address","type":"address"},{"internalType":"bool","name":"_is_middleman","type":"bool"},{"internalType":"bool","name":"_is_active","type":"bool"}],"name":"setGaugeState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_new_timelock","type":"address"}],"name":"setTimelock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"timelock_address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"toggleDistributions","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b5060405162001bc138038062001bc1833981016040819052620000349162000164565b846001600160a01b038116620000905760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f74206265203000000000000000604482015260640160405180910390fd5b600080546001600160a01b0319166001600160a01b03831690811782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a150600580546001600160a01b03199081166001600160a01b03958616179091556004805482169585169590951790945560028054851692841692909217909155600380549093169116179055506009805460ff19166001179055620001d3565b80516001600160a01b03811681146200015f57600080fd5b919050565b600080600080600060a086880312156200017c578081fd5b620001878662000147565b9450620001976020870162000147565b9350620001a76040870162000147565b9250620001b76060870162000147565b9150620001c76080870162000147565b90509295509295909350565b6119de80620001e36000396000f3fe608060405234801561001057600080fd5b50600436106101355760003560e01c806379ba5097116100b2578063bdacb30311610081578063dc6663c711610066578063dc6663c7146102e1578063e81e17c614610301578063e90956cf1461032157600080fd5b8063bdacb303146102ae578063c92073c1146102c157600080fd5b806379ba5097146102525780638980f11f1461025a5780638da5cb5b1461026d5780639d18e4b01461028d57600080fd5b80632fd37b081161010957806353a47bb7116100ee57806353a47bb7146101d7578063570b1e991461021c5780636ca81c1c1461022f57600080fd5b80632fd37b08146101ac578063305d6d5f146101cf57600080fd5b806291d2b81461013a578063092193ab1461014f5780631627540c1461017c5780631f8a7edf1461018f575b600080fd5b61014d61014836600461172e565b610334565b005b61016261015d36600461172e565b610423565b604080519283526020830191909152015b60405180910390f35b61014d61018a36600461172e565b610a27565b60095461019c9060ff1681565b6040519015158152602001610173565b61019c6101ba36600461172e565b60066020526000908152604090205460ff1681565b61014d610b47565b6001546101f79073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610173565b61014d61022a366004611748565b610c77565b61019c61023d36600461172e565b60076020526000908152604090205460ff1681565b61014d610dc4565b61014d610268366004611790565b610f0f565b6000546101f79073ffffffffffffffffffffffffffffffffffffffff1681565b6102a061029b36600461172e565b61102a565b604051908152602001610173565b61014d6102bc36600461172e565b61116a565b6005546101f79073ffffffffffffffffffffffffffffffffffffffff1681565b6004546101f79073ffffffffffffffffffffffffffffffffffffffff1681565b6102a061030f36600461172e565b60086020526000908152604090205481565b61014d61032f36600461172e565b611254565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610371575060045473ffffffffffffffffffffffffffffffffffffffff1633145b6103dc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064015b60405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600954600090819060ff161515600114610499576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f446973747269627574696f6e7320617265206f6666000000000000000000000060448201526064016103d3565b73ffffffffffffffffffffffffffffffffffffffff831660009081526006602052604090205460ff16610528576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4761756765206e6f742077686974656c6973746564000000000000000000000060448201526064016103d3565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600860205260409020548061055c57600192506105af565b73ffffffffffffffffffffffffffffffffffffffff841660009081526008602052604090205462093a809061059290429061133e565b61059c9190611872565b9250826105af5750600093849350915050565b6000915060005b8381101561083f57600081610677576003546040517f6472eee100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015242602483015290911690636472eee190604401602060405180830381600087803b15801561063857600080fd5b505af115801561064c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067091906117d5565b9050610751565b60035473ffffffffffffffffffffffffffffffffffffffff1663d3078c94876106ad6106a68662093a806118ab565b429061133e565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff9092166004830152602482015260440160206040518083038186803b15801561071657600080fd5b505afa15801561072a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074e91906117d5565b90505b600061080f670de0b6b3a764000061080984600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630a3be7576040518163ffffffff1660e01b815260040160206040518083038186803b1580156107cb57600080fd5b505afa1580156107df573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080391906117d5565b90611389565b9061143e565b90506108286108218262093a80611389565b8690611480565b9450505080806108379061192f565b9150506105b6565b5073ffffffffffffffffffffffffffffffffffffffff84166000908152600860209081526040808320429055600790915290205460ff16156109ad576002546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018590529091169063095ea7b390604401602060405180830381600087803b1580156108ef57600080fd5b505af1158015610903573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092791906117b9565b506040517f4ae3decf0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff851690634ae3decf90602401600060405180830381600087803b15801561099057600080fd5b505af11580156109a4573d6000803e3d6000fd5b505050506109d1565b6002546109d19073ffffffffffffffffffffffffffffffffffffffff1685846114f9565b8373ffffffffffffffffffffffffffffffffffffffff167fe34918ff1c7084970068b53fd71ad6d8b04e9f15d3886cbf006443e6cdc52ea683604051610a1991815260200190565b60405180910390a250915091565b60005473ffffffffffffffffffffffffffffffffffffffff163314610ace576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201527f6f726d207468697320616374696f6e000000000000000000000000000000000060648201526084016103d3565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229060200160405180910390a150565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610b84575060055473ffffffffffffffffffffffffffffffffffffffff1633145b80610ba6575060045473ffffffffffffffffffffffffffffffffffffffff1633145b610c0c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f4e6f74206f776e65722c2063757261746f722c206f722074696d656c6f636b0060448201526064016103d3565b6009805460ff808216157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0090921682179092556040519116151581527fa47e236370e478b9d163098c7c1f4f67b6efbb6683eeb0a669f04f302653779d9060200160405180910390a1565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610cb4575060045473ffffffffffffffffffffffffffffffffffffffff1633145b610d1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064016103d3565b73ffffffffffffffffffffffffffffffffffffffff8316600081815260076020908152604080832080548715157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff009182168117909255600684529382902080548715159516851790558151948552918401919091528201527f404f22d93b56a7e73713d7bbe543b016084d4d75b4d9177e8b8ab251f6e877d09060600160405180910390a1505050565b60015473ffffffffffffffffffffffffffffffffffffffff163314610e6b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527f2063616e20616363657074206f776e657273686970000000000000000000000060648201526084016103d3565b6000546001546040805173ffffffffffffffffffffffffffffffffffffffff93841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff841617909155169055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610f4c575060045473ffffffffffffffffffffffffffffffffffffffff1633145b610fb2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064016103d3565b600054610fd790839073ffffffffffffffffffffffffffffffffffffffff16836114f9565b6040805173ffffffffffffffffffffffffffffffffffffffff84168152602081018390527f55350610fe57096d8c0ffa30beede987326bccfcb0b4415804164d0dd50ce8b1910160405180910390a15050565b6003546040517fd3078c9400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152426024830152600092839291169063d3078c949060440160206040518083038186803b15801561109f57600080fd5b505afa1580156110b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110d791906117d5565b90506000611153670de0b6b3a764000061080984600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630a3be7576040518163ffffffff1660e01b815260040160206040518083038186803b1580156107cb57600080fd5b90506111628162093a80611389565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314806111a7575060045473ffffffffffffffffffffffffffffffffffffffff1633145b61120d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064016103d3565b600480547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480611291575060045473ffffffffffffffffffffffffffffffffffffffff1633145b6112f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064016103d3565b600580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600061138083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611669565b90505b92915050565b60008261139857506000611383565b60006113a483856118ab565b9050826113b18583611872565b14611380576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60448201527f770000000000000000000000000000000000000000000000000000000000000060648201526084016103d3565b600061138083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506116bd565b60008061148d838561185a565b905083811015611380576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016103d3565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052915160009283929087169161159091906117ed565b6000604051808303816000865af19150503d80600081146115cd576040519150601f19603f3d011682016040523d82523d6000602084013e6115d2565b606091505b50915091508180156115fc5750805115806115fc5750808060200190518101906115fc91906117b9565b611662576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c45440060448201526064016103d3565b5050505050565b600081848411156116a7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d39190611809565b5060006116b484866118e8565b95945050505050565b600081836116f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d39190611809565b5060006116b48486611872565b803573ffffffffffffffffffffffffffffffffffffffff8116811461172957600080fd5b919050565b60006020828403121561173f578081fd5b61138082611705565b60008060006060848603121561175c578182fd5b61176584611705565b9250602084013561177581611997565b9150604084013561178581611997565b809150509250925092565b600080604083850312156117a2578182fd5b6117ab83611705565b946020939093013593505050565b6000602082840312156117ca578081fd5b815161138081611997565b6000602082840312156117e6578081fd5b5051919050565b600082516117ff8184602087016118ff565b9190910192915050565b60208152600082518060208401526118288160408501602087016118ff565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b6000821982111561186d5761186d611968565b500190565b6000826118a6577f4e487b710000000000000000000000000000000000000000000000000000000081526012600452602481fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156118e3576118e3611968565b500290565b6000828210156118fa576118fa611968565b500390565b60005b8381101561191a578181015183820152602001611902565b83811115611929576000848401525b50505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561196157611961611968565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80151581146119a557600080fd5b5056fea2646970667358221220a26a038e3b6187a26ab936fb43cab72516ed5af4a3d935602cd5cbba8a4cd36a64736f6c63430008040033000000000000000000000000234d953a9404bf9dbc3b526271d440cd2870bcd20000000000000000000000008412ebf45bac1b340bbe8f318b928c466c4e39ca00000000000000000000000073f9f84b04584227b4f0baffd8b37d6d0c11a23c0000000000000000000000003432b6a60d23ca0dfca7761b7ab56459d9c964d000000000000000000000000044ade9aa409b0c29463ff7fcf07c9d3c939166ce

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101355760003560e01c806379ba5097116100b2578063bdacb30311610081578063dc6663c711610066578063dc6663c7146102e1578063e81e17c614610301578063e90956cf1461032157600080fd5b8063bdacb303146102ae578063c92073c1146102c157600080fd5b806379ba5097146102525780638980f11f1461025a5780638da5cb5b1461026d5780639d18e4b01461028d57600080fd5b80632fd37b081161010957806353a47bb7116100ee57806353a47bb7146101d7578063570b1e991461021c5780636ca81c1c1461022f57600080fd5b80632fd37b08146101ac578063305d6d5f146101cf57600080fd5b806291d2b81461013a578063092193ab1461014f5780631627540c1461017c5780631f8a7edf1461018f575b600080fd5b61014d61014836600461172e565b610334565b005b61016261015d36600461172e565b610423565b604080519283526020830191909152015b60405180910390f35b61014d61018a36600461172e565b610a27565b60095461019c9060ff1681565b6040519015158152602001610173565b61019c6101ba36600461172e565b60066020526000908152604090205460ff1681565b61014d610b47565b6001546101f79073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610173565b61014d61022a366004611748565b610c77565b61019c61023d36600461172e565b60076020526000908152604090205460ff1681565b61014d610dc4565b61014d610268366004611790565b610f0f565b6000546101f79073ffffffffffffffffffffffffffffffffffffffff1681565b6102a061029b36600461172e565b61102a565b604051908152602001610173565b61014d6102bc36600461172e565b61116a565b6005546101f79073ffffffffffffffffffffffffffffffffffffffff1681565b6004546101f79073ffffffffffffffffffffffffffffffffffffffff1681565b6102a061030f36600461172e565b60086020526000908152604090205481565b61014d61032f36600461172e565b611254565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610371575060045473ffffffffffffffffffffffffffffffffffffffff1633145b6103dc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064015b60405180910390fd5b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600954600090819060ff161515600114610499576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f446973747269627574696f6e7320617265206f6666000000000000000000000060448201526064016103d3565b73ffffffffffffffffffffffffffffffffffffffff831660009081526006602052604090205460ff16610528576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4761756765206e6f742077686974656c6973746564000000000000000000000060448201526064016103d3565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600860205260409020548061055c57600192506105af565b73ffffffffffffffffffffffffffffffffffffffff841660009081526008602052604090205462093a809061059290429061133e565b61059c9190611872565b9250826105af5750600093849350915050565b6000915060005b8381101561083f57600081610677576003546040517f6472eee100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015242602483015290911690636472eee190604401602060405180830381600087803b15801561063857600080fd5b505af115801561064c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067091906117d5565b9050610751565b60035473ffffffffffffffffffffffffffffffffffffffff1663d3078c94876106ad6106a68662093a806118ab565b429061133e565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff9092166004830152602482015260440160206040518083038186803b15801561071657600080fd5b505afa15801561072a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061074e91906117d5565b90505b600061080f670de0b6b3a764000061080984600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630a3be7576040518163ffffffff1660e01b815260040160206040518083038186803b1580156107cb57600080fd5b505afa1580156107df573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080391906117d5565b90611389565b9061143e565b90506108286108218262093a80611389565b8690611480565b9450505080806108379061192f565b9150506105b6565b5073ffffffffffffffffffffffffffffffffffffffff84166000908152600860209081526040808320429055600790915290205460ff16156109ad576002546040517f095ea7b300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8681166004830152602482018590529091169063095ea7b390604401602060405180830381600087803b1580156108ef57600080fd5b505af1158015610903573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061092791906117b9565b506040517f4ae3decf0000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff851690634ae3decf90602401600060405180830381600087803b15801561099057600080fd5b505af11580156109a4573d6000803e3d6000fd5b505050506109d1565b6002546109d19073ffffffffffffffffffffffffffffffffffffffff1685846114f9565b8373ffffffffffffffffffffffffffffffffffffffff167fe34918ff1c7084970068b53fd71ad6d8b04e9f15d3886cbf006443e6cdc52ea683604051610a1991815260200190565b60405180910390a250915091565b60005473ffffffffffffffffffffffffffffffffffffffff163314610ace576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201527f6f726d207468697320616374696f6e000000000000000000000000000000000060648201526084016103d3565b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce229060200160405180910390a150565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610b84575060055473ffffffffffffffffffffffffffffffffffffffff1633145b80610ba6575060045473ffffffffffffffffffffffffffffffffffffffff1633145b610c0c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f4e6f74206f776e65722c2063757261746f722c206f722074696d656c6f636b0060448201526064016103d3565b6009805460ff808216157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0090921682179092556040519116151581527fa47e236370e478b9d163098c7c1f4f67b6efbb6683eeb0a669f04f302653779d9060200160405180910390a1565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610cb4575060045473ffffffffffffffffffffffffffffffffffffffff1633145b610d1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064016103d3565b73ffffffffffffffffffffffffffffffffffffffff8316600081815260076020908152604080832080548715157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff009182168117909255600684529382902080548715159516851790558151948552918401919091528201527f404f22d93b56a7e73713d7bbe543b016084d4d75b4d9177e8b8ab251f6e877d09060600160405180910390a1505050565b60015473ffffffffffffffffffffffffffffffffffffffff163314610e6b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527f2063616e20616363657074206f776e657273686970000000000000000000000060648201526084016103d3565b6000546001546040805173ffffffffffffffffffffffffffffffffffffffff93841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811673ffffffffffffffffffffffffffffffffffffffff841617909155169055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480610f4c575060045473ffffffffffffffffffffffffffffffffffffffff1633145b610fb2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064016103d3565b600054610fd790839073ffffffffffffffffffffffffffffffffffffffff16836114f9565b6040805173ffffffffffffffffffffffffffffffffffffffff84168152602081018390527f55350610fe57096d8c0ffa30beede987326bccfcb0b4415804164d0dd50ce8b1910160405180910390a15050565b6003546040517fd3078c9400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8381166004830152426024830152600092839291169063d3078c949060440160206040518083038186803b15801561109f57600080fd5b505afa1580156110b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110d791906117d5565b90506000611153670de0b6b3a764000061080984600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16630a3be7576040518163ffffffff1660e01b815260040160206040518083038186803b1580156107cb57600080fd5b90506111628162093a80611389565b949350505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314806111a7575060045473ffffffffffffffffffffffffffffffffffffffff1633145b61120d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064016103d3565b600480547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60005473ffffffffffffffffffffffffffffffffffffffff16331480611291575060045473ffffffffffffffffffffffffffffffffffffffff1633145b6112f7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f4e6f74206f776e6572206f722074696d656c6f636b000000000000000000000060448201526064016103d3565b600580547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600061138083836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611669565b90505b92915050565b60008261139857506000611383565b60006113a483856118ab565b9050826113b18583611872565b14611380576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60448201527f770000000000000000000000000000000000000000000000000000000000000060648201526084016103d3565b600061138083836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506116bd565b60008061148d838561185a565b905083811015611380576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f77000000000060448201526064016103d3565b6040805173ffffffffffffffffffffffffffffffffffffffff8481166024830152604480830185905283518084039091018152606490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb00000000000000000000000000000000000000000000000000000000179052915160009283929087169161159091906117ed565b6000604051808303816000865af19150503d80600081146115cd576040519150601f19603f3d011682016040523d82523d6000602084013e6115d2565b606091505b50915091508180156115fc5750805115806115fc5750808060200190518101906115fc91906117b9565b611662576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c45440060448201526064016103d3565b5050505050565b600081848411156116a7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d39190611809565b5060006116b484866118e8565b95945050505050565b600081836116f8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d39190611809565b5060006116b48486611872565b803573ffffffffffffffffffffffffffffffffffffffff8116811461172957600080fd5b919050565b60006020828403121561173f578081fd5b61138082611705565b60008060006060848603121561175c578182fd5b61176584611705565b9250602084013561177581611997565b9150604084013561178581611997565b809150509250925092565b600080604083850312156117a2578182fd5b6117ab83611705565b946020939093013593505050565b6000602082840312156117ca578081fd5b815161138081611997565b6000602082840312156117e6578081fd5b5051919050565b600082516117ff8184602087016118ff565b9190910192915050565b60208152600082518060208401526118288160408501602087016118ff565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b6000821982111561186d5761186d611968565b500190565b6000826118a6577f4e487b710000000000000000000000000000000000000000000000000000000081526012600452602481fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156118e3576118e3611968565b500290565b6000828210156118fa576118fa611968565b500390565b60005b8381101561191a578181015183820152602001611902565b83811115611929576000848401525b50505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561196157611961611968565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b80151581146119a557600080fd5b5056fea2646970667358221220a26a038e3b6187a26ab936fb43cab72516ed5af4a3d935602cd5cbba8a4cd36a64736f6c63430008040033

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

000000000000000000000000234d953a9404bf9dbc3b526271d440cd2870bcd20000000000000000000000008412ebf45bac1b340bbe8f318b928c466c4e39ca00000000000000000000000073f9f84b04584227b4f0baffd8b37d6d0c11a23c0000000000000000000000003432b6a60d23ca0dfca7761b7ab56459d9c964d000000000000000000000000044ade9aa409b0c29463ff7fcf07c9d3c939166ce

-----Decoded View---------------
Arg [0] : _owner (address): 0x234D953a9404Bf9DbC3b526271d440cD2870bCd2
Arg [1] : _timelock_address (address): 0x8412ebf45bAC1B340BbE8F318b928C466c4E39CA
Arg [2] : _curator_address (address): 0x73f9F84B04584227b4f0bafFd8B37D6D0C11a23c
Arg [3] : _reward_token_address (address): 0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0
Arg [4] : _gauge_controller_address (address): 0x44ade9AA409B0C29463fF7fcf07c9d3c939166ce

-----Encoded View---------------
5 Constructor Arguments found :
Arg [0] : 000000000000000000000000234d953a9404bf9dbc3b526271d440cd2870bcd2
Arg [1] : 0000000000000000000000008412ebf45bac1b340bbe8f318b928c466c4e39ca
Arg [2] : 00000000000000000000000073f9f84b04584227b4f0baffd8b37d6d0c11a23c
Arg [3] : 0000000000000000000000003432b6a60d23ca0dfca7761b7ab56459d9c964d0
Arg [4] : 00000000000000000000000044ade9aa409b0c29463ff7fcf07c9d3c939166ce


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.