Overview
S Balance
0 S
S Value
-More Info
Private Name Tags
ContractCreator
Latest 2 internal transactions
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
631730 | 11 hrs ago | Contract Creation | 0 S | |||
631730 | 11 hrs ago | Contract Creation | 0 S |
Loading...
Loading
Contract Name:
VotingRewardsFactory
Compiler Version
v0.8.19+commit.7dd6d404
Contract Source Code (Solidity)
/** *Submitted for verification at SonicScan.org on 2024-12-18 */ // SPDX-License-Identifier: GPL-3.0-or-later // Hydrometer combines powerful liquidity incentives, low slippage, and a vote-locked governance model using $HYDRO and $veHYDRO tokens, ensuring an innovative and decentralized experience for all users. //https://x.com/Hydrometer_Fi pragma solidity 0.8.19; interface IVotingRewardsFactory { /// @notice creates a BribeVotingReward and a FeesVotingReward contract for a gauge /// @param _forwarder Address of trusted forwarder /// @param _rewards Addresses of pool tokens to be used as valid rewards tokens /// @return feesVotingReward Address of FeesVotingReward contract created /// @return bribeVotingReward Address of BribeVotingReward contract created function createRewards( address _forwarder, address[] memory _rewards ) external returns (address feesVotingReward, address bribeVotingReward); } // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } } interface IReward { error InvalidReward(); error NotAuthorized(); error NotGauge(); error NotEscrowToken(); error NotSingleToken(); error NotVotingEscrow(); error NotWhitelisted(); error ZeroAmount(); event Deposit(address indexed from, uint256 indexed tokenId, uint256 amount); event Withdraw(address indexed from, uint256 indexed tokenId, uint256 amount); event NotifyReward(address indexed from, address indexed reward, uint256 indexed epoch, uint256 amount); event ClaimRewards(address indexed from, address indexed reward, uint256 amount); /// @notice A checkpoint for marking balance struct Checkpoint { uint256 timestamp; uint256 balanceOf; } /// @notice A checkpoint for marking supply struct SupplyCheckpoint { uint256 timestamp; uint256 supply; } /// @notice Epoch duration constant (7 days) function DURATION() external view returns (uint256); /// @notice Address of Voter.sol function voter() external view returns (address); /// @notice Address of VotingEscrow.sol function ve() external view returns (address); /// @dev Address which has permission to externally call _deposit() & _withdraw() function authorized() external view returns (address); /// @notice Total amount currently deposited via _deposit() function totalSupply() external view returns (uint256); /// @notice Current amount deposited by tokenId function balanceOf(uint256 tokenId) external view returns (uint256); /// @notice Amount of tokens to reward depositors for a given epoch /// @param token Address of token to reward /// @param epochStart Startime of rewards epoch /// @return Amount of token function tokenRewardsPerEpoch(address token, uint256 epochStart) external view returns (uint256); /// @notice Most recent timestamp a veNFT has claimed their rewards /// @param token Address of token rewarded /// @param tokenId veNFT unique identifier /// @return Timestamp function lastEarn(address token, uint256 tokenId) external view returns (uint256); /// @notice True if a token is or has been an active reward token, else false function isReward(address token) external view returns (bool); /// @notice The number of checkpoints for each tokenId deposited function numCheckpoints(uint256 tokenId) external view returns (uint256); /// @notice The total number of checkpoints function supplyNumCheckpoints() external view returns (uint256); /// @notice Deposit an amount into the rewards contract to earn future rewards associated to a veNFT /// @dev Internal notation used as only callable internally by `authorized`. /// @param amount Amount deposited for the veNFT /// @param tokenId Unique identifier of the veNFT function _deposit(uint256 amount, uint256 tokenId) external; /// @notice Withdraw an amount from the rewards contract associated to a veNFT /// @dev Internal notation used as only callable internally by `authorized`. /// @param amount Amount deposited for the veNFT /// @param tokenId Unique identifier of the veNFT function _withdraw(uint256 amount, uint256 tokenId) external; /// @notice Claim the rewards earned by a veNFT staker /// @param tokenId Unique identifier of the veNFT /// @param tokens Array of tokens to claim rewards of function getReward(uint256 tokenId, address[] memory tokens) external; /// @notice Add rewards for stakers to earn /// @param token Address of token to reward /// @param amount Amount of token to transfer to rewards function notifyRewardAmount(address token, uint256 amount) external; /// @notice Determine the prior balance for an account as of a block number /// @dev Block number must be a finalized block or else this function will revert to prevent misinformation. /// @param tokenId The token of the NFT to check /// @param timestamp The timestamp to get the balance at /// @return The balance the account had as of the given block function getPriorBalanceIndex(uint256 tokenId, uint256 timestamp) external view returns (uint256); /// @notice Determine the prior index of supply staked by of a timestamp /// @dev Timestamp must be <= current timestamp /// @param timestamp The timestamp to get the index at /// @return Index of supply checkpoint function getPriorSupplyIndex(uint256 timestamp) external view returns (uint256); /// @notice Get number of rewards tokens function rewardsListLength() external view returns (uint256); /// @notice Calculate how much in rewards are earned for a specific token and veNFT /// @param token Address of token to fetch rewards of /// @param tokenId Unique identifier of the veNFT /// @return Amount of token earned in rewards function earned(address token, uint256 tokenId) external view returns (uint256); } interface IVoter { error AlreadyVotedOrDeposited(); error DistributeWindow(); error FactoryPathNotApproved(); error GaugeAlreadyKilled(); error GaugeAlreadyRevived(); error GaugeExists(); error GaugeDoesNotExist(address _pool); error GaugeNotAlive(address _gauge); error InactiveManagedNFT(); error MaximumVotingNumberTooLow(); error NonZeroVotes(); error NotAPool(); error NotApprovedOrOwner(); error NotGovernor(); error NotEmergencyCouncil(); error NotMinter(); error NotWhitelistedNFT(); error NotWhitelistedToken(); error SameValue(); error SpecialVotingWindow(); error TooManyPools(); error UnequalLengths(); error ZeroBalance(); error ZeroAddress(); event GaugeCreated( address indexed poolFactory, address indexed votingRewardsFactory, address indexed gaugeFactory, address pool, address bribeVotingReward, address feeVotingReward, address gauge, address creator ); event GaugeKilled(address indexed gauge); event GaugeRevived(address indexed gauge); event Voted( address indexed voter, address indexed pool, uint256 indexed tokenId, uint256 weight, uint256 totalWeight, uint256 timestamp ); event Abstained( address indexed voter, address indexed pool, uint256 indexed tokenId, uint256 weight, uint256 totalWeight, uint256 timestamp ); event NotifyReward(address indexed sender, address indexed reward, uint256 amount); event DistributeReward(address indexed sender, address indexed gauge, uint256 amount); event WhitelistToken(address indexed whitelister, address indexed token, bool indexed _bool); event WhitelistNFT(address indexed whitelister, uint256 indexed tokenId, bool indexed _bool); /// @notice Store trusted forwarder address to pass into factories function forwarder() external view returns (address); /// @notice The ve token that governs these contracts function ve() external view returns (address); /// @notice Factory registry for valid pool / gauge / rewards factories function factoryRegistry() external view returns (address); /// @notice Address of Minter.sol function minter() external view returns (address); /// @notice Standard OZ IGovernor using ve for vote weights. function governor() external view returns (address); /// @notice Custom Epoch Governor using ve for vote weights. function epochGovernor() external view returns (address); /// @notice credibly neutral party similar to Curve's Emergency DAO function emergencyCouncil() external view returns (address); /// @dev Total Voting Weights function totalWeight() external view returns (uint256); /// @dev Most number of pools one voter can vote for at once function maxVotingNum() external view returns (uint256); // mappings /// @dev Pool => Gauge function gauges(address pool) external view returns (address); /// @dev Gauge => Pool function poolForGauge(address gauge) external view returns (address); /// @dev Gauge => Fees Voting Reward function gaugeToFees(address gauge) external view returns (address); /// @dev Gauge => Bribes Voting Reward function gaugeToBribe(address gauge) external view returns (address); /// @dev Pool => Weights function weights(address pool) external view returns (uint256); /// @dev NFT => Pool => Votes function votes(uint256 tokenId, address pool) external view returns (uint256); /// @dev NFT => Total voting weight of NFT function usedWeights(uint256 tokenId) external view returns (uint256); /// @dev Nft => Timestamp of last vote (ensures single vote per epoch) function lastVoted(uint256 tokenId) external view returns (uint256); /// @dev Address => Gauge function isGauge(address) external view returns (bool); /// @dev Token => Whitelisted status function isWhitelistedToken(address token) external view returns (bool); /// @dev TokenId => Whitelisted status function isWhitelistedNFT(uint256 tokenId) external view returns (bool); /// @dev Gauge => Liveness status function isAlive(address gauge) external view returns (bool); /// @dev Gauge => Amount claimable function claimable(address gauge) external view returns (uint256); /// @notice Number of pools with a Gauge function length() external view returns (uint256); /// @notice Called by Minter to distribute weekly emissions rewards for disbursement amongst gauges. /// @dev Assumes totalWeight != 0 (Will never be zero as long as users are voting). /// Throws if not called by minter. /// @param _amount Amount of rewards to distribute. function notifyRewardAmount(uint256 _amount) external; /// @dev Utility to distribute to gauges of pools in range _start to _finish. /// @param _start Starting index of gauges to distribute to. /// @param _finish Ending index of gauges to distribute to. function distribute(uint256 _start, uint256 _finish) external; /// @dev Utility to distribute to gauges of pools in array. /// @param _gauges Array of gauges to distribute to. function distribute(address[] memory _gauges) external; /// @notice Called by users to update voting balances in voting rewards contracts. /// @param _tokenId Id of veNFT whose balance you wish to update. function poke(uint256 _tokenId) external; /// @notice Called by users to vote for pools. Votes distributed proportionally based on weights. /// Can only vote or deposit into a managed NFT once per epoch. /// Can only vote for gauges that have not been killed. /// @dev Weights are distributed proportional to the sum of the weights in the array. /// Throws if length of _poolVote and _weights do not match. /// @param _tokenId Id of veNFT you are voting with. /// @param _poolVote Array of pools you are voting for. /// @param _weights Weights of pools. function vote(uint256 _tokenId, address[] calldata _poolVote, uint256[] calldata _weights) external; /// @notice Called by users to reset voting state. Required if you wish to make changes to /// veNFT state (e.g. merge, split, deposit into managed etc). /// Cannot reset in the same epoch that you voted in. /// Can vote or deposit into a managed NFT again after reset. /// @param _tokenId Id of veNFT you are reseting. function reset(uint256 _tokenId) external; /// @notice Called by users to deposit into a managed NFT. /// Can only vote or deposit into a managed NFT once per epoch. /// Note that NFTs deposited into a managed NFT will be re-locked /// to the maximum lock time on withdrawal. /// @dev Throws if not approved or owner. /// Throws if managed NFT is inactive. /// Throws if depositing within privileged window (one hour prior to epoch flip). function depositManaged(uint256 _tokenId, uint256 _mTokenId) external; /// @notice Called by users to withdraw from a managed NFT. /// Cannot do it in the same epoch that you deposited into a managed NFT. /// Can vote or deposit into a managed NFT again after withdrawing. /// Note that the NFT withdrawn is re-locked to the maximum lock time. function withdrawManaged(uint256 _tokenId) external; /// @notice Claim emissions from gauges. /// @param _gauges Array of gauges to collect emissions from. function claimRewards(address[] memory _gauges) external; /// @notice Claim bribes for a given NFT. /// @dev Utility to help batch bribe claims. /// @param _bribes Array of BribeVotingReward contracts to collect from. /// @param _tokens Array of tokens that are used as bribes. /// @param _tokenId Id of veNFT that you wish to claim bribes for. function claimBribes(address[] memory _bribes, address[][] memory _tokens, uint256 _tokenId) external; /// @notice Claim fees for a given NFT. /// @dev Utility to help batch fee claims. /// @param _fees Array of FeesVotingReward contracts to collect from. /// @param _tokens Array of tokens that are used as fees. /// @param _tokenId Id of veNFT that you wish to claim fees for. function claimFees(address[] memory _fees, address[][] memory _tokens, uint256 _tokenId) external; /// @notice Set new governor. /// @dev Throws if not called by governor. /// @param _governor . function setGovernor(address _governor) external; /// @notice Set new epoch based governor. /// @dev Throws if not called by governor. /// @param _epochGovernor . function setEpochGovernor(address _epochGovernor) external; /// @notice Set new emergency council. /// @dev Throws if not called by emergency council. /// @param _emergencyCouncil . function setEmergencyCouncil(address _emergencyCouncil) external; /// @notice Set maximum number of gauges that can be voted for. /// @dev Throws if not called by governor. /// Throws if _maxVotingNum is too low. /// Throws if the values are the same. /// @param _maxVotingNum . function setMaxVotingNum(uint256 _maxVotingNum) external; /// @notice Whitelist (or unwhitelist) token for use in bribes. /// @dev Throws if not called by governor. /// @param _token . /// @param _bool . function whitelistToken(address _token, bool _bool) external; /// @notice Whitelist (or unwhitelist) token id for voting in last hour prior to epoch flip. /// @dev Throws if not called by governor. /// Throws if already whitelisted. /// @param _tokenId . /// @param _bool . function whitelistNFT(uint256 _tokenId, bool _bool) external; /// @notice Create a new gauge (unpermissioned). /// @dev Governor can create a new gauge for a pool with any address. /// @param _poolFactory . /// @param _pool . function createGauge(address _poolFactory, address _pool) external returns (address); /// @notice Kills a gauge. The gauge will not receive any new emissions and cannot be deposited into. /// Can still withdraw from gauge. /// @dev Throws if not called by emergency council. /// Throws if gauge already killed. /// @param _gauge . function killGauge(address _gauge) external; /// @notice Revives a killed gauge. Gauge will can receive emissions and deposits again. /// @dev Throws if not called by emergency council. /// Throws if gauge is not killed. /// @param _gauge . function reviveGauge(address _gauge) external; /// @dev Update claims to emissions for an array of gauges. /// @param _gauges Array of gauges to update emissions for. function updateFor(address[] memory _gauges) external; /// @dev Update claims to emissions for gauges based on their pool id as stored in Voter. /// @param _start Starting index of pools. /// @param _end Ending index of pools. function updateFor(uint256 _start, uint256 _end) external; /// @dev Update claims to emissions for single gauge /// @param _gauge . function updateFor(address _gauge) external; } // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); } // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Permit.sol) /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); } // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } // OpenZeppelin Contracts (last updated v4.7.0) (metatx/ERC2771Context.sol) // OpenZeppelin Contracts v4.4.1 (utils/Context.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 Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } } /** * @dev Context variant with ERC2771 support. */ abstract contract ERC2771Context is Context { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable _trustedForwarder; /// @custom:oz-upgrades-unsafe-allow constructor constructor(address trustedForwarder) { _trustedForwarder = trustedForwarder; } function isTrustedForwarder(address forwarder) public view virtual returns (bool) { return forwarder == _trustedForwarder; } function _msgSender() internal view virtual override returns (address sender) { if (isTrustedForwarder(msg.sender)) { // The assembly code is more direct than the Solidity version using `abi.decode`. /// @solidity memory-safe-assembly assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) } } else { return super._msgSender(); } } function _msgData() internal view virtual override returns (bytes calldata) { if (isTrustedForwarder(msg.sender)) { return msg.data[:msg.data.length - 20]; } else { return super._msgData(); } } } // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } } library ProtocolTimeLibrary { uint256 internal constant WEEK = 7 days; /// @dev Returns start of epoch based on current timestamp function epochStart(uint256 timestamp) internal pure returns (uint256) { unchecked { return timestamp - (timestamp % WEEK); } } /// @dev Returns start of next epoch / end of current epoch function epochNext(uint256 timestamp) internal pure returns (uint256) { unchecked { return timestamp - (timestamp % WEEK) + WEEK; } } /// @dev Returns start of voting window function epochVoteStart(uint256 timestamp) internal pure returns (uint256) { unchecked { return timestamp - (timestamp % WEEK) + 1 hours; } } /// @dev Returns end of voting window / beginning of unrestricted voting window function epochVoteEnd(uint256 timestamp) internal pure returns (uint256) { unchecked { return timestamp - (timestamp % WEEK) + WEEK - 1 hours; } } } /// @title Reward /// @author velodrome.finance, @figs999, @pegahcarter /// @notice Base reward contract for distribution of rewards abstract contract Reward is IReward, ERC2771Context, ReentrancyGuard { using SafeERC20 for IERC20; /// @inheritdoc IReward uint256 public constant DURATION = 7 days; /// @inheritdoc IReward address public immutable voter; /// @inheritdoc IReward address public immutable ve; /// @inheritdoc IReward address public authorized; /// @inheritdoc IReward uint256 public totalSupply; /// @inheritdoc IReward mapping(uint256 => uint256) public balanceOf; /// @inheritdoc IReward mapping(address => mapping(uint256 => uint256)) public tokenRewardsPerEpoch; /// @inheritdoc IReward mapping(address => mapping(uint256 => uint256)) public lastEarn; address[] public rewards; /// @inheritdoc IReward mapping(address => bool) public isReward; /// @notice A record of balance checkpoints for each account, by index mapping(uint256 => mapping(uint256 => Checkpoint)) public checkpoints; /// @inheritdoc IReward mapping(uint256 => uint256) public numCheckpoints; /// @notice A record of balance checkpoints for each token, by index mapping(uint256 => SupplyCheckpoint) public supplyCheckpoints; /// @inheritdoc IReward uint256 public supplyNumCheckpoints; constructor(address _forwarder, address _voter) ERC2771Context(_forwarder) { voter = _voter; ve = IVoter(_voter).ve(); } /// @inheritdoc IReward function getPriorBalanceIndex(uint256 tokenId, uint256 timestamp) public view returns (uint256) { uint256 nCheckpoints = numCheckpoints[tokenId]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (checkpoints[tokenId][nCheckpoints - 1].timestamp <= timestamp) { return (nCheckpoints - 1); } // Next check implicit zero balance if (checkpoints[tokenId][0].timestamp > timestamp) { return 0; } uint256 lower = 0; uint256 upper = nCheckpoints - 1; while (upper > lower) { uint256 center = upper - (upper - lower) / 2; // ceil, avoiding overflow Checkpoint memory cp = checkpoints[tokenId][center]; if (cp.timestamp == timestamp) { return center; } else if (cp.timestamp < timestamp) { lower = center; } else { upper = center - 1; } } return lower; } /// @inheritdoc IReward function getPriorSupplyIndex(uint256 timestamp) public view returns (uint256) { uint256 nCheckpoints = supplyNumCheckpoints; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (supplyCheckpoints[nCheckpoints - 1].timestamp <= timestamp) { return (nCheckpoints - 1); } // Next check implicit zero balance if (supplyCheckpoints[0].timestamp > timestamp) { return 0; } uint256 lower = 0; uint256 upper = nCheckpoints - 1; while (upper > lower) { uint256 center = upper - (upper - lower) / 2; // ceil, avoiding overflow SupplyCheckpoint memory cp = supplyCheckpoints[center]; if (cp.timestamp == timestamp) { return center; } else if (cp.timestamp < timestamp) { lower = center; } else { upper = center - 1; } } return lower; } function _writeCheckpoint(uint256 tokenId, uint256 balance) internal { uint256 _nCheckPoints = numCheckpoints[tokenId]; uint256 _timestamp = block.timestamp; if ( _nCheckPoints > 0 && ProtocolTimeLibrary.epochStart(checkpoints[tokenId][_nCheckPoints - 1].timestamp) == ProtocolTimeLibrary.epochStart(_timestamp) ) { checkpoints[tokenId][_nCheckPoints - 1] = Checkpoint(_timestamp, balance); } else { checkpoints[tokenId][_nCheckPoints] = Checkpoint(_timestamp, balance); numCheckpoints[tokenId] = _nCheckPoints + 1; } } function _writeSupplyCheckpoint() internal { uint256 _nCheckPoints = supplyNumCheckpoints; uint256 _timestamp = block.timestamp; if ( _nCheckPoints > 0 && ProtocolTimeLibrary.epochStart(supplyCheckpoints[_nCheckPoints - 1].timestamp) == ProtocolTimeLibrary.epochStart(_timestamp) ) { supplyCheckpoints[_nCheckPoints - 1] = SupplyCheckpoint(_timestamp, totalSupply); } else { supplyCheckpoints[_nCheckPoints] = SupplyCheckpoint(_timestamp, totalSupply); supplyNumCheckpoints = _nCheckPoints + 1; } } /// @inheritdoc IReward function rewardsListLength() external view returns (uint256) { return rewards.length; } /// @inheritdoc IReward function earned(address token, uint256 tokenId) public view returns (uint256) { if (numCheckpoints[tokenId] == 0) { return 0; } uint256 reward = 0; uint256 _supply = 1; uint256 _currTs = ProtocolTimeLibrary.epochStart(lastEarn[token][tokenId]); // take epoch last claimed in as starting point uint256 _index = getPriorBalanceIndex(tokenId, _currTs); Checkpoint memory cp0 = checkpoints[tokenId][_index]; // accounts for case where lastEarn is before first checkpoint _currTs = Math.max(_currTs, ProtocolTimeLibrary.epochStart(cp0.timestamp)); // get epochs between current epoch and first checkpoint in same epoch as last claim uint256 numEpochs = (ProtocolTimeLibrary.epochStart(block.timestamp) - _currTs) / DURATION; if (numEpochs > 0) { for (uint256 i = 0; i < numEpochs; i++) { // get index of last checkpoint in this epoch _index = getPriorBalanceIndex(tokenId, _currTs + DURATION - 1); // get checkpoint in this epoch cp0 = checkpoints[tokenId][_index]; // get supply of last checkpoint in this epoch _supply = Math.max(supplyCheckpoints[getPriorSupplyIndex(_currTs + DURATION - 1)].supply, 1); reward += (cp0.balanceOf * tokenRewardsPerEpoch[token][_currTs]) / _supply; _currTs += DURATION; } } return reward; } /// @inheritdoc IReward function _deposit(uint256 amount, uint256 tokenId) external { address sender = _msgSender(); if (sender != authorized) revert NotAuthorized(); totalSupply += amount; balanceOf[tokenId] += amount; _writeCheckpoint(tokenId, balanceOf[tokenId]); _writeSupplyCheckpoint(); emit Deposit(sender, tokenId, amount); } /// @inheritdoc IReward function _withdraw(uint256 amount, uint256 tokenId) external { address sender = _msgSender(); if (sender != authorized) revert NotAuthorized(); totalSupply -= amount; balanceOf[tokenId] -= amount; _writeCheckpoint(tokenId, balanceOf[tokenId]); _writeSupplyCheckpoint(); emit Withdraw(sender, tokenId, amount); } /// @inheritdoc IReward function getReward(uint256 tokenId, address[] memory tokens) external virtual nonReentrant {} /// @dev used with all getReward implementations function _getReward(address recipient, uint256 tokenId, address[] memory tokens) internal { uint256 _length = tokens.length; for (uint256 i = 0; i < _length; i++) { uint256 _reward = earned(tokens[i], tokenId); lastEarn[tokens[i]][tokenId] = block.timestamp; if (_reward > 0) IERC20(tokens[i]).safeTransfer(recipient, _reward); emit ClaimRewards(recipient, tokens[i], _reward); } } /// @inheritdoc IReward function notifyRewardAmount(address token, uint256 amount) external virtual nonReentrant {} /// @dev used within all notifyRewardAmount implementations function _notifyRewardAmount(address sender, address token, uint256 amount) internal { if (amount == 0) revert ZeroAmount(); IERC20(token).safeTransferFrom(sender, address(this), amount); uint256 epochStart = ProtocolTimeLibrary.epochStart(block.timestamp); tokenRewardsPerEpoch[token][epochStart] += amount; emit NotifyReward(sender, token, epochStart, amount); } } // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) /** * @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); } /** * @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 caller. * * 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); } /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // OpenZeppelin Contracts (interfaces/IERC6372.sol) interface IERC6372 { /** * @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting). */ function clock() external view returns (uint48); /** * @dev Description of the clock */ // solhint-disable-next-line func-name-mixedcase function CLOCK_MODE() external view returns (string memory); } // OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol) // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol) /// @title EIP-721 Metadata Update Extension interface IERC4906 is IERC165, IERC721 { /// @dev This event emits when the metadata of a token is changed. /// So that the third-party platforms such as NFT market could /// timely update the images and related attributes of the NFT. event MetadataUpdate(uint256 _tokenId); /// @dev This event emits when the metadata of a range of tokens is changed. /// So that the third-party platforms such as NFT market could /// timely update the images and related attributes of the NFTs. event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId); } /// Modified IVotes interface for tokenId based voting interface IVotes { /** * @dev Emitted when an account changes their delegate. */ event DelegateChanged(address indexed delegator, uint256 indexed fromDelegate, uint256 indexed toDelegate); /** * @dev Emitted when a token transfer or delegate change results in changes to a delegate's number of votes. */ event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance); /** * @dev Returns the amount of votes that `tokenId` had at a specific moment in the past. * If the account passed in is not the owner, returns 0. */ function getPastVotes(address account, uint256 tokenId, uint256 timepoint) external view returns (uint256); /** * @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is * configured to use block numbers, this will return the value the end of the corresponding block. * * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes. * Votes that have not been delegated are still part of total supply, even though they would not participate in a * vote. */ function getPastTotalSupply(uint256 timepoint) external view returns (uint256); /** * @dev Returns the delegate that `tokenId` has chosen. Can never be equal to the delegator's `tokenId`. * Returns 0 if not delegated. */ function delegates(uint256 tokenId) external view returns (uint256); /** * @dev Delegates votes from the sender to `delegatee`. */ function delegate(uint256 delegator, uint256 delegatee) external; /** * @dev Delegates votes from `delegator` to `delegatee`. Signer must own `delegator`. */ function delegateBySig( uint256 delegator, uint256 delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external; } interface IVotingEscrow is IVotes, IERC4906, IERC6372, IERC721Metadata { struct LockedBalance { int128 amount; uint256 end; bool isPermanent; } struct UserPoint { int128 bias; int128 slope; // # -dweight / dt uint256 ts; uint256 blk; // block uint256 permanent; } struct GlobalPoint { int128 bias; int128 slope; // # -dweight / dt uint256 ts; uint256 blk; // block uint256 permanentLockBalance; } /// @notice A checkpoint for recorded delegated voting weights at a certain timestamp struct Checkpoint { uint256 fromTimestamp; address owner; uint256 delegatedBalance; uint256 delegatee; } enum DepositType { DEPOSIT_FOR_TYPE, CREATE_LOCK_TYPE, INCREASE_LOCK_AMOUNT, INCREASE_UNLOCK_TIME } /// @dev Different types of veNFTs: /// NORMAL - typical veNFT /// LOCKED - veNFT which is locked into a MANAGED veNFT /// MANAGED - veNFT which can accept the deposit of NORMAL veNFTs enum EscrowType { NORMAL, LOCKED, MANAGED } error AlreadyVoted(); error AmountTooBig(); error ERC721ReceiverRejectedTokens(); error ERC721TransferToNonERC721ReceiverImplementer(); error InvalidNonce(); error InvalidSignature(); error InvalidSignatureS(); error InvalidManagedNFTId(); error LockDurationNotInFuture(); error LockDurationTooLong(); error LockExpired(); error LockNotExpired(); error NoLockFound(); error NonExistentToken(); error NotApprovedOrOwner(); error NotDistributor(); error NotEmergencyCouncilOrGovernor(); error NotGovernor(); error NotGovernorOrManager(); error NotManagedNFT(); error NotManagedOrNormalNFT(); error NotLockedNFT(); error NotNormalNFT(); error NotPermanentLock(); error NotOwner(); error NotTeam(); error NotVoter(); error OwnershipChange(); error PermanentLock(); error SameAddress(); error SameNFT(); error SameState(); error SplitNoOwner(); error SplitNotAllowed(); error SignatureExpired(); error TooManyTokenIDs(); error ZeroAddress(); error ZeroAmount(); error ZeroBalance(); event Deposit( address indexed provider, uint256 indexed tokenId, DepositType indexed depositType, uint256 value, uint256 locktime, uint256 ts ); event Withdraw(address indexed provider, uint256 indexed tokenId, uint256 value, uint256 ts); event LockPermanent(address indexed _owner, uint256 indexed _tokenId, uint256 amount, uint256 _ts); event UnlockPermanent(address indexed _owner, uint256 indexed _tokenId, uint256 amount, uint256 _ts); event Supply(uint256 prevSupply, uint256 supply); event Merge( address indexed _sender, uint256 indexed _from, uint256 indexed _to, uint256 _amountFrom, uint256 _amountTo, uint256 _amountFinal, uint256 _locktime, uint256 _ts ); event Split( uint256 indexed _from, uint256 indexed _tokenId1, uint256 indexed _tokenId2, address _sender, uint256 _splitAmount1, uint256 _splitAmount2, uint256 _locktime, uint256 _ts ); event CreateManaged( address indexed _to, uint256 indexed _mTokenId, address indexed _from, address _lockedManagedReward, address _freeManagedReward ); event DepositManaged( address indexed _owner, uint256 indexed _tokenId, uint256 indexed _mTokenId, uint256 _weight, uint256 _ts ); event WithdrawManaged( address indexed _owner, uint256 indexed _tokenId, uint256 indexed _mTokenId, uint256 _weight, uint256 _ts ); event SetAllowedManager(address indexed _allowedManager); // State variables /// @notice Address of Meta-tx Forwarder function forwarder() external view returns (address); /// @notice Address of FactoryRegistry.sol function factoryRegistry() external view returns (address); /// @notice Address of token (HYDRO) used to create a veNFT function token() external view returns (address); /// @notice Address of RewardsDistributor.sol function distributor() external view returns (address); /// @notice Address of Voter.sol function voter() external view returns (address); /// @notice Address of Protocol Team multisig function team() external view returns (address); /// @notice Address of art proxy used for on-chain art generation function artProxy() external view returns (address); /// @dev address which can create managed NFTs function allowedManager() external view returns (address); /// @dev Current count of token function tokenId() external view returns (uint256); /*/////////////////////////////////////////////////////////////// MANAGED NFT STORAGE //////////////////////////////////////////////////////////////*/ /// @dev Mapping of token id to escrow type /// Takes advantage of the fact default value is EscrowType.NORMAL function escrowType(uint256 tokenId) external view returns (EscrowType); /// @dev Mapping of token id to managed id function idToManaged(uint256 tokenId) external view returns (uint256 managedTokenId); /// @dev Mapping of user token id to managed token id to weight of token id function weights(uint256 tokenId, uint256 managedTokenId) external view returns (uint256 weight); /// @dev Mapping of managed id to deactivated state function deactivated(uint256 tokenId) external view returns (bool inactive); /// @dev Mapping from managed nft id to locked managed rewards /// `token` denominated rewards (rebases/rewards) stored in locked managed rewards contract /// to prevent co-mingling of assets function managedToLocked(uint256 tokenId) external view returns (address); /// @dev Mapping from managed nft id to free managed rewards contract /// these rewards can be freely withdrawn by users function managedToFree(uint256 tokenId) external view returns (address); /*/////////////////////////////////////////////////////////////// MANAGED NFT LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Create managed NFT (a permanent lock) for use within ecosystem. /// @dev Throws if address already owns a managed NFT. /// @return _mTokenId managed token id. function createManagedLockFor(address _to) external returns (uint256 _mTokenId); /// @notice Delegates balance to managed nft /// Note that NFTs deposited into a managed NFT will be re-locked /// to the maximum lock time on withdrawal. /// Permanent locks that are deposited will automatically unlock. /// @dev Managed nft will remain max-locked as long as there is at least one /// deposit or withdrawal per week. /// Throws if deposit nft is managed. /// Throws if recipient nft is not managed. /// Throws if deposit nft is already locked. /// Throws if not called by voter. /// @param _tokenId tokenId of NFT being deposited /// @param _mTokenId tokenId of managed NFT that will receive the deposit function depositManaged(uint256 _tokenId, uint256 _mTokenId) external; /// @notice Retrieves locked rewards and withdraws balance from managed nft. /// Note that the NFT withdrawn is re-locked to the maximum lock time. /// @dev Throws if NFT not locked. /// Throws if not called by voter. /// @param _tokenId tokenId of NFT being deposited. function withdrawManaged(uint256 _tokenId) external; /// @notice Permit one address to call createManagedLockFor() that is not Voter.governor() function setAllowedManager(address _allowedManager) external; /// @notice Set Managed NFT state. Inactive NFTs cannot be deposited into. /// @param _mTokenId managed nft state to set /// @param _state true => inactive, false => active function setManagedState(uint256 _mTokenId, bool _state) external; /*/////////////////////////////////////////////////////////////// METADATA STORAGE //////////////////////////////////////////////////////////////*/ function name() external view returns (string memory); function symbol() external view returns (string memory); function version() external view returns (string memory); function decimals() external view returns (uint8); function setTeam(address _team) external; function setArtProxy(address _proxy) external; /// @inheritdoc IERC721Metadata function tokenURI(uint256 tokenId) external view returns (string memory); /*////////////////////////////////////////////////////////////// ERC721 BALANCE/OWNER STORAGE //////////////////////////////////////////////////////////////*/ /// @dev Mapping from owner address to mapping of index to tokenId function ownerToNFTokenIdList(address _owner, uint256 _index) external view returns (uint256 _tokenId); /// @inheritdoc IERC721 function ownerOf(uint256 tokenId) external view returns (address owner); /// @inheritdoc IERC721 function balanceOf(address owner) external view returns (uint256 balance); /*////////////////////////////////////////////////////////////// ERC721 APPROVAL STORAGE //////////////////////////////////////////////////////////////*/ /// @inheritdoc IERC721 function getApproved(uint256 _tokenId) external view returns (address operator); /// @inheritdoc IERC721 function isApprovedForAll(address owner, address operator) external view returns (bool); /// @notice Check whether spender is owner or an approved user for a given veNFT /// @param _spender . /// @param _tokenId . function isApprovedOrOwner(address _spender, uint256 _tokenId) external returns (bool); /*////////////////////////////////////////////////////////////// ERC721 LOGIC //////////////////////////////////////////////////////////////*/ /// @inheritdoc IERC721 function approve(address to, uint256 tokenId) external; /// @inheritdoc IERC721 function setApprovalForAll(address operator, bool approved) external; /// @inheritdoc IERC721 function transferFrom(address from, address to, uint256 tokenId) external; /// @inheritdoc IERC721 function safeTransferFrom(address from, address to, uint256 tokenId) external; /// @inheritdoc IERC721 function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /*////////////////////////////////////////////////////////////// ERC165 LOGIC //////////////////////////////////////////////////////////////*/ /// @inheritdoc IERC165 function supportsInterface(bytes4 _interfaceID) external view returns (bool); /*////////////////////////////////////////////////////////////// ESCROW STORAGE //////////////////////////////////////////////////////////////*/ /// @notice Total count of epochs witnessed since contract creation function epoch() external view returns (uint256); /// @notice Total amount of token() deposited function supply() external view returns (uint256); /// @notice Aggregate permanent locked balances function permanentLockBalance() external view returns (uint256); function userPointEpoch(uint256 _tokenId) external view returns (uint256 _epoch); /// @notice time -> signed slope change function slopeChanges(uint256 _timestamp) external view returns (int128); /// @notice account -> can split function canSplit(address _account) external view returns (bool); /// @notice Global point history at a given index function pointHistory(uint256 _loc) external view returns (GlobalPoint memory); /// @notice Get the LockedBalance (amount, end) of a _tokenId /// @param _tokenId . /// @return LockedBalance of _tokenId function locked(uint256 _tokenId) external view returns (LockedBalance memory); /// @notice User -> UserPoint[userEpoch] function userPointHistory(uint256 _tokenId, uint256 _loc) external view returns (UserPoint memory); /*////////////////////////////////////////////////////////////// ESCROW LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Record global data to checkpoint function checkpoint() external; /// @notice Deposit `_value` tokens for `_tokenId` and add to the lock /// @dev Anyone (even a smart contract) can deposit for someone else, but /// cannot extend their locktime and deposit for a brand new user /// @param _tokenId lock NFT /// @param _value Amount to add to user's lock function depositFor(uint256 _tokenId, uint256 _value) external; /// @notice Deposit `_value` tokens for `msg.sender` and lock for `_lockDuration` /// @param _value Amount to deposit /// @param _lockDuration Number of seconds to lock tokens for (rounded down to nearest week) /// @return TokenId of created veNFT function createLock(uint256 _value, uint256 _lockDuration) external returns (uint256); /// @notice Deposit `_value` tokens for `_to` and lock for `_lockDuration` /// @param _value Amount to deposit /// @param _lockDuration Number of seconds to lock tokens for (rounded down to nearest week) /// @param _to Address to deposit /// @return TokenId of created veNFT function createLockFor(uint256 _value, uint256 _lockDuration, address _to) external returns (uint256); /// @notice Deposit `_value` additional tokens for `_tokenId` without modifying the unlock time /// @param _value Amount of tokens to deposit and add to the lock function increaseAmount(uint256 _tokenId, uint256 _value) external; /// @notice Extend the unlock time for `_tokenId` /// Cannot extend lock time of permanent locks /// @param _lockDuration New number of seconds until tokens unlock function increaseUnlockTime(uint256 _tokenId, uint256 _lockDuration) external; /// @notice Withdraw all tokens for `_tokenId` /// @dev Only possible if the lock is both expired and not permanent /// This will burn the veNFT. Any rebases or rewards that are unclaimed /// will no longer be claimable. Claim all rebases and rewards prior to calling this. function withdraw(uint256 _tokenId) external; /// @notice Merges `_from` into `_to`. /// @dev Cannot merge `_from` locks that are permanent or have already voted this epoch. /// Cannot merge `_to` locks that have already expired. /// This will burn the veNFT. Any rebases or rewards that are unclaimed /// will no longer be claimable. Claim all rebases and rewards prior to calling this. /// @param _from VeNFT to merge from. /// @param _to VeNFT to merge into. function merge(uint256 _from, uint256 _to) external; /// @notice Splits veNFT into two new veNFTS - one with oldLocked.amount - `_amount`, and the second with `_amount` /// @dev This burns the tokenId of the target veNFT /// Callable by approved or owner /// If this is called by approved, approved will not have permissions to manipulate the newly created veNFTs /// Returns the two new split veNFTs to owner /// If `from` is permanent, will automatically dedelegate. /// This will burn the veNFT. Any rebases or rewards that are unclaimed /// will no longer be claimable. Claim all rebases and rewards prior to calling this. /// @param _from VeNFT to split. /// @param _amount Amount to split from veNFT. /// @return _tokenId1 Return tokenId of veNFT with oldLocked.amount - `_amount`. /// @return _tokenId2 Return tokenId of veNFT with `_amount`. function split(uint256 _from, uint256 _amount) external returns (uint256 _tokenId1, uint256 _tokenId2); /// @notice Toggle split for a specific address. /// @dev Toggle split for address(0) to enable or disable for all. /// @param _account Address to toggle split permissions /// @param _bool True to allow, false to disallow function toggleSplit(address _account, bool _bool) external; /// @notice Permanently lock a veNFT. Voting power will be equal to /// `LockedBalance.amount` with no decay. Required to delegate. /// @dev Only callable by unlocked normal veNFTs. /// @param _tokenId tokenId to lock. function lockPermanent(uint256 _tokenId) external; /// @notice Unlock a permanently locked veNFT. Voting power will decay. /// Will automatically dedelegate if delegated. /// @dev Only callable by permanently locked veNFTs. /// Cannot unlock if already voted this epoch. /// @param _tokenId tokenId to unlock. function unlockPermanent(uint256 _tokenId) external; /*/////////////////////////////////////////////////////////////// GAUGE VOTING STORAGE //////////////////////////////////////////////////////////////*/ /// @notice Get the voting power for _tokenId at the current timestamp /// @dev Returns 0 if called in the same block as a transfer. /// @param _tokenId . /// @return Voting power function balanceOfNFT(uint256 _tokenId) external view returns (uint256); /// @notice Get the voting power for _tokenId at a given timestamp /// @param _tokenId . /// @param _t Timestamp to query voting power /// @return Voting power function balanceOfNFTAt(uint256 _tokenId, uint256 _t) external view returns (uint256); /// @notice Calculate total voting power at current timestamp /// @return Total voting power at current timestamp function totalSupply() external view returns (uint256); /// @notice Calculate total voting power at a given timestamp /// @param _t Timestamp to query total voting power /// @return Total voting power at given timestamp function totalSupplyAt(uint256 _t) external view returns (uint256); /*/////////////////////////////////////////////////////////////// GAUGE VOTING LOGIC //////////////////////////////////////////////////////////////*/ /// @notice See if a queried _tokenId has actively voted /// @param _tokenId . /// @return True if voted, else false function voted(uint256 _tokenId) external view returns (bool); /// @notice Set the global state voter and distributor /// @dev This is only called once, at setup function setVoterAndDistributor(address _voter, address _distributor) external; /// @notice Set `voted` for _tokenId to true or false /// @dev Only callable by voter /// @param _tokenId . /// @param _voted . function voting(uint256 _tokenId, bool _voted) external; /*/////////////////////////////////////////////////////////////// DAO VOTING STORAGE //////////////////////////////////////////////////////////////*/ /// @notice The number of checkpoints for each tokenId function numCheckpoints(uint256 tokenId) external view returns (uint48); /// @notice A record of states for signing / validating signatures function nonces(address account) external view returns (uint256); /// @inheritdoc IVotes function delegates(uint256 delegator) external view returns (uint256); /// @notice A record of delegated token checkpoints for each account, by index /// @param tokenId . /// @param index . /// @return Checkpoint function checkpoints(uint256 tokenId, uint48 index) external view returns (Checkpoint memory); /// @inheritdoc IVotes function getPastVotes(address account, uint256 tokenId, uint256 timestamp) external view returns (uint256); /// @inheritdoc IVotes function getPastTotalSupply(uint256 timestamp) external view returns (uint256); /*/////////////////////////////////////////////////////////////// DAO VOTING LOGIC //////////////////////////////////////////////////////////////*/ /// @inheritdoc IVotes function delegate(uint256 delegator, uint256 delegatee) external; /// @inheritdoc IVotes function delegateBySig( uint256 delegator, uint256 delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) external; /*////////////////////////////////////////////////////////////// ERC6372 LOGIC //////////////////////////////////////////////////////////////*/ /// @inheritdoc IERC6372 function clock() external view returns (uint48); /// @inheritdoc IERC6372 function CLOCK_MODE() external view returns (string memory); } /// @title Base voting reward contract for distribution of rewards by token id /// on a weekly basis abstract contract VotingReward is Reward { constructor(address _forwarder, address _voter, address[] memory _rewards) Reward(_forwarder, _voter) { uint256 _length = _rewards.length; for (uint256 i; i < _length; i++) { if (_rewards[i] != address(0)) { isReward[_rewards[i]] = true; rewards.push(_rewards[i]); } } authorized = _voter; } /// @inheritdoc Reward function getReward(uint256 tokenId, address[] memory tokens) external override nonReentrant { address sender = _msgSender(); if (!IVotingEscrow(ve).isApprovedOrOwner(sender, tokenId) && sender != voter) revert NotAuthorized(); address _owner = IVotingEscrow(ve).ownerOf(tokenId); _getReward(_owner, tokenId, tokens); } /// @inheritdoc Reward function notifyRewardAmount(address token, uint256 amount) external virtual override {} } /// @notice Bribes pay out rewards for a given pool based on the votes that were received from the user (goes hand in hand with Voter.vote()) contract FeesVotingReward is VotingReward { constructor( address _forwarder, address _voter, address[] memory _rewards ) VotingReward(_forwarder, _voter, _rewards) {} /// @inheritdoc VotingReward function notifyRewardAmount(address token, uint256 amount) external override nonReentrant { address sender = _msgSender(); if (IVoter(voter).gaugeToFees(sender) != address(this)) revert NotGauge(); if (!isReward[token]) revert InvalidReward(); _notifyRewardAmount(sender, token, amount); } } /// @notice Bribes pay out rewards for a given pool based on the votes that were received from the user (goes hand in hand with Voter.vote()) contract BribeVotingReward is VotingReward { constructor( address _forwarder, address _voter, address[] memory _rewards ) VotingReward(_forwarder, _voter, _rewards) {} /// @inheritdoc VotingReward function notifyRewardAmount(address token, uint256 amount) external override nonReentrant { address sender = _msgSender(); if (!isReward[token]) { if (!IVoter(voter).isWhitelistedToken(token)) revert NotWhitelisted(); isReward[token] = true; rewards.push(token); } _notifyRewardAmount(sender, token, amount); } } contract VotingRewardsFactory is IVotingRewardsFactory { /// @inheritdoc IVotingRewardsFactory function createRewards( address _forwarder, address[] memory _rewards ) external returns (address feesVotingReward, address bribeVotingReward) { feesVotingReward = address(new FeesVotingReward(_forwarder, msg.sender, _rewards)); bribeVotingReward = address(new BribeVotingReward(_forwarder, msg.sender, _rewards)); } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_forwarder","type":"address"},{"internalType":"address[]","name":"_rewards","type":"address[]"}],"name":"createRewards","outputs":[{"internalType":"address","name":"feesVotingReward","type":"address"},{"internalType":"address","name":"bribeVotingReward","type":"address"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50613a31806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80634c455a9714610030575b600080fd5b61004361003e366004610131565b610067565b604080516001600160a01b0393841681529290911660208301520160405180910390f35b600080833384604051610079906100e5565b61008593929190610209565b604051809103906000f0801580156100a1573d6000803e3d6000fd5b5091508333846040516100b3906100f2565b6100bf93929190610209565b604051809103906000f0801580156100db573d6000803e3d6000fd5b5090509250929050565b611ba78061026d83390190565b611be880611e1483390190565b80356001600160a01b038116811461011657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561014457600080fd5b61014d836100ff565b915060208084013567ffffffffffffffff8082111561016b57600080fd5b818601915086601f83011261017f57600080fd5b8135818111156101915761019161011b565b8060051b604051601f19603f830116810181811085821117156101b6576101b661011b565b6040529182528482019250838101850191898311156101d457600080fd5b938501935b828510156101f9576101ea856100ff565b845293850193928501926101d9565b8096505050505050509250929050565b60006060820160018060a01b03808716845260208187168186015260606040860152828651808552608087019150828801945060005b8181101561025d57855185168352948301949183019160010161023f565b5090999850505050505050505056fe60e06040523480156200001157600080fd5b5060405162001ba738038062001ba7833981016040819052620000349162000233565b6001600160a01b038084166080526001600055821660a081905260408051630fc2838b60e11b81529051859285928592859285929091631f850716916004808201926020929091908290030181865afa15801562000096573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000bc91906200032d565b6001600160a01b031660c0525050805160005b81811015620001d15760006001600160a01b0316838281518110620000f857620000f862000352565b60200260200101516001600160a01b031614620001bc576001600760008584815181106200012a576200012a62000352565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600683828151811062000180576200018062000352565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b039092169190911790555b80620001c88162000368565b915050620000cf565b5050600180546001600160a01b0319166001600160a01b03939093169290921790915550620003909350505050565b80516001600160a01b03811681146200021857600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156200024957600080fd5b620002548462000200565b925060206200026581860162000200565b60408601519093506001600160401b03808211156200028357600080fd5b818701915087601f8301126200029857600080fd5b815181811115620002ad57620002ad6200021d565b8060051b604051601f19603f83011681018181108582111715620002d557620002d56200021d565b60405291825284820192508381018501918a831115620002f457600080fd5b938501935b828510156200031d576200030d8562000200565b84529385019392850192620002f9565b8096505050505050509250925092565b6000602082840312156200034057600080fd5b6200034b8262000200565b9392505050565b634e487b7160e01b600052603260045260246000fd5b6000600182016200038957634e487b7160e01b600052601160045260246000fd5b5060010190565b60805160a05160c0516117c4620003e36000396000818161017d01528181610ba50152610c8a0152600081816101e2015281816109880152610c1e0152600081816102ae0152610d3001526117c46000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806392777b29116100c3578063e8111a121161007c578063e8111a121461037f578063f25e55a514610388578063f301af42146103b3578063f3207723146103c6578063f5f8d365146103d9578063f7412baf146103ec57600080fd5b806392777b29146102f15780639cc7f7081461031c5780639e2bf22c1461033c578063a28d4c9c14610351578063b66503cf14610364578063e68863961461037757600080fd5b806346c96aac1161011557806346c96aac146101dd57806349dcc204146102045780634d5ce0381461024b578063505897931461027e578063572b6c051461029e57806376f4be36146102de57600080fd5b806318160ddd146101525780631be052891461016e5780631f850716146101785780633e491d47146101b7578063456cb7c6146101ca575b600080fd5b61015b60025481565b6040519081526020015b60405180910390f35b61015b62093a8081565b61019f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610165565b61015b6101c53660046114cd565b610413565b60015461019f906001600160a01b031681565b61019f7f000000000000000000000000000000000000000000000000000000000000000081565b6102366102123660046114f9565b60086020908152600092835260408084209091529082529020805460019091015482565b60408051928352602083019190915201610165565b61026e61025936600461151b565b60076020526000908152604090205460ff1681565b6040519015158152602001610165565b61015b61028c366004611538565b60096020526000908152604090205481565b61026e6102ac36600461151b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b61015b6102ec366004611538565b6105f9565b61015b6102ff3660046114cd565b600460209081526000928352604080842090915290825290205481565b61015b61032a366004611538565b60036020526000908152604090205481565b61034f61034a3660046114f9565b61072d565b005b61015b61035f3660046114f9565b61080d565b61034f6103723660046114cd565b610952565b60065461015b565b61015b600b5481565b61015b6103963660046114cd565b600560209081526000928352604080842090915290825290205481565b61019f6103c1366004611538565b610a6d565b61034f6103d43660046114f9565b610a97565b61034f6103e7366004611567565b610b6a565b6102366103fa366004611538565b600a602052600090815260409020805460019091015482565b6000818152600960205260408120548103610430575060006105f3565b6001600160a01b038316600090815260056020908152604080832085845290915281205460019062093a80810690038261046a868361080d565b60008781526008602090815260408083208484528252918290208251808401909352805480845260019091015491830191909152919250906104b590849062093a8081069003610d16565b9250600062093a806104cc8542838106900361164e565b6104d69190611661565b905080156105ea5760005b818110156105e8576105068960016104fc62093a8089611683565b61035f919061164e565b60008a815260086020908152604080832084845282528083208151808301909252805482526001908101549282019290925292965091945061057a91600a91906105619061055762093a808b611683565b6102ec919061164e565b8152602001908152602001600020600101546001610d16565b6001600160a01b038b1660009081526004602090815260408083208984528252909120549085015191975087916105b19190611696565b6105bb9190611661565b6105c59088611683565b96506105d462093a8086611683565b9450806105e0816116ad565b9150506104e1565b505b50939450505050505b92915050565b600b5460009080820361060f5750600092915050565b82600a600061061f60018561164e565b815260200190815260200160002060000154116106485761064160018261164e565b9392505050565b60008052600a6020527f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e3548310156106835750600092915050565b60008061069160018461164e565b90505b8181111561072557600060026106aa848461164e565b6106b49190611661565b6106be908361164e565b6000818152600a60209081526040918290208251808401909352805480845260019091015491830191909152919250908790036106ff575095945050505050565b80518711156107105781935061071e565b61071b60018361164e565b92505b5050610694565b509392505050565b6000610737610d2c565b6001549091506001600160a01b038083169116146107685760405163ea8e4eb560e01b815260040160405180910390fd5b826002600082825461077a919061164e565b90915550506000828152600360205260408120805485929061079d90849061164e565b90915550506000828152600360205260409020546107bc908390610d70565b6107c4610e7a565b81816001600160a01b03167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5688560405161080091815260200190565b60405180910390a3505050565b60008281526009602052604081205480820361082d5760009150506105f3565b6000848152600860205260408120849161084860018561164e565b815260200190815260200160002060000154116108725761086a60018261164e565b9150506105f3565b600084815260086020908152604080832083805290915290205483101561089d5760009150506105f3565b6000806108ab60018461164e565b90505b8181111561094957600060026108c4848461164e565b6108ce9190611661565b6108d8908361164e565b6000888152600860209081526040808320848452825291829020825180840190935280548084526001909101549183019190915291925090879003610923575093506105f392505050565b805187111561093457819350610942565b61093f60018361164e565b92505b50506108ae565b50949350505050565b61095a610f32565b6000610964610d2c565b60405163c4f0816560e01b81526001600160a01b03808316600483015291925030917f0000000000000000000000000000000000000000000000000000000000000000169063c4f0816590602401602060405180830381865afa1580156109cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f391906116c6565b6001600160a01b031614610a1a576040516304639b6160e11b815260040160405180910390fd5b6001600160a01b03831660009081526007602052604090205460ff16610a53576040516314414f4160e11b815260040160405180910390fd5b610a5e818484610f90565b50610a696001600055565b5050565b60068181548110610a7d57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000610aa1610d2c565b6001549091506001600160a01b03808316911614610ad25760405163ea8e4eb560e01b815260040160405180910390fd5b8260026000828254610ae49190611683565b909155505060008281526003602052604081208054859290610b07908490611683565b9091555050600082815260036020526040902054610b26908390610d70565b610b2e610e7a565b81816001600160a01b03167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a158560405161080091815260200190565b610b72610f32565b6000610b7c610d2c565b60405163430c208160e01b81526001600160a01b038083166004830152602482018690529192507f00000000000000000000000000000000000000000000000000000000000000009091169063430c2081906044016020604051808303816000875af1158015610bf0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1491906116e3565b158015610c5357507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b031614155b15610c715760405163ea8e4eb560e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018490526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa158015610cd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cfd91906116c6565b9050610d0a81858561106a565b5050610a696001600055565b6000818311610d255781610641565b5090919050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610d6b575060131936013560601c90565b503390565b600082815260096020526040902054428115801590610dce575062093a80810681036000858152600860205260408120610dcc91610daf60018761164e565b81526020019081526020016000206000015462093a808106900390565b145b15610e24576040805180820182528281526020808201869052600087815260089091529182209091610e0160018661164e565b815260208082019290925260400160002082518155910151600190910155610e74565b6040805180820182528281526020808201868152600088815260088352848120878252909252929020905181559051600191820155610e64908390611683565b6000858152600960205260409020555b50505050565b600b54428115801590610ea4575062093a8081068103610ea2600a6000610daf60018761164e565b145b15610eef57604080518082019091528181526002546020820152600a6000610ecd60018661164e565b8152602080820192909252604001600020825181559101516001909101555050565b60408051808201825282815260025460208083019182526000868152600a90915292909220905181559051600191820155610f2b908390611683565b600b555050565b600260005403610f895760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b6002600055565b80600003610fb157604051631f2a200560e01b815260040160405180910390fd5b610fc66001600160a01b0383168430846111a3565b6000610fd74262093a808106900390565b6001600160a01b038416600090815260046020908152604080832084845290915281208054929350849290919061100f908490611683565b9250508190555080836001600160a01b0316856001600160a01b03167f52977ea98a2220a03ee9ba5cb003ada08d394ea10155483c95dc2dc77a7eb24b8560405161105c91815260200190565b60405180910390a450505050565b805160005b8181101561119c57600061109c84838151811061108e5761108e611705565b602002602001015186610413565b905042600560008685815181106110b5576110b5611705565b6020908102919091018101516001600160a01b031682528181019290925260409081016000908120898252909252902055801561112357611123868286858151811061110357611103611705565b60200260200101516001600160a01b031661120e9092919063ffffffff16565b83828151811061113557611135611705565b60200260200101516001600160a01b0316866001600160a01b03167f9aa05b3d70a9e3e2f004f039648839560576334fb45c81f91b6db03ad9e2efc98360405161118191815260200190565b60405180910390a35080611194816116ad565b91505061106f565b5050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610e749085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611243565b6040516001600160a01b03831660248201526044810182905261123e90849063a9059cbb60e01b906064016111d7565b505050565b6000611298826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166113159092919063ffffffff16565b80519091501561123e57808060200190518101906112b691906116e3565b61123e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610f80565b6060611324848460008561132c565b949350505050565b60608247101561138d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610f80565b600080866001600160a01b031685876040516113a9919061173f565b60006040518083038185875af1925050503d80600081146113e6576040519150601f19603f3d011682016040523d82523d6000602084013e6113eb565b606091505b50915091506113fc87838387611407565b979650505050505050565b6060831561147657825160000361146f576001600160a01b0385163b61146f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f80565b5081611324565b611324838381511561148b5781518083602001fd5b8060405162461bcd60e51b8152600401610f80919061175b565b6001600160a01b03811681146114ba57600080fd5b50565b80356114c8816114a5565b919050565b600080604083850312156114e057600080fd5b82356114eb816114a5565b946020939093013593505050565b6000806040838503121561150c57600080fd5b50508035926020909101359150565b60006020828403121561152d57600080fd5b8135610641816114a5565b60006020828403121561154a57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561157a57600080fd5b8235915060208084013567ffffffffffffffff8082111561159a57600080fd5b818601915086601f8301126115ae57600080fd5b8135818111156115c0576115c0611551565b8060051b604051601f19603f830116810181811085821117156115e5576115e5611551565b60405291825284820192508381018501918983111561160357600080fd5b938501935b8285101561162857611619856114bd565b84529385019392850192611608565b8096505050505050509250929050565b634e487b7160e01b600052601160045260246000fd5b818103818111156105f3576105f3611638565b60008261167e57634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156105f3576105f3611638565b80820281158282048414176105f3576105f3611638565b6000600182016116bf576116bf611638565b5060010190565b6000602082840312156116d857600080fd5b8151610641816114a5565b6000602082840312156116f557600080fd5b8151801515811461064157600080fd5b634e487b7160e01b600052603260045260246000fd5b60005b8381101561173657818101518382015260200161171e565b50506000910152565b6000825161175181846020870161171b565b9190910192915050565b602081526000825180602084015261177a81604085016020870161171b565b601f01601f1916919091016040019291505056fea26469706673582212205848a5636f0995d81d55580a148b7a71b5244f34e052e7efafa659d1dac1091b64736f6c6343000813003360e06040523480156200001157600080fd5b5060405162001be838038062001be8833981016040819052620000349162000233565b6001600160a01b038084166080526001600055821660a081905260408051630fc2838b60e11b81529051859285928592859285929091631f850716916004808201926020929091908290030181865afa15801562000096573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000bc91906200032d565b6001600160a01b031660c0525050805160005b81811015620001d15760006001600160a01b0316838281518110620000f857620000f862000352565b60200260200101516001600160a01b031614620001bc576001600760008584815181106200012a576200012a62000352565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600683828151811062000180576200018062000352565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b039092169190911790555b80620001c88162000368565b915050620000cf565b5050600180546001600160a01b0319166001600160a01b03939093169290921790915550620003909350505050565b80516001600160a01b03811681146200021857600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156200024957600080fd5b620002548462000200565b925060206200026581860162000200565b60408601519093506001600160401b03808211156200028357600080fd5b818701915087601f8301126200029857600080fd5b815181811115620002ad57620002ad6200021d565b8060051b604051601f19603f83011681018181108582111715620002d557620002d56200021d565b60405291825284820192508381018501918a831115620002f457600080fd5b938501935b828510156200031d576200030d8562000200565b84529385019392850192620002f9565b8096505050505050509250925092565b6000602082840312156200034057600080fd5b6200034b8262000200565b9392505050565b634e487b7160e01b600052603260045260246000fd5b6000600182016200038957634e487b7160e01b600052601160045260246000fd5b5060010190565b60805160a05160c051611805620003e36000396000818161017d01528181610be60152610ccb0152600081816101e2015281816109a60152610c5f0152600081816102ae0152610d7101526118056000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806392777b29116100c3578063e8111a121161007c578063e8111a121461037f578063f25e55a514610388578063f301af42146103b3578063f3207723146103c6578063f5f8d365146103d9578063f7412baf146103ec57600080fd5b806392777b29146102f15780639cc7f7081461031c5780639e2bf22c1461033c578063a28d4c9c14610351578063b66503cf14610364578063e68863961461037757600080fd5b806346c96aac1161011557806346c96aac146101dd57806349dcc204146102045780634d5ce0381461024b578063505897931461027e578063572b6c051461029e57806376f4be36146102de57600080fd5b806318160ddd146101525780631be052891461016e5780631f850716146101785780633e491d47146101b7578063456cb7c6146101ca575b600080fd5b61015b60025481565b6040519081526020015b60405180910390f35b61015b62093a8081565b61019f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610165565b61015b6101c536600461150e565b610413565b60015461019f906001600160a01b031681565b61019f7f000000000000000000000000000000000000000000000000000000000000000081565b61023661021236600461153a565b60086020908152600092835260408084209091529082529020805460019091015482565b60408051928352602083019190915201610165565b61026e61025936600461155c565b60076020526000908152604090205460ff1681565b6040519015158152602001610165565b61015b61028c366004611579565b60096020526000908152604090205481565b61026e6102ac36600461155c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b61015b6102ec366004611579565b6105f9565b61015b6102ff36600461150e565b600460209081526000928352604080842090915290825290205481565b61015b61032a366004611579565b60036020526000908152604090205481565b61034f61034a36600461153a565b61072d565b005b61015b61035f36600461153a565b61080d565b61034f61037236600461150e565b610952565b60065461015b565b61015b600b5481565b61015b61039636600461150e565b600560209081526000928352604080842090915290825290205481565b61019f6103c1366004611579565b610aae565b61034f6103d436600461153a565b610ad8565b61034f6103e73660046115a8565b610bab565b6102366103fa366004611579565b600a602052600090815260409020805460019091015482565b6000818152600960205260408120548103610430575060006105f3565b6001600160a01b038316600090815260056020908152604080832085845290915281205460019062093a80810690038261046a868361080d565b60008781526008602090815260408083208484528252918290208251808401909352805480845260019091015491830191909152919250906104b590849062093a8081069003610d57565b9250600062093a806104cc8542838106900361168f565b6104d691906116a2565b905080156105ea5760005b818110156105e8576105068960016104fc62093a80896116c4565b61035f919061168f565b60008a815260086020908152604080832084845282528083208151808301909252805482526001908101549282019290925292965091945061057a91600a91906105619061055762093a808b6116c4565b6102ec919061168f565b8152602001908152602001600020600101546001610d57565b6001600160a01b038b1660009081526004602090815260408083208984528252909120549085015191975087916105b191906116d7565b6105bb91906116a2565b6105c590886116c4565b96506105d462093a80866116c4565b9450806105e0816116ee565b9150506104e1565b505b50939450505050505b92915050565b600b5460009080820361060f5750600092915050565b82600a600061061f60018561168f565b815260200190815260200160002060000154116106485761064160018261168f565b9392505050565b60008052600a6020527f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e3548310156106835750600092915050565b60008061069160018461168f565b90505b8181111561072557600060026106aa848461168f565b6106b491906116a2565b6106be908361168f565b6000818152600a60209081526040918290208251808401909352805480845260019091015491830191909152919250908790036106ff575095945050505050565b80518711156107105781935061071e565b61071b60018361168f565b92505b5050610694565b509392505050565b6000610737610d6d565b6001549091506001600160a01b038083169116146107685760405163ea8e4eb560e01b815260040160405180910390fd5b826002600082825461077a919061168f565b90915550506000828152600360205260408120805485929061079d90849061168f565b90915550506000828152600360205260409020546107bc908390610db1565b6107c4610ebb565b81816001600160a01b03167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5688560405161080091815260200190565b60405180910390a3505050565b60008281526009602052604081205480820361082d5760009150506105f3565b6000848152600860205260408120849161084860018561168f565b815260200190815260200160002060000154116108725761086a60018261168f565b9150506105f3565b600084815260086020908152604080832083805290915290205483101561089d5760009150506105f3565b6000806108ab60018461168f565b90505b8181111561094957600060026108c4848461168f565b6108ce91906116a2565b6108d8908361168f565b6000888152600860209081526040808320848452825291829020825180840190935280548084526001909101549183019190915291925090879003610923575093506105f392505050565b805187111561093457819350610942565b61093f60018361168f565b92505b50506108ae565b50949350505050565b61095a610f73565b6000610964610d6d565b6001600160a01b03841660009081526007602052604090205490915060ff16610a945760405163559bfa4360e11b81526001600160a01b0384811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063ab37f48690602401602060405180830381865afa1580156109ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a119190611707565b610a2e57604051630b094f2760e31b815260040160405180910390fd5b6001600160a01b0383166000818152600760205260408120805460ff191660019081179091556006805491820181559091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0180546001600160a01b03191690911790555b610a9f818484610fd1565b50610aaa6001600055565b5050565b60068181548110610abe57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000610ae2610d6d565b6001549091506001600160a01b03808316911614610b135760405163ea8e4eb560e01b815260040160405180910390fd5b8260026000828254610b2591906116c4565b909155505060008281526003602052604081208054859290610b489084906116c4565b9091555050600082815260036020526040902054610b67908390610db1565b610b6f610ebb565b81816001600160a01b03167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a158560405161080091815260200190565b610bb3610f73565b6000610bbd610d6d565b60405163430c208160e01b81526001600160a01b038083166004830152602482018690529192507f00000000000000000000000000000000000000000000000000000000000000009091169063430c2081906044016020604051808303816000875af1158015610c31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c559190611707565b158015610c9457507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b031614155b15610cb25760405163ea8e4eb560e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018490526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa158015610d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3e9190611729565b9050610d4b8185856110ab565b5050610aaa6001600055565b6000818311610d665781610641565b5090919050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610dac575060131936013560601c90565b503390565b600082815260096020526040902054428115801590610e0f575062093a80810681036000858152600860205260408120610e0d91610df060018761168f565b81526020019081526020016000206000015462093a808106900390565b145b15610e65576040805180820182528281526020808201869052600087815260089091529182209091610e4260018661168f565b815260208082019290925260400160002082518155910151600190910155610eb5565b6040805180820182528281526020808201868152600088815260088352848120878252909252929020905181559051600191820155610ea59083906116c4565b6000858152600960205260409020555b50505050565b600b54428115801590610ee5575062093a8081068103610ee3600a6000610df060018761168f565b145b15610f3057604080518082019091528181526002546020820152600a6000610f0e60018661168f565b8152602080820192909252604001600020825181559101516001909101555050565b60408051808201825282815260025460208083019182526000868152600a90915292909220905181559051600191820155610f6c9083906116c4565b600b555050565b600260005403610fca5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b6002600055565b80600003610ff257604051631f2a200560e01b815260040160405180910390fd5b6110076001600160a01b0383168430846111e4565b60006110184262093a808106900390565b6001600160a01b03841660009081526004602090815260408083208484529091528120805492935084929091906110509084906116c4565b9250508190555080836001600160a01b0316856001600160a01b03167f52977ea98a2220a03ee9ba5cb003ada08d394ea10155483c95dc2dc77a7eb24b8560405161109d91815260200190565b60405180910390a450505050565b805160005b818110156111dd5760006110dd8483815181106110cf576110cf611746565b602002602001015186610413565b905042600560008685815181106110f6576110f6611746565b6020908102919091018101516001600160a01b031682528181019290925260409081016000908120898252909252902055801561116457611164868286858151811061114457611144611746565b60200260200101516001600160a01b031661124f9092919063ffffffff16565b83828151811061117657611176611746565b60200260200101516001600160a01b0316866001600160a01b03167f9aa05b3d70a9e3e2f004f039648839560576334fb45c81f91b6db03ad9e2efc9836040516111c291815260200190565b60405180910390a350806111d5816116ee565b9150506110b0565b5050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610eb59085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611284565b6040516001600160a01b03831660248201526044810182905261127f90849063a9059cbb60e01b90606401611218565b505050565b60006112d9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166113569092919063ffffffff16565b80519091501561127f57808060200190518101906112f79190611707565b61127f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610fc1565b6060611365848460008561136d565b949350505050565b6060824710156113ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610fc1565b600080866001600160a01b031685876040516113ea9190611780565b60006040518083038185875af1925050503d8060008114611427576040519150601f19603f3d011682016040523d82523d6000602084013e61142c565b606091505b509150915061143d87838387611448565b979650505050505050565b606083156114b75782516000036114b0576001600160a01b0385163b6114b05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610fc1565b5081611365565b61136583838151156114cc5781518083602001fd5b8060405162461bcd60e51b8152600401610fc1919061179c565b6001600160a01b03811681146114fb57600080fd5b50565b8035611509816114e6565b919050565b6000806040838503121561152157600080fd5b823561152c816114e6565b946020939093013593505050565b6000806040838503121561154d57600080fd5b50508035926020909101359150565b60006020828403121561156e57600080fd5b8135610641816114e6565b60006020828403121561158b57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600080604083850312156115bb57600080fd5b8235915060208084013567ffffffffffffffff808211156115db57600080fd5b818601915086601f8301126115ef57600080fd5b81358181111561160157611601611592565b8060051b604051601f19603f8301168101818110858211171561162657611626611592565b60405291825284820192508381018501918983111561164457600080fd5b938501935b828510156116695761165a856114fe565b84529385019392850192611649565b8096505050505050509250929050565b634e487b7160e01b600052601160045260246000fd5b818103818111156105f3576105f3611679565b6000826116bf57634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156105f3576105f3611679565b80820281158282048414176105f3576105f3611679565b60006001820161170057611700611679565b5060010190565b60006020828403121561171957600080fd5b8151801515811461064157600080fd5b60006020828403121561173b57600080fd5b8151610641816114e6565b634e487b7160e01b600052603260045260246000fd5b60005b8381101561177757818101518382015260200161175f565b50506000910152565b6000825161179281846020870161175c565b9190910192915050565b60208152600082518060208401526117bb81604085016020870161175c565b601f01601f1916919091016040019291505056fea2646970667358221220374af667613c8ac36e3fb05e4836d6493e9eab55087da4e497158d5e3603bf8d64736f6c63430008130033a2646970667358221220a18c4e792042e04aea0169a2c348ac9383a697ac6fbee6275bd7d35ce29a5ac664736f6c63430008130033
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061002b5760003560e01c80634c455a9714610030575b600080fd5b61004361003e366004610131565b610067565b604080516001600160a01b0393841681529290911660208301520160405180910390f35b600080833384604051610079906100e5565b61008593929190610209565b604051809103906000f0801580156100a1573d6000803e3d6000fd5b5091508333846040516100b3906100f2565b6100bf93929190610209565b604051809103906000f0801580156100db573d6000803e3d6000fd5b5090509250929050565b611ba78061026d83390190565b611be880611e1483390190565b80356001600160a01b038116811461011657600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561014457600080fd5b61014d836100ff565b915060208084013567ffffffffffffffff8082111561016b57600080fd5b818601915086601f83011261017f57600080fd5b8135818111156101915761019161011b565b8060051b604051601f19603f830116810181811085821117156101b6576101b661011b565b6040529182528482019250838101850191898311156101d457600080fd5b938501935b828510156101f9576101ea856100ff565b845293850193928501926101d9565b8096505050505050509250929050565b60006060820160018060a01b03808716845260208187168186015260606040860152828651808552608087019150828801945060005b8181101561025d57855185168352948301949183019160010161023f565b5090999850505050505050505056fe60e06040523480156200001157600080fd5b5060405162001ba738038062001ba7833981016040819052620000349162000233565b6001600160a01b038084166080526001600055821660a081905260408051630fc2838b60e11b81529051859285928592859285929091631f850716916004808201926020929091908290030181865afa15801562000096573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000bc91906200032d565b6001600160a01b031660c0525050805160005b81811015620001d15760006001600160a01b0316838281518110620000f857620000f862000352565b60200260200101516001600160a01b031614620001bc576001600760008584815181106200012a576200012a62000352565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600683828151811062000180576200018062000352565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b039092169190911790555b80620001c88162000368565b915050620000cf565b5050600180546001600160a01b0319166001600160a01b03939093169290921790915550620003909350505050565b80516001600160a01b03811681146200021857600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156200024957600080fd5b620002548462000200565b925060206200026581860162000200565b60408601519093506001600160401b03808211156200028357600080fd5b818701915087601f8301126200029857600080fd5b815181811115620002ad57620002ad6200021d565b8060051b604051601f19603f83011681018181108582111715620002d557620002d56200021d565b60405291825284820192508381018501918a831115620002f457600080fd5b938501935b828510156200031d576200030d8562000200565b84529385019392850192620002f9565b8096505050505050509250925092565b6000602082840312156200034057600080fd5b6200034b8262000200565b9392505050565b634e487b7160e01b600052603260045260246000fd5b6000600182016200038957634e487b7160e01b600052601160045260246000fd5b5060010190565b60805160a05160c0516117c4620003e36000396000818161017d01528181610ba50152610c8a0152600081816101e2015281816109880152610c1e0152600081816102ae0152610d3001526117c46000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806392777b29116100c3578063e8111a121161007c578063e8111a121461037f578063f25e55a514610388578063f301af42146103b3578063f3207723146103c6578063f5f8d365146103d9578063f7412baf146103ec57600080fd5b806392777b29146102f15780639cc7f7081461031c5780639e2bf22c1461033c578063a28d4c9c14610351578063b66503cf14610364578063e68863961461037757600080fd5b806346c96aac1161011557806346c96aac146101dd57806349dcc204146102045780634d5ce0381461024b578063505897931461027e578063572b6c051461029e57806376f4be36146102de57600080fd5b806318160ddd146101525780631be052891461016e5780631f850716146101785780633e491d47146101b7578063456cb7c6146101ca575b600080fd5b61015b60025481565b6040519081526020015b60405180910390f35b61015b62093a8081565b61019f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610165565b61015b6101c53660046114cd565b610413565b60015461019f906001600160a01b031681565b61019f7f000000000000000000000000000000000000000000000000000000000000000081565b6102366102123660046114f9565b60086020908152600092835260408084209091529082529020805460019091015482565b60408051928352602083019190915201610165565b61026e61025936600461151b565b60076020526000908152604090205460ff1681565b6040519015158152602001610165565b61015b61028c366004611538565b60096020526000908152604090205481565b61026e6102ac36600461151b565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b61015b6102ec366004611538565b6105f9565b61015b6102ff3660046114cd565b600460209081526000928352604080842090915290825290205481565b61015b61032a366004611538565b60036020526000908152604090205481565b61034f61034a3660046114f9565b61072d565b005b61015b61035f3660046114f9565b61080d565b61034f6103723660046114cd565b610952565b60065461015b565b61015b600b5481565b61015b6103963660046114cd565b600560209081526000928352604080842090915290825290205481565b61019f6103c1366004611538565b610a6d565b61034f6103d43660046114f9565b610a97565b61034f6103e7366004611567565b610b6a565b6102366103fa366004611538565b600a602052600090815260409020805460019091015482565b6000818152600960205260408120548103610430575060006105f3565b6001600160a01b038316600090815260056020908152604080832085845290915281205460019062093a80810690038261046a868361080d565b60008781526008602090815260408083208484528252918290208251808401909352805480845260019091015491830191909152919250906104b590849062093a8081069003610d16565b9250600062093a806104cc8542838106900361164e565b6104d69190611661565b905080156105ea5760005b818110156105e8576105068960016104fc62093a8089611683565b61035f919061164e565b60008a815260086020908152604080832084845282528083208151808301909252805482526001908101549282019290925292965091945061057a91600a91906105619061055762093a808b611683565b6102ec919061164e565b8152602001908152602001600020600101546001610d16565b6001600160a01b038b1660009081526004602090815260408083208984528252909120549085015191975087916105b19190611696565b6105bb9190611661565b6105c59088611683565b96506105d462093a8086611683565b9450806105e0816116ad565b9150506104e1565b505b50939450505050505b92915050565b600b5460009080820361060f5750600092915050565b82600a600061061f60018561164e565b815260200190815260200160002060000154116106485761064160018261164e565b9392505050565b60008052600a6020527f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e3548310156106835750600092915050565b60008061069160018461164e565b90505b8181111561072557600060026106aa848461164e565b6106b49190611661565b6106be908361164e565b6000818152600a60209081526040918290208251808401909352805480845260019091015491830191909152919250908790036106ff575095945050505050565b80518711156107105781935061071e565b61071b60018361164e565b92505b5050610694565b509392505050565b6000610737610d2c565b6001549091506001600160a01b038083169116146107685760405163ea8e4eb560e01b815260040160405180910390fd5b826002600082825461077a919061164e565b90915550506000828152600360205260408120805485929061079d90849061164e565b90915550506000828152600360205260409020546107bc908390610d70565b6107c4610e7a565b81816001600160a01b03167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5688560405161080091815260200190565b60405180910390a3505050565b60008281526009602052604081205480820361082d5760009150506105f3565b6000848152600860205260408120849161084860018561164e565b815260200190815260200160002060000154116108725761086a60018261164e565b9150506105f3565b600084815260086020908152604080832083805290915290205483101561089d5760009150506105f3565b6000806108ab60018461164e565b90505b8181111561094957600060026108c4848461164e565b6108ce9190611661565b6108d8908361164e565b6000888152600860209081526040808320848452825291829020825180840190935280548084526001909101549183019190915291925090879003610923575093506105f392505050565b805187111561093457819350610942565b61093f60018361164e565b92505b50506108ae565b50949350505050565b61095a610f32565b6000610964610d2c565b60405163c4f0816560e01b81526001600160a01b03808316600483015291925030917f0000000000000000000000000000000000000000000000000000000000000000169063c4f0816590602401602060405180830381865afa1580156109cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f391906116c6565b6001600160a01b031614610a1a576040516304639b6160e11b815260040160405180910390fd5b6001600160a01b03831660009081526007602052604090205460ff16610a53576040516314414f4160e11b815260040160405180910390fd5b610a5e818484610f90565b50610a696001600055565b5050565b60068181548110610a7d57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000610aa1610d2c565b6001549091506001600160a01b03808316911614610ad25760405163ea8e4eb560e01b815260040160405180910390fd5b8260026000828254610ae49190611683565b909155505060008281526003602052604081208054859290610b07908490611683565b9091555050600082815260036020526040902054610b26908390610d70565b610b2e610e7a565b81816001600160a01b03167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a158560405161080091815260200190565b610b72610f32565b6000610b7c610d2c565b60405163430c208160e01b81526001600160a01b038083166004830152602482018690529192507f00000000000000000000000000000000000000000000000000000000000000009091169063430c2081906044016020604051808303816000875af1158015610bf0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1491906116e3565b158015610c5357507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b031614155b15610c715760405163ea8e4eb560e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018490526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa158015610cd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cfd91906116c6565b9050610d0a81858561106a565b5050610a696001600055565b6000818311610d255781610641565b5090919050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610d6b575060131936013560601c90565b503390565b600082815260096020526040902054428115801590610dce575062093a80810681036000858152600860205260408120610dcc91610daf60018761164e565b81526020019081526020016000206000015462093a808106900390565b145b15610e24576040805180820182528281526020808201869052600087815260089091529182209091610e0160018661164e565b815260208082019290925260400160002082518155910151600190910155610e74565b6040805180820182528281526020808201868152600088815260088352848120878252909252929020905181559051600191820155610e64908390611683565b6000858152600960205260409020555b50505050565b600b54428115801590610ea4575062093a8081068103610ea2600a6000610daf60018761164e565b145b15610eef57604080518082019091528181526002546020820152600a6000610ecd60018661164e565b8152602080820192909252604001600020825181559101516001909101555050565b60408051808201825282815260025460208083019182526000868152600a90915292909220905181559051600191820155610f2b908390611683565b600b555050565b600260005403610f895760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b6002600055565b80600003610fb157604051631f2a200560e01b815260040160405180910390fd5b610fc66001600160a01b0383168430846111a3565b6000610fd74262093a808106900390565b6001600160a01b038416600090815260046020908152604080832084845290915281208054929350849290919061100f908490611683565b9250508190555080836001600160a01b0316856001600160a01b03167f52977ea98a2220a03ee9ba5cb003ada08d394ea10155483c95dc2dc77a7eb24b8560405161105c91815260200190565b60405180910390a450505050565b805160005b8181101561119c57600061109c84838151811061108e5761108e611705565b602002602001015186610413565b905042600560008685815181106110b5576110b5611705565b6020908102919091018101516001600160a01b031682528181019290925260409081016000908120898252909252902055801561112357611123868286858151811061110357611103611705565b60200260200101516001600160a01b031661120e9092919063ffffffff16565b83828151811061113557611135611705565b60200260200101516001600160a01b0316866001600160a01b03167f9aa05b3d70a9e3e2f004f039648839560576334fb45c81f91b6db03ad9e2efc98360405161118191815260200190565b60405180910390a35080611194816116ad565b91505061106f565b5050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610e749085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611243565b6040516001600160a01b03831660248201526044810182905261123e90849063a9059cbb60e01b906064016111d7565b505050565b6000611298826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166113159092919063ffffffff16565b80519091501561123e57808060200190518101906112b691906116e3565b61123e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610f80565b6060611324848460008561132c565b949350505050565b60608247101561138d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610f80565b600080866001600160a01b031685876040516113a9919061173f565b60006040518083038185875af1925050503d80600081146113e6576040519150601f19603f3d011682016040523d82523d6000602084013e6113eb565b606091505b50915091506113fc87838387611407565b979650505050505050565b6060831561147657825160000361146f576001600160a01b0385163b61146f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610f80565b5081611324565b611324838381511561148b5781518083602001fd5b8060405162461bcd60e51b8152600401610f80919061175b565b6001600160a01b03811681146114ba57600080fd5b50565b80356114c8816114a5565b919050565b600080604083850312156114e057600080fd5b82356114eb816114a5565b946020939093013593505050565b6000806040838503121561150c57600080fd5b50508035926020909101359150565b60006020828403121561152d57600080fd5b8135610641816114a5565b60006020828403121561154a57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561157a57600080fd5b8235915060208084013567ffffffffffffffff8082111561159a57600080fd5b818601915086601f8301126115ae57600080fd5b8135818111156115c0576115c0611551565b8060051b604051601f19603f830116810181811085821117156115e5576115e5611551565b60405291825284820192508381018501918983111561160357600080fd5b938501935b8285101561162857611619856114bd565b84529385019392850192611608565b8096505050505050509250929050565b634e487b7160e01b600052601160045260246000fd5b818103818111156105f3576105f3611638565b60008261167e57634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156105f3576105f3611638565b80820281158282048414176105f3576105f3611638565b6000600182016116bf576116bf611638565b5060010190565b6000602082840312156116d857600080fd5b8151610641816114a5565b6000602082840312156116f557600080fd5b8151801515811461064157600080fd5b634e487b7160e01b600052603260045260246000fd5b60005b8381101561173657818101518382015260200161171e565b50506000910152565b6000825161175181846020870161171b565b9190910192915050565b602081526000825180602084015261177a81604085016020870161171b565b601f01601f1916919091016040019291505056fea26469706673582212205848a5636f0995d81d55580a148b7a71b5244f34e052e7efafa659d1dac1091b64736f6c6343000813003360e06040523480156200001157600080fd5b5060405162001be838038062001be8833981016040819052620000349162000233565b6001600160a01b038084166080526001600055821660a081905260408051630fc2838b60e11b81529051859285928592859285929091631f850716916004808201926020929091908290030181865afa15801562000096573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620000bc91906200032d565b6001600160a01b031660c0525050805160005b81811015620001d15760006001600160a01b0316838281518110620000f857620000f862000352565b60200260200101516001600160a01b031614620001bc576001600760008584815181106200012a576200012a62000352565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a81548160ff021916908315150217905550600683828151811062000180576200018062000352565b60209081029190910181015182546001810184556000938452919092200180546001600160a01b0319166001600160a01b039092169190911790555b80620001c88162000368565b915050620000cf565b5050600180546001600160a01b0319166001600160a01b03939093169290921790915550620003909350505050565b80516001600160a01b03811681146200021857600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156200024957600080fd5b620002548462000200565b925060206200026581860162000200565b60408601519093506001600160401b03808211156200028357600080fd5b818701915087601f8301126200029857600080fd5b815181811115620002ad57620002ad6200021d565b8060051b604051601f19603f83011681018181108582111715620002d557620002d56200021d565b60405291825284820192508381018501918a831115620002f457600080fd5b938501935b828510156200031d576200030d8562000200565b84529385019392850192620002f9565b8096505050505050509250925092565b6000602082840312156200034057600080fd5b6200034b8262000200565b9392505050565b634e487b7160e01b600052603260045260246000fd5b6000600182016200038957634e487b7160e01b600052601160045260246000fd5b5060010190565b60805160a05160c051611805620003e36000396000818161017d01528181610be60152610ccb0152600081816101e2015281816109a60152610c5f0152600081816102ae0152610d7101526118056000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c806392777b29116100c3578063e8111a121161007c578063e8111a121461037f578063f25e55a514610388578063f301af42146103b3578063f3207723146103c6578063f5f8d365146103d9578063f7412baf146103ec57600080fd5b806392777b29146102f15780639cc7f7081461031c5780639e2bf22c1461033c578063a28d4c9c14610351578063b66503cf14610364578063e68863961461037757600080fd5b806346c96aac1161011557806346c96aac146101dd57806349dcc204146102045780634d5ce0381461024b578063505897931461027e578063572b6c051461029e57806376f4be36146102de57600080fd5b806318160ddd146101525780631be052891461016e5780631f850716146101785780633e491d47146101b7578063456cb7c6146101ca575b600080fd5b61015b60025481565b6040519081526020015b60405180910390f35b61015b62093a8081565b61019f7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b039091168152602001610165565b61015b6101c536600461150e565b610413565b60015461019f906001600160a01b031681565b61019f7f000000000000000000000000000000000000000000000000000000000000000081565b61023661021236600461153a565b60086020908152600092835260408084209091529082529020805460019091015482565b60408051928352602083019190915201610165565b61026e61025936600461155c565b60076020526000908152604090205460ff1681565b6040519015158152602001610165565b61015b61028c366004611579565b60096020526000908152604090205481565b61026e6102ac36600461155c565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811691161490565b61015b6102ec366004611579565b6105f9565b61015b6102ff36600461150e565b600460209081526000928352604080842090915290825290205481565b61015b61032a366004611579565b60036020526000908152604090205481565b61034f61034a36600461153a565b61072d565b005b61015b61035f36600461153a565b61080d565b61034f61037236600461150e565b610952565b60065461015b565b61015b600b5481565b61015b61039636600461150e565b600560209081526000928352604080842090915290825290205481565b61019f6103c1366004611579565b610aae565b61034f6103d436600461153a565b610ad8565b61034f6103e73660046115a8565b610bab565b6102366103fa366004611579565b600a602052600090815260409020805460019091015482565b6000818152600960205260408120548103610430575060006105f3565b6001600160a01b038316600090815260056020908152604080832085845290915281205460019062093a80810690038261046a868361080d565b60008781526008602090815260408083208484528252918290208251808401909352805480845260019091015491830191909152919250906104b590849062093a8081069003610d57565b9250600062093a806104cc8542838106900361168f565b6104d691906116a2565b905080156105ea5760005b818110156105e8576105068960016104fc62093a80896116c4565b61035f919061168f565b60008a815260086020908152604080832084845282528083208151808301909252805482526001908101549282019290925292965091945061057a91600a91906105619061055762093a808b6116c4565b6102ec919061168f565b8152602001908152602001600020600101546001610d57565b6001600160a01b038b1660009081526004602090815260408083208984528252909120549085015191975087916105b191906116d7565b6105bb91906116a2565b6105c590886116c4565b96506105d462093a80866116c4565b9450806105e0816116ee565b9150506104e1565b505b50939450505050505b92915050565b600b5460009080820361060f5750600092915050565b82600a600061061f60018561168f565b815260200190815260200160002060000154116106485761064160018261168f565b9392505050565b60008052600a6020527f13da86008ba1c6922daee3e07db95305ef49ebced9f5467a0b8613fcc6b343e3548310156106835750600092915050565b60008061069160018461168f565b90505b8181111561072557600060026106aa848461168f565b6106b491906116a2565b6106be908361168f565b6000818152600a60209081526040918290208251808401909352805480845260019091015491830191909152919250908790036106ff575095945050505050565b80518711156107105781935061071e565b61071b60018361168f565b92505b5050610694565b509392505050565b6000610737610d6d565b6001549091506001600160a01b038083169116146107685760405163ea8e4eb560e01b815260040160405180910390fd5b826002600082825461077a919061168f565b90915550506000828152600360205260408120805485929061079d90849061168f565b90915550506000828152600360205260409020546107bc908390610db1565b6107c4610ebb565b81816001600160a01b03167ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5688560405161080091815260200190565b60405180910390a3505050565b60008281526009602052604081205480820361082d5760009150506105f3565b6000848152600860205260408120849161084860018561168f565b815260200190815260200160002060000154116108725761086a60018261168f565b9150506105f3565b600084815260086020908152604080832083805290915290205483101561089d5760009150506105f3565b6000806108ab60018461168f565b90505b8181111561094957600060026108c4848461168f565b6108ce91906116a2565b6108d8908361168f565b6000888152600860209081526040808320848452825291829020825180840190935280548084526001909101549183019190915291925090879003610923575093506105f392505050565b805187111561093457819350610942565b61093f60018361168f565b92505b50506108ae565b50949350505050565b61095a610f73565b6000610964610d6d565b6001600160a01b03841660009081526007602052604090205490915060ff16610a945760405163559bfa4360e11b81526001600160a01b0384811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063ab37f48690602401602060405180830381865afa1580156109ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a119190611707565b610a2e57604051630b094f2760e31b815260040160405180910390fd5b6001600160a01b0383166000818152600760205260408120805460ff191660019081179091556006805491820181559091527ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0180546001600160a01b03191690911790555b610a9f818484610fd1565b50610aaa6001600055565b5050565b60068181548110610abe57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000610ae2610d6d565b6001549091506001600160a01b03808316911614610b135760405163ea8e4eb560e01b815260040160405180910390fd5b8260026000828254610b2591906116c4565b909155505060008281526003602052604081208054859290610b489084906116c4565b9091555050600082815260036020526040902054610b67908390610db1565b610b6f610ebb565b81816001600160a01b03167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a158560405161080091815260200190565b610bb3610f73565b6000610bbd610d6d565b60405163430c208160e01b81526001600160a01b038083166004830152602482018690529192507f00000000000000000000000000000000000000000000000000000000000000009091169063430c2081906044016020604051808303816000875af1158015610c31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c559190611707565b158015610c9457507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316816001600160a01b031614155b15610cb25760405163ea8e4eb560e01b815260040160405180910390fd5b6040516331a9108f60e11b8152600481018490526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636352211e90602401602060405180830381865afa158015610d1a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d3e9190611729565b9050610d4b8185856110ab565b5050610aaa6001600055565b6000818311610d665781610641565b5090919050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303610dac575060131936013560601c90565b503390565b600082815260096020526040902054428115801590610e0f575062093a80810681036000858152600860205260408120610e0d91610df060018761168f565b81526020019081526020016000206000015462093a808106900390565b145b15610e65576040805180820182528281526020808201869052600087815260089091529182209091610e4260018661168f565b815260208082019290925260400160002082518155910151600190910155610eb5565b6040805180820182528281526020808201868152600088815260088352848120878252909252929020905181559051600191820155610ea59083906116c4565b6000858152600960205260409020555b50505050565b600b54428115801590610ee5575062093a8081068103610ee3600a6000610df060018761168f565b145b15610f3057604080518082019091528181526002546020820152600a6000610f0e60018661168f565b8152602080820192909252604001600020825181559101516001909101555050565b60408051808201825282815260025460208083019182526000868152600a90915292909220905181559051600191820155610f6c9083906116c4565b600b555050565b600260005403610fca5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b6002600055565b80600003610ff257604051631f2a200560e01b815260040160405180910390fd5b6110076001600160a01b0383168430846111e4565b60006110184262093a808106900390565b6001600160a01b03841660009081526004602090815260408083208484529091528120805492935084929091906110509084906116c4565b9250508190555080836001600160a01b0316856001600160a01b03167f52977ea98a2220a03ee9ba5cb003ada08d394ea10155483c95dc2dc77a7eb24b8560405161109d91815260200190565b60405180910390a450505050565b805160005b818110156111dd5760006110dd8483815181106110cf576110cf611746565b602002602001015186610413565b905042600560008685815181106110f6576110f6611746565b6020908102919091018101516001600160a01b031682528181019290925260409081016000908120898252909252902055801561116457611164868286858151811061114457611144611746565b60200260200101516001600160a01b031661124f9092919063ffffffff16565b83828151811061117657611176611746565b60200260200101516001600160a01b0316866001600160a01b03167f9aa05b3d70a9e3e2f004f039648839560576334fb45c81f91b6db03ad9e2efc9836040516111c291815260200190565b60405180910390a350806111d5816116ee565b9150506110b0565b5050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610eb59085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152611284565b6040516001600160a01b03831660248201526044810182905261127f90849063a9059cbb60e01b90606401611218565b505050565b60006112d9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166113569092919063ffffffff16565b80519091501561127f57808060200190518101906112f79190611707565b61127f5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610fc1565b6060611365848460008561136d565b949350505050565b6060824710156113ce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610fc1565b600080866001600160a01b031685876040516113ea9190611780565b60006040518083038185875af1925050503d8060008114611427576040519150601f19603f3d011682016040523d82523d6000602084013e61142c565b606091505b509150915061143d87838387611448565b979650505050505050565b606083156114b75782516000036114b0576001600160a01b0385163b6114b05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610fc1565b5081611365565b61136583838151156114cc5781518083602001fd5b8060405162461bcd60e51b8152600401610fc1919061179c565b6001600160a01b03811681146114fb57600080fd5b50565b8035611509816114e6565b919050565b6000806040838503121561152157600080fd5b823561152c816114e6565b946020939093013593505050565b6000806040838503121561154d57600080fd5b50508035926020909101359150565b60006020828403121561156e57600080fd5b8135610641816114e6565b60006020828403121561158b57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b600080604083850312156115bb57600080fd5b8235915060208084013567ffffffffffffffff808211156115db57600080fd5b818601915086601f8301126115ef57600080fd5b81358181111561160157611601611592565b8060051b604051601f19603f8301168101818110858211171561162657611626611592565b60405291825284820192508381018501918983111561164457600080fd5b938501935b828510156116695761165a856114fe565b84529385019392850192611649565b8096505050505050509250929050565b634e487b7160e01b600052601160045260246000fd5b818103818111156105f3576105f3611679565b6000826116bf57634e487b7160e01b600052601260045260246000fd5b500490565b808201808211156105f3576105f3611679565b80820281158282048414176105f3576105f3611679565b60006001820161170057611700611679565b5060010190565b60006020828403121561171957600080fd5b8151801515811461064157600080fd5b60006020828403121561173b57600080fd5b8151610641816114e6565b634e487b7160e01b600052603260045260246000fd5b60005b8381101561177757818101518382015260200161175f565b50506000910152565b6000825161179281846020870161175c565b9190910192915050565b60208152600082518060208401526117bb81604085016020870161175c565b601f01601f1916919091016040019291505056fea2646970667358221220374af667613c8ac36e3fb05e4836d6493e9eab55087da4e497158d5e3603bf8d64736f6c63430008130033a2646970667358221220a18c4e792042e04aea0169a2c348ac9383a697ac6fbee6275bd7d35ce29a5ac664736f6c63430008130033
Deployed Bytecode Sourcemap
98747:470:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;98852:362;;;;;;:::i;:::-;;:::i;:::-;;;;-1:-1:-1;;;;;1754:15:1;;;1736:34;;1806:15;;;;1801:2;1786:18;;1779:43;1671:18;98852:362:0;;;;;;;;98965:24;98991:25;99077:10;99089;99101:8;99056:54;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;99029:82;;99172:10;99184;99196:8;99150:55;;;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;99122:84;;98852:362;;;;;:::o;-1:-1:-1:-;;;;;;;;:::o;:::-;;;;;;;;:::o;14:173:1:-;82:20;;-1:-1:-1;;;;;131:31:1;;121:42;;111:70;;177:1;174;167:12;111:70;14:173;;;:::o;192:127::-;253:10;248:3;244:20;241:1;234:31;284:4;281:1;274:15;308:4;305:1;298:15;324:1195;417:6;425;478:2;466:9;457:7;453:23;449:32;446:52;;;494:1;491;484:12;446:52;517:29;536:9;517:29;:::i;:::-;507:39;;565:2;618;607:9;603:18;590:32;641:18;682:2;674:6;671:14;668:34;;;698:1;695;688:12;668:34;736:6;725:9;721:22;711:32;;781:7;774:4;770:2;766:13;762:27;752:55;;803:1;800;793:12;752:55;839:2;826:16;861:2;857;854:10;851:36;;;867:18;;:::i;:::-;913:2;910:1;906:10;945:2;939:9;1008:2;1004:7;999:2;995;991:11;987:25;979:6;975:38;1063:6;1051:10;1048:22;1043:2;1031:10;1028:18;1025:46;1022:72;;;1074:18;;:::i;:::-;1110:2;1103:22;1160:18;;;1194:15;;;;-1:-1:-1;1236:11:1;;;1232:20;;;1264:19;;;1261:39;;;1296:1;1293;1286:12;1261:39;1320:11;;;;1340:148;1356:6;1351:3;1348:15;1340:148;;;1422:23;1441:3;1422:23;:::i;:::-;1410:36;;1373:12;;;;1466;;;;1340:148;;;1507:6;1497:16;;;;;;;;324:1195;;;;;:::o;1833:840::-;2031:4;2079:2;2068:9;2064:18;2118:1;2114;2109:3;2105:11;2101:19;2159:2;2151:6;2147:15;2136:9;2129:34;2182:2;2232;2224:6;2220:15;2215:2;2204:9;2200:18;2193:43;2272:2;2267;2256:9;2252:18;2245:30;2295:6;2330;2324:13;2361:6;2353;2346:22;2399:3;2388:9;2384:19;2377:26;;2438:2;2430:6;2426:15;2412:29;;2459:1;2469:178;2483:6;2480:1;2477:13;2469:178;;;2548:13;;2544:22;;2532:35;;2622:15;;;;2587:12;;;;2505:1;2498:9;2469:178;;;-1:-1:-1;2664:3:1;;1833:840;-1:-1:-1;;;;;;;;;1833:840:1:o
Swarm Source
ipfs://a18c4e792042e04aea0169a2c348ac9383a697ac6fbee6275bd7d35ce29a5ac6
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.