Source Code
Overview
S Balance
S Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Contract Name:
Voter
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 800 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {SafeERC20, IERC20} from "openzeppelin/token/ERC20/utils/SafeERC20.sol";
import {Ownable2StepUpgradeable} from "openzeppelin-contracts-upgradeable/access/Ownable2StepUpgradeable.sol";
import {EnumerableSet} from "openzeppelin/utils/structs/EnumerableSet.sol";
import {EnumerableMap} from "openzeppelin/utils/structs/EnumerableMap.sol";
import {IMetroStaking} from "./interfaces/IMetroStaking.sol";
import {IBribeRewarder} from "./interfaces/IBribeRewarder.sol";
import {IRewarderFactory} from "./interfaces/IRewarderFactory.sol";
import {IMasterChef, IMasterChefRewarder} from "./interfaces/IMasterChef.sol";
import {IVoterPoolValidator} from "./interfaces/IVoterPoolValidator.sol";
import {IVoter} from "./interfaces/IVoter.sol";
import {Amounts} from "./libraries/Amounts.sol";
import {Constants} from "./libraries/Constants.sol";
contract Voter is Ownable2StepUpgradeable, IVoter {
using Amounts for Amounts.Parameter;
using EnumerableSet for EnumerableSet.UintSet;
using EnumerableSet for EnumerableSet.Bytes32Set;
using EnumerableMap for EnumerableMap.AddressToUintMap;
IMasterChef internal immutable _masterChef;
IMetroStaking internal immutable _mlumStaking;
IRewarderFactory internal immutable _rewarderFactory;
uint256 private _currentVotingPeriodId;
/// @dev votingPeriodId => tokenId => hasVoted
mapping(uint256 => mapping(uint256 => bool)) private _hasVotedInPeriod;
/// @dev period => total amount of votes
mapping(uint256 => uint256) private _totalVotesInPeriod; // total Weight in period
/// @dev minimum votes (mlum) to get created
uint256 private _minimumVotesPerPool = 50e18;
uint256 private _periodDuration = 1209600;
uint256 private _minimumLockTime = 60 * 60 * 24 * 30 * 3;
/// @dev period => pool => votes
mapping(uint256 => mapping(address => uint256)) private _poolVotesPerPeriod;
// period id => rewarders;
mapping(uint256 => EnumerableSet.Bytes32Set)
private _registeredBribesPerPeriod; //extra check
// periodId => account => bribes
mapping(uint256 periodId => mapping(address account => IBribeRewarder[])) private _userBribesPerPeriod;
// periodId => pool => bribeRewarders
mapping(uint256 => mapping(address => IBribeRewarder[]))
private _bribesPerPriod;
/// @dev tokenId => pool => votes
mapping(uint256 => mapping(address => uint256)) private _userVotes;
/// @dev period => startTime
mapping(uint256 => VotingPeriod) _startTimes;
/// @dev votes per pool
EnumerableMap.AddressToUintMap private _votes;
/// @dev total votes
uint256 private _totalVotes;
/// @dev weight per pid
mapping(uint256 => uint256) private _weights; // pid => weight
/// @dev totalWeight of pids
uint256 private _topPidsTotalWeights;
/// @dev stores the top pids
EnumerableSet.UintSet private _topPids;
/// @dev set pool validator;
IVoterPoolValidator private _poolValidator;
/// @dev operator for the voter
address private _operator;
/// @dev holds elevated rewarders eligible bribing beyond the bribe limit per pool
mapping(address rewarder => bool isElevated) private _elevatedRewarders;
uint256[9] __gap;
constructor(
IMasterChef masterChef,
IMetroStaking mlumStaking,
IRewarderFactory factory
) {
_disableInitializers();
_masterChef = masterChef;
_mlumStaking = mlumStaking;
_rewarderFactory = factory;
}
/**
* @dev Initializes the contract.
* @param initialOwner The initial owner of the contract.
*/
function initialize(address initialOwner) external reinitializer(2) {
__Ownable_init(initialOwner);
_minimumVotesPerPool = 50e18;
_periodDuration = 1209600;
_minimumLockTime = 60 * 60 * 24 * 30 * 3;
}
/**
* @dev start a new voting period
*/
function startNewVotingPeriod() public {
if (msg.sender != _operator) _checkOwner();
_currentVotingPeriodId++;
VotingPeriod storage period = _startTimes[_currentVotingPeriodId];
period.startTime = block.timestamp;
period.endTime = block.timestamp + _periodDuration;
emit VotingPeriodStarted();
}
function _votingStarted() internal view returns (bool) {
return
_startTimes[_currentVotingPeriodId].startTime != 0 &&
_startTimes[_currentVotingPeriodId].startTime <= block.timestamp;
}
function _votingEnded() internal view returns (bool) {
return
_votingStarted() &&
_startTimes[_currentVotingPeriodId].endTime <= block.timestamp;
}
/**
* @dev bribe rewarder registers itself
* Checks if rewarder is from allowed rewarderFactory
*/
function onRegister() external override {
IBribeRewarder rewarder = IBribeRewarder(msg.sender);
_checkRegisterCaller(rewarder);
uint256 currentPeriodId = _currentVotingPeriodId;
bool isElevated = _elevatedRewarders[address(rewarder)];
(address pool, uint256[] memory periods) = rewarder.getBribePeriods();
for (uint256 i = 0; i < periods.length; ++i) {
require(periods[i] >= currentPeriodId, "wrong period");
// only admin is allowed to add more bribes when limit is reached
require(_bribesPerPriod[periods[i]][pool].length + 1 <= Constants.MAX_BRIBES_PER_POOL || isElevated, "too much bribes");
_bribesPerPriod[periods[i]][pool].push(rewarder);
}
// remove elevated status
if (isElevated) {
delete _elevatedRewarders[address(rewarder)];
}
}
/**
* Cast votes for current voting period
*
* @param tokenId - token id of mlum staking position
* @param pools - array of pool addresses
* @param deltaAmounts - array of amounts must not exceed the total voting power
*/
function vote(
uint256 tokenId,
address[] calldata pools,
uint256[] calldata deltaAmounts
) external {
if (pools.length != deltaAmounts.length) revert IVoter__InvalidLength();
// check voting started
if (!_votingStarted()) revert IVoter_VotingPeriodNotStarted();
if (_votingEnded()) revert IVoter_VotingPeriodEnded();
// dont allow voting if emergency unlock is active
if (_mlumStaking.isUnlocked()) {
revert IVoter__EmergencyUnlock();
}
// check ownership of tokenId
address voterAccount = _mlumStaking.ownerOf(tokenId);
if (voterAccount != msg.sender) {
revert IVoter__NotOwner();
}
uint256 currentPeriodId = _currentVotingPeriodId;
// check if alreay voted
if (_hasVotedInPeriod[currentPeriodId][tokenId]) {
revert IVoter__AlreadyVoted();
}
uint256 totalUserVotes;
{
// scope to avoid stack too deep
IMetroStaking.StakingPosition memory position = _mlumStaking
.getStakingPosition(tokenId);
// check initialLockDuration and remaining lock durations
_checkLockDurations(position);
uint256 votingPower = position.amountWithMultiplier;
// check if deltaAmounts > votingPower
for (uint256 i = 0; i < pools.length; ++i) {
totalUserVotes += deltaAmounts[i];
}
if (totalUserVotes > votingPower) {
revert IVoter__InsufficientVotingPower();
}
}
IVoterPoolValidator validator = _poolValidator;
for (uint256 i = 0; i < pools.length; ++i) {
address pool = pools[i];
if (address(validator) != address(0) && !validator.isValid(pool)) {
revert Voter__PoolNotVotable();
}
uint256 deltaAmount = deltaAmounts[i];
_userVotes[tokenId][pool] += deltaAmount;
_poolVotesPerPeriod[currentPeriodId][pool] += deltaAmount;
if (_votes.contains(pool)) {
_votes.set(pool, _votes.get(pool) + deltaAmount);
} else {
_votes.set(pool, deltaAmount);
}
_notifyBribes(_currentVotingPeriodId, pool, voterAccount, deltaAmount); // msg.sender, deltaAmount);
}
_totalVotes += totalUserVotes;
_hasVotedInPeriod[currentPeriodId][tokenId] = true;
emit Voted(tokenId, currentPeriodId, pools, deltaAmounts);
}
function _checkLockDurations(
IMetroStaking.StakingPosition memory position
) internal view {
if (position.initialLockDuration < _minimumLockTime) {
revert IVoter__InsufficientLockTime();
}
// check if the position is locked for the voting period
uint256 _votingEndTime = _startTimes[_currentVotingPeriodId].endTime;
if (_votingEndTime > block.timestamp) {
uint256 _remainingVotingTime = _votingEndTime - block.timestamp;
if (_remainingLockTime(position) < _remainingVotingTime) {
revert IVoter__InsufficientLockTime();
}
}
}
function _remainingLockTime(
IMetroStaking.StakingPosition memory position
) internal view returns (uint256) {
uint256 blockTimestamp = block.timestamp;
if (
(position.startLockTime + position.lockDuration) <= blockTimestamp
) {
return 0;
}
return
(position.startLockTime + position.lockDuration) - blockTimestamp;
}
function _notifyBribes(
uint256 periodId,
address pool,
address account,
uint256 deltaAmount
) private {
IBribeRewarder[] storage rewarders = _bribesPerPriod[periodId][pool];
for (uint256 i = 0; i < rewarders.length; ++i) {
if (address(rewarders[i]) != address(0)) {
rewarders[i].deposit(periodId, account, deltaAmount);
_userBribesPerPeriod[periodId][account].push(rewarders[i]);
}
}
}
/**
* @dev Set farm pools with their weight;
*
* WARNING:
* Caller is responsible to updateAll all pids on masterChef before using this function!
*
* @param pids - list of pids
* @param weights - list of weights
*/
function setTopPoolIdsWithWeights(
uint256[] calldata pids,
uint256[] calldata weights
) external {
if (msg.sender != _operator) _checkOwner();
uint256 length = pids.length;
if (length != weights.length) revert IVoter__InvalidLength();
uint256[] memory oldIds = _topPids.values();
if (oldIds.length > 0) {
// masterchef snould be updated beforehand
for (uint256 i = oldIds.length; i > 0; ) {
uint256 pid = oldIds[--i];
_topPids.remove(pid);
_weights[pid] = 0;
}
}
for (uint256 i; i < length; ++i) {
uint256 pid = pids[i];
if (!_topPids.add(pid)) revert IVoter__DuplicatePoolId(pid);
}
uint256 totalWeights;
for (uint256 i; i < length; ++i) {
uint256 pid = pids[i];
uint256 weight = weights[i];
_weights[pid] = weight;
totalWeights += weight;
}
_topPidsTotalWeights = totalWeights;
emit TopPoolIdsWithWeightsSet(pids, weights);
}
function updatePoolValidator(
IVoterPoolValidator poolValidator
) external onlyOwner {
_poolValidator = poolValidator;
emit VoterPoolValidatorUpdated(address(poolValidator));
}
/**
* @dev returns current voting period
*/
function getCurrentVotingPeriod() external view override returns (uint256) {
return _currentVotingPeriodId;
}
/**
* @dev returns current period start time
*/
function getPeriodStartTime() external view override returns (uint256) {
return _startTimes[_currentVotingPeriodId].startTime;
}
/**
* @dev get votes per period
* @param periodId - period of the vote
* @param pool - pool address
*/
function getVotesPerPeriod(
uint256 periodId,
address pool
) external view override returns (uint256) {
return _poolVotesPerPeriod[periodId][pool];
}
/**
* @dev get total accrued votes
*/
function getTotalVotes() external view override returns (uint256) {
return _totalVotes;
}
/**
* @dev Get accrued user votes for given tokenId and pool
*
*/
function getUserVotes(
uint256 tokenId,
address pool
) external view override returns (uint256) {
return _userVotes[tokenId][pool];
}
/**
* @dev Get pool votes for given period
*/
function getPoolVotesPerPeriod(
uint256 periodId,
address pool
) external view override returns (uint256) {
return _poolVotesPerPeriod[periodId][pool];
}
/**
* @dev Get accrued pool votes
*/
function getPoolVotes(address pool) external view returns (uint256) {
if (_votes.contains(pool)) {
return _votes.get(pool);
}
return 0;
}
/**
* @dev get voted pools
*/
function getVotedPools() external view returns (address[] memory) {
return _votes.keys();
}
/**
* returns votedPoolsLengths
*/
function getVotedPoolsLength() external view returns (uint256) {
return _votes.length();
}
function getVotedPoolsAtIndex(
uint256 index
) external view returns (address, uint256) {
return _votes.at(index);
}
function getMlumStaking() external view returns (IMetroStaking) {
return _mlumStaking;
}
function getMasterChef() external view override returns (IMasterChef) {
return _masterChef;
}
function getTotalWeight() external view override returns (uint256) {
return _topPidsTotalWeights;
}
function getTopPoolIds() external view override returns (uint256[] memory) {
return _topPids.values();
}
function getWeight(uint256 pid) external view override returns (uint256) {
return _weights[pid];
}
function hasVoted(
uint256 periodId,
uint256 tokenId
) external view override returns (bool) {
return _hasVotedInPeriod[periodId][tokenId];
}
function ownerOf(
uint256 tokenId,
address account
) external view returns (bool) {
return _mlumStaking.ownerOf(tokenId) == account;
}
/**
* @dev get bribe rewarder at index
*/
function getUserBribeRewaderAt(uint256 period, address account, uint256 index)
external
view
returns (IBribeRewarder)
{
return _userBribesPerPeriod[period][account][index];
}
/**
* Returns number of bribe rewarders for period and account
*/
function getUserBribeRewarderLength(uint256 period, address account) external view returns (uint256) {
return _userBribesPerPeriod[period][account].length;
}
/**
* checks if rewarder registers on rewarderfactory
*/
function _checkRegisterCaller(IBribeRewarder rewarder) internal view {
if (
_rewarderFactory.getRewarderType(rewarder) !=
IRewarderFactory.RewarderType.BribeRewarder
) {
revert Voter__InvalidRegisterCaller();
}
}
/**
* Get rewarder at index
* @param period - period id
* @param pool - pool address
* @param index - index
*/
function getBribeRewarderAt(
uint256 period,
address pool,
uint256 index
) external view override returns (IBribeRewarder) {
return _bribesPerPriod[period][pool][index];
}
/**
* Returns rewarders length
* @param period - voting period id
* @param pool - pool address
*/
function getBribeRewarderLength(
uint256 period,
address pool
) external view override returns (uint256) {
return _bribesPerPriod[period][pool].length;
}
/**
* Get start and endtime for period
* @param periodId - periodId
* @return startTime - periodStartTime
* @return endTime - period endTime
*/
function getPeriodStartEndtime(
uint256 periodId
) external view override returns (uint256, uint256) {
return (_startTimes[periodId].startTime, _startTimes[periodId].endTime);
}
/**
* @dev returns the latest ended period, either the period before the current period
* or the current period if its ended. Reverts if no period is finished so far
*/
function getLatestFinishedPeriod()
external
view
override
returns (uint256)
{
// the current period ended and no new period exists
if (_votingEnded()) {
return _currentVotingPeriodId;
}
if (_currentVotingPeriodId == 0) revert IVoter__NoFinishedPeriod();
return _currentVotingPeriodId - 1;
}
/**
* Get duration of voting epoch
*/
function getPeriodDuration() external view returns (uint256) {
return _periodDuration;
}
/**
* Get minimum time which a position needs be locked for voting
*/
function getMinimumLockTime() external view returns (uint256) {
return _minimumLockTime;
}
/**
* mininmum votes per pool
*/
function getMinimumVotesPerPool() external view returns (uint256) {
return _minimumVotesPerPool;
}
/**
* @dev update duration of voding period
* @param duration - duration in seconds
*/
function updatePeriodDuration(uint256 duration) external onlyOwner {
if (duration == 0) revert IVoter_ZeroValue();
_periodDuration = duration;
emit VotingDurationUpdated(duration);
}
/**
* @dev update minimum time a position needs to be locked
* @param lockTime - locktime in seconds
*/
function updateMinimumLockTime(uint256 lockTime) external onlyOwner {
if (lockTime == 0) revert IVoter_ZeroValue();
_minimumLockTime = lockTime;
emit MinimumLockTimeUpdated(lockTime);
}
/**
* @dev update votes per pool
* @param votesPerPool - minimum votes per pool got counted into farms
*/
function updateMinimumVotesPerPool(
uint256 votesPerPool
) external onlyOwner {
// no check needed
_minimumVotesPerPool = votesPerPool;
emit MinimumVotesPerPoolUpdated(votesPerPool);
}
/**
* @dev Updates the operator.
* @param operator The new operator.
*/
function updateOperator(address operator) external onlyOwner {
_operator = operator;
emit OperatorUpdated(operator);
}
/**
* @dev Adds an elevated rewarder. Elevated rewarders are allowed to bribe beyond the bribe limit per pool and epoch.
* @param rewarder - rewarder address
*/
function addElevatedRewarder(address rewarder) external onlyOwner {
_elevatedRewarders[rewarder] = true;
emit ElevatedRewarderAdded(address(rewarder));
}
/**
* @dev Removes an elevated rewarder.
* @param rewarder - rewarder address
*/
function removeElevatedRewarder(address rewarder) external onlyOwner {
delete _elevatedRewarders[rewarder];
emit ElevatedRewarderRemoved(address(rewarder));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @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);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {OwnableUpgradeable} from "./OwnableUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2StepUpgradeable is Initializable, OwnableUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable2Step
struct Ownable2StepStorage {
address _pendingOwner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable2Step")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant Ownable2StepStorageLocation = 0x237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c00;
function _getOwnable2StepStorage() private pure returns (Ownable2StepStorage storage $) {
assembly {
$.slot := Ownable2StepStorageLocation
}
}
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
function __Ownable2Step_init() internal onlyInitializing {
}
function __Ownable2Step_init_unchained() internal onlyInitializing {
}
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
Ownable2StepStorage storage $ = _getOwnable2StepStorage();
return $._pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
Ownable2StepStorage storage $ = _getOwnable2StepStorage();
$._pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
Ownable2StepStorage storage $ = _getOwnable2StepStorage();
delete $._pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.20;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position is the index of the value in the `values` array plus 1.
// Position 0 is used to mean a value is not in the set.
mapping(bytes32 value => uint256) _positions;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._positions[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We cache the value's position to prevent multiple reads from the same storage slot
uint256 position = set._positions[value];
if (position != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 valueIndex = position - 1;
uint256 lastIndex = set._values.length - 1;
if (valueIndex != lastIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the lastValue to the index where the value to delete is
set._values[valueIndex] = lastValue;
// Update the tracked position of the lastValue (that was just moved)
set._positions[lastValue] = position;
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the tracked position for the deleted slot
delete set._positions[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._positions[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableMap.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableMap.js.
pragma solidity ^0.8.20;
import {EnumerableSet} from "./EnumerableSet.sol";
/**
* @dev Library for managing an enumerable variant of Solidity's
* https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
* type.
*
* Maps have the following properties:
*
* - Entries are added, removed, and checked for existence in constant time
* (O(1)).
* - Entries are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableMap for EnumerableMap.UintToAddressMap;
*
* // Declare a set state variable
* EnumerableMap.UintToAddressMap private myMap;
* }
* ```
*
* The following map types are supported:
*
* - `uint256 -> address` (`UintToAddressMap`) since v3.0.0
* - `address -> uint256` (`AddressToUintMap`) since v4.6.0
* - `bytes32 -> bytes32` (`Bytes32ToBytes32Map`) since v4.6.0
* - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0
* - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableMap, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableMap.
* ====
*/
library EnumerableMap {
using EnumerableSet for EnumerableSet.Bytes32Set;
// To implement this library for multiple types with as little code repetition as possible, we write it in
// terms of a generic Map type with bytes32 keys and values. The Map implementation uses private functions,
// and user-facing implementations such as `UintToAddressMap` are just wrappers around the underlying Map.
// This means that we can only create new EnumerableMaps for types that fit in bytes32.
/**
* @dev Query for a nonexistent map key.
*/
error EnumerableMapNonexistentKey(bytes32 key);
struct Bytes32ToBytes32Map {
// Storage of keys
EnumerableSet.Bytes32Set _keys;
mapping(bytes32 key => bytes32) _values;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) {
map._values[key] = value;
return map._keys.add(key);
}
/**
* @dev Removes a key-value pair from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) {
delete map._values[key];
return map._keys.remove(key);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) {
return map._keys.contains(key);
}
/**
* @dev Returns the number of key-value pairs in the map. O(1).
*/
function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) {
return map._keys.length();
}
/**
* @dev Returns the key-value pair stored at position `index` in the map. O(1).
*
* Note that there are no guarantees on the ordering of entries inside the
* array, and it may change when more entries are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32, bytes32) {
bytes32 key = map._keys.at(index);
return (key, map._values[key]);
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) {
bytes32 value = map._values[key];
if (value == bytes32(0)) {
return (contains(map, key), bytes32(0));
} else {
return (true, value);
}
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) {
bytes32 value = map._values[key];
if (value == 0 && !contains(map, key)) {
revert EnumerableMapNonexistentKey(key);
}
return value;
}
/**
* @dev Return the an array containing all the keys
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(Bytes32ToBytes32Map storage map) internal view returns (bytes32[] memory) {
return map._keys.values();
}
// UintToUintMap
struct UintToUintMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) {
return set(map._inner, bytes32(key), bytes32(value));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(UintToUintMap storage map, uint256 key) internal returns (bool) {
return remove(map._inner, bytes32(key));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(UintToUintMap storage map, uint256 key) internal view returns (bool) {
return contains(map._inner, bytes32(key));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(UintToUintMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintToUintMap storage map, uint256 index) internal view returns (uint256, uint256) {
(bytes32 key, bytes32 value) = at(map._inner, index);
return (uint256(key), uint256(value));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool, uint256) {
(bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
return (success, uint256(value));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) {
return uint256(get(map._inner, bytes32(key)));
}
/**
* @dev Return the an array containing all the keys
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(UintToUintMap storage map) internal view returns (uint256[] memory) {
bytes32[] memory store = keys(map._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintToAddressMap
struct UintToAddressMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
return set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
return remove(map._inner, bytes32(key));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
return contains(map._inner, bytes32(key));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(UintToAddressMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
(bytes32 key, bytes32 value) = at(map._inner, index);
return (uint256(key), address(uint160(uint256(value))));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
(bool success, bytes32 value) = tryGet(map._inner, bytes32(key));
return (success, address(uint160(uint256(value))));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
return address(uint160(uint256(get(map._inner, bytes32(key)))));
}
/**
* @dev Return the an array containing all the keys
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(UintToAddressMap storage map) internal view returns (uint256[] memory) {
bytes32[] memory store = keys(map._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressToUintMap
struct AddressToUintMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) {
return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(AddressToUintMap storage map, address key) internal returns (bool) {
return remove(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(AddressToUintMap storage map, address key) internal view returns (bool) {
return contains(map._inner, bytes32(uint256(uint160(key))));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(AddressToUintMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) {
(bytes32 key, bytes32 value) = at(map._inner, index);
return (address(uint160(uint256(key))), uint256(value));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) {
(bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key))));
return (success, uint256(value));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(AddressToUintMap storage map, address key) internal view returns (uint256) {
return uint256(get(map._inner, bytes32(uint256(uint160(key)))));
}
/**
* @dev Return the an array containing all the keys
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(AddressToUintMap storage map) internal view returns (address[] memory) {
bytes32[] memory store = keys(map._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// Bytes32ToUintMap
struct Bytes32ToUintMap {
Bytes32ToBytes32Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) {
return set(map._inner, key, bytes32(value));
}
/**
* @dev Removes a value from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(Bytes32ToUintMap storage map, bytes32 key) internal returns (bool) {
return remove(map._inner, key);
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool) {
return contains(map._inner, key);
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(Bytes32ToUintMap storage map) internal view returns (uint256) {
return length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the map. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32, uint256) {
(bytes32 key, bytes32 value) = at(map._inner, index);
return (key, uint256(value));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool, uint256) {
(bool success, bytes32 value) = tryGet(map._inner, key);
return (success, uint256(value));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) {
return uint256(get(map._inner, key));
}
/**
* @dev Return the an array containing all the keys
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function keys(Bytes32ToUintMap storage map) internal view returns (bytes32[] memory) {
bytes32[] memory store = keys(map._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "openzeppelin/token/ERC20/IERC20.sol";
import "openzeppelin/token/ERC721/IERC721.sol";
interface IMetroStaking is IERC721 {
// Info of each NFT (staked position).
struct StakingPosition {
uint256 amount; // How many lp tokens the user has provided
uint256 amountWithMultiplier; // Amount + lock bonus faked amount (amount + amount*multiplier)
uint256 startLockTime; // The time at which the user made his deposit
uint256 initialLockDuration; // lock duration on creation
uint256 lockDuration; // The lock duration in seconds
uint256 lockMultiplier; // Active lock multiplier (times 1e2)
uint256 rewardDebt; // Reward debt
uint256 totalMultiplier; // lockMultiplier
}
error IMetroStaking_TooMuchTokenDecimals();
error IMetroStaking_ZeroAddress();
error IMetroStaking_NotOwner();
error IMetroStaking_MaxLockMultiplierTooHigh();
error IMetroStaking_LocksDisabled();
error IMetroStaking_ZeroAmount();
error IMetroStaking_PositionStillLocked();
error IMetroStaking_InvalidLockDuration();
error IMetroStaking_TransferNotAllowed();
error IMetroStaking_AmountTooHigh();
error IMetroStaking_SameAddress();
// Events
event AddToPosition(uint256 indexed tokenId, address user, uint256 amount);
event CreatePosition(uint256 indexed tokenId, uint256 amount, uint256 lockDuration);
event WithdrawFromPosition(uint256 indexed tokenId, uint256 amount);
event EmergencyWithdraw(uint256 indexed tokenId, uint256 amount);
event LockPosition(uint256 indexed tokenId, uint256 lockDuration);
event HarvestPosition(uint256 indexed tokenId, address to, uint256 pending);
event PoolUpdated(uint256 lastRewardTime, uint256 accRewardsPerShare);
event SetLockMultiplierSettings(uint256 maxLockDuration, uint256 maxLockMultiplier);
event SetBoostMultiplierSettings(uint256 maxGlobalMultiplier, uint256 maxBoostMultiplier);
event SetEmergencyUnlock(bool emergencyUnlock);
event SetMinimumLockDuration(uint256 minimumLockDuration);
function exists(uint256 tokenId) external view returns (bool);
function getStakedToken() external view returns (IERC20);
function getRewardToken() external view returns (IERC20);
function getMultiplierSettings() external view returns (uint256, uint256, uint256);
function getLastRewardBalance() external view returns (uint256);
function lastTokenId() external view returns (uint256);
function getStakedSupply() external view returns (uint256);
function isUnlocked() external view returns (bool);
function getStakedSupplyWithMultiplier() external view returns (uint256);
function hasDeposits() external view returns (bool);
function getStakingPosition(uint256 tokenId) external view returns (StakingPosition memory position);
function pendingRewards(uint256 tokenId) external view returns (uint256);
function createPosition(uint256 amount, uint256 lockDuration) external;
function addToPosition(uint256 tokenId, uint256 amountToAdd) external;
function harvestPosition(uint256 tokenId) external;
function harvestPositions(uint256[] calldata tokenIds) external;
function withdrawFromPosition(uint256 tokenId, uint256 amountToWithdraw) external;
function emergencyWithdraw(uint256 tokenId) external;
function setMinimumLockDuration(uint256 minimumLockDuration) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
import {IRewarder} from "./IRewarder.sol";
interface IBribeRewarder is IRewarder {
error BribeRewarder__OnlyVoter();
error BribeRewarder__InsufficientFunds();
error BribeRewarder__WrongStartId();
error BribeRewarder__WrongEndId();
error BribeRewarder__ZeroReward();
error BribeRewarder__NativeTransferFailed();
error BribeRewarder__NotOwner();
error BribeRewarder__CannotRenounceOwnership();
error BribeRewarder__NotNativeRewarder();
error BribeRewarder__AlreadyInitialized();
error BribeRewarder__PeriodNotFound();
error BribeRewarder__AmountTooLow();
error BribeRewarder__OnlyVoterAdmin();
event Claimed(address indexed account, address indexed pool, uint256 amount);
event Deposited(uint256 indexed periodId, address indexed account, address indexed pool, uint256 amount);
event BribeInit(uint256 indexed startId, uint256 indexed lastId, uint256 amountPerPeriod);
event Swept(IERC20 indexed token, address indexed account, uint256 amount);
function bribe(uint256 startId, uint256 lastId, uint256 amountPerPeriod) external;
function claim(address account) external;
function deposit(uint256 periodId, address account, uint256 deltaAmount) external;
function getPool() external view returns (address);
function getPendingReward(address account) external view returns (uint256);
function getBribePeriods() external view returns (address pool, uint256[] memory);
function getStartVotingPeriodId() external view returns (uint256);
function getLastVotingPeriodId() external view returns (uint256);
function getAmountPerPeriod() external view returns (uint256);
function sweep(IERC20 token, address account) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
import {IRewarder} from "../interfaces/IRewarder.sol";
import {IBribeRewarder} from "../interfaces/IBribeRewarder.sol";
import {IBaseRewarder} from "../interfaces/IBaseRewarder.sol";
interface IRewarderFactory {
error RewarderFactory__ZeroAddress();
error RewarderFactory__InvalidRewarderType();
error RewarderFactory__InvalidPid();
error RewarderFactory__TokenNotWhitelisted();
error RewarderFactory__InvalidLength();
enum RewarderType {
InvalidRewarder,
MasterChefRewarder,
BribeRewarder
}
event RewarderCreated(
RewarderType indexed rewarderType, IERC20 indexed token, uint256 indexed pid, IBaseRewarder rewarder
);
event BribeRewarderCreated(
RewarderType indexed rewarderType, IERC20 indexed token, address indexed pool, IBribeRewarder rewarder
);
event RewarderImplementationSet(RewarderType indexed rewarderType, IRewarder indexed implementation);
function getBribeCreatorFee() external view returns (uint256);
function getWhitelistedTokenInfo (address token) external view returns (bool, uint256);
function getRewarderImplementation(RewarderType rewarderType) external view returns (IRewarder);
function getRewarderCount(RewarderType rewarderType) external view returns (uint256);
function getRewarderAt(RewarderType rewarderType, uint256 index) external view returns (IRewarder);
function getRewarderType(IRewarder rewarder) external view returns (RewarderType);
function setRewarderImplementation(RewarderType rewarderType, IRewarder implementation) external;
function createRewarder(RewarderType rewarderType, IERC20 token, uint256 pid) external returns (IBaseRewarder);
function createBribeRewarder(IERC20 token, address pool) external returns (IBribeRewarder);
function setWhitelist(address[] calldata tokens, uint256[] calldata minBribeAmounts) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
import {IMasterChefRewarder} from "./IMasterChefRewarder.sol";
import {IMetro} from "./IMetro.sol";
import {IVoter} from "./IVoter.sol";
import {Rewarder} from "../libraries/Rewarder.sol";
import {Amounts} from "../libraries/Amounts.sol";
import {IRewarderFactory} from "./IRewarderFactory.sol";
interface IMasterChef {
error MasterChef__InvalidShares();
error MasterChef__InvalidMetroPerSecond();
error MasterChef__ZeroAddress();
error MasterChef__NotMasterchefRewarder();
error MasterChef__CannotRenounceOwnership();
error MasterChef__MintFailed();
error MasterChef__TrusteeNotSet();
error MasterChef__NotTrustedCaller();
struct Farm {
Amounts.Parameter amounts;
Rewarder.Parameter rewarder;
IERC20 token;
IMasterChefRewarder extraRewarder;
}
// bool depositOnBehalf; // true if v2 pool zap in should be possible
// uint256 startTime;
event PositionModified(uint256 indexed pid, address indexed account, int256 deltaAmount, uint256 metroReward);
event MetroPerSecondSet(uint256 metroPerSecond);
event FarmAdded(uint256 indexed pid, IERC20 indexed token);
event ExtraRewarderSet(uint256 indexed pid, IMasterChefRewarder extraRewarder);
event TreasurySet(address indexed treasury);
event VoterSet(IVoter indexed newVoter);
event TrusteeSet(address indexed trustee);
event MintMetroSet(bool mintMetro);
event OperatorUpdated(address indexed operator);
function add(IERC20 token, IMasterChefRewarder extraRewarder) external;
function claim(uint256[] memory pids) external;
function deposit(uint256 pid, uint256 amount) external;
function depositOnBehalf(uint256 pid, uint256 amount, address account) external;
function emergencyWithdraw(uint256 pid) external;
function getDeposit(uint256 pid, address account) external view returns (uint256);
function getLastUpdateTimestamp(uint256 pid) external view returns (uint256);
function getPendingRewards(address account, uint256[] memory pids)
external
view
returns (uint256[] memory metroRewards, IERC20[] memory extraTokens, uint256[] memory extraRewards);
function getExtraRewarder(uint256 pid) external view returns (IMasterChefRewarder);
function getMetro() external view returns (IMetro);
function getMetroPerSecond() external view returns (uint256);
function getMetroPerSecondForPid(uint256 pid) external view returns (uint256);
function getNumberOfFarms() external view returns (uint256);
function getToken(uint256 pid) external view returns (IERC20);
function getTotalDeposit(uint256 pid) external view returns (uint256);
function getTreasury() external view returns (address);
function getTreasuryShare() external view returns (uint256);
function getRewarderFactory() external view returns (IRewarderFactory);
function getLBHooksManager() external view returns (address);
function getVoter() external view returns (IVoter);
function setExtraRewarder(uint256 pid, IMasterChefRewarder extraRewarder) external;
function setMetroPerSecond(uint96 metroPerSecond) external;
function setTreasury(address treasury) external;
function setVoter(IVoter voter) external;
function setTrustee(address trustee) external;
function updateAll(uint256[] calldata pids) external;
function withdraw(uint256 pid, uint256 amount) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IVoterPoolValidator {
function isValid(address pool) external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IBribeRewarder} from "./IBribeRewarder.sol";
import {IMasterChef} from "./IMasterChef.sol";
interface IVoter {
error IVoter__InvalidLength();
error IVoter_VotingPeriodNotStarted();
error IVoter_VotingPeriodEnded();
error IVoter__AlreadyVoted();
error IVoter__NotOwner();
error IVoter__InsufficientVotingPower();
error IVoter__TooManyPoolIds();
error IVoter__DuplicatePoolId(uint256 pid);
error IVoter__InsufficientLockTime();
error Voter__InvalidRegisterCaller();
error Voter__PoolNotVotable();
error IVoter__NoFinishedPeriod();
error IVoter_ZeroValue();
error IVoter__EmergencyUnlock();
event VotingPeriodStarted();
event Voted(uint256 indexed tokenId, uint256 votingPeriod, address[] votedPools, uint256[] votesDeltaAmounts);
event TopPoolIdsWithWeightsSet(uint256[] poolIds, uint256[] pidWeights);
event VoterPoolValidatorUpdated(address indexed validator);
event VotingDurationUpdated(uint256 duration);
event MinimumLockTimeUpdated(uint256 lockTime);
event MinimumVotesPerPoolUpdated(uint256 minimum);
event OperatorUpdated(address indexed operator);
event ElevatedRewarderAdded(address indexed rewarder);
event ElevatedRewarderRemoved(address indexed rewarder);
struct VotingPeriod {
uint256 startTime;
uint256 endTime;
}
function getMasterChef() external view returns (IMasterChef);
function getTotalWeight() external view returns (uint256);
function getTopPoolIds() external view returns (uint256[] memory);
function getWeight(uint256 pid) external view returns (uint256);
function hasVoted(uint256 period, uint256 tokenId) external view returns (bool);
function getCurrentVotingPeriod() external view returns (uint256);
function getLatestFinishedPeriod() external view returns (uint256);
function getPeriodStartTime() external view returns (uint256);
function getPeriodStartEndtime(uint256 periodId) external view returns (uint256, uint256);
function getVotesPerPeriod(uint256 periodId, address pool) external view returns (uint256);
function getVotedPools() external view returns (address[] memory);
function getVotedPoolsLength() external view returns (uint256);
function getVotedPoolsAtIndex(uint256 index) external view returns (address, uint256);
function getTotalVotes() external view returns (uint256);
function getUserVotes(uint256 tokenId, address pool) external view returns (uint256);
function getPoolVotesPerPeriod(uint256 periodId, address pool) external view returns (uint256);
function getUserBribeRewaderAt(uint256 period, address account, uint256 index)
external
view
returns (IBribeRewarder);
function getUserBribeRewarderLength(uint256 period, address account) external view returns (uint256);
function getBribeRewarderAt(uint256 period, address pool, uint256 index) external view returns (IBribeRewarder);
function getBribeRewarderLength(uint256 period, address pool) external view returns (uint256);
function ownerOf(uint256 tokenId, address account) external view returns (bool);
function onRegister() external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Math} from "./Math.sol";
/**
* @title Amounts Library
* @dev A library that defines various functions for manipulating amounts of a key and a total.
* The key can be bytes32, address, or uint256.
*/
library Amounts {
using Math for uint256;
struct Parameter {
uint256 totalAmount;
mapping(bytes32 => uint256) amounts;
}
/**
* @dev Returns the amount of a key.
* @param amounts The storage pointer to the amounts.
* @param key The key of the amount.
* @return The amount of the key.
*/
function getAmountOf(Parameter storage amounts, bytes32 key) internal view returns (uint256) {
return amounts.amounts[key];
}
/**
* @dev Returns the amount of an address.
* @param amounts The storage pointer to the amounts.
* @param account The address of the amount.
* @return The amount of the address.
*/
function getAmountOf(Parameter storage amounts, address account) internal view returns (uint256) {
return getAmountOf(amounts, bytes32(uint256(uint160(account))));
}
/**
* @dev Returns the amount of an id.
* @param amounts The storage pointer to the amounts.
* @param id The id of the amount.
* @return The amount of the id.
*/
function getAmountOf(Parameter storage amounts, uint256 id) internal view returns (uint256) {
return getAmountOf(amounts, bytes32(id));
}
/**
* @dev Returns the total amount.
* @param amounts The storage pointer to the amounts.
* @return The total amount.
*/
function getTotalAmount(Parameter storage amounts) internal view returns (uint256) {
return amounts.totalAmount;
}
/**
* @dev Updates the amount of a key. The delta is added to the key amount and the total amount.
* @param amounts The storage pointer to the amounts.
* @param key The key of the amount.
* @param deltaAmount The delta amount to update.
* @return oldAmount The old amount of the key.
* @return newAmount The new amount of the key.
* @return oldTotalAmount The old total amount.
* @return newTotalAmount The new total amount.
*/
function update(Parameter storage amounts, bytes32 key, int256 deltaAmount)
internal
returns (uint256 oldAmount, uint256 newAmount, uint256 oldTotalAmount, uint256 newTotalAmount)
{
oldAmount = amounts.amounts[key];
oldTotalAmount = amounts.totalAmount;
if (deltaAmount == 0) {
newAmount = oldAmount;
newTotalAmount = oldTotalAmount;
} else {
newAmount = oldAmount.addDelta(deltaAmount);
newTotalAmount = oldTotalAmount.addDelta(deltaAmount);
amounts.amounts[key] = newAmount;
amounts.totalAmount = newTotalAmount;
}
}
/**
* @dev Updates the amount of an address. The delta is added to the address amount and the total amount.
* @param amounts The storage pointer to the amounts.
* @param account The address of the amount.
* @param deltaAmount The delta amount to update.
* @return oldAmount The old amount of the key.
* @return newAmount The new amount of the key.
* @return oldTotalAmount The old total amount.
* @return newTotalAmount The new total amount.
*/
function update(Parameter storage amounts, address account, int256 deltaAmount)
internal
returns (uint256 oldAmount, uint256 newAmount, uint256 oldTotalAmount, uint256 newTotalAmount)
{
return update(amounts, bytes32(uint256(uint160(account))), deltaAmount);
}
/**
* @dev Updates the amount of an id. The delta is added to the id amount and the total amount.
* @param amounts The storage pointer to the amounts.
* @param id The id of the amount.
* @param deltaAmount The delta amount to update.
* @return oldAmount The old amount of the key.
* @return newAmount The new amount of the key.
* @return oldTotalAmount The old total amount.
* @return newTotalAmount The new total amount.
*/
function update(Parameter storage amounts, uint256 id, int256 deltaAmount)
internal
returns (uint256 oldAmount, uint256 newAmount, uint256 oldTotalAmount, uint256 newTotalAmount)
{
return update(amounts, bytes32(id), deltaAmount);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title Constants Library
* @dev A library that defines various constants used throughout the codebase.
*/
library Constants {
uint256 internal constant ACC_PRECISION_BITS = 64;
uint256 internal constant PRECISION = 1e18;
uint256 internal constant MAX_NUMBER_OF_FARMS = 32;
uint256 internal constant MAX_NUMBER_OF_REWARDS = 32;
uint256 internal constant MAX_METRO_PER_SECOND = 10e18;
uint256 internal constant MAX_BRIBES_PER_POOL = 5;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @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 or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* 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.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @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`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Ownable
struct OwnableStorage {
address _owner;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
assembly {
$.slot := OwnableStorageLocation
}
}
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
OwnableStorage storage $ = _getOwnableStorage();
return $._owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
* {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
interface IRewarder {
function getToken() external view returns (IERC20);
function getCaller() external view returns (address);
function initialize(address initialOwner) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
import {IRewarder} from "./IRewarder.sol";
interface IBaseRewarder is IRewarder {
error BaseRewarder__NativeTransferFailed();
error BaseRewarder__InvalidCaller();
error BaseRewarder__Stopped();
error BaseRewarder__AlreadyStopped();
error BaseRewarder__NotNativeRewarder();
error BaseRewarder__ZeroAmount();
error BaseRewarder__ZeroReward();
error BaseRewarder__InvalidDuration();
error BaseRewarder__InvalidPid(uint256 pid);
error BaseRewarder__InvalidStartTimestamp(uint256 startTimestamp);
error BaseRewarder__CannotRenounceOwnership();
event Claim(address indexed account, IERC20 indexed token, uint256 reward);
event RewardParameterUpdated(uint256 rewardPerSecond, uint256 startTimestamp, uint256 endTimestamp);
event Stopped();
event Swept(IERC20 indexed token, address indexed account, uint256 amount);
function getToken() external view returns (IERC20);
function getCaller() external view returns (address);
function getPid() external view returns (uint256);
function getRewarderParameter()
external
view
returns (IERC20 token, uint256 rewardPerSecond, uint256 lastUpdateTimestamp, uint256 endTimestamp);
function getRemainingReward() external view returns (uint256);
function getPendingReward(address account, uint256 balance, uint256 totalSupply)
external
view
returns (IERC20 token, uint256 pendingReward);
function isStopped() external view returns (bool);
function initialize(address initialOwner) external;
function setRewardPerSecond(uint256 maxRewardPerSecond, uint256 expectedDuration)
external
returns (uint256 rewardPerSecond);
function setRewarderParameters(uint256 maxRewardPerSecond, uint256 startTimestamp, uint256 expectedDuration)
external
returns (uint256 rewardPerSecond);
function stop() external;
function sweep(IERC20 token, address account) external;
function onModify(address account, uint256 pid, uint256 oldBalance, uint256 newBalance, uint256 totalSupply)
external
returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IBaseRewarder} from "./IBaseRewarder.sol";
interface IMasterChefRewarder is IBaseRewarder {
error MasterChefRewarder__AlreadyLinked();
error MasterChefRewarder__NotLinked();
error MasterChefRewarder__UseUnlink();
enum Status {
Unlinked,
Linked,
Stopped
}
function link(uint256 pid) external;
function unlink(uint256 pid) external;
function onEmergency(address account, uint256 pid, uint256 oldBalance, uint256 newBalance, uint256 oldTotalSupply) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";
interface IMetro is IERC20 {
function mint(address account, uint256 amount) external returns (uint256);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Amounts} from "./Amounts.sol";
import {Constants} from "./Constants.sol";
/**
* @title Rewarder Library
* @dev A library that defines various functions for calculating rewards.
* It takes care about the reward debt and the accumulated debt per share.
*/
library Rewarder {
using Amounts for Amounts.Parameter;
struct Parameter {
uint256 lastUpdateTimestamp;
uint256 accDebtPerShare;
mapping(address => uint256) debt;
}
/**
* @dev Returns the debt associated with an amount.
* @param accDebtPerShare The accumulated debt per share.
* @param deposit The amount.
* @return The debt associated with the amount.
*/
function getDebt(uint256 accDebtPerShare, uint256 deposit) internal pure returns (uint256) {
return (deposit * accDebtPerShare) >> Constants.ACC_PRECISION_BITS;
}
/**
* @dev Returns the debt per share associated with a total deposit and total rewards.
* @param totalDeposit The total deposit.
* @param totalRewards The total rewards.
* @return The debt per share associated with the total deposit and total rewards.
*/
function getDebtPerShare(uint256 totalDeposit, uint256 totalRewards) internal pure returns (uint256) {
return totalDeposit == 0 ? 0 : (totalRewards << Constants.ACC_PRECISION_BITS) / totalDeposit;
}
/**
* @dev Returns the total rewards to emit.
* If the end timestamp is in the past, the rewards are calculated up to the end timestamp.
* If the last update timestamp is in the future, it will return 0.
* @param rewarder The storage pointer to the rewarder.
* @param rewardPerSecond The reward per second.
* @param endTimestamp The end timestamp.
* @param totalSupply The total supply.
* @return The total rewards.
*/
function getTotalRewards(
Parameter storage rewarder,
uint256 rewardPerSecond,
uint256 endTimestamp,
uint256 totalSupply
) internal view returns (uint256) {
if (totalSupply == 0) return 0;
uint256 lastUpdateTimestamp = rewarder.lastUpdateTimestamp;
uint256 timestamp = block.timestamp > endTimestamp ? endTimestamp : block.timestamp;
return timestamp > lastUpdateTimestamp ? (timestamp - lastUpdateTimestamp) * rewardPerSecond : 0;
}
/**
* @dev Returns the total rewards to emit.
* @param rewarder The storage pointer to the rewarder.
* @param rewardPerSecond The reward per second.
* @param totalSupply The total supply.
* @return The total rewards.
*/
function getTotalRewards(Parameter storage rewarder, uint256 rewardPerSecond, uint256 totalSupply)
internal
view
returns (uint256)
{
return getTotalRewards(rewarder, rewardPerSecond, block.timestamp, totalSupply);
}
/**
* @dev Returns the pending reward of an account.
* @param rewarder The storage pointer to the rewarder.
* @param amounts The storage pointer to the amounts.
* @param account The address of the account.
* @param totalRewards The total rewards.
* @return The pending reward of the account.
*/
function getPendingReward(
Parameter storage rewarder,
Amounts.Parameter storage amounts,
address account,
uint256 totalRewards
) internal view returns (uint256) {
return getPendingReward(rewarder, account, amounts.getAmountOf(account), amounts.getTotalAmount(), totalRewards);
}
/**
* @dev Returns the pending reward of an account.
* If the balance of the account is 0, it will always return 0.
* @param rewarder The storage pointer to the rewarder.
* @param account The address of the account.
* @param balance The balance of the account.
* @param totalSupply The total supply.
* @param totalRewards The total rewards.
* @return The pending reward of the account.
*/
function getPendingReward(
Parameter storage rewarder,
address account,
uint256 balance,
uint256 totalSupply,
uint256 totalRewards
) internal view returns (uint256) {
uint256 accDebtPerShare = rewarder.accDebtPerShare + getDebtPerShare(totalSupply, totalRewards);
return balance == 0 ? 0 : getDebt(accDebtPerShare, balance) - rewarder.debt[account];
}
/**
* @dev Updates the rewarder.
* If the balance of the account is 0, it will always return 0.
* @param rewarder The storage pointer to the rewarder.
* @param account The address of the account.
* @param oldBalance The old balance of the account.
* @param newBalance The new balance of the account.
* @param totalSupply The total supply.
* @param totalRewards The total rewards.
* @return rewards The rewards of the account.
*/
function update(
Parameter storage rewarder,
address account,
uint256 oldBalance,
uint256 newBalance,
uint256 totalSupply,
uint256 totalRewards
) internal returns (uint256 rewards) {
uint256 accDebtPerShare = updateAccDebtPerShare(rewarder, totalSupply, totalRewards);
rewards = oldBalance == 0 ? 0 : getDebt(accDebtPerShare, oldBalance) - rewarder.debt[account];
rewarder.debt[account] = getDebt(accDebtPerShare, newBalance);
}
/**
* @dev Updates the accumulated debt per share.
* If the last update timestamp is in the future, it will not update the last update timestamp.
* @param rewarder The storage pointer to the rewarder.
* @param totalSupply The total supply.
* @param totalRewards The total rewards.
* @return The accumulated debt per share.
*/
function updateAccDebtPerShare(Parameter storage rewarder, uint256 totalSupply, uint256 totalRewards)
internal
returns (uint256)
{
uint256 debtPerShare = getDebtPerShare(totalSupply, totalRewards);
if (block.timestamp > rewarder.lastUpdateTimestamp) rewarder.lastUpdateTimestamp = block.timestamp;
return debtPerShare == 0 ? rewarder.accDebtPerShare : rewarder.accDebtPerShare += debtPerShare;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title Math
* @dev Library for mathematical operations with overflow and underflow checks.
*/
library Math {
error Math__UnderOverflow();
uint256 internal constant MAX_INT256 = 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
/**
* @dev Adds a signed integer to an unsigned integer with overflow check.
* The result must be greater than or equal to 0 and less than or equal to MAX_INT256.
* @param x Unsigned integer to add to.
* @param delta Signed integer to add.
* @return y The result of the addition.
*/
function addDelta(uint256 x, int256 delta) internal pure returns (uint256 y) {
uint256 success;
assembly {
y := add(x, delta)
success := iszero(or(gt(x, MAX_INT256), gt(y, MAX_INT256)))
}
if (success == 0) revert Math__UnderOverflow();
}
/**
* @dev Safely converts an unsigned integer to a signed integer.
* @param x Unsigned integer to convert.
* @return y Signed integer result.
*/
function toInt256(uint256 x) internal pure returns (int256 y) {
if (x > MAX_INT256) revert Math__UnderOverflow();
return int256(x);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}{
"remappings": [
"ds-test/=lib/forge-std/lib/ds-test/src/",
"forge-std/=lib/forge-std/src/",
"openzeppelin/=lib/openzeppelin-contracts/contracts/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"solmate/=lib/solmate/",
"joe-v2/=lib/joe-v2/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
],
"optimizer": {
"enabled": true,
"runs": 800
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "shanghai",
"viaIR": false,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"contract IMasterChef","name":"masterChef","type":"address"},{"internalType":"contract IMetroStaking","name":"mlumStaking","type":"address"},{"internalType":"contract IRewarderFactory","name":"factory","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32","name":"key","type":"bytes32"}],"name":"EnumerableMapNonexistentKey","type":"error"},{"inputs":[],"name":"IVoter_VotingPeriodEnded","type":"error"},{"inputs":[],"name":"IVoter_VotingPeriodNotStarted","type":"error"},{"inputs":[],"name":"IVoter_ZeroValue","type":"error"},{"inputs":[],"name":"IVoter__AlreadyVoted","type":"error"},{"inputs":[{"internalType":"uint256","name":"pid","type":"uint256"}],"name":"IVoter__DuplicatePoolId","type":"error"},{"inputs":[],"name":"IVoter__EmergencyUnlock","type":"error"},{"inputs":[],"name":"IVoter__InsufficientLockTime","type":"error"},{"inputs":[],"name":"IVoter__InsufficientVotingPower","type":"error"},{"inputs":[],"name":"IVoter__InvalidLength","type":"error"},{"inputs":[],"name":"IVoter__NoFinishedPeriod","type":"error"},{"inputs":[],"name":"IVoter__NotOwner","type":"error"},{"inputs":[],"name":"IVoter__TooManyPoolIds","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"Voter__InvalidRegisterCaller","type":"error"},{"inputs":[],"name":"Voter__PoolNotVotable","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewarder","type":"address"}],"name":"ElevatedRewarderAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewarder","type":"address"}],"name":"ElevatedRewarderRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"lockTime","type":"uint256"}],"name":"MinimumLockTimeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minimum","type":"uint256"}],"name":"MinimumVotesPerPoolUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"}],"name":"OperatorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"poolIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"pidWeights","type":"uint256[]"}],"name":"TopPoolIdsWithWeightsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"votingPeriod","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"votedPools","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"votesDeltaAmounts","type":"uint256[]"}],"name":"Voted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"validator","type":"address"}],"name":"VoterPoolValidatorUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"VotingDurationUpdated","type":"event"},{"anonymous":false,"inputs":[],"name":"VotingPeriodStarted","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"rewarder","type":"address"}],"name":"addElevatedRewarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getBribeRewarderAt","outputs":[{"internalType":"contract IBribeRewarder","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"address","name":"pool","type":"address"}],"name":"getBribeRewarderLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentVotingPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLatestFinishedPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMasterChef","outputs":[{"internalType":"contract IMasterChef","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMinimumLockTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMinimumVotesPerPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMlumStaking","outputs":[{"internalType":"contract IMetroStaking","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPeriodDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"periodId","type":"uint256"}],"name":"getPeriodStartEndtime","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPeriodStartTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"}],"name":"getPoolVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"periodId","type":"uint256"},{"internalType":"address","name":"pool","type":"address"}],"name":"getPoolVotesPerPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTopPoolIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getUserBribeRewaderAt","outputs":[{"internalType":"contract IBribeRewarder","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"address","name":"account","type":"address"}],"name":"getUserBribeRewarderLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"pool","type":"address"}],"name":"getUserVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVotedPools","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getVotedPoolsAtIndex","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVotedPoolsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"periodId","type":"uint256"},{"internalType":"address","name":"pool","type":"address"}],"name":"getVotesPerPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"pid","type":"uint256"}],"name":"getWeight","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"periodId","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"hasVoted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"initialOwner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"onRegister","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"account","type":"address"}],"name":"ownerOf","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"rewarder","type":"address"}],"name":"removeElevatedRewarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"pids","type":"uint256[]"},{"internalType":"uint256[]","name":"weights","type":"uint256[]"}],"name":"setTopPoolIdsWithWeights","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startNewVotingPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"lockTime","type":"uint256"}],"name":"updateMinimumLockTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"votesPerPool","type":"uint256"}],"name":"updateMinimumVotesPerPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"updateOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"updatePeriodDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IVoterPoolValidator","name":"poolValidator","type":"address"}],"name":"updatePoolValidator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address[]","name":"pools","type":"address[]"},{"internalType":"uint256[]","name":"deltaAmounts","type":"uint256[]"}],"name":"vote","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60e06040526802b5e3af16b1880000600355621275006004556276a7006005553480156200002b575f80fd5b50604051620026d3380380620026d38339810160408190526200004e916200013f565b6200005862000076565b6001600160a01b0392831660805290821660a0521660c05262000190565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff1615620000c75760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b0390811614620001275780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6001600160a01b038116811462000127575f80fd5b5f805f6060848603121562000152575f80fd5b83516200015f816200012a565b602085015190935062000172816200012a565b604085015190925062000185816200012a565b809150509250925092565b60805160a05160c0516124fc620001d75f395f611aa101525f81816104f6015281816106c501528181610c7e01528181610d320152610e2d01525f61057c01526124fc5ff3fe608060405234801561000f575f80fd5b50600436106102d7575f3560e01c80637ac09bf711610187578063c4d66de8116100dd578063e1e4d41911610093578063e8d12fb21161006e578063e8d12fb214610661578063eaed4f831461069d578063f2fde38b146106a5575f80fd5b8063e1e4d4191461060f578063e30c397814610624578063e8abfd941461062c575f80fd5b8063d317dee9116100c3578063d317dee914610472578063d851fdfd146105bb578063dad82849146105da575f80fd5b8063c4d66de8146105a0578063c7b90cc3146105b3575f80fd5b80639a0e7d661161013d578063ae40bc7911610118578063ae40bc791461056b578063b36fec5714610572578063b56449631461057a575f80fd5b80639a0e7d6614610548578063ab95481e14610550578063ac7475ed14610558575f80fd5b80638588aca91161016d5780638588aca91461051a5780638c5f86031461052d5780638da5cb5b14610540575f80fd5b80637ac09bf7146104e157806383938552146104f4575f80fd5b8063442c74e61161023c5780636b54ae3e116101f257806372abb0c2116101cd57806372abb0c21461047257806379ba5097146104a75780637aa9ba39146104af575f80fd5b80636b54ae3e1461044f578063715018a614610457578063717cee7d1461045f575f80fd5b8063592ed1ab11610222578063592ed1ab1461040557806364390ff11461041a57806366f1b69214610447575f80fd5b8063442c74e6146103de5780634ff9537e146103f2575f80fd5b80631e7726af11610291578063281698d911610277578063281698d9146103835780632f87a28b14610396578063374cbcae146103a9575f80fd5b80631e7726af146103455780632458810514610358575f80fd5b80630f12fb71116102c15780630f12fb711461031557806316c284a11461032a5780631babad101461033d575f80fd5b8062f74867146102db57806306aba0e114610303575b5f80fd5b6102ee6102e9366004611f05565b6106b8565b60405190151581526020015b60405180910390f35b6011545b6040519081526020016102fa565b610328610323366004611f33565b610763565b005b610328610338366004611f4a565b6107c7565b600554610307565b610328610353366004611f4a565b610817565b61036b610366366004611f65565b610868565b6040516001600160a01b0390911681526020016102fa565b610328610391366004611fdb565b6108b7565b6103286103a4366004611f33565b610a97565b6103076103b7366004611f05565b5f9182526008602090815260408084206001600160a01b0393909316845291905290205490565b5f80548152600b6020526040902054610307565b610328610400366004611f4a565b610ad4565b61040d610b27565b6040516102fa9190612042565b6102ee61042836600461208e565b5f91825260016020908152604080842092845291905290205460ff1690565b600354610307565b610307610b38565b610328610b43565b61032861046d366004611f33565b610b56565b610307610480366004611f05565b5f9182526006602090815260408084206001600160a01b0393909316845291905290205490565b610328610bb3565b6104c26104bd366004611f33565b610bfb565b604080516001600160a01b0390931683526020830191909152016102fa565b6103286104ef3660046120ae565b610c11565b7f000000000000000000000000000000000000000000000000000000000000000061036b565b610307610528366004611f4a565b61115f565b61036b61053b366004611f65565b611182565b61036b6111b5565b600f54610307565b6103286111e9565b610328610566366004611f4a565b611264565b5f54610307565b600454610307565b7f000000000000000000000000000000000000000000000000000000000000000061036b565b6103286105ae366004611f4a565b6112b5565b6103286113bf565b6103076105c9366004611f33565b5f9081526010602052604090205490565b6103076105e8366004611f05565b5f9182526009602090815260408084206001600160a01b0393909316845291905290205490565b610617611624565b6040516102fa9190612122565b61036b611630565b61030761063a366004611f05565b5f918252600a602090815260408084206001600160a01b0393909316845291905290205490565b61068861066f366004611f33565b5f908152600b6020526040902080546001909101549091565b604080519283526020830191909152016102fa565b610307611658565b6103286106b3366004611f4a565b61169b565b5f816001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636352211e856040518263ffffffff1660e01b815260040161071191815260200190565b602060405180830381865afa15801561072c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107509190612159565b6001600160a01b03161490505b92915050565b61076b611720565b805f0361078b57604051632de8f7df60e11b815260040160405180910390fd5b60058190556040518181527f7a38c3c9f3e3dd64e7a2a1fbacea9c6c4eaedde596941be17850af6bd5eaaf6c906020015b60405180910390a150565b6107cf611720565b6001600160a01b0381165f81815260166020526040808220805460ff19169055517f3a30f115b98774118710a926d4e552492a349d8c8d131fd8b1e97c51b5c870d59190a250565b61081f611720565b601480546001600160a01b0319166001600160a01b0383169081179091556040517ff66cab3a5f4987ab7b2085fe95447581510be5297c2d38a88827535409421c08905f90a250565b5f8381526009602090815260408083206001600160a01b0386168452909152812080548390811061089b5761089b612174565b5f918252602090912001546001600160a01b0316949350505050565b6015546001600160a01b031633146108d1576108d1611720565b828181146108f25760405163070dea3960e11b815260040160405180910390fd5b5f6108fd6012611752565b8051909150156109625780515b8015610960575f8261091b8361219c565b9250828151811061092e5761092e612174565b6020026020010151905061094c81601261176590919063ffffffff16565b505f9081526010602052604081205561090a565b505b5f5b828110156109d2575f87878381811061097f5761097f612174565b90506020020135905061099c81601261177090919063ffffffff16565b6109c157604051635f43916760e01b8152600481018290526024015b60405180910390fd5b506109cb816121b1565b9050610964565b505f805b83811015610a4a575f8888838181106109f1576109f1612174565b9050602002013590505f878784818110610a0d57610a0d612174565b5f8581526010602090815260409091209102929092013591829055509050610a3581856121c9565b9350505080610a43906121b1565b90506109d6565b5060118190556040517fb09a8cc2d88ae837f40cde0ebd3b8c7eed43ec57844d12af93c0deeabb41b42e90610a86908990899089908990612225565b60405180910390a150505050505050565b610a9f611720565b60038190556040518181527fb9db7999b0374a08d39d31787f536625b090e330dfc74b5e807afc6f239fee64906020016107bc565b610adc611720565b6001600160a01b0381165f81815260166020526040808220805460ff19166001179055517fc50f30dac30a421d8993cfa45e447bcfd740729436dd05fbb0a511feb293245b9190a250565b6060610b33600c61177b565b905090565b5f610b33600c611787565b610b4b611720565b610b545f611791565b565b610b5e611720565b805f03610b7e57604051632de8f7df60e11b815260040160405180910390fd5b60048190556040518181527f8bfdfd03860750d17bbdb52e09d863153c6b782f8b752a66ada6e614c34f4ce3906020016107bc565b3380610bbd611630565b6001600160a01b031614610bef5760405163118cdaa760e01b81526001600160a01b03821660048201526024016109b8565b610bf881611791565b50565b5f80610c08600c846117cd565b91509150915091565b828114610c315760405163070dea3960e11b815260040160405180910390fd5b610c396117ea565b610c5657604051630d34d7ff60e01b815260040160405180910390fd5b610c5e611818565b15610c7c576040516350322c3f60e11b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316638380edb76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cd8573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cfc9190612256565b15610d1a5760405163abf2e32f60e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018690525f907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa158015610d7f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610da39190612159565b90506001600160a01b0381163314610dce5760405163af3f344d60e01b815260040160405180910390fd5b5f80548082526001602090815260408084208a85529091529091205460ff1615610e0b5760405163034b31dd60e11b815260040160405180910390fd5b6040516308521f7960e01b8152600481018890525f9081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906308521f799060240161010060405180830381865afa158015610e73573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e9791906122ba565b9050610ea281611841565b60208101515f5b88811015610ee757878782818110610ec357610ec3612174565b9050602002013584610ed591906121c9565b9350610ee0816121b1565b9050610ea9565b5080831115610f08576040516259b0eb60e51b815260040160405180910390fd5b50506014546001600160a01b03165f5b878110156110d8575f898983818110610f3357610f33612174565b9050602002016020810190610f489190611f4a565b90506001600160a01b03831615801590610fc75750604051638b1b925f60e01b81526001600160a01b038281166004830152841690638b1b925f90602401602060405180830381865afa158015610fa1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610fc59190612256565b155b15610fe557604051631b0b542960e31b815260040160405180910390fd5b5f888884818110610ff857610ff8612174565b5f8f8152600a602090815260408083206001600160a01b0389168452825282208054939091029490940135945084939250906110359084906121c9565b90915550505f8681526006602090815260408083206001600160a01b03861684529091528120805483929061106b9084906121c9565b9091555061107c9050600c836118bd565b156110aa576110a48282611091600c836118d1565b61109b91906121c9565b600c91906118e5565b506110b8565b6110b6600c83836118e5565b505b6110c55f54838984611902565b5050806110d1906121b1565b9050610f18565b5081600f5f8282546110ea91906121c9565b90915550505f8381526001602081815260408084208d855290915291829020805460ff191690911790555189907f988a5ed257015fba159d63226be24c8c12636d8b6061117c4a6bb1af9ae769539061114c9086908c908c908c908c90612348565b60405180910390a2505050505050505050565b5f61116b600c836118bd565b1561117b5761075d600c836118d1565b505f919050565b5f8381526008602090815260408083206001600160a01b0386168452909152812080548390811061089b5761089b612174565b5f807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005b546001600160a01b031692915050565b6015546001600160a01b0316331461120357611203611720565b5f80549080611211836121b1565b90915550505f80548152600b6020526040902042808255600454611234916121c9565b60018201556040517fa70f48122dbca2be85eee736914b947a897b4770ff5e51990e897c1f925e6e95905f90a150565b61126c611720565b601580546001600160a01b0319166001600160a01b0383169081179091556040517fb3b3f5f64ab192e4b5fefde1f51ce9733bbdcf831951543b325aebd49cc27ec4905f90a250565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0080546002919068010000000000000000900460ff16806113045750805467ffffffffffffffff808416911610155b156113225760405163f92ee8a960e01b815260040160405180910390fd5b805468ffffffffffffffffff191667ffffffffffffffff8316176801000000000000000017815561135283611a6f565b6802b5e3af16b1880000600355621275006004556276a700600555805468ff00000000000000001916815560405167ffffffffffffffff831681527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a1505050565b336113c981611a80565b5f80546001600160a01b038316808352601660205260408084205481516348a1edd560e01b81529151939460ff909116939092839290916348a1edd59160048082019286929091908290030181865afa158015611428573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261144f91908101906123b5565b915091505f5b81518110156115f6578482828151811061147157611471612174565b602002602001015110156114c75760405162461bcd60e51b815260206004820152600c60248201527f77726f6e6720706572696f64000000000000000000000000000000000000000060448201526064016109b8565b600560095f8484815181106114de576114de612174565b602002602001015181526020019081526020015f205f856001600160a01b03166001600160a01b031681526020019081526020015f2080549050600161152491906121c9565b11158061152e5750835b61157a5760405162461bcd60e51b815260206004820152600f60248201527f746f6f206d75636820627269626573000000000000000000000000000000000060448201526064016109b8565b60095f83838151811061158f5761158f612174565b60209081029190910181015182528181019290925260409081015f9081206001600160a01b038781168352908452918120805460018101825590825292902090910180546001600160a01b0319169188169190911790556115ef816121b1565b9050611455565b50821561161d576001600160a01b0385165f908152601660205260409020805460ff191690555b5050505050565b6060610b336012611752565b5f807f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c006111d9565b5f611661611818565b1561166c57505f5490565b5f545f0361168d57604051634bad693960e11b815260040160405180910390fd5b60015f54610b33919061246d565b6116a3611720565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b0319166001600160a01b03831690811782556116e76111b5565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a35050565b336117296111b5565b6001600160a01b031614610b545760405163118cdaa760e01b81523360048201526024016109b8565b60605f61175e83611b39565b9392505050565b5f61175e8383611b92565b5f61175e8383611c75565b60605f61175e83611cc1565b5f61075d82611ccc565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b03191681556117c982611cd6565b5050565b5f8080806117db8686611d46565b909450925050505b9250929050565b5f80548152600b602052604081205415801590610b335750505f80548152600b602052604090205442101590565b5f6118216117ea565b8015610b335750505f80548152600b602052604090206001015442101590565b600554816060015110156118685760405163ed1abb5760e01b815260040160405180910390fd5b5f80548152600b6020526040902060010154428111156117c9575f61188d428361246d565b90508061189984611d6f565b10156118b85760405163ed1abb5760e01b815260040160405180910390fd5b505050565b5f61175e836001600160a01b038416611db4565b5f61175e836001600160a01b038416611dbf565b5f6118fa846001600160a01b03851684611e05565b949350505050565b5f8481526009602090815260408083206001600160a01b03871684529091528120905b8154811015611a67575f6001600160a01b031682828154811061194a5761194a612174565b5f918252602090912001546001600160a01b031614611a575781818154811061197557611975612174565b5f9182526020909120015460405163bc157ac160e01b8152600481018890526001600160a01b038681166024830152604482018690529091169063bc157ac1906064015f604051808303815f87803b1580156119cf575f80fd5b505af11580156119e1573d5f803e3d5ffd5b5050505f8781526008602090815260408083206001600160a01b038916845290915290208354909150839083908110611a1c57611a1c612174565b5f9182526020808320909101548354600181018555938352912090910180546001600160a01b0319166001600160a01b039092169190911790555b611a60816121b1565b9050611925565b505050505050565b611a77611e21565b610bf881611e6f565b6002604051634f4ee65b60e11b81526001600160a01b0383811660048301527f00000000000000000000000000000000000000000000000000000000000000001690639e9dccb690602401602060405180830381865afa158015611ae6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611b0a9190612494565b6002811115611b1b57611b1b612480565b14610bf857604051630fa3eda760e31b815260040160405180910390fd5b6060815f01805480602002602001604051908101604052809291908181526020018280548015611b8657602002820191905f5260205f20905b815481526020019060010190808311611b72575b50505050509050919050565b5f8181526001830160205260408120548015611c6c575f611bb460018361246d565b85549091505f90611bc79060019061246d565b9050808214611c26575f865f018281548110611be557611be5612174565b905f5260205f200154905080875f018481548110611c0557611c05612174565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080611c3757611c376124b2565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f90556001935050505061075d565b5f91505061075d565b5f818152600183016020526040812054611cba57508154600181810184555f84815260208082209093018490558454848252828601909352604090209190915561075d565b505f61075d565b606061075d82611752565b5f61075d82611ea0565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b5f8080611d538585611ea9565b5f81815260029690960160205260409095205494959350505050565b608081015160408201515f9142918291611d88916121c9565b11611d9557505f92915050565b8083608001518460400151611daa91906121c9565b61175e919061246d565b5f61175e8383611eb4565b5f81815260028301602052604081205480158015611de45750611de28484611db4565b155b1561175e5760405163015ab34360e11b8152600481018490526024016109b8565b5f82815260028401602052604081208290556118fa8484611770565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16610b5457604051631afcd79f60e31b815260040160405180910390fd5b611e77611e21565b6001600160a01b038116610bef57604051631e4fbdf760e01b81525f60048201526024016109b8565b5f61075d825490565b5f61175e8383611ecb565b5f818152600183016020526040812054151561175e565b5f825f018281548110611ee057611ee0612174565b905f5260205f200154905092915050565b6001600160a01b0381168114610bf8575f80fd5b5f8060408385031215611f16575f80fd5b823591506020830135611f2881611ef1565b809150509250929050565b5f60208284031215611f43575f80fd5b5035919050565b5f60208284031215611f5a575f80fd5b813561175e81611ef1565b5f805f60608486031215611f77575f80fd5b833592506020840135611f8981611ef1565b929592945050506040919091013590565b5f8083601f840112611faa575f80fd5b50813567ffffffffffffffff811115611fc1575f80fd5b6020830191508360208260051b85010111156117e3575f80fd5b5f805f8060408587031215611fee575f80fd5b843567ffffffffffffffff80821115612005575f80fd5b61201188838901611f9a565b90965094506020870135915080821115612029575f80fd5b5061203687828801611f9a565b95989497509550505050565b602080825282518282018190525f9190848201906040850190845b818110156120825783516001600160a01b03168352928401929184019160010161205d565b50909695505050505050565b5f806040838503121561209f575f80fd5b50508035926020909101359150565b5f805f805f606086880312156120c2575f80fd5b85359450602086013567ffffffffffffffff808211156120e0575f80fd5b6120ec89838a01611f9a565b90965094506040880135915080821115612104575f80fd5b5061211188828901611f9a565b969995985093965092949392505050565b602080825282518282018190525f9190848201906040850190845b818110156120825783518352928401929184019160010161213d565b5f60208284031215612169575f80fd5b815161175e81611ef1565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b5f816121aa576121aa612188565b505f190190565b5f600182016121c2576121c2612188565b5060010190565b8082018082111561075d5761075d612188565b8183525f7f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83111561220c575f80fd5b8260051b80836020870137939093016020019392505050565b604081525f6122386040830186886121dc565b828103602084015261224b8185876121dc565b979650505050505050565b5f60208284031215612266575f80fd5b8151801515811461175e575f80fd5b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff811182821017156122b2576122b2612275565b604052919050565b5f6101008083850312156122cc575f80fd5b6040519081019067ffffffffffffffff821181831017156122ef576122ef612275565b81604052835181526020840151602082015260408401516040820152606084015160608201526080840151608082015260a084015160a082015260c084015160c082015260e084015160e0820152809250505092915050565b858152606060208083018290529082018590525f90869060808401835b8881101561239357833561237881611ef1565b6001600160a01b031682529282019290820190600101612365565b5084810360408601526123a78187896121dc565b9a9950505050505050505050565b5f80604083850312156123c6575f80fd5b82516123d181611ef1565b8092505060208084015167ffffffffffffffff808211156123f0575f80fd5b818601915086601f830112612403575f80fd5b81518181111561241557612415612275565b8060051b9150612426848301612289565b818152918301840191848101908984111561243f575f80fd5b938501935b8385101561245d57845182529385019390850190612444565b8096505050505050509250929050565b8181038181111561075d5761075d612188565b634e487b7160e01b5f52602160045260245ffd5b5f602082840312156124a4575f80fd5b81516003811061175e575f80fd5b634e487b7160e01b5f52603160045260245ffdfea26469706673582212205842a48f26bda172c6a2a460d69de4aed92fc8deb830c540b8ce8050ef14f89a64736f6c634300081400330000000000000000000000001a5ded6adcfc64acede86151b1f142088c6e03da000000000000000000000000dcbc470ec51480f6ce58e7a2a1787ac8cddf6bc8000000000000000000000000d9db92613867fe0d290ce64fe737e2f8b80cadc3
Deployed Bytecode
0x608060405234801561000f575f80fd5b50600436106102d7575f3560e01c80637ac09bf711610187578063c4d66de8116100dd578063e1e4d41911610093578063e8d12fb21161006e578063e8d12fb214610661578063eaed4f831461069d578063f2fde38b146106a5575f80fd5b8063e1e4d4191461060f578063e30c397814610624578063e8abfd941461062c575f80fd5b8063d317dee9116100c3578063d317dee914610472578063d851fdfd146105bb578063dad82849146105da575f80fd5b8063c4d66de8146105a0578063c7b90cc3146105b3575f80fd5b80639a0e7d661161013d578063ae40bc7911610118578063ae40bc791461056b578063b36fec5714610572578063b56449631461057a575f80fd5b80639a0e7d6614610548578063ab95481e14610550578063ac7475ed14610558575f80fd5b80638588aca91161016d5780638588aca91461051a5780638c5f86031461052d5780638da5cb5b14610540575f80fd5b80637ac09bf7146104e157806383938552146104f4575f80fd5b8063442c74e61161023c5780636b54ae3e116101f257806372abb0c2116101cd57806372abb0c21461047257806379ba5097146104a75780637aa9ba39146104af575f80fd5b80636b54ae3e1461044f578063715018a614610457578063717cee7d1461045f575f80fd5b8063592ed1ab11610222578063592ed1ab1461040557806364390ff11461041a57806366f1b69214610447575f80fd5b8063442c74e6146103de5780634ff9537e146103f2575f80fd5b80631e7726af11610291578063281698d911610277578063281698d9146103835780632f87a28b14610396578063374cbcae146103a9575f80fd5b80631e7726af146103455780632458810514610358575f80fd5b80630f12fb71116102c15780630f12fb711461031557806316c284a11461032a5780631babad101461033d575f80fd5b8062f74867146102db57806306aba0e114610303575b5f80fd5b6102ee6102e9366004611f05565b6106b8565b60405190151581526020015b60405180910390f35b6011545b6040519081526020016102fa565b610328610323366004611f33565b610763565b005b610328610338366004611f4a565b6107c7565b600554610307565b610328610353366004611f4a565b610817565b61036b610366366004611f65565b610868565b6040516001600160a01b0390911681526020016102fa565b610328610391366004611fdb565b6108b7565b6103286103a4366004611f33565b610a97565b6103076103b7366004611f05565b5f9182526008602090815260408084206001600160a01b0393909316845291905290205490565b5f80548152600b6020526040902054610307565b610328610400366004611f4a565b610ad4565b61040d610b27565b6040516102fa9190612042565b6102ee61042836600461208e565b5f91825260016020908152604080842092845291905290205460ff1690565b600354610307565b610307610b38565b610328610b43565b61032861046d366004611f33565b610b56565b610307610480366004611f05565b5f9182526006602090815260408084206001600160a01b0393909316845291905290205490565b610328610bb3565b6104c26104bd366004611f33565b610bfb565b604080516001600160a01b0390931683526020830191909152016102fa565b6103286104ef3660046120ae565b610c11565b7f000000000000000000000000dcbc470ec51480f6ce58e7a2a1787ac8cddf6bc861036b565b610307610528366004611f4a565b61115f565b61036b61053b366004611f65565b611182565b61036b6111b5565b600f54610307565b6103286111e9565b610328610566366004611f4a565b611264565b5f54610307565b600454610307565b7f0000000000000000000000001a5ded6adcfc64acede86151b1f142088c6e03da61036b565b6103286105ae366004611f4a565b6112b5565b6103286113bf565b6103076105c9366004611f33565b5f9081526010602052604090205490565b6103076105e8366004611f05565b5f9182526009602090815260408084206001600160a01b0393909316845291905290205490565b610617611624565b6040516102fa9190612122565b61036b611630565b61030761063a366004611f05565b5f918252600a602090815260408084206001600160a01b0393909316845291905290205490565b61068861066f366004611f33565b5f908152600b6020526040902080546001909101549091565b604080519283526020830191909152016102fa565b610307611658565b6103286106b3366004611f4a565b61169b565b5f816001600160a01b03167f000000000000000000000000dcbc470ec51480f6ce58e7a2a1787ac8cddf6bc86001600160a01b0316636352211e856040518263ffffffff1660e01b815260040161071191815260200190565b602060405180830381865afa15801561072c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107509190612159565b6001600160a01b03161490505b92915050565b61076b611720565b805f0361078b57604051632de8f7df60e11b815260040160405180910390fd5b60058190556040518181527f7a38c3c9f3e3dd64e7a2a1fbacea9c6c4eaedde596941be17850af6bd5eaaf6c906020015b60405180910390a150565b6107cf611720565b6001600160a01b0381165f81815260166020526040808220805460ff19169055517f3a30f115b98774118710a926d4e552492a349d8c8d131fd8b1e97c51b5c870d59190a250565b61081f611720565b601480546001600160a01b0319166001600160a01b0383169081179091556040517ff66cab3a5f4987ab7b2085fe95447581510be5297c2d38a88827535409421c08905f90a250565b5f8381526009602090815260408083206001600160a01b0386168452909152812080548390811061089b5761089b612174565b5f918252602090912001546001600160a01b0316949350505050565b6015546001600160a01b031633146108d1576108d1611720565b828181146108f25760405163070dea3960e11b815260040160405180910390fd5b5f6108fd6012611752565b8051909150156109625780515b8015610960575f8261091b8361219c565b9250828151811061092e5761092e612174565b6020026020010151905061094c81601261176590919063ffffffff16565b505f9081526010602052604081205561090a565b505b5f5b828110156109d2575f87878381811061097f5761097f612174565b90506020020135905061099c81601261177090919063ffffffff16565b6109c157604051635f43916760e01b8152600481018290526024015b60405180910390fd5b506109cb816121b1565b9050610964565b505f805b83811015610a4a575f8888838181106109f1576109f1612174565b9050602002013590505f878784818110610a0d57610a0d612174565b5f8581526010602090815260409091209102929092013591829055509050610a3581856121c9565b9350505080610a43906121b1565b90506109d6565b5060118190556040517fb09a8cc2d88ae837f40cde0ebd3b8c7eed43ec57844d12af93c0deeabb41b42e90610a86908990899089908990612225565b60405180910390a150505050505050565b610a9f611720565b60038190556040518181527fb9db7999b0374a08d39d31787f536625b090e330dfc74b5e807afc6f239fee64906020016107bc565b610adc611720565b6001600160a01b0381165f81815260166020526040808220805460ff19166001179055517fc50f30dac30a421d8993cfa45e447bcfd740729436dd05fbb0a511feb293245b9190a250565b6060610b33600c61177b565b905090565b5f610b33600c611787565b610b4b611720565b610b545f611791565b565b610b5e611720565b805f03610b7e57604051632de8f7df60e11b815260040160405180910390fd5b60048190556040518181527f8bfdfd03860750d17bbdb52e09d863153c6b782f8b752a66ada6e614c34f4ce3906020016107bc565b3380610bbd611630565b6001600160a01b031614610bef5760405163118cdaa760e01b81526001600160a01b03821660048201526024016109b8565b610bf881611791565b50565b5f80610c08600c846117cd565b91509150915091565b828114610c315760405163070dea3960e11b815260040160405180910390fd5b610c396117ea565b610c5657604051630d34d7ff60e01b815260040160405180910390fd5b610c5e611818565b15610c7c576040516350322c3f60e11b815260040160405180910390fd5b7f000000000000000000000000dcbc470ec51480f6ce58e7a2a1787ac8cddf6bc86001600160a01b0316638380edb76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cd8573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610cfc9190612256565b15610d1a5760405163abf2e32f60e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018690525f907f000000000000000000000000dcbc470ec51480f6ce58e7a2a1787ac8cddf6bc86001600160a01b031690636352211e90602401602060405180830381865afa158015610d7f573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610da39190612159565b90506001600160a01b0381163314610dce5760405163af3f344d60e01b815260040160405180910390fd5b5f80548082526001602090815260408084208a85529091529091205460ff1615610e0b5760405163034b31dd60e11b815260040160405180910390fd5b6040516308521f7960e01b8152600481018890525f9081906001600160a01b037f000000000000000000000000dcbc470ec51480f6ce58e7a2a1787ac8cddf6bc816906308521f799060240161010060405180830381865afa158015610e73573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e9791906122ba565b9050610ea281611841565b60208101515f5b88811015610ee757878782818110610ec357610ec3612174565b9050602002013584610ed591906121c9565b9350610ee0816121b1565b9050610ea9565b5080831115610f08576040516259b0eb60e51b815260040160405180910390fd5b50506014546001600160a01b03165f5b878110156110d8575f898983818110610f3357610f33612174565b9050602002016020810190610f489190611f4a565b90506001600160a01b03831615801590610fc75750604051638b1b925f60e01b81526001600160a01b038281166004830152841690638b1b925f90602401602060405180830381865afa158015610fa1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610fc59190612256565b155b15610fe557604051631b0b542960e31b815260040160405180910390fd5b5f888884818110610ff857610ff8612174565b5f8f8152600a602090815260408083206001600160a01b0389168452825282208054939091029490940135945084939250906110359084906121c9565b90915550505f8681526006602090815260408083206001600160a01b03861684529091528120805483929061106b9084906121c9565b9091555061107c9050600c836118bd565b156110aa576110a48282611091600c836118d1565b61109b91906121c9565b600c91906118e5565b506110b8565b6110b6600c83836118e5565b505b6110c55f54838984611902565b5050806110d1906121b1565b9050610f18565b5081600f5f8282546110ea91906121c9565b90915550505f8381526001602081815260408084208d855290915291829020805460ff191690911790555189907f988a5ed257015fba159d63226be24c8c12636d8b6061117c4a6bb1af9ae769539061114c9086908c908c908c908c90612348565b60405180910390a2505050505050505050565b5f61116b600c836118bd565b1561117b5761075d600c836118d1565b505f919050565b5f8381526008602090815260408083206001600160a01b0386168452909152812080548390811061089b5761089b612174565b5f807f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005b546001600160a01b031692915050565b6015546001600160a01b0316331461120357611203611720565b5f80549080611211836121b1565b90915550505f80548152600b6020526040902042808255600454611234916121c9565b60018201556040517fa70f48122dbca2be85eee736914b947a897b4770ff5e51990e897c1f925e6e95905f90a150565b61126c611720565b601580546001600160a01b0319166001600160a01b0383169081179091556040517fb3b3f5f64ab192e4b5fefde1f51ce9733bbdcf831951543b325aebd49cc27ec4905f90a250565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0080546002919068010000000000000000900460ff16806113045750805467ffffffffffffffff808416911610155b156113225760405163f92ee8a960e01b815260040160405180910390fd5b805468ffffffffffffffffff191667ffffffffffffffff8316176801000000000000000017815561135283611a6f565b6802b5e3af16b1880000600355621275006004556276a700600555805468ff00000000000000001916815560405167ffffffffffffffff831681527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a1505050565b336113c981611a80565b5f80546001600160a01b038316808352601660205260408084205481516348a1edd560e01b81529151939460ff909116939092839290916348a1edd59160048082019286929091908290030181865afa158015611428573d5f803e3d5ffd5b505050506040513d5f823e601f3d908101601f1916820160405261144f91908101906123b5565b915091505f5b81518110156115f6578482828151811061147157611471612174565b602002602001015110156114c75760405162461bcd60e51b815260206004820152600c60248201527f77726f6e6720706572696f64000000000000000000000000000000000000000060448201526064016109b8565b600560095f8484815181106114de576114de612174565b602002602001015181526020019081526020015f205f856001600160a01b03166001600160a01b031681526020019081526020015f2080549050600161152491906121c9565b11158061152e5750835b61157a5760405162461bcd60e51b815260206004820152600f60248201527f746f6f206d75636820627269626573000000000000000000000000000000000060448201526064016109b8565b60095f83838151811061158f5761158f612174565b60209081029190910181015182528181019290925260409081015f9081206001600160a01b038781168352908452918120805460018101825590825292902090910180546001600160a01b0319169188169190911790556115ef816121b1565b9050611455565b50821561161d576001600160a01b0385165f908152601660205260409020805460ff191690555b5050505050565b6060610b336012611752565b5f807f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c006111d9565b5f611661611818565b1561166c57505f5490565b5f545f0361168d57604051634bad693960e11b815260040160405180910390fd5b60015f54610b33919061246d565b6116a3611720565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b0319166001600160a01b03831690811782556116e76111b5565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a35050565b336117296111b5565b6001600160a01b031614610b545760405163118cdaa760e01b81523360048201526024016109b8565b60605f61175e83611b39565b9392505050565b5f61175e8383611b92565b5f61175e8383611c75565b60605f61175e83611cc1565b5f61075d82611ccc565b7f237e158222e3e6968b72b9db0d8043aacf074ad9f650f0d1606b4d82ee432c0080546001600160a01b03191681556117c982611cd6565b5050565b5f8080806117db8686611d46565b909450925050505b9250929050565b5f80548152600b602052604081205415801590610b335750505f80548152600b602052604090205442101590565b5f6118216117ea565b8015610b335750505f80548152600b602052604090206001015442101590565b600554816060015110156118685760405163ed1abb5760e01b815260040160405180910390fd5b5f80548152600b6020526040902060010154428111156117c9575f61188d428361246d565b90508061189984611d6f565b10156118b85760405163ed1abb5760e01b815260040160405180910390fd5b505050565b5f61175e836001600160a01b038416611db4565b5f61175e836001600160a01b038416611dbf565b5f6118fa846001600160a01b03851684611e05565b949350505050565b5f8481526009602090815260408083206001600160a01b03871684529091528120905b8154811015611a67575f6001600160a01b031682828154811061194a5761194a612174565b5f918252602090912001546001600160a01b031614611a575781818154811061197557611975612174565b5f9182526020909120015460405163bc157ac160e01b8152600481018890526001600160a01b038681166024830152604482018690529091169063bc157ac1906064015f604051808303815f87803b1580156119cf575f80fd5b505af11580156119e1573d5f803e3d5ffd5b5050505f8781526008602090815260408083206001600160a01b038916845290915290208354909150839083908110611a1c57611a1c612174565b5f9182526020808320909101548354600181018555938352912090910180546001600160a01b0319166001600160a01b039092169190911790555b611a60816121b1565b9050611925565b505050505050565b611a77611e21565b610bf881611e6f565b6002604051634f4ee65b60e11b81526001600160a01b0383811660048301527f000000000000000000000000d9db92613867fe0d290ce64fe737e2f8b80cadc31690639e9dccb690602401602060405180830381865afa158015611ae6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611b0a9190612494565b6002811115611b1b57611b1b612480565b14610bf857604051630fa3eda760e31b815260040160405180910390fd5b6060815f01805480602002602001604051908101604052809291908181526020018280548015611b8657602002820191905f5260205f20905b815481526020019060010190808311611b72575b50505050509050919050565b5f8181526001830160205260408120548015611c6c575f611bb460018361246d565b85549091505f90611bc79060019061246d565b9050808214611c26575f865f018281548110611be557611be5612174565b905f5260205f200154905080875f018481548110611c0557611c05612174565b5f918252602080832090910192909255918252600188019052604090208390555b8554869080611c3757611c376124b2565b600190038181905f5260205f20015f90559055856001015f8681526020019081526020015f205f90556001935050505061075d565b5f91505061075d565b5f818152600183016020526040812054611cba57508154600181810184555f84815260208082209093018490558454848252828601909352604090209190915561075d565b505f61075d565b606061075d82611752565b5f61075d82611ea0565b7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930080546001600160a01b031981166001600160a01b03848116918217845560405192169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a3505050565b5f8080611d538585611ea9565b5f81815260029690960160205260409095205494959350505050565b608081015160408201515f9142918291611d88916121c9565b11611d9557505f92915050565b8083608001518460400151611daa91906121c9565b61175e919061246d565b5f61175e8383611eb4565b5f81815260028301602052604081205480158015611de45750611de28484611db4565b155b1561175e5760405163015ab34360e11b8152600481018490526024016109b8565b5f82815260028401602052604081208290556118fa8484611770565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff16610b5457604051631afcd79f60e31b815260040160405180910390fd5b611e77611e21565b6001600160a01b038116610bef57604051631e4fbdf760e01b81525f60048201526024016109b8565b5f61075d825490565b5f61175e8383611ecb565b5f818152600183016020526040812054151561175e565b5f825f018281548110611ee057611ee0612174565b905f5260205f200154905092915050565b6001600160a01b0381168114610bf8575f80fd5b5f8060408385031215611f16575f80fd5b823591506020830135611f2881611ef1565b809150509250929050565b5f60208284031215611f43575f80fd5b5035919050565b5f60208284031215611f5a575f80fd5b813561175e81611ef1565b5f805f60608486031215611f77575f80fd5b833592506020840135611f8981611ef1565b929592945050506040919091013590565b5f8083601f840112611faa575f80fd5b50813567ffffffffffffffff811115611fc1575f80fd5b6020830191508360208260051b85010111156117e3575f80fd5b5f805f8060408587031215611fee575f80fd5b843567ffffffffffffffff80821115612005575f80fd5b61201188838901611f9a565b90965094506020870135915080821115612029575f80fd5b5061203687828801611f9a565b95989497509550505050565b602080825282518282018190525f9190848201906040850190845b818110156120825783516001600160a01b03168352928401929184019160010161205d565b50909695505050505050565b5f806040838503121561209f575f80fd5b50508035926020909101359150565b5f805f805f606086880312156120c2575f80fd5b85359450602086013567ffffffffffffffff808211156120e0575f80fd5b6120ec89838a01611f9a565b90965094506040880135915080821115612104575f80fd5b5061211188828901611f9a565b969995985093965092949392505050565b602080825282518282018190525f9190848201906040850190845b818110156120825783518352928401929184019160010161213d565b5f60208284031215612169575f80fd5b815161175e81611ef1565b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b5f816121aa576121aa612188565b505f190190565b5f600182016121c2576121c2612188565b5060010190565b8082018082111561075d5761075d612188565b8183525f7f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83111561220c575f80fd5b8260051b80836020870137939093016020019392505050565b604081525f6122386040830186886121dc565b828103602084015261224b8185876121dc565b979650505050505050565b5f60208284031215612266575f80fd5b8151801515811461175e575f80fd5b634e487b7160e01b5f52604160045260245ffd5b604051601f8201601f1916810167ffffffffffffffff811182821017156122b2576122b2612275565b604052919050565b5f6101008083850312156122cc575f80fd5b6040519081019067ffffffffffffffff821181831017156122ef576122ef612275565b81604052835181526020840151602082015260408401516040820152606084015160608201526080840151608082015260a084015160a082015260c084015160c082015260e084015160e0820152809250505092915050565b858152606060208083018290529082018590525f90869060808401835b8881101561239357833561237881611ef1565b6001600160a01b031682529282019290820190600101612365565b5084810360408601526123a78187896121dc565b9a9950505050505050505050565b5f80604083850312156123c6575f80fd5b82516123d181611ef1565b8092505060208084015167ffffffffffffffff808211156123f0575f80fd5b818601915086601f830112612403575f80fd5b81518181111561241557612415612275565b8060051b9150612426848301612289565b818152918301840191848101908984111561243f575f80fd5b938501935b8385101561245d57845182529385019390850190612444565b8096505050505050509250929050565b8181038181111561075d5761075d612188565b634e487b7160e01b5f52602160045260245ffd5b5f602082840312156124a4575f80fd5b81516003811061175e575f80fd5b634e487b7160e01b5f52603160045260245ffdfea26469706673582212205842a48f26bda172c6a2a460d69de4aed92fc8deb830c540b8ce8050ef14f89a64736f6c63430008140033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000001a5ded6adcfc64acede86151b1f142088c6e03da000000000000000000000000dcbc470ec51480f6ce58e7a2a1787ac8cddf6bc8000000000000000000000000d9db92613867fe0d290ce64fe737e2f8b80cadc3
-----Decoded View---------------
Arg [0] : masterChef (address): 0x1a5Ded6adCfc64aceDE86151B1F142088C6E03da
Arg [1] : mlumStaking (address): 0xDcbC470ec51480f6cE58E7a2a1787AC8cdDF6Bc8
Arg [2] : factory (address): 0xd9db92613867FE0d290CE64Fe737E2F8B80CADc3
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000001a5ded6adcfc64acede86151b1f142088c6e03da
Arg [1] : 000000000000000000000000dcbc470ec51480f6ce58e7a2a1787ac8cddf6bc8
Arg [2] : 000000000000000000000000d9db92613867fe0d290ce64fe737e2f8b80cadc3
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in S
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.