Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Initialize | 18029008 | 530 days ago | IN | 0 ETH | 0.00176919 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
Rewards
Compiler Version
v0.8.9+commit.e5eed63a
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "./dependencies/@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "./dependencies/@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "./dependencies/@openzeppelin/contracts/utils/math/Math.sol"; import "./dependencies/@openzeppelin/contracts/utils/math/SafeCast.sol"; import "./access/Governable.sol"; import "./storage/RewardsStorage.sol"; /** * @title Rewards contract */ contract Rewards is ReentrancyGuard, Governable, RewardsStorageV1 { using SafeERC20 for IERC20; using SafeCast for uint256; string public constant VERSION = "1.0.0"; uint256 public constant REWARD_DURATION = 30 days; /// Emitted after reward added event RewardAdded(address indexed rewardToken, uint256 reward, uint256 rewardDuration); /// Emitted whenever any user claim rewards event RewardPaid(address indexed user, address indexed rewardToken, uint256 reward); /// Emitted after adding new rewards token into rewardTokens array event RewardTokenAdded(address indexed rewardToken, address[] existingRewardTokens); /// Emitted when distributor approval is updated event RewardDistributorApprovalUpdated(address rewardsToken, address distributor, bool approved); function initialize(IESVSP esVSP_) external initializer { require(address(esVSP_) != address(0), "esVSP-is-null"); __Governable_init(); esVSP = esVSP_; } /** * @notice Get claimable rewards * @param account_ The account * @return _rewardTokens The addresses of the reward tokens * @return _claimableAmounts The claimable amounts */ function claimableRewards( address account_ ) external view override returns (address[] memory _rewardTokens, uint256[] memory _claimableAmounts) { uint256 _len = rewardTokens.length; _rewardTokens = new address[](_len); _claimableAmounts = new uint256[](_len); uint256 _totalSupply; uint256 _userBalance; for (uint256 i; i < _len; i++) { address _rewardToken = rewardTokens[i]; (_totalSupply, _userBalance) = _getSupplyAndBalance(_rewardToken, account_); _rewardTokens[i] = _rewardToken; _claimableAmounts[i] = _claimable(_rewardToken, account_, _totalSupply, _userBalance); } } /** * @notice Claim earned rewards * @dev This function will claim rewards for all tokens being rewarded * @param account_ The account */ function claimRewards(address account_) external override nonReentrant { uint256 _len = rewardTokens.length; uint256 _totalSupply; uint256 _userBalance; for (uint256 i; i < _len; i++) { address _rewardToken = rewardTokens[i]; (_totalSupply, _userBalance) = _getSupplyAndBalance(_rewardToken, account_); _updateReward(_rewardToken, account_, _totalSupply, _userBalance); uint256 _rewardAmount = rewardOf[_rewardToken][account_].claimableRewardsStored; if (_rewardAmount > 0) { _claimReward(_rewardToken, account_, _rewardAmount); } } } /** * @notice Drip reward token and extend current reward duration by 30 days * User get drip based on their boosted VSP amount * @dev Restricted method * @param rewardToken_ Reward token address * @param rewardAmount_ Reward amount */ function dripRewardAmount(address rewardToken_, uint256 rewardAmount_) external override { require(rewards[rewardToken_].lastUpdateTime > 0, "reward-token-not-added"); require(isRewardDistributor[rewardToken_][_msgSender()], "not-distributor"); require(rewardAmount_ > 0, "incorrect-reward-amount"); _dripRewardAmount(rewardToken_, rewardAmount_); } /** * @notice Returns timestamp of last reward update * @param _rewardToken The reward token * @return The timestamp */ function lastTimeRewardApplicable(address _rewardToken) public view override returns (uint256) { return Math.min(block.timestamp, rewards[_rewardToken].periodFinish); } /** * @notice Update reward earning of user * @param account_ The account */ function updateReward(address account_) external override { uint256 _len = rewardTokens.length; uint256 _totalSupply; uint256 _userBalance; for (uint256 i; i < _len; i++) { address _rewardToken = rewardTokens[i]; (_totalSupply, _userBalance) = _getSupplyAndBalance(_rewardToken, account_); _updateReward(_rewardToken, account_, _totalSupply, _userBalance); } } /** * @notice Get claimable rewards for a reward token * @param rewardToken_ The address of the reward token * @param account_ The account * @param totalSupply_ The supply of reference (boosted or locked) * @param balance_ The balance of reference (boosted or locked) * @return The claimable amount */ function _claimable( address rewardToken_, address account_, uint256 totalSupply_, uint256 balance_ ) private view returns (uint256) { UserReward memory _userReward = rewardOf[rewardToken_][account_]; uint256 _rewardPerTokenAvailable = _rewardPerToken(rewardToken_, totalSupply_) - _userReward.rewardPerTokenPaid; uint256 _rewardsEarnedSinceLastUpdate = (balance_ * _rewardPerTokenAvailable) / 1e18; return _userReward.claimableRewardsStored + _rewardsEarnedSinceLastUpdate; } /** * @notice Transfer claimable reward to user * @param rewardToken_ The reward token * @param account_ The account * @param reward_ The reward amount */ function _claimReward(address rewardToken_, address account_, uint256 reward_) private { rewardOf[rewardToken_][account_].claimableRewardsStored = 0; IERC20(rewardToken_).safeTransfer(account_, reward_); emit RewardPaid(account_, rewardToken_, reward_); } /** * @notice Drip reward token and extend current reward duration by 30 days * User get drip based on their boosted VSP amount * @param rewardToken_ Reward token address * @param rewardAmount_ Reward amount */ function _dripRewardAmount(address rewardToken_, uint256 rewardAmount_) private { uint256 _balanceBefore = IERC20(rewardToken_).balanceOf(address(this)); IERC20(rewardToken_).safeTransferFrom(_msgSender(), address(this), rewardAmount_); uint256 _dripAmount = IERC20(rewardToken_).balanceOf(address(this)) - _balanceBefore; Reward storage _reward = rewards[rewardToken_]; uint256 _totalSupply = _reward.isBoosted ? esVSP.totalBoosted() : esVSP.totalLocked(); _reward.rewardPerTokenStored = _rewardPerToken(rewardToken_, _totalSupply); if (block.timestamp >= _reward.periodFinish) { _reward.rewardPerSecond = _dripAmount / REWARD_DURATION; } else { uint256 _remainingPeriod = _reward.periodFinish - block.timestamp; uint256 _leftover = _remainingPeriod * _reward.rewardPerSecond; _reward.rewardPerSecond = (_dripAmount + _leftover) / REWARD_DURATION; } // Start new drip time _reward.lastUpdateTime = block.timestamp; _reward.periodFinish = block.timestamp + REWARD_DURATION; emit RewardAdded(rewardToken_, _dripAmount, REWARD_DURATION); } /** * @notice Get supply and balance for reference (i.e. locked or boosted) */ function _getSupplyAndBalance( address rewardToken_, address account_ ) private view returns (uint256 _totalSupply, uint256 _userBalance) { if (rewards[rewardToken_].isBoosted) { _totalSupply = esVSP.totalBoosted(); _userBalance = esVSP.boosted(account_); } else { _totalSupply = esVSP.totalLocked(); _userBalance = esVSP.locked(account_); } } /** * @notice Returns the reward per VSP locked based on time elapsed since last notification multiplied by reward rate * @param rewardToken_ The reward token * @param totalSupply_ The supply of reference (boosted or locked) * @return The reward per VSP */ function _rewardPerToken(address rewardToken_, uint256 totalSupply_) private view returns (uint256) { if (totalSupply_ == 0) { return rewards[rewardToken_].rewardPerTokenStored; } uint256 _timeSinceLastUpdate = lastTimeRewardApplicable(rewardToken_) - rewards[rewardToken_].lastUpdateTime; uint256 _rewardsSinceLastUpdate = _timeSinceLastUpdate * rewards[rewardToken_].rewardPerSecond; uint256 _rewardsPerTokenSinceLastUpdate = (_rewardsSinceLastUpdate * 1e18) / totalSupply_; return rewards[rewardToken_].rewardPerTokenStored + _rewardsPerTokenSinceLastUpdate; } /** * @notice Update reward earning of user * @param rewardToken_ The address of the reward token * @param account_ The account * @param totalSupply_ The supply of reference (boosted or locked) * @param balance_ The balance of reference (boosted or locked) */ function _updateReward(address rewardToken_, address account_, uint256 totalSupply_, uint256 balance_) private { uint256 _rewardPerTokenStored = _rewardPerToken(rewardToken_, totalSupply_); Reward storage _reward = rewards[rewardToken_]; _reward.rewardPerTokenStored = _rewardPerTokenStored; _reward.lastUpdateTime = lastTimeRewardApplicable(rewardToken_); if (account_ != address(0)) { rewardOf[rewardToken_][account_] = UserReward({ claimableRewardsStored: _claimable(rewardToken_, account_, totalSupply_, balance_).toUint128(), rewardPerTokenPaid: _rewardPerTokenStored.toUint128() }); } } /** Governance methods **/ /** * @notice Allow/disallow address as a reward distributor for a given token * @param rewardsToken_ The reward token * @param distributor_ The distributor address * @param approved_ The approved boolean flag */ function setRewardDistributorApproval( address rewardsToken_, address distributor_, bool approved_ ) external onlyGovernor { require(rewards[rewardsToken_].lastUpdateTime > 0, "reward-token-not-added"); isRewardDistributor[rewardsToken_][distributor_] = approved_; emit RewardDistributorApprovalUpdated(rewardsToken_, distributor_, approved_); } /** * @notice add new reward token for distribution * @param rewardsToken_ Reward token address * @param distributor_ Authorized called to call dripRewardAmount * @param isBoosted_ If reward token is boosted than rewards is distributed on boost amount depends on lock period */ function addRewardToken(address rewardsToken_, address distributor_, bool isBoosted_) external onlyGovernor { require(rewards[rewardsToken_].lastUpdateTime == 0, "reward-already-added"); rewards[rewardsToken_] = Reward({ isBoosted: isBoosted_, periodFinish: block.timestamp, rewardPerSecond: 0, rewardPerTokenStored: 0, lastUpdateTime: block.timestamp }); emit RewardTokenAdded(rewardsToken_, rewardTokens); rewardTokens.push(rewardsToken_); isRewardDistributor[rewardsToken_][distributor_] = true; } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "../dependencies/@openzeppelin/contracts/utils/Context.sol"; import "../dependencies/@openzeppelin/contracts/proxy/utils/Initializable.sol"; import "../interface/IGovernable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (governor) that can be granted exclusive access to * specific functions. * * By default, the governor account will be the one that deploys the contract. This * can later be changed with {transferGovernorship}. * */ abstract contract Governable is IGovernable, Initializable, Context { address public governor; address public proposedGovernor; event UpdatedGovernor(address indexed previousGovernor, address indexed proposedGovernor); /** * @dev If inheriting child is using proxy then child contract can use * __Governable_init() function to initialization this contract */ // solhint-disable-next-line func-name-mixedcase function __Governable_init() internal onlyInitializing { governor = _msgSender(); emit UpdatedGovernor(address(0), governor); } /** * @dev Throws if called by any account other than the governor. */ modifier onlyGovernor() { require(governor == _msgSender(), "not-governor"); _; } /** * @dev Transfers governorship of the contract to a new account (`proposedGovernor`). * Can only be called by the current owner. */ function transferGovernorship(address _proposedGovernor) external onlyGovernor { require(_proposedGovernor != address(0), "proposed-governor-is-zero"); proposedGovernor = _proposedGovernor; } /** * @dev Allows new governor to accept governorship of the contract. */ function acceptGovernorship() external { require(proposedGovernor == _msgSender(), "not-the-proposed-governor"); emit UpdatedGovernor(governor, proposedGovernor); governor = proposedGovernor; proposedGovernor = address(0); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/Address.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; 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"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [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://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (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); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @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); /////////////////////////////////////////////// // 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 10, 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 * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "../dependencies/@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import "./IRewards.sol"; interface IESVSP is IERC20Metadata { function totalLocked() external view returns (uint256); function totalBoosted() external view returns (uint256); function locked(address _account) external view returns (uint256); function boosted(address _account) external view returns (uint256); function lock(uint256 amount_, uint256 lockPeriod_) external; function lockFor(address to_, uint256 amount_, uint256 lockPeriod_) external; function updateExitPenalty(uint256 exitPenalty_) external; function unlock(uint256 tokenId_, bool unexpired_) external; function kick(uint256 tokenId_) external; function kickAllExpiredOf(address account_) external; function transferPosition(uint256 tokenId_, address to_) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; /** * @notice Governable interface */ interface IGovernable { function governor() external view returns (address _governor); function transferGovernorship(address _proposedGovernor) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; interface IRewards { function addRewardToken(address rewardsToken_, address distributor_, bool isBoosted_) external; function claimRewards(address account_) external; function claimableRewards( address account_ ) external view returns (address[] memory rewardTokens_, uint256[] memory claimableAmounts_); function dripRewardAmount(address rewardToken_, uint256 rewardAmount_) external; function setRewardDistributorApproval(address rewardsToken_, address distributor_, bool approved_) external; function updateReward(address account_) external; function lastTimeRewardApplicable(address _rewardToken) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity 0.8.9; import "../interface/IESVSP.sol"; import "../interface/IRewards.sol"; abstract contract RewardsStorageV1 is IRewards { struct Reward { bool isBoosted; // linear distribution if false uint256 periodFinish; // end of a drip period uint256 rewardPerSecond; // distribution per second (i.e. dripAmount/dripPeriod) uint256 lastUpdateTime; // stores last drip time uint256 rewardPerTokenStored; // reward per VSP } struct UserReward { uint128 rewardPerTokenPaid; // reward per VSP accumulator uint128 claimableRewardsStored; // pending to claim } /** * @notice Locker contract */ IESVSP public esVSP; /** * @notice Array of reward tokens */ address[] public rewardTokens; /** * @notice Rewards state per token * @dev RewardToken => Reward */ mapping(address => Reward) public rewards; /** * @notice User's rewards state per token * @dev User => RewardToken => UserReward */ mapping(address => mapping(address => UserReward)) public rewardOf; /** * @notice Reward distributors * RewardToken -> distributor -> is approved to drip */ mapping(address => mapping(address => bool)) public isRewardDistributor; }
{ "evmVersion": "london", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 100 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardDuration","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"rewardsToken","type":"address"},{"indexed":false,"internalType":"address","name":"distributor","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"RewardDistributorApprovalUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"},{"indexed":false,"internalType":"address[]","name":"existingRewardTokens","type":"address[]"}],"name":"RewardTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGovernor","type":"address"},{"indexed":true,"internalType":"address","name":"proposedGovernor","type":"address"}],"name":"UpdatedGovernor","type":"event"},{"inputs":[],"name":"REWARD_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptGovernorship","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"rewardsToken_","type":"address"},{"internalType":"address","name":"distributor_","type":"address"},{"internalType":"bool","name":"isBoosted_","type":"bool"}],"name":"addRewardToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"}],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"}],"name":"claimableRewards","outputs":[{"internalType":"address[]","name":"_rewardTokens","type":"address[]"},{"internalType":"uint256[]","name":"_claimableAmounts","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"rewardToken_","type":"address"},{"internalType":"uint256","name":"rewardAmount_","type":"uint256"}],"name":"dripRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"esVSP","outputs":[{"internalType":"contract IESVSP","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IESVSP","name":"esVSP_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"isRewardDistributor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_rewardToken","type":"address"}],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proposedGovernor","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"rewardOf","outputs":[{"internalType":"uint128","name":"rewardPerTokenPaid","type":"uint128"},{"internalType":"uint128","name":"claimableRewardsStored","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardTokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewards","outputs":[{"internalType":"bool","name":"isBoosted","type":"bool"},{"internalType":"uint256","name":"periodFinish","type":"uint256"},{"internalType":"uint256","name":"rewardPerSecond","type":"uint256"},{"internalType":"uint256","name":"lastUpdateTime","type":"uint256"},{"internalType":"uint256","name":"rewardPerTokenStored","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"rewardsToken_","type":"address"},{"internalType":"address","name":"distributor_","type":"address"},{"internalType":"bool","name":"approved_","type":"bool"}],"name":"setRewardDistributorApproval","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_proposedGovernor","type":"address"}],"name":"transferGovernorship","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"}],"name":"updateReward","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506001600055611d8b806100256000396000f3fe608060405234801561001057600080fd5b50600436106101105760003560e01c80637bb7bed1116100ad578063dc01f60d11610071578063dc01f60d146102e2578063e947582814610303578063ef5cfb8c14610341578063f3b27bc314610354578063ffa1ad741461035c57600080fd5b80637bb7bed1146102835780638a11a37014610296578063ac5c3f86146102a9578063b6aa515b146102bc578063c4d66de8146102cf57600080fd5b806281cd0b146101155780630700037d1461012a5780630c340a241461019a57806311a208fa146101c05780634732aa1d146101d357806351892ba3146102325780635ade228a14610245578063632447c91461025d578063638634ee14610270575b600080fd5b6101286101233660046119b3565b61038d565b005b61016b6101383660046119fe565b6005602052600090815260409020805460018201546002830154600384015460049094015460ff90931693919290919085565b6040805195151586526020860194909452928401919091526060830152608082015260a0015b60405180910390f35b6001546101b3906201000090046001600160a01b031681565b6040516101919190611a1b565b6101286101ce3660046119b3565b610542565b6102126101e1366004611a2f565b60066020908152600092835260408084209091529082529020546001600160801b0380821691600160801b90041682565b604080516001600160801b03938416815292909116602083015201610191565b610128610240366004611a68565b610627565b61024f62278d0081565b604051908152602001610191565b61012861026b3660046119fe565b61071c565b61024f61027e3660046119fe565b61078d565b6101b3610291366004611a94565b6107ba565b6002546101b3906001600160a01b031681565b6003546101b3906001600160a01b031681565b6101286102ca3660046119fe565b6107e4565b6101286102dd3660046119fe565b610889565b6102f56102f03660046119fe565b6109f5565b604051610191929190611aad565b610331610311366004611a2f565b600760209081526000928352604080842090915290825290205460ff1681565b6040519015158152602001610191565b61012861034f3660046119fe565b610b4b565b610128610c17565b610380604051806040016040528060058152602001640312e302e360dc1b81525081565b6040516101919190611b5d565b6001546001600160a01b03620100009091041633146103c75760405162461bcd60e51b81526004016103be90611b90565b60405180910390fd5b6001600160a01b038316600090815260056020526040902060030154156104275760405162461bcd60e51b81526020600482015260146024820152731c995dd85c990b585b1c9958591e4b585919195960621b60448201526064016103be565b6040805160a0810182528215158152426020808301828152600084860181815260608601948552608086018281526001600160a01b038b168084526005909552918790209551865460ff1916901515178655915160018601559051600285015591516003840155905160049283015591517f438dc3ee1ea07ec168befb145c10eb363aad7cbec063f8a006b032031582ac2b916104c391611bb6565b60405180910390a2506004805460018082019092557f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0180546001600160a01b0319166001600160a01b03948516908117909155600090815260076020908152604080832094909516825292909252919020805460ff19169091179055565b6001546001600160a01b03620100009091041633146105735760405162461bcd60e51b81526004016103be90611b90565b6001600160a01b0383166000908152600560205260409020600301546105ab5760405162461bcd60e51b81526004016103be90611c06565b6001600160a01b03838116600081815260076020908152604080832094871680845294825291829020805460ff19168615159081179091558251938452908301939093528101919091527fb324d0d65aefe344b0ced3f062ed49bff7641e4527a8727807e98936704e20c69060600160405180910390a1505050565b6001600160a01b03821660009081526005602052604090206003015461065f5760405162461bcd60e51b81526004016103be90611c06565b6001600160a01b038216600090815260076020908152604080832033845290915290205460ff166106c45760405162461bcd60e51b815260206004820152600f60248201526e3737ba16b234b9ba3934b13aba37b960891b60448201526064016103be565b6000811161070e5760405162461bcd60e51b81526020600482015260176024820152761a5b98dbdc9c9958dd0b5c995dd85c990b585b5bdd5b9d604a1b60448201526064016103be565b6107188282610ce7565b5050565b600454600080805b838110156107865760006004828154811061074157610741611c36565b6000918252602090912001546001600160a01b031690506107628187611020565b909450925061077381878686611262565b508061077e81611c62565b915050610724565b5050505050565b6001600160a01b0381166000908152600560205260408120600101546107b490429061133a565b92915050565b600481815481106107ca57600080fd5b6000918252602090912001546001600160a01b0316905081565b6001546001600160a01b03620100009091041633146108155760405162461bcd60e51b81526004016103be90611b90565b6001600160a01b0381166108675760405162461bcd60e51b815260206004820152601960248201527870726f706f7365642d676f7665726e6f722d69732d7a65726f60381b60448201526064016103be565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b600154610100900460ff16158080156108a657506001805460ff16105b806108bf5750303b1580156108bf57506001805460ff16145b6109225760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103be565b6001805460ff1916811790558015610944576001805461ff0019166101001790555b6001600160a01b03821661098a5760405162461bcd60e51b815260206004820152600d60248201526c195cd594d40b5a5ccb5b9d5b1b609a1b60448201526064016103be565b610992611352565b600380546001600160a01b0319166001600160a01b0384161790558015610718576001805461ff00191681556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b60045460609081908067ffffffffffffffff811115610a1657610a16611c7d565b604051908082528060200260200182016040528015610a3f578160200160208202803683370190505b5092508067ffffffffffffffff811115610a5b57610a5b611c7d565b604051908082528060200260200182016040528015610a84578160200160208202803683370190505b50915060008060005b83811015610b4257600060048281548110610aaa57610aaa611c36565b6000918252602090912001546001600160a01b03169050610acb8189611020565b809450819550505080878381518110610ae657610ae6611c36565b60200260200101906001600160a01b031690816001600160a01b031681525050610b1281898686611417565b868381518110610b2457610b24611c36565b60209081029190910101525080610b3a81611c62565b915050610a8d565b50505050915091565b610b536114c8565b600454600080805b83811015610c0657600060048281548110610b7857610b78611c36565b6000918252602090912001546001600160a01b03169050610b998187611020565b9094509250610baa81878686611262565b6001600160a01b038181166000908152600660209081526040808320938a1683529290522054600160801b90046001600160801b03168015610bf157610bf1828883611522565b50508080610bfe90611c62565b915050610b5b565b50505050610c146001600055565b50565b6002546001600160a01b03163314610c6d5760405162461bcd60e51b81526020600482015260196024820152783737ba16ba343296b83937b837b9b2b216b3b7bb32b93737b960391b60448201526064016103be565b6002546001546040516001600160a01b039283169262010000909204909116907fd4459d5b8b913cab0244230fd9b1c08b6ceace7fe9230e60d0f74cbffdf849d090600090a3600280546001805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6040516370a0823160e01b81526000906001600160a01b038416906370a0823190610d16903090600401611a1b565b60206040518083038186803b158015610d2e57600080fd5b505afa158015610d42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d669190611c93565b9050610d7d6001600160a01b0384163330856115b4565b600081846001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610dac9190611a1b565b60206040518083038186803b158015610dc457600080fd5b505afa158015610dd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dfc9190611c93565b610e069190611cac565b6001600160a01b038516600090815260056020526040812080549293509160ff16610eb657600360009054906101000a90046001600160a01b03166001600160a01b031663568914126040518163ffffffff1660e01b815260040160206040518083038186803b158015610e7957600080fd5b505afa158015610e8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb19190611c93565b610f3c565b600360009054906101000a90046001600160a01b03166001600160a01b031663631516c26040518163ffffffff1660e01b815260040160206040518083038186803b158015610f0457600080fd5b505afa158015610f18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3c9190611c93565b9050610f488682611625565b600483015560018201544210610f6f57610f6562278d0084611cc3565b6002830155610fb7565b6000428360010154610f819190611cac565b90506000836002015482610f959190611ce5565b905062278d00610fa58287611d04565b610faf9190611cc3565b600285015550505b4260038301819055610fcd9062278d0090611d04565b60018301556040805184815262278d0060208201526001600160a01b038816917f6a6f77044107a33658235d41bedbbaf2fe9ccdceb313143c947a5e76e1ec8474910160405180910390a2505050505050565b6001600160a01b038216600090815260056020526040812054819060ff161561115157600360009054906101000a90046001600160a01b03166001600160a01b031663631516c26040518163ffffffff1660e01b815260040160206040518083038186803b15801561109157600080fd5b505afa1580156110a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c99190611c93565b6003546040516341f0635960e11b81529193506001600160a01b0316906383e0c6b2906110fa908690600401611a1b565b60206040518083038186803b15801561111257600080fd5b505afa158015611126573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114a9190611c93565b905061125b565b600360009054906101000a90046001600160a01b03166001600160a01b031663568914126040518163ffffffff1660e01b815260040160206040518083038186803b15801561119f57600080fd5b505afa1580156111b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d79190611c93565b60035460405163cbf9fe5f60e01b81529193506001600160a01b03169063cbf9fe5f90611208908690600401611a1b565b60206040518083038186803b15801561122057600080fd5b505afa158015611234573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112589190611c93565b90505b9250929050565b600061126e8584611625565b6001600160a01b0386166000908152600560205260409020600481018290559091506112998661078d565b60038201556001600160a01b038516156113325760405180604001604052806112c1846116fc565b6001600160801b031681526020016112e36112de89898989611417565b6116fc565b6001600160801b039081169091526001600160a01b038089166000908152600660209081526040808320938b168352928152919020835193909101518216600160801b02929091169190911790555b505050505050565b6000818310611349578161134b565b825b9392505050565b600154610100900460ff166113bd5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016103be565b600180546201000033810262010000600160b01b0319909216919091179182905560405191046001600160a01b0316906000907fd4459d5b8b913cab0244230fd9b1c08b6ceace7fe9230e60d0f74cbffdf849d0908290a3565b6001600160a01b03808516600090815260066020908152604080832093871683529281528282208351808501909452546001600160801b03808216808652600160801b909204169184019190915290919082906114748887611625565b61147e9190611cac565b90506000670de0b6b3a76400006114958387611ce5565b61149f9190611cc3565b90508083602001516001600160801b03166114ba9190611d04565b93505050505b949350505050565b6002600054141561151b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103be565b6002600055565b6001600160a01b03808416600081815260066020908152604080832094871683529390529190912080546001600160801b03169055611562908383611769565b826001600160a01b0316826001600160a01b03167f540798df468d7b23d11f156fdb954cb19ad414d150722a7b6d55ba369dea792e836040516115a791815260200190565b60405180910390a3505050565b6040516001600160a01b038085166024830152831660448201526064810182905261161f9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261179e565b50505050565b60008161164e57506001600160a01b0382166000908152600560205260409020600401546107b4565b6001600160a01b0383166000908152600560205260408120600301546116738561078d565b61167d9190611cac565b6001600160a01b038516600090815260056020526040812060020154919250906116a79083611ce5565b90506000846116be83670de0b6b3a7640000611ce5565b6116c89190611cc3565b6001600160a01b0387166000908152600560205260409020600401549091506116f2908290611d04565b9695505050505050565b60006001600160801b038211156117655760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b60648201526084016103be565b5090565b6040516001600160a01b03831660248201526044810182905261179990849063a9059cbb60e01b906064016115e8565b505050565b60006117f3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166118709092919063ffffffff16565b80519091501561179957808060200190518101906118119190611d1c565b6117995760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103be565b60606114c0848460008585600080866001600160a01b031685876040516118979190611d39565b60006040518083038185875af1925050503d80600081146118d4576040519150601f19603f3d011682016040523d82523d6000602084013e6118d9565b606091505b50915091506118ea878383876118f5565b979650505050505050565b6060831561196157825161195a576001600160a01b0385163b61195a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103be565b50816114c0565b6114c083838151156119765781518083602001fd5b8060405162461bcd60e51b81526004016103be9190611b5d565b6001600160a01b0381168114610c1457600080fd5b8015158114610c1457600080fd5b6000806000606084860312156119c857600080fd5b83356119d381611990565b925060208401356119e381611990565b915060408401356119f3816119a5565b809150509250925092565b600060208284031215611a1057600080fd5b813561134b81611990565b6001600160a01b0391909116815260200190565b60008060408385031215611a4257600080fd5b8235611a4d81611990565b91506020830135611a5d81611990565b809150509250929050565b60008060408385031215611a7b57600080fd5b8235611a8681611990565b946020939093013593505050565b600060208284031215611aa657600080fd5b5035919050565b604080825283519082018190526000906020906060840190828701845b82811015611aef5781516001600160a01b031684529284019290840190600101611aca565b5050508381038285015284518082528583019183019060005b81811015611b2457835183529284019291840191600101611b08565b5090979650505050505050565b60005b83811015611b4c578181015183820152602001611b34565b8381111561161f5750506000910152565b6020815260008251806020840152611b7c816040850160208701611b31565b601f01601f19169190910160400192915050565b6020808252600c908201526b3737ba16b3b7bb32b93737b960a11b604082015260600190565b6020808252825482820181905260008481528281209092916040850190845b81811015611bfa5783546001600160a01b031683526001938401939285019201611bd5565b50909695505050505050565b6020808252601690820152751c995dd85c990b5d1bdad95b8b5b9bdd0b585919195960521b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415611c7657611c76611c4c565b5060010190565b634e487b7160e01b600052604160045260246000fd5b600060208284031215611ca557600080fd5b5051919050565b600082821015611cbe57611cbe611c4c565b500390565b600082611ce057634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611cff57611cff611c4c565b500290565b60008219821115611d1757611d17611c4c565b500190565b600060208284031215611d2e57600080fd5b815161134b816119a5565b60008251611d4b818460208701611b31565b919091019291505056fea2646970667358221220d080abc20ebb9c9862ad242e769a89381e8b5fa01de02190bb532cd82a9a8e0964736f6c63430008090033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101105760003560e01c80637bb7bed1116100ad578063dc01f60d11610071578063dc01f60d146102e2578063e947582814610303578063ef5cfb8c14610341578063f3b27bc314610354578063ffa1ad741461035c57600080fd5b80637bb7bed1146102835780638a11a37014610296578063ac5c3f86146102a9578063b6aa515b146102bc578063c4d66de8146102cf57600080fd5b806281cd0b146101155780630700037d1461012a5780630c340a241461019a57806311a208fa146101c05780634732aa1d146101d357806351892ba3146102325780635ade228a14610245578063632447c91461025d578063638634ee14610270575b600080fd5b6101286101233660046119b3565b61038d565b005b61016b6101383660046119fe565b6005602052600090815260409020805460018201546002830154600384015460049094015460ff90931693919290919085565b6040805195151586526020860194909452928401919091526060830152608082015260a0015b60405180910390f35b6001546101b3906201000090046001600160a01b031681565b6040516101919190611a1b565b6101286101ce3660046119b3565b610542565b6102126101e1366004611a2f565b60066020908152600092835260408084209091529082529020546001600160801b0380821691600160801b90041682565b604080516001600160801b03938416815292909116602083015201610191565b610128610240366004611a68565b610627565b61024f62278d0081565b604051908152602001610191565b61012861026b3660046119fe565b61071c565b61024f61027e3660046119fe565b61078d565b6101b3610291366004611a94565b6107ba565b6002546101b3906001600160a01b031681565b6003546101b3906001600160a01b031681565b6101286102ca3660046119fe565b6107e4565b6101286102dd3660046119fe565b610889565b6102f56102f03660046119fe565b6109f5565b604051610191929190611aad565b610331610311366004611a2f565b600760209081526000928352604080842090915290825290205460ff1681565b6040519015158152602001610191565b61012861034f3660046119fe565b610b4b565b610128610c17565b610380604051806040016040528060058152602001640312e302e360dc1b81525081565b6040516101919190611b5d565b6001546001600160a01b03620100009091041633146103c75760405162461bcd60e51b81526004016103be90611b90565b60405180910390fd5b6001600160a01b038316600090815260056020526040902060030154156104275760405162461bcd60e51b81526020600482015260146024820152731c995dd85c990b585b1c9958591e4b585919195960621b60448201526064016103be565b6040805160a0810182528215158152426020808301828152600084860181815260608601948552608086018281526001600160a01b038b168084526005909552918790209551865460ff1916901515178655915160018601559051600285015591516003840155905160049283015591517f438dc3ee1ea07ec168befb145c10eb363aad7cbec063f8a006b032031582ac2b916104c391611bb6565b60405180910390a2506004805460018082019092557f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0180546001600160a01b0319166001600160a01b03948516908117909155600090815260076020908152604080832094909516825292909252919020805460ff19169091179055565b6001546001600160a01b03620100009091041633146105735760405162461bcd60e51b81526004016103be90611b90565b6001600160a01b0383166000908152600560205260409020600301546105ab5760405162461bcd60e51b81526004016103be90611c06565b6001600160a01b03838116600081815260076020908152604080832094871680845294825291829020805460ff19168615159081179091558251938452908301939093528101919091527fb324d0d65aefe344b0ced3f062ed49bff7641e4527a8727807e98936704e20c69060600160405180910390a1505050565b6001600160a01b03821660009081526005602052604090206003015461065f5760405162461bcd60e51b81526004016103be90611c06565b6001600160a01b038216600090815260076020908152604080832033845290915290205460ff166106c45760405162461bcd60e51b815260206004820152600f60248201526e3737ba16b234b9ba3934b13aba37b960891b60448201526064016103be565b6000811161070e5760405162461bcd60e51b81526020600482015260176024820152761a5b98dbdc9c9958dd0b5c995dd85c990b585b5bdd5b9d604a1b60448201526064016103be565b6107188282610ce7565b5050565b600454600080805b838110156107865760006004828154811061074157610741611c36565b6000918252602090912001546001600160a01b031690506107628187611020565b909450925061077381878686611262565b508061077e81611c62565b915050610724565b5050505050565b6001600160a01b0381166000908152600560205260408120600101546107b490429061133a565b92915050565b600481815481106107ca57600080fd5b6000918252602090912001546001600160a01b0316905081565b6001546001600160a01b03620100009091041633146108155760405162461bcd60e51b81526004016103be90611b90565b6001600160a01b0381166108675760405162461bcd60e51b815260206004820152601960248201527870726f706f7365642d676f7665726e6f722d69732d7a65726f60381b60448201526064016103be565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b600154610100900460ff16158080156108a657506001805460ff16105b806108bf5750303b1580156108bf57506001805460ff16145b6109225760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103be565b6001805460ff1916811790558015610944576001805461ff0019166101001790555b6001600160a01b03821661098a5760405162461bcd60e51b815260206004820152600d60248201526c195cd594d40b5a5ccb5b9d5b1b609a1b60448201526064016103be565b610992611352565b600380546001600160a01b0319166001600160a01b0384161790558015610718576001805461ff00191681556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b60045460609081908067ffffffffffffffff811115610a1657610a16611c7d565b604051908082528060200260200182016040528015610a3f578160200160208202803683370190505b5092508067ffffffffffffffff811115610a5b57610a5b611c7d565b604051908082528060200260200182016040528015610a84578160200160208202803683370190505b50915060008060005b83811015610b4257600060048281548110610aaa57610aaa611c36565b6000918252602090912001546001600160a01b03169050610acb8189611020565b809450819550505080878381518110610ae657610ae6611c36565b60200260200101906001600160a01b031690816001600160a01b031681525050610b1281898686611417565b868381518110610b2457610b24611c36565b60209081029190910101525080610b3a81611c62565b915050610a8d565b50505050915091565b610b536114c8565b600454600080805b83811015610c0657600060048281548110610b7857610b78611c36565b6000918252602090912001546001600160a01b03169050610b998187611020565b9094509250610baa81878686611262565b6001600160a01b038181166000908152600660209081526040808320938a1683529290522054600160801b90046001600160801b03168015610bf157610bf1828883611522565b50508080610bfe90611c62565b915050610b5b565b50505050610c146001600055565b50565b6002546001600160a01b03163314610c6d5760405162461bcd60e51b81526020600482015260196024820152783737ba16ba343296b83937b837b9b2b216b3b7bb32b93737b960391b60448201526064016103be565b6002546001546040516001600160a01b039283169262010000909204909116907fd4459d5b8b913cab0244230fd9b1c08b6ceace7fe9230e60d0f74cbffdf849d090600090a3600280546001805462010000600160b01b0319166001600160a01b03831662010000021790556001600160a01b0319169055565b6040516370a0823160e01b81526000906001600160a01b038416906370a0823190610d16903090600401611a1b565b60206040518083038186803b158015610d2e57600080fd5b505afa158015610d42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d669190611c93565b9050610d7d6001600160a01b0384163330856115b4565b600081846001600160a01b03166370a08231306040518263ffffffff1660e01b8152600401610dac9190611a1b565b60206040518083038186803b158015610dc457600080fd5b505afa158015610dd8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dfc9190611c93565b610e069190611cac565b6001600160a01b038516600090815260056020526040812080549293509160ff16610eb657600360009054906101000a90046001600160a01b03166001600160a01b031663568914126040518163ffffffff1660e01b815260040160206040518083038186803b158015610e7957600080fd5b505afa158015610e8d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eb19190611c93565b610f3c565b600360009054906101000a90046001600160a01b03166001600160a01b031663631516c26040518163ffffffff1660e01b815260040160206040518083038186803b158015610f0457600080fd5b505afa158015610f18573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3c9190611c93565b9050610f488682611625565b600483015560018201544210610f6f57610f6562278d0084611cc3565b6002830155610fb7565b6000428360010154610f819190611cac565b90506000836002015482610f959190611ce5565b905062278d00610fa58287611d04565b610faf9190611cc3565b600285015550505b4260038301819055610fcd9062278d0090611d04565b60018301556040805184815262278d0060208201526001600160a01b038816917f6a6f77044107a33658235d41bedbbaf2fe9ccdceb313143c947a5e76e1ec8474910160405180910390a2505050505050565b6001600160a01b038216600090815260056020526040812054819060ff161561115157600360009054906101000a90046001600160a01b03166001600160a01b031663631516c26040518163ffffffff1660e01b815260040160206040518083038186803b15801561109157600080fd5b505afa1580156110a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c99190611c93565b6003546040516341f0635960e11b81529193506001600160a01b0316906383e0c6b2906110fa908690600401611a1b565b60206040518083038186803b15801561111257600080fd5b505afa158015611126573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061114a9190611c93565b905061125b565b600360009054906101000a90046001600160a01b03166001600160a01b031663568914126040518163ffffffff1660e01b815260040160206040518083038186803b15801561119f57600080fd5b505afa1580156111b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111d79190611c93565b60035460405163cbf9fe5f60e01b81529193506001600160a01b03169063cbf9fe5f90611208908690600401611a1b565b60206040518083038186803b15801561122057600080fd5b505afa158015611234573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112589190611c93565b90505b9250929050565b600061126e8584611625565b6001600160a01b0386166000908152600560205260409020600481018290559091506112998661078d565b60038201556001600160a01b038516156113325760405180604001604052806112c1846116fc565b6001600160801b031681526020016112e36112de89898989611417565b6116fc565b6001600160801b039081169091526001600160a01b038089166000908152600660209081526040808320938b168352928152919020835193909101518216600160801b02929091169190911790555b505050505050565b6000818310611349578161134b565b825b9392505050565b600154610100900460ff166113bd5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016103be565b600180546201000033810262010000600160b01b0319909216919091179182905560405191046001600160a01b0316906000907fd4459d5b8b913cab0244230fd9b1c08b6ceace7fe9230e60d0f74cbffdf849d0908290a3565b6001600160a01b03808516600090815260066020908152604080832093871683529281528282208351808501909452546001600160801b03808216808652600160801b909204169184019190915290919082906114748887611625565b61147e9190611cac565b90506000670de0b6b3a76400006114958387611ce5565b61149f9190611cc3565b90508083602001516001600160801b03166114ba9190611d04565b93505050505b949350505050565b6002600054141561151b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103be565b6002600055565b6001600160a01b03808416600081815260066020908152604080832094871683529390529190912080546001600160801b03169055611562908383611769565b826001600160a01b0316826001600160a01b03167f540798df468d7b23d11f156fdb954cb19ad414d150722a7b6d55ba369dea792e836040516115a791815260200190565b60405180910390a3505050565b6040516001600160a01b038085166024830152831660448201526064810182905261161f9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261179e565b50505050565b60008161164e57506001600160a01b0382166000908152600560205260409020600401546107b4565b6001600160a01b0383166000908152600560205260408120600301546116738561078d565b61167d9190611cac565b6001600160a01b038516600090815260056020526040812060020154919250906116a79083611ce5565b90506000846116be83670de0b6b3a7640000611ce5565b6116c89190611cc3565b6001600160a01b0387166000908152600560205260409020600401549091506116f2908290611d04565b9695505050505050565b60006001600160801b038211156117655760405162461bcd60e51b815260206004820152602760248201527f53616665436173743a2076616c756520646f65736e27742066697420696e20316044820152663238206269747360c81b60648201526084016103be565b5090565b6040516001600160a01b03831660248201526044810182905261179990849063a9059cbb60e01b906064016115e8565b505050565b60006117f3826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166118709092919063ffffffff16565b80519091501561179957808060200190518101906118119190611d1c565b6117995760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103be565b60606114c0848460008585600080866001600160a01b031685876040516118979190611d39565b60006040518083038185875af1925050503d80600081146118d4576040519150601f19603f3d011682016040523d82523d6000602084013e6118d9565b606091505b50915091506118ea878383876118f5565b979650505050505050565b6060831561196157825161195a576001600160a01b0385163b61195a5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103be565b50816114c0565b6114c083838151156119765781518083602001fd5b8060405162461bcd60e51b81526004016103be9190611b5d565b6001600160a01b0381168114610c1457600080fd5b8015158114610c1457600080fd5b6000806000606084860312156119c857600080fd5b83356119d381611990565b925060208401356119e381611990565b915060408401356119f3816119a5565b809150509250925092565b600060208284031215611a1057600080fd5b813561134b81611990565b6001600160a01b0391909116815260200190565b60008060408385031215611a4257600080fd5b8235611a4d81611990565b91506020830135611a5d81611990565b809150509250929050565b60008060408385031215611a7b57600080fd5b8235611a8681611990565b946020939093013593505050565b600060208284031215611aa657600080fd5b5035919050565b604080825283519082018190526000906020906060840190828701845b82811015611aef5781516001600160a01b031684529284019290840190600101611aca565b5050508381038285015284518082528583019183019060005b81811015611b2457835183529284019291840191600101611b08565b5090979650505050505050565b60005b83811015611b4c578181015183820152602001611b34565b8381111561161f5750506000910152565b6020815260008251806020840152611b7c816040850160208701611b31565b601f01601f19169190910160400192915050565b6020808252600c908201526b3737ba16b3b7bb32b93737b960a11b604082015260600190565b6020808252825482820181905260008481528281209092916040850190845b81811015611bfa5783546001600160a01b031683526001938401939285019201611bd5565b50909695505050505050565b6020808252601690820152751c995dd85c990b5d1bdad95b8b5b9bdd0b585919195960521b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415611c7657611c76611c4c565b5060010190565b634e487b7160e01b600052604160045260246000fd5b600060208284031215611ca557600080fd5b5051919050565b600082821015611cbe57611cbe611c4c565b500390565b600082611ce057634e487b7160e01b600052601260045260246000fd5b500490565b6000816000190483118215151615611cff57611cff611c4c565b500290565b60008219821115611d1757611d17611c4c565b500190565b600060208284031215611d2e57600080fd5b815161134b816119a5565b60008251611d4b818460208701611b31565b919091019291505056fea2646970667358221220d080abc20ebb9c9862ad242e769a89381e8b5fa01de02190bb532cd82a9a8e0964736f6c63430008090033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.