Contract 0xC5be2c918EB04B091962fDF095A217A55CFA42C5 1

 
Txn Hash Method
Index
From
To
Value
0x9736a3d9ac1adf09911434dde3177861366a8673591a6e8fa6a54c6c96daf82c0x60806040100786682022-06-01 20:01:38121 days 3 hrs agoVelodrome Finance: Deployer IN  Create: GaugeFactory0 Ether0.0268401259840.001
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x01201a4a92906d697f5375633399778eebd218df7bdd083cbc5b1093e4ad9ea7263351552022-09-29 20:53:321 day 2 hrs ago 0xc5be2c918eb04b091962fdf095a217a55cfa42c5  Contract Creation0 Ether
0x01201a4a92906d697f5375633399778eebd218df7bdd083cbc5b1093e4ad9ea7263351552022-09-29 20:53:321 day 2 hrs ago 0x09236cff45047dbee6b921e00704bed6d6b8cf7e 0xc5be2c918eb04b091962fdf095a217a55cfa42c50 Ether
0x5dbaafd6eb7cb5a510f473bf67c110a3032196bde37a30b9c32095fce6535f40259155922022-09-28 6:27:412 days 16 hrs ago 0xc5be2c918eb04b091962fdf095a217a55cfa42c5  Contract Creation0 Ether
0x5dbaafd6eb7cb5a510f473bf67c110a3032196bde37a30b9c32095fce6535f40259155922022-09-28 6:27:412 days 16 hrs ago 0x09236cff45047dbee6b921e00704bed6d6b8cf7e 0xc5be2c918eb04b091962fdf095a217a55cfa42c50 Ether
0x571f894cf57ba4cb1adbb5141c2fc757f354077128c4b3a1f45f0813b3d82a75257442822022-09-27 11:43:063 days 11 hrs ago 0xc5be2c918eb04b091962fdf095a217a55cfa42c5  Contract Creation0 Ether
0x571f894cf57ba4cb1adbb5141c2fc757f354077128c4b3a1f45f0813b3d82a75257442822022-09-27 11:43:063 days 11 hrs ago 0x09236cff45047dbee6b921e00704bed6d6b8cf7e 0xc5be2c918eb04b091962fdf095a217a55cfa42c50 Ether
0x13375016c59f88af8366686426afe877c54d104839a3066c9da0711355c2f840257082382022-09-27 7:40:433 days 15 hrs ago 0xc5be2c918eb04b091962fdf095a217a55cfa42c5  Contract Creation0 Ether
0x13375016c59f88af8366686426afe877c54d104839a3066c9da0711355c2f840257082382022-09-27 7:40:433 days 15 hrs ago 0x09236cff45047dbee6b921e00704bed6d6b8cf7e 0xc5be2c918eb04b091962fdf095a217a55cfa42c50 Ether
0x7f3c1c1f516ecd94df679c5635f517aef17e78e6d01f7f7b4243e989006a8cca256098622022-09-26 17:24:234 days 5 hrs ago 0xc5be2c918eb04b091962fdf095a217a55cfa42c5  Contract Creation0 Ether
0x7f3c1c1f516ecd94df679c5635f517aef17e78e6d01f7f7b4243e989006a8cca256098622022-09-26 17:24:234 days 5 hrs ago 0x09236cff45047dbee6b921e00704bed6d6b8cf7e 0xc5be2c918eb04b091962fdf095a217a55cfa42c50 Ether
0x96dcab4171bb6a83972b2655722b58df9381036206f6a74ee033abed6f5ed890255728862022-09-26 13:51:134 days 9 hrs ago 0xc5be2c918eb04b091962fdf095a217a55cfa42c5  Contract Creation0 Ether
0x96dcab4171bb6a83972b2655722b58df9381036206f6a74ee033abed6f5ed890255728862022-09-26 13:51:134 days 9 hrs ago 0x09236cff45047dbee6b921e00704bed6d6b8cf7e 0xc5be2c918eb04b091962fdf095a217a55cfa42c50 Ether
0xb8b751b1840b1217a61cc136c90a9f20c5433a43fd84dcb0e4f27dfa0fe88b66253577502022-09-25 15:49:075 days 7 hrs ago 0xc5be2c918eb04b091962fdf095a217a55cfa42c5  Contract Creation0 Ether
0xb8b751b1840b1217a61cc136c90a9f20c5433a43fd84dcb0e4f27dfa0fe88b66253577502022-09-25 15:49:075 days 7 hrs ago 0x09236cff45047dbee6b921e00704bed6d6b8cf7e 0xc5be2c918eb04b091962fdf095a217a55cfa42c50 Ether
0x431e037f61798cb3f23c2ce104033b39cb4c9dee6fef0429d8b5b9945925b72a247786042022-09-23 7:45:477 days 15 hrs ago 0xc5be2c918eb04b091962fdf095a217a55cfa42c5  Contract Creation0 Ether
0x431e037f61798cb3f23c2ce104033b39cb4c9dee6fef0429d8b5b9945925b72a247786042022-09-23 7:45:477 days 15 hrs ago 0x09236cff45047dbee6b921e00704bed6d6b8cf7e 0xc5be2c918eb04b091962fdf095a217a55cfa42c50 Ether
0x85f1409a904adf0582a5d98e330def69c3c33f2e16215ac91b0b980fcc09868e244500502022-09-22 5:48:108 days 17 hrs ago 0xc5be2c918eb04b091962fdf095a217a55cfa42c5  Contract Creation0 Ether
0x85f1409a904adf0582a5d98e330def69c3c33f2e16215ac91b0b980fcc09868e244500502022-09-22 5:48:108 days 17 hrs ago 0x09236cff45047dbee6b921e00704bed6d6b8cf7e 0xc5be2c918eb04b091962fdf095a217a55cfa42c50 Ether
0xac3cfc5462191ed5ef2c0d9beaa4f4dce89b3c65b38e42142816afab10afc19e244497392022-09-22 5:46:258 days 17 hrs ago 0xc5be2c918eb04b091962fdf095a217a55cfa42c5  Contract Creation0 Ether
0xac3cfc5462191ed5ef2c0d9beaa4f4dce89b3c65b38e42142816afab10afc19e244497392022-09-22 5:46:258 days 17 hrs ago 0x09236cff45047dbee6b921e00704bed6d6b8cf7e 0xc5be2c918eb04b091962fdf095a217a55cfa42c50 Ether
0x9e40d206ef0213810d909f4924676dc6c134bcacf811020b0882cc7dfc500723244224962022-09-22 2:57:058 days 20 hrs ago 0xc5be2c918eb04b091962fdf095a217a55cfa42c5  Contract Creation0 Ether
0x9e40d206ef0213810d909f4924676dc6c134bcacf811020b0882cc7dfc500723244224962022-09-22 2:57:058 days 20 hrs ago 0x09236cff45047dbee6b921e00704bed6d6b8cf7e 0xc5be2c918eb04b091962fdf095a217a55cfa42c50 Ether
0xe3d05f66fffce8c557527f52a71c44bacf4340843ff40e42f3a5f13307d85719242231552022-09-21 13:03:399 days 10 hrs ago 0xc5be2c918eb04b091962fdf095a217a55cfa42c5  Contract Creation0 Ether
0xe3d05f66fffce8c557527f52a71c44bacf4340843ff40e42f3a5f13307d85719242231552022-09-21 13:03:399 days 10 hrs ago 0x09236cff45047dbee6b921e00704bed6d6b8cf7e 0xc5be2c918eb04b091962fdf095a217a55cfa42c50 Ether
0xbfee05b92ed134950ed39756828eabd8e5915ef19f3465c771f365f311c97c80237451072022-09-19 11:51:4111 days 11 hrs ago 0xc5be2c918eb04b091962fdf095a217a55cfa42c5  Contract Creation0 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
GaugeFactory

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 10 : GaugeFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

import 'contracts/interfaces/IGaugeFactory.sol';
import 'contracts/Gauge.sol';

contract GaugeFactory is IGaugeFactory {
    address public last_gauge;

    function createGauge(address _pool, address _internal_bribe, address _external_bribe, address _ve, bool isPair, address[] memory allowedRewards) external returns (address) {
        last_gauge = address(new Gauge(_pool, _internal_bribe, _external_bribe, _ve, msg.sender, isPair, allowedRewards));
        return last_gauge;
    }
}

File 2 of 10 : IGaugeFactory.sol
pragma solidity 0.8.13;

interface IGaugeFactory {
    function createGauge(address, address, address, address, bool, address[] memory) external returns (address);
}

File 3 of 10 : Gauge.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

import 'contracts/libraries/Math.sol';
import 'contracts/interfaces/IBribe.sol';
import 'contracts/interfaces/IERC20.sol';
import 'contracts/interfaces/IGauge.sol';
import 'contracts/interfaces/IPair.sol';
import 'contracts/interfaces/IVoter.sol';
import 'contracts/interfaces/IVotingEscrow.sol';

// Gauges are used to incentivize pools, they emit reward tokens over 7 days for staked LP tokens
contract Gauge is IGauge {

    address public immutable stake; // the LP token that needs to be staked for rewards
    address public immutable _ve; // the ve token used for gauges
    address public immutable internal_bribe;
    address public immutable external_bribe;
    address public immutable voter;

    uint public derivedSupply;
    mapping(address => uint) public derivedBalances;

    bool public isForPair;

    uint internal constant DURATION = 7 days; // rewards are released over 7 days
    uint internal constant PRECISION = 10 ** 18;
    uint internal constant MAX_REWARD_TOKENS = 16;

    // default snx staking contract implementation
    mapping(address => uint) public rewardRate;
    mapping(address => uint) public periodFinish;
    mapping(address => uint) public lastUpdateTime;
    mapping(address => uint) public rewardPerTokenStored;

    mapping(address => mapping(address => uint)) public lastEarn;
    mapping(address => mapping(address => uint)) public userRewardPerTokenStored;

    mapping(address => uint) public tokenIds;

    uint public totalSupply;
    mapping(address => uint) public balanceOf;

    address[] public rewards;
    mapping(address => bool) public isReward;

    /// @notice A checkpoint for marking balance
    struct Checkpoint {
        uint timestamp;
        uint balanceOf;
    }

    /// @notice A checkpoint for marking reward rate
    struct RewardPerTokenCheckpoint {
        uint timestamp;
        uint rewardPerToken;
    }

    /// @notice A checkpoint for marking supply
    struct SupplyCheckpoint {
        uint timestamp;
        uint supply;
    }

    /// @notice A record of balance checkpoints for each account, by index
    mapping (address => mapping (uint => Checkpoint)) public checkpoints;
    /// @notice The number of checkpoints for each account
    mapping (address => uint) public numCheckpoints;
    /// @notice A record of balance checkpoints for each token, by index
    mapping (uint => SupplyCheckpoint) public supplyCheckpoints;
    /// @notice The number of checkpoints
    uint public supplyNumCheckpoints;
    /// @notice A record of balance checkpoints for each token, by index
    mapping (address => mapping (uint => RewardPerTokenCheckpoint)) public rewardPerTokenCheckpoints;
    /// @notice The number of checkpoints for each token
    mapping (address => uint) public rewardPerTokenNumCheckpoints;

    uint public fees0;
    uint public fees1;

    event Deposit(address indexed from, uint tokenId, uint amount);
    event Withdraw(address indexed from, uint tokenId, uint amount);
    event NotifyReward(address indexed from, address indexed reward, uint amount);
    event ClaimFees(address indexed from, uint claimed0, uint claimed1);
    event ClaimRewards(address indexed from, address indexed reward, uint amount);

    constructor(address _stake, address _internal_bribe, address _external_bribe, address  __ve, address _voter, bool _forPair, address[] memory _allowedRewardTokens) {
        stake = _stake;
        internal_bribe = _internal_bribe;
        external_bribe = _external_bribe;
        _ve = __ve;
        voter = _voter;
        isForPair = _forPair;

        for (uint i; i < _allowedRewardTokens.length; i++) {
            if (_allowedRewardTokens[i] != address(0)) {
                isReward[_allowedRewardTokens[i]] = true;
                rewards.push(_allowedRewardTokens[i]);
            }
        }
    }

    // simple re-entrancy check
    uint internal _unlocked = 1;
    modifier lock() {
        require(_unlocked == 1);
        _unlocked = 2;
        _;
        _unlocked = 1;
    }

    function claimFees() external lock returns (uint claimed0, uint claimed1) {
        return _claimFees();
    }

    function _claimFees() internal returns (uint claimed0, uint claimed1) {
        if (!isForPair) {
            return (0, 0);
        }
        (claimed0, claimed1) = IPair(stake).claimFees();
        if (claimed0 > 0 || claimed1 > 0) {
            uint _fees0 = fees0 + claimed0;
            uint _fees1 = fees1 + claimed1;
            (address _token0, address _token1) = IPair(stake).tokens();
            if (_fees0 > IBribe(internal_bribe).left(_token0) && _fees0 / DURATION > 0) {
                fees0 = 0;
                _safeApprove(_token0, internal_bribe, _fees0);
                IBribe(internal_bribe).notifyRewardAmount(_token0, _fees0);
            } else {
                fees0 = _fees0;
            }
            if (_fees1 > IBribe(internal_bribe).left(_token1) && _fees1 / DURATION > 0) {
                fees1 = 0;
                _safeApprove(_token1, internal_bribe, _fees1);
                IBribe(internal_bribe).notifyRewardAmount(_token1, _fees1);
            } else {
                fees1 = _fees1;
            }

            emit ClaimFees(msg.sender, claimed0, claimed1);
        }
    }

    /**
    * @notice Determine the prior balance for an account as of a block number
    * @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
    * @param account The address of the account to check
    * @param timestamp The timestamp to get the balance at
    * @return The balance the account had as of the given block
    */
    function getPriorBalanceIndex(address account, uint timestamp) public view returns (uint) {
        uint nCheckpoints = numCheckpoints[account];
        if (nCheckpoints == 0) {
            return 0;
        }

        // First check most recent balance
        if (checkpoints[account][nCheckpoints - 1].timestamp <= timestamp) {
            return (nCheckpoints - 1);
        }

        // Next check implicit zero balance
        if (checkpoints[account][0].timestamp > timestamp) {
            return 0;
        }

        uint lower = 0;
        uint upper = nCheckpoints - 1;
        while (upper > lower) {
            uint center = upper - (upper - lower) / 2; // ceil, avoiding overflow
            Checkpoint memory cp = checkpoints[account][center];
            if (cp.timestamp == timestamp) {
                return center;
            } else if (cp.timestamp < timestamp) {
                lower = center;
            } else {
                upper = center - 1;
            }
        }
        return lower;
    }

    function getPriorSupplyIndex(uint timestamp) public view returns (uint) {
        uint nCheckpoints = supplyNumCheckpoints;
        if (nCheckpoints == 0) {
            return 0;
        }

        // First check most recent balance
        if (supplyCheckpoints[nCheckpoints - 1].timestamp <= timestamp) {
            return (nCheckpoints - 1);
        }

        // Next check implicit zero balance
        if (supplyCheckpoints[0].timestamp > timestamp) {
            return 0;
        }

        uint lower = 0;
        uint upper = nCheckpoints - 1;
        while (upper > lower) {
            uint center = upper - (upper - lower) / 2; // ceil, avoiding overflow
            SupplyCheckpoint memory cp = supplyCheckpoints[center];
            if (cp.timestamp == timestamp) {
                return center;
            } else if (cp.timestamp < timestamp) {
                lower = center;
            } else {
                upper = center - 1;
            }
        }
        return lower;
    }

    function getPriorRewardPerToken(address token, uint timestamp) public view returns (uint, uint) {
        uint nCheckpoints = rewardPerTokenNumCheckpoints[token];
        if (nCheckpoints == 0) {
            return (0,0);
        }

        // First check most recent balance
        if (rewardPerTokenCheckpoints[token][nCheckpoints - 1].timestamp <= timestamp) {
            return (rewardPerTokenCheckpoints[token][nCheckpoints - 1].rewardPerToken, rewardPerTokenCheckpoints[token][nCheckpoints - 1].timestamp);
        }

        // Next check implicit zero balance
        if (rewardPerTokenCheckpoints[token][0].timestamp > timestamp) {
            return (0,0);
        }

        uint lower = 0;
        uint upper = nCheckpoints - 1;
        while (upper > lower) {
            uint center = upper - (upper - lower) / 2; // ceil, avoiding overflow
            RewardPerTokenCheckpoint memory cp = rewardPerTokenCheckpoints[token][center];
            if (cp.timestamp == timestamp) {
                return (cp.rewardPerToken, cp.timestamp);
            } else if (cp.timestamp < timestamp) {
                lower = center;
            } else {
                upper = center - 1;
            }
        }
        return (rewardPerTokenCheckpoints[token][lower].rewardPerToken, rewardPerTokenCheckpoints[token][lower].timestamp);
    }

    function _writeCheckpoint(address account, uint balance) internal {
        uint _timestamp = block.timestamp;
        uint _nCheckPoints = numCheckpoints[account];

        if (_nCheckPoints > 0 && checkpoints[account][_nCheckPoints - 1].timestamp == _timestamp) {
            checkpoints[account][_nCheckPoints - 1].balanceOf = balance;
        } else {
            checkpoints[account][_nCheckPoints] = Checkpoint(_timestamp, balance);
            numCheckpoints[account] = _nCheckPoints + 1;
        }
    }

    function _writeRewardPerTokenCheckpoint(address token, uint reward, uint timestamp) internal {
        uint _nCheckPoints = rewardPerTokenNumCheckpoints[token];

        if (_nCheckPoints > 0 && rewardPerTokenCheckpoints[token][_nCheckPoints - 1].timestamp == timestamp) {
            rewardPerTokenCheckpoints[token][_nCheckPoints - 1].rewardPerToken = reward;
        } else {
            rewardPerTokenCheckpoints[token][_nCheckPoints] = RewardPerTokenCheckpoint(timestamp, reward);
            rewardPerTokenNumCheckpoints[token] = _nCheckPoints + 1;
        }
    }

    function _writeSupplyCheckpoint() internal {
        uint _nCheckPoints = supplyNumCheckpoints;
        uint _timestamp = block.timestamp;

        if (_nCheckPoints > 0 && supplyCheckpoints[_nCheckPoints - 1].timestamp == _timestamp) {
            supplyCheckpoints[_nCheckPoints - 1].supply = derivedSupply;
        } else {
            supplyCheckpoints[_nCheckPoints] = SupplyCheckpoint(_timestamp, derivedSupply);
            supplyNumCheckpoints = _nCheckPoints + 1;
        }
    }

    function rewardsListLength() external view returns (uint) {
        return rewards.length;
    }

    // returns the last time the reward was modified or periodFinish if the reward has ended
    function lastTimeRewardApplicable(address token) public view returns (uint) {
        return Math.min(block.timestamp, periodFinish[token]);
    }

    function getReward(address account, address[] memory tokens) external lock {
        require(msg.sender == account || msg.sender == voter);
        _unlocked = 1;
        IVoter(voter).distribute(address(this));
        _unlocked = 2;

        for (uint i = 0; i < tokens.length; i++) {
            (rewardPerTokenStored[tokens[i]], lastUpdateTime[tokens[i]]) = _updateRewardPerToken(tokens[i], type(uint).max, true);

            uint _reward = earned(tokens[i], account);
            lastEarn[tokens[i]][account] = block.timestamp;
            userRewardPerTokenStored[tokens[i]][account] = rewardPerTokenStored[tokens[i]];
            if (_reward > 0) _safeTransfer(tokens[i], account, _reward);

            emit ClaimRewards(msg.sender, tokens[i], _reward);
        }

        uint _derivedBalance = derivedBalances[account];
        derivedSupply -= _derivedBalance;
        _derivedBalance = derivedBalance(account);
        derivedBalances[account] = _derivedBalance;
        derivedSupply += _derivedBalance;

        _writeCheckpoint(account, derivedBalances[account]);
        _writeSupplyCheckpoint();
    }


    function rewardPerToken(address token) public view returns (uint) {
        if (derivedSupply == 0) {
            return rewardPerTokenStored[token];
        }
        return rewardPerTokenStored[token] + ((lastTimeRewardApplicable(token) - Math.min(lastUpdateTime[token], periodFinish[token])) * rewardRate[token] * PRECISION / derivedSupply);
    }

    function derivedBalance(address account) public view returns (uint) {
        return balanceOf[account];
    }

    function batchRewardPerToken(address token, uint maxRuns) external {
        (rewardPerTokenStored[token], lastUpdateTime[token])  = _batchRewardPerToken(token, maxRuns);
    }

    function _batchRewardPerToken(address token, uint maxRuns) internal returns (uint, uint) {
        uint _startTimestamp = lastUpdateTime[token];
        uint reward = rewardPerTokenStored[token];

        if (supplyNumCheckpoints == 0) {
            return (reward, _startTimestamp);
        }

        if (rewardRate[token] == 0) {
            return (reward, block.timestamp);
        }

        uint _startIndex = getPriorSupplyIndex(_startTimestamp);
        uint _endIndex = Math.min(supplyNumCheckpoints-1, maxRuns);

        for (uint i = _startIndex; i < _endIndex; i++) {
            SupplyCheckpoint memory sp0 = supplyCheckpoints[i];
            if (sp0.supply > 0) {
                SupplyCheckpoint memory sp1 = supplyCheckpoints[i+1];
                (uint _reward, uint _endTime) = _calcRewardPerToken(token, sp1.timestamp, sp0.timestamp, sp0.supply, _startTimestamp);
                reward += _reward;
                _writeRewardPerTokenCheckpoint(token, reward, _endTime);
                _startTimestamp = _endTime;
            }
        }

        return (reward, _startTimestamp);
    }

    function _calcRewardPerToken(address token, uint timestamp1, uint timestamp0, uint supply, uint startTimestamp) internal view returns (uint, uint) {
        uint endTime = Math.max(timestamp1, startTimestamp);
        return (((Math.min(endTime, periodFinish[token]) - Math.min(Math.max(timestamp0, startTimestamp), periodFinish[token])) * rewardRate[token] * PRECISION / supply), endTime);
    }

    /// @dev Update stored rewardPerToken values without the last one snapshot
    ///      If the contract will get "out of gas" error on users actions this will be helpful
    function batchUpdateRewardPerToken(address token, uint maxRuns) external {
      (rewardPerTokenStored[token], lastUpdateTime[token]) = _updateRewardPerToken(token, maxRuns, false);
    }

    function _updateRewardForAllTokens() internal {
      uint length = rewards.length;
      for (uint i; i < length; i++) {
        address token = rewards[i];
        (rewardPerTokenStored[token], lastUpdateTime[token]) = _updateRewardPerToken(token, type(uint).max, true);
      }
    }

    function _updateRewardPerToken(address token, uint maxRuns, bool actualLast) internal returns (uint, uint) {
        uint _startTimestamp = lastUpdateTime[token];
        uint reward = rewardPerTokenStored[token];

        if (supplyNumCheckpoints == 0) {
            return (reward, _startTimestamp);
        }

        if (rewardRate[token] == 0) {
            return (reward, block.timestamp);
        }

        uint _startIndex = getPriorSupplyIndex(_startTimestamp);
        uint _endIndex = Math.min(supplyNumCheckpoints - 1, maxRuns);

        if (_endIndex > 0) {
            for (uint i = _startIndex; i <= _endIndex - 1; i++) {
                SupplyCheckpoint memory sp0 = supplyCheckpoints[i];
                if (sp0.supply > 0) {
                    SupplyCheckpoint memory sp1 = supplyCheckpoints[i+1];
                    (uint _reward, uint _endTime) = _calcRewardPerToken(token, sp1.timestamp, sp0.timestamp, sp0.supply, _startTimestamp);
                    reward += _reward;
                    _writeRewardPerTokenCheckpoint(token, reward, _endTime);
                    _startTimestamp = _endTime;
                }
            }
        }

        // need to override the last value with actual numbers only on deposit/withdraw/claim/notify actions
        if (actualLast) {
            SupplyCheckpoint memory sp = supplyCheckpoints[_endIndex];
            if (sp.supply > 0) {
                (uint _reward,) = _calcRewardPerToken(token, lastTimeRewardApplicable(token), Math.max(sp.timestamp, _startTimestamp), sp.supply, _startTimestamp);
                reward += _reward;
                _writeRewardPerTokenCheckpoint(token, reward, block.timestamp);
                _startTimestamp = block.timestamp;
            }
        }

        return (reward, _startTimestamp);
    }

    // earned is an estimation, it won't be exact till the supply > rewardPerToken calculations have run
    function earned(address token, address account) public view returns (uint) {
        uint _startTimestamp = Math.max(lastEarn[token][account], rewardPerTokenCheckpoints[token][0].timestamp);
        if (numCheckpoints[account] == 0) {
            return 0;
        }

        uint _startIndex = getPriorBalanceIndex(account, _startTimestamp);
        uint _endIndex = numCheckpoints[account]-1;

        uint reward = 0;

        if (_endIndex > 0) {
            for (uint i = _startIndex; i <= _endIndex-1; i++) {
                Checkpoint memory cp0 = checkpoints[account][i];
                Checkpoint memory cp1 = checkpoints[account][i+1];
                (uint _rewardPerTokenStored0,) = getPriorRewardPerToken(token, cp0.timestamp);
                (uint _rewardPerTokenStored1,) = getPriorRewardPerToken(token, cp1.timestamp);
                reward += cp0.balanceOf * (_rewardPerTokenStored1 - _rewardPerTokenStored0) / PRECISION;
            }
        }

        Checkpoint memory cp = checkpoints[account][_endIndex];
        (uint _rewardPerTokenStored,) = getPriorRewardPerToken(token, cp.timestamp);
        reward += cp.balanceOf * (rewardPerToken(token) - Math.max(_rewardPerTokenStored, userRewardPerTokenStored[token][account])) / PRECISION;

        return reward;
    }

    function depositAll(uint tokenId) external {
        deposit(IERC20(stake).balanceOf(msg.sender), tokenId);
    }

    function deposit(uint amount, uint tokenId) public lock {
        require(amount > 0);
        _updateRewardForAllTokens();

        _safeTransferFrom(stake, msg.sender, address(this), amount);
        totalSupply += amount;
        balanceOf[msg.sender] += amount;

        if (tokenId > 0) {
            require(IVotingEscrow(_ve).ownerOf(tokenId) == msg.sender);
            if (tokenIds[msg.sender] == 0) {
                tokenIds[msg.sender] = tokenId;
                IVoter(voter).attachTokenToGauge(tokenId, msg.sender);
            }
            require(tokenIds[msg.sender] == tokenId);
        } else {
            tokenId = tokenIds[msg.sender];
        }

        uint _derivedBalance = derivedBalances[msg.sender];
        derivedSupply -= _derivedBalance;
        _derivedBalance = derivedBalance(msg.sender);
        derivedBalances[msg.sender] = _derivedBalance;
        derivedSupply += _derivedBalance;

        _writeCheckpoint(msg.sender, _derivedBalance);
        _writeSupplyCheckpoint();

        IVoter(voter).emitDeposit(tokenId, msg.sender, amount);
        emit Deposit(msg.sender, tokenId, amount);
    }

    function withdrawAll() external {
        withdraw(balanceOf[msg.sender]);
    }

    function withdraw(uint amount) public {
        uint tokenId = 0;
        if (amount == balanceOf[msg.sender]) {
            tokenId = tokenIds[msg.sender];
        }
        withdrawToken(amount, tokenId);
    }

    function withdrawToken(uint amount, uint tokenId) public lock {
        _updateRewardForAllTokens();

        totalSupply -= amount;
        balanceOf[msg.sender] -= amount;
        _safeTransfer(stake, msg.sender, amount);

        if (tokenId > 0) {
            require(tokenId == tokenIds[msg.sender]);
            tokenIds[msg.sender] = 0;
            IVoter(voter).detachTokenFromGauge(tokenId, msg.sender);
        } else {
            tokenId = tokenIds[msg.sender];
        }

        uint _derivedBalance = derivedBalances[msg.sender];
        derivedSupply -= _derivedBalance;
        _derivedBalance = derivedBalance(msg.sender);
        derivedBalances[msg.sender] = _derivedBalance;
        derivedSupply += _derivedBalance;

        _writeCheckpoint(msg.sender, derivedBalances[msg.sender]);
        _writeSupplyCheckpoint();

        IVoter(voter).emitWithdraw(tokenId, msg.sender, amount);
        emit Withdraw(msg.sender, tokenId, amount);
    }

    function left(address token) external view returns (uint) {
        if (block.timestamp >= periodFinish[token]) return 0;
        uint _remaining = periodFinish[token] - block.timestamp;
        return _remaining * rewardRate[token];
    }

    function notifyRewardAmount(address token, uint amount) external lock {
        require(token != stake);
        require(amount > 0);
        if (!isReward[token]) {
            require(IVoter(voter).isWhitelisted(token), "rewards tokens must be whitelisted");
            require(rewards.length < MAX_REWARD_TOKENS, "too many rewards tokens");
        }
        if (rewardRate[token] == 0) _writeRewardPerTokenCheckpoint(token, 0, block.timestamp);
        (rewardPerTokenStored[token], lastUpdateTime[token]) = _updateRewardPerToken(token, type(uint).max, true);
        _claimFees();

        if (block.timestamp >= periodFinish[token]) {
            _safeTransferFrom(token, msg.sender, address(this), amount);
            rewardRate[token] = amount / DURATION;
        } else {
            uint _remaining = periodFinish[token] - block.timestamp;
            uint _left = _remaining * rewardRate[token];
            require(amount > _left);
            _safeTransferFrom(token, msg.sender, address(this), amount);
            rewardRate[token] = (amount + _left) / DURATION;
        }
        require(rewardRate[token] > 0);
        uint balance = IERC20(token).balanceOf(address(this));
        require(rewardRate[token] <= balance / DURATION, "Provided reward too high");
        periodFinish[token] = block.timestamp + DURATION;
        if (!isReward[token]) {
            isReward[token] = true;
            rewards.push(token);
        }

        emit NotifyReward(msg.sender, token, amount);
    }

    function swapOutRewardToken(uint i, address oldToken, address newToken) external {
        require(msg.sender == IVotingEscrow(_ve).team(), 'only team');
        require(rewards[i] == oldToken);
        isReward[oldToken] = false;
        isReward[newToken] = true;
        rewards[i] = newToken;
    }

    function _safeTransfer(address token, address to, uint256 value) internal {
        require(token.code.length > 0);
        (bool success, bytes memory data) =
        token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))));
    }

    function _safeTransferFrom(address token, address from, address to, uint256 value) internal {
        require(token.code.length > 0);
        (bool success, bytes memory data) =
        token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))));
    }

    function _safeApprove(address token, address spender, uint256 value) internal {
        require(token.code.length > 0);
        (bool success, bytes memory data) =
        token.call(abi.encodeWithSelector(IERC20.approve.selector, spender, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))));
    }
}

File 4 of 10 : Math.sol
pragma solidity 0.8.13;

library Math {
    function max(uint a, uint b) internal pure returns (uint) {
        return a >= b ? a : b;
    }
    function min(uint a, uint b) internal pure returns (uint) {
        return a < b ? a : b;
    }
    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;
        }
    }
    function cbrt(uint256 n) internal pure returns (uint256) { unchecked {
        uint256 x = 0;
        for (uint256 y = 1 << 255; y > 0; y >>= 3) {
            x <<= 1;
            uint256 z = 3 * x * (x + 1) + 1;
            if (n / y >= z) {
                n -= y * z;
                x += 1;
            }
        }
        return x;
    }}
}

File 5 of 10 : IBribe.sol
pragma solidity 0.8.13;

interface IBribe {
    function _deposit(uint amount, uint tokenId) external;
    function _withdraw(uint amount, uint tokenId) external;
    function getRewardForOwner(uint tokenId, address[] memory tokens) external;
    function notifyRewardAmount(address token, uint amount) external;
    function left(address token) external view returns (uint);
}

File 6 of 10 : IERC20.sol
pragma solidity 0.8.13;

interface IERC20 {
    function totalSupply() external view returns (uint256);
    function transfer(address recipient, uint amount) external returns (bool);
    function decimals() external view returns (uint8);
    function symbol() external view returns (string memory);
    function balanceOf(address) external view returns (uint);
    function transferFrom(address sender, address recipient, uint amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint);
    function approve(address spender, uint value) external returns (bool);

    event Transfer(address indexed from, address indexed to, uint value);
    event Approval(address indexed owner, address indexed spender, uint value);
}

File 7 of 10 : IGauge.sol
pragma solidity 0.8.13;

interface IGauge {
    function notifyRewardAmount(address token, uint amount) external;
    function getReward(address account, address[] memory tokens) external;
    function claimFees() external returns (uint claimed0, uint claimed1);
    function left(address token) external view returns (uint);
    function isForPair() external view returns (bool);
}

File 8 of 10 : IPair.sol
pragma solidity 0.8.13;

interface IPair {
    function metadata() external view returns (uint dec0, uint dec1, uint r0, uint r1, bool st, address t0, address t1);
    function claimFees() external returns (uint, uint);
    function tokens() external returns (address, address);
    function transferFrom(address src, address dst, uint amount) external returns (bool);
    function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
    function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
    function burn(address to) external returns (uint amount0, uint amount1);
    function mint(address to) external returns (uint liquidity);
    function getReserves() external view returns (uint _reserve0, uint _reserve1, uint _blockTimestampLast);
    function getAmountOut(uint, address) external view returns (uint);
}

File 9 of 10 : IVoter.sol
pragma solidity 0.8.13;

interface IVoter {
    function _ve() external view returns (address);
    function governor() external view returns (address);
    function emergencyCouncil() external view returns (address);
    function attachTokenToGauge(uint _tokenId, address account) external;
    function detachTokenFromGauge(uint _tokenId, address account) external;
    function emitDeposit(uint _tokenId, address account, uint amount) external;
    function emitWithdraw(uint _tokenId, address account, uint amount) external;
    function isWhitelisted(address token) external view returns (bool);
    function notifyRewardAmount(uint amount) external;
    function distribute(address _gauge) external;
}

File 10 of 10 : IVotingEscrow.sol
pragma solidity 0.8.13;

interface IVotingEscrow {

    struct Point {
        int128 bias;
        int128 slope; // # -dweight / dt
        uint256 ts;
        uint256 blk; // block
    }

    function token() external view returns (address);
    function team() external returns (address);
    function epoch() external view returns (uint);
    function point_history(uint loc) external view returns (Point memory);
    function user_point_history(uint tokenId, uint loc) external view returns (Point memory);
    function user_point_epoch(uint tokenId) external view returns (uint);

    function ownerOf(uint) external view returns (address);
    function isApprovedOrOwner(address, uint) external view returns (bool);
    function transferFrom(address, address, uint) external;

    function voting(uint tokenId) external;
    function abstain(uint tokenId) external;
    function attach(uint tokenId) external;
    function detach(uint tokenId) external;

    function checkpoint() external;
    function deposit_for(uint tokenId, uint value) external;
    function create_lock_for(uint, uint, address) external returns (uint);

    function balanceOfNFT(uint) external view returns (uint);
    function totalSupply() external view returns (uint);
}

Settings
{
  "remappings": [
    "LayerZero/=lib/LayerZero/contracts/",
    "ds-test/=lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solmate/=lib/solmate/src/",
    "utils/=test/utils/",
    "contracts/=contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london"
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_pool","type":"address"},{"internalType":"address","name":"_internal_bribe","type":"address"},{"internalType":"address","name":"_external_bribe","type":"address"},{"internalType":"address","name":"_ve","type":"address"},{"internalType":"bool","name":"isPair","type":"bool"},{"internalType":"address[]","name":"allowedRewards","type":"address[]"}],"name":"createGauge","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"last_gauge","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50613b19806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80630bc25f4f1461003b578063730a8bdb1461006a575b600080fd5b61004e610049366004610128565b61007d565b6040516001600160a01b03909116815260200160405180910390f35b60005461004e906001600160a01b031681565b600086868686338787604051610092906100e9565b6100a29796959493929190610248565b604051809103906000f0801580156100be573d6000803e3d6000fd5b50600080546001600160a01b0319166001600160a01b03929092169182179055979650505050505050565b613813806102d183390190565b80356001600160a01b038116811461010d57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60008060008060008060c0878903121561014157600080fd5b61014a876100f6565b955060206101598189016100f6565b9550610167604089016100f6565b9450610175606089016100f6565b93506080880135801515811461018a57600080fd5b925060a088013567ffffffffffffffff808211156101a757600080fd5b818a0191508a601f8301126101bb57600080fd5b8135818111156101cd576101cd610112565b8060051b604051601f19603f830116810181811085821117156101f2576101f2610112565b60405291825284820192508381018501918d83111561021057600080fd5b938501935b8285101561023557610226856100f6565b84529385019392850192610215565b8096505050505050509295509295509295565b600060e0820160018060a01b03808b1684526020818b1681860152818a1660408601528189166060860152818816608086015286151560a086015260e060c086015282865180855261010087019150828801945060005b818110156102bd57855185168352948301949183019160010161029f565b50909d9c5050505050505050505050505056fe61012060405260016016553480156200001757600080fd5b5060405162003813380380620038138339810160408190526200003a91620001b5565b6001600160a01b0387811660805286811660c05285811660e05284811660a0528316610100526002805460ff191683151517905560005b8151811015620001745760006001600160a01b03168282815181106200009b576200009b62000300565b60200260200101516001600160a01b0316146200015f576001600d6000848481518110620000cd57620000cd62000300565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600c82828151811062000123576200012362000300565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b039092169190911790555b806200016b8162000316565b91505062000071565b50505050505050506200033e565b80516001600160a01b03811681146200019a57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600080600080600080600060e0888a031215620001d157600080fd5b620001dc8862000182565b96506020620001ed818a0162000182565b9650620001fd60408a0162000182565b95506200020d60608a0162000182565b94506200021d60808a0162000182565b935060a089015180151581146200023357600080fd5b60c08a01519093506001600160401b03808211156200025157600080fd5b818b0191508b601f8301126200026657600080fd5b8151818111156200027b576200027b6200019f565b8060051b604051601f19603f83011681018181108582111715620002a357620002a36200019f565b60405291825284820192508381018501918e831115620002c257600080fd5b938501935b82851015620002eb57620002db8562000182565b84529385019392850192620002c7565b80965050505050505092959891949750929550565b634e487b7160e01b600052603260045260246000fd5b6000600182016200033757634e487b7160e01b600052601160045260246000fd5b5060010190565b60805160a05160c05160e051610100516133fd620004166000396000818161045301528181610beb01528181610c300152818161140b01528181611aa501528181611bc9015281816120590152612170015260006102eb01526000818161056201528181612aa401528181612b3b01528181612b8601528181612c0c01528181612ca10152612cec0152600081816105910152818161117301526119d9015260008181610401015281816113910152818161187e0152818161195101528181611fda0152818161293c01526129fe01526133fd6000f3fe608060405234801561001057600080fd5b50600436106102955760003560e01c8063853828b611610167578063d7da4bb0116100ce578063f122977711610087578063f1229777146106fe578063f301af4214610711578063f7412baf14610724578063fc97a3031461074b578063fd3140981461076b578063fdb483c71461077e57600080fd5b8063d7da4bb0146106a4578063da09d19d146106ad578063e2bbb158146106cd578063e5748213146106e0578063e6886396146106ed578063e8111a12146106f557600080fd5b8063a495e5b511610120578063a495e5b514610602578063aa4796521461062d578063b66503cf1461064d578063c6f678bd14610660578063d294f09314610673578063d35e25441461067b57600080fd5b8063853828b6146105845780638dd598fb1461058c57806393f1c442146105b35780639418f939146105bc57806399bcc052146105cf5780639ce43f90146105e257600080fd5b80633ca068b61161020b57806363fb415b116101c457806363fb415b146104d757806368fcee1a146104f75780636fcfff451461050a57806370a082311461052a57806376f4be361461054a578063770f85711461055d57600080fd5b80633ca068b61461042357806346c96aac1461044e5780634c02a21c146104755780634d5ce0381461047e5780635a45d052146104b1578063638634ee146104c457600080fd5b8063211dc32d1161025d578063211dc32d14610381578063221ca18c146103945780632ce9aead146103b45780632e1a7d4d146103d457806331279d3d146103e95780633a4b66f1146103fc57600080fd5b806301316ddf1461029a57806303fbf83a146102e65780630cdfebfa14610325578063115c6f391461035757806318160ddd14610378575b600080fd5b6102cc6102a836600461303d565b60126020908152600092835260408084209091529082529020805460019091015482565b604080519283526020830191909152015b60405180910390f35b61030d7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016102dd565b6102cc61033336600461303d565b600e6020908152600092835260408084209091529082529020805460019091015482565b61036a61036536600461303d565b610791565b6040519081526020016102dd565b61036a600a5481565b61036a61038f366004613069565b610900565b61036a6103a23660046130a2565b60036020526000908152604090205481565b61036a6103c23660046130a2565b60056020526000908152604090205481565b6103e76103e23660046130bf565b610b84565b005b6103e76103f73660046130ee565b610bba565b61030d7f000000000000000000000000000000000000000000000000000000000000000081565b61036a610431366004613069565b600860209081526000928352604080842090915290825290205481565b61030d7f000000000000000000000000000000000000000000000000000000000000000081565b61036a60155481565b6104a161048c3660046130a2565b600d6020526000908152604090205460ff1681565b60405190151581526020016102dd565b6103e76104bf36600461303d565b610fba565b61036a6104d23660046130a2565b610ff2565b61036a6104e53660046130a2565b60016020526000908152604090205481565b6103e761050536600461303d565b611016565b61036a6105183660046130a2565b600f6020526000908152604090205481565b61036a6105383660046130a2565b600b6020526000908152604090205481565b61036a6105583660046130bf565b611022565b61030d7f000000000000000000000000000000000000000000000000000000000000000081565b6103e7611156565b61030d7f000000000000000000000000000000000000000000000000000000000000000081565b61036a60145481565b6103e76105ca3660046131c8565b611171565b61036a6105dd3660046130a2565b611302565b61036a6105f03660046130a2565b60066020526000908152604090205481565b61036a610610366004613069565b600760209081526000928352604080842090915290825290205481565b61036a61063b3660046130a2565b60136020526000908152604090205481565b6103e761065b36600461303d565b611373565b6103e761066e3660046130bf565b611865565b6102cc6118fa565b61036a6106893660046130a2565b6001600160a01b03166000908152600b602052604090205490565b61036a60005481565b61036a6106bb3660046130a2565b60046020526000908152604090205481565b6103e76106db36600461320a565b611926565b6002546104a19060ff1681565b600c5461036a565b61036a60115481565b61036a61070c3660046130a2565b611c73565b61030d61071f3660046130bf565b611d32565b6102cc6107323660046130bf565b6010602052600090815260409020805460019091015482565b61036a6107593660046130a2565b60096020526000908152604090205481565b6102cc61077936600461303d565b611d5c565b6103e761078c36600461320a565b611f7d565b6001600160a01b0382166000908152600f60205260408120548082036107bb5760009150506108fa565b6001600160a01b0384166000908152600e6020526040812084916107e0600185613242565b8152602001908152602001600020600001541161080a57610802600182613242565b9150506108fa565b6001600160a01b0384166000908152600e6020908152604080832083805290915290205483101561083f5760009150506108fa565b60008061084d600184613242565b90505b818111156108f557600060026108668484613242565b6108709190613259565b61087a9083613242565b6001600160a01b0388166000908152600e602090815260408083208484528252918290208251808401909352805480845260019091015491830191909152919250908790036108cf575093506108fa92505050565b80518711156108e0578193506108ee565b6108eb600183613242565b92505b5050610850565b509150505b92915050565b6001600160a01b0380831660008181526007602090815260408083209486168352938152838220549282526012815283822082805290529182205482916109469161220c565b6001600160a01b0384166000908152600f6020526040812054919250036109715760009150506108fa565b600061097d8483610791565b6001600160a01b0385166000908152600f6020526040812054919250906109a690600190613242565b905060008115610ab857825b6109bd600184613242565b8111610ab6576001600160a01b0387166000818152600e602081815260408084208685528083528185208251808401909352805483526001908101548385015295855292909152928290610a1290869061327b565b81526020019081526020016000206040518060400160405290816000820154815260200160018201548152505090506000610a518b8460000151611d5c565b5090506000610a648c8460000151611d5c565b509050670de0b6b3a7640000610a7a8383613242565b8560200151610a899190613293565b610a939190613259565b610a9d908761327b565b9550505050508080610aae906132b2565b9150506109b2565b505b6001600160a01b0386166000908152600e60209081526040808320858452825280832081518083019092528054808352600190910154928201929092529190610b02908a90611d5c565b506001600160a01b03808b166000908152600860209081526040808320938d1683529290522054909150670de0b6b3a764000090610b4190839061220c565b610b4a8b611c73565b610b549190613242565b8360200151610b639190613293565b610b6d9190613259565b610b77908461327b565b9998505050505050505050565b336000908152600b60205260408120548203610bac5750336000908152600960205260409020545b610bb68282611f7d565b5050565b601654600114610bc957600080fd5b6002601655336001600160a01b0383161480610c0d5750336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016145b610c1657600080fd5b60016016556040516363453ae160e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906363453ae190602401600060405180830381600087803b158015610c7c57600080fd5b505af1158015610c90573d6000803e3d6000fd5b5050600260165550600090505b8151811015610f1357610ccd828281518110610cbb57610cbb6132cb565b60200260200101516000196001612223565b60066000858581518110610ce357610ce36132cb565b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020600060056000878781518110610d2357610d236132cb565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060008491905055839190505550506000610d7e838381518110610d7057610d706132cb565b602002602001015185610900565b90504260076000858581518110610d9757610d976132cb565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000206000866001600160a01b03166001600160a01b031681526020019081526020016000208190555060066000848481518110610dfc57610dfc6132cb565b60200260200101516001600160a01b03166001600160a01b031681526020019081526020016000205460086000858581518110610e3b57610e3b6132cb565b6020908102919091018101516001600160a01b039081168352828201939093526040918201600090812093891681529290529020558015610e9a57610e9a838381518110610e8b57610e8b6132cb565b60200260200101518583612413565b828281518110610eac57610eac6132cb565b60200260200101516001600160a01b0316336001600160a01b03167f9aa05b3d70a9e3e2f004f039648839560576334fb45c81f91b6db03ad9e2efc983604051610ef891815260200190565b60405180910390a35080610f0b816132b2565b915050610c9d565b506001600160a01b0382166000908152600160205260408120548154909182918190610f40908490613242565b9091555050506001600160a01b0382166000908152600b6020908152604080832054600190925282208190558154909182918190610f7f90849061327b565b90915550506001600160a01b038316600090815260016020526040902054610fa8908490612513565b610fb061261e565b5050600160165550565b610fc482826126c1565b6001600160a01b03909316600090815260066020908152604080832060059092529091209390935590915550565b6001600160a01b0381166000908152600460205260408120546108fa904290612824565b610fc482826000612223565b6011546000908082036110385750600092915050565b8260106000611048600185613242565b815260200190815260200160002060000154116110715761106a600182613242565b9392505050565b6000805260106020527f6e0956cda88cad152e89927e53611735b61a5c762d1428573c6931b0a5efcb01548310156110ac5750600092915050565b6000806110ba600184613242565b90505b8181111561114e57600060026110d38484613242565b6110dd9190613259565b6110e79083613242565b600081815260106020908152604091829020825180840190935280548084526001909101549183019190915291925090879003611128575095945050505050565b805187111561113957819350611147565b611144600183613242565b92505b50506110bd565b509392505050565b336000908152600b602052604090205461116f90610b84565b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166385f2aef26040518163ffffffff1660e01b81526004016020604051808303816000875af11580156111d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111f591906132e1565b6001600160a01b0316336001600160a01b0316146112465760405162461bcd60e51b81526020600482015260096024820152686f6e6c79207465616d60b81b60448201526064015b60405180910390fd5b816001600160a01b0316600c8481548110611263576112636132cb565b6000918252602090912001546001600160a01b03161461128257600080fd5b6001600160a01b038083166000908152600d6020526040808220805460ff199081169091559284168252902080549091166001179055600c8054829190859081106112cf576112cf6132cb565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550505050565b6001600160a01b038116600090815260046020526040812054421061132957506000919050565b6001600160a01b03821660009081526004602052604081205461134d904290613242565b6001600160a01b03841660009081526003602052604090205490915061106a9082613293565b60165460011461138257600080fd5b60026016556001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116908316036113bf57600080fd5b600081116113cc57600080fd5b6001600160a01b0382166000908152600d602052604090205460ff1661151f57604051633af32abf60e01b81526001600160a01b0383811660048301527f00000000000000000000000000000000000000000000000000000000000000001690633af32abf90602401602060405180830381865afa158015611452573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147691906132fe565b6114cd5760405162461bcd60e51b815260206004820152602260248201527f7265776172647320746f6b656e73206d7573742062652077686974656c697374604482015261195960f21b606482015260840161123d565b600c5460101161151f5760405162461bcd60e51b815260206004820152601760248201527f746f6f206d616e79207265776172647320746f6b656e73000000000000000000604482015260640161123d565b6001600160a01b038216600090815260036020526040812054900361154a5761154a82600042612833565b611558826000196001612223565b6001600160a01b038416600090815260066020908152604080832060059092529091209190915555611588612922565b50506001600160a01b03821660009081526004602052604090205442106115e0576115b582333084612d97565b6115c262093a8082613259565b6001600160a01b038316600090815260036020526040902055611679565b6001600160a01b038216600090815260046020526040812054611604904290613242565b6001600160a01b0384166000908152600360205260408120549192509061162b9083613293565b905080831161163957600080fd5b61164584333086612d97565b62093a80611653828561327b565b61165d9190613259565b6001600160a01b03851660009081526003602052604090205550505b6001600160a01b03821660009081526003602052604090205461169b57600080fd5b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa1580156116e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117069190613320565b905061171562093a8082613259565b6001600160a01b038416600090815260036020526040902054111561177c5760405162461bcd60e51b815260206004820152601860248201527f50726f76696465642072657761726420746f6f20686967680000000000000000604482015260640161123d565b61178962093a804261327b565b6001600160a01b038416600090815260046020908152604080832093909355600d9052205460ff1661181b576001600160a01b0383166000818152600d60205260408120805460ff19166001908117909155600c805491820181559091527fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c70180546001600160a01b03191690911790555b6040518281526001600160a01b0384169033907ff70d5c697de7ea828df48e5c4573cb2194c659f1901f70110c52b066dcf508269060200160405180910390a35050600160165550565b6040516370a0823160e01b81523360048201526118f7907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa1580156118cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118f19190613320565b82611926565b50565b60008060165460011461190c57600080fd5b6002601655611919612922565b9150915060016016559091565b60165460011461193557600080fd5b60026016558161194457600080fd5b61194c612e8f565b6119787f0000000000000000000000000000000000000000000000000000000000000000333085612d97565b81600a600082825461198a919061327b565b9091555050336000908152600b6020526040812080548492906119ae90849061327b565b90915550508015611b22576040516331a9108f60e11b81526004810182905233906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636352211e90602401602060405180830381865afa158015611a20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a4491906132e1565b6001600160a01b031614611a5757600080fd5b336000908152600960205260408120549003611b025733600081815260096020526040908190208390555163698473e360e01b81526004810183905260248101919091526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063698473e390604401600060405180830381600087803b158015611ae957600080fd5b505af1158015611afd573d6000803e3d6000fd5b505050505b336000908152600960205260409020548114611b1d57600080fd5b611b34565b50336000908152600960205260409020545b336000908152600160205260408120548154909182918190611b57908490613242565b9091555050336000908152600b60209081526040808320546001909252822081905581549092508291908190611b8e90849061327b565b90915550611b9e90503382612513565b611ba661261e565b60405163530e389d60e11b815260048101839052336024820152604481018490527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063a61c713a90606401600060405180830381600087803b158015611c1557600080fd5b505af1158015611c29573d6000803e3d6000fd5b505060408051858152602081018790523393507f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a159250015b60405180910390a25050600160165550565b60008054600003611c9a57506001600160a01b031660009081526006602052604090205490565b600080546001600160a01b038416825260036020908152604080842054600583528185205460049093529320549192670de0b6b3a7640000929091611cde91612824565b611ce786610ff2565b611cf19190613242565b611cfb9190613293565b611d059190613293565b611d0f9190613259565b6001600160a01b0383166000908152600660205260409020546108fa919061327b565b600c8181548110611d4257600080fd5b6000918252602090912001546001600160a01b0316905081565b6001600160a01b0382166000908152601360205260408120548190808203611d8b576000809250925050611f76565b6001600160a01b03851660009081526012602052604081208591611db0600185613242565b81526020019081526020016000206000015411611e4d576001600160a01b038516600090815260126020526040812090611deb600184613242565b81526020019081526020016000206001015460126000876001600160a01b03166001600160a01b031681526020019081526020016000206000600184611e319190613242565b8152602001908152602001600020600001549250925050611f76565b6001600160a01b0385166000908152601260209081526040808320838052909152902054841015611e85576000809250925050611f76565b600080611e93600184613242565b90505b81811115611f455760006002611eac8484613242565b611eb69190613259565b611ec09083613242565b6001600160a01b0389166000908152601260209081526040808320848452825291829020825180840190935280548084526001909101549183019190915291925090889003611f1f57602081015190519096509450611f769350505050565b8051881115611f3057819350611f3e565b611f3b600183613242565b92505b5050611e96565b506001600160a01b038616600090815260126020908152604080832093835292905220600181015490549093509150505b9250929050565b601654600114611f8c57600080fd5b6002601655611f99612e8f565b81600a6000828254611fab9190613242565b9091555050336000908152600b602052604081208054849290611fcf908490613242565b9091555061200090507f00000000000000000000000000000000000000000000000000000000000000003384612413565b80156120ba5733600090815260096020526040902054811461202157600080fd5b33600081815260096020526040808220919091555163411b1f7760e01b81526004810183905260248101919091526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063411b1f7790604401600060405180830381600087803b15801561209d57600080fd5b505af11580156120b1573d6000803e3d6000fd5b505050506120cc565b50336000908152600960205260409020545b3360009081526001602052604081205481549091829181906120ef908490613242565b9091555050336000908152600b6020908152604080832054600190925282208190558154909250829190819061212690849061327b565b9091555050336000818152600160205260409020546121459190612513565b61214d61261e565b604051633aa53b9160e21b815260048101839052336024820152604481018490527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063ea94ee4490606401600060405180830381600087803b1580156121bc57600080fd5b505af11580156121d0573d6000803e3d6000fd5b505060408051858152602081018790523393507ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b568925001611c61565b60008183101561221c578161106a565b5090919050565b6001600160a01b038316600090815260056020908152604080832054600690925282205460115483929190830361225d579250905061240b565b6001600160a01b038716600090815260036020526040812054900361228857925042915061240b9050565b600061229383611022565b905060006122af60016011546122a99190613242565b89612824565b9050801561238857815b6122c4600183613242565b811161238657600081815260106020908152604091829020825180840190935280548352600101549082018190521561237357600060108161230785600161327b565b81526020019081526020016000206040518060400160405290816000820154815260200160018201548152505090506000806123528e8460000151866000015187602001518d612f13565b9092509050612361828961327b565b975061236e8e8983612833565b975050505b508061237e816132b2565b9150506122b9565b505b86156124025760008181526010602090815260409182902082518084019093528054835260010154908201819052156124005760006123e18b6123ca8d610ff2565b84516123d6908a61220c565b85602001518a612f13565b5090506123ee818661327b565b94506123fb8b8642612833565b429550505b505b50909350909150505b935093915050565b6000836001600160a01b03163b1161242a57600080fd5b6040516001600160a01b03838116602483015260448201839052600091829186169063a9059cbb60e01b906064015b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516124979190613339565b6000604051808303816000865af19150503d80600081146124d4576040519150601f19603f3d011682016040523d82523d6000602084013e6124d9565b606091505b509150915081801561250357508051158061250357508080602001905181019061250391906132fe565b61250c57600080fd5b5050505050565b6001600160a01b0382166000908152600f60205260409020544290801580159061257157506001600160a01b0384166000908152600e60205260408120839161255d600185613242565b815260200190815260200160002060000154145b156125b4576001600160a01b0384166000908152600e60205260408120849161259b600185613242565b8152602081019190915260400160002060010155612618565b60408051808201825283815260208082018681526001600160a01b0388166000908152600e83528481208682529092529290209051815590516001918201556125fe90829061327b565b6001600160a01b0385166000908152600f60205260409020555b50505050565b6011544281158015906126505750806010600061263c600186613242565b815260200190815260200160002060000154145b1561268157600054601060006001856126699190613242565b81526020810191909152604001600020600101555050565b604080518082018252828152600080546020808401918252868352601090529290209051815590516001918201556126ba90839061327b565b6011555050565b6001600160a01b03821660009081526005602090815260408083205460069092528220546011548392919083036126fb5792509050611f76565b6001600160a01b0386166000908152600360205260408120549003612726579250429150611f769050565b600061273183611022565b9050600061274d60016011546127479190613242565b88612824565b9050815b8181101561281557600081815260106020908152604091829020825180840190935280548352600101549082018190521561280257600060108161279685600161327b565b81526020019081526020016000206040518060400160405290816000820154815260200160018201548152505090506000806127e18d8460000151866000015187602001518d612f13565b90925090506127f0828961327b565b97506127fd8d8983612833565b975050505b508061280d816132b2565b915050612751565b50919792965091945050505050565b600081831061221c578161106a565b6001600160a01b038316600090815260136020526040902054801580159061288f57506001600160a01b0384166000908152601260205260408120839161287b600185613242565b815260200190815260200160002060000154145b156128b9576001600160a01b0384166000908152601260205260408120849161259b600185613242565b60408051808201825283815260208082018681526001600160a01b03881660009081526012835284812086825290925292902090518155905160019182015561290390829061327b565b6001600160a01b03851660009081526013602052604090205550505050565b600254600090819060ff1661293a5750600091829150565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d294f0936040518163ffffffff1660e01b815260040160408051808303816000875af1158015612999573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129bd9190613374565b9092509050811515806129d05750600081115b15612d93576000826014546129e5919061327b565b90506000826015546129f7919061327b565b90506000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316639d63848a6040518163ffffffff1660e01b815260040160408051808303816000875af1158015612a5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a7f9190613398565b604051634cde602960e11b81526001600160a01b0380841660048301529294509092507f0000000000000000000000000000000000000000000000000000000000000000909116906399bcc05290602401602060405180830381865afa158015612aed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b119190613320565b84118015612b2b57506000612b2962093a8086613259565b115b15612be7576000601455612b60827f000000000000000000000000000000000000000000000000000000000000000086612fce565b60405163b66503cf60e01b81526001600160a01b038381166004830152602482018690527f0000000000000000000000000000000000000000000000000000000000000000169063b66503cf90604401600060405180830381600087803b158015612bca57600080fd5b505af1158015612bde573d6000803e3d6000fd5b50505050612bed565b60148490555b604051634cde602960e11b81526001600160a01b0382811660048301527f000000000000000000000000000000000000000000000000000000000000000016906399bcc05290602401602060405180830381865afa158015612c53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c779190613320565b83118015612c9157506000612c8f62093a8085613259565b115b15612d4d576000601555612cc6817f000000000000000000000000000000000000000000000000000000000000000085612fce565b60405163b66503cf60e01b81526001600160a01b038281166004830152602482018590527f0000000000000000000000000000000000000000000000000000000000000000169063b66503cf90604401600060405180830381600087803b158015612d3057600080fd5b505af1158015612d44573d6000803e3d6000fd5b50505050612d53565b60158390555b604080518781526020810187905233917fbc567d6cbad26368064baa0ab5a757be46aae4d70f707f9203d9d9b6c8ccbfa3910160405180910390a2505050505b9091565b6000846001600160a01b03163b11612dae57600080fd5b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b1790529151600092839290881691612e129190613339565b6000604051808303816000865af19150503d8060008114612e4f576040519150601f19603f3d011682016040523d82523d6000602084013e612e54565b606091505b5091509150818015612e7e575080511580612e7e575080806020019051810190612e7e91906132fe565b612e8757600080fd5b505050505050565b600c5460005b81811015610bb6576000600c8281548110612eb257612eb26132cb565b6000918252602090912001546001600160a01b03169050612ed7816000196001612223565b6001600160a01b039092166000908152600660209081526040808320600590925290912092909255905580612f0b816132b2565b915050612e95565b6000806000612f22878561220c565b6001600160a01b0389166000908152600360205260409020549091508590670de0b6b3a764000090612f75612f578a8961220c565b6001600160a01b038d16600090815260046020526040902054612824565b6001600160a01b038c16600090815260046020526040902054612f99908690612824565b612fa39190613242565b612fad9190613293565b612fb79190613293565b612fc19190613259565b9890975095505050505050565b6000836001600160a01b03163b11612fe557600080fd5b6040516001600160a01b03838116602483015260448201839052600091829186169063095ea7b360e01b90606401612459565b6001600160a01b03811681146118f757600080fd5b803561303881613018565b919050565b6000806040838503121561305057600080fd5b823561305b81613018565b946020939093013593505050565b6000806040838503121561307c57600080fd5b823561308781613018565b9150602083013561309781613018565b809150509250929050565b6000602082840312156130b457600080fd5b813561106a81613018565b6000602082840312156130d157600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561310157600080fd5b823561310c81613018565b915060208381013567ffffffffffffffff8082111561312a57600080fd5b818601915086601f83011261313e57600080fd5b813581811115613150576131506130d8565b8060051b604051601f19603f83011681018181108582111715613175576131756130d8565b60405291825284820192508381018501918983111561319357600080fd5b938501935b828510156131b8576131a98561302d565b84529385019392850192613198565b8096505050505050509250929050565b6000806000606084860312156131dd57600080fd5b8335925060208401356131ef81613018565b915060408401356131ff81613018565b809150509250925092565b6000806040838503121561321d57600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b6000828210156132545761325461322c565b500390565b60008261327657634e487b7160e01b600052601260045260246000fd5b500490565b6000821982111561328e5761328e61322c565b500190565b60008160001904831182151516156132ad576132ad61322c565b500290565b6000600182016132c4576132c461322c565b5060010190565b634e487b7160e01b600052603260045260246000fd5b6000602082840312156132f357600080fd5b815161106a81613018565b60006020828403121561331057600080fd5b8151801515811461106a57600080fd5b60006020828403121561333257600080fd5b5051919050565b6000825160005b8181101561335a5760208186018101518583015201613340565b81811115613369576000828501525b509190910192915050565b6000806040838503121561338757600080fd5b505080516020909101519092909150565b600080604083850312156133ab57600080fd5b82516133b681613018565b60208401519092506130978161301856fea26469706673582212209cbd20125a25a94a5234f0308c21588b2e92d8d0a2106edd5a30cc6f6565597a64736f6c634300080d0033a2646970667358221220faec3c9ddffa91d552e43cfd45d42f9defb30d7ebc2797536ff50a177e521a0f64736f6c634300080d0033

Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.